Skip to content

Commit

Permalink
pseries: added allocator for a block of IRQs
Browse files Browse the repository at this point in the history
The patch adds a simple helper which allocates a consecutive sequence
of IRQs calling spapr_allocate_irq for each and checks that allocated
IRQs go consequently.

The patch is required for upcoming support of MSI/MSIX on POWER.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
  • Loading branch information
aik authored and agraf committed Aug 15, 2012
1 parent fa28f71 commit f4b9523
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions hw/spapr.c
Expand Up @@ -105,6 +105,32 @@ int spapr_allocate_irq(int hint, enum xics_irq_type type)
return irq;
}

/* Allocate block of consequtive IRQs, returns a number of the first */
int spapr_allocate_irq_block(int num, enum xics_irq_type type)
{
int first = -1;
int i;

for (i = 0; i < num; ++i) {
int irq;

irq = spapr_allocate_irq(0, type);
if (!irq) {
return -1;
}

if (0 == i) {
first = irq;
}

/* If the above doesn't create a consecutive block then that's
* an internal bug */
assert(irq == (first + i));
}

return first;
}

static int spapr_set_associativity(void *fdt, sPAPREnvironment *spapr)
{
int ret = 0, offset;
Expand Down
1 change: 1 addition & 0 deletions hw/spapr.h
Expand Up @@ -290,6 +290,7 @@ target_ulong spapr_hypercall(CPUPPCState *env, target_ulong opcode,
target_ulong *args);

int spapr_allocate_irq(int hint, enum xics_irq_type type);
int spapr_allocate_irq_block(int num, enum xics_irq_type type);

static inline int spapr_allocate_msi(int hint)
{
Expand Down

0 comments on commit f4b9523

Please sign in to comment.