From: Jesse Barnes <jbarnes@engr.sgi.com>
To: Grant Grundler <grundler@parisc-linux.org>
Cc: Andrew Vasquez <andrew.vasquez@qlogic.com>,
pj@sgi.com, linux-scsi@vger.kernel.org, mdr@cthulhu.engr.sgi.com,
jeremy@cthulhu.engr.sgi.com, djh@cthulhu.engr.sgi.com,
Andrew Morton <akpm@osdl.org>
Subject: Re: SCSI QLA not working on latest *-mm SN2
Date: Mon, 20 Sep 2004 17:09:44 -0700 [thread overview]
Message-ID: <200409201709.45008.jbarnes@engr.sgi.com> (raw)
In-Reply-To: <20040920232716.GD19511@colo.lackof.org>
[-- Attachment #1: Type: text/plain, Size: 2641 bytes --]
On Monday, September 20, 2004 4:27 pm, Grant Grundler wrote:
> "write posting" is orthogonal to PCI ordering rules.
> AFAIK, Write posting is not specific to PCI - but any memory mapped IO.
Right.
> I understand "write posting" as when the CPU posts the write
> to the chipset and the chipset says the write is done even though
> it hasn't reached the PCI device. It just means the write has reached
> the PCI "domain" (which is supposed to be strongly ordered).
That's my understanding too.
> Secondly, I don't recall hearing about problems like this
> on Intel or HP ia64 machines. I've only run into PCI posted write
> and DMA syncronization problems where the drivers aren't following
> all the rules quite right (missing mb() and readl()'s mostly).
Problems like what? If mmio writes are posted, then the driver has to deal
with it with reads like you said. If the example code was fixed to lose the
read() in the second spinlock protected region, I think it would describe
mmio write posting accurately, no?
> So far, I still think this document is misnamed and should
> be called something like "SGI Altix porting issues" and moved
> under the Documentation/ia64 directory.
But it has nothing to do with Altix at all...
>
> > > [ Is this example broken or am I just staying up too late?
> > > The example is doing a readl() in the second critical section.
> > > Shouldn't that enforce the write ordering?
> > > ]
> >
> > Yep, that's a bug. It should just be writes.
>
> ok. Can you fix that up and post a new version where I can see it?
>
> > > The reads from safe_register will cause the I/O chipset to flush any
> > > pending writes before actually posting the read to the chipset,
> > > preventing possible data corruption.
> > >
> > > [ How about interactions with:
> > > o read_relaxed()?
> > > o DMA?
> > > o IO Port space reads?
> > > o IO Port space writes?
> > > ]
> >
> > None that I know of.
>
> You mean none that are surprising to you?
> ie writes can pass read_relaxed() transactions or vice versa?
> DMA read returns can bypass MMIO writes? (parisc chipsets allow this)
No, as far as mmio ordering goes, read_relaxed is exactly the same as read, so
in the example code, a read_relaxed would be sufficient for write ordering.
> IIRC, IO port space writes are NOT posted.
> So the rules for ordering must be impacted or different somehow.
> ie Are IO Port space writes strongly ordered WRT MMIO space writes?
Right, they're supposed to be strongly ordered, I think arches are supposed to
guarantee that in their in/out routines.
Here's a new version that should be clearer.
Thanks,
Jesse
[-- Attachment #2: io_ordering.txt --]
[-- Type: text/plain, Size: 2098 bytes --]
Dealing with posted writes
--------------------------
On some platforms platforms, driver writers are responsible for
ensuring that I/O writes to memory-mapped addresses on their device
arrive in the order intended. This is typically done by reading a
'safe' device or bridge register, causing the I/O chipset to flush
pending writes to the device before any reads are posted. A driver
would usually use this technique immediately prior to the exit of a
critical section of code protected by spinlocks. This would ensure
that subsequent writes to I/O space arrived only after all prior
writes (much like a memory barrier op, mb(), only with respect to
I/O).
Some pseudocode to illustrate the problem:
...
CPU A: spin_lock_irqsave(&dev_lock, flags)
CPU A: ...
CPU A: writel(newval, ring_ptr);
CPU A: spin_unlock_irqrestore(&dev_lock, flags)
...
CPU B: spin_lock_irqsave(&dev_lock, flags)
CPU B: ...
CPU B: writel(newval2, ring_ptr);
CPU B: spin_unlock_irqrestore(&dev_lock, flags)
...
In the case above, the device may receive newval2 before it receives newval,
which could cause problems. Fixing it is easy enough though:
...
CPU A: spin_lock_irqsave(&dev_lock, flags)
CPU A: ...
CPU A: writel(newval, ring_ptr);
CPU A: (void)readl(safe_register); /* maybe a config register? */
CPU A: spin_unlock_irqrestore(&dev_lock, flags)
...
CPU B: spin_lock_irqsave(&dev_lock, flags)
CPU B: ...
CPU B: writel(newval2, ring_ptr);
CPU B: (void)readl(safe_register); /* or read_relaxed() */
CPU B: spin_unlock_irqrestore(&dev_lock, flags)
Here, the reads from safe_register will cause the I/O chipset to flush any
pending writes before actually posting the read to the chipset, preventing
possible data corruption.
This sort of synchronization is only necessary for read/write calls,
not in/out calls, since they're by definition strongly ordered.
We should probably add a writeflush call or something to deal with the
above in an easier to read way. Some platforms could even implement
such a routine more efficiently than a regular read.
next prev parent reply other threads:[~2004-09-21 0:10 UTC|newest]
Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <B179AE41C1147041AA1121F44614F0B060EF48@AVEXCH02.qlogic.org>
[not found] ` <20040916121235.5e4f9c32.pj@sgi.com>
[not found] ` <1095362263.16326.12.camel@praka>
2004-09-16 19:56 ` SCSI QLA not working on latest *-mm SN2 Paul Jackson
2004-09-16 20:05 ` Jesse Barnes
2004-09-16 20:56 ` Andrew Vasquez
2004-09-16 21:09 ` Jesse Barnes
2004-09-16 21:40 ` Andrew Vasquez
2004-09-16 22:25 ` Andrew Morton
2004-09-16 22:29 ` Jesse Barnes
2004-09-17 17:21 ` Jesse Barnes
2004-09-18 6:10 ` Grant Grundler
2004-09-18 17:57 ` Documentation/io_ordering.txt is wrong Matthew Wilcox
2004-09-20 23:39 ` Jesse Barnes
2004-09-21 0:38 ` Jesse Barnes
2004-09-20 22:40 ` SCSI QLA not working on latest *-mm SN2 Jesse Barnes
2004-09-20 23:27 ` Grant Grundler
2004-09-21 0:09 ` Jesse Barnes [this message]
2004-09-21 5:46 ` Grant Grundler
2004-09-21 6:45 ` Jeremy Higdon
2004-09-21 13:29 ` Jesse Barnes
2004-09-21 13:25 ` Jesse Barnes
2004-09-21 15:13 ` Jesse Barnes
2004-09-21 15:41 ` James Bottomley
2004-09-21 15:58 ` Jesse Barnes
2004-09-21 16:01 ` Matthew Wilcox
2004-09-21 16:05 ` Jesse Barnes
2004-09-21 16:11 ` James Bottomley
2004-09-21 16:18 ` Jesse Barnes
2004-09-21 16:24 ` James Bottomley
2004-09-21 17:03 ` Jesse Barnes
2004-09-21 17:15 ` Matthew Wilcox
2004-09-21 17:24 ` Jesse Barnes
2004-09-21 17:20 ` James Bottomley
2004-09-21 17:46 ` Jesse Barnes
2004-09-21 17:56 ` James Bottomley
2004-09-21 18:09 ` Jesse Barnes
2004-09-21 19:06 ` Grant Grundler
2004-09-21 19:40 ` Jesse Barnes
2004-09-21 22:44 ` Grant Grundler
2004-09-21 21:03 ` Jeremy Higdon
2004-09-21 21:11 ` Matthew Wilcox
2004-09-21 21:43 ` Jeremy Higdon
2004-09-21 22:33 ` Jesse Barnes
2004-09-22 0:02 ` Matthew Wilcox
2004-09-22 1:16 ` Jeremy Higdon
2004-09-22 1:44 ` Grant Grundler
2004-09-22 2:58 ` Jeremy Higdon
2004-09-22 14:32 ` I/O write ordering Matthew Wilcox
2004-09-22 14:40 ` Benjamin Herrenschmidt
2004-09-22 14:50 ` Jesse Barnes
2004-09-22 14:47 ` James Bottomley
2004-09-22 14:51 ` Benjamin Herrenschmidt
2004-09-22 15:11 ` James Bottomley
2004-09-22 15:11 ` Benjamin Herrenschmidt
2004-09-22 15:22 ` James Bottomley
2004-09-22 15:28 ` Benjamin Herrenschmidt
2004-09-22 15:43 ` James Bottomley
2004-09-23 0:19 ` Benjamin Herrenschmidt
2004-09-23 1:58 ` Matthew Wilcox
2004-09-23 3:01 ` James Bottomley
2004-09-23 3:40 ` Benjamin Herrenschmidt
2004-09-23 4:26 ` Grant Grundler
2004-09-21 23:03 ` SCSI QLA not working on latest *-mm SN2 Guennadi Liakhovetski
2004-09-16 23:14 ` Jeremy Higdon
2004-09-16 20:11 ` Andrew Morton
2004-09-21 21:22 Andrew Vasquez
2004-09-21 21:44 ` Jeremy Higdon
2004-09-21 22:37 ` Jesse Barnes
2004-09-21 22:49 ` Jeremy Higdon
-- strict thread matches above, loose matches on Subject: below --
2004-09-21 20:50 Andrew Vasquez
2004-09-21 21:06 ` Jeremy Higdon
2004-09-21 22:36 ` Jesse Barnes
2004-09-21 22:39 ` Jeremy Higdon
2004-09-21 22:43 ` Jesse Barnes
2004-09-21 22:54 ` Jeremy Higdon
2004-09-21 23:17 ` Jesse Barnes
2004-09-22 21:33 ` Jesse Barnes
2004-09-21 17:33 Andrew Vasquez
2004-09-21 17:52 ` Jesse Barnes
2004-09-21 18:04 ` Matthew Wilcox
2004-09-21 18:59 ` Matthew Wilcox
2004-09-21 19:10 ` Jesse Barnes
2004-09-21 15:58 Andrew Vasquez
2004-09-21 16:07 ` Jesse Barnes
2004-09-21 16:25 ` Matthew Wilcox
2004-09-21 16:33 ` James Bottomley
2004-09-21 20:39 ` Jeremy Higdon
2004-09-21 20:43 ` Jeremy Higdon
2004-09-17 22:55 Andrew Vasquez
2004-09-17 23:10 ` Jesse Barnes
2004-09-17 23:55 ` James Bottomley
2004-09-18 1:15 ` Andrew Vasquez
2004-09-18 1:25 ` Matthew Wilcox
2004-09-18 1:24 ` Andrew Vasquez
2004-09-18 2:36 ` Jeremy Higdon
2004-09-18 19:12 ` James Bottomley
2004-09-15 22:51 Paul Jackson
2004-09-15 23:13 ` Andrew Morton
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=200409201709.45008.jbarnes@engr.sgi.com \
--to=jbarnes@engr.sgi.com \
--cc=akpm@osdl.org \
--cc=andrew.vasquez@qlogic.com \
--cc=djh@cthulhu.engr.sgi.com \
--cc=grundler@parisc-linux.org \
--cc=jeremy@cthulhu.engr.sgi.com \
--cc=linux-scsi@vger.kernel.org \
--cc=mdr@cthulhu.engr.sgi.com \
--cc=pj@sgi.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.