[SRU][J:linux-bluefield][PATCH v1 1/1] UBUNTU: SAUCE: mlxbf-ptm: add atx debugfs nodes
Jitendra Lanka
jlanka at nvidia.com
Wed Mar 15 20:32:18 UTC 2023
BugLink: https://bugs.launchpad.net/bugs/2011738
* Add additional debugfs nodes that provide ATX status and
power profile data.
* Replace S_IRUGO with 0444
Signed-off-by: Jitendra Lanka <jlanka at nvidia.com>
---
drivers/platform/mellanox/mlxbf-ptm.c | 86 ++++++++++++++++-----------
1 file changed, 50 insertions(+), 36 deletions(-)
diff --git a/drivers/platform/mellanox/mlxbf-ptm.c b/drivers/platform/mellanox/mlxbf-ptm.c
index 3692018b9d60..81fedd5ce1f9 100644
--- a/drivers/platform/mellanox/mlxbf-ptm.c
+++ b/drivers/platform/mellanox/mlxbf-ptm.c
@@ -1,32 +1,11 @@
// SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause
/*
+ * Copyright (C) 2023 NVIDIA Corporation & Affiliates.
+ *
* Nvidia Bluefield power and thermal debugfs driver
* This driver provides a debugfs interface for systems management
* software to monitor power and thermal actions.
*
- * Copyright (C) 2023 NVIDIA Corporation. All rights reserved.
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- * available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- * available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- * copy of which is available from the Open Source Initiative, see
- * http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
*/
#include <linux/kernel.h>
@@ -45,6 +24,9 @@
#define MLNX_PTM_GET_MAX_TEMP 0x82000108
#define MLNX_PTM_GET_PWR_EVT_CNT 0x82000109
#define MLNX_PTM_GET_TEMP_EVT_CNT 0x8200010A
+#define MLNX_PTM_GET_POWER_ENVELOPE 0x8200010B
+#define MLNX_PTM_GET_ATX_PWR_STATE 0x8200010C
+#define MLNX_PTM_GET_CUR_PPROFILE 0x8200010D
#define MLNX_POWER_ERROR 300
@@ -164,6 +146,33 @@ static int error_status_show(void *data, u64 *val)
DEFINE_SIMPLE_ATTRIBUTE(error_status_fops,
error_status_show, NULL, "%llu\n");
+static int power_envelope_show(void *data, u64 *val)
+{
+ *val = smc_call0(MLNX_PTM_GET_POWER_ENVELOPE);
+
+ return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(power_envelope_fops,
+ power_envelope_show, NULL, "%llu\n");
+
+static int atx_status_show(void *data, u64 *val)
+{
+ *val = smc_call0(MLNX_PTM_GET_ATX_PWR_STATE);
+
+ return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(atx_status_fops,
+ atx_status_show, NULL, "%lld\n");
+
+static int current_pprofile_show(void *data, u64 *val)
+{
+ *val = smc_call0(MLNX_PTM_GET_CUR_PPROFILE);
+
+ return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(current_pprofile_fops,
+ current_pprofile_show, NULL, "%llu\n");
+
static int __init mlxbf_ptm_init(void)
{
@@ -176,29 +185,34 @@ static int __init mlxbf_ptm_init(void)
monitors = debugfs_create_dir("monitors", ptm_root);
status = debugfs_create_dir("status", monitors);
- debugfs_create_file("vr0_power", S_IRUGO, status, NULL,
+ debugfs_create_file("vr0_power", 0444, status, NULL,
&vr0_power_fops);
- debugfs_create_file("vr1_power", S_IRUGO, status, NULL,
+ debugfs_create_file("vr1_power", 0444, status, NULL,
&vr1_power_fops);
- debugfs_create_file("total_power", S_IRUGO, status, NULL,
+ debugfs_create_file("total_power", 0444, status, NULL,
&total_power_fops);
- debugfs_create_file("ddr_temp", S_IRUGO, status,
+ debugfs_create_file("ddr_temp", 0444, status,
NULL, &ddr_thld_fops);
- debugfs_create_file("core_temp", S_IRUGO, status,
+ debugfs_create_file("core_temp", 0444, status,
NULL, &core_temp_fops);
- debugfs_create_file("power_throttling_event_count", S_IRUGO, status,
+ debugfs_create_file("power_throttling_event_count", 0444, status,
NULL, &pwr_evt_counter_fops);
- debugfs_create_file("thermal_throttling_event_count", S_IRUGO, status,
+ debugfs_create_file("thermal_throttling_event_count", 0444, status,
NULL, &temp_evt_counter_fops);
- debugfs_create_file("throttling_state", S_IRUGO, status,
+ debugfs_create_file("throttling_state", 0444, status,
NULL, &throttling_state_fops);
- debugfs_create_file("power_throttling_state", S_IRUGO, status,
+ debugfs_create_file("power_throttling_state", 0444, status,
NULL, &pthrottling_state_fops);
- debugfs_create_file("thermal_throttling_state", S_IRUGO, status,
+ debugfs_create_file("thermal_throttling_state", 0444, status,
NULL, &tthrottling_state_fops);
- debugfs_create_file("error_state", S_IRUGO, status,
+ debugfs_create_file("error_state", 0444, status,
NULL, &error_status_fops);
-
+ debugfs_create_file("power_envelope", 0444, status,
+ NULL, &power_envelope_fops);
+ debugfs_create_file("atx_power_available", 0444, status,
+ NULL, &atx_status_fops);
+ debugfs_create_file("active_power_profile", 0444, status,
+ NULL, ¤t_pprofile_fops);
return 0;
}
@@ -213,4 +227,4 @@ module_exit(mlxbf_ptm_exit);
MODULE_AUTHOR("Jitendra Lanka <jlanka at nvidia.com>");
MODULE_DESCRIPTION("Nvidia Bluefield power and thermal debugfs driver");
MODULE_LICENSE("Dual BSD/GPL");
-MODULE_VERSION("1.0");
+MODULE_VERSION("1.1");
--
2.30.1
More information about the kernel-team
mailing list