aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorSuresh Siddha <suresh.b.siddha@intel.com>2008-07-10 14:16:59 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-12 02:45:07 -0400
commit2d9579a124d746a3e0e0ba45e57d80800ee80807 (patch)
treeb95f34d75309ac8ae91c6ff0331731214ae1c93d /arch/x86
parent6e1cb38a2aef7680975e71f23de187859ee8b158 (diff)
x64, x2apic/intr-remap: support for x2apic physical mode support
x2apic Physical mode support. By default we will use x2apic cluster mode. x2apic physical mode can be selected using "x2apic_phys" boot parameter. Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com> Cc: akpm@linux-foundation.org Cc: arjan@linux.intel.com Cc: andi@firstfloor.org Cc: ebiederm@xmission.com Cc: jbarnes@virtuousgeek.org Cc: steiner@sgi.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kernel/Makefile1
-rw-r--r--arch/x86/kernel/genapic_64.c18
-rw-r--r--arch/x86/kernel/genx2apic_phys.c122
3 files changed, 138 insertions, 3 deletions
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index bde3e9b6fec9..81280e93e792 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -96,6 +96,7 @@ obj-$(CONFIG_OLPC) += olpc.o
96ifeq ($(CONFIG_X86_64),y) 96ifeq ($(CONFIG_X86_64),y)
97 obj-y += genapic_64.o genapic_flat_64.o genx2apic_uv_x.o tlb_uv.o 97 obj-y += genapic_64.o genapic_flat_64.o genx2apic_uv_x.o tlb_uv.o
98 obj-y += genx2apic_cluster.o 98 obj-y += genx2apic_cluster.o
99 obj-y += genx2apic_phys.o
99 obj-$(CONFIG_X86_PM_TIMER) += pmtimer_64.o 100 obj-$(CONFIG_X86_PM_TIMER) += pmtimer_64.o
100 obj-$(CONFIG_AUDIT) += audit_64.o 101 obj-$(CONFIG_AUDIT) += audit_64.o
101 102
diff --git a/arch/x86/kernel/genapic_64.c b/arch/x86/kernel/genapic_64.c
index 792e21ba1a81..3940d8161f8b 100644
--- a/arch/x86/kernel/genapic_64.c
+++ b/arch/x86/kernel/genapic_64.c
@@ -30,6 +30,15 @@ DEFINE_PER_CPU(int, x2apic_extra_bits);
30 30
31struct genapic __read_mostly *genapic = &apic_flat; 31struct genapic __read_mostly *genapic = &apic_flat;
32 32
33static int x2apic_phys = 0;
34
35static int set_x2apic_phys_mode(char *arg)
36{
37 x2apic_phys = 1;
38 return 0;
39}
40early_param("x2apic_phys", set_x2apic_phys_mode);
41
33static enum uv_system_type uv_system_type; 42static enum uv_system_type uv_system_type;
34 43
35/* 44/*
@@ -39,9 +48,12 @@ void __init setup_apic_routing(void)
39{ 48{
40 if (uv_system_type == UV_NON_UNIQUE_APIC) 49 if (uv_system_type == UV_NON_UNIQUE_APIC)
41 genapic = &apic_x2apic_uv_x; 50 genapic = &apic_x2apic_uv_x;
42 else if (cpu_has_x2apic && intr_remapping_enabled) 51 else if (cpu_has_x2apic && intr_remapping_enabled) {
43 genapic = &apic_x2apic_cluster; 52 if (x2apic_phys)
44 else 53 genapic = &apic_x2apic_phys;
54 else
55 genapic = &apic_x2apic_cluster;
56 } else
45#ifdef CONFIG_ACPI 57#ifdef CONFIG_ACPI
46 /* 58 /*
47 * Quirk: some x86_64 machines can only use physical APIC mode 59 * Quirk: some x86_64 machines can only use physical APIC mode
diff --git a/arch/x86/kernel/genx2apic_phys.c b/arch/x86/kernel/genx2apic_phys.c
new file mode 100644
index 000000000000..3c70b9d692b2
--- /dev/null
+++ b/arch/x86/kernel/genx2apic_phys.c
@@ -0,0 +1,122 @@
1#include <linux/threads.h>
2#include <linux/cpumask.h>
3#include <linux/string.h>
4#include <linux/kernel.h>
5#include <linux/ctype.h>
6#include <linux/init.h>
7#include <asm/smp.h>
8#include <asm/ipi.h>
9#include <asm/genapic.h>
10
11
12/* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */
13
14static cpumask_t x2apic_target_cpus(void)
15{
16 return cpumask_of_cpu(0);
17}
18
19static cpumask_t x2apic_vector_allocation_domain(int cpu)
20{
21 cpumask_t domain = CPU_MASK_NONE;
22 cpu_set(cpu, domain);
23 return domain;
24}
25
26static void __x2apic_send_IPI_dest(unsigned int apicid, int vector,
27 unsigned int dest)
28{
29 unsigned long cfg;
30
31 cfg = __prepare_ICR(0, vector, dest);
32
33 /*
34 * send the IPI.
35 */
36 x2apic_icr_write(cfg, apicid);
37}
38
39static void x2apic_send_IPI_mask(cpumask_t mask, int vector)
40{
41 unsigned long flags;
42 unsigned long query_cpu;
43
44 local_irq_save(flags);
45 for_each_cpu_mask(query_cpu, mask) {
46 __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu),
47 vector, APIC_DEST_PHYSICAL);
48 }
49 local_irq_restore(flags);
50}
51
52static void x2apic_send_IPI_allbutself(int vector)
53{
54 cpumask_t mask = cpu_online_map;
55
56 cpu_clear(smp_processor_id(), mask);
57
58 if (!cpus_empty(mask))
59 x2apic_send_IPI_mask(mask, vector);
60}
61
62static void x2apic_send_IPI_all(int vector)
63{
64 x2apic_send_IPI_mask(cpu_online_map, vector);
65}
66
67static int x2apic_apic_id_registered(void)
68{
69 return 1;
70}
71
72static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask)
73{
74 int cpu;
75
76 /*
77 * We're using fixed IRQ delivery, can only return one phys APIC ID.
78 * May as well be the first.
79 */
80 cpu = first_cpu(cpumask);
81 if ((unsigned)cpu < NR_CPUS)
82 return per_cpu(x86_cpu_to_apicid, cpu);
83 else
84 return BAD_APICID;
85}
86
87static unsigned int x2apic_read_id(void)
88{
89 return apic_read(APIC_ID);
90}
91
92static unsigned int phys_pkg_id(int index_msb)
93{
94 return x2apic_read_id() >> index_msb;
95}
96
97void x2apic_send_IPI_self(int vector)
98{
99 apic_write(APIC_SELF_IPI, vector);
100}
101
102void init_x2apic_ldr(void)
103{
104 return;
105}
106
107struct genapic apic_x2apic_phys = {
108 .name = "physical x2apic",
109 .int_delivery_mode = dest_Fixed,
110 .int_dest_mode = (APIC_DEST_PHYSICAL != 0),
111 .target_cpus = x2apic_target_cpus,
112 .vector_allocation_domain = x2apic_vector_allocation_domain,
113 .apic_id_registered = x2apic_apic_id_registered,
114 .init_apic_ldr = init_x2apic_ldr,
115 .send_IPI_all = x2apic_send_IPI_all,
116 .send_IPI_allbutself = x2apic_send_IPI_allbutself,
117 .send_IPI_mask = x2apic_send_IPI_mask,
118 .send_IPI_self = x2apic_send_IPI_self,
119 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
120 .phys_pkg_id = phys_pkg_id,
121 .read_apic_id = x2apic_read_id,
122};