Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] ata: pata_macio: Do not disable the PCI device on suspend
@ 2026-12-01 19:17 Arina Kharlamova via B4 Relay
  2026-12-01 19:24 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Arina Kharlamova via B4 Relay @ 2026-12-01 19:17 UTC (permalink / raw)
  To: Damien Le Moal, Niklas Cassel, Krzysztof Wilczyński,
	Bjorn Helgaas, Philipp Stanner
  Cc: linux-ide, linux-kernel, Weidong Wang, linux-pci, linuxppc-dev,
	Arina Kharlamova

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

pata_macio_suspend() disables the PCI device with pci_disable_device(),
and pata_macio_reset_hw() enables it again on resume with
pcim_enable_device(). Since commit f748a07a0b64 ("PCI: Remove legacy
pcim_release()") every pcim_enable_device() call adds a
pcim_disable_device() devres action, so each suspend and resume leaves
one more action behind. On unbind they all run, and every one after
the first warns about disabling an already disabled device.

The device is enabled with pcim_enable_device() in probe and stays
managed until unbind, so the driver should not disable and enable it by
hand. On suspend, clear only the bus master bit, which is all that
pci_disable_device() did on this hardware, and set it again on resume
without enabling the device.

Fixes: f748a07a0b64 ("PCI: Remove legacy pcim_release()")
Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
---
I found this while checking the other drivers that call
pcim_enable_device() again on resume, after the discussion of the t7xx
fix:
https://lore.kernel.org/all/20261201-s2p-d64-v1-1-c9147b2eedb0@mbzuai.ac.ae/

Weidong Wang's patch for ata_pci_device_do_resume() fixes the same
problem in libata core by switching resume to pci_enable_device():
https://lore.kernel.org/all/20261128-kbug-l080-v1-1-90f7309990ea@illinois.edu/
Philipp replied there that a driver should either use only pcim_ and
never undo it, or use only the pci_ functions. This patch takes the
first way, so the device is no longer disabled on suspend.

With the help of an AI coding assistant (Claude); I reviewed the
analysis and the fix. Not triggered at runtime. Compile-tested only
(powerpc pmac32_defconfig), not tested on hardware.
---
 drivers/ata/pata_macio.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/ata/pata_macio.c b/drivers/ata/pata_macio.c
index a11a1eae2ae8..ba946a4116c3 100644
--- a/drivers/ata/pata_macio.c
+++ b/drivers/ata/pata_macio.c
@@ -788,16 +788,8 @@ static void pata_macio_reset_hw(struct pata_macio_priv *priv, int resume)
 
 	/* If resuming a PCI device, restore the config space here */
 	if (priv->pdev && resume) {
-		int rc;
-
 		pci_restore_state(priv->pdev);
-		rc = pcim_enable_device(priv->pdev);
-		if (rc)
-			dev_err(&priv->pdev->dev,
-				"Failed to enable device after resume (%d)\n",
-				rc);
-		else
-			pci_set_master(priv->pdev);
+		pci_set_master(priv->pdev);
 	}
 
 	/* On Kauai, initialize the FCR. We don't perform a reset, doesn't really
@@ -898,7 +890,7 @@ static int pata_macio_do_suspend(struct pata_macio_priv *priv, pm_message_t mesg
 	 */
 	if (priv->pdev) {
 		pci_save_state(priv->pdev);
-		pci_disable_device(priv->pdev);
+		pci_clear_master(priv->pdev);
 	}
 
 	/* Disable the bus on older machines and the cell on kauai */

---
base-commit: d8f7cc53ae072fb64f98d95e1acb7221a5fd6eae
change-id: 20261201-s2p-d104-ea2574e74227

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



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

* Re: [PATCH] ata: pata_macio: Do not disable the PCI device on suspend
  2026-12-01 19:17 [PATCH] ata: pata_macio: Do not disable the PCI device on suspend Arina Kharlamova via B4 Relay
@ 2026-12-01 19:24 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-01 19:24 UTC (permalink / raw)
  To: Arina Kharlamova; +Cc: linux-pci

> From: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>
> 
> pata_macio_suspend() disables the PCI device with pci_disable_device(),
> and pata_macio_reset_hw() enables it again on resume with
> pcim_enable_device(). Since commit f748a07a0b64 ("PCI: Remove legacy
> pcim_release()") every pcim_enable_device() call adds a
> pcim_disable_device() devres action, so each suspend and resume leaves
> one more action behind. On unbind they all run, and every one after
> the first warns about disabling an already disabled device.
> 
> The device is enabled with pcim_enable_device() in probe and stays
> managed until unbind, so the driver should not disable and enable it by
> hand. On suspend, clear only the bus master bit, which is all that
> pci_disable_device() did on this hardware, and set it again on resume
> without enabling the device.
> 
> Fixes: f748a07a0b64 ("PCI: Remove legacy pcim_release()")
> Signed-off-by: Arina Kharlamova <arina.kharlamova@mbzuai.ac.ae>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-s2p-d104-v1-1-df4a9ef2b79d@mbzuai.ac.ae?part=1

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

end of thread, other threads:[~2026-12-01 19:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 19:17 [PATCH] ata: pata_macio: Do not disable the PCI device on suspend Arina Kharlamova via B4 Relay
2026-12-01 19:24 ` sashiko-bot

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