Remove wrappers
diff mbox series

Message ID 20191122122019.23069-1-frankja@linux.ibm.com
State New
Headers show
Series
  • Remove wrappers
Related show

Commit Message

Janosch Frank Nov. 22, 2019, 12:20 p.m. UTC
That's what it would look like.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 target/s390x/cpu-qom.h | 12 ++++++++----
 target/s390x/cpu.c     | 28 +++++-----------------------
 target/s390x/cpu.h     |  8 +++++---
 target/s390x/sigp.c    |  4 ++--
 4 files changed, 20 insertions(+), 32 deletions(-)

Comments

David Hildenbrand Nov. 22, 2019, 12:23 p.m. UTC | #1
On 22.11.19 13:20, Janosch Frank wrote:
> That's what it would look like.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>   target/s390x/cpu-qom.h | 12 ++++++++----
>   target/s390x/cpu.c     | 28 +++++-----------------------
>   target/s390x/cpu.h     |  8 +++++---
>   target/s390x/sigp.c    |  4 ++--
>   4 files changed, 20 insertions(+), 32 deletions(-)
> 
> diff --git a/target/s390x/cpu-qom.h b/target/s390x/cpu-qom.h
> index b809ec8418..e8ec999e77 100644
> --- a/target/s390x/cpu-qom.h
> +++ b/target/s390x/cpu-qom.h
> @@ -34,13 +34,18 @@
>   typedef struct S390CPUModel S390CPUModel;
>   typedef struct S390CPUDef S390CPUDef;
>   
> +typedef enum cpu_reset_type {
> +    S390_CPU_RESET_NORMAL,
> +    S390_CPU_RESET_INITIAL,
> +    S390_CPU_RESET_CLEAR,
> +} cpu_reset_type;
> +
>   /**
>    * S390CPUClass:
>    * @parent_realize: The parent class' realize handler.
>    * @parent_reset: The parent class' reset handler.
>    * @load_normal: Performs a load normal.
> - * @cpu_reset: Performs a CPU reset.
> - * @initial_cpu_reset: Performs an initial CPU reset.
> + * @reset: Performs a CPU reset of a given type.
>    *
>    * An S/390 CPU model.
>    */
> @@ -57,8 +62,7 @@ typedef struct S390CPUClass {
>       DeviceRealize parent_realize;
>       void (*parent_reset)(CPUState *cpu);
>       void (*load_normal)(CPUState *cpu);
> -    void (*cpu_reset)(CPUState *cpu);
> -    void (*initial_cpu_reset)(CPUState *cpu);
> +    void (*reset)(CPUState *cpu, cpu_reset_type type);
>   } S390CPUClass;
>   
>   typedef struct S390CPU S390CPU;
> diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
> index 556afecbc1..970495d042 100644
> --- a/target/s390x/cpu.c
> +++ b/target/s390x/cpu.c
> @@ -82,12 +82,6 @@ static void s390_cpu_load_normal(CPUState *s)
>   }
>   #endif
>   
> -typedef enum cpu_reset_type {
> -    S390_CPU_RESET_NORMAL,
> -    S390_CPU_RESET_INITIAL,
> -    S390_CPU_RESET_CLEAR,
> -} cpu_reset_type;
> -
>   static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
>   {
>       S390CPU *cpu = S390_CPU(s);
> @@ -138,21 +132,6 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
>   #endif
>   }
>   
> -static void s390_cpu_reset_normal(CPUState *s)
> -{
> -    return s390_cpu_reset(s, S390_CPU_RESET_NORMAL);
> -}
> -
> -static void s390_cpu_reset_initial(CPUState *s)
> -{
> -    return s390_cpu_reset(s, S390_CPU_RESET_INITIAL);
> -}
> -
> -static void s390_cpu_reset_clear(CPUState *s)
> -{
> -    return s390_cpu_reset(s, S390_CPU_RESET_CLEAR);
> -}
> -
>   #if !defined(CONFIG_USER_ONLY)
>   static void s390_cpu_machine_reset_cb(void *opaque)
>   {
> @@ -444,6 +423,11 @@ static Property s390x_cpu_properties[] = {
>       DEFINE_PROP_END_OF_LIST()
>   };
>   
> +static void s390_cpu_reset_clear(CPUState *s)
> +{
> +    return s390_cpu_reset(s, S390_CPU_RESET_CLEAR);
> +}
> +
>   static void s390_cpu_class_init(ObjectClass *oc, void *data)
>   {
>       S390CPUClass *scc = S390_CPU_CLASS(oc);
> @@ -459,8 +443,6 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)
>   #if !defined(CONFIG_USER_ONLY)
>       scc->load_normal = s390_cpu_load_normal;
>   #endif
> -    scc->cpu_reset = s390_cpu_reset_normal;
> -    scc->initial_cpu_reset = s390_cpu_reset_initial;

You have to set

scc->reset = s390_cpu_reset;

if I'm not wrong.

>       cc->reset = s390_cpu_reset_clear;
>       cc->class_by_name = s390_cpu_class_by_name,
>       cc->has_work = s390_cpu_has_work;
> diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
> index 17460ed7b3..687b31d87e 100644
> --- a/target/s390x/cpu.h
> +++ b/target/s390x/cpu.h
> @@ -734,21 +734,23 @@ static inline uint64_t s390_build_validity_mcic(void)
>   
>   static inline void s390_do_cpu_full_reset(CPUState *cs, run_on_cpu_data arg)
>   {
> -    cpu_reset(cs);
> +    S390CPUClass *scc = S390_CPU_GET_CLASS(cs);
> +
> +    scc->reset(cs, S390_CPU_RESET_CLEAR);
>   }
>   
>   static inline void s390_do_cpu_reset(CPUState *cs, run_on_cpu_data arg)
>   {
>       S390CPUClass *scc = S390_CPU_GET_CLASS(cs);
>   
> -    scc->cpu_reset(cs);
> +    scc->reset(cs, S390_CPU_RESET_CLEAR);
>   }
>   
>   static inline void s390_do_cpu_initial_reset(CPUState *cs, run_on_cpu_data arg)
>   {
>       S390CPUClass *scc = S390_CPU_GET_CLASS(cs);
>   
> -    scc->initial_cpu_reset(cs);
> +    scc->reset(cs, S390_CPU_RESET_INITIAL);
>   }
>   
>   static inline void s390_do_cpu_load_normal(CPUState *cs, run_on_cpu_data arg)
> diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c
> index 2ce22d4dc1..727875bb4a 100644
> --- a/target/s390x/sigp.c
> +++ b/target/s390x/sigp.c
> @@ -254,7 +254,7 @@ static void sigp_initial_cpu_reset(CPUState *cs, run_on_cpu_data arg)
>       SigpInfo *si = arg.host_ptr;
>   
>       cpu_synchronize_state(cs);
> -    scc->initial_cpu_reset(cs);
> +    scc->reset(cs, S390_CPU_RESET_INITIAL);
>       cpu_synchronize_post_reset(cs);
>       si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
>   }
> @@ -266,7 +266,7 @@ static void sigp_cpu_reset(CPUState *cs, run_on_cpu_data arg)
>       SigpInfo *si = arg.host_ptr;
>   
>       cpu_synchronize_state(cs);
> -    scc->cpu_reset(cs);
> +    scc->reset(cs, S390_CPU_RESET_NORMAL);
>       cpu_synchronize_post_reset(cs);
>       si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
>   }
> 

