Re: [PATCH v2 5/5] firmware: tegra: bpmp: Add MBWT sysfs interface
Mikko Perttunen <[email protected]> Thu, 23 Jul 2026 14:21:37 +0900
| Newsgroups | org.kernel.vger.linux-tegra,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Wednesday, July 22, 2026 8:05 PM Aniruddha Rao wrote: > Different workloads can place different memory-bandwidth demands on the > system. Selecting an appropriate bandwidth limit depends on the runtime > workload mix and on the devices carrying that traffic, such as PCIe > traffic or GPU traffic connected over the chip-to-chip link (NVCLINK). > That information is not available to the kernel. > > BPMP firmware of some Tegra platforms provides Memory Bandwidth > Throttler (MBWT) controls for PCIe and GPU traffic connected over > NVCLINK on the path to DRAM. Each PCIe bandwidth group has a single > shared cap for all traffic in that group. Bandwidth for a group can be > set per traffic type. > > Add sysfs attributes on the tegra-bpmp platform device to expose a > narrow userspace interface for MBWT control. The attributes are arranged > as mbwt/pcie0..pcie5/pcie_read/bandwidth, > pcie_write/bandwidth and nvclink/bandwidth files. Each pcieN directory > identifies a PCIe bandwidth group and each traffic directory identifies > the traffic type. > > Reading a bandwidth attribute queries firmware for the selected bandwidth > group and traffic type. Writing an integer programs the target bandwidth > cap in GB/s for that bandwidth group and traffic type. > > Register the attributes only when BPMP firmware reports support for the > MBWT GET_BW and SET_BW requests through its query ABI. > > Signed-off-by: Aniruddha Rao <[email protected]> > --- > Changes since v1: > - Register the interface based on MBWT firmware support, not ACPI. > - Replace the stateful tuple attribute with per-traffic bandwidth files. > - Remove software bandwidth range checks. > - Build the sysfs interface under CONFIG_SYSFS. > - Rename the registration helper to tegra_bpmp_init_sysfs(). > - Avoid platform-specific or transport-specific MBWT wording. > > .../ABI/testing/sysfs-platform-tegra-bpmp | 48 ++++ > drivers/firmware/tegra/Makefile | 1 + > drivers/firmware/tegra/bpmp-private.h | 9 + > drivers/firmware/tegra/bpmp-tegra-sysfs.c | 205 ++++++++++++++++++ > drivers/firmware/tegra/bpmp.c | 4 + > 5 files changed, 267 insertions(+) > create mode 100644 Documentation/ABI/testing/sysfs-platform-tegra-bpmp > create mode 100644 drivers/firmware/tegra/bpmp-tegra-sysfs.c > > diff --git a/Documentation/ABI/testing/sysfs-platform-tegra-bpmp b/Documentation/ABI/testing/sysfs-platform-tegra-bpmp > new file mode 100644 > index 000000000000..36440e696e7d > --- /dev/null > +++ b/Documentation/ABI/testing/sysfs-platform-tegra-bpmp > @@ -0,0 +1,48 @@ > +What: /sys/bus/platform/devices/<bpmp-device>/mbwt/pcie[0-5]/pcie_read/bandwidth > +What: /sys/bus/platform/devices/<bpmp-device>/mbwt/pcie[0-5]/pcie_write/bandwidth > +What: /sys/bus/platform/devices/<bpmp-device>/mbwt/pcie[0-5]/nvclink/bandwidth > +Date: July 2026 > +KernelVersion: 7.2 > +Contact: Aniruddha TVS Rao <[email protected]> > +Description: > + Provides access to Memory Bandwidth Throttler (MBWT) > + controls exposed by BPMP firmware for PCIe traffic and GPU > + traffic connected over the chip-to-chip link (NVCLINK) on > + the path to DRAM. > + > + The attributes are present only when BPMP firmware reports > + support for the MBWT GET_BW and SET_BW requests through the > + MBWT query ABI. > + > + Each pcieN directory identifies one PCIe bandwidth group. > + Each bandwidth group has a single shared cap for all traffic > + in that group. A group may contain only PCIe devices, only a > + GPU connected over NVCLINK, or both PCIe and GPU traffic in a > + bifurcated topology. > + > + The pcie_read, pcie_write and nvclink directories select the > + traffic type for the selected group: > + > + pcie_read > + PCIe read traffic > + > + pcie_write > + PCIe write traffic > + > + nvclink > + GPU traffic connected over NVCLINK > + > + Reading a bandwidth attribute returns the bandwidth cap in GB/s > + reported by firmware for that bandwidth group and traffic > + type. > + > + Writing an integer to a bandwidth attribute programs the target > + bandwidth cap in GB/s for that bandwidth group and traffic > + type. > + > + Examples: > + cat .../mbwt/pcie0/pcie_write/bandwidth > + echo 100 > .../mbwt/pcie0/pcie_write/bandwidth > + > +Users: Platform integration and bandwidth tuning on systems with BPMP > + firmware MBWT support. > diff --git a/drivers/firmware/tegra/Makefile b/drivers/firmware/tegra/Makefile > index 41e2e4dc31d6..59085e183fbd 100644 > --- a/drivers/firmware/tegra/Makefile > +++ b/drivers/firmware/tegra/Makefile > @@ -6,5 +6,6 @@ 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_264_SOC) += bpmp-tegra186.o > tegra-bpmp-$(CONFIG_DEBUG_FS) += bpmp-debugfs.o > +tegra-bpmp-$(CONFIG_SYSFS) += bpmp-tegra-sysfs.o > obj-$(CONFIG_TEGRA_BPMP) += tegra-bpmp.o > obj-$(CONFIG_TEGRA_IVC) += ivc.o > diff --git a/drivers/firmware/tegra/bpmp-private.h b/drivers/firmware/tegra/bpmp-private.h > index b3770e71020e..3a15a7aa0ffc 100644 > --- a/drivers/firmware/tegra/bpmp-private.h > +++ b/drivers/firmware/tegra/bpmp-private.h > @@ -33,4 +33,13 @@ int tegra_bpmp_mbwt_get(struct tegra_bpmp *bpmp, unsigned int instance, > int tegra_bpmp_mbwt_set(struct tegra_bpmp *bpmp, unsigned int instance, > unsigned int vc_type, unsigned int bandwidth); > > +#ifdef CONFIG_SYSFS > +int tegra_bpmp_init_sysfs(struct tegra_bpmp *bpmp); > +#else > +static inline int tegra_bpmp_init_sysfs(struct tegra_bpmp *bpmp) > +{ > + return 0; > +} > +#endif > + > #endif > diff --git a/drivers/firmware/tegra/bpmp-tegra-sysfs.c b/drivers/firmware/tegra/bpmp-tegra-sysfs.c The directory already says 'tegra', so the file can be just 'bpmp-sysfs.c'. That matches the existing 'bpmp-debugfs.c' as well.