[Qemu-devel] [PATCH v3 16/19] spapr: Expose the name of the interrupt controller node

Greg Kurz posted 19 patches 6 years, 9 months ago
There is a newer version of this series
[Qemu-devel] [PATCH v3 16/19] spapr: Expose the name of the interrupt controller node
Posted by Greg Kurz 6 years, 9 months ago
This will be needed by PHB hotplug in order to access the "phandle"
property of the interrupt controller node.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 hw/intc/xics_spapr.c        |    2 +-
 include/hw/ppc/spapr_xive.h |    5 +++++
 include/hw/ppc/xics_spapr.h |    7 +++++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
index 375cb883c86d..ec50e21b8607 100644
--- a/hw/intc/xics_spapr.c
+++ b/hw/intc/xics_spapr.c
@@ -252,7 +252,7 @@ int spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt)
     };
     int node;
 
-    _FDT(node = fdt_add_subnode(fdt, 0, "interrupt-controller"));
+    _FDT(node = fdt_add_subnode(fdt, 0, XICS_NODENAME));
 
     _FDT(fdt_setprop_string(fdt, node, "device_type",
                             "PowerPC-External-Interrupt-Presentation"));
diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h
index deea34b03ee5..e769c2f9a018 100644
--- a/include/hw/ppc/spapr_xive.h
+++ b/include/hw/ppc/spapr_xive.h
@@ -51,4 +51,9 @@ int spapr_dt_xive(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt);
 void spapr_xive_set_tctx_os_cam(XiveTCTX *tctx);
 void spapr_xive_mmio_set_enabled(sPAPRXive *xive, bool enable);
 
+static inline const char *spapr_xive_get_nodename(sPAPRXive *xive)
+{
+    return xive->nodename;
+}
+
 #endif /* PPC_SPAPR_XIVE_H */
diff --git a/include/hw/ppc/xics_spapr.h b/include/hw/ppc/xics_spapr.h
index 9f51f8621f75..fd66cf7bbba3 100644
--- a/include/hw/ppc/xics_spapr.h
+++ b/include/hw/ppc/xics_spapr.h
@@ -29,6 +29,13 @@
 
 #include "hw/ppc/spapr.h"
 
+#define XICS_NODENAME "interrupt-controller"
+
+static inline const char *xics_spapr_get_nodename(void)
+{
+    return XICS_NODENAME;
+}
+
 int spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt);
 int xics_kvm_init(sPAPRMachineState *spapr, Error **errp);
 void xics_spapr_init(sPAPRMachineState *spapr);


Re: [Qemu-devel] [PATCH v3 16/19] spapr: Expose the name of the interrupt controller node
Posted by Cédric Le Goater 6 years, 9 months ago
On 1/17/19 6:16 PM, Greg Kurz wrote:
> This will be needed by PHB hotplug in order to access the "phandle"
> property of the interrupt controller node.
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>
> ---
>  hw/intc/xics_spapr.c        |    2 +-
>  include/hw/ppc/spapr_xive.h |    5 +++++
>  include/hw/ppc/xics_spapr.h |    7 +++++++
>  3 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
> index 375cb883c86d..ec50e21b8607 100644
> --- a/hw/intc/xics_spapr.c
> +++ b/hw/intc/xics_spapr.c
> @@ -252,7 +252,7 @@ int spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt)
>      };
>      int node;
>  
> -    _FDT(node = fdt_add_subnode(fdt, 0, "interrupt-controller"));
> +    _FDT(node = fdt_add_subnode(fdt, 0, XICS_NODENAME));
>  
>      _FDT(fdt_setprop_string(fdt, node, "device_type",
>                              "PowerPC-External-Interrupt-Presentation"));
> diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h
> index deea34b03ee5..e769c2f9a018 100644
> --- a/include/hw/ppc/spapr_xive.h
> +++ b/include/hw/ppc/spapr_xive.h
> @@ -51,4 +51,9 @@ int spapr_dt_xive(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt);
>  void spapr_xive_set_tctx_os_cam(XiveTCTX *tctx);
>  void spapr_xive_mmio_set_enabled(sPAPRXive *xive, bool enable);
>  
> +static inline const char *spapr_xive_get_nodename(sPAPRXive *xive)
> +{
> +    return xive->nodename;
> +}

There I would compute the nodename here in a static char * and return it. 

>  #endif /* PPC_SPAPR_XIVE_H */
> diff --git a/include/hw/ppc/xics_spapr.h b/include/hw/ppc/xics_spapr.h
> index 9f51f8621f75..fd66cf7bbba3 100644
> --- a/include/hw/ppc/xics_spapr.h
> +++ b/include/hw/ppc/xics_spapr.h
> @@ -29,6 +29,13 @@
>  
>  #include "hw/ppc/spapr.h"
>  
> +#define XICS_NODENAME "interrupt-controller"
> +
> +static inline const char *xics_spapr_get_nodename(void)
> +{
> +    return XICS_NODENAME;
> +}

I don't see much point in that helper. 

>  int spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt);
>  int xics_kvm_init(sPAPRMachineState *spapr, Error **errp);
>  void xics_spapr_init(sPAPRMachineState *spapr);
>