diff mbox

[2/3] pseries: added allocator for a block of IRQs

Message ID 4FD96989.4090600@ozlabs.ru
State New
Headers show

Commit Message

Alexey Kardashevskiy June 14, 2012, 4:33 a.m. UTC
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>
---
 hw/spapr.c |   19 +++++++++++++++++++
 hw/spapr.h |    1 +
 2 files changed, 20 insertions(+), 0 deletions(-)

Comments

Alexander Graf June 27, 2012, 2:47 p.m. UTC | #1
On 14.06.2012, at 06:33, Alexey Kardashevskiy wrote:

> 
> 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>
> ---
> hw/spapr.c |   19 +++++++++++++++++++
> hw/spapr.h |    1 +
> 2 files changed, 20 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/spapr.c b/hw/spapr.c
> index 2e0b4b8..ef6ffcb 100644
> --- a/hw/spapr.c
> +++ b/hw/spapr.c
> @@ -113,6 +113,25 @@ qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num,
>     return qirq;
> }
> 
> +/* Allocate block of consequtive IRQs, returns a number of the first */
> +int spapr_allocate_irq_block(uint32_t num, enum xics_irq_type type)
> +{
> +    int i, ret;
> +    uint32_t irq = -1;
> +
> +    for (i = 0; i < num; ++i) {
> +        if (!spapr_allocate_irq(0, &irq, type)) {
> +            return -1;
> +        }
> +        if (0 == i) {
> +            ret = irq;
> +        } else if (ret + i != irq) {

else? Why?

Alex

> +            return -1;
> +        }
> +    }
> +    return ret;
> +}
> +
> static int spapr_set_associativity(void *fdt, sPAPREnvironment *spapr)
> {
>     int ret = 0, offset;
> diff --git a/hw/spapr.h b/hw/spapr.h
> index 502393a..408b470 100644
> --- a/hw/spapr.h
> +++ b/hw/spapr.h
> @@ -289,6 +289,7 @@ target_ulong spapr_hypercall(CPUPPCState *env, target_ulong opcode,
> 
> qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num,
>                             enum xics_irq_type type);
> +int spapr_allocate_irq_block(uint32_t num, enum xics_irq_type type);
> 
> static inline qemu_irq spapr_allocate_msi(uint32_t hint, uint32_t *irq_num)
> {
> -- 
> 1.7.7.3
> --
> To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/hw/spapr.c b/hw/spapr.c
index 2e0b4b8..ef6ffcb 100644
--- a/hw/spapr.c
+++ b/hw/spapr.c
@@ -113,6 +113,25 @@  qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num,
     return qirq;
 }

+/* Allocate block of consequtive IRQs, returns a number of the first */
+int spapr_allocate_irq_block(uint32_t num, enum xics_irq_type type)
+{
+    int i, ret;
+    uint32_t irq = -1;
+
+    for (i = 0; i < num; ++i) {
+        if (!spapr_allocate_irq(0, &irq, type)) {
+            return -1;
+        }
+        if (0 == i) {
+            ret = irq;
+        } else if (ret + i != irq) {
+            return -1;
+        }
+    }
+    return ret;
+}
+
 static int spapr_set_associativity(void *fdt, sPAPREnvironment *spapr)
 {
     int ret = 0, offset;
diff --git a/hw/spapr.h b/hw/spapr.h
index 502393a..408b470 100644
--- a/hw/spapr.h
+++ b/hw/spapr.h
@@ -289,6 +289,7 @@  target_ulong spapr_hypercall(CPUPPCState *env, target_ulong opcode,

 qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num,
                             enum xics_irq_type type);
+int spapr_allocate_irq_block(uint32_t num, enum xics_irq_type type);

 static inline qemu_irq spapr_allocate_msi(uint32_t hint, uint32_t *irq_num)
 {