* [PATCH] ata: pata_macio: Do not disable the PCI device on suspend
@ 2026-12-01 19:17 Arina Kharlamova via B4 Relay
2026-12-02 7:05 ` Damien Le Moal
2026-12-03 16:00 ` Bjorn Helgaas
0 siblings, 2 replies; 4+ 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 [flat|nested] 4+ 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-02 7:05 ` Damien Le Moal
2026-12-03 11:30 ` Arina Kharlamova
2026-12-03 16:00 ` Bjorn Helgaas
1 sibling, 1 reply; 4+ messages in thread
From: Damien Le Moal @ 2026-12-02 7:05 UTC (permalink / raw)
To: arina.kharlamova, Niklas Cassel, Krzysztof Wilczyński,
Bjorn Helgaas, Philipp Stanner
Cc: linux-ide, linux-kernel, Weidong Wang, linux-pci, linuxppc-dev
On 12/2/26 04:17, Arina Kharlamova via B4 Relay wrote:
> 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>
This needs testing.
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ata: pata_macio: Do not disable the PCI device on suspend
2026-12-02 7:05 ` Damien Le Moal
@ 2026-12-03 11:30 ` Arina Kharlamova
0 siblings, 0 replies; 4+ messages in thread
From: Arina Kharlamova @ 2026-12-03 11:30 UTC (permalink / raw)
To: Damien Le Moal
Cc: Arina Kharlamova, Niklas Cassel, Krzysztof Wilczyński,
Bjorn Helgaas, Philipp Stanner, linux-ide, linux-kernel,
Weidong Wang, linux-pci, linuxppc-dev
> This needs testing.
Understood. I do not have a PowerMac with this controller, so I could
only compile-test it (pmac32_defconfig). If someone on linuxppc-dev can
run a suspend and resume cycle with it, that would settle it
Thanks,
Arina
> On 2 Dec 2026, at 11:05, Damien Le Moal <dlemoal@kernel.org> wrote:
>
> Notice: This email originated from outside MBZUAI.
> Please exercise caution before clicking links, opening attachments, or sharing sensitive information.
> On 12/2/26 04:17, Arina Kharlamova via B4 Relay wrote:
> > 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>
>
> This needs testing.
>
> --
> Damien Le Moal
> Western Digital Research
>
^ permalink raw reply [flat|nested] 4+ 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-02 7:05 ` Damien Le Moal
@ 2026-12-03 16:00 ` Bjorn Helgaas
1 sibling, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2026-12-03 16:00 UTC (permalink / raw)
To: Arina Kharlamova
Cc: Damien Le Moal, Niklas Cassel, Krzysztof Wilczyński,
Bjorn Helgaas, Philipp Stanner, linux-ide, linux-kernel,
Weidong Wang, linux-pci, linuxppc-dev, Vaibhav Gupta
[+cc Vaibhav]
On Tue, Dec 01, 2026 at 11:17:11PM +0400, Arina Kharlamova wrote:
> 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 */
This driver uses legacy PCI power management, i.e.,
pci_driver.suspend() and .resume(). If converted to generic power
management (pci_driver.driver.pm hooks), it probably wouldn't need any
of the pci_save_state() and related gunk because the PCI core would
take care of it.
For example:
d5376026f926 ("gpio: bt8xx: use generic power management")
892bb0740b02 ("firewire: ohci: use generic power management")
0aeddbd0cb07 ("via-agp: convert to generic power management")
Bjorn
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-03 16:00 UTC | newest]
Thread overview: 4+ 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-02 7:05 ` Damien Le Moal
2026-12-03 11:30 ` Arina Kharlamova
2026-12-03 16:00 ` Bjorn Helgaas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®