On Tue, Dec 01, 2026 at 10:45:31AM +0100, psta…@redhat.com wrote:
> On Mon, 2026-11-30 at 18:02 -0600, Bjorn Helgaas wrote:
> > On Tue, Dec 01, 2026 at 02:56:31AM +0400, Arina Kharlamova wrote:
> > > t7xx_pcie_reinit() runs on resume from L2 or L3 and on every reprobe > > > after a modem reset. It calls pcim_enable_device(), which did nothing > > > for an already enabled managed device until commit 77f79ac8de0f > > > ("PCI: Remove struct pci_devres.enabled status bit"). Since then each > > > call raises the enable count. Since commit f748a07a0b64 ("PCI: Remove > > > legacy pcim_release()") each call also registers a new > > > pcim_disable_device() devres action, and the actions pile up until the > > > device is unbound. > > > > > > The device is enabled once in t7xx_pci_probe() and the driver never > > > disables it, so drop the call from the reinit path.
> > > > This and the loongson/lsdc issue > > (https://lore.kernel.org/all/2026…@mbzuai.ac.ae) > > seem like basically the same issue, so I wonder if the pcim API could > > be improved to avoid it.  It seems a bit subtle and like something > > driver authors are likely to trip over.
> > I don't think that the APIs behavior should be guarded with more checks > (like "already enabled" checks). In the past, first the managed API was > added, and then (for unknown reasons) counter APIs were added to revoke > the managed actions. Look at pcim_pin_device(). IMO that makes the API > more convoluted, inconsistent and even harder to understand. > > But it's true that drivers often don't seem to understand what a > managed interface is, proven by the fact that many of them also called > pcim_disable_device() in their remove(), which leads the entire design > ad absurdum. > > I think what we can is to document more explicitly what functions you > could use when and for what purpose. Especially, we should deprecate > pcim_disable_device(), pcim_iounmap() et al.
I wonder if sashiko could be taught to look for this issue, e.g., maybe something in https://github.com/sashiko-dev/sashiko/blob/main/projects/linux/prompts/maintainers/pci.md?