From: Shawn Lin <shawn.lin@rock-chips.com>
To: Anand Moon <linux.amoon@gmail.com>
Cc: shawn.lin@rock-chips.com,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Heiko Stuebner" <heiko@sntech.de>,
"Niklas Cassel" <cassel@kernel.org>,
"Hans Zhang" <18255117159@163.com>,
"Nicolas Frattaroli" <nicolas.frattaroli@collabora.com>,
"open list:PCI NATIVE HOST BRIDGE AND ENDPOINT DRIVERS"
<linux-pci@vger.kernel.org>,
"moderated list:ARM/Rockchip SoC support"
<linux-arm-kernel@lists.infradead.org>,
"open list:ARM/Rockchip SoC support"
<linux-rockchip@lists.infradead.org>,
"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1 1/2] PCI: dw-rockchip: Add remove callback for resource cleanup
Date: Wed, 29 Oct 2025 08:28:10 +0800 [thread overview]
Message-ID: <3fcd5562-a367-41e9-8bff-51e5990145e2@rock-chips.com> (raw)
In-Reply-To: <CANAwSgRXcg4tO00SNu77EKdp6Ay6X7+_f-ZoHxgkv1himxdi0Q@mail.gmail.com>
在 2025/10/28 星期二 17:34, Anand Moon 写道:
> Hi Shawn,
>
> Thanks for your review comments.
>
> On Tue, 28 Oct 2025 at 05:56, Shawn Lin <shawn.lin@rock-chips.com> wrote:
>>
>> 在 2025/10/27 星期一 22:55, Anand Moon 写道:
>>> Introduce a .remove() callback to the Rockchip DesignWare PCIe
>>> controller driver to ensure proper resource deinitialization during
>>> device removal. This includes disabling clocks and deinitializing the
>>> PCIe PHY.
>>>
>>> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
>>> ---
>>> drivers/pci/controller/dwc/pcie-dw-rockchip.c | 11 +++++++++++
>>> 1 file changed, 11 insertions(+)
>>>
>>> diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
>>> index 87dd2dd188b4..b878ae8e2b3e 100644
>>> --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
>>> +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
>>> @@ -717,6 +717,16 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
>>> return ret;
>>> }
>>>
>>> +static void rockchip_pcie_remove(struct platform_device *pdev)
>>> +{
>>> + struct device *dev = &pdev->dev;
>>> + struct rockchip_pcie *rockchip = dev_get_drvdata(dev);
>>> +
>>> + /* Perform other cleanups as necessary */
>>> + clk_bulk_disable_unprepare(rockchip->clk_cnt, rockchip->clks);
>>> + rockchip_pcie_phy_deinit(rockchip);
>>> +}
>>
>> Thanks for the patch.
>>
>> Dou you need to call dw_pcie_host_deinit()?
> I feel the rockchip_pcie_phy_deinit will power off the phy
>> And I think you should also try to mask PCIE_CLIENT_INTR_MASK_MISC and
>> remove the irq domain as well.
>>
>> if (rockchip->irq_domain) {
>> int virq, j;
>> for (j = 0; j < PCI_NUM_INTX; j++) {
>> virq = irq_find_mapping(rockchip->irq_domain, j);
>> if (virq > 0)
>> irq_dispose_mapping(virq);
>> }
>> irq_set_chained_handler_and_data(rockchip->irq, NULL, NULL);
>> irq_domain_remove(rockchip->irq_domain);
>> }
>>
> I have implemented resource cleanup in rockchip_pcie_remove,
> which is invoked when the system is shutting down.
> Your feedback on the updated code is welcome.
>
> static void rockchip_pcie_remove(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> struct rockchip_pcie *rockchip = dev_get_drvdata(dev);
> int irq;
>
> irq = of_irq_get_byname(dev->of_node, "legacy");
> if (irq < 0)
> return;
>
> /* Perform other cleanups as necessary */
> /* clear up INTR staatus register */
> rockchip_pcie_writel_apb(rockchip, 0xffffffff,
> PCIE_CLIENT_INTR_STATUS_MISC);
> if (rockchip->irq_domain) {
> int virq, j;
> for (j = 0; j < PCI_NUM_INTX; j++) {
> virq = irq_find_mapping(rockchip->irq_domain, j);
> if (virq > 0)
> irq_dispose_mapping(virq);
> }
> irq_set_chained_handler_and_data(irq, NULL, NULL);
> irq_domain_remove(rockchip->irq_domain);
> }
>
> clk_bulk_disable_unprepare(rockchip->clk_cnt, rockchip->clks);
> /* poweroff the phy */
> rockchip_pcie_phy_deinit(rockchip);
> /* release the reset */
release? Or "reset the controller"?
> reset_control_assert(rockchip->rst);
> pm_runtime_put_sync(dev);
> pm_runtime_disable(dev);
> pm_runtime_no_callbacks(dev);
> }
>
>> Another thin I noticed is should we call pm_runtime_* here for hope that
>> genpd could be powered donw once removed?
>>
> I could not find 'genpd' (power domain) used in the PCIe driver
> If we have an example to use genpd I will update this.
> > I am also looking into adding NOIRQ_SYSTEM_SLEEP_PM_OPS
That sounds good, you can pick up my patch[1] if you'd like to continue
addressing the comments that I haven't had time to think more.
[1] https://www.spinics.net/lists/linux-pci/msg171846.html
>
> Thanks
> -Anand
>
next prev parent reply other threads:[~2025-10-29 6:11 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-27 14:55 [PATCH v1 0/2] Add runtime PM support to Rockchip DW PCIe driver Anand Moon
2025-10-27 14:55 ` [PATCH v1 1/2] PCI: dw-rockchip: Add remove callback for resource cleanup Anand Moon
2025-10-27 15:12 ` Nicolas Frattaroli
2025-10-27 16:31 ` Anand Moon
2025-10-27 17:17 ` Nicolas Frattaroli
2025-10-28 0:26 ` Shawn Lin
2025-10-28 9:34 ` Anand Moon
2025-10-29 0:28 ` Shawn Lin [this message]
2025-10-29 6:24 ` Anand Moon
2025-10-31 8:36 ` Manivannan Sadhasivam
2025-10-31 12:29 ` Nicolas Frattaroli
2025-10-31 15:08 ` Manivannan Sadhasivam
2025-10-27 14:55 ` [PATCH v1 2/2] PCI: dw-rockchip: Add runtime PM support to Rockchip PCIe driver Anand Moon
2025-10-28 0:44 ` Shawn Lin
2025-10-28 9:34 ` Anand Moon
2025-10-31 8:39 ` Manivannan Sadhasivam
2025-10-31 14:03 ` Anand Moon
2025-10-31 14:53 ` Manivannan Sadhasivam
2025-11-01 8:09 ` Anand Moon
2025-10-27 15:06 ` [PATCH v1 0/2] Add runtime PM support to Rockchip DW " Nicolas Frattaroli
2025-10-29 6:29 ` Anand Moon
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=3fcd5562-a367-41e9-8bff-51e5990145e2@rock-chips.com \
--to=shawn.lin@rock-chips.com \
--cc=18255117159@163.com \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=heiko@sntech.de \
--cc=kwilczynski@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux.amoon@gmail.com \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=nicolas.frattaroli@collabora.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
all inboxes | Powered by JetHome®