Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86: Cleanup irq_domain ops

We have 3 identical copies of the ioapic domain ops for acpi, mpparse,
and sfi. Have a global one in the io_apic code and be done with it.

To avoid include hell in io_apic.h, create a private irqdomain header
and include the generic irqdomain header from there.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: David Cohen <david.a.cohen@linux.intel.com>
Cc: Sander Eikelenboom <linux@eikelenboom.it>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: sfi-devel@simplefirmware.org
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dimitri Sivanich <sivanich@sgi.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Rob Herring <robh@kernel.org>
Cc: x86@kernel.org
Link: http://lkml.kernel.org/r/1428978610-28986-32-git-send-email-jiang.liu@linux.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

+56 -60
+2 -27
arch/x86/include/asm/io_apic.h
··· 96 96 } __attribute__ ((packed)); 97 97 98 98 struct irq_alloc_info; 99 - struct irq_data; 99 + struct ioapic_domain_cfg; 100 100 101 101 #define IOAPIC_AUTO -1 102 102 #define IOAPIC_EDGE 0 ··· 163 163 extern void setup_ioapic_ids_from_mpc(void); 164 164 extern void setup_ioapic_ids_from_mpc_nocheck(void); 165 165 166 - enum ioapic_domain_type { 167 - IOAPIC_DOMAIN_INVALID, 168 - IOAPIC_DOMAIN_LEGACY, 169 - IOAPIC_DOMAIN_STRICT, 170 - IOAPIC_DOMAIN_DYNAMIC, 171 - }; 172 - 173 - struct device_node; 174 - struct irq_domain; 175 - struct irq_domain_ops; 176 - 177 - struct ioapic_domain_cfg { 178 - enum ioapic_domain_type type; 179 - const struct irq_domain_ops *ops; 180 - struct device_node *dev; 181 - }; 182 - 183 166 extern int mp_find_ioapic(u32 gsi); 184 167 extern int mp_find_ioapic_pin(int ioapic, u32 gsi); 185 168 extern int mp_map_gsi_to_irq(u32 gsi, unsigned int flags, ··· 172 189 struct ioapic_domain_cfg *cfg); 173 190 extern int mp_unregister_ioapic(u32 gsi_base); 174 191 extern int mp_ioapic_registered(u32 gsi_base); 175 - extern int mp_irqdomain_alloc(struct irq_domain *domain, unsigned int virq, 176 - unsigned int nr_irqs, void *arg); 177 - extern void mp_irqdomain_free(struct irq_domain *domain, unsigned int virq, 178 - unsigned int nr_irqs); 179 - extern void mp_irqdomain_activate(struct irq_domain *domain, 180 - struct irq_data *irq_data); 181 - extern void mp_irqdomain_deactivate(struct irq_domain *domain, 182 - struct irq_data *irq_data); 183 - extern int mp_irqdomain_ioapic_idx(struct irq_domain *domain); 192 + 184 193 extern void ioapic_set_alloc_attr(struct irq_alloc_info *info, 185 194 int node, int trigger, int polarity); 186 195
+34
arch/x86/include/asm/irqdomain.h
··· 1 + #ifndef _ASM_IRQDOMAIN_H 2 + #define _ASM_IRQDOMAIN_H 3 + 4 + #include <linux/irqdomain.h> 5 + 6 + enum ioapic_domain_type { 7 + IOAPIC_DOMAIN_INVALID, 8 + IOAPIC_DOMAIN_LEGACY, 9 + IOAPIC_DOMAIN_STRICT, 10 + IOAPIC_DOMAIN_DYNAMIC, 11 + }; 12 + 13 + struct device_node; 14 + struct irq_data; 15 + 16 + struct ioapic_domain_cfg { 17 + enum ioapic_domain_type type; 18 + const struct irq_domain_ops *ops; 19 + struct device_node *dev; 20 + }; 21 + 22 + extern const struct irq_domain_ops mp_ioapic_irqdomain_ops; 23 + 24 + extern int mp_irqdomain_alloc(struct irq_domain *domain, unsigned int virq, 25 + unsigned int nr_irqs, void *arg); 26 + extern void mp_irqdomain_free(struct irq_domain *domain, unsigned int virq, 27 + unsigned int nr_irqs); 28 + extern void mp_irqdomain_activate(struct irq_domain *domain, 29 + struct irq_data *irq_data); 30 + extern void mp_irqdomain_deactivate(struct irq_domain *domain, 31 + struct irq_data *irq_data); 32 + extern int mp_irqdomain_ioapic_idx(struct irq_domain *domain); 33 + 34 + #endif
+3 -10
arch/x86/kernel/acpi/boot.c
··· 31 31 #include <linux/module.h> 32 32 #include <linux/dmi.h> 33 33 #include <linux/irq.h> 34 - #include <linux/irqdomain.h> 35 34 #include <linux/slab.h> 36 35 #include <linux/bootmem.h> 37 36 #include <linux/ioport.h> 38 37 #include <linux/pci.h> 39 38 39 + #include <asm/irqdomain.h> 40 40 #include <asm/pci_x86.h> 41 41 #include <asm/pgtable.h> 42 42 #include <asm/io_apic.h> ··· 400 400 return 0; 401 401 } 402 402 403 - static struct irq_domain_ops acpi_irqdomain_ops = { 404 - .alloc = mp_irqdomain_alloc, 405 - .free = mp_irqdomain_free, 406 - .activate = mp_irqdomain_activate, 407 - .deactivate = mp_irqdomain_deactivate, 408 - }; 409 - 410 403 static int __init 411 404 acpi_parse_ioapic(struct acpi_subtable_header * header, const unsigned long end) 412 405 { 413 406 struct acpi_madt_io_apic *ioapic = NULL; 414 407 struct ioapic_domain_cfg cfg = { 415 408 .type = IOAPIC_DOMAIN_DYNAMIC, 416 - .ops = &acpi_irqdomain_ops, 409 + .ops = &mp_ioapic_irqdomain_ops, 417 410 }; 418 411 419 412 ioapic = (struct acpi_madt_io_apic *)header; ··· 757 764 u64 addr; 758 765 struct ioapic_domain_cfg cfg = { 759 766 .type = IOAPIC_DOMAIN_DYNAMIC, 760 - .ops = &acpi_irqdomain_ops, 767 + .ops = &mp_ioapic_irqdomain_ops, 761 768 }; 762 769 763 770 ioapic_id = acpi_get_ioapic_id(handle, gsi_base, &addr);
+8 -1
arch/x86/kernel/apic/io_apic.c
··· 41 41 #include <linux/acpi.h> 42 42 #include <linux/module.h> 43 43 #include <linux/syscore_ops.h> 44 - #include <linux/irqdomain.h> 45 44 #include <linux/freezer.h> 46 45 #include <linux/kthread.h> 47 46 #include <linux/jiffies.h> /* time_after() */ 48 47 #include <linux/slab.h> 49 48 #include <linux/bootmem.h> 50 49 50 + #include <asm/irqdomain.h> 51 51 #include <asm/idle.h> 52 52 #include <asm/io.h> 53 53 #include <asm/smp.h> ··· 2995 2995 { 2996 2996 return (int)(long)domain->host_data; 2997 2997 } 2998 + 2999 + const struct irq_domain_ops mp_ioapic_irqdomain_ops = { 3000 + .alloc = mp_irqdomain_alloc, 3001 + .free = mp_irqdomain_free, 3002 + .activate = mp_irqdomain_activate, 3003 + .deactivate = mp_irqdomain_deactivate, 3004 + };
+6 -6
arch/x86/kernel/devicetree.c
··· 4 4 #include <linux/bootmem.h> 5 5 #include <linux/export.h> 6 6 #include <linux/io.h> 7 - #include <linux/irqdomain.h> 8 7 #include <linux/interrupt.h> 9 8 #include <linux/list.h> 10 9 #include <linux/of.h> ··· 16 17 #include <linux/of_pci.h> 17 18 #include <linux/initrd.h> 18 19 20 + #include <asm/irqdomain.h> 19 21 #include <asm/hpet.h> 20 22 #include <asm/apic.h> 21 23 #include <asm/pci_x86.h> ··· 216 216 return mp_irqdomain_alloc(domain, virq, nr_irqs, &tmp); 217 217 } 218 218 219 - const struct irq_domain_ops ioapic_irq_domain_ops = { 220 - .alloc = dt_irqdomain_alloc, 221 - .free = mp_irqdomain_free, 222 - .activate = mp_irqdomain_activate, 223 - .deactivate = mp_irqdomain_deactivate, 219 + static const struct irq_domain_ops ioapic_irq_domain_ops = { 220 + .alloc = dt_irqdomain_alloc, 221 + .free = mp_irqdomain_free, 222 + .activate = mp_irqdomain_activate, 223 + .deactivate = mp_irqdomain_deactivate, 224 224 }; 225 225 226 226 static void __init dtb_add_ioapic(struct device_node *dn)
+1 -8
arch/x86/kernel/mpparse.c
··· 19 19 #include <linux/module.h> 20 20 #include <linux/smp.h> 21 21 #include <linux/pci.h> 22 - #include <linux/irqdomain.h> 23 22 23 + #include <asm/irqdomain.h> 24 24 #include <asm/mtrr.h> 25 25 #include <asm/mpspec.h> 26 26 #include <asm/pgalloc.h> ··· 112 112 } else 113 113 pr_warn("Unknown bustype %s - ignoring\n", str); 114 114 } 115 - 116 - static struct irq_domain_ops mp_ioapic_irqdomain_ops = { 117 - .alloc = mp_irqdomain_alloc, 118 - .free = mp_irqdomain_free, 119 - .activate = mp_irqdomain_activate, 120 - .deactivate = mp_irqdomain_deactivate, 121 - }; 122 115 123 116 static void __init MP_ioapic_info(struct mpc_ioapic *m) 124 117 {
+2 -8
arch/x86/platform/sfi/sfi.c
··· 25 25 #include <linux/init.h> 26 26 #include <linux/sfi.h> 27 27 #include <linux/io.h> 28 - #include <linux/irqdomain.h> 29 28 29 + #include <asm/irqdomain.h> 30 30 #include <asm/io_apic.h> 31 31 #include <asm/mpspec.h> 32 32 #include <asm/setup.h> ··· 71 71 #endif /* CONFIG_X86_LOCAL_APIC */ 72 72 73 73 #ifdef CONFIG_X86_IO_APIC 74 - static struct irq_domain_ops sfi_ioapic_irqdomain_ops = { 75 - .alloc = mp_irqdomain_alloc, 76 - .free = mp_irqdomain_free, 77 - .activate = mp_irqdomain_activate, 78 - .deactivate = mp_irqdomain_deactivate, 79 - }; 80 74 81 75 static int __init sfi_parse_ioapic(struct sfi_table_header *table) 82 76 { ··· 79 85 int i, num; 80 86 struct ioapic_domain_cfg cfg = { 81 87 .type = IOAPIC_DOMAIN_STRICT, 82 - .ops = &sfi_ioapic_irqdomain_ops, 88 + .ops = &mp_ioapic_irqdomain_ops, 83 89 }; 84 90 85 91 sb = (struct sfi_table_simple *)table;