Skip to contentSkip to conversation

hw: Use PCI macros from 'hw/pci/pci.h'

PATCH In review Philippe Mathieu-Daudé 6 participants 15 messages Oct 12, 2020 – Jan 4, 2021

lore
Share & tools
lore
#0 lore raw

cover hw: Use PCI macros from 'hw/pci/pci.h'

Trivial patches using the generic PCI macros from "hw/pci/pci.h".

Philippe Mathieu-Daudé (5):
hw/pci-host/bonito: Make PCI_ADDR() macro more readable hw/pci-host: Use the PCI_BUILD_BDF() macro from 'hw/pci/pci.h' hw/pci-host/uninorth: Use the PCI_FUNC() macro from 'hw/pci/pci.h'
hw: Use the PCI_SLOT() macro from 'hw/pci/pci.h'
hw: Use the PCI_DEVFN() macro from 'hw/pci/pci.h'

 hw/arm/virt.c          | 3 ++-
 hw/hppa/dino.c         | 2 +-
 hw/i386/xen/xen-hvm.c  | 2 +-
 hw/isa/piix3.c         | 2 +-
 hw/mips/gt64xxx_pci.c  | 2 +-
 hw/pci-host/bonito.c   | 5 ++---
 hw/pci-host/pnv_phb4.c | 2 +-
 hw/pci-host/ppce500.c  | 2 +-
 hw/pci-host/uninorth.c | 8 +++-----
 hw/ppc/ppc4xx_pci.c    | 2 +-
 hw/sh4/sh_pci.c        | 2 +-
 11 files changed, 15 insertions(+), 17 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/5 hw/pci-host/bonito: Make PCI_ADDR() macro more readable

From: Philippe Mathieu-Daudé <[email protected]>

The PCI_ADDR() macro use generic PCI fields shifted by 8-bit. Rewrite it extracting the shift operation one layer.

---
 hw/pci-host/bonito.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/pci-host/bonito.c +2 -2
index a99eced0657..abb3ee86769 100644
@@ -196,8 +196,8 @@ FIELD(BONGENCFG, PCIQUEUE,      12, 1)
 #define PCI_IDSEL_VIA686B          (1 << PCI_IDSEL_VIA686B_BIT)
 
 #define PCI_ADDR(busno , devno , funno , regno)  \
-    ((((busno) << 16) & 0xff0000) + (((devno) << 11) & 0xf800) + \
-    (((funno) << 8) & 0x700) + (regno))
+    ((((busno) << 8) & 0xff00) + (((devno) << 3) & 0xf8) + \
+    (((funno) & 0x7) << 8) + (regno))
 
 typedef struct BonitoState BonitoState;
 
Signature · 1 line
2.26.2
#2 lore raw

Re: [PATCH 1/5] hw/pci-host/bonito: Make PCI_ADDR() macro more readable

Quoted 15 lines · Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

The PCI_ADDR() macro use generic PCI fields shifted by 8-bit. Rewrite it extracting the shift operation one layer.

---
hw/pci-host/bonito.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
hw/pci-host/bonito.c +0 -0
index a99eced0657..abb3ee86769 100644

hw/pci-host/bonito.c FIELD(BONGENCFG, PCIQUEUE, 12, 1) · line 200

Quoted 7 lines
hw/pci-host/bonito.c +2 -2
@@ -196,8 +196,8 @@ FIELD(BONGENCFG, PCIQUEUE,      12, 1)
 #define PCI_IDSEL_VIA686B          (1 << PCI_IDSEL_VIA686B_BIT)
 
 #define PCI_ADDR(busno , devno , funno , regno)  \
-    ((((busno) << 16) & 0xff0000) + (((devno) << 11) & 0xf800) + \
-    (((funno) << 8) & 0x700) + (regno))
+    ((((busno) << 8) & 0xff00) + (((devno) << 3) & 0xf8) + \
+    (((funno) & 0x7) << 8) + (regno))

