From nobody Fri Sep 25 12:06:09 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E8E53515F1; Tue, 15 Sep 2026 08:28:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789460927; cv=none; b=CqEU/lzPJczOE07b51L93/ejYM5ZZSr50qS7Adluyv6zi09eL3hh2EvBMn7d2wKWytJe7C9LVe7QUCqP8J795c28A94LTWtLkhOGUpIvVvvdMw5eeujoISFFFeODPaYefswj2gPueLyPIUYkad307FJET2rK/s++ClqcMjuN2pU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789460927; c=relaxed/simple; bh=6DFX5EHsc3kZbkxlD3BSWbEya4idlWUBiU3+3hZIVN4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=fdOyjsc1av+AUjoCLMjcYZVVWkFs1OuXJknYBAF/T1qZxcJee6+libFoe+pEtGcqNpLtS7sp9jX7fgqjsSbCwieARgNOwTeyG1mdJPZ57E+OLvI7CXHgw8AVSknpLT6q2Rz9N6jP52tNf8OZ1Q7Gi5EteqKX3LDVA2xub2nobFk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 71ca4c80b0df11f19a56ed5b684f684d-20260915 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.19,REQID:2bf64f99-0be0-4f1f-b4d8-6db001d4099b,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:7db8b62,CLOUDID:6c4b5a1387fed50d946b92379747ef9d,BulkI D:nil,BulkQuantity:0,SF:102|850|865|898,TC:nil,Content:0|15|50|99,EDM:-3,I P:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 ,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 71ca4c80b0df11f19a56ed5b684f684d-20260915 X-User: lilinmao@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 1606268940; Tue, 15 Sep 2026 16:28:35 +0800 From: Linmao Li To: Bjorn Helgaas , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam Cc: Rob Herring , Aksh Garg , Tom Joseph , Vladimir Oltean , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Linmao Li Subject: [PATCH v2] PCI: cadence: Store the core controller in platform drvdata Date: Tue, 15 Sep 2026 16:28:26 +0800 Message-Id: <20260915082826.4135665-1-lilinmao@kylinos.cn> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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() and 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. Fixes: bd22885aa188 ("PCI: cadence: Refactor driver to use as a core librar= y") Suggested-by: Aksh Garg Signed-off-by: Linmao Li Reviewed-by: Aksh Garg Suggested-by tag can be dropped IMO as the suggestion was not the core=20 --- Changes in v2: - Drop the redundant struct cdns_plat_pcie wrapper (Aksh Garg). --- .../controller/cadence/pcie-cadence-plat.c | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/pci/controller/cadence/pcie-cadence-plat.c b/drivers/p= ci/controller/cadence/pcie-cadence-plat.c index 13edc6be21f5..4a24302cc5b2 100644 --- a/drivers/pci/controller/cadence/pcie-cadence-plat.c +++ b/drivers/pci/controller/cadence/pcie-cadence-plat.c @@ -14,14 +14,6 @@ =20 #define CDNS_PLAT_CPU_TO_BUS_ADDR 0x0FFFFFFF =20 -/** - * 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[]; =20 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 =3D { 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 =3D &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 =3D data->is_rc; =20 pr_debug(" Started %s with is_rc: %d\n", __func__, is_rc); - cdns_plat_pcie =3D 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 *p= dev) rc =3D pci_host_bridge_priv(bridge); rc->pcie.dev =3D dev; rc->pcie.ops =3D &cdns_plat_ops; - cdns_plat_pcie->pcie =3D &rc->pcie; + pcie =3D &rc->pcie; =20 - ret =3D cdns_pcie_init_phy(dev, cdns_plat_pcie->pcie); + ret =3D 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 *p= dev) =20 ep->pcie.dev =3D dev; ep->pcie.ops =3D &cdns_plat_ops; - cdns_plat_pcie->pcie =3D &ep->pcie; + pcie =3D &ep->pcie; =20 - ret =3D cdns_pcie_init_phy(dev, cdns_plat_pcie->pcie); + ret =3D 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_devic= e *pdev) goto err_init; } =20 + platform_set_drvdata(pdev, pcie); + return 0; =20 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); =20 return ret; } base-commit: 9a9d18547ddc97a73d5d90cff4d5aef90bd8c15d --=20 2.25.1