Looks good and much cleaner to me :)
Janosch Frank Nov. 22, 2019, 12:28 p.m. UTC | #2
On 11/22/19 1:23 PM, David Hildenbrand wrote:
> On 22.11.19 13:20, Janosch Frank wrote:
>> That's what it would look like.
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> ---
>>   target/s390x/cpu-qom.h | 12 ++++++++----
>>   target/s390x/cpu.c     | 28 +++++-----------------------
>>   target/s390x/cpu.h     |  8 +++++---
>>   target/s390x/sigp.c    |  4 ++--
>>   4 files changed, 20 insertions(+), 32 deletions(-)
>>
>> diff --git a/target/s390x/cpu-qom.h b/target/s390x/cpu-qom.h
>> index b809ec8418..e8ec999e77 100644
>> --- a/target/s390x/cpu-qom.h
>> +++ b/target/s390x/cpu-qom.h
>> @@ -34,13 +34,18 @@
>>   typedef struct S390CPUModel S390CPUModel;
>>   typedef struct S390CPUDef S390CPUDef;
>>   
>> +typedef enum cpu_reset_type {
>> +    S390_CPU_RESET_NORMAL,
>> +    S390_CPU_RESET_INITIAL,
>> +    S390_CPU_RESET_CLEAR,
>> +} cpu_reset_type;
>> +
>>   /**
>>    * S390CPUClass:
>>    * @parent_realize: The parent class' realize handler.
>>    * @parent_reset: The parent class' reset handler.
>>    * @load_normal: Performs a load normal.
>> - * @cpu_reset: Performs a CPU reset.
>> - * @initial_cpu_reset: Performs an initial CPU reset.
>> + * @reset: Performs a CPU reset of a given type.
>>    *
>>    * An S/390 CPU model.
>>    */
>> @@ -57,8 +62,7 @@ typedef struct S390CPUClass {
>>       DeviceRealize parent_realize;
>>       void (*parent_reset)(CPUState *cpu);
>>       void (*load_normal)(CPUState *cpu);
>> -    void (*cpu_reset)(CPUState *cpu);
>> -    void (*initial_cpu_reset)(CPUState *cpu);
>> +    void (*reset)(CPUState *cpu, cpu_reset_type type);
>>   } S390CPUClass;
>>   
>>   typedef struct S390CPU S390CPU;
>> diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
>> index 556afecbc1..970495d042 100644
>> --- a/target/s390x/cpu.c
>> +++ b/target/s390x/cpu.c
>> @@ -82,12 +82,6 @@ static void s390_cpu_load_normal(CPUState *s)
>>   }
>>   #endif
>>   
>> -typedef enum cpu_reset_type {
>> -    S390_CPU_RESET_NORMAL,
>> -    S390_CPU_RESET_INITIAL,
>> -    S390_CPU_RESET_CLEAR,
>> -} cpu_reset_type;
>> -
>>   static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
>>   {
>>       S390CPU *cpu = S390_CPU(s);
>> @@ -138,21 +132,6 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
>>   #endif
>>   }
>>   
>> -static void s390_cpu_reset_normal(CPUState *s)
>> -{
>> -    return s390_cpu_reset(s, S390_CPU_RESET_NORMAL);
>> -}
>> -
>> -static void s390_cpu_reset_initial(CPUState *s)
>> -{
>> -    return s390_cpu_reset(s, S390_CPU_RESET_INITIAL);
>> -}
>> -
>> -static void s390_cpu_reset_clear(CPUState *s)
>> -{
>> -    return s390_cpu_reset(s, S390_CPU_RESET_CLEAR);
>> -}
>> -
>>   #if !defined(CONFIG_USER_ONLY)
>>   static void s390_cpu_machine_reset_cb(void *opaque)
>>   {
>> @@ -444,6 +423,11 @@ static Property s390x_cpu_properties[] = {
>>       DEFINE_PROP_END_OF_LIST()
>>   };
>>   
>> +static void s390_cpu_reset_clear(CPUState *s)
>> +{
>> +    return s390_cpu_reset(s, S390_CPU_RESET_CLEAR);
>> +}
>> +
>>   static void s390_cpu_class_init(ObjectClass *oc, void *data)
>>   {
>>       S390CPUClass *scc = S390_CPU_CLASS(oc);
>> @@ -459,8 +443,6 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)
>>   #if !defined(CONFIG_USER_ONLY)
>>       scc->load_normal = s390_cpu_load_normal;
>>   #endif
>> -    scc->cpu_reset = s390_cpu_reset_normal;
>> -    scc->initial_cpu_reset = s390_cpu_reset_initial;
> 
> You have to set
> 
> scc->reset = s390_cpu_reset;
> 
> if I'm not wrong.

Yeah, that would make sense :)
I'm also going to tripple check if we are doing the right resets.


> 
>>       cc->reset = s390_cpu_reset_clear;
>>       cc->class_by_name = s390_cpu_class_by_name,
>>       cc->has_work = s390_cpu_has_work;
>> diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
>> index 17460ed7b3..687b31d87e 100644
>> --- a/target/s390x/cpu.h
>> +++ b/target/s390x/cpu.h
>> @@ -734,21 +734,23 @@ static inline uint64_t s390_build_validity_mcic(void)
>>   
>>   static inline void s390_do_cpu_full_reset(CPUState *cs, run_on_cpu_data arg)
>>   {
>> -    cpu_reset(cs);
>> +    S390CPUClass *scc = S390_CPU_GET_CLASS(cs);
>> +
>> +    scc->reset(cs, S390_CPU_RESET_CLEAR);
>>   }
>>   
>>   static inline void s390_do_cpu_reset(CPUState *cs, run_on_cpu_data arg)
>>   {
>>       S390CPUClass *scc = S390_CPU_GET_CLASS(cs);
>>   
>> -    scc->cpu_reset(cs);
>> +    scc->reset(cs, S390_CPU_RESET_CLEAR);
>>   }
>>   
>>   static inline void s390_do_cpu_initial_reset(CPUState *cs, run_on_cpu_data arg)
>>   {
>>       S390CPUClass *scc = S390_CPU_GET_CLASS(cs);
>>   
>> -    scc->initial_cpu_reset(cs);
>> +    scc->reset(cs, S390_CPU_RESET_INITIAL);
>>   }
>>   
>>   static inline void s390_do_cpu_load_normal(CPUState *cs, run_on_cpu_data arg)
>> diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c
>> index 2ce22d4dc1..727875bb4a 100644
>> --- a/target/s390x/sigp.c
>> +++ b/target/s390x/sigp.c
>> @@ -254,7 +254,7 @@ static void sigp_initial_cpu_reset(CPUState *cs, run_on_cpu_data arg)
>>       SigpInfo *si = arg.host_ptr;
>>   
>>       cpu_synchronize_state(cs);
>> -    scc->initial_cpu_reset(cs);
>> +    scc->reset(cs, S390_CPU_RESET_INITIAL);
>>       cpu_synchronize_post_reset(cs);
>>       si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
>>   }
>> @@ -266,7 +266,7 @@ static void sigp_cpu_reset(CPUState *cs, run_on_cpu_data arg)
>>       SigpInfo *si = arg.host_ptr;
>>   
>>       cpu_synchronize_state(cs);
>> -    scc->cpu_reset(cs);
>> +    scc->reset(cs, S390_CPU_RESET_NORMAL);
>>       cpu_synchronize_post_reset(cs);
>>       si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
>>   }
>>
> 
> Looks good and much cleaner to me :)
>

