From patchwork Sun Aug 11 02:47:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 2842657 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9870EBF546 for ; Sun, 11 Aug 2013 02:56:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AD101202F0 for ; Sun, 11 Aug 2013 02:56:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C45CF202EA for ; Sun, 11 Aug 2013 02:56:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751786Ab3HKCso (ORCPT ); Sat, 10 Aug 2013 22:48:44 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:34734 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751956Ab3HKCsm (ORCPT ); Sat, 10 Aug 2013 22:48:42 -0400 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r7B2mDlE015617 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 11 Aug 2013 02:48:14 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r7B2mDbn001353 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 11 Aug 2013 02:48:13 GMT Received: from abhmt117.oracle.com (abhmt117.oracle.com [141.146.116.69]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r7B2mC00001349; Sun, 11 Aug 2013 02:48:12 GMT Received: from linux-siqj.site.site (/75.36.254.102) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 10 Aug 2013 19:48:12 -0700 From: Yinghai Lu To: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Tony Luck , Bjorn Helgaas , "Rafael J. Wysocki" Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Yinghai Lu , Joerg Roedel , Konrad Rzeszutek Wilk , Sebastian Andrzej Siewior Subject: [PATCH v4 02/28] genirq: Add irq_alloc_reserved_desc() Date: Sat, 10 Aug 2013 19:47:48 -0700 Message-Id: <1376189294-32022-3-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1376189294-32022-1-git-send-email-yinghai@kernel.org> References: <1376189294-32022-1-git-send-email-yinghai@kernel.org> X-Source-IP: acsinet21.oracle.com [141.146.126.237] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For ioapic hot-add support, it would be easy if we have continuous irq numbers for hot added ioapic controller. We can reserve irq range at first, and later allocate desc for those pre-reserved irqs when they are needed. The reasons for not allocating them during reserving: 1. only several pins of one ioapic are used, allocate for all pins, will waste memory for not used pins. 2. allocate later when is needed could make sure irq_desc is allocated on local node ram, as dev->node is set at that point. -v2: update changelog by adding reasons, requested by Konrad. -v3: according to tglx: separate core code change with arch code change. change function name to irq_alloc_reserved_desc. kill __irq_is_reserved(). remove not need exports. according to Sebastian: spare one comments by put two functions together. Signed-off-by: Yinghai Lu Cc: Joerg Roedel Cc: Konrad Rzeszutek Wilk Cc: Sebastian Andrzej Siewior --- include/linux/irq.h | 3 +++ kernel/irq/irqdesc.c | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/linux/irq.h b/include/linux/irq.h index 8c46cb2..b998ea7 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -592,10 +592,13 @@ static inline u32 irq_get_trigger_type(unsigned int irq) int __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node, struct module *owner); +int __irq_alloc_reserved_desc(int at, int node, struct module *owner); /* use macros to avoid needing export.h for THIS_MODULE */ #define irq_alloc_descs(irq, from, cnt, node) \ __irq_alloc_descs(irq, from, cnt, node, THIS_MODULE) +#define irq_alloc_reserved_desc_at(at, node) \ + __irq_alloc_reserved_desc(at, node, THIS_MODULE) #define irq_alloc_desc(node) \ irq_alloc_descs(-1, 0, 1, node) diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index a151db6..1166545 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -410,6 +410,29 @@ __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node, EXPORT_SYMBOL_GPL(__irq_alloc_descs); /** + * __irq_alloc_reserved_desc - allocate irq descriptor for irq that is already reserved + * @irq: Allocate for specific irq number if irq >= 0 + * @node: Preferred node on which the irq descriptor should be allocated + * @owner: Owning module (can be NULL) + * + * Returns the irq number or error code + */ +int __ref __irq_alloc_reserved_desc(int irq, int node, struct module *owner) +{ + mutex_lock(&sparse_irq_lock); + if (!test_bit(irq, allocated_irqs)) { + mutex_unlock(&sparse_irq_lock); + return -EINVAL; + } + mutex_unlock(&sparse_irq_lock); + + if (irq_to_desc(irq)) + return irq; + + return alloc_descs(irq, 1, node, owner); +} + +/** * irq_reserve_irqs - mark irqs allocated * @from: mark from irq number * @cnt: number of irqs to mark