mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
spapr: introduce a fixed IRQ number space
This proposal introduces a new IRQ number space layout using static numbers for all devices, depending on a device index, and a bitmap allocator for the MSI IRQ numbers which are negotiated by the guest at runtime. As the VIO device model does not have a device index but a "reg" property, we introduce a formula to compute an IRQ number from a "reg" value. It should minimize most of the collisions. The previous layout is kept in pre-3.1 machines raising the 'legacy_irq_allocation' machine class flag. Signed-off-by: Cédric Le Goater <clg@kaod.org> Reviewed-by: Greg Kurz <groug@kaod.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
d45360d93d
commit
82cffa2eb2
8 changed files with 216 additions and 18 deletions
56
hw/ppc/spapr_irq.c
Normal file
56
hw/ppc/spapr_irq.c
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* QEMU PowerPC sPAPR IRQ interface
|
||||
*
|
||||
* Copyright (c) 2018, IBM Corporation.
|
||||
*
|
||||
* This code is licensed under the GPL version 2 or later. See the
|
||||
* COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/log.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qapi/error.h"
|
||||
#include "hw/ppc/spapr.h"
|
||||
#include "hw/ppc/xics.h"
|
||||
|
||||
void spapr_irq_msi_init(sPAPRMachineState *spapr, uint32_t nr_msis)
|
||||
{
|
||||
spapr->irq_map_nr = nr_msis;
|
||||
spapr->irq_map = bitmap_new(spapr->irq_map_nr);
|
||||
}
|
||||
|
||||
int spapr_irq_msi_alloc(sPAPRMachineState *spapr, uint32_t num, bool align,
|
||||
Error **errp)
|
||||
{
|
||||
int irq;
|
||||
|
||||
/*
|
||||
* The 'align_mask' parameter of bitmap_find_next_zero_area()
|
||||
* should be one less than a power of 2; 0 means no
|
||||
* alignment. Adapt the 'align' value of the former allocator
|
||||
* to fit the requirements of bitmap_find_next_zero_area()
|
||||
*/
|
||||
align -= 1;
|
||||
|
||||
irq = bitmap_find_next_zero_area(spapr->irq_map, spapr->irq_map_nr, 0, num,
|
||||
align);
|
||||
if (irq == spapr->irq_map_nr) {
|
||||
error_setg(errp, "can't find a free %d-IRQ block", num);
|
||||
return -1;
|
||||
}
|
||||
|
||||
bitmap_set(spapr->irq_map, irq, num);
|
||||
|
||||
return irq + SPAPR_IRQ_MSI;
|
||||
}
|
||||
|
||||
void spapr_irq_msi_free(sPAPRMachineState *spapr, int irq, uint32_t num)
|
||||
{
|
||||
bitmap_clear(spapr->irq_map, irq - SPAPR_IRQ_MSI, num);
|
||||
}
|
||||
|
||||
void spapr_irq_msi_reset(sPAPRMachineState *spapr)
|
||||
{
|
||||
bitmap_clear(spapr->irq_map, 0, spapr->irq_map_nr);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue