Skip to contentSkip to conversation

hw/arm/virt: "bus-range"/end is off by one

PATCH In review Laszlo Ersek 4 participants 4 messages Feb 12, 2015 – Feb 13, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/arm/virt: "bus-range"/end is off by one

According to "PCI Bus Binding to IEEE Std 1275-1994", 3.1.2. Bus-specific Properties for Bus Nodes, the second integer in "bus-range" is an inclusive limit.

This seems to be consistent with several *.dtsi files in the kernel tree, where examples like

  bus-range = <0 0>;

are visible.

In addition, the loop in gen_pci_parse_map_cfg_windows() [drivers/pci/host/pci-host-generic.c] uses "bus_range->end" as an inclusive limit.

---

Notes:
Applies on top of target-arm.next.

 hw/arm/virt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/arm/virt.c +2 -1
index a2a5c96..ee77093 100644
@@ -693,7 +693,8 @@ static void create_pcie(const VirtBoardInfo *vbi, qemu_irq *pic,
     qemu_fdt_setprop_string(vbi->fdt, nodename, "device_type", "pci");
     qemu_fdt_setprop_cell(vbi->fdt, nodename, "#address-cells", 3);
     qemu_fdt_setprop_cell(vbi->fdt, nodename, "#size-cells", 2);
-    qemu_fdt_setprop_cells(vbi->fdt, nodename, "bus-range", 0, nr_pcie_buses);
+    qemu_fdt_setprop_cells(vbi->fdt, nodename, "bus-range", 0,
+                           nr_pcie_buses - 1);
 
     qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg",
                                  2, base_ecam, 2, size_ecam);
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 30 lines · Laszlo Ersek

According to "PCI Bus Binding to IEEE Std 1275-1994", 3.1.2. Bus-specific Properties for Bus Nodes, the second integer in "bus-range" is an inclusive limit.

This seems to be consistent with several *.dtsi files in the kernel tree, where examples like

  bus-range = <0 0>;

are visible.

In addition, the loop in gen_pci_parse_map_cfg_windows() [drivers/pci/host/pci-host-generic.c] uses "bus_range->end" as an inclusive limit.

---

Notes:
Applies on top of target-arm.next.

 hw/arm/virt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/arm/virt.c +0 -0
index a2a5c96..ee77093 100644

hw/arm/virt.c static void create_pcie(const VirtBoardInfo *vbi, qemu_irq *pic, · line 700

Quoted 9 lines
hw/arm/virt.c +2 -1
@@ -693,7 +693,8 @@ static void create_pcie(const VirtBoardInfo *vbi, qemu_irq *pic,
     qemu_fdt_setprop_string(vbi->fdt, nodename, "device_type", "pci");
     qemu_fdt_setprop_cell(vbi->fdt, nodename, "#address-cells", 3);
     qemu_fdt_setprop_cell(vbi->fdt, nodename, "#size-cells", 2);
-    qemu_fdt_setprop_cells(vbi->fdt, nodename, "bus-range", 0, nr_pcie_buses);
+    qemu_fdt_setprop_cells(vbi->fdt, nodename, "bus-range", 0,
+                           nr_pcie_buses - 1);
 
     qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg",
                                  2, base_ecam, 2, size_ecam);

I instrumented a guest VM (of/of_pci.c) to print out the bus range. Without this patch, bus_range->[start, end]=[0, 16]. So this patch makes sense to me:

Thanks,
-Wei

Reviewed-by on v1 1/1
#2 lore raw
In reply to Laszlo Ersek
Quoted 9 lines · Laszlo Ersek

According to "PCI Bus Binding to IEEE Std 1275-1994", 3.1.2. Bus-specific Properties for Bus Nodes, the second integer in "bus-range" is an inclusive limit.

This seems to be consistent with several *.dtsi files in the kernel tree, where examples like

  bus-range = <0 0>;
Quoted 7 lines

are visible.

In addition, the loop in gen_pci_parse_map_cfg_windows() [drivers/pci/host/pci-host-generic.c] uses "bus_range->end" as an inclusive limit.

Nice catch!

Alex

#3 lore raw
Quoted 18 lines · Alexander Graf
Quoted 15 lines · Laszlo Ersek

According to "PCI Bus Binding to IEEE Std 1275-1994", 3.1.2. Bus-specific Properties for Bus Nodes, the second integer in "bus-range" is an inclusive limit.

This seems to be consistent with several *.dtsi files in the kernel tree, where examples like

  bus-range = <0 0>;

are visible.

In addition, the loop in gen_pci_parse_map_cfg_windows() [drivers/pci/host/pci-host-generic.c] uses "bus_range->end" as an inclusive limit.

Quoted 5 lines
Quoted 1 line

Nice catch!

Since I haven't pushed the pci patches yet I'll just squash this fix in to them.

thanks
-- PMM