Commit a6a25dd3270944f3c4182ffcbe0f60482471e849

Authored by Joerg Roedel
1 parent 373dd7a27f

x86, io_apic: Convert setup_ioapic_entry to function pointer

This pointer is changed to a different function when IRQ
remapping is enabled.

Signed-off-by: Joerg Roedel <joro@8bytes.org>
Acked-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

Showing 5 changed files with 17 additions and 9 deletions Side-by-side Diff

arch/x86/include/asm/io_apic.h
... ... @@ -149,6 +149,10 @@
149 149 void setup_IO_APIC_irq_extra(u32 gsi);
150 150 extern void ioapic_insert_resources(void);
151 151  
  152 +extern int native_setup_ioapic_entry(int, struct IO_APIC_route_entry *,
  153 + unsigned int, int,
  154 + struct io_apic_irq_attr *);
  155 +
152 156 int io_apic_setup_irq_pin_once(unsigned int irq, int node, struct io_apic_irq_attr *attr);
153 157  
154 158 extern int save_ioapic_entries(void);
... ... @@ -232,6 +236,7 @@
232 236 #define native_disable_io_apic NULL
233 237 #define native_io_apic_print_entries NULL
234 238 #define native_ioapic_set_affinity NULL
  239 +#define native_setup_ioapic_entry NULL
235 240 #endif
236 241  
237 242 #endif /* _ASM_X86_IO_APIC_H */
arch/x86/include/asm/x86_init.h
... ... @@ -190,6 +190,8 @@
190 190 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
191 191 };
192 192  
  193 +struct IO_APIC_route_entry;
  194 +struct io_apic_irq_attr;
193 195 struct irq_data;
194 196 struct cpumask;
195 197  
... ... @@ -203,6 +205,9 @@
203 205 int (*set_affinity)(struct irq_data *data,
204 206 const struct cpumask *mask,
205 207 bool force);
  208 + int (*setup_entry)(int irq, struct IO_APIC_route_entry *entry,
  209 + unsigned int destination, int vector,
  210 + struct io_apic_irq_attr *attr);
206 211 };
207 212  
208 213 extern struct x86_init_ops x86_init;
arch/x86/kernel/apic/io_apic.c
... ... @@ -1315,14 +1315,10 @@
1315 1315 fasteoi ? "fasteoi" : "edge");
1316 1316 }
1317 1317  
1318   -static int setup_ioapic_entry(int irq, struct IO_APIC_route_entry *entry,
1319   - unsigned int destination, int vector,
1320   - struct io_apic_irq_attr *attr)
  1318 +int native_setup_ioapic_entry(int irq, struct IO_APIC_route_entry *entry,
  1319 + unsigned int destination, int vector,
  1320 + struct io_apic_irq_attr *attr)
1321 1321 {
1322   - if (irq_remapping_enabled)
1323   - return setup_ioapic_remapped_entry(irq, entry, destination,
1324   - vector, attr);
1325   -
1326 1322 memset(entry, 0, sizeof(*entry));
1327 1323  
1328 1324 entry->delivery_mode = apic->irq_delivery_mode;
... ... @@ -1370,8 +1366,8 @@
1370 1366 attr->ioapic, mpc_ioapic_id(attr->ioapic), attr->ioapic_pin,
1371 1367 cfg->vector, irq, attr->trigger, attr->polarity, dest);
1372 1368  
1373   - if (setup_ioapic_entry(irq, &entry, dest, cfg->vector, attr)) {
1374   - pr_warn("Failed to setup ioapic entry for ioapic %d, pin %d\n",
  1369 + if (x86_io_apic_ops.setup_entry(irq, &entry, dest, cfg->vector, attr)) {
  1370 + pr_warn("Failed to setup ioapic entry for ioapic %d, pin %d\n",
1375 1371 mpc_ioapic_id(attr->ioapic), attr->ioapic_pin);
1376 1372 __clear_irq_vector(irq, cfg);
1377 1373  
arch/x86/kernel/x86_init.c
... ... @@ -127,5 +127,6 @@
127 127 .disable = native_disable_io_apic,
128 128 .print_entries = native_io_apic_print_entries,
129 129 .set_affinity = native_ioapic_set_affinity,
  130 + .setup_entry = native_setup_ioapic_entry,
130 131 };
drivers/iommu/irq_remapping.c
... ... @@ -146,6 +146,7 @@
146 146 {
147 147 x86_io_apic_ops.disable = irq_remapping_disable_io_apic;
148 148 x86_io_apic_ops.set_affinity = set_remapped_irq_affinity;
  149 + x86_io_apic_ops.setup_entry = setup_ioapic_remapped_entry;
149 150 x86_msi.setup_msi_irqs = irq_remapping_setup_msi_irqs;
150 151 x86_msi.setup_hpet_msi = setup_hpet_msi_remapped;
151 152 }