hw/ppc/spapr: Add the "rtas-version" property to /rtas
PATCH 1/1 hw/ppc/spapr: Add the "rtas-version" property to /rtas
LoPAR requires every property listed in its table of /rtas device tree properties to be present before the OS is booted (R1-7.2.6-3 and Table 7.4 in LoPAR 2.9; the same requirement is in LoPAPR 1.1). One of them is "rtas-version", an integer encoding of the RTAS interface version, and LoPAR says it describes version 1 of that interface.
spapr_dt_rtas() sets "rtas-size", "rtas-error-log-max" and "rtas-event-scan-rate" but never "rtas-version", so a client that reads it finds no RTAS: NetBSD's RTAS driver fails to attach when the property is absent.
Set it to 1, the version LoPAR describes.
--- hw/ppc/spapr.c | 1 + include/hw/ppc/spapr.h | 3 +++ 2 files changed, 4 insertions(+)
hw/ppc/spapr.c +1 -0
@@ -1068,6 +1068,7 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt) RTAS_ERROR_LOG_MAX));_FDT (fdt_setprop_cell (fdt, rtas,"rtas-event-scan-rate" ,RTAS_EVENT_SCAN_RATE )); +_FDT (fdt_setprop_cell (fdt, rtas,"rtas-version" ,RTAS_VERSION ));g_assert (msi_nonbroken);_FDT (fdt_setprop (fdt, rtas,"ibm,change-msix-capable" ,NULL ,0 ));
include/hw/ppc/spapr.h +3 -0
@@ -830,6 +830,9 @@ void spapr_load_rtas(SpaprMachineState *spapr, void *fdt, hwaddr addr);#define RTAS_EVENT_SCAN_RATE 1 +/* The interface version LoPAR 2.9 Table 7.4 describes */ +#define RTAS_VERSION 1 +/* This helper should be used to encode interrupt specifiers when the related * "interrupt-controller" node has its "#interrupt-cells" property set to 2 (ie, * VIO devices, RTAS event sources and PHBs).
Signature · 1 line
2.54.0 (Apple Git-157)
Quoted 6 lines · Showta Ishizaki
LoPAR requires every property listed in its table of /rtas device tree properties to be present before the OS is booted (R1-7.2.6-3 and Table 7.4 in LoPAR 2.9; the same requirement is in LoPAPR 1.1). One of them is "rtas-version", an integer encoding of the RTAS interface version, and LoPAR says it describes version 1 of that interface.
Quoted 6 lines
spapr_dt_rtas()sets "rtas-size", "rtas-error-log-max" and "rtas-event-scan-rate" but never "rtas-version", so a client that reads it finds no RTAS: NetBSD's RTAS driver fails to attach when the property is absent.Set it to 1, the version LoPAR describes.
The fix looks correct and the motivation is well explained. I do see that PAPR v10.60 [1] does mention:
"R–7.2.6–3. The OF properties listed in Table 20, “OF Device Tree Properties” must be in the /rtas device tree node prior to booting the OS"
And in Table 20:
“rtas-version” : An integer encoding of the RTAS interface version. This
document describes version 1
Nit: The existing QEMU spapr codebase consistently references the spec as "PAPR" rather than "LoPAR"/"LoPAPR". I would prefer the commit message reference PAPR as the primary spec, with LoPAR as secondary if you want to retain both citations.
[1] https://openpowerfoundation.org/specifications/papr/
Quoted 24 lines
Signed-off-by Showta Ishizaki <[email protected]>--- hw/ppc/spapr.c | 1 + include/hw/ppc/spapr.h | 3 +++ 2 files changed, 4 insertions(+)hw/ppc/spapr.c +1
-0@@ -1068,6 +1068,7 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt) RTAS_ERROR_LOG_MAX));_FDT (fdt_setprop_cell (fdt, rtas,"rtas-event-scan-rate" ,RTAS_EVENT_SCAN_RATE )); +_FDT (fdt_setprop_cell (fdt, rtas,"rtas-version" ,RTAS_VERSION ));g_assert (msi_nonbroken);_FDT (fdt_setprop (fdt, rtas,"ibm,change-msix-capable" ,NULL ,0 ));include/hw/ppc/spapr.h +0
-0
include/hw/ppc/spapr.h void spapr_load_rtas(SpaprMachineState *spapr, void *fdt, hwaddr addr); · line 833
Quoted 4 lines
include/hw/ppc/spapr.h +1
-0@@ -830,6 +830,9 @@ void spapr_load_rtas(SpaprMachineState *spapr, void *fdt, hwaddr addr);#define RTAS_EVENT_SCAN_RATE 1 +/* The interface version LoPAR 2.9 Table 7.4 describes */
As mentioned above, I think the comment should refer to PAPR instead.
include/hw/ppc/spapr.h void spapr_load_rtas(SpaprMachineState *spapr, void *fdt, hwaddr addr); · line 834
Quoted 1 line
include/hw/ppc/spapr.h +1
-0+#define RTAS_VERSION 1
Code change itself is good. Tested it on a nestedv2 KVM guest and with this patch the property is present as expected which was not there without the patch.
Without patch
=============
# lsprop /sys/firmware/devicetree/base/rtas/rtas-* /sys/firmware/devicetree/base/rtas/rtas-error-log-max 00000800 (2048) /sys/firmware/devicetree/base/rtas/rtas-event-scan-rate 00000001 /sys/firmware/devicetree/base/rtas/rtas-size 0000085c (2140)
With patch
===========
# lsprop /sys/firmware/devicetree/base/rtas/rtas-* /sys/firmware/devicetree/base/rtas/rtas-error-log-max 00000800 (2048) /sys/firmware/devicetree/base/rtas/rtas-event-scan-rate 00000001 /sys/firmware/devicetree/base/rtas/rtas-size 0000085c (2140) /sys/firmware/devicetree/base/rtas/rtas-version 00000001
With the above suggested nits taken care of, please feel free to add:
Thanks,
Amit
Hi Amit,
I am sorry for the slow reply. I have just started a new job, and it took me a while to get back to this work.
Thank you for the review, for checking it against PAPR v10.60, and for testing it on a nestedv2 KVM guest. Both of your suggestions make sense; v2 below cites PAPR v10.60 first, keeps LoPAR and LoPAPR as secondary references, and the comment on RTAS_VERSION now names PAPR v10.60 Table 20. There is no other change to the code.
Thanks,
Showta
-- >8 --
Subject: [PATCH v2] hw/ppc/spapr: Add the "rtas-version" property to /rtas
PAPR requires every property listed in its table of /rtas device tree properties to be present before the OS is booted (R-7.2.6-3 and Table 20 in PAPR v10.60; the same requirement is in LoPAR 2.9 and LoPAPR 1.1). One of them is "rtas-version", an integer encoding of the RTAS interface version, and PAPR says it describes version 1 of that interface.
spapr_dt_rtas() sets "rtas-size", "rtas-error-log-max" and "rtas-event-scan-rate" but never "rtas-version", so a client that reads it finds no RTAS: NetBSD's RTAS driver fails to attach when the property is absent.
Set it to 1, the version PAPR describes.
---
v2:
- Cite PAPR v10.60 first, as the rest of the spapr code does, and keep LoPAR and LoPAPR as secondary references.
- The comment on RTAS_VERSION now names PAPR v10.60 Table 20.
hw/ppc/spapr.c | 1 + include/hw/ppc/spapr.h | 3 +++ 2 files changed, 4 insertions(+)
hw/ppc/spapr.c +1 -0
@@ -1068,6 +1068,7 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt) RTAS_ERROR_LOG_MAX));_FDT (fdt_setprop_cell (fdt, rtas,"rtas-event-scan-rate" ,RTAS_EVENT_SCAN_RATE )); +_FDT (fdt_setprop_cell (fdt, rtas,"rtas-version" ,RTAS_VERSION ));g_assert (msi_nonbroken);_FDT (fdt_setprop (fdt, rtas,"ibm,change-msix-capable" ,NULL ,0 ));
include/hw/ppc/spapr.h +3 -0
@@ -830,6 +830,9 @@ void spapr_load_rtas(SpaprMachineState *spapr, void *fdt, hwaddr addr);#define RTAS_EVENT_SCAN_RATE 1 +/* The RTAS interface version PAPR v10.60 Table 20 describes */ +#define RTAS_VERSION 1 +/* This helper should be used to encode interrupt specifiers when the related * "interrupt-controller" node has its "#interrupt-cells" property set to 2 (ie, * VIO devices, RTAS event sources and PHBs).
Hi Showta,
Thanks for addressing the nits — both look good. A few things before this is ready:
1. Please send v2 as a proper standalone patch submission (not inline in a reply), so it gets picked up correctly by patchwork.
2. Since the nits have been addressed, please carry over the tags in v2:
3. One minor nit - see below:
Quoted 59 lines · 蟹澤翔太
Hi Amit,
I am sorry for the slow reply. I have just started a new job, and it took me a while to get back to this work.
Thank you for the review, for checking it against PAPR v10.60, and for testing it on a nestedv2 KVM guest. Both of your suggestions make sense; v2 below cites PAPR v10.60 first, keeps LoPAR and LoPAPR as secondary references, and the comment on
RTAS_VERSIONnow names PAPR v10.60 Table 20. There is no other change to the code.Thanks,
Showta-- >8 --
Subject: [PATCH v2] hw/ppc/spapr: Add the "rtas-version" property to /rtas PAPR requires every property listed in its table of /rtas device tree properties to be present before the OS is booted (R-7.2.6-3 and Table 20 in PAPR v10.60; the same requirement is in LoPAR 2.9 and LoPAPR 1.1). One of them is "rtas-version", an integer encoding of the RTAS interface version, and PAPR says it describes version 1 of that interface.
spapr_dt_rtas()sets "rtas-size", "rtas-error-log-max" and "rtas-event-scan-rate" but never "rtas-version", so a client that reads it finds no RTAS: NetBSD's RTAS driver fails to attach when the property is absent.Set it to 1, the version PAPR describes.
Signed-off-by Showta Ishizaki <[email protected]>---
v2:
- Cite PAPR v10.60 first, as the rest of the spapr code does, and keep LoPAR and LoPAPR as secondary references.
- The comment onRTAS_VERSIONnow names PAPR v10.60 Table 20.hw/ppc/spapr.c | 1 + include/hw/ppc/spapr.h | 3 +++ 2 files changed, 4 insertions(+)hw/ppc/spapr.c +1
-0@@ -1068,6 +1068,7 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt) RTAS_ERROR_LOG_MAX));_FDT (fdt_setprop_cell (fdt, rtas,"rtas-event-scan-rate" ,RTAS_EVENT_SCAN_RATE )); +_FDT (fdt_setprop_cell (fdt, rtas,"rtas-version" ,RTAS_VERSION ));g_assert (msi_nonbroken);_FDT (fdt_setprop (fdt, rtas,"ibm,change-msix-capable" ,NULL ,0 ));include/hw/ppc/spapr.h +0
-0
include/hw/ppc/spapr.h void spapr_load_rtas(SpaprMachineState *spapr, void *fdt, hwaddr addr); · line 833
Quoted 4 lines
include/hw/ppc/spapr.h +1
-0@@ -830,6 +830,9 @@ void spapr_load_rtas(SpaprMachineState *spapr, void *fdt, hwaddr addr);#define RTAS_EVENT_SCAN_RATE 1 +/* The RTAS interface version PAPR v10.60 Table 20 describes */
The wording reads a bit awkwardly. How about:
/* RTAS interface version, as defined by PAPR v10.60 Table 20 */
Thanks,
Amit
Quoted 5 lines · Amit Machhiwal
Hi Showta,
Thanks for addressing the nits — both look good. A few things before this is ready:
Quoted 7 lines
1. Please send v2 as a proper standalone patch submission (not inline in a reply), so it gets picked up correctly by patchwork.
2. Since the nits have been addressed, please carry over the tags in v2:
Reviewed-by Amit Machhiwal [email protected]Tested-by Amit Machhiwal [email protected]
Correction, the tags should read:
Thanks,
Amit