qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Greg Kurz <groug@kaod.org>
Cc: Eduardo Habkost <ehabkost@redhat.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	qemu-devel@nongnu.org, Alexander Graf <agraf@suse.de>,
	qemu-ppc@nongnu.org, Cedric Le Goater <clg@kaod.org>,
	Bharata B Rao <bharata@linux.vnet.ibm.com>,
	Scott Wood <scottwood@freescale.com>,
	Igor Mammedov <imammedo@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 5/7] ppc: each machine type to provide vcpu_dt_id
Date: Fri, 8 Jul 2016 11:57:07 +1000	[thread overview]
Message-ID: <20160708015707.GW14675@voom.fritz.box> (raw)
In-Reply-To: <20160707105502.4f3aa6fa@bahia.lan>

[-- Attachment #1: Type: text/plain, Size: 9899 bytes --]

On Thu, Jul 07, 2016 at 10:55:02AM +0200, Greg Kurz wrote:
> On Thu, 7 Jul 2016 12:01:51 +1000
> David Gibson <david@gibson.dropbear.id.au> wrote:
> 
> > On Wed, Jul 06, 2016 at 02:14:36PM +0200, Greg Kurz wrote:
> > > This patch switches machine types to provide device-tree cpu ids.
> > > 
> > > We have three cases to handle:
> > > 
> > > - pseries < 2.7 call ppc_cpu_init() and should compute the DT id as it is
> > >   currently done in the target code.
> > > 
> > > - pseries 2.7 don't call ppc_cpu_init() and compute the DT as the sum of
> > >   the core DT id and the the thread index within the core
> > > 
> > > - all other machine types don't support SMT and just need to provide a
> > >   different index for each vcpu  
> > 
> > Would it instead make sense to expose the dt_id as a vcpu property and
> > have the machine type set it if it wants to override?
> > 
> 
> And the default would be cs->cpu_index I guess, correct ?

That was my intention.  However Bharata has since pointed out that
this doesn't work, because the cpu_index is only computed at realize time.

> > dt_id is probably not a good name though, since there's no guarantee
> > the machine type actually uses a dt, which is part of the point of
> > this series.
> > 
> 
> machine_cpu_index ?
> 
> > > 
> > > Signed-off-by: Greg Kurz <groug@kaod.org>
> > > ---
> > >  hw/ppc/e500.c           |    2 +-
> > >  hw/ppc/mac_newworld.c   |    2 +-
> > >  hw/ppc/mac_oldworld.c   |    2 +-
> > >  hw/ppc/ppc.c            |    5 ++++-
> > >  hw/ppc/ppc440_bamboo.c  |    2 +-
> > >  hw/ppc/ppc4xx_devs.c    |    2 +-
> > >  hw/ppc/prep.c           |    2 +-
> > >  hw/ppc/spapr.c          |    5 ++++-
> > >  hw/ppc/spapr_cpu_core.c |    7 +++++--
> > >  hw/ppc/virtex_ml507.c   |    2 +-
> > >  include/hw/ppc/ppc.h    |    2 +-
> > >  11 files changed, 21 insertions(+), 12 deletions(-)
> > > 
> > > diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
> > > index b9221cc2c14a..513a42a3f952 100644
> > > --- a/hw/ppc/e500.c
> > > +++ b/hw/ppc/e500.c
> > > @@ -823,7 +823,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
> > >          CPUState *cs;
> > >          qemu_irq *input;
> > >  
> > > -        cpu = ppc_cpu_init(machine->cpu_model);
> > > +        cpu = ppc_cpu_init(machine->cpu_model, i);
> > >          if (cpu == NULL) {
> > >              fprintf(stderr, "Unable to initialize CPU!\n");
> > >              exit(1);
> > > diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
> > > index 366089085844..9ef9504ff29c 100644
> > > --- a/hw/ppc/mac_newworld.c
> > > +++ b/hw/ppc/mac_newworld.c
> > > @@ -194,7 +194,7 @@ static void ppc_core99_init(MachineState *machine)
> > >      }
> > >      ppc_cpu_parse_features(machine->cpu_model);
> > >      for (i = 0; i < smp_cpus; i++) {
> > > -        cpu = ppc_cpu_init(machine->cpu_model);
> > > +        cpu = ppc_cpu_init(machine->cpu_model, i);
> > >          if (cpu == NULL) {
> > >              fprintf(stderr, "Unable to find PowerPC CPU definition\n");
> > >              exit(1);
> > > diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
> > > index 5c2dc53cb584..0b09a8da8bf2 100644
> > > --- a/hw/ppc/mac_oldworld.c
> > > +++ b/hw/ppc/mac_oldworld.c
> > > @@ -114,7 +114,7 @@ static void ppc_heathrow_init(MachineState *machine)
> > >          machine->cpu_model = "G3";
> > >      ppc_cpu_parse_features(machine->cpu_model);
> > >      for (i = 0; i < smp_cpus; i++) {
> > > -        cpu = ppc_cpu_init(machine->cpu_model);
> > > +        cpu = ppc_cpu_init(machine->cpu_model, i);
> > >          if (cpu == NULL) {
> > >              fprintf(stderr, "Unable to find PowerPC CPU definition\n");
> > >              exit(1);
> > > diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
> > > index 0df32a9b3965..3d7739b9540e 100644
> > > --- a/hw/ppc/ppc.c
> > > +++ b/hw/ppc/ppc.c
> > > @@ -1353,7 +1353,7 @@ PowerPCCPU *ppc_get_vcpu_by_dt_id(int cpu_dt_id)
> > >      return NULL;
> > >  }
> > >  
> > > -PowerPCCPU *ppc_cpu_init(const char *cpu_model)
> > > +PowerPCCPU *ppc_cpu_init(const char *cpu_model, unsigned vcpu_dt_id)
> > >  {
> > >      PowerPCCPU *cpu;
> > >      ObjectClass *oc;
> > > @@ -1373,6 +1373,9 @@ PowerPCCPU *ppc_cpu_init(const char *cpu_model)
> > >      }
> > >  
> > >      cpu = POWERPC_CPU(object_new(object_class_get_name(oc)));
> > > +
> > > +    cpu->cpu_dt_id = vcpu_dt_id;
> > > +
> > >      object_property_set_bool(OBJECT(cpu), true, "realized", &err);
> > >  
> > >  out:
> > > diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c
> > > index 709a779cba7e..9dbe87207304 100644
> > > --- a/hw/ppc/ppc440_bamboo.c
> > > +++ b/hw/ppc/ppc440_bamboo.c
> > > @@ -187,7 +187,7 @@ static void bamboo_init(MachineState *machine)
> > >          machine->cpu_model = "440EP";
> > >      }
> > >      ppc_cpu_parse_features(machine->cpu_model);
> > > -    cpu = ppc_cpu_init(machine->cpu_model);
> > > +    cpu = ppc_cpu_init(machine->cpu_model, 0);
> > >      if (cpu == NULL) {
> > >          fprintf(stderr, "Unable to initialize CPU!\n");
> > >          exit(1);
> > > diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c
> > > index 8cbe50361e86..ac39202c0d1c 100644
> > > --- a/hw/ppc/ppc4xx_devs.c
> > > +++ b/hw/ppc/ppc4xx_devs.c
> > > @@ -57,7 +57,7 @@ PowerPCCPU *ppc4xx_init(const char *cpu_model,
> > >  
> > >      /* init CPUs */
> > >      ppc_cpu_parse_features(cpu_model);
> > > -    cpu = ppc_cpu_init(cpu_model);
> > > +    cpu = ppc_cpu_init(cpu_model, 0);
> > >      if (cpu == NULL) {
> > >          fprintf(stderr, "Unable to find PowerPC %s CPU definition\n",
> > >                  cpu_model);
> > > diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
> > > index 99409a09f0ef..9e8cf233d98d 100644
> > > --- a/hw/ppc/prep.c
> > > +++ b/hw/ppc/prep.c
> > > @@ -510,7 +510,7 @@ static void ppc_prep_init(MachineState *machine)
> > >          machine->cpu_model = "602";
> > >      ppc_cpu_parse_features(machine->cpu_model);
> > >      for (i = 0; i < smp_cpus; i++) {
> > > -        cpu = ppc_cpu_init(machine->cpu_model);
> > > +        cpu = ppc_cpu_init(machine->cpu_model, i);
> > >          if (cpu == NULL) {
> > >              fprintf(stderr, "Unable to find PowerPC CPU definition\n");
> > >              exit(1);
> > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> > > index 8ca80812f16a..baefc7bd279c 100644
> > > --- a/hw/ppc/spapr.c
> > > +++ b/hw/ppc/spapr.c
> > > @@ -1849,7 +1849,10 @@ static void ppc_spapr_init(MachineState *machine)
> > >          g_free(type);
> > >      } else {
> > >          for (i = 0; i < smp_cpus; i++) {
> > > -            PowerPCCPU *cpu = ppc_cpu_init(machine->cpu_model);
> > > +            unsigned core_index = i / smp_threads;
> > > +            unsigned thread_index = i % smp_threads;
> > > +            PowerPCCPU *cpu = ppc_cpu_init(machine->cpu_model,
> > > +                                           core_index * smt + thread_index);
> > >              if (cpu == NULL) {
> > >                  error_report("Unable to find PowerPC CPU definition");
> > >                  exit(1);
> > > diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
> > > index 70b6b0b5ee17..e3a3024baf32 100644
> > > --- a/hw/ppc/spapr_cpu_core.c
> > > +++ b/hw/ppc/spapr_cpu_core.c
> > > @@ -259,13 +259,16 @@ out:
> > >      error_propagate(errp, local_err);
> > >  }
> > >  
> > > -static void spapr_cpu_core_realize_child(Object *child, Error **errp)
> > > +static void spapr_cpu_core_realize_child(Object *child, unsigned vcpu_dt_id,
> > > +                                         Error **errp)
> > >  {
> > >      Error *local_err = NULL;
> > >      sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
> > >      CPUState *cs = CPU(child);
> > >      PowerPCCPU *cpu = POWERPC_CPU(cs);
> > >  
> > > +    cpu->cpu_dt_id = vcpu_dt_id;
> > > +
> > >      object_property_set_bool(child, true, "realized", &local_err);
> > >      if (local_err) {
> > >          error_propagate(errp, local_err);
> > > @@ -306,7 +309,7 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp)
> > >      for (j = 0; j < cc->nr_threads; j++) {
> > >          obj = sc->threads + j * size;
> > >  
> > > -        spapr_cpu_core_realize_child(obj, &local_err);
> > > +        spapr_cpu_core_realize_child(obj, cc->core_id + j, &local_err);
> > >          if (local_err) {
> > >              goto err;
> > >          }
> > > diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
> > > index a19dd17addda..efbc58137df4 100644
> > > --- a/hw/ppc/virtex_ml507.c
> > > +++ b/hw/ppc/virtex_ml507.c
> > > @@ -97,7 +97,7 @@ static PowerPCCPU *ppc440_init_xilinx(ram_addr_t *ram_size,
> > >      qemu_irq *irqs;
> > >  
> > >      ppc_cpu_parse_features(cpu_model);
> > > -    cpu = ppc_cpu_init(cpu_model);
> > > +    cpu = ppc_cpu_init(cpu_model, 0);
> > >      if (cpu == NULL) {
> > >          fprintf(stderr, "Unable to initialize CPU!\n");
> > >          exit(1);
> > > diff --git a/include/hw/ppc/ppc.h b/include/hw/ppc/ppc.h
> > > index 2ed063e09bec..379b2f5d8e3d 100644
> > > --- a/include/hw/ppc/ppc.h
> > > +++ b/include/hw/ppc/ppc.h
> > > @@ -106,6 +106,6 @@ enum {
> > >  /* ppc_booke.c */
> > >  void ppc_booke_timers_init(PowerPCCPU *cpu, uint32_t freq, uint32_t flags);
> > >  
> > > -PowerPCCPU *ppc_cpu_init(const char *cpu_model);
> > > +PowerPCCPU *ppc_cpu_init(const char *cpu_model, unsigned vcpu_dt_id);
> > >  void ppc_cpu_parse_features(const char *cpu_model);
> > >  #endif
> > >   
> > 
> 



-- 
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-07-08  2:02 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-06 12:12 [Qemu-devel] [PATCH v3 0/7] ppc: compute cpu_dt_id in the machine code Greg Kurz
2016-07-06 12:13 ` [Qemu-devel] [PATCH v3 1/7] ppc: different creation paths for cpus in system and user mode Greg Kurz
2016-07-07  1:11   ` David Gibson
2016-07-06 12:13 ` [Qemu-devel] [PATCH v3 2/7] ppc: move smp_threads sanity checks to spapr Greg Kurz
2016-07-07  1:12   ` David Gibson
2016-07-07  1:57     ` Benjamin Herrenschmidt
2016-07-07  2:05       ` David Gibson
2016-07-07  7:15       ` Greg Kurz
2016-07-07  6:49     ` Greg Kurz
2016-07-06 12:13 ` [Qemu-devel] [PATCH v3 3/7] ppc: parse cpu features once Greg Kurz
2016-07-06 12:14 ` [Qemu-devel] [PATCH v3 4/7] ppc: open code cpu creation for machine types Greg Kurz
2016-07-06 16:06   ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2016-07-07  1:59     ` David Gibson
2016-07-07  1:54   ` [Qemu-devel] " David Gibson
2016-07-06 12:14 ` [Qemu-devel] [PATCH v3 5/7] ppc: each machine type to provide vcpu_dt_id Greg Kurz
2016-07-07  2:01   ` David Gibson
2016-07-07  8:55     ` Greg Kurz
2016-07-08  1:57       ` David Gibson [this message]
2016-07-08  6:41         ` Greg Kurz
2016-07-06 12:14 ` [Qemu-devel] [PATCH v3 6/7] ppc: drop vcpu_idt_id bits from the target code Greg Kurz
2016-07-06 12:14 ` [Qemu-devel] [PATCH v3 7/7] spapr: consolidate the logic of core cpu_dt_id Greg Kurz
2016-07-07  2:05   ` David Gibson
2016-07-07  8:44     ` Greg Kurz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160708015707.GW14675@voom.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=agraf@suse.de \
    --cc=benh@kernel.crashing.org \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=clg@kaod.org \
    --cc=ehabkost@redhat.com \
    --cc=groug@kaod.org \
    --cc=imammedo@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=scottwood@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).