From: Philippe Gerum <rpm@xenomai.org>
To: "M. Koehrer" <mathias_koehrer@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] Atomic 64 bit write access on PCIe device
Date: Wed, 20 Feb 2008 10:19:20 +0100 [thread overview]
Message-ID: <47BBF098.8030409@domain.hid> (raw)
In-Reply-To: <23559868.1203495913401.JavaMail.ngmail@domain.hid>
M. Koehrer wrote:
> Hi everybody,
>
> perhaps this issue is off-topic, but I expect that there are many experts on that issue reading the Xenomai list...
> I have a Core2Duo Intel CPU (32 bit mode) and a proprietary PCI Express I/O board plugged in.
> This PCI Express I/O board has some 64 bit registers that are mapped into address space via mmap.
> Now, I want to write atomically (one PCIe access) to one of the 64 bit registers.
> Unfortunately, the Intel CPUs does not have an atomic 64 bit write operations when running the CPU in 32 bit mode.
> When doing something like
>
> volatile unsigned long long *ull = register_address;
> *ull = my_new_register_value;
>
> I see the gcc is generating two 32 bit write accesses. Of course this will not lead to an atomic 64 bit write access.
>
> Any idea, how I can write 64 bit integers atomically to such an 64 bit register?
>
Assuming this register may only be accessed from userland through
mmapped memory (and not concurrently from a kernel driver), and that you
may write this value as 2 x 32bit as far as the hw is concerned but you
want to avoid software access races doing so, something like this would
probably do:
iopl(3)
...
mutex_lock(&lock); /* prevent SMP race */
asm volatile("cli"); /* prevent local preemption */
*ull = my_new_register_value;
asm volatile("sti");
mutex_unlock(&lock);
Yeah, that's pretty ugly. Yum.
>
> Thanks for any feedback!
>
> Regards
>
> Mathias
>
--
Philippe.
next prev parent reply other threads:[~2008-02-20 9:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-20 8:25 [Xenomai-help] Atomic 64 bit write access on PCIe device M. Koehrer
2008-02-20 8:55 ` Gilles Chanteperdrix
2008-02-20 9:19 ` Philippe Gerum [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-02-20 9:50 Fillod Stephane
2008-02-20 12:50 ` M. Koehrer
2008-02-20 14:20 Fillod Stephane
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=47BBF098.8030409@domain.hid \
--to=rpm@xenomai.org \
--cc=mathias_koehrer@domain.hid \
--cc=xenomai@xenomai.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 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.