mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: linux-kernel@vger.kernel.org
Subject: memory barriers and dma_sync_single_for_*
Date: Sun, 09 Jul 2006 16:53:21 +0200	[thread overview]
Message-ID: <44B11861.3070703@s5r6.in-berlin.de> (raw)

Hi all,

I have a memory area which is written by the CPU and concurrently read 
by a DMA capable device, multiple times.

Among else there are two fields in the memory area, both are 32 bits 
wide. Whenever the CPU updates the fields, I have to make sure that the 
device does not get to see a new value in field B before I updated field 
A. Conversely, it is safe to update field A anytime before field B. The 
driver has no way to know when the device is going to read any of the 
fields.

My question: Do I need wmb() within the following code?

	dma_sync_single_for_cpu(..., DMA_TO_DEVICE);
	area->a = new_val_a;
	wmb();  /* necessary? */
	area->b = new_val_b;
	dma_sync_single_for_device(..., DMA_TO_DEVICE);

Or are all changes to the area hidden from the device between 
dma_sync_single_for_cpu and _for_device, thereby making the write order 
a non-issue? Thanks,
-- 
Stefan Richter
-=====-=-==- -=== -=--=
http://arcgraph.de/sr/

             reply	other threads:[~2006-07-09 14:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-09 14:53 Stefan Richter [this message]
2006-07-09 15:46 ` Alan Cox

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=44B11861.3070703@s5r6.in-berlin.de \
    --to=stefanr@s5r6.in-berlin.de \
    --cc=linux-kernel@vger.kernel.org \
    /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®