FAILED: patch "[PATCH] PCI: cadence: Store the core controller in platform drvdata" failed to apply to 5.15-stable tree
Subsystems (4)
Sasha Levin
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x cfe96ce583c51bf6e034d4038c652a1e8227867c
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From cfe96ce583c51bf6e034d4038c652a1e8227867c Mon Sep 17 00:00:00 2001
From: Linmao Li <[email protected]>
Date: Tue, 15 Sep 2026 16:28:26 +0800
Subject: [PATCH] PCI: cadence: Store the core controller in platform drvdata
cdns_plat_pcie_probe() stores a struct cdns_plat_pcie pointer with platform_set_drvdata(). cdns_plat_pcie_shutdown() and the callbacks in cdns_pcie_pm_ops retrieve the same pointer with dev_get_drvdata() but use it as a struct cdns_pcie pointer. This makes them read phy_count and phy beyond the wrapper.
struct cdns_plat_pcie only contains a pointer to struct cdns_pcie. Drop the redundant wrapper and store the struct cdns_pcie pointer directly.
--- .../controller/cadence/pcie-cadence-plat.c | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-)
drivers/pci/controller/cadence/pcie-cadence-plat.c +8 -19
@@ -14,14 +14,6 @@#define CDNS_PLAT_CPU_TO_BUS_ADDR 0x0FFFFFFF -/** -* struct cdns_plat_pcie - private data for this PCIe platform driver -* @pcie: Cadence PCIe controller -*/ -struct cdns_plat_pcie { -struct cdns_pcie *pcie; -}; -static const struct of_device_id cdns_plat_pcie_of_match[];static u64 cdns_plat_cpu_addr_fixup (struct cdns_pcie *pcie,u64 cpu_addr)
@@ -36,9 +28,9 @@ static const struct cdns_pcie_ops cdns_plat_ops = {static int cdns_plat_pcie_probe (struct platform_device *pdev) {const struct cdns_plat_pcie_of_data *data; -struct cdns_plat_pcie *cdns_plat_pcie;struct device *dev = &pdev->dev;struct pci_host_bridge *bridge; +struct cdns_pcie *pcie;struct cdns_pcie_ep *ep;struct cdns_pcie_rc *rc;bool is_rc;
@@ -51,11 +43,6 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev) is_rc = data->is_rc;pr_debug (" Started %s with is_rc: %d\n" , __func__, is_rc); - cdns_plat_pcie =devm_kzalloc (dev,sizeof (*cdns_plat_pcie),GFP_KERNEL ); -if (!cdns_plat_pcie) -return -ENOMEM ; - -platform_set_drvdata (pdev, cdns_plat_pcie);if (is_rc) {if (!IS_ENABLED (CONFIG_PCIE_CADENCE_PLAT_HOST ))return -ENODEV ;
@@ -67,9 +54,9 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev) rc =pci_host_bridge_priv (bridge); rc->pcie.dev = dev; rc->pcie.ops = &cdns_plat_ops; - cdns_plat_pcie->pcie = &rc->pcie; + pcie = &rc->pcie; - ret =cdns_pcie_init_phy (dev, cdns_plat_pcie->pcie); + ret =cdns_pcie_init_phy (dev, pcie);if (ret) {dev_err (dev,"failed to init phy\n" );return ret;
@@ -94,9 +81,9 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev) ep->pcie.dev = dev; ep->pcie.ops = &cdns_plat_ops; - cdns_plat_pcie->pcie = &ep->pcie; + pcie = &ep->pcie; - ret =cdns_pcie_init_phy (dev, cdns_plat_pcie->pcie); + ret =cdns_pcie_init_phy (dev, pcie);if (ret) {dev_err (dev,"failed to init phy\n" );return ret;
@@ -114,13 +101,15 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev) goto err_init; } +platform_set_drvdata (pdev, pcie); +return 0 ; err_init: err_get_sync:pm_runtime_put_sync (dev);pm_runtime_disable (dev); -cdns_pcie_disable_phy (cdns_plat_pcie->pcie); +cdns_pcie_disable_phy (pcie);return ret; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 PCI: cadence: Store the core controller in platform drvdata
From: Linmao Li <[email protected]>
[ Upstream commit cfe96ce583c51bf6e034d4038c652a1e8227867c ]
cdns_plat_pcie_probe() stores a struct cdns_plat_pcie pointer with platform_set_drvdata(). cdns_plat_pcie_shutdown() and the callbacks in cdns_pcie_pm_ops retrieve the same pointer with dev_get_drvdata() but use it as a struct cdns_pcie pointer. This makes them read phy_count and phy beyond the wrapper.
struct cdns_plat_pcie only contains a pointer to struct cdns_pcie. Drop the redundant wrapper and store the struct cdns_pcie pointer directly.
--- .../controller/cadence/pcie-cadence-plat.c | 36 ++++++------------- 1 file changed, 10 insertions(+), 26 deletions(-)
drivers/pci/controller/cadence/pcie-cadence-plat.c +10 -26
@@ -15,17 +15,6 @@#define CDNS_PLAT_CPU_TO_BUS_ADDR 0x0FFFFFFF -/** -* struct cdns_plat_pcie - private data for this PCIe platform driver -* @pcie: Cadence PCIe controller -* @is_rc: Set to 1 indicates the PCIe controller mode is Root Complex, -* if 0 it is in Endpoint mode. -*/ -struct cdns_plat_pcie { -struct cdns_pcie *pcie; -bool is_rc; -}; -struct cdns_plat_pcie_of_data {bool is_rc; };
@@ -44,10 +33,10 @@ static const struct cdns_pcie_ops cdns_plat_ops = {static int cdns_plat_pcie_probe (struct platform_device *pdev) {const struct cdns_plat_pcie_of_data *data; -struct cdns_plat_pcie *cdns_plat_pcie;const struct of_device_id *match;struct device *dev = &pdev->dev;struct pci_host_bridge *bridge; +struct cdns_pcie *pcie;struct cdns_pcie_ep *ep;struct cdns_pcie_rc *rc;int phy_count;
@@ -62,11 +51,6 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev) is_rc = data->is_rc;pr_debug (" Started %s with is_rc: %d\n" , __func__, is_rc); - cdns_plat_pcie =devm_kzalloc (dev,sizeof (*cdns_plat_pcie),GFP_KERNEL ); -if (!cdns_plat_pcie) -return -ENOMEM ; - -platform_set_drvdata (pdev, cdns_plat_pcie);if (is_rc) {if (!IS_ENABLED (CONFIG_PCIE_CADENCE_PLAT_HOST ))return -ENODEV ;
@@ -78,10 +62,10 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev) rc =pci_host_bridge_priv (bridge); rc->pcie.dev = dev; rc->pcie.ops = &cdns_plat_ops; - cdns_plat_pcie->pcie = &rc->pcie; - cdns_plat_pcie->is_rc = is_rc; + pcie = &rc->pcie; +platform_set_drvdata (pdev, pcie); - ret =cdns_pcie_init_phy (dev, cdns_plat_pcie->pcie); + ret =cdns_pcie_init_phy (dev, pcie);if (ret) {dev_err (dev,"failed to init phy\n" );return ret;
@@ -106,10 +90,10 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev) ep->pcie.dev = dev; ep->pcie.ops = &cdns_plat_ops; - cdns_plat_pcie->pcie = &ep->pcie; - cdns_plat_pcie->is_rc = is_rc; + pcie = &ep->pcie; +platform_set_drvdata (pdev, pcie); - ret =cdns_pcie_init_phy (dev, cdns_plat_pcie->pcie); + ret =cdns_pcie_init_phy (dev, pcie);if (ret) {dev_err (dev,"failed to init phy\n" );return ret;
@@ -133,10 +117,10 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev) err_get_sync:pm_runtime_put_sync (dev);pm_runtime_disable (dev); -cdns_pcie_disable_phy (cdns_plat_pcie->pcie); - phy_count = cdns_plat_pcie->pcie->phy_count; +cdns_pcie_disable_phy (pcie); + phy_count = pcie->phy_count;while (phy_count--) -device_link_del (cdns_plat_pcie->pcie->link[phy_count]); +device_link_del (pcie->link[phy_count]);return 0 ; }
Signature · 1 line
2.53.0