diff options
Diffstat (limited to 'arch/x86/kernel/cpu/mtrr/main.c')
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/main.c | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c index 01c0f3ee6cc3..929739a653d1 100644 --- a/arch/x86/kernel/cpu/mtrr/main.c +++ b/arch/x86/kernel/cpu/mtrr/main.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/cpu.h> | 45 | #include <linux/cpu.h> |
46 | #include <linux/pci.h> | 46 | #include <linux/pci.h> |
47 | #include <linux/smp.h> | 47 | #include <linux/smp.h> |
48 | #include <linux/syscore_ops.h> | ||
48 | 49 | ||
49 | #include <asm/processor.h> | 50 | #include <asm/processor.h> |
50 | #include <asm/e820.h> | 51 | #include <asm/e820.h> |
@@ -292,14 +293,24 @@ set_mtrr(unsigned int reg, unsigned long base, unsigned long size, mtrr_type typ | |||
292 | 293 | ||
293 | /* | 294 | /* |
294 | * HACK! | 295 | * HACK! |
295 | * We use this same function to initialize the mtrrs on boot. | 296 | * |
296 | * The state of the boot cpu's mtrrs has been saved, and we want | 297 | * We use this same function to initialize the mtrrs during boot, |
297 | * to replicate across all the APs. | 298 | * resume, runtime cpu online and on an explicit request to set a |
298 | * If we're doing that @reg is set to something special... | 299 | * specific MTRR. |
300 | * | ||
301 | * During boot or suspend, the state of the boot cpu's mtrrs has been | ||
302 | * saved, and we want to replicate that across all the cpus that come | ||
303 | * online (either at the end of boot or resume or during a runtime cpu | ||
304 | * online). If we're doing that, @reg is set to something special and on | ||
305 | * this cpu we still do mtrr_if->set_all(). During boot/resume, this | ||
306 | * is unnecessary if at this point we are still on the cpu that started | ||
307 | * the boot/resume sequence. But there is no guarantee that we are still | ||
308 | * on the same cpu. So we do mtrr_if->set_all() on this cpu aswell to be | ||
309 | * sure that we are in sync with everyone else. | ||
299 | */ | 310 | */ |
300 | if (reg != ~0U) | 311 | if (reg != ~0U) |
301 | mtrr_if->set(reg, base, size, type); | 312 | mtrr_if->set(reg, base, size, type); |
302 | else if (!mtrr_aps_delayed_init) | 313 | else |
303 | mtrr_if->set_all(); | 314 | mtrr_if->set_all(); |
304 | 315 | ||
305 | /* Wait for the others */ | 316 | /* Wait for the others */ |
@@ -630,7 +641,7 @@ struct mtrr_value { | |||
630 | 641 | ||
631 | static struct mtrr_value mtrr_value[MTRR_MAX_VAR_RANGES]; | 642 | static struct mtrr_value mtrr_value[MTRR_MAX_VAR_RANGES]; |
632 | 643 | ||
633 | static int mtrr_save(struct sys_device *sysdev, pm_message_t state) | 644 | static int mtrr_save(void) |
634 | { | 645 | { |
635 | int i; | 646 | int i; |
636 | 647 | ||
@@ -642,7 +653,7 @@ static int mtrr_save(struct sys_device *sysdev, pm_message_t state) | |||
642 | return 0; | 653 | return 0; |
643 | } | 654 | } |
644 | 655 | ||
645 | static int mtrr_restore(struct sys_device *sysdev) | 656 | static void mtrr_restore(void) |
646 | { | 657 | { |
647 | int i; | 658 | int i; |
648 | 659 | ||
@@ -653,12 +664,11 @@ static int mtrr_restore(struct sys_device *sysdev) | |||
653 | mtrr_value[i].ltype); | 664 | mtrr_value[i].ltype); |
654 | } | 665 | } |
655 | } | 666 | } |
656 | return 0; | ||
657 | } | 667 | } |
658 | 668 | ||
659 | 669 | ||
660 | 670 | ||
661 | static struct sysdev_driver mtrr_sysdev_driver = { | 671 | static struct syscore_ops mtrr_syscore_ops = { |
662 | .suspend = mtrr_save, | 672 | .suspend = mtrr_save, |
663 | .resume = mtrr_restore, | 673 | .resume = mtrr_restore, |
664 | }; | 674 | }; |
@@ -793,13 +803,21 @@ void set_mtrr_aps_delayed_init(void) | |||
793 | } | 803 | } |
794 | 804 | ||
795 | /* | 805 | /* |
796 | * MTRR initialization for all AP's | 806 | * Delayed MTRR initialization for all AP's |
797 | */ | 807 | */ |
798 | void mtrr_aps_init(void) | 808 | void mtrr_aps_init(void) |
799 | { | 809 | { |
800 | if (!use_intel()) | 810 | if (!use_intel()) |
801 | return; | 811 | return; |
802 | 812 | ||
813 | /* | ||
814 | * Check if someone has requested the delay of AP MTRR initialization, | ||
815 | * by doing set_mtrr_aps_delayed_init(), prior to this point. If not, | ||
816 | * then we are done. | ||
817 | */ | ||
818 | if (!mtrr_aps_delayed_init) | ||
819 | return; | ||
820 | |||
803 | set_mtrr(~0U, 0, 0, 0); | 821 | set_mtrr(~0U, 0, 0, 0); |
804 | mtrr_aps_delayed_init = false; | 822 | mtrr_aps_delayed_init = false; |
805 | } | 823 | } |
@@ -831,7 +849,7 @@ static int __init mtrr_init_finialize(void) | |||
831 | * TBD: is there any system with such CPU which supports | 849 | * TBD: is there any system with such CPU which supports |
832 | * suspend/resume? If no, we should remove the code. | 850 | * suspend/resume? If no, we should remove the code. |
833 | */ | 851 | */ |
834 | sysdev_driver_register(&cpu_sysdev_class, &mtrr_sysdev_driver); | 852 | register_syscore_ops(&mtrr_syscore_ops); |
835 | 853 | ||
836 | return 0; | 854 | return 0; |
837 | } | 855 | } |