iwlwifi: use rmb/wmb to protect indirect mmio operation
authorZhu, Yi <yi.zhu@intel.com>
Fri, 5 Dec 2008 15:58:41 +0000 (07:58 -0800)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 12 Dec 2008 18:48:22 +0000 (13:48 -0500)
This patch protects iwlwifi indirect mmio operations with rmb() and
wmb(). It makes sure CPU reordering won't affect our indirect mmio
access.

Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/iwlwifi/iwl-3945-io.h
drivers/net/wireless/iwlwifi/iwl-io.h

index 994f8bab0dab4c542fdeb072e174035136662ca1..d381b82a75986c9b713967ee14f09c0750bc1755 100644 (file)
@@ -298,6 +298,7 @@ static inline int __iwl3945_poll_direct_bit(const char *f, u32 l,
 static inline u32 _iwl3945_read_prph(struct iwl3945_priv *priv, u32 reg)
 {
        _iwl3945_write_direct32(priv, HBUS_TARG_PRPH_RADDR, reg | (3 << 24));
+       rmb();
        return _iwl3945_read_direct32(priv, HBUS_TARG_PRPH_RDAT);
 }
 #ifdef CONFIG_IWL3945_DEBUG
@@ -319,6 +320,7 @@ static inline void _iwl3945_write_prph(struct iwl3945_priv *priv,
 {
        _iwl3945_write_direct32(priv, HBUS_TARG_PRPH_WADDR,
                              ((addr & 0x0000FFFF) | (3 << 24)));
+       wmb();
        _iwl3945_write_direct32(priv, HBUS_TARG_PRPH_WDAT, val);
 }
 #ifdef CONFIG_IWL3945_DEBUG
@@ -380,12 +382,14 @@ static inline void iwl3945_clear_bits_prph(struct iwl3945_priv
 static inline u32 iwl3945_read_targ_mem(struct iwl3945_priv *priv, u32 addr)
 {
        iwl3945_write_direct32(priv, HBUS_TARG_MEM_RADDR, addr);
+       rmb();
        return iwl3945_read_direct32(priv, HBUS_TARG_MEM_RDAT);
 }
 
 static inline void iwl3945_write_targ_mem(struct iwl3945_priv *priv, u32 addr, u32 val)
 {
        iwl3945_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr);
+       wmb();
        iwl3945_write_direct32(priv, HBUS_TARG_MEM_WDAT, val);
 }
 
@@ -393,6 +397,7 @@ static inline void iwl3945_write_targ_mem_buf(struct iwl3945_priv *priv, u32 add
                                          u32 len, u32 *values)
 {
        iwl3945_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr);
+       wmb();
        for (; 0 < len; len -= sizeof(u32), values++)
                iwl3945_write_direct32(priv, HBUS_TARG_MEM_WDAT, *values);
 }
index c56dc215fef7bb3d208d9d9d2cb55fee8eee0ea0..10ca032f905ed9c0839bdae8a2ddc49a9f687e18 100644 (file)
@@ -299,6 +299,7 @@ static inline int __iwl_poll_direct_bit(const char *f, u32 l,
 static inline u32 _iwl_read_prph(struct iwl_priv *priv, u32 reg)
 {
        _iwl_write_direct32(priv, HBUS_TARG_PRPH_RADDR, reg | (3 << 24));
+       rmb();
        return _iwl_read_direct32(priv, HBUS_TARG_PRPH_RDAT);
 }
 #ifdef CONFIG_IWLWIFI_DEBUG
@@ -321,6 +322,7 @@ static inline void _iwl_write_prph(struct iwl_priv *priv,
 {
        _iwl_write_direct32(priv, HBUS_TARG_PRPH_WADDR,
                              ((addr & 0x0000FFFF) | (3 << 24)));
+       wmb();
        _iwl_write_direct32(priv, HBUS_TARG_PRPH_WDAT, val);
 }
 #ifdef CONFIG_IWLWIFI_DEBUG
@@ -383,12 +385,14 @@ static inline void iwl_clear_bits_prph(struct iwl_priv
 static inline u32 iwl_read_targ_mem(struct iwl_priv *priv, u32 addr)
 {
        iwl_write_direct32(priv, HBUS_TARG_MEM_RADDR, addr);
+       rmb();
        return iwl_read_direct32(priv, HBUS_TARG_MEM_RDAT);
 }
 
 static inline void iwl_write_targ_mem(struct iwl_priv *priv, u32 addr, u32 val)
 {
        iwl_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr);
+       wmb();
        iwl_write_direct32(priv, HBUS_TARG_MEM_WDAT, val);
 }
 
@@ -396,6 +400,7 @@ static inline void iwl_write_targ_mem_buf(struct iwl_priv *priv, u32 addr,
                                          u32 len, u32 *values)
 {
        iwl_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr);
+       wmb();
        for (; 0 < len; len -= sizeof(u32), values++)
                iwl_write_direct32(priv, HBUS_TARG_MEM_WDAT, *values);
 }