All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kurz <groug@kaod.org>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
	David Gibson <david@gibson.dropbear.id.au>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [Qemu-devel] [PATCH for-2.12 v3 09/11] spapr: split the IRQ number space for LSI interrupts
Date: Wed, 15 Nov 2017 16:52:18 +0100	[thread overview]
Message-ID: <20171115165218.6bb14b6f@bahia.lab.toulouse-stg.fr.ibm.com> (raw)
In-Reply-To: <20171110152017.24324-10-clg@kaod.org>

On Fri, 10 Nov 2017 15:20:15 +0000
Cédric Le Goater <clg@kaod.org> wrote:

> The type of an interrupt, MSI or LSI, is stored under the flag
> attribute of the ICSIRQState array. To reduce the use of this array
> and consequently of the ICSState object (This is needed to introduce
> the new XIVE model), we choose to split the IRQ number space of the
> machine in two: first the LSIs and then the MSIs.
> 
> This also has the benefit to keep the LSI IRQ numbers in a well known
> range which will be useful for PHB hotplug.
> 

Well... LSIs indeed land in a well known range, but it isn't enough for PHB
hotplug. Each PHB is uniquely identified by its 'index' property, and we
want each PHB to have fixed LSIs, so that they are invariant across migration.

> This change only applies to the latest pseries machines. Older
> machines still use the ICSIRQState array to define the IRQ type.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
> 
>  Changes since v2 :
> 
>  - introduced a second set of XICSFabric IRQ operations for older
>    pseries machines
> 
>  hw/intc/xics_spapr.c  |  6 +++---
>  hw/ppc/spapr.c        | 33 +++++++++++++++++++++++++++++----
>  include/hw/ppc/xics.h |  2 +-
>  3 files changed, 33 insertions(+), 8 deletions(-)pe-total-#msi
> 
> diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
> index de9e65d35247..b8e91aaf52bd 100644
> --- a/hw/intc/xics_spapr.c
> +++ b/hw/intc/xics_spapr.c
> @@ -260,7 +260,7 @@ int spapr_ics_alloc(ICSState *ics, int irq_hint, bool lsi, Error **errp)
>          }
>          irq = irq_hint;
>      } else {
> -        irq = xic->irq_alloc_block(ics->xics, 1, 1);
> +        irq = xic->irq_alloc_block(ics->xics, 1, 1, lsi);
>          if (irq < 0) {
>              error_setg(errp, "can't allocate IRQ: no IRQ left");
>              return -1;
> @@ -297,9 +297,9 @@ int spapr_ics_alloc_block(ICSState *ics, int num, bool lsi,
>      if (align) {
>          assert((num == 1) || (num == 2) || (num == 4) ||
>                 (num == 8) || (num == 16) || (num == 32));
> -        first = xic->irq_alloc_block(ics->xics, num, num);
> +        first = xic->irq_alloc_block(ics->xics, num, num, lsi);
>      } else {
> -        first = xic->irq_alloc_block(ics->xics, num, 1);
> +        first = xic->irq_alloc_block(ics->xics, num, 1, lsi);
>      }
>      if (first < 0) {
>          error_setg(errp, "can't find a free %d-IRQ block", num);
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index ce314fcf38db..f14eae6196cd 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -3596,7 +3596,8 @@ static bool spapr_irq_test_2_11(XICSFabric *xi, int irq)
>      return !ICS_IRQ_FREE(ics, srcno);
>  }
>  
> -static int spapr_irq_alloc_block_2_11(XICSFabric *xi, int count, int align)
> +static int spapr_irq_alloc_block_2_11(XICSFabric *xi, int count, int align,
> +                                      bool lsi)
>  {
>      sPAPRMachineState *spapr = SPAPR_MACHINE(xi);
>      ICSState *ics = spapr->ics;
> @@ -3628,7 +3629,7 @@ static void spapr_irq_free_block_2_11(XICSFabric *xi, int irq, int num)
>      }
>  }
>  
> -static bool spapr_irq_is_lsi(XICSFabric *xi, int irq)
> +static bool spapr_irq_is_lsi_2_11(XICSFabric *xi, int irq)
>  {
>      sPAPRMachineState *spapr = SPAPR_MACHINE(xi);
>      int srcno = irq - spapr->ics->offset;
> @@ -3644,10 +3645,21 @@ static bool spapr_irq_test(XICSFabric *xi, int irq)
>      return test_bit(srcno, spapr->irq_map);
>  }
>  
> -static int spapr_irq_alloc_block(XICSFabric *xi, int count, int align)
> +
> +/*
> + * Let's provision 4 LSIs per PHBs
> + */
> +#define SPAPR_MAX_LSI (SPAPR_MAX_PHBS * 4)
> +
> +/*
> + * Split the IRQ number space of the machine in two: first the LSIs
> + * and then the MSIs. This allows us to keep the LSI IRQ numbers in a
> + * well known range which is useful for PHB hotplug.
> + */
> +static int spapr_irq_alloc_block(XICSFabric *xi, int count, int align, bool lsi)
>  {
>      sPAPRMachineState *spapr = SPAPR_MACHINE(xi);
> -    int start = 0;
> +    int start = lsi ? 0 : SPAPR_MAX_LSI;
>      int srcno;
>  
>      /*
> @@ -3664,6 +3676,10 @@ static int spapr_irq_alloc_block(XICSFabric *xi, int count, int align)
>          return -1;
>      }
>  
> +    if (lsi && srcno >= SPAPR_MAX_LSI) {
> +        return -1;
> +    }
> +
>      bitmap_set(spapr->irq_map, srcno, count);
>      return srcno + spapr->irq_base;
>  }
> @@ -3676,6 +3692,14 @@ static void spapr_irq_free_block(XICSFabric *xi, int irq, int num)
>      bitmap_clear(spapr->irq_map, srcno, num);
>  }
>  
> +static bool spapr_irq_is_lsi(XICSFabric *xi, int irq)
> +{
> +    sPAPRMachineState *spapr = SPAPR_MACHINE(xi);
> +    int srcno = irq - spapr->irq_base;
> +
> +    return (srcno >= 0) && (srcno < SPAPR_MAX_LSI);
> +}
> +
>  static void spapr_pic_print_info(InterruptStatsProvider *obj,
>                                   Monitor *mon)
>  {
> @@ -3860,6 +3884,7 @@ static void spapr_machine_2_11_class_options(MachineClass *mc)
>      xic->irq_test = spapr_irq_test_2_11;
>      xic->irq_alloc_block = spapr_irq_alloc_block_2_11;
>      xic->irq_free_block = spapr_irq_free_block_2_11;
> +    xic->irq_is_lsi = spapr_irq_is_lsi_2_11;
>  }
>  
>  DEFINE_SPAPR_MACHINE(2_11, "2.11", false);
> diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h
> index 478f8e510179..292b929e88eb 100644
> --- a/include/hw/ppc/xics.h
> +++ b/include/hw/ppc/xics.h
> @@ -177,7 +177,7 @@ typedef struct XICSFabricClass {
>      ICPState *(*icp_get)(XICSFabric *xi, int server);
>      /* IRQ allocator helpers */
>      bool (*irq_test)(XICSFabric *xi, int irq);
> -    int (*irq_alloc_block)(XICSFabric *xi, int count, int align);
> +    int (*irq_alloc_block)(XICSFabric *xi, int count, int align, bool lsi);
>      void (*irq_free_block)(XICSFabric *xi, int irq, int num);
>      bool (*irq_is_lsi)(XICSFabric *xi, int irq);
>  } XICSFabricClass;

  reply	other threads:[~2017-11-15 15:52 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
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 [this message]
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=20171115165218.6bb14b6f@bahia.lab.toulouse-stg.fr.ibm.com \
    --to=groug@kaod.org \
    --cc=benh@kernel.crashing.org \
    --cc=clg@kaod.org \
    --cc=david@gibson.dropbear.id.au \
    --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.