From 2c2a933a9fd71c396033a51b45005463a2a9d72d Mon Sep 17 00:00:00 2001 From: Vedashree Vidwans Date: Thu, 31 Oct 2024 21:14:21 -0700 Subject: [PATCH] tegra: hwpm: add debugfs node to skip alist Currently, HWPM driver checks regops address to validate that the address belongs to an IP allowlist that is reserved for profiling. However, it is possible that the allowlist doesn't include all register offset that are required for profiling. This scenario is often encountered during early stages of bringup. This patch adds a debugfs node to make HWPM driver skip allowlist check. This change will allow users to dynamically skip allowlist check when debugfs is available. JIRA THWPM-65 Change-Id: Ic85a1c7fac6a95f7cde532f3bdf6040bbcc7f5f3 Signed-off-by: Vedashree Vidwans Reviewed-on: https://git-master.nvidia.com/r/c/linux-hwpm/+/3241080 Reviewed-by: Seema Khowala Reviewed-by: Vasuki Shankar Reviewed-by: mobile promotions GVS: buildbot_gerritrpt Tested-by: mobile promotions Tested-by: Vasuki Shankar --- drivers/tegra/hwpm/common/init.c | 1 + drivers/tegra/hwpm/common/ip.c | 8 +++++++ drivers/tegra/hwpm/include/tegra_hwpm.h | 1 + drivers/tegra/hwpm/os/linux/debugfs.c | 30 ++++++++++++++----------- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/drivers/tegra/hwpm/common/init.c b/drivers/tegra/hwpm/common/init.c index 227b8b3..e3f2ac0 100644 --- a/drivers/tegra/hwpm/common/init.c +++ b/drivers/tegra/hwpm/common/init.c @@ -132,6 +132,7 @@ int tegra_hwpm_init_sw_components(struct tegra_soc_hwpm *hwpm, tegra_hwpm_fn(hwpm, " "); hwpm->dbg_mask = TEGRA_HWPM_DEFAULT_DBG_MASK; + hwpm->dbg_skip_alist = false; err = tegra_hwpm_init_chip_ip_structures(hwpm, chip_id, chip_id_rev); if (err != 0) { diff --git a/drivers/tegra/hwpm/common/ip.c b/drivers/tegra/hwpm/common/ip.c index dbc13e4..604f146 100644 --- a/drivers/tegra/hwpm/common/ip.c +++ b/drivers/tegra/hwpm/common/ip.c @@ -369,6 +369,14 @@ static bool tegra_hwpm_addr_in_single_element(struct tegra_soc_hwpm *hwpm, "a_type %d s_element_idx %d address not in alist", *ip_idx, (unsigned long long)find_addr, *s_inst_idx, a_type, *s_element_idx); + + if (hwpm->dbg_skip_alist) { + *element_type = element->element_type; + tegra_hwpm_dbg(hwpm, hwpm_dbg_regops, + "skipping allowlist check"); + return true; + } + return false; } diff --git a/drivers/tegra/hwpm/include/tegra_hwpm.h b/drivers/tegra/hwpm/include/tegra_hwpm.h index 9aee42f..bd66ca2 100644 --- a/drivers/tegra/hwpm/include/tegra_hwpm.h +++ b/drivers/tegra/hwpm/include/tegra_hwpm.h @@ -623,6 +623,7 @@ struct tegra_soc_hwpm { bool bind_completed; bool device_opened; bool fake_registers_enabled; + bool dbg_skip_alist; }; #endif /* TEGRA_HWPM_H */ diff --git a/drivers/tegra/hwpm/os/linux/debugfs.c b/drivers/tegra/hwpm/os/linux/debugfs.c index ea29156..1a2e19d 100644 --- a/drivers/tegra/hwpm/os/linux/debugfs.c +++ b/drivers/tegra/hwpm/os/linux/debugfs.c @@ -1,18 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. - * - * 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. - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ +* SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +* +* 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. +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ #include @@ -42,6 +42,10 @@ void tegra_hwpm_debugfs_init(struct tegra_hwpm_os_linux *hwpm_linux) debugfs_create_u32("log_mask", S_IRUGO|S_IWUSR, hwpm_linux->debugfs_root, &hwpm->dbg_mask); + /* Skip allowlist check */ + debugfs_create_bool("skip_allowlist", S_IRUGO|S_IWUSR, + hwpm_linux->debugfs_root, &hwpm->dbg_skip_alist); + return; fail: