From patchwork Mon Feb 20 14:05:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Gupta X-Patchwork-Id: 655284 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E655C64EC7 for ; Mon, 20 Feb 2023 14:10:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231839AbjBTOKH (ORCPT ); Mon, 20 Feb 2023 09:10:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231370AbjBTOKF (ORCPT ); Mon, 20 Feb 2023 09:10:05 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2049.outbound.protection.outlook.com [40.107.223.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CD761E9C6; Mon, 20 Feb 2023 06:09:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H1izPu7yZl+ro4ZyZvamhib7LZB8lH4yAzDhalttz+VpLcsSDUvAd8Q5daKq+5agMIM2yi7QtsGIf33fam2ILfjBhDkjH5hyoA7et8fRkuQ3nAl5IfPwNiLHZodmFdRMKn21xIFUskA7FJR4zyNZ1ii28zWqymEpFte3X3N+aYALj4SwPIwAxbUhwKZDskImzQ6kuLEC0dGD7Ml+CNLlRbuag9VcmRIyBefOmUhRPEjU2dRijJuFhWEDvn/WvTtxtI2vZJw+rauLeX5F50S79FHhkwy2vLimSBGVkuSamIRpkyH5+4aAVDXy3M4eKouA5+sHrSYQDoyUK/VBmDAApQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2krSbNIP8iffDdJCA2t8lFOEDeiVztGZnw/JflQijCk=; b=Vh9Cyu2XblZGYjy83Xi8Vd10l9QCjs6WGIpcGxqwJg8wcmrtnkzQ9+c1PotAGASRcVVK8Hm6pyTrwxlJj6e9f8aIn5CMJcpZiy8IdoYUWu78I6e47wm04hEnnfxdc6ssA/j9KqIqS6YmQ1SuSEq1cMYpXatxIizI3FdK7JdGwO9pJcaEimkO0x96R59mVovM1GsrqmJmrzwL8r8bP/nQC2ekx+47Mlu1IaTTrWg80IftlGL5VVWQLtk2GHnUKuTphIzszYywGtyS0bj69Keq8/dt6//ykZN8aRJNAP+XZZm+y0oe1h3Q2Twwak/lYwyuRl/iuV5hAukAaaTOid2hng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=google.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2krSbNIP8iffDdJCA2t8lFOEDeiVztGZnw/JflQijCk=; b=noqivzF6fWijYuD6PF9PmmfKuaos+hZdwOy36Zo9nW0thVwwzQAY5IsEGFa3uUAQV4qtNp6XkKEYco81PUk9tysl+3remaRht1H20izobPGBuNPMh/Lw7OWGZywlkItDc8Px8cxG4Ap6B0aB1pX/TyRMqJurmXZ0FywyQj8xY98Z0jN5+5dUSMW7xIKXd9mgiqv8KtLy5GPQXqjbFIdivM4DW8i3JeEiUjX7B3EYCmZxGJlnoCD7S4NRhGjYlj2rYfzoXZz5PN3iYDpMTqDrWVZKmkqE8d3M+JBLerZ6HfTNprZWP/N6qB4IMlIJAYyM1tBYEwlE/0Fnrla+FoDRvA== Received: from BN9PR03CA0349.namprd03.prod.outlook.com (2603:10b6:408:f6::24) by PH8PR12MB7110.namprd12.prod.outlook.com (2603:10b6:510:22e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20; Mon, 20 Feb 2023 14:08:42 +0000 Received: from BL02EPF0000C403.namprd05.prod.outlook.com (2603:10b6:408:f6:cafe::4a) by BN9PR03CA0349.outlook.office365.com (2603:10b6:408:f6::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20 via Frontend Transport; Mon, 20 Feb 2023 14:08:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BL02EPF0000C403.mail.protection.outlook.com (10.167.241.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.14 via Frontend Transport; Mon, 20 Feb 2023 14:08:41 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 20 Feb 2023 06:08:34 -0800 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 20 Feb 2023 06:08:34 -0800 Received: from sumitg-l4t.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 20 Feb 2023 06:08:28 -0800 From: Sumit Gupta To: , , , , , , , CC: , , , , , , , , , , , , , Subject: [Patch v2 8/9] memory: tegra: make cpu cluster bw request a multiple of mc channels Date: Mon, 20 Feb 2023 19:35:58 +0530 Message-ID: <20230220140559.28289-9-sumitg@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230220140559.28289-1-sumitg@nvidia.com> References: <20230220140559.28289-1-sumitg@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000C403:EE_|PH8PR12MB7110:EE_ X-MS-Office365-Filtering-Correlation-Id: 1bea0e85-7e6a-4af0-caae-08db134bf894 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tBMuj/EranDxylpXx0QoShNgt58qrvBVPOD1ETG9nVsV8OTj2lQ8nL8OEvFyiz6JnLUvdsj0rAQVS/a4ED/0LbWXshhgb9U37H0OS0xUha8I8B2JhlPI6A8DHXqnTX6QsTQJC+/6M99UtCLy7GknMh3wqEusV65aNobVRD2s7HJ9fTAag4QqocoSHEu/zDp2iVotQQVkHZZ2X33r99ZIfLAOwLXX5f+v9VanvJkEYY4WD9/rKDCsOflwkFcPWUTdcVt82TLZWQt/tW+P68FhQ6t8r3zsqtpcj8yh5Ce6E7KjguCSqMQXuDeJMeH2cqaAhHAv58esrU6GiT6f388aO3PQvYgEmAuPFLdGQa/NTYSaCRqS4vLbPiMbYo3MHAYJ3go+tLBe25LPyYg0MNe8RNxT6bXzqH9EYbgrxjrU4rhCbmATA3NEl4KUMYiYpk8SMSnjTD1x3j1MlAFPa0Snu5WRrMzkr/JrWZ8g874+UcFZIEaAT943Aq4cIipyMk3g51Lg8RF+kA/y7QSWc5kU/mxUBNTYRVEzGudRmn1AmovL8wKz1zE0Z3/lVi0HuEdgkivTrNYA7wJjJV+Xd9qQ+s7q460r/2eytIC6wN8JnP5mXhBcTSNt37XZxRzoQShf7Pr1DtmjzKsXvzr/wnIjTAzNjGeM5H1k4X8g1+8CzzXKy1wEYYqHg9NOygJx+Ziee1Rib+QGnUV7QgeTwE/pMw== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(396003)(136003)(376002)(39860400002)(346002)(451199018)(36840700001)(46966006)(40470700004)(40460700003)(478600001)(2616005)(8676002)(4326008)(82310400005)(41300700001)(70586007)(70206006)(86362001)(83380400001)(110136005)(54906003)(316002)(7416002)(5660300002)(36860700001)(8936002)(82740400003)(7636003)(426003)(36756003)(47076005)(2906002)(7696005)(40480700001)(356005)(336012)(26005)(186003)(1076003)(107886003)(6666004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 14:08:41.5001 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1bea0e85-7e6a-4af0-caae-08db134bf894 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0000C403.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7110 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Make CPU cluster's bandwidth (BW) request a multiple of MC channels. CPU OPP tables have BW info per MC channel. But, the actual BW depends on the number of MC channels which can change as per the boot config. Get the number of MC channels which are actually enabled in current boot configuration and multiply the BW request from a CPU cluster with the number of enabled MC channels. This is not required to be done for other MC clients. Signed-off-by: Sumit Gupta --- drivers/memory/tegra/mc.c | 19 +++++++++++++++++++ drivers/memory/tegra/mc.h | 1 + drivers/memory/tegra/tegra234.c | 21 ++++++++++++++++++++- include/soc/tegra/mc.h | 1 + 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c index 7318eaa3819c..de3af77fb80c 100644 --- a/drivers/memory/tegra/mc.c +++ b/drivers/memory/tegra/mc.c @@ -845,6 +845,23 @@ static int tegra_mc_interconnect_setup(struct tegra_mc *mc) return err; } +static void tegra_mc_num_channel_enabled(struct tegra_mc *mc) +{ + unsigned int i; + u32 value; + + value = mc_ch_readl(mc, 0, MC_EMEM_ADR_CFG_CHANNEL_ENABLE); + if (value <= 0) { + mc->num_channels = mc->soc->num_channels; + return; + } + + for (i = 0; i < 32; i++) { + if (value & BIT(i)) + mc->num_channels++; + } +} + static int tegra_mc_probe(struct platform_device *pdev) { struct tegra_mc *mc; @@ -883,6 +900,8 @@ static int tegra_mc_probe(struct platform_device *pdev) return err; } + tegra_mc_num_channel_enabled(mc); + if (mc->soc->ops && mc->soc->ops->handle_irq) { mc->irq = platform_get_irq(pdev, 0); if (mc->irq < 0) diff --git a/drivers/memory/tegra/mc.h b/drivers/memory/tegra/mc.h index bc01586b6560..c3f6655bec60 100644 --- a/drivers/memory/tegra/mc.h +++ b/drivers/memory/tegra/mc.h @@ -53,6 +53,7 @@ #define MC_ERR_ROUTE_SANITY_ADR 0x9c4 #define MC_ERR_GENERALIZED_CARVEOUT_STATUS 0xc00 #define MC_ERR_GENERALIZED_CARVEOUT_ADR 0xc04 +#define MC_EMEM_ADR_CFG_CHANNEL_ENABLE 0xdf8 #define MC_GLOBAL_INTSTATUS 0xf24 #define MC_ERR_ADR_HI 0x11fc diff --git a/drivers/memory/tegra/tegra234.c b/drivers/memory/tegra/tegra234.c index 0c666e52bf46..0b608b820b28 100644 --- a/drivers/memory/tegra/tegra234.c +++ b/drivers/memory/tegra/tegra234.c @@ -868,6 +868,25 @@ static int tegra234_mc_icc_set(struct icc_node *src, struct icc_node *dst) return ret; } +static int tegra234_mc_icc_aggregate(struct icc_node *node, u32 tag, u32 avg_bw, + u32 peak_bw, u32 *agg_avg, u32 *agg_peak) +{ + struct icc_provider *p = node->provider; + struct tegra_mc *mc = icc_provider_to_tegra_mc(p); + + if (node->id == TEGRA_ICC_MC_CPU_CLUSTER0 || + node->id == TEGRA_ICC_MC_CPU_CLUSTER1 || + node->id == TEGRA_ICC_MC_CPU_CLUSTER2) { + if (mc) + peak_bw = peak_bw * mc->num_channels; + } + + *agg_avg += avg_bw; + *agg_peak = max(*agg_peak, peak_bw); + + return 0; +} + static struct icc_node* tegra234_mc_of_icc_xlate(struct of_phandle_args *spec, void *data) { @@ -899,7 +918,7 @@ static int tegra234_mc_icc_get_init_bw(struct icc_node *node, u32 *avg, u32 *pea static const struct tegra_mc_icc_ops tegra234_mc_icc_ops = { .xlate = tegra234_mc_of_icc_xlate, - .aggregate = icc_std_aggregate, + .aggregate = tegra234_mc_icc_aggregate, .get_bw = tegra234_mc_icc_get_init_bw, .set = tegra234_mc_icc_set, }; diff --git a/include/soc/tegra/mc.h b/include/soc/tegra/mc.h index fefac9622987..2fe6f0217a39 100644 --- a/include/soc/tegra/mc.h +++ b/include/soc/tegra/mc.h @@ -233,6 +233,7 @@ struct tegra_mc { struct tegra_mc_timing *timings; unsigned int num_timings; + unsigned int num_channels; struct reset_controller_dev reset;