[PATCH] PCI: dwc: Remove duplicate dw_pcie_ep_hide_ext_capability() function

Qiang Yu posted 1 patch 1 month, 2 weeks ago
drivers/pci/controller/dwc/pcie-designware-ep.c | 39 -------------------------
drivers/pci/controller/dwc/pcie-designware.h    |  7 -----
drivers/pci/controller/dwc/pcie-dw-rockchip.c   |  4 +--
3 files changed, 1 insertion(+), 49 deletions(-)
[PATCH] PCI: dwc: Remove duplicate dw_pcie_ep_hide_ext_capability() function
Posted by Qiang Yu 1 month, 2 weeks ago
Remove dw_pcie_ep_hide_ext_capability() and replace its usage with
dw_pcie_remove_ext_capability(). Both functions serve the same purpose
of hiding PCIe extended capabilities, but dw_pcie_remove_ext_capability()
provides a cleaner API that doesn't require the caller to specify the
previous capability ID.

Compile-tested only. Runtime testing on RK3588 hardware would be
appreciated.

Suggested-by: Niklas Cassel <cassel@kernel.org>
Signed-off-by: Qiang Yu <qiang.yu@oss.qualcomm.com>
---
 drivers/pci/controller/dwc/pcie-designware-ep.c | 39 -------------------------
 drivers/pci/controller/dwc/pcie-designware.h    |  7 -----
 drivers/pci/controller/dwc/pcie-dw-rockchip.c   |  4 +--
 3 files changed, 1 insertion(+), 49 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
index 1195d401df19eafbab2fb267f5cda3c24ecdfbd1..cfd59899c7b85fd0dddc9c6ce6b9c9fed84ad7a3 100644
--- a/drivers/pci/controller/dwc/pcie-designware-ep.c
+++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
@@ -75,45 +75,6 @@ static u8 dw_pcie_ep_find_capability(struct dw_pcie_ep *ep, u8 func_no, u8 cap)
 				 cap, NULL, ep, func_no);
 }
 
-/**
- * dw_pcie_ep_hide_ext_capability - Hide a capability from the linked list
- * @pci: DWC PCI device
- * @prev_cap: Capability preceding the capability that should be hidden
- * @cap: Capability that should be hidden
- *
- * Return: 0 if success, errno otherwise.
- */
-int dw_pcie_ep_hide_ext_capability(struct dw_pcie *pci, u8 prev_cap, u8 cap)
-{
-	u16 prev_cap_offset, cap_offset;
-	u32 prev_cap_header, cap_header;
-
-	prev_cap_offset = dw_pcie_find_ext_capability(pci, prev_cap);
-	if (!prev_cap_offset)
-		return -EINVAL;
-
-	prev_cap_header = dw_pcie_readl_dbi(pci, prev_cap_offset);
-	cap_offset = PCI_EXT_CAP_NEXT(prev_cap_header);
-	cap_header = dw_pcie_readl_dbi(pci, cap_offset);
-
-	/* cap must immediately follow prev_cap. */
-	if (PCI_EXT_CAP_ID(cap_header) != cap)
-		return -EINVAL;
-
-	/* Clear next ptr. */
-	prev_cap_header &= ~GENMASK(31, 20);
-
-	/* Set next ptr to next ptr of cap. */
-	prev_cap_header |= cap_header & GENMASK(31, 20);
-
-	dw_pcie_dbi_ro_wr_en(pci);
-	dw_pcie_writel_dbi(pci, prev_cap_offset, prev_cap_header);
-	dw_pcie_dbi_ro_wr_dis(pci);
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(dw_pcie_ep_hide_ext_capability);
-
 static int dw_pcie_ep_write_header(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
 				   struct pci_epf_header *hdr)
 {
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index 3a81d46e60b00f7cb92d9634eba6708244bce976..c5fff03073ea3945a5c38b1626838c6a67d21c57 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -909,7 +909,6 @@ int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no,
 int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep, u8 func_no,
 				       u16 interrupt_num);
 void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar);
-int dw_pcie_ep_hide_ext_capability(struct dw_pcie *pci, u8 prev_cap, u8 cap);
 struct dw_pcie_ep_func *
 dw_pcie_ep_get_func_from_ep(struct dw_pcie_ep *ep, u8 func_no);
 #else
@@ -967,12 +966,6 @@ static inline void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar)
 {
 }
 
-static inline int dw_pcie_ep_hide_ext_capability(struct dw_pcie *pci,
-						 u8 prev_cap, u8 cap)
-{
-	return 0;
-}
-
 static inline struct dw_pcie_ep_func *
 dw_pcie_ep_get_func_from_ep(struct dw_pcie_ep *ep, u8 func_no)
 {
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index 352f513ebf0363ff0ec79fdd8d8b245eeb28474c..77c4e6a4ddead91fe12eb6c727e77350207ef5fa 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -347,9 +347,7 @@ static void rockchip_pcie_ep_hide_broken_ats_cap_rk3588(struct dw_pcie_ep *ep)
 	if (!of_device_is_compatible(dev->of_node, "rockchip,rk3588-pcie-ep"))
 		return;
 
-	if (dw_pcie_ep_hide_ext_capability(pci, PCI_EXT_CAP_ID_SECPCI,
-					   PCI_EXT_CAP_ID_ATS))
-		dev_err(dev, "failed to hide ATS capability\n");
+	dw_pcie_remove_ext_capability(pci, PCI_EXT_CAP_ID_ATS);
 }
 
 static void rockchip_pcie_ep_init(struct dw_pcie_ep *ep)

