Skip to contentSkip to conversation

riscv: virt: Correct pci "bus-range" encoding

PATCH In review Bin Meng 3 participants 7 messages May 29, 2019 – Jun 26, 2019 RISC-V

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/1 riscv: virt: Correct pci "bus-range" encoding

The largest pci bus number should be calculated from ECAM size, instead of its base address.

---

 hw/riscv/virt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/virt.c +1 -1
index fc4c6b3..d6132d9 100644
@@ -299,7 +299,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
     qemu_fdt_setprop_string(fdt, nodename, "device_type", "pci");
     qemu_fdt_setprop_cell(fdt, nodename, "linux,pci-domain", 0);
     qemu_fdt_setprop_cells(fdt, nodename, "bus-range", 0,
-                           memmap[VIRT_PCIE_ECAM].base /
+                           memmap[VIRT_PCIE_ECAM].size /
                                PCIE_MMCFG_SIZE_MIN - 1);
     qemu_fdt_setprop(fdt, nodename, "dma-coherent", NULL, 0);
     qemu_fdt_setprop_cells(fdt, nodename, "reg", 0, memmap[VIRT_PCIE_ECAM].base,
Signature · 1 line
2.7.4
#1 lore raw
Quoted 5 lines · Bin Meng

The largest pci bus number should be calculated from ECAM size, instead of its base address.

This seems ok, can you maybe explain what this fixes?

Alistair

Quoted 22 lines

---

 hw/riscv/virt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/virt.c +1 -2
index fc4c6b3..d6132d9 100644
@@ -299,7 +299,7 @@ static void *create_fdt(RISCVVirtState *s, const struct MemmapEntry *memmap,
     qemu_fdt_setprop_string(fdt, nodename, "device_type", "pci");
     qemu_fdt_setprop_cell(fdt, nodename, "linux,pci-domain", 0);
     qemu_fdt_setprop_cells(fdt, nodename, "bus-range", 0,
-                           memmap[VIRT_PCIE_ECAM].base /
+                           memmap[VIRT_PCIE_ECAM].size /
                                PCIE_MMCFG_SIZE_MIN - 1);
     qemu_fdt_setprop(fdt, nodename, "dma-coherent", NULL, 0);
     qemu_fdt_setprop_cells(fdt, nodename, "reg", 0, memmap[VIRT_PCIE_ECAM].base,
--

2.7.4

author
#2 lore raw

Hi Alistair,

Quoted 10 lines · Alistair Francis
Quoted 5 lines · Bin Meng

The largest pci bus number should be calculated from ECAM size, instead of its base address.

This seems ok, can you maybe explain what this fixes?

The logic is wrong, as the commit message said. With current wrong logic, the largest pci bus number encoded in "bus-ranges" property was wrongly set to 0x2ff in this case. Per pci spec, the bus number should not exceed 0xff.

Regards,
Bin

author
#3 lore raw
Quoted 12 lines · Bin Meng

Hi Alistair,

Quoted 8 lines · Alistair Francis
Quoted 5 lines · Bin Meng

The largest pci bus number should be calculated from ECAM size, instead of its base address.

Quoted 8 lines
Quoted 2 lines

This seems ok, can you maybe explain what this fixes?

The logic is wrong, as the commit message said. With current wrong logic, the largest pci bus number encoded in "bus-ranges" property was wrongly set to 0x2ff in this case. Per pci spec, the bus number should not exceed 0xff.

Ping?

Reviewed-by
#4 lore raw
Quoted 17 lines · Bin Meng
Quoted 15 lines · Bin Meng

Hi Alistair,

Quoted 10 lines · Alistair Francis
Quoted 5 lines · Bin Meng

The largest pci bus number should be calculated from ECAM size, instead of its base address.

This seems ok, can you maybe explain what this fixes?

Quoted 7 lines
Quoted 5 lines

The logic is wrong, as the commit message said. With current wrong logic, the largest pci bus number encoded in "bus-ranges" property was wrongly set to 0x2ff in this case. Per pci spec, the bus number should not exceed 0xff.

Ping?

Alistair

author
#5 lore raw

Hi,

Quoted 25 lines · Alistair Francis
Quoted 23 lines · Bin Meng
Quoted 20 lines · Bin Meng

Hi Alistair,

Quoted 10 lines · Alistair Francis
Quoted 5 lines · Bin Meng

The largest pci bus number should be calculated from ECAM size, instead of its base address.

This seems ok, can you maybe explain what this fixes?

The logic is wrong, as the commit message said. With current wrong logic, the largest pci bus number encoded in "bus-ranges" property was wrongly set to 0x2ff in this case. Per pci spec, the bus number should not exceed 0xff.

Quoted 3 lines
Quoted 1 line

Ping?

Can this go in the 4.1 PR?

Regards,
Bin

#6 lore raw
Quoted 28 lines · On Tue, 25 Jun 2019 18:47:33 PDT (-0700), [email protected] wrote:

Hi,

Quoted 25 lines · Alistair Francis
Quoted 23 lines · Bin Meng
Quoted 20 lines · Bin Meng

Hi Alistair,

Quoted 10 lines · Alistair Francis
Quoted 5 lines · Bin Meng

The largest pci bus number should be calculated from ECAM size, instead of its base address.

This seems ok, can you maybe explain what this fixes?

The logic is wrong, as the commit message said. With current wrong logic, the largest pci bus number encoded in "bus-ranges" property was wrongly set to 0x2ff in this case. Per pci spec, the bus number should not exceed 0xff.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Ping?

Can this go in the 4.1 PR?

This one I didn't miss, it's been in the queue for a bit. Thanks!