From patchwork Sun Nov 13 19:12:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 19430 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1812157wru; Sun, 13 Nov 2022 11:56:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf7VsslbwQPignw++KJgi+y9CuBxJ4LBc2prIgrv/zkl0P3qJ4tYZiiUElBqbr7guFRX8pqo X-Received: by 2002:aa7:dd1a:0:b0:461:c2a4:c419 with SMTP id i26-20020aa7dd1a000000b00461c2a4c419mr8729209edv.399.1668369376176; Sun, 13 Nov 2022 11:56:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668369376; cv=none; d=google.com; s=arc-20160816; b=NUhIWdWqLQ513kB0WC6kkfUfa13XlS4ultHKucF+3T2Qq8L4/oFzTsysI6HHT1Mlew GxHVTsmoGRqkoIzbVvv9/cGQTFDXwWSvwhG6e4zOPefbaubF/fBBk7ToTOzZp1qangKn t7yPcIzLHRjQaZvT8wNdrDhsElzX3LEvZQKcQ3uLhVQ9K1N57u+qsjxpvtXKnUfDm+UB 3FqzuVJkU4FZbJcDhLDVCr48h1R1AFg1eWBWCxQtQ5uPRPrPndb5T8P297sznkll9jgE at+OGPd4ZCFWmQqIs5g6dX4fdvjwQL289MR8cBbDYLs+WOUhM8ZJxXm+RfofDbbjWFzj goKQ== 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; bh=hCqDKw9nl+YimRa662+7IgYS942qQCtnOVTTGikh2Yo=; b=WaCHGoXpLMzi+3ViJjnOxnYcvHUOgvQ97WHlIs/njBCrfIhkSXaMShibxQLldxyAF9 I1cfde5wel3VM0lSVq7zp+v91SRlscZdFzqR2NgKmltpXnZzLl5DGkmQl69nELPzv/+9 93WOgD4zuoOk3J3UdejnIe1cqMQQaoBYLB0jpXmbR7ywipWIHolF4r0Y35BOBjp+vBiS t3TnQL38kenPsRjkGpAXJsMtbaQrTNjHo19e9NQsUcO8lj7NcQcfuKMSPCHfT8nYRw5o 3eZHPhh1YOPM82swuq5fZw2oruN1MC1tQOK15dHp/u6ucWkTDs0jHQVmFjWI8j8TaCOq nuYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=post header.b=Q5vKjrz8; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=baikalelectronics.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt18-20020a1709072d9200b00797e151e571si8488506ejc.36.2022.11.13.11.55.52; Sun, 13 Nov 2022 11:56:16 -0800 (PST) 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=post header.b=Q5vKjrz8; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=baikalelectronics.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235678AbiKMTQ0 (ORCPT + 99 others); Sun, 13 Nov 2022 14:16:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235665AbiKMTPm (ORCPT ); Sun, 13 Nov 2022 14:15:42 -0500 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3EB6B13E21; Sun, 13 Nov 2022 11:15:07 -0800 (PST) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id 127CEE0EAD; Sun, 13 Nov 2022 22:15:07 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=hCqDKw9nl+YimRa662+7IgYS942qQCtnOVTTGikh2Yo=; b=Q5vKjrz8Q3bS dO4UrNTIX8j91U2uQO/l2KS6PeAAX0Vu9Qr7Yvyqix2YcuYH82in1a08AMn8ry+f LplYFkjweJUW+ecpQcSZ4GJ5XhAmPRUQlxgdR6WBag+QHn4R8Ju7IsP9wM3HyVT1 5/wnso95bN8mdk+zzG5SKQT/WY5A38w= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id 044B0E0E6A; Sun, 13 Nov 2022 22:15:07 +0300 (MSK) Received: from localhost (192.168.168.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sun, 13 Nov 2022 22:15:06 +0300 From: Serge Semin To: Rob Herring , Rob Herring , Krzysztof Kozlowski , Bjorn Helgaas , Lorenzo Pieralisi , Cai Huoqing , Robin Murphy , Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Frank Li , Manivannan Sadhasivam , caihuoqing , Vinod Koul , , , Subject: [PATCH v7 18/20] PCI: dwc: Combine iATU detection procedures Date: Sun, 13 Nov 2022 22:12:59 +0300 Message-ID: <20221113191301.5526-19-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221113191301.5526-1-Sergey.Semin@baikalelectronics.ru> References: <20221113191301.5526-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-Originating-IP: [192.168.168.10] 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_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749412086550884512?= X-GMAIL-MSGID: =?utf-8?q?1749412086550884512?= Since the iATU CSR region is now retrieved in the DW PCIe resources getter there is no much benefits in the iATU detection procedures splitting up. Therefore let's join the iATU unroll/viewport detection procedure with the rest of the iATU parameters detection code. The resultant method will be as coherent as before, while the redundant functions will be eliminated thus producing more readable code. Signed-off-by: Serge Semin Reviewed-by: Rob Herring Reviewed-by: Manivannan Sadhasivam --- Changelog v3: - This is a new patch created on v3 lap of the series. --- drivers/pci/controller/dwc/pcie-designware.c | 39 +++++--------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c index a8436027434d..d31f9d41d5cb 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c @@ -628,26 +628,21 @@ static void dw_pcie_link_set_max_speed(struct dw_pcie *pci, u32 link_gen) } -static bool dw_pcie_iatu_unroll_enabled(struct dw_pcie *pci) -{ - u32 val; - - val = dw_pcie_readl_dbi(pci, PCIE_ATU_VIEWPORT); - if (val == 0xffffffff) - return true; - - return false; -} - -static void dw_pcie_iatu_detect_regions(struct dw_pcie *pci) +void dw_pcie_iatu_detect(struct dw_pcie *pci) { int max_region, ob, ib; u32 val, min, dir; u64 max; - if (dw_pcie_cap_is(pci, IATU_UNROLL)) { + val = dw_pcie_readl_dbi(pci, PCIE_ATU_VIEWPORT); + if (val == 0xFFFFFFFF) { + dw_pcie_cap_set(pci, IATU_UNROLL); + max_region = min((int)pci->atu_size / 512, 256); } else { + pci->atu_base = pci->dbi_base + PCIE_ATU_VIEWPORT_BASE; + pci->atu_size = PCIE_ATU_VIEWPORT_SIZE; + dw_pcie_writel_dbi(pci, PCIE_ATU_VIEWPORT, 0xFF); max_region = dw_pcie_readl_dbi(pci, PCIE_ATU_VIEWPORT) + 1; } @@ -689,23 +684,9 @@ static void dw_pcie_iatu_detect_regions(struct dw_pcie *pci) pci->num_ib_windows = ib; pci->region_align = 1 << fls(min); pci->region_limit = (max << 32) | (SZ_4G - 1); -} - -void dw_pcie_iatu_detect(struct dw_pcie *pci) -{ - if (dw_pcie_iatu_unroll_enabled(pci)) { - dw_pcie_cap_set(pci, IATU_UNROLL); - } else { - pci->atu_base = pci->dbi_base + PCIE_ATU_VIEWPORT_BASE; - pci->atu_size = PCIE_ATU_VIEWPORT_SIZE; - } - - dw_pcie_iatu_detect_regions(pci); - - dev_info(pci->dev, "iATU unroll: %s\n", dw_pcie_cap_is(pci, IATU_UNROLL) ? - "enabled" : "disabled"); - dev_info(pci->dev, "iATU regions: %u ob, %u ib, align %uK, limit %lluG\n", + dev_info(pci->dev, "iATU: unroll %s, %u ob, %u ib, align %uK, limit %lluG\n", + dw_pcie_cap_is(pci, IATU_UNROLL) ? "T" : "F", pci->num_ob_windows, pci->num_ib_windows, pci->region_align / SZ_1K, (pci->region_limit + 1) / SZ_1G); }