Skip to contentSkip to conversation

FAILED: patch "[PATCH] drm/amdgpu: fix autosuspend cleanup during removal" failed to apply to 5.15-stable tree

PATCH New [email protected] 2 participants 3 messages Sep 9 – Sep 12

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x ef5fcf2a6c320676bf8be2dadac93d9023b468b7
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090919-halt-gusto-67b7@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From ef5fcf2a6c320676bf8be2dadac93d9023b468b7 Mon Sep 17 00:00:00 2001
From: Guangshuo Li <[email protected]>
Date: Sat, 8 Aug 2026 20:09:34 +0800
Subject: [PATCH] drm/amdgpu: fix autosuspend cleanup during removal

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.

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
index 0ab380ca7e64..5c33c19fd9bc 100644
@@ -2557,6 +2557,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);
maintainer
#1 lore raw

PATCH 1/2 drm/amdgpu: move runtime pm init after drm and fbdev init

From: Alex Deucher <[email protected]>

[ Upstream commit d0d66b8c66d04363eff3a5b09da4074fc1dfc758 ]

Seems more logical to enable runtime pm at the end of the init sequence so we don't end up entering runtime suspend before init is finished.

Stable dependency adaptation for ef5fcf2a6c320676bf8be2dadac93d9023b468b7:
Retain only the runtime-PM teardown relocation into amdgpu_pci_remove() and remove the corresponding load-failure pm_runtime_put_noidle(), since amdgpu_driver_unload_kms() no longer takes that reference.

The target adds autosuspend cleanup to this removal block. Moving runtime PM initialization and the audio helper is unnecessary for that fix, so leave both in amdgpu_kms.c. This also avoids the insertion conflict with the stable-only amdgpu_is_fw_framebuffer() helper and adds no functions. Keep the stable adev->runpm condition; the target merges cleanly with it.

Stable-dep-of: ef5fcf2a6c32 ("drm/amdgpu: fix autosuspend cleanup during removal")

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c |  7 +++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 11 +----------
 2 files changed, 8 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +7 -0
index 58292a296875b..7f2e71a51e0e6 100644
@@ -2115,8 +2115,15 @@ static void
 amdgpu_pci_remove(struct pci_dev *pdev)
 {
 	struct drm_device *dev = pci_get_drvdata(pdev);
+	struct amdgpu_device *adev = drm_to_adev(dev);
 
 	drm_dev_unplug(dev);
+
+	if (adev->runpm) {
+		pm_runtime_get_sync(dev->dev);
+		pm_runtime_forbid(dev->dev);
+	}
+
 	amdgpu_driver_unload_kms(dev);
 
 	/*
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -10
index b8b0b819de72b..d18221f7d17d8 100644
@@ -98,11 +98,6 @@ void amdgpu_driver_unload_kms(struct drm_device *dev)
 	if (adev->rmmio == NULL)
 		return;
 
-	if (adev->runpm) {
-		pm_runtime_get_sync(dev->dev);
-		pm_runtime_forbid(dev->dev);
-	}
-
 	if (amdgpu_acpi_smart_shift_update(dev, AMDGPU_SS_DRV_UNLOAD))
 		DRM_WARN("smart shift update failed\n");
 
@@ -273,12 +268,8 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags)
 		DRM_WARN("smart shift update failed\n");
 
 out:
-	if (r) {
-		/* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */
-		if (adev->rmmio && adev->runpm)
-			pm_runtime_put_noidle(dev->dev);
+	if (r)
 		amdgpu_driver_unload_kms(dev);
-	}
 
 	return r;
 }
Signature · 1 line
2.53.0
maintainer
#2 lore raw

PATCH 2/2 drm/amdgpu: fix autosuspend cleanup during removal

From: Guangshuo Li <[email protected]>

[ Upstream commit ef5fcf2a6c320676bf8be2dadac93d9023b468b7 ]

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.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
index 7f2e71a51e0e6..d4eebeebaed18 100644
@@ -2122,6 +2122,7 @@ amdgpu_pci_remove(struct pci_dev *pdev)
 	if (adev->runpm) {
 		pm_runtime_get_sync(dev->dev);
 		pm_runtime_forbid(dev->dev);
+		pm_runtime_dont_use_autosuspend(dev->dev);
 	}
 
 	amdgpu_driver_unload_kms(dev);
Signature · 1 line
2.53.0