]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
PCI: designware-ep: Fix the Header Type check
authorHou Zhiqiang <Zhiqiang.Hou@nxp.com>
Tue, 18 Aug 2020 09:27:46 +0000 (17:27 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 09:08:04 +0000 (10:08 +0100)
[ Upstream commit 16270a92355722e387e9ca19627c5a4d7bae1354 ]

The current check will result in the multiple function device
fails to initialize. So fix the check by masking out the
multiple function bit.

Link: https://lore.kernel.org/r/20200818092746.24366-1-Zhiqiang.Hou@nxp.com
Fixes: 0b24134f7888 ("PCI: dwc: Add validation that PCIe core is set to correct mode")
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pci/controller/dwc/pcie-designware-ep.c
include/uapi/linux/pci_regs.h

index 5e5b8821bed8cec22fbc7e77c7198850cc22fcc8..ce1c00ea5fdcab326090adb157bcf62a9e945e14 100644 (file)
@@ -505,7 +505,8 @@ int dw_pcie_ep_init_complete(struct dw_pcie_ep *ep)
        u32 reg;
        int i;
 
-       hdr_type = dw_pcie_readb_dbi(pci, PCI_HEADER_TYPE);
+       hdr_type = dw_pcie_readb_dbi(pci, PCI_HEADER_TYPE) &
+                  PCI_HEADER_TYPE_MASK;
        if (hdr_type != PCI_HEADER_TYPE_NORMAL) {
                dev_err(pci->dev,
                        "PCIe controller is not set to EP mode (hdr_type:0x%x)!\n",
index f9701410d3b52b7cfc549c50f08ab5478e04e385..57a222014cd20286aad93347404a07cfab708764 100644 (file)
@@ -76,6 +76,7 @@
 #define PCI_CACHE_LINE_SIZE    0x0c    /* 8 bits */
 #define PCI_LATENCY_TIMER      0x0d    /* 8 bits */
 #define PCI_HEADER_TYPE                0x0e    /* 8 bits */
+#define  PCI_HEADER_TYPE_MASK          0x7f
 #define  PCI_HEADER_TYPE_NORMAL                0
 #define  PCI_HEADER_TYPE_BRIDGE                1
 #define  PCI_HEADER_TYPE_CARDBUS       2