Skip to contentSkip to conversation

hw/riscv/virt.c: fix 'iommu-map' FDT entry

PATCH Applied Daniel Henrique Barboza 2 participants 3 messages Jun 8 – Jun 12 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/riscv/virt.c: fix 'iommu-map' FDT entry

Based on the DT documentation of 'iommu-map':

https://www.kernel.org/doc/Documentation/devicetree/bindings/pci/pci-iommu.txt

- iommu-map: Maps a Requester ID to an IOMMU and associated IOMMU specifier data.

The property is an arbitrary number of tuples of (rid-base,iommu,iommu-base,length).

----------

We're adding a no-op entry (length = 0) in iommu-map:

         qemu_fdt_setprop_cells(ms->fdt, name, "iommu-map",
                                0, iommu_sys_phandle, 0, 0, 0,
                                iommu_sys_phandle, 0, 0xffff);

This is easily seen in the generated DT:

iommu-map = <0x00 0x8000 0x00 0x00 0x00 0x8000 0x00 0xffff>;

The tuple (0 0 0x8000 0) does nothing since it has length = 0. The information we want to advertise is in the second tuple only. Thus remove the empty tuple.

While we're at it, seems like we've mistaken the API and we're using 0xffff as 'last address', but in fact it is length. This means that we're telling the DT we're mapping 0x0 -> 0xfffe, which wasn't our intention. Therefore change size to '0x10000' to reflect the address mapping we want (0x0 -> 0xffff).

Found while reviewing the RISC-V Server Platform DT generation, which happens to copy a lot of code from the 'virt' board, and this nit is also present there.

Fixes 2c12de1460 ("hw/riscv/virt: Add IOMMU as platform device if the option is set")
---
 hw/riscv/virt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/riscv/virt.c +1 -2
index ce64eaaef7..0c489bb412 100644
@@ -900,8 +900,7 @@ static void create_fdt_pcie(RISCVVirtState *s,
 
     if (virt_is_iommu_sys_enabled(s)) {
         qemu_fdt_setprop_cells(ms->fdt, name, "iommu-map",
-                               0, iommu_sys_phandle, 0, 0, 0,
-                               iommu_sys_phandle, 0, 0xffff);
+                               0, iommu_sys_phandle, 0, 0x10000);
     }
 
     create_pcie_irq_map(s, ms->fdt, name, irq_pcie_phandle);
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 33 lines · Daniel Henrique Barboza

Based on the DT documentation of 'iommu-map':

https://www.kernel.org/doc/Documentation/devicetree/bindings/pci/pci-iommu.txt

- iommu-map: Maps a Requester ID to an IOMMU and associated IOMMU specifier data.

The property is an arbitrary number of tuples of (rid-base,iommu,iommu-base,length).

----------

We're adding a no-op entry (length = 0) in iommu-map:

         qemu_fdt_setprop_cells(ms->fdt, name, "iommu-map",
                                0, iommu_sys_phandle, 0, 0, 0,
                                iommu_sys_phandle, 0, 0xffff);

This is easily seen in the generated DT:

iommu-map = <0x00 0x8000 0x00 0x00 0x00 0x8000 0x00 0xffff>;

The tuple (0 0 0x8000 0) does nothing since it has length = 0. The information we want to advertise is in the second tuple only. Thus remove the empty tuple.

While we're at it, seems like we've mistaken the API and we're using 0xffff as 'last address', but in fact it is length. This means that we're telling the DT we're mapping 0x0 -> 0xfffe, which wasn't our intention. Therefore change size to '0x10000' to reflect the address mapping we want (0x0 -> 0xffff).

Quoted 6 lines

Found while reviewing the RISC-V Server Platform DT generation, which happens to copy a lot of code from the 'virt' board, and this nit is also present there.

Fixes 2c12de1460 ("hw/riscv/virt: Add IOMMU as platform device if the option is set")

Alistair

Quoted 22 lines
---
 hw/riscv/virt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/riscv/virt.c +1 -3
index ce64eaaef7..0c489bb412 100644
@@ -900,8 +900,7 @@ static void create_fdt_pcie(RISCVVirtState *s,
 
     if (virt_is_iommu_sys_enabled(s)) {
         qemu_fdt_setprop_cells(ms->fdt, name, "iommu-map",
-                               0, iommu_sys_phandle, 0, 0, 0,
-                               iommu_sys_phandle, 0, 0xffff);
+                               0, iommu_sys_phandle, 0, 0x10000);
     }
 
     create_pcie_irq_map(s, ms->fdt, name, irq_pcie_phandle);
--

2.43.0

#2 lore raw
In reply to Daniel Henrique Barboza
Quoted 33 lines · Daniel Henrique Barboza

Based on the DT documentation of 'iommu-map':

https://www.kernel.org/doc/Documentation/devicetree/bindings/pci/pci-iommu.txt

- iommu-map: Maps a Requester ID to an IOMMU and associated IOMMU specifier data.

The property is an arbitrary number of tuples of (rid-base,iommu,iommu-base,length).

----------

We're adding a no-op entry (length = 0) in iommu-map:

         qemu_fdt_setprop_cells(ms->fdt, name, "iommu-map",
                                0, iommu_sys_phandle, 0, 0, 0,
                                iommu_sys_phandle, 0, 0xffff);

This is easily seen in the generated DT:

iommu-map = <0x00 0x8000 0x00 0x00 0x00 0x8000 0x00 0xffff>;

The tuple (0 0 0x8000 0) does nothing since it has length = 0. The information we want to advertise is in the second tuple only. Thus remove the empty tuple.

While we're at it, seems like we've mistaken the API and we're using 0xffff as 'last address', but in fact it is length. This means that we're telling the DT we're mapping 0x0 -> 0xfffe, which wasn't our intention. Therefore change size to '0x10000' to reflect the address mapping we want (0x0 -> 0xffff).

Quoted 6 lines

Found while reviewing the RISC-V Server Platform DT generation, which happens to copy a lot of code from the 'virt' board, and this nit is also present there.

Fixes 2c12de1460 ("hw/riscv/virt: Add IOMMU as platform device if the option is set")

Thanks!

Applied to riscv-to-apply.next

Alistair

Quoted 22 lines
---
 hw/riscv/virt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/riscv/virt.c +1 -3
index ce64eaaef7..0c489bb412 100644
@@ -900,8 +900,7 @@ static void create_fdt_pcie(RISCVVirtState *s,
 
     if (virt_is_iommu_sys_enabled(s)) {
         qemu_fdt_setprop_cells(ms->fdt, name, "iommu-map",
-                               0, iommu_sys_phandle, 0, 0, 0,
-                               iommu_sys_phandle, 0, 0xffff);
+                               0, iommu_sys_phandle, 0, 0x10000);
     }
 
     create_pcie_irq_map(s, ms->fdt, name, irq_pcie_phandle);
--

2.43.0