diff options
author | Yinghai Lu <yinghai@kernel.org> | 2009-03-13 15:46:07 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-14 07:27:06 -0400 |
commit | 63516ef6d6a8379ee5c32463efc6a75f9da8a309 (patch) | |
tree | c9096842aaa9d598b29c45c8c3ef71a301dfa8e7 /arch/x86/kernel/cpu/mtrr/generic.c | |
parent | 3ff42da5048649503e343a32be37b14a6a4e8aaf (diff) |
x86: fix get_mtrr() warning about smp_processor_id() with CONFIG_PREEMPT=y
Impact: fix debug warning
Jaswinder noticed that there is a warning about smp_processor_id()
in get_mtrr().
Fix it by wrapping the printout into a get/put_cpu() pair.
Reported-by: Jaswinder Singh Rajput <jaswinder@kernel.org>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <49BAB7FF.4030107@kernel.org>
[ changed to get/put_cpu(), cleaned up surrounding code a it. ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/cpu/mtrr/generic.c')
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/generic.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c index 950c434f793d..641ee3507d06 100644 --- a/arch/x86/kernel/cpu/mtrr/generic.c +++ b/arch/x86/kernel/cpu/mtrr/generic.c | |||
@@ -381,11 +381,14 @@ static void generic_get_mtrr(unsigned int reg, unsigned long *base, | |||
381 | { | 381 | { |
382 | unsigned int mask_lo, mask_hi, base_lo, base_hi; | 382 | unsigned int mask_lo, mask_hi, base_lo, base_hi; |
383 | unsigned int tmp, hi; | 383 | unsigned int tmp, hi; |
384 | int cpu; | ||
384 | 385 | ||
385 | /* | 386 | /* |
386 | * get_mtrr doesn't need to update mtrr_state, also it could be called | 387 | * get_mtrr doesn't need to update mtrr_state, also it could be called |
387 | * from any cpu, so try to print it out directly. | 388 | * from any cpu, so try to print it out directly. |
388 | */ | 389 | */ |
390 | cpu = get_cpu(); | ||
391 | |||
389 | rdmsr(MTRRphysMask_MSR(reg), mask_lo, mask_hi); | 392 | rdmsr(MTRRphysMask_MSR(reg), mask_lo, mask_hi); |
390 | 393 | ||
391 | if ((mask_lo & 0x800) == 0) { | 394 | if ((mask_lo & 0x800) == 0) { |
@@ -393,15 +396,16 @@ static void generic_get_mtrr(unsigned int reg, unsigned long *base, | |||
393 | *base = 0; | 396 | *base = 0; |
394 | *size = 0; | 397 | *size = 0; |
395 | *type = 0; | 398 | *type = 0; |
396 | return; | 399 | goto out_put_cpu; |
397 | } | 400 | } |
398 | 401 | ||
399 | rdmsr(MTRRphysBase_MSR(reg), base_lo, base_hi); | 402 | rdmsr(MTRRphysBase_MSR(reg), base_lo, base_hi); |
400 | 403 | ||
401 | /* Work out the shifted address mask. */ | 404 | /* Work out the shifted address mask: */ |
402 | tmp = mask_hi << (32 - PAGE_SHIFT) | mask_lo >> PAGE_SHIFT; | 405 | tmp = mask_hi << (32 - PAGE_SHIFT) | mask_lo >> PAGE_SHIFT; |
403 | mask_lo = size_or_mask | tmp; | 406 | mask_lo = size_or_mask | tmp; |
404 | /* Expand tmp with high bits to all 1s*/ | 407 | |
408 | /* Expand tmp with high bits to all 1s: */ | ||
405 | hi = fls(tmp); | 409 | hi = fls(tmp); |
406 | if (hi > 0) { | 410 | if (hi > 0) { |
407 | tmp |= ~((1<<(hi - 1)) - 1); | 411 | tmp |= ~((1<<(hi - 1)) - 1); |
@@ -412,15 +416,19 @@ static void generic_get_mtrr(unsigned int reg, unsigned long *base, | |||
412 | } | 416 | } |
413 | } | 417 | } |
414 | 418 | ||
415 | /* This works correctly if size is a power of two, i.e. a | 419 | /* |
416 | contiguous range. */ | 420 | * This works correctly if size is a power of two, i.e. a |
421 | * contiguous range: | ||
422 | */ | ||
417 | *size = -mask_lo; | 423 | *size = -mask_lo; |
418 | *base = base_hi << (32 - PAGE_SHIFT) | base_lo >> PAGE_SHIFT; | 424 | *base = base_hi << (32 - PAGE_SHIFT) | base_lo >> PAGE_SHIFT; |
419 | *type = base_lo & 0xff; | 425 | *type = base_lo & 0xff; |
420 | 426 | ||
421 | printk(KERN_DEBUG " get_mtrr: cpu%d reg%02d base=%010lx size=%010lx %s\n", | 427 | printk(KERN_DEBUG " get_mtrr: cpu%d reg%02d base=%010lx size=%010lx %s\n", |
422 | smp_processor_id(), reg, *base, *size, | 428 | cpu, reg, *base, *size, |
423 | mtrr_attrib_to_str(*type & 0xff)); | 429 | mtrr_attrib_to_str(*type & 0xff)); |
430 | out_put_cpu: | ||
431 | put_cpu(); | ||
424 | } | 432 | } |
425 | 433 | ||
426 | /** | 434 | /** |