Re: [PATCH v3 3/5] PCI/pwrctrl: Skip scanning for the device further if pwrctrl device is created

From: Manivannan Sadhasivam
Date: Fri Feb 21 2025 - 12:39:25 EST


On Thu, Feb 20, 2025 at 05:24:51PM -0600, Bjorn Helgaas wrote:
> On Thu, Jan 16, 2025 at 07:39:13PM +0530, Manivannan Sadhasivam via B4 Relay wrote:
> > From: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx>
> >
> > The pwrctrl core will rescan the bus once the device is powered on. So
> > there is no need to continue scanning for the device further.
>
> > @@ -2487,7 +2487,14 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
> > struct pci_dev *dev;
> > u32 l;
> >
> > - pci_pwrctrl_create_device(bus, devfn);
> > + /*
> > + * Create pwrctrl device (if required) for the PCI device to handle the
> > + * power state. If the pwrctrl device is created, then skip scanning
> > + * further as the pwrctrl core will rescan the bus after powering on
> > + * the device.
> > + */
> > + if (pci_pwrctrl_create_device(bus, devfn))
> > + return NULL;
>
> I assume it's possible for the PCI device to already be powered on
> even if there's a pwrctrl device for it?
>

Yes, if the device was powered on by the bootloader.

> Does this change the enumeration order in that case? It sounds like
> it may delay enumeration of the PCI device until the pwrctrl core
> rescans the bus?
>

So previously, while enumerating a PCI device that requires a pwrctrl device
(indicated by DT), its client driver won't be probed until the pwrctrl driver is
probed (thanks to devlink). This was required to make sure that there would be
no race between client drivers and pwrctrl drivers probing parallely.

So in that case, there is no reason to enumerate the such devices in the first
place. That's why this patch is skipping the enumeration for those devices.

- Mani

--
மணிவண்ணன் சதாசிவம்