mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xingbang Liu <liu.airalert@gmail.com>
To: jdmason@kudzu.us, dave.jiang@intel.com, allenbh@gmail.com
Cc: ntb@lists.linux.dev, linux-kernel@vger.kernel.org,
	Xingbang Liu <liu.airalert@gmail.com>
Subject: [PATCH v1] ntb_transport: replace wmb() with dma_wmb() in TX paths
Date: Fri, 24 Apr 2026 17:23:40 +0800	[thread overview]
Message-ID: <20260424092340.3792297-1-liu.airalert@gmail.com> (raw)

The TX paths currently use wmb() after memcpy_toio() to ensure that
writes to the peer memory window are visible before subsequent
notification.

The actual ordering requirement is to ensure that data written to the
peer memory is observed before the associated notification or status
update. This matches the semantics of dma_wmb(), which orders memory
writes with respect to external observers.

The peer memory window is mapped with ioremap_wc(), allowing
write-combining. On weakly ordered architectures such as arm64,
dma_wmb() ensures that prior writes are committed from write-combining
buffers and become visible to the peer before subsequent operations.

This aligns with common patterns in PCIe-based drivers, where it is
used to order descriptor or payload writes before notification, while
avoiding the stronger ordering semantics of wmb().

The ordering with respect to peer observation is completed by the
subsequent notification mechanism.

No functional change is intended.

Signed-off-by: Xingbang Liu <liu.airalert@gmail.com>
---
 drivers/ntb/ntb_transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index 7cabc82305d6..c8ef46ddcc57 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -1791,7 +1791,7 @@ static void ntb_memcpy_tx_on_stack(struct ntb_queue_entry *entry, void __iomem *
 #endif
 
 	/* Ensure that the data is fully copied out before setting the flags */
-	wmb();
+	dma_wmb();
 
 	ntb_tx_copy_callback(entry, NULL);
 }
-- 
2.34.1


             reply	other threads:[~2026-04-24  9:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-24  9:23 Xingbang Liu [this message]
2026-04-24 15:32 ` Dave Jiang
2026-04-27  2:00   ` xingbang liu

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=20260424092340.3792297-1-liu.airalert@gmail.com \
    --to=liu.airalert@gmail.com \
    --cc=allenbh@gmail.com \
    --cc=dave.jiang@intel.com \
    --cc=jdmason@kudzu.us \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntb@lists.linux.dev \
    /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

all inboxes | Powered by JetHome®