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 v5 4/5] firmware: tegra: bpmp: Add MBWT BPMP helpers
Date: Tue, 29 Sep 2026 09:59:14 +0000 [thread overview]
Message-ID: <20260929095915.2215685-5-anrao@nvidia.com> (raw)
In-Reply-To: <20260929095915.2215685-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 v4:
- No change.
Changes since v3:
- No change.
Changes since v2:
- Move the MBWT helpers near probe.
- Explain why the MBWT helpers are needed in the commit message.
Changes since v1:
- Use generic MBWT helper names.
- Fold the MBWT helpers into bpmp.c.
- Drop MBWT Kconfig dependencies.
- Add firmware error handling for MBWT requests.
drivers/firmware/tegra/bpmp-private.h | 7 ++
drivers/firmware/tegra/bpmp.c | 111 +++++++++++++++++++++++++-
2 files changed, 117 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/tegra/bpmp-private.h b/drivers/firmware/tegra/bpmp-private.h
index 163b1c82d445..f0a7d6254bdc 100644
--- a/drivers/firmware/tegra/bpmp-private.h
+++ b/drivers/firmware/tegra/bpmp-private.h
@@ -32,4 +32,11 @@ int tegra_bpmp_init_ping(struct tegra_bpmp *bpmp);
void tegra_bpmp_deinit_ping(struct tegra_bpmp *bpmp);
int tegra_bpmp_init_dt_providers(struct tegra_bpmp *bpmp);
+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 bd8564865638..f2b739977f13 100644
--- a/drivers/firmware/tegra/bpmp.c
+++ b/drivers/firmware/tegra/bpmp.c
@@ -844,8 +844,117 @@ void tegra_bpmp_handle_rx(struct tegra_bpmp *bpmp)
spin_unlock(&bpmp->lock);
}
-int tegra_bpmp_init_channels(struct tegra_bpmp *bpmp)
+/*
+ * MBWT controls are not exposed through ordinary host MMIO and are accessed
+ * through BPMP firmware requests. These helpers provide the request wrappers
+ * used by bandwidth control callers.
+ */
+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) {
+ dev_err(bpmp->dev, "MBWT get bandwidth failed: BPMP error %d\n",
+ msg.rx.ret);
+ return -EIO;
+ }
+
+ *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) {
+ dev_err(bpmp->dev, "MBWT set bandwidth failed: BPMP error %d\n",
+ msg.rx.ret);
+ return -EIO;
+ }
+
+ return 0;
+}
+
+int tegra_bpmp_init_channels(struct tegra_bpmp *bpmp)
{
size_t size;
--
2.43.0
next prev parent reply other threads:[~2026-09-29 9:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 9:59 [PATCH v5 0/5] firmware: tegra: bpmp: Add ACPI and MBWT support Aniruddha Rao
2026-09-29 9:59 ` [PATCH v5 1/5] firmware: tegra: bpmp: Move channel initialization to helper Aniruddha Rao
2026-09-29 9:59 ` [PATCH v5 2/5] firmware: tegra: bpmp: Add ACPI support Aniruddha Rao
2026-09-29 9:59 ` [PATCH v5 3/5] firmware: tegra: bpmp: Add the Memory Bandwidth Throttler ABI definitions Aniruddha Rao
2026-09-29 9:59 ` Aniruddha Rao [this message]
2026-09-29 9:59 ` [PATCH v5 5/5] firmware: tegra: bpmp: Add MBWT sysfs interface Aniruddha Rao
2026-10-02 7:50 ` [PATCH v5 0/5] firmware: tegra: bpmp: Add ACPI and MBWT support Thierry Reding
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=20260929095915.2215685-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.