From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50854) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sf1kG-0004O7-Lh for qemu-devel@nongnu.org; Thu, 14 Jun 2012 00:33:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sf1kE-00005m-Vg for qemu-devel@nongnu.org; Thu, 14 Jun 2012 00:33:20 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:48774) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sf1kE-00005X-PW for qemu-devel@nongnu.org; Thu, 14 Jun 2012 00:33:18 -0400 Received: by dadn2 with SMTP id n2so953043dad.4 for ; Wed, 13 Jun 2012 21:33:16 -0700 (PDT) Message-ID: <4FD96989.4090600@ozlabs.ru> Date: Thu, 14 Jun 2012 14:33:13 +1000 From: Alexey Kardashevskiy MIME-Version: 1.0 References: <4FD968BB.2000505@ozlabs.ru> In-Reply-To: <4FD968BB.2000505@ozlabs.ru> Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 2/3] pseries: added allocator for a block of IRQs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "qemu-devel@nongnu.org" , kvm-ppc@vger.kernel.org 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 | 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) { + 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexey Kardashevskiy Date: Thu, 14 Jun 2012 04:33:13 +0000 Subject: [PATCH 2/3] pseries: added allocator for a block of IRQs Message-Id: <4FD96989.4090600@ozlabs.ru> List-Id: References: <4FD968BB.2000505@ozlabs.ru> In-Reply-To: <4FD968BB.2000505@ozlabs.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: "qemu-devel@nongnu.org" , kvm-ppc@vger.kernel.org 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 | 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) { + 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