probe_64.c 2.4 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 * Copyright 2004 James Cleverdon, IBM.
 * Subject to the GNU Public License, v.2
 *
 * Generic APIC sub-arch probe layer.
 *
 * Hacked for x86-64 by James Cleverdon from i386 architecture code by
 * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
 * James Cleverdon.
 */
#include <linux/threads.h>
#include <linux/cpumask.h>
#include <linux/string.h>
14
#include <linux/module.h>
L
Linus Torvalds 已提交
15 16 17
#include <linux/kernel.h>
#include <linux/ctype.h>
#include <linux/init.h>
J
Jack Steiner 已提交
18
#include <linux/hardirq.h>
19
#include <linux/dmar.h>
L
Linus Torvalds 已提交
20 21

#include <asm/smp.h>
I
Ingo Molnar 已提交
22
#include <asm/apic.h>
Y
Yinghai Lu 已提交
23
#include <asm/ipi.h>
24
#include <asm/setup.h>
L
Linus Torvalds 已提交
25

26 27 28 29 30
extern struct apic apic_flat;
extern struct apic apic_physflat;
extern struct apic apic_x2xpic_uv_x;
extern struct apic apic_x2apic_phys;
extern struct apic apic_x2apic_cluster;
L
Linus Torvalds 已提交
31

32
struct apic __read_mostly *apic = &apic_flat;
33
EXPORT_SYMBOL_GPL(apic);
L
Linus Torvalds 已提交
34

35
static struct apic *apic_probe[] __initdata = {
N
Nick Piggin 已提交
36
#ifdef CONFIG_X86_UV
37
	&apic_x2apic_uv_x,
N
Nick Piggin 已提交
38
#endif
Y
Yinghai Lu 已提交
39
#ifdef CONFIG_X86_X2APIC
40 41
	&apic_x2apic_phys,
	&apic_x2apic_cluster,
Y
Yinghai Lu 已提交
42
#endif
43 44 45
	&apic_physflat,
	NULL,
};
46

Y
Yinghai Lu 已提交
47 48 49 50 51
static int apicid_phys_pkg_id(int initial_apic_id, int index_msb)
{
	return hard_smp_processor_id() >> index_msb;
}

L
Linus Torvalds 已提交
52 53 54
/*
 * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
 */
55
void __init default_setup_apic_routing(void)
L
Linus Torvalds 已提交
56
{
57 58 59

	enable_IR_x2apic();

Y
Yinghai Lu 已提交
60
#ifdef CONFIG_X86_X2APIC
61
	if (x2apic_mode
62
#ifdef CONFIG_X86_UV
63
		       && apic != &apic_x2apic_uv_x
64
#endif
65
		       ) {
66 67 68 69
		if (x2apic_phys)
			apic = &apic_x2apic_phys;
		else
			apic = &apic_x2apic_cluster;
70
	}
Y
Yinghai Lu 已提交
71
#endif
72

73
	if (apic == &apic_flat && num_possible_cpus() > 8)
74
			apic = &apic_physflat;
75 76

	printk(KERN_INFO "Setting APIC routing to %s\n", apic->name);
77

Y
Yinghai Lu 已提交
78 79 80 81 82
	if (is_vsmp_box()) {
		/* need to update phys_pkg_id */
		apic->phys_pkg_id = apicid_phys_pkg_id;
	}

83 84 85 86 87 88
	/*
	 * Now that apic routing model is selected, configure the
	 * fault handling for intr remapping.
	 */
	if (intr_remapping_enabled)
		enable_drhd_fault_handling();
L
Linus Torvalds 已提交
89 90
}

91
/* Same for both flat and physical. */
L
Linus Torvalds 已提交
92

93
void apic_send_IPI_self(int vector)
L
Linus Torvalds 已提交
94
{
95
	__default_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
L
Linus Torvalds 已提交
96
}
97

98
int __init default_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
99
{
100 101 102 103
	int i;

	for (i = 0; apic_probe[i]; ++i) {
		if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
I
Ingo Molnar 已提交
104
			apic = apic_probe[i];
105
			printk(KERN_INFO "Setting APIC routing to %s.\n",
I
Ingo Molnar 已提交
106
				apic->name);
107 108
			return 1;
		}
109 110 111
	}
	return 0;
}