mirror of
https://github.com/AetherDroid/android_kernel_samsung_on5xelte.git
synced 2025-10-29 23:28:52 +01:00
Fixed MTP to work with TWRP
This commit is contained in:
commit
f6dfaef42e
50820 changed files with 20846062 additions and 0 deletions
24
arch/x86/kernel/apic/Makefile
Normal file
24
arch/x86/kernel/apic/Makefile
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#
|
||||
# Makefile for local APIC drivers and for the IO-APIC code
|
||||
#
|
||||
|
||||
obj-$(CONFIG_X86_LOCAL_APIC) += apic.o apic_noop.o ipi.o
|
||||
obj-y += hw_nmi.o
|
||||
|
||||
obj-$(CONFIG_X86_IO_APIC) += io_apic.o
|
||||
obj-$(CONFIG_SMP) += ipi.o
|
||||
|
||||
ifeq ($(CONFIG_X86_64),y)
|
||||
# APIC probe will depend on the listing order here
|
||||
obj-$(CONFIG_X86_NUMACHIP) += apic_numachip.o
|
||||
obj-$(CONFIG_X86_UV) += x2apic_uv_x.o
|
||||
obj-$(CONFIG_X86_X2APIC) += x2apic_phys.o
|
||||
obj-$(CONFIG_X86_X2APIC) += x2apic_cluster.o
|
||||
obj-y += apic_flat_64.o
|
||||
endif
|
||||
|
||||
# APIC probe will depend on the listing order here
|
||||
obj-$(CONFIG_X86_BIGSMP) += bigsmp_32.o
|
||||
|
||||
# For 32bit, probe_32 need to be listed last
|
||||
obj-$(CONFIG_X86_LOCAL_APIC) += probe_$(BITS).o
|
||||
2578
arch/x86/kernel/apic/apic.c
Normal file
2578
arch/x86/kernel/apic/apic.c
Normal file
File diff suppressed because it is too large
Load diff
317
arch/x86/kernel/apic/apic_flat_64.c
Normal file
317
arch/x86/kernel/apic/apic_flat_64.c
Normal file
|
|
@ -0,0 +1,317 @@
|
|||
/*
|
||||
* Copyright 2004 James Cleverdon, IBM.
|
||||
* Subject to the GNU Public License, v.2
|
||||
*
|
||||
* Flat APIC subarch code.
|
||||
*
|
||||
* 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/errno.h>
|
||||
#include <linux/threads.h>
|
||||
#include <linux/cpumask.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/hardirq.h>
|
||||
#include <linux/module.h>
|
||||
#include <asm/smp.h>
|
||||
#include <asm/apic.h>
|
||||
#include <asm/ipi.h>
|
||||
|
||||
#include <linux/acpi.h>
|
||||
|
||||
static struct apic apic_physflat;
|
||||
static struct apic apic_flat;
|
||||
|
||||
struct apic __read_mostly *apic = &apic_flat;
|
||||
EXPORT_SYMBOL_GPL(apic);
|
||||
|
||||
static int flat_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up the logical destination ID.
|
||||
*
|
||||
* Intel recommends to set DFR, LDR and TPR before enabling
|
||||
* an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
|
||||
* document number 292116). So here it goes...
|
||||
*/
|
||||
void flat_init_apic_ldr(void)
|
||||
{
|
||||
unsigned long val;
|
||||
unsigned long num, id;
|
||||
|
||||
num = smp_processor_id();
|
||||
id = 1UL << num;
|
||||
apic_write(APIC_DFR, APIC_DFR_FLAT);
|
||||
val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
|
||||
val |= SET_APIC_LOGICAL_ID(id);
|
||||
apic_write(APIC_LDR, val);
|
||||
}
|
||||
|
||||
static inline void _flat_send_IPI_mask(unsigned long mask, int vector)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
local_irq_save(flags);
|
||||
__default_send_IPI_dest_field(mask, vector, apic->dest_logical);
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
static void flat_send_IPI_mask(const struct cpumask *cpumask, int vector)
|
||||
{
|
||||
unsigned long mask = cpumask_bits(cpumask)[0];
|
||||
|
||||
_flat_send_IPI_mask(mask, vector);
|
||||
}
|
||||
|
||||
static void
|
||||
flat_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector)
|
||||
{
|
||||
unsigned long mask = cpumask_bits(cpumask)[0];
|
||||
int cpu = smp_processor_id();
|
||||
|
||||
if (cpu < BITS_PER_LONG)
|
||||
clear_bit(cpu, &mask);
|
||||
|
||||
_flat_send_IPI_mask(mask, vector);
|
||||
}
|
||||
|
||||
static void flat_send_IPI_allbutself(int vector)
|
||||
{
|
||||
int cpu = smp_processor_id();
|
||||
#ifdef CONFIG_HOTPLUG_CPU
|
||||
int hotplug = 1;
|
||||
#else
|
||||
int hotplug = 0;
|
||||
#endif
|
||||
if (hotplug || vector == NMI_VECTOR) {
|
||||
if (!cpumask_equal(cpu_online_mask, cpumask_of(cpu))) {
|
||||
unsigned long mask = cpumask_bits(cpu_online_mask)[0];
|
||||
|
||||
if (cpu < BITS_PER_LONG)
|
||||
clear_bit(cpu, &mask);
|
||||
|
||||
_flat_send_IPI_mask(mask, vector);
|
||||
}
|
||||
} else if (num_online_cpus() > 1) {
|
||||
__default_send_IPI_shortcut(APIC_DEST_ALLBUT,
|
||||
vector, apic->dest_logical);
|
||||
}
|
||||
}
|
||||
|
||||
static void flat_send_IPI_all(int vector)
|
||||
{
|
||||
if (vector == NMI_VECTOR) {
|
||||
flat_send_IPI_mask(cpu_online_mask, vector);
|
||||
} else {
|
||||
__default_send_IPI_shortcut(APIC_DEST_ALLINC,
|
||||
vector, apic->dest_logical);
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned int flat_get_apic_id(unsigned long x)
|
||||
{
|
||||
unsigned int id;
|
||||
|
||||
id = (((x)>>24) & 0xFFu);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
static unsigned long set_apic_id(unsigned int id)
|
||||
{
|
||||
unsigned long x;
|
||||
|
||||
x = ((id & 0xFFu)<<24);
|
||||
return x;
|
||||
}
|
||||
|
||||
static unsigned int read_xapic_id(void)
|
||||
{
|
||||
unsigned int id;
|
||||
|
||||
id = flat_get_apic_id(apic_read(APIC_ID));
|
||||
return id;
|
||||
}
|
||||
|
||||
static int flat_apic_id_registered(void)
|
||||
{
|
||||
return physid_isset(read_xapic_id(), phys_cpu_present_map);
|
||||
}
|
||||
|
||||
static int flat_phys_pkg_id(int initial_apic_id, int index_msb)
|
||||
{
|
||||
return initial_apic_id >> index_msb;
|
||||
}
|
||||
|
||||
static int flat_probe(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct apic apic_flat = {
|
||||
.name = "flat",
|
||||
.probe = flat_probe,
|
||||
.acpi_madt_oem_check = flat_acpi_madt_oem_check,
|
||||
.apic_id_valid = default_apic_id_valid,
|
||||
.apic_id_registered = flat_apic_id_registered,
|
||||
|
||||
.irq_delivery_mode = dest_LowestPrio,
|
||||
.irq_dest_mode = 1, /* logical */
|
||||
|
||||
.target_cpus = online_target_cpus,
|
||||
.disable_esr = 0,
|
||||
.dest_logical = APIC_DEST_LOGICAL,
|
||||
.check_apicid_used = NULL,
|
||||
|
||||
.vector_allocation_domain = flat_vector_allocation_domain,
|
||||
.init_apic_ldr = flat_init_apic_ldr,
|
||||
|
||||
.ioapic_phys_id_map = NULL,
|
||||
.setup_apic_routing = NULL,
|
||||
.cpu_present_to_apicid = default_cpu_present_to_apicid,
|
||||
.apicid_to_cpu_present = NULL,
|
||||
.check_phys_apicid_present = default_check_phys_apicid_present,
|
||||
.phys_pkg_id = flat_phys_pkg_id,
|
||||
|
||||
.get_apic_id = flat_get_apic_id,
|
||||
.set_apic_id = set_apic_id,
|
||||
.apic_id_mask = 0xFFu << 24,
|
||||
|
||||
.cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and,
|
||||
|
||||
.send_IPI_mask = flat_send_IPI_mask,
|
||||
.send_IPI_mask_allbutself = flat_send_IPI_mask_allbutself,
|
||||
.send_IPI_allbutself = flat_send_IPI_allbutself,
|
||||
.send_IPI_all = flat_send_IPI_all,
|
||||
.send_IPI_self = apic_send_IPI_self,
|
||||
|
||||
.wait_for_init_deassert = false,
|
||||
.inquire_remote_apic = default_inquire_remote_apic,
|
||||
|
||||
.read = native_apic_mem_read,
|
||||
.write = native_apic_mem_write,
|
||||
.eoi_write = native_apic_mem_write,
|
||||
.icr_read = native_apic_icr_read,
|
||||
.icr_write = native_apic_icr_write,
|
||||
.wait_icr_idle = native_apic_wait_icr_idle,
|
||||
.safe_wait_icr_idle = native_safe_apic_wait_icr_idle,
|
||||
};
|
||||
|
||||
/*
|
||||
* Physflat mode is used when there are more than 8 CPUs on a system.
|
||||
* We cannot use logical delivery in this case because the mask
|
||||
* overflows, so use physical mode.
|
||||
*/
|
||||
static int physflat_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
|
||||
{
|
||||
#ifdef CONFIG_ACPI
|
||||
/*
|
||||
* Quirk: some x86_64 machines can only use physical APIC mode
|
||||
* regardless of how many processors are present (x86_64 ES7000
|
||||
* is an example).
|
||||
*/
|
||||
if (acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID &&
|
||||
(acpi_gbl_FADT.flags & ACPI_FADT_APIC_PHYSICAL)) {
|
||||
printk(KERN_DEBUG "system APIC only can use physical flat");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!strncmp(oem_id, "IBM", 3) && !strncmp(oem_table_id, "EXA", 3)) {
|
||||
printk(KERN_DEBUG "IBM Summit detected, will use apic physical");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void physflat_send_IPI_mask(const struct cpumask *cpumask, int vector)
|
||||
{
|
||||
default_send_IPI_mask_sequence_phys(cpumask, vector);
|
||||
}
|
||||
|
||||
static void physflat_send_IPI_mask_allbutself(const struct cpumask *cpumask,
|
||||
int vector)
|
||||
{
|
||||
default_send_IPI_mask_allbutself_phys(cpumask, vector);
|
||||
}
|
||||
|
||||
static void physflat_send_IPI_allbutself(int vector)
|
||||
{
|
||||
default_send_IPI_mask_allbutself_phys(cpu_online_mask, vector);
|
||||
}
|
||||
|
||||
static void physflat_send_IPI_all(int vector)
|
||||
{
|
||||
physflat_send_IPI_mask(cpu_online_mask, vector);
|
||||
}
|
||||
|
||||
static int physflat_probe(void)
|
||||
{
|
||||
if (apic == &apic_physflat || num_possible_cpus() > 8)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct apic apic_physflat = {
|
||||
|
||||
.name = "physical flat",
|
||||
.probe = physflat_probe,
|
||||
.acpi_madt_oem_check = physflat_acpi_madt_oem_check,
|
||||
.apic_id_valid = default_apic_id_valid,
|
||||
.apic_id_registered = flat_apic_id_registered,
|
||||
|
||||
.irq_delivery_mode = dest_Fixed,
|
||||
.irq_dest_mode = 0, /* physical */
|
||||
|
||||
.target_cpus = online_target_cpus,
|
||||
.disable_esr = 0,
|
||||
.dest_logical = 0,
|
||||
.check_apicid_used = NULL,
|
||||
|
||||
.vector_allocation_domain = default_vector_allocation_domain,
|
||||
/* not needed, but shouldn't hurt: */
|
||||
.init_apic_ldr = flat_init_apic_ldr,
|
||||
|
||||
.ioapic_phys_id_map = NULL,
|
||||
.setup_apic_routing = NULL,
|
||||
.cpu_present_to_apicid = default_cpu_present_to_apicid,
|
||||
.apicid_to_cpu_present = NULL,
|
||||
.check_phys_apicid_present = default_check_phys_apicid_present,
|
||||
.phys_pkg_id = flat_phys_pkg_id,
|
||||
|
||||
.get_apic_id = flat_get_apic_id,
|
||||
.set_apic_id = set_apic_id,
|
||||
.apic_id_mask = 0xFFu << 24,
|
||||
|
||||
.cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
|
||||
|
||||
.send_IPI_mask = physflat_send_IPI_mask,
|
||||
.send_IPI_mask_allbutself = physflat_send_IPI_mask_allbutself,
|
||||
.send_IPI_allbutself = physflat_send_IPI_allbutself,
|
||||
.send_IPI_all = physflat_send_IPI_all,
|
||||
.send_IPI_self = apic_send_IPI_self,
|
||||
|
||||
.wait_for_init_deassert = false,
|
||||
.inquire_remote_apic = default_inquire_remote_apic,
|
||||
|
||||
.read = native_apic_mem_read,
|
||||
.write = native_apic_mem_write,
|
||||
.eoi_write = native_apic_mem_write,
|
||||
.icr_read = native_apic_icr_read,
|
||||
.icr_write = native_apic_icr_write,
|
||||
.wait_icr_idle = native_apic_wait_icr_idle,
|
||||
.safe_wait_icr_idle = native_safe_apic_wait_icr_idle,
|
||||
};
|
||||
|
||||
/*
|
||||
* We need to check for physflat first, so this order is important.
|
||||
*/
|
||||
apic_drivers(apic_physflat, apic_flat);
|
||||
169
arch/x86/kernel/apic/apic_noop.c
Normal file
169
arch/x86/kernel/apic/apic_noop.c
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* NOOP APIC driver.
|
||||
*
|
||||
* Does almost nothing and should be substituted by a real apic driver via
|
||||
* probe routine.
|
||||
*
|
||||
* Though in case if apic is disabled (for some reason) we try
|
||||
* to not uglify the caller's code and allow to call (some) apic routines
|
||||
* like self-ipi, etc...
|
||||
*/
|
||||
|
||||
#include <linux/threads.h>
|
||||
#include <linux/cpumask.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/errno.h>
|
||||
#include <asm/fixmap.h>
|
||||
#include <asm/mpspec.h>
|
||||
#include <asm/apicdef.h>
|
||||
#include <asm/apic.h>
|
||||
#include <asm/setup.h>
|
||||
|
||||
#include <linux/smp.h>
|
||||
#include <asm/ipi.h>
|
||||
|
||||
#include <linux/interrupt.h>
|
||||
#include <asm/acpi.h>
|
||||
#include <asm/e820.h>
|
||||
|
||||
static void noop_init_apic_ldr(void) { }
|
||||
static void noop_send_IPI_mask(const struct cpumask *cpumask, int vector) { }
|
||||
static void noop_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector) { }
|
||||
static void noop_send_IPI_allbutself(int vector) { }
|
||||
static void noop_send_IPI_all(int vector) { }
|
||||
static void noop_send_IPI_self(int vector) { }
|
||||
static void noop_apic_wait_icr_idle(void) { }
|
||||
static void noop_apic_icr_write(u32 low, u32 id) { }
|
||||
|
||||
static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static u32 noop_safe_apic_wait_icr_idle(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u64 noop_apic_icr_read(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int noop_phys_pkg_id(int cpuid_apic, int index_msb)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int noop_get_apic_id(unsigned long x)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int noop_probe(void)
|
||||
{
|
||||
/*
|
||||
* NOOP apic should not ever be
|
||||
* enabled via probe routine
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int noop_apic_id_registered(void)
|
||||
{
|
||||
/*
|
||||
* if we would be really "pedantic"
|
||||
* we should pass read_apic_id() here
|
||||
* but since NOOP suppose APIC ID = 0
|
||||
* lets save a few cycles
|
||||
*/
|
||||
return physid_isset(0, phys_cpu_present_map);
|
||||
}
|
||||
|
||||
static const struct cpumask *noop_target_cpus(void)
|
||||
{
|
||||
/* only BSP here */
|
||||
return cpumask_of(0);
|
||||
}
|
||||
|
||||
static void noop_vector_allocation_domain(int cpu, struct cpumask *retmask,
|
||||
const struct cpumask *mask)
|
||||
{
|
||||
if (cpu != 0)
|
||||
pr_warning("APIC: Vector allocated for non-BSP cpu\n");
|
||||
cpumask_copy(retmask, cpumask_of(cpu));
|
||||
}
|
||||
|
||||
static u32 noop_apic_read(u32 reg)
|
||||
{
|
||||
WARN_ON_ONCE((cpu_has_apic && !disable_apic));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void noop_apic_write(u32 reg, u32 v)
|
||||
{
|
||||
WARN_ON_ONCE(cpu_has_apic && !disable_apic);
|
||||
}
|
||||
|
||||
struct apic apic_noop = {
|
||||
.name = "noop",
|
||||
.probe = noop_probe,
|
||||
.acpi_madt_oem_check = NULL,
|
||||
|
||||
.apic_id_valid = default_apic_id_valid,
|
||||
.apic_id_registered = noop_apic_id_registered,
|
||||
|
||||
.irq_delivery_mode = dest_LowestPrio,
|
||||
/* logical delivery broadcast to all CPUs: */
|
||||
.irq_dest_mode = 1,
|
||||
|
||||
.target_cpus = noop_target_cpus,
|
||||
.disable_esr = 0,
|
||||
.dest_logical = APIC_DEST_LOGICAL,
|
||||
.check_apicid_used = default_check_apicid_used,
|
||||
|
||||
.vector_allocation_domain = noop_vector_allocation_domain,
|
||||
.init_apic_ldr = noop_init_apic_ldr,
|
||||
|
||||
.ioapic_phys_id_map = default_ioapic_phys_id_map,
|
||||
.setup_apic_routing = NULL,
|
||||
|
||||
.cpu_present_to_apicid = default_cpu_present_to_apicid,
|
||||
.apicid_to_cpu_present = physid_set_mask_of_physid,
|
||||
|
||||
.check_phys_apicid_present = default_check_phys_apicid_present,
|
||||
|
||||
.phys_pkg_id = noop_phys_pkg_id,
|
||||
|
||||
.get_apic_id = noop_get_apic_id,
|
||||
.set_apic_id = NULL,
|
||||
.apic_id_mask = 0x0F << 24,
|
||||
|
||||
.cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and,
|
||||
|
||||
.send_IPI_mask = noop_send_IPI_mask,
|
||||
.send_IPI_mask_allbutself = noop_send_IPI_mask_allbutself,
|
||||
.send_IPI_allbutself = noop_send_IPI_allbutself,
|
||||
.send_IPI_all = noop_send_IPI_all,
|
||||
.send_IPI_self = noop_send_IPI_self,
|
||||
|
||||
.wakeup_secondary_cpu = noop_wakeup_secondary_cpu,
|
||||
|
||||
.wait_for_init_deassert = false,
|
||||
.inquire_remote_apic = NULL,
|
||||
|
||||
.read = noop_apic_read,
|
||||
.write = noop_apic_write,
|
||||
.eoi_write = noop_apic_write,
|
||||
.icr_read = noop_apic_icr_read,
|
||||
.icr_write = noop_apic_icr_write,
|
||||
.wait_icr_idle = noop_apic_wait_icr_idle,
|
||||
.safe_wait_icr_idle = noop_safe_apic_wait_icr_idle,
|
||||
|
||||
#ifdef CONFIG_X86_32
|
||||
.x86_32_early_logical_apicid = noop_x86_32_early_logical_apicid,
|
||||
#endif
|
||||
};
|
||||
256
arch/x86/kernel/apic/apic_numachip.c
Normal file
256
arch/x86/kernel/apic/apic_numachip.c
Normal file
|
|
@ -0,0 +1,256 @@
|
|||
/*
|
||||
* This file is subject to the terms and conditions of the GNU General Public
|
||||
* License. See the file "COPYING" in the main directory of this archive
|
||||
* for more details.
|
||||
*
|
||||
* Numascale NumaConnect-Specific APIC Code
|
||||
*
|
||||
* Copyright (C) 2011 Numascale AS. All rights reserved.
|
||||
*
|
||||
* Send feedback to <support@numascale.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/errno.h>
|
||||
#include <linux/threads.h>
|
||||
#include <linux/cpumask.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/hardirq.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#include <asm/numachip/numachip.h>
|
||||
#include <asm/numachip/numachip_csr.h>
|
||||
#include <asm/smp.h>
|
||||
#include <asm/apic.h>
|
||||
#include <asm/ipi.h>
|
||||
#include <asm/apic_flat_64.h>
|
||||
#include <asm/pgtable.h>
|
||||
|
||||
static int numachip_system __read_mostly;
|
||||
|
||||
static const struct apic apic_numachip;
|
||||
|
||||
static unsigned int get_apic_id(unsigned long x)
|
||||
{
|
||||
unsigned long value;
|
||||
unsigned int id;
|
||||
|
||||
rdmsrl(MSR_FAM10H_NODE_ID, value);
|
||||
id = ((x >> 24) & 0xffU) | ((value << 2) & 0xff00U);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
static unsigned long set_apic_id(unsigned int id)
|
||||
{
|
||||
unsigned long x;
|
||||
|
||||
x = ((id & 0xffU) << 24);
|
||||
return x;
|
||||
}
|
||||
|
||||
static unsigned int read_xapic_id(void)
|
||||
{
|
||||
return get_apic_id(apic_read(APIC_ID));
|
||||
}
|
||||
|
||||
static int numachip_apic_id_valid(int apicid)
|
||||
{
|
||||
/* Trust what bootloader passes in MADT */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int numachip_apic_id_registered(void)
|
||||
{
|
||||
return physid_isset(read_xapic_id(), phys_cpu_present_map);
|
||||
}
|
||||
|
||||
static int numachip_phys_pkg_id(int initial_apic_id, int index_msb)
|
||||
{
|
||||
return initial_apic_id >> index_msb;
|
||||
}
|
||||
|
||||
static int numachip_wakeup_secondary(int phys_apicid, unsigned long start_rip)
|
||||
{
|
||||
union numachip_csr_g3_ext_irq_gen int_gen;
|
||||
|
||||
int_gen.s._destination_apic_id = phys_apicid;
|
||||
int_gen.s._vector = 0;
|
||||
int_gen.s._msgtype = APIC_DM_INIT >> 8;
|
||||
int_gen.s._index = 0;
|
||||
|
||||
write_lcsr(CSR_G3_EXT_IRQ_GEN, int_gen.v);
|
||||
|
||||
int_gen.s._msgtype = APIC_DM_STARTUP >> 8;
|
||||
int_gen.s._vector = start_rip >> 12;
|
||||
|
||||
write_lcsr(CSR_G3_EXT_IRQ_GEN, int_gen.v);
|
||||
|
||||
atomic_set(&init_deasserted, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void numachip_send_IPI_one(int cpu, int vector)
|
||||
{
|
||||
union numachip_csr_g3_ext_irq_gen int_gen;
|
||||
int apicid = per_cpu(x86_cpu_to_apicid, cpu);
|
||||
|
||||
int_gen.s._destination_apic_id = apicid;
|
||||
int_gen.s._vector = vector;
|
||||
int_gen.s._msgtype = (vector == NMI_VECTOR ? APIC_DM_NMI : APIC_DM_FIXED) >> 8;
|
||||
int_gen.s._index = 0;
|
||||
|
||||
write_lcsr(CSR_G3_EXT_IRQ_GEN, int_gen.v);
|
||||
}
|
||||
|
||||
static void numachip_send_IPI_mask(const struct cpumask *mask, int vector)
|
||||
{
|
||||
unsigned int cpu;
|
||||
|
||||
for_each_cpu(cpu, mask)
|
||||
numachip_send_IPI_one(cpu, vector);
|
||||
}
|
||||
|
||||
static void numachip_send_IPI_mask_allbutself(const struct cpumask *mask,
|
||||
int vector)
|
||||
{
|
||||
unsigned int this_cpu = smp_processor_id();
|
||||
unsigned int cpu;
|
||||
|
||||
for_each_cpu(cpu, mask) {
|
||||
if (cpu != this_cpu)
|
||||
numachip_send_IPI_one(cpu, vector);
|
||||
}
|
||||
}
|
||||
|
||||
static void numachip_send_IPI_allbutself(int vector)
|
||||
{
|
||||
unsigned int this_cpu = smp_processor_id();
|
||||
unsigned int cpu;
|
||||
|
||||
for_each_online_cpu(cpu) {
|
||||
if (cpu != this_cpu)
|
||||
numachip_send_IPI_one(cpu, vector);
|
||||
}
|
||||
}
|
||||
|
||||
static void numachip_send_IPI_all(int vector)
|
||||
{
|
||||
numachip_send_IPI_mask(cpu_online_mask, vector);
|
||||
}
|
||||
|
||||
static void numachip_send_IPI_self(int vector)
|
||||
{
|
||||
__default_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
|
||||
}
|
||||
|
||||
static int __init numachip_probe(void)
|
||||
{
|
||||
return apic == &apic_numachip;
|
||||
}
|
||||
|
||||
static void __init map_csrs(void)
|
||||
{
|
||||
printk(KERN_INFO "NumaChip: Mapping local CSR space (%016llx - %016llx)\n",
|
||||
NUMACHIP_LCSR_BASE, NUMACHIP_LCSR_BASE + NUMACHIP_LCSR_SIZE - 1);
|
||||
init_extra_mapping_uc(NUMACHIP_LCSR_BASE, NUMACHIP_LCSR_SIZE);
|
||||
|
||||
printk(KERN_INFO "NumaChip: Mapping global CSR space (%016llx - %016llx)\n",
|
||||
NUMACHIP_GCSR_BASE, NUMACHIP_GCSR_BASE + NUMACHIP_GCSR_SIZE - 1);
|
||||
init_extra_mapping_uc(NUMACHIP_GCSR_BASE, NUMACHIP_GCSR_SIZE);
|
||||
}
|
||||
|
||||
static void fixup_cpu_id(struct cpuinfo_x86 *c, int node)
|
||||
{
|
||||
|
||||
if (c->phys_proc_id != node) {
|
||||
c->phys_proc_id = node;
|
||||
per_cpu(cpu_llc_id, smp_processor_id()) = node;
|
||||
}
|
||||
}
|
||||
|
||||
static int __init numachip_system_init(void)
|
||||
{
|
||||
unsigned int val;
|
||||
|
||||
if (!numachip_system)
|
||||
return 0;
|
||||
|
||||
x86_cpuinit.fixup_cpu_id = fixup_cpu_id;
|
||||
x86_init.pci.arch_init = pci_numachip_init;
|
||||
|
||||
map_csrs();
|
||||
|
||||
val = read_lcsr(CSR_G0_NODE_IDS);
|
||||
printk(KERN_INFO "NumaChip: Local NodeID = %08x\n", val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
early_initcall(numachip_system_init);
|
||||
|
||||
static int numachip_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
|
||||
{
|
||||
if (!strncmp(oem_id, "NUMASC", 6)) {
|
||||
numachip_system = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct apic apic_numachip __refconst = {
|
||||
|
||||
.name = "NumaConnect system",
|
||||
.probe = numachip_probe,
|
||||
.acpi_madt_oem_check = numachip_acpi_madt_oem_check,
|
||||
.apic_id_valid = numachip_apic_id_valid,
|
||||
.apic_id_registered = numachip_apic_id_registered,
|
||||
|
||||
.irq_delivery_mode = dest_Fixed,
|
||||
.irq_dest_mode = 0, /* physical */
|
||||
|
||||
.target_cpus = online_target_cpus,
|
||||
.disable_esr = 0,
|
||||
.dest_logical = 0,
|
||||
.check_apicid_used = NULL,
|
||||
|
||||
.vector_allocation_domain = default_vector_allocation_domain,
|
||||
.init_apic_ldr = flat_init_apic_ldr,
|
||||
|
||||
.ioapic_phys_id_map = NULL,
|
||||
.setup_apic_routing = NULL,
|
||||
.cpu_present_to_apicid = default_cpu_present_to_apicid,
|
||||
.apicid_to_cpu_present = NULL,
|
||||
.check_phys_apicid_present = default_check_phys_apicid_present,
|
||||
.phys_pkg_id = numachip_phys_pkg_id,
|
||||
|
||||
.get_apic_id = get_apic_id,
|
||||
.set_apic_id = set_apic_id,
|
||||
.apic_id_mask = 0xffU << 24,
|
||||
|
||||
.cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
|
||||
|
||||
.send_IPI_mask = numachip_send_IPI_mask,
|
||||
.send_IPI_mask_allbutself = numachip_send_IPI_mask_allbutself,
|
||||
.send_IPI_allbutself = numachip_send_IPI_allbutself,
|
||||
.send_IPI_all = numachip_send_IPI_all,
|
||||
.send_IPI_self = numachip_send_IPI_self,
|
||||
|
||||
.wakeup_secondary_cpu = numachip_wakeup_secondary,
|
||||
.wait_for_init_deassert = false,
|
||||
.inquire_remote_apic = NULL, /* REMRD not supported */
|
||||
|
||||
.read = native_apic_mem_read,
|
||||
.write = native_apic_mem_write,
|
||||
.eoi_write = native_apic_mem_write,
|
||||
.icr_read = native_apic_icr_read,
|
||||
.icr_write = native_apic_icr_write,
|
||||
.wait_icr_idle = native_apic_wait_icr_idle,
|
||||
.safe_wait_icr_idle = native_safe_apic_wait_icr_idle,
|
||||
};
|
||||
apic_driver(apic_numachip);
|
||||
|
||||
223
arch/x86/kernel/apic/bigsmp_32.c
Normal file
223
arch/x86/kernel/apic/bigsmp_32.c
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
/*
|
||||
* APIC driver for "bigsmp" xAPIC machines with more than 8 virtual CPUs.
|
||||
*
|
||||
* Drives the local APIC in "clustered mode".
|
||||
*/
|
||||
#include <linux/threads.h>
|
||||
#include <linux/cpumask.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/dmi.h>
|
||||
#include <linux/smp.h>
|
||||
|
||||
#include <asm/apicdef.h>
|
||||
#include <asm/fixmap.h>
|
||||
#include <asm/mpspec.h>
|
||||
#include <asm/apic.h>
|
||||
#include <asm/ipi.h>
|
||||
|
||||
static unsigned bigsmp_get_apic_id(unsigned long x)
|
||||
{
|
||||
return (x >> 24) & 0xFF;
|
||||
}
|
||||
|
||||
static int bigsmp_apic_id_registered(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static unsigned long bigsmp_check_apicid_used(physid_mask_t *map, int apicid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bigsmp_early_logical_apicid(int cpu)
|
||||
{
|
||||
/* on bigsmp, logical apicid is the same as physical */
|
||||
return early_per_cpu(x86_cpu_to_apicid, cpu);
|
||||
}
|
||||
|
||||
static inline unsigned long calculate_ldr(int cpu)
|
||||
{
|
||||
unsigned long val, id;
|
||||
|
||||
val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
|
||||
id = per_cpu(x86_bios_cpu_apicid, cpu);
|
||||
val |= SET_APIC_LOGICAL_ID(id);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up the logical destination ID.
|
||||
*
|
||||
* Intel recommends to set DFR, LDR and TPR before enabling
|
||||
* an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
|
||||
* document number 292116). So here it goes...
|
||||
*/
|
||||
static void bigsmp_init_apic_ldr(void)
|
||||
{
|
||||
unsigned long val;
|
||||
int cpu = smp_processor_id();
|
||||
|
||||
apic_write(APIC_DFR, APIC_DFR_FLAT);
|
||||
val = calculate_ldr(cpu);
|
||||
apic_write(APIC_LDR, val);
|
||||
}
|
||||
|
||||
static void bigsmp_setup_apic_routing(void)
|
||||
{
|
||||
printk(KERN_INFO
|
||||
"Enabling APIC mode: Physflat. Using %d I/O APICs\n",
|
||||
nr_ioapics);
|
||||
}
|
||||
|
||||
static int bigsmp_cpu_present_to_apicid(int mps_cpu)
|
||||
{
|
||||
if (mps_cpu < nr_cpu_ids)
|
||||
return (int) per_cpu(x86_bios_cpu_apicid, mps_cpu);
|
||||
|
||||
return BAD_APICID;
|
||||
}
|
||||
|
||||
static void bigsmp_ioapic_phys_id_map(physid_mask_t *phys_map, physid_mask_t *retmap)
|
||||
{
|
||||
/* For clustered we don't have a good way to do this yet - hack */
|
||||
physids_promote(0xFFL, retmap);
|
||||
}
|
||||
|
||||
static int bigsmp_check_phys_apicid_present(int phys_apicid)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int bigsmp_phys_pkg_id(int cpuid_apic, int index_msb)
|
||||
{
|
||||
return cpuid_apic >> index_msb;
|
||||
}
|
||||
|
||||
static inline void bigsmp_send_IPI_mask(const struct cpumask *mask, int vector)
|
||||
{
|
||||
default_send_IPI_mask_sequence_phys(mask, vector);
|
||||
}
|
||||
|
||||
static void bigsmp_send_IPI_allbutself(int vector)
|
||||
{
|
||||
default_send_IPI_mask_allbutself_phys(cpu_online_mask, vector);
|
||||
}
|
||||
|
||||
static void bigsmp_send_IPI_all(int vector)
|
||||
{
|
||||
bigsmp_send_IPI_mask(cpu_online_mask, vector);
|
||||
}
|
||||
|
||||
static int dmi_bigsmp; /* can be set by dmi scanners */
|
||||
|
||||
static int hp_ht_bigsmp(const struct dmi_system_id *d)
|
||||
{
|
||||
printk(KERN_NOTICE "%s detected: force use of apic=bigsmp\n", d->ident);
|
||||
dmi_bigsmp = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static const struct dmi_system_id bigsmp_dmi_table[] = {
|
||||
{ hp_ht_bigsmp, "HP ProLiant DL760 G2",
|
||||
{ DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
|
||||
DMI_MATCH(DMI_BIOS_VERSION, "P44-"),
|
||||
}
|
||||
},
|
||||
|
||||
{ hp_ht_bigsmp, "HP ProLiant DL740",
|
||||
{ DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
|
||||
DMI_MATCH(DMI_BIOS_VERSION, "P47-"),
|
||||
}
|
||||
},
|
||||
{ } /* NULL entry stops DMI scanning */
|
||||
};
|
||||
|
||||
static int probe_bigsmp(void)
|
||||
{
|
||||
if (def_to_bigsmp)
|
||||
dmi_bigsmp = 1;
|
||||
else
|
||||
dmi_check_system(bigsmp_dmi_table);
|
||||
|
||||
return dmi_bigsmp;
|
||||
}
|
||||
|
||||
static struct apic apic_bigsmp = {
|
||||
|
||||
.name = "bigsmp",
|
||||
.probe = probe_bigsmp,
|
||||
.acpi_madt_oem_check = NULL,
|
||||
.apic_id_valid = default_apic_id_valid,
|
||||
.apic_id_registered = bigsmp_apic_id_registered,
|
||||
|
||||
.irq_delivery_mode = dest_Fixed,
|
||||
/* phys delivery to target CPU: */
|
||||
.irq_dest_mode = 0,
|
||||
|
||||
.target_cpus = default_target_cpus,
|
||||
.disable_esr = 1,
|
||||
.dest_logical = 0,
|
||||
.check_apicid_used = bigsmp_check_apicid_used,
|
||||
|
||||
.vector_allocation_domain = default_vector_allocation_domain,
|
||||
.init_apic_ldr = bigsmp_init_apic_ldr,
|
||||
|
||||
.ioapic_phys_id_map = bigsmp_ioapic_phys_id_map,
|
||||
.setup_apic_routing = bigsmp_setup_apic_routing,
|
||||
.cpu_present_to_apicid = bigsmp_cpu_present_to_apicid,
|
||||
.apicid_to_cpu_present = physid_set_mask_of_physid,
|
||||
.check_phys_apicid_present = bigsmp_check_phys_apicid_present,
|
||||
.phys_pkg_id = bigsmp_phys_pkg_id,
|
||||
|
||||
.get_apic_id = bigsmp_get_apic_id,
|
||||
.set_apic_id = NULL,
|
||||
.apic_id_mask = 0xFF << 24,
|
||||
|
||||
.cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
|
||||
|
||||
.send_IPI_mask = bigsmp_send_IPI_mask,
|
||||
.send_IPI_mask_allbutself = NULL,
|
||||
.send_IPI_allbutself = bigsmp_send_IPI_allbutself,
|
||||
.send_IPI_all = bigsmp_send_IPI_all,
|
||||
.send_IPI_self = default_send_IPI_self,
|
||||
|
||||
.wait_for_init_deassert = true,
|
||||
.inquire_remote_apic = default_inquire_remote_apic,
|
||||
|
||||
.read = native_apic_mem_read,
|
||||
.write = native_apic_mem_write,
|
||||
.eoi_write = native_apic_mem_write,
|
||||
.icr_read = native_apic_icr_read,
|
||||
.icr_write = native_apic_icr_write,
|
||||
.wait_icr_idle = native_apic_wait_icr_idle,
|
||||
.safe_wait_icr_idle = native_safe_apic_wait_icr_idle,
|
||||
|
||||
.x86_32_early_logical_apicid = bigsmp_early_logical_apicid,
|
||||
};
|
||||
|
||||
void __init generic_bigsmp_probe(void)
|
||||
{
|
||||
unsigned int cpu;
|
||||
|
||||
if (!probe_bigsmp())
|
||||
return;
|
||||
|
||||
apic = &apic_bigsmp;
|
||||
|
||||
for_each_possible_cpu(cpu) {
|
||||
if (early_per_cpu(x86_cpu_to_logical_apicid,
|
||||
cpu) == BAD_APICID)
|
||||
continue;
|
||||
early_per_cpu(x86_cpu_to_logical_apicid, cpu) =
|
||||
bigsmp_early_logical_apicid(cpu);
|
||||
}
|
||||
|
||||
pr_info("Overriding APIC driver with %s\n", apic_bigsmp.name);
|
||||
}
|
||||
|
||||
apic_driver(apic_bigsmp);
|
||||
102
arch/x86/kernel/apic/hw_nmi.c
Normal file
102
arch/x86/kernel/apic/hw_nmi.c
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* HW NMI watchdog support
|
||||
*
|
||||
* started by Don Zickus, Copyright (C) 2010 Red Hat, Inc.
|
||||
*
|
||||
* Arch specific calls to support NMI watchdog
|
||||
*
|
||||
* Bits copied from original nmi.c file
|
||||
*
|
||||
*/
|
||||
#include <asm/apic.h>
|
||||
#include <asm/nmi.h>
|
||||
|
||||
#include <linux/cpumask.h>
|
||||
#include <linux/kdebug.h>
|
||||
#include <linux/notifier.h>
|
||||
#include <linux/kprobes.h>
|
||||
#include <linux/nmi.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#ifdef CONFIG_HARDLOCKUP_DETECTOR
|
||||
u64 hw_nmi_get_sample_period(int watchdog_thresh)
|
||||
{
|
||||
return (u64)(cpu_khz) * 1000 * watchdog_thresh;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef arch_trigger_all_cpu_backtrace
|
||||
/* For reliability, we're prepared to waste bits here. */
|
||||
static DECLARE_BITMAP(backtrace_mask, NR_CPUS) __read_mostly;
|
||||
|
||||
/* "in progress" flag of arch_trigger_all_cpu_backtrace */
|
||||
static unsigned long backtrace_flag;
|
||||
|
||||
void arch_trigger_all_cpu_backtrace(bool include_self)
|
||||
{
|
||||
int i;
|
||||
int cpu = get_cpu();
|
||||
|
||||
if (test_and_set_bit(0, &backtrace_flag)) {
|
||||
/*
|
||||
* If there is already a trigger_all_cpu_backtrace() in progress
|
||||
* (backtrace_flag == 1), don't output double cpu dump infos.
|
||||
*/
|
||||
put_cpu();
|
||||
return;
|
||||
}
|
||||
|
||||
cpumask_copy(to_cpumask(backtrace_mask), cpu_online_mask);
|
||||
if (!include_self)
|
||||
cpumask_clear_cpu(cpu, to_cpumask(backtrace_mask));
|
||||
|
||||
if (!cpumask_empty(to_cpumask(backtrace_mask))) {
|
||||
pr_info("sending NMI to %s CPUs:\n",
|
||||
(include_self ? "all" : "other"));
|
||||
apic->send_IPI_mask(to_cpumask(backtrace_mask), NMI_VECTOR);
|
||||
}
|
||||
|
||||
/* Wait for up to 10 seconds for all CPUs to do the backtrace */
|
||||
for (i = 0; i < 10 * 1000; i++) {
|
||||
if (cpumask_empty(to_cpumask(backtrace_mask)))
|
||||
break;
|
||||
mdelay(1);
|
||||
touch_softlockup_watchdog();
|
||||
}
|
||||
|
||||
clear_bit(0, &backtrace_flag);
|
||||
smp_mb__after_atomic();
|
||||
put_cpu();
|
||||
}
|
||||
|
||||
static int
|
||||
arch_trigger_all_cpu_backtrace_handler(unsigned int cmd, struct pt_regs *regs)
|
||||
{
|
||||
int cpu;
|
||||
|
||||
cpu = smp_processor_id();
|
||||
|
||||
if (cpumask_test_cpu(cpu, to_cpumask(backtrace_mask))) {
|
||||
static arch_spinlock_t lock = __ARCH_SPIN_LOCK_UNLOCKED;
|
||||
|
||||
arch_spin_lock(&lock);
|
||||
printk(KERN_WARNING "NMI backtrace for cpu %d\n", cpu);
|
||||
show_regs(regs);
|
||||
arch_spin_unlock(&lock);
|
||||
cpumask_clear_cpu(cpu, to_cpumask(backtrace_mask));
|
||||
return NMI_HANDLED;
|
||||
}
|
||||
|
||||
return NMI_DONE;
|
||||
}
|
||||
NOKPROBE_SYMBOL(arch_trigger_all_cpu_backtrace_handler);
|
||||
|
||||
static int __init register_trigger_all_cpu_backtrace(void)
|
||||
{
|
||||
register_nmi_handler(NMI_LOCAL, arch_trigger_all_cpu_backtrace_handler,
|
||||
0, "arch_bt");
|
||||
return 0;
|
||||
}
|
||||
early_initcall(register_trigger_all_cpu_backtrace);
|
||||
#endif
|
||||
3994
arch/x86/kernel/apic/io_apic.c
Normal file
3994
arch/x86/kernel/apic/io_apic.c
Normal file
File diff suppressed because it is too large
Load diff
166
arch/x86/kernel/apic/ipi.c
Normal file
166
arch/x86/kernel/apic/ipi.c
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
#include <linux/cpumask.h>
|
||||
#include <linux/interrupt.h>
|
||||
|
||||
#include <linux/mm.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/kernel_stat.h>
|
||||
#include <linux/mc146818rtc.h>
|
||||
#include <linux/cache.h>
|
||||
#include <linux/cpu.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#include <asm/smp.h>
|
||||
#include <asm/mtrr.h>
|
||||
#include <asm/tlbflush.h>
|
||||
#include <asm/mmu_context.h>
|
||||
#include <asm/apic.h>
|
||||
#include <asm/proto.h>
|
||||
#include <asm/ipi.h>
|
||||
|
||||
void default_send_IPI_mask_sequence_phys(const struct cpumask *mask, int vector)
|
||||
{
|
||||
unsigned long query_cpu;
|
||||
unsigned long flags;
|
||||
|
||||
/*
|
||||
* Hack. The clustered APIC addressing mode doesn't allow us to send
|
||||
* to an arbitrary mask, so I do a unicast to each CPU instead.
|
||||
* - mbligh
|
||||
*/
|
||||
local_irq_save(flags);
|
||||
for_each_cpu(query_cpu, mask) {
|
||||
__default_send_IPI_dest_field(per_cpu(x86_cpu_to_apicid,
|
||||
query_cpu), vector, APIC_DEST_PHYSICAL);
|
||||
}
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
void default_send_IPI_mask_allbutself_phys(const struct cpumask *mask,
|
||||
int vector)
|
||||
{
|
||||
unsigned int this_cpu = smp_processor_id();
|
||||
unsigned int query_cpu;
|
||||
unsigned long flags;
|
||||
|
||||
/* See Hack comment above */
|
||||
|
||||
local_irq_save(flags);
|
||||
for_each_cpu(query_cpu, mask) {
|
||||
if (query_cpu == this_cpu)
|
||||
continue;
|
||||
__default_send_IPI_dest_field(per_cpu(x86_cpu_to_apicid,
|
||||
query_cpu), vector, APIC_DEST_PHYSICAL);
|
||||
}
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_X86_32
|
||||
|
||||
void default_send_IPI_mask_sequence_logical(const struct cpumask *mask,
|
||||
int vector)
|
||||
{
|
||||
unsigned long flags;
|
||||
unsigned int query_cpu;
|
||||
|
||||
/*
|
||||
* Hack. The clustered APIC addressing mode doesn't allow us to send
|
||||
* to an arbitrary mask, so I do a unicasts to each CPU instead. This
|
||||
* should be modified to do 1 message per cluster ID - mbligh
|
||||
*/
|
||||
|
||||
local_irq_save(flags);
|
||||
for_each_cpu(query_cpu, mask)
|
||||
__default_send_IPI_dest_field(
|
||||
early_per_cpu(x86_cpu_to_logical_apicid, query_cpu),
|
||||
vector, apic->dest_logical);
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
void default_send_IPI_mask_allbutself_logical(const struct cpumask *mask,
|
||||
int vector)
|
||||
{
|
||||
unsigned long flags;
|
||||
unsigned int query_cpu;
|
||||
unsigned int this_cpu = smp_processor_id();
|
||||
|
||||
/* See Hack comment above */
|
||||
|
||||
local_irq_save(flags);
|
||||
for_each_cpu(query_cpu, mask) {
|
||||
if (query_cpu == this_cpu)
|
||||
continue;
|
||||
__default_send_IPI_dest_field(
|
||||
early_per_cpu(x86_cpu_to_logical_apicid, query_cpu),
|
||||
vector, apic->dest_logical);
|
||||
}
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is only used on smaller machines.
|
||||
*/
|
||||
void default_send_IPI_mask_logical(const struct cpumask *cpumask, int vector)
|
||||
{
|
||||
unsigned long mask = cpumask_bits(cpumask)[0];
|
||||
unsigned long flags;
|
||||
|
||||
if (!mask)
|
||||
return;
|
||||
|
||||
local_irq_save(flags);
|
||||
WARN_ON(mask & ~cpumask_bits(cpu_online_mask)[0]);
|
||||
__default_send_IPI_dest_field(mask, vector, apic->dest_logical);
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
void default_send_IPI_allbutself(int vector)
|
||||
{
|
||||
/*
|
||||
* if there are no other CPUs in the system then we get an APIC send
|
||||
* error if we try to broadcast, thus avoid sending IPIs in this case.
|
||||
*/
|
||||
if (!(num_online_cpus() > 1))
|
||||
return;
|
||||
|
||||
__default_local_send_IPI_allbutself(vector);
|
||||
}
|
||||
|
||||
void default_send_IPI_all(int vector)
|
||||
{
|
||||
__default_local_send_IPI_all(vector);
|
||||
}
|
||||
|
||||
void default_send_IPI_self(int vector)
|
||||
{
|
||||
__default_send_IPI_shortcut(APIC_DEST_SELF, vector, apic->dest_logical);
|
||||
}
|
||||
|
||||
/* must come after the send_IPI functions above for inlining */
|
||||
static int convert_apicid_to_cpu(int apic_id)
|
||||
{
|
||||
int i;
|
||||
|
||||
for_each_possible_cpu(i) {
|
||||
if (per_cpu(x86_cpu_to_apicid, i) == apic_id)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int safe_smp_processor_id(void)
|
||||
{
|
||||
int apicid, cpuid;
|
||||
|
||||
if (!cpu_has_apic)
|
||||
return 0;
|
||||
|
||||
apicid = hard_smp_processor_id();
|
||||
if (apicid == BAD_APICID)
|
||||
return 0;
|
||||
|
||||
cpuid = convert_apicid_to_cpu(apicid);
|
||||
|
||||
return cpuid >= 0 ? cpuid : 0;
|
||||
}
|
||||
#endif
|
||||
227
arch/x86/kernel/apic/probe_32.c
Normal file
227
arch/x86/kernel/apic/probe_32.c
Normal file
|
|
@ -0,0 +1,227 @@
|
|||
/*
|
||||
* Default generic APIC driver. This handles up to 8 CPUs.
|
||||
*
|
||||
* Copyright 2003 Andi Kleen, SuSE Labs.
|
||||
* Subject to the GNU Public License, v.2
|
||||
*
|
||||
* Generic x86 APIC driver probe layer.
|
||||
*/
|
||||
#include <linux/threads.h>
|
||||
#include <linux/cpumask.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/errno.h>
|
||||
#include <asm/fixmap.h>
|
||||
#include <asm/mpspec.h>
|
||||
#include <asm/apicdef.h>
|
||||
#include <asm/apic.h>
|
||||
#include <asm/setup.h>
|
||||
|
||||
#include <linux/smp.h>
|
||||
#include <asm/ipi.h>
|
||||
|
||||
#include <linux/interrupt.h>
|
||||
#include <asm/acpi.h>
|
||||
#include <asm/e820.h>
|
||||
|
||||
#ifdef CONFIG_HOTPLUG_CPU
|
||||
#define DEFAULT_SEND_IPI (1)
|
||||
#else
|
||||
#define DEFAULT_SEND_IPI (0)
|
||||
#endif
|
||||
|
||||
int no_broadcast = DEFAULT_SEND_IPI;
|
||||
|
||||
static __init int no_ipi_broadcast(char *str)
|
||||
{
|
||||
get_option(&str, &no_broadcast);
|
||||
pr_info("Using %s mode\n",
|
||||
no_broadcast ? "No IPI Broadcast" : "IPI Broadcast");
|
||||
return 1;
|
||||
}
|
||||
__setup("no_ipi_broadcast=", no_ipi_broadcast);
|
||||
|
||||
static int __init print_ipi_mode(void)
|
||||
{
|
||||
pr_info("Using IPI %s mode\n",
|
||||
no_broadcast ? "No-Shortcut" : "Shortcut");
|
||||
return 0;
|
||||
}
|
||||
late_initcall(print_ipi_mode);
|
||||
|
||||
static int default_x86_32_early_logical_apicid(int cpu)
|
||||
{
|
||||
return 1 << cpu;
|
||||
}
|
||||
|
||||
static void setup_apic_flat_routing(void)
|
||||
{
|
||||
#ifdef CONFIG_X86_IO_APIC
|
||||
printk(KERN_INFO
|
||||
"Enabling APIC mode: Flat. Using %d I/O APICs\n",
|
||||
nr_ioapics);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* should be called last. */
|
||||
static int probe_default(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct apic apic_default = {
|
||||
|
||||
.name = "default",
|
||||
.probe = probe_default,
|
||||
.acpi_madt_oem_check = NULL,
|
||||
.apic_id_valid = default_apic_id_valid,
|
||||
.apic_id_registered = default_apic_id_registered,
|
||||
|
||||
.irq_delivery_mode = dest_LowestPrio,
|
||||
/* logical delivery broadcast to all CPUs: */
|
||||
.irq_dest_mode = 1,
|
||||
|
||||
.target_cpus = default_target_cpus,
|
||||
.disable_esr = 0,
|
||||
.dest_logical = APIC_DEST_LOGICAL,
|
||||
.check_apicid_used = default_check_apicid_used,
|
||||
|
||||
.vector_allocation_domain = flat_vector_allocation_domain,
|
||||
.init_apic_ldr = default_init_apic_ldr,
|
||||
|
||||
.ioapic_phys_id_map = default_ioapic_phys_id_map,
|
||||
.setup_apic_routing = setup_apic_flat_routing,
|
||||
.cpu_present_to_apicid = default_cpu_present_to_apicid,
|
||||
.apicid_to_cpu_present = physid_set_mask_of_physid,
|
||||
.check_phys_apicid_present = default_check_phys_apicid_present,
|
||||
.phys_pkg_id = default_phys_pkg_id,
|
||||
|
||||
.get_apic_id = default_get_apic_id,
|
||||
.set_apic_id = NULL,
|
||||
.apic_id_mask = 0x0F << 24,
|
||||
|
||||
.cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and,
|
||||
|
||||
.send_IPI_mask = default_send_IPI_mask_logical,
|
||||
.send_IPI_mask_allbutself = default_send_IPI_mask_allbutself_logical,
|
||||
.send_IPI_allbutself = default_send_IPI_allbutself,
|
||||
.send_IPI_all = default_send_IPI_all,
|
||||
.send_IPI_self = default_send_IPI_self,
|
||||
|
||||
.wait_for_init_deassert = true,
|
||||
.inquire_remote_apic = default_inquire_remote_apic,
|
||||
|
||||
.read = native_apic_mem_read,
|
||||
.write = native_apic_mem_write,
|
||||
.eoi_write = native_apic_mem_write,
|
||||
.icr_read = native_apic_icr_read,
|
||||
.icr_write = native_apic_icr_write,
|
||||
.wait_icr_idle = native_apic_wait_icr_idle,
|
||||
.safe_wait_icr_idle = native_safe_apic_wait_icr_idle,
|
||||
|
||||
.x86_32_early_logical_apicid = default_x86_32_early_logical_apicid,
|
||||
};
|
||||
|
||||
apic_driver(apic_default);
|
||||
|
||||
struct apic *apic = &apic_default;
|
||||
EXPORT_SYMBOL_GPL(apic);
|
||||
|
||||
static int cmdline_apic __initdata;
|
||||
static int __init parse_apic(char *arg)
|
||||
{
|
||||
struct apic **drv;
|
||||
|
||||
if (!arg)
|
||||
return -EINVAL;
|
||||
|
||||
for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) {
|
||||
if (!strcmp((*drv)->name, arg)) {
|
||||
apic = *drv;
|
||||
cmdline_apic = 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Parsed again by __setup for debug/verbose */
|
||||
return 0;
|
||||
}
|
||||
early_param("apic", parse_apic);
|
||||
|
||||
void __init default_setup_apic_routing(void)
|
||||
{
|
||||
int version = apic_version[boot_cpu_physical_apicid];
|
||||
|
||||
if (num_possible_cpus() > 8) {
|
||||
switch (boot_cpu_data.x86_vendor) {
|
||||
case X86_VENDOR_INTEL:
|
||||
if (!APIC_XAPIC(version)) {
|
||||
def_to_bigsmp = 0;
|
||||
break;
|
||||
}
|
||||
/* If P4 and above fall through */
|
||||
case X86_VENDOR_AMD:
|
||||
def_to_bigsmp = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_X86_BIGSMP
|
||||
/*
|
||||
* This is used to switch to bigsmp mode when
|
||||
* - There is no apic= option specified by the user
|
||||
* - generic_apic_probe() has chosen apic_default as the sub_arch
|
||||
* - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
|
||||
*/
|
||||
|
||||
if (!cmdline_apic && apic == &apic_default)
|
||||
generic_bigsmp_probe();
|
||||
#endif
|
||||
|
||||
if (apic->setup_apic_routing)
|
||||
apic->setup_apic_routing();
|
||||
|
||||
if (x86_platform.apic_post_init)
|
||||
x86_platform.apic_post_init();
|
||||
}
|
||||
|
||||
void __init generic_apic_probe(void)
|
||||
{
|
||||
if (!cmdline_apic) {
|
||||
struct apic **drv;
|
||||
|
||||
for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) {
|
||||
if ((*drv)->probe()) {
|
||||
apic = *drv;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Not visible without early console */
|
||||
if (drv == __apicdrivers_end)
|
||||
panic("Didn't find an APIC driver");
|
||||
}
|
||||
printk(KERN_INFO "Using APIC driver %s\n", apic->name);
|
||||
}
|
||||
|
||||
/* This function can switch the APIC even after the initial ->probe() */
|
||||
int __init default_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
|
||||
{
|
||||
struct apic **drv;
|
||||
|
||||
for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) {
|
||||
if (!(*drv)->acpi_madt_oem_check)
|
||||
continue;
|
||||
if (!(*drv)->acpi_madt_oem_check(oem_id, oem_table_id))
|
||||
continue;
|
||||
|
||||
if (!cmdline_apic) {
|
||||
apic = *drv;
|
||||
printk(KERN_INFO "Switched to APIC driver `%s'.\n",
|
||||
apic->name);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
72
arch/x86/kernel/apic/probe_64.c
Normal file
72
arch/x86/kernel/apic/probe_64.c
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* 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>
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/hardirq.h>
|
||||
#include <linux/dmar.h>
|
||||
|
||||
#include <asm/smp.h>
|
||||
#include <asm/apic.h>
|
||||
#include <asm/ipi.h>
|
||||
#include <asm/setup.h>
|
||||
|
||||
/*
|
||||
* Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
|
||||
*/
|
||||
void __init default_setup_apic_routing(void)
|
||||
{
|
||||
struct apic **drv;
|
||||
|
||||
enable_IR_x2apic();
|
||||
|
||||
for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) {
|
||||
if ((*drv)->probe && (*drv)->probe()) {
|
||||
if (apic != *drv) {
|
||||
apic = *drv;
|
||||
pr_info("Switched APIC routing to %s.\n",
|
||||
apic->name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (x86_platform.apic_post_init)
|
||||
x86_platform.apic_post_init();
|
||||
}
|
||||
|
||||
/* Same for both flat and physical. */
|
||||
|
||||
void apic_send_IPI_self(int vector)
|
||||
{
|
||||
__default_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
|
||||
}
|
||||
|
||||
int __init default_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
|
||||
{
|
||||
struct apic **drv;
|
||||
|
||||
for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) {
|
||||
if ((*drv)->acpi_madt_oem_check(oem_id, oem_table_id)) {
|
||||
if (apic != *drv) {
|
||||
apic = *drv;
|
||||
pr_info("Setting APIC routing to %s.\n",
|
||||
apic->name);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
287
arch/x86/kernel/apic/x2apic_cluster.c
Normal file
287
arch/x86/kernel/apic/x2apic_cluster.c
Normal file
|
|
@ -0,0 +1,287 @@
|
|||
#include <linux/threads.h>
|
||||
#include <linux/cpumask.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/dmar.h>
|
||||
#include <linux/cpu.h>
|
||||
|
||||
#include <asm/smp.h>
|
||||
#include <asm/x2apic.h>
|
||||
|
||||
static DEFINE_PER_CPU(u32, x86_cpu_to_logical_apicid);
|
||||
static DEFINE_PER_CPU(cpumask_var_t, cpus_in_cluster);
|
||||
static DEFINE_PER_CPU(cpumask_var_t, ipi_mask);
|
||||
|
||||
static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
|
||||
{
|
||||
return x2apic_enabled();
|
||||
}
|
||||
|
||||
static inline u32 x2apic_cluster(int cpu)
|
||||
{
|
||||
return per_cpu(x86_cpu_to_logical_apicid, cpu) >> 16;
|
||||
}
|
||||
|
||||
static void
|
||||
__x2apic_send_IPI_mask(const struct cpumask *mask, int vector, int apic_dest)
|
||||
{
|
||||
struct cpumask *cpus_in_cluster_ptr;
|
||||
struct cpumask *ipi_mask_ptr;
|
||||
unsigned int cpu, this_cpu;
|
||||
unsigned long flags;
|
||||
u32 dest;
|
||||
|
||||
x2apic_wrmsr_fence();
|
||||
|
||||
local_irq_save(flags);
|
||||
|
||||
this_cpu = smp_processor_id();
|
||||
|
||||
/*
|
||||
* We are to modify mask, so we need an own copy
|
||||
* and be sure it's manipulated with irq off.
|
||||
*/
|
||||
ipi_mask_ptr = this_cpu_cpumask_var_ptr(ipi_mask);
|
||||
cpumask_copy(ipi_mask_ptr, mask);
|
||||
|
||||
/*
|
||||
* The idea is to send one IPI per cluster.
|
||||
*/
|
||||
for_each_cpu(cpu, ipi_mask_ptr) {
|
||||
unsigned long i;
|
||||
|
||||
cpus_in_cluster_ptr = per_cpu(cpus_in_cluster, cpu);
|
||||
dest = 0;
|
||||
|
||||
/* Collect cpus in cluster. */
|
||||
for_each_cpu_and(i, ipi_mask_ptr, cpus_in_cluster_ptr) {
|
||||
if (apic_dest == APIC_DEST_ALLINC || i != this_cpu)
|
||||
dest |= per_cpu(x86_cpu_to_logical_apicid, i);
|
||||
}
|
||||
|
||||
if (!dest)
|
||||
continue;
|
||||
|
||||
__x2apic_send_IPI_dest(dest, vector, apic->dest_logical);
|
||||
/*
|
||||
* Cluster sibling cpus should be discared now so
|
||||
* we would not send IPI them second time.
|
||||
*/
|
||||
cpumask_andnot(ipi_mask_ptr, ipi_mask_ptr, cpus_in_cluster_ptr);
|
||||
}
|
||||
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector)
|
||||
{
|
||||
__x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLINC);
|
||||
}
|
||||
|
||||
static void
|
||||
x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector)
|
||||
{
|
||||
__x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLBUT);
|
||||
}
|
||||
|
||||
static void x2apic_send_IPI_allbutself(int vector)
|
||||
{
|
||||
__x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLBUT);
|
||||
}
|
||||
|
||||
static void x2apic_send_IPI_all(int vector)
|
||||
{
|
||||
__x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC);
|
||||
}
|
||||
|
||||
static int
|
||||
x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
|
||||
const struct cpumask *andmask,
|
||||
unsigned int *apicid)
|
||||
{
|
||||
u32 dest = 0;
|
||||
u16 cluster;
|
||||
int i;
|
||||
|
||||
for_each_cpu_and(i, cpumask, andmask) {
|
||||
if (!cpumask_test_cpu(i, cpu_online_mask))
|
||||
continue;
|
||||
dest = per_cpu(x86_cpu_to_logical_apicid, i);
|
||||
cluster = x2apic_cluster(i);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!dest)
|
||||
return -EINVAL;
|
||||
|
||||
for_each_cpu_and(i, cpumask, andmask) {
|
||||
if (!cpumask_test_cpu(i, cpu_online_mask))
|
||||
continue;
|
||||
if (cluster != x2apic_cluster(i))
|
||||
continue;
|
||||
dest |= per_cpu(x86_cpu_to_logical_apicid, i);
|
||||
}
|
||||
|
||||
*apicid = dest;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void init_x2apic_ldr(void)
|
||||
{
|
||||
unsigned int this_cpu = smp_processor_id();
|
||||
unsigned int cpu;
|
||||
|
||||
per_cpu(x86_cpu_to_logical_apicid, this_cpu) = apic_read(APIC_LDR);
|
||||
|
||||
__cpu_set(this_cpu, per_cpu(cpus_in_cluster, this_cpu));
|
||||
for_each_online_cpu(cpu) {
|
||||
if (x2apic_cluster(this_cpu) != x2apic_cluster(cpu))
|
||||
continue;
|
||||
__cpu_set(this_cpu, per_cpu(cpus_in_cluster, cpu));
|
||||
__cpu_set(cpu, per_cpu(cpus_in_cluster, this_cpu));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* At CPU state changes, update the x2apic cluster sibling info.
|
||||
*/
|
||||
static int
|
||||
update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
|
||||
{
|
||||
unsigned int this_cpu = (unsigned long)hcpu;
|
||||
unsigned int cpu;
|
||||
int err = 0;
|
||||
|
||||
switch (action) {
|
||||
case CPU_UP_PREPARE:
|
||||
if (!zalloc_cpumask_var(&per_cpu(cpus_in_cluster, this_cpu),
|
||||
GFP_KERNEL)) {
|
||||
err = -ENOMEM;
|
||||
} else if (!zalloc_cpumask_var(&per_cpu(ipi_mask, this_cpu),
|
||||
GFP_KERNEL)) {
|
||||
free_cpumask_var(per_cpu(cpus_in_cluster, this_cpu));
|
||||
err = -ENOMEM;
|
||||
}
|
||||
break;
|
||||
case CPU_UP_CANCELED:
|
||||
case CPU_UP_CANCELED_FROZEN:
|
||||
case CPU_DEAD:
|
||||
for_each_online_cpu(cpu) {
|
||||
if (x2apic_cluster(this_cpu) != x2apic_cluster(cpu))
|
||||
continue;
|
||||
__cpu_clear(this_cpu, per_cpu(cpus_in_cluster, cpu));
|
||||
__cpu_clear(cpu, per_cpu(cpus_in_cluster, this_cpu));
|
||||
}
|
||||
free_cpumask_var(per_cpu(cpus_in_cluster, this_cpu));
|
||||
free_cpumask_var(per_cpu(ipi_mask, this_cpu));
|
||||
break;
|
||||
}
|
||||
|
||||
return notifier_from_errno(err);
|
||||
}
|
||||
|
||||
static struct notifier_block __refdata x2apic_cpu_notifier = {
|
||||
.notifier_call = update_clusterinfo,
|
||||
};
|
||||
|
||||
static int x2apic_init_cpu_notifier(void)
|
||||
{
|
||||
int cpu = smp_processor_id();
|
||||
|
||||
zalloc_cpumask_var(&per_cpu(cpus_in_cluster, cpu), GFP_KERNEL);
|
||||
zalloc_cpumask_var(&per_cpu(ipi_mask, cpu), GFP_KERNEL);
|
||||
|
||||
BUG_ON(!per_cpu(cpus_in_cluster, cpu) || !per_cpu(ipi_mask, cpu));
|
||||
|
||||
__cpu_set(cpu, per_cpu(cpus_in_cluster, cpu));
|
||||
register_hotcpu_notifier(&x2apic_cpu_notifier);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int x2apic_cluster_probe(void)
|
||||
{
|
||||
if (x2apic_mode)
|
||||
return x2apic_init_cpu_notifier();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct cpumask *x2apic_cluster_target_cpus(void)
|
||||
{
|
||||
return cpu_all_mask;
|
||||
}
|
||||
|
||||
/*
|
||||
* Each x2apic cluster is an allocation domain.
|
||||
*/
|
||||
static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
|
||||
const struct cpumask *mask)
|
||||
{
|
||||
/*
|
||||
* To minimize vector pressure, default case of boot, device bringup
|
||||
* etc will use a single cpu for the interrupt destination.
|
||||
*
|
||||
* On explicit migration requests coming from irqbalance etc,
|
||||
* interrupts will be routed to the x2apic cluster (cluster-id
|
||||
* derived from the first cpu in the mask) members specified
|
||||
* in the mask.
|
||||
*/
|
||||
if (mask == x2apic_cluster_target_cpus())
|
||||
cpumask_copy(retmask, cpumask_of(cpu));
|
||||
else
|
||||
cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
|
||||
}
|
||||
|
||||
static struct apic apic_x2apic_cluster = {
|
||||
|
||||
.name = "cluster x2apic",
|
||||
.probe = x2apic_cluster_probe,
|
||||
.acpi_madt_oem_check = x2apic_acpi_madt_oem_check,
|
||||
.apic_id_valid = x2apic_apic_id_valid,
|
||||
.apic_id_registered = x2apic_apic_id_registered,
|
||||
|
||||
.irq_delivery_mode = dest_LowestPrio,
|
||||
.irq_dest_mode = 1, /* logical */
|
||||
|
||||
.target_cpus = x2apic_cluster_target_cpus,
|
||||
.disable_esr = 0,
|
||||
.dest_logical = APIC_DEST_LOGICAL,
|
||||
.check_apicid_used = NULL,
|
||||
|
||||
.vector_allocation_domain = cluster_vector_allocation_domain,
|
||||
.init_apic_ldr = init_x2apic_ldr,
|
||||
|
||||
.ioapic_phys_id_map = NULL,
|
||||
.setup_apic_routing = NULL,
|
||||
.cpu_present_to_apicid = default_cpu_present_to_apicid,
|
||||
.apicid_to_cpu_present = NULL,
|
||||
.check_phys_apicid_present = default_check_phys_apicid_present,
|
||||
.phys_pkg_id = x2apic_phys_pkg_id,
|
||||
|
||||
.get_apic_id = x2apic_get_apic_id,
|
||||
.set_apic_id = x2apic_set_apic_id,
|
||||
.apic_id_mask = 0xFFFFFFFFu,
|
||||
|
||||
.cpu_mask_to_apicid_and = x2apic_cpu_mask_to_apicid_and,
|
||||
|
||||
.send_IPI_mask = x2apic_send_IPI_mask,
|
||||
.send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself,
|
||||
.send_IPI_allbutself = x2apic_send_IPI_allbutself,
|
||||
.send_IPI_all = x2apic_send_IPI_all,
|
||||
.send_IPI_self = x2apic_send_IPI_self,
|
||||
|
||||
.wait_for_init_deassert = false,
|
||||
.inquire_remote_apic = NULL,
|
||||
|
||||
.read = native_apic_msr_read,
|
||||
.write = native_apic_msr_write,
|
||||
.eoi_write = native_apic_msr_eoi_write,
|
||||
.icr_read = native_x2apic_icr_read,
|
||||
.icr_write = native_x2apic_icr_write,
|
||||
.wait_icr_idle = native_x2apic_wait_icr_idle,
|
||||
.safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle,
|
||||
};
|
||||
|
||||
apic_driver(apic_x2apic_cluster);
|
||||
141
arch/x86/kernel/apic/x2apic_phys.c
Normal file
141
arch/x86/kernel/apic/x2apic_phys.c
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
#include <linux/threads.h>
|
||||
#include <linux/cpumask.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/dmar.h>
|
||||
|
||||
#include <asm/smp.h>
|
||||
#include <asm/x2apic.h>
|
||||
|
||||
int x2apic_phys;
|
||||
|
||||
static struct apic apic_x2apic_phys;
|
||||
|
||||
static int set_x2apic_phys_mode(char *arg)
|
||||
{
|
||||
x2apic_phys = 1;
|
||||
return 0;
|
||||
}
|
||||
early_param("x2apic_phys", set_x2apic_phys_mode);
|
||||
|
||||
static bool x2apic_fadt_phys(void)
|
||||
{
|
||||
if ((acpi_gbl_FADT.header.revision >= FADT2_REVISION_ID) &&
|
||||
(acpi_gbl_FADT.flags & ACPI_FADT_APIC_PHYSICAL)) {
|
||||
printk(KERN_DEBUG "System requires x2apic physical mode\n");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
|
||||
{
|
||||
return x2apic_enabled() && (x2apic_phys || x2apic_fadt_phys());
|
||||
}
|
||||
|
||||
static void
|
||||
__x2apic_send_IPI_mask(const struct cpumask *mask, int vector, int apic_dest)
|
||||
{
|
||||
unsigned long query_cpu;
|
||||
unsigned long this_cpu;
|
||||
unsigned long flags;
|
||||
|
||||
x2apic_wrmsr_fence();
|
||||
|
||||
local_irq_save(flags);
|
||||
|
||||
this_cpu = smp_processor_id();
|
||||
for_each_cpu(query_cpu, mask) {
|
||||
if (apic_dest == APIC_DEST_ALLBUT && this_cpu == query_cpu)
|
||||
continue;
|
||||
__x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu),
|
||||
vector, APIC_DEST_PHYSICAL);
|
||||
}
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector)
|
||||
{
|
||||
__x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLINC);
|
||||
}
|
||||
|
||||
static void
|
||||
x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector)
|
||||
{
|
||||
__x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLBUT);
|
||||
}
|
||||
|
||||
static void x2apic_send_IPI_allbutself(int vector)
|
||||
{
|
||||
__x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLBUT);
|
||||
}
|
||||
|
||||
static void x2apic_send_IPI_all(int vector)
|
||||
{
|
||||
__x2apic_send_IPI_mask(cpu_online_mask, vector, APIC_DEST_ALLINC);
|
||||
}
|
||||
|
||||
static void init_x2apic_ldr(void)
|
||||
{
|
||||
}
|
||||
|
||||
static int x2apic_phys_probe(void)
|
||||
{
|
||||
if (x2apic_mode && (x2apic_phys || x2apic_fadt_phys()))
|
||||
return 1;
|
||||
|
||||
return apic == &apic_x2apic_phys;
|
||||
}
|
||||
|
||||
static struct apic apic_x2apic_phys = {
|
||||
|
||||
.name = "physical x2apic",
|
||||
.probe = x2apic_phys_probe,
|
||||
.acpi_madt_oem_check = x2apic_acpi_madt_oem_check,
|
||||
.apic_id_valid = x2apic_apic_id_valid,
|
||||
.apic_id_registered = x2apic_apic_id_registered,
|
||||
|
||||
.irq_delivery_mode = dest_Fixed,
|
||||
.irq_dest_mode = 0, /* physical */
|
||||
|
||||
.target_cpus = online_target_cpus,
|
||||
.disable_esr = 0,
|
||||
.dest_logical = 0,
|
||||
.check_apicid_used = NULL,
|
||||
|
||||
.vector_allocation_domain = default_vector_allocation_domain,
|
||||
.init_apic_ldr = init_x2apic_ldr,
|
||||
|
||||
.ioapic_phys_id_map = NULL,
|
||||
.setup_apic_routing = NULL,
|
||||
.cpu_present_to_apicid = default_cpu_present_to_apicid,
|
||||
.apicid_to_cpu_present = NULL,
|
||||
.check_phys_apicid_present = default_check_phys_apicid_present,
|
||||
.phys_pkg_id = x2apic_phys_pkg_id,
|
||||
|
||||
.get_apic_id = x2apic_get_apic_id,
|
||||
.set_apic_id = x2apic_set_apic_id,
|
||||
.apic_id_mask = 0xFFFFFFFFu,
|
||||
|
||||
.cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
|
||||
|
||||
.send_IPI_mask = x2apic_send_IPI_mask,
|
||||
.send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself,
|
||||
.send_IPI_allbutself = x2apic_send_IPI_allbutself,
|
||||
.send_IPI_all = x2apic_send_IPI_all,
|
||||
.send_IPI_self = x2apic_send_IPI_self,
|
||||
|
||||
.wait_for_init_deassert = false,
|
||||
.inquire_remote_apic = NULL,
|
||||
|
||||
.read = native_apic_msr_read,
|
||||
.write = native_apic_msr_write,
|
||||
.eoi_write = native_apic_msr_eoi_write,
|
||||
.icr_read = native_x2apic_icr_read,
|
||||
.icr_write = native_x2apic_icr_write,
|
||||
.wait_icr_idle = native_x2apic_wait_icr_idle,
|
||||
.safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle,
|
||||
};
|
||||
|
||||
apic_driver(apic_x2apic_phys);
|
||||
1002
arch/x86/kernel/apic/x2apic_uv_x.c
Normal file
1002
arch/x86/kernel/apic/x2apic_uv_x.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue