From patchwork Thu Jun 14 04:33:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 164796 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id A6896B7037 for ; Thu, 14 Jun 2012 14:33:18 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750917Ab2FNEdR (ORCPT ); Thu, 14 Jun 2012 00:33:17 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:57639 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750878Ab2FNEdR (ORCPT ); Thu, 14 Jun 2012 00:33:17 -0400 Received: by dady13 with SMTP id y13so2001055dad.19 for ; Wed, 13 Jun 2012 21:33:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=6aHgr10AyU84ZVjqzTI5E0pj/aXS5mTUWpocLmFT81k=; b=O2+i6nBsxqNCyoMxMhNc4zvRFQKr4SBAvYTeldGwKsz8P+Amsa1ezPDZwWUVV+/dIv x99n6JC7rcdC/o9xcaXif12pHn+5Cr/Elzb6xrIHaWUj+92Kg1r1BHS7xVN0QIkRKW8l hi7OKhzO0Dy+/VUHmXdU8GjPfzmDhUfdXxoyjkWJunMn4DBBSUH0qi+cnqpMSoTxv/ad fUuw3443GCXQzEnZJiwmc7PBE8W6jL1hOYgq9kKhN3kQpfBFQi1DrCRKWExcIR9pEFiK 3xL5jxAWRS6k2KAHsPjP+vKm17W5v+qtmcN5aobzgn/102OFJfa2Ygx5J5blHZ36EZQs wPDw== Received: by 10.68.232.161 with SMTP id tp1mr3577822pbc.44.1339648396754; Wed, 13 Jun 2012 21:33:16 -0700 (PDT) Received: from [10.61.2.175] (ibmaus65.lnk.telstra.net. [165.228.126.9]) by mx.google.com with ESMTPS id hf5sm469950pbc.4.2012.06.13.21.33.15 (version=SSLv3 cipher=OTHER); 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 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: "qemu-devel@nongnu.org" , kvm-ppc@vger.kernel.org Subject: [PATCH 2/3] pseries: added allocator for a block of IRQs References: <4FD968BB.2000505@ozlabs.ru> In-Reply-To: <4FD968BB.2000505@ozlabs.ru> X-Gm-Message-State: ALoCoQnQBUQmZkuDspGB8mwUIyhYmVk6MhBHO+72Nb+pizvBPZ8OhIsg+GYK6jqq2EunCFr2fmo+ Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: 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) {