Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4814203imj; Wed, 13 Feb 2019 01:19:58 -0800 (PST) X-Google-Smtp-Source: AHgI3IZK162pTYJglIbv1UHvWjpJJNyWH579OzJhjOamLZxj2IIhshDv4cWro94H8IoJCQxPavhQ X-Received: by 2002:a17:902:a588:: with SMTP id az8mr8750583plb.77.1550049598084; Wed, 13 Feb 2019 01:19:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550049598; cv=none; d=google.com; s=arc-20160816; b=am/B/388mTn/3lBl8+mzHWmTLLV69dh1pUDEXUtSRI/NdCKM+Q+4dQJBZqQdfN45bo BmsUoE1xiShGy/XDZov6/9oJEh7tgo0X42iIKjn8/N8lTbFMHEZCEkEVdeRm17GYzSCN wfodeK5AHnBPsWsajJB+RPcyt53AGI6jDtpK9epCWy2zGg9PMH/cAlrQ7XYbXixr5N2a IDyuCRHlt8iRyyHpEw9b4+S2BJYYmRVzUd4QZvOBm89irnQz4gvBVBvL7dA94kbXWS/N k/Q1alaIsMm3u3e4tqatGanh7XJZDUln3QCoaYfMfzzu6LwG6hMOhHW1qPa1g+dw06EB V0gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=jfUvnKqx0/LCU+eBTQY2ytjcTCXtaG67jN7oy6DeBZA=; b=ulKq29L0N8KzicvKuoVmXpaSsDkz52aEDzGfCprWLEtyHhFajiQmbLEN8h+co1+TRZ 3jN7QloXiBn1JkM+VUOEXjzOXsmy4wqkeT2Lqk8CNoookujjnFO5QHnW1d110sRLYiMb cJIm8ariuo5DcD10MrbS1WMFSVjJ451mnREi9XHQpTNiyvUegvkhOmlWDhEfAy+24qXQ SRTFf2ASB7euuQ59t6i53SydpSAv4SDKdQ2ftaS1qEaM6galzCDfx5r14srjC3gbXPNK F239T560vrW7OCmPEmEZXeA96lp9Rwmo3TV3LzQo5Q5qrAYwyN50WtuQBhOuDzcKOo8q SI0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=DmyEk0sG; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t75si4318225pfa.170.2019.02.13.01.19.42; Wed, 13 Feb 2019 01:19:58 -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; dkim=pass header.i=@broadcom.com header.s=google header.b=DmyEk0sG; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387416AbfBMD5f (ORCPT + 99 others); Tue, 12 Feb 2019 22:57:35 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:32850 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731048AbfBMD5e (ORCPT ); Tue, 12 Feb 2019 22:57:34 -0500 Received: by mail-wm1-f66.google.com with SMTP id h22so868717wmb.0 for ; Tue, 12 Feb 2019 19:57:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jfUvnKqx0/LCU+eBTQY2ytjcTCXtaG67jN7oy6DeBZA=; b=DmyEk0sGurpgvmp4zIbLlSavXJkeT8OZWWI0bFMWGU1Iy8YxY1BbMtrTb7GDOEID99 60/WqKQYCvwBGERow7H8/Tk8/doa+iZLN76e+5S4DULYQqFWsFFp3wfaBnrWnmqfGhqJ 1NdsTi5MoIcYn9dGdfh1mNULZBORZiWeJRADw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jfUvnKqx0/LCU+eBTQY2ytjcTCXtaG67jN7oy6DeBZA=; b=QRpPkP3tM9J+lCH+saPn18sVhnEK4kroBT1VzCNDoxPvBn9LDu18GF4YWUwIq+h587 n6UCuqXsqiGVDPEbVosaWnkgKLUI55uMogY4sL9v/LYMRpyHgSw65f7zvZ+GyZki/jsU B2YQ5tgyEybCcjd9k9Xhg0UiluN9um7TrihzENTBV+i3ovPK8e6oH8I4vVBg1B1xNGpt K5WBc9lon693sWxJtK8hQMiT5oH6nPYnAqIHbIiBQLOZ4hOvNgvsCuQ+16ITHqhKnYSf JtvhG8VAvkqeJ/utwcXX0CS9mX7lhzm5MM9FcjyG+qXY5tLSquWCz5bjN+dNBk7A7VoT bXog== X-Gm-Message-State: AHQUAuYZi7Kp3L1gdtXXUajgt00o/a9d2sigwT7eD2h5vm8TE1D8z0IF Oy99bdbApKtNKsSF5zgPVLVB2QAM1Q2WrJ21ZU0stA== X-Received: by 2002:a1c:c44c:: with SMTP id u73mr1504168wmf.45.1550030251533; Tue, 12 Feb 2019 19:57:31 -0800 (PST) MIME-Version: 1.0 References: <1549342622-9929-1-git-send-email-srinath.mannam@broadcom.com> <1549342622-9929-2-git-send-email-srinath.mannam@broadcom.com> <20190212181208.GA918@e107981-ln.cambridge.arm.com> In-Reply-To: <20190212181208.GA918@e107981-ln.cambridge.arm.com> From: Srinath Mannam Date: Wed, 13 Feb 2019 09:27:20 +0530 Message-ID: Subject: Re: [PATCH v2 1/2] PCI: iproc: Add CRS check in config read To: Lorenzo Pieralisi Cc: Bjorn Helgaas , Ray Jui , Scott Branden , BCM Kernel Feedback , linux-pci@vger.kernel.org, iommu@lists.linux-foundation.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lorenzo, Thanks for review, please see my comments below inline. On Tue, Feb 12, 2019 at 11:42 PM Lorenzo Pieralisi wrote: > > 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 ? > Yes, this feature(register) is available only in "iProc PCIe PAXB v2" controller for other controllers it will not applicable. Regards, Srinath. > 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 > >