summaryrefslogtreecommitdiffstats
path: root/drivers/firmware/tegra/bpmp-debugfs.c
AgeCommit message (Collapse)AuthorFilesLines
2022-10-24firmware: tegra: bpmp: Do not support big-endianThierry Reding1-23/+19
The CPU and BPMP inter-processor communication code is only partially endian-aware, so it doesn't work properly when run on a big-endian CPU anyway. Running Tegra SoCs in big-endian mode has also never been supported, especially not on those with 64-bit ARM processors. If big-endian support ever becomes necessary this can be added back but will need additional fixes for completeness. Signed-off-by: Thierry Reding <treding@nvidia.com>
2022-10-24firmware: tegra: bpmp: Prefer u32 over uint32_tThierry Reding1-20/+20
The canonical type for 32-bit unsigned integers in the kernel is u32, so use that instead of uint32_t. Signed-off-by: Thierry Reding <treding@nvidia.com>
2022-09-15firmware: tegra: Switch over to memdup_user()Qing Wang1-10/+3
This patch fixes the following Coccinelle warning: drivers/firmware/tegra/bpmp-debugfs.c:379: WARNING opportunity for memdup_user Use memdup_user() rather than duplicating its implementation. This is a little bit restricted to reduce false positives. Signed-off-by: Qing Wang <wangqing@vivo.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
2022-07-08firmware: tegra: Fix error check return value of debugfs_create_file()Lv Ruyi1-5/+5
If an error occurs, debugfs_create_file() will return ERR_PTR(-ERROR), so use IS_ERR() to check it. Reported-by: Zeal Robot <zealci@zte.com.cn> Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn> Signed-off-by: Thierry Reding <treding@nvidia.com>
2021-10-18firmware: tegra: Fix error application of sizeof() to pointerLv Ruyi1-2/+3
Application of sizeof() to pointer yields the number of bytes of the pointer, but it should use the length of buffer in the code. Fixes: 06c2d9a078ab ("firmware: tegra: Reduce stack usage") Reported-by: Zeal Robot <zealci@zte.com.cn> Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn> Reviewed-by: Jon Hunter <jonathanh@nvidia.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
2021-10-07firmware: tegra: Reduce stack usageArnd Bergmann1-9/+17
Building the bpmp-debugfs driver for Arm results in a warning for stack usage: drivers/firmware/tegra/bpmp-debugfs.c:321:16: error: stack frame size of 1224 bytes in function 'bpmp_debug_store' [-Werror,-Wframe-larger-than=] static ssize_t bpmp_debug_store(struct file *file, const char __user *buf, It should be possible to rearrange the code to not require two separate buffers for the file name, but the easiest workaround is to use dynamic allocation. Fixes: 5e37b9c137ee ("firmware: tegra: Add support for in-band debug") Link: https://lore.kernel.org/all/20201204193714.3134651-1-arnd@kernel.org/ Signed-off-by: Arnd Bergmann <arnd@arndb.de> [treding@nvidia.com: consistently return NULL on failure] Signed-off-by: Thierry Reding <treding@nvidia.com>
2021-08-11firmware: tegra: Stop using seq_get_buf()Christoph Hellwig1-11/+47
Opencode a copy of mrq_debug_read() in bpmp_debug_show() so that it can use seq_write() directly instead of poking holes into the seq_file abstractions using seq_get_buf(). Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Thierry Reding <treding@nvidia.com>
2020-11-10firmware: tegra: fix strncpy()/strncat() confusionArnd Bergmann1-5/+1
The way that bpmp_populate_debugfs_inband() uses strncpy() and strncat() makes no sense since the size argument for the first is insufficient to contain the trailing '/' and the second passes the length of the input rather than the output, which triggers a warning: In function 'strncat', inlined from 'bpmp_populate_debugfs_inband' at ../drivers/firmware/tegra/bpmp-debugfs.c:422:4: include/linux/string.h:289:30: warning: '__builtin_strncat' specified bound depends on the length of the source argument [-Wstringop-overflow=] 289 | #define __underlying_strncat __builtin_strncat | ^ include/linux/string.h:367:10: note: in expansion of macro '__underlying_strncat' 367 | return __underlying_strncat(p, q, count); | ^~~~~~~~~~~~~~~~~~~~ drivers/firmware/tegra/bpmp-debugfs.c: In function 'bpmp_populate_debugfs_inband': include/linux/string.h:288:29: note: length computed here 288 | #define __underlying_strlen __builtin_strlen | ^ include/linux/string.h:321:10: note: in expansion of macro '__underlying_strlen' 321 | return __underlying_strlen(p); Simplify this to use an snprintf() instead. Fixes: 5e37b9c137ee ("firmware: tegra: Add support for in-band debug") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
2020-07-14firmware: tegra: Add support for in-band debugJon Hunter1-8/+369
Add support for retrieving BPMP debug information via in-band messaging as opposed to using shared-memory which older BPMP firmware used. Note that it is possible to detect at runtime whether the BPMP firmware being used supports the in-band messaging for retrieving the debug informaation. Therefore, if the BPMP firmware supports the in-band messaging for debug use this and otherwise fall-back to using shared memory. Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
2020-07-14firmware: tegra: Prepare for supporting in-band debugfsJon Hunter1-30/+23
Currently, BPMP debug information is accessible via the Linux debugfs file-system using a shared-memory scheme. More recent BPMP firmware now supports accessing the debug information by in-band messaging which does not require shared-memory. To prepare for adding in-band debugfs support for the BPMP, move the shared-memory specific initialisation from the tegra_bpmp_init_debugfs() into a sub-function. Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
2020-07-14firmware: tegra: Use consistent return variable nameJon Hunter1-18/+18
Most functions in the BPMP driver use 'err' as the return variable name but there are a few places that use 'ret'. Let's use 'err' to be consistent. Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
2020-07-14firmware: tegra: Add return code checks and increase debugfs sizeTimo Alho1-2/+10
Add checking of the BPMP-FW return code values for MRQ_DEBUGFS calls. Also, development versions of the firmware may have debugfs with a directory structure larger than 256 KiB. Hence increase the size of the memory buffer to accommodate those firmware revisions. And finally, ensure that no access outside of allocated memory buffer happens in case BPMP-FW returns an invalid response size (nbytes) from mrq_debugfs_dumpdir() call. Signed-off-by: Timo Alho <talho@nvidia.com> Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
2019-06-05treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288Thomas Gleixner1-10/+1
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms and conditions of the gnu general public license version 2 as published by the free software foundation this program is distributed in the hope it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 263 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Alexios Zavras <alexios.zavras@intel.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190529141901.208660670@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-08firmware: tegra: Switch to global mrq_is_supported()Timo Alho1-28/+1
Patch "firmware: tegra: add helper to check for supported MRQs" added an API to check if MRQ is supported. Remove the implementation from bpmp debugfs code in favor of that. Signed-off-by: Timo Alho <talho@nvidia.com> Acked-by: Sivaram Nair <sivaramn@nvidia.com> Acked-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
2017-10-19firmware: tegra: Add BPMP debugfs supportTimo Alho1-0/+444
Tegra power management firmware running on the co-processor (BPMP) implements a simple pseudo file system akin to debugfs. The file system can be used for debugging purposes to examine and change the status of selected resources controlled by the firmware (such as clocks, resets, voltages, powergates, ...). Add support to "mirror" the firmware's file system to debugfs. At boot, query firmware for a list of all possible files and create corresponding debugfs entries. Read/write of individual files is implemented by sending a Message ReQuest (MRQ) that passes the full file path name and data to firmware via DRAM. Signed-off-by: Timo Alho <talho@nvidia.com> Reviewed-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>