Re: [PATCH] ata: libata-core: Do not use pcim_enable_device() on PCI resume
From: Niklas Cassel
Date: Thu Dec 03 2026 - 08:27:56 EST
Hello Weidong,
On Tue, Dec 01, 2026 at 02:15:04PM -0600, Weidong Wang wrote:
> On Mon, 2026-11-30 at 14:00 +0100, Philipp Stanner wrote:
>
> 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.
Philipp is the author of f748a07a0b64 ("PCI: Remove legacy pcim_release()"),
so I trust his judgement.
But to me it makes sense to make libata consistent, either fully use the
pci_* APIs or fully use the pcim_* APIs.
Without looking at the patches, it is hard to know if it is more wise to
convert everything to pci_* or to convert everything to pcim_*.
(I assume that there was some weird corner case that caused someone to mix
the APIs in the first place... So personally I would prefer the solution
which untangles this mess with the most logical/beautiful end result.)
Kind regards,
Niklas