All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
	Greg Kurz <groug@kaod.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [Qemu-devel] [PATCH for-2.12 v3 08/11] spapr: introduce a XICSFabric irq_is_lsi() operation
Date: Fri, 17 Nov 2017 15:54:12 +1100	[thread overview]
Message-ID: <20171117045412.GC26448@umbus.fritz.box> (raw)
In-Reply-To: <20171110152017.24324-9-clg@kaod.org>

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

On Fri, Nov 10, 2017 at 03:20:14PM +0000, Cédric Le Goater wrote:
> It will be used later on to distinguish the allocation of an LSI
> interrupt from an MSI and also to reduce the use of the ICSIRQState
> array of the ICSState object, which is on our way to introduce XIVE.
> 
> The 'irq' parameter continues to refer to the global IRQ number space.
> 
> On PowerNV, only the PSI controller interrupts are handled and they
> are all LSIs.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

!?! AFAICT this is a step backwards.  The users of ics_is_lsi() here
are in the xics code.  So they already have the right information
locally in the ICSState object.  Why on earth would you indirect
through the fabric.

> ---
>  hw/intc/xics.c        | 26 +++++++++++++++++---------
>  hw/intc/xics_kvm.c    |  4 ++--
>  hw/ppc/pnv.c          | 16 ++++++++++++++++
>  hw/ppc/spapr.c        |  9 +++++++++
>  include/hw/ppc/xics.h |  2 ++
>  5 files changed, 46 insertions(+), 11 deletions(-)
> 
> diff --git a/hw/intc/xics.c b/hw/intc/xics.c
> index 2c4899f278e2..42880e736697 100644
> --- a/hw/intc/xics.c
> +++ b/hw/intc/xics.c
> @@ -33,6 +33,7 @@
>  #include "trace.h"
>  #include "qemu/timer.h"
>  #include "hw/ppc/xics.h"
> +#include "hw/ppc/spapr.h"
>  #include "qemu/error-report.h"
>  #include "qapi/visitor.h"
>  #include "monitor/monitor.h"
> @@ -70,8 +71,7 @@ void ics_pic_print_info(ICSState *ics, Monitor *mon)
>          }
>          monitor_printf(mon, "  %4x %s %02x %02x\n",
>                         ics->offset + i,
> -                       (irq->flags & XICS_FLAGS_IRQ_LSI) ?
> -                       "LSI" : "MSI",
> +                       ics_is_lsi(ics, i) ? "LSI" : "MSI",

!?! 

>                         irq->priority, irq->status);
>      }
>  }
> @@ -377,6 +377,14 @@ static const TypeInfo icp_info = {
>  /*
>   * ICS: Source layer
>   */
> +bool ics_is_lsi(ICSState *ics, int srcno)
> +{
> +    XICSFabric *xi = ics->xics;
> +    XICSFabricClass *xic = XICS_FABRIC_GET_CLASS(xi);
> +
> +    return xic->irq_is_lsi(xi, srcno + ics->offset);
> +}
> +
>  static void ics_simple_resend_msi(ICSState *ics, int srcno)
>  {
>      ICSIRQState *irq = ics->irqs + srcno;
> @@ -435,7 +443,7 @@ static void ics_simple_set_irq(void *opaque, int srcno, int val)
>  {
>      ICSState *ics = (ICSState *)opaque;
>  
> -    if (ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI) {
> +    if (ics_is_lsi(ics, srcno)) {
>          ics_simple_set_irq_lsi(ics, srcno, val);
>      } else {
>          ics_simple_set_irq_msi(ics, srcno, val);
> @@ -472,7 +480,7 @@ void ics_simple_write_xive(ICSState *ics, int srcno, int server,
>      trace_xics_ics_simple_write_xive(ics->offset + srcno, srcno, server,
>                                       priority);
>  
> -    if (ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI) {
> +    if (ics_is_lsi(ics, srcno)) {
>          ics_simple_write_xive_lsi(ics, srcno);
>      } else {
>          ics_simple_write_xive_msi(ics, srcno);
> @@ -484,10 +492,10 @@ static void ics_simple_reject(ICSState *ics, uint32_t nr)
>      ICSIRQState *irq = ics->irqs + nr - ics->offset;
>  
>      trace_xics_ics_simple_reject(nr, nr - ics->offset);
> -    if (irq->flags & XICS_FLAGS_IRQ_MSI) {
> -        irq->status |= XICS_STATUS_REJECTED;
> -    } else if (irq->flags & XICS_FLAGS_IRQ_LSI) {
> +    if (ics_is_lsi(ics, nr - ics->offset)) {
>          irq->status &= ~XICS_STATUS_SENT;
> +    } else {
> +        irq->status |= XICS_STATUS_REJECTED;
>      }
>  }
>  
> @@ -497,7 +505,7 @@ static void ics_simple_resend(ICSState *ics)
>  
>      for (i = 0; i < ics->nr_irqs; i++) {
>          /* FIXME: filter by server#? */
> -        if (ics->irqs[i].flags & XICS_FLAGS_IRQ_LSI) {
> +        if (ics_is_lsi(ics, i)) {
>              ics_simple_resend_lsi(ics, i);
>          } else {
>              ics_simple_resend_msi(ics, i);
> @@ -512,7 +520,7 @@ static void ics_simple_eoi(ICSState *ics, uint32_t nr)
>  
>      trace_xics_ics_simple_eoi(nr);
>  
> -    if (ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI) {
> +    if (ics_is_lsi(ics, srcno)) {
>          irq->status &= ~XICS_STATUS_SENT;
>      }
>  }
> diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
> index 3091ad3ac2c8..2f10637c9f7c 100644
> --- a/hw/intc/xics_kvm.c
> +++ b/hw/intc/xics_kvm.c
> @@ -258,7 +258,7 @@ static int ics_set_kvm_state(ICSState *ics, int version_id)
>              state |= KVM_XICS_MASKED;
>          }
>  
> -        if (ics->irqs[i].flags & XICS_FLAGS_IRQ_LSI) {
> +        if (ics_is_lsi(ics, i)) {
>              state |= KVM_XICS_LEVEL_SENSITIVE;
>              if (irq->status & XICS_STATUS_ASSERTED) {
>                  state |= KVM_XICS_PENDING;
> @@ -293,7 +293,7 @@ static void ics_kvm_set_irq(void *opaque, int srcno, int val)
>      int rc;
>  
>      args.irq = srcno + ics->offset;
> -    if (ics->irqs[srcno].flags & XICS_FLAGS_IRQ_MSI) {
> +    if (!ics_is_lsi(ics, srcno)) {
>          if (!val) {
>              return;
>          }
> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> index 8288940ef9d7..958223376b4c 100644
> --- a/hw/ppc/pnv.c
> +++ b/hw/ppc/pnv.c
> @@ -1035,6 +1035,21 @@ static bool pnv_irq_test(XICSFabric *xi, int irq)
>      return false;
>  }
>  
> +static bool pnv_irq_is_lsi(XICSFabric *xi, int irq)
> +{
> +    PnvMachineState *pnv = POWERNV_MACHINE(xi);
> +    int i;
> +
> +    /* PowerNV machine only has PSI interrupts which are all LSIs */
> +    for (i = 0; i < pnv->num_chips; i++) {
> +        ICSState *ics = &pnv->chips[i]->psi.ics;
> +        if (ics_valid_irq(ics, irq)) {
> +            return true;
> +        }
> +    }
> +    return false;
> +}
> +
>  static void pnv_pic_print_info(InterruptStatsProvider *obj,
>                                 Monitor *mon)
>  {
> @@ -1120,6 +1135,7 @@ static void powernv_machine_class_init(ObjectClass *oc, void *data)
>      xic->ics_get = pnv_ics_get;
>      xic->ics_resend = pnv_ics_resend;
>      xic->irq_test = pnv_irq_test;
> +    xic->irq_is_lsi = pnv_irq_is_lsi;
>      ispc->print_info = pnv_pic_print_info;
>  
>      powernv_machine_class_props_init(oc);
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 1cbbd7715a85..ce314fcf38db 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -3628,6 +3628,14 @@ static void spapr_irq_free_block_2_11(XICSFabric *xi, int irq, int num)
>      }
>  }
>  
> +static bool spapr_irq_is_lsi(XICSFabric *xi, int irq)
> +{
> +    sPAPRMachineState *spapr = SPAPR_MACHINE(xi);
> +    int srcno = irq - spapr->ics->offset;
> +
> +    return spapr->ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI;
> +}
> +
>  static bool spapr_irq_test(XICSFabric *xi, int irq)
>  {
>      sPAPRMachineState *spapr = SPAPR_MACHINE(xi);
> @@ -3765,6 +3773,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
>      xic->irq_test = spapr_irq_test;
>      xic->irq_alloc_block = spapr_irq_alloc_block;
>      xic->irq_free_block = spapr_irq_free_block;
> +    xic->irq_is_lsi = spapr_irq_is_lsi;
>  
>      ispc->print_info = spapr_pic_print_info;
>      /* Force NUMA node memory size to be a multiple of
> diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
> index 30e7f2e0a7dd..478f8e510179 100644
> --- a/include/hw/ppc/xics.h
> +++ b/include/hw/ppc/xics.h
> @@ -179,6 +179,7 @@ typedef struct XICSFabricClass {
>      bool (*irq_test)(XICSFabric *xi, int irq);
>      int (*irq_alloc_block)(XICSFabric *xi, int count, int align);
>      void (*irq_free_block)(XICSFabric *xi, int irq, int num);
> +    bool (*irq_is_lsi)(XICSFabric *xi, int irq);
>  } XICSFabricClass;
>  
>  #define XICS_IRQS_SPAPR               1024
> @@ -205,6 +206,7 @@ void ics_simple_write_xive(ICSState *ics, int nr, int server,
>  void ics_set_irq_type(ICSState *ics, int srcno, bool lsi);
>  void icp_pic_print_info(ICPState *icp, Monitor *mon);
>  void ics_pic_print_info(ICSState *ics, Monitor *mon);
> +bool ics_is_lsi(ICSState *ics, int srno);
>  
>  void ics_resend(ICSState *ics);
>  void icp_resend(ICPState *ss);

-- 
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:[~2017-11-17  5:13 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-10 15:20 [Qemu-devel] [PATCH for-2.12 v3 00/11] spapr: introduce an IRQ allocator at the machine level Cédric Le Goater
2017-11-10 15:20 ` [Qemu-devel] [PATCH for-2.12 v3 01/11] spapr: add pseries 2.12 machine type Cédric Le Goater
2017-11-11 15:15   ` Greg Kurz
2017-11-13  5:51   ` David Gibson
2017-11-13  9:50     ` Greg Kurz
2017-11-14  9:08       ` David Gibson
2017-11-13  7:14   ` [Qemu-devel] QEMU 3.0 ? (was: [PATCH for-2.12 v3 01/11] spapr: add pseries 2.12 machine type) Thomas Huth
2017-11-13  9:53     ` Peter Maydell
2017-11-13 10:03       ` [Qemu-devel] QEMU 3.0 ? Cédric Le Goater
2017-11-13 10:21         ` Peter Maydell
2017-11-13 10:25       ` Thomas Huth
2017-11-23 10:03     ` [Qemu-devel] QEMU 3.0 ? (was: [PATCH for-2.12 v3 01/11] spapr: add pseries 2.12 machine type) Cornelia Huck
2017-11-23 10:17       ` Peter Maydell
2017-11-23 10:57         ` [Qemu-devel] QEMU 3.0 ? Thomas Huth
2017-11-23 11:11           ` Daniel P. Berrange
2017-11-23 11:24             ` Thomas Huth
2017-11-23 11:33               ` Daniel P. Berrange
2017-11-23 11:40                 ` Thomas Huth
2017-11-23 11:17           ` Paolo Bonzini
2017-11-23 11:57             ` Thomas Huth
2017-11-23 12:05               ` Paolo Bonzini
2017-11-23 12:09                 ` Cornelia Huck
2017-11-23 12:26                   ` Paolo Bonzini
2017-11-23 12:39                     ` Cornelia Huck
2017-11-23 12:59                       ` Daniel P. Berrange
2017-11-23 13:08                         ` Paolo Bonzini
2017-11-23 13:23                           ` Daniel P. Berrange
2017-11-23 13:25                             ` Paolo Bonzini
2017-11-23 13:02                       ` Paolo Bonzini
2017-11-23 13:13                         ` Cornelia Huck
2017-11-23 13:27                           ` Paolo Bonzini
2017-11-23 13:13                         ` Peter Maydell
2017-11-23 13:51                           ` Paolo Bonzini
2017-11-23 13:57                             ` Peter Maydell
2017-11-23 14:01                               ` Thomas Huth
2017-11-23 14:13                                 ` Paolo Bonzini
2017-11-23 13:57                             ` Daniel P. Berrange
2017-11-23 14:57             ` Igor Mammedov
2017-11-23 11:14         ` [Qemu-devel] QEMU 3.0 ? (was: [PATCH for-2.12 v3 01/11] spapr: add pseries 2.12 machine type) Daniel P. Berrange
2017-11-23 11:26           ` [Qemu-devel] QEMU 3.0 ? Thomas Huth
2017-11-10 15:20 ` [Qemu-devel] [PATCH for-2.12 v3 02/11] ppc/xics: remove useless if condition Cédric Le Goater
2017-11-11 14:50   ` Greg Kurz
2017-11-13  5:28   ` David Gibson
2017-11-10 15:20 ` [Qemu-devel] [PATCH for-2.12 v3 03/11] spapr: introduce new XICSFabric operations for an IRQ allocator Cédric Le Goater
2017-11-14  8:52   ` Greg Kurz
2017-11-17  4:48   ` David Gibson
2017-11-17  7:16     ` Cédric Le Goater
2017-11-23 11:07       ` David Gibson
2017-11-23 13:22         ` Cédric Le Goater
2017-11-10 15:20 ` [Qemu-devel] [PATCH for-2.12 v3 04/11] spapr: move current IRQ allocation under the machine Cédric Le Goater
2017-11-14  8:56   ` Greg Kurz
2017-11-10 15:20 ` [Qemu-devel] [PATCH for-2.12 v3 05/11] spapr: introduce an IRQ allocator using a bitmap Cédric Le Goater
2017-11-14  9:42   ` Greg Kurz
2017-11-14 11:54     ` Cédric Le Goater
2017-11-14 15:28       ` Greg Kurz
2017-11-15  8:47         ` Cédric Le Goater
2017-11-17  4:50     ` David Gibson
2017-11-17  7:19       ` Cédric Le Goater
2017-11-23 11:08         ` David Gibson
2017-11-20 12:07       ` Greg Kurz
2017-11-23 11:13         ` David Gibson
2017-11-10 15:20 ` [Qemu-devel] [PATCH for-2.12 v3 06/11] spapr: store a reference IRQ bitmap Cédric Le Goater
2017-11-14 15:12   ` Greg Kurz
2017-11-10 15:20 ` [Qemu-devel] [PATCH for-2.12 v3 07/11] spapr: introduce an 'irq_base' number Cédric Le Goater
2017-11-14 15:45   ` Greg Kurz
2017-11-15 15:24     ` Cédric Le Goater
2017-11-15 16:43       ` Greg Kurz
2017-11-10 15:20 ` [Qemu-devel] [PATCH for-2.12 v3 08/11] spapr: introduce a XICSFabric irq_is_lsi() operation Cédric Le Goater
2017-11-14 16:21   ` Greg Kurz
2017-11-17  4:54   ` David Gibson [this message]
2017-11-17  7:23     ` Cédric Le Goater
2017-11-23 11:12       ` David Gibson
2017-11-23 13:26         ` Cédric Le Goater
2017-11-10 15:20 ` [Qemu-devel] [PATCH for-2.12 v3 09/11] spapr: split the IRQ number space for LSI interrupts Cédric Le Goater
2017-11-15 15:52   ` Greg Kurz
2017-11-15 16:08     ` Cédric Le Goater
2017-11-15 20:27       ` Greg Kurz
2017-11-10 15:20 ` [Qemu-devel] [PATCH for-2.12 v3 10/11] sparp: merge ics_set_irq_type() in irq_alloc_block() operation Cédric Le Goater
2017-11-10 15:20 ` [Qemu-devel] [PATCH for-2.12 v3 11/11] spapr: use sPAPRMachineState in spapr_ics_ prototypes 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=20171117045412.GC26448@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=benh@kernel.crashing.org \
    --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 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.