Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp795447imp; Wed, 20 Feb 2019 09:08:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IbUv/aXC6kputB1H2hKqJq3ZfANlIO0l6z+xdrFK81JC0yjhgJPDUbtVH/g4D+WrU98+Uyq X-Received: by 2002:a17:902:8687:: with SMTP id g7mr37439309plo.96.1550682532695; Wed, 20 Feb 2019 09:08:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550682532; cv=none; d=google.com; s=arc-20160816; b=tSJzOqxWR5rr5gRtBMqCrc2143aFsdUBCCGjXV9hFekq8vR5WPfg8ravdtW3eULANf +pMCytUpn09lf5n+83aGuQFnlYphBs1PzqLJ1SkTR4qU3lAbqYS60y5DIJkFVzwVC5HH rnpGVFIC3GsoxB0JzYhrHL7QjrWPWMjIO1cwKVABv6c9sSurKdNyorCtjLcl6wt673mw 2vknu0PZRQJpQwmYA0mO46soCz8/DtrjNz8ytqfZfE4AHmR0ssR3rvq21cIp58fihdWn 4lxHvbvjLDZxyvZugg3XsbjLbP0qzbUtI4XW+EO2CBihoFOe77ta9GemLHJMQWeSfbmv NFOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=5JMpbtJFok6NmyP09wHWoeTClnCNAZoek3gSUOSs3x0=; b=XsOi1GcutgAGyMKJD/5Q3JbHr3GSBD7e3thAB2T1KGHrZtFMRviFdyF+FRTffmU9Bq WelBEs5A0iThiQZ/N+m2HGVaV8PAih72IDqmtfVOn+0BbCejYQXayc38gSx5v9xain0c 1Jbshi0iS2Ia/kxP1xmVgn0KtkXr/FHVlwn2nVNTDRUHZPDvOCrM2H9at10X4HjkBsSB nkzY3ByYt9aqO59ZWxVyYKcRtEByTYUuadAU3F2mQ8Z9QZ9h7wfJO2U7VsU7/U4lCip0 X674qHOpEYO4bTm296xOySFPDnNIOjjTX4SdPzDuoxSP8qK37415OWfR3r1AwVLn3PqW gaSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=RmlccQeC; 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 v5si18655451pgh.510.2019.02.20.09.08.37; Wed, 20 Feb 2019 09:08:52 -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=RmlccQeC; 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 S1726794AbfBTQeN (ORCPT + 99 others); Wed, 20 Feb 2019 11:34:13 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:33533 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726352AbfBTQeL (ORCPT ); Wed, 20 Feb 2019 11:34:11 -0500 Received: by mail-pl1-f193.google.com with SMTP id y10so12494380plp.0 for ; Wed, 20 Feb 2019 08:34:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5JMpbtJFok6NmyP09wHWoeTClnCNAZoek3gSUOSs3x0=; b=RmlccQeCYowaxbJ7ccWoPEOLRf/t0oWGtdbuaYzv+WOyd9XtLfEjlHPhzZT9uyTbsy ZMB4mcyyQn/rwdJnS5z3g6L6BxV/EdbgUBowBsNpsUH5zS3JouwtPVvIi8QXrp5+BIQq hNf1+ASiQ2Z1/AYpTJBwW2GP83LFjCRPr39s8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5JMpbtJFok6NmyP09wHWoeTClnCNAZoek3gSUOSs3x0=; b=MUlN5BrCHzSxrYseZmBnfkv3e0RsxZDb2Nd6FpkB0QTc7KjIFgF/mFlMd1rAhcUmJX HpEB1dMtRyN09g3pz49vcwOJEFLnJ8tY+uocUu1rLMucjyd8z/IAL8JaPVcfbu5g+hzW 3Y9MJCMpnH/w7ciTApdFt9/XnMpRAQyCrfk6P1yw4EPxCnaeO0PTjHJSZ2OUfTQR9Ipi g1ALsnFZnqrzrZUqr/L9otiqFYhMx0Ae/GyBb0KlQqDpj5cItXwMsK5EXNi1sSKwYGKT CgasS3AzQpsLK25aEDxuiyMpjPZRPZHM2h4OJndb8zHoxwu0yPA6NjoCT/X/Kz4MzDw7 K/Wg== X-Gm-Message-State: AHQUAuZXFOtOMLSFOoNNu6UEOVzhwb+6p6JJtIfTqU+FnaA7i7AtsEtA OlgtaOrNq0goO3ahwTBqx/4o5Q== X-Received: by 2002:a17:902:6b4b:: with SMTP id g11mr36696005plt.92.1550680451148; Wed, 20 Feb 2019 08:34:11 -0800 (PST) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id t10sm26556717pfa.151.2019.02.20.08.34.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Feb 2019 08:34:10 -0800 (PST) From: Srinath Mannam To: Bjorn Helgaas , Lorenzo Pieralisi , Ray Jui , Scott Branden Cc: bcm-kernel-feedback-list@broadcom.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Srinath Mannam Subject: [PATCH v3 1/2] PCI: iproc: Add CRS check in config read Date: Wed, 20 Feb 2019 22:03:54 +0530 Message-Id: <1550680435-9706-2-git-send-email-srinath.mannam@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550680435-9706-1-git-send-email-srinath.mannam@broadcom.com> References: <1550680435-9706-1-git-send-email-srinath.mannam@broadcom.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 PAXB v2 has a register to show config read 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, [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