Subject: Re: [PATCH net] net: enetc: fix VSI mailbox timeout handling and DMA lifecycle

From: Jakub Kicinski <[email-masked]>
Date: Mon, 27 Apr 2026 18:55:56 -0700

On Fri, 24 Apr 2026 10:15:34 +0800 Wei Fang wrote:
> +	/* The VSI mailbox may be busy if last message was not yet processed
> +	 * by PSI. So need to check the mailbox status before sending.
> +	 */
> +	vsimsgsr = enetc_rd(&si->hw, ENETC_VSIMSGSR);
> +	if (vsimsgsr & ENETC_VSIMSGSR_MB) {
> +		/* It is safe to free the DMA buffer here, the caller does
> +		 * not access the DMA buffer if enetc_msg_vsi_send() fails.
> +		 */
> +		enetc_msg_dma_free(dev, msg);
> +		dev_err(dev, "VSI mailbox is busy\n");
> +		return -EBUSY;

Sashiko suggests EIO here, since it's effectively an IO issue
and this errno goes back to user space

> +	}
> +
> +	/* Free the DMA buffer of the last message */
> +	enetc_msg_dma_free(dev, &si->msg);
> +	si->msg = *msg;
>  	enetc_msg_vsi_write_msg(&si->hw, msg);
>  
>  	do {

> @@ -269,7 +292,7 @@ static void enetc_vf_remove(struct pci_dev *pdev)
>  	enetc_teardown_cbdr(&si->cbd_ring);
>  
>  	free_netdev(si->ndev);
> -
> +	enetc_msg_dma_free(&pdev->dev, &si->msg);
>  	enetc_pci_remove(pdev);

Sashiko points out that if the goal is to avoid memory corruption we
should only free the buffer if the mbox is not busy. If it's busy
printing a warning and leaking is probably better.
-- 
pw-bot: cr