Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp190424iob; Tue, 3 May 2022 14:48:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/vUligOUWbwt1QUcfjk1/kU0i6nfAO4A9AdF7g+FffIpV0MKRXD8/u5dzkvB8tJtH6vg6 X-Received: by 2002:a17:907:761c:b0:6d6:e553:7bd1 with SMTP id jx28-20020a170907761c00b006d6e5537bd1mr17162218ejc.5.1651614483245; Tue, 03 May 2022 14:48:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651614483; cv=none; d=google.com; s=arc-20160816; b=Qlw1IYPwkvPXi05YsL95Wl5lEl/8TGht8DP54WKZQR2qRrNaZnM7lBXQHUJVXpqvG0 NGPsSZi3Nk2TQ634lHJPbxlKvWpzKRG0meD8EnclZl1dCW0Xa4xsIeIMhBBpoa27J9hy 80z5fXnD62rKNS6nQlXS8NYgRgb/9qaP5GuUJpYUbNkx+3ZVmIw7AEULeolOCJEaC62V bMRZzRxsvFxDGG7nca4A+Rlu2bKRknlPpBEAN3AfeLxayizn0a6cAQVTJySj62+VC+4R J2+CerfmAR0isti+ExHZZpLBEdxO035WC5K0o5K1HosYhmK24Di+Q3fPIbxpNoJl3s9g d3NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=XYnO1lsXXAnMSVaqJeTDa7D3vkcagfwfusr5cHoPFV8=; b=ashwfhEFGA0MyLXr3mPhFqkVl4Tg63nnU22JVqkaYvToB1HpZfd9/t9p3YHeg6vcHb YwthVrENdrctC4iLlMm6iK4egwfQVVZrRScKI5hTxYUshR4SaZOwY/mObNFkt5hXoicn vKiu0xnPlfe0MO/x+VtY8Mqem2qzcT75MAeByFxPPsor5mkqAegtf+XD+XUzf/mbmBFE 8lilvx4l0xVZAZL6P/JMcpKezavH7y+1aHBF3YjpLHCJH+rBg6wg3Kw9+j69n/F054gK dlioEh8THfgtviawhqNKAhJnwvS3oaI2U1hK+0I0a+LRyr1pEETyuFjAEi8H3Upbh/HN zdjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=b9ADFNQv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n15-20020a170906164f00b006e7f5d0f45asi15860174ejd.791.2022.05.03.14.47.39; Tue, 03 May 2022 14:48:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=b9ADFNQv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242850AbiECV1R (ORCPT + 99 others); Tue, 3 May 2022 17:27:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242786AbiECV1D (ORCPT ); Tue, 3 May 2022 17:27:03 -0400 Received: from mail.baikalelectronics.ru (mail.baikalelectronics.com [87.245.175.226]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 21CB74161F; Tue, 3 May 2022 14:23:30 -0700 (PDT) Received: from mail.baikalelectronics.ru (unknown [192.168.51.25]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 2A7C516D8; Wed, 4 May 2022 00:24:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.baikalelectronics.ru 2A7C516D8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baikalelectronics.ru; s=mail; t=1651613043; bh=XYnO1lsXXAnMSVaqJeTDa7D3vkcagfwfusr5cHoPFV8=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=b9ADFNQvh1+CWQT95JVYQ2DwJoirsRwnoy3vZOdELAvbW6FcKEo++HPD9rsxdsfbL 5zPzDoUZAbwMZTs1Dkt66yl4tKYHHrh0ZYmSdaB/FkbE/kEMESwlt8mQ3uaadmPz8u feWpbgsa2OVD8D51bvIPxaeoxjp2g6p2NulDbbHA= Received: from localhost (192.168.53.207) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 4 May 2022 00:23:29 +0300 From: Serge Semin To: Jingoo Han , Gustavo Pimentel , Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Frank Li , Manivannan Sadhasivam , , Subject: [PATCH v2 04/13] PCI: dwc: Disable outbound windows for controllers with iATU Date: Wed, 4 May 2022 00:22:51 +0300 Message-ID: <20220503212300.30105-5-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20220503212300.30105-1-Sergey.Semin@baikalelectronics.ru> References: <20220503212300.30105-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In accordance with the dw_pcie_setup_rc() method semantics and judging by what the comment added in commit dd193929d91e ("PCI: designware: Explain why we don't program ATU for some platforms") states there are DWC PCIe-available platforms like Keystone (pci-keystone.c) or Amazon's Annapurna Labs (pcie-al.c) which don't have the DW PCIe internal ATU enabled and use it's own address translation approach implemented. In these cases at the very least there is no point in touching the DW PCIe iATU CSRs. Moreover depending on the vendor-specific address translation implementation it might be even erroneous. So let's move the iATU windows disabling procedure to being under the corresponding conditional statement clause thus performing that procedure only if the iATU is expected to be available on the platform. Fixes: 458ad06c4cdd ("PCI: dwc: Ensure all outbound ATU windows are reset") Signed-off-by: Serge Semin Reviewed-by: Manivannan Sadhasivam --- drivers/pci/controller/dwc/pcie-designware-host.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index a250869334a5..4e5c89c19f78 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -572,7 +572,6 @@ static struct pci_ops dw_pcie_ops = { void dw_pcie_setup_rc(struct pcie_port *pp) { - int i; u32 val, ctrl, num_ctrls; struct dw_pcie *pci = to_dw_pcie_from_pp(pp); @@ -623,19 +622,22 @@ void dw_pcie_setup_rc(struct pcie_port *pp) PCI_COMMAND_MASTER | PCI_COMMAND_SERR; dw_pcie_writel_dbi(pci, PCI_COMMAND, val); - /* Ensure all outbound windows are disabled so there are multiple matches */ - for (i = 0; i < pci->num_ob_windows; i++) - dw_pcie_disable_atu(pci, i, DW_PCIE_REGION_OUTBOUND); - /* * If the platform provides its own child bus config accesses, it means * the platform uses its own address translation component rather than * ATU, so we should not program the ATU here. */ if (pp->bridge->child_ops == &dw_child_pcie_ops) { - int atu_idx = 0; + int i, atu_idx = 0; struct resource_entry *entry; + /* + * Ensure all outbound windows are disabled so there are + * multiple matches + */ + for (i = 0; i < pci->num_ob_windows; i++) + dw_pcie_disable_atu(pci, i, DW_PCIE_REGION_OUTBOUND); + /* Get last memory resource entry */ resource_list_for_each_entry(entry, &pp->bridge->windows) { if (resource_type(entry->res) != IORESOURCE_MEM) -- 2.35.1