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 06/10] xics: Explicitely call KVM ICS methods from the common code
Date: Mon, 18 Feb 2019 10:39:41 +1100	[thread overview]
Message-ID: <20190217233941.GG2765@umbus.fritz.box> (raw)
In-Reply-To: <155023081817.1011724.14078777320394028836.stgit@bahia.lan>

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

On Fri, Feb 15, 2019 at 12:40:18PM +0100, Greg Kurz wrote:
> The pre_save(), post_load() and synchronize_state() methods of the
> ICSStateClass 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        |   23 ++++++++++-------------
>  hw/intc/xics_kvm.c    |   12 ++++--------
>  include/hw/ppc/xics.h |    7 ++++---
>  3 files changed, 18 insertions(+), 24 deletions(-)
> 
> diff --git a/hw/intc/xics.c b/hw/intc/xics.c
> index acd63ab5e0b9..ae5d5ea135b8 100644
> --- a/hw/intc/xics.c
> +++ b/hw/intc/xics.c
> @@ -58,7 +58,6 @@ void icp_pic_print_info(ICPState *icp, Monitor *mon)
>  
>  void ics_pic_print_info(ICSState *ics, Monitor *mon)
>  {
> -    ICSStateClass *icsc = ICS_BASE_GET_CLASS(ics);
>      uint32_t i;
>  
>      monitor_printf(mon, "ICS %4x..%4x %p\n",
> @@ -68,8 +67,8 @@ void ics_pic_print_info(ICSState *ics, Monitor *mon)
>          return;
>      }
>  
> -    if (icsc->synchronize_state) {
> -        icsc->synchronize_state(ics);
> +    if (kvm_irqchip_in_kernel()) {
> +        ics_synchronize_state(ics);
>      }
>  
>      for (i = 0; i < ics->nr_irqs; i++) {
> @@ -647,25 +646,23 @@ static void ics_base_instance_init(Object *obj)
>      ics->offset = XICS_IRQ_BASE;
>  }
>  
> -static int ics_base_dispatch_pre_save(void *opaque)
> +static int ics_base_pre_save(void *opaque)
>  {
>      ICSState *ics = opaque;
> -    ICSStateClass *info = ICS_BASE_GET_CLASS(ics);
>  
> -    if (info->pre_save) {
> -        info->pre_save(ics);
> +    if (kvm_irqchip_in_kernel()) {
> +        ics_get_kvm_state(ics);
>      }
>  
>      return 0;
>  }
>  
> -static int ics_base_dispatch_post_load(void *opaque, int version_id)
> +static int ics_base_post_load(void *opaque, int version_id)
>  {
>      ICSState *ics = opaque;
> -    ICSStateClass *info = ICS_BASE_GET_CLASS(ics);
>  
> -    if (info->post_load) {
> -        return info->post_load(ics, version_id);
> +    if (kvm_irqchip_in_kernel()) {
> +        return ics_set_kvm_state(ics);
>      }
>  
>      return 0;
> @@ -689,8 +686,8 @@ static const VMStateDescription vmstate_ics_base = {
>      .name = "ics",
>      .version_id = 1,
>      .minimum_version_id = 1,
> -    .pre_save = ics_base_dispatch_pre_save,
> -    .post_load = ics_base_dispatch_post_load,
> +    .pre_save = ics_base_pre_save,
> +    .post_load = ics_base_post_load,
>      .fields = (VMStateField[]) {
>          /* Sanity check */
>          VMSTATE_UINT32_EQUAL(nr_irqs, ICSState, NULL),
> diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
> index fae4ac431f2f..642351e5790f 100644
> --- a/hw/intc/xics_kvm.c
> +++ b/hw/intc/xics_kvm.c
> @@ -155,7 +155,7 @@ void icp_kvm_realize(DeviceState *dev, Error **errp)
>  /*
>   * ICS-KVM
>   */
> -static void ics_get_kvm_state(ICSState *ics)
> +void ics_get_kvm_state(ICSState *ics)
>  {
>      uint64_t state;
>      int i;
> @@ -208,12 +208,12 @@ static void ics_get_kvm_state(ICSState *ics)
>      }
>  }
>  
> -static void ics_synchronize_state(ICSState *ics)
> +void ics_synchronize_state(ICSState *ics)
>  {
>      ics_get_kvm_state(ics);
>  }
>  
> -static int ics_set_kvm_state(ICSState *ics, int version_id)
> +int ics_set_kvm_state(ICSState *ics)
>  {
>      uint64_t state;
>      int i;
> @@ -286,7 +286,7 @@ static void ics_kvm_reset(DeviceState *dev)
>  
>      icsc->parent_reset(dev);
>  
> -    ics_set_kvm_state(ICS_KVM(dev), 1);
> +    ics_set_kvm_state(ICS_KVM(dev));
>  }
>  
>  static void ics_kvm_reset_handler(void *dev)
> @@ -318,10 +318,6 @@ static void ics_kvm_class_init(ObjectClass *klass, void *data)
>                                      &icsc->parent_realize);
>      device_class_set_parent_reset(dc, ics_kvm_reset,
>                                    &icsc->parent_reset);
> -
> -    icsc->pre_save = ics_get_kvm_state;
> -    icsc->post_load = ics_set_kvm_state;
> -    icsc->synchronize_state = ics_synchronize_state;
>  }
>  
>  static const TypeInfo ics_kvm_info = {
> diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
> index fae54e6f28ae..06e87128f88e 100644
> --- a/include/hw/ppc/xics.h
> +++ b/include/hw/ppc/xics.h
> @@ -109,12 +109,9 @@ struct ICSStateClass {
>      DeviceRealize parent_realize;
>      DeviceReset parent_reset;
>  
> -    void (*pre_save)(ICSState *s);
> -    int (*post_load)(ICSState *s, int version_id);
>      void (*reject)(ICSState *s, uint32_t irq);
>      void (*resend)(ICSState *s);
>      void (*eoi)(ICSState *s, uint32_t irq);
> -    void (*synchronize_state)(ICSState *s);
>  };
>  
>  struct ICSState {
> @@ -201,4 +198,8 @@ int icp_set_kvm_state(ICPState *icp);
>  void icp_synchronize_state(ICPState *icp);
>  void icp_kvm_realize(DeviceState *dev, Error **errp);
>  
> +void ics_get_kvm_state(ICSState *ics);
> +int ics_set_kvm_state(ICSState *ics);
> +void ics_synchronize_state(ICSState *ics);
> +
>  #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
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 [this message]
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=20190217233941.GG2765@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).