diff options
author | Jesse Brandeburg <jesse.brandeburg@intel.com> | 2015-02-24 00:26:03 -0500 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2015-02-26 07:53:59 -0500 |
commit | a68de58d2791dd9f2b159703b70377011b35a568 (patch) | |
tree | babbcc9ce7bfcb265702fc03ce6a42b0d01f80eb /drivers/net | |
parent | 71da61976ec18fb57b3ba9a1dd846b747cc7c884 (diff) |
i40e: fix race in hang check
The driver was having some issues with false Tx hang detection. This
makes the driver a little more direct with the checks for progress
forward by directly checking the head write back address and tail register
when determining progress. This avoids Tx hangs where the software
gets behind, because we are directly checking hardware state when
determining hang state.
Change-ID: I774f0e861c9e8ab5ccb213634100fe15440ae24a
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Jim Young <james.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ethernet/intel/i40e/i40e_txrx.c | 54 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 54 |
2 files changed, 60 insertions, 48 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c index 0aad61170f75..bbf1b1247ac4 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c +++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c | |||
@@ -586,6 +586,20 @@ void i40e_free_tx_resources(struct i40e_ring *tx_ring) | |||
586 | } | 586 | } |
587 | 587 | ||
588 | /** | 588 | /** |
589 | * i40e_get_head - Retrieve head from head writeback | ||
590 | * @tx_ring: tx ring to fetch head of | ||
591 | * | ||
592 | * Returns value of Tx ring head based on value stored | ||
593 | * in head write-back location | ||
594 | **/ | ||
595 | static inline u32 i40e_get_head(struct i40e_ring *tx_ring) | ||
596 | { | ||
597 | void *head = (struct i40e_tx_desc *)tx_ring->desc + tx_ring->count; | ||
598 | |||
599 | return le32_to_cpu(*(volatile __le32 *)head); | ||
600 | } | ||
601 | |||
602 | /** | ||
589 | * i40e_get_tx_pending - how many tx descriptors not processed | 603 | * i40e_get_tx_pending - how many tx descriptors not processed |
590 | * @tx_ring: the ring of descriptors | 604 | * @tx_ring: the ring of descriptors |
591 | * | 605 | * |
@@ -594,10 +608,16 @@ void i40e_free_tx_resources(struct i40e_ring *tx_ring) | |||
594 | **/ | 608 | **/ |
595 | static u32 i40e_get_tx_pending(struct i40e_ring *ring) | 609 | static u32 i40e_get_tx_pending(struct i40e_ring *ring) |
596 | { | 610 | { |
597 | u32 ntu = ((ring->next_to_clean <= ring->next_to_use) | 611 | u32 head, tail; |
598 | ? ring->next_to_use | 612 | |
599 | : ring->next_to_use + ring->count); | 613 | head = i40e_get_head(ring); |
600 | return ntu - ring->next_to_clean; | 614 | tail = readl(ring->tail); |
615 | |||
616 | if (head != tail) | ||
617 | return (head < tail) ? | ||
618 | tail - head : (tail + ring->count - head); | ||
619 | |||
620 | return 0; | ||
601 | } | 621 | } |
602 | 622 | ||
603 | /** | 623 | /** |
@@ -606,6 +626,8 @@ static u32 i40e_get_tx_pending(struct i40e_ring *ring) | |||
606 | **/ | 626 | **/ |
607 | static bool i40e_check_tx_hang(struct i40e_ring *tx_ring) | 627 | static bool i40e_check_tx_hang(struct i40e_ring *tx_ring) |
608 | { | 628 | { |
629 | u32 tx_done = tx_ring->stats.packets; | ||
630 | u32 tx_done_old = tx_ring->tx_stats.tx_done_old; | ||
609 | u32 tx_pending = i40e_get_tx_pending(tx_ring); | 631 | u32 tx_pending = i40e_get_tx_pending(tx_ring); |
610 | struct i40e_pf *pf = tx_ring->vsi->back; | 632 | struct i40e_pf *pf = tx_ring->vsi->back; |
611 | bool ret = false; | 633 | bool ret = false; |
@@ -623,41 +645,25 @@ static bool i40e_check_tx_hang(struct i40e_ring *tx_ring) | |||
623 | * run the check_tx_hang logic with a transmit completion | 645 | * run the check_tx_hang logic with a transmit completion |
624 | * pending but without time to complete it yet. | 646 | * pending but without time to complete it yet. |
625 | */ | 647 | */ |
626 | if ((tx_ring->tx_stats.tx_done_old == tx_ring->stats.packets) && | 648 | if ((tx_done_old == tx_done) && tx_pending) { |
627 | (tx_pending >= I40E_MIN_DESC_PENDING)) { | ||
628 | /* make sure it is true for two checks in a row */ | 649 | /* make sure it is true for two checks in a row */ |
629 | ret = test_and_set_bit(__I40E_HANG_CHECK_ARMED, | 650 | ret = test_and_set_bit(__I40E_HANG_CHECK_ARMED, |
630 | &tx_ring->state); | 651 | &tx_ring->state); |
631 | } else if ((tx_ring->tx_stats.tx_done_old == tx_ring->stats.packets) && | 652 | } else if (tx_done_old == tx_done && |
632 | (tx_pending < I40E_MIN_DESC_PENDING) && | 653 | (tx_pending < I40E_MIN_DESC_PENDING) && (tx_pending > 0)) { |
633 | (tx_pending > 0)) { | ||
634 | if (I40E_DEBUG_FLOW & pf->hw.debug_mask) | 654 | if (I40E_DEBUG_FLOW & pf->hw.debug_mask) |
635 | dev_info(tx_ring->dev, "HW needs some more descs to do a cacheline flush. tx_pending %d, queue %d", | 655 | dev_info(tx_ring->dev, "HW needs some more descs to do a cacheline flush. tx_pending %d, queue %d", |
636 | tx_pending, tx_ring->queue_index); | 656 | tx_pending, tx_ring->queue_index); |
637 | pf->tx_sluggish_count++; | 657 | pf->tx_sluggish_count++; |
638 | } else { | 658 | } else { |
639 | /* update completed stats and disarm the hang check */ | 659 | /* update completed stats and disarm the hang check */ |
640 | tx_ring->tx_stats.tx_done_old = tx_ring->stats.packets; | 660 | tx_ring->tx_stats.tx_done_old = tx_done; |
641 | clear_bit(__I40E_HANG_CHECK_ARMED, &tx_ring->state); | 661 | clear_bit(__I40E_HANG_CHECK_ARMED, &tx_ring->state); |
642 | } | 662 | } |
643 | 663 | ||
644 | return ret; | 664 | return ret; |
645 | } | 665 | } |
646 | 666 | ||
647 | /** | ||
648 | * i40e_get_head - Retrieve head from head writeback | ||
649 | * @tx_ring: tx ring to fetch head of | ||
650 | * | ||
651 | * Returns value of Tx ring head based on value stored | ||
652 | * in head write-back location | ||
653 | **/ | ||
654 | static inline u32 i40e_get_head(struct i40e_ring *tx_ring) | ||
655 | { | ||
656 | void *head = (struct i40e_tx_desc *)tx_ring->desc + tx_ring->count; | ||
657 | |||
658 | return le32_to_cpu(*(volatile __le32 *)head); | ||
659 | } | ||
660 | |||
661 | #define WB_STRIDE 0x3 | 667 | #define WB_STRIDE 0x3 |
662 | 668 | ||
663 | /** | 669 | /** |
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c index 1320a433b8ed..be05829ba619 100644 --- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c +++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c | |||
@@ -126,6 +126,20 @@ void i40evf_free_tx_resources(struct i40e_ring *tx_ring) | |||
126 | } | 126 | } |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * i40e_get_head - Retrieve head from head writeback | ||
130 | * @tx_ring: tx ring to fetch head of | ||
131 | * | ||
132 | * Returns value of Tx ring head based on value stored | ||
133 | * in head write-back location | ||
134 | **/ | ||
135 | static inline u32 i40e_get_head(struct i40e_ring *tx_ring) | ||
136 | { | ||
137 | void *head = (struct i40e_tx_desc *)tx_ring->desc + tx_ring->count; | ||
138 | |||
139 | return le32_to_cpu(*(volatile __le32 *)head); | ||
140 | } | ||
141 | |||
142 | /** | ||
129 | * i40e_get_tx_pending - how many tx descriptors not processed | 143 | * i40e_get_tx_pending - how many tx descriptors not processed |
130 | * @tx_ring: the ring of descriptors | 144 | * @tx_ring: the ring of descriptors |
131 | * | 145 | * |
@@ -134,10 +148,16 @@ void i40evf_free_tx_resources(struct i40e_ring *tx_ring) | |||
134 | **/ | 148 | **/ |
135 | static u32 i40e_get_tx_pending(struct i40e_ring *ring) | 149 | static u32 i40e_get_tx_pending(struct i40e_ring *ring) |
136 | { | 150 | { |
137 | u32 ntu = ((ring->next_to_clean <= ring->next_to_use) | 151 | u32 head, tail; |
138 | ? ring->next_to_use | 152 | |
139 | : ring->next_to_use + ring->count); | 153 | head = i40e_get_head(ring); |
140 | return ntu - ring->next_to_clean; | 154 | tail = readl(ring->tail); |
155 | |||
156 | if (head != tail) | ||
157 | return (head < tail) ? | ||
158 | tail - head : (tail + ring->count - head); | ||
159 | |||
160 | return 0; | ||
141 | } | 161 | } |
142 | 162 | ||
143 | /** | 163 | /** |
@@ -146,6 +166,8 @@ static u32 i40e_get_tx_pending(struct i40e_ring *ring) | |||
146 | **/ | 166 | **/ |
147 | static bool i40e_check_tx_hang(struct i40e_ring *tx_ring) | 167 | static bool i40e_check_tx_hang(struct i40e_ring *tx_ring) |
148 | { | 168 | { |
169 | u32 tx_done = tx_ring->stats.packets; | ||
170 | u32 tx_done_old = tx_ring->tx_stats.tx_done_old; | ||
149 | u32 tx_pending = i40e_get_tx_pending(tx_ring); | 171 | u32 tx_pending = i40e_get_tx_pending(tx_ring); |
150 | bool ret = false; | 172 | bool ret = false; |
151 | 173 | ||
@@ -162,36 +184,20 @@ static bool i40e_check_tx_hang(struct i40e_ring *tx_ring) | |||
162 | * run the check_tx_hang logic with a transmit completion | 184 | * run the check_tx_hang logic with a transmit completion |
163 | * pending but without time to complete it yet. | 185 | * pending but without time to complete it yet. |
164 | */ | 186 | */ |
165 | if ((tx_ring->tx_stats.tx_done_old == tx_ring->stats.packets) && | 187 | if ((tx_done_old == tx_done) && tx_pending) { |
166 | (tx_pending >= I40E_MIN_DESC_PENDING)) { | ||
167 | /* make sure it is true for two checks in a row */ | 188 | /* make sure it is true for two checks in a row */ |
168 | ret = test_and_set_bit(__I40E_HANG_CHECK_ARMED, | 189 | ret = test_and_set_bit(__I40E_HANG_CHECK_ARMED, |
169 | &tx_ring->state); | 190 | &tx_ring->state); |
170 | } else if (!(tx_ring->tx_stats.tx_done_old == tx_ring->stats.packets) || | 191 | } else if (tx_done_old == tx_done && |
171 | !(tx_pending < I40E_MIN_DESC_PENDING) || | 192 | (tx_pending < I40E_MIN_DESC_PENDING) && (tx_pending > 0)) { |
172 | !(tx_pending > 0)) { | ||
173 | /* update completed stats and disarm the hang check */ | 193 | /* update completed stats and disarm the hang check */ |
174 | tx_ring->tx_stats.tx_done_old = tx_ring->stats.packets; | 194 | tx_ring->tx_stats.tx_done_old = tx_done; |
175 | clear_bit(__I40E_HANG_CHECK_ARMED, &tx_ring->state); | 195 | clear_bit(__I40E_HANG_CHECK_ARMED, &tx_ring->state); |
176 | } | 196 | } |
177 | 197 | ||
178 | return ret; | 198 | return ret; |
179 | } | 199 | } |
180 | 200 | ||
181 | /** | ||
182 | * i40e_get_head - Retrieve head from head writeback | ||
183 | * @tx_ring: tx ring to fetch head of | ||
184 | * | ||
185 | * Returns value of Tx ring head based on value stored | ||
186 | * in head write-back location | ||
187 | **/ | ||
188 | static inline u32 i40e_get_head(struct i40e_ring *tx_ring) | ||
189 | { | ||
190 | void *head = (struct i40e_tx_desc *)tx_ring->desc + tx_ring->count; | ||
191 | |||
192 | return le32_to_cpu(*(volatile __le32 *)head); | ||
193 | } | ||
194 | |||
195 | #define WB_STRIDE 0x3 | 201 | #define WB_STRIDE 0x3 |
196 | 202 | ||
197 | /** | 203 | /** |