Patch
diff mbox series

diff --git a/target/s390x/cpu-qom.h b/target/s390x/cpu-qom.h
index b809ec8418..e8ec999e77 100644
--- a/target/s390x/cpu-qom.h
+++ b/target/s390x/cpu-qom.h
@@ -34,13 +34,18 @@ 
 typedef struct S390CPUModel S390CPUModel;
 typedef struct S390CPUDef S390CPUDef;
 
+typedef enum cpu_reset_type {
+    S390_CPU_RESET_NORMAL,
+    S390_CPU_RESET_INITIAL,
+    S390_CPU_RESET_CLEAR,
+} cpu_reset_type;
+
 /**
  * S390CPUClass:
  * @parent_realize: The parent class' realize handler.
  * @parent_reset: The parent class' reset handler.
  * @load_normal: Performs a load normal.
- * @cpu_reset: Performs a CPU reset.
- * @initial_cpu_reset: Performs an initial CPU reset.
+ * @reset: Performs a CPU reset of a given type.
  *
  * An S/390 CPU model.
  */
@@ -57,8 +62,7 @@  typedef struct S390CPUClass {
     DeviceRealize parent_realize;
     void (*parent_reset)(CPUState *cpu);
     void (*load_normal)(CPUState *cpu);
-    void (*cpu_reset)(CPUState *cpu);
-    void (*initial_cpu_reset)(CPUState *cpu);
+    void (*reset)(CPUState *cpu, cpu_reset_type type);
 } S390CPUClass;
 
 typedef struct S390CPU S390CPU;
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index 556afecbc1..970495d042 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -82,12 +82,6 @@  static void s390_cpu_load_normal(CPUState *s)
 }
 #endif
 
-typedef enum cpu_reset_type {
-    S390_CPU_RESET_NORMAL,
-    S390_CPU_RESET_INITIAL,
-    S390_CPU_RESET_CLEAR,
-} cpu_reset_type;
-
 static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
 {
     S390CPU *cpu = S390_CPU(s);
@@ -138,21 +132,6 @@  static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
 #endif
 }
 
-static void s390_cpu_reset_normal(CPUState *s)
-{
-    return s390_cpu_reset(s, S390_CPU_RESET_NORMAL);
-}
-
-static void s390_cpu_reset_initial(CPUState *s)
-{
-    return s390_cpu_reset(s, S390_CPU_RESET_INITIAL);
-}
-
-static void s390_cpu_reset_clear(CPUState *s)
-{
-    return s390_cpu_reset(s, S390_CPU_RESET_CLEAR);
-}
-
 #if !defined(CONFIG_USER_ONLY)
 static void s390_cpu_machine_reset_cb(void *opaque)
 {
@@ -444,6 +423,11 @@  static Property s390x_cpu_properties[] = {
     DEFINE_PROP_END_OF_LIST()
 };
 
+static void s390_cpu_reset_clear(CPUState *s)
+{
+    return s390_cpu_reset(s, S390_CPU_RESET_CLEAR);
+}
+
 static void s390_cpu_class_init(ObjectClass *oc, void *data)
 {
     S390CPUClass *scc = S390_CPU_CLASS(oc);
@@ -459,8 +443,6 @@  static void s390_cpu_class_init(ObjectClass *oc, void *data)
 #if !defined(CONFIG_USER_ONLY)
     scc->load_normal = s390_cpu_load_normal;
 #endif
-    scc->cpu_reset = s390_cpu_reset_normal;
-    scc->initial_cpu_reset = s390_cpu_reset_initial;
     cc->reset = s390_cpu_reset_clear;
     cc->class_by_name = s390_cpu_class_by_name,
     cc->has_work = s390_cpu_has_work;
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 17460ed7b3..687b31d87e 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -734,21 +734,23 @@  static inline uint64_t s390_build_validity_mcic(void)
 
 static inline void s390_do_cpu_full_reset(CPUState *cs, run_on_cpu_data arg)
 {
-    cpu_reset(cs);
+    S390CPUClass *scc = S390_CPU_GET_CLASS(cs);
+
+    scc->reset(cs, S390_CPU_RESET_CLEAR);
 }
 
 static inline void s390_do_cpu_reset(CPUState *cs, run_on_cpu_data arg)
 {
     S390CPUClass *scc = S390_CPU_GET_CLASS(cs);
 
-    scc->cpu_reset(cs);
+    scc->reset(cs, S390_CPU_RESET_CLEAR);
 }
 
 static inline void s390_do_cpu_initial_reset(CPUState *cs, run_on_cpu_data arg)
 {
     S390CPUClass *scc = S390_CPU_GET_CLASS(cs);
 
-    scc->initial_cpu_reset(cs);
+    scc->reset(cs, S390_CPU_RESET_INITIAL);
 }
 
 static inline void s390_do_cpu_load_normal(CPUState *cs, run_on_cpu_data arg)
diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c
index 2ce22d4dc1..727875bb4a 100644
--- a/target/s390x/sigp.c
+++ b/target/s390x/sigp.c
@@ -254,7 +254,7 @@  static void sigp_initial_cpu_reset(CPUState *cs, run_on_cpu_data arg)
     SigpInfo *si = arg.host_ptr;
 
     cpu_synchronize_state(cs);
-    scc->initial_cpu_reset(cs);
+    scc->reset(cs, S390_CPU_RESET_INITIAL);
     cpu_synchronize_post_reset(cs);
     si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
 }
@@ -266,7 +266,7 @@  static void sigp_cpu_reset(CPUState *cs, run_on_cpu_data arg)
     SigpInfo *si = arg.host_ptr;
 
     cpu_synchronize_state(cs);
-    scc->cpu_reset(cs);
+    scc->reset(cs, S390_CPU_RESET_NORMAL);
     cpu_synchronize_post_reset(cs);
     si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
 }