Commit b545b6ea authored by Jijie Shao's avatar Jijie Shao Committed by Paolo Abeni
Browse files

net: hibmcge: move dma_rmb() after dma_sync_single_for_cpu() in RX path



The dma_rmb() barrier was placed before dma_sync_single_for_cpu(), which
is incorrect. DMA sync must complete first to make the buffer accessible
to the CPU, then the rmb barrier ensures subsequent descriptor reads
observe the latest data written by the hardware.

Reorder the operations so dma_sync_single_for_cpu() is called before
dma_rmb() to guarantee the driver reads consistent data from the DMA
buffer.

Fixes: f72e2559 ("net: hibmcge: Implement rx_poll function to receive packets")
Signed-off-by: default avatarJijie Shao <shaojijie@huawei.com>
Link: https://patch.msgid.link/20260525144525.94884-3-shaojijie@huawei.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 463a1271
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -452,12 +452,12 @@ static bool hbg_sync_data_from_hw(struct hbg_priv *priv,
{
	struct hbg_rx_desc *rx_desc;

	/* make sure HW write desc complete */
	dma_rmb();

	dma_sync_single_for_cpu(&priv->pdev->dev, buffer->page_dma,
				buffer->page_size, DMA_FROM_DEVICE);

	/* make sure HW write desc complete */
	dma_rmb();

	rx_desc = (struct hbg_rx_desc *)buffer->page_addr;
	return FIELD_GET(HBG_RX_DESC_W2_PKT_LEN_M, rx_desc->word2) != 0;
}