aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/kernel/cpu/mtrr/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/i386/kernel/cpu/mtrr/main.c')
-rw-r--r--arch/i386/kernel/cpu/mtrr/main.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/arch/i386/kernel/cpu/mtrr/main.c b/arch/i386/kernel/cpu/mtrr/main.c
index 3b4618bed70d..fff90bda4733 100644
--- a/arch/i386/kernel/cpu/mtrr/main.c
+++ b/arch/i386/kernel/cpu/mtrr/main.c
@@ -36,6 +36,7 @@
36#include <linux/pci.h> 36#include <linux/pci.h>
37#include <linux/smp.h> 37#include <linux/smp.h>
38#include <linux/cpu.h> 38#include <linux/cpu.h>
39#include <linux/mutex.h>
39 40
40#include <asm/mtrr.h> 41#include <asm/mtrr.h>
41 42
@@ -47,7 +48,7 @@
47u32 num_var_ranges = 0; 48u32 num_var_ranges = 0;
48 49
49unsigned int *usage_table; 50unsigned int *usage_table;
50static DECLARE_MUTEX(mtrr_sem); 51static DEFINE_MUTEX(mtrr_mutex);
51 52
52u32 size_or_mask, size_and_mask; 53u32 size_or_mask, size_and_mask;
53 54
@@ -333,7 +334,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
333 /* No CPU hotplug when we change MTRR entries */ 334 /* No CPU hotplug when we change MTRR entries */
334 lock_cpu_hotplug(); 335 lock_cpu_hotplug();
335 /* Search for existing MTRR */ 336 /* Search for existing MTRR */
336 down(&mtrr_sem); 337 mutex_lock(&mtrr_mutex);
337 for (i = 0; i < num_var_ranges; ++i) { 338 for (i = 0; i < num_var_ranges; ++i) {
338 mtrr_if->get(i, &lbase, &lsize, &ltype); 339 mtrr_if->get(i, &lbase, &lsize, &ltype);
339 if (base >= lbase + lsize) 340 if (base >= lbase + lsize)
@@ -371,7 +372,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
371 printk(KERN_INFO "mtrr: no more MTRRs available\n"); 372 printk(KERN_INFO "mtrr: no more MTRRs available\n");
372 error = i; 373 error = i;
373 out: 374 out:
374 up(&mtrr_sem); 375 mutex_unlock(&mtrr_mutex);
375 unlock_cpu_hotplug(); 376 unlock_cpu_hotplug();
376 return error; 377 return error;
377} 378}
@@ -464,7 +465,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
464 max = num_var_ranges; 465 max = num_var_ranges;
465 /* No CPU hotplug when we change MTRR entries */ 466 /* No CPU hotplug when we change MTRR entries */
466 lock_cpu_hotplug(); 467 lock_cpu_hotplug();
467 down(&mtrr_sem); 468 mutex_lock(&mtrr_mutex);
468 if (reg < 0) { 469 if (reg < 0) {
469 /* Search for existing MTRR */ 470 /* Search for existing MTRR */
470 for (i = 0; i < max; ++i) { 471 for (i = 0; i < max; ++i) {
@@ -503,7 +504,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
503 set_mtrr(reg, 0, 0, 0); 504 set_mtrr(reg, 0, 0, 0);
504 error = reg; 505 error = reg;
505 out: 506 out:
506 up(&mtrr_sem); 507 mutex_unlock(&mtrr_mutex);
507 unlock_cpu_hotplug(); 508 unlock_cpu_hotplug();
508 return error; 509 return error;
509} 510}
@@ -685,7 +686,7 @@ void mtrr_ap_init(void)
685 if (!mtrr_if || !use_intel()) 686 if (!mtrr_if || !use_intel())
686 return; 687 return;
687 /* 688 /*
688 * Ideally we should hold mtrr_sem here to avoid mtrr entries changed, 689 * Ideally we should hold mtrr_mutex here to avoid mtrr entries changed,
689 * but this routine will be called in cpu boot time, holding the lock 690 * but this routine will be called in cpu boot time, holding the lock
690 * breaks it. This routine is called in two cases: 1.very earily time 691 * breaks it. This routine is called in two cases: 1.very earily time
691 * of software resume, when there absolutely isn't mtrr entry changes; 692 * of software resume, when there absolutely isn't mtrr entry changes;