airport: remove useless return in a function returning void
[linux/fpc-iii.git] / arch / x86 / kernel / genx2apic_phys.c
blobd042211768b74243f0c7b7dbfd321be707109f04
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 <linux/dmar.h>
9 #include <asm/smp.h>
10 #include <asm/ipi.h>
11 #include <asm/genapic.h>
13 static int x2apic_phys;
15 static int set_x2apic_phys_mode(char *arg)
17 x2apic_phys = 1;
18 return 0;
20 early_param("x2apic_phys", set_x2apic_phys_mode);
22 static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
24 if (cpu_has_x2apic && x2apic_phys)
25 return 1;
27 return 0;
30 /* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */
32 static cpumask_t x2apic_target_cpus(void)
34 return cpumask_of_cpu(0);
37 static cpumask_t x2apic_vector_allocation_domain(int cpu)
39 cpumask_t domain = CPU_MASK_NONE;
40 cpu_set(cpu, domain);
41 return domain;
44 static void __x2apic_send_IPI_dest(unsigned int apicid, int vector,
45 unsigned int dest)
47 unsigned long cfg;
49 cfg = __prepare_ICR(0, vector, dest);
52 * send the IPI.
54 x2apic_icr_write(cfg, apicid);
57 static void x2apic_send_IPI_mask(cpumask_t mask, int vector)
59 unsigned long flags;
60 unsigned long query_cpu;
62 local_irq_save(flags);
63 for_each_cpu_mask(query_cpu, mask) {
64 __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu),
65 vector, APIC_DEST_PHYSICAL);
67 local_irq_restore(flags);
70 static void x2apic_send_IPI_allbutself(int vector)
72 cpumask_t mask = cpu_online_map;
74 cpu_clear(smp_processor_id(), mask);
76 if (!cpus_empty(mask))
77 x2apic_send_IPI_mask(mask, vector);
80 static void x2apic_send_IPI_all(int vector)
82 x2apic_send_IPI_mask(cpu_online_map, vector);
85 static int x2apic_apic_id_registered(void)
87 return 1;
90 static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask)
92 int cpu;
95 * We're using fixed IRQ delivery, can only return one phys APIC ID.
96 * May as well be the first.
98 cpu = first_cpu(cpumask);
99 if ((unsigned)cpu < NR_CPUS)
100 return per_cpu(x86_cpu_to_apicid, cpu);
101 else
102 return BAD_APICID;
105 static unsigned int get_apic_id(unsigned long x)
107 unsigned int id;
109 id = x;
110 return id;
113 static unsigned long set_apic_id(unsigned int id)
115 unsigned long x;
117 x = id;
118 return x;
121 static unsigned int phys_pkg_id(int index_msb)
123 return current_cpu_data.initial_apicid >> index_msb;
126 void x2apic_send_IPI_self(int vector)
128 apic_write(APIC_SELF_IPI, vector);
131 void init_x2apic_ldr(void)
133 return;
136 struct genapic apic_x2apic_phys = {
137 .name = "physical x2apic",
138 .acpi_madt_oem_check = x2apic_acpi_madt_oem_check,
139 .int_delivery_mode = dest_Fixed,
140 .int_dest_mode = (APIC_DEST_PHYSICAL != 0),
141 .target_cpus = x2apic_target_cpus,
142 .vector_allocation_domain = x2apic_vector_allocation_domain,
143 .apic_id_registered = x2apic_apic_id_registered,
144 .init_apic_ldr = init_x2apic_ldr,
145 .send_IPI_all = x2apic_send_IPI_all,
146 .send_IPI_allbutself = x2apic_send_IPI_allbutself,
147 .send_IPI_mask = x2apic_send_IPI_mask,
148 .send_IPI_self = x2apic_send_IPI_self,
149 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
150 .phys_pkg_id = phys_pkg_id,
151 .get_apic_id = get_apic_id,
152 .set_apic_id = set_apic_id,
153 .apic_id_mask = (0xFFFFFFFFu),