Re: [PATCH v2 3/5] PCI/pwrctl: Ensure that the pwrctl drivers are probed before the PCI client drivers
From: Bjorn Helgaas
Date: Wed Nov 20 2024 - 11:11:07 EST
On Fri, Oct 25, 2024 at 01:24:53PM +0530, Manivannan Sadhasivam via B4 Relay wrote:
> From: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx>
>
> As per the kernel device driver model, pwrctl device is the supplier for
> the PCI device. But the device link that enforces the supplier-consumer
> relationship is created inside the pwrctl driver currently. Due to this,
> the driver model doesn't prevent probing of the PCI client drivers before
> probing the corresponding pwrctl drivers. This may lead to a race condition
> if the PCI device was already powered on by the bootloader (before the
> pwrctl driver).
> + * Create a device link between the PCI device and pwrctl device (if
> + * exists). This ensures that the pwrctl drivers are probed before the
> + * PCI client drivers.
> + */
> + pdev = of_find_device_by_node(dn);
> + if (pdev) {
> + if (!device_link_add(&dev->dev, &pdev->dev, DL_FLAG_AUTOREMOVE_CONSUMER))
> + pci_err(dev, "failed to add device link between %s and %s\n",
> + dev_name(&dev->dev), pdev->name);
This prints the name for "dev" twice (once by pci_err(dev) and again
from dev_name(&dev->dev)). Is it helpful to see it twice here?