Skip to content

Commit ea2b50e

Browse files
committed
Merge branch 'x86-apic-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'x86-apic-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: x86, apic: Include module.h header in apic_flat_64.c x86, apic: Make apic drivers static x86, apic: Clean up bigsmp apic selection code x86, apic: Use .apicdrivers section for the apic drivers list x86, apic: Introduce .apicdrivers section to find the list of apic drivers x86, x2apic: Move the common bits to x2apic.h x86, x2apic: Minimize IPI register writes using cluster groups x86, x2apic: Track the x2apic cluster sibling map x86, x2apic: Remove duplicate code for IPI mask routines x86, apic: Use probe routines to simplify apic selection x86, ioapic: Consolidate mp_ioapic_routing[] into 'struct ioapic' x86, ioapic: Consolidate gsi routing info into 'struct ioapic' x86, ioapic: Consolidate mp_ioapics[] into 'struct ioapic' x86, ioapic: Consolidate ioapic_saved_data[] into 'struct ioapic' x86, ioapic: Add struct ioapic x86, ioapic: Remove duplicate code for saving/restoring RTEs x86, ioapic: Use ioapic_saved_data while enabling intr-remapping x86, ioapic: Allocate ioapic_saved_data early x86, ioapic: Fix potential resume deadlock
2 parents 15a3d11 + b18bf09 commit ea2b50e

20 files changed

Lines changed: 539 additions & 563 deletions

‎arch/x86/include/asm/apic.h‎

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,26 @@ struct apic {
380380
*/
381381
extern struct apic *apic;
382382

383+
/*
384+
* APIC drivers are probed based on how they are listed in the .apicdrivers
385+
* section. So the order is important and enforced by the ordering
386+
* of different apic driver files in the Makefile.
387+
*
388+
* For the files having two apic drivers, we use apic_drivers()
389+
* to enforce the order with in them.
390+
*/
391+
#define apic_driver(sym) \
392+
static struct apic *__apicdrivers_##sym __used \
393+
__aligned(sizeof(struct apic *)) \
394+
__section(.apicdrivers) = { &sym }
395+
396+
#define apic_drivers(sym1, sym2) \
397+
static struct apic *__apicdrivers_##sym1##sym2[2] __used \
398+
__aligned(sizeof(struct apic *)) \
399+
__section(.apicdrivers) = { &sym1, &sym2 }
400+
401+
extern struct apic *__apicdrivers[], *__apicdrivers_end[];
402+
383403
/*
384404
* APIC functionality to boot other CPUs - only used on SMP:
385405
*/
@@ -458,15 +478,10 @@ static inline unsigned default_get_apic_id(unsigned long x)
458478
#define DEFAULT_TRAMPOLINE_PHYS_HIGH 0x469
459479

460480
#ifdef CONFIG_X86_64
461-
extern struct apic apic_flat;
462-
extern struct apic apic_physflat;
463-
extern struct apic apic_x2apic_cluster;
464-
extern struct apic apic_x2apic_phys;
465481
extern int default_acpi_madt_oem_check(char *, char *);
466482

467483
extern void apic_send_IPI_self(int vector);
468484

469-
extern struct apic apic_x2apic_uv_x;
470485
DECLARE_PER_CPU(int, x2apic_extra_bits);
471486

472487
extern int default_cpu_present_to_apicid(int mps_cpu);
@@ -480,7 +495,7 @@ static inline void default_wait_for_init_deassert(atomic_t *deassert)
480495
return;
481496
}
482497

483-
extern void generic_bigsmp_probe(void);
498+
extern struct apic *generic_bigsmp_probe(void);
484499

485500

486501
#ifdef CONFIG_X86_LOCAL_APIC
@@ -516,8 +531,6 @@ extern struct apic apic_noop;
516531

517532
#ifdef CONFIG_X86_32
518533

519-
extern struct apic apic_default;
520-
521534
static inline int noop_x86_32_early_logical_apicid(int cpu)
522535
{
523536
return BAD_APICID;

‎arch/x86/include/asm/io_apic.h‎

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ struct IR_IO_APIC_route_entry {
105105
* # of IO-APICs and # of IRQ routing registers
106106
*/
107107
extern int nr_ioapics;
108-
extern int nr_ioapic_registers[MAX_IO_APICS];
109108

110-
#define MP_MAX_IOAPIC_PIN 127
109+
extern int mpc_ioapic_id(int ioapic);
110+
extern unsigned int mpc_ioapic_addr(int ioapic);
111+
extern struct mp_ioapic_gsi *mp_ioapic_gsi_routing(int ioapic);
111112

112-
/* I/O APIC entries */
113-
extern struct mpc_ioapic mp_ioapics[MAX_IO_APICS];
113+
#define MP_MAX_IOAPIC_PIN 127
114114

115115
/* # of MP IRQ source entries */
116116
extern int mp_irq_entries;
@@ -152,11 +152,9 @@ extern void ioapic_insert_resources(void);
152152

153153
int io_apic_setup_irq_pin_once(unsigned int irq, int node, struct io_apic_irq_attr *attr);
154154

155-
extern struct IO_APIC_route_entry **alloc_ioapic_entries(void);
156-
extern void free_ioapic_entries(struct IO_APIC_route_entry **ioapic_entries);
157-
extern int save_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
158-
extern void mask_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
159-
extern int restore_IO_APIC_setup(struct IO_APIC_route_entry **ioapic_entries);
155+
extern int save_ioapic_entries(void);
156+
extern void mask_ioapic_entries(void);
157+
extern int restore_ioapic_entries(void);
160158

161159
extern int get_nr_irqs_gsi(void);
162160

@@ -192,19 +190,13 @@ struct io_apic_irq_attr;
192190
static inline int io_apic_set_pci_routing(struct device *dev, int irq,
193191
struct io_apic_irq_attr *irq_attr) { return 0; }
194192

195-
static inline struct IO_APIC_route_entry **alloc_ioapic_entries(void)
196-
{
197-
return NULL;
198-
}
199-
200-
static inline void free_ioapic_entries(struct IO_APIC_route_entry **ent) { }
201-
static inline int save_IO_APIC_setup(struct IO_APIC_route_entry **ent)
193+
static inline int save_ioapic_entries(void)
202194
{
203195
return -ENOMEM;
204196
}
205197

206-
static inline void mask_IO_APIC_setup(struct IO_APIC_route_entry **ent) { }
207-
static inline int restore_IO_APIC_setup(struct IO_APIC_route_entry **ent)
198+
static inline void mask_ioapic_entries(void) { }
199+
static inline int restore_ioapic_entries(void)
208200
{
209201
return -ENOMEM;
210202
}

‎arch/x86/include/asm/x2apic.h‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Common bits for X2APIC cluster/physical modes.
3+
*/
4+
5+
#ifndef _ASM_X86_X2APIC_H
6+
#define _ASM_X86_X2APIC_H
7+
8+
#include <asm/apic.h>
9+
#include <asm/ipi.h>
10+
#include <linux/cpumask.h>
11+
12+
/*
13+
* Need to use more than cpu 0, because we need more vectors
14+
* when MSI-X are used.
15+
*/
16+
static const struct cpumask *x2apic_target_cpus(void)
17+
{
18+
return cpu_online_mask;
19+
}
20+
21+
static int x2apic_apic_id_registered(void)
22+
{
23+
return 1;
24+
}
25+
26+
/*
27+
* For now each logical cpu is in its own vector allocation domain.
28+
*/
29+
static void x2apic_vector_allocation_domain(int cpu, struct cpumask *retmask)
30+
{
31+
cpumask_clear(retmask);
32+
cpumask_set_cpu(cpu, retmask);
33+
}
34+
35+
static void
36+
__x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest)
37+
{
38+
unsigned long cfg = __prepare_ICR(0, vector, dest);
39+
native_x2apic_icr_write(cfg, apicid);
40+
}
41+
42+
static unsigned int x2apic_get_apic_id(unsigned long id)
43+
{
44+
return id;
45+
}
46+
47+
static unsigned long x2apic_set_apic_id(unsigned int id)
48+
{
49+
return id;
50+
}
51+
52+
static int x2apic_phys_pkg_id(int initial_apicid, int index_msb)
53+
{
54+
return initial_apicid >> index_msb;
55+
}
56+
57+
static void x2apic_send_IPI_self(int vector)
58+
{
59+
apic_write(APIC_SELF_IPI, vector);
60+
}
61+
62+
#endif /* _ASM_X86_X2APIC_H */

‎arch/x86/kernel/acpi/boot.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
970970
mp_irq.irqflag = (trigger << 2) | polarity;
971971
mp_irq.srcbus = MP_ISA_BUS;
972972
mp_irq.srcbusirq = bus_irq; /* IRQ */
973-
mp_irq.dstapic = mp_ioapics[ioapic].apicid; /* APIC ID */
973+
mp_irq.dstapic = mpc_ioapic_id(ioapic); /* APIC ID */
974974
mp_irq.dstirq = pin; /* INTIN# */
975975

976976
mp_save_irq(&mp_irq);
@@ -1021,7 +1021,7 @@ void __init mp_config_acpi_legacy_irqs(void)
10211021
if (ioapic < 0)
10221022
continue;
10231023
pin = mp_find_ioapic_pin(ioapic, gsi);
1024-
dstapic = mp_ioapics[ioapic].apicid;
1024+
dstapic = mpc_ioapic_id(ioapic);
10251025

10261026
for (idx = 0; idx < mp_irq_entries; idx++) {
10271027
struct mpc_intsrc *irq = mp_irqs + idx;
@@ -1082,7 +1082,7 @@ static int mp_config_acpi_gsi(struct device *dev, u32 gsi, int trigger,
10821082
mp_irq.srcbus = number;
10831083
mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
10841084
ioapic = mp_find_ioapic(gsi);
1085-
mp_irq.dstapic = mp_ioapics[ioapic].apicid;
1085+
mp_irq.dstapic = mpc_ioapic_id(ioapic);
10861086
mp_irq.dstirq = mp_find_ioapic_pin(ioapic, gsi);
10871087

10881088
mp_save_irq(&mp_irq);
@@ -1113,7 +1113,7 @@ int mp_register_gsi(struct device *dev, u32 gsi, int trigger, int polarity)
11131113

11141114
if (ioapic_pin > MP_MAX_IOAPIC_PIN) {
11151115
printk(KERN_ERR "Invalid reference to IOAPIC pin "
1116-
"%d-%d\n", mp_ioapics[ioapic].apicid,
1116+
"%d-%d\n", mpc_ioapic_id(ioapic),
11171117
ioapic_pin);
11181118
return gsi;
11191119
}

‎arch/x86/kernel/apic/Makefile‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22
# Makefile for local APIC drivers and for the IO-APIC code
33
#
44

5-
obj-$(CONFIG_X86_LOCAL_APIC) += apic.o apic_noop.o probe_$(BITS).o ipi.o
5+
obj-$(CONFIG_X86_LOCAL_APIC) += apic.o apic_noop.o ipi.o
66
obj-y += hw_nmi.o
77

88
obj-$(CONFIG_X86_IO_APIC) += io_apic.o
99
obj-$(CONFIG_SMP) += ipi.o
1010

1111
ifeq ($(CONFIG_X86_64),y)
12-
obj-y += apic_flat_64.o
13-
obj-$(CONFIG_X86_X2APIC) += x2apic_cluster.o
14-
obj-$(CONFIG_X86_X2APIC) += x2apic_phys.o
12+
# APIC probe will depend on the listing order here
1513
obj-$(CONFIG_X86_UV) += x2apic_uv_x.o
14+
obj-$(CONFIG_X86_X2APIC) += x2apic_phys.o
15+
obj-$(CONFIG_X86_X2APIC) += x2apic_cluster.o
16+
obj-y += apic_flat_64.o
1617
endif
1718

18-
obj-$(CONFIG_X86_BIGSMP) += bigsmp_32.o
19+
# APIC probe will depend on the listing order here
1920
obj-$(CONFIG_X86_NUMAQ) += numaq_32.o
20-
obj-$(CONFIG_X86_ES7000) += es7000_32.o
2121
obj-$(CONFIG_X86_SUMMIT) += summit_32.o
22+
obj-$(CONFIG_X86_BIGSMP) += bigsmp_32.o
23+
obj-$(CONFIG_X86_ES7000) += es7000_32.o
24+
25+
# For 32bit, probe_32 need to be listed last
26+
obj-$(CONFIG_X86_LOCAL_APIC) += probe_$(BITS).o

‎arch/x86/kernel/apic/apic.c‎

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,29 +1461,22 @@ int __init enable_IR(void)
14611461
void __init enable_IR_x2apic(void)
14621462
{
14631463
unsigned long flags;
1464-
struct IO_APIC_route_entry **ioapic_entries;
14651464
int ret, x2apic_enabled = 0;
14661465
int dmar_table_init_ret;
14671466

14681467
dmar_table_init_ret = dmar_table_init();
14691468
if (dmar_table_init_ret && !x2apic_supported())
14701469
return;
14711470

1472-
ioapic_entries = alloc_ioapic_entries();
1473-
if (!ioapic_entries) {
1474-
pr_err("Allocate ioapic_entries failed\n");
1475-
goto out;
1476-
}
1477-
1478-
ret = save_IO_APIC_setup(ioapic_entries);
1471+
ret = save_ioapic_entries();
14791472
if (ret) {
14801473
pr_info("Saving IO-APIC state failed: %d\n", ret);
14811474
goto out;
14821475
}
14831476

14841477
local_irq_save(flags);
14851478
legacy_pic->mask_all();
1486-
mask_IO_APIC_setup(ioapic_entries);
1479+
mask_ioapic_entries();
14871480

14881481
if (dmar_table_init_ret)
14891482
ret = 0;
@@ -1514,14 +1507,11 @@ void __init enable_IR_x2apic(void)
15141507

15151508
nox2apic:
15161509
if (!ret) /* IR enabling failed */
1517-
restore_IO_APIC_setup(ioapic_entries);
1510+
restore_ioapic_entries();
15181511
legacy_pic->restore_mask();
15191512
local_irq_restore(flags);
15201513

15211514
out:
1522-
if (ioapic_entries)
1523-
free_ioapic_entries(ioapic_entries);
1524-
15251515
if (x2apic_enabled)
15261516
return;
15271517

@@ -2095,28 +2085,20 @@ static void lapic_resume(void)
20952085
{
20962086
unsigned int l, h;
20972087
unsigned long flags;
2098-
int maxlvt, ret;
2099-
struct IO_APIC_route_entry **ioapic_entries = NULL;
2088+
int maxlvt;
21002089

21012090
if (!apic_pm_state.active)
21022091
return;
21032092

21042093
local_irq_save(flags);
21052094
if (intr_remapping_enabled) {
2106-
ioapic_entries = alloc_ioapic_entries();
2107-
if (!ioapic_entries) {
2108-
WARN(1, "Alloc ioapic_entries in lapic resume failed.");
2109-
goto restore;
2110-
}
2111-
2112-
ret = save_IO_APIC_setup(ioapic_entries);
2113-
if (ret) {
2114-
WARN(1, "Saving IO-APIC state failed: %d\n", ret);
2115-
free_ioapic_entries(ioapic_entries);
2116-
goto restore;
2117-
}
2118-
2119-
mask_IO_APIC_setup(ioapic_entries);
2095+
/*
2096+
* IO-APIC and PIC have their own resume routines.
2097+
* We just mask them here to make sure the interrupt
2098+
* subsystem is completely quiet while we enable x2apic
2099+
* and interrupt-remapping.
2100+
*/
2101+
mask_ioapic_entries();
21202102
legacy_pic->mask_all();
21212103
}
21222104

@@ -2159,13 +2141,9 @@ static void lapic_resume(void)
21592141
apic_write(APIC_ESR, 0);
21602142
apic_read(APIC_ESR);
21612143

2162-
if (intr_remapping_enabled) {
2144+
if (intr_remapping_enabled)
21632145
reenable_intr_remapping(x2apic_mode);
2164-
legacy_pic->restore_mask();
2165-
restore_IO_APIC_setup(ioapic_entries);
2166-
free_ioapic_entries(ioapic_entries);
2167-
}
2168-
restore:
2146+
21692147
local_irq_restore(flags);
21702148
}
21712149

0 commit comments

Comments
 (0)