All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for 2.7] ppc: parse cpu features once
@ 2016-08-10 19:08 Cédric Le Goater
  2016-08-10 19:10 ` Cédric Le Goater
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Cédric Le Goater @ 2016-08-10 19:08 UTC (permalink / raw)
  To: qemu-ppc
  Cc: David Gibson, Bharata B Rao, qemu-devel, Eduardo Habkost,
	Greg Kurz, Cédric Le Goater

From: Greg Kurz <groug@kaod.org>

Considering that features are converted to global properties and
global properties are automatically applied to every new instance
of created CPU (at object_new() time), there is no point in
parsing cpu_model string every time a CPU created. So move
parsing outside CPU creation loop and do it only once.

Parsing also should be done before any CPU is created so that
features would affect the first CPU a well.

This patch does that for all PowerPC machine types.

It is based on previous work from Bharata:

https://lists.nongnu.org/archive/html/qemu-devel/2016-06/msg07564.html

Signed-off-by: Greg Kurz <groug@kaod.org>
[clg: only kept the fix for the spapr platform. support for other
      platform will be added in 2.8 ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>

---

This is a standalone version of patch 2 from my latest series:

https://lists.nongnu.org/archive/html/qemu-devel/2016-07/msg02433.html

The only changes are trivial conflict fixes caused by the introduction
of ppc_cpu_init by patch 1.

---
 hw/ppc/ppc.c         |   26 ++++++++++++++++++++++++++
 hw/ppc/spapr.c       |    2 ++
 include/hw/ppc/ppc.h |    1 +
 3 files changed, 29 insertions(+)

Index: qemu-dgibson-for-2.8.git/hw/ppc/ppc.c
===================================================================
--- qemu-dgibson-for-2.8.git.orig/hw/ppc/ppc.c
+++ qemu-dgibson-for-2.8.git/hw/ppc/ppc.c
@@ -33,6 +33,7 @@
 #include "hw/timer/m48t59.h"
 #include "qemu/log.h"
 #include "qemu/error-report.h"
+#include "qapi/error.h"
 #include "hw/loader.h"
 #include "sysemu/kvm.h"
 #include "kvm_ppc.h"
@@ -1350,3 +1351,28 @@ PowerPCCPU *ppc_get_vcpu_by_dt_id(int cp
 
     return NULL;
 }
+
+void ppc_cpu_parse_features(const char *cpu_model)
+{
+    CPUClass *cc;
+    ObjectClass *oc;
+    const char *typename;
+    gchar **model_pieces;
+
+    model_pieces = g_strsplit(cpu_model, ",", 2);
+    if (!model_pieces[0]) {
+        error_report("Invalid/empty CPU model name");
+        exit(1);
+    }
+
+    oc = cpu_class_by_name(TYPE_POWERPC_CPU, model_pieces[0]);
+    if (oc == NULL) {
+        error_report("Unable to find CPU definition: %s", model_pieces[0]);
+        exit(1);
+    }
+
+    typename = object_class_get_name(oc);
+    cc = CPU_CLASS(oc);
+    cc->parse_features(typename, model_pieces[1], &error_fatal);
+    g_strfreev(model_pieces);
+}
Index: qemu-dgibson-for-2.8.git/hw/ppc/spapr.c
===================================================================
--- qemu-dgibson-for-2.8.git.orig/hw/ppc/spapr.c
+++ qemu-dgibson-for-2.8.git/hw/ppc/spapr.c
@@ -1769,6 +1769,8 @@ static void ppc_spapr_init(MachineState
         machine->cpu_model = kvm_enabled() ? "host" : "POWER7";
     }
 
+    ppc_cpu_parse_features(machine->cpu_model);
+
     if (mc->query_hotpluggable_cpus) {
         char *type = spapr_get_cpu_core_type(machine->cpu_model);
 
Index: qemu-dgibson-for-2.8.git/include/hw/ppc/ppc.h
===================================================================
--- qemu-dgibson-for-2.8.git.orig/include/hw/ppc/ppc.h
+++ qemu-dgibson-for-2.8.git/include/hw/ppc/ppc.h
@@ -106,4 +106,5 @@ enum {
 /* ppc_booke.c */
 void ppc_booke_timers_init(PowerPCCPU *cpu, uint32_t freq, uint32_t flags);
 
+void ppc_cpu_parse_features(const char *cpu_model);
 #endif

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH for 2.7] ppc: parse cpu features once
  2016-08-10 19:08 [Qemu-devel] [PATCH for 2.7] ppc: parse cpu features once Cédric Le Goater
@ 2016-08-10 19:10 ` Cédric Le Goater
  2016-08-11  3:16 ` Bharata B Rao
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Cédric Le Goater @ 2016-08-10 19:10 UTC (permalink / raw)
  To: qemu-ppc
  Cc: David Gibson, Bharata B Rao, qemu-devel, Eduardo Habkost, Greg Kurz

On 08/10/2016 09:08 PM, Cédric Le Goater wrote:
> From: Greg Kurz <groug@kaod.org>
> 
> Considering that features are converted to global properties and
> global properties are automatically applied to every new instance
> of created CPU (at object_new() time), there is no point in
> parsing cpu_model string every time a CPU created. So move
> parsing outside CPU creation loop and do it only once.
> 
> Parsing also should be done before any CPU is created so that
> features would affect the first CPU a well.
> 
> This patch does that for all PowerPC machine types.
> 
> It is based on previous work from Bharata:
> 
> https://lists.nongnu.org/archive/html/qemu-devel/2016-06/msg07564.html
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>
> [clg: only kept the fix for the spapr platform. support for other
>       platform will be added in 2.8 ]
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Eduardo,

Greg being away, I gave his patch a respin. Could you please give it 
a try ?

Thanks,

C.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH for 2.7] ppc: parse cpu features once
  2016-08-10 19:08 [Qemu-devel] [PATCH for 2.7] ppc: parse cpu features once Cédric Le Goater
  2016-08-10 19:10 ` Cédric Le Goater
