From: netdev-bot+sashiko@kernel.org
To: lirongqing@baidu.com
Cc: saeedm@nvidia.com, leon@kernel.org, tariqt@nvidia.com,
mbloch@nvidia.com, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org,
john.fastabend@gmail.com, sdf@fomichev.me, borisp@nvidia.com,
richardcochran@gmail.com, cratiu@nvidia.com, dtatulea@nvidia.com,
cjubran@nvidia.com, kees@kernel.org, agoldberger@nvidia.com,
horms@kernel.org, netdev@vger.kernel.org,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org
Subject: Re: [PATCH net-next, v3] net/mlx5: Use dma_wmb() for completion queue doorbell updates
Date: Sun, 06 Sep 2026 14:02:24 +0000 [thread overview]
Message-ID: <178870334429.219967.11248144823139889707@kernel.org> (raw)
In-Reply-To: <20260902023429.1717-1-lirongqing@baidu.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider:
Critical: 0 · High: 0 · Medium: 1 · Low: 0
- [Medium] Commit message justification is factually wrong for at least
one converted site, and the change's correctness silently depends on…
--
net/mlx5: Use dma_wmb() for completion queue doorbell updates
This converts the wmb() that follows mlx5_cqwq_update_db_record() into
dma_wmb() at six CQ polling sites in the mlx5 driver. The reasoning given
is that only DMA coherent memory is written around the barrier, so the
lighter DMA barrier is sufficient. The wmb() in wc.c is intentionally left
alone.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
[ ... ]
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
> index 1f6bde5d76265..1341874ee58a3 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
> @@ -384,7 +384,7 @@ static inline void mlx5_fpga_conn_cqes(struct mlx5_fpga_conn *conn,
>
> mlx5_fpga_dbg(conn->fdev, "Re-arming CQ with cc# %u\n", conn->cq.wq.cc);
> /* ensure cq space is freed before enabling more cqes */
> - wmb();
> + dma_wmb();
> mlx5_fpga_conn_arm_cq(conn);
> }
[Severity: Medium]
The commit message says:
Since only DMA coherent memory accesses are involved (no MMIO accesses
follow), we can safely use dma_wmb() instead of wmb().
Is that accurate for mlx5_fpga_conn_cqes()? The statement right after the
converted barrier is mlx5_fpga_conn_arm_cq(), which reaches an MMIO write:
drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c:
static void mlx5_fpga_conn_arm_cq(struct mlx5_fpga_conn *conn)
{
mlx5_cq_arm(&conn->cq.mcq, MLX5_CQ_DB_REQ_NOT,
conn->fdev->conn_res.uar->map, conn->cq.wq.cc);
}
include/linux/mlx5/cq.h:mlx5_cq_arm() {
*cq->arm_db = cpu_to_be32(sn << 28 | cmd | ci);
/* Make sure that the doorbell record in host memory is
* written before ringing the doorbell via PCI MMIO.
*/
wmb();
...
mlx5_write64(doorbell, uar_page + MLX5_CQ_DOORBELL);
}
and mlx5_write64() uses __raw_writeq()/__raw_writel(), which carry no
implicit barriers.
The same holds indirectly for the other four converted sites,
mlx5e_poll_rx_cq(), mlx5e_poll_tx_cq(), mlx5e_poll_xdpsq_cq() and
mlx5e_ptp_poll_ts_cq(): the NAPI caller in en_txrx.c arms the CQ over MMIO
shortly after the poll returns:
drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h:
static inline void mlx5e_cq_arm(struct mlx5e_cq *cq)
{
mlx5_cq_arm(&cq->mcq, MLX5_CQ_DB_REQ_NOT, cq->uar->map, cq->wq.cc);
}
dma_wmb() is strictly weaker than wmb() on some architectures (arm64
dmb(oshst) versus dsb(st)), and by itself it does not order the coherent
memory consumer-index store against a later MMIO write. So is the change
relying on the wmb() inside mlx5_cq_arm() to provide that ordering?
If so, could the changelog state that instead, and could the code comment
be updated from "ensure cq space is freed before enabling more cqes" to
mention that the MMIO ordering comes from mlx5_cq_arm()? Otherwise a later
change that relaxes the wmb() in mlx5_cq_arm(), or a new arm path without
one, would quietly lose the CQ consumer-index versus arm-doorbell ordering
with nothing in the history pointing at it.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260902023429.1717-1-lirongqing%40baidu.com
next prev parent reply other threads:[~2026-09-06 14:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 2:34 [PATCH net-next, v3] net/mlx5: Use dma_wmb() for completion queue doorbell updates lirongqing
2026-09-02 2:52 ` sashiko-bot
2026-09-05 20:10 ` patchwork-bot+netdevbpf
2026-09-06 14:02 ` netdev-bot+sashiko [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-08-16 3:56 lirongqing
2026-08-20 13:25 ` Paolo Abeni
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=178870334429.219967.11248144823139889707@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=agoldberger@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=borisp@nvidia.com \
--cc=bpf@vger.kernel.org \
--cc=cjubran@nvidia.com \
--cc=cratiu@nvidia.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dtatulea@nvidia.com \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=lirongqing@baidu.com \
--cc=mbloch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=saeedm@nvidia.com \
--cc=sdf@fomichev.me \
--cc=tariqt@nvidia.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