Re: [PATCH] ata: libata-core: Do not use pcim_enable_device() on PCI resume
From: Weidong Wang
Date: Tue Dec 01 2026 - 15:15:13 EST
On Mon, 2026-11-30 at 14:00 +0100, Philipp Stanner wrote:
> That's evident from the *very* verbose commit message, which I think
> should be slimmed down a bit :)
Fair point, thanks for the review. v2 will have a much shorter one.
>> it would need a pci_is_enabled()
>> check in pcim_disable_device(). I can send that as a separate patch
>
> That's not a good idea. This intertwining makes the API inconsistent.
Understood, I will drop that idea.
> So will pcim_enable_device() still be called somewhere else?
Yes. The probe-time enable stays managed: ata_pci_init_one() in
libata-sff.c (used through ata_pci_bmdma_init_one() and
ata_pci_sff_init_one()) and the probe functions of the other drivers
still call pcim_enable_device(). Only the re-enable on resume changes,
so that it balances the pci_disable_device() in
ata_pci_device_do_suspend().
> ata_pci_device_do_resume() is used in 28 files. Will the parties other
> than cs5520 be affected by this change? That seems quite likely.
Most of them suspend through ata_pci_device_suspend(), which disables
the device, so the enable on resume matches it. The exceptions are
drivers whose suspend leaves the device enabled: pata_cs5520,
pata_triflex, and the broken-suspend path of ata_piix. ata_piix already
skips ata_pci_device_do_resume() there and uses pci_reenable_device().
I missed pata_triflex (sashiko pointed it out); v2 will handle it the
same way as pata_cs5520.
> That change looks suspicious. I would expect it to be unnecessary if
> all that were changed in ATA were replacing the pcim_ functions with
> the pci_ ones.
pata_cs5520 does not disable the device on suspend, so any resume path
that calls pci_enable_device() raises the enable count without a
matching disable, whether probe used pcim_ or pci_. That is why its
resume must not go through ata_pci_device_do_resume().
Moving all of libata to the unmanaged API would touch the probe and
remove paths of every PCI ATA driver, so I kept the fix to the resume
path. Damien, Niklas, let me know if you would prefer that instead.
Weidong