@ 2016-08-11  3:16 ` Bharata B Rao
  2016-08-11  7:14 ` David Gibson
  2016-08-12 19:26 ` Eduardo Habkost
  3 siblings, 0 replies; 5+ messages in thread
From: Bharata B Rao @ 2016-08-11  3:16 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: qemu-ppc, David Gibson, qemu-devel, Eduardo Habkost, Greg Kurz

On Wed, Aug 10, 2016 at 09:08:01PM +0200, Cédric Le Goater wrote:
> From: Greg Kurz <groug@kaod.org>
> 
> Considering that features are converted to global properties and
> global properties are automatically applied to every new instance
> of created CPU (at object_new() time), there is no point in
> parsing cpu_model string every time a CPU created. So move
> parsing outside CPU creation loop and do it only once.
> 
> Parsing also should be done before any CPU is created so that
> features would affect the first CPU a well.
> 
> This patch does that for all PowerPC machine types.
> 
> It is based on previous work from Bharata:
> 
> https://lists.nongnu.org/archive/html/qemu-devel/2016-06/msg07564.html
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>
> [clg: only kept the fix for the spapr platform. support for other
>       platform will be added in 2.8 ]
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Tested-by: Bharata B Rao <bharata@linux.vnet.ibm.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH for 2.7] ppc: parse cpu features once
  2016-08-10 19:08 [Qemu-devel] [PATCH for 2.7] ppc: parse cpu features once Cédric Le Goater
  2016-08-10 19:10 ` Cédric Le Goater
  2016-08-11  3:16 ` Bharata B Rao
@ 2016-08-11  7:14 ` David Gibson
  2016-08-12 19:26 ` Eduardo Habkost
  3 siblings, 0 replies; 5+ messages in thread
From: David Gibson @ 2016-08-11  7:14 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: qemu-ppc, Bharata B Rao, qemu-devel, Eduardo Habkost, Greg Kurz

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

On Wed, Aug 10, 2016 at 09:08:01PM +0200, Cédric Le Goater wrote:
> From: Greg Kurz <groug@kaod.org>
> 
> Considering that features are converted to global properties and
> global properties are automatically applied to every new instance
> of created CPU (at object_new() time), there is no point in
> parsing cpu_model string every time a CPU created. So move
> parsing outside CPU creation loop and do it only once.
> 
> Parsing also should be done before any CPU is created so that
> features would affect the first CPU a well.
> 
> This patch does that for all PowerPC machine types.
> 
> It is based on previous work from Bharata:
> 
> https://lists.nongnu.org/archive/html/qemu-devel/2016-06/msg07564.html
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>
> [clg: only kept the fix for the spapr platform. support for other
>       platform will be added in 2.8 ]
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> 
> ---
> 
> This is a standalone version of patch 2 from my latest series:
> 
> https://lists.nongnu.org/archive/html/qemu-devel/2016-07/msg02433.html
> 
> The only changes are trivial conflict fixes caused by the introduction
> of ppc_cpu_init by patch 1.
> 
> ---
>  hw/ppc/ppc.c         |   26 ++++++++++++++++++++++++++
>  hw/ppc/spapr.c       |    2 ++
>  include/hw/ppc/ppc.h |    1 +
>  3 files changed, 29 insertions(+)

Applied to ppc-for-2.7.

> 
> Index: qemu-dgibson-for-2.8.git/hw/ppc/ppc.c
> ===================================================================
> --- qemu-dgibson-for-2.8.git.orig/hw/ppc/ppc.c
> +++ qemu-dgibson-for-2.8.git/hw/ppc/ppc.c
> @@ -33,6 +33,7 @@
>  #include "hw/timer/m48t59.h"
>  #include "qemu/log.h"
>  #include "qemu/error-report.h"
> +#include "qapi/error.h"
>  #include "hw/loader.h"
>  #include "sysemu/kvm.h"
>  #include "kvm_ppc.h"
> @@ -1350,3 +1351,28 @@ PowerPCCPU *ppc_get_vcpu_by_dt_id(int cp
>  
>      return NULL;
>  }
> +
> +void ppc_cpu_parse_features(const char *cpu_model)
> +{
> +    CPUClass *cc;
> +    ObjectClass *oc;
> +    const char *typename;
> +    gchar **model_pieces;
> +
> +    model_pieces = g_strsplit(cpu_model, ",", 2);
> +    if (!model_pieces[0]) {
> +        error_report("Invalid/empty CPU model name");
> +        exit(1);
> +    }
> +
> +    oc = cpu_class_by_name(TYPE_POWERPC_CPU, model_pieces[0]);
> +    if (oc == NULL) {
> +        error_report("Unable to find CPU definition: %s", model_pieces[0]);
> +        exit(1);
> +    }
> +
> +    typename = object_class_get_name(oc);
> +    cc = CPU_CLASS(oc);
> +    cc->parse_features(typename, model_pieces[1], &error_fatal);
> +    g_strfreev(model_pieces);
> +}
> Index: qemu-dgibson-for-2.8.git/hw/ppc/spapr.c
> ===================================================================
> --- qemu-dgibson-for-2.8.git.orig/hw/ppc/spapr.c
> +++ qemu-dgibson-for-2.8.git/hw/ppc/spapr.c
> @@ -1769,6 +1769,8 @@ static void ppc_spapr_init(MachineState
>          machine->cpu_model = kvm_enabled() ? "host" : "POWER7";
>      }
>  
> +    ppc_cpu_parse_features(machine->cpu_model);
> +
>      if (mc->query_hotpluggable_cpus) {
>          char *type = spapr_get_cpu_core_type(machine->cpu_model);
>  
> Index: qemu-dgibson-for-2.8.git/include/hw/ppc/ppc.h
> ===================================================================
> --- qemu-dgibson-for-2.8.git.orig/include/hw/ppc/ppc.h
> +++ qemu-dgibson-for-2.8.git/include/hw/ppc/ppc.h
> @@ -106,4 +106,5 @@ enum {
>  /* ppc_booke.c */
>  void ppc_booke_timers_init(PowerPCCPU *cpu, uint32_t freq, uint32_t flags);
>  
> +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 --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH for 2.7] ppc: parse cpu features once
  2016-08-10 19:08 [Qemu-devel] [PATCH for 2.7] ppc: parse cpu features once Cédric Le Goater
                   ` (2 preceding siblings ...)
  2016-08-11  7:14 ` David Gibson
@ 2016-08-12 19:26 ` Eduardo Habkost
  3 siblings, 0 replies; 5+ messages in thread
