diff mbox series

[for-2.12,v2,07/12] spapr: introduce an 'irq_base' number

Message ID 20171109101439.390-8-clg@kaod.org
State New
Headers show
Series spapr: introduce an IRQ allocator at the machine level | expand

Commit Message

Cédric Le Goater Nov. 9, 2017, 10:14 a.m. UTC
'irq_base' is a base IRQ number which lets us allocate only the subset
of the IRQ numbers used on the sPAPR platform. It is sync with the
ICSState 'offset' attribute and this is slightly redundant. We could
also choose to waste some extra bytes (512) and allocate the whole
number space. To be discussed.

But more important, it removes a dependency on the ICSState object of
the sPAPR machine which is required for XIVE.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/ppc/spapr.c         | 11 +++++------
 include/hw/ppc/spapr.h |  1 +
 2 files changed, 6 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index d4d0a36cc5bf..6c3fc12ed8e1 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2383,6 +2383,7 @@  static void ppc_spapr_init(MachineState *machine)
     /* Initialize the IRQ allocator */
     spapr->nr_irqs  = XICS_IRQS_SPAPR;
     spapr->irq_map  = bitmap_new(spapr->nr_irqs);
+    spapr->irq_base = XICS_IRQ_BASE;
 
     /* Set up Interrupt Controller before we create the VCPUs */
     xics_system_init(machine, spapr->nr_irqs, &error_fatal);
@@ -3586,8 +3587,7 @@  static ICPState *spapr_icp_get(XICSFabric *xi, int vcpu_id)
 static bool spapr_irq_test(XICSFabric *xi, int irq)
 {
     sPAPRMachineState *spapr = SPAPR_MACHINE(xi);
-    ICSState *ics = spapr->ics;
-    int srcno = irq - ics->offset;
+    int srcno = irq - spapr->irq_base;
 
     return test_bit(srcno, spapr->irq_map);
 }
@@ -3595,7 +3595,6 @@  static bool spapr_irq_test(XICSFabric *xi, int irq)
 static int spapr_irq_alloc_block(XICSFabric *xi, int count, int align)
 {
     sPAPRMachineState *spapr = SPAPR_MACHINE(xi);
-    ICSState *ics = spapr->ics;
     int start = 0;
     int srcno;
 
@@ -3614,21 +3613,21 @@  static int spapr_irq_alloc_block(XICSFabric *xi, int count, int align)
     }
 
     bitmap_set(spapr->irq_map, srcno, count);
-    return srcno + ics->offset;
+    return srcno + spapr->irq_base;
 }
 
 static void spapr_irq_free_block(XICSFabric *xi, int irq, int num)
 {
     sPAPRMachineState *spapr = SPAPR_MACHINE(xi);
     ICSState *ics = spapr->ics;
-    int srcno = irq - ics->offset;
+    int srcno = irq - spapr->irq_base;
     int i;
 
     if (ics_valid_irq(ics, irq)) {
         trace_spapr_irq_free(0, irq, num);
         for (i = srcno; i < srcno + num; ++i) {
             if (!test_bit(i, spapr->irq_map)) {
-                trace_spapr_irq_free_warn(0, i + ics->offset);
+                trace_spapr_irq_free_warn(0, i + spapr->irq_base);
             }
         }
         bitmap_clear(spapr->irq_map, srcno, num);
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 090eda962ccb..8d227fe6f56c 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -83,6 +83,7 @@  struct sPAPRMachineState {
     int32_t nr_irqs;
     unsigned long *irq_map;
     unsigned long *irq_map_ref;
+    uint32_t irq_base;
     ICSState *ics;
     sPAPRRTCState rtc;