From patchwork Wed Aug 15 09:58:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 177609 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 239B72C0086 for ; Wed, 15 Aug 2012 20:24:08 +1000 (EST) Received: from localhost ([::1]:50920 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1ali-00020J-65 for incoming@patchwork.ozlabs.org; Wed, 15 Aug 2012 06:24:06 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1alZ-0001zr-6Y for qemu-devel@nongnu.org; Wed, 15 Aug 2012 06:23:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T1alY-0005ef-79 for qemu-devel@nongnu.org; Wed, 15 Aug 2012 06:23:57 -0400 Received: from cantor2.suse.de ([195.135.220.15]:39652 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T1alX-0005eZ-Te; Wed, 15 Aug 2012 06:23:56 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 8C6C3A3D8B; Wed, 15 Aug 2012 11:59:20 +0200 (CEST) From: Alexander Graf To: qemu-ppc Mailing List Date: Wed, 15 Aug 2012 11:58:56 +0200 Message-Id: <1345024742-18394-19-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1345024742-18394-1-git-send-email-agraf@suse.de> References: <1345024742-18394-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: Blue Swirl , Alexey Kardashevskiy , qemu-devel qemu-devel , Aurelien Jarno , David Gibson Subject: [Qemu-devel] [PATCH 18/24] 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 Signed-off-by: Alexander Graf --- hw/spapr.c | 26 ++++++++++++++++++++++++++ hw/spapr.h | 1 + 2 files changed, 27 insertions(+), 0 deletions(-) diff --git a/hw/spapr.c b/hw/spapr.c index 8153c05..afbdbc5 100644 --- a/hw/spapr.c +++ b/hw/spapr.c @@ -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; diff --git a/hw/spapr.h b/hw/spapr.h index b5cf6af..6229769 100644 --- a/hw/spapr.h +++ b/hw/spapr.h @@ -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) {