Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD5D9C43441 for ; Tue, 27 Nov 2018 03:52:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9CC9520989 for ; Tue, 27 Nov 2018 03:52:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="qsATxvnU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9CC9520989 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-pci-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727670AbeK0OtX (ORCPT ); Tue, 27 Nov 2018 09:49:23 -0500 Received: from hqemgate14.nvidia.com ([216.228.121.143]:5806 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727630AbeK0OtX (ORCPT ); Tue, 27 Nov 2018 09:49:23 -0500 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 26 Nov 2018 19:52:54 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Mon, 26 Nov 2018 19:52:53 -0800 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 26 Nov 2018 19:52:53 -0800 Received: from [10.24.71.180] (172.20.13.39) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 27 Nov 2018 03:52:49 +0000 Subject: Re: [PATCH V2] PCI: dwc: Don't hard-code DBI/ATU offset To: Stephen Warren , Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , Bjorn Helgaas CC: , Manikanta Maddireddy , Stephen Warren References: <20181120175750.26141-1-swarren@wwwdotorg.org> <1f407736-7cfd-0aa7-202f-ab70314be422@wwwdotorg.org> X-Nvconfidentiality: public From: Vidya Sagar Message-ID: Date: Tue, 27 Nov 2018 09:22:46 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <1f407736-7cfd-0aa7-202f-ab70314be422@wwwdotorg.org> X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL103.nvidia.com (172.20.187.11) To HQMAIL101.nvidia.com (172.20.187.10) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: en-US DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1543290774; bh=0AM6QtYOghPQ+WAs/4lAP4ujqFVy4XxQN5Jc2sau78E=; h=X-PGP-Universal:Subject:To:CC:References:X-Nvconfidentiality:From: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type: Content-Transfer-Encoding:Content-Language; b=qsATxvnUHRHcGUuIuB5ziAgnYR5ZAKVcPfDFqRoYYKErGf28BkBtOC+ANggc9/Es0 NGECAH4gXi1LnoOcXIZxWWKwUrmJ8ApFjhxbKjAcwbjv4ole43P3vhH1b2LpXpf7/5 dKix8WFDMB5UZrThqUPH1RYg6GXDhkBv4FUNNFhLXHWAzR8AWxrYqdxC7uaGxRDka+ NOcycMO4JgxuCyJyKebGmh/986VjlLiFRCWyodcyX8UPEt0BzMi28TqnIfboTppwaR xEttdX8qt+bNfYd/RrZ4q88VaKqhrW0VlELyhlcGYJ4ph65eEFhwmonIZsU6M8vuA2 80RnP3JbhKnAA== Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On 11/26/2018 10:24 PM, Stephen Warren wrote: > On 11/25/18 10:51 PM, Vidya Sagar wrote: >> >> On 11/20/2018 11:27 PM, Stephen Warren wrote: >>> From: Stephen Warren >>> >>> The DWC PCIe core contains various separate register spaces: DBI, DBI2, >>> ATU, DMA, etc. The relationship between the addresses of these register >>> spaces is entirely determined by the implementation of the IP block,=20 >>> not >>> by the IP block design itself. Hence, the DWC driver must not make >>> assumptions that one register space can be accessed at a fixed=20 >>> offset from >>> any other register space. To avoid such assumptions, introduce an >>> explicit/separate register pointer for the ATU register space. In >>> particular, the current assumption is not valid for NVIDIA's T194 SoC. >>> >>> The ATU register space is only used on systems that require unrolled=20 >>> ATU >>> access. This property is detected at run-time for host controllers, and >>> when this is detected, this patch provides a default value for atu_base >>> that matches the previous assumption re: register layout. An=20 >>> alternative >>> would be to update all drivers for HW that requires unrolled access to >>> explicitly set atu_base. However, it's hard to tell which drivers would >>> require atu_base to be set. The unrolled property is not detected for >>> endpoint systems, and so any endpoint driver that requires unrolled=20 >>> access >>> must explicitly set the iatu_unroll_enabled flag (none do at=20 >>> present), and >>> so a check is added to require the driver to also set atu_base while at >>> it. >>> >>> Signed-off-by: Stephen Warren >>> Acked-by: Gustavo Pimentel >>> --- >>> v2: >>> * Modified patch subject >>> * Added missing outer brackets to PCIE_GET_ATU_INB_UNR_REG_OFFSET macro >>> --- >>> =C2=A0 .../pci/controller/dwc/pcie-designware-ep.c=C2=A0=C2=A0 |=C2=A0 = 4 ++++ >>> =C2=A0 .../pci/controller/dwc/pcie-designware-host.c |=C2=A0 3 +++ >>> =C2=A0 drivers/pci/controller/dwc/pcie-designware.c=C2=A0 |=C2=A0 8 +++= +---- >>> =C2=A0 drivers/pci/controller/dwc/pcie-designware.h=C2=A0 | 20=20 >>> +++++++++++++++---- >>> =C2=A0 4 files changed, 27 insertions(+), 8 deletions(-) >>> >>> diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c=20 >>> b/drivers/pci/controller/dwc/pcie-designware-ep.c >>> index 1e7b02221eac..880210366e71 100644 >>> --- a/drivers/pci/controller/dwc/pcie-designware-ep.c >>> +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c >>> @@ -504,6 +504,10 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev_err(dev, "db= i_base/dbi_base2 is not populated\n"); >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EINVAL; >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >>> +=C2=A0=C2=A0=C2=A0 if (pci->iatu_unroll_enabled && !pci->atu_base) { >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev_err(dev, "atu_base is n= ot populated\n"); >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EINVAL; >>> +=C2=A0=C2=A0=C2=A0 } >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ret =3D of_property_read_u32(np, "num-ib= -windows",=20 >>> &ep->num_ib_windows); >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ret < 0) { >>> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c=20 >>> b/drivers/pci/controller/dwc/pcie-designware-host.c >>> index 29a05759a294..2ebb7f4768cf 100644 >>> --- a/drivers/pci/controller/dwc/pcie-designware-host.c >>> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c >>> @@ -699,6 +699,9 @@ void dw_pcie_setup_rc(struct pcie_port *pp) >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dev_dbg(pci->dev= , "iATU unroll: %s\n", >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 pci->iatu_unroll_enabled ? "enabled" : "disabled"); >> >> I see that dw_pcie_setup_rc() API has code where=20 >> pci->iatu_unroll_enabled gets set based on reading a viewport register. >> >> IMO, we need a check like following to avoid pci->iatu_unroll_enabled=20 >> getting modified (if already set) >> >> if (!pci->iatu_unroll_enabled) >> =C2=A0=C2=A0=C2=A0 =C2=A0pci->iatu_unroll_enabled =3D dw_pcie_iatu_unrol= l_enabled(pci); > > That's only true if you believe that dw_pcie_iatu_unroll_enabled()=20 > will give the wrong answer in some circumstances. It's working OK=20 > right now, so I'm not sure why that function would start having problems? Since dw_pcie_iatu_unroll_enabled() is reading PCIE_ATU_VIEWPORT=20 register and in case of Nvidia's DWC based PCIe implementation, this=20 register is not listed. In case, if it is returning '0', then,=20 pci->iatu_unroll_enabled which was set by implementation specific driver=20 gets overwritten with this value. Though it is working fine now, I'm not=20 sure if we can take this for granted that it would always work.