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: "Cédric Le Goater" <clg@kaod.org>,
	qemu-devel@nongnu.org, qemu-ppc@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 01/10] xics: Explicitely call KVM ICP methods from the common code
Date: Mon, 18 Feb 2019 10:14:55 +1100	[thread overview]
Message-ID: <20190217231455.GB2765@umbus.fritz.box> (raw)
In-Reply-To: <155023078871.1011724.3083923389814185598.stgit@bahia.lan>

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

On Fri, Feb 15, 2019 at 12:39:48PM +0100, Greg Kurz wrote:
> The pre_save(), post_load() and synchronize_state() methods of the
> ICPStateClass type are really KVM only things. Make that obvious
> by dropping the indirections and directly calling the KVM functions
> instead.
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>

Applied, thanks.

> ---
>  hw/intc/xics.c        |   24 +++++++++++-------------
>  hw/intc/xics_kvm.c    |   12 ++++--------
>  include/hw/ppc/xics.h |    9 +++++----
>  3 files changed, 20 insertions(+), 25 deletions(-)
> 
> diff --git a/hw/intc/xics.c b/hw/intc/xics.c
> index 16e8ffa2aaf7..988b53abd17d 100644
> --- a/hw/intc/xics.c
> +++ b/hw/intc/xics.c
> @@ -37,18 +37,18 @@
>  #include "qapi/visitor.h"
>  #include "monitor/monitor.h"
>  #include "hw/intc/intc.h"
> +#include "sysemu/kvm.h"
>  
>  void icp_pic_print_info(ICPState *icp, Monitor *mon)
>  {
> -    ICPStateClass *icpc = ICP_GET_CLASS(icp);
>      int cpu_index = icp->cs ? icp->cs->cpu_index : -1;
>  
>      if (!icp->output) {
>          return;
>      }
>  
> -    if (icpc->synchronize_state) {
> -        icpc->synchronize_state(icp);
> +    if (kvm_irqchip_in_kernel()) {
> +        icp_synchronize_state(icp);
>      }
>  
>      monitor_printf(mon, "CPU %d XIRR=%08x (%p) PP=%02x MFRR=%02x\n",
> @@ -252,25 +252,23 @@ static void icp_irq(ICSState *ics, int server, int nr, uint8_t priority)
>      }
>  }
>  
> -static int icp_dispatch_pre_save(void *opaque)
> +static int icp_pre_save(void *opaque)
>  {
>      ICPState *icp = opaque;
> -    ICPStateClass *info = ICP_GET_CLASS(icp);
>  
> -    if (info->pre_save) {
> -        info->pre_save(icp);
> +    if (kvm_irqchip_in_kernel()) {
> +        icp_get_kvm_state(icp);
>      }
>  
>      return 0;
>  }
>  
> -static int icp_dispatch_post_load(void *opaque, int version_id)
> +static int icp_post_load(void *opaque, int version_id)
>  {
>      ICPState *icp = opaque;
> -    ICPStateClass *info = ICP_GET_CLASS(icp);
>  
> -    if (info->post_load) {
> -        return info->post_load(icp, version_id);
> +    if (kvm_irqchip_in_kernel()) {
> +        return icp_set_kvm_state(icp);
>      }
>  
>      return 0;
> @@ -280,8 +278,8 @@ static const VMStateDescription vmstate_icp_server = {
>      .name = "icp/server",
>      .version_id = 1,
>      .minimum_version_id = 1,
> -    .pre_save = icp_dispatch_pre_save,
> -    .post_load = icp_dispatch_post_load,
> +    .pre_save = icp_pre_save,
> +    .post_load = icp_post_load,
>      .fields = (VMStateField[]) {
>          /* Sanity check */
>          VMSTATE_UINT32(xirr, ICPState),
> diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
> index dff13300504c..7efa99b8b434 100644
> --- a/hw/intc/xics_kvm.c
> +++ b/hw/intc/xics_kvm.c
> @@ -54,7 +54,7 @@ static QLIST_HEAD(, KVMEnabledICP)
>  /*
>   * ICP-KVM
>   */
> -static void icp_get_kvm_state(ICPState *icp)
> +void icp_get_kvm_state(ICPState *icp)
>  {
>      uint64_t state;
>      int ret;
> @@ -83,14 +83,14 @@ static void do_icp_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
>      icp_get_kvm_state(arg.host_ptr);
>  }
>  
> -static void icp_synchronize_state(ICPState *icp)
> +void icp_synchronize_state(ICPState *icp)
>  {
>      if (icp->cs) {
>          run_on_cpu(icp->cs, do_icp_synchronize_state, RUN_ON_CPU_HOST_PTR(icp));
>      }
>  }
>  
> -static int icp_set_kvm_state(ICPState *icp, int version_id)
> +int icp_set_kvm_state(ICPState *icp)
>  {
>      uint64_t state;
>      int ret;
> @@ -121,7 +121,7 @@ static void icp_kvm_reset(DeviceState *dev)
>  
>      icpc->parent_reset(dev);
>  
> -    icp_set_kvm_state(ICP(dev), 1);
> +    icp_set_kvm_state(ICP(dev));
>  }
>  
>  static void icp_kvm_realize(DeviceState *dev, Error **errp)
> @@ -178,10 +178,6 @@ static void icp_kvm_class_init(ObjectClass *klass, void *data)
>                                      &icpc->parent_realize);
>      device_class_set_parent_reset(dc, icp_kvm_reset,
>                                    &icpc->parent_reset);
> -
> -    icpc->pre_save = icp_get_kvm_state;
> -    icpc->post_load = icp_set_kvm_state;
> -    icpc->synchronize_state = icp_synchronize_state;
>  }
>  
>  static const TypeInfo icp_kvm_info = {
> diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
> index fad786e8b22d..3236ccec924c 100644
> --- a/include/hw/ppc/xics.h
> +++ b/include/hw/ppc/xics.h
> @@ -66,10 +66,6 @@ struct ICPStateClass {
>  
>      DeviceRealize parent_realize;
>      DeviceReset parent_reset;
> -
> -    void (*pre_save)(ICPState *icp);
> -    int (*post_load)(ICPState *icp, int version_id);
> -    void (*synchronize_state)(ICPState *icp);
>  };
>  
>  struct ICPState {
> @@ -203,4 +199,9 @@ void icp_resend(ICPState *ss);
>  Object *icp_create(Object *cpu, const char *type, XICSFabric *xi,
>                     Error **errp);
>  
> +/* KVM */
> +void icp_get_kvm_state(ICPState *icp);
> +int icp_set_kvm_state(ICPState *icp);
> +void icp_synchronize_state(ICPState *icp);
> +
>  #endif /* XICS_H */
> 

-- 
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: 833 bytes --]

  parent reply	other threads:[~2019-02-18  0:23 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-15 11:39 [Qemu-devel] [PATCH 00/10] xics: Get rid of KVM specific classes Greg Kurz
2019-02-15 11:39 ` [Qemu-devel] [PATCH 01/10] xics: Explicitely call KVM ICP methods from the common code Greg Kurz
2019-02-15 12:49   ` Cédric Le Goater
2019-02-17 23:14   ` David Gibson [this message]
2019-02-18 20:10     ` Eric Blake
2019-02-19  5:36       ` David Gibson
2019-02-15 11:39 ` [Qemu-devel] [PATCH 02/10] xics: Handle KVM ICP reset " Greg Kurz
2019-02-15 12:50   ` Cédric Le Goater
2019-02-17 23:32   ` David Gibson
2019-02-15 11:40 ` [Qemu-devel] [PATCH 03/10] xics: Handle KVM ICP realize " Greg Kurz
2019-02-15 12:54   ` Cédric Le Goater
2019-02-15 13:03     ` Greg Kurz
2019-02-15 13:09       ` Cédric Le Goater
2019-02-15 13:27         ` Greg Kurz
2019-02-15 13:35           ` Cédric Le Goater
2019-02-17 23:33           ` David Gibson
2019-02-15 11:40 ` [Qemu-devel] [PATCH 04/10] spapr/irq: Use the base ICP class for KVM Greg Kurz
2019-02-15 12:54   ` Cédric Le Goater
2019-02-17 23:35   ` David Gibson
2019-02-15 11:40 ` [Qemu-devel] [PATCH 05/10] xics: Drop the KVM ICP class Greg Kurz
2019-02-15 12:55   ` Cédric Le Goater
2019-02-15 13:18     ` Greg Kurz
2019-02-15 13:35       ` Cédric Le Goater
2019-02-15 13:35         ` Greg Kurz
2019-02-17 23:37         ` David Gibson
2019-02-18  7:08           ` Cédric Le Goater
2019-02-15 11:40 ` [Qemu-devel] [PATCH 06/10] xics: Explicitely call KVM ICS methods from the common code Greg Kurz
2019-02-15 12:56   ` Cédric Le Goater
2019-02-17 23:39   ` David Gibson
2019-02-15 11:40 ` [Qemu-devel] [PATCH 07/10] xics: Handle KVM ICS reset from the "simple" ICS code Greg Kurz
2019-02-15 12:57   ` Cédric Le Goater
2019-02-17 23:41   ` David Gibson
2019-02-15 11:40 ` [Qemu-devel] [PATCH 08/10] xics: Handle KVM interrupt presentation from " Greg Kurz
2019-02-15 12:59   ` Cédric Le Goater
2019-02-15 13:25     ` Greg Kurz
2019-02-17 23:43   ` David Gibson
2019-02-15 11:40 ` [Qemu-devel] [PATCH 09/10] spapr/irq: Use the "simple" ICS class for KVM Greg Kurz
2019-02-15 13:02   ` Cédric Le Goater
2019-02-15 13:32     ` Greg Kurz
2019-02-15 13:37       ` Cédric Le Goater
2019-02-17 23:49     ` David Gibson
2019-02-17 23:51   ` David Gibson
2019-02-15 11:40 ` [Qemu-devel] [PATCH 10/10] xics: Drop the KVM ICS class Greg Kurz
2019-02-15 13:02   ` Cédric Le Goater

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=20190217231455.GB2765@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=clg@kaod.org \
    --cc=groug@kaod.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /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).