From: Eduardo Habkost @ 2016-08-12 19:26 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: qemu-ppc, David Gibson, Bharata B Rao, qemu-devel, Greg Kurz

On Wed, Aug 10, 2016 at 09:08:01PM +0200, Cédric Le Goater wrote:
> From: Greg Kurz <groug@kaod.org>
> 
> Considering that features are converted to global properties and
> global properties are automatically applied to every new instance
> of created CPU (at object_new() time), there is no point in
> parsing cpu_model string every time a CPU created. So move
> parsing outside CPU creation loop and do it only once.
> 
> Parsing also should be done before any CPU is created so that
> features would affect the first CPU a well.
> 
> This patch does that for all PowerPC machine types.

This line needs to be removed from the commit message.

> 
> It is based on previous work from Bharata:
> 
> https://lists.nongnu.org/archive/html/qemu-devel/2016-06/msg07564.html
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>
> [clg: only kept the fix for the spapr platform. support for other
>       platform will be added in 2.8 ]
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

Thanks!

-- 
Eduardo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-08-12 19:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-10 19:08 [Qemu-devel] [PATCH for 2.7] ppc: parse cpu features once Cédric Le Goater
2016-08-10 19:10 ` Cédric Le Goater
2016-08-11  3:16 ` Bharata B Rao
2016-08-11  7:14 ` David Gibson
2016-08-12 19:26 ` Eduardo Habkost

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.