summaryrefslogtreecommitdiff
path: root/sys/arch/loongson/dev
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2010-01-27 05:35:03 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2010-01-27 05:35:03 +0000
commit5352dc72322ef20069415c701f9d33341165f686 (patch)
treebb6c726ea9079f7d2aa59b170b27ba9bfedfb122 /sys/arch/loongson/dev
parent22e8e4266ba2a5fb7a1251ef852b7984b9905f49 (diff)
disable interrupts in rdmsr() and wrmsr() so that their operation does not
risk being interrupted.
Diffstat (limited to 'sys/arch/loongson/dev')
-rw-r--r--sys/arch/loongson/dev/glx.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/sys/arch/loongson/dev/glx.c b/sys/arch/loongson/dev/glx.c
index ac56891fbce..215153d0bd4 100644
--- a/sys/arch/loongson/dev/glx.c
+++ b/sys/arch/loongson/dev/glx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: glx.c,v 1.1 2009/12/25 22:11:08 miod Exp $ */
+/* $OpenBSD: glx.c,v 1.2 2010/01/27 05:35:02 miod Exp $ */
/*
* Copyright (c) 2009 Miodrag Vallat.
@@ -112,25 +112,36 @@ uint64_t
rdmsr(uint msr)
{
uint64_t lo, hi;
+ uint32_t sr;
+#ifdef DIAGNOSTIC
if (glxbase_tag == 0)
panic("rdmsr invoked before glx initialization");
+#endif
+ sr = disableintr();
pci_conf_write(glxbase_pc, glxbase_tag, PCI_MSR_ADDR, msr);
lo = (uint32_t)pci_conf_read(glxbase_pc, glxbase_tag, PCI_MSR_LO32);
hi = (uint32_t)pci_conf_read(glxbase_pc, glxbase_tag, PCI_MSR_HI32);
+ setsr(sr);
return (hi << 32) | lo;
}
void
wrmsr(uint msr, uint64_t value)
{
+ uint32_t sr;
+
+#ifdef DIAGNOSTIC
if (glxbase_tag == 0)
- panic("rdmsr invoked before glx initialization");
+ panic("wrmsr invoked before glx initialization");
+#endif
+ sr = disableintr();
pci_conf_write(glxbase_pc, glxbase_tag, PCI_MSR_ADDR, msr);
pci_conf_write(glxbase_pc, glxbase_tag, PCI_MSR_LO32, (uint32_t)value);
pci_conf_write(glxbase_pc, glxbase_tag, PCI_MSR_HI32, value >> 32);
+ setsr(sr);
}
int