Skip to contentSkip to conversation

x86: Use PCI_HEADER_TYPE_* instead of literals

PATCH Applied Ilpo Järvinen 7 participants 16 messages Nov 24, 2023 – Dec 6, 2023

Subsystems (8)
x86 SCSI PowerPC PCI +4 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/6 x86: Use PCI_HEADER_TYPE_* instead of literals

Replace 0x7f and 0x80 literals with PCI_HEADER_TYPE_* defines.

---
 arch/x86/kernel/aperture_64.c  | 3 +--
 arch/x86/kernel/early-quirks.c | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)
arch/x86/kernel/aperture_64.c +1 -2
index 4feaa670d578..89c0c8a3fc7e 100644
@@ -259,10 +259,9 @@ static u32 __init search_agp_bridge(u32 *order, int *valid_agp)
 							order);
 				}
 
-				/* No multi-function device? */
 				type = read_pci_config_byte(bus, slot, func,
 							       PCI_HEADER_TYPE);
-				if (!(type & 0x80))
+				if (!(type & PCI_HEADER_TYPE_MFD))
 					break;
 			}
 		}
arch/x86/kernel/early-quirks.c +2 -2
index a6c1867fc7aa..59f4aefc6bc1 100644
@@ -779,13 +779,13 @@ static int __init check_dev_quirk(int num, int slot, int func)
 	type = read_pci_config_byte(num, slot, func,
 				    PCI_HEADER_TYPE);
 
