From patchwork Fri Dec 18 12:38:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 58657 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp998439lbb; Fri, 18 Dec 2015 04:39:25 -0800 (PST) X-Received: by 10.98.64.201 with SMTP id f70mr4876861pfd.147.1450442365307; Fri, 18 Dec 2015 04:39:25 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 143si19823996pfa.219.2015.12.18.04.39.25; Fri, 18 Dec 2015 04:39:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753204AbbLRMjY (ORCPT + 6 others); Fri, 18 Dec 2015 07:39:24 -0500 Received: from mail-wm0-f47.google.com ([74.125.82.47]:38547 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753111AbbLRMjV (ORCPT ); Fri, 18 Dec 2015 07:39:21 -0500 Received: by mail-wm0-f47.google.com with SMTP id l126so63483553wml.1 for ; Fri, 18 Dec 2015 04:39:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uNiOdE91x72CQiQJEr/iqtsJSXqi1RL6SoYUpc7VLZA=; b=QECuFB/pEka8ABiMxoHpNmbeYcwxOhoSKPla/j+p6Uarcmq1/wTb8SnOSnYlp4BXN8 3f2c4UuKmq3mVvaxxiGB55ocZNQHaMkjpKTSSnSzRp6SU1AuStMM3jrlzEXI3+SQtvh7 1gZQSv514ObsE5R+44pg0LvNuq22Kj9KPhXHk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uNiOdE91x72CQiQJEr/iqtsJSXqi1RL6SoYUpc7VLZA=; b=Q+fj9bfR84JUt9VuxQQmhDPljV7I13tC7Q5BdphdM57MNLRWpM9+Ei3c2qcD+JqHfs iLEJeS2+gIgaOD9fjE1TBTYrQJsQirBQ+5iIXgcmvGf2UPJ4wOLTo7Nbld2zGjUu8lpV r6BhreNPH8+anHbu/xbuKLtFlANSyjMEPDuac+t/f+2Dd6AvyrxRt8s7d1Ezlp6yrjOc 2jIcKVK44zzE5SqgIytGEDkS5+rC7h+CGbTk8f8eEpykaeIXuCzBh5F4yDnM3sC0u3bI CZ0l/PtyaFYJJplUjqteHSvdGb6aNTN+J5tb1s8swMhzO2gMDS7ONyGO2FRbOUCvdkqV l+TA== X-Gm-Message-State: ALoCoQlA50W8ZlDSPxSzLOvv2sukvo/ntmTr8/4c5NLowrNQgnpNUEmq8nNrHi+7kTGTYmcKTdYoszxP7hXmf368G/8LLyHQqw== X-Received: by 10.194.133.100 with SMTP id pb4mr4501333wjb.133.1450442360443; Fri, 18 Dec 2015 04:39:20 -0800 (PST) Received: from mms734.qualcomm.mm-sol.com ([37.157.136.206]) by smtp.gmail.com with ESMTPSA id c13sm6521619wmd.14.2015.12.18.04.39.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Dec 2015 04:39:19 -0800 (PST) From: Stanimir Varbanov To: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, Bjorn Helgaas Cc: Srinivas Kandagatla , Russell King , Rob Herring , Rob Herring , Mark Rutland , Pawel Moll , Ian Campbell , Arnd Bergmann , Jingoo Han , Pratyush Anand , Bjorn Andersson , Stanimir Varbanov Subject: [PATCH v5 1/5] PCI: designware: ensure ATU is enabled before IO/conf space accesses Date: Fri, 18 Dec 2015 14:38:55 +0200 Message-Id: <1450442339-18765-2-git-send-email-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1450442339-18765-1-git-send-email-stanimir.varbanov@linaro.org> References: <1450442339-18765-1-git-send-email-stanimir.varbanov@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org There is no guarantees that enabling ATU will hit the hardware immediately, and subsequent accesses to configuration / IO spaces are reliable. So fixing this by read back PCIE_ATU_CR2 register just after writing. Without such a fix the PCI device enumeration during kernel boot is not reliable, and reading configuration space for particular PCI device on the bus returns zero aka no device. Signed-off-by: Stanimir Varbanov --- drivers/pci/host/pcie-designware.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c index 02a7452bdf23..7880de63895d 100644 --- a/drivers/pci/host/pcie-designware.c +++ b/drivers/pci/host/pcie-designware.c @@ -154,6 +154,8 @@ static int dw_pcie_wr_own_conf(struct pcie_port *pp, int where, int size, static void dw_pcie_prog_outbound_atu(struct pcie_port *pp, int index, int type, u64 cpu_addr, u64 pci_addr, u32 size) { + u32 val; + dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | index, PCIE_ATU_VIEWPORT); dw_pcie_writel_rc(pp, lower_32_bits(cpu_addr), PCIE_ATU_LOWER_BASE); @@ -164,6 +166,11 @@ static void dw_pcie_prog_outbound_atu(struct pcie_port *pp, int index, dw_pcie_writel_rc(pp, upper_32_bits(pci_addr), PCIE_ATU_UPPER_TARGET); dw_pcie_writel_rc(pp, type, PCIE_ATU_CR1); dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2); + /* + * ensure that the ATU enable has been happaned before accessing + * pci configuration/io spaces through dw_pcie_cfg_[read|write]. + */ + dw_pcie_readl_rc(pp, PCIE_ATU_CR2, &val); } static struct irq_chip dw_msi_irq_chip = {