All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bhelgaas@google.com>
To: Guenter Roeck <groeck@juniper.net>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	Yinghai Lu <yinghai@kernel.org>
Subject: Re: BAR 7 io space assignment errors
Date: Mon, 18 May 2015 10:55:46 -0500	[thread overview]
Message-ID: <20150518155546.GM31666@google.com> (raw)
In-Reply-To: <20150516164151.GA2042@svl-evodev-groeck.juniper.net>

On Sat, May 16, 2015 at 09:41:51AM -0700, Guenter Roeck wrote:
> Hi Bjorn,
> 
> On Sat, May 16, 2015 at 08:12:09AM -0500, Bjorn Helgaas wrote:
> > > The problem is that I can not reprogram PCI_IO_BASE on 0000:00:00.0.
> > > Here is a debug log:
> > > 
> > > pci 0000:00:00.0: io base written 0xe0f0 reads back as 0x0
> > > pci 0000:00:00.0: io base written 0xf000 reads back as 0x0
> > 
> > That's odd; that's a non-conformant bridge.  Per spec (PCI-to-PCI Bridge
> > r1.2, sec 3.2.5.6), for a bridge that implements an I/O address range, the
> > upper four bits of I/O Base is writable.
> > 
> > But I suspect this bridge is discovered via OF and there's something broken
> > about how config access is done.  That's arch code and I don't know much
> > about it.
> > 
> Maybe. I'll dig into it some more.
> 
> > Or maybe the hardware itself is not quite spec-compliant, although it would
> > be strange to have I/O aperture addresses hard-wired into the hardware.  
> > 
> This is a Freesale P2020. We should have the specification somewhere.
> Guess it may be time for some digging in there.

Hmm, I spoke too fast above.  I assumed that we checked whether the
bridge actually implements an I/O aperture, but pci_read_bridge_io()
doesn't do that.  On a bridge that doesn't implement an I/O range, both I/O
Base and I/O Limit must be read-only zeroes.  But pci_read_bridge_io()
doesn't test whether they are writable, so it treats that situation as an
enabled [io 0x0000-0x0fff] window.

pci_bridge_check_ranges() *does* check for writability, but it might be
too late to make a difference in this case.  I would like to get rid of 
pci_bridge_check_ranges() anyway; it seems like whatever it does should be
folded into pci_read_bridge_io() and pci_read_bridge_mmio_pref().

Bottom line, 

1) I don't know whether your bridge actually implements an I/O aperture,
and 2) I think pci_read_bridge_io() should check for writability.

> > > The io ranges of ports behind it (ie the ones below) are programmable.
> > > I can try to find out if there is a means to program the io range
> > > on 0000:00:00.0, but I would prefer to just disable the io range
> > > fpci_bridge_check_rangesor
> > > everything downstream of it.
> > 
> > As far as I can tell, you don't need any I/O port space anywhere in this
> > hierarchy.  If you could disable this host bridge I/O aperture:
> > 
> >   PCI host bridge /pcie@a000 (primary) ranges:
> >     IO 0x0000000fffc00000..0x0000000fffc0ffff -> 0x0000000000000000
> > 
> > e.g., remove it from the OF description of the bridge, the core could know
> > that it needn't bother trying to assign I/O space.  It might not be smart
> > enough to notice that today, but it would at least be possible in
> > principle.
> > 
> I tried this. Unfortunately, the PCI core code still tries to assign
> the IO space to all ports downstream of it, and I end up with the same
> problem, ie lots of BAR 7 messages.

Yep, sounds like the core isn't smart enough to notice that.  But it
*could* and probably should be.

> PCI host bridge /pcie@a000 (primary) ranges:
>  MEM 0x0000000c00000000..0x0000000c3fffffff -> 0x0000000080000000 
> ...
> pci 0000:00:00.0: PCI bridge to [bus 01-ff]
> pci 0000:00:00.0:   bridge window [io  0x0000-0x0fff]
> pci 0000:00:00.0:   bridge window [mem 0xc00000000-0xc3fffffff]
> pci 0000:00:00.0:   bridge window [mem 0x00000000-0x000fffff 64bit pref]
> 
> Partially this is because pci_read_bridge_io() doesn't care if IO is supported
> or not - it reads 0x0 from the IO_BASE/IO_LIMIT register and interprets it as 
> 0x0000-0x0fff range. Even if I change pci_read_bridge_io() to not add an io
> range if base == limit == 0, the result is not much better. Then I get
> 
> pci 0000:00:00.0: PCI bridge to [bus 01-ff]
> pci 0000:00:00.0:   bridge window [mem 0xc00000000-0xc3fffffff]
> pci 0000:00:00.0:   bridge window [mem 0x00000000-0x000fffff 64bit pref]
> 
> and no BAR 7 message for the root port, but still for all other ports.

Right.  All the other bridges (01:00.0, 02:00.0, etc.) have a non-zero I/O
Base, so they clearly implement I/O apertures.  We should make the core
smart enough to stop trying to assign I/O space when there's none
available.

We just have to figure out the best way to do that.  If we find a bridge
(either host bridge or PCI-PCI bridge) that doesn't implement an I/O
aperture, we should be able to just ignore I/O space below it.  If we find
one with a disabled aperture, we probably want to size the downstream
devices and potentially enable the aperture.

Bjorn

  reply	other threads:[~2015-05-18 15:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-15 17:28 BAR 7 io space assignment errors Guenter Roeck
2015-05-15 19:25 ` Bjorn Helgaas
2015-05-15 20:04   ` Guenter Roeck
2015-05-15 22:11     ` Bjorn Helgaas
2015-05-16  2:27       ` Guenter Roeck
2015-05-16 13:12         ` Bjorn Helgaas
2015-05-16 16:41           ` Guenter Roeck
2015-05-18 15:55             ` Bjorn Helgaas [this message]
2015-05-19  0:18               ` Guenter Roeck

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=20150518155546.GM31666@google.com \
    --to=bhelgaas@google.com \
    --cc=groeck@juniper.net \
    --cc=linux-pci@vger.kernel.org \
    --cc=yinghai@kernel.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.