From: Bjorn Helgaas <bhelgaas@google.com>
To: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
Jason Cooper <jason@lakedaemon.net>, Andrew Lunn <andrew@lunn.ch>,
Gregory Clement <gregory.clement@free-electrons.com>,
Ezequiel Garcia <ezequiel.garcia@free-electrons.com>,
Lior Amsalem <alior@marvell.com>,
Maen Suleiman <maen@marvell.com>,
Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
linux-arm <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 2/4] pci: mvebu: allow the enumeration of devices beyond physical bridges
Date: Wed, 22 May 2013 08:31:33 -0600 [thread overview]
Message-ID: <CAErSpo6J2ZFOosTWQ5uN_6aAFziUEFK2Es3e3A8pTtrdrf6bdQ@mail.gmail.com> (raw)
In-Reply-To: <1369228358-32580-3-git-send-email-thomas.petazzoni@free-electrons.com>
On Wed, May 22, 2013 at 7:12 AM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Until now, the Marvell PCIe driver was only allowing the enumeration
> of the devices in the secondary bus of the emulated PCI-to-PCI
> bridge. This works fine when a PCIe device is directly connected into
> a PCIe slot of the Marvell board.
>
> However, when the device connected in the PCIe slot is a physical PCIe
> bridge, beyond which a real PCIe device is connected, it no longer
> worked, as the driver was preventing the Linux PCI core from seeing
> such devices.
>
> This commit fixes that by ensuring that configuration transactions on
> subordinate busses are properly forwarded on the right PCIe interface.
>
> Thanks to this patch, a PCIe card beyond a PCIe bridge, itself beyond
> the emulated PCI-to-PCI bridge is properly detected, with the
> following layout:
>
> -[0000:00]-+-01.0-[01]----00.0
> +-09.0-[02-07]----00.0-[03-07]--+-01.0-[04]--
> | +-05.0-[05]--
> | +-07.0-[06]--
> | \-09.0-[07]----00.0
> \-0a.0-[08]----00.0
>
> Where the PCIe interface that sits beyond the emulated PCI-to-PCI
> bridge at 09.0 allows to access the secondary bus 02, on which there
> is a PCIe bridge that allows to access the 3 to 7 busses, that are
> subordinates to this bridge. And on one of this bus (bus 7), there is
> one real PCIe device connected.
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
> drivers/pci/host/pci-mvebu.c | 31 ++++++++++++++++++++++++++++---
> 1 file changed, 28 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
> index 0bc21b0..c21ca84 100644
> --- a/drivers/pci/host/pci-mvebu.c
> +++ b/drivers/pci/host/pci-mvebu.c
> @@ -554,7 +554,8 @@ mvebu_pcie_find_port(struct mvebu_pcie *pcie, struct pci_bus *bus,
> if (bus->number == 0 && port->devfn == devfn)
> return port;
> if (bus->number != 0 &&
> - port->bridge.secondary_bus == bus->number)
> + bus->number >= port->bridge.secondary_bus &&
> + bus->number <= port->bridge.subordinate_bus)
> return port;
> }
>
> @@ -578,7 +579,18 @@ static int mvebu_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
> if (bus->number == 0)
> return mvebu_sw_pci_bridge_write(port, where, size, val);
>
> - if (!port->haslink || PCI_SLOT(devfn) != 0)
> + if (!port->haslink)
> + return PCIBIOS_DEVICE_NOT_FOUND;
> +
> + /*
> + * On the secondary bus, we don't want to expose any other
> + * device that the device physically connected in the PCIe
s/that/than/ (also below)
> + * slot, visible in slot 0. In slot 1, there's a special
> + * Marvell device that only makes sense when the Armada is
> + * used as a PCIe endpoint.
> + */
> + if (bus->number == port->bridge.secondary_bus &&
> + PCI_SLOT(devfn) != 0)
> return PCIBIOS_DEVICE_NOT_FOUND;
>
> /* Access the real PCIe interface */
> @@ -609,7 +621,20 @@ static int mvebu_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
> if (bus->number == 0)
> return mvebu_sw_pci_bridge_read(port, where, size, val);
>
> - if (!port->haslink || PCI_SLOT(devfn) != 0) {
> + if (!port->haslink) {
> + *val = 0xffffffff;
> + return PCIBIOS_DEVICE_NOT_FOUND;
> + }
> +
> + /*
> + * On the secondary bus, we don't want to expose any other
> + * device that the device physically connected in the PCIe
> + * slot, visible in slot 0. In slot 1, there's a special
> + * Marvell device that only makes sense when the Armada is
> + * used as a PCIe endpoint.
> + */
> + if (bus->number == port->bridge.secondary_bus &&
> + PCI_SLOT(devfn) != 0) {
> *val = 0xffffffff;
> return PCIBIOS_DEVICE_NOT_FOUND;
> }
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-05-22 14:31 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-22 13:12 [PATCH 0/4] Marvell PCIe driver improvements Thomas Petazzoni
2013-05-22 13:12 ` [PATCH 1/4] pci: mvebu: no longer fake the slot location of downstream devices Thomas Petazzoni
2013-05-22 13:12 ` [PATCH 2/4] pci: mvebu: allow the enumeration of devices beyond physical bridges Thomas Petazzoni
2013-05-22 14:31 ` Bjorn Helgaas [this message]
2013-05-22 13:12 ` [PATCH 3/4] pci: mvebu: emulate an empty capability list Thomas Petazzoni
2013-05-22 14:39 ` Bjorn Helgaas
2013-05-22 14:55 ` Thomas Petazzoni
2013-05-22 13:12 ` [PATCH 4/4] pci: mvebu: fix the emulation of the status register Thomas Petazzoni
2013-05-22 14:49 ` Bjorn Helgaas
2013-05-22 13:43 ` [PATCH 0/4] Marvell PCIe driver improvements Jason Cooper
2013-05-22 15:09 ` Gregory CLEMENT
2013-05-22 15:18 ` Jason Cooper
2013-05-23 0:13 ` Willy Tarreau
2013-05-23 6:35 ` Thomas Petazzoni
2013-05-23 6:52 ` Willy Tarreau
2013-05-23 16:46 ` Jason Gunthorpe
2013-05-23 18:57 ` Thomas Petazzoni
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=CAErSpo6J2ZFOosTWQ5uN_6aAFziUEFK2Es3e3A8pTtrdrf6bdQ@mail.gmail.com \
--to=bhelgaas@google.com \
--cc=alior@marvell.com \
--cc=andrew@lunn.ch \
--cc=ezequiel.garcia@free-electrons.com \
--cc=gregory.clement@free-electrons.com \
--cc=jason@lakedaemon.net \
--cc=jgunthorpe@obsidianresearch.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=maen@marvell.com \
--cc=thomas.petazzoni@free-electrons.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;
as well as URLs for NNTP newsgroup(s).