From patchwork Mon Aug 17 10:47:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yijing Wang X-Patchwork-Id: 7024431 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B35DD9F344 for ; Mon, 17 Aug 2015 10:54:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DCE45205F9 for ; Mon, 17 Aug 2015 10:54:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C5FB8205E8 for ; Mon, 17 Aug 2015 10:54:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754795AbbHQKy4 (ORCPT ); Mon, 17 Aug 2015 06:54:56 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:37885 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750937AbbHQKyz (ORCPT ); Mon, 17 Aug 2015 06:54:55 -0400 Received: from 172.24.1.51 (EHLO szxeml434-hub.china.huawei.com) ([172.24.1.51]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BLD17685; Mon, 17 Aug 2015 18:51:26 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml434-hub.china.huawei.com (10.82.67.225) with Microsoft SMTP Server id 14.3.235.1; Mon, 17 Aug 2015 18:51:15 +0800 From: Yijing Wang To: Bjorn Helgaas CC: , , Yijing Wang Subject: [PATCH] PCI/ASPM: Fix a NULL pointer crash on sparc64 Date: Mon, 17 Aug 2015 18:47:58 +0800 Message-ID: <1439808478-23253-1-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.1 MIME-Version: 1.0 X-Originating-IP: [10.175.100.166] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.55D1BCAE.013D, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: b5fe415000b65f4abba0e3380f3cf0ac Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reported-by: Meelis Roos Tested-by: Meelis Roos Signed-off-by: Yijing Wang --- 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; } }