* HELP: Is writeq an atomic operation??
@ 2008-05-02 22:19 Moore, Eric
2008-05-02 22:32 ` David Miller
0 siblings, 1 reply; 9+ messages in thread
From: Moore, Eric @ 2008-05-02 22:19 UTC (permalink / raw)
To: linux-scsi
Is a 64bit write to MMIO registers an atomic operation when using the
writeq API?
My concern is when I send 64bit data via writeq, will it be sent out as
two 32 bit writes? If so, is it possible that another CPU be sending
the data at the same time. Meaning can I write the 1st 32bit data from
CPU-A, meanwhile CPU-B is writing his 32bit data at the same time, and
CPU-A didn't complete the full 64bit in one shot. If this could occur,
is there an API that I can use to make sure the entire data sent in one
atomic operation?
Here is a trace from pci express analyzer. I'm sending
0x0800010000000000 to the adress DD1400C0 using writeq. Notice that in
the TLP header it sent a 32bit Memory write with data length of two.
Trace follows:
Link Tra(597) Downstream 2.5(x1) TLP(1992) Mem MWr(32)(10:00000) TC(0)
TD(0)
_______| EP(0) Attributes(01) Length(2) RequesterID(000:02:0) Tag(8)
_______| Address(DD1400C0) 1st BE(1111) Last BE(1111) Data(08000100
00000000)
_______| VC ID(0) Explicit ACK(Packet #1195) Metrics # Packets(2)
_______| Time Stamp(0003 . 120 181 840 s)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: HELP: Is writeq an atomic operation??
2008-05-02 22:19 HELP: Is writeq an atomic operation?? Moore, Eric
@ 2008-05-02 22:32 ` David Miller
2008-05-02 22:43 ` Roland Dreier
0 siblings, 1 reply; 9+ messages in thread
From: David Miller @ 2008-05-02 22:32 UTC (permalink / raw)
To: Eric.Moore; +Cc: linux-scsi, linux-kernel
From: "Moore, Eric" <Eric.Moore@lsi.com>
Date: Fri, 2 May 2008 16:19:49 -0600
> Is a 64bit write to MMIO registers an atomic operation when using the
> writeq API?
The answer to this question this is platform dependent.
On most 64-bit platforms, it is. On some 32-bit ones, it is not.
This is not a SCSI layer question, so belongs minimally on
linux-kernel which I've CC:'d.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: HELP: Is writeq an atomic operation??
2008-05-02 22:32 ` David Miller
@ 2008-05-02 22:43 ` Roland Dreier
2008-05-02 22:49 ` David Miller
2008-05-02 22:49 ` Moore, Eric
0 siblings, 2 replies; 9+ messages in thread
From: Roland Dreier @ 2008-05-02 22:43 UTC (permalink / raw)
To: David Miller; +Cc: Eric.Moore, linux-scsi, linux-kernel
> > Is a 64bit write to MMIO registers an atomic operation when using the
> > writeq API?
>
> The answer to this question this is platform dependent.
>
> On most 64-bit platforms, it is. On some 32-bit ones, it is not.
Are there any 32-bit platforms with writeq()? A quick grep suggests not.
Are there any 64-bit platforms where writeq() allows the MMIO to be
split into multiple cycles from the target device's view? I've been
coding assuming that at least no other MMIO writes will reach the device
in the middle of a writeq().
- R.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: HELP: Is writeq an atomic operation??
2008-05-02 22:43 ` Roland Dreier
@ 2008-05-02 22:49 ` David Miller
2008-05-02 22:49 ` Moore, Eric
1 sibling, 0 replies; 9+ messages in thread
From: David Miller @ 2008-05-02 22:49 UTC (permalink / raw)
To: rdreier; +Cc: Eric.Moore, linux-scsi, linux-kernel
From: Roland Dreier <rdreier@cisco.com>
Date: Fri, 02 May 2008 15:43:32 -0700
> Are there any 32-bit platforms with writeq()? A quick grep suggests not.
Right, I guess there aren't, but what drivers do currently is roll
their own 64-bit MMIO for such cases.
I noticed this when writing drivers/net/niu.c
I suppose this is on purpose, so the driver can setup any
such protection and handling, as needed.
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: HELP: Is writeq an atomic operation??
2008-05-02 22:43 ` Roland Dreier
2008-05-02 22:49 ` David Miller
@ 2008-05-02 22:49 ` Moore, Eric
2008-05-02 22:53 ` Roland Dreier
1 sibling, 1 reply; 9+ messages in thread
From: Moore, Eric @ 2008-05-02 22:49 UTC (permalink / raw)
To: Roland Dreier, David Miller; +Cc: linux-scsi, linux-kernel
> >
> > The answer to this question this is platform dependent.
> >
> > On most 64-bit platforms, it is. On some 32-bit ones, it is not.
>
> Are there any 32-bit platforms with writeq()? A quick grep
> suggests not.
I think writeq defined in include/asm-x86/io_64.h
>
> Are there any 64-bit platforms where writeq() allows the MMIO to be
> split into multiple cycles from the target device's view? I've been
> coding assuming that at least no other MMIO writes will reach
> the device
> in the middle of a writeq().
>
I hope that is the case.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: HELP: Is writeq an atomic operation??
2008-05-02 22:49 ` Moore, Eric
@ 2008-05-02 22:53 ` Roland Dreier
2008-05-02 23:13 ` Moore, Eric
0 siblings, 1 reply; 9+ messages in thread
From: Roland Dreier @ 2008-05-02 22:53 UTC (permalink / raw)
To: Moore, Eric; +Cc: David Miller, linux-scsi, linux-kernel
> > Are there any 32-bit platforms with writeq()? A quick grep
> > suggests not.
>
> I think writeq defined in include/asm-x86/io_64.h
Umm... io_64.h is 64-bit only (look at asm-x86/io.h if you don't believe me ;)
- R.
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: HELP: Is writeq an atomic operation??
2008-05-02 22:53 ` Roland Dreier
@ 2008-05-02 23:13 ` Moore, Eric
2008-05-02 23:21 ` Roland Dreier
0 siblings, 1 reply; 9+ messages in thread
From: Moore, Eric @ 2008-05-02 23:13 UTC (permalink / raw)
To: Roland Dreier; +Cc: David Miller, linux-scsi, linux-kernel
On Friday, May 02, 2008 4:53 PM, Roland Dreier wrote:
>
> > > Are there any 32-bit platforms with writeq()? A quick grep
> > > suggests not.
> >
> > I think writeq defined in include/asm-x86/io_64.h
>
> Umm... io_64.h is 64-bit only (look at asm-x86/io.h if you
> don't believe me ;)
>
Yeah, I forgot I have a #ifndef writeq, then defined the x86_64 version
of that. I've not tested on x86, so I'm not sure whether it works.
How are you handling writeq when its not defined, as the case in x86?
Eric
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: HELP: Is writeq an atomic operation??
2008-05-02 23:13 ` Moore, Eric
@ 2008-05-02 23:21 ` Roland Dreier
2008-05-02 23:31 ` Moore, Eric
0 siblings, 1 reply; 9+ messages in thread
From: Roland Dreier @ 2008-05-02 23:21 UTC (permalink / raw)
To: Moore, Eric; +Cc: David Miller, linux-scsi, linux-kernel
> Yeah, I forgot I have a #ifndef writeq, then defined the x86_64 version
> of that. I've not tested on x86, so I'm not sure whether it works.
> How are you handling writeq when its not defined, as the case in x86?
Write two writel() inside a spinlock to avoid any transactions in the
middle (the HW I'm dealing with can deal with two 32-bit transactions,
as long as nothing comes in the middle). If your hardware demands a
single 64-bit transaction, you may be in trouble, because I'm not sure
all 32-bit systems can generate such a PCIe transaction.
You can see include/linux/mlx4/doorbell.h for exactly what I did.
- R.
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: HELP: Is writeq an atomic operation??
2008-05-02 23:21 ` Roland Dreier
@ 2008-05-02 23:31 ` Moore, Eric
0 siblings, 0 replies; 9+ messages in thread
From: Moore, Eric @ 2008-05-02 23:31 UTC (permalink / raw)
To: Roland Dreier; +Cc: David Miller, linux-scsi, linux-kernel
On Friday, May 02, 2008 5:22 PM, Roland Dreier wrote:
> > Yeah, I forgot I have a #ifndef writeq, then defined the
> x86_64 version
> > of that. I've not tested on x86, so I'm not sure whether
> it works.
> > How are you handling writeq when its not defined, as the
> case in x86?
>
> Write two writel() inside a spinlock to avoid any transactions in the
> middle (the HW I'm dealing with can deal with two 32-bit transactions,
> as long as nothing comes in the middle). If your hardware demands a
> single 64-bit transaction, you may be in trouble, because I'm not sure
> all 32-bit systems can generate such a PCIe transaction.
>
> You can see include/linux/mlx4/doorbell.h for exactly what I did.
>
Thanks for the code sample. Yes, I need to send a single atomic 64-bit
transaction.
Eric
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-05-02 23:32 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-02 22:19 HELP: Is writeq an atomic operation?? Moore, Eric
2008-05-02 22:32 ` David Miller
2008-05-02 22:43 ` Roland Dreier
2008-05-02 22:49 ` David Miller
2008-05-02 22:49 ` Moore, Eric
2008-05-02 22:53 ` Roland Dreier
2008-05-02 23:13 ` Moore, Eric
2008-05-02 23:21 ` Roland Dreier
2008-05-02 23:31 ` Moore, Eric
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox