Linux Tegra architecture development
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Aniruddha Rao <anrao@nvidia.com>
Cc: thierry.reding@kernel.org, jonathanh@nvidia.com,
	 linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/6] firmware: tegra: bpmp: Add Tegra410 MBWT BPMP helpers
Date: Fri, 10 Jul 2026 12:19:48 +0200	[thread overview]
Message-ID: <alDGXqtZfA_6O_6d@orome> (raw)
In-Reply-To: <20260615083731.888055-6-anrao@nvidia.com>

[-- Attachment #1: Type: text/plain, Size: 6213 bytes --]

On Mon, Jun 15, 2026 at 08:37:30AM +0000, Aniruddha Rao wrote:
> Add helper functions that send MBWT requests to BPMP firmware on
> Tegra410.
> 
> The helpers implement the GET_BW and SET_BW operations and provide a
> QUERY_ABI-based probe for command availability.

I'd rather not make this Tegra410 specific. We might need it on future
chips, too.

In fact, given the size, I'd be inclined to just include this
unconditionally in the BPMP driver.

> Signed-off-by: Aniruddha Rao <anrao@nvidia.com>
> ---
>  drivers/firmware/tegra/Makefile        |   1 +
>  drivers/firmware/tegra/bpmp-private.h  |  31 +++++++
>  drivers/firmware/tegra/bpmp-tegra410.c | 108 +++++++++++++++++++++++++
>  3 files changed, 140 insertions(+)
>  create mode 100644 drivers/firmware/tegra/bpmp-tegra410.c
> 
> diff --git a/drivers/firmware/tegra/Makefile b/drivers/firmware/tegra/Makefile
> index 41e2e4dc31d6..4310cc0ff294 100644
> --- a/drivers/firmware/tegra/Makefile
> +++ b/drivers/firmware/tegra/Makefile
> @@ -4,6 +4,7 @@ tegra-bpmp-$(CONFIG_ARCH_TEGRA_210_SOC)	+= bpmp-tegra210.o
>  tegra-bpmp-$(CONFIG_ARCH_TEGRA_186_SOC)	+= bpmp-tegra186.o
>  tegra-bpmp-$(CONFIG_ARCH_TEGRA_194_SOC)	+= bpmp-tegra186.o
>  tegra-bpmp-$(CONFIG_ARCH_TEGRA_234_SOC)	+= bpmp-tegra186.o
> +tegra-bpmp-$(CONFIG_ARCH_TEGRA_410_SOC)	+= bpmp-tegra410.o

Just make this bpmp-mbwt.o or maybe even stick it into bpmp.c. It's
barely 100 lines of proper code.

>  tegra-bpmp-$(CONFIG_ARCH_TEGRA_264_SOC)	+= bpmp-tegra186.o
>  tegra-bpmp-$(CONFIG_DEBUG_FS)	+= bpmp-debugfs.o
>  obj-$(CONFIG_TEGRA_BPMP)	+= tegra-bpmp.o
> diff --git a/drivers/firmware/tegra/bpmp-private.h b/drivers/firmware/tegra/bpmp-private.h
> index ebde0e36ae20..c3f466ae5979 100644
> --- a/drivers/firmware/tegra/bpmp-private.h
> +++ b/drivers/firmware/tegra/bpmp-private.h
> @@ -35,4 +35,35 @@ struct tegra_bpmp_acpi_message {
>  	u8 data[TEGRA_BPMP_ACPI_BMRQ_DATA_SZ];
>  };
>  
> +#if IS_ENABLED(CONFIG_ARCH_TEGRA_410_SOC)
> +int tegra410_bpmp_mbwt_set(struct tegra_bpmp *bpmp, unsigned int instance,
> +			   unsigned int vc_type, unsigned int bandwidth);
> +int tegra410_bpmp_mbwt_get(struct tegra_bpmp *bpmp, unsigned int instance,
> +			   unsigned int vc_type, unsigned int *bandwidth_out);
> +bool tegra410_bpmp_mbwt_cmd_is_supported(struct tegra_bpmp *bpmp,
> +					 unsigned int cmd_code);
> +#else
> +static inline int tegra410_bpmp_mbwt_set(struct tegra_bpmp *bpmp,
> +					 unsigned int instance,
> +					 unsigned int vc_type,
> +					 unsigned int bandwidth)
> +{
> +	return -EOPNOTSUPP;
> +}
> +
> +static inline int tegra410_bpmp_mbwt_get(struct tegra_bpmp *bpmp,
> +					 unsigned int instance,
> +					 unsigned int vc_type,
> +					 unsigned int *bandwidth_out)
> +{
> +	return -EOPNOTSUPP;
> +}
> +
> +static inline bool tegra410_bpmp_mbwt_cmd_is_supported(struct tegra_bpmp *bpmp,
> +						       unsigned int cmd_code)
> +{
> +	return false;
> +}
> +#endif

We can then drop the 410 from the prefix and get rid of the dummy
implementations.

Thierry

> +
>  #endif
> diff --git a/drivers/firmware/tegra/bpmp-tegra410.c b/drivers/firmware/tegra/bpmp-tegra410.c
> new file mode 100644
> index 000000000000..87c5dfab864b
> --- /dev/null
> +++ b/drivers/firmware/tegra/bpmp-tegra410.c
> @@ -0,0 +1,108 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (c) 2026, NVIDIA CORPORATION.
> + */
> +
> +#include <linux/device.h>
> +#include <linux/kernel.h>
> +#include <linux/string.h>
> +
> +#include <soc/tegra/bpmp.h>
> +#include <soc/tegra/bpmp-abi.h>
> +
> +#include "bpmp-private.h"
> +
> +bool tegra410_bpmp_mbwt_cmd_is_supported(struct tegra_bpmp *bpmp,
> +					 unsigned int cmd_code)
> +{
> +	struct mrq_sochub_mbwt_request request;
> +	struct tegra_bpmp_message msg;
> +	int err;
> +
> +	memset(&request, 0, sizeof(request));
> +	request.cmd = CMD_SOCHUB_MBWT_QUERY_ABI;
> +	request.query_abi.cmd_code = cmd_code;
> +
> +	memset(&msg, 0, sizeof(msg));
> +	msg.mrq = MRQ_SOCHUB_MBWT;
> +	msg.tx.data = &request;
> +	msg.tx.size = sizeof(request);
> +
> +	err = tegra_bpmp_transfer(bpmp, &msg);
> +	if (err || msg.rx.ret)
> +		return false;
> +
> +	return true;
> +}
> +
> +int tegra410_bpmp_mbwt_set(struct tegra_bpmp *bpmp,
> +			   unsigned int instance,
> +			   unsigned int vc_type,
> +			   unsigned int bandwidth)
> +{
> +	struct mrq_sochub_mbwt_request request;
> +	struct tegra_bpmp_message msg;
> +	int err;
> +
> +	memset(&request, 0, sizeof(request));
> +	request.cmd = CMD_SOCHUB_MBWT_SET_BW;
> +	request.set_bw.instance = instance;
> +	request.set_bw.vc_type = vc_type;
> +	request.set_bw.bw = bandwidth;
> +
> +	memset(&msg, 0, sizeof(msg));
> +	msg.mrq = MRQ_SOCHUB_MBWT;
> +	msg.tx.data = &request;
> +	msg.tx.size = sizeof(request);
> +
> +	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 < 0)
> +		return msg.rx.ret;
> +
> +	return 0;
> +}
> +
> +int tegra410_bpmp_mbwt_get(struct tegra_bpmp *bpmp,
> +			   unsigned int instance,
> +			   unsigned int vc_type,
> +			   unsigned int *bandwidth_out)
> +{
> +	struct mrq_sochub_mbwt_request request;
> +	struct mrq_sochub_mbwt_response response;
> +	struct tegra_bpmp_message msg;
> +	int err;
> +
> +	if (!bandwidth_out)
> +		return -EINVAL;
> +
> +	memset(&request, 0, sizeof(request));
> +	request.cmd = CMD_SOCHUB_MBWT_GET_BW;
> +	request.get_bw.instance = instance;
> +	request.get_bw.vc_type = vc_type;
> +
> +	memset(&response, 0, sizeof(response));
> +
> +	memset(&msg, 0, sizeof(msg));
> +	msg.mrq = MRQ_SOCHUB_MBWT;
> +	msg.tx.data = &request;
> +	msg.tx.size = sizeof(request);
> +	msg.rx.data = &response;
> +	msg.rx.size = sizeof(response);
> +
> +	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 < 0)
> +		return msg.rx.ret;
> +
> +	*bandwidth_out = response.get_bw.bw;
> +
> +	return 0;
> +}
> -- 
> 2.43.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2026-07-10 10:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-15  8:37 [PATCH 0/6] firmware: tegra: bpmp: Add Tegra410 ACPI MBWT support Aniruddha Rao
2026-06-15  8:37 ` [PATCH 1/6] soc/tegra: Add Tegra410 SoC Kconfig symbol Aniruddha Rao
2026-07-10  9:34   ` Thierry Reding
2026-06-15  8:37 ` [PATCH 2/6] firmware: tegra: bpmp: Move channel, resource init to helper Aniruddha Rao
2026-07-10  9:39   ` Thierry Reding
2026-06-15  8:37 ` [PATCH 3/6] firmware: tegra: bpmp: Add ACPI support Aniruddha Rao
2026-07-10 10:08   ` Thierry Reding
2026-06-15  8:37 ` [PATCH 4/6] firmware: tegra: bpmp: Add the Memory Bandwidth Throttler ABI definitions Aniruddha Rao
2026-07-10 10:13   ` Thierry Reding
2026-06-15  8:37 ` [PATCH 5/6] firmware: tegra: bpmp: Add Tegra410 MBWT BPMP helpers Aniruddha Rao
2026-07-10 10:19   ` Thierry Reding [this message]
2026-06-15  8:37 ` [PATCH 6/6] firmware: tegra: bpmp: Add Tegra410 MBWT sysfs interface Aniruddha Rao
2026-07-10 10:46   ` 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=alDGXqtZfA_6O_6d@orome \
    --to=thierry.reding@gmail.com \
    --cc=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