From patchwork Sun Aug 11 02:47:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 2842639 Return-Path: X-Original-To: patchwork-linux-acpi@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 EC9BABF546 for ; Sun, 11 Aug 2013 02:53:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 15763202E9 for ; Sun, 11 Aug 2013 02:53:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AAFCD202CA for ; Sun, 11 Aug 2013 02:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753424Ab3HKCxy (ORCPT ); Sat, 10 Aug 2013 22:53:54 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:34820 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753299Ab3HKCtK (ORCPT ); Sat, 10 Aug 2013 22:49:10 -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 r7B2mg0w015701 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 11 Aug 2013 02:48:43 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 r7B2mghP001577 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 11 Aug 2013 02:48:42 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 r7B2mgk7001574; Sun, 11 Aug 2013 02:48:42 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:41 -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 13/28] x86, irq: Add alloc_reserved_irq_and_cfg_at() Date: Sat, 10 Aug 2013 19:47:59 -0700 Message-Id: <1376189294-32022-14-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-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@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 new added ioapic controller. We can reserve irq range at first, then allocate those pre-reserved one when it is needed. Add alloc_reserved_irq_and_cfg_at() to really allocate irq_desc and cfg, because pre-reserved only mark bits in allocate_irqs bit maps. Also fallback to alloc_irq_and_cfg_at(), and it is needed as we do not actually reserved irq for io apic irq yet. This patch is x86 arch code. -v2: update changelog by adding reasons, requested by Konrad. -v3: according to tglx, separate to another patch, and use alloc_reserved_... instead of realloc_... also add handling for one possible path in alloc_reserved_irq_and_cfg_at(). Signed-off-by: Yinghai Lu Cc: Joerg Roedel Cc: Konrad Rzeszutek Wilk Cc: Sebastian Andrzej Siewior --- arch/x86/kernel/apic/io_apic.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index ef2d530..c883da9 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -301,6 +301,29 @@ static void free_irq_at(unsigned int at, struct irq_cfg *cfg) irq_free_desc(at); } +static struct irq_cfg *alloc_reserved_irq_and_cfg_at(unsigned int at, int node) +{ + struct irq_cfg *cfg; + int res; + + res = irq_alloc_reserved_desc_at(at, node); + + if (res >= 0) { + cfg = irq_desc_get_chip_data(irq_to_desc(at)); + if (cfg) + return cfg; + + cfg = alloc_irq_cfg(at, node); + if (cfg) + irq_set_chip_data(at, cfg); + else + irq_free_desc(at); + + return cfg; + } + + return alloc_irq_and_cfg_at(at, node); +} struct io_apic { unsigned int index; @@ -3352,7 +3375,7 @@ int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev) static int io_apic_setup_irq_pin(unsigned int irq, int node, struct io_apic_irq_attr *attr) { - struct irq_cfg *cfg = alloc_irq_and_cfg_at(irq, node); + struct irq_cfg *cfg = alloc_reserved_irq_and_cfg_at(irq, node); int ret; if (!cfg)