Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d63785c authored by Simon Guinot's avatar Simon Guinot Committed by David S. Miller
Browse files

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: 2a90f7e1 ("net: mvneta: add xmit_more support")
Cc: stable@vger.kernel.org # 4.11+
Signed-off-by: default avatarSimon Guinot <simon.guinot@sequanux.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 096d1dd0
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -816,11 +816,14 @@ static void mvneta_txq_pend_desc_add(struct mvneta_port *pp,
{
{
	u32 val;
	u32 val;


	/* Only 255 descriptors can be added at once ; Assume caller
	pend_desc += txq->pending;
	 * process TX desriptors in quanta less than 256

	 */
	/* Only 255 Tx descriptors can be added at once */
	val = pend_desc + txq->pending;
	do {
		val = min(pend_desc, 255);
		mvreg_write(pp, MVNETA_TXQ_UPDATE_REG(txq->id), val);
		mvreg_write(pp, MVNETA_TXQ_UPDATE_REG(txq->id), val);
		pend_desc -= val;
	} while (pend_desc > 0);
	txq->pending = 0;
	txq->pending = 0;
}
}