net: stmmac: fix completely hung TX when using TSO
Subsystems (4)
PATCH 1/1 net: stmmac: fix completely hung TX when using TSO
stmmac_tso_allocator can fail to set the Last Descriptor bit on a descriptor that actually was the last descriptor.
This happens when the buffer of the last descriptor ends up having a size of exactly TSO_MAX_BUFF_SIZE.
When the IP eventually reaches the next last descriptor, which actually has the bit set, the DMA will hang.
When the DMA hangs, we get a tx timeout, however, since stmmac does not do a complete reset of the IP in stmmac_tx_timeout, we end up in a state with completely hung TX.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -1
@@ -2723,7 +2723,7 @@ static void stmmac_tso_allocator(struct stmmac_priv *priv, unsigned int des, priv->hw->desc->prepare_tso_tx_desc (desc,0 , buff_size,0 ,1 , - (last_segment) && (buff_size <TSO_MAX_BUFF_SIZE ), + (last_segment) && (tmp_len <=TSO_MAX_BUFF_SIZE ),0 ,0 ); tmp_len -=TSO_MAX_BUFF_SIZE ;
Signature · 1 line
2.11.0
Hi Niklas
I get the point and I acked the patch but Alex, please, can you confirm that this issue has never seen on your boxes where the TSO has been fully tested? The initial development (commit f748be531) introduces the following:
(last_segment) && (buff_size < TSO_MAX_BUFF_SIZE),
...
Quoted 9 lines · Niklas Cassel
stmmac_tso_allocatorcan fail to set the Last Descriptor bit on a descriptor that actually was the last descriptor.This happens when the buffer of the last descriptor ends up having a size of exactly
TSO_MAX_BUFF_SIZE.When the IP eventually reaches the next last descriptor, which actually has the bit set, the DMA will hang.
Quoted 6 lines
When the DMA hangs, we get a tx timeout, however, since stmmac does not do a complete reset of the IP in
stmmac_tx_timeout, we end up in a state with completely hung TX.Signed-off-by Niklas Cassel <[email protected]>
Quoted 9 lines
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static void stmmac_tso_allocator(struct stmmac_priv *priv, unsigned int des, · line 2729
Quoted 8 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -2723,7 +2723,7 @@ static void stmmac_tso_allocator(struct stmmac_priv *priv, unsigned int des, priv->hw->desc->prepare_tso_tx_desc (desc,0 , buff_size,0 ,1 , - (last_segment) && (buff_size <TSO_MAX_BUFF_SIZE ), + (last_segment) && (tmp_len <=TSO_MAX_BUFF_SIZE ),0 ,0 ); tmp_len -=TSO_MAX_BUFF_SIZE ;
Regards
Peppe
Alexandre Torgue
Acked-byHi Guys,
Quoted 7 lines · Giuseppe CAVALLARO
Hi Niklas
I get the point and I acked the patch but Alex, please, can you confirm that this issue has never seen on your boxes where the TSO has been fully tested? The initial development (commit
f748be531) introduces the following:(last_segment) && (buff_size < TSO_MAX_BUFF_SIZE),
I don't remember to have seen this kind of issue in the past but for sure I agree with this patch.
Quoted 43 lines
...
Quoted 9 lines · Niklas Cassel
stmmac_tso_allocatorcan fail to set the Last Descriptor bit on a descriptor that actually was the last descriptor.This happens when the buffer of the last descriptor ends up having a size of exactly
TSO_MAX_BUFF_SIZE.When the IP eventually reaches the next last descriptor, which actually has the bit set, the DMA will hang.
Quoted 6 lines
When the DMA hangs, we get a tx timeout, however, since stmmac does not do a complete reset of the IP in
stmmac_tx_timeout, we end up in a state with completely hung TX.Signed-off-by Niklas Cassel <[email protected]>Quoted 10 lines
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static void stmmac_tso_allocator(struct · line 2728
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -2723,7 +2723,7 @@ static void stmmac_tso_allocator(struct stmmac_priv *priv, unsigned int des, priv->hw->desc->prepare_tso_tx_desc(desc, 0, buff_size, 0, 1, - (last_segment) && (buff_size < TSO_MAX_BUFF_SIZE), + (last_segment) && (tmp_len <= TSO_MAX_BUFF_SIZE), 0, 0); tmp_len -=TSO_MAX_BUFF_SIZE ;Regards
Peppe
Quoted 1 line · Giuseppe CAVALLARO
Hi Niklas
Hello Peppe, Alex
Quoted 7 lines
I get the point and I acked the patch but Alex, please, can you confirm that this issue has never seen on your boxes where the TSO has been fully tested? The initial development (commit
f748be531) introduces the following:(last_segment) && (buff_size < TSO_MAX_BUFF_SIZE),...
Since you need a packet where the txbuff size of last descriptor has the exact size of 16K-1, depending on your workload, it is possible to run your system for a very long time without triggering the bug.
We noticed the problem since a test in our test suite fetches the syslog. The syslog usually has a size that is not constant, and the size usually increases with time.
During some of the test runs, far from all of them, we would eventually end up with a packet of the exact size that triggers the bug.
It should be possible to trigger the bug more easily if you know what buffer size to write to your TCP socket, together with some manual TCP corking.
Regards,
Niklas
Quoted 40 lines · Niklas Cassel
Quoted 9 lines
stmmac_tso_allocatorcan fail to set the Last Descriptor bit on a descriptor that actually was the last descriptor.This happens when the buffer of the last descriptor ends up having a size of exactly
TSO_MAX_BUFF_SIZE.When the IP eventually reaches the next last descriptor, which actually has the bit set, the DMA will hang.
Quoted 6 lines
When the DMA hangs, we get a tx timeout, however, since stmmac does not do a complete reset of the IP in
stmmac_tx_timeout, we end up in a state with completely hung TX.Signed-off-by Niklas Cassel <[email protected]>Quoted 9 lines
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0
-0drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static void stmmac_tso_allocator(struct stmmac_priv *priv, unsigned int des, · line 2727
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -2723,7 +2723,7 @@ static void stmmac_tso_allocator(struct stmmac_priv *priv, unsigned int des, priv->hw->desc->prepare_tso_tx_desc (desc,0 , buff_size,0 ,1 , - (last_segment) && (buff_size <TSO_MAX_BUFF_SIZE ), + (last_segment) && (tmp_len <=TSO_MAX_BUFF_SIZE ),0 ,0 ); tmp_len -=TSO_MAX_BUFF_SIZE ;Regards
Peppe
Quoted 9 lines · Niklas Cassel
stmmac_tso_allocatorcan fail to set the Last Descriptor bit on a descriptor that actually was the last descriptor.This happens when the buffer of the last descriptor ends up having a size of exactly
TSO_MAX_BUFF_SIZE.When the IP eventually reaches the next last descriptor, which actually has the bit set, the DMA will hang.
Quoted 6 lines
When the DMA hangs, we get a tx timeout, however, since stmmac does not do a complete reset of the IP in
stmmac_tx_timeout, we end up in a state with completely hung TX.Signed-off-by Niklas Cassel <[email protected]>
This should have:
right?
Quoted 18 lines
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -2723,7 +2723,7 @@ static void stmmac_tso_allocator(struct stmmac_priv *priv, unsigned int des, priv->hw->desc->prepare_tso_tx_desc (desc,0 , buff_size,0 ,1 , - (last_segment) && (buff_size <TSO_MAX_BUFF_SIZE ), + (last_segment) && (tmp_len <=TSO_MAX_BUFF_SIZE ),0 ,0 ); tmp_len -=TSO_MAX_BUFF_SIZE ;
Signature · 1 line
Florian
David Miller
maintainerFrom: Niklas Cassel <[email protected]>
Date: Tue, 6 Jun 2017 09:25:00 +0200
Quoted 9 lines
stmmac_tso_allocatorcan fail to set the Last Descriptor bit on a descriptor that actually was the last descriptor.This happens when the buffer of the last descriptor ends up having a size of exactly
TSO_MAX_BUFF_SIZE.When the IP eventually reaches the next last descriptor, which actually has the bit set, the DMA will hang.
Quoted 6 lines
When the DMA hangs, we get a tx timeout, however, since stmmac does not do a complete reset of the IP in
stmmac_tx_timeout, we end up in a state with completely hung TX.Signed-off-by Niklas Cassel <[email protected]>
Applied and queued up for -stable, thank you.