Are you missing a << 8 somewhere before + (regno) or both of these are equally unreadable and I've missed something? This seems to be completely replaced by next patch so what's the point of this change?

Regards,
BALATON Zoltan

Quoted 4 lines
hw/pci-host/bonito.c +0 -0
 typedef struct BonitoState BonitoState;
 
 
#3 lore raw

Re: [PATCH 1/5] hw/pci-host/bonito: Make PCI_ADDR() macro more readable

Quoted 18 lines · BALATON Zoltan
Quoted 17 lines · Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

The PCI_ADDR() macro use generic PCI fields shifted by 8-bit. Rewrite it extracting the shift operation one layer.

---
hw/pci-host/bonito.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
hw/pci-host/bonito.c +0 -0
index a99eced0657..abb3ee86769 100644
@@ -196,8 +196,8 @@ FIELD(BONGENCFG, PCIQUEUE,      12, 1)
 #define PCI_IDSEL_VIA686B          (1 << PCI_IDSEL_VIA686B_BIT)
 
Quoted 7 lines

hw/pci-host/bonito.c FIELD(BONGENCFG, PCIQUEUE, 12, 1) · line 200

Quoted 5 lines
hw/pci-host/bonito.c +2 -2
 #define PCI_ADDR(busno , devno , funno , regno)  \
-    ((((busno) << 16) & 0xff0000) + (((devno) << 11) & 0xf800) + \
-    (((funno) << 8) & 0x700) + (regno))
+    ((((busno) << 8) & 0xff00) + (((devno) << 3) & 0xf8) + \
+    (((funno) & 0x7) << 8) + (regno))

Are you missing a << 8 somewhere before + (regno) or both of these are equally unreadable and I've missed something? This seems to be completely replaced by next patch so what's the point of this change?

I might have missed a parenthesis somewhere indeed =)

I'm happy to merge it in the next patch, I thought it would be easier to review but it isn't.

Thanks for reviewing!

Quoted 8 lines

Regards,
BALATON Zoltan

Quoted 4 lines
hw/pci-host/bonito.c +0 -0
 typedef struct BonitoState BonitoState;
 
 
#4 lore raw

PATCH 2/5 hw/pci-host: Use the PCI_BUILD_BDF() macro from 'hw/pci/pci.h'

In reply to Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

We already have a generic PCI_BUILD_BDF() macro in "hw/pci/pci.h" to pack these values, use it.

---
 hw/pci-host/bonito.c   | 3 +--
 hw/pci-host/pnv_phb4.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)
hw/pci-host/bonito.c +1 -2
index abb3ee86769..b05295639a6 100644
@@ -196,8 +196,7 @@ FIELD(BONGENCFG, PCIQUEUE,      12, 1)
 #define PCI_IDSEL_VIA686B          (1 << PCI_IDSEL_VIA686B_BIT)
 
 #define PCI_ADDR(busno , devno , funno , regno)  \
-    ((((busno) << 8) & 0xff00) + (((devno) << 3) & 0xf8) + \
-    (((funno) & 0x7) << 8) + (regno))
+    ((PCI_BUILD_BDF(busno, PCI_DEVFN(devno , funno)) << 8) + (regno))
 
 typedef struct BonitoState BonitoState;
 
hw/pci-host/pnv_phb4.c +1 -1
index 03daf40a237..6328e985f81 100644
@@ -889,7 +889,7 @@ static bool pnv_phb4_resolve_pe(PnvPhb4DMASpace *ds)
     /* Read RTE */
     bus_num = pci_bus_num(ds->bus);
     addr = rtt & PHB_RTT_BASE_ADDRESS_MASK;
-    addr += 2 * ((bus_num << 8) | ds->devfn);
+    addr += 2 * PCI_BUILD_BDF(bus_num, ds->devfn);
     if (dma_memory_read(&address_space_memory, addr, &rte, sizeof(rte))) {
         phb_error(ds->phb, "Failed to read RTT entry at 0x%"PRIx64, addr);
         /* Set error bits ? fence ? ... */
Signature · 1 line
2.26.2
Acked-by on v1 2/5
#5 lore raw

Re: [PATCH 2/5] hw/pci-host: Use the PCI_BUILD_BDF() macro from 'hw/pci/pci.h'

Quoted 6 lines · Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

We already have a generic PCI_BUILD_BDF() macro in "hw/pci/pci.h" to pack these values, use it.

pnv part

Quoted 32 lines
---
 hw/pci-host/bonito.c   | 3 +--
 hw/pci-host/pnv_phb4.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)
hw/pci-host/bonito.c +1 -2
index abb3ee86769..b05295639a6 100644
@@ -196,8 +196,7 @@ FIELD(BONGENCFG, PCIQUEUE,      12, 1)
 #define PCI_IDSEL_VIA686B          (1 << PCI_IDSEL_VIA686B_BIT)
 
 #define PCI_ADDR(busno , devno , funno , regno)  \
-    ((((busno) << 8) & 0xff00) + (((devno) << 3) & 0xf8) + \
-    (((funno) & 0x7) << 8) + (regno))
+    ((PCI_BUILD_BDF(busno, PCI_DEVFN(devno , funno)) << 8) + (regno))
 
 typedef struct BonitoState BonitoState;
 
hw/pci-host/pnv_phb4.c +1 -1
index 03daf40a237..6328e985f81 100644
@@ -889,7 +889,7 @@ static bool pnv_phb4_resolve_pe(PnvPhb4DMASpace *ds)
     /* Read RTE */
     bus_num = pci_bus_num(ds->bus);
     addr = rtt & PHB_RTT_BASE_ADDRESS_MASK;
-    addr += 2 * ((bus_num << 8) | ds->devfn);
+    addr += 2 * PCI_BUILD_BDF(bus_num, ds->devfn);
     if (dma_memory_read(&address_space_memory, addr, &rte, sizeof(rte))) {
         phb_error(ds->phb, "Failed to read RTT entry at 0x%"PRIx64, addr);
         /* Set error bits ? fence ? ... */
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#6 lore raw

PATCH 3/5 hw/pci-host/uninorth: Use the PCI_FUNC() macro from 'hw/pci/pci.h'

In reply to Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

We already have a generic PCI_FUNC() macro in "hw/pci/pci.h" to extract the PCI function identifier, use it.

---
 hw/pci-host/uninorth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci-host/uninorth.c +1 -1
index 1ed1072eeb5..c21de0ab805 100644
@@ -65,7 +65,7 @@ static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr)
         if (slot == 32) {
             slot = -1; /* XXX: should this be 0? */
         }
-        func = (reg >> 8) & 7;
+        func = PCI_FUNC(reg >> 8);
 
         /* ... and then convert them to x86 format */
         /* config pointer */
Signature · 1 line
2.26.2
Acked-by on v1 3/5
#7 lore raw

Re: [PATCH 3/5] hw/pci-host/uninorth: Use the PCI_FUNC() macro from 'hw/pci/pci.h'

Quoted 6 lines · Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

We already have a generic PCI_FUNC() macro in "hw/pci/pci.h" to extract the PCI function identifier, use it.

Quoted 17 lines
---
 hw/pci-host/uninorth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci-host/uninorth.c +1 -1
index 1ed1072eeb5..c21de0ab805 100644
@@ -65,7 +65,7 @@ static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr)
         if (slot == 32) {
             slot = -1; /* XXX: should this be 0? */
         }
-        func = (reg >> 8) & 7;
+        func = PCI_FUNC(reg >> 8);
 
         /* ... and then convert them to x86 format */
         /* config pointer */
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#8 lore raw

PATCH 4/5 hw: Use the PCI_SLOT() macro from 'hw/pci/pci.h'

In reply to Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

We already have a generic PCI_SLOT() macro in "hw/pci/pci.h" to extract the PCI slot identifier, use it.

