From patchwork Fri Mar 6 17:58:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murali Karicheri X-Patchwork-Id: 5956981 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 6D1C59F36A for ; Fri, 6 Mar 2015 17:58:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B706A20397 for ; Fri, 6 Mar 2015 17:58:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E28A320392 for ; Fri, 6 Mar 2015 17:58:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752924AbbCFR6I (ORCPT ); Fri, 6 Mar 2015 12:58:08 -0500 Received: from bear.ext.ti.com ([192.94.94.41]:43569 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751278AbbCFR6I (ORCPT ); Fri, 6 Mar 2015 12:58:08 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id t26Hw13W009578; Fri, 6 Mar 2015 11:58:01 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id t26Hw0ZM031180; Fri, 6 Mar 2015 11:58:00 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.224.2; Fri, 6 Mar 2015 11:57:59 -0600 Received: from [172.22.170.225] (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id t26HvxP4001189; Fri, 6 Mar 2015 11:57:59 -0600 Message-ID: <54F9EAA8.30007@ti.com> Date: Fri, 6 Mar 2015 12:58:00 -0500 From: Murali Karicheri User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: Guenter Roeck CC: Fengguang Wu , Bjorn Helgaas , LKP , , Subject: Re: [PCI] BUG: unable to handle kernel References: <20150306060631.GD28187@wfg-t540p.sh.intel.com> <54F9C407.5020602@ti.com> <54F9CC6B.5070803@ti.com> <20150306165504.GA30094@roeck-us.net> In-Reply-To: <20150306165504.GA30094@roeck-us.net> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, T_TVD_MIME_EPI, 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 On 03/06/2015 11:55 AM, Guenter Roeck wrote: > On Fri, Mar 06, 2015 at 10:48:59AM -0500, Murali Karicheri wrote: > [ ... ] > >> > From 098b4f5e4ab9407fbdbfcca3a91785c17e25cf03 Mon Sep 17 00:00:00 2001 >> From: Murali Karicheri >> Date: Fri, 6 Mar 2015 10:23:08 -0500 >> Subject: [PATCH] pci: of : fix kernel crash >> >> This is a debug patch to root cause the kernel crash >> >> commit 0b2af171520e5d5e7d5b5f479b90a6a5014d9df6 >> >> PCI: Update DMA configuration from DT >> >> Signed-off-by: Murali Karicheri >> --- >> drivers/of/of_pci.c | 8 ++++++++ >> drivers/pci/host-bridge.c | 5 +++++ >> 2 files changed, 13 insertions(+) >> >> diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c >> index 86d3c38..5a59fb8 100644 >> --- a/drivers/of/of_pci.c >> +++ b/drivers/of/of_pci.c >> @@ -129,6 +129,14 @@ void of_pci_dma_configure(struct pci_dev *pci_dev) >> struct device *dev =&pci_dev->dev; >> struct device *bridge = pci_get_host_bridge_device(pci_dev); >> >> + if (!bridge || !bridge->parent) { >> + if (!bridge) >> + pr_err("PCI bridge not found\n"); >> + if (!bridge->parent) >> + pr_err("PCI bridge parent not found\n"); > > You'll see a crash here if bridge is NULL. Maybe add an else before the second > if statement ? Also, dev_err might be a bit more useful and would be available. > Fixed and attached. Murali > Thanks, > Guenter > >> + return; >> + } >> + >> of_dma_configure(dev, bridge->parent->of_node); >> pci_put_host_bridge_device(bridge); >> } >> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c >> index 3e5bbf9..ef2ab51 100644 >> --- a/drivers/pci/host-bridge.c >> +++ b/drivers/pci/host-bridge.c >> @@ -28,6 +28,11 @@ struct device *pci_get_host_bridge_device(struct pci_dev *dev) >> struct pci_bus *root_bus = find_pci_root_bus(dev->bus); >> struct device *bridge = root_bus->bridge; >> >> + if (!bridge) { >> + pr_err("PCI: bridge not found\n"); >> + return NULL; >> + } >> + >> kobject_get(&bridge->kobj); >> return bridge; >> } >> -- >> 1.7.9.5 >> > From 4965a4580e0ffe13e7e6e9fd58d6e56b08c730c4 Mon Sep 17 00:00:00 2001 From: Murali Karicheri Date: Fri, 6 Mar 2015 10:23:08 -0500 Subject: [PATCH] pci: of : fix kernel crash This is a debug patch to root cause the kernel crash commit 0b2af171520e5d5e7d5b5f479b90a6a5014d9df6 PCI: Update DMA configuration from DT Signed-off-by: Murali Karicheri --- drivers/of/of_pci.c | 9 +++++++++ drivers/pci/host-bridge.c | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c index 86d3c38..6e1b111 100644 --- a/drivers/of/of_pci.c +++ b/drivers/of/of_pci.c @@ -129,6 +129,15 @@ void of_pci_dma_configure(struct pci_dev *pci_dev) struct device *dev = &pci_dev->dev; struct device *bridge = pci_get_host_bridge_device(pci_dev); + if (!bridge || !bridge->parent) { + if (!bridge) + dev_err(&pci_dev->dev, "PCI bridge not found\n"); + else if (!bridge->parent) + dev_err(&pci_dev->dev, + "PCI bridge parent not found\n"); + return; + } + of_dma_configure(dev, bridge->parent->of_node); pci_put_host_bridge_device(bridge); } diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c index 3e5bbf9..ba642b8 100644 --- a/drivers/pci/host-bridge.c +++ b/drivers/pci/host-bridge.c @@ -28,6 +28,11 @@ struct device *pci_get_host_bridge_device(struct pci_dev *dev) struct pci_bus *root_bus = find_pci_root_bus(dev->bus); struct device *bridge = root_bus->bridge; + if (!bridge) { + dev_err(&dev->dev, "PCI: bridge not found\n"); + return NULL; + } + kobject_get(&bridge->kobj); return bridge; } -- 1.7.9.5