From patchwork Sun Aug 11 02:48:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 266287 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 9E5E12C00B7 for ; Sun, 11 Aug 2013 12:50:39 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753719Ab3HKCtl (ORCPT ); Sat, 10 Aug 2013 22:49:41 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:34914 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753709Ab3HKCtj (ORCPT ); Sat, 10 Aug 2013 22:49:39 -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 r7B2n9fX016059 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 11 Aug 2013 02:49:09 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r7B2n8G0001901 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 11 Aug 2013 02:49:08 GMT Received: from abhmt117.oracle.com (abhmt117.oracle.com [141.146.116.69]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r7B2n78B012427; Sun, 11 Aug 2013 02:49:07 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:49:06 -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 22/28] x86, irq: Add mp_unregister_ioapic to handle hot-remove ioapic Date: Sat, 10 Aug 2013 19:48:08 -0700 Message-Id: <1376189294-32022-23-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 It will free ioapic related irq_desc and also clear allocated_irqs bits. Signed-off-by: Yinghai Lu Cc: Joerg Roedel Cc: Konrad Rzeszutek Wilk Cc: Sebastian Andrzej Siewior --- arch/x86/include/asm/mpspec.h | 1 + arch/x86/kernel/apic/io_apic.c | 44 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/arch/x86/include/asm/mpspec.h b/arch/x86/include/asm/mpspec.h index 13cf60c..49f6ecc 100644 --- a/arch/x86/include/asm/mpspec.h +++ b/arch/x86/include/asm/mpspec.h @@ -97,6 +97,7 @@ static inline void early_reserve_e820_mpc_new(void) { } void generic_processor_info(int apicid, int version); #ifdef CONFIG_ACPI int __mp_register_ioapic(int id, u32 address, u32 gsi_base, bool hot); +int mp_unregister_ioapic(u32 gsi_base); extern void mp_register_ioapic(int id, u32 address, u32 gsi_base); extern void mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi); diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 1616a35..a75e9d8 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -334,6 +334,20 @@ static void __init reserve_ioapic_gsi_irq_extra(void) } } +static void free_ioapic_gsi_irq_base(int idx) +{ + int i; + struct mp_ioapic_gsi *gsi_cfg = mp_ioapic_gsi_routing(idx); + int irq_base = gsi_cfg->irq_base; + int irq_cnt = gsi_cfg->gsi_end - gsi_cfg->gsi_base + 1; + + if (irq_base < 0) + return; + + for (i = irq_base; i < irq_base + irq_cnt; i++) + free_irq_at(i, irq_get_chip_data(i)); +} + static void alloc_ioapic_saved_registers(int idx) { if (ioapics[idx].saved_registers) @@ -347,6 +361,11 @@ static void alloc_ioapic_saved_registers(int idx) pr_err("IOAPIC %d: suspend/resume impossible!\n", idx); } +static void free_ioapic_saved_registers(int idx) +{ + kfree(ioapics[idx].saved_registers); +} + int __init arch_early_irq_init(void) { int node = cpu_to_node(0); @@ -3991,6 +4010,31 @@ void mp_register_ioapic(int id, u32 address, u32 gsi_base) __mp_register_ioapic(id, address, gsi_base, false); } +int mp_unregister_ioapic(u32 gsi_base) +{ + int idx; + + lock_ioapics(); + + idx = __mp_find_ioapic(gsi_base); + if (idx < 0) { + unlock_ioapics(); + return -EINVAL; + } + + free_ioapic_saved_registers(idx); + + free_ioapic_gsi_irq_base(idx); + + clear_fixmap(FIX_IO_APIC_BASE_0 + idx); + memset(&ioapics[idx], 0, sizeof(struct ioapic)); + clear_bit(idx, ioapics_mask); + + unlock_ioapics(); + + return 0; +} + /* Enable IOAPIC early just for system timer */ void __init pre_init_apic_IRQ0(void) {