Hello, Currently, the ICSState 'ics' object of the sPAPR machine acts as the global interrupt source handler and also as the IRQ number allocator for the machine. Some IRQ numbers are allocated very early in the machine initialization sequence to populate the device tree, and this is a problem to introduce the new POWER XIVE interrupt model, as it needs to share the IRQ numbers with the older model.
To prepare ground for XIVE, here is a proposal adding a set of new XICSFabric operations to let the machine handle directly the IRQ number allocation and to decorrelate the allocation from the interrupt source object : 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); In these prototypes, the 'irq' parameter refers to a number in the global IRQ number space. On the latest pseries machines, these operations are simply backed by a bitmap and to handle migration compatibility, we keep an old set of operations using the ICSIRQState array. To completely remove the use of the ICSState object (required to introduce XIVE), we also need to change how the nature of an interrupt, MSI or LSI, is stored. Today, this is done using the flag attribute of the ICSIRQState array. We change that by splitting the IRQ number space of the machine in two: first the LSIs and then the MSIs. This has the benefit to keep the LSI IRQ numbers in a well known range which is useful for PHB hotplug. The git repo for this pachset can be found here along with the latest XIVE model: https://github.com/legoater/qemu/commits/xive Thanks, C. Tests : - make check on each patch - migration : qemu-2.12 (pseries-2.12) <-> qemu-2.12 (pseries-2.12) qemu-2.12 (pseries-2.10) <-> qemu-2.12 (pseries-2.10) qemu-2.10 (pseries-2.10) <-> qemu-2.12 (pseries-2.10) Changes since v2 : - introduced a second set of XICSFabric IRQ operations for older pseries machines Changes since v1 : - reorganised patchset to introduce the XICSFabric operations before the major changes: bitmap and IRQ number space split - introduced a reference bitmap to save some state in migration Cédric Le Goater (11): spapr: add pseries 2.12 machine type ppc/xics: remove useless if condition spapr: introduce new XICSFabric operations for an IRQ allocator spapr: move current IRQ allocation under the machine spapr: introduce an IRQ allocator using a bitmap spapr: store a reference IRQ bitmap spapr: introduce an 'irq_base' number spapr: introduce a XICSFabric irq_is_lsi() operation spapr: split the IRQ number space for LSI interrupts sparp: merge ics_set_irq_type() in irq_alloc_block() operation spapr: use sPAPRMachineState in spapr_ics_ prototypes hw/intc/trace-events | 2 - hw/intc/xics.c | 37 ++++----- hw/intc/xics_kvm.c | 4 +- hw/intc/xics_spapr.c | 76 +++--------------- hw/ppc/pnv.c | 34 ++++++++ hw/ppc/pnv_psi.c | 4 - hw/ppc/spapr.c | 209 ++++++++++++++++++++++++++++++++++++++++++++++++- hw/ppc/spapr_events.c | 4 +- hw/ppc/spapr_pci.c | 8 +- hw/ppc/spapr_vio.c | 2 +- hw/ppc/trace-events | 2 + include/hw/ppc/spapr.h | 5 ++ include/hw/ppc/xics.h | 20 +++-- 13 files changed, 301 insertions(+), 106 deletions(-) -- 2.13.6