[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH for-2.12 v2 10/12] spapr: split the IRQ number space f
From: |
Cédric Le Goater |
Subject: |
[Qemu-ppc] [PATCH for-2.12 v2 10/12] spapr: split the IRQ number space for LSI interrupts |
Date: |
Thu, 9 Nov 2017 11:14:37 +0100 |
The nature 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 (needed to introduce for 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.
For compatibility with older machines, we use the machine class flag
'has_irq_bitmap'.
Signed-off-by: Cédric Le Goater <address@hidden>
---
hw/intc/xics_spapr.c | 6 +++---
hw/ppc/spapr.c | 27 ++++++++++++++++++++++++++-
include/hw/ppc/xics.h | 2 +-
3 files changed, 30 insertions(+), 5 deletions(-)
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 86d5e310e85f..d576e235d226 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3592,9 +3592,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);
+ sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
int start = 0;
int srcno;
@@ -3606,12 +3618,20 @@ static int spapr_irq_alloc_block(XICSFabric *xi, int
count, int align)
*/
align -= 1;
+ if (!lsi && smc->has_irq_bitmap) {
+ start = SPAPR_MAX_LSI;
+ }
+
srcno = bitmap_find_next_zero_area(spapr->irq_map, spapr->nr_irqs, start,
count, align);
if (srcno == spapr->nr_irqs) {
return -1;
}
+ if (lsi && smc->has_irq_bitmap && srcno >= SPAPR_MAX_LSI) {
+ return -1;
+ }
+
bitmap_set(spapr->irq_map, srcno, count);
return srcno + spapr->irq_base;
}
@@ -3636,8 +3656,13 @@ static void spapr_irq_free_block(XICSFabric *xi, int
irq, int num)
static bool spapr_irq_is_lsi(XICSFabric *xi, int irq)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(xi);
+ sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
int srcno = irq - spapr->irq_base;
+ if (smc->has_irq_bitmap) {
+ return (srcno >= 0) && (srcno < SPAPR_MAX_LSI);
+ }
+
return spapr->ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI;
}
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;
--
2.13.6
- [Qemu-ppc] [PATCH for-2.12 v2 00/12] spapr: introduce an IRQ allocator at the machine level, Cédric Le Goater, 2017/11/09
- [Qemu-ppc] [PATCH for-2.12 v2 01/12] spapr: add pseries 2.12 machine type, Cédric Le Goater, 2017/11/09
- [Qemu-ppc] [PATCH for-2.12 v2 02/12] ppc/xics: remove useless if condition, Cédric Le Goater, 2017/11/09
- [Qemu-ppc] [PATCH for-2.12 v2 03/12] spapr: introduce new XICSFabric operations for an IRQ allocator, Cédric Le Goater, 2017/11/09
- [Qemu-ppc] [PATCH for-2.12 v2 04/12] spapr: move current IRQ allocation under the machine, Cédric Le Goater, 2017/11/09
- [Qemu-ppc] [PATCH for-2.12 v2 05/12] spapr: introduce an IRQ allocator using a bitmap, Cédric Le Goater, 2017/11/09
- [Qemu-ppc] [PATCH for-2.12 v2 06/12] spapr: store a reference IRQ bitmap, Cédric Le Goater, 2017/11/09
- [Qemu-ppc] [PATCH for-2.12 v2 07/12] spapr: introduce an 'irq_base' number, Cédric Le Goater, 2017/11/09
- [Qemu-ppc] [PATCH for-2.12 v2 08/12] spapr: remove the use of ics_valid_irq(), Cédric Le Goater, 2017/11/09
- [Qemu-ppc] [PATCH for-2.12 v2 09/12] spapr: introduce a XICSFabric irq_is_lsi() operation, Cédric Le Goater, 2017/11/09
- [Qemu-ppc] [PATCH for-2.12 v2 10/12] spapr: split the IRQ number space for LSI interrupts,
Cédric Le Goater <=
- [Qemu-ppc] [PATCH for-2.12 v2 11/12] sparp: merge ics_set_irq_type() in irq_alloc_block() operation, Cédric Le Goater, 2017/11/09
- [Qemu-ppc] [PATCH for-2.12 v2 12/12] spapr: use sPAPRMachineState in spapr_ics_ prototypes, Cédric Le Goater, 2017/11/09
- Re: [Qemu-ppc] [PATCH for-2.12 v2 00/12] spapr: introduce an IRQ allocator at the machine level, Cédric Le Goater, 2017/11/09