Re: [PATCH net v3] net: stmmac: fix transmit queue timed out after resume for tso

From: Russell King (Oracle)

Date: Sat Jan 17 2026 - 06:10:00 EST


On Sat, Jan 17, 2026 at 03:59:22PM +0800, Tao Wang wrote:
> > Rather than using tx_q->tx_skbuff_dma[].last_segment to determine
> > whether the first descriptor entry is the only segment, calculate the
> > number of descriptor entries used. If there is only one descriptor,
> > then the first is also the last, so mark it as such.
>
> This is a good idea. tx_q->tx_skbuff_dma[].last_segment no longer carries
> much meaning and can indeed be removed altogether.
>
> > +       is_last_segment = ((tx_q->cur_tx - first_entry) &
> > +                          (priv->dma_conf.dma_tx_size - 1)) == 1;
>
> Since tx_q->cur_tx may wrap around and become smaller than first_entry,
> the following statement is more concise:
> is_last_segment = (tx_q->cur_tx == first_entry);

That's incorrect. We advance tx_q->cur_tx by at least one by this
point:

first_entry = tx_q->cur_tx;

... fill descriptors ...

/* We've used all descriptors we need for this skb, however,
* advance cur_tx so that it references a fresh descriptor.
* ndo_start_xmit will fill this descriptor the next time it's
* called and stmmac_tx_clean may clean up to this descriptor.
*/
tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx, priv->dma_conf.dma_tx_size);

...

/* If we only have one entry used, then the first entry is the last
* segment.
*/
is_last_segment = ((tx_q->cur_tx - first_entry) &
(priv->dma_conf.dma_tx_size - 1)) == 1;

So, replacing this with a check for tx_q->cur_tx == first_entry
would always be false here, unless we completely filled the ring
with a single TSO.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!