All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	Ashok Raj <ashok.raj@intel.com>,
	Keith Busch <keith.busch@intel.com>,
	"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
	Lukas Wunner <lukas@wunner.de>,
	Michael Jamet <michael.jamet@intel.com>,
	Yehezkel Bernat <yehezkel.bernat@intel.com>,
	Mario.Limonciello@dell.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/7] PCI: Distribute available buses to hotplug capable PCIe downstream ports
Date: Fri, 13 Oct 2017 13:26:18 +0300	[thread overview]
Message-ID: <20171013102618.GA2761@lahna.fi.intel.com> (raw)
In-Reply-To: <20171012183223.GY25517@bhelgaas-glaptop.roam.corp.google.com>

On Thu, Oct 12, 2017 at 01:32:23PM -0500, Bjorn Helgaas wrote:
> On Thu, Oct 12, 2017 at 03:47:03PM +0300, Mika Westerberg wrote:
> > On Wed, Oct 11, 2017 at 06:32:43PM -0500, Bjorn Helgaas wrote:
> > > On Tue, Sep 26, 2017 at 05:17:16PM +0300, Mika Westerberg wrote:
> > > > System BIOS sometimes allocates extra bus space for hotplug capable PCIe
> > > > root/downstream ports. This space is needed if the device plugged to the
> > > > port will have more hotplug capable downstream ports. A good example of
> > > > this is Thunderbolt. Each Thunderbolt device contains a PCIe switch and
> > > > one or more hotplug capable PCIe downstream ports where the daisy chain
> > > > can be extended.
> > > > 
> > > > Currently Linux only allocates minimal bus space to make sure all the
> > > > enumerated devices barely fit there. The BIOS reserved extra space is
> > > > not taken into consideration at all. Because of this we run out of bus
> > > > space pretty quickly when more PCIe devices are attached to hotplug
> > > > downstream ports in order to extend the chain.
> > > > 
> > > > This modifies PCI core so that we distribute the available BIOS
> > > > allocated bus space equally between hotplug capable PCIe downstream
> > > > ports to make sure there is enough bus space for extending the
> > > > hierarchy later on.
> > > 
> > > I think this makes sense in general.  It's a fairly complicated patch,
> > > so my comments here are just a first pass.
> > 
> > Thanks for the comments!
> > 
> > > Why do you limit it to PCIe?  Isn't it conceivable that one could
> > > hot-add a conventional PCI card that contained a bridge leading to
> > > another hotplug slot?  E.g., a PCI card with PCMCIA slot or something
> > > on it?
> > 
> > I guess this could be generalized to such configurations but I wanted to
> > restrict this with PCIe for a couple of reasons. Firstly, I'm able to
> > actually test this ;-) Second, the rules in PCIe are quite simple,
> > whenever you have hotplug bridge (downstream port with a hotplug
> > capability set) you distribute the available bus space with it. With a
> > conventional PCI it is not so clear (at least to me).
> 
> You're testing dev->is_hotplug_bridge, which I think is the right
> approach.  It happens that we currently only set that for PCIe bridges
> with PCI_EXP_SLTCAP_HPC and for some ACPI cases (and a quirk for one
> device).  But in principle we could and probably should set it if we
> can identify a conventional PCI hotplug bridge.  So my suggestion is
> to just remove the explicit PCIe tests.

Fair enough :)

