* [PATCH 2/2] PCI: meson: Add missing remove callback
@ 2026-05-18 16:59 ` Shuvam Pandey
2026-06-09 16:41 ` (subset) " Manivannan Sadhasivam
2026-06-11 22:26 ` Bjorn Helgaas
0 siblings, 2 replies; 6+ messages in thread
From: Shuvam Pandey @ 2026-05-18 16:59 UTC (permalink / raw)
To: Jingoo Han, Manivannan Sadhasivam, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bjorn Helgaas, Yue Wang,
Neil Armstrong
Cc: Rob Herring, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Fan Ni, Shradha Todi, Hanjie Lin, linux-pci, linux-amlogic,
linux-arm-kernel, linux-kernel
meson_pcie_probe() powers on the PHY and registers the DesignWare host
bridge with dw_pcie_host_init(), but the driver has no remove callback.
On driver unbind or module unload, the driver core therefore proceeds to
devres cleanup without first unregistering the host bridge or powering off
the PHY.
Add a remove callback that deinitializes the DesignWare host bridge and
powers off the PHY while device-managed resources are still valid.
Fixes: 9c0ef6d34fdb ("PCI: amlogic: Add the Amlogic Meson PCIe controller driver")
Signed-off-by: Shuvam Pandey <shuvampandey1@gmail.com>
---
drivers/pci/controller/dwc/pci-meson.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/pci/controller/dwc/pci-meson.c b/drivers/pci/controller/dwc/pci-meson.c
index 0694084f6..c96e2244a 100644
--- a/drivers/pci/controller/dwc/pci-meson.c
+++ b/drivers/pci/controller/dwc/pci-meson.c
@@ -451,6 +451,14 @@ static int meson_pcie_probe(struct platform_device *pdev)
return ret;
}
+static void meson_pcie_remove(struct platform_device *pdev)
+{
+ struct meson_pcie *mp = platform_get_drvdata(pdev);
+
+ dw_pcie_host_deinit(&mp->pci.pp);
+ meson_pcie_power_off(mp);
+}
+
static const struct of_device_id meson_pcie_of_match[] = {
{
.compatible = "amlogic,axg-pcie",
@@ -464,6 +472,7 @@ MODULE_DEVICE_TABLE(of, meson_pcie_of_match);
static struct platform_driver meson_pcie_driver = {
.probe = meson_pcie_probe,
+ .remove = meson_pcie_remove,
.driver = {
.name = "meson-pcie",
.of_match_table = meson_pcie_of_match,
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: (subset) [PATCH 2/2] PCI: meson: Add missing remove callback
2026-05-18 16:59 ` [PATCH 2/2] PCI: meson: Add missing remove callback Shuvam Pandey
@ 2026-06-09 16:41 ` Manivannan Sadhasivam
2026-06-11 22:26 ` Bjorn Helgaas
1 sibling, 0 replies; 6+ messages in thread
From: Manivannan Sadhasivam @ 2026-06-09 16:41 UTC (permalink / raw)
To: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczyński,
Bjorn Helgaas, Yue Wang, Neil Armstrong, Shuvam Pandey
Cc: Rob Herring, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Fan Ni, Shradha Todi, Hanjie Lin, linux-pci, linux-amlogic,
linux-arm-kernel, linux-kernel
On Mon, 18 May 2026 22:44:18 +0545, Shuvam Pandey wrote:
> meson_pcie_probe() powers on the PHY and registers the DesignWare host
> bridge with dw_pcie_host_init(), but the driver has no remove callback.
> On driver unbind or module unload, the driver core therefore proceeds to
> devres cleanup without first unregistering the host bridge or powering off
> the PHY.
>
> Add a remove callback that deinitializes the DesignWare host bridge and
> powers off the PHY while device-managed resources are still valid.
>
> [...]
Applied, thanks!
[2/2] PCI: meson: Add missing remove callback
commit: 4b0dc84b293984f75598881809fb2d3daf54a2a8
Best regards,
--
Manivannan Sadhasivam <mani@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 2/2] PCI: meson: Add missing remove callback
2026-05-18 16:59 ` [PATCH 2/2] PCI: meson: Add missing remove callback Shuvam Pandey
2026-06-09 16:41 ` (subset) " Manivannan Sadhasivam
@ 2026-06-11 22:26 ` Bjorn Helgaas
1 sibling, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2026-06-11 22:26 UTC (permalink / raw)
To: Shuvam Pandey
Cc: Jingoo Han, Manivannan Sadhasivam, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bjorn Helgaas, Yue Wang,
Neil Armstrong, Rob Herring, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Fan Ni, Shradha Todi, Hanjie Lin, linux-pci,
linux-amlogic, linux-arm-kernel, linux-kernel
On Mon, May 18, 2026 at 10:44:18PM +0545, Shuvam Pandey wrote:
> meson_pcie_probe() powers on the PHY and registers the DesignWare host
> bridge with dw_pcie_host_init(), but the driver has no remove callback.
> On driver unbind or module unload, the driver core therefore proceeds to
> devres cleanup without first unregistering the host bridge or powering off
> the PHY.
>
> Add a remove callback that deinitializes the DesignWare host bridge and
> powers off the PHY while device-managed resources are still valid.
What's the user-visible effect of this? Does it avoid an oops?
Reduce power usage?
Of the 34 instances of .probe() in drivers/pci/controller/dwc/, on 12
implement .remove(), so if this fixes a problem, I'm wondering whether
other drivers have the same problem.
> Fixes: 9c0ef6d34fdb ("PCI: amlogic: Add the Amlogic Meson PCIe controller driver")
> Signed-off-by: Shuvam Pandey <shuvampandey1@gmail.com>
> ---
> drivers/pci/controller/dwc/pci-meson.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/pci/controller/dwc/pci-meson.c b/drivers/pci/controller/dwc/pci-meson.c
> index 0694084f6..c96e2244a 100644
> --- a/drivers/pci/controller/dwc/pci-meson.c
> +++ b/drivers/pci/controller/dwc/pci-meson.c
> @@ -451,6 +451,14 @@ static int meson_pcie_probe(struct platform_device *pdev)
> return ret;
> }
>
> +static void meson_pcie_remove(struct platform_device *pdev)
> +{
> + struct meson_pcie *mp = platform_get_drvdata(pdev);
> +
> + dw_pcie_host_deinit(&mp->pci.pp);
> + meson_pcie_power_off(mp);
> +}
> +
> static const struct of_device_id meson_pcie_of_match[] = {
> {
> .compatible = "amlogic,axg-pcie",
> @@ -464,6 +472,7 @@ MODULE_DEVICE_TABLE(of, meson_pcie_of_match);
>
> static struct platform_driver meson_pcie_driver = {
> .probe = meson_pcie_probe,
> + .remove = meson_pcie_remove,
> .driver = {
> .name = "meson-pcie",
> .of_match_table = meson_pcie_of_match,
> --
> 2.50.1 (Apple Git-155)
>
>
> _______________________________________________
> linux-amlogic mailing list
> linux-amlogic@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: (subset) [PATCH 1/2] PCI: dwc: Guard RAS DES debugfs deinit
2026-05-18 16:59 [PATCH 1/2] PCI: dwc: Guard RAS DES debugfs deinit Shuvam Pandey
2026-05-18 16:59 ` [PATCH 2/2] PCI: meson: Add missing remove callback Shuvam Pandey
@ 2026-06-09 16:44 ` Manivannan Sadhasivam
2026-06-11 22:10 ` Bjorn Helgaas
2 siblings, 0 replies; 6+ messages in thread
From: Manivannan Sadhasivam @ 2026-06-09 16:44 UTC (permalink / raw)
To: Jingoo Han, Lorenzo Pieralisi, Krzysztof Wilczyński,
Bjorn Helgaas, Yue Wang, Neil Armstrong, Shuvam Pandey
Cc: Rob Herring, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Fan Ni, Shradha Todi, Hanjie Lin, linux-pci, linux-amlogic,
linux-arm-kernel, linux-kernel
On Mon, 18 May 2026 22:44:17 +0545, Shuvam Pandey wrote:
> dwc_pcie_rasdes_debugfs_init() returns success when the controller has
> no RAS DES capability, leaving pci->debugfs->rasdes_info unset. The
> common debugfs teardown path still calls
> dwc_pcie_rasdes_debugfs_deinit(), which dereferences rasdes_info
> unconditionally.
>
> Return early when no RAS DES state was allocated. In that case no RAS DES
> mutex was initialized, so there is nothing to destroy.
>
> [...]
Applied, thanks!
[1/2] PCI: dwc: Guard RAS DES debugfs deinit
commit: a5ee214bb36f43b4d8bb2615b30d3b5c0ea80826
Best regards,
--
Manivannan Sadhasivam <mani@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 1/2] PCI: dwc: Guard RAS DES debugfs deinit
2026-05-18 16:59 [PATCH 1/2] PCI: dwc: Guard RAS DES debugfs deinit Shuvam Pandey
2026-05-18 16:59 ` [PATCH 2/2] PCI: meson: Add missing remove callback Shuvam Pandey
2026-06-09 16:44 ` (subset) [PATCH 1/2] PCI: dwc: Guard RAS DES debugfs deinit Manivannan Sadhasivam
@ 2026-06-11 22:10 ` Bjorn Helgaas
2 siblings, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2026-06-11 22:10 UTC (permalink / raw)
To: Shuvam Pandey
Cc: Jingoo Han, Manivannan Sadhasivam, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bjorn Helgaas, Yue Wang,
Neil Armstrong, Rob Herring, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Fan Ni, Shradha Todi, Hanjie Lin, linux-pci,
linux-amlogic, linux-arm-kernel, linux-kernel
On Mon, May 18, 2026 at 10:44:17PM +0545, Shuvam Pandey wrote:
> dwc_pcie_rasdes_debugfs_init() returns success when the controller has
> no RAS DES capability, leaving pci->debugfs->rasdes_info unset. The
> common debugfs teardown path still calls
> dwc_pcie_rasdes_debugfs_deinit(), which dereferences rasdes_info
> unconditionally.
>
> Return early when no RAS DES state was allocated. In that case no RAS DES
> mutex was initialized, so there is nothing to destroy.
>
> Fixes: 4fbfa17f9a07 ("PCI: dwc: Add debugfs based Silicon Debug support for DWC")
> Signed-off-by: Shuvam Pandey <shuvampandey1@gmail.com>
> ---
> drivers/pci/controller/dwc/pcie-designware-debugfs.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> index d0884253b..c3671cb2f 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
> @@ -557,6 +557,9 @@ static void dwc_pcie_rasdes_debugfs_deinit(struct dw_pcie *pci)
> {
> struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
>
> + if (!rinfo)
> + return;
I guess this prevents a NULL pointer dereference, right?
> mutex_destroy(&rinfo->reg_event_lock);
> }
>
> --
> 2.50.1 (Apple Git-155)
>
>
> _______________________________________________
> linux-amlogic mailing list
> linux-amlogic@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 6+ messages in thread