Skip to content

Commit 0d63785

Browse files
simonguinotdavem330
authored andcommitted
net: mvneta: fix handling of the Tx descriptor counter
The mvneta controller provides a 8-bit register to update the pending Tx descriptor counter. Then, a maximum of 255 Tx descriptors can be added at once. In the current code the mvneta_txq_pend_desc_add function assumes the caller takes care of this limit. But it is not the case. In some situations (xmit_more flag), more than 255 descriptors are added. When this happens, the Tx descriptor counter register is updated with a wrong value, which breaks the whole Tx queue management. This patch fixes the issue by allowing the mvneta_txq_pend_desc_add function to process more than 255 Tx descriptors. Fixes: 2a90f7e ("net: mvneta: add xmit_more support") Cc: [email protected] # 4.11+ Signed-off-by: Simon Guinot <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 096d1dd commit 0d63785

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

drivers/net/ethernet/marvell/mvneta.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -816,11 +816,14 @@ static void mvneta_txq_pend_desc_add(struct mvneta_port *pp,
816816
{
817817
u32 val;
818818

819-
/* Only 255 descriptors can be added at once ; Assume caller
820-
* process TX desriptors in quanta less than 256
821-
*/
822-
val = pend_desc + txq->pending;
823-
mvreg_write(pp, MVNETA_TXQ_UPDATE_REG(txq->id), val);
819+
pend_desc += txq->pending;
820+
821+
/* Only 255 Tx descriptors can be added at once */
822+
do {
823+
val = min(pend_desc, 255);
824+
mvreg_write(pp, MVNETA_TXQ_UPDATE_REG(txq->id), val);
825+
pend_desc -= val;
826+
} while (pend_desc > 0);
824827
txq->pending = 0;
825828
}
826829

0 commit comments

Comments
 (0)