public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
To: Matthew Wilcox <matthew@wil.cx>
Cc: Grant Grundler <grundler@parisc-linux.org>,
	linux-ia64@vger.kernel.org, Roland Dreier <rdreier@cisco.com>,
	linux-kernel@vger.kernel.org, openib-general@openib.org,
	linux-pci@atrey.karlin.mff.cuni.cz
Subject: Re: [openib-general] Ordering between PCI config space writes and MMIO reads?
Date: Wed, 25 Oct 2006 11:15:54 -0600	[thread overview]
Message-ID: <20061025171554.GM4054@obsidianresearch.com> (raw)
In-Reply-To: <20061025141859.GC5591@parisc-linux.org>

On Wed, Oct 25, 2006 at 08:18:59AM -0600, Matthew Wilcox wrote:

> PCI-PCI bridges are allowed to do it.  If you look in table E-1 of PCI
> 2.3, or table 8-3 of PCI-X 2.0, you'll see that a Posted Memory Write
> can pass a Delayed Write Request (or in PCI-X, a Memory Write can pass a
> Split Write Request).

Carefull here.. Only MMIO writes are of the posted variety. Non posted
transactions (config write, IO write, all reads) are not ever allowed
to pass a posted write, but they can be re-ordered.

Table 8-3 shows that Split Write vs Split Read are all Y/N
meaning they could be re-ordered with respect to each other.

The problem with mthca is exactly this, although the operations were
issued in-order by the bridges the end device (mthca) is free to
complete them in any order, and it choose to complete the MMIO read
before the config write.

>   In most PCI-X implementations, Split Requests are managed in separate
>   buffers from Split Completions, so Split Requests naturally pass Split
>   Completions. However, no deadlocks occur if Split Completions block
>   Split Requests.

Again, this is only for posted writes. All these rules are designed to
prevent the bus from deadlocking due to buffer starvation under
certain situations. [Basically split completions and posted writes are
given a seperate queue that can advance if the request queue is
stalled. Otherwise you can deadlock a bridge]

> So all this code that checks to see if a write had an effect is unsafe.
> I'm a little perturbed by this.  It means the only way to reliably

MMIO based code that does this is correct and reliable.. PIO code that
does this is only safe if the platform is waiting for the PIO write
completion before starting the PIO read.

PCI-X (pg 80) says this about non-posted transaction ordering requirements:
  As in convention PCI, if a requester requires one non-posted
  transaction to complete before another, it must not initiate the
  second transaction until the first one compeltes.

IMHO, all sane hardware implementations of config ops and PIO should
block the host bridge until the completion is generated by the end
device..I'm sure that most x86 platforms do this. (For instance I've
observed this kind of behavior with a Hyper Transport probe on
Opterons)

This is more than just worrying about ordering, it is about how to
engage a platform specific way to know that the completion has been
generated. The person who suggested polling the PIO_OUTSTANDING
register on SN2 seems to have the right idea (if that counts all
pending non-posted operations, not just PIO ones) :|

The risk of re-ordering is probably not so much in the bridges since
that would be a fairly strange thing to do - but it is very likely in
end-devices. This is especially true if the accesses are to different
internal resources!

Jason

  reply	other threads:[~2006-10-25 17:16 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-24 19:13 Ordering between PCI config space writes and MMIO reads? Roland Dreier
2006-10-24 19:22 ` Jeff Garzik
2006-10-24 21:47   ` Matthew Wilcox
2006-10-24 21:51     ` Roland Dreier
2006-10-24 22:12       ` John Partridge
2006-10-24 22:36       ` Matthew Wilcox
2006-10-24 22:43         ` David Miller
2006-10-25 14:15           ` Roland Dreier
2006-10-31 19:02             ` Roland Dreier
2006-10-31 19:53               ` Michael S. Tsirkin
2006-10-31 19:53                 ` Roland Dreier
2006-10-31 19:58                   ` Matthew Wilcox
2006-10-31 20:28                   ` Michael S. Tsirkin
2006-10-31 20:34                 ` Richard B. Johnson
2006-10-31 20:47                   ` Matthew Wilcox
2006-10-31 22:30                     ` Roland Dreier
2006-11-01 16:27                       ` John Partridge
2006-11-01 16:46                         ` Matthew Wilcox
2006-11-01 17:08                           ` John Partridge
2006-11-01 17:14                             ` Matthew Wilcox
2006-11-01 23:04                         ` David Miller
2006-11-02  1:08                           ` John Partridge
2006-10-31 20:50                   ` Michael S. Tsirkin
2006-10-24 22:59         ` [openib-general] " Jason Gunthorpe
2006-10-25 14:04           ` Roland Dreier
2006-10-24 23:09         ` Michael S. Tsirkin
2006-10-24 23:27         ` Jack Steiner
2006-10-25 14:05           ` Roland Dreier
2006-11-02  3:05           ` Jeremy Higdon
2006-10-24 21:01 ` [openib-general] " JWM
2006-10-24 21:24 ` Alan Cox
2006-10-24 21:29   ` Roland Dreier
2006-10-24 21:37     ` Jeff Garzik
2006-10-25  6:30 ` Grant Grundler
2006-10-25 14:11   ` Roland Dreier
2006-10-25 14:18   ` Matthew Wilcox
2006-10-25 17:15     ` Jason Gunthorpe [this message]
2006-10-25 18:22     ` Michael S. Tsirkin

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=20061025171554.GM4054@obsidianresearch.com \
    --to=jgunthorpe@obsidianresearch.com \
    --cc=grundler@parisc-linux.org \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@atrey.karlin.mff.cuni.cz \
    --cc=matthew@wil.cx \
    --cc=openib-general@openib.org \
    --cc=rdreier@cisco.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox