ixgbe: Check for adapter removal on register writes
authorMark Rustad <mark.d.rustad@intel.com>
Wed, 15 Jan 2014 02:53:16 +0000 (18:53 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Jan 2014 02:59:17 +0000 (18:59 -0800)
Prevent writes to an adapter that has been detected as removed
by a previous failing read. This also fixes some include file
ordering confusion that this patch revealed.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c
drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c

index b6faaacbe7a987b2f79ad6d45de67ecd5a184fa8..f2e3919750ec8ca0d7d1b6ac27d63550ab4724a3 100644 (file)
@@ -135,7 +135,11 @@ void ixgbe_check_remove(struct ixgbe_hw *hw, u32 reg);
 
 static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value)
 {
-       writel(value, hw->hw_addr + reg);
+       u8 __iomem *reg_addr = ACCESS_ONCE(hw->hw_addr);
+
+       if (ixgbe_removed(reg_addr))
+               return;
+       writel(value, reg_addr + reg);
 }
 #define IXGBE_WRITE_REG(a, reg, value) ixgbe_write_reg((a), (reg), (value))
 
@@ -150,7 +154,11 @@ static inline void writeq(u64 val, void __iomem *addr)
 
 static inline void ixgbe_write_reg64(struct ixgbe_hw *hw, u32 reg, u64 value)
 {
-       writeq(value, hw->hw_addr + reg);
+       u8 __iomem *reg_addr = ACCESS_ONCE(hw->hw_addr);
+
+       if (ixgbe_removed(reg_addr))
+               return;
+       writeq(value, reg_addr + reg);
 }
 #define IXGBE_WRITE_REG64(a, reg, value) ixgbe_write_reg64((a), (reg), (value))
 
index d4a64e6653987be9e42e71fdce34a9267f607241..cc3101afd29fe8745d0cd870271b3f5246ee88fa 100644 (file)
@@ -27,8 +27,7 @@
 
 #include <linux/pci.h>
 #include <linux/delay.h>
-#include "ixgbe_type.h"
-#include "ixgbe_common.h"
+#include "ixgbe.h"
 #include "ixgbe_mbx.h"
 
 /**
index 39217e5ff7dcd74ddcfc49c7e33e43ec2633c515..132557c318f810b5f8bce65b4b0f2ebac613fdfd 100644 (file)
@@ -29,7 +29,7 @@
 #include <linux/delay.h>
 #include <linux/sched.h>
 
-#include "ixgbe_common.h"
+#include "ixgbe.h"
 #include "ixgbe_phy.h"
 
 static void ixgbe_i2c_start(struct ixgbe_hw *hw);