Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp700545iob; Wed, 4 May 2022 06:21:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweLTLU/o36VwbDDa8PyRgWX0ykuY3hV3V2eX0mvOatQnsLgFY+cwoUEA5uluAX6q+zfNxS X-Received: by 2002:a17:907:8c85:b0:6f4:6b2a:5f0 with SMTP id td5-20020a1709078c8500b006f46b2a05f0mr10866643ejc.491.1651670466144; Wed, 04 May 2022 06:21:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651670466; cv=none; d=google.com; s=arc-20160816; b=NIxnp0YXqXxdIdqeIowuwOr/SvhsIrbmIC2GVgFFQ12ylgFUelu98ITgcRoKRvpfd/ Y3i3o8tp9tLIJLKJA2iwcZzuqjcJ51ThNor6jCRBBskf8ObSMZIKa/LZ7HivRgUL1TDL mSETHT9ZIGoSg66y/JFiyRnzIP2LwUOYuAuqJVlH4ITUFZ+8Nd5bdNDaKQ9sALR6jbak aRbMIwBGTfK7hRm4DVzCD6QrjYGqmQBH2JViG+p+piB4gkCA6FlJObAbby9sRkNkgsqy Ax00B8tvNv/v0FniO4KHfEAnZqG2Fyp6xuHFkfmtBL54NCaXkGfD0j2qxxTCmqmxGWuf pljg== 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=OoVanQ5yHiv0xhE+4SxgGCL4ZPscVZSKRi+k0Dp0Pu4=; b=WHsWpVmhQo4PsMVGFkh+YcAlETLoGIS+BBGjVpltDdXtI7U3qjUATYML8nC713VHUt n8EJf+BBjKqdq42vnbqLs47Pxp0fPawn6ucbBknaIsabiRtceBS9YiVHj2kPFU2qX4zA B7M1Z1Uv4T+ZGvH1mWB4quA+9zRVe7vAWJw54PjaPQG9hxUVAMwX1uGRkb6l/ZmY5KLA aDF7EBKlCQg5EMHdvNwz1qxD7DaJpN7VUvfG+x8asuhLJCXNYBakp9NZhTZD0rxqanrK zDh/TCzNTB3cf0aGgNrBuCmIlkIjKIqF8V4wIZW8UeUmjELpRk+KXWEy8CydRqF0qkGK VR4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=WqBBT8V8; 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 oz7-20020a170906cd0700b006f3ce7e0968si16432103ejb.67.2022.05.04.06.20.41; Wed, 04 May 2022 06:21:06 -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=WqBBT8V8; 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 S242840AbiECV1N (ORCPT + 99 others); Tue, 3 May 2022 17:27:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242778AbiECV1D (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 5EED44162D; Tue, 3 May 2022 14:23:29 -0700 (PDT) Received: from mail.baikalelectronics.ru (unknown [192.168.51.25]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 1D88916D7; Wed, 4 May 2022 00:24:02 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.baikalelectronics.ru 1D88916D7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baikalelectronics.ru; s=mail; t=1651613042; bh=OoVanQ5yHiv0xhE+4SxgGCL4ZPscVZSKRi+k0Dp0Pu4=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=WqBBT8V8GSa1uspDANgO6tEUvItY/vR2mDUUYUKXlQ2MYY4RxD4s6khMFjAAGfBnk zZQSuLOybikWFNaE2kXhov4SHm6QSQlBK1RBxT+a2puFtE/svh5UCZqw1akhtfIL9m xuod+aruFyQtmoKsqEe4hN5Je4tm5wypqeTkyXUI= 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:28 +0300 From: Serge Semin To: Jingoo Han , Gustavo Pimentel , Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Kishon Vijay Abraham I CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Frank Li , Manivannan Sadhasivam , , Subject: [PATCH v2 03/13] PCI: dwc: Add unroll iATU space support to the regions disable method Date: Wed, 4 May 2022 00:22:50 +0300 Message-ID: <20220503212300.30105-4-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 The dw_pcie_disable_atu() method was introduced in the commit f8aed6ec624f ("PCI: dwc: designware: Add EP mode support"). Since then it hasn't changed at all. For all that time the method has supported the viewport version of the iATU CSRs only. Basically it works for the DW PCIe IP-cores older than v4.80a since the newer controllers are equipped with the unrolled iATU/eDMA space. It means the methods using it like pci_epc_ops.clear_bar and pci_epc_ops.unmap_addr callbacks just don't work correctly for the DW PCIe controllers with unrolled iATU CSRs. The same concerns the dw_pcie_setup_rc() method, which disables the outbound iATU entries before re-initializing them. So in order to fix the problems denoted above let's convert the dw_pcie_disable_atu() method to disabling the iATU inbound and outbound regions in the unrolled iATU CSRs in case the DW PCIe controller has been synthesized with the ones support. The former semantics will be remained for the controller having iATU mapped over the viewport. Fixes: f8aed6ec624f ("PCI: dwc: designware: Add EP mode support") Signed-off-by: Serge Semin Reviewed-by: Manivannan Sadhasivam --- drivers/pci/controller/dwc/pcie-designware.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c index d92c8a25094f..7dc8c360a0d4 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c @@ -504,8 +504,18 @@ void dw_pcie_disable_atu(struct dw_pcie *pci, int index, return; } - dw_pcie_writel_dbi(pci, PCIE_ATU_VIEWPORT, region | index); - dw_pcie_writel_dbi(pci, PCIE_ATU_CR2, ~(u32)PCIE_ATU_ENABLE); + if (pci->iatu_unroll_enabled) { + if (region == PCIE_ATU_REGION_INBOUND) { + dw_pcie_writel_ib_unroll(pci, index, PCIE_ATU_UNR_REGION_CTRL2, + ~(u32)PCIE_ATU_ENABLE); + } else { + dw_pcie_writel_ob_unroll(pci, index, PCIE_ATU_UNR_REGION_CTRL2, + ~(u32)PCIE_ATU_ENABLE); + } + } else { + dw_pcie_writel_dbi(pci, PCIE_ATU_VIEWPORT, region | index); + dw_pcie_writel_dbi(pci, PCIE_ATU_CR2, ~(u32)PCIE_ATU_ENABLE); + } } int dw_pcie_wait_for_link(struct dw_pcie *pci) -- 2.35.1