Re:Re: [PATCH v3] net: stmmac: fix fatal bus error on resume by reinitializing RX buffers

From: Ding Hui

Date: Sun Jun 14 2026 - 02:05:02 EST


At 2026-06-08 17:41:25, "Jakub Raczynski" <j.raczynski@xxxxxxxxxxx> wrote:
>On Thu, Jun 04, 2026 at 10:45:54PM +0800, Ding Hui wrote:
>> From: Ding Hui <dinghui@xxxxxxxxxxx>
>> + for (queue = 0; queue < priv->plat->rx_queues_to_use; queue++) {
>> + ret = stmmac_reinit_rx_descriptors(priv, &priv->dma_conf,
>> + queue);
>> + if (ret) {
>> + netdev_err(priv->dev,
>> + "%s: rx desc reinit failed on queue %u\n",
>> + __func__, queue);
>> + mutex_unlock(&priv->lock);
>> + rtnl_unlock();
>> + return ret;
>> + }
>> + }
>
>This is not directly related to the patch, but rather stmmac_resume() itself,
>but doesn't this return and hw_setup one leave bunch of descriptor memory
>hanging and effectively leaked?
>
>> +
>> ret = stmmac_hw_setup(ndev);
>> if (ret < 0) {
>> netdev_err(priv->dev, "%s: Hw setup failed\n", __func__);
>> --
>

You are right that both error paths leave the descriptor rings and RX
buffers allocated without an explicit cleanup. However, I prefer to call
it a memory "hanging" but not "leaked":

The memory is not permanently leaked. All RX buffers allocated in the
error path are stored in dma_conf->rx_queue[q].buf_pool[].page (or
.xdp for XSK queues), and the DMA descriptor rings themselves remain
reachable via priv->dma_conf. When the user eventually brings the
interface down, stmmac_release() -> free_dma_desc_resources() will
free everything correctly.

Maybe I should submit a follow-up patch that adds proper cleanup to
stmmac_resume()'s error paths (calling free_dma_desc_resources() and
marking the device as not running), if that would be welcome. I'd
prefer to keep it separate from this fix to keep the scope clean.

>Other than that, I don't see any obvious issues.
>

Thanks for the review.