diff options
author | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2010-08-08 12:02:31 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-08-08 23:02:45 -0400 |
commit | 2d0bb1c1f4524befe9f0fcf0d0cd3081a451223f (patch) | |
tree | 16abb34e4f852ac6c4101ef9e46940c3bcd5937f | |
parent | 4bc091d85f979a1a18ef2d710b819b3c5b397707 (diff) |
e100/e1000*/igb*/ixgb*: Add missing read memory barrier
Based on patches from Sonny Rao and Milton Miller...
Combined the patches to fix up clean_tx_irq and clean_rx_irq.
The PowerPC architecture does not require loads to independent bytes
to be ordered without adding an explicit barrier.
In ixgbe_clean_rx_irq we load the status bit then load the packet data.
With packet split disabled if these loads go out of order we get a
stale packet, but we will notice the bad sequence numbers and drop it.
The problem occurs with packet split enabled where the TCP/IP header
and data are in different descriptors. If the reads go out of order
we may have data that doesn't match the TCP/IP header. Since we use
hardware checksumming this bad data is never verified and it makes it
all the way to the application.
This bug was found during stress testing and adding this barrier has
been shown to fix it. The bug can manifest as a data integrity issue
(bad payload data) or as a BUG in skb_pull().
This was a nasty bug to hunt down, if people agree with the fix I think
it's a candidate for stable.
Previously Submitted to e1000-devel only for ixgbe
http://marc.info/?l=e1000-devel&m=126593062701537&w=3
We've now seen this problem hit with other device drivers (e1000e mostly)
So I'm resubmitting with fixes for other Intel Device Drivers with
similar issues.
CC: Milton Miller <miltonm@bga.com>
CC: Anton Blanchard <anton@samba.org>
CC: Sonny Rao <sonnyrao@us.ibm.com>
CC: stable <stable@kernel.org>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/e100.c | 2 | ||||
-rw-r--r-- | drivers/net/e1000/e1000_main.c | 3 | ||||
-rw-r--r-- | drivers/net/e1000e/netdev.c | 4 | ||||
-rw-r--r-- | drivers/net/igb/igb_main.c | 2 | ||||
-rw-r--r-- | drivers/net/igbvf/netdev.c | 2 | ||||
-rw-r--r-- | drivers/net/ixgb/ixgb_main.c | 2 | ||||
-rw-r--r-- | drivers/net/ixgbe/ixgbe_main.c | 1 | ||||
-rw-r--r-- | drivers/net/ixgbevf/ixgbevf_main.c | 2 |
8 files changed, 18 insertions, 0 deletions
diff --git a/drivers/net/e100.c b/drivers/net/e100.c index b194bad29ace..8e2eab4e7c75 100644 --- a/drivers/net/e100.c +++ b/drivers/net/e100.c | |||
@@ -1779,6 +1779,7 @@ static int e100_tx_clean(struct nic *nic) | |||
1779 | for (cb = nic->cb_to_clean; | 1779 | for (cb = nic->cb_to_clean; |
1780 | cb->status & cpu_to_le16(cb_complete); | 1780 | cb->status & cpu_to_le16(cb_complete); |
1781 | cb = nic->cb_to_clean = cb->next) { | 1781 | cb = nic->cb_to_clean = cb->next) { |
1782 | rmb(); /* read skb after status */ | ||
1782 | netif_printk(nic, tx_done, KERN_DEBUG, nic->netdev, | 1783 | netif_printk(nic, tx_done, KERN_DEBUG, nic->netdev, |
1783 | "cb[%d]->status = 0x%04X\n", | 1784 | "cb[%d]->status = 0x%04X\n", |
1784 | (int)(((void*)cb - (void*)nic->cbs)/sizeof(struct cb)), | 1785 | (int)(((void*)cb - (void*)nic->cbs)/sizeof(struct cb)), |
@@ -1927,6 +1928,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx, | |||
1927 | 1928 | ||
1928 | netif_printk(nic, rx_status, KERN_DEBUG, nic->netdev, | 1929 | netif_printk(nic, rx_status, KERN_DEBUG, nic->netdev, |
1929 | "status=0x%04X\n", rfd_status); | 1930 | "status=0x%04X\n", rfd_status); |
1931 | rmb(); /* read size after status bit */ | ||
1930 | 1932 | ||
1931 | /* If data isn't ready, nothing to indicate */ | 1933 | /* If data isn't ready, nothing to indicate */ |
1932 | if (unlikely(!(rfd_status & cb_complete))) { | 1934 | if (unlikely(!(rfd_status & cb_complete))) { |
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c index 02833af8a0b1..5cc39ed289c6 100644 --- a/drivers/net/e1000/e1000_main.c +++ b/drivers/net/e1000/e1000_main.c | |||
@@ -3454,6 +3454,7 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter, | |||
3454 | while ((eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) && | 3454 | while ((eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) && |
3455 | (count < tx_ring->count)) { | 3455 | (count < tx_ring->count)) { |
3456 | bool cleaned = false; | 3456 | bool cleaned = false; |
3457 | rmb(); /* read buffer_info after eop_desc */ | ||
3457 | for ( ; !cleaned; count++) { | 3458 | for ( ; !cleaned; count++) { |
3458 | tx_desc = E1000_TX_DESC(*tx_ring, i); | 3459 | tx_desc = E1000_TX_DESC(*tx_ring, i); |
3459 | buffer_info = &tx_ring->buffer_info[i]; | 3460 | buffer_info = &tx_ring->buffer_info[i]; |
@@ -3643,6 +3644,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, | |||
3643 | if (*work_done >= work_to_do) | 3644 | if (*work_done >= work_to_do) |
3644 | break; | 3645 | break; |
3645 | (*work_done)++; | 3646 | (*work_done)++; |
3647 | rmb(); /* read descriptor and rx_buffer_info after status DD */ | ||
3646 | 3648 | ||
3647 | status = rx_desc->status; | 3649 | status = rx_desc->status; |
3648 | skb = buffer_info->skb; | 3650 | skb = buffer_info->skb; |
@@ -3849,6 +3851,7 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, | |||
3849 | if (*work_done >= work_to_do) | 3851 | if (*work_done >= work_to_do) |
3850 | break; | 3852 | break; |
3851 | (*work_done)++; | 3853 | (*work_done)++; |
3854 | rmb(); /* read descriptor and rx_buffer_info after status DD */ | ||
3852 | 3855 | ||
3853 | status = rx_desc->status; | 3856 | status = rx_desc->status; |
3854 | skb = buffer_info->skb; | 3857 | skb = buffer_info->skb; |
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c index 36d31a416320..c3dd590d87b2 100644 --- a/drivers/net/e1000e/netdev.c +++ b/drivers/net/e1000e/netdev.c | |||
@@ -781,6 +781,7 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, | |||
781 | if (*work_done >= work_to_do) | 781 | if (*work_done >= work_to_do) |
782 | break; | 782 | break; |
783 | (*work_done)++; | 783 | (*work_done)++; |
784 | rmb(); /* read descriptor and rx_buffer_info after status DD */ | ||
784 | 785 | ||
785 | status = rx_desc->status; | 786 | status = rx_desc->status; |
786 | skb = buffer_info->skb; | 787 | skb = buffer_info->skb; |
@@ -991,6 +992,7 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter) | |||
991 | while ((eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) && | 992 | while ((eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) && |
992 | (count < tx_ring->count)) { | 993 | (count < tx_ring->count)) { |
993 | bool cleaned = false; | 994 | bool cleaned = false; |
995 | rmb(); /* read buffer_info after eop_desc */ | ||
994 | for (; !cleaned; count++) { | 996 | for (; !cleaned; count++) { |
995 | tx_desc = E1000_TX_DESC(*tx_ring, i); | 997 | tx_desc = E1000_TX_DESC(*tx_ring, i); |
996 | buffer_info = &tx_ring->buffer_info[i]; | 998 | buffer_info = &tx_ring->buffer_info[i]; |
@@ -1087,6 +1089,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, | |||
1087 | break; | 1089 | break; |
1088 | (*work_done)++; | 1090 | (*work_done)++; |
1089 | skb = buffer_info->skb; | 1091 | skb = buffer_info->skb; |
1092 | rmb(); /* read descriptor and rx_buffer_info after status DD */ | ||
1090 | 1093 | ||
1091 | /* in the packet split case this is header only */ | 1094 | /* in the packet split case this is header only */ |
1092 | prefetch(skb->data - NET_IP_ALIGN); | 1095 | prefetch(skb->data - NET_IP_ALIGN); |
@@ -1286,6 +1289,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, | |||
1286 | if (*work_done >= work_to_do) | 1289 | if (*work_done >= work_to_do) |
1287 | break; | 1290 | break; |
1288 | (*work_done)++; | 1291 | (*work_done)++; |
1292 | rmb(); /* read descriptor and rx_buffer_info after status DD */ | ||
1289 | 1293 | ||
1290 | status = rx_desc->status; | 1294 | status = rx_desc->status; |
1291 | skb = buffer_info->skb; | 1295 | skb = buffer_info->skb; |
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index df5dcd23e4fc..9b4e5895f5f9 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c | |||
@@ -5353,6 +5353,7 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector) | |||
5353 | 5353 | ||
5354 | while ((eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD)) && | 5354 | while ((eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD)) && |
5355 | (count < tx_ring->count)) { | 5355 | (count < tx_ring->count)) { |
5356 | rmb(); /* read buffer_info after eop_desc status */ | ||
5356 | for (cleaned = false; !cleaned; count++) { | 5357 | for (cleaned = false; !cleaned; count++) { |
5357 | tx_desc = E1000_TX_DESC_ADV(*tx_ring, i); | 5358 | tx_desc = E1000_TX_DESC_ADV(*tx_ring, i); |
5358 | buffer_info = &tx_ring->buffer_info[i]; | 5359 | buffer_info = &tx_ring->buffer_info[i]; |
@@ -5558,6 +5559,7 @@ static bool igb_clean_rx_irq_adv(struct igb_q_vector *q_vector, | |||
5558 | if (*work_done >= budget) | 5559 | if (*work_done >= budget) |
5559 | break; | 5560 | break; |
5560 | (*work_done)++; | 5561 | (*work_done)++; |
5562 | rmb(); /* read descriptor and rx_buffer_info after status DD */ | ||
5561 | 5563 | ||
5562 | skb = buffer_info->skb; | 5564 | skb = buffer_info->skb; |
5563 | prefetch(skb->data - NET_IP_ALIGN); | 5565 | prefetch(skb->data - NET_IP_ALIGN); |
diff --git a/drivers/net/igbvf/netdev.c b/drivers/net/igbvf/netdev.c index ec808fa8dc21..c539f7c9c3e0 100644 --- a/drivers/net/igbvf/netdev.c +++ b/drivers/net/igbvf/netdev.c | |||
@@ -248,6 +248,7 @@ static bool igbvf_clean_rx_irq(struct igbvf_adapter *adapter, | |||
248 | if (*work_done >= work_to_do) | 248 | if (*work_done >= work_to_do) |
249 | break; | 249 | break; |
250 | (*work_done)++; | 250 | (*work_done)++; |
251 | rmb(); /* read descriptor and rx_buffer_info after status DD */ | ||
251 | 252 | ||
252 | buffer_info = &rx_ring->buffer_info[i]; | 253 | buffer_info = &rx_ring->buffer_info[i]; |
253 | 254 | ||
@@ -780,6 +781,7 @@ static bool igbvf_clean_tx_irq(struct igbvf_ring *tx_ring) | |||
780 | 781 | ||
781 | while ((eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD)) && | 782 | while ((eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD)) && |
782 | (count < tx_ring->count)) { | 783 | (count < tx_ring->count)) { |
784 | rmb(); /* read buffer_info after eop_desc status */ | ||
783 | for (cleaned = false; !cleaned; count++) { | 785 | for (cleaned = false; !cleaned; count++) { |
784 | tx_desc = IGBVF_TX_DESC_ADV(*tx_ring, i); | 786 | tx_desc = IGBVF_TX_DESC_ADV(*tx_ring, i); |
785 | buffer_info = &tx_ring->buffer_info[i]; | 787 | buffer_info = &tx_ring->buffer_info[i]; |
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c index c6b75c83100c..45fc89b9ba64 100644 --- a/drivers/net/ixgb/ixgb_main.c +++ b/drivers/net/ixgb/ixgb_main.c | |||
@@ -1816,6 +1816,7 @@ ixgb_clean_tx_irq(struct ixgb_adapter *adapter) | |||
1816 | 1816 | ||
1817 | while (eop_desc->status & IXGB_TX_DESC_STATUS_DD) { | 1817 | while (eop_desc->status & IXGB_TX_DESC_STATUS_DD) { |
1818 | 1818 | ||
1819 | rmb(); /* read buffer_info after eop_desc */ | ||
1819 | for (cleaned = false; !cleaned; ) { | 1820 | for (cleaned = false; !cleaned; ) { |
1820 | tx_desc = IXGB_TX_DESC(*tx_ring, i); | 1821 | tx_desc = IXGB_TX_DESC(*tx_ring, i); |
1821 | buffer_info = &tx_ring->buffer_info[i]; | 1822 | buffer_info = &tx_ring->buffer_info[i]; |
@@ -1976,6 +1977,7 @@ ixgb_clean_rx_irq(struct ixgb_adapter *adapter, int *work_done, int work_to_do) | |||
1976 | break; | 1977 | break; |
1977 | 1978 | ||
1978 | (*work_done)++; | 1979 | (*work_done)++; |
1980 | rmb(); /* read descriptor and rx_buffer_info after status DD */ | ||
1979 | status = rx_desc->status; | 1981 | status = rx_desc->status; |
1980 | skb = buffer_info->skb; | 1982 | skb = buffer_info->skb; |
1981 | buffer_info->skb = NULL; | 1983 | buffer_info->skb = NULL; |
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c index 55394a2d3a8f..e32af434cc9d 100644 --- a/drivers/net/ixgbe/ixgbe_main.c +++ b/drivers/net/ixgbe/ixgbe_main.c | |||
@@ -748,6 +748,7 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, | |||
748 | while ((eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD)) && | 748 | while ((eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD)) && |
749 | (count < tx_ring->work_limit)) { | 749 | (count < tx_ring->work_limit)) { |
750 | bool cleaned = false; | 750 | bool cleaned = false; |
751 | rmb(); /* read buffer_info after eop_desc */ | ||
751 | for ( ; !cleaned; count++) { | 752 | for ( ; !cleaned; count++) { |
752 | struct sk_buff *skb; | 753 | struct sk_buff *skb; |
753 | tx_desc = IXGBE_TX_DESC_ADV(*tx_ring, i); | 754 | tx_desc = IXGBE_TX_DESC_ADV(*tx_ring, i); |
diff --git a/drivers/net/ixgbevf/ixgbevf_main.c b/drivers/net/ixgbevf/ixgbevf_main.c index 3e291ccc629d..918c00359b0a 100644 --- a/drivers/net/ixgbevf/ixgbevf_main.c +++ b/drivers/net/ixgbevf/ixgbevf_main.c | |||
@@ -231,6 +231,7 @@ static bool ixgbevf_clean_tx_irq(struct ixgbevf_adapter *adapter, | |||
231 | while ((eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD)) && | 231 | while ((eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD)) && |
232 | (count < tx_ring->work_limit)) { | 232 | (count < tx_ring->work_limit)) { |
233 | bool cleaned = false; | 233 | bool cleaned = false; |
234 | rmb(); /* read buffer_info after eop_desc */ | ||
234 | for ( ; !cleaned; count++) { | 235 | for ( ; !cleaned; count++) { |
235 | struct sk_buff *skb; | 236 | struct sk_buff *skb; |
236 | tx_desc = IXGBE_TX_DESC_ADV(*tx_ring, i); | 237 | tx_desc = IXGBE_TX_DESC_ADV(*tx_ring, i); |
@@ -518,6 +519,7 @@ static bool ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector, | |||
518 | break; | 519 | break; |
519 | (*work_done)++; | 520 | (*work_done)++; |
520 | 521 | ||
522 | rmb(); /* read descriptor and rx_buffer_info after status DD */ | ||
521 | if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) { | 523 | if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) { |
522 | hdr_info = le16_to_cpu(ixgbevf_get_hdr_info(rx_desc)); | 524 | hdr_info = le16_to_cpu(ixgbevf_get_hdr_info(rx_desc)); |
523 | len = (hdr_info & IXGBE_RXDADV_HDRBUFLEN_MASK) >> | 525 | len = (hdr_info & IXGBE_RXDADV_HDRBUFLEN_MASK) >> |