From: Bartosz Golaszewski <brgl@bgdev.pl>
To: manivannan.sadhasivam@oss.qualcomm.com
Cc: "Manivannan Sadhasivam" <mani@kernel.org>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Saravana Kannan" <saravanak@google.com>,
linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
"Krishna Chaitanya Chundru" <krishna.chundru@oss.qualcomm.com>,
"Brian Norris" <briannorris@chromium.org>
Subject: Re: [PATCH 3/6] PCI/pwrctrl: Add support for toggling PERST#
Date: Wed, 27 Aug 2025 18:32:30 +0200 [thread overview]
Message-ID: <CAMRc=Me2P9r9w-UPtjMAEvuQ_oNtibzPBg6tE7s1wdKkLmQgcQ@mail.gmail.com> (raw)
In-Reply-To: <20250819-pci-pwrctrl-perst-v1-3-4b74978d2007@oss.qualcomm.com>
On Tue, Aug 19, 2025 at 9:15 AM Manivannan Sadhasivam via B4 Relay
<devnull+manivannan.sadhasivam.oss.qualcomm.com@kernel.org> wrote:
>
> From: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
>
> As per PCIe spec r6.0, sec 6.6.1, PERST# is an auxiliary signal provided by
> the system to a component as a Fundamental Reset. This signal if available,
> should conform to the rules defined by the electromechanical form factor
> specifications like PCIe CEM spec r4.0, sec 2.2.
>
> Since pwrctrl driver is meant to control the power supplies, it should also
> control the PERST# signal if available. But traditionally, the host bridge
> (controller) drivers are the ones parsing and controlling the PERST#
> signal. They also sometimes need to assert PERST# during their own hardware
> initialization. So it is not possible to move the PERST# control away from
> the controller drivers and it must be shared logically.
>
> Hence, add a new callback 'pci_host_bridge::toggle_perst', that allows the
> pwrctrl core to toggle PERST# with the help of the controller drivers. But
> care must be taken care by the controller drivers to not deassert the
> PERST# signal if this callback is populated.
>
> This callback if available, will be called by the pwrctrl core during the
> device power up and power down scenarios. Controller drivers should
> identify the device using the 'struct device_node' passed during the
> callback and toggle PERST# accordingly.
>
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
> ---
> drivers/pci/pwrctrl/core.c | 27 +++++++++++++++++++++++++++
> include/linux/pci.h | 1 +
> 2 files changed, 28 insertions(+)
>
> diff --git a/drivers/pci/pwrctrl/core.c b/drivers/pci/pwrctrl/core.c
> index 6bdbfed584d6d79ce28ba9e384a596b065ca69a4..8a26f432436d064acb7ebbbc9ce8fc339909fbe9 100644
> --- a/drivers/pci/pwrctrl/core.c
> +++ b/drivers/pci/pwrctrl/core.c
> @@ -6,6 +6,7 @@
> #include <linux/device.h>
> #include <linux/export.h>
> #include <linux/kernel.h>
> +#include <linux/of.h>
> #include <linux/pci.h>
> #include <linux/pci-pwrctrl.h>
> #include <linux/property.h>
> @@ -61,6 +62,28 @@ void pci_pwrctrl_init(struct pci_pwrctrl *pwrctrl, struct device *dev)
> }
> EXPORT_SYMBOL_GPL(pci_pwrctrl_init);
>
> +static void pci_pwrctrl_perst_deassert(struct pci_pwrctrl *pwrctrl)
> +{
> + struct pci_host_bridge *host_bridge = to_pci_host_bridge(pwrctrl->dev->parent);
> + struct device_node *np = dev_of_node(pwrctrl->dev);
> +
> + if (!host_bridge->toggle_perst)
> + return;
> +
> + host_bridge->toggle_perst(host_bridge, np, false);
> +}
> +
> +static void pci_pwrctrl_perst_assert(struct pci_pwrctrl *pwrctrl)
> +{
> + struct pci_host_bridge *host_bridge = to_pci_host_bridge(pwrctrl->dev->parent);
> + struct device_node *np = dev_of_node(pwrctrl->dev);
> +
> + if (!host_bridge->toggle_perst)
> + return;
> +
> + host_bridge->toggle_perst(host_bridge, np, true);
> +}
> +
> /**
> * pci_pwrctrl_device_set_ready() - Notify the pwrctrl subsystem that the PCI
> * device is powered-up and ready to be detected.
> @@ -82,6 +105,8 @@ int pci_pwrctrl_device_set_ready(struct pci_pwrctrl *pwrctrl)
> if (!pwrctrl->dev)
> return -ENODEV;
>
> + pci_pwrctrl_perst_deassert(pwrctrl);
> +
> pwrctrl->nb.notifier_call = pci_pwrctrl_notify;
> ret = bus_register_notifier(&pci_bus_type, &pwrctrl->nb);
> if (ret)
> @@ -103,6 +128,8 @@ void pci_pwrctrl_device_unset_ready(struct pci_pwrctrl *pwrctrl)
> {
> cancel_work_sync(&pwrctrl->work);
>
> + pci_pwrctrl_perst_assert(pwrctrl);
> +
> /*
> * We don't have to delete the link here. Typically, this function
> * is only called when the power control device is being detached. If
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 59876de13860dbe50ee6c207cd57e54f51a11079..9eeee84d550bb9f15a90b5db9da03fccef8097ee 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -605,6 +605,7 @@ struct pci_host_bridge {
> void (*release_fn)(struct pci_host_bridge *);
> int (*enable_device)(struct pci_host_bridge *bridge, struct pci_dev *dev);
> void (*disable_device)(struct pci_host_bridge *bridge, struct pci_dev *dev);
> + void (*toggle_perst)(struct pci_host_bridge *bridge, struct device_node *np, bool assert);
Shouldn't this be wrapped in an #if IS_ENABLED(PCI_PWRCTL)?
Bart
> void *release_data;
> unsigned int ignore_reset_delay:1; /* For entire hierarchy */
> unsigned int no_ext_tags:1; /* No Extended Tags */
>
> --
> 2.45.2
>
>
next prev parent reply other threads:[~2025-08-27 16:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-19 7:14 [PATCH 0/6] PCI/pwrctrl: Allow pwrctrl framework to control PERST# if available Manivannan Sadhasivam via B4 Relay
2025-08-19 7:14 ` [PATCH 1/6] PCI: qcom: Wait for PCIE_RESET_CONFIG_WAIT_MS after PERST# deassert Manivannan Sadhasivam via B4 Relay
2025-08-19 7:14 ` [PATCH 2/6] PCI/pwrctrl: Move pci_pwrctrl_init() before turning ON the supplies Manivannan Sadhasivam via B4 Relay
2025-08-19 7:14 ` [PATCH 3/6] PCI/pwrctrl: Add support for toggling PERST# Manivannan Sadhasivam via B4 Relay
2025-08-27 16:32 ` Bartosz Golaszewski [this message]
2025-08-27 17:26 ` Manivannan Sadhasivam
2025-08-19 7:14 ` [PATCH 4/6] PCI: of: Add an API to get the BDF for the device node Manivannan Sadhasivam via B4 Relay
2025-08-22 13:51 ` Rob Herring
2025-08-22 14:27 ` Manivannan Sadhasivam
2025-08-25 22:43 ` Rob Herring
2025-08-26 7:15 ` Manivannan Sadhasivam
2025-08-26 13:12 ` Rob Herring
2025-08-28 13:33 ` Manivannan Sadhasivam
2025-08-19 7:14 ` [PATCH 5/6] PCI: qcom: Parse PERST# from all PCIe bridge nodes Manivannan Sadhasivam via B4 Relay
2025-08-27 16:34 ` Bartosz Golaszewski
2025-08-27 17:27 ` Manivannan Sadhasivam
2025-08-27 19:48 ` Bartosz Golaszewski
2025-08-19 7:14 ` [PATCH 6/6] PCI: qcom: Allow pwrctrl core to toggle PERST# for new DT binding Manivannan Sadhasivam via B4 Relay
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='CAMRc=Me2P9r9w-UPtjMAEvuQ_oNtibzPBg6tE7s1wdKkLmQgcQ@mail.gmail.com' \
--to=brgl@bgdev.pl \
--cc=bhelgaas@google.com \
--cc=briannorris@chromium.org \
--cc=devicetree@vger.kernel.org \
--cc=krishna.chundru@oss.qualcomm.com \
--cc=kwilczynski@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=manivannan.sadhasivam@oss.qualcomm.com \
--cc=robh@kernel.org \
--cc=saravanak@google.com \
/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;
as well as URLs for NNTP newsgroup(s).