From patchwork Tue Jan 2 18:44:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ray Jui X-Patchwork-Id: 10141207 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2D89E6020A for ; Tue, 2 Jan 2018 18:44:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25B3F28A5F for ; Tue, 2 Jan 2018 18:44:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17F0D28DD4; Tue, 2 Jan 2018 18:44:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B1DA28A5F for ; Tue, 2 Jan 2018 18:44:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751131AbeABSod (ORCPT ); Tue, 2 Jan 2018 13:44:33 -0500 Received: from mail-qk0-f193.google.com ([209.85.220.193]:46585 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751127AbeABSoc (ORCPT ); Tue, 2 Jan 2018 13:44:32 -0500 Received: by mail-qk0-f193.google.com with SMTP id b132so32466205qkc.13 for ; Tue, 02 Jan 2018 10:44:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=NnPjuWlUYxVFJa/y1uuUr2e7JkBsaf2uIkmy5spsgXc=; b=LkNUmFt5rf0++a9GojHhQgAjWhmOCr81HzxK/MMIZPFszq1yXvse6x8rdlCrejMkTl mkBQ+9O0APcuT6J9O16LuuICTM6IXRrbkN4n7GERzB3znE2PIWhQJwvR6NVYhGC68Tf5 8U4eTosozaYmiGZDDsGAyPDJ8tnfbjt6s6RrQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=NnPjuWlUYxVFJa/y1uuUr2e7JkBsaf2uIkmy5spsgXc=; b=VuDwAcuPwmSBFKPOayp3WZSNmyzVWW9gOd0WJPiv+ALF3gR/mtjMIxINLgpKMA0PES /C1BK4MpxpIPTQD5QwiZm1Q5KRtKJX410hiOX4wDOhlUm85jJosc789khphlhdPO9uX4 OrwBX1YpLPPheJzXlzlCD+6QAn9m16Q+5A9i+yYxh5HNoY6mGIbcmJb5SKNWn29ESF7l 8nhFbRK5vDOhCxjUJrAEpT09c1eyILjaNPeCDmwUScanWgiIzUsnSwbAMa9y4hF/RE0a 5WxcisJFaZ9O6cSE1EOzHk6j4mn5UxWxTJOkQ1tbcJTY9Mnl4cuZdKZj4acntJqZVPZ7 Hjhw== X-Gm-Message-State: AKGB3mKaxVIsgIBZ352mR1+9PyiFBq60KEEXPTn2o1631OraI2+4B9mj 7+mGBvI2wCaTJsC9weJH5mm1VA== X-Google-Smtp-Source: ACJfBouijdwmH0H0/50OV+stDQOWuqeCX0KJBcTNuoJuczxPwbNX99Az1oUOA5lGhegsZ3jsR0NYcg== X-Received: by 10.55.31.86 with SMTP id f83mr61287979qkf.79.1514918672046; Tue, 02 Jan 2018 10:44:32 -0800 (PST) Received: from [10.136.8.227] ([192.19.224.250]) by smtp.gmail.com with ESMTPSA id v73sm21250961qkg.34.2018.01.02.10.44.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jan 2018 10:44:30 -0800 (PST) Subject: Re: Regression: NULL pointer dereference caused by iproc_pcie_map_dma_ranges To: =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= Cc: Oza Oza , Bjorn Helgaas , Scott Branden , Linux PCI , bcm-kernel-feedback-list , Jon Mason , Hauke Mehrtens References: From: Ray Jui Message-ID: <6707e532-7a5e-261c-4d5b-950d0ccc8f66@broadcom.com> Date: Tue, 2 Jan 2018 10:44:27 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Rafal, Can you please give the following patch a try to see if that fixes the issue? Thanks. From f91de124bc8fb5645d7dbbfd68a9a68617955749 Mon Sep 17 00:00:00 2001 From: Ray Jui Date: Tue, 2 Jan 2018 10:36:03 -0800 Subject: [PATCH] PCI: iproc: Fix NULL pointer dereference for BCMA With the inbound DMA mapping supported added, the iProc PCIe driver parses DT property "dma-ranges" through call to "of_pci_dma_range_parser_init". In the case of BCMA, this results in a NULL pointer deference due to a missing of_node. Fix this by adding a guard in pcie-iproc-platform.c to only enable the inbound DMA mapping logic when DT property "dma-ranges" is present fixes: dd9d4e7498de3 ("PCI: iproc: Add inbound DMA mapping support") Signed-off-by: Ray Jui Tested-by: Rafał Miłecki --- drivers/pci/host/pcie-iproc-platform.c | 3 +++ drivers/pci/host/pcie-iproc.c | 8 +++++--- drivers/pci/host/pcie-iproc.h | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/pci/host/pcie-iproc-platform.c b/drivers/pci/host/pcie-iproc-platform.c index a5073a9..235c545 100644 --- a/drivers/pci/host/pcie-iproc-platform.c +++ b/drivers/pci/host/pcie-iproc-platform.c @@ -92,6 +92,9 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev) pcie->need_ob_cfg = true; } + if (of_property_read_bool(np, "dma-ranges")) + pcie->need_ib_cfg = true; + /* PHY use is optional */ pcie->phy = devm_phy_get(dev, "pcie-phy"); if (IS_ERR(pcie->phy)) { diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c index 935909b..7583606 100644 --- a/drivers/pci/host/pcie-iproc.c +++ b/drivers/pci/host/pcie-iproc.c @@ -1378,9 +1378,11 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) } } - ret = iproc_pcie_map_dma_ranges(pcie); - if (ret && ret != -ENOENT) - goto err_power_off_phy; + if (pcie->need_ib_cfg) { + ret = iproc_pcie_map_dma_ranges(pcie); + if (ret && ret != -ENOENT) + goto err_power_off_phy; + } #ifdef CONFIG_ARM pcie->sysdata.private_data = pcie; diff --git a/drivers/pci/host/pcie-iproc.h b/drivers/pci/host/pcie-iproc.h index a6b55ce..4ac6282 100644 --- a/drivers/pci/host/pcie-iproc.h +++ b/drivers/pci/host/pcie-iproc.h @@ -74,6 +74,7 @@ struct iproc_msi; * @ob: outbound mapping related parameters * @ob_map: outbound mapping related parameters specific to the controller * + * @need_ib_cfg: indicates SW needs to configure the inbound mapping window * @ib: inbound mapping related parameters * @ib_map: outbound mapping region related parameters * @@ -101,6 +102,7 @@ struct iproc_pcie { struct iproc_pcie_ob ob; const struct iproc_pcie_ob_map *ob_map; + bool need_ib_cfg; struct iproc_pcie_ib ib; const struct iproc_pcie_ib_map *ib_map;