hw/riscv/virt: Fix PCI devices with AIA
cover hw/riscv/virt: Fix PCI devices with AIA
Linux does not properly handle '#msi-cells=<0>' when searching for MSI controllers for PCI devices which results in the devices being unable to use MSIs. A patch for Linux has been sent[1] but until it, or something like it, is merged and in distro kernels we should stop adding the property. It's harmless to stop adding it since the absence of the property and a value of zero for the property mean the same thing according to the DT binding definition.
The first patch stops adding the property by simply reverting the patch that started adding it and should be applied for 9.1 since it's a fix. The second patch allows users to bring it back by enabling a new machine property 'strict-dt' which is meant to be used for cases like these going forward. There's no rush for the second patch.
[1] https://lore.kernel.org/all/[email protected]/
Thanks,
drew
Andrew Jones (2):
Revert "hw/riscv/virt.c: imsics DT: add '#msi-cells'" hw/riscv/virt: Introduce strict-dt
docs/system/riscv/virt.rst | 11 ++++++++++ hw/riscv/virt.c | 44 +++++++++++++++++++++++++++++--------- include/hw/riscv/virt.h | 1 + 3 files changed, 46 insertions(+), 10 deletions(-)
Signature · 1 line
2.45.2
PATCH 1/2 Revert "hw/riscv/virt.c: imsics DT: add '#msi-cells'"
This reverts commit f42cdf2ea5b3a1dc369792d7acbf9cd3e5c90815.
Linux does not properly handle '#msi-cells=<0>' when searching for MSI controllers for PCI devices which results in the devices being unable to use MSIs. A patch for Linux has been sent[1] but until it, or something like it, is merged and in distro kernels we should stop adding the property. It's harmless to stop adding it since the absence of the property and a value of zero for the property mean the same thing according to the DT binding definition.
--- hw/riscv/virt.c | 1 - 1 file changed, 1 deletion(-)
hw/riscv/virt.c +0 -1
@@ -552,7 +552,6 @@ static void create_fdt_one_imsic(RISCVVirtState *s, hwaddr base_addr, FDT_IMSIC_INT_CELLS);qemu_fdt_setprop (ms->fdt, imsic_name,"interrupt-controller" ,NULL ,0 );qemu_fdt_setprop (ms->fdt, imsic_name,"msi-controller" ,NULL ,0 ); -qemu_fdt_setprop_cell (ms->fdt, imsic_name,"#msi-cells" ,0 );qemu_fdt_setprop (ms->fdt, imsic_name,"interrupts-extended" , imsic_cells, ms->smp.cpus *sizeof (uint32_t ) *2 ); qemu_fdt_setprop(ms->fdt, imsic_name, "reg", imsic_regs,
Signature · 1 line
2.45.2
Re: [PATCH for-9.1 1/2] Revert "hw/riscv/virt.c: imsics DT: add '#msi-cells'"
Quoted 10 lines · Andrew Jones
This reverts commit
f42cdf2ea5b3a1dc369792d7acbf9cd3e5c90815.Linux does not properly handle '#msi-cells=<0>' when searching for MSI controllers for PCI devices which results in the devices being unable to use MSIs. A patch for Linux has been sent[1] but until it, or something like it, is merged and in distro kernels we should stop adding the property. It's harmless to stop adding it since the absence of the property and a value of zero for the property mean the same thing according to the DT binding definition.
This reverts commit f42cdf2ea5b3a1dc369792d7acbf9cd3e5c90815.
Quoted 18 lines
Signed-off-by Andrew Jones <[email protected]>--- hw/riscv/virt.c | 1 - 1 file changed, 1 deletion(-)hw/riscv/virt.c +0
-1@@ -552,7 +552,6 @@ static void create_fdt_one_imsic(RISCVVirtState *s, hwaddr base_addr, FDT_IMSIC_INT_CELLS);qemu_fdt_setprop (ms->fdt, imsic_name,"interrupt-controller" ,NULL ,0 );qemu_fdt_setprop (ms->fdt, imsic_name,"msi-controller" ,NULL ,0 ); -qemu_fdt_setprop_cell (ms->fdt, imsic_name,"#msi-cells" ,0 );qemu_fdt_setprop (ms->fdt, imsic_name,"interrupts-extended" , imsic_cells, ms->smp.cpus *sizeof (uint32_t ) *2 ); qemu_fdt_setprop(ms->fdt, imsic_name, "reg", imsic_regs,
Re: [PATCH for-9.1 1/2] Revert "hw/riscv/virt.c: imsics DT: add '#msi-cells'"
Quoted 2 lines · Philippe Mathieu-Daudé
Quoted 1 line · Andrew Jones
This reverts commit
f42cdf2ea5b3a1dc369792d7acbf9cd3e5c90815.
Ahah sorry I'm not seeing well after a long day in front of the monitor =)
Quoted 31 lines
Quoted 8 lines
Linux does not properly handle '#msi-cells=<0>' when searching for MSI controllers for PCI devices which results in the devices being unable to use MSIs. A patch for Linux has been sent[1] but until it, or something like it, is merged and in distro kernels we should stop adding the property. It's harmless to stop adding it since the absence of the property and a value of zero for the property mean the same thing according to the DT binding definition.
This reverts commit
f42cdf2ea5b3a1dc369792d7acbf9cd3e5c90815.Quoted 19 lines
Signed-off-by Andrew Jones <[email protected]>---
hw/riscv/virt.c| 1 -1 file changed, 1 deletion(-)hw/riscv/virt.c +0
-1@@ -552,7 +552,6 @@ static void create_fdt_one_imsic(RISCVVirtState *s, hwaddr base_addr, FDT_IMSIC_INT_CELLS); qemu_fdt_setprop(ms->fdt, imsic_name, "interrupt-controller", NULL, 0); qemu_fdt_setprop(ms->fdt, imsic_name, "msi-controller", NULL, 0); - qemu_fdt_setprop_cell(ms->fdt, imsic_name, "#msi-cells", 0); qemu_fdt_setprop(ms->fdt, imsic_name, "interrupts-extended", imsic_cells, ms->smp.cpus * sizeof(uint32_t) * 2);qemu_fdt_setprop(ms->fdt,
imsic_name, "reg",imsic_regs,
Re: [PATCH for-9.1 1/2] Revert "hw/riscv/virt.c: imsics DT: add '#msi-cells'"
In reply to Andrew JonesQuoted 10 lines · Andrew Jones
This reverts commit
f42cdf2ea5b3a1dc369792d7acbf9cd3e5c90815.Linux does not properly handle '#msi-cells=<0>' when searching for MSI controllers for PCI devices which results in the devices being unable to use MSIs. A patch for Linux has been sent[1] but until it, or something like it, is merged and in distro kernels we should stop adding the property. It's harmless to stop adding it since the absence of the property and a value of zero for the property mean the same thing according to the DT binding definition.
Quoted 3 lines
Signed-off-by Andrew Jones <[email protected]>---
This is indeed a 9.1 fix. Thanks Drew for sending it.
We can discuss whether we should wrap this around the 'strict-dt' flag or not, but that can wait for 9.2.
Thanks,
Daniel
Quoted 15 lines
hw/riscv/virt.c | 1 - 1 file changed, 1 deletion(-)hw/riscv/virt.c +0
-1@@ -552,7 +552,6 @@ static void create_fdt_one_imsic(RISCVVirtState *s, hwaddr base_addr, FDT_IMSIC_INT_CELLS);qemu_fdt_setprop (ms->fdt, imsic_name,"interrupt-controller" ,NULL ,0 );qemu_fdt_setprop (ms->fdt, imsic_name,"msi-controller" ,NULL ,0 ); -qemu_fdt_setprop_cell (ms->fdt, imsic_name,"#msi-cells" ,0 );qemu_fdt_setprop (ms->fdt, imsic_name,"interrupts-extended" , imsic_cells, ms->smp.cpus *sizeof (uint32_t ) *2 ); qemu_fdt_setprop(ms->fdt, imsic_name, "reg", imsic_regs,
Alistair Francis
AppliedRe: [PATCH for-9.1 1/2] Revert "hw/riscv/virt.c: imsics DT: add '#msi-cells'"
In reply to Andrew JonesQuoted 11 lines · Andrew Jones
This reverts commit
f42cdf2ea5b3a1dc369792d7acbf9cd3e5c90815.Linux does not properly handle '#msi-cells=<0>' when searching for MSI controllers for PCI devices which results in the devices being unable to use MSIs. A patch for Linux has been sent[1] but until it, or something like it, is merged and in distro kernels we should stop adding the property. It's harmless to stop adding it since the absence of the property and a value of zero for the property mean the same thing according to the DT binding definition.
Quoted 2 lines
Signed-off-by Andrew Jones <[email protected]>
Thanks!
Applied to riscv-to-apply.next
Alistair
Quoted 20 lines
--- hw/riscv/virt.c | 1 - 1 file changed, 1 deletion(-)hw/riscv/virt.c +0
-2@@ -552,7 +552,6 @@ static void create_fdt_one_imsic(RISCVVirtState *s, hwaddr base_addr, FDT_IMSIC_INT_CELLS);qemu_fdt_setprop (ms->fdt, imsic_name,"interrupt-controller" ,NULL ,0 );qemu_fdt_setprop (ms->fdt, imsic_name,"msi-controller" ,NULL ,0 ); -qemu_fdt_setprop_cell (ms->fdt, imsic_name,"#msi-cells" ,0 );qemu_fdt_setprop (ms->fdt, imsic_name,"interrupts-extended" , imsic_cells, ms->smp.cpus *sizeof (uint32_t ) *2 ); qemu_fdt_setprop(ms->fdt, imsic_name, "reg", imsic_regs, --2.45.2
PATCH 2/2 hw/riscv/virt: Introduce strict-dt
In reply to Andrew JonesOlder firmwares and OS kernels which use deprecated device tree properties or are missing support for new properties may not be tolerant of fully compliant device trees. When divergence to the bindings specifications is harmless for new firmwares and OS kernels which are compliant, then it's probably better to also continue supporting the old firmwares and OS kernels by generating non-compliant device trees. The '#msi-cells=<0>' property of the imsic is one such property. Generating that property doesn't provide anything necessary (no '#msi-cells' property or an '#msi-cells' property with a value of zero mean the same thing) but it does cause PCI devices to fail to find the MSI controller on Linux and, for that reason, riscv virt doesn't currently generate it despite that putting the DT out of compliance. For users that want a compliant DT and know their software supports it, introduce a machine property 'strict-dt' to do so. We also drop the one redundant property that uses a deprecated name when strict-dt is enabled.
--- docs/system/riscv/virt.rst | 11 ++++++++++ hw/riscv/virt.c | 43 ++++++++++++++++++++++++++++++-------- include/hw/riscv/virt.h | 1 + 3 files changed, 46 insertions(+), 9 deletions(-)
docs/system/riscv/virt.rst +11 -0
@@ -116,6 +116,17 @@ The following machine-specific options are supported: having AIA IMSIC (i.e. "aia=aplic-imsic" selected). When not specified, the default number of per-HART VS-level AIA IMSIC pages is 0. +- strict-dt=[on|off] + + Older firmwares and OS kernels which use deprecated device tree properties + or are missing support for new properties may not be tolerant of fully + compliant device trees. When divergence to the bindings specifications is + harmless for new firmwares and OS kernels which are compliant, then it's + considered better to also continue supporting the old firmwares and OS + kernels by generating non-compliant device trees, and doing so is the default + behavior. This option may be enabled in order to force QEMU to only generate + compliant device trees. + Running Linux kernel --------------------
hw/riscv/virt.c +34 -9
67 lines not on this page · raw message
include/hw/riscv/virt.h +1 -0
@@ -62,6 +62,7 @@ struct RISCVVirtState {OnOffAuto acpi;const MemMapEntry *memmap;struct GPEXHost *gpex_host; +bool strict_dt; };enum {
Signature · 1 line
2.45.2
Re: [PATCH 2/2] hw/riscv/virt: Introduce strict-dt
Quoted 30 lines · Andrew Jones
Older firmwares and OS kernels which use deprecated device tree properties or are missing support for new properties may not be tolerant of fully compliant device trees. When divergence to the bindings specifications is harmless for new firmwares and OS kernels which are compliant, then it's probably better to also continue supporting the old firmwares and OS kernels by generating non-compliant device trees. The '#msi-cells=<0>' property of the imsic is one such property. Generating that property doesn't provide anything necessary (no '#msi-cells' property or an '#msi-cells' property with a value of zero mean the same thing) but it does cause PCI devices to fail to find the MSI controller on Linux and, for that reason, riscv virt doesn't currently generate it despite that putting the DT out of compliance. For users that want a compliant DT and know their software supports it, introduce a machine property 'strict-dt' to do so. We also drop the one redundant property that uses a deprecated name when strict-dt is enabled.
Signed-off-by Andrew Jones <[email protected]>--- docs/system/riscv/virt.rst | 11 ++++++++++ hw/riscv/virt.c | 43 ++++++++++++++++++++++++++++++-------- include/hw/riscv/virt.h | 1 + 3 files changed, 46 insertions(+), 9 deletions(-)docs/system/riscv/virt.rst +0
-0
docs/system/riscv/virt.rst The following machine-specific options are supported: · line 119
Quoted 4 lines
docs/system/riscv/virt.rst +1
-0@@ -116,6 +116,17 @@ The following machine-specific options are supported: having AIA IMSIC (i.e. "aia=aplic-imsic" selected). When not specified, the default number of per-HART VS-level AIA IMSIC pages is 0. +- strict-dt=[on|off]
Hmm... I don't love the idea of having yet another command line option.
Does this really buy us a lot? Eventually we should deprecate the invalid DT bindings anyway
Alistair
Re: [PATCH 2/2] hw/riscv/virt: Introduce strict-dt
Quoted 34 lines · Alistair Francis
Quoted 33 lines · Andrew Jones
Older firmwares and OS kernels which use deprecated device tree properties or are missing support for new properties may not be tolerant of fully compliant device trees. When divergence to the bindings specifications is harmless for new firmwares and OS kernels which are compliant, then it's probably better to also continue supporting the old firmwares and OS kernels by generating non-compliant device trees. The '#msi-cells=<0>' property of the imsic is one such property. Generating that property doesn't provide anything necessary (no '#msi-cells' property or an '#msi-cells' property with a value of zero mean the same thing) but it does cause PCI devices to fail to find the MSI controller on Linux and, for that reason, riscv virt doesn't currently generate it despite that putting the DT out of compliance. For users that want a compliant DT and know their software supports it, introduce a machine property 'strict-dt' to do so. We also drop the one redundant property that uses a deprecated name when strict-dt is enabled.
Signed-off-by Andrew Jones <[email protected]>--- docs/system/riscv/virt.rst | 11 ++++++++++ hw/riscv/virt.c | 43 ++++++++++++++++++++++++++++++-------- include/hw/riscv/virt.h | 1 + 3 files changed, 46 insertions(+), 9 deletions(-)docs/system/riscv/virt.rst +0
-0@@ -116,6 +116,17 @@ The following machine-specific options are supported: having AIA IMSIC (i.e. "aia=aplic-imsic" selected). When not specified, the default number of per-HART VS-level AIA IMSIC pages is 0.
Quoted 6 lines
docs/system/riscv/virt.rst The following machine-specific options are supported: · line 119
Quoted 1 line
docs/system/riscv/virt.rst +1
-0+- strict-dt=[on|off]Hmm... I don't love the idea of having yet another command line option.
Does this really buy us a lot? Eventually we should deprecate the invalid DT bindings anyway
I agree we should deprecate the invalid DT usage, with the goal of only generating DTs that make the validator happy. I'm not sure how long that deprecation period should be, though. It may need to be a while since we'll need to decide when we've waited long enough to no longer care about older kernels. In the meantime, we won't be making the validator happy and may get bug reports due to that. With strct-dt we can just direct people in that direction. Also, I wouldn't be surprised if something else like this comes along some day, which is why I tried to make the option as generic as possible. Finally, the 'if (strict_dt)' self-documents to some extent. Otherwise we'll need to add comments around explaining why we're diverging from the specs. Although we should probably do that anyway, i.e. I should have put a comment on the 'if (strict-dt) then #msi-cells' explaining why it's under strict-dt. If we want strict-dt, then I'll send a v2 doing that. If we don't want strict-dt then I'll send a v2 with just a comment explaining why #msi-cells was left out.
Thanks,
drew
Re: [PATCH 2/2] hw/riscv/virt: Introduce strict-dt
Quoted 5 lines · Andrew Jones
I agree we should deprecate the invalid DT usage, with the goal of only generating DTs that make the validator happy. I'm not sure how long that deprecation period should be, though. It may need to be a while since we'll need to decide when we've waited long enough to no longer care about older kernels.
This is the kind of thing versioned machine models are good for.
For instance, for the next release define virt-9.1 and virt-9.2. Set strict-dt in virt-9.2 and reset it in virt-9.1.
C.f. hw/arm/virt.c, where virt_machine_8_2_options invokes virt_machine_9_0_options and then adjusts for backward compatibility.
r~
Re: [PATCH 2/2] hw/riscv/virt: Introduce strict-dt
In reply to Andrew JonesQuoted 43 lines · Andrew Jones
Quoted 34 lines · Alistair Francis
Quoted 33 lines · Andrew Jones
Older firmwares and OS kernels which use deprecated device tree properties or are missing support for new properties may not be tolerant of fully compliant device trees. When divergence to the bindings specifications is harmless for new firmwares and OS kernels which are compliant, then it's probably better to also continue supporting the old firmwares and OS kernels by generating non-compliant device trees. The '#msi-cells=<0>' property of the imsic is one such property. Generating that property doesn't provide anything necessary (no '#msi-cells' property or an '#msi-cells' property with a value of zero mean the same thing) but it does cause PCI devices to fail to find the MSI controller on Linux and, for that reason, riscv virt doesn't currently generate it despite that putting the DT out of compliance. For users that want a compliant DT and know their software supports it, introduce a machine property 'strict-dt' to do so. We also drop the one redundant property that uses a deprecated name when strict-dt is enabled.
Signed-off-by Andrew Jones <[email protected]>--- docs/system/riscv/virt.rst | 11 ++++++++++ hw/riscv/virt.c | 43 ++++++++++++++++++++++++++++++-------- include/hw/riscv/virt.h | 1 + 3 files changed, 46 insertions(+), 9 deletions(-)docs/system/riscv/virt.rst +0
-0@@ -116,6 +116,17 @@ The following machine-specific options are supported: having AIA IMSIC (i.e. "aia=aplic-imsic" selected). When not specified, the default number of per-HART VS-level AIA IMSIC pages is 0.Quoted 6 lines
docs/system/riscv/virt.rst The following machine-specific options are supported: · line 119
Quoted 1 line
docs/system/riscv/virt.rst +1
-0+- strict-dt=[on|off]Hmm... I don't love the idea of having yet another command line option.
Does this really buy us a lot? Eventually we should deprecate the invalid DT bindings anyway
Quoted 16 lines
I agree we should deprecate the invalid DT usage, with the goal of only generating DTs that make the validator happy. I'm not sure how long that deprecation period should be, though. It may need to be a while since we'll need to decide when we've waited long enough to no longer care about older kernels. In the meantime, we won't be making the validator happy and may get bug reports due to that. With strct-dt we can just direct people in that direction. Also, I wouldn't be surprised if something else like this comes along some day, which is why I tried to make the option as generic as possible. Finally, the 'if (
strict_dt)' self-documents to some extent. Otherwise we'll need to add comments around explaining why we're diverging from the specs. Although we should probably do that anyway, i.e. I should have put a comment on the 'if (strict-dt) then #msi-cells' explaining why it's under strict-dt. If we want strict-dt, then I'll send a v2 doing that. If we don't want strict-dt then I'll send a v2 with just a comment explaining why #msi-cells was left out.
I think go without strict-dt and add a comment.
In the future if we decide we really want to keep the validator happy then we can version the virt machine and use the older machine for backwards compatible kernels
Alistair
Quoted 3 lines
Thanks,
drew
Re: [PATCH 2/2] hw/riscv/virt: Introduce strict-dt
Quoted 61 lines · Alistair Francis
Quoted 43 lines · Andrew Jones
Quoted 34 lines · Alistair Francis
Quoted 33 lines · Andrew Jones
Older firmwares and OS kernels which use deprecated device tree properties or are missing support for new properties may not be tolerant of fully compliant device trees. When divergence to the bindings specifications is harmless for new firmwares and OS kernels which are compliant, then it's probably better to also continue supporting the old firmwares and OS kernels by generating non-compliant device trees. The '#msi-cells=<0>' property of the imsic is one such property. Generating that property doesn't provide anything necessary (no '#msi-cells' property or an '#msi-cells' property with a value of zero mean the same thing) but it does cause PCI devices to fail to find the MSI controller on Linux and, for that reason, riscv virt doesn't currently generate it despite that putting the DT out of compliance. For users that want a compliant DT and know their software supports it, introduce a machine property 'strict-dt' to do so. We also drop the one redundant property that uses a deprecated name when strict-dt is enabled.
Signed-off-by Andrew Jones <[email protected]>--- docs/system/riscv/virt.rst | 11 ++++++++++ hw/riscv/virt.c | 43 ++++++++++++++++++++++++++++++-------- include/hw/riscv/virt.h | 1 + 3 files changed, 46 insertions(+), 9 deletions(-)docs/system/riscv/virt.rst +0
-0@@ -116,6 +116,17 @@ The following machine-specific options are supported: having AIA IMSIC (i.e. "aia=aplic-imsic" selected). When not specified, the default number of per-HART VS-level AIA IMSIC pages is 0.Quoted 6 lines
docs/system/riscv/virt.rst The following machine-specific options are supported: · line 119
Quoted 1 line
docs/system/riscv/virt.rst +1
-0+- strict-dt=[on|off]Hmm... I don't love the idea of having yet another command line option.
Does this really buy us a lot? Eventually we should deprecate the invalid DT bindings anyway
Quoted 16 lines
I agree we should deprecate the invalid DT usage, with the goal of only generating DTs that make the validator happy. I'm not sure how long that deprecation period should be, though. It may need to be a while since we'll need to decide when we've waited long enough to no longer care about older kernels. In the meantime, we won't be making the validator happy and may get bug reports due to that. With strct-dt we can just direct people in that direction. Also, I wouldn't be surprised if something else like this comes along some day, which is why I tried to make the option as generic as possible. Finally, the 'if (
strict_dt)' self-documents to some extent. Otherwise we'll need to add comments around explaining why we're diverging from the specs. Although we should probably do that anyway, i.e. I should have put a comment on the 'if (strict-dt) then #msi-cells' explaining why it's under strict-dt. If we want strict-dt, then I'll send a v2 doing that. If we don't want strict-dt then I'll send a v2 with just a comment explaining why #msi-cells was left out.
Quoted 5 lines
I think go without strict-dt and add a comment.
In the future if we decide we really want to keep the validator happy then we can version the virt machine and use the older machine for backwards compatible kernels
OK, I'll post a patch with a comment as soon as I have an upstream Linux commit to reference for the fix. So far the fix is only in linux-next.
Thanks,
drew