Commit 4a6ff3e2 authored by Igor Russkikh's avatar Igor Russkikh Committed by Greg Kroah-Hartman

net: aquantia: tx clean budget logic error

[ Upstream commit 31bafc49 ]

In case no other traffic happening on the ring, full tx cleanup
may not be completed. That may cause socket buffer to overflow
and tx traffic to stuck until next activity on the ring happens.

This is due to logic error in budget variable decrementor.
Variable is compared with zero, and then post decremented,
causing it to become MAX_INT. Solution is remove decrementor
from the `for` statement and rewrite it in a clear way.

Fixes: b647d398 ("net: aquantia: Add tx clean budget and valid budget handling logic")
Signed-off-by: default avatarIgor Russkikh <igor.russkikh@aquantia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 7251bb77
...@@ -139,10 +139,10 @@ void aq_ring_queue_stop(struct aq_ring_s *ring) ...@@ -139,10 +139,10 @@ void aq_ring_queue_stop(struct aq_ring_s *ring)
bool aq_ring_tx_clean(struct aq_ring_s *self) bool aq_ring_tx_clean(struct aq_ring_s *self)
{ {
struct device *dev = aq_nic_get_dev(self->aq_nic); struct device *dev = aq_nic_get_dev(self->aq_nic);
unsigned int budget = AQ_CFG_TX_CLEAN_BUDGET; unsigned int budget;
for (; self->sw_head != self->hw_head && budget--; for (budget = AQ_CFG_TX_CLEAN_BUDGET;
self->sw_head = aq_ring_next_dx(self, self->sw_head)) { budget && self->sw_head != self->hw_head; budget--) {
struct aq_ring_buff_s *buff = &self->buff_ring[self->sw_head]; struct aq_ring_buff_s *buff = &self->buff_ring[self->sw_head];
if (likely(buff->is_mapped)) { if (likely(buff->is_mapped)) {
...@@ -167,6 +167,7 @@ bool aq_ring_tx_clean(struct aq_ring_s *self) ...@@ -167,6 +167,7 @@ bool aq_ring_tx_clean(struct aq_ring_s *self)
buff->pa = 0U; buff->pa = 0U;
buff->eop_index = 0xffffU; buff->eop_index = 0xffffU;
self->sw_head = aq_ring_next_dx(self, self->sw_head);
} }
return !!budget; return !!budget;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment