Skip to contentSkip to conversation

PCI: designware-ep: Fix the Header Type check

PATCH Applied Zhiqiang Hou 3 participants 4 messages Aug 18, 2020 – Sep 7, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 PCI: designware-ep: Fix the Header Type check

From: Hou Zhiqiang <[email protected]>

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

Fixes 0b24134f7888 ("PCI: dwc: Add validation that PCIe core is set to correct mode")

---
V2:
- Add marco PCI_HEADER_TYPE_MASK and print the masked value.

 drivers/pci/controller/dwc/pcie-designware-ep.c | 3 ++-
 include/uapi/linux/pci_regs.h                   | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-designware-ep.c +2 -1
index 4680a51c49c0..0634bd3a0b96 100644
@@ -653,7 +653,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",
include/uapi/linux/pci_regs.h +1 -0
index f9701410d3b5..57a222014cd2 100644
@@ -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
Signature · 1 line
2.17.1
reviewer Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Zhiqiang Hou

From: Hou Zhiqiang <[email protected]>

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

Fixes 0b24134f7888 ("PCI: dwc: Add validation that PCIe core is set to correct mode")
Quoted 7 lines

---
V2:
- Add marco PCI_HEADER_TYPE_MASK and print the masked value.

 drivers/pci/controller/dwc/pcie-designware-ep.c | 3 ++-
 include/uapi/linux/pci_regs.h                   | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
author
#2 lore raw

Hi Rob,

Thanks a lot for your review!

Regards,
Zhiqiang

Quoted 31 lines

-----Original Message-----
From: Rob Herring <[email protected]>
Sent: 2020年8月18日 21:52
To: Z.q. Hou <[email protected]>
Cc: [email protected]; PCI <[email protected]>; Lorenzo Pieralisi <[email protected]>; Bjorn Helgaas <[email protected]>; Andrew Murray <[email protected]>; Jingoo Han <[email protected]>; Gustavo Pimentel <[email protected]>
Subject: Re: [PATCHv2] PCI: designware-ep: Fix the Header Type check

Quoted 8 lines · Zhiqiang Hou

From: Hou Zhiqiang <[email protected]>

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

Fixes 0b24134f7888 ("PCI: dwc: Add validation that PCIe core is set

to correct mode")

Quoted 8 lines

---
V2:
- Add marco PCI_HEADER_TYPE_MASK and print the masked value.

 drivers/pci/controller/dwc/pcie-designware-ep.c | 3 ++-
 include/uapi/linux/pci_regs.h                   | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
#3 lore raw
In reply to Zhiqiang Hou
Quoted 8 lines · Zhiqiang Hou

From: Hou Zhiqiang <[email protected]>

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

Fixes 0b24134f7888 ("PCI: dwc: Add validation that PCIe core is set to correct mode")
Quoted 7 lines

---
V2:
- Add marco PCI_HEADER_TYPE_MASK and print the masked value.

 drivers/pci/controller/dwc/pcie-designware-ep.c | 3 ++-
 include/uapi/linux/pci_regs.h                   | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

Applied to pci/dwc, thanks.

Lorenzo

Quoted 29 lines
drivers/pci/controller/dwc/pcie-designware-ep.c +2 -1
index 4680a51c49c0..0634bd3a0b96 100644
@@ -653,7 +653,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",
include/uapi/linux/pci_regs.h +1 -0
index f9701410d3b5..57a222014cd2 100644
@@ -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
Signature · 1 line
2.17.1