From: Bjorn Helgaas <bhelgaas@google.com>
To: Yijing Wang <wangyijing@huawei.com>
Cc: linux-pci@vger.kernel.org, mroos@linux.ee,
"David S. Miller" <davem@davemloft.net>,
sparclinux@vger.kernel.org,
Eric Snowberg <eric.snowberg@oracle.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: Re: [PATCH] PCI/ASPM: Fix a NULL pointer crash on sparc64
Date: Tue, 18 Aug 2015 13:49:43 -0500 [thread overview]
Message-ID: <20150818184943.GA26431@google.com> (raw)
In-Reply-To: <1439808478-23253-1-git-send-email-wangyijing@huawei.com>
[+cc Dave, Eric, Ben, sparclinux]
On Mon, Aug 17, 2015 at 06:47:58PM +0800, Yijing Wang wrote:
> Commit d0751b98dfa3 ("PCI: Add dev->has_secondary_link to
> track downstream PCIe links")assumed root port is always
> the top device in pcie tree. But on sparc64 V245 and T2000
> the pcie tree has no root port device in top level, the
> upstream port device is connected directly to root bus.
> So we may get NULL parent for this upstream port device.
>
> Upstream port ------ Downstream port ------PCIe-PCI bridge
This is an unusual, possibly even illegal, PCIe topology because it
lacks a Root Port at the top of the hierarchy. From lspci output [1]
collected by Meelis, the top-level devices are:
0000:02:00.0 PCI bridge to [bus 03-0d] Upstream Port
0001:02:00.0 PCI bridge to [bus 03] PCIe to PCI/PCI-X Bridge
0001:02:00.2 PCI bridge to [bus 04] PCIe to PCI/PCI-X Bridge
There *should* be two Root Ports, one leading to 0000:02 and another
leading to 0001:02.1
I suspect this is an artifact of the way sparc and powerpc use OF to
enumerate PCI. I suspect there actually *is* a Root Port in the
hardware: why would the hardware designers go to the trouble of
working out special-case rules and behavior for a non-standard PCIe
hierarchy when it would be much easier to reuse existing hardware?
As long as the Root Port is configured correctly, Linux can pretend it
doesn't exist and things will mostly just work. Except for a few
corner cases like this one.
I really hate to put special case workarounds like this patch in the
generic code. It's likely that we'd trip over the same issue again in
other areas, e.g., MPS or other configuration.
Sparc & powerpc guys, any input on this?
Bjorn
[1] http://lkml.kernel.org/r/alpine.LRH.2.20.1508131111570.9039@math.ut.ee
> Reported-by: Meelis Roos <mroos@linux.ee>
> Tested-by: Meelis Roos <mroos@linux.ee>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> ---
> drivers/pci/probe.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 51ebb97..cd54298 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1003,7 +1003,10 @@ void set_pcie_port_type(struct pci_dev *pdev)
> else if (type == PCI_EXP_TYPE_UPSTREAM ||
> type == PCI_EXP_TYPE_DOWNSTREAM) {
> parent = pci_upstream_bridge(pdev);
> - if (!parent->has_secondary_link)
> + /* For sparc64 V245 and T2000, upstream port may be
> + * the top level device, connect to root bus directly.
> + */
> + if (parent && !parent->has_secondary_link)
> pdev->has_secondary_link = 1;
> }
> }
> --
> 1.7.1
>
next prev parent reply other threads:[~2015-08-18 18:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-17 10:47 [PATCH] PCI/ASPM: Fix a NULL pointer crash on sparc64 Yijing Wang
2015-08-18 18:49 ` Bjorn Helgaas [this message]
2015-08-18 19:10 ` David Miller
2015-08-19 22:16 ` Bjorn Helgaas
2015-08-19 22:29 ` Benjamin Herrenschmidt
2015-08-20 6:01 ` Bjorn Helgaas
2015-08-20 6:38 ` Benjamin Herrenschmidt
2015-08-20 6:44 ` Kjetil Oftedal
2015-08-20 17:51 ` David Miller
2015-08-20 17:50 ` David Miller
2015-08-20 5:48 ` Bjorn Helgaas
2015-08-20 17:47 ` David Miller
2015-08-20 18:23 ` Bjorn Helgaas
2015-08-20 18:40 ` David Miller
2015-08-20 20:21 ` Bjorn Helgaas
2015-08-20 20:58 ` David Miller
2015-08-20 21:21 ` Bjorn Helgaas
2015-08-20 21:38 ` David Miller
2015-08-21 1:48 ` wangyijing
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=20150818184943.GA26431@google.com \
--to=bhelgaas@google.com \
--cc=benh@kernel.crashing.org \
--cc=davem@davemloft.net \
--cc=eric.snowberg@oracle.com \
--cc=linux-pci@vger.kernel.org \
--cc=mroos@linux.ee \
--cc=sparclinux@vger.kernel.org \
--cc=wangyijing@huawei.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).