From patchwork Thu Aug 20 21:21:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 509172 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id DA417140773 for ; Fri, 21 Aug 2015 07:21:19 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=NJPgRtJI; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752837AbbHTVVR (ORCPT ); Thu, 20 Aug 2015 17:21:17 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:35423 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751955AbbHTVVQ (ORCPT ); Thu, 20 Aug 2015 17:21:16 -0400 Received: by pacdd16 with SMTP id dd16so27915453pac.2 for ; Thu, 20 Aug 2015 14:21:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=cEGDG7bxhyAOf6KO6nikqYrL66RR5TKpmjeCXb/4Ftc=; b=NJPgRtJI6/9BFKeaDwCoqq4xR4/IWNhZZejMvDeofCvQqTbXclAYQOzqGNZ6t/3X41 tWG+8huPfhTAZ0wAUDv9pNh9D4jULKG6wtdxB/2kpVc1HYq9Oc5/VOwo2Bv/tr5tKuNz BQDhaxWNiWQu4Bs+Mi4mxSHFTNaUWzXvv2OmkdWQ5WMAetwBLawnVZmtqTzU3tDRCYNL ee5xJAgTqbJJeWOiG9UeBKeIjoA+MWIYcKvoIrpzLM/3Y763MMyn6j4gybXgZA0MvuHZ hDNMI3GsSWP+VCciThoWuLyXrKc6JaAh0s+kz465E/nMFj2oDWC5iXCAtBybxqmM75BN 8beA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=cEGDG7bxhyAOf6KO6nikqYrL66RR5TKpmjeCXb/4Ftc=; b=lDsmyIhYBOyoU1zwdwHQyD1t9XiOwpB/xbFwW50AGlB6y7/eFiqQ4wCEuie1cQx4oy 9XQ5W5tyVYdyv5raRFAATNeKC5y0qWbOKiHizXiQ5Eg0O6EAvgyjT77/YaUkZLTpIEiQ L7r6TTwN6PyMqsIi1c8edxRb3bXtdnGv5DZmPymD5ThlTc9M6BoA8f5/iSbl0paNnf/o 73ebGOHSX5WzhusCIhFbzISPkn/+79IUIB4GwggADwmlb1P7L6qL3/rSko5wxalErJu+ Mwi0bh/8bLCSsO9bU64syhISg5i7UIZOSLvwPNznvwZc1mBcAxwlhEgWLtKjUotPdLBH bPRg== X-Gm-Message-State: ALoCoQmSzJukuVME+x3gHuGpt2BgNv55IQpL9vk3vg6wmrSag9rIpxeJVnLZLMuXftv/6C6rnQ08 X-Received: by 10.66.140.8 with SMTP id rc8mr10380640pab.34.1440105675773; Thu, 20 Aug 2015 14:21:15 -0700 (PDT) Received: from google.com ([69.84.245.29]) by smtp.gmail.com with ESMTPSA id dw2sm5395253pab.18.2015.08.20.14.21.11 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 20 Aug 2015 14:21:12 -0700 (PDT) Date: Thu, 20 Aug 2015 16:21:09 -0500 From: Bjorn Helgaas To: David Miller Cc: wangyijing@huawei.com, linux-pci@vger.kernel.org, mroos@linux.ee, sparclinux@vger.kernel.org, eric.snowberg@oracle.com, benh@kernel.crashing.org Subject: Re: [PATCH] PCI/ASPM: Fix a NULL pointer crash on sparc64 Message-ID: <20150820212109.GB14810@google.com> References: <20150820.114042.1327127338658980319.davem@davemloft.net> <20150820202135.GA14810@google.com> <20150820.135832.47467691959908917.davem@davemloft.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150820.135832.47467691959908917.davem@davemloft.net> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org On Thu, Aug 20, 2015 at 01:58:32PM -0700, David Miller wrote: > From: Bjorn Helgaas > Date: Thu, 20 Aug 2015 15:21:35 -0500 > > > On Thu, Aug 20, 2015 at 11:40:42AM -0700, David Miller wrote: > >> From: Bjorn Helgaas > >> Date: Thu, 20 Aug 2015 11:23:43 -0700 > >> > >> > On Thu, Aug 20, 2015 at 10:47 AM, David Miller wrote: > >> >> From: Bjorn Helgaas > >> >> Date: Thu, 20 Aug 2015 00:48:00 -0500 > >> >> > >> >>> [+cc Dave, Eric, Ben, sparclinux] > >> >> > >> >> I think the comment is terrible. > >> > > >> > I'll update the comment if you suggest some text. Do you object > >> > mainly to the mention of the specific systems? > >> > >> "PCI root complex can not be assumed to be instantiated in the PCI bus > >> hierarchy." > > > > AIUI, the root complex itself (as distinct from root ports) doesn't > > normally appear in the PCI hierarchy, so I reworded it as follows. I hope > > this helps address your objection, but if not, I can try again. > > This is fine, but it was the comment we were talking about adjusting not > the commit message :-) Oh, sorry! I totally misread that. Here's another try. commit 27ff9f3e0ab34a75a3420bffd3eb5316de2e4d92 Author: Yijing Wang Date: Mon Aug 17 18:47:58 2015 +0800 PCI: Tolerate hierarchies with no Root Port We should not assume any particular hardware topology. Commit d0751b98dfa3 ("PCI: Add dev->has_secondary_link to track downstream PCIe links") relied on the assumption that every PCIe hierarchy is rooted at a Root Port. But we can't rely on any assumption about what hardware we will find; we just have to deal with the world as it is. On some platforms, PCIe devices (endpoints, switch upstream ports, etc.) appear directly on the root bus, and there is no Root Port in the PCI bus hierarchy. For example, Meelis observed these top-level devices on a Sparc V245: 0000:02:00.0 PCI bridge to [bus 03-0d] Switch Upstream Port 0001:02:00.0 PCI bridge to [bus 03] PCIe to PCI/PCI-X Bridge These devices *look* like they have links going upstream, but there really are no upstream devices. In set_pcie_port_type(), we used the parent device to figure out which side of a switch port has a link, so if the parent device did not exist, we dereferenced a NULL parent pointer. Check whether the parent device exists before dereferencing it. Meelis observed this oops on Sparc V245 and T2000. Ben Herrenschmidt says this is also possible on IBM PowerVM guests on PowerPC. [bhelgaas: changelog, comment] Link: http://lkml.kernel.org/r/alpine.LRH.2.20.1508122118210.18637@math.ut.ee Reported-by: Meelis Roos Tested-by: Meelis Roos Signed-off-by: Yijing Wang Signed-off-by: Bjorn Helgaas Acked-by: David S. Miller --- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index cefd636..b978bbf 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -997,7 +997,12 @@ 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) + + /* + * Usually there's a parent device (Root Port or Switch + * Downstream Port), but we can't assume one exists. + */ + if (parent && !parent->has_secondary_link) pdev->has_secondary_link = 1; } }