---
base-commit: 37781eb814e16c75abb78dec2f9412d2e4d88298
change-id: 20251224-remove_dw_pcie_ep_hide_ext_capability-3dba1507a331

Best regards,
-- 
Qiang Yu <qiang.yu@oss.qualcomm.com>
Re: [PATCH] PCI: dwc: Remove duplicate dw_pcie_ep_hide_ext_capability() function
Posted by Manivannan Sadhasivam 2 weeks, 5 days ago
On Wed, 24 Dec 2025 02:10:46 -0800, Qiang Yu wrote:
> Remove dw_pcie_ep_hide_ext_capability() and replace its usage with
> dw_pcie_remove_ext_capability(). Both functions serve the same purpose
> of hiding PCIe extended capabilities, but dw_pcie_remove_ext_capability()
> provides a cleaner API that doesn't require the caller to specify the
> previous capability ID.
> 
> Compile-tested only. Runtime testing on RK3588 hardware would be
> appreciated.
> 
> [...]

Applied, thanks!

[1/1] PCI: dwc: Remove duplicate dw_pcie_ep_hide_ext_capability() function
      commit: 86291f774fe8524178446cb2c792939640b4970c

Best regards,
-- 
Manivannan Sadhasivam <mani@kernel.org>
Re: [PATCH] PCI: dwc: Remove duplicate dw_pcie_ep_hide_ext_capability() function
Posted by Niklas Cassel 1 month, 1 week ago
Hello Qiang Yu,

On Wed, Dec 24, 2025 at 02:10:46AM -0800, Qiang Yu wrote:
> Remove dw_pcie_ep_hide_ext_capability() and replace its usage with
> dw_pcie_remove_ext_capability(). Both functions serve the same purpose
> of hiding PCIe extended capabilities, but dw_pcie_remove_ext_capability()
> provides a cleaner API that doesn't require the caller to specify the
> previous capability ID.
> 
> Compile-tested only. Runtime testing on RK3588 hardware would be
> appreciated.

This patch does not appy on top of pci/controller/dwc

Anyway, I applied it manually, and tested, thus:
Tested-by: Niklas Cassel <cassel@kernel.org>
Re: [PATCH] PCI: dwc: Remove duplicate dw_pcie_ep_hide_ext_capability() function
Posted by Niklas Cassel 2 weeks, 5 days ago
On Tue, Dec 30, 2025 at 03:22:39PM +0100, Niklas Cassel wrote:
> Hello Qiang Yu,
> 
> On Wed, Dec 24, 2025 at 02:10:46AM -0800, Qiang Yu wrote:
> > Remove dw_pcie_ep_hide_ext_capability() and replace its usage with
> > dw_pcie_remove_ext_capability(). Both functions serve the same purpose
> > of hiding PCIe extended capabilities, but dw_pcie_remove_ext_capability()
> > provides a cleaner API that doesn't require the caller to specify the
> > previous capability ID.
> > 
> > Compile-tested only. Runtime testing on RK3588 hardware would be
> > appreciated.
> 
> This patch does not appy on top of pci/controller/dwc
> 
> Anyway, I applied it manually, and tested, thus:
> Tested-by: Niklas Cassel <cassel@kernel.org>

I just tried to apply this patch for pci/controller/dwc and right now,
this patch does apply.

Mani, any chance to get this picked up?


Kind regards,
Niklas
Re: [PATCH] PCI: dwc: Remove duplicate dw_pcie_ep_hide_ext_capability() function
Posted by Manivannan Sadhasivam 2 weeks, 5 days ago
On Wed, Jan 21, 2026 at 11:13:12AM +0100, Niklas Cassel wrote:
> On Tue, Dec 30, 2025 at 03:22:39PM +0100, Niklas Cassel wrote:
> > Hello Qiang Yu,
> > 
> > On Wed, Dec 24, 2025 at 02:10:46AM -0800, Qiang Yu wrote:
> > > Remove dw_pcie_ep_hide_ext_capability() and replace its usage with
> > > dw_pcie_remove_ext_capability(). Both functions serve the same purpose
> > > of hiding PCIe extended capabilities, but dw_pcie_remove_ext_capability()
> > > provides a cleaner API that doesn't require the caller to specify the
> > > previous capability ID.
> > > 
> > > Compile-tested only. Runtime testing on RK3588 hardware would be
> > > appreciated.
> > 
> > This patch does not appy on top of pci/controller/dwc
> > 
> > Anyway, I applied it manually, and tested, thus:
> > Tested-by: Niklas Cassel <cassel@kernel.org>
> 
> I just tried to apply this patch for pci/controller/dwc and right now,
> this patch does apply.
> 
> Mani, any chance to get this picked up?
> 

Qiang was supposed to submit a series addressing a few more issues pointed
by Bjorn. Since you reported that this patch didn't apply on top of
controller/dwc, I didn't apply it.

But now did, thanks!

- Mani

-- 
மணிவண்ணன் சதாசிவம்