From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Mark Rustad <mark.d.rustad@intel.com>,
netdev@vger.kernel.org, gospo@redhat.com, sassmann@redhat.com,
bhutchings@solarflare.com,
Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next v2 06/11] ixgbe: Check for adapter removal on register writes
Date: Thu, 2 Jan 2014 21:18:25 -0800 [thread overview]
Message-ID: <1388726310-2996-7-git-send-email-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <1388726310-2996-1-git-send-email-jeffrey.t.kirsher@intel.com>
From: Mark Rustad <mark.d.rustad@intel.com>
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>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe.h | 5 +++++
drivers/net/ethernet/intel/ixgbe/ixgbe_common.h | 12 ++++++++++--
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 6 ++++++
drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c | 3 +--
drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c | 2 +-
5 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index 002c9e2..8a4b03b 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -257,6 +257,9 @@ struct ixgbe_ring {
};
unsigned long last_rx_timestamp;
unsigned long state;
+#ifdef CONFIG_IXGBE_LER
+ u8 __iomem **adapter_present; /* Points to hw_addr in ixgbe_hw */
+#endif /* CONFIG_IXGBE_LER */
u8 __iomem *tail;
dma_addr_t dma; /* phys. address of descriptor ring */
unsigned int size; /* length in bytes */
@@ -587,6 +590,8 @@ static inline u16 ixgbe_desc_unused(struct ixgbe_ring *ring)
static inline void ixgbe_write_tail(struct ixgbe_ring *ring, u32 value)
{
+ if (IXGBE_REMOVED(*ring->adapter_present))
+ return;
writel(value, ring->tail);
}
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
index 551025a..b07a887 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
@@ -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);
}
#ifndef writeq
@@ -145,7 +149,11 @@ static inline void IXGBE_WRITE_REG(struct ixgbe_hw *hw, u32 reg, u32 value)
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);
}
static inline u32 IXGBE_READ_REG(struct ixgbe_hw *hw, u32 reg)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 0f0ca66..22e51d1 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -3001,6 +3001,9 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter,
ring->count * sizeof(union ixgbe_adv_tx_desc));
IXGBE_WRITE_REG(hw, IXGBE_TDH(reg_idx), 0);
IXGBE_WRITE_REG(hw, IXGBE_TDT(reg_idx), 0);
+#ifdef CONFIG_IXGBE_LER
+ ring->adapter_present = &hw->hw_addr;
+#endif /* CONFIG_IXGBE_LER */
ring->tail = adapter->io_addr + IXGBE_TDT(reg_idx);
/*
@@ -3404,6 +3407,9 @@ void ixgbe_configure_rx_ring(struct ixgbe_adapter *adapter,
ring->count * sizeof(union ixgbe_adv_rx_desc));
IXGBE_WRITE_REG(hw, IXGBE_RDH(reg_idx), 0);
IXGBE_WRITE_REG(hw, IXGBE_RDT(reg_idx), 0);
+#ifdef CONFIG_IXGBE_LER
+ ring->adapter_present = &hw->hw_addr;
+#endif /* CONFIG_IXGBE_LER */
ring->tail = adapter->io_addr + IXGBE_RDT(reg_idx);
ixgbe_configure_srrctl(adapter, ring);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c
index d4a64e6..cc3101a 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c
@@ -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"
/**
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
index 39217e5..132557c 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
@@ -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);
--
1.8.3.1
next prev parent reply other threads:[~2014-01-03 5:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-03 5:18 [net-next v2 00/11][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
2014-01-03 5:18 ` [net-next v2 01/11] ixbge: Protect ixgbe_down with __IXGBE_DOWN bit Jeff Kirsher
2014-01-03 5:18 ` [net-next v2 02/11] ixgbe: Indicate removal state explicitly Jeff Kirsher
2014-01-03 5:18 ` [net-next v2 03/11] ixgbe: Use static inlines instead of macros Jeff Kirsher
2014-01-03 5:28 ` Joe Perches
2014-01-03 18:31 ` Rustad, Mark D
2014-01-03 5:18 ` [net-next v2 04/11] ixgbe: Make ethtool register test use accessors Jeff Kirsher
2014-01-03 5:18 ` [net-next v2 05/11] ixgbe: Check register reads for adapter removal Jeff Kirsher
2014-01-03 5:18 ` Jeff Kirsher [this message]
2014-01-03 5:18 ` [net-next v2 07/11] ixgbe: Additional adapter removal checks Jeff Kirsher
2014-01-03 5:18 ` [net-next v2 08/11] ixgbe: Add Live Error Recovery configuration option Jeff Kirsher
2014-01-04 1:43 ` David Miller
2014-01-03 5:18 ` [net-next v2 09/11] net: e1000e calls skb_set_hash Jeff Kirsher
2014-01-03 5:18 ` [net-next v2 10/11] net: igb " Jeff Kirsher
2014-01-03 5:18 ` [net-next v2 11/11] igb: make local functions static and remove dead code Jeff Kirsher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1388726310-2996-7-git-send-email-jeffrey.t.kirsher@intel.com \
--to=jeffrey.t.kirsher@intel.com \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=gospo@redhat.com \
--cc=mark.d.rustad@intel.com \
--cc=netdev@vger.kernel.org \
--cc=sassmann@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox