|
36 | 36 | #include <linux/pci.h> |
37 | 37 | #include <linux/smp.h> |
38 | 38 | #include <linux/cpu.h> |
| 39 | +#include <linux/mutex.h> |
39 | 40 |
|
40 | 41 | #include <asm/mtrr.h> |
41 | 42 |
|
|
47 | 48 | u32 num_var_ranges = 0; |
48 | 49 |
|
49 | 50 | unsigned int *usage_table; |
50 | | -static DECLARE_MUTEX(mtrr_sem); |
| 51 | +static DEFINE_MUTEX(mtrr_mutex); |
51 | 52 |
|
52 | 53 | u32 size_or_mask, size_and_mask; |
53 | 54 |
|
@@ -333,7 +334,7 @@ int mtrr_add_page(unsigned long base, unsigned long size, |
333 | 334 | /* No CPU hotplug when we change MTRR entries */ |
334 | 335 | lock_cpu_hotplug(); |
335 | 336 | /* Search for existing MTRR */ |
336 | | - down(&mtrr_sem); |
| 337 | + mutex_lock(&mtrr_mutex); |
337 | 338 | for (i = 0; i < num_var_ranges; ++i) { |
338 | 339 | mtrr_if->get(i, &lbase, &lsize, <ype); |
339 | 340 | if (base >= lbase + lsize) |
@@ -371,7 +372,7 @@ int mtrr_add_page(unsigned long base, unsigned long size, |
371 | 372 | printk(KERN_INFO "mtrr: no more MTRRs available\n"); |
372 | 373 | error = i; |
373 | 374 | out: |
374 | | - up(&mtrr_sem); |
| 375 | + mutex_unlock(&mtrr_mutex); |
375 | 376 | unlock_cpu_hotplug(); |
376 | 377 | return error; |
377 | 378 | } |
@@ -464,7 +465,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size) |
464 | 465 | max = num_var_ranges; |
465 | 466 | /* No CPU hotplug when we change MTRR entries */ |
466 | 467 | lock_cpu_hotplug(); |
467 | | - down(&mtrr_sem); |
| 468 | + mutex_lock(&mtrr_mutex); |
468 | 469 | if (reg < 0) { |
469 | 470 | /* Search for existing MTRR */ |
470 | 471 | for (i = 0; i < max; ++i) { |
@@ -503,7 +504,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size) |
503 | 504 | set_mtrr(reg, 0, 0, 0); |
504 | 505 | error = reg; |
505 | 506 | out: |
506 | | - up(&mtrr_sem); |
| 507 | + mutex_unlock(&mtrr_mutex); |
507 | 508 | unlock_cpu_hotplug(); |
508 | 509 | return error; |
509 | 510 | } |
@@ -685,7 +686,7 @@ void mtrr_ap_init(void) |
685 | 686 | if (!mtrr_if || !use_intel()) |
686 | 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 | 690 | * but this routine will be called in cpu boot time, holding the lock |
690 | 691 | * breaks it. This routine is called in two cases: 1.very earily time |
691 | 692 | * of software resume, when there absolutely isn't mtrr entry changes; |
|
0 commit comments