From: Marek Vasut <marek.vasut@mailbox.org>
To: "Guangshuo Li" <lgs201920130244@gmail.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>,
"Siddharth Vadapalli" <s-vadapalli@ti.com>,
"Frank Li" <Frank.Li@nxp.com>,
"Niklas Cassel" <cassel@kernel.org>,
"Yuho Choi" <dbgh9129@gmail.com>,
"Kishon Vijay Abraham I" <kishon@kernel.org>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
"Koichiro Den" <den@valinux.co.jp>
Cc: stable@vger.kernel.org
Subject: Re: [PATCH] PCI: keystone: deinitialize endpoint on remove
Date: Thu, 17 Sep 2026 00:56:20 +0200 [thread overview]
Message-ID: <736ff398-98fa-43bc-9771-1b0d4c2a591c@mailbox.org> (raw)
In-Reply-To: <20260916080030.2960608-1-lgs201920130244@gmail.com>
On 9/16/26 10:00 AM, Guangshuo Li wrote:
> ks_pcie_probe() initializes the DesignWare PCIe endpoint with
> dw_pcie_ep_init(). The probe failure path calls dw_pcie_ep_deinit()
> when endpoint register initialization fails, but the remove path does
> not perform the corresponding endpoint teardown after a successful
> probe.
>
> The successful endpoint initialization also calls pci_epc_init_notify().
> Without the matching teardown on removal, the EPC initialization state
> and resources allocated by the DesignWare endpoint core are left
> active after the driver is removed.
>
> Notify the endpoint framework about deinitialization and call
> dw_pcie_ep_deinit() before disabling runtime PM and the PHYs.
>
> This issue was found by manual code inspection.
>
> Fixes: 23284ad677a9 ("PCI: keystone: Add support for PCIe EP in AM654x Platforms")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
> drivers/pci/controller/dwc/pci-keystone.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c
> index 602516239a57..35787e727c5c 100644
> --- a/drivers/pci/controller/dwc/pci-keystone.c
> +++ b/drivers/pci/controller/dwc/pci-keystone.c
> @@ -1349,9 +1349,17 @@ static void ks_pcie_remove(struct platform_device *pdev)
> {
> struct keystone_pcie *ks_pcie = platform_get_drvdata(pdev);
> struct device_link **link = ks_pcie->link;
> + struct dw_pcie *pci = ks_pcie->pci;
> + const struct ks_pcie_of_data *data;
> int num_lanes = ks_pcie->num_lanes;
> struct device *dev = &pdev->dev;
>
> + data = of_device_get_match_data(dev);
Could you maybe cache the mode in struct keystone_pcie {} instead ?
> + if (data->mode == DW_PCIE_EP_TYPE) {
> + pci_epc_deinit_notify(pci->ep.epc);
> + dw_pcie_ep_deinit(&pci->ep);
Would it make sense to make dw_pcie_ep_deinit() call
pci_epc_deinit_notify() , to avoid duplication in controller drivers ?
> + }
> +
> pm_runtime_put(dev);
> pm_runtime_disable(dev);
> ks_pcie_disable_phy(ks_pcie);
--
Best regards,
Marek Vasut
next prev parent reply other threads:[~2026-09-16 22:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 8:00 [PATCH] PCI: keystone: deinitialize endpoint on remove Guangshuo Li
2026-09-16 8:09 ` sashiko-bot
2026-09-16 22:56 ` Marek Vasut [this message]
2026-09-21 14:15 ` Guangshuo Li
2026-09-21 14:46 ` Marek Vasut
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=736ff398-98fa-43bc-9771-1b0d4c2a591c@mailbox.org \
--to=marek.vasut@mailbox.org \
--cc=Frank.Li@nxp.com \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=dbgh9129@gmail.com \
--cc=den@valinux.co.jp \
--cc=kishon@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=lgs201920130244@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=robh@kernel.org \
--cc=s-vadapalli@ti.com \
--cc=stable@vger.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