-	if ((type & 0x7f) == PCI_HEADER_TYPE_BRIDGE) {
+	if ((type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
 		sec = read_pci_config_byte(num, slot, func, PCI_SECONDARY_BUS);
 		if (sec > num)
 			early_pci_scan_bus(sec);
 	}
 
-	if (!(type & 0x80))
+	if (!(type & PCI_HEADER_TYPE_MFD))
 		return -1;
 
 	return 0;
Signature · 1 line
2.30.2
#1 lore raw

PATCH 2/6 powerpc/fsl-pci: Use PCI_HEADER_TYPE_MASK instead of literal

Replace 0x7f literals with PCI_HEADER_TYPE_MASK.

---
 arch/powerpc/sysdev/fsl_pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/sysdev/fsl_pci.c +2 -2
index 3868483fbe29..ef7707ea0db7 100644
@@ -54,7 +54,7 @@ static void quirk_fsl_pcie_early(struct pci_dev *dev)
 
 	/* if we aren't in host mode don't bother */
 	pci_read_config_byte(dev, PCI_HEADER_TYPE, &hdr_type);
-	if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE)
+	if ((hdr_type & PCI_HEADER_TYPE_MASK) != PCI_HEADER_TYPE_BRIDGE)
 		return;
 
 	dev->class = PCI_CLASS_BRIDGE_PCI_NORMAL;
@@ -581,7 +581,7 @@ static int fsl_add_bridge(struct platform_device *pdev, int is_primary)
 		hose->ops = &fsl_indirect_pcie_ops;
 		/* For PCIE read HEADER_TYPE to identify controller mode */
 		early_read_config_byte(hose, 0, 0, PCI_HEADER_TYPE, &hdr_type);
-		if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE)
+		if ((hdr_type & PCI_HEADER_TYPE_MASK) != PCI_HEADER_TYPE_BRIDGE)
 			goto no_bridge;
 
 	} else {
Signature · 1 line
2.30.2
#2 lore raw

PATCH 3/6 xtensa: Use PCI_HEADER_TYPE_MFD instead of literal

In reply to Ilpo Järvinen

Replace literal 0x80 with PCI_HEADER_TYPE_MFD. While at it, convert found_multi into boolean.

---
 arch/xtensa/lib/pci-auto.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
arch/xtensa/lib/pci-auto.c +5 -3
index aa6752237985..05fc02f9e1c7 100644
@@ -11,6 +11,7 @@
  * Based on work from Matt Porter <[email protected]>
  */
 
+#include <linux/bitfield.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/pci.h>
@@ -222,10 +223,11 @@ pciauto_postscan_setup_bridge(struct pci_dev *dev, int current_bus, int sub_bus,
 
 int __init pciauto_bus_scan(struct pci_controller *pci_ctrl, int current_bus)
 {
-	int sub_bus, pci_devfn, pci_class, cmdstat, found_multi=0;
+	int sub_bus, pci_devfn, pci_class, cmdstat;
 	unsigned short vid;
 	unsigned char header_type;
 	struct pci_dev *dev = &pciauto_dev;
+	bool found_multi = false;
 
 	pciauto_dev.bus = &pciauto_bus;
 	pciauto_dev.sysdata = pci_ctrl;
@@ -261,11 +263,11 @@ int __init pciauto_bus_scan(struct pci_controller *pci_ctrl, int current_bus)
 			continue;
 
 		if (!PCI_FUNC(pci_devfn))
-			found_multi = header_type & 0x80;
+			found_multi = FIELD_GET(PCI_HEADER_TYPE_MFD, header_type);
 		pci_read_config_word(dev, PCI_VENDOR_ID, &vid);
 
 		if (vid == 0xffff || vid == 0x0000) {
-			found_multi = 0;
+			found_multi = false;
 			continue;
 		}
 
Signature · 1 line
2.30.2
maintainer
#3 lore raw

Re: [PATCH 3/6] xtensa: Use PCI_HEADER_TYPE_MFD instead of literal

Quoted 8 lines · Ilpo Järvinen

Replace literal 0x80 with PCI_HEADER_TYPE_MFD. While at it, convert found_multi into boolean.

---
 arch/xtensa/lib/pci-auto.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Thanks. Applied to my xtensa tree.

Signature · 2 lines
Thanks.
-- Max
#4 lore raw

PATCH 4/6 scsi: lpfc: Use PCI_HEADER_TYPE_MFD instead of literal

In reply to Ilpo Järvinen

Replace literal 0x80 with PCI_HEADER_TYPE_MFD.

---
 drivers/scsi/lpfc/lpfc_sli.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_sli.c +1 -1
index 9386e7b44750..4ac6afd3c2fe 100644
@@ -4875,7 +4875,7 @@ void lpfc_reset_barrier(struct lpfc_hba *phba)
 	lockdep_assert_held(&phba->hbalock);
 
 	pci_read_config_byte(phba->pcidev, PCI_HEADER_TYPE, &hdrtype);
-	if (hdrtype != 0x80 ||
+	if (hdrtype != PCI_HEADER_TYPE_MFD ||
 	    (FC_JEDEC_ID(phba->vpd.rev.biuRev) != HELIOS_JEDEC_ID &&
 	     FC_JEDEC_ID(phba->vpd.rev.biuRev) != THOR_JEDEC_ID))
 		return;
Signature · 1 line
2.30.2
#5 lore raw

Re: [PATCH 4/6] scsi: lpfc: Use PCI_HEADER_TYPE_MFD instead of literal

Ilpo,

Quoted 1 line

Replace literal 0x80 with PCI_HEADER_TYPE_MFD.

Applied to 6.8/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#6 lore raw

PATCH 5/6 EDAC: Use PCI_HEADER_TYPE_MASK instead of literals

In reply to Ilpo Järvinen

Replace literal 0x7f with PCI_HEADER_TYPE_MASK.

---
 drivers/edac/edac_pci_sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/edac/edac_pci_sysfs.c +2 -2
index 287cc51dbc86..901d4cd3ca38 100644
@@ -521,7 +521,7 @@ static void edac_pci_dev_parity_clear(struct pci_dev *dev)
 	/* read the device TYPE, looking for bridges */
 	pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
 
-	if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE)
+	if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE)
 		get_pci_parity_status(dev, 1);
 }
 
@@ -583,7 +583,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
 	edac_dbg(4, "PCI HEADER TYPE= 0x%02x %s\n",
 		 header_type, dev_name(&dev->dev));
 
-	if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
+	if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
 		/* On bridges, need to examine secondary status register  */
 		status = get_pci_parity_status(dev, 1);
 
Signature · 1 line
2.30.2
maintainer Applied
#7 lore raw

Re: [PATCH 5/6] EDAC: Use PCI_HEADER_TYPE_MASK instead of literals

Quoted 6 lines · Ilpo Järvinen

Replace literal 0x7f with PCI_HEADER_TYPE_MASK.

---
 drivers/edac/edac_pci_sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#8 lore raw

PATCH 6/6 bcma: Use PCI_HEADER_TYPE_MASK instead of literal

In reply to Ilpo Järvinen

Replace literal 0x7f with PCI_HEADER_TYPE_MASK.

---
 drivers/bcma/driver_pci_host.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bcma/driver_pci_host.c +1 -1
index aa0581cda718..ed3be52ab63d 100644
@@ -280,7 +280,7 @@ static u8 bcma_find_pci_capability(struct bcma_drv_pci *pc, unsigned int dev,
 	/* check for Header type 0 */
 	bcma_extpci_read_config(pc, dev, func, PCI_HEADER_TYPE, &byte_val,
 				sizeof(u8));
-	if ((byte_val & 0x7F) != PCI_HEADER_TYPE_NORMAL)
+	if ((byte_val & PCI_HEADER_TYPE_MASK) != PCI_HEADER_TYPE_NORMAL)
 		return cap_ptr;
 
 	/* check if the capability pointer field exists */
Signature · 1 line
2.30.2
#9 lore raw

Re: [PATCH 6/6] bcma: Use PCI_HEADER_TYPE_MASK instead of literal

Quoted 3 lines · Ilpo Järvinen

Replace literal 0x7f with PCI_HEADER_TYPE_MASK.

I couldn't find the cover letter. Should I take this patch to wireless-next or do you have other plans for this?

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#10 lore raw

Re: [PATCH 6/6] bcma: Use PCI_HEADER_TYPE_MASK instead of literal

Quoted 8 lines · Kalle Valo
Quoted 3 lines · Ilpo Järvinen

Replace literal 0x7f with PCI_HEADER_TYPE_MASK.

I couldn't find the cover letter. Should I take this patch to wireless-next or do you have other plans for this?

Just take it through the normal trees, so in this case wireless-next. Thank you.

Signature · 1 line
 i.
#11 lore raw

Re: [PATCH 6/6] bcma: Use PCI_HEADER_TYPE_MASK instead of literal

In reply to Ilpo Järvinen
Quoted 3 lines · Ilpo Järvinen

Replace literal 0x7f with PCI_HEADER_TYPE_MASK.

Patch applied to wireless-next.git, thanks.

ac586b8401c9 bcma: Use PCI_HEADER_TYPE_MASK instead of literal

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#12 lore raw
In reply to Ilpo Järvinen
Quoted 3 lines · Ilpo Järvinen

Replace 0x7f and 0x80 literals with PCI_HEADER_TYPE_* defines.

Applied entire series on the PCI "enumeration" branch for v6.8, thanks!

If anybody wants to take pieces separately, let me know and I'll drop from PCI.

Quoted 44 lines
---
 arch/x86/kernel/aperture_64.c  | 3 +--
 arch/x86/kernel/early-quirks.c | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)
arch/x86/kernel/aperture_64.c +1 -2
index 4feaa670d578..89c0c8a3fc7e 100644
@@ -259,10 +259,9 @@ static u32 __init search_agp_bridge(u32 *order, int *valid_agp)
 							order);
 				}
 
