| From a6310a884cd9bb469c6267554c3913ad8300b55c Mon Sep 17 00:00:00 2001 |
| From: Wu Zhangjin <wuzhangjin@gmail.com> |
| Date: Wed, 10 Mar 2010 21:52:07 +0800 |
| Subject: [PATCH] Loongson: make _rdmsr, _wrmsr be atomic |
| |
| commit a6310a884cd9bb469c6267554c3913ad8300b55c in tip. |
| |
| The _rdmsr, _wrdmsr operation must be atomic to ensure accessing the |
| right msr address we want. |
| |
| Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com> |
| |
| diff --git a/arch/mips/pci/ops-loongson2.c b/arch/mips/pci/ops-loongson2.c |
| index aa5d3da..98aa2f3 100644 |
| --- a/arch/mips/pci/ops-loongson2.c |
| +++ b/arch/mips/pci/ops-loongson2.c |
| @@ -182,15 +182,22 @@ struct pci_ops loongson_pci_ops = { |
| }; |
| |
| #ifdef CONFIG_CS5536 |
| + |
| +DEFINE_RAW_SPINLOCK(msr_lock); |
| + |
| void _rdmsr(u32 msr, u32 *hi, u32 *lo) |
| { |
| struct pci_bus bus = { |
| .number = PCI_BUS_CS5536 |
| }; |
| u32 devfn = PCI_DEVFN(PCI_IDSEL_CS5536, 0); |
| + unsigned long flags; |
| + |
| + raw_spin_lock_irqsave(&msr_lock, flags); |
| loongson_pcibios_write(&bus, devfn, PCI_MSR_ADDR, 4, msr); |
| loongson_pcibios_read(&bus, devfn, PCI_MSR_DATA_LO, 4, lo); |
| loongson_pcibios_read(&bus, devfn, PCI_MSR_DATA_HI, 4, hi); |
| + raw_spin_unlock_irqrestore(&msr_lock, flags); |
| } |
| EXPORT_SYMBOL(_rdmsr); |
| |
| @@ -200,9 +207,13 @@ void _wrmsr(u32 msr, u32 hi, u32 lo) |
| .number = PCI_BUS_CS5536 |
| }; |
| u32 devfn = PCI_DEVFN(PCI_IDSEL_CS5536, 0); |
| + unsigned long flags; |
| + |
| + raw_spin_lock_irqsave(&msr_lock, flags); |
| loongson_pcibios_write(&bus, devfn, PCI_MSR_ADDR, 4, msr); |
| loongson_pcibios_write(&bus, devfn, PCI_MSR_DATA_LO, 4, lo); |
| loongson_pcibios_write(&bus, devfn, PCI_MSR_DATA_HI, 4, hi); |
| + raw_spin_unlock_irqrestore(&msr_lock, flags); |
| } |
| EXPORT_SYMBOL(_wrmsr); |
| #endif |
| -- |
| 1.7.1.1 |
| |