From: Aniruddha Rao <anrao@nvidia.com>
To: <thierry.reding@kernel.org>, <jonathanh@nvidia.com>
Cc: <linux-tegra@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
"Aniruddha Rao" <anrao@nvidia.com>
Subject: [PATCH v2 4/5] firmware: tegra: bpmp: Add MBWT BPMP helpers
Date: Wed, 22 Jul 2026 11:05:43 +0000 [thread overview]
Message-ID: <20260722110544.193551-5-anrao@nvidia.com> (raw)
In-Reply-To: <20260722110544.193551-1-anrao@nvidia.com>
Add helper functions that send MBWT requests to BPMP firmware.
The helpers implement the GET_BW and SET_BW operations.
They also provide a QUERY_ABI-based probe for command availability.
Signed-off-by: Aniruddha Rao <anrao@nvidia.com>
---
Changes since v1:
- Use generic tegra_bpmp_mbwt_*() helper names.
- Fold the helpers into bpmp.c instead of adding a separate source file.
- Drop SoC-specific Kconfig dependencies from the helper patch.
- Return BPMP firmware errors directly.
drivers/firmware/tegra/bpmp-private.h | 7 ++
drivers/firmware/tegra/bpmp.c | 98 +++++++++++++++++++++++++++
2 files changed, 105 insertions(+)
diff --git a/drivers/firmware/tegra/bpmp-private.h b/drivers/firmware/tegra/bpmp-private.h
index 07c3d46abb87..b3770e71020e 100644
--- a/drivers/firmware/tegra/bpmp-private.h
+++ b/drivers/firmware/tegra/bpmp-private.h
@@ -26,4 +26,11 @@ struct tegra_bpmp_ops {
extern const struct tegra_bpmp_ops tegra186_bpmp_ops;
extern const struct tegra_bpmp_ops tegra210_bpmp_ops;
+bool tegra_bpmp_mbwt_cmd_is_supported(struct tegra_bpmp *bpmp,
+ unsigned int cmd_code);
+int tegra_bpmp_mbwt_get(struct tegra_bpmp *bpmp, unsigned int instance,
+ unsigned int vc_type, unsigned int *bandwidth);
+int tegra_bpmp_mbwt_set(struct tegra_bpmp *bpmp, unsigned int instance,
+ unsigned int vc_type, unsigned int bandwidth);
+
#endif
diff --git a/drivers/firmware/tegra/bpmp.c b/drivers/firmware/tegra/bpmp.c
index 2dcb74a45b59..2cf8490b8b2e 100644
--- a/drivers/firmware/tegra/bpmp.c
+++ b/drivers/firmware/tegra/bpmp.c
@@ -675,6 +675,104 @@ bool tegra_bpmp_mrq_is_supported(struct tegra_bpmp *bpmp, unsigned int mrq)
}
EXPORT_SYMBOL_GPL(tegra_bpmp_mrq_is_supported);
+bool tegra_bpmp_mbwt_cmd_is_supported(struct tegra_bpmp *bpmp,
+ unsigned int cmd_code)
+{
+ struct mrq_sochub_mbwt_request request = {
+ .cmd = CMD_SOCHUB_MBWT_QUERY_ABI,
+ .query_abi.cmd_code = cmd_code,
+ };
+ struct tegra_bpmp_message msg = {
+ .mrq = MRQ_SOCHUB_MBWT,
+ .tx = {
+ .data = &request,
+ .size = sizeof(request),
+ },
+ };
+ int err;
+
+ err = tegra_bpmp_transfer(bpmp, &msg);
+ if (err || msg.rx.ret)
+ return false;
+
+ return true;
+}
+
+int tegra_bpmp_mbwt_get(struct tegra_bpmp *bpmp, unsigned int instance,
+ unsigned int vc_type, unsigned int *bandwidth)
+{
+ struct mrq_sochub_mbwt_request request = {
+ .cmd = CMD_SOCHUB_MBWT_GET_BW,
+ .get_bw = {
+ .instance = instance,
+ .vc_type = vc_type,
+ },
+ };
+ struct mrq_sochub_mbwt_response response = {};
+ struct tegra_bpmp_message msg = {
+ .mrq = MRQ_SOCHUB_MBWT,
+ .tx = {
+ .data = &request,
+ .size = sizeof(request),
+ },
+ .rx = {
+ .data = &response,
+ .size = sizeof(response),
+ },
+ };
+ int err;
+
+ if (!bandwidth)
+ return -EINVAL;
+
+ err = tegra_bpmp_transfer(bpmp, &msg);
+ if (err) {
+ dev_err(bpmp->dev, "MBWT get bandwidth transfer failed: %d\n",
+ err);
+ return err;
+ }
+
+ if (msg.rx.ret)
+ return msg.rx.ret;
+
+ *bandwidth = response.get_bw.bw;
+
+ return 0;
+}
+
+int tegra_bpmp_mbwt_set(struct tegra_bpmp *bpmp, unsigned int instance,
+ unsigned int vc_type, unsigned int bandwidth)
+{
+ struct mrq_sochub_mbwt_request request = {
+ .cmd = CMD_SOCHUB_MBWT_SET_BW,
+ .set_bw = {
+ .instance = instance,
+ .vc_type = vc_type,
+ .bw = bandwidth,
+ },
+ };
+ struct tegra_bpmp_message msg = {
+ .mrq = MRQ_SOCHUB_MBWT,
+ .tx = {
+ .data = &request,
+ .size = sizeof(request),
+ },
+ };
+ int err;
+
+ err = tegra_bpmp_transfer(bpmp, &msg);
+ if (err) {
+ dev_err(bpmp->dev, "MBWT set bandwidth transfer failed: %d\n",
+ err);
+ return err;
+ }
+
+ if (msg.rx.ret)
+ return msg.rx.ret;
+
+ return 0;
+}
+
static void tegra_bpmp_mrq_handle_ping(unsigned int mrq,
struct tegra_bpmp_channel *channel,
void *data)
--
2.43.0
next prev parent reply other threads:[~2026-07-22 11:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 11:05 [PATCH v2 0/5] firmware: tegra: bpmp: Add ACPI and MBWT support Aniruddha Rao
2026-07-22 11:05 ` [PATCH v2 1/5] firmware: tegra: bpmp: Move channel initialization to helper Aniruddha Rao
2026-07-22 11:05 ` [PATCH v2 2/5] firmware: tegra: bpmp: Add ACPI support Aniruddha Rao
2026-07-23 5:10 ` Mikko Perttunen
2026-08-12 9:30 ` Thierry Reding
2026-07-22 11:05 ` [PATCH v2 3/5] firmware: tegra: bpmp: Add the Memory Bandwidth Throttler ABI definitions Aniruddha Rao
2026-07-22 11:05 ` Aniruddha Rao [this message]
2026-07-23 5:15 ` [PATCH v2 4/5] firmware: tegra: bpmp: Add MBWT BPMP helpers Mikko Perttunen
2026-08-12 9:43 ` Thierry Reding
2026-07-22 11:05 ` [PATCH v2 5/5] firmware: tegra: bpmp: Add MBWT sysfs interface Aniruddha Rao
2026-07-23 5:21 ` Mikko Perttunen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260722110544.193551-5-anrao@nvidia.com \
--to=anrao@nvidia.com \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=thierry.reding@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®