-				/* No multi-function device? */
 				type = read_pci_config_byte(bus, slot, func,
 							       PCI_HEADER_TYPE);
-				if (!(type & 0x80))
+				if (!(type & PCI_HEADER_TYPE_MFD))
 					break;
 			}
 		}
arch/x86/kernel/early-quirks.c +2 -2
index a6c1867fc7aa..59f4aefc6bc1 100644
@@ -779,13 +779,13 @@ static int __init check_dev_quirk(int num, int slot, int func)
 	type = read_pci_config_byte(num, slot, func,
 				    PCI_HEADER_TYPE);
 
-	if ((type & 0x7f) == PCI_HEADER_TYPE_BRIDGE) {
+	if ((type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
 		sec = read_pci_config_byte(num, slot, func, PCI_SECONDARY_BUS);
 		if (sec > num)
 			early_pci_scan_bus(sec);
 	}
 
-	if (!(type & 0x80))
+	if (!(type & PCI_HEADER_TYPE_MFD))
 		return -1;
 
 	return 0;
Signature · 1 line
2.30.2
#13 lore raw

[+cc scsi, powerpc folks]

Quoted 10 lines · Bjorn Helgaas
Quoted 3 lines · Ilpo Järvinen

Replace 0x7f and 0x80 literals with PCI_HEADER_TYPE_* defines.

Applied entire series on the PCI "enumeration" branch for v6.8, thanks!

If anybody wants to take pieces separately, let me know and I'll drop from PCI.

OK, b4 picked up the entire series but I was only cc'd on this first patch, so I missed the responses about EDAC, xtensa, bcma already being applied elsewhere.

So I kept these in the PCI tree:

420ac76610d7 ("scsi: lpfc: Use PCI_HEADER_TYPE_MFD instead of literal") 3773343dd890 ("powerpc/fsl-pci: Use PCI_HEADER_TYPE_MASK instead of literal") 197e0da1f1a3 ("x86/pci: Use PCI_HEADER_TYPE_* instead of literals")

and dropped the others.

x86, SCSI, powerpc folks, if you want to take these instead, let me know and I'll drop them.

Quoted 44 lines
Quoted 44 lines
---
 arch/x86/kernel/aperture_64.c  | 3 +--
 arch/x86/kernel/early-quirks.c | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)
arch/x86/kernel/aperture_64.c +1 -2
index 4feaa670d578..89c0c8a3fc7e 100644
@@ -259,10 +259,9 @@ static u32 __init search_agp_bridge(u32 *order, int *valid_agp)
 							order);
 				}
 
-				/* No multi-function device? */
 				type = read_pci_config_byte(bus, slot, func,
 							       PCI_HEADER_TYPE);
-				if (!(type & 0x80))
+				if (!(type & PCI_HEADER_TYPE_MFD))
 					break;
 			}
 		}
arch/x86/kernel/early-quirks.c +2 -2
index a6c1867fc7aa..59f4aefc6bc1 100644
@@ -779,13 +779,13 @@ static int __init check_dev_quirk(int num, int slot, int func)
 	type = read_pci_config_byte(num, slot, func,
 				    PCI_HEADER_TYPE);
 
-	if ((type & 0x7f) == PCI_HEADER_TYPE_BRIDGE) {
+	if ((type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
 		sec = read_pci_config_byte(num, slot, func, PCI_SECONDARY_BUS);
 		if (sec > num)
 			early_pci_scan_bus(sec);
 	}
 
-	if (!(type & 0x80))
+	if (!(type & PCI_HEADER_TYPE_MFD))
 		return -1;
 
 	return 0;
Signature · 1 line
2.30.2
#14 lore raw
Quoted 20 lines · Bjorn Helgaas

[+cc scsi, powerpc folks]

Quoted 10 lines · Bjorn Helgaas
Quoted 3 lines · Ilpo Järvinen

Replace 0x7f and 0x80 literals with PCI_HEADER_TYPE_* defines.

Applied entire series on the PCI "enumeration" branch for v6.8, thanks!

If anybody wants to take pieces separately, let me know and I'll drop from PCI.

OK, b4 picked up the entire series but I was only cc'd on this first patch, so I missed the responses about EDAC, xtensa, bcma already being applied elsewhere.

So I kept these in the PCI tree:

Quoted 8 lines

420ac76610d7 ("scsi: lpfc: Use PCI_HEADER_TYPE_MFD instead of literal") 3773343dd890 ("powerpc/fsl-pci: Use PCI_HEADER_TYPE_MASK instead of literal") 197e0da1f1a3 ("x86/pci: Use PCI_HEADER_TYPE_* instead of literals")

and dropped the others.

x86, SCSI, powerpc folks, if you want to take these instead, let me know and I'll drop them.

Nah that's fine, you keep them.

cheers

#15 lore raw
In reply to Bjorn Helgaas

Bjorn,

Quoted 3 lines

So I kept these in the PCI tree:

420ac76610d7 ("scsi: lpfc: Use PCI_HEADER_TYPE_MFD instead of literal")

I merged this without seeing your note but I haven't pushed yet so I'll just drop the commit.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering