From nobody Fri Oct 24 13:48:27 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9771D1D5CEA; Wed, 22 Oct 2025 01:09:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761095399; cv=none; b=hjntHNh0JmCy5S6GKDg5FOQp6ZLc12Vv8sVxePUz75NBCo89Pe4N7Cjh2MMk+9Xbq/6wR5m3XJ4jyXAL+nByQG2LiON6fqNsdzArIqlQ1t8lmHV4RgNWc64SOOFRCnz1iZIrImdUdC1LMOGiBTa6YTcvW2eiW2ZSFYqIZ30yTCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761095399; c=relaxed/simple; bh=xGfi7N756BFoSPrY0lKVBtD8tN6LRZTUKS0ghi9+B4U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kjrBmJYY4eR51j6lg6ie2Mo5rlsAgZ3v15eHma5TJs14sukEnbAbEqUwwRATmfsQ20AXn/WfUJNA7LzGis9jimpn2wm9ezXcFVrZi/+k17g4H2YsGtHlQDOBKUAunoz67act4vT9zmLxkvTTtMcAXuedU1GRWTRPMekvhFpGpZQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ozSYO9pK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ozSYO9pK" Received: by smtp.kernel.org (Postfix) with ESMTPS id 317ABC4CEFF; Wed, 22 Oct 2025 01:09:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761095399; bh=xGfi7N756BFoSPrY0lKVBtD8tN6LRZTUKS0ghi9+B4U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=ozSYO9pKSb0ii4Kxc7j02XGSwZ5ranSwqV0KYTdfVPGqXgEMEb+4+gKJ3mHbNpPz8 q41fu6D8DyGi8TePeWBOrPc5BWvs4eAa28R5pA1F+SUKCzQnrFWBk9q1O4EXxRy7k9 z59HA85uBU6LOy8b6SN0XYpckbFWVzXeEspa/5xy1COuW+VKYrJNiDzGsxpwI1sqwI UTaJbwfdVdXu8FL6WTROdYZ9z2z0LiChWnX0QKx2vjTHi29U+GvSBBdRsyyd3t5aNM DPJ4FGI7vpVnjZ7xv4auq2GzSCQ6mS1AgVnljzMkXga4hpX06FVPly278yGKEleZg2 WHGNARiPyIwHA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 206B8CCD1BC; Wed, 22 Oct 2025 01:09:59 +0000 (UTC) From: Aaron Kling via B4 Relay Date: Tue, 21 Oct 2025 20:09:53 -0500 Subject: [PATCH v3 1/5] dt-bindings: memory: tegra186-mc: Add dummy client IDs for Tegra186 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251021-tegra186-icc-p2-v3-1-1a50b526dd40@gmail.com> References: <20251021-tegra186-icc-p2-v3-0-1a50b526dd40@gmail.com> In-Reply-To: <20251021-tegra186-icc-p2-v3-0-1a50b526dd40@gmail.com> To: Krzysztof Kozlowski , Rob Herring , Conor Dooley , Thierry Reding , Jonathan Hunter Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, Aaron Kling X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1761095398; l=816; i=webgeek1234@gmail.com; s=20250217; h=from:subject:message-id; bh=PmMpfHWG2+f6l6AbTUSHWT7B2d2RhnPduQ58vW6+634=; b=hJmB/Gxo2ATmMQCkbH8lwMDDgE1IkcWS2KcJwh3LXh2R3q8Sya6o1LEXeoyx4ptbew/KF56u5 TKkg1YAJzcMA94pMHUTBfpTVRglYyZC5V/FWyXfbWyY7BoPj7uPRmjC X-Developer-Key: i=webgeek1234@gmail.com; a=ed25519; pk=TQwd6q26txw7bkK7B8qtI/kcAohZc7bHHGSD7domdrU= X-Endpoint-Received: by B4 Relay for webgeek1234@gmail.com/20250217 with auth_id=342 X-Original-From: Aaron Kling Reply-To: webgeek1234@gmail.com From: Aaron Kling Add ICC IDs for dummy software clients representing CCPLEX clusters. Signed-off-by: Aaron Kling --- include/dt-bindings/memory/tegra186-mc.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/dt-bindings/memory/tegra186-mc.h b/include/dt-bindings= /memory/tegra186-mc.h index 82a1e27f73576212bc227c74adff28c5f33c6bb1..8abbc26f3123aad2dffaec6be21= f99f8de1ccf89 100644 --- a/include/dt-bindings/memory/tegra186-mc.h +++ b/include/dt-bindings/memory/tegra186-mc.h @@ -247,4 +247,8 @@ #define TEGRA186_MEMORY_CLIENT_VICSRD1 0xa2 #define TEGRA186_MEMORY_CLIENT_NVDECSRD1 0xa3 =20 +/* ICC ID's for dummy MC clients used to represent CPU Clusters */ +#define TEGRA_ICC_MC_CPU_CLUSTER0 1003 +#define TEGRA_ICC_MC_CPU_CLUSTER1 1004 + #endif --=20 2.51.0 From nobody Fri Oct 24 13:48:27 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F5F9136349; Wed, 22 Oct 2025 01:09:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761095399; cv=none; b=D0p8OaPF9i6ZswO0sfwoMnG3bJUcLaH3MvF2giBP+hIX6dbjJ9T6mQ8fMnB7l+4qIMmJsW53wryIxki//+fLbrB6lNK3MM+ZVL4JJBFmHU/eExMHqpySHcGsVAV7HxCMw80ZT7B+wSqybijov3eHxvu99QVgXhDx+5J0Nx4spwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761095399; c=relaxed/simple; bh=/JgzL9VdvfstUomPfZ32E6t/L8VPBz9Fmo+sGuWeS+8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LFqqumq7UDtQoKPUM2FOOdwwvRnXbaqFQud9ANLH41aYpyRSCwmS+RCwaBxE/cXFlTdI0WLOnWyi5DyXmDALsWUeeofRAVVS5hO6GSczV09K5QvpAda0Wd7E16r4lHzympdRqz/6ja5O/XpMy/1M5G9IWu/L0ZLJ7HmtROyXGT0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XsDmbcPW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XsDmbcPW" Received: by smtp.kernel.org (Postfix) with ESMTPS id 403CAC4CEFD; Wed, 22 Oct 2025 01:09:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761095399; bh=/JgzL9VdvfstUomPfZ32E6t/L8VPBz9Fmo+sGuWeS+8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=XsDmbcPWf9PtkZ4+HXuTibHRnuCasneXPr+73qvmeJA8H0gDqiDBLklZg61LOx9LE L50p1bgzRNFd8i+3ktAODe3rq4kSNz+uuY4bqUg2yhYD66Tfonam9bgZ7Bv+iGDm2x GTfqlh3TdDVluWhsY+ubetjn+0syZUVqykTN8RcjtNAZOFZJrIoRFw8Lmy4I8e8DBU Jr1iDNMZsn6qnhFbO8ef6XU5LYyURBP8qgOpGGKCOXMtxfp6uzv8Si4IhI2qTF7gje YnwE4SZQ79/sWfRKQdDnAsoZNxG40n15B+jkjZel4ipslunokkfa4izjcSII4ZfFNv B7Amp2w6yMdww== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31B86CCD1BE; Wed, 22 Oct 2025 01:09:59 +0000 (UTC) From: Aaron Kling via B4 Relay Date: Tue, 21 Oct 2025 20:09:54 -0500 Subject: [PATCH v3 2/5] dt-bindings: memory: tegra194-mc: Add dummy client IDs for Tegra194 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251021-tegra186-icc-p2-v3-2-1a50b526dd40@gmail.com> References: <20251021-tegra186-icc-p2-v3-0-1a50b526dd40@gmail.com> In-Reply-To: <20251021-tegra186-icc-p2-v3-0-1a50b526dd40@gmail.com> To: Krzysztof Kozlowski , Rob Herring , Conor Dooley , Thierry Reding , Jonathan Hunter Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, Aaron Kling X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1761095398; l=911; i=webgeek1234@gmail.com; s=20250217; h=from:subject:message-id; bh=7znC8jN7FMo0ABLPSWxCMceZ2XZ3qZ4hFMoMP46i7rM=; b=D3kzh+visaH5xzA16ZAhNfW7fT4Giy6y5K/zijJL1uhkaobbVmfO3naTEutehIGYMGEvzF6iS 2rvx8xZQ/7SBS6kbcCdwe2tpfjtorXBMu8HmTUZSvMYiiPmx02LvWhR X-Developer-Key: i=webgeek1234@gmail.com; a=ed25519; pk=TQwd6q26txw7bkK7B8qtI/kcAohZc7bHHGSD7domdrU= X-Endpoint-Received: by B4 Relay for webgeek1234@gmail.com/20250217 with auth_id=342 X-Original-From: Aaron Kling Reply-To: webgeek1234@gmail.com From: Aaron Kling Add ICC IDs for dummy software clients representing CCPLEX clusters. Signed-off-by: Aaron Kling --- include/dt-bindings/memory/tegra194-mc.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/dt-bindings/memory/tegra194-mc.h b/include/dt-bindings= /memory/tegra194-mc.h index eed48b746bc94072a6bd0af7f344dbb6f6618859..a7d97a1a470cd3cfb18c7ef45c4= 21426ea3c7abf 100644 --- a/include/dt-bindings/memory/tegra194-mc.h +++ b/include/dt-bindings/memory/tegra194-mc.h @@ -407,4 +407,10 @@ /* MSS internal memqual MIU6 write clients */ #define TEGRA194_MEMORY_CLIENT_MIU6W 0xff =20 +/* ICC ID's for dummy MC clients used to represent CPU Clusters */ +#define TEGRA_ICC_MC_CPU_CLUSTER0 1003 +#define TEGRA_ICC_MC_CPU_CLUSTER1 1004 +#define TEGRA_ICC_MC_CPU_CLUSTER2 1005 +#define TEGRA_ICC_MC_CPU_CLUSTER3 1006 + #endif --=20 2.51.0 From nobody Fri Oct 24 13:48:27 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A97711E51EF; Wed, 22 Oct 2025 01:09:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761095399; cv=none; b=FidM904kdnXEbFzT0OgZGtbu0mH3lj5M+qWrQo6lWAmMdx9Z5NAQNRkwaylx0ZPRYstD1fjoe+dUlhUM6g4l9aoClrTKGkzno3aWpakcwkd8U//Q5Ph4v/ZV4wiTGa9gwU0cgEElhF6nF/Ii6+2yMktBk+V+wuVNp7GrR4eSp74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761095399; c=relaxed/simple; bh=0eDdK4b/3nddpmliz5OasFAtnPd3gM0tosIXvB2EJPk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KafRTQMCm+DQgr+mSL3h60482jO4ZBEK4AM1TU76QnQIJCDcOSZqf35YNqDH++UrNESIvJIVkwAcBlQ7am9Se0KVHVGZ4PCK4mUIrPb4r4szohcmdM9KfU9BnWwS/pTj9oRbog53YA1bAKT8iEfsxN91osfAVuGjTe1/FvF/z34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WNKncRRI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WNKncRRI" Received: by smtp.kernel.org (Postfix) with ESMTPS id 4DB40C116C6; Wed, 22 Oct 2025 01:09:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761095399; bh=0eDdK4b/3nddpmliz5OasFAtnPd3gM0tosIXvB2EJPk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=WNKncRRIFVNR8FZc0fgSPaYIqGNbFF09IVn5CW75uFgJLu4SF2wMb5zQjqydYF6jP XPSyb3/yp5eaAUlgkqDaB5oF2AE+zh3ZqIaVSjjGKEpWhShfCglhjoPBoHQ/kqxI1b oxQ7FARFRCovETQBW2TUDKqsAgRZE2anEclqLDUTXz321t3buzRyRolmRF+QR+PDMO GvOyk3sKDiQIf1LDu35n88GSbpeG367/o/PyGyWXiYMzRoGjeE/jVkldfsRe/emQhs b3TjybAdZcrmAUzn65iWo8SDzn/20pqvcvhDqkyc2CGWoQpHKAEFEz3qS9hW9Pr0iz 7sMSIBKM7d8Kg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41E49CCD1AB; Wed, 22 Oct 2025 01:09:59 +0000 (UTC) From: Aaron Kling via B4 Relay Date: Tue, 21 Oct 2025 20:09:55 -0500 Subject: [PATCH v3 3/5] memory: tegra186-emc: Support non-bpmp icc scaling Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251021-tegra186-icc-p2-v3-3-1a50b526dd40@gmail.com> References: <20251021-tegra186-icc-p2-v3-0-1a50b526dd40@gmail.com> In-Reply-To: <20251021-tegra186-icc-p2-v3-0-1a50b526dd40@gmail.com> To: Krzysztof Kozlowski , Rob Herring , Conor Dooley , Thierry Reding , Jonathan Hunter Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, Aaron Kling X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1761095398; l=5749; i=webgeek1234@gmail.com; s=20250217; h=from:subject:message-id; bh=bEqU2+m1cIiAkfxH0WziFCipmkQWfrA4Sqg3Wj3YbhY=; b=YGMPByvELFQzvRclbL9jDXlZhsEyGB4sHYDmKANA4YMlZ0Ol4nKb5sohvJ/35KEmJ8teQDdui tUuKhzbNigFBmrILMCqveayGTzBCN7FDtVPafmRBJ9cha+UE7HQ728+ X-Developer-Key: i=webgeek1234@gmail.com; a=ed25519; pk=TQwd6q26txw7bkK7B8qtI/kcAohZc7bHHGSD7domdrU= X-Endpoint-Received: by B4 Relay for webgeek1234@gmail.com/20250217 with auth_id=342 X-Original-From: Aaron Kling Reply-To: webgeek1234@gmail.com From: Aaron Kling This adds support for dynamic frequency scaling of external memory on devices with bpmp firmware that does not support bwmgr. Signed-off-by: Aaron Kling --- drivers/memory/tegra/tegra186-emc.c | 132 ++++++++++++++++++++++++++++++++= +++- 1 file changed, 130 insertions(+), 2 deletions(-) diff --git a/drivers/memory/tegra/tegra186-emc.c b/drivers/memory/tegra/teg= ra186-emc.c index d6cd90c7ad5380a9ff9052a60f62c9bcc4fdac5f..1711f2e85ad07692feb8f6f14c8= c2b10ea42fde5 100644 --- a/drivers/memory/tegra/tegra186-emc.c +++ b/drivers/memory/tegra/tegra186-emc.c @@ -18,6 +18,17 @@ struct tegra186_emc_dvfs { unsigned long rate; }; =20 +enum emc_rate_request_type { + EMC_RATE_DEBUG, + EMC_RATE_ICC, + EMC_RATE_TYPE_MAX, +}; + +struct emc_rate_request { + unsigned long min_rate; + unsigned long max_rate; +}; + struct tegra186_emc { struct tegra_bpmp *bpmp; struct device *dev; @@ -33,8 +44,90 @@ struct tegra186_emc { } debugfs; =20 struct icc_provider provider; + + /* + * There are multiple sources in the EMC driver which could request + * a min/max clock rate, these rates are contained in this array. + */ + struct emc_rate_request requested_rate[EMC_RATE_TYPE_MAX]; + + /* protect shared rate-change code path */ + struct mutex rate_lock; }; =20 +static void tegra_emc_rate_requests_init(struct tegra186_emc *emc) +{ + unsigned int i; + + for (i =3D 0; i < EMC_RATE_TYPE_MAX; i++) { + emc->requested_rate[i].min_rate =3D 0; + emc->requested_rate[i].max_rate =3D ULONG_MAX; + } +} + +static int emc_request_rate(struct tegra186_emc *emc, + unsigned long new_min_rate, + unsigned long new_max_rate, + enum emc_rate_request_type type) +{ + struct emc_rate_request *req =3D emc->requested_rate; + unsigned long min_rate =3D 0, max_rate =3D ULONG_MAX; + unsigned int i; + int err; + + /* select minimum and maximum rates among the requested rates */ + for (i =3D 0; i < EMC_RATE_TYPE_MAX; i++, req++) { + if (i =3D=3D type) { + min_rate =3D max(new_min_rate, min_rate); + max_rate =3D min(new_max_rate, max_rate); + } else { + min_rate =3D max(req->min_rate, min_rate); + max_rate =3D min(req->max_rate, max_rate); + } + } + + if (min_rate > max_rate) { + dev_err_ratelimited(emc->dev, "%s: type %u: out of range: %lu %lu\n", + __func__, type, min_rate, max_rate); + return -ERANGE; + } + + err =3D clk_set_rate(emc->clk, min_rate); + if (err) + return err; + + emc->requested_rate[type].min_rate =3D new_min_rate; + emc->requested_rate[type].max_rate =3D new_max_rate; + + return 0; +} + +static int emc_set_min_rate(struct tegra186_emc *emc, unsigned long rate, + enum emc_rate_request_type type) +{ + struct emc_rate_request *req =3D &emc->requested_rate[type]; + int ret; + + mutex_lock(&emc->rate_lock); + ret =3D emc_request_rate(emc, rate, req->max_rate, type); + mutex_unlock(&emc->rate_lock); + + return ret; +} + +static int emc_set_max_rate(struct tegra186_emc *emc, unsigned long rate, + enum emc_rate_request_type type) +{ + struct emc_rate_request *req =3D &emc->requested_rate[type]; + int ret; + + mutex_lock(&emc->rate_lock); + ret =3D emc_request_rate(emc, req->min_rate, rate, type); + mutex_unlock(&emc->rate_lock); + + return ret; +} + /* * debugfs interface * @@ -107,7 +200,7 @@ static int tegra186_emc_debug_min_rate_set(void *data, = u64 rate) if (!tegra186_emc_validate_rate(emc, rate)) return -EINVAL; =20 - err =3D clk_set_min_rate(emc->clk, rate); + err =3D emc_set_min_rate(emc, rate, EMC_RATE_DEBUG); if (err < 0) return err; =20 @@ -137,7 +230,7 @@ static int tegra186_emc_debug_max_rate_set(void *data, = u64 rate) if (!tegra186_emc_validate_rate(emc, rate)) return -EINVAL; =20 - err =3D clk_set_max_rate(emc->clk, rate); + err =3D emc_set_max_rate(emc, rate, EMC_RATE_DEBUG); if (err < 0) return err; =20 @@ -217,6 +310,12 @@ static int tegra186_emc_get_emc_dvfs_latency(struct te= gra186_emc *emc) return 0; } =20 +static inline struct tegra186_emc * +to_tegra186_emc_provider(struct icc_provider *provider) +{ + return container_of(provider, struct tegra186_emc, provider); +} + /* * tegra_emc_icc_set_bw() - Set BW api for EMC provider * @src: ICC node for External Memory Controller (EMC) @@ -227,6 +326,33 @@ static int tegra186_emc_get_emc_dvfs_latency(struct te= gra186_emc *emc) */ static int tegra_emc_icc_set_bw(struct icc_node *src, struct icc_node *dst) { + struct tegra186_emc *emc =3D to_tegra186_emc_provider(dst->provider); + struct tegra_mc *mc =3D dev_get_drvdata(emc->dev->parent); + unsigned long long peak_bw =3D icc_units_to_bps(dst->peak_bw); + unsigned long long avg_bw =3D icc_units_to_bps(dst->avg_bw); + unsigned long long rate =3D max(avg_bw, peak_bw); + const unsigned int ddr =3D 2; + int err; + + /* + * Do nothing here if bwmgr is supported in BPMP-FW. BPMP-FW sets the fin= al + * Freq based on the passed values. + */ + if (mc->bwmgr_mrq_supported) + return 0; + + /* + * Tegra186 EMC runs on a clock rate of SDRAM bus. This means that + * EMC clock rate is twice smaller than the peak data rate because + * data is sampled on both EMC clock edges. + */ + do_div(rate, ddr); + rate =3D min_t(u64, rate, U32_MAX); + + err =3D emc_set_min_rate(emc, rate, EMC_RATE_ICC); + if (err) + return err; + return 0; } =20 @@ -334,6 +460,8 @@ static int tegra186_emc_probe(struct platform_device *p= dev) platform_set_drvdata(pdev, emc); emc->dev =3D &pdev->dev; =20 + tegra_emc_rate_requests_init(emc); + if (tegra_bpmp_mrq_is_supported(emc->bpmp, MRQ_EMC_DVFS_LATENCY)) { err =3D tegra186_emc_get_emc_dvfs_latency(emc); if (err) --=20 2.51.0 From nobody Fri Oct 24 13:48:27 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0ECC1EEA31; Wed, 22 Oct 2025 01:09:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761095399; cv=none; b=PpjQazka5MdmMnXKsHIZoL8oeUTiB5T3n/odPiXvp3QFLUGwjIuXEeKiSY4XcoxV3jJ8m2dbSXYbn0bDRCbSp/N1Z50BnJSTObSKzezTzCY1NhC83HTuJGL+b1nAGFiqVwEG2qTp3NsQOQQokMpmqzKyt3te1dEdFjeflYNUAXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761095399; c=relaxed/simple; bh=g2mmajcxbCrl4r+56yYrwyyJINURxPSPFab71xwisCM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TSuILzCI8I9IFgcmVTyGJYjOul0Gilj7Jr1iSSc/t1s79QMQDdYWsFY/+EGg1nVFh1k+v7OA9wVnriSx8PYP3xBpkWI+NtSR7BFpJS5L7Yd0AfzNRjFNUHDXf+UuL4k3Q+gEn1rEkt372Y8dmcwCqXYvZuLUXTvwLqC3Xw50sGM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YH8TU+sx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YH8TU+sx" Received: by smtp.kernel.org (Postfix) with ESMTPS id 6044FC19421; Wed, 22 Oct 2025 01:09:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761095399; bh=g2mmajcxbCrl4r+56yYrwyyJINURxPSPFab71xwisCM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=YH8TU+sxkBoYm96QxliVTx9+0HsD7MlJuDo5jsNdFgmVtHMMPEcKjbcumJWDNO6Ds +fo3UlUojJGIjP9zQOmR5XCcDKT7MsmxHdl+yZfq9oizL15mSazwRfMe+57QDvURcC yb/wAyXhVQk5RnOxQVo9IXxS6VtGoZkmgepqdyZuIE5hmIeZd3doY7FdikoBrV7dVf 4tf1/UOG/VJ5r3KliNN2+KG1TToV81WFLTSusKtqtkK+ir1xCV4A8HE1C9858vt9fe 4K10owpguhbCDb40lHcInnlivHIbF41q+B5/AfHy58k/z9Sh1LMkA+/T5pFdD5qrm2 dtKE2MoCWiyzw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57487CCD1BF; Wed, 22 Oct 2025 01:09:59 +0000 (UTC) From: Aaron Kling via B4 Relay Date: Tue, 21 Oct 2025 20:09:56 -0500 Subject: [PATCH v3 4/5] memory: tegra186: Support icc scaling Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251021-tegra186-icc-p2-v3-4-1a50b526dd40@gmail.com> References: <20251021-tegra186-icc-p2-v3-0-1a50b526dd40@gmail.com> In-Reply-To: <20251021-tegra186-icc-p2-v3-0-1a50b526dd40@gmail.com> To: Krzysztof Kozlowski , Rob Herring , Conor Dooley , Thierry Reding , Jonathan Hunter Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, Aaron Kling X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1761095398; l=2383; i=webgeek1234@gmail.com; s=20250217; h=from:subject:message-id; bh=a/aaiaGuHyMc5nlB9Xe5+rxhKDOKwn8mtxYy/DM7ELQ=; b=Yk5YsCNB6DiGET9qss2G+OM4WNG9CCpvOykJIfkiuDJjupA84uwgWW/mnIG1ZA8bGtI2rbJIQ iUoAGxnJLSvDkzHOF2CCMybUIf5iIx/DjAN61yKHYxiIqvT7GARcEWv X-Developer-Key: i=webgeek1234@gmail.com; a=ed25519; pk=TQwd6q26txw7bkK7B8qtI/kcAohZc7bHHGSD7domdrU= X-Endpoint-Received: by B4 Relay for webgeek1234@gmail.com/20250217 with auth_id=342 X-Original-From: Aaron Kling Reply-To: webgeek1234@gmail.com From: Aaron Kling Add Interconnect framework support to dynamically set the DRAM bandwidth from different clients. The MC driver is added as an ICC provider and the EMC driver is already a provider. Signed-off-by: Aaron Kling --- drivers/memory/tegra/tegra186.c | 48 +++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 48 insertions(+) diff --git a/drivers/memory/tegra/tegra186.c b/drivers/memory/tegra/tegra18= 6.c index aee11457bf8e032637d1772affb87da0cac68494..1384164f624af5d4aaccedc8444= 3d203ba3db2c6 100644 --- a/drivers/memory/tegra/tegra186.c +++ b/drivers/memory/tegra/tegra186.c @@ -899,9 +899,56 @@ static const struct tegra_mc_client tegra186_mc_client= s[] =3D { .security =3D 0x51c, }, }, + }, { + .id =3D TEGRA_ICC_MC_CPU_CLUSTER0, + .name =3D "sw_cluster0", + .type =3D TEGRA_ICC_NISO, + }, { + .id =3D TEGRA_ICC_MC_CPU_CLUSTER1, + .name =3D "sw_cluster1", + .type =3D TEGRA_ICC_NISO, }, }; =20 +static int tegra186_mc_icc_set(struct icc_node *src, struct icc_node *dst) +{ + /* TODO: program PTSA */ + return 0; +} + +static int tegra186_mc_icc_aggregate(struct icc_node *node, u32 tag, u32 a= vg_bw, + u32 peak_bw, u32 *agg_avg, u32 *agg_peak) +{ + struct icc_provider *p =3D node->provider; + struct tegra_mc *mc =3D icc_provider_to_tegra_mc(p); + + if (node->id =3D=3D TEGRA_ICC_MC_CPU_CLUSTER0 || + node->id =3D=3D TEGRA_ICC_MC_CPU_CLUSTER1) { + if (mc) + peak_bw =3D peak_bw * mc->num_channels; + } + + *agg_avg +=3D avg_bw; + *agg_peak =3D max(*agg_peak, peak_bw); + + return 0; +} + +static int tegra186_mc_icc_get_init_bw(struct icc_node *node, u32 *avg, u3= 2 *peak) +{ + *avg =3D 0; + *peak =3D 0; + + return 0; +} + +static const struct tegra_mc_icc_ops tegra186_mc_icc_ops =3D { + .xlate =3D tegra_mc_icc_xlate, + .aggregate =3D tegra186_mc_icc_aggregate, + .get_bw =3D tegra186_mc_icc_get_init_bw, + .set =3D tegra186_mc_icc_set, +}; + const struct tegra_mc_soc tegra186_mc_soc =3D { .num_clients =3D ARRAY_SIZE(tegra186_mc_clients), .clients =3D tegra186_mc_clients, @@ -912,6 +959,7 @@ const struct tegra_mc_soc tegra186_mc_soc =3D { MC_INT_SECERR_SEC | MC_INT_DECERR_VPR | MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM, .ops =3D &tegra186_mc_ops, + .icc_ops =3D &tegra186_mc_icc_ops, .ch_intmask =3D 0x0000000f, .global_intstatus_channel_shift =3D 0, }; --=20 2.51.0 From nobody Fri Oct 24 13:48:27 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0E4A1DC997; Wed, 22 Oct 2025 01:09:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761095399; cv=none; b=WyI1Qd4I+XgZhHcoctAn2ZZ3tbRS+Pta+sxGdxgsWyW0+mNA0niEutNaVIX76ZwZRkFDSQucrsu0orJQclIKhoVRVYljtuqoaPNl37yIPX2pGgjokDjxwmShcGrTJvQUVpf59S+S6TJtQeMG8XSw/A3r3Dq5kKjvKlyMJMTQcnA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761095399; c=relaxed/simple; bh=ldF0nGpWAR7TOjezYKVTTUArSP8PCCaKaY6s6ILTcfE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VVUDZeS5ctJk/EgkNEtc2VX2QpDOCWRIv/L92vz8fS8BSXsmJsjG3F5HRcZjQ/lZwLmLT+v8AgAZZaKxpBOLxv9KeSM8JTZEA3PQjZdsmZP6Mh++Onb3J5Oo5KWR8aqgU8PPUQjAO4S8JmN8jorKliOBmxx4wj20t8NqsDyv7nA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TxxzD3bL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TxxzD3bL" Received: by smtp.kernel.org (Postfix) with ESMTPS id 6E450C19425; Wed, 22 Oct 2025 01:09:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761095399; bh=ldF0nGpWAR7TOjezYKVTTUArSP8PCCaKaY6s6ILTcfE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=TxxzD3bLAaswbh2rCkm0e0kQGTpnOtHsu/hnx8al/raDmLCP2lbqbtgnREp7DUTHs +2BXRSwvikQx/jPQwAQ+0e+trsml7/fVoOIyE8YCXEH+d1710jarYr2UcA5mAMTof+ WZDqeImzGzzmk536/VfGj/l/RxHrGiKh/4CAmOxHlCRaUIwbdM7AhurZDmqKumd0xM JjJmam9rDQA8+1dUlVLhaoCE29DtmttRDp2xTsscAzbgG5oaPj2h5HCQxLTmMqy9QQ sYM4rAameNobFCASWVdPz0asnPQ8+KncQ/ZwdoZofbAYeBs/w6zEEycn0uavT4xQxS DAv1nPNUuck7A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 666FCCCD1BC; Wed, 22 Oct 2025 01:09:59 +0000 (UTC) From: Aaron Kling via B4 Relay Date: Tue, 21 Oct 2025 20:09:57 -0500 Subject: [PATCH v3 5/5] memory: tegra194: Support icc scaling Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251021-tegra186-icc-p2-v3-5-1a50b526dd40@gmail.com> References: <20251021-tegra186-icc-p2-v3-0-1a50b526dd40@gmail.com> In-Reply-To: <20251021-tegra186-icc-p2-v3-0-1a50b526dd40@gmail.com> To: Krzysztof Kozlowski , Rob Herring , Conor Dooley , Thierry Reding , Jonathan Hunter Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, Aaron Kling X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1761095398; l=2712; i=webgeek1234@gmail.com; s=20250217; h=from:subject:message-id; bh=LQh6Wx9w2ZA6cjZPbhQTpnWCKJr1fmEA9mYm4DrdFjk=; b=IXG/pf/jKK7U2UVw0vEnt+iJZYSZo54Qplt3DjZtoSQ2Lnhb+vG5wO6obGgNwmTR2rmAjDr79 D12IGJdHFX0C+aM2TyvFioPJJQK3ucXY831l6IGUi1eVX5cMpzL8b1a X-Developer-Key: i=webgeek1234@gmail.com; a=ed25519; pk=TQwd6q26txw7bkK7B8qtI/kcAohZc7bHHGSD7domdrU= X-Endpoint-Received: by B4 Relay for webgeek1234@gmail.com/20250217 with auth_id=342 X-Original-From: Aaron Kling Reply-To: webgeek1234@gmail.com From: Aaron Kling Add Interconnect framework support to dynamically set the DRAM bandwidth from different clients. The MC driver is added as an ICC provider and the EMC driver is already a provider. Signed-off-by: Aaron Kling --- drivers/memory/tegra/tegra194.c | 59 +++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/drivers/memory/tegra/tegra194.c b/drivers/memory/tegra/tegra19= 4.c index 26035ac3a1eb51a3d8ce3830427b4412b48baf3c..e478587586e7f01afd41ff74d26= a9a3f1d881347 100644 --- a/drivers/memory/tegra/tegra194.c +++ b/drivers/memory/tegra/tegra194.c @@ -1340,9 +1340,66 @@ static const struct tegra_mc_client tegra194_mc_clie= nts[] =3D { .security =3D 0x7fc, }, }, + }, { + .id =3D TEGRA_ICC_MC_CPU_CLUSTER0, + .name =3D "sw_cluster0", + .type =3D TEGRA_ICC_NISO, + }, { + .id =3D TEGRA_ICC_MC_CPU_CLUSTER1, + .name =3D "sw_cluster1", + .type =3D TEGRA_ICC_NISO, + }, { + .id =3D TEGRA_ICC_MC_CPU_CLUSTER2, + .name =3D "sw_cluster2", + .type =3D TEGRA_ICC_NISO, + }, { + .id =3D TEGRA_ICC_MC_CPU_CLUSTER3, + .name =3D "sw_cluster3", + .type =3D TEGRA_ICC_NISO, }, }; =20 +static int tegra194_mc_icc_set(struct icc_node *src, struct icc_node *dst) +{ + /* TODO: program PTSA */ + return 0; +} + +static int tegra194_mc_icc_aggregate(struct icc_node *node, u32 tag, u32 a= vg_bw, + u32 peak_bw, u32 *agg_avg, u32 *agg_peak) +{ + struct icc_provider *p =3D node->provider; + struct tegra_mc *mc =3D icc_provider_to_tegra_mc(p); + + if (node->id =3D=3D TEGRA_ICC_MC_CPU_CLUSTER0 || + node->id =3D=3D TEGRA_ICC_MC_CPU_CLUSTER1 || + node->id =3D=3D TEGRA_ICC_MC_CPU_CLUSTER2 || + node->id =3D=3D TEGRA_ICC_MC_CPU_CLUSTER3) { + if (mc) + peak_bw =3D peak_bw * mc->num_channels; + } + + *agg_avg +=3D avg_bw; + *agg_peak =3D max(*agg_peak, peak_bw); + + return 0; +} + +static int tegra194_mc_icc_get_init_bw(struct icc_node *node, u32 *avg, u3= 2 *peak) +{ + *avg =3D 0; + *peak =3D 0; + + return 0; +} + +static const struct tegra_mc_icc_ops tegra194_mc_icc_ops =3D { + .xlate =3D tegra_mc_icc_xlate, + .aggregate =3D tegra194_mc_icc_aggregate, + .get_bw =3D tegra194_mc_icc_get_init_bw, + .set =3D tegra194_mc_icc_set, +}; + const struct tegra_mc_soc tegra194_mc_soc =3D { .num_clients =3D ARRAY_SIZE(tegra194_mc_clients), .clients =3D tegra194_mc_clients, @@ -1355,7 +1412,7 @@ const struct tegra_mc_soc tegra194_mc_soc =3D { MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM, .has_addr_hi_reg =3D true, .ops =3D &tegra186_mc_ops, - .icc_ops =3D &tegra_mc_icc_ops, + .icc_ops =3D &tegra194_mc_icc_ops, .ch_intmask =3D 0x00000f00, .global_intstatus_channel_shift =3D 8, }; --=20 2.51.0