From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Lukas Wunner <lukas@wunner.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Qiang Yu <quic_qianyu@quicinc.com>
Subject: Re: [PATCH 1/4] PCI/pwrctrl: Move creation of pwrctrl devices to pci_scan_device()
Date: Tue, 17 Dec 2024 20:20:35 +0530 [thread overview]
Message-ID: <20241217145035.xqfl4yp3atpgqzth@thinkpad> (raw)
In-Reply-To: <Z2F5Oph2o8o_LiZc@wunner.de>
On Tue, Dec 17, 2024 at 02:14:34PM +0100, Lukas Wunner wrote:
> On Mon, Dec 16, 2024 at 10:45:21AM +0530, Manivannan Sadhasivam wrote:
> > On Sun, Dec 15, 2024 at 06:19:22PM +0100, Lukas Wunner wrote:
> > > On Tue, Dec 10, 2024 at 03:25:24PM +0530, Manivannan Sadhasivam wrote:
> > > > diff --git a/drivers/pci/pwrctrl/core.c b/drivers/pci/pwrctrl/core.c
> > > > index 2fb174db91e5..9cc7e2b7f2b5 100644
> > > > --- a/drivers/pci/pwrctrl/core.c
> > > > +++ b/drivers/pci/pwrctrl/core.c
> > > > @@ -44,7 +44,7 @@ static void rescan_work_func(struct work_struct *work)
> > > > struct pci_pwrctrl, work);
> > > >
> > > > pci_lock_rescan_remove();
> > > > - pci_rescan_bus(to_pci_dev(pwrctrl->dev->parent)->bus);
> > > > + pci_rescan_bus(to_pci_host_bridge(pwrctrl->dev->parent)->bus);
> > > > pci_unlock_rescan_remove();
> > > > }
> > >
> > > Remind me, what's the purpose of this? I'm guessing that it
> > > recursively creates the platform devices below the newly
> > > powered up device, is that correct? If so, is it still
> > > necessary? Doesn't the new approach automatically create
> > > those devices upon their enumeration?
> >
> > If the pwrctrl driver is available at the time of platform device creation,
> > this is not needed. But if the driver is not available at that time and
> > probed later, then we need to rescan the bus to enumerate the devices.
>
> I see. Sounds like this can be made conditional on the caller
> being a module. I think you could achieve this with the following
> in pci_pwrctl_device_set_ready():
>
> - schedule_work(&pwrctl->work);
> + if (is_module_address(_RET_IP_))
> + schedule_work(&pwrctl->work);
>
> Though you'd also have to declare pci_pwrctl_device_set_ready()
> "__attribute__((always_inline))" so that it gets inlined into
> devm_pci_pwrctl_device_set_ready() and the condition works there
> as well.
>
I'd prefer to skip the rescan if the pwrctrl device is created and let the
pci_pwrctrl_device_set_ready() initiate rescan once the device is powered on.
This way, we could avoid scanning for the device twice.
> I'm wondering whether the bus notifier is still necessary with
> the new scheme. Since the power control device is instantiated
> and destroyed in unison with the pci_dev, can't the device link
> always be created on instantiation of the power control device?
>
I did move the devlink handling out of bus notifier callback with commit,
b458ff7e8176 ("PCI/pwrctl: Ensure that pwrctl drivers are probed before PCI
client drivers").
The bus notifier is only used to set 'of_node_reused' flag to indicate that the
corresponding DT node is already used.
- Mani
--
மணிவண்ணன் சதாசிவம்
next prev parent reply other threads:[~2024-12-17 14:50 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-10 9:55 [PATCH 0/4] PCI/pwrctrl: Rework pwrctrl driver integration and add driver for PCI slot Manivannan Sadhasivam via B4 Relay
2024-12-10 9:55 ` [PATCH 1/4] PCI/pwrctrl: Move creation of pwrctrl devices to pci_scan_device() Manivannan Sadhasivam via B4 Relay
2024-12-15 17:19 ` Lukas Wunner
2024-12-16 5:15 ` Manivannan Sadhasivam
2024-12-17 13:14 ` Lukas Wunner
2024-12-17 14:50 ` Manivannan Sadhasivam [this message]
2024-12-10 9:55 ` [PATCH 2/4] PCI/pwrctrl: Move pci_pwrctrl_unregister() to pci_destroy_dev() Manivannan Sadhasivam via B4 Relay
2024-12-15 17:20 ` Lukas Wunner
2024-12-10 9:55 ` [PATCH 3/4] dt-bindings: vendor-prefixes: Document the 'pciclass' prefix Manivannan Sadhasivam via B4 Relay
2024-12-17 13:34 ` Rob Herring (Arm)
2024-12-10 9:55 ` [PATCH 4/4] PCI/pwrctrl: Add pwrctrl driver for PCI Slots Manivannan Sadhasivam via B4 Relay
2024-12-18 9:16 ` kernel test robot
2024-12-10 12:40 ` [PATCH 0/4] PCI/pwrctrl: Rework pwrctrl driver integration and add driver for PCI slot Bartosz Golaszewski
2024-12-11 9:55 ` Qiang Yu
2024-12-15 17:32 ` Lukas Wunner
2024-12-16 5:21 ` Manivannan Sadhasivam
2024-12-16 8:26 ` Manivannan Sadhasivam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241217145035.xqfl4yp3atpgqzth@thinkpad \
--to=manivannan.sadhasivam@linaro.org \
--cc=andersson@kernel.org \
--cc=bhelgaas@google.com \
--cc=brgl@bgdev.pl \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=quic_qianyu@quicinc.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox