Netdev List
 help / color / mirror / Atom feed
From: Jijie Shao <shaojijie@huawei.com>
To: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
	<pabeni@redhat.com>, <andrew+netdev@lunn.ch>, <horms@kernel.org>
Cc: <shenjian15@huawei.com>, <liuyonglong@huawei.com>,
	<chenhao418@huawei.com>, <huangdonghua3@h-partners.com>,
	<yangshuaisong@h-partners.com>, <shiyongbang@huawei.com>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<shaojijie@huawei.com>
Subject: [PATCH net] net: hibmcge: fix incorrect packets in the RX path issue
Date: Tue, 12 May 2026 20:34:56 +0800	[thread overview]
Message-ID: <20260512123456.3786635-1-shaojijie@huawei.com> (raw)

The test found that when the SMMU is disabled,
the driver may receive the following error packet:
note: The memory is initialized to 0xfe,
and 0xbf is what we expect.

00000440: bf bf bf bf bf bf bf bf bf bf bf bf bf bf bf bf
00000450: bf bf bf bf bf bf bf bf bf bf bf bf bf bf bf bf
00000460: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe
00000470: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe
00000480: bf bf bf bf bf bf bf bf bf bf bf bf bf bf bf bf
00000490: bf bf bf bf bf bf bf bf bf bf bf bf bf bf bf bf

It seems that the packet is not completely written when the descriptor
indicates that the packet is valid. According to the chip document,
the chip writes packets first and then writes the descriptor.
However, the actual sequence in which the packets and descriptor are
written to the memory is incorrect.

Each packet and descriptor of the hibmcge are in the same page.
Therefore, when the Relaxed Ordering is enabled, the transactions for
writing packets and writing descriptors may not be strictly ordered.
As a result, the driver receives incorrect packets.

Therefore, this patch disables the Relaxed Ordering to ensure the
strict order of packets and descriptors.

Additionally, during the process of analyzing the issue,
it was discovered that the position of dma_rmb() was incorrect.
It should first execute dma_sync_single_for_cpu(), and then dma_rmb().
This patch has also made the corresponding modifications.

Fixes: f72e25594061 ("net: hibmcge: Implement rx_poll function to receive packets")
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
 drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c | 4 +++-
 drivers/net/ethernet/hisilicon/hibmcge/hbg_txrx.c | 6 +++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c b/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c
index 068da2fd1fea..5b91b596349c 100644
--- a/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c
+++ b/drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c
@@ -420,6 +420,8 @@ static int hbg_pci_init(struct pci_dev *pdev)
 		return -ENOMEM;
 
 	pci_set_master(pdev);
+	pcie_capability_clear_word(pdev, PCI_EXP_DEVCTL,
+				   PCI_EXP_DEVCTL_RELAX_EN);
 	return 0;
 }
 
@@ -525,4 +527,4 @@ module_exit(hbg_module_exit);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Huawei Tech. Co., Ltd.");
 MODULE_DESCRIPTION("hibmcge driver");
-MODULE_VERSION("1.0");
+MODULE_VERSION("2.0");
diff --git a/drivers/net/ethernet/hisilicon/hibmcge/hbg_txrx.c b/drivers/net/ethernet/hisilicon/hibmcge/hbg_txrx.c
index a4ea92c31c2f..0ae314994676 100644
--- a/drivers/net/ethernet/hisilicon/hibmcge/hbg_txrx.c
+++ b/drivers/net/ethernet/hisilicon/hibmcge/hbg_txrx.c
@@ -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;
 }
-- 
2.33.0


             reply	other threads:[~2026-05-12 12:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 12:34 Jijie Shao [this message]
2026-05-15  0:16 ` [PATCH net] net: hibmcge: fix incorrect packets in the RX path issue Jakub Kicinski
2026-05-15  1:45   ` Jijie Shao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260512123456.3786635-1-shaojijie@huawei.com \
    --to=shaojijie@huawei.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=chenhao418@huawei.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=huangdonghua3@h-partners.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuyonglong@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shenjian15@huawei.com \
    --cc=shiyongbang@huawei.com \
    --cc=yangshuaisong@h-partners.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox