Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp2717370rwa; Mon, 22 Aug 2022 12:21:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR4aoJt3wxOMrzA5n7N249iBNt+g2w3TuHu/uN/3oKC291yhNRqoS2XK7TF+OgkygKIJf1Ia X-Received: by 2002:a05:6a00:1a04:b0:52a:d4dc:5653 with SMTP id g4-20020a056a001a0400b0052ad4dc5653mr22336756pfv.69.1661196103838; Mon, 22 Aug 2022 12:21:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661196103; cv=none; d=google.com; s=arc-20160816; b=f0W7pMucIH1wLxY2ppgqvK5s5fCduQPXAkRgS3ll5Uy6GObVnt/rcbZPwcQU5NIf1d eoLCvAAcWExVr8R7uExFPm5ajxUptPOGAwpqWqfwcGW2PZ9rfcrSupJ0/Zp88Z7C+pM4 gGSoGh+Q6qA7GoXjZM6/rKAIRR2V0U+/sPq13tMVQ8vP0TqV4h/E7S+VIhnrh/ps9Ogv dDhAHOx1oK4PAV2hfM0RJH/z1BEcWJrGGTHhGQM+tg6wCPgjvqaLCeAYIFgFNAzbHryJ tsqVFX18afvoOaFDDgXeLrHg9vmdTxvgf45sFkhOjMiaqv0OLuOKvj/ojpJldSCtaaUF SzXw== 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=WT5RHILejfotZ238xy1IN0z+UtE1d8MWmFYTuBK7tos=; b=xQbkqLlPQ5Om0I2bFjyMb0g9Ru9xHi0xkvGCNyZZXTJNNmQ7YU65lASuppUfWgJ1uZ ZTrtf/QDu+dqcdXO6GMiyOZLtULDPXScuXueWSolpFmK3Qs2ij7LIkVE+ssuIt5ZK7Fs fVfj7qeoSK+1j0BqAa1oHTVYpfVwthm56/IFubKIEYJQXIE0t010F7+qqUej2/vcs7Qy m+BAo21Oa7l2g45pfcGQs2YyxZOXRyJmLGwrryMFY+GZvIbLTuy40EiG3a/muj9On2FP B8A8Fdo6lWS2K9qsJGQQFYeePJfQUfarC4y2GhzfLlh7cSj90NyWgKoGz1+C0KiJFWDx QNyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=btHSZPIT; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p18-20020a056a000a1200b005289628be08si12402744pfh.336.2022.08.22.12.21.27; Mon, 22 Aug 2022 12:21:43 -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=btHSZPIT; 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 S237852AbiHVStT (ORCPT + 99 others); Mon, 22 Aug 2022 14:49:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237698AbiHVSsM (ORCPT ); Mon, 22 Aug 2022 14:48:12 -0400 Received: from mail.baikalelectronics.com (mail.baikalelectronics.com [87.245.175.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 790AB24F2E; Mon, 22 Aug 2022 11:47:52 -0700 (PDT) Received: from mail (mail.baikal.int [192.168.51.25]) by mail.baikalelectronics.com (Postfix) with ESMTP id 1E4C5DA4; Mon, 22 Aug 2022 21:50:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.baikalelectronics.com 1E4C5DA4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baikalelectronics.ru; s=mail; t=1661194254; bh=WT5RHILejfotZ238xy1IN0z+UtE1d8MWmFYTuBK7tos=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=btHSZPIT3BZ+CSTJR84ZcAdqWnIlMxw29hnRYLuhtXiw/pew7zQHKzXaD5oDvhsoz m/WYfJRB5fjYnOsa6fZV60w/oQKYSm0tyemiAXY2chTlGESUATjzhQUZh6E05F5mWa VrdVJ4/fYpQE3OTF2VlrsAscr+bnb4eHem+yUsuA= Received: from localhost (192.168.168.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 22 Aug 2022 21:47:39 +0300 From: Serge Semin To: Rob Herring , Rob Herring , Krzysztof Kozlowski , Bjorn Helgaas , Lorenzo Pieralisi , Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Frank Li , Manivannan Sadhasivam , , , Subject: [PATCH v5 18/20] PCI: dwc: Combine iATU detection procedures Date: Mon, 22 Aug 2022 21:46:59 +0300 Message-ID: <20220822184701.25246-19-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20220822184701.25246-1-Sergey.Semin@baikalelectronics.ru> References: <20220822184701.25246-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_PASS, T_SCC_BODY_TEXT_LINE,T_SPF_PERMERROR 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 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 --- 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); } -- 2.35.1