> > > > +	/* Second pass. Bridges that need to be configured. */
> > > > +	list_for_each_entry(dev, &bus->devices, bus_list) {
> > > > +		if (pci_is_bridge(dev)) {
> > > > +			unsigned int buses = 0;
> > > > +
> > > > +			if (pcie_upstream_port(dev)) {
> > > > +				/* Upstream port gets all available buses */
> > > > +				buses = available_buses;
> > > 
> > > I guess this relies on the assumption that there can only be one
> > > upstream port on a bus?  Is that true?  Typically a switch only has a
> > > function 0 upstream port, but something niggles at me like the spec
> > > admits the possibility of a switch with multiple functions of upstream
> > > ports?  I don't know where that is right now (or if it exists), but
> > > I'll try to find it.
> > 
> > My understanding is that there can be only one upstream port on a bus.
> > That said I looked at the spec again and there is this in chapter 7.3.1
> > of PCIe 3.1 spec:
> > 
> >   Switches, and components wishing to incorporate more than eight
> >   Functions at their Upstream Port, are permitted to implement one or
> >   more “virtual switches” represented by multiple Type 1 (PCI-PCI
> >   Bridge) Configuration Space headers as illustrated in Figure 7-2.
> >   These virtual switches serve to allow fan-out beyond eight Functions.
> >   Since Switch Downstream Ports are permitted to appear on any Device
> >   Number, in this case all address information fields (Bus, Device, and
> >   Function Numbers) must be completely decoded to access the correct
> >   register. Any Configuration Request targeting an unimplemented Bus,
> >   Device, or Function must return a Completion with Unsupported Request
> >   Completion Status.
> > 
> > Not sure what it actually means, though. A "virtual switch" to me says
> > it is a switch with one upstream port and multiple downstream ports,
> > just like normal switch. Is this what you meant? Do you understand it so
> > that there can be multiple upstream ports connected to a bus?
> 
> I agree with you; I think that section is just saying that if a
> component needs more then eight functions, it can incorporate a
> switch, so it could have one upstream port, one internal logical bus,
> up to 32 * 8 = 256 downstream ports on that logical bus, and 8
> endpoints below each downstream port.  Of course, there wouldn't be
> enough bus number space for all that.  But I don't think this is
> talking about a multifunction switch upstream port.
> 
> Anyway, I think you're right that there can only be one upstream port
> on a bus, because an upstream port contains link management stuff, and
> it wouldn't make sense to have two upstream ports trying to manage the
> same end of a single link.
> 
> But I would really like to remove the PCIe-specific nature of this
> test somehow so it could work on a conventional PCI topology.

I think we can change the test to check if the bus has only one
non-hotplug bridge and assing resources to it then instead of explictly
checking for PCIe upstream port.

  reply	other threads:[~2017-10-13 10:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-26 14:17 [PATCH 0/7] PCI: Improvements for native PCIe hotplug Mika Westerberg
2017-09-26 14:17 ` [PATCH 1/7] PCI: Do not allocate more buses than available in parent Mika Westerberg
2017-09-26 14:17 ` [PATCH 2/7] PCI: Introduce pcie_upstream_port() Mika Westerberg
2017-09-26 14:17 ` [PATCH 3/7] PCI: Distribute available buses to hotplug capable PCIe downstream ports Mika Westerberg
2017-10-11 23:32   ` Bjorn Helgaas
2017-10-12  9:50     ` David Laight
2017-10-12 12:47     ` Mika Westerberg
2017-10-12 18:32       ` Bjorn Helgaas
2017-10-13 10:26         ` Mika Westerberg [this message]
2017-09-26 14:17 ` [PATCH 4/7] PCI: Distribute available resources " Mika Westerberg
2017-09-26 14:17 ` [PATCH 5/7] PCI: pciehp: Fix race condition handling surprise link down Mika Westerberg
2017-09-26 14:17 ` [PATCH 6/7] PCI: pciehp: Do not clear Presence Detect Changed during initialization Mika Westerberg
2017-09-26 14:17 ` [PATCH 7/7] PCI: pciehp: Check that the device is really present before touching it Mika Westerberg
2017-10-09  8:47 ` [PATCH 0/7] PCI: Improvements for native PCIe hotplug Mika Westerberg

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=20171013102618.GA2761@lahna.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=Mario.Limonciello@dell.com \
    --cc=ashok.raj@intel.com \
    --cc=bhelgaas@google.com \
    --cc=helgaas@kernel.org \
    --cc=keith.busch@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=michael.jamet@intel.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=yehezkel.bernat@intel.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.