Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4127737imj; Tue, 12 Feb 2019 10:13:46 -0800 (PST) X-Google-Smtp-Source: AHgI3IaK/j5t+ce55EUcL98BE53lPQ7OVPyYv1X5gOsT+Rw5sOPd0tDzALw+CTr+TzO96CpHCa5S X-Received: by 2002:a63:fe58:: with SMTP id x24mr4754640pgj.255.1549995226121; Tue, 12 Feb 2019 10:13:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549995226; cv=none; d=google.com; s=arc-20160816; b=DtDBkc99SufKKbeECsDO7SXMK1VG+LaaOoUTP3AXGiP6VPJcylK81nR/SljtxU6sHc UKWziXL6aZ+wekhOybQxJN/RZ5uwZsmRQXMVCZ4HZhzPwJI0myRxkZc4ST14VgKSS9WX J1JoWOHHlE+ZZ9ab4ojz4nryjU2aQlyy02A3KEZRIdp5LzjbTsMhqWeGup9I5rP79vdU NvPqHuu9pYExRvZofDavrnh43pKYFfcfSzaur3DuXDjB1ifjINFImjTBplTzK4mXfGEE HKs7nDoX99aStKTGEgP1AyUL2CIcMvzNEwwjCehdq2WIwjbj8GPuzRE2wsbOj6N2Hkbm yAYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=oJkuaty3Vw6eYOMRHcFYIqvZOxkpOO2Syot56YchFl0=; b=tGUV55HT1T4QFj27GwzIPP4VlHNdvsA+khZqXOeAx8mBkTS30pBs3B/SLu99P0yzFX mdm/UAMXEXIkUnadMggfhzeNBwCjTfacDHmMNxG6Q5UQPwtCpScLZE1GlTWA6Q8e2q+Q zTKj6ItdQ9ignwbY6RCRa9Pl3ybpaMDjTX5BOORVPM6PnqKUols4F/2hO18wbF+wSXEW 9b/3UiVkcnBLPK44m2kX3HxDcF0Dx+1t5arqjAXaNQCBizKaKkUDLjnTaSlYovibYb5/ 4l+EXPvJ/BveVEZI1Zv6kRVnzriLfZNkY+81jNHRyGikTL6KZOT+48zRZiSJXptH5alT Knrg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2si1286529plp.380.2019.02.12.10.13.29; Tue, 12 Feb 2019 10:13:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729862AbfBLSMR (ORCPT + 99 others); Tue, 12 Feb 2019 13:12:17 -0500 Received: from foss.arm.com ([217.140.101.70]:41688 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726855AbfBLSMQ (ORCPT ); Tue, 12 Feb 2019 13:12:16 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B1292A78; Tue, 12 Feb 2019 10:12:15 -0800 (PST) Received: from e107981-ln.cambridge.arm.com (e107981-ln.cambridge.arm.com [10.1.197.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 134893F575; Tue, 12 Feb 2019 10:12:13 -0800 (PST) Date: Tue, 12 Feb 2019 18:12:08 +0000 From: Lorenzo Pieralisi To: Srinath Mannam Cc: Bjorn Helgaas , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, linux-pci@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] PCI: iproc: Add CRS check in config read Message-ID: <20190212181208.GA918@e107981-ln.cambridge.arm.com> References: <1549342622-9929-1-git-send-email-srinath.mannam@broadcom.com> <1549342622-9929-2-git-send-email-srinath.mannam@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1549342622-9929-2-git-send-email-srinath.mannam@broadcom.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 05, 2019 at 10:27:00AM +0530, Srinath Mannam wrote: > In the current implementation, config read output data 0xffff0001 is > assumed as CRS completion. But sometimes 0xffff0001 can be a valid data. > > IPROC PCIe host controller has a register to show config read request > status flags like SC, UR, CRS and CA. So that extra check is added to > confirm the CRS using status flags before reissue config read. > > Signed-off-by: Srinath Mannam > Reviewed-by: Ray Jui > --- > drivers/pci/controller/pcie-iproc.c | 23 +++++++++++++++++++++-- > 1 file changed, 21 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c > index c20fd6b..b882255 100644 > --- a/drivers/pci/controller/pcie-iproc.c > +++ b/drivers/pci/controller/pcie-iproc.c > @@ -60,6 +60,10 @@ > #define APB_ERR_EN_SHIFT 0 > #define APB_ERR_EN BIT(APB_ERR_EN_SHIFT) > > +#define CFG_RD_SUCCESS 0 > +#define CFG_RD_UR 1 > +#define CFG_RD_CRS 2 > +#define CFG_RD_CA 3 > #define CFG_RETRY_STATUS 0xffff0001 > #define CFG_RETRY_STATUS_TIMEOUT_US 500000 /* 500 milliseconds */ > > @@ -289,6 +293,9 @@ enum iproc_pcie_reg { > IPROC_PCIE_IARR4, > IPROC_PCIE_IMAP4, > > + /* config read status */ > + IPROC_PCIE_CFG_RD_STATUS, > + > /* link status */ > IPROC_PCIE_LINK_STATUS, > > @@ -350,6 +357,7 @@ static const u16 iproc_pcie_reg_paxb_v2[] = { > [IPROC_PCIE_IMAP3] = 0xe08, > [IPROC_PCIE_IARR4] = 0xe68, > [IPROC_PCIE_IMAP4] = 0xe70, > + [IPROC_PCIE_CFG_RD_STATUS] = 0xee0, So, with the *current* code, on controllers that does not support this register you won't be able to get any HW whose config space register value reads 0xffff0001 to work, is that correct ? Lorenzo > [IPROC_PCIE_LINK_STATUS] = 0xf0c, > [IPROC_PCIE_APB_ERR_EN] = 0xf40, > }; > @@ -474,10 +482,12 @@ static void __iomem *iproc_pcie_map_ep_cfg_reg(struct iproc_pcie *pcie, > return (pcie->base + offset); > } > > -static unsigned int iproc_pcie_cfg_retry(void __iomem *cfg_data_p) > +static unsigned int iproc_pcie_cfg_retry(struct iproc_pcie *pcie, > + void __iomem *cfg_data_p) > { > int timeout = CFG_RETRY_STATUS_TIMEOUT_US; > unsigned int data; > + u32 status; > > /* > * As per PCIe spec r3.1, sec 2.3.2, CRS Software Visibility only > @@ -498,6 +508,15 @@ static unsigned int iproc_pcie_cfg_retry(void __iomem *cfg_data_p) > */ > data = readl(cfg_data_p); > while (data == CFG_RETRY_STATUS && timeout--) { > + /* > + * CRS state is set in CFG_RD status register > + * This will handle the case where CFG_RETRY_STATUS is > + * valid config data. > + */ > + status = iproc_pcie_read_reg(pcie, IPROC_PCIE_CFG_RD_STATUS); > + if (status != CFG_RD_CRS) > + return data; > + > udelay(1); > data = readl(cfg_data_p); > } > @@ -576,7 +595,7 @@ static int iproc_pcie_config_read(struct pci_bus *bus, unsigned int devfn, > if (!cfg_data_p) > return PCIBIOS_DEVICE_NOT_FOUND; > > - data = iproc_pcie_cfg_retry(cfg_data_p); > + data = iproc_pcie_cfg_retry(pcie, cfg_data_p); > > *val = data; > if (size <= 2) > -- > 2.7.4 >