qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] spapr: remove the 'nr_servers' field from the m


From: David Gibson
Subject: Re: [Qemu-devel] [PATCH] spapr: remove the 'nr_servers' field from the machine
Date: Tue, 11 Apr 2017 17:06:46 +1000
User-agent: Mutt/1.8.0 (2017-02-23)

On Wed, Apr 05, 2017 at 08:37:44AM +0200, Cédric Le Goater wrote:
> xics_system_init() does not need 'nr_servers' anymore as it is only
> used to define the 'interrupt-controller' node in the device tree. So
> let's just compute the value when calling spapr_dt_xics().
> 
> This also gives us an opportunity to simplify the xics_system_init()
> routine and introduce a specific spapr_ics_create() helper to create
> the sPAPR ICS object.
> 
> Signed-off-by: Cédric Le Goater <address@hidden>

Applied to ppc-for-2.10.

> ---
>  hw/ppc/spapr.c         | 56 
> ++++++++++++++++++++++----------------------------
>  include/hw/ppc/spapr.h |  1 -
>  2 files changed, 24 insertions(+), 33 deletions(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 4e87ffe776ea..df231a3fc4a1 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -96,45 +96,40 @@
>  
>  #define HTAB_SIZE(spapr)        (1ULL << ((spapr)->htab_shift))
>  
> -static int try_create_xics(sPAPRMachineState *spapr, const char *type_ics,
> -                           const char *type_icp, int nr_servers,
> -                           int nr_irqs, Error **errp)
> +static ICSState *spapr_ics_create(sPAPRMachineState *spapr,
> +                                  const char *type_ics,
> +                                  int nr_irqs, Error **errp)
>  {
> -    XICSFabric *xi = XICS_FABRIC(spapr);
>      Error *err = NULL, *local_err = NULL;
> -    ICSState *ics = NULL;
> +    Object *obj;
>  
> -    ics = ICS_SIMPLE(object_new(type_ics));
> -    object_property_add_child(OBJECT(spapr), "ics", OBJECT(ics), NULL);
> -    object_property_set_int(OBJECT(ics), nr_irqs, "nr-irqs", &err);
> -    object_property_add_const_link(OBJECT(ics), "xics", OBJECT(xi), NULL);
> -    object_property_set_bool(OBJECT(ics), true, "realized", &local_err);
> +    obj = object_new(type_ics);
> +    object_property_add_child(OBJECT(spapr), "ics", obj, NULL);
> +    object_property_add_const_link(obj, "xics", OBJECT(spapr), &error_abort);
> +    object_property_set_int(obj, nr_irqs, "nr-irqs", &err);
> +    object_property_set_bool(obj, true, "realized", &local_err);
>      error_propagate(&err, local_err);
>      if (err) {
>          error_propagate(errp, err);
> -        return -1;
> +        return NULL;
>      }
>  
> -    spapr->nr_servers = nr_servers;
> -    spapr->ics = ics;
> -    spapr->icp_type = type_icp;
> -    return 0;
> +    return ICS_SIMPLE(obj);
>  }
>  
> -static int xics_system_init(MachineState *machine,
> -                            int nr_servers, int nr_irqs, Error **errp)
> +static void xics_system_init(MachineState *machine, int nr_irqs, Error 
> **errp)
>  {
> -    int rc = -1;
> +    sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
>  
>      if (kvm_enabled()) {
>          Error *err = NULL;
>  
>          if (machine_kernel_irqchip_allowed(machine) &&
> -            !xics_kvm_init(SPAPR_MACHINE(machine), errp)) {
> -            rc = try_create_xics(SPAPR_MACHINE(machine), TYPE_ICS_KVM,
> -                                 TYPE_KVM_ICP, nr_servers, nr_irqs, &err);
> +            !xics_kvm_init(spapr, errp)) {
> +            spapr->icp_type = TYPE_KVM_ICP;
> +            spapr->ics = spapr_ics_create(spapr, TYPE_ICS_KVM, nr_irqs, 
> &err);
>          }
> -        if (machine_kernel_irqchip_required(machine) && rc < 0) {
> +        if (machine_kernel_irqchip_required(machine) && !spapr->ics) {
>              error_reportf_err(err,
>                                "kernel_irqchip requested but unavailable: ");
>          } else {
> @@ -142,13 +137,11 @@ static int xics_system_init(MachineState *machine,
>          }
>      }
>  
> -    if (rc < 0) {
> -        xics_spapr_init(SPAPR_MACHINE(machine), errp);
> -        rc = try_create_xics(SPAPR_MACHINE(machine), TYPE_ICS_SIMPLE,
> -                               TYPE_ICP, nr_servers, nr_irqs, errp);
> +    if (!spapr->ics) {
> +        xics_spapr_init(spapr, errp);
> +        spapr->icp_type = TYPE_ICP;
> +        spapr->ics = spapr_ics_create(spapr, TYPE_ICS_SIMPLE, nr_irqs, errp);
>      }
> -
> -    return rc;
>  }
>  
>  static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,
> @@ -912,6 +905,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr,
>      void *fdt;
>      sPAPRPHBState *phb;
>      char *buf;
> +    int smt = kvmppc_smt_threads();
>  
>      fdt = g_malloc0(FDT_MAX_SIZE);
>      _FDT((fdt_create_empty_tree(fdt, FDT_MAX_SIZE)));
> @@ -951,7 +945,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr,
>      _FDT(fdt_setprop_cell(fdt, 0, "#size-cells", 2));
>  
>      /* /interrupt controller */
> -    spapr_dt_xics(spapr->nr_servers, fdt, PHANDLE_XICP);
> +    spapr_dt_xics(DIV_ROUND_UP(max_cpus * smt, smp_threads), fdt, 
> PHANDLE_XICP);
>  
>      ret = spapr_populate_memory(spapr, fdt);
>      if (ret < 0) {
> @@ -1970,7 +1964,6 @@ static void ppc_spapr_init(MachineState *machine)
>      hwaddr node0_size = spapr_node0_size();
>      long load_limit, fw_size;
>      char *filename;
> -    int smt = kvmppc_smt_threads();
>  
>      msi_nonbroken = true;
>  
> @@ -2021,8 +2014,7 @@ static void ppc_spapr_init(MachineState *machine)
>      load_limit = MIN(spapr->rma_size, RTAS_MAX_ADDR) - FW_OVERHEAD;
>  
>      /* Set up Interrupt Controller before we create the VCPUs */
> -    xics_system_init(machine, DIV_ROUND_UP(max_cpus * smt, smp_threads),
> -                     XICS_IRQS_SPAPR, &error_fatal);
> +    xics_system_init(machine, XICS_IRQS_SPAPR, &error_fatal);
>  
>      /* Set up containers for ibm,client-set-architecture negotiated options 
> */
>      spapr->ov5 = spapr_ovec_new();
> diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
> index db3d4acb18a6..742777f40a2d 100644
> --- a/include/hw/ppc/spapr.h
> +++ b/include/hw/ppc/spapr.h
> @@ -95,7 +95,6 @@ struct sPAPRMachineState {
>      char *kvm_type;
>      MemoryHotplugState hotplug_memory;
>  
> -    uint32_t nr_servers;
>      const char *icp_type;
>  };
>  

-- 
David Gibson                    | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
                                | _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]