[PATCH 03/15] firmware: xilinx: Add comments about number of arguments

From: Gregory Williams

Date: Wed Nov 18 2026 - 18:32:35 EST


From: Senthil Nathan Thangaraj <senthilnathan.thangaraj@xxxxxxx>

The driver checks the number of arguments, but it is not clear what those
values reflect. Introduce the SMC_ARG_CNT_BASIC_32 macro and add comments
to clarify.

Signed-off-by: Michal Simek <michal.simek@xxxxxxx>
Signed-off-by: Senthil Nathan Thangaraj <senthilnathan.thangaraj@xxxxxxx>
---
drivers/firmware/xilinx/zynqmp.c | 14 +++++++++++---
include/linux/firmware/xlnx-zynqmp.h | 10 ++++++++--
2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index e264a1914f06..fb8ea7b9fdb1 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -454,6 +454,10 @@ int zynqmp_pm_invoke_fw_fn(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...)
u32 args[SMC_ARG_CNT_32] = {0};
u32 module_id;

+ /*
+ * Of the 16 32-bit argument registers, the extended SMC header uses 3,
+ * leaving at most SMC_ARG_CNT_32 (13) for arguments.
+ */
if (num_args > SMC_ARG_CNT_32)
return -EINVAL;

@@ -512,12 +516,16 @@ int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...)
* Added SIP service call Function Identifier
* Make sure to stay in x0 register
*/
- u64 smc_arg[8];
+ u64 smc_arg[SMC_ARG_CNT_64];
int ret, i;
va_list arg_list;
- u32 args[14] = {0};
+ u32 args[SMC_ARG_CNT_BASIC_32] = {0};

- if (num_args > 14)
+ /*
+ * Of the 16 32-bit argument registers, the basic SMC header uses 2,
+ * leaving at most SMC_ARG_CNT_BASIC_32 (14) for arguments.
+ */
+ if (num_args > SMC_ARG_CNT_BASIC_32)
return -EINVAL;

/* Check if feature is supported or not */
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index 41a1cd810bda..681ab99ceffc 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -79,8 +79,14 @@
/* Number of 64bits arguments for SMC call */
#define SMC_ARG_CNT_64 8U

-/* Number of 32bits arguments for SMC call */
-#define SMC_ARG_CNT_32 13U
+/*
+ * The SMC call provides 16 32-bit argument registers. The header consumes
+ * some of them, so the number left for arguments depends on the SMC format:
+ * - Extended SMC: 3 used by the header, SMC_ARG_CNT_32 (13) for arguments.
+ * - Basic SMC: 2 used by the header, SMC_ARG_CNT_BASIC_32 (14) for arguments.
+ */
+#define SMC_ARG_CNT_32 13U /* Extended SMC 32-bit arg count */
+#define SMC_ARG_CNT_BASIC_32 14U /* Basic SMC 32-bit arg count */

/* Number of arguments for a callback */
#define CB_ARG_CNT 4
--
2.34.1