From nobody Wed Oct 22 15:56:49 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 15D3734A3BA; Tue, 21 Oct 2025 18:29:47 +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=1761071388; cv=none; b=sn1m0OziO099NUbL4T7DcbsbperzQzsstqLlromiBrpWoiRgSPqc/rXt2I9AY37y52hZGggWGyqtPjXf9tnrVybR+0HGe55MQJ3nTDJ5YaQ6gFnuFpz0J1R3XIKQPQGxY2mM13p4MTSTnZc/PupnTXYuyl8yXQ0/O5EPmQkG9ok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761071388; c=relaxed/simple; bh=xGfi7N756BFoSPrY0lKVBtD8tN6LRZTUKS0ghi9+B4U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IwjyYEFmyAfsDeJ33gNA0By6bI7FAoI7+mZnnMdtbF9ouj990jGew4os155/TAI+C1WmmNmGRHnk4OR1QbNA+SqJHJXDtXDwG6F0cmon3KZxPR80PL4du617jdU/wCI5htCNjTvPJh8R1i1Mz/shSUZ1vMQKMVqUGSkA0pYir+s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aPtaE92m; 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="aPtaE92m" Received: by smtp.kernel.org (Postfix) with ESMTPS id B3EA7C4CEF7; Tue, 21 Oct 2025 18:29:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761071387; bh=xGfi7N756BFoSPrY0lKVBtD8tN6LRZTUKS0ghi9+B4U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=aPtaE92mwRazhWUYAp6vS6dkdm+YzDDP7yUmqBtFNjuhWWOV3xVcGPm8QtMcIcP0H BAMpfTFNhwMJSOqyY1bevz3Lbrp7MX2sQ9pqqSYyQ7Is+Frp5Cb1cZbSbeAWlvfkoi dhZGC5iowAMsjj+hwoDf++rlkgiEukVGV62eeM5NZrCyrhnTllPe64Gkuz6PZUCy3u 9HEgVQlXw7GNaxRgDFXxCcy+TKGYdmDXBaDXgQSM5gXsXeLkkOXoFCNMHYvR1bzaj/ jRbD+NedCkRGxYl+FxpUX4LoJiT//jB2S3Jp2bDEyQEuqBh771zF26AW+4rq54w6L+ tQLBt64wmQ0Iw== 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 A0247CCD1AF; Tue, 21 Oct 2025 18:29:47 +0000 (UTC) From: Aaron Kling via B4 Relay Date: Tue, 21 Oct 2025 13:29:40 -0500 Subject: [PATCH 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-v1-1-39d53bdc9aab@gmail.com> References: <20251021-tegra186-icc-p2-v1-0-39d53bdc9aab@gmail.com> In-Reply-To: <20251021-tegra186-icc-p2-v1-0-39d53bdc9aab@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=1761071387; l=816; i=webgeek1234@gmail.com; s=20250217; h=from:subject:message-id; bh=PmMpfHWG2+f6l6AbTUSHWT7B2d2RhnPduQ58vW6+634=; b=D8ljeun3vfFLelIQsNfoHL3K30Pvz7Pw1rG/qOKJSSontzCyHz5w8fte/uNxZTLxARSDTiju3 sQdi+hN3lGKDhgzD7Xz9uYdSbcyKclfoR/RoxGKtcqiccqIEiAKJCLG 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 Wed Oct 22 15:56:49 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 15D1634A3B4; Tue, 21 Oct 2025 18:29:47 +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=1761071388; cv=none; b=EbQVRxiRZFGhXLNzYl72AEovDXqt3kT3boQk9xLrMRotZBKMJvRRcxSCwsFCO5jfEItftVvuOFTmD3Vpx5QpM8htjxGbyHGGPQP0tAdPMDgng4dOjSwnRGgf9GDT6YA5YtbTUPwkDC/aNRes+vkjRWcdwc3Lp+mK/5ugH5bnyu0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761071388; 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=g4H+KETHxRMcGrDs8dh6RYTCmaW0tCYAqMyClDjO4FXUqkIt4OOnPZnSG5eZBaTzRW4G+xy88pwQfGXqsxRovIitZ43nXYUEg1/EieBtlkqpjGLM+/sFMVVBXoj9Y5dpLOYmjNBqs+r3WAJIi2ZalkIRr/PFy5j303yVAwFXLSI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BjFHcQLe; 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="BjFHcQLe" Received: by smtp.kernel.org (Postfix) with ESMTPS id BF84BC116B1; Tue, 21 Oct 2025 18:29:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761071387; bh=/JgzL9VdvfstUomPfZ32E6t/L8VPBz9Fmo+sGuWeS+8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=BjFHcQLeFHUdKp6HcAZzBOECmps4EB6R+S4xrVoToTWkPpvVm2fdRLBQYTAry2A5r LatLBA9d/a0IRNiminiXvnLgwZLr6Lai6+0wvT7dCqSHXm+AiH+QBUnBxQwRkADZiJ Sbia+cGXC4sk0UxIUD90uWrjiuh54ykXlsxZC/xh4UhkaiRsmzOAntbqIEbpbrmyMT kqp5ZfCPZipZouxKPr5EBS+oN0/7RXYO0IJUMnqDVBDxjzTv22/+6hFG/0hERG/oSK Kzc3gGwZHSGcA6QmmygCBAVrdQHc7iR+wf9/qIAzck1rO5Sjr6Q9mrla2FYVoisRGD 7WBMSzl34xTpw== 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 B3248CCD1B9; Tue, 21 Oct 2025 18:29:47 +0000 (UTC) From: Aaron Kling via B4 Relay Date: Tue, 21 Oct 2025 13:29:41 -0500 Subject: [PATCH 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-v1-2-39d53bdc9aab@gmail.com> References: <20251021-tegra186-icc-p2-v1-0-39d53bdc9aab@gmail.com> In-Reply-To: <20251021-tegra186-icc-p2-v1-0-39d53bdc9aab@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=1761071387; l=911; i=webgeek1234@gmail.com; s=20250217; h=from:subject:message-id; bh=7znC8jN7FMo0ABLPSWxCMceZ2XZ3qZ4hFMoMP46i7rM=; b=zWJCmicg76VRVKZ6EChbYG3RAP7H+mKtBdGAUJoOUlcWWhieYyHCt4hINvVH4dOyqtlWWYLDJ ZpiV5v1W8ZIDbTRdhrKbtDrz0V9zm7KLsgpN/8KkXSBPdldo/0ViZ7N 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 Wed Oct 22 15:56:49 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 33C2634A3BC; Tue, 21 Oct 2025 18:29:47 +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=1761071388; cv=none; b=lU29RPQyaczRm9ov4dNJikOY5nYddPA59prTJCgezzVVPJuzGVtSIYzrI3lOlR0TEeXInUNo7OuPZ4TeOdFl6vi8dxfIhKS2lPJoBlVaZCbBLyjhEATe3LCf0wnohN2/itclUYkPVviInDoQ7IXML5evUWlVRHr1xkgQ54jyL5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761071388; c=relaxed/simple; bh=0eDdK4b/3nddpmliz5OasFAtnPd3gM0tosIXvB2EJPk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jaAWtFW5iPuHekEolHThLmSyrPjfeueTj/ZPMp56dbRjOgY/Oq70nXp1OEXJbZFymyd5b4hZMa8uVf/Q41mazbLX2cdy6tgc/8GBBU1MUsN2adff43U3U1iocsNvSF/LVsH+IR8dVCoIGcDhobzbyIxTu7XIdoV6AyQ3yWTm83o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DfAis6pR; 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="DfAis6pR" Received: by smtp.kernel.org (Postfix) with ESMTPS id CE735C4CEF5; Tue, 21 Oct 2025 18:29:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761071387; bh=0eDdK4b/3nddpmliz5OasFAtnPd3gM0tosIXvB2EJPk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=DfAis6pR4swm6A96XiQy5EZK6nzjS3tO2Nyi+Tqf1w6DXf79Y8WJR2PFL5BychnTQ yYRtM69l7GFmk4WQeHPOZ2Zt3EzOJ+9CKKVBBL/TWa8Np7jmdMuIo4nlbCPeQFEJqh vQObILpBci00wD5Fcy2/ctYcTHjzTG9hFSqxfMp2BqZ6Wr0IRTdO03byCuTtbgPYCR wLx22qrSDwcrPWXGz42qWLsry8vnF07RAMerw65ug2g97yhLruqWhLfsSySALRALnq PpZAOAjhCn44X6xbI9DNX3CmLpupUsRxpVWKeM4ic5zFOy9U9C1XRvo84UapB8KETO zqLKFbbmvR2Cw== 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 C45F4CCD1A5; Tue, 21 Oct 2025 18:29:47 +0000 (UTC) From: Aaron Kling via B4 Relay Date: Tue, 21 Oct 2025 13:29:42 -0500 Subject: [PATCH 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-v1-3-39d53bdc9aab@gmail.com> References: <20251021-tegra186-icc-p2-v1-0-39d53bdc9aab@gmail.com> In-Reply-To: <20251021-tegra186-icc-p2-v1-0-39d53bdc9aab@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=1761071387; l=5749; i=webgeek1234@gmail.com; s=20250217; h=from:subject:message-id; bh=bEqU2+m1cIiAkfxH0WziFCipmkQWfrA4Sqg3Wj3YbhY=; b=wRcGSuY8GRLVl23IUlK2y6gKeDHWjQaeeVmmagYXTfmiEWT7DINF6TK7hlXEmrC13pwJJkqjP 7RpKbkme6bHD9FmQqiv8W45FIIMd6xabBdrkPsx+uykJT2bXjujOTrF 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 Wed Oct 22 15:56:49 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 78E6F351FC4; Tue, 21 Oct 2025 18:29:48 +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=1761071389; cv=none; b=J/xiWB4gURjWtQ+Nzz6GtI3dgtaTU+dglPRWL8ZC81367/HuIbA7bBmbmiI9D0Kn6EKOPs7f26WBgB7NBB77RZzNTWN/JvsZxmTXj1N0lanecJx9DxbJgOqzxrbc5RYzt/2UUauRSWXJx2HskH1O4LLqZsLVi2fNRb76llOsG2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761071389; c=relaxed/simple; bh=g2mmajcxbCrl4r+56yYrwyyJINURxPSPFab71xwisCM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cClpYmG6mn/p2OgH+yKkz/ojEHSf4WUTqRET2g5UEFkMOAdEbYn5pVOQWGVSZ4n2rEL2RcrYvIuXT8r19uup3yVyUPXzBXBGNsaOtAsihcESE8+eNbVrYKKIVLQUDK+tyDGocSVqcwC0+0UXsebdYjJO/dgDkaqgI855TTLbcEE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fG+Qcl89; 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="fG+Qcl89" Received: by smtp.kernel.org (Postfix) with ESMTPS id DD0B3C19422; Tue, 21 Oct 2025 18:29:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761071387; bh=g2mmajcxbCrl4r+56yYrwyyJINURxPSPFab71xwisCM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fG+Qcl896GZdAUVbnSnm6mUwZl1tEwPaqx922x1OSNRBIaqYzLPrStSxJ2C1KEMSU tAQt+DBSMyomWeQYLqScE2YhrGCAE2RZFXYqTKMyahYV7+hVEbTYkqKzCdoCvJAuAG /SzuF22a/E4oj0Xzj+uNb5o+0mrhukn980HPUbzWegT3kHwCz9HZlomlp2EwIN+Wh7 Afe45agO/2dCESM+NsM0I3XMJPkms89pvP3tk0cnh6/JvI3sNtmpL1PdCwuQlYlu5q p6B6JSYggR0isyM7UceysGxVh8hPLyD3KPlUDX/u0BJE4iVVJfNb6kUGhfxv265YTw PWBS92et4gGjA== 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 D35A6CCD1BB; Tue, 21 Oct 2025 18:29:47 +0000 (UTC) From: Aaron Kling via B4 Relay Date: Tue, 21 Oct 2025 13:29:43 -0500 Subject: [PATCH 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-v1-4-39d53bdc9aab@gmail.com> References: <20251021-tegra186-icc-p2-v1-0-39d53bdc9aab@gmail.com> In-Reply-To: <20251021-tegra186-icc-p2-v1-0-39d53bdc9aab@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=1761071387; l=2383; i=webgeek1234@gmail.com; s=20250217; h=from:subject:message-id; bh=a/aaiaGuHyMc5nlB9Xe5+rxhKDOKwn8mtxYy/DM7ELQ=; b=MlFoJ3of+99Qz3Zcxb6hoB4n+vU9Dzs7v/abYNrVrsiCBYziO1VHSmqBr962JMTKXDxo/yOAa U0rbVjz7z6JDNoguiurW+TkzAV7Aorh1SMfLiTyS0obpVV/iehr0Ht0 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 Wed Oct 22 15:56:49 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 407D134A3CC; Tue, 21 Oct 2025 18:29:48 +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=1761071388; cv=none; b=uPScXbwQO4iMCgf7Eii9Zs4ceusdTFx0WGAzj8GQGnymxlafkcInyR8dh+mgtwKD0gbfbD58TlUolFz7LA3tKtfC/nbK5PnKArDGSidYrGhdIrTyzSNyikedoXTTa2deObfN3EorwmnenYa3CaJMp5GJsZe/czrPPf9fAstnMvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761071388; c=relaxed/simple; bh=ldF0nGpWAR7TOjezYKVTTUArSP8PCCaKaY6s6ILTcfE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MW9xE4plMhCv/6/vbASgvuKJebGNKz+RKX1rLbuyCMAVelJVrIsPbNU99ReHkZ7wZBmj2r3LMEmHu9d6WvZbfhAomldIDDnC927iPV749Z38uQl5ACOBq5dZYASM2V6gZbj/vKB8hCdwWixXw/aekSQFLEg6GKLCt7q2NKqGBn4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p5LU1dF4; 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="p5LU1dF4" Received: by smtp.kernel.org (Postfix) with ESMTPS id EA0DEC19423; Tue, 21 Oct 2025 18:29:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761071388; bh=ldF0nGpWAR7TOjezYKVTTUArSP8PCCaKaY6s6ILTcfE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=p5LU1dF4iX0zOqX6aNQwLKF2xSd2jh1itOtfBKHhzf/rFAKLSo9P/14DBatdusE5r Icy2TY0JVSjXPP65Nii5PznicD4XnAX5TSjnzsx6PdSyINbwTnyZpyJwjrp8zR1wzS uSKiTSDEcUIsG6ladgodpk7gwwuLaINQPvjuNjeFcI2+gT0phN5DO45ozgalTeKETZ o3lVfPHtlM/XmR1jYJp7SabDy/nVMryPvWIg2cAIUvFuOJAPJ/TqxNW0LlLF9R+XwM 1bMbzTfDlkq04bjZnFhVY4PyuoY0QNV8EFq7+MvdN62ZkqNe6LadCdPoDsOxtdWeQk BlFYHw9YzJ52Q== 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 E09E8CCD1AF; Tue, 21 Oct 2025 18:29:47 +0000 (UTC) From: Aaron Kling via B4 Relay Date: Tue, 21 Oct 2025 13:29:44 -0500 Subject: [PATCH 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-v1-5-39d53bdc9aab@gmail.com> References: <20251021-tegra186-icc-p2-v1-0-39d53bdc9aab@gmail.com> In-Reply-To: <20251021-tegra186-icc-p2-v1-0-39d53bdc9aab@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=1761071387; l=2712; i=webgeek1234@gmail.com; s=20250217; h=from:subject:message-id; bh=LQh6Wx9w2ZA6cjZPbhQTpnWCKJr1fmEA9mYm4DrdFjk=; b=QSZ2Q9JQFbPUfVVdQ6u+jnYDhA+rMKvUIywVkiwRFXxy2daq0XAg9PgUJ0BBNdfUprFEKb0Lj y/ZhxkJkOEjCZV8K9pmHVq7gltXngduf0UorIYjX3mGw3w4M+IxawG7 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