From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Eliot Blennerhassett <linux@audioscience.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Q: volatile vs barriers to access memory data changed by device DMA
Date: Mon, 25 Feb 2008 08:32:01 +0000 [thread overview]
Message-ID: <20080225083201.51067611@core> (raw)
In-Reply-To: <200802251404.01874.linux@audioscience.com>
> === after conversion
> struct bus_master_interface *interface;
> while (interface->ack != OK) {
> delay(a short while);
> rmb();
> [ after X loops device changes interface->ack by dma ]
> };
>
> All I need is for the read of interface->ack in the loop not to be optimised
> away - is rmb() the appropriate incantation to achieve this?
Yes - ish. You want the equivalent of
do {
rmb();
if (interface->ack == OK)
break;
} while(1);
(eg putting another rmb before the while in your case)
You want a barrier before the *first* read in case the
compiler has managed to cache the value before you enter the loop.
> struct bus_master_interface *interface;
> interface->cmd = command;
> wmb();
> iowrite(device_interrupt, 1);
Yes.
prev parent reply other threads:[~2008-02-25 8:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-25 1:04 Q: volatile vs barriers to access memory data changed by device DMA Eliot Blennerhassett
2008-02-25 8:32 ` Alan Cox [this message]
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=20080225083201.51067611@core \
--to=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@audioscience.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.