From: Christian Bruel <christian.bruel@foss.st.com>
To: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: <lpieralisi@kernel.org>, <kw@linux.com>, <robh@kernel.org>,
<bhelgaas@google.com>, <krzk+dt@kernel.org>,
<conor+dt@kernel.org>, <mcoquelin.stm32@gmail.com>,
<alexandre.torgue@foss.st.com>, <p.zabel@pengutronix.de>,
<thippeswamy.havalige@amd.com>, <shradha.t@samsung.com>,
<quic_schintav@quicinc.com>, <cassel@kernel.org>,
<johan+linaro@kernel.org>, <linux-pci@vger.kernel.org>,
<devicetree@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v8 2/9] PCI: stm32: Add PCIe host support for STM32MP25
Date: Fri, 16 May 2025 10:37:16 +0200 [thread overview]
Message-ID: <7df0c1e5-f53b-4a44-920a-c2dfe8842481@foss.st.com> (raw)
In-Reply-To: <ec33uuugief45swij7eu3mbx7htfxov6qa5miucqsrdp36z7qe@svpbhliveks4>
On 5/15/25 13:29, Manivannan Sadhasivam wrote:
> On Mon, May 12, 2025 at 05:08:13PM +0200, Christian Bruel wrote:
>> Hi Manivannan,
>>
>> On 4/30/25 09:30, Manivannan Sadhasivam wrote:
>>> On Wed, Apr 23, 2025 at 11:01:12AM +0200, Christian Bruel wrote:
>>>> Add driver for the STM32MP25 SoC PCIe Gen1 2.5 GT/s and Gen2 5GT/s
>>>> controller based on the DesignWare PCIe core.
>>>>
>>>> Supports MSI via GICv2m, Single Virtual Channel, Single Function
>>>>
>>>> Supports WAKE# GPIO.
>>>>
>>>
>>> Mostly looks good. Just a couple of comments below.
>>>
>>>> Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
>>>> ---
>>>> drivers/pci/controller/dwc/Kconfig | 12 +
>>>> drivers/pci/controller/dwc/Makefile | 1 +
>>>> drivers/pci/controller/dwc/pcie-stm32.c | 368 ++++++++++++++++++++++++
>>>> drivers/pci/controller/dwc/pcie-stm32.h | 15 +
>>>> 4 files changed, 396 insertions(+)
>>>> create mode 100644 drivers/pci/controller/dwc/pcie-stm32.c
>>>> create mode 100644 drivers/pci/controller/dwc/pcie-stm32.h
>>>>
>>>
>>> [...]
>>>
>>>> +static int stm32_pcie_probe(struct platform_device *pdev)
>>>> +{
>>>> + struct stm32_pcie *stm32_pcie;
>>>> + struct device *dev = &pdev->dev;
>>>> + int ret;
>>>> +
>>>> + stm32_pcie = devm_kzalloc(dev, sizeof(*stm32_pcie), GFP_KERNEL);
>>>> + if (!stm32_pcie)
>>>> + return -ENOMEM;
>>>> +
>>>> + stm32_pcie->pci.dev = dev;
>>>> + stm32_pcie->pci.ops = &dw_pcie_ops;
>>>> + stm32_pcie->pci.pp.ops = &stm32_pcie_host_ops;
>>>> +
>>>> + stm32_pcie->regmap = syscon_regmap_lookup_by_compatible("st,stm32mp25-syscfg");
>>>> + if (IS_ERR(stm32_pcie->regmap))
>>>> + return dev_err_probe(dev, PTR_ERR(stm32_pcie->regmap),
>>>> + "No syscfg specified\n");
>>>> +
>>>> + stm32_pcie->clk = devm_clk_get(dev, NULL);
>>>> + if (IS_ERR(stm32_pcie->clk))
>>>> + return dev_err_probe(dev, PTR_ERR(stm32_pcie->clk),
>>>> + "Failed to get PCIe clock source\n");
>>>> +
>>>> + stm32_pcie->rst = devm_reset_control_get_exclusive(dev, NULL);
>>>> + if (IS_ERR(stm32_pcie->rst))
>>>> + return dev_err_probe(dev, PTR_ERR(stm32_pcie->rst),
>>>> + "Failed to get PCIe reset\n");
>>>> +
>>>> + ret = stm32_pcie_parse_port(stm32_pcie);
>>>> + if (ret)
>>>> + return ret;
>>>> +
>>>> + platform_set_drvdata(pdev, stm32_pcie);
>>>> +
>>>> + ret = pm_runtime_set_active(dev);
>>>> + if (ret < 0) {
>>>> + dev_err(dev, "Failed to activate runtime PM %d\n", ret);
>>>
>>> Please use dev_err_probe() here and below.
>>
>> OK, will report this in the EP driver also.
>>
>>>
>>>> + return ret;
>>>> + }
>>>> +
>>>> + ret = devm_pm_runtime_enable(dev);
>>>> + if (ret < 0) {
>>>> + dev_err(dev, "Failed to enable runtime PM %d\n", ret);
>>>> + return ret;
>>>> + }
>>>> +
>>>> + pm_runtime_get_noresume(dev);
>>>> +
>>>
>>> I know that a lot of the controller drivers do this for no obvious reason. But
>>> in this case, I believe you want to enable power domain or genpd before
>>> registering the host bridge. Is that right?
>>
>> We call pm_runtime_enable() before stm32_add_pcie_port() and
>> dw_pcie_host_init(). This ensures that PCIe is active during the PERST#
>> sequence and before accessing the DWC registers.
>>
>
> What do you mean by 'PCIe is active'? Who is activating it other than this
> driver?
"PCIe is active" in the sense of pm_runtime_active() and PM runtime_enabled.
A better call point would be just before dw_host_init(), after the PCIe
controller is reset :
stm32_add_pcie_port()
clk_prepare_enable()
devm_pm_runtime_enable()
dw_pcie_host_init()
with this sequence, the stm32_pcie_suspend_noirq() is well balanced.
does that sound better ?
>
>>> And the fact that you are not
>>> decrementing the runtime usage count means, you want to keep it ON all the time?
>>> Beware that your system suspend/resume calls would never get executed.
>>
>> We do not support PM runtime autosuspend, so we must notify PM runtime that
>> PCIe is always active. Without invoking pm_runtime_get_noresume(), PCIe
>> would mistakenly be marked as suspended.
>
> This cannot happen unless the child devices are also suspended? Or if there are
> no child devices connected.
If no device is connected or if one is active, without
pm_runtime_get_noresume(), pm_genpd_summary says "PCIe suspended"
despite being clocked and having accessible configuration space
thank you,
Christian
>
> - Mani
>
next prev parent reply other threads:[~2025-05-16 8:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-23 9:01 [PATCH v8 0/9] Add STM32MP25 PCIe drivers Christian Bruel
2025-04-23 9:01 ` [PATCH v8 1/9] dt-bindings: PCI: Add STM32MP25 PCIe Root Complex bindings Christian Bruel
2025-04-23 9:01 ` [PATCH v8 2/9] PCI: stm32: Add PCIe host support for STM32MP25 Christian Bruel
2025-04-30 7:30 ` Manivannan Sadhasivam
2025-05-12 15:08 ` Christian Bruel
2025-05-15 11:29 ` Manivannan Sadhasivam
2025-05-16 8:37 ` Christian Bruel [this message]
2025-05-16 14:52 ` Manivannan Sadhasivam
2025-06-04 16:35 ` Christian Bruel
2025-04-23 9:01 ` [PATCH v8 3/9] dt-bindings: PCI: Add STM32MP25 PCIe Endpoint bindings Christian Bruel
2025-04-23 9:01 ` [PATCH v8 4/9] PCI: stm32: Add PCIe Endpoint support for STM32MP25 Christian Bruel
2025-04-30 7:50 ` Manivannan Sadhasivam
2025-05-12 16:06 ` Christian Bruel
2025-05-15 11:26 ` Manivannan Sadhasivam
2025-05-16 12:07 ` Christian Bruel
2025-04-23 9:01 ` [PATCH v8 5/9] MAINTAINERS: add entry for ST STM32MP25 PCIe drivers Christian Bruel
2025-04-23 9:01 ` [PATCH v8 6/9] arm64: dts: st: add PCIe pinctrl entries in stm32mp25-pinctrl.dtsi Christian Bruel
2025-04-23 9:01 ` [PATCH v8 7/9] arm64: dts: st: Add PCIe Root Complex mode on stm32mp251 Christian Bruel
2025-04-23 9:01 ` [PATCH v8 8/9] arm64: dts: st: Add PCIe Endpoint " Christian Bruel
2025-04-23 9:01 ` [PATCH v8 9/9] arm64: dts: st: Enable PCIe on the stm32mp257f-ev1 board Christian Bruel
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=7df0c1e5-f53b-4a44-920a-c2dfe8842481@foss.st.com \
--to=christian.bruel@foss.st.com \
--cc=alexandre.torgue@foss.st.com \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=johan+linaro@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=lpieralisi@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=mcoquelin.stm32@gmail.com \
--cc=p.zabel@pengutronix.de \
--cc=quic_schintav@quicinc.com \
--cc=robh@kernel.org \
--cc=shradha.t@samsung.com \
--cc=thippeswamy.havalige@amd.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
all inboxes | Powered by JetHome®