]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
PCI: cadence: Use cdns_pcie_read_sz() for byte or word read access
authorAksh Garg <a-garg7@ti.com>
Thu, 2 Apr 2026 08:55:45 +0000 (14:25 +0530)
committerManivannan Sadhasivam <mani@kernel.org>
Sat, 4 Apr 2026 17:25:27 +0000 (22:55 +0530)
The commit 18ac51ae9df9 ("PCI: cadence: Implement capability search
using PCI core APIs") assumed all the platforms using Cadence PCIe
controller support byte and word register accesses. This is not true
for all platforms (e.g., TI J721E SoC, which only supports dword
register accesses).

This causes capability searches via cdns_pcie_find_capability() to fail
on such platforms.

Fix this by using cdns_pcie_read_sz() for config read functions, which
properly handles size-aligned accesses. Remove the now-unused byte and
word read wrapper functions (cdns_pcie_readw and cdns_pcie_readb).

Fixes: 18ac51ae9df9 ("PCI: cadence: Implement capability search using PCI core APIs")
Signed-off-by: Aksh Garg <a-garg7@ti.com>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260402085545.284457-1-a-garg7@ti.com
drivers/pci/controller/cadence/pcie-cadence.h

index 443033c607d75212812711b76316a3172e03673b..277f3706a4f47fc1ca2d624ad5e1a4420a406b70 100644 (file)
@@ -249,37 +249,6 @@ static inline u32 cdns_pcie_hpa_readl(struct cdns_pcie *pcie,
        return readl(pcie->reg_base + reg);
 }
 
-static inline u16 cdns_pcie_readw(struct cdns_pcie *pcie, u32 reg)
-{
-       return readw(pcie->reg_base + reg);
-}
-
-static inline u8 cdns_pcie_readb(struct cdns_pcie *pcie, u32 reg)
-{
-       return readb(pcie->reg_base + reg);
-}
-
-static inline int cdns_pcie_read_cfg_byte(struct cdns_pcie *pcie, int where,
-                                         u8 *val)
-{
-       *val = cdns_pcie_readb(pcie, where);
-       return PCIBIOS_SUCCESSFUL;
-}
-
-static inline int cdns_pcie_read_cfg_word(struct cdns_pcie *pcie, int where,
-                                         u16 *val)
-{
-       *val = cdns_pcie_readw(pcie, where);
-       return PCIBIOS_SUCCESSFUL;
-}
-
-static inline int cdns_pcie_read_cfg_dword(struct cdns_pcie *pcie, int where,
-                                          u32 *val)
-{
-       *val = cdns_pcie_readl(pcie, where);
-       return PCIBIOS_SUCCESSFUL;
-}
-
 static inline u32 cdns_pcie_read_sz(void __iomem *addr, int size)
 {
        void __iomem *aligned_addr = PTR_ALIGN_DOWN(addr, 0x4);
@@ -320,6 +289,31 @@ static inline void cdns_pcie_write_sz(void __iomem *addr, int size, u32 value)
        writel(val, aligned_addr);
 }
 
+static inline int cdns_pcie_read_cfg_byte(struct cdns_pcie *pcie, int where,
+                                         u8 *val)
+{
+       void __iomem *addr = pcie->reg_base + where;
+
+       *val = cdns_pcie_read_sz(addr, 0x1);
+       return PCIBIOS_SUCCESSFUL;
+}
+
+static inline int cdns_pcie_read_cfg_word(struct cdns_pcie *pcie, int where,
+                                         u16 *val)
+{
+       void __iomem *addr = pcie->reg_base + where;
+
+       *val = cdns_pcie_read_sz(addr, 0x2);
+       return PCIBIOS_SUCCESSFUL;
+}
+
+static inline int cdns_pcie_read_cfg_dword(struct cdns_pcie *pcie, int where,
+                                          u32 *val)
+{
+       *val = cdns_pcie_readl(pcie, where);
+       return PCIBIOS_SUCCESSFUL;
+}
+
 /* Root Port register access */
 static inline void cdns_pcie_rp_writeb(struct cdns_pcie *pcie,
                                       u32 reg, u8 value)