From: Gregory Williams <gregory.williams@amd.com>
To: Michal Simek <michal.simek@amd.com>
Cc: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH 04/15] firmware: xilinx: Use match data for ZynqMP/Versal
Date: Wed, 18 Nov 2026 15:32:00 -0800 [thread overview]
Message-ID: <20261118233211.4121361-5-gregory.williams@amd.com> (raw)
In-Reply-To: <20261118233211.4121361-1-gregory.williams@amd.com>
From: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
Refactor the platform management (PM) firmware API invocation by
extending the existing `platform_fw_data` match data interface with
helpers for feature check and firmware call.
This allows platform-specific handling of feature checks and firmware
calls, and prepares the firmware driver to easily extend support for
the extended SMCCC firmware format.
Signed-off-by: Michal Simek <michal.simek@amd.com>
Signed-off-by: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
---
drivers/firmware/xilinx/zynqmp.c | 92 ++++++++++++++++++++++++++++----
1 file changed, 82 insertions(+), 10 deletions(-)
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index fb8ea7b9fdb1..f5ad99e0026c 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -74,6 +74,21 @@ struct pm_api_feature_data {
};
struct platform_fw_data {
+ /*
+ * Invokes the platform-specific feature check PM FW API call.
+ * Uses either the basic or extended SMCCC frame format based on the
+ * platform.
+ */
+ int (*do_feature_check)(const u32 api_id, u32 *ret_payload);
+
+ /*
+ * Invokes all other platform-specific PM FW APIs.
+ * Uses either the basic or extended SMCCC frame format based
+ * on the platform.
+ */
+ int (*zynqmp_pm_fw_call)(u32 pm_api_id, u32 *ret_payload,
+ u32 num_args, va_list *arg_list);
+
/*
* Family code for platform.
*/
@@ -319,7 +334,11 @@ static int dispatch_feature_check(const u32 api_id, u32 *ret_payload)
if (module_id == TF_A_MODULE_ID)
return do_feature_check_for_tfa_apis(api_id, ret_payload);
- return do_feature_check_basic(api_id, ret_payload);
+ if (active_platform_fw_data)
+ return active_platform_fw_data->do_feature_check(api_id, ret_payload);
+
+ pr_err("%s: no platform firmware data; missing match data\n", __func__);
+ return -ENODEV;
}
static int do_feature_check_call(const u32 api_id)
@@ -489,11 +508,14 @@ int zynqmp_pm_invoke_fw_fn(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...)
}
/**
- * zynqmp_pm_invoke_fn() - Invoke the system-level platform management layer
- * caller function depending on the configuration
+ * __zynqmp_pm_fw_call_basic() - Invoke the system-level platform management layer
+ * supporting basic SMC format.
+ *
* @pm_api_id: Requested PM-API call
* @ret_payload: Returned value array
* @num_args: Number of arguments to requested PM-API call
+ * @arg_list: va_list initialized with va_start, containing arguments passed
+ * to the firmware.
*
* Invoke platform management function for SMC or HVC call, depending on
* configuration.
@@ -510,7 +532,8 @@ int zynqmp_pm_invoke_fw_fn(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...)
*
* Return: Returns status, either success or error+reason
*/
-int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...)
+static int __zynqmp_pm_fw_call_basic(u32 pm_api_id, u32 *ret_payload,
+ u32 num_args, va_list *arg_list)
{
/*
* Added SIP service call Function Identifier
@@ -518,7 +541,6 @@ int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...)
*/
u64 smc_arg[SMC_ARG_CNT_64];
int ret, i;
- va_list arg_list;
u32 args[SMC_ARG_CNT_BASIC_32] = {0};
/*
@@ -533,12 +555,8 @@ int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...)
if (ret < 0)
return ret;
- va_start(arg_list, num_args);
-
for (i = 0; i < num_args; i++)
- args[i] = va_arg(arg_list, u32);
-
- va_end(arg_list);
+ args[i] = va_arg(*arg_list, u32);
smc_arg[0] = PM_SIP_SVC | pm_api_id;
for (i = 0; i < 7; i++)
@@ -548,6 +566,54 @@ int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...)
smc_arg[4], smc_arg[5], smc_arg[6], smc_arg[7]);
}
+/**
+ * zynqmp_pm_invoke_fn() - Invokes the platform-specific PM FW API.
+ * @pm_api_id: Requested PM-API call
+ * @ret_payload: Returned value array
+ * @num_args: Number of arguments to requested PM-API call
+ *
+ * Return: Returns status, either success or error+reason
+ */
+int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...)
+{
+ int ret = -ENODEV;
+ va_list arg_list;
+ u32 module_id;
+
+ /*
+ * Of the 16 32-bit argument registers, the header consumes some,
+ * leaving SMC_ARG_CNT_32 (13) for the extended format and
+ * SMC_ARG_CNT_BASIC_32 (14) for the basic format.
+ *
+ * Impose the larger of the two limits (14) here so callers are not
+ * rejected prematurely; the basic and extended handlers each further
+ * validate the exact count required by their format.
+ */
+ if (num_args > SMC_ARG_CNT_BASIC_32)
+ return -EINVAL;
+
+ va_start(arg_list, num_args);
+
+ module_id = FIELD_GET(MODULE_ID_MASK, pm_api_id);
+
+ /*
+ * Invoke the platform-specific PM FW API based on the platform type.
+ *
+ * The only exception is the TF-A module, which supports the basic
+ * SMC format only.
+ */
+ if (module_id == TF_A_MODULE_ID)
+ ret = __zynqmp_pm_fw_call_basic(pm_api_id, ret_payload, num_args, &arg_list);
+ else if (active_platform_fw_data)
+ ret = active_platform_fw_data->zynqmp_pm_fw_call(pm_api_id, ret_payload,
+ num_args, &arg_list);
+ else
+ pr_err("%s: no platform firmware data; missing match data\n", __func__);
+
+ va_end(arg_list);
+ return ret;
+}
+
static u32 pm_api_version;
static u32 pm_tz_version;
@@ -2457,14 +2523,20 @@ static void zynqmp_firmware_sync_state(struct device *dev)
}
static const struct platform_fw_data platform_fw_data_versal = {
+ .do_feature_check = do_feature_check_basic,
+ .zynqmp_pm_fw_call = __zynqmp_pm_fw_call_basic,
.family_code = PM_VERSAL_FAMILY_CODE,
};
static const struct platform_fw_data platform_fw_data_versal_net = {
+ .do_feature_check = do_feature_check_basic,
+ .zynqmp_pm_fw_call = __zynqmp_pm_fw_call_basic,
.family_code = PM_VERSAL_NET_FAMILY_CODE,
};
static const struct platform_fw_data platform_fw_data_zynqmp = {
+ .do_feature_check = do_feature_check_basic,
+ .zynqmp_pm_fw_call = __zynqmp_pm_fw_call_basic,
.family_code = PM_ZYNQMP_FAMILY_CODE,
};
--
2.34.1
next prev parent reply other threads:[~2026-11-18 23:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 23:31 [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Gregory Williams
2026-11-18 23:31 ` [PATCH 01/15] firmware: xilinx: Separate TF-A checking Gregory Williams
2026-11-18 23:31 ` [PATCH 02/15] firmware: xilinx: Call va_start after pm feature check Gregory Williams
2026-11-18 23:31 ` [PATCH 03/15] firmware: xilinx: Add comments about number of arguments Gregory Williams
2026-11-18 23:32 ` Gregory Williams [this message]
2026-11-18 23:32 ` [PATCH 05/15] firmware: xilinx: Rename zynqmp_pm_invoke_fw_fn() Gregory Williams
2026-11-18 23:32 ` [PATCH 06/15] dt-bindings: firmware: xilinx: Add Versal Gen 2 compatible string Gregory Williams
2026-11-18 23:32 ` [PATCH 07/15] firmware: xilinx: Add support for Versal Gen 2 Gregory Williams
2026-11-18 23:32 ` [PATCH 08/15] dt-bindings: clock: versal: add Versal Gen 2 compatible string Gregory Williams
2026-11-18 23:32 ` [PATCH 09/15] clk: zynqmp: Add " Gregory Williams
2026-11-18 23:32 ` [PATCH 10/15] drivers: firmware: xilinx: Add IOCTL support for the AIE run time operations Gregory Williams
2026-11-18 23:32 ` [PATCH 11/15] dt-bindings: soc: xilinx: Add Versal AI Engine DT binding Gregory Williams
2026-11-18 23:32 ` [PATCH 12/15] accel/amd-ai-engine: Add AMD AI Engine device driver Gregory Williams
2026-11-18 23:32 ` [PATCH 13/15] accel/amd-ai-engine: Add pm ops for firmware calls Gregory Williams
2026-11-18 23:32 ` [PATCH 14/15] accel/amd-ai-engine: Add support to enable/disable tile clocks Gregory Williams
2026-11-18 23:32 ` [PATCH 15/15] accel/amd-ai-engine: Add reset operations Gregory Williams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261118233211.4121361-5-gregory.williams@amd.com \
--to=gregory.williams@amd.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=senthilnathan.thangaraj@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®