[PATCH] drm/amdgpu: fix autosuspend cleanup during removal

Guangshuo Li posted 1 patch 1 month, 3 weeks ago
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] drm/amdgpu: fix autosuspend cleanup during removal
Posted by Guangshuo Li 1 month, 3 weeks ago
amdgpu_pci_probe() calls pm_runtime_use_autosuspend(), but
amdgpu_pci_remove() does not call the matching
pm_runtime_dont_use_autosuspend().

If the autosuspend delay is set to a negative value while autosuspend
is enabled, the runtime PM core increments usage_count to prevent
runtime suspend. Without calling pm_runtime_dont_use_autosuspend()
during teardown, this reference is not dropped and usage_count remains
unbalanced.

The documentation for pm_runtime_use_autosuspend() also notes that it
is important to undo it with pm_runtime_dont_use_autosuspend() at
driver exit time, unless runtime PM was initially enabled with
devm_pm_runtime_enable().

Add the missing pm_runtime_dont_use_autosuspend() call to the remove
path.

This issue was found by manual code inspection.

Fixes: d38ceaf99ed0 ("drm/amdgpu: add core driver (v4)")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 1aed121f4ddb..e814701bc8fd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2548,6 +2548,7 @@ amdgpu_pci_remove(struct pci_dev *pdev)
 	if (adev->pm.rpm_mode != AMDGPU_RUNPM_NONE) {
 		pm_runtime_get_sync(dev->dev);
 		pm_runtime_forbid(dev->dev);
+		pm_runtime_dont_use_autosuspend(dev->dev);
 	}
 
 	amdgpu_driver_unload_kms(dev);
-- 
2.43.0
Re: [PATCH] drm/amdgpu: fix autosuspend cleanup during removal
Posted by Mario Limonciello 1 month, 2 weeks ago
On 8/8/26 07:09, Guangshuo Li wrote:
> amdgpu_pci_probe() calls pm_runtime_use_autosuspend(), but
> amdgpu_pci_remove() does not call the matching
> pm_runtime_dont_use_autosuspend().
> 
> If the autosuspend delay is set to a negative value while autosuspend
> is enabled, the runtime PM core increments usage_count to prevent
> runtime suspend. Without calling pm_runtime_dont_use_autosuspend()
> during teardown, this reference is not dropped and usage_count remains
> unbalanced.
> 
> The documentation for pm_runtime_use_autosuspend() also notes that it
> is important to undo it with pm_runtime_dont_use_autosuspend() at
> driver exit time, unless runtime PM was initially enabled with
> devm_pm_runtime_enable().
> 
> Add the missing pm_runtime_dont_use_autosuspend() call to the remove
> path.
> 
> This issue was found by manual code inspection.
> 
> Fixes: d38ceaf99ed0 ("drm/amdgpu: add core driver (v4)")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>

Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>

Also applied to amd-staging-drm-next.

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index 1aed121f4ddb..e814701bc8fd 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -2548,6 +2548,7 @@ amdgpu_pci_remove(struct pci_dev *pdev)
>   	if (adev->pm.rpm_mode != AMDGPU_RUNPM_NONE) {
>   		pm_runtime_get_sync(dev->dev);
>   		pm_runtime_forbid(dev->dev);
> +		pm_runtime_dont_use_autosuspend(dev->dev);
>   	}
>   
>   	amdgpu_driver_unload_kms(dev);
Re: [PATCH] drm/amdgpu: fix autosuspend cleanup during removal
Posted by Alex Deucher 1 month, 2 weeks ago
Did this ever land?  I don't see it in ASDN.

Alex

On Mon, Aug 10, 2026 at 10:35 AM Mario Limonciello <superm1@kernel.org> wrote:
>
> On 8/8/26 07:09, Guangshuo Li wrote:
> > amdgpu_pci_probe() calls pm_runtime_use_autosuspend(), but
> > amdgpu_pci_remove() does not call the matching
> > pm_runtime_dont_use_autosuspend().
> >
> > If the autosuspend delay is set to a negative value while autosuspend
> > is enabled, the runtime PM core increments usage_count to prevent
> > runtime suspend. Without calling pm_runtime_dont_use_autosuspend()
> > during teardown, this reference is not dropped and usage_count remains
> > unbalanced.
> >
> > The documentation for pm_runtime_use_autosuspend() also notes that it
> > is important to undo it with pm_runtime_dont_use_autosuspend() at
> > driver exit time, unless runtime PM was initially enabled with
> > devm_pm_runtime_enable().
> >
> > Add the missing pm_runtime_dont_use_autosuspend() call to the remove
> > path.
> >
> > This issue was found by manual code inspection.
> >
> > Fixes: d38ceaf99ed0 ("drm/amdgpu: add core driver (v4)")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
>
> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
>
> Also applied to amd-staging-drm-next.
>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 +
> >   1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > index 1aed121f4ddb..e814701bc8fd 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > @@ -2548,6 +2548,7 @@ amdgpu_pci_remove(struct pci_dev *pdev)
> >       if (adev->pm.rpm_mode != AMDGPU_RUNPM_NONE) {
> >               pm_runtime_get_sync(dev->dev);
> >               pm_runtime_forbid(dev->dev);
> > +             pm_runtime_dont_use_autosuspend(dev->dev);
> >       }
> >
> >       amdgpu_driver_unload_kms(dev);
>
Re: [PATCH] drm/amdgpu: fix autosuspend cleanup during removal
Posted by Mario Limonciello 1 month, 2 weeks ago
On 8/12/26 14:41, Alex Deucher wrote:
> Did this ever land?  I don't see it in ASDN.
> 

It's on gerrit, but it seems stuck.  I'll ping you the link offline.

> Alex
> 
> On Mon, Aug 10, 2026 at 10:35 AM Mario Limonciello <superm1@kernel.org> wrote:
>>
>> On 8/8/26 07:09, Guangshuo Li wrote:
>>> amdgpu_pci_probe() calls pm_runtime_use_autosuspend(), but
>>> amdgpu_pci_remove() does not call the matching
>>> pm_runtime_dont_use_autosuspend().
>>>
>>> If the autosuspend delay is set to a negative value while autosuspend
>>> is enabled, the runtime PM core increments usage_count to prevent
>>> runtime suspend. Without calling pm_runtime_dont_use_autosuspend()
>>> during teardown, this reference is not dropped and usage_count remains
>>> unbalanced.
>>>
>>> The documentation for pm_runtime_use_autosuspend() also notes that it
>>> is important to undo it with pm_runtime_dont_use_autosuspend() at
>>> driver exit time, unless runtime PM was initially enabled with
>>> devm_pm_runtime_enable().
>>>
>>> Add the missing pm_runtime_dont_use_autosuspend() call to the remove
>>> path.
>>>
>>> This issue was found by manual code inspection.
>>>
>>> Fixes: d38ceaf99ed0 ("drm/amdgpu: add core driver (v4)")
>>> Cc: stable@vger.kernel.org
>>> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
>>
>> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
>>
>> Also applied to amd-staging-drm-next.
>>
>>> ---
>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 +
>>>    1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
>>> index 1aed121f4ddb..e814701bc8fd 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
>>> @@ -2548,6 +2548,7 @@ amdgpu_pci_remove(struct pci_dev *pdev)
>>>        if (adev->pm.rpm_mode != AMDGPU_RUNPM_NONE) {
>>>                pm_runtime_get_sync(dev->dev);
>>>                pm_runtime_forbid(dev->dev);
>>> +             pm_runtime_dont_use_autosuspend(dev->dev);
>>>        }
>>>
>>>        amdgpu_driver_unload_kms(dev);
>>