summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2009-10-24 20:17:18 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2009-10-24 20:17:18 +0000
commitd0a6f98358ceeddb8063a66cbb2c6eeaf8af0b9b (patch)
treee88044646551e057ff651a3489ce89d1bd095cc3 /sys
parent7baa71c51b9dbf84ab1d35c621b2e28f06e39a46 (diff)
add explicit barriers for read/write accesses to prph and internal memory.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/if_iwn.c6
-rw-r--r--sys/dev/pci/if_iwnreg.h10
-rw-r--r--sys/dev/pci/if_wpi.c6
-rw-r--r--sys/dev/pci/if_wpireg.h9
4 files changed, 27 insertions, 4 deletions
diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c
index 4c5fbbbc87f..065192cc0b7 100644
--- a/sys/dev/pci/if_iwn.c
+++ b/sys/dev/pci/if_iwn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_iwn.c,v 1.68 2009/10/24 19:00:40 damien Exp $ */
+/* $OpenBSD: if_iwn.c,v 1.69 2009/10/24 20:17:17 damien Exp $ */
/*-
* Copyright (c) 2007-2009 Damien Bergamini <damien.bergamini@free.fr>
@@ -737,6 +737,7 @@ static __inline uint32_t
iwn_prph_read(struct iwn_softc *sc, uint32_t addr)
{
IWN_WRITE(sc, IWN_PRPH_RADDR, IWN_PRPH_DWORD | addr);
+ IWN_BARRIER_READ_WRITE(sc);
return IWN_READ(sc, IWN_PRPH_RDATA);
}
@@ -744,6 +745,7 @@ static __inline void
iwn_prph_write(struct iwn_softc *sc, uint32_t addr, uint32_t data)
{
IWN_WRITE(sc, IWN_PRPH_WADDR, IWN_PRPH_DWORD | addr);
+ IWN_BARRIER_WRITE(sc);
IWN_WRITE(sc, IWN_PRPH_WDATA, data);
}
@@ -771,6 +773,7 @@ static __inline uint32_t
iwn_mem_read(struct iwn_softc *sc, uint32_t addr)
{
IWN_WRITE(sc, IWN_MEM_RADDR, addr);
+ IWN_BARRIER_READ_WRITE(sc);
return IWN_READ(sc, IWN_MEM_RDATA);
}
@@ -778,6 +781,7 @@ static __inline void
iwn_mem_write(struct iwn_softc *sc, uint32_t addr, uint32_t data)
{
IWN_WRITE(sc, IWN_MEM_WADDR, addr);
+ IWN_BARRIER_WRITE(sc);
IWN_WRITE(sc, IWN_MEM_WDATA, data);
}
diff --git a/sys/dev/pci/if_iwnreg.h b/sys/dev/pci/if_iwnreg.h
index 68de80122f3..b4addc90e65 100644
--- a/sys/dev/pci/if_iwnreg.h
+++ b/sys/dev/pci/if_iwnreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_iwnreg.h,v 1.28 2009/10/24 19:00:40 damien Exp $ */
+/* $OpenBSD: if_iwnreg.h,v 1.29 2009/10/24 20:17:17 damien Exp $ */
/*-
* Copyright (c) 2007, 2008
@@ -1604,3 +1604,11 @@ static const char * const iwn_fw_errmsg[] = {
#define IWN_CLRBITS(sc, reg, mask) \
IWN_WRITE(sc, reg, IWN_READ(sc, reg) & ~(mask))
+
+#define IWN_BARRIER_WRITE(sc) \
+ bus_space_barrier((sc)->sc_st, (sc)->sc_sh, 0, (sc)->sc_sz, \
+ BUS_SPACE_BARRIER_WRITE)
+
+#define IWN_BARRIER_READ_WRITE(sc) \
+ bus_space_barrier((sc)->sc_st, (sc)->sc_sh, 0, (sc)->sc_sz, \
+ BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE)
diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c
index 6ef190f6d2f..fe49035f747 100644
--- a/sys/dev/pci/if_wpi.c
+++ b/sys/dev/pci/if_wpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_wpi.c,v 1.93 2009/10/24 18:19:49 damien Exp $ */
+/* $OpenBSD: if_wpi.c,v 1.94 2009/10/24 20:17:17 damien Exp $ */
/*-
* Copyright (c) 2006-2008
@@ -477,6 +477,7 @@ static __inline uint32_t
wpi_prph_read(struct wpi_softc *sc, uint32_t addr)
{
WPI_WRITE(sc, WPI_PRPH_RADDR, WPI_PRPH_DWORD | addr);
+ WPI_BARRIER_READ_WRITE(sc);
return WPI_READ(sc, WPI_PRPH_RDATA);
}
@@ -484,6 +485,7 @@ static __inline void
wpi_prph_write(struct wpi_softc *sc, uint32_t addr, uint32_t data)
{
WPI_WRITE(sc, WPI_PRPH_WADDR, WPI_PRPH_DWORD | addr);
+ WPI_BARRIER_WRITE(sc);
WPI_WRITE(sc, WPI_PRPH_WDATA, data);
}
@@ -511,6 +513,7 @@ static __inline uint32_t
wpi_mem_read(struct wpi_softc *sc, uint32_t addr)
{
WPI_WRITE(sc, WPI_MEM_RADDR, addr);
+ WPI_BARRIER_READ_WRITE(sc);
return WPI_READ(sc, WPI_MEM_RDATA);
}
@@ -518,6 +521,7 @@ static __inline void
wpi_mem_write(struct wpi_softc *sc, uint32_t addr, uint32_t data)
{
WPI_WRITE(sc, WPI_MEM_WADDR, addr);
+ WPI_BARRIER_WRITE(sc);
WPI_WRITE(sc, WPI_MEM_WDATA, data);
}
diff --git a/sys/dev/pci/if_wpireg.h b/sys/dev/pci/if_wpireg.h
index 04b08ed483b..5f447eab55a 100644
--- a/sys/dev/pci/if_wpireg.h
+++ b/sys/dev/pci/if_wpireg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_wpireg.h,v 1.26 2009/10/24 18:21:05 damien Exp $ */
+/* $OpenBSD: if_wpireg.h,v 1.27 2009/10/24 20:17:17 damien Exp $ */
/*-
* Copyright (c) 2006-2008
@@ -831,3 +831,10 @@ static const char * const wpi_fw_errmsg[] = {
#define WPI_CLRBITS(sc, reg, mask) \
WPI_WRITE(sc, reg, WPI_READ(sc, reg) & ~(mask))
+#define WPI_BARRIER_WRITE(sc) \
+ bus_space_barrier((sc)->sc_st, (sc)->sc_sh, 0, (sc)->sc_sz, \
+ BUS_SPACE_BARRIER_WRITE)
+
+#define WPI_BARRIER_READ_WRITE(sc) \
+ bus_space_barrier((sc)->sc_st, (sc)->sc_sh, 0, (sc)->sc_sz, \
+ BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE)