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: 7883111 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7145F9F1AF for ; Fri, 18 Dec 2015 12:41:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 69CA620503 for ; Fri, 18 Dec 2015 12:41:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8DA502035E for ; Fri, 18 Dec 2015 12:41:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a9uK3-0007bg-Mm; Fri, 18 Dec 2015 12:39:47 +0000 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a9uJx-0007WD-QQ for linux-arm-kernel@lists.infradead.org; Fri, 18 Dec 2015 12:39:43 +0000 Received: by mail-wm0-x233.google.com with SMTP id p187so61869017wmp.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=NVK6w2Xf0Nw25pAd6ieWTQa6auDbHvs99rxD27aSt+u/Tyg2yiycNjGT4SFt/JWGyV Om3D6JNS7//uxRhijD9oj4Zk1T6NGEuHyceS3NUSYWpkCNZdVLvdz7E+v91V2jkXW/rZ 1VCyqXnPsrEEz4/HonvdGTo6Te/ZHDiFCzzEFFpd1/jTVel7AwofvrXMQCQBWkqmlkCt rhUxUJcWR3r4yVMwQxHhqmFxmA+EE099D5+UHsFq5irrQeNB2VV+yqSGxVAslmKFHKj2 MremWot+UnO1Hi/JTtzIC6tqtcjGtq4blH7E14w6qFoOLywpW5j83nj8h6cGcf6G15aI +4/g== X-Gm-Message-State: ALoCoQkO5PGBGDY74lsstSEpRDv2ICkB2zI9BIGZKoS0oRBAPYSXdUM7hi/Qf9iWpM/xa41Wgw7LbDafT2TQBG7z+XXc9EzJAg== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151218_043942_102664_FA9D3C66 X-CRM114-Status: GOOD ( 12.31 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Russell King , Arnd Bergmann , Pawel Moll , Ian Campbell , Jingoo Han , Pratyush Anand , Stanimir Varbanov , Rob Herring , Srinivas Kandagatla , Bjorn Andersson MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Pratyush Anand --- drivers/pci/host/pcie-designware.c | 7 +++++++ 1 file changed, 7 insertions(+) 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 = {