From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Guinot Subject: Re: [PATCH] net: mvneta: fix handling of the Tx descriptor counter Date: Wed, 8 Nov 2017 18:17:35 +0100 Message-ID: <20171108171735.GI18407@kw.sim.vm.gnt> References: <20171108165835.13453-1-simon.guinot@sequanux.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="vkEkAx9hr54EJ73W" Cc: netdev@vger.kernel.org, Thomas Petazzoni , =?utf-8?Q?Gr=C3=A9gory?= Clement , Antoine =?utf-8?Q?T=C3=A9nart?= , Marcin Wojtas , stable@vger.kernel.org To: Sven =?utf-8?Q?M=C3=BCller?= , Andreas Tobler Return-path: Content-Disposition: inline In-Reply-To: <20171108165835.13453-1-simon.guinot@sequanux.org> Sender: stable-owner@vger.kernel.org List-Id: netdev.vger.kernel.org --vkEkAx9hr54EJ73W Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Sven and Andreas, Please, can you try with this patch ? Thanks. Simon On Wed, Nov 08, 2017 at 05:58:35PM +0100, Simon Guinot wrote: > 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. >=20 > This patch fixes the issue by allowing the mvneta_txq_pend_desc_add > function to process more than 255 Tx descriptors. >=20 > Fixes: 2a90f7e1d5d0 ("net: mvneta: add xmit_more support") > Cc: stable@vger.kernel.org # 4.11+ > Signed-off-by: Simon Guinot > --- > drivers/net/ethernet/marvell/mvneta.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) >=20 > diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet= /marvell/mvneta.c > index 64a04975bcf8..027c08ce4e5d 100644 > --- a/drivers/net/ethernet/marvell/mvneta.c > +++ b/drivers/net/ethernet/marvell/mvneta.c > @@ -816,11 +816,14 @@ static void mvneta_txq_pend_desc_add(struct mvneta_= port *pp, > { > u32 val; > =20 > - /* Only 255 descriptors can be added at once ; Assume caller > - * process TX desriptors in quanta less than 256 > - */ > - val =3D pend_desc + txq->pending; > - mvreg_write(pp, MVNETA_TXQ_UPDATE_REG(txq->id), val); > + pend_desc +=3D txq->pending; > + > + /* Only 255 Tx descriptors can be added at once */ > + while (pend_desc > 0) { > + val =3D min(pend_desc, 255); > + mvreg_write(pp, MVNETA_TXQ_UPDATE_REG(txq->id), val); > + pend_desc -=3D val; > + } > txq->pending =3D 0; > } > =20 > @@ -2413,8 +2416,7 @@ static int mvneta_tx(struct sk_buff *skb, struct ne= t_device *dev) > if (txq->count >=3D txq->tx_stop_threshold) > netif_tx_stop_queue(nq); > =20 > - if (!skb->xmit_more || netif_xmit_stopped(nq) || > - txq->pending + frags > MVNETA_TXQ_DEC_SENT_MASK) > + if (!skb->xmit_more || netif_xmit_stopped(nq)) > mvneta_txq_pend_desc_add(pp, txq, frags); > else > txq->pending +=3D frags; > --=20 > 2.9.3 --vkEkAx9hr54EJ73W Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAloDPC8ACgkQgtp0PDeOcDpq4gCeMgo5SpInF9sVGey0+hnpO1se bVcAoI0unPkBgqq+BftgGzwjwsuN8cVX =c+Hc -----END PGP SIGNATURE----- --vkEkAx9hr54EJ73W--