Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 161391
b: refs/heads/master
c: d0af9ee
h: refs/heads/master
i:
  161389: 914c215
  161387: 3637887
  161383: 246d4cb
  161375: ec27aba
v: v3
  • Loading branch information
Suresh Siddha authored and H. Peter Anvin committed Aug 21, 2009
1 parent 46109d2 commit 4ae8980
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 269c861baa2fe7c114c3bc7831292758d29eb336
refs/heads/master: d0af9eed5aa91b6b7b5049cae69e5ea956fd85c3
7 changes: 7 additions & 0 deletions trunk/arch/x86/include/asm/mtrr.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,12 @@ extern int mtrr_del_page(int reg, unsigned long base, unsigned long size);
extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi);
extern void mtrr_ap_init(void);
extern void mtrr_bp_init(void);
extern void set_mtrr_aps_delayed_init(void);
extern void mtrr_aps_init(void);
extern void mtrr_bp_restore(void);
extern int mtrr_trim_uncached_memory(unsigned long end_pfn);
extern int amd_special_default_mtrr(void);
extern u32 mtrr_aps_delayed_init;
# else
static inline u8 mtrr_type_lookup(u64 addr, u64 end)
{
Expand Down Expand Up @@ -161,6 +165,9 @@ static inline void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi)

#define mtrr_ap_init() do {} while (0)
#define mtrr_bp_init() do {} while (0)
#define set_mtrr_aps_delayed_init() do {} while (0)
#define mtrr_aps_init() do {} while (0)
#define mtrr_bp_restore() do {} while (0)
# endif

#ifdef CONFIG_COMPAT
Expand Down
46 changes: 37 additions & 9 deletions trunk/arch/x86/kernel/cpu/mtrr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ unsigned int mtrr_usage_table[MTRR_MAX_VAR_RANGES];
static DEFINE_MUTEX(mtrr_mutex);

u64 size_or_mask, size_and_mask;
u32 mtrr_aps_delayed_init;

static struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];

Expand Down Expand Up @@ -163,7 +164,10 @@ static void ipi_handler(void *info)
if (data->smp_reg != ~0U) {
mtrr_if->set(data->smp_reg, data->smp_base,
data->smp_size, data->smp_type);
} else {
} else if (mtrr_aps_delayed_init) {
/*
* Initialize the MTRRs inaddition to the synchronisation.
*/
mtrr_if->set_all();
}

Expand Down Expand Up @@ -265,6 +269,8 @@ set_mtrr(unsigned int reg, unsigned long base, unsigned long size, mtrr_type typ
*/
if (reg != ~0U)
mtrr_if->set(reg, base, size, type);
else if (!mtrr_aps_delayed_init)
mtrr_if->set_all();

/* Wait for the others */
while (atomic_read(&data.count))
Expand Down Expand Up @@ -721,9 +727,7 @@ void __init mtrr_bp_init(void)

void mtrr_ap_init(void)
{
unsigned long flags;

if (!mtrr_if || !use_intel())
if (!use_intel() || mtrr_aps_delayed_init)
return;
/*
* Ideally we should hold mtrr_mutex here to avoid mtrr entries
Expand All @@ -738,11 +742,7 @@ void mtrr_ap_init(void)
* 2. cpu hotadd time. We let mtrr_add/del_page hold cpuhotplug
* lock to prevent mtrr entry changes
*/
local_irq_save(flags);

mtrr_if->set_all();

local_irq_restore(flags);
set_mtrr(~0U, 0, 0, 0);
}

/**
Expand All @@ -753,6 +753,34 @@ void mtrr_save_state(void)
smp_call_function_single(0, mtrr_save_fixed_ranges, NULL, 1);
}

void set_mtrr_aps_delayed_init(void)
{
if (!use_intel())
return;

mtrr_aps_delayed_init = 1;
}

/*
* MTRR initialization for all AP's
*/
void mtrr_aps_init(void)
{
if (!use_intel())
return;

set_mtrr(~0U, 0, 0, 0);
mtrr_aps_delayed_init = 0;
}

void mtrr_bp_restore(void)
{
if (!use_intel())
return;

mtrr_if->set_all();
}

static int __init mtrr_init_finialize(void)
{
if (!mtrr_if)
Expand Down
14 changes: 14 additions & 0 deletions trunk/arch/x86/kernel/smpboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1116,9 +1116,22 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)

if (is_uv_system())
uv_system_init();

set_mtrr_aps_delayed_init();
out:
preempt_enable();
}

void arch_enable_nonboot_cpus_begin(void)
{
set_mtrr_aps_delayed_init();
}

void arch_enable_nonboot_cpus_end(void)
{
mtrr_aps_init();
}

/*
* Early setup to make printk work.
*/
Expand All @@ -1140,6 +1153,7 @@ void __init native_smp_cpus_done(unsigned int max_cpus)
setup_ioapic_dest();
#endif
check_nmi_watchdog();
mtrr_aps_init();
}

static int __initdata setup_possible_cpus = -1;
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/power/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ static void __restore_processor_state(struct saved_context *ctxt)
fix_processor_context();

do_fpu_end();
mtrr_ap_init();
mtrr_bp_restore();

#ifdef CONFIG_X86_OLD_MCE
mcheck_init(&boot_cpu_data);
Expand Down
14 changes: 14 additions & 0 deletions trunk/kernel/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,14 @@ int disable_nonboot_cpus(void)
return error;
}

void __weak arch_enable_nonboot_cpus_begin(void)
{
}

void __weak arch_enable_nonboot_cpus_end(void)
{
}

void __ref enable_nonboot_cpus(void)
{
int cpu, error;
Expand All @@ -424,6 +432,9 @@ void __ref enable_nonboot_cpus(void)
goto out;

printk("Enabling non-boot CPUs ...\n");

arch_enable_nonboot_cpus_begin();

for_each_cpu(cpu, frozen_cpus) {
error = _cpu_up(cpu, 1);
if (!error) {
Expand All @@ -432,6 +443,9 @@ void __ref enable_nonboot_cpus(void)
}
printk(KERN_WARNING "Error taking CPU%d up: %d\n", cpu, error);
}

arch_enable_nonboot_cpus_end();

cpumask_clear(frozen_cpus);
out:
cpu_maps_update_done();
Expand Down

0 comments on commit 4ae8980

Please sign in to comment.