From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:52943) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Soam2-0008EH-Pz for qemu-devel@nongnu.org; Tue, 10 Jul 2012 09:46:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Soals-000150-Of for qemu-devel@nongnu.org; Tue, 10 Jul 2012 09:46:42 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:34715) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Soals-00014e-IZ for qemu-devel@nongnu.org; Tue, 10 Jul 2012 09:46:32 -0400 Received: by pbbro12 with SMTP id ro12so335205pbb.4 for ; Tue, 10 Jul 2012 06:46:30 -0700 (PDT) From: Alexey Kardashevskiy Date: Tue, 10 Jul 2012 23:46:10 +1000 Message-Id: <1341927973-5615-3-git-send-email-aik@ozlabs.ru> In-Reply-To: <1341927973-5615-1-git-send-email-aik@ozlabs.ru> References: <1341927973-5615-1-git-send-email-aik@ozlabs.ru> Subject: [Qemu-devel] [PATCH] pseries: added allocator for a block of IRQs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , qemu-devel@nongnu.org, Alexander Graf , qemu-ppc@nongnu.org, David Gibson 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 --- hw/spapr.c | 20 ++++++++++++++++++++ hw/spapr.h | 1 + 2 files changed, 21 insertions(+) diff --git a/hw/spapr.c b/hw/spapr.c index 6a9a7ca..f47c109 100644 --- a/hw/spapr.c +++ b/hw/spapr.c @@ -113,6 +113,26 @@ 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; + } + if (ret + i != irq) { + return -1; + } + } + return ret; +} + static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment *spapr) { int ret = 0, offset; diff --git a/hw/spapr.h b/hw/spapr.h index d0c1749..4a3520f 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.10