aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorJiang Liu <jiang.liu@linux.intel.com>2014-10-27 01:21:46 -0400
committerThomas Gleixner <tglx@linutronix.de>2014-12-16 08:08:15 -0500
commit15516a3b8633a32f03a82a2db23b87cf9600514c (patch)
tree49093c302c72768b0d921c02cedcb5e252191f8b /arch/x86/kernel
parent7db298cb70125e322dfdb3f41e8129681a6f6b20 (diff)
x86, irq, ACPI: Implement interfaces to support ACPI based IOAPIC hot-removal
Implement acpi_unregister_ioapic() to support ACPI based IOAPIC hot-removal. An IOAPIC could only be removed when all its pins are unused. Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Tony Luck <tony.luck@intel.com> Cc: Joerg Roedel <joro@8bytes.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Rafael J. Wysocki <rjw@rjwysocki.net> Cc: Bjorn Helgaas <bhelgaas@google.com> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Yinghai Lu <yinghai@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Len Brown <len.brown@intel.com> Cc: Pavel Machek <pavel@ucw.cz> Cc: Grant Likely <grant.likely@linaro.org> Cc: Prarit Bhargava <prarit@redhat.com> Link: http://lkml.kernel.org/r/1414387308-27148-17-git-send-email-jiang.liu@linux.intel.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/acpi/boot.c13
-rw-r--r--arch/x86/kernel/apic/io_apic.c55
2 files changed, 64 insertions, 4 deletions
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 0b993511e0c5..5427d9b70f75 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -810,15 +810,20 @@ int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
810 810
811 return ret; 811 return ret;
812} 812}
813
814EXPORT_SYMBOL(acpi_register_ioapic); 813EXPORT_SYMBOL(acpi_register_ioapic);
815 814
816int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base) 815int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
817{ 816{
818 /* TBD */ 817 int ret = -ENOSYS;
819 return -EINVAL; 818
820} 819#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
820 mutex_lock(&acpi_ioapic_lock);
821 ret = mp_unregister_ioapic(gsi_base);
822 mutex_unlock(&acpi_ioapic_lock);
823#endif
821 824
825 return ret;
826}
822EXPORT_SYMBOL(acpi_unregister_ioapic); 827EXPORT_SYMBOL(acpi_unregister_ioapic);
823 828
824static int __init acpi_parse_sbf(struct acpi_table_header *table) 829static int __init acpi_parse_sbf(struct acpi_table_header *table)
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 826f44f0a2bf..06a0a6ce6750 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -112,6 +112,7 @@ static struct ioapic {
112 struct ioapic_domain_cfg irqdomain_cfg; 112 struct ioapic_domain_cfg irqdomain_cfg;
113 struct irq_domain *irqdomain; 113 struct irq_domain *irqdomain;
114 struct mp_pin_info *pin_info; 114 struct mp_pin_info *pin_info;
115 struct resource *iomem_res;
115} ioapics[MAX_IO_APICS]; 116} ioapics[MAX_IO_APICS];
116 117
117#define mpc_ioapic_ver(ioapic_idx) ioapics[ioapic_idx].mp_config.apicver 118#define mpc_ioapic_ver(ioapic_idx) ioapics[ioapic_idx].mp_config.apicver
@@ -250,6 +251,12 @@ static void alloc_ioapic_saved_registers(int idx)
250 pr_err("IOAPIC %d: suspend/resume impossible!\n", idx); 251 pr_err("IOAPIC %d: suspend/resume impossible!\n", idx);
251} 252}
252 253
254static void free_ioapic_saved_registers(int idx)
255{
256 kfree(ioapics[idx].saved_registers);
257 ioapics[idx].saved_registers = NULL;
258}
259
253int __init arch_early_irq_init(void) 260int __init arch_early_irq_init(void)
254{ 261{
255 struct irq_cfg *cfg; 262 struct irq_cfg *cfg;
@@ -2973,6 +2980,16 @@ static int mp_irqdomain_create(int ioapic)
2973 return 0; 2980 return 0;
2974} 2981}
2975 2982
2983static void ioapic_destroy_irqdomain(int idx)
2984{
2985 if (ioapics[idx].irqdomain) {
2986 irq_domain_remove(ioapics[idx].irqdomain);
2987 ioapics[idx].irqdomain = NULL;
2988 }
2989 kfree(ioapics[idx].pin_info);
2990 ioapics[idx].pin_info = NULL;
2991}
2992
2976void __init setup_IO_APIC(void) 2993void __init setup_IO_APIC(void)
2977{ 2994{
2978 int ioapic; 2995 int ioapic;
@@ -3743,6 +3760,7 @@ static struct resource * __init ioapic_setup_resources(void)
3743 snprintf(mem, IOAPIC_RESOURCE_NAME_SIZE, "IOAPIC %u", i); 3760 snprintf(mem, IOAPIC_RESOURCE_NAME_SIZE, "IOAPIC %u", i);
3744 mem += IOAPIC_RESOURCE_NAME_SIZE; 3761 mem += IOAPIC_RESOURCE_NAME_SIZE;
3745 num++; 3762 num++;
3763 ioapics[i].iomem_res = res;
3746 } 3764 }
3747 3765
3748 ioapic_resources = res; 3766 ioapic_resources = res;
@@ -3971,6 +3989,43 @@ int mp_register_ioapic(int id, u32 address, u32 gsi_base,
3971 return 0; 3989 return 0;
3972} 3990}
3973 3991
3992int mp_unregister_ioapic(u32 gsi_base)
3993{
3994 int ioapic, pin;
3995 int found = 0;
3996 struct mp_pin_info *pin_info;
3997
3998 for_each_ioapic(ioapic)
3999 if (ioapics[ioapic].gsi_config.gsi_base == gsi_base) {
4000 found = 1;
4001 break;
4002 }
4003 if (!found) {
4004 pr_warn("can't find IOAPIC for GSI %d\n", gsi_base);
4005 return -ENODEV;
4006 }
4007
4008 for_each_pin(ioapic, pin) {
4009 pin_info = mp_pin_info(ioapic, pin);
4010 if (pin_info->count) {
4011 pr_warn("pin%d on IOAPIC%d is still in use.\n",
4012 pin, ioapic);
4013 return -EBUSY;
4014 }
4015 }
4016
4017 /* Mark entry not present */
4018 ioapics[ioapic].nr_registers = 0;
4019 ioapic_destroy_irqdomain(ioapic);
4020 free_ioapic_saved_registers(ioapic);
4021 if (ioapics[ioapic].iomem_res)
4022 release_resource(ioapics[ioapic].iomem_res);
4023 clear_fixmap(FIX_IO_APIC_BASE_0 + ioapic);
4024 memset(&ioapics[ioapic], 0, sizeof(ioapics[ioapic]));
4025
4026 return 0;
4027}
4028
3974int mp_irqdomain_map(struct irq_domain *domain, unsigned int virq, 4029int mp_irqdomain_map(struct irq_domain *domain, unsigned int virq,
3975 irq_hw_number_t hwirq) 4030 irq_hw_number_t hwirq)
3976{ 4031{