Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH] drm/loongson: Do not add a devres action on every resume
@ 2026-11-30 22:56 Arina Kharlamova via B4 Relay
  2026-12-02  6:44 ` Icenowy Zheng
  2026-12-03 15:48 ` Bjorn Helgaas
  0 siblings, 2 replies; 5+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-11-30 22:56 UTC (permalink / raw)
  To: Jianmin Lv, Qianhai Wu, Huacai Chen, Mingcong Bai, Xi Ruoyao,
	Icenowy Zheng, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Philipp Stanner,
	Bjorn Helgaas, Krzysztof Wilczyński
  Cc: dri-devel, stable, Arina Kharlamova

From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>

lsdc_pm_suspend() disables the PCI device with pci_disable_device() and
lsdc_pm_resume() enables it again with pcim_enable_device(). Since
commit f748a07a0b64 ("PCI: Remove legacy pcim_release()") the managed
variant registers a new pcim_disable_device() devres action on each
call, so every suspend and resume cycle leaves one more action on the
device. When the driver is unbound, all of them run: the first one
drops the enable count to zero, the next one triggers the "disabling
already-disabled device" warning, and each further one makes the count
more negative.

The device is already managed from lsdc_pci_probe(). Use the plain
pci_enable_device() in the resume path so that it only balances the
pci_disable_device() done at suspend. lsdc_pm_resume() is also the
.restore callback, and .poweroff does not disable the device, so only
enable it when it is disabled.

Fixes: f748a07a0b64 ("PCI: Remove legacy pcim_release()")
Cc: stable@vger.kernel.org
Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
---
Found by checks derived from the spec2patch kernel API specifications,
with the help of an AI coding assistant (Claude); I reviewed the
analysis and the fix.
---
 drivers/gpu/drm/loongson/lsdc_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/loongson/lsdc_drv.c b/drivers/gpu/drm/loongson/lsdc_drv.c
index 5a13df31eb90..e5b7b34d739e 100644
--- a/drivers/gpu/drm/loongson/lsdc_drv.c
+++ b/drivers/gpu/drm/loongson/lsdc_drv.c
@@ -428,7 +428,7 @@ static int lsdc_pm_resume(struct device *dev)
 
 	pci_restore_state(pdev);
 
-	if (pcim_enable_device(pdev))
+	if (!pci_is_enabled(pdev) && pci_enable_device(pdev))
 		return -EIO;
 
 	return lsdc_pm_thaw(dev);

---
base-commit: 25faec9ce61c01fb45abf812a222c5b43c3cd5c5
change-id: 20261129-s2p-d60-877e4d1f97de

Best regards,
--  
Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-03 15:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 22:56 [PATCH] drm/loongson: Do not add a devres action on every resume Arina Kharlamova via B4 Relay
2026-12-02  6:44 ` Icenowy Zheng
2026-12-03 11:17   ` Arina Kharlamova
2026-12-03 11:20     ` Icenowy Zheng
2026-12-03 15:48 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox