Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

firmware: xilinx: Add debugfs support for PM_GET_NODE_STATUS

Add new debug interface to support PM_GET_NODE_STATUS to get the node
information like requirements and usage.

The debugfs firmware driver interface is only meant for testing and
debugging EEMI APIs. Hence, it is by-default disabled in production
systems.

Signed-off-by: Madhav Bhatt <madhav.bhatt@amd.com>
Link: https://lore.kernel.org/r/20250417094543.3873507-1-madhav.bhatt@amd.com
Signed-off-by: Michal Simek <michal.simek@amd.com>

authored by

Madhav Bhatt and committed by
Michal Simek
548fe517 8f5ae30d

+64 -2
+13
drivers/firmware/xilinx/zynqmp-debug.c
··· 3 3 * Xilinx Zynq MPSoC Firmware layer for debugfs APIs 4 4 * 5 5 * Copyright (C) 2014-2018 Xilinx, Inc. 6 + * Copyright (C) 2022 - 2025 Advanced Micro Devices, Inc. 6 7 * 7 8 * Michal Simek <michal.simek@amd.com> 8 9 * Davorin Mista <davorin.mista@aggios.com> ··· 39 38 PM_API(PM_RELEASE_NODE), 40 39 PM_API(PM_SET_REQUIREMENT), 41 40 PM_API(PM_GET_API_VERSION), 41 + PM_API(PM_GET_NODE_STATUS), 42 42 PM_API(PM_REGISTER_NOTIFIER), 43 43 PM_API(PM_RESET_ASSERT), 44 44 PM_API(PM_RESET_GET_STATUS), ··· 168 166 pm_api_arg[2] : 0, 169 167 pm_api_arg[3] ? pm_api_arg[3] : 170 168 ZYNQMP_PM_REQUEST_ACK_BLOCKING); 169 + break; 170 + case PM_GET_NODE_STATUS: 171 + ret = zynqmp_pm_get_node_status(pm_api_arg[0], 172 + &pm_api_ret[0], 173 + &pm_api_ret[1], 174 + &pm_api_ret[2]); 175 + if (!ret) 176 + sprintf(debugfs_buf, 177 + "GET_NODE_STATUS:\n\tNodeId: %llu\n\tStatus: %u\n\tRequirements: %u\n\tUsage: %u\n", 178 + pm_api_arg[0], pm_api_ret[0], 179 + pm_api_ret[1], pm_api_ret[2]); 171 180 break; 172 181 case PM_REGISTER_NOTIFIER: 173 182 ret = zynqmp_pm_register_notifier(pm_api_arg[0],
+40 -1
drivers/firmware/xilinx/zynqmp.c
··· 3 3 * Xilinx Zynq MPSoC Firmware layer 4 4 * 5 5 * Copyright (C) 2014-2022 Xilinx, Inc. 6 - * Copyright (C) 2022 - 2024, Advanced Micro Devices, Inc. 6 + * Copyright (C) 2022 - 2025 Advanced Micro Devices, Inc. 7 7 * 8 8 * Michal Simek <michal.simek@amd.com> 9 9 * Davorin Mista <davorin.mista@aggios.com> ··· 1412 1412 (u32)tcm_mode); 1413 1413 } 1414 1414 EXPORT_SYMBOL_GPL(zynqmp_pm_set_tcm_config); 1415 + 1416 + /** 1417 + * zynqmp_pm_get_node_status - PM call to request a node's current power state 1418 + * @node: ID of the component or sub-system in question 1419 + * @status: Current operating state of the requested node 1420 + * @requirements: Current requirements asserted on the node, 1421 + * used for slave nodes only. 1422 + * @usage: Usage information, used for slave nodes only: 1423 + * PM_USAGE_NO_MASTER - No master is currently using 1424 + * the node 1425 + * PM_USAGE_CURRENT_MASTER - Only requesting master is 1426 + * currently using the node 1427 + * PM_USAGE_OTHER_MASTER - Only other masters are 1428 + * currently using the node 1429 + * PM_USAGE_BOTH_MASTERS - Both the current and at least 1430 + * one other master is currently 1431 + * using the node 1432 + * 1433 + * Return: Returns status, either success or error+reason 1434 + */ 1435 + int zynqmp_pm_get_node_status(const u32 node, u32 *const status, 1436 + u32 *const requirements, u32 *const usage) 1437 + { 1438 + u32 ret_payload[PAYLOAD_ARG_CNT]; 1439 + int ret; 1440 + 1441 + if (!status || !requirements || !usage) 1442 + return -EINVAL; 1443 + 1444 + ret = zynqmp_pm_invoke_fn(PM_GET_NODE_STATUS, ret_payload, 1, node); 1445 + if (ret_payload[0] == XST_PM_SUCCESS) { 1446 + *status = ret_payload[1]; 1447 + *requirements = ret_payload[2]; 1448 + *usage = ret_payload[3]; 1449 + } 1450 + 1451 + return ret; 1452 + } 1453 + EXPORT_SYMBOL_GPL(zynqmp_pm_get_node_status); 1415 1454 1416 1455 /** 1417 1456 * zynqmp_pm_force_pwrdwn - PM call to request for another PU or subsystem to
+11 -1
include/linux/firmware/xlnx-zynqmp.h
··· 3 3 * Xilinx Zynq MPSoC Firmware layer 4 4 * 5 5 * Copyright (C) 2014-2021 Xilinx 6 - * Copyright (C) 2022 - 2024, Advanced Micro Devices, Inc. 6 + * Copyright (C) 2022 - 2025 Advanced Micro Devices, Inc. 7 7 * 8 8 * Michal Simek <michal.simek@amd.com> 9 9 * Davorin Mista <davorin.mista@aggios.com> ··· 164 164 enum pm_api_id { 165 165 PM_API_FEATURES = 0, 166 166 PM_GET_API_VERSION = 1, 167 + PM_GET_NODE_STATUS = 3, 167 168 PM_REGISTER_NOTIFIER = 5, 168 169 PM_FORCE_POWERDOWN = 8, 169 170 PM_REQUEST_WAKEUP = 10, ··· 630 629 int zynqmp_pm_get_rpu_mode(u32 node_id, enum rpu_oper_mode *rpu_mode); 631 630 int zynqmp_pm_set_rpu_mode(u32 node_id, enum rpu_oper_mode rpu_mode); 632 631 int zynqmp_pm_set_tcm_config(u32 node_id, enum rpu_tcm_comb tcm_mode); 632 + int zynqmp_pm_get_node_status(const u32 node, u32 *const status, 633 + u32 *const requirements, u32 *const usage); 633 634 int zynqmp_pm_set_sd_config(u32 node, enum pm_sd_config_type config, u32 value); 634 635 int zynqmp_pm_set_gem_config(u32 node, enum pm_gem_config_type config, 635 636 u32 value); ··· 930 927 } 931 928 932 929 static inline int zynqmp_pm_set_tcm_config(u32 node_id, enum rpu_tcm_comb tcm_mode) 930 + { 931 + return -ENODEV; 932 + } 933 + 934 + static inline int zynqmp_pm_get_node_status(const u32 node, u32 *const status, 935 + u32 *const requirements, 936 + u32 *const usage) 933 937 { 934 938 return -ENODEV; 935 939 }