diff options
Diffstat (limited to 'arch/x86/kernel/apic/io_apic.c')
-rw-r--r-- | arch/x86/kernel/apic/io_apic.c | 55 |
1 files changed, 55 insertions, 0 deletions
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 | ||
254 | static void free_ioapic_saved_registers(int idx) | ||
255 | { | ||
256 | kfree(ioapics[idx].saved_registers); | ||
257 | ioapics[idx].saved_registers = NULL; | ||
258 | } | ||
259 | |||
253 | int __init arch_early_irq_init(void) | 260 | int __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 | ||
2983 | static 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 | |||
2976 | void __init setup_IO_APIC(void) | 2993 | void __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 | ||
3992 | int 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 | |||
3974 | int mp_irqdomain_map(struct irq_domain *domain, unsigned int virq, | 4029 | int mp_irqdomain_map(struct irq_domain *domain, unsigned int virq, |
3975 | irq_hw_number_t hwirq) | 4030 | irq_hw_number_t hwirq) |
3976 | { | 4031 | { |