From patchwork Wed Aug 8 02:10:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 175849 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4996A2C00B3 for ; Wed, 8 Aug 2012 12:56:25 +1000 (EST) Received: from localhost ([::1]:40593 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SyvkB-0002WO-K0 for incoming@patchwork.ozlabs.org; Tue, 07 Aug 2012 22:11:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Syvjc-000129-41 for qemu-devel@nongnu.org; Tue, 07 Aug 2012 22:10:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SyvjZ-0005IX-Db for qemu-devel@nongnu.org; Tue, 07 Aug 2012 22:10:56 -0400 Received: from ozlabs.org ([203.10.76.45]:60524) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SyvjZ-0005Hn-26; Tue, 07 Aug 2012 22:10:53 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 997E72C00BE; Wed, 8 Aug 2012 12:10:49 +1000 (EST) From: David Gibson To: agraf@suse.de, qemu-ppc@nongnu.org Date: Wed, 8 Aug 2012 12:10:34 +1000 Message-Id: <1344391839-2006-6-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1344391839-2006-1-git-send-email-david@gibson.dropbear.id.au> References: <1344391839-2006-1-git-send-email-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 203.10.76.45 Cc: Alexey Kardashevskiy , aliguori@us.ibm.com, qemu-devel@nongnu.org, David Gibson Subject: [Qemu-devel] [PATCH 05/10] pseries: added allocator for a block of IRQs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Alexey Kardashevskiy 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 Signed-off-by: David Gibson --- hw/spapr.c | 26 ++++++++++++++++++++++++++ hw/spapr.h | 1 + 2 files changed, 27 insertions(+) diff --git a/hw/spapr.c b/hw/spapr.c index 8b4af62..2b66f54 100644 --- a/hw/spapr.c +++ b/hw/spapr.c @@ -104,6 +104,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; diff --git a/hw/spapr.h b/hw/spapr.h index c5de18d..76493cb 100644 --- a/hw/spapr.h +++ b/hw/spapr.h @@ -289,6 +289,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) {