Subject: [PATCH] ARM64: PCI: do not enable resources on PROBE_ONLY systems

From: [email-masked] (Bjorn Helgaas)
Date: Thu, 3 Sep 2015 11:35:04 -0500

On Mon, Aug 31, 2015 at 11:49:20AM -0500, Bjorn Helgaas wrote:
> On Mon, Aug 31, 2015 at 11:33 AM, Lorenzo Pieralisi
> <[email-masked]> wrote:
> > On Mon, Aug 31, 2015 at 02:28:03PM +0100, Bjorn Helgaas wrote:
> >> On Sat, Aug 29, 2015 at 01:44:57PM +0100, Lorenzo Pieralisi wrote:
> >> > On Fri, Aug 28, 2015 at 10:14:44PM +0100, Bjorn Helgaas wrote:
> >> > > On Thu, Jul 30, 2015 at 02:13:59PM +0100, Lorenzo Pieralisi wrote:
> >> > > > On ARM64 PROBE_ONLY PCI systems resources are not currently claimed,
> >> > > > therefore they can't be enabled since they do not have a valid
> >> > > > parent pointer; this in turn prevents enabling PCI devices on
> >> > > > ARM64 PROBE_ONLY systems, causing PCI devices initialization to
> >> > > > fail.
> >> > >
> >> > > Where does arm64 claim PCI BAR resources for the non-PROBE_ONLY case?
> >> >
> >> > arm64 (and arm) does not claim resources in arch code, they are always
> >> > assigned in the respective host controllers (or the pcibios on arm),
> >> > except for the PCI generic host when in PROBE_ONLY mode, where resources
> >> > are neither claimed nor assigned (the reason for this patch to exist).
> >> > ...
> >> >
> >> > > I know it must be there somewhere, but I don't see it.
> >> >
> >> > It is not there, it is done in the host controllers by assigning the
> >> > resources (which also "claim" them by assigning the parent pointer).
> >>
> >> The host controller drivers should claim the apertures forwarded to
> >> the PCI bus.  For pci-host-generic, this happens when
> >> gen_pci_parse_request_of_pci_ranges() calls devm_request_resource().
> >
> > Yes, the generic host claims the apertures at DT probing time.
> >
> >> But that doesn't do anything for the BARs of the PCI devices
> >> themselves, of course.
> >>
> >> If this patch fixes a problem that will occur in the future, when we
> >> add arm/arm64 code to claim BARs, let's make this patch part of that
> >> series.  If it fixes a problem in the current tree, I'll merge it now,
> >> but so far I haven't been able to make the connection between this
> >> patch and a problem in the current code.
> >
> > It fixes a problem in the current tree (I mean when the PCI pull is
> > merged - it contains code that enables PCI host generic on arm64),
> > since without it PROBE_ONLY systems (ie PCI host generic on kvmtool) would
> > try to enable resources and fail, since the resources were not claimed.
> >
> > It works the same way as arm, I will rework both arches when I am done
> > refactoring the resource claiming implementation.
> >
> > Will picked it up already I do not know what's the best way to
> > merge it I guess it can go via the arm64 tree if you do not have any
> > objections.
> 
> OK, if it fixes a problem in my v4.3 pull request, we need to merge
> it.  I missed the connection, probably because I was browsing the
> v4.2-rc1 tree, which wouldn't have those changes.
> 
> It's OK with me to merge it via the arm64 tree.

Do you need me to do anything with this?  It'd be nice to get it in
before -rc1.  The PCI changes have already been merged, and it'd be
nice to mention the commit that this fixes.

Bjorn