All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] Atomic 64 bit write access on PCIe device
@ 2008-02-20  8:25 M. Koehrer
  2008-02-20  8:55 ` Gilles Chanteperdrix
  2008-02-20  9:19 ` Philippe Gerum
  0 siblings, 2 replies; 6+ messages in thread
From: M. Koehrer @ 2008-02-20  8:25 UTC (permalink / raw)
  To: xenomai

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?


Thanks for any feedback!

Regards

Mathias

-- 
Mathias Koehrer
mathias_koehrer@domain.hid


Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren
ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT FÜR ALLE NEUEINSTEIGER
Jetzt bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket
für clevere Doppel-Sparer, nur  29,95 Euro  inkl. DSL- und ISDN-Grundgebühr!
http://www.arcor.de/rd/emf-dsl-2


^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [Xenomai-help] Atomic 64 bit write access on PCIe device
@ 2008-02-20  9:50 Fillod Stephane
  2008-02-20 12:50 ` M. Koehrer
  0 siblings, 1 reply; 6+ messages in thread
From: Fillod Stephane @ 2008-02-20  9:50 UTC (permalink / raw)
  To: M. Koehrer, xenomai

M. Koehrer wrote:
>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.

I'm no expert, but did you tried already using FP instructions, which is
a common
trick to make use of 64 bits I/O in code optimization (before SIMD era).

How about the following:

void do_write64(void *p, unsigned long long x)
{
        volatile union {
                unsigned long long ull;
                double d;
        } u;

        u.ull = x;
        *(volatile double *)p = u.d;
}

Disassemble that code, you should see some fldl and fstpl.
-- 
Stephane


^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [Xenomai-help] Atomic 64 bit write access on PCIe device
@ 2008-02-20 14:20 Fillod Stephane
  0 siblings, 0 replies; 6+ messages in thread
From: Fillod Stephane @ 2008-02-20 14:20 UTC (permalink / raw)
  To: M. Koehrer, xenomai

M. Koehrer wrote:
>First I thought of using the FPU for this issue.
>Hoever, I am not sure if it is allowed to use the FPU here as I think
there are some 64 bit integer values
>that will be modified by fldl (e.g. if they represent some kind of
NaN).

Might be. To be checked whether there are some other safer FP
instructions.

Another idea would be to use MMX and the MOVQ instruction for example.

Regards,
-- 
Stephane


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-02-20 14:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
  -- 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

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.