---
 hw/hppa/dino.c        | 2 +-
 hw/i386/xen/xen-hvm.c | 2 +-
 hw/isa/piix3.c        | 2 +-
 hw/mips/gt64xxx_pci.c | 2 +-
 hw/pci-host/bonito.c  | 2 +-
 hw/pci-host/ppce500.c | 2 +-
 hw/ppc/ppc4xx_pci.c   | 2 +-
 hw/sh4/sh_pci.c       | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)
hw/hppa/dino.c +1 -1
index 81053b5fb64..5b82c9440d1 100644
@@ -496,7 +496,7 @@ static void dino_set_irq(void *opaque, int irq, int level)
 
 static int dino_pci_map_irq(PCIDevice *d, int irq_num)
 {
-    int slot = d->devfn >> 3;
+    int slot = PCI_SLOT(d->devfn);
 
     assert(irq_num >= 0 && irq_num <= 3);
 
hw/i386/xen/xen-hvm.c +1 -1
index f3ababf33b6..276254e6ca9 100644
@@ -140,7 +140,7 @@ typedef struct XenIOState {
 
 int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
 {
-    return irq_num + ((pci_dev->devfn >> 3) << 2);
+    return irq_num + (PCI_SLOT(pci_dev->devfn) << 2);
 }
 
 void xen_piix3_set_irq(void *opaque, int irq_num, int level)
hw/isa/piix3.c +1 -1
index 587850b8881..f46ccae25cf 100644
@@ -361,7 +361,7 @@ type_init(piix3_register_types)
 static int pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx)
 {
     int slot_addend;
-    slot_addend = (pci_dev->devfn >> 3) - 1;
+    slot_addend = PCI_SLOT(pci_dev->devfn) - 1;
     return (pci_intx + slot_addend) & 3;
 }
 
hw/mips/gt64xxx_pci.c +1 -1
index e091bc4ed55..588e6f99301 100644
@@ -982,7 +982,7 @@ static int gt64120_pci_map_irq(PCIDevice *pci_dev, int irq_num)
 {
     int slot;
 
-    slot = (pci_dev->devfn >> 3);
+    slot = PCI_SLOT(pci_dev->devfn);
 
     switch (slot) {
     /* PIIX4 USB */
hw/pci-host/bonito.c +1 -1
index b05295639a6..ee8b193e15b 100644
@@ -570,7 +570,7 @@ static int pci_bonito_map_irq(PCIDevice *pci_dev, int irq_num)
 {
     int slot;
 
-    slot = (pci_dev->devfn >> 3);
+    slot = PCI_SLOT(pci_dev->devfn);
 
     switch (slot) {
     case 5:   /* FULOONG2E_VIA_SLOT, SouthBridge, IDE, USB, ACPI, AC97, MC97 */
hw/pci-host/ppce500.c +1 -1
index 9517aab913e..5ad1424b31a 100644
@@ -342,7 +342,7 @@ static const MemoryRegionOps e500_pci_reg_ops = {
 
 static int mpc85xx_pci_map_irq(PCIDevice *pci_dev, int pin)
 {
-    int devno = pci_dev->devfn >> 3;
+    int devno = PCI_SLOT(pci_dev->devfn);
     int ret;
 
     ret = ppce500_pci_map_irq_slot(devno, pin);
hw/ppc/ppc4xx_pci.c +1 -1
index 28724c06f88..e8789f64e80 100644
@@ -243,7 +243,7 @@ static void ppc4xx_pci_reset(void *opaque)
  * may need further refactoring for other boards. */
 static int ppc4xx_pci_map_irq(PCIDevice *pci_dev, int irq_num)
 {
-    int slot = pci_dev->devfn >> 3;
+    int slot = PCI_SLOT(pci_dev->devfn);
 
     trace_ppc4xx_pci_map_irq(pci_dev->devfn, irq_num, slot);
 
hw/sh4/sh_pci.c +1 -1
index 73d2d0bccb0..734892f47c7 100644
@@ -109,7 +109,7 @@ static const MemoryRegionOps sh_pci_reg_ops = {
 
 static int sh_pci_map_irq(PCIDevice *d, int irq_num)
 {
-    return (d->devfn >> 3);
+    return PCI_SLOT(d->devfn);
 }
 
 static void sh_pci_set_irq(void *opaque, int irq_num, int level)
Signature · 1 line
2.26.2
Acked-by on v1 4/5
#9 lore raw

RE: [PATCH 4/5] hw: Use the PCI_SLOT() macro from 'hw/pci/pci.h'

Quoted 16 lines

-----Original Message-----
From: Philippe Mathieu-Daudé <[email protected]>
Sent: 12 October 2020 13:45
To: [email protected]
Cc: Peter Maydell <[email protected]>; [email protected]; [email protected]; Paul Durrant <[email protected]>; Aurelien Jarno <[email protected]>; [email protected]; Philippe Mathieu- Daudé <[email protected]>; Michael S. Tsirkin <[email protected]>; Eduardo Habkost <[email protected]>; Jiaxun Yang <[email protected]>; Yoshinori Sato <[email protected]>; Cédric Le Goater <[email protected]>; David Gibson <[email protected]>; Stefano Stabellini <[email protected]>; Helge Deller <[email protected]>; Anthony Perard <[email protected]>; Richard Henderson <[email protected]>; Aleksandar Markovic <[email protected]>; xen- [email protected]; Aleksandar Rikalo <[email protected]>; Marcel Apfelbaum <[email protected]>; Mark Cave-Ayland <[email protected]>; Paolo Bonzini <[email protected]>; Huacai Chen <[email protected]>
Subject: [PATCH 4/5] hw: Use the PCI_SLOT() macro from 'hw/pci/pci.h'

Quoted 6 lines

From: Philippe Mathieu-Daudé <[email protected]>

We already have a generic PCI_SLOT() macro in "hw/pci/pci.h" to extract the PCI slot identifier, use it.

xen-hvm change...

Acked-by on v1 4/5
#10 lore raw

Re: [PATCH 4/5] hw: Use the PCI_SLOT() macro from 'hw/pci/pci.h'

In reply to Philippe Mathieu-Daudé
Quoted 6 lines · Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

We already have a generic PCI_SLOT() macro in "hw/pci/pci.h" to extract the PCI slot identifier, use it.

ppc parts

Quoted 115 lines
---
 hw/hppa/dino.c        | 2 +-
 hw/i386/xen/xen-hvm.c | 2 +-
 hw/isa/piix3.c        | 2 +-
 hw/mips/gt64xxx_pci.c | 2 +-
 hw/pci-host/bonito.c  | 2 +-
 hw/pci-host/ppce500.c | 2 +-
 hw/ppc/ppc4xx_pci.c   | 2 +-
 hw/sh4/sh_pci.c       | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)
hw/hppa/dino.c +1 -1
index 81053b5fb64..5b82c9440d1 100644
@@ -496,7 +496,7 @@ static void dino_set_irq(void *opaque, int irq, int level)
 
 static int dino_pci_map_irq(PCIDevice *d, int irq_num)
 {
-    int slot = d->devfn >> 3;
+    int slot = PCI_SLOT(d->devfn);
 
     assert(irq_num >= 0 && irq_num <= 3);
 
hw/i386/xen/xen-hvm.c +1 -1
index f3ababf33b6..276254e6ca9 100644
@@ -140,7 +140,7 @@ typedef struct XenIOState {
 
 int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
 {
-    return irq_num + ((pci_dev->devfn >> 3) << 2);
+    return irq_num + (PCI_SLOT(pci_dev->devfn) << 2);
 }
 
 void xen_piix3_set_irq(void *opaque, int irq_num, int level)
hw/isa/piix3.c +1 -1
index 587850b8881..f46ccae25cf 100644
@@ -361,7 +361,7 @@ type_init(piix3_register_types)
 static int pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx)
 {
     int slot_addend;
-    slot_addend = (pci_dev->devfn >> 3) - 1;
+    slot_addend = PCI_SLOT(pci_dev->devfn) - 1;
     return (pci_intx + slot_addend) & 3;
 }
 
hw/mips/gt64xxx_pci.c +1 -1
index e091bc4ed55..588e6f99301 100644
@@ -982,7 +982,7 @@ static int gt64120_pci_map_irq(PCIDevice *pci_dev, int irq_num)
 {
     int slot;
 
-    slot = (pci_dev->devfn >> 3);
+    slot = PCI_SLOT(pci_dev->devfn);
 
     switch (slot) {
     /* PIIX4 USB */
hw/pci-host/bonito.c +1 -1
index b05295639a6..ee8b193e15b 100644
@@ -570,7 +570,7 @@ static int pci_bonito_map_irq(PCIDevice *pci_dev, int irq_num)
 {
     int slot;
 
-    slot = (pci_dev->devfn >> 3);
+    slot = PCI_SLOT(pci_dev->devfn);
 
     switch (slot) {
     case 5:   /* FULOONG2E_VIA_SLOT, SouthBridge, IDE, USB, ACPI, AC97, MC97 */
hw/pci-host/ppce500.c +1 -1
index 9517aab913e..5ad1424b31a 100644
@@ -342,7 +342,7 @@ static const MemoryRegionOps e500_pci_reg_ops = {
 
 static int mpc85xx_pci_map_irq(PCIDevice *pci_dev, int pin)
 {
-    int devno = pci_dev->devfn >> 3;
+    int devno = PCI_SLOT(pci_dev->devfn);
     int ret;
 
     ret = ppce500_pci_map_irq_slot(devno, pin);
hw/ppc/ppc4xx_pci.c +1 -1
index 28724c06f88..e8789f64e80 100644
@@ -243,7 +243,7 @@ static void ppc4xx_pci_reset(void *opaque)
  * may need further refactoring for other boards. */
 static int ppc4xx_pci_map_irq(PCIDevice *pci_dev, int irq_num)
 {
-    int slot = pci_dev->devfn >> 3;
+    int slot = PCI_SLOT(pci_dev->devfn);
 
     trace_ppc4xx_pci_map_irq(pci_dev->devfn, irq_num, slot);
 
hw/sh4/sh_pci.c +1 -1
index 73d2d0bccb0..734892f47c7 100644
@@ -109,7 +109,7 @@ static const MemoryRegionOps sh_pci_reg_ops = {
 
 static int sh_pci_map_irq(PCIDevice *d, int irq_num)
 {
-    return (d->devfn >> 3);
+    return PCI_SLOT(d->devfn);
 }
 
 static void sh_pci_set_irq(void *opaque, int irq_num, int level)
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#11 lore raw

PATCH 5/5 hw: Use the PCI_DEVFN() macro from 'hw/pci/pci.h'

In reply to Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

We already have a generic PCI_DEVFN() macro in "hw/pci/pci.h" to pack the PCI slot/function identifiers, use it.

---
 hw/arm/virt.c          | 3 ++-
 hw/pci-host/uninorth.c | 6 ++----
 2 files changed, 4 insertions(+), 5 deletions(-)
hw/arm/virt.c +2 -1
index e465a988d68..f601ef0798c 100644
@@ -1144,7 +1144,8 @@ static void create_pcie_irq_map(const VirtMachineState *vms,
                      full_irq_map, sizeof(full_irq_map));
 
     qemu_fdt_setprop_cells(vms->fdt, nodename, "interrupt-map-mask",
-                           0x1800, 0, 0, /* devfn (PCI_SLOT(3)) */
+                           cpu_to_be16(PCI_DEVFN(3, 0)), /* Slot 3 */
+                           0, 0,
                            0x7           /* PCI irq */);
 }
 
hw/pci-host/uninorth.c +2 -4
index c21de0ab805..f73d452bdce 100644
@@ -70,10 +70,8 @@ static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr)
         /* ... and then convert them to x86 format */
         /* config pointer */
         retval = (reg & (0xff - 7)) | (addr & 7);
-        /* slot */
-        retval |= slot << 11;
-        /* fn */
-        retval |= func << 8;
+        /* slot, fn */
+        retval |= PCI_DEVFN(slot, func) << 8;
     }
 
     trace_unin_get_config_reg(reg, addr, retval);
Signature · 1 line
2.26.2
Acked-by on v1 5/5
#12 lore raw

Re: [PATCH 5/5] hw: Use the PCI_DEVFN() macro from 'hw/pci/pci.h'

Quoted 6 lines · Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

We already have a generic PCI_DEVFN() macro in "hw/pci/pci.h" to pack the PCI slot/function identifiers, use it.

ppc part

Quoted 36 lines
---
 hw/arm/virt.c          | 3 ++-
 hw/pci-host/uninorth.c | 6 ++----
 2 files changed, 4 insertions(+), 5 deletions(-)
hw/arm/virt.c +2 -1
index e465a988d68..f601ef0798c 100644
@@ -1144,7 +1144,8 @@ static void create_pcie_irq_map(const VirtMachineState *vms,
                      full_irq_map, sizeof(full_irq_map));
 
     qemu_fdt_setprop_cells(vms->fdt, nodename, "interrupt-map-mask",
-                           0x1800, 0, 0, /* devfn (PCI_SLOT(3)) */
+                           cpu_to_be16(PCI_DEVFN(3, 0)), /* Slot 3 */
+                           0, 0,
                            0x7           /* PCI irq */);
 }
 
hw/pci-host/uninorth.c +2 -4
index c21de0ab805..f73d452bdce 100644
@@ -70,10 +70,8 @@ static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr)
         /* ... and then convert them to x86 format */
         /* config pointer */
         retval = (reg & (0xff - 7)) | (addr & 7);
-        /* slot */
-        retval |= slot << 11;
-        /* fn */
-        retval |= func << 8;
+        /* slot, fn */
+        retval |= PCI_DEVFN(slot, func) << 8;
     }
 
     trace_unin_get_config_reg(reg, addr, retval);
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#13 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 8 lines · Philippe Mathieu-Daudé

Trivial patches using the generic PCI macros from "hw/pci/pci.h".

Philippe Mathieu-Daudé (5):
hw/pci-host/bonito: Make PCI_ADDR() macro more readable hw/pci-host: Use the PCI_BUILD_BDF() macro from 'hw/pci/pci.h' hw/pci-host/uninorth: Use the PCI_FUNC() macro from 'hw/pci/pci.h'
hw: Use the PCI_SLOT() macro from 'hw/pci/pci.h'
hw: Use the PCI_DEVFN() macro from 'hw/pci/pci.h'

As this series are trivial and Acked, I'm going to queue it via the mips-tree, as other reviewed patches depend on it.

Thanks,

Phil.

#14 lore raw
Quoted 10 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Philippe Mathieu-Daudé

Trivial patches using the generic PCI macros from "hw/pci/pci.h".

Philippe Mathieu-Daudé (5):
hw/pci-host/bonito: Make PCI_ADDR() macro more readable hw/pci-host: Use the PCI_BUILD_BDF() macro from 'hw/pci/pci.h' hw/pci-host/uninorth: Use the PCI_FUNC() macro from 'hw/pci/pci.h'
hw: Use the PCI_SLOT() macro from 'hw/pci/pci.h'
hw: Use the PCI_DEVFN() macro from 'hw/pci/pci.h'

Quoted 7 lines

As this series are trivial and Acked, I'm going to queue it via the mips-tree, as other reviewed patches depend on it.

Thanks,

Phil.

Fine.