From: David Hildenbrand <david@redhat.com>
To: Janosch Frank <frankja@linux.ibm.com>, qemu-devel@nongnu.org
Cc: thuth@redhat.com, pmorel@linux.ibm.com, cohuck@redhat.com,
borntraeger@de.ibm.com, qemu-s390x@nongnu.org,
mihajlov@linux.ibm.com
Subject: Re: [PATCH] Remove wrappers
Date: Fri, 22 Nov 2019 13:23:41 +0100 [thread overview]
Message-ID: <f63f7243-005a-6679-df31-577126938170@redhat.com> (raw)
In-Reply-To: <20191122122019.23069-1-frankja@linux.ibm.com>
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 :)
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2019-11-22 12:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-22 7:52 [PATCH 0/4] s390x: Reset cleanup Janosch Frank
2019-11-22 7:52 ` [PATCH 1/4] s390x: Don't do a normal reset on the initial cpu Janosch Frank
2019-11-22 10:55 ` David Hildenbrand
2019-11-22 7:52 ` [PATCH 2/4] s390x: Cleanup cpu resets Janosch Frank
2019-11-22 10:35 ` Philippe Mathieu-Daudé
2019-11-22 13:07 ` Janosch Frank
2019-11-22 11:14 ` David Hildenbrand
2019-11-22 12:20 ` [PATCH] Remove wrappers Janosch Frank
2019-11-22 12:23 ` David Hildenbrand [this message]
2019-11-22 12:28 ` Janosch Frank
2019-11-22 7:52 ` [PATCH 3/4] s390x: Beautify diag308 handling Janosch Frank
2019-11-22 10:56 ` David Hildenbrand
2019-11-22 7:52 ` [PATCH 4/4] s390x: Beautify machine reset Janosch Frank
2019-11-22 10:59 ` David Hildenbrand
2019-11-22 11:46 ` Janosch Frank
2019-11-22 11:47 ` David Hildenbrand
2019-11-22 12:10 ` Cornelia Huck
2019-11-22 12:22 ` Janosch Frank
2019-11-22 12:25 ` David Hildenbrand
2019-11-22 12:30 ` Janosch Frank
2019-11-22 12:42 ` David Hildenbrand
2019-11-22 10:10 ` [PATCH 0/4] s390x: Reset cleanup no-reply
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=f63f7243-005a-6679-df31-577126938170@redhat.com \
--to=david@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=mihajlov@linux.ibm.com \
--cc=pmorel@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=thuth@redhat.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).