* [PATCH 01/15] firmware: xilinx: Separate TF-A checking
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 ` Gregory Williams
2026-11-18 23:31 ` [PATCH 02/15] firmware: xilinx: Call va_start after pm feature check Gregory Williams
` (14 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Gregory Williams @ 2026-11-18 23:31 UTC (permalink / raw)
To: Michal Simek; +Cc: Senthil Nathan Thangaraj, linux-arm-kernel, linux-kernel
From: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
Feature check of TF-A APIs has special requirement to fill in specific
module/id and API ID based on the platform requirement.
This separation of TF-A feature checking facilitates a smoother transition
to extended SMCCC format.
Co-developed-by: Michal Simek <michal.simek@amd.com>
Signed-off-by: Michal Simek <michal.simek@amd.com>
Signed-off-by: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
---
drivers/firmware/xilinx/zynqmp.c | 105 +++++++++++++++++++++++++------
1 file changed, 85 insertions(+), 20 deletions(-)
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 727a9888a933..940306079a78 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -214,12 +214,65 @@ static noinline int do_fw_call_hvc(u32 *ret_payload, u32 num_args, ...)
return zynqmp_pm_ret_code((enum pm_ret_status)res.a0);
}
-static int __do_feature_check_call(const u32 api_id, u32 *ret_payload)
+/**
+ * prep_pm_hdr_feature_check - Prepare SMC header for PM_FEATURE_CHECK.
+ *
+ * TF-A expects the module field of arg[0] to be PM_MODULE_ID for its feature
+ * check, independent of the queried API's module; hence no module_id arg.
+ *
+ * Return: SMC arg[0] header value.
+ */
+static u64 prep_pm_hdr_feature_check(void)
+{
+ return PM_SIP_SVC | FIELD_PREP(MODULE_ID_MASK, PM_MODULE_ID) | PM_FEATURE_CHECK;
+}
+
+/**
+ * do_feature_check_for_tfa_apis - Perform feature check for TF-A APIs.
+ * @api_id: API ID to be checked.
+ * @ret_payload: Pointer to store the firmware's response payload.
+ *
+ * Prepares the command header and payload for TF-A APIs and makes the FW call.
+ *
+ * Return:
+ * - Feature status word from ret_payload[1] on success
+ * - -EOPNOTSUPP if the firmware call fails
+ */
+static int do_feature_check_for_tfa_apis(const u32 api_id, u32 *ret_payload)
{
+ u64 smc_arg[2];
int ret;
+
+ smc_arg[0] = prep_pm_hdr_feature_check();
+ smc_arg[1] = api_id;
+
+ ret = do_fw_call(ret_payload, 2, smc_arg[0], smc_arg[1]);
+
+ if (ret)
+ return -EOPNOTSUPP;
+
+ return ret_payload[1];
+}
+
+/**
+ * do_feature_check_basic - Perform feature check for an API ID with
+ * basic SMC format.
+ * @api_id: API ID to be checked.
+ * @ret_payload: Pointer to store the firmware's response payload.
+ *
+ * Determines the appropriate API (PM_FEATURE_CHECK or PM_API_FEATURES) based on
+ * the module ID in the given API ID. Frames the SMC call arguments in the basic
+ * format, executes the firmware call, and processes the result.
+ *
+ * Return: Feature status word from ret_payload[1] on success; -EOPNOTSUPP if
+ * the firmware call fails.
+ */
+static int do_feature_check_basic(const u32 api_id, u32 *ret_payload)
+{
+ u32 feature_check_api_id;
u64 smc_arg[2];
u32 module_id;
- u32 feature_check_api_id;
+ int ret;
module_id = FIELD_GET(MODULE_ID_MASK, api_id);
@@ -232,29 +285,41 @@ static int __do_feature_check_call(const u32 api_id, u32 *ret_payload)
else
feature_check_api_id = PM_API_FEATURES;
- if (module_id == TF_A_MODULE_ID)
- smc_arg[1] = api_id;
- else
- smc_arg[1] = (api_id & API_ID_MASK);
-
smc_arg[0] = PM_SIP_SVC | FIELD_PREP(MODULE_ID_MASK, module_id) | feature_check_api_id;
+ smc_arg[1] = (api_id & API_ID_MASK);
ret = do_fw_call(ret_payload, 2, smc_arg[0], smc_arg[1]);
+ if (ret)
+ ret = -EOPNOTSUPP;
+ else
+ ret = ret_payload[1];
- /*
- * For TF-A APIs, if the feature check with PM_API_FEATURES fails,
- * retry with the legacy PM_FEATURE_CHECK for backward compatibility.
- */
- if (module_id == TF_A_MODULE_ID && ret) {
- smc_arg[0] = PM_SIP_SVC | FIELD_PREP(MODULE_ID_MASK, PM_MODULE_ID) |
- PM_FEATURE_CHECK;
- ret = do_fw_call(ret_payload, 2, smc_arg[0], smc_arg[1]);
- }
+ return ret;
+}
- if (ret)
- return ret;
+/**
+ * dispatch_feature_check - Dispatch feature check based on module ID.
+ * @api_id: API ID to be checked.
+ * @ret_payload: Pointer to store the firmware's response payload.
+ *
+ * Determines the appropriate feature check function to call based on the
+ * module ID extracted from the API ID. If the module ID corresponds to
+ * TF-A, it calls do_feature_check_for_tfa_apis(); otherwise, it calls
+ * do_feature_check_basic() which uses basic SMCCC format.
+ *
+ * Return: Feature status word from ret_payload[1] on success; negative error
+ * code on failure.
+ */
+static int dispatch_feature_check(const u32 api_id, u32 *ret_payload)
+{
+ u32 module_id;
- return ret_payload[1];
+ module_id = FIELD_GET(MODULE_ID_MASK, api_id);
+
+ 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);
}
static int do_feature_check_call(const u32 api_id)
@@ -276,7 +341,7 @@ static int do_feature_check_call(const u32 api_id)
return -ENOMEM;
feature_data->pm_api_id = api_id;
- ret = __do_feature_check_call(api_id, ret_payload);
+ ret = dispatch_feature_check(api_id, ret_payload);
feature_data->feature_status = ret;
hash_add(pm_api_features_map, &feature_data->hentry, api_id);
--
2.34.1
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH 02/15] firmware: xilinx: Call va_start after pm feature check
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 ` Gregory Williams
2026-11-18 23:31 ` [PATCH 03/15] firmware: xilinx: Add comments about number of arguments Gregory Williams
` (13 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Gregory Williams @ 2026-11-18 23:31 UTC (permalink / raw)
To: Michal Simek, Izhar Ameer Shaikh, Greg Kroah-Hartman,
Jay Buddhabhatti, Ronak Jain
Cc: Senthil Nathan Thangaraj, linux-arm-kernel, linux-kernel
From: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
zynqmp_pm_invoke_fw_fn() and zynqmp_pm_invoke_fn() call va_start() before
checking whether the PM API is supported. If the feature check fails, the
function returns early without a matching va_end().
Per the C standard, every va_start() must be paired with va_end() on every
exit path; calling va_start() and returning without va_end() is undefined
behavior.
Move va_start() to after the feature check so it is only invoked when the
va_list will actually be consumed.
Fixes: f922b16aa5fa ("firmware: xilinx: Update firmware call interface to support additional args")
Fixes: 92fb71333d57 ("firmware: xilinx: add support for new SMC call 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 | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 940306079a78..e264a1914f06 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -457,13 +457,13 @@ int zynqmp_pm_invoke_fw_fn(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...)
if (num_args > SMC_ARG_CNT_32)
return -EINVAL;
- va_start(arg_list, num_args);
-
/* Check if feature is supported or not */
ret = zynqmp_pm_feature(pm_api_id);
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);
@@ -520,13 +520,13 @@ int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...)
if (num_args > 14)
return -EINVAL;
- va_start(arg_list, num_args);
-
/* Check if feature is supported or not */
ret = zynqmp_pm_feature(pm_api_id);
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);
--
2.34.1
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH 03/15] firmware: xilinx: Add comments about number of arguments
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 ` Gregory Williams
2026-11-18 23:32 ` [PATCH 04/15] firmware: xilinx: Use match data for ZynqMP/Versal Gregory Williams
` (12 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Gregory Williams @ 2026-11-18 23:31 UTC (permalink / raw)
To: Michal Simek; +Cc: Senthil Nathan Thangaraj, linux-arm-kernel, linux-kernel
From: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
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@amd.com>
Signed-off-by: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
---
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
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH 04/15] firmware: xilinx: Use match data for ZynqMP/Versal
2026-11-18 23:31 [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Gregory Williams
` (2 preceding siblings ...)
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
2026-11-18 23:32 ` [PATCH 05/15] firmware: xilinx: Rename zynqmp_pm_invoke_fw_fn() Gregory Williams
` (11 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Gregory Williams @ 2026-11-18 23:32 UTC (permalink / raw)
To: Michal Simek; +Cc: Senthil Nathan Thangaraj, linux-arm-kernel, linux-kernel
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
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH 05/15] firmware: xilinx: Rename zynqmp_pm_invoke_fw_fn()
2026-11-18 23:31 [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Gregory Williams
` (3 preceding siblings ...)
2026-11-18 23:32 ` [PATCH 04/15] firmware: xilinx: Use match data for ZynqMP/Versal Gregory Williams
@ 2026-11-18 23:32 ` Gregory Williams
2026-11-18 23:32 ` [PATCH 06/15] dt-bindings: firmware: xilinx: Add Versal Gen 2 compatible string Gregory Williams
` (10 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Gregory Williams @ 2026-11-18 23:32 UTC (permalink / raw)
To: Michal Simek; +Cc: Senthil Nathan Thangaraj, linux-arm-kernel, linux-kernel
From: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
The function name zynqmp_pm_invoke_fw_fn() doesn't really reflect what this
function does, so rename it to zynqmp_pm_fw_call_extended(), which reflects
which firmware format is used.
Signed-off-by: Michal Simek <michal.simek@amd.com>
Signed-off-by: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
---
drivers/firmware/xilinx/zynqmp.c | 10 +++++-----
include/linux/firmware/xlnx-zynqmp.h | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index f5ad99e0026c..709370933741 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -440,7 +440,7 @@ int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id)
EXPORT_SYMBOL_GPL(zynqmp_pm_is_function_supported);
/**
- * zynqmp_pm_invoke_fw_fn() - Invoke the system-level platform management layer
+ * zynqmp_pm_fw_call_extended() - Invoke the system-level platform management layer
* caller function depending on the configuration
* @pm_api_id: Requested PM-API call
* @ret_payload: Returned value array
@@ -461,7 +461,7 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_is_function_supported);
*
* Return: Returns status, either success or error+reason
*/
-int zynqmp_pm_invoke_fw_fn(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...)
+int zynqmp_pm_fw_call_extended(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...)
{
/*
* Added SIP service call Function Identifier
@@ -796,9 +796,9 @@ int zynqmp_pm_query_data(struct zynqmp_pm_query_data qdata, u32 *out)
u32 ret_payload[PAYLOAD_ARG_CNT] = {0};
if (sip_svc_version >= SIP_SVC_PASSTHROUGH_VERSION) {
- ret = zynqmp_pm_invoke_fw_fn(PM_QUERY_DATA, ret_payload, 4,
- qdata.qid, qdata.arg1,
- qdata.arg2, qdata.arg3);
+ ret = zynqmp_pm_fw_call_extended(PM_QUERY_DATA, ret_payload, 4,
+ qdata.qid, qdata.arg1,
+ qdata.arg2, qdata.arg3);
/* To support backward compatibility */
if (!ret && !ret_payload[0]) {
/*
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index 681ab99ceffc..58f2e3fddfaf 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -578,7 +578,7 @@ struct zynqmp_pm_query_data {
};
int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...);
-int zynqmp_pm_invoke_fw_fn(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...);
+int zynqmp_pm_fw_call_extended(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...);
#if IS_REACHABLE(CONFIG_ZYNQMP_FIRMWARE)
int zynqmp_pm_get_api_version(u32 *version);
--
2.34.1
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH 06/15] dt-bindings: firmware: xilinx: Add Versal Gen 2 compatible string
2026-11-18 23:31 [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Gregory Williams
` (4 preceding siblings ...)
2026-11-18 23:32 ` [PATCH 05/15] firmware: xilinx: Rename zynqmp_pm_invoke_fw_fn() Gregory Williams
@ 2026-11-18 23:32 ` Gregory Williams
2026-11-18 23:32 ` [PATCH 07/15] firmware: xilinx: Add support for Versal Gen 2 Gregory Williams
` (9 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Gregory Williams @ 2026-11-18 23:32 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Michal Simek,
kishore Manne
Cc: Senthil Nathan Thangaraj, devicetree, linux-arm-kernel, linux-kernel
From: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
Add compatible string for Versal Gen 2 firmware driver.
Signed-off-by: Michal Simek <michal.simek@amd.com>
Signed-off-by: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
---
.../bindings/firmware/xilinx/xlnx,zynqmp-firmware.yaml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.yaml b/Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.yaml
index 72af37cdb103..60d1bd329d0e 100644
--- a/Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.yaml
+++ b/Documentation/devicetree/bindings/firmware/xilinx/xlnx,zynqmp-firmware.yaml
@@ -32,6 +32,9 @@ properties:
- xlnx,versal-net-firmware
- const: xlnx,versal-firmware
+ - description: For implementations complying for Versal Gen 2.
+ const: xlnx,versal2-firmware
+
method:
description: |
The method of calling the PM-API firmware layer.
--
2.34.1
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH 07/15] firmware: xilinx: Add support for Versal Gen 2
2026-11-18 23:31 [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Gregory Williams
` (5 preceding siblings ...)
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 ` Gregory Williams
2026-11-18 23:32 ` [PATCH 08/15] dt-bindings: clock: versal: add Versal Gen 2 compatible string Gregory Williams
` (8 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Gregory Williams @ 2026-11-18 23:32 UTC (permalink / raw)
To: Michal Simek; +Cc: Senthil Nathan Thangaraj, linux-arm-kernel, linux-kernel
From: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
Until Versal, the extended SMCCC payload was supported only for QUERY_DATA,
while other APIs used the basic SMCCC format.
In Versal Gen 2, all EEMI APIs are supported with extended SMCCC payload
only, enabling a simplified and efficient pass-through implementation.
The TF-A feature check now tries PM_API_FEATURES first and falls back to
PM_FEATURE_CHECK so the same code path works on Versal Gen 2 (where TF-A
only exposes PM_API_FEATURES on the SiP service) and on the older
ZynqMP/Versal/Versal NET platforms (where TF-A exposes PM_FEATURE_CHECK).
Signed-off-by: Michal Simek <michal.simek@amd.com>
Signed-off-by: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
---
drivers/firmware/xilinx/zynqmp.c | 117 ++++++++++++++++++++++++---
include/linux/firmware/xlnx-zynqmp.h | 1 +
2 files changed, 109 insertions(+), 9 deletions(-)
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 709370933741..a8c70e775ae3 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -242,12 +242,24 @@ static u64 prep_pm_hdr_feature_check(void)
return PM_SIP_SVC | FIELD_PREP(MODULE_ID_MASK, PM_MODULE_ID) | PM_FEATURE_CHECK;
}
+/**
+ * prep_pm_hdr_api_features - Prepare SMC header for PM_API_FEATURES.
+ * @module_id: Module ID of the API to be checked.
+ *
+ * Return: SMC arg[0] header value.
+ */
+static u64 prep_pm_hdr_api_features(u32 module_id)
+{
+ return PM_SIP_SVC | FIELD_PREP(MODULE_ID_MASK, module_id) | PM_API_FEATURES;
+}
+
/**
* do_feature_check_for_tfa_apis - Perform feature check for TF-A APIs.
* @api_id: API ID to be checked.
* @ret_payload: Pointer to store the firmware's response payload.
*
* Prepares the command header and payload for TF-A APIs and makes the FW call.
+ * Tries PM_API_FEATURES first, then falls back to PM_FEATURE_CHECK.
*
* Return:
* - Feature status word from ret_payload[1] on success
@@ -256,13 +268,68 @@ static u64 prep_pm_hdr_feature_check(void)
static int do_feature_check_for_tfa_apis(const u32 api_id, u32 *ret_payload)
{
u64 smc_arg[2];
+ u32 module_id;
int ret;
- smc_arg[0] = prep_pm_hdr_feature_check();
+ module_id = FIELD_GET(MODULE_ID_MASK, api_id);
+
+ smc_arg[0] = prep_pm_hdr_api_features(module_id);
smc_arg[1] = api_id;
ret = do_fw_call(ret_payload, 2, smc_arg[0], smc_arg[1]);
+ if (ret) {
+ smc_arg[0] = prep_pm_hdr_feature_check();
+ ret = do_fw_call(ret_payload, 2, smc_arg[0], smc_arg[1]);
+ if (ret)
+ return -EOPNOTSUPP;
+ }
+
+ return ret_payload[1];
+}
+
+/**
+ * do_feature_check_extended - Perform feature check for an API ID
+ * using extended SMCCC format.
+ * @api_id: API ID to be checked.
+ * @ret_payload: Pointer to store the firmware's response payload.
+ *
+ * Determines the appropriate API (PM_FEATURE_CHECK or PM_API_FEATURES) based on
+ * the module ID in the given API ID. Frames the arguments in the extended
+ * SMCCC format, executes the firmware call, and processes the result.
+ *
+ * Return:
+ * - 0 on success
+ * - -EOPNOTSUPP if the firmware call fails.
+ */
+static int do_feature_check_extended(const u32 api_id, u32 *ret_payload)
+{
+ u32 feature_check_api_id;
+ u64 smc_arg[2];
+ u32 module_id;
+ int ret;
+
+ module_id = FIELD_GET(MODULE_ID_MASK, api_id);
+
+ /*
+ * Feature check of APIs belonging to PM and XSEM are handled by calling
+ * PM_FEATURE_CHECK API. For other modules, call PM_API_FEATURES API.
+ */
+ if (module_id == PM_MODULE_ID || module_id == XSEM_MODULE_ID)
+ feature_check_api_id = PM_FEATURE_CHECK;
+ else
+ feature_check_api_id = PM_API_FEATURES;
+
+ if (module_id == PM_MODULE_ID)
+ module_id = XPM_MODULE_ID;
+
+ /* Frame extended SMC format */
+ smc_arg[0] = PM_SIP_SVC | PASS_THROUGH_FW_CMD_ID;
+ smc_arg[1] = ((u64)(api_id & API_ID_MASK) << 32) |
+ FIELD_PREP(MODULE_ID_MASK, module_id) |
+ feature_check_api_id;
+
+ ret = do_fw_call(ret_payload, 2, smc_arg[0], smc_arg[1]);
if (ret)
return -EOPNOTSUPP;
@@ -440,11 +507,13 @@ int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id)
EXPORT_SYMBOL_GPL(zynqmp_pm_is_function_supported);
/**
- * zynqmp_pm_fw_call_extended() - Invoke the system-level platform management layer
+ * __zynqmp_pm_fw_call_extended() - Invoke the system-level platform management layer
* caller function depending on the configuration
* @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.
@@ -461,7 +530,8 @@ EXPORT_SYMBOL_GPL(zynqmp_pm_is_function_supported);
*
* Return: Returns status, either success or error+reason
*/
-int zynqmp_pm_fw_call_extended(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...)
+static int __zynqmp_pm_fw_call_extended(u32 pm_api_id, u32 *ret_payload,
+ u32 num_args, va_list *arg_list)
{
/*
* Added SIP service call Function Identifier
@@ -469,7 +539,6 @@ int zynqmp_pm_fw_call_extended(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_32] = {0};
u32 module_id;
@@ -485,12 +554,8 @@ int zynqmp_pm_fw_call_extended(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);
module_id = FIELD_GET(PLM_MODULE_ID_MASK, pm_api_id);
@@ -507,6 +572,33 @@ int zynqmp_pm_fw_call_extended(u32 pm_api_id, u32 *ret_payload, u32 num_args, ..
smc_arg[4], smc_arg[5], smc_arg[6], smc_arg[7]);
}
+/**
+ * zynqmp_pm_fw_call_extended - Invoke a PM function with variable arguments
+ * @pm_api_id: ID of the PM API to be called
+ * @ret_payload: Pointer to the buffer for storing the return payload
+ * @num_args: Number of arguments to pass to the PM API function
+ *
+ * This function serves as a wrapper around __zynqmp_pm_fw_call_extended(),
+ * facilitating the invocation of platform management (PM) functions that
+ * require an extended SMC (Secure Monitor Call) format with variable
+ * arguments. Specifically, the PM_QUERY_DATA API necessitates this extended
+ * payload format, making it essential to retain zynqmp_pm_fw_call_extended
+ * with variable arguments.
+ *
+ * Return: 0 on success; a negative error code on failure.
+ */
+int zynqmp_pm_fw_call_extended(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...)
+{
+ va_list arg_list;
+ int ret;
+
+ va_start(arg_list, num_args);
+ ret = __zynqmp_pm_fw_call_extended(pm_api_id, ret_payload,
+ num_args, &arg_list);
+ va_end(arg_list);
+ return ret;
+}
+
/**
* __zynqmp_pm_fw_call_basic() - Invoke the system-level platform management layer
* supporting basic SMC format.
@@ -2522,6 +2614,12 @@ static void zynqmp_firmware_sync_state(struct device *dev)
dev_warn(dev, "failed to release power management to firmware\n");
}
+static const struct platform_fw_data platform_fw_data_versal2 = {
+ .do_feature_check = do_feature_check_extended,
+ .zynqmp_pm_fw_call = __zynqmp_pm_fw_call_extended,
+ .family_code = PM_VERSAL2_FAMILY_CODE,
+};
+
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,
@@ -2544,6 +2642,7 @@ static const struct of_device_id zynqmp_firmware_of_match[] = {
{.compatible = "xlnx,zynqmp-firmware", .data = &platform_fw_data_zynqmp},
{.compatible = "xlnx,versal-firmware", .data = &platform_fw_data_versal},
{.compatible = "xlnx,versal-net-firmware", .data = &platform_fw_data_versal_net},
+ {.compatible = "xlnx,versal2-firmware", .data = &platform_fw_data_versal2},
{},
};
MODULE_DEVICE_TABLE(of, zynqmp_firmware_of_match);
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index 58f2e3fddfaf..effa1a2445b3 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -58,6 +58,7 @@
#define PM_ZYNQMP_FAMILY_CODE 0x1 /* ZynqMP family code */
#define PM_VERSAL_FAMILY_CODE 0x2 /* Versal family code */
#define PM_VERSAL_NET_FAMILY_CODE 0x3 /* Versal NET family code */
+#define PM_VERSAL2_FAMILY_CODE 0x4 /* Versal Gen 2 family code */
#define API_ID_MASK GENMASK(7, 0)
#define MODULE_ID_MASK GENMASK(11, 8)
--
2.34.1
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH 08/15] dt-bindings: clock: versal: add Versal Gen 2 compatible string
2026-11-18 23:31 [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Gregory Williams
` (6 preceding siblings ...)
2026-11-18 23:32 ` [PATCH 07/15] firmware: xilinx: Add support for Versal Gen 2 Gregory Williams
@ 2026-11-18 23:32 ` Gregory Williams
2026-11-18 23:32 ` [PATCH 09/15] clk: zynqmp: Add " Gregory Williams
` (7 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Gregory Williams @ 2026-11-18 23:32 UTC (permalink / raw)
To: Stephen Boyd, Brian Masney, Jerome Brunet, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Michal Simek
Cc: Naman Trivedi, Senthil Nathan Thangaraj, linux-clk, devicetree,
linux-kernel
From: Naman Trivedi <naman.trivedimanojbhai@amd.com>
Add compatible string for Versal Gen 2 clock driver and validate
clock-names for xlnx,versal2-clk compatible.
Signed-off-by: Naman Trivedi <naman.trivedimanojbhai@amd.com>
Signed-off-by: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
---
Documentation/devicetree/bindings/clock/xlnx,versal-clk.yaml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/clock/xlnx,versal-clk.yaml b/Documentation/devicetree/bindings/clock/xlnx,versal-clk.yaml
index 1f36ccc4cde1..e06f1ebc192a 100644
--- a/Documentation/devicetree/bindings/clock/xlnx,versal-clk.yaml
+++ b/Documentation/devicetree/bindings/clock/xlnx,versal-clk.yaml
@@ -17,10 +17,13 @@ description: |
properties:
compatible:
oneOf:
- - const: xlnx,versal-clk
+ - enum:
+ - xlnx,versal-clk
+ - xlnx,versal2-clk
- items:
- enum:
- xlnx,versal-net-clk
+ - xlnx,versal2-clk
- const: xlnx,versal-clk
"#clock-cells":
--
2.34.1
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH 09/15] clk: zynqmp: Add Versal Gen 2 compatible string
2026-11-18 23:31 [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Gregory Williams
` (7 preceding siblings ...)
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 ` Gregory Williams
2026-11-18 23:32 ` [PATCH 10/15] drivers: firmware: xilinx: Add IOCTL support for the AIE run time operations Gregory Williams
` (6 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Gregory Williams @ 2026-11-18 23:32 UTC (permalink / raw)
To: Stephen Boyd, Brian Masney, Jerome Brunet, Michal Simek
Cc: Senthil Nathan Thangaraj, linux-clk, linux-arm-kernel, linux-kernel
From: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
The Versal Gen 2 PLM exposes its clocks through the same EEMI clock
API that ZynqMP and Versal use, so the existing zynqmp clock driver
already implements everything needed once it accepts the platform's
device-tree node.
Add the "xlnx,versal2-clk" compatible to the zynqmp_clock_of_match
table so the driver binds against Versal Gen 2 device trees in
addition to ZynqMP and Versal. No code changes are required beyond
the match-table entry; clock enumeration, gating and rate control
all reuse the existing implementation.
Signed-off-by: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
---
drivers/clk/zynqmp/clkc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c
index d62f1901d0ab..ba8823e385e3 100644
--- a/drivers/clk/zynqmp/clkc.c
+++ b/drivers/clk/zynqmp/clkc.c
@@ -789,6 +789,7 @@ static int zynqmp_clock_probe(struct platform_device *pdev)
static const struct of_device_id zynqmp_clock_of_match[] = {
{.compatible = "xlnx,zynqmp-clk"},
{.compatible = "xlnx,versal-clk"},
+ {.compatible = "xlnx,versal2-clk"},
{},
};
MODULE_DEVICE_TABLE(of, zynqmp_clock_of_match);
--
2.34.1
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH 10/15] drivers: firmware: xilinx: Add IOCTL support for the AIE run time operations
2026-11-18 23:31 [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Gregory Williams
` (8 preceding siblings ...)
2026-11-18 23:32 ` [PATCH 09/15] clk: zynqmp: Add " Gregory Williams
@ 2026-11-18 23:32 ` Gregory Williams
2026-11-18 23:32 ` [PATCH 11/15] dt-bindings: soc: xilinx: Add Versal AI Engine DT binding Gregory Williams
` (5 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Gregory Williams @ 2026-11-18 23:32 UTC (permalink / raw)
To: Michal Simek
Cc: Abhyuday Godhasara, Naman Trivedi, Senthil Nathan Thangaraj,
linux-arm-kernel, linux-kernel
From: Abhyuday Godhasara <abhyuday.godhasara@xilinx.com>
Add IOCTL support for the Versal 2 AIE run time operations listed as below
- Column Reset
- Shim Reset
- Enabling of column clock buffer
- Zeroisation of Program and data memories
- Disabling of column clock buffer
- Enabling AXI-MM error event
- Set L2 controller NPI INTR
Signed-off-by: Abhyuday Godhasara <abhyuday.godhasara@xilinx.com>
Co-developed-by: Gregory Williams <gregory.williams@amd.com>
Signed-off-by: Gregory Williams <gregory.williams@amd.com>
Signed-off-by: Naman Trivedi <naman.trivedimanojbhai@amd.com>
Signed-off-by: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
---
drivers/firmware/xilinx/zynqmp.c | 16 +++++++++
include/linux/firmware/xlnx-zynqmp.h | 52 ++++++++++++++++++++++++++++
2 files changed, 68 insertions(+)
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index a8c70e775ae3..995db401519c 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -1268,6 +1268,22 @@ int zynqmp_pm_set_boot_health_status(u32 value)
return zynqmp_pm_invoke_fn(PM_IOCTL, NULL, 3, 0, IOCTL_SET_BOOT_HEALTH_STATUS, value);
}
+/**
+ * versal2_pm_aie2ps_operation - AIE2PS run time operations
+ * @node: AI engine node id
+ * @size: Size of the DMA addr
+ * @addr_high: higher 32 bits of DMA addr
+ * @addr_low: lower 32 bits of DMA addr
+ *
+ * Return: Returns status, either success or error+reason
+ */
+int versal2_pm_aie2ps_operation(u32 node, u32 size, u32 addr_high, u32 addr_low)
+{
+ return zynqmp_pm_invoke_fn(PM_IOCTL, NULL, 5, node, IOCTL_AIE2PS_OPS,
+ size, addr_high, addr_low);
+}
+EXPORT_SYMBOL_GPL(versal2_pm_aie2ps_operation);
+
/**
* zynqmp_pm_reset_assert - Request setting of reset (1 - assert, 0 - release)
* @reset: Reset to be configured
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index effa1a2445b3..042dcb164fc3 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -141,6 +141,16 @@
#define SD_ITAPDLY 0xFF180314
#define SD_OTAPDLYSEL 0xFF180318
+/**
+ * XPM_VERSAL_EVENT_ERROR_MASK_AIE_CR: Error event mask for ME Correctable Error.
+ */
+#define XPM_VERSAL_EVENT_ERROR_MASK_AIE_CR BIT(16)
+
+/**
+ * XPM_VERSAL_EVENT_ERROR_MASK_AIE_NCR: Error event mask for ME Non-Correctable Error.
+ */
+#define XPM_VERSAL_EVENT_ERROR_MASK_AIE_NCR BIT(17)
+
/**
* XPM_EVENT_ERROR_MASK_DDRMC_CR: Error event mask for DDRMC MC Correctable ECC Error.
*/
@@ -166,6 +176,37 @@ enum pm_module_id {
TF_A_MODULE_ID = 0xa,
};
+/* AIE Operation */
+enum pm_aie_operations {
+ XILINX_AIE_OPS_MIN = 0U,
+ XILINX_AIE_OPS_COL_RST = 1U,
+ XILINX_AIE_OPS_SHIM_RST = 2U,
+ XILINX_AIE_OPS_UC_ZEROIZATION = 3U,
+ XILINX_AIE_OPS_ENB_COL_CLK_BUFF = 4U,
+ XILINX_AIE_OPS_HANDSHAKE = 5U,
+ XILINX_AIE_OPS_CLR_HW_ERR_STS = 6U,
+ XILINX_AIE_OPS_START_NUM_COL = 7U,
+ XILINX_AIE_OPS_ZEROISATION = 8U,
+ XILINX_AIE_OPS_AXIMM_ISOLATION = 9U,
+ XILINX_AIE_OPS_NMU_CONFIG = 10U,
+ XILINX_AIE_OPS_DIS_MEM_PRIV = 11U,
+ XILINX_AIE_OPS_DIS_MEM_INTERLEAVE = 12U,
+ XILINX_AIE_OPS_ENB_UC_DMA_PAUSE = 13U,
+ XILINX_AIE_OPS_ENB_NOC_DMA_PAUSE = 14U,
+ XILINX_AIE_OPS_SET_ECC_SCRUB_PERIOD = 15U,
+ XILINX_AIE_OPS_DIS_COL_CLK_BUFF = 16U,
+ XILINX_AIE_OPS_HW_ERR_INT = 17U,
+ XILINX_AIE_OPS_HW_ERR_MASK = 18U,
+ XILINX_AIE_OPS_ENB_MEM_PRIV = 19U,
+ XILINX_AIE_OPS_CTRL_PKT_TLAST_ERR = 20U,
+ XILINX_AIE_OPS_ENB_AXI_MM_ERR_EVENT = 32U, /* Backward compatibility for AIE1/AIE2 */
+ XILINX_AIE_OPS_SET_L2_CTRL_NPI_INTR = 64U, /* Backward compatibility for AIE1/AIE2 */
+ XILINX_AIE_OPS_PROG_MEM_ZEROIZATION = 128U, /* Backward compatibility for AIE1/AIE2 */
+ XILINX_AIE_OPS_DATA_MEM_ZEROIZATION = 256U, /* Backward compatibility for AIE1/AIE2 */
+ XILINX_AIE_OPS_MEM_TILE_ZEROIZATION = 512U, /* Backward compatibility for AIE1/AIE2 */
+ XILINX_AIE_OPS_MAX = 1023U, /* Backward compatibility for AIE1/AIE2 */
+};
+
enum pm_api_cb_id {
PM_INIT_SUSPEND_CB = 30,
PM_ACKNOWLEDGE_CB = 31,
@@ -257,8 +298,12 @@ enum pm_ioctl_id {
/* Dynamic SD/GEM configuration */
IOCTL_SET_SD_CONFIG = 30,
IOCTL_SET_GEM_CONFIG = 31,
+ /* AIE/AIEML Operations */
+ IOCTL_AIE_OPS = 33,
/* IOCTL to get default/current QoS */
IOCTL_GET_QOS = 34,
+ /* AIE2PS Operations */
+ IOCTL_AIE2PS_OPS = 39,
};
enum pm_query_id {
@@ -659,6 +704,7 @@ int zynqmp_pm_stop_rpu(const u32 node);
int zynqmp_pm_set_sd_config(u32 node, enum pm_sd_config_type config, u32 value);
int zynqmp_pm_set_gem_config(u32 node, enum pm_gem_config_type config,
u32 value);
+int versal2_pm_aie2ps_operation(u32 node, u32 size, u32 addr_high, u32 addr_low);
#else
static inline int zynqmp_pm_get_api_version(u32 *version)
{
@@ -996,6 +1042,12 @@ static inline int zynqmp_pm_set_gem_config(u32 node,
return -ENODEV;
}
+static inline int versal2_pm_aie2ps_operation(u32 node, u32 size, u32 addr_high,
+ u32 addr_low)
+{
+ return -ENODEV;
+}
+
#endif
#endif /* __FIRMWARE_ZYNQMP_H__ */
--
2.34.1
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH 11/15] dt-bindings: soc: xilinx: Add Versal AI Engine DT binding
2026-11-18 23:31 [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Gregory Williams
` (9 preceding siblings ...)
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 ` Gregory Williams
2026-11-18 23:32 ` [PATCH 12/15] accel/amd-ai-engine: Add AMD AI Engine device driver Gregory Williams
` (4 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Gregory Williams @ 2026-11-18 23:32 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Michal Simek
Cc: dri-devel, devicetree, linux-arm-kernel, linux-kernel
Add documentation to describe Versal AI Engine device tree bindings. AI
Engine is a tile array based processor with many cores and local memory
cache. Data routing between the cores is done through internal switches,
interface tiles are used to connect to external sources such as memory
or PL. Configuration registers of the device are accessed through a
memory mapped AXI address space.
Signed-off-by: Gregory Williams <gregory.williams@amd.com>
---
.../bindings/soc/xilinx/xlnx,ai-engine.yaml | 61 +++++++++++++++++++
1 file changed, 61 insertions(+)
create mode 100644 Documentation/devicetree/bindings/soc/xilinx/xlnx,ai-engine.yaml
diff --git a/Documentation/devicetree/bindings/soc/xilinx/xlnx,ai-engine.yaml b/Documentation/devicetree/bindings/soc/xilinx/xlnx,ai-engine.yaml
new file mode 100644
index 000000000000..6c97b5f0fb03
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/xilinx/xlnx,ai-engine.yaml
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright(C) 2026 Advanced Micro Devices, Inc. All rights reserved.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/xilinx/xlnx,ai-engine.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: AMD AI Engine for Versal SoCs
+
+maintainers:
+ - Gregory Williams <gregory.williams@amd.com>
+
+description:
+ The AMD AI Engine is a tile processor with many cores (up to 400) that
+ can run in parallel with some devices containing local cache (memory tiles).
+ The data routing between cores is configured through internal switches, and
+ shim tiles interface with external interconnect, such as memory or PL.
+
+properties:
+ compatible:
+ enum:
+ - xlnx,versal2-aieml
+
+ reg:
+ maxItems: 1
+
+ clocks:
+ maxItems: 1
+
+ clock-names:
+ const: aclk0
+
+ xlnx,firmware-device-id:
+ description:
+ Device identifier as defined by Versal firmware interface. This value is
+ passed unchanged to firmware calls.
+ $ref: /schemas/types.yaml#/definitions/uint32
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+ - xlnx,firmware-device-id
+
+additionalProperties: false
+
+examples:
+ - |
+ soc {
+ #address-cells = <2>;
+ #size-cells = <2>;
+
+ ai_engine: ai-engine@20000000000 {
+ compatible = "xlnx,versal2-aieml";
+ reg = <0x200 0x00 0x01 0x00>;
+ clocks = <&aclk0>;
+ clock-names = "aclk0";
+ xlnx,firmware-device-id = <0x18224072>;
+ };
+ };
--
2.34.1
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH 12/15] accel/amd-ai-engine: Add AMD AI Engine device driver
2026-11-18 23:31 [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Gregory Williams
` (10 preceding siblings ...)
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 ` Gregory Williams
2026-11-18 23:32 ` [PATCH 13/15] accel/amd-ai-engine: Add pm ops for firmware calls Gregory Williams
` (3 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Gregory Williams @ 2026-11-18 23:32 UTC (permalink / raw)
To: Oded Gabbay; +Cc: linux-kernel, dri-devel
Add support for AMD AI Engine on AMD Versal devices. AMD AI Engine is a
tile array based accelerator for applications like beamforming and machine
learning inference [1].
AI Engine device driver is responsible for the management of AI engine
partitions (groups of AI engine columns). At runtime applications request
a partition from the AI engine device. Applications use the partition
handle for application setup and control.
The driver architecture:
+-------------------------------------------+
| AIE Device |
| +----------------+ +----------------+ |
| | partition_0 | ... | partition_X | |
| +----------------+ +----------------+ |
+-------------------------------------------+
The driver provides the following functionality:
- AI Engine device probe
- Partition request and release
[1] https://www.amd.com/en/products/adaptive-socs-and-fpgas/technologies/ai-engine.html
Signed-off-by: Gregory Williams <gregory.williams@amd.com>
---
MAINTAINERS | 9 +
drivers/accel/Kconfig | 1 +
drivers/accel/Makefile | 3 +-
drivers/accel/amd-ai-engine/Kconfig | 15 ++
drivers/accel/amd-ai-engine/Makefile | 11 +
.../accel/amd-ai-engine/ai-engine-aiemlv2.c | 47 ++++
drivers/accel/amd-ai-engine/ai-engine-dev.c | 244 ++++++++++++++++++
.../accel/amd-ai-engine/ai-engine-internal.h | 160 ++++++++++++
drivers/accel/amd-ai-engine/ai-engine-part.c | 77 ++++++
drivers/accel/amd-ai-engine/ai-engine-res.c | 112 ++++++++
include/linux/amd-ai-engine.h | 59 +++++
11 files changed, 737 insertions(+), 1 deletion(-)
create mode 100644 drivers/accel/amd-ai-engine/Kconfig
create mode 100644 drivers/accel/amd-ai-engine/Makefile
create mode 100644 drivers/accel/amd-ai-engine/ai-engine-aiemlv2.c
create mode 100644 drivers/accel/amd-ai-engine/ai-engine-dev.c
create mode 100644 drivers/accel/amd-ai-engine/ai-engine-internal.h
create mode 100644 drivers/accel/amd-ai-engine/ai-engine-part.c
create mode 100644 drivers/accel/amd-ai-engine/ai-engine-res.c
create mode 100644 include/linux/amd-ai-engine.h
diff --git a/MAINTAINERS b/MAINTAINERS
index bcade5bfbafe..d8bfa7cbf8f6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1080,6 +1080,15 @@ L: linux-sound@vger.kernel.org
S: Supported
F: sound/soc/amd/
+AMD AI ENGINE DRIVER
+M: Gregory Williams <gregory.williams@amd.com>
+L: dri-devel@lists.freedesktop.org
+S: Maintained
+T: git https://gitlab.freedesktop.org/drm/misc/kernel.git
+F: Documentation/devicetree/bindings/soc/xilinx/xlnx,ai-engine.yaml
+F: drivers/accel/amd-ai-engine/
+F: include/linux/amd-ai-engine.h
+
AMD AXI I3C MASTER DRIVER
M: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
M: Shubham Patil <shubhamsanjay.patil@amd.com>
diff --git a/drivers/accel/Kconfig b/drivers/accel/Kconfig
index bdf48ccafcf2..b20a1445629d 100644
--- a/drivers/accel/Kconfig
+++ b/drivers/accel/Kconfig
@@ -24,6 +24,7 @@ menuconfig DRM_ACCEL
different device files, called accel/accel* (in /dev, sysfs
and debugfs).
+source "drivers/accel/amd-ai-engine/Kconfig"
source "drivers/accel/amdxdna/Kconfig"
source "drivers/accel/ethosu/Kconfig"
source "drivers/accel/habanalabs/Kconfig"
diff --git a/drivers/accel/Makefile b/drivers/accel/Makefile
index 1d3a7251b950..f0f09f3b6a56 100644
--- a/drivers/accel/Makefile
+++ b/drivers/accel/Makefile
@@ -1,8 +1,9 @@
# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_DRM_ACCEL_AMDAIE) += amd-ai-engine/
obj-$(CONFIG_DRM_ACCEL_AMDXDNA) += amdxdna/
obj-$(CONFIG_DRM_ACCEL_ARM_ETHOSU) += ethosu/
obj-$(CONFIG_DRM_ACCEL_HABANALABS) += habanalabs/
obj-$(CONFIG_DRM_ACCEL_IVPU) += ivpu/
obj-$(CONFIG_DRM_ACCEL_QAIC) += qaic/
-obj-$(CONFIG_DRM_ACCEL_ROCKET) += rocket/
\ No newline at end of file
+obj-$(CONFIG_DRM_ACCEL_ROCKET) += rocket/
diff --git a/drivers/accel/amd-ai-engine/Kconfig b/drivers/accel/amd-ai-engine/Kconfig
new file mode 100644
index 000000000000..7f32928cb20f
--- /dev/null
+++ b/drivers/accel/amd-ai-engine/Kconfig
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config DRM_ACCEL_AMDAIE
+ tristate "AMD Versal AI Engine"
+ depends on ARM64 || COMPILE_TEST
+ depends on ZYNQMP_FIRMWARE
+ depends on DRM_ACCEL
+ help
+ This option enables support for the AMD AI engine driver.
+ One AMD AI engine device can have multiple partitions (groups of
+ AI engine tiles). AMD AI engine device driver instance manages
+ AI engine partitions. Applications access its partitions through
+ AI engine partition device instance.
+
+ If unsure, say N.
diff --git a/drivers/accel/amd-ai-engine/Makefile b/drivers/accel/amd-ai-engine/Makefile
new file mode 100644
index 000000000000..cb456ee7ec37
--- /dev/null
+++ b/drivers/accel/amd-ai-engine/Makefile
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Makefile for AMD AI engine device driver
+
+obj-$(CONFIG_DRM_ACCEL_AMDAIE) += amd-aie.o
+
+amd-aie-$(CONFIG_DRM_ACCEL_AMDAIE) := \
+ ai-engine-aiemlv2.o \
+ ai-engine-dev.o \
+ ai-engine-part.o \
+ ai-engine-res.o
diff --git a/drivers/accel/amd-ai-engine/ai-engine-aiemlv2.c b/drivers/accel/amd-ai-engine/ai-engine-aiemlv2.c
new file mode 100644
index 000000000000..0c9c7ccdd54e
--- /dev/null
+++ b/drivers/accel/amd-ai-engine/ai-engine-aiemlv2.c
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * AMD AI Engine driver AIEMLv2 device specific implementation
+ *
+ * Copyright(C) 2026 Advanced Micro Devices, Inc. All rights reserved.
+ */
+
+#include <linux/amd-ai-engine.h>
+
+#include "ai-engine-internal.h"
+
+#define AIEMLV2_ARRAY_SHIFT 32U
+#define AIEMLV2_COL_SHIFT 25U
+#define AIEMLV2_ROW_SHIFT 20U
+
+static u32 aiemlv2_get_tile_type(struct aie_device *adev, struct aie_location *loc)
+{
+ u8 num_mem_rows = adev->ttype_attr[AIE_TILE_TYPE_MEMORY].num_rows;
+
+ if (loc->row > num_mem_rows)
+ return AIE_TILE_TYPE_TILE;
+ if (loc->row)
+ return AIE_TILE_TYPE_MEMORY;
+
+ return AIE_TILE_TYPE_SHIMNOC;
+}
+
+static const struct aie_tile_operations aiemlv2_ops = {
+ .get_tile_type = aiemlv2_get_tile_type,
+};
+
+/**
+ * aiemlv2_device_init() - Initialize AI engine device struct AIEMLV2 specific
+ * @adev: AI engine device
+ *
+ * This function initialize the AI engine device structure device version
+ * specific elements such as register addressing related array shift,
+ * column shift, and row shift; AIEMLV2 device specific device operations, device
+ * columns resource.
+ */
+void aiemlv2_device_init(struct aie_device *adev)
+{
+ adev->array_shift = AIEMLV2_ARRAY_SHIFT;
+ adev->col_shift = AIEMLV2_COL_SHIFT;
+ adev->row_shift = AIEMLV2_ROW_SHIFT;
+ adev->ops = &aiemlv2_ops;
+}
diff --git a/drivers/accel/amd-ai-engine/ai-engine-dev.c b/drivers/accel/amd-ai-engine/ai-engine-dev.c
new file mode 100644
index 000000000000..7dad3004e30a
--- /dev/null
+++ b/drivers/accel/amd-ai-engine/ai-engine-dev.c
@@ -0,0 +1,244 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * AMD AI Engine device driver
+ *
+ * Copyright(C) 2026 Advanced Micro Devices, Inc. All rights reserved.
+ */
+
+#include <linux/amd-ai-engine.h>
+#include <linux/clk.h>
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/list.h>
+#include <linux/mutex.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+
+#include "ai-engine-internal.h"
+
+/**
+ * aie_partition_request() - Request an AI engine partition
+ * @dev: AI engine device pointer
+ * @req: AI engine partition request arguments
+ *
+ * Return: pointer to the AI engine partition device, error pointer value for
+ * failure.
+ */
+struct device *aie_partition_request(struct device *dev, struct aie_partition_req *req)
+{
+ struct aie_device *adev = dev_get_drvdata(dev);
+ struct aie_partition *apart = NULL;
+ u8 start_col, num_col, end_col;
+ int ret;
+
+ if (!req)
+ return ERR_PTR(-EINVAL);
+
+ start_col = aie_part_id_get_start_col(req->partition_id);
+ num_col = aie_part_id_get_num_cols(req->partition_id);
+ if (num_col == 0) {
+ start_col = adev->range.start.col;
+ num_col = adev->range.size.col;
+ }
+
+ end_col = start_col + num_col - 1;
+ if (start_col < adev->range.start.col ||
+ end_col >= (adev->range.start.col + adev->range.size.col)) {
+ dev_err(adev->dev, "partition is outside of device range\n");
+ return ERR_PTR(-ERANGE);
+ }
+
+ mutex_lock(&adev->mlock);
+ ret = aie_resource_get_region(&adev->cols_res,
+ start_col - adev->range.start.col,
+ num_col);
+ if (ret != (u32)start_col - adev->range.start.col) {
+ /* column range returned is not what user requested */
+ if (ret > 0)
+ aie_resource_put_region(&adev->cols_res, ret, num_col);
+ mutex_unlock(&adev->mlock);
+ dev_err(adev->dev, "partition requested is busy\n");
+ return ERR_PTR(-EBUSY);
+ }
+
+ apart = aie_part_create(adev, start_col, num_col);
+ if (IS_ERR(apart)) {
+ aie_resource_put_region(&adev->cols_res, ret, num_col);
+ ret = PTR_ERR(apart);
+ mutex_unlock(&adev->mlock);
+ dev_err(adev->dev, "failed to create partition\n");
+ return ERR_PTR(ret);
+ }
+
+ list_add_tail(&apart->node, &adev->partitions);
+ mutex_unlock(&adev->mlock);
+ dev_dbg(adev->dev, "Partition (%u, %u) created successfully.\n",
+ apart->range.start.col, apart->range.size.col);
+
+ return &apart->dev;
+}
+EXPORT_SYMBOL_GPL(aie_partition_request);
+
+/**
+ * aie_partition_release() - Release the AI engine partition
+ * @dev: AI engine partition device pointer
+ */
+void aie_partition_release(struct device *dev)
+{
+ struct aie_partition *apart = dev_to_aiepart(dev);
+
+ mutex_lock(&apart->adev->mlock);
+ aie_part_release(apart);
+ mutex_unlock(&apart->adev->mlock);
+}
+EXPORT_SYMBOL_GPL(aie_partition_release);
+
+static int amd_ai_engine_probe(struct platform_device *pdev)
+{
+ const struct aie_device_cfg *match;
+ struct aie_device *adev;
+ u32 pm_reg;
+ int ret;
+
+ adev = devm_kzalloc(&pdev->dev, sizeof(*adev), GFP_KERNEL);
+ if (!adev)
+ return -ENOMEM;
+
+ platform_set_drvdata(pdev, adev);
+ INIT_LIST_HEAD(&adev->partitions);
+ mutex_init(&adev->mlock);
+
+ match = of_device_get_match_data(&pdev->dev);
+ if (!match) {
+ dev_err(&pdev->dev, "Failed to find aie device configuration\n");
+ return -ENODEV;
+ }
+
+ /* setup device layout configuration */
+ adev->dev = &pdev->dev;
+ adev->range.start.col = 0;
+ adev->range.size.col = match->num_columns;
+ adev->range.start.row = 0;
+ adev->range.size.row = match->mem_num_row + match->core_num_row + 1;
+ adev->ttype_attr[AIE_TILE_TYPE_SHIMPL].start_row = 0;
+ adev->ttype_attr[AIE_TILE_TYPE_SHIMPL].num_rows = 1;
+ adev->ttype_attr[AIE_TILE_TYPE_SHIMNOC].start_row = 0;
+ adev->ttype_attr[AIE_TILE_TYPE_SHIMNOC].num_rows = 0;
+ adev->ttype_attr[AIE_TILE_TYPE_TILE].start_row = match->core_start_row;
+ adev->ttype_attr[AIE_TILE_TYPE_TILE].num_rows = match->core_num_row;
+ adev->ttype_attr[AIE_TILE_TYPE_MEMORY].start_row = match->mem_start_row;
+ adev->ttype_attr[AIE_TILE_TYPE_MEMORY].num_rows = match->mem_num_row;
+
+ adev->dev_gen = match->aie_gen;
+ if (adev->dev_gen == AIE_DEVICE_GEN_AIEMLV2) {
+ aiemlv2_device_init(adev);
+ } else {
+ dev_err(&pdev->dev, "Device generation not supported\n");
+ return -EINVAL;
+ }
+
+ /*
+ * AI Engine platform management node ID is required for requesting
+ * services from firmware driver.
+ */
+ ret = of_property_read_u32(pdev->dev.of_node, "xlnx,firmware-device-id",
+ &pm_reg);
+ if (ret < 0) {
+ dev_err(&pdev->dev,
+ "Failed to read power management information\n");
+ return ret;
+ }
+ adev->fw_dev_id = pm_reg;
+
+ adev->clk = devm_clk_get(&pdev->dev, "aclk0");
+ if (IS_ERR(adev->clk)) {
+ dev_err(&pdev->dev, "Failed to get device clock.\n");
+ return PTR_ERR(adev->clk);
+ }
+
+ adev->base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(adev->base)) {
+ dev_err(&pdev->dev, "Failed to map IO resources\n");
+ return PTR_ERR(adev->base);
+ }
+
+ /*
+ * Initialize columns resource map to remember which columns have been
+ * assigned. Used for partition management.
+ */
+ ret = aie_resource_initialize(&adev->cols_res,
+ adev->range.size.col);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to initialize columns resource.\n");
+ return ret;
+ }
+
+ dev_dbg(&pdev->dev,
+ "AMD AI Engine device probed. Device generation: %u. Clock frequency: %luHz.\n",
+ adev->dev_gen, clk_get_rate(adev->clk));
+ dev_dbg(&pdev->dev,
+ "AI engine cols(%u, %u) aie_tile_rows(%u, %u) memory_tile_rows(%u, %u)\n",
+ adev->range.start.col, adev->range.size.col,
+ adev->ttype_attr[AIE_TILE_TYPE_TILE].start_row,
+ adev->ttype_attr[AIE_TILE_TYPE_TILE].num_rows,
+ adev->ttype_attr[AIE_TILE_TYPE_MEMORY].start_row,
+ adev->ttype_attr[AIE_TILE_TYPE_MEMORY].num_rows);
+ return 0;
+}
+
+static void amd_ai_engine_remove(struct platform_device *pdev)
+{
+ struct aie_device *adev = platform_get_drvdata(pdev);
+ struct aie_partition *apart, *lapart;
+
+ mutex_lock(&adev->mlock);
+ list_for_each_entry_safe(apart, lapart, &adev->partitions, node)
+ aie_part_release(apart);
+ mutex_unlock(&adev->mlock);
+
+ aie_resource_uninitialize(&adev->cols_res);
+}
+
+static const struct aie_device_cfg versal2_aieml = {
+ .num_columns = 32,
+ .mem_start_row = 1,
+ .mem_num_row = 2,
+ .core_start_row = 3,
+ .core_num_row = 4,
+ .aie_gen = AIE_DEVICE_GEN_AIEMLV2,
+};
+
+static const struct of_device_id amd_ai_engine_of_match[] = {
+ {
+ .compatible = "xlnx,versal2-aieml",
+ .data = &versal2_aieml,
+ },
+ { /* end of table */ },
+};
+MODULE_DEVICE_TABLE(of, amd_ai_engine_of_match);
+
+static struct platform_driver amd_ai_engine_driver = {
+ .probe = amd_ai_engine_probe,
+ .remove = amd_ai_engine_remove,
+ .driver = {
+ .name = "amd-ai-engine",
+ .of_match_table = amd_ai_engine_of_match,
+ },
+};
+
+static int __init amd_ai_engine_init(void)
+{
+ return platform_driver_register(&amd_ai_engine_driver);
+}
+module_init(amd_ai_engine_init);
+
+static void __exit amd_ai_engine_exit(void)
+{
+ platform_driver_unregister(&amd_ai_engine_driver);
+}
+module_exit(amd_ai_engine_exit);
+
+MODULE_AUTHOR("Advanced Micro Devices, Inc.");
+MODULE_DESCRIPTION("AMD Versal AI Engine driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/accel/amd-ai-engine/ai-engine-internal.h b/drivers/accel/amd-ai-engine/ai-engine-internal.h
new file mode 100644
index 000000000000..61ebd7f4b3d1
--- /dev/null
+++ b/drivers/accel/amd-ai-engine/ai-engine-internal.h
@@ -0,0 +1,160 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * AMD AI Engine driver internal header
+ *
+ * Copyright(C) 2026 Advanced Micro Devices, Inc. All rights reserved.
+ */
+
+#ifndef AIE_INTERNAL_H
+#define AIE_INTERNAL_H
+
+#include <linux/amd-ai-engine.h>
+#include <linux/clk.h>
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/list.h>
+#include <linux/mutex.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+
+#define AIE_DEVICE_GEN_AIEMLV2 3U
+
+/*
+ * Macros for AI engine tile type
+ */
+enum aie_tile_type {
+ AIE_TILE_TYPE_TILE,
+ AIE_TILE_TYPE_SHIMPL,
+ AIE_TILE_TYPE_SHIMNOC,
+ AIE_TILE_TYPE_MEMORY,
+ AIE_TILE_TYPE_MAX
+};
+
+struct aie_device;
+struct aie_partition;
+
+/**
+ * struct aie_tile_operations - AI engine device operations
+ * @get_tile_type: get type of tile based on tile operation
+ * Different AI engine device version has its own device
+ * operation.
+ */
+struct aie_tile_operations {
+ u32 (*get_tile_type)(struct aie_device *adev, struct aie_location *loc);
+};
+
+/**
+ * struct aie_resource - AI engine resource structure
+ * @bitmap: resource bitmap
+ * @total: total number of resource
+ */
+struct aie_resource {
+ unsigned long *bitmap;
+ u32 total;
+};
+
+/**
+ * struct aie_range - AIE range information
+ * @start: start tile location
+ * @size: size of the range, number of columns and rows
+ */
+struct aie_range {
+ struct aie_location start;
+ struct aie_location size;
+};
+
+/**
+ * struct aie_tile_attr - AI engine device tile type attributes
+ * @start_row: start row
+ * @num_rows: number of rows
+ */
+struct aie_tile_attr {
+ u8 start_row;
+ u8 num_rows;
+};
+
+/**
+ * struct aie_device - AI engine device structure
+ * @partitions: list of partitions
+ * @dev: device pointer for the AI engine device
+ * @mlock: protection for AI engine device operations
+ * @clk: AI engine device clock
+ * @base: AI engine base virtual address
+ * @ops: tile operations
+ * @cols_res: AI engine columns resources to indicate
+ * while columns are occupied by partitions.
+ * @ttype_attr: tile type attributes
+ * @range: range of whole AI engine
+ * @array_shift: array address shift
+ * @col_shift: column address shift
+ * @row_shift: row address shift
+ * @dev_gen: aie hardware device generation
+ * @fw_dev_id: AI Engine firmware device ID
+ */
+struct aie_device {
+ struct list_head partitions;
+ struct device *dev;
+ struct mutex mlock;
+ struct clk *clk;
+ void __iomem *base;
+ const struct aie_tile_operations *ops;
+ struct aie_resource cols_res;
+ struct aie_tile_attr ttype_attr[AIE_TILE_TYPE_MAX];
+ struct aie_range range;
+ u32 array_shift;
+ u32 col_shift;
+ u32 row_shift;
+ u32 dev_gen;
+ u32 fw_dev_id;
+};
+
+/**
+ * struct aie_partition - AI engine partition structure
+ * @node: list node
+ * @dev: AI Engine partition device
+ * @adev: pointer to AI device instance
+ * @range: range of partition
+ * @mlock: protection for AI engine partition operations
+ */
+struct aie_partition {
+ struct list_head node;
+ struct device dev;
+ struct aie_device *adev;
+ struct aie_range range;
+ struct mutex mlock;
+};
+
+/**
+ * struct aie_device_cfg - AI engine device configuration and layout
+ * @num_columns: number of columns in the device
+ * @mem_start_row: start row index for memory tiles
+ * @mem_num_row: number of memory tile rows
+ * @core_start_row: start row index for core tiles
+ * @core_num_row: number of core tile rows
+ * @aie_gen: AI Engine generation
+ */
+struct aie_device_cfg {
+ u8 num_columns;
+ u8 mem_start_row;
+ u8 mem_num_row;
+ u8 core_start_row;
+ u8 core_num_row;
+ u8 aie_gen;
+};
+
+#define dev_to_aiepart(_dev) container_of((_dev), struct aie_partition, dev)
+
+void aiemlv2_device_init(struct aie_device *adev);
+struct aie_partition *aie_part_create(struct aie_device *adev,
+ u8 start_col, u8 num_col);
+void aie_part_release(struct aie_partition *apart);
+int aie_resource_initialize(struct aie_resource *res, int count);
+void aie_resource_uninitialize(struct aie_resource *res);
+int aie_resource_check_region(struct aie_resource *res, u32 start,
+ u32 count);
+int aie_resource_get_region(struct aie_resource *res, u32 start,
+ u32 count);
+void aie_resource_put_region(struct aie_resource *res, int start, u32 count);
+
+#endif /* AIE_INTERNAL_H */
diff --git a/drivers/accel/amd-ai-engine/ai-engine-part.c b/drivers/accel/amd-ai-engine/ai-engine-part.c
new file mode 100644
index 000000000000..f80a6fa433aa
--- /dev/null
+++ b/drivers/accel/amd-ai-engine/ai-engine-part.c
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * AMD AI Engine partition implementation
+ *
+ * Copyright(C) 2026 Advanced Micro Devices, Inc. All rights reserved.
+ */
+
+#include <linux/amd-ai-engine.h>
+#include <linux/device.h>
+#include <linux/list.h>
+#include <linux/mutex.h>
+
+#include "ai-engine-internal.h"
+
+/**
+ * aie_part_release() - release an AI engine partition instance
+ * @apart: AI engine partition device
+ */
+void aie_part_release(struct aie_partition *apart)
+{
+ struct aie_device *adev = apart->adev;
+
+ list_del(&apart->node);
+ aie_resource_put_region(&adev->cols_res,
+ apart->range.start.col -
+ adev->range.start.col,
+ apart->range.size.col);
+ device_unregister(&apart->dev);
+}
+
+static void aie_part_release_device(struct device *dev)
+{
+ (void)dev;
+}
+
+/**
+ * aie_part_create() - create AI engine partition instance
+ * @adev: AI engine device
+ * @start_col: start column of AI engine partition
+ * @num_col: number of columns of AI engine partition
+ *
+ * Return: created AI engine partition pointer for success, and PTR_ERR
+ * for failure.
+ */
+struct aie_partition *aie_part_create(struct aie_device *adev,
+ u8 start_col, u8 num_col)
+{
+ struct aie_partition *apart;
+ struct device *dev;
+
+ apart = devm_kzalloc(adev->dev, sizeof(*apart), GFP_KERNEL);
+ if (!apart)
+ return ERR_PTR(-ENOMEM);
+
+ apart->adev = adev;
+ mutex_init(&apart->mlock);
+ apart->range.start.col = start_col;
+ apart->range.size.col = num_col;
+ apart->range.start.row = adev->range.start.row;
+ apart->range.size.row = adev->range.size.row;
+
+ /* create partition device */
+ dev = &apart->dev;
+ dev->parent = apart->adev->dev;
+ dev_set_name(dev, "aiepart_%u_%u", apart->range.start.col,
+ apart->range.size.col);
+ dev_set_drvdata(dev, apart);
+ dev->release = aie_part_release_device;
+
+ if (device_register(&apart->dev)) {
+ dev_err(adev->dev, "failed to register partition device\n");
+ put_device(dev);
+ return ERR_PTR(-ENODEV);
+ }
+
+ return apart;
+}
diff --git a/drivers/accel/amd-ai-engine/ai-engine-res.c b/drivers/accel/amd-ai-engine/ai-engine-res.c
new file mode 100644
index 000000000000..62df26edf87d
--- /dev/null
+++ b/drivers/accel/amd-ai-engine/ai-engine-res.c
@@ -0,0 +1,112 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * AMD AI Engine resource implementation
+ *
+ * Copyright(C) 2026 Advanced Micro Devices, Inc. All rights reserved.
+ */
+
+#include <linux/bitmap.h>
+
+#include "ai-engine-internal.h"
+
+/**
+ * aie_resource_initialize() - initialize AI engine resource
+ * @res: pointer to AI engine resource
+ * @count: total number of element of this resource
+ *
+ * Return: 0 for success, negative value for failure.
+ *
+ * This function will initialize the data structure for the
+ * resource.
+ */
+int aie_resource_initialize(struct aie_resource *res, int count)
+{
+ res->bitmap = bitmap_zalloc(count, GFP_KERNEL);
+ if (!res->bitmap)
+ return -ENOMEM;
+ res->total = count;
+
+ return 0;
+}
+
+/**
+ * aie_resource_uninitialize() - uninitialize AI engine resource
+ * @res: pointer to AI engine resource
+ *
+ * This function will release the AI engine resource data members.
+ */
+void aie_resource_uninitialize(struct aie_resource *res)
+{
+ res->total = 0;
+ if (res->bitmap)
+ bitmap_free(res->bitmap);
+}
+
+/**
+ * aie_resource_check_region() - check availability of requested resource
+ * @res: pointer to AI engine resource to check
+ * @start: start index of the required resource
+ * @count: number of requested element
+ *
+ * Return: start resource id if the requested number of resources are available
+ * It will return negative value of errors.
+ *
+ * This function will check the availability. It will return start resource id
+ * if the requested number of resources are available.
+ */
+int aie_resource_check_region(struct aie_resource *res,
+ u32 start, u32 count)
+{
+ unsigned long id;
+
+ if (!res || !res->bitmap || !count)
+ return -EINVAL;
+ id = bitmap_find_next_zero_area(res->bitmap, res->total, start,
+ count, 0);
+ if (id >= res->total)
+ return -ERANGE;
+
+ return (int)id;
+}
+
+/**
+ * aie_resource_get_region() - get requested AI engine resource
+ * @res: pointer to AI engine resource to check
+ * @start: start index of the required resource
+ * @count: number of requested element
+ *
+ * Return: start resource id for success, and negative value for failure.
+ *
+ * This function check if the requested AI engine resource is available.
+ * If it is available, mark it used and return the start resource id.
+ */
+int aie_resource_get_region(struct aie_resource *res, u32 start, u32 count)
+{
+ unsigned long off;
+
+ if (!res || !res->bitmap || !count)
+ return -EINVAL;
+ off = bitmap_find_next_zero_area(res->bitmap, res->total, start,
+ count, 0);
+ if (off >= res->total)
+ return -ERANGE;
+
+ bitmap_set(res->bitmap, off, count);
+
+ return (int)off;
+}
+
+/**
+ * aie_resource_put_region() - release requested AI engine resource
+ * @res: pointer to AI engine resource to check
+ * @start: start index of the resource to release
+ * @count: number of elements to release
+ *
+ * This function release the requested AI engine resource.
+ */
+void aie_resource_put_region(struct aie_resource *res, int start, u32 count)
+{
+ if (!res || !count)
+ return;
+ bitmap_clear(res->bitmap, start, count);
+}
diff --git a/include/linux/amd-ai-engine.h b/include/linux/amd-ai-engine.h
new file mode 100644
index 000000000000..f5750d219e21
--- /dev/null
+++ b/include/linux/amd-ai-engine.h
@@ -0,0 +1,59 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * amd-ai-engine.h - AMD AI engine external interface
+ *
+ * Copyright(C) 2026 Advanced Micro Devices, Inc. All rights reserved.
+ */
+
+#ifndef _AMD_AI_ENGINE_H_
+#define _AMD_AI_ENGINE_H_
+
+#include <linux/device.h>
+#include <linux/list.h>
+#include <linux/mutex.h>
+
+#define AIE_PART_ID_START_COL_SHIFT 0U
+#define AIE_PART_ID_NUM_COLS_SHIFT 8U
+#define AIE_PART_ID_START_COL_MASK (0xFFU << AIE_PART_ID_START_COL_SHIFT)
+#define AIE_PART_ID_NUM_COLS_MASK (0xFFU << AIE_PART_ID_NUM_COLS_SHIFT)
+
+#define aie_part_id_get_val(part_id, F) \
+ (((part_id) & AIE_PART_ID_##F ##_MASK) >> AIE_PART_ID_##F ##_SHIFT)
+#define aie_part_id_get_start_col(part_id) \
+ aie_part_id_get_val((part_id), START_COL)
+#define aie_part_id_get_num_cols(part_id) \
+ aie_part_id_get_val((part_id), NUM_COLS)
+#define aie_calc_part_id(start_col, num_col) \
+ (((start_col) << AIE_PART_ID_START_COL_SHIFT) + \
+ ((num_col) << AIE_PART_ID_NUM_COLS_SHIFT))
+
+/**
+ * struct aie_partition_req - AIE request partition arguments
+ * @partition_id: partition node id. It is used to identify the AI engine
+ * partition. Its format is:
+ * Reserved_16bits | start_col_8bits | num_cols_8bits
+ * @meta_data: meta data to indicate which resources used by application.
+ * @flag: used for application to indicate particular driver requirements
+ * application wants to have for the partition. e.g. do not clean
+ * resource when closing the partition.
+ */
+struct aie_partition_req {
+ u32 partition_id;
+ u64 meta_data;
+ u32 flag;
+};
+
+/**
+ * struct aie_location - AIE location information
+ * @col: column id
+ * @row: row id
+ */
+struct aie_location {
+ u32 col;
+ u32 row;
+};
+
+struct device *aie_partition_request(struct device *dev, struct aie_partition_req *req);
+void aie_partition_release(struct device *dev);
+
+#endif
--
2.34.1
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH 13/15] accel/amd-ai-engine: Add pm ops for firmware calls
2026-11-18 23:31 [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Gregory Williams
` (11 preceding siblings ...)
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 ` Gregory Williams
2026-11-18 23:32 ` [PATCH 14/15] accel/amd-ai-engine: Add support to enable/disable tile clocks Gregory Williams
` (2 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Gregory Williams @ 2026-11-18 23:32 UTC (permalink / raw)
To: Oded Gabbay; +Cc: linux-kernel, dri-devel
The AI engine array has privileged registers that can only be written to
by the trusted firmware. The registers are critical for device
functionality such as, memory resets, column and shim resets, routing of
NoC traffic and interrupts, and enabling/disabling of tile clocks.
Structures are defined for each operation type which contain an
operation type, length, and operation specific parameters. The ops are
packed into a buffer and passed directly to the firmware which will
execute operations sequentially.
Signed-off-by: Gregory Williams <gregory.williams@amd.com>
---
drivers/accel/amd-ai-engine/Makefile | 1 +
drivers/accel/amd-ai-engine/ai-engine-dev.c | 13 +-
.../accel/amd-ai-engine/ai-engine-internal.h | 168 ++++++-
drivers/accel/amd-ai-engine/ai-engine-part.c | 17 +-
drivers/accel/amd-ai-engine/ai-engine-pm.c | 472 ++++++++++++++++++
include/linux/amd-ai-engine.h | 53 +-
6 files changed, 714 insertions(+), 10 deletions(-)
create mode 100644 drivers/accel/amd-ai-engine/ai-engine-pm.c
diff --git a/drivers/accel/amd-ai-engine/Makefile b/drivers/accel/amd-ai-engine/Makefile
index cb456ee7ec37..8b0d857d3347 100644
--- a/drivers/accel/amd-ai-engine/Makefile
+++ b/drivers/accel/amd-ai-engine/Makefile
@@ -8,4 +8,5 @@ amd-aie-$(CONFIG_DRM_ACCEL_AMDAIE) := \
ai-engine-aiemlv2.o \
ai-engine-dev.o \
ai-engine-part.o \
+ ai-engine-pm.o \
ai-engine-res.o
diff --git a/drivers/accel/amd-ai-engine/ai-engine-dev.c b/drivers/accel/amd-ai-engine/ai-engine-dev.c
index 7dad3004e30a..8866d3cf6ed8 100644
--- a/drivers/accel/amd-ai-engine/ai-engine-dev.c
+++ b/drivers/accel/amd-ai-engine/ai-engine-dev.c
@@ -8,15 +8,19 @@
#include <linux/amd-ai-engine.h>
#include <linux/clk.h>
#include <linux/device.h>
+#include <linux/dma-mapping.h>
#include <linux/io.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include "ai-engine-internal.h"
+#define AIE_DMA_BIT_MASK 48
+
/**
* aie_partition_request() - Request an AI engine partition
* @dev: AI engine device pointer
@@ -115,8 +119,15 @@ static int amd_ai_engine_probe(struct platform_device *pdev)
return -ENODEV;
}
- /* setup device layout configuration */
+ /* setup dma */
adev->dev = &pdev->dev;
+ ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(AIE_DMA_BIT_MASK));
+ if (ret) {
+ dev_err(adev->dev, "Failed to set dma mask\n");
+ return ret;
+ }
+
+ /* setup device layout configuration */
adev->range.start.col = 0;
adev->range.size.col = match->num_columns;
adev->range.start.row = 0;
diff --git a/drivers/accel/amd-ai-engine/ai-engine-internal.h b/drivers/accel/amd-ai-engine/ai-engine-internal.h
index 61ebd7f4b3d1..d2857ec50033 100644
--- a/drivers/accel/amd-ai-engine/ai-engine-internal.h
+++ b/drivers/accel/amd-ai-engine/ai-engine-internal.h
@@ -74,6 +74,166 @@ struct aie_tile_attr {
u8 num_rows;
};
+/**
+ * struct aie_op_start_num_col - start/number of columns op
+ * @type: operation type
+ * @len: operation struct length
+ * @start_col: start column
+ * @num_col: number of columns
+ */
+struct aie_op_start_num_col {
+ u16 type;
+ u16 len;
+ u16 start_col;
+ u16 num_col;
+} __aligned(4);
+
+/**
+ * struct aie_op_l2_ctrl_irq - l2 control irq ops
+ * @type: operation type.
+ * @len: length of the op
+ * @irq: irq value to be written to l2
+ */
+struct aie_op_l2_ctrl_irq {
+ u16 type;
+ u16 len;
+ u16 irq;
+} __aligned(4);
+
+/**
+ * struct aie_op_type_len - op that just needs type
+ * @type: operation type
+ * @len: length of the op
+ */
+struct aie_op_type_len {
+ u16 type;
+ u16 len;
+} __aligned(4);
+
+/**
+ * struct aie_op_hw_err - hardware error op
+ * @type: operation type
+ * @len: length of the op
+ * @val: value of hardware interrupt mask or irq number
+ */
+struct aie_op_hw_err {
+ u16 type;
+ u16 len;
+ u16 val;
+} __aligned(4);
+
+/**
+ * struct aie_op_uc_zeroisation - zeroize uc memory op
+ * @type: operation type
+ * @len: length of the op
+ * @flag: flag contains the following data:
+ * bit(2) - zeroize uc data memory
+ * bit(1) - zeroize uc private data memory
+ * bit(0) - zeroize uc program memory
+ */
+struct aie_op_uc_zeroisation {
+ u16 type;
+ u16 len;
+ u16 flag;
+} __aligned(4);
+
+/**
+ * struct aie_op_handshake - set handshake region op
+ * @type: operation type
+ * @len: length of the op
+ * @offset: handshake region offset
+ * @high_addr: high part of physical address of buffer with handshake data
+ * @low_addr: low part of physical address of buffer with handshake data
+ */
+struct aie_op_handshake {
+ u16 type;
+ u16 len;
+ u32 offset;
+ u32 high_addr;
+ u32 low_addr;
+} __aligned(4);
+
+/**
+ * struct aie_op_nmu_switch - nmu switch ops
+ * @type: operation type
+ * @len: length of the op
+ * @c0_route: where to route nmu data in col 0
+ * @c1_route: where to route nmu data in col 1
+ */
+struct aie_op_nmu_switch {
+ u16 type;
+ u16 len;
+ u16 c0_route;
+ u16 c1_route;
+} __aligned(4);
+
+/**
+ * struct aie_op_aximm_isolation - set axi isolation ops
+ * @type: operation type
+ * @len: length of the op
+ * @traffic: value to write to axi isolation register
+ */
+struct aie_op_aximm_isolation {
+ u16 type;
+ u16 len;
+ u16 traffic;
+} __aligned(4);
+
+/**
+ * struct aie_op_ecc_scrub_period - set ecc scrub period op
+ * @type: operation type
+ * @len: length of the op
+ * @scrub_period: ECC scrub period
+ */
+struct aie_op_ecc_scrub_period {
+ u16 type;
+ u16 len;
+ u16 scrub_period;
+} __aligned(4);
+
+/**
+ * struct aie_op_tlast - tlast errors op
+ * @type: operation type
+ * @len: length of the op
+ * @state: state of the op
+ */
+struct aie_op_tlast {
+ u16 type;
+ u16 len;
+ u16 state;
+} __aligned(4);
+
+/**
+ * struct aie_pm_ops - AI engine pm calls struct.
+ * @pkt_va: pm ops data virtual address.
+ * @pkt_dma: pm ops data dma address.
+ * @size: size of pkt_va.
+ * @offset: offset within pkt_va;
+ * @op_range: pointer to pkt_va for latest range. All op headers added at offset
+ * will be for this range.
+ */
+struct aie_pm_ops {
+ void *pkt_va;
+ dma_addr_t pkt_dma;
+ size_t size;
+ size_t offset;
+ struct aie_op_start_num_col *op_range;
+};
+
+/**
+ * struct aie_op_handshake_addr - AI engine handshake region
+ * @hs_va: virtual address of handshake buffer
+ * @size: size of buffer.
+ * @offset: offset into buffer;
+ * @hs_dma: dma address of handshake buffer
+ */
+struct aie_op_handshake_addr {
+ void *hs_va;
+ size_t size;
+ size_t offset;
+ dma_addr_t hs_dma;
+};
+
/**
* struct aie_device - AI engine device structure
* @partitions: list of partitions
@@ -116,6 +276,7 @@ struct aie_device {
* @adev: pointer to AI device instance
* @range: range of partition
* @mlock: protection for AI engine partition operations
+ * @pm_ops: pm ops pkt and metadata for pm firmware calls
*/
struct aie_partition {
struct list_head node;
@@ -123,6 +284,7 @@ struct aie_partition {
struct aie_device *adev;
struct aie_range range;
struct mutex mlock;
+ struct aie_pm_ops pm_ops;
};
/**
@@ -156,5 +318,9 @@ int aie_resource_check_region(struct aie_resource *res, u32 start,
int aie_resource_get_region(struct aie_resource *res, u32 start,
u32 count);
void aie_resource_put_region(struct aie_resource *res, int start, u32 count);
-
+int aie_part_pm_ops_create(struct aie_partition *apart);
+void aie_part_pm_ops_destroy(struct aie_partition *apart);
+int aie_part_pm_ops_flush(struct aie_partition *apart);
+int aie_part_pm_ops(struct aie_partition *apart, void *data, u32 type,
+ struct aie_range range, bool flush);
#endif /* AIE_INTERNAL_H */
diff --git a/drivers/accel/amd-ai-engine/ai-engine-part.c b/drivers/accel/amd-ai-engine/ai-engine-part.c
index f80a6fa433aa..51580049f0e7 100644
--- a/drivers/accel/amd-ai-engine/ai-engine-part.c
+++ b/drivers/accel/amd-ai-engine/ai-engine-part.c
@@ -21,6 +21,7 @@ void aie_part_release(struct aie_partition *apart)
struct aie_device *adev = apart->adev;
list_del(&apart->node);
+ aie_part_pm_ops_destroy(apart);
aie_resource_put_region(&adev->cols_res,
apart->range.start.col -
adev->range.start.col,
@@ -47,6 +48,7 @@ struct aie_partition *aie_part_create(struct aie_device *adev,
{
struct aie_partition *apart;
struct device *dev;
+ int ret;
apart = devm_kzalloc(adev->dev, sizeof(*apart), GFP_KERNEL);
if (!apart)
@@ -67,11 +69,22 @@ struct aie_partition *aie_part_create(struct aie_device *adev,
dev_set_drvdata(dev, apart);
dev->release = aie_part_release_device;
- if (device_register(&apart->dev)) {
+ ret = device_register(&apart->dev);
+ if (ret) {
dev_err(adev->dev, "failed to register partition device\n");
put_device(dev);
- return ERR_PTR(-ENODEV);
+ return ERR_PTR(ret);
+ }
+
+ ret = aie_part_pm_ops_create(apart);
+ if (ret) {
+ dev_err(&apart->dev, "failed to create pm ops buffer\n");
+ goto err;
}
return apart;
+
+err:
+ device_unregister(&apart->dev);
+ return ERR_PTR(ret);
}
diff --git a/drivers/accel/amd-ai-engine/ai-engine-pm.c b/drivers/accel/amd-ai-engine/ai-engine-pm.c
new file mode 100644
index 000000000000..103879456f52
--- /dev/null
+++ b/drivers/accel/amd-ai-engine/ai-engine-pm.c
@@ -0,0 +1,472 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * AMD AI Engine driver platform management implementations
+ *
+ * Copyright (C) 2026 Advanced Micro Devices, Inc.
+ */
+
+#include "ai-engine-internal.h"
+
+#include <linux/dma-mapping.h>
+#include <linux/firmware/xlnx-zynqmp.h>
+
+#define AIE_PM_OPS_PKT_SIZE 200
+
+int aie_part_pm_ops_create(struct aie_partition *apart)
+{
+ struct aie_pm_ops *pm_ops = &apart->pm_ops;
+
+ if (apart->adev->dev_gen != AIE_DEVICE_GEN_AIEMLV2)
+ return 0;
+
+ pm_ops->pkt_va = dma_alloc_coherent(apart->adev->dev,
+ AIE_PM_OPS_PKT_SIZE,
+ &pm_ops->pkt_dma, GFP_KERNEL);
+ if (!pm_ops->pkt_va)
+ return -ENOMEM;
+
+ pm_ops->size = AIE_PM_OPS_PKT_SIZE;
+ return 0;
+}
+
+void aie_part_pm_ops_destroy(struct aie_partition *apart)
+{
+ struct aie_pm_ops *pm_ops = &apart->pm_ops;
+
+ if (pm_ops->pkt_va)
+ dma_free_coherent(apart->adev->dev, pm_ops->size,
+ pm_ops->pkt_va, pm_ops->pkt_dma);
+
+ pm_ops->pkt_va = NULL;
+}
+
+int aie_part_pm_ops_flush(struct aie_partition *apart)
+{
+ struct aie_pm_ops *pm_ops = &apart->pm_ops;
+ int ret = 0;
+
+ /*
+ * If the last thing queued is a range header with no op after it,
+ * drop it: firmware has nothing to do for that range.
+ */
+ if (pm_ops->op_range &&
+ pm_ops->offset == (size_t)((u8 *)pm_ops->op_range -
+ (u8 *)pm_ops->pkt_va) +
+ sizeof(*pm_ops->op_range))
+ pm_ops->offset -= sizeof(*pm_ops->op_range);
+
+ if (pm_ops->offset)
+ ret = versal2_pm_aie2ps_operation(apart->adev->fw_dev_id,
+ pm_ops->offset,
+ upper_32_bits(pm_ops->pkt_dma),
+ lower_32_bits(pm_ops->pkt_dma));
+
+ pm_ops->offset = 0;
+ pm_ops->op_range = NULL;
+ memset(pm_ops->pkt_va, 0, AIE_PM_OPS_PKT_SIZE);
+
+ return ret;
+}
+
+int aie_part_pm_ops(struct aie_partition *apart, void *data, u32 type,
+ struct aie_range range, bool flush)
+{
+ struct aie_pm_ops *pm_ops = &apart->pm_ops;
+ struct aie_op_start_num_col *op_range;
+ ssize_t end;
+ int ret = 0;
+
+again:
+ op_range = pm_ops->op_range;
+ if (!op_range ||
+ op_range->num_col != range.size.col ||
+ op_range->start_col != range.start.col) {
+ if (check_add_overflow(pm_ops->offset, sizeof(*op_range), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ }
+ pm_ops->op_range = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*pm_ops->op_range);
+ op_range = pm_ops->op_range;
+ op_range->type = XILINX_AIE_OPS_START_NUM_COL;
+ op_range->start_col = range.start.col;
+ op_range->num_col = range.size.col;
+ op_range->len = sizeof(*op_range);
+ }
+
+ if (type & AIE_PART_INIT_OPT_COLUMN_RST) {
+ struct aie_op_type_len *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_COLUMN_RST;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_COL_RST;
+ op->len = sizeof(*op);
+ }
+ if (type & AIE_PART_INIT_OPT_SHIM_RST) {
+ struct aie_op_type_len *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_SHIM_RST;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_SHIM_RST;
+ op->len = sizeof(*op);
+ }
+ if (type & AIE_PART_INIT_OPT_BLOCK_NOCAXIMMERR) {
+ struct aie_op_type_len *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_BLOCK_NOCAXIMMERR;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_ENB_AXI_MM_ERR_EVENT;
+ op->len = sizeof(*op);
+ }
+ if (type & AIE_PART_INIT_OPT_ENB_COLCLK_BUFF) {
+ struct aie_op_type_len *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_ENB_COLCLK_BUFF;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_ENB_COL_CLK_BUFF;
+ op->len = sizeof(*op);
+ }
+ if (type & AIE_PART_INIT_OPT_DIS_COLCLK_BUFF) {
+ struct aie_op_type_len *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_DIS_COLCLK_BUFF;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_DIS_COL_CLK_BUFF;
+ op->len = sizeof(*op);
+ }
+ if (type & AIE_PART_INIT_OPT_ZEROIZEMEM) {
+ struct aie_op_type_len *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_ZEROIZEMEM;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_ZEROISATION;
+ op->len = sizeof(*op);
+ }
+ if (type & AIE_PART_INIT_OPT_UC_ENB_MEM_PRIV) {
+ struct aie_op_type_len *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_UC_ENB_MEM_PRIV;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_ENB_MEM_PRIV;
+ op->len = sizeof(*op);
+ }
+ if (type & AIE_PART_INIT_OPT_UC_DIS_MEM_PRIV) {
+ struct aie_op_type_len *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_UC_DIS_MEM_PRIV;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_DIS_MEM_PRIV;
+ op->len = sizeof(*op);
+ }
+ if (type & AIE_PART_INIT_OPT_ENB_NOC_DMA_PAUSE) {
+ struct aie_op_type_len *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_ENB_NOC_DMA_PAUSE;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_ENB_NOC_DMA_PAUSE;
+ op->len = sizeof(*op);
+ }
+ if (type & AIE_PART_INIT_OPT_ENB_UC_DMA_PAUSE) {
+ struct aie_op_type_len *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_ENB_UC_DMA_PAUSE;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_ENB_UC_DMA_PAUSE;
+ op->len = sizeof(*op);
+ }
+ if (type & AIE_PART_INIT_OPT_DIS_MEM_INTERLEAVE) {
+ struct aie_op_type_len *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_DIS_MEM_INTERLEAVE;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_DIS_MEM_INTERLEAVE;
+ op->len = sizeof(*op);
+ }
+ if (type & AIE_PART_INIT_OPT_UC_ZEROIZATION) {
+ struct aie_op_uc_zeroisation *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_UC_ZEROIZATION;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_UC_ZEROIZATION;
+ op->len = sizeof(*op);
+ op->flag = *((u16 *)data);
+ }
+ if (type & AIE_PART_INIT_OPT_ISOLATE) {
+ struct aie_op_aximm_isolation *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_ISOLATE;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_AXIMM_ISOLATION;
+ op->len = sizeof(*op);
+ op->traffic = *((u16 *)data);
+ }
+ if (type & AIE_PART_INIT_OPT_SET_L2_IRQ) {
+ struct aie_op_l2_ctrl_irq *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_SET_L2_IRQ;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_SET_L2_CTRL_NPI_INTR;
+ op->len = sizeof(*op);
+ op->irq = *((u16 *)data);
+ }
+ if (type & AIE_PART_INIT_OPT_NMU_CONFIG) {
+ struct aie_op_nmu_switch *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_NMU_CONFIG;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_NMU_CONFIG;
+ op->len = sizeof(*op);
+ /*
+ * Configure col0 to route data to east neighbor
+ * Configure col1 to accept data from west neighbor
+ */
+ op->c0_route = 0x1;
+ op->c1_route = 0x2;
+ }
+ if (type & AIE_PART_INIT_OPT_HW_ERR_INT) {
+ struct aie_op_hw_err *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_HW_ERR_INT;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_HW_ERR_INT;
+ op->len = sizeof(*op);
+ op->val = *((u16 *)data);
+ }
+ if (type & AIE_PART_INIT_OPT_HW_ERR_MASK) {
+ struct aie_op_hw_err *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_HW_ERR_MASK;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_HW_ERR_MASK;
+ op->len = sizeof(*op);
+ op->val = *((u16 *)data);
+ }
+ if (type & AIE_PART_INIT_OPT_SET_ECC_SCRUB_PERIOD) {
+ struct aie_op_ecc_scrub_period *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_SET_ECC_SCRUB_PERIOD;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_SET_ECC_SCRUB_PERIOD;
+ op->len = sizeof(*op);
+ op->scrub_period = *((u16 *)data);
+ }
+ if (type & AIE_PART_INIT_OPT_HW_ERR_STS) {
+ struct aie_op_hw_err *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_HW_ERR_STS;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_CLR_HW_ERR_STS;
+ op->len = sizeof(*op);
+ op->val = *((u16 *)data);
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ if (type & AIE_PART_INIT_OPT_DIS_TLAST_ERROR) {
+ struct aie_op_tlast *op;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+ type &= ~AIE_PART_INIT_OPT_DIS_TLAST_ERROR;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_CTRL_PKT_TLAST_ERR;
+ op->len = sizeof(*op);
+ op->state = *((u16 *)data);
+ }
+ if (type & AIE_PART_INIT_OPT_HANDSHAKE) {
+ struct aie_op_handshake *op;
+ struct aie_op_handshake_addr *hs_addr = data;
+
+ if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
+ end >= pm_ops->size) {
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ return ret;
+ goto again;
+ }
+
+ type &= ~AIE_PART_INIT_OPT_HANDSHAKE;
+ op = pm_ops->pkt_va + pm_ops->offset;
+ pm_ops->offset += sizeof(*op);
+ op->type = XILINX_AIE_OPS_HANDSHAKE;
+ op->len = sizeof(*op) + hs_addr->size;
+ op->offset = hs_addr->offset;
+ op->low_addr = hs_addr->hs_dma & 0xFFFFFFFFULL;
+ op->high_addr = hs_addr->hs_dma >> 32;
+ if (flush)
+ ret = aie_part_pm_ops_flush(apart);
+
+ if (ret)
+ return ret;
+ goto again;
+ }
+
+ if (type)
+ dev_warn(&apart->dev, "Unknown ops type: 0x%x\n", type);
+
+ if (flush)
+ ret = aie_part_pm_ops_flush(apart);
+
+ return ret;
+}
diff --git a/include/linux/amd-ai-engine.h b/include/linux/amd-ai-engine.h
index f5750d219e21..9df3463985af 100644
--- a/include/linux/amd-ai-engine.h
+++ b/include/linux/amd-ai-engine.h
@@ -12,6 +12,16 @@
#include <linux/list.h>
#include <linux/mutex.h>
+/**
+ * struct aie_location - AIE location information
+ * @col: column id
+ * @row: row id
+ */
+struct aie_location {
+ u32 col;
+ u32 row;
+};
+
#define AIE_PART_ID_START_COL_SHIFT 0U
#define AIE_PART_ID_NUM_COLS_SHIFT 8U
#define AIE_PART_ID_START_COL_MASK (0xFFU << AIE_PART_ID_START_COL_SHIFT)
@@ -43,14 +53,45 @@ struct aie_partition_req {
u32 flag;
};
+/*
+ * AI engine partition initialize options
+ */
+#define AIE_PART_INIT_OPT_START_NUM_COL 0U
+#define AIE_PART_INIT_OPT_COLUMN_RST BIT(0)
+#define AIE_PART_INIT_OPT_SHIM_RST BIT(1)
+#define AIE_PART_INIT_OPT_BLOCK_NOCAXIMMERR BIT(2)
+#define AIE_PART_INIT_OPT_ISOLATE BIT(3)
+#define AIE_PART_INIT_OPT_ZEROIZEMEM BIT(4)
+#define AIE_PART_INIT_OPT_UC_ENB_MEM_PRIV BIT(5)
+#define AIE_PART_INIT_ERROR_HANDLING BIT(6)
+#define AIE_PART_INIT_OPT_DIS_COLCLK_BUFF BIT(7)
+#define AIE_PART_INIT_OPT_SET_L2_IRQ BIT(8)
+#define AIE_PART_INIT_OPT_HW_ERR_INT BIT(9)
+#define AIE_PART_INIT_OPT_HW_ERR_MASK BIT(10)
+#define AIE_PART_INIT_OPT_SET_ECC_SCRUB_PERIOD BIT(11)
+#define AIE_PART_INIT_OPT_NMU_CONFIG BIT(12)
+#define AIE_PART_INIT_OPT_ENB_COLCLK_BUFF BIT(13)
+#define AIE_PART_INIT_OPT_UC_ZEROIZATION BIT(14)
+#define AIE_PART_INIT_OPT_UC_DIS_MEM_PRIV BIT(15)
+#define AIE_PART_INIT_OPT_ENB_NOC_DMA_PAUSE BIT(16)
+#define AIE_PART_INIT_OPT_ENB_UC_DMA_PAUSE BIT(17)
+#define AIE_PART_INIT_OPT_HW_ERR_STS BIT(18)
+#define AIE_PART_INIT_OPT_DIS_MEM_INTERLEAVE BIT(19)
+#define AIE_PART_INIT_OPT_HANDSHAKE BIT(20)
+#define AIE_PART_INIT_OPT_DIS_TLAST_ERROR BIT(21)
+#define AIE_PART_INIT_OPT_EN_TLAST_ERROR BIT(22)
+
/**
- * struct aie_location - AIE location information
- * @col: column id
- * @row: row id
+ * struct aie_op_handshake_data - AI engine uc handshake region information
+ * @addr: handshake data address from where the data needs to be copied.
+ * @size: handshake data size.
+ * @offset: offset for handshake region update.
*/
-struct aie_location {
- u32 col;
- u32 row;
+struct aie_op_handshake_data {
+ void *addr;
+ size_t size;
+ size_t offset;
+ struct aie_location loc;
};
struct device *aie_partition_request(struct device *dev, struct aie_partition_req *req);
--
2.34.1
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH 14/15] accel/amd-ai-engine: Add support to enable/disable tile clocks
2026-11-18 23:31 [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Gregory Williams
` (12 preceding siblings ...)
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 ` Gregory Williams
2026-11-18 23:32 ` [PATCH 15/15] accel/amd-ai-engine: Add reset operations Gregory Williams
2026-11-19 8:19 ` [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Jerome Brunet
15 siblings, 0 replies; 17+ messages in thread
From: Gregory Williams @ 2026-11-18 23:32 UTC (permalink / raw)
To: Oded Gabbay; +Cc: linux-kernel, dri-devel
Add support for enabling tile clocks and requesting/releasing tiles.
Requesting tiles will enable the clocks of the tiles requested, releasing
tiles will disable the tile clocks.
Signed-off-by: Gregory Williams <gregory.williams@amd.com>
---
drivers/accel/amd-ai-engine/Makefile | 1 +
.../accel/amd-ai-engine/ai-engine-aiemlv2.c | 150 +++++++++++++++++
drivers/accel/amd-ai-engine/ai-engine-clock.c | 154 ++++++++++++++++++
.../accel/amd-ai-engine/ai-engine-internal.h | 43 +++++
drivers/accel/amd-ai-engine/ai-engine-part.c | 18 ++
drivers/accel/amd-ai-engine/ai-engine-res.c | 56 +++++++
include/linux/amd-ai-engine.h | 1 -
7 files changed, 422 insertions(+), 1 deletion(-)
create mode 100644 drivers/accel/amd-ai-engine/ai-engine-clock.c
diff --git a/drivers/accel/amd-ai-engine/Makefile b/drivers/accel/amd-ai-engine/Makefile
index 8b0d857d3347..c6d090257d6e 100644
--- a/drivers/accel/amd-ai-engine/Makefile
+++ b/drivers/accel/amd-ai-engine/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_DRM_ACCEL_AMDAIE) += amd-aie.o
amd-aie-$(CONFIG_DRM_ACCEL_AMDAIE) := \
ai-engine-aiemlv2.o \
ai-engine-dev.o \
+ ai-engine-clock.o \
ai-engine-part.o \
ai-engine-pm.o \
ai-engine-res.o
diff --git a/drivers/accel/amd-ai-engine/ai-engine-aiemlv2.c b/drivers/accel/amd-ai-engine/ai-engine-aiemlv2.c
index 0c9c7ccdd54e..26dd1d726bfa 100644
--- a/drivers/accel/amd-ai-engine/ai-engine-aiemlv2.c
+++ b/drivers/accel/amd-ai-engine/ai-engine-aiemlv2.c
@@ -13,6 +13,16 @@
#define AIEMLV2_COL_SHIFT 25U
#define AIEMLV2_ROW_SHIFT 20U
+/*
+ * Register offsets
+ */
+#define AIEMLV2_SHIMPL_COLCLOCK_CTRL_REGOFF 0x0007FF20U
+
+/*
+ * Register masks
+ */
+#define AIEMLV2_SHIMPL_COLCLOCK_CTRL_MASK GENMASK(1, 0)
+
static u32 aiemlv2_get_tile_type(struct aie_device *adev, struct aie_location *loc)
{
u8 num_mem_rows = adev->ttype_attr[AIE_TILE_TYPE_MEMORY].num_rows;
@@ -25,8 +35,148 @@ static u32 aiemlv2_get_tile_type(struct aie_device *adev, struct aie_location *l
return AIE_TILE_TYPE_SHIMNOC;
}
+static int aiemlv2_scan_part_clocks(struct aie_partition *apart)
+{
+ struct aie_range *range = &apart->range;
+ struct aie_device *adev = apart->adev;
+ struct aie_location loc;
+
+ /* Clear the bitmap of cores and memories clock state */
+ aie_resource_put_region(&apart->cores_clk_state, 0,
+ apart->cores_clk_state.total);
+
+ /*
+ * If the clock buffer on shim tile is enabled, then all tiles above in
+ * the same column are also enabled.
+ */
+
+ loc.row = 0;
+ for (loc.col = range->start.col;
+ loc.col < range->start.col + range->size.col;
+ loc.col++) {
+ void __iomem *va;
+ u32 val, nbitpos;
+
+ nbitpos = (loc.col - range->start.col) * (range->size.row - 1) + loc.row;
+
+ va = adev->base +
+ aie_cal_regoff(adev, loc,
+ AIEMLV2_SHIMPL_COLCLOCK_CTRL_REGOFF);
+ val = readl(va);
+
+ if (!((val & AIEMLV2_SHIMPL_COLCLOCK_CTRL_MASK) % 2))
+ continue;
+
+ aie_resource_set(&apart->cores_clk_state, nbitpos,
+ range->size.row - 1);
+ }
+ /*
+ * Set the tiles in use bitmap.
+ * In case of scanning, tiles which are powered on are considered as
+ * tiles in use.
+ */
+ bitmap_copy(apart->tiles_inuse.bitmap, apart->cores_clk_state.bitmap,
+ apart->tiles_inuse.total);
+
+ return 0;
+}
+
+static int aiemlv2_set_part_clocks(struct aie_partition *apart)
+{
+ struct aie_range *range = &apart->range;
+ struct aie_range prev_range = {};
+ struct aie_location loc;
+ int ret = -EINVAL;
+ u32 prev_ops = 0;
+
+ for (loc.col = 0; loc.col < range->size.col; loc.col++) {
+ u32 startbit, col_inuse = 0;
+
+ startbit = loc.col * (range->size.row - 1);
+
+ for (loc.row = range->start.row + 1;
+ loc.row < range->start.row + range->size.row;
+ loc.row++) {
+ u32 nbitpos = startbit + loc.row - 1;
+
+ if (aie_resource_testbit(&apart->tiles_inuse, nbitpos)) {
+ col_inuse = 1;
+ break;
+ }
+ }
+
+ if (col_inuse) {
+ struct aie_range op_range = {
+ .start.col = loc.col + range->start.col,
+ .size.col = 1,
+ };
+
+ ret = aie_resource_set(&apart->tiles_inuse, startbit,
+ apart->range.size.row - 1);
+ if (ret)
+ return ret;
+ ret = aie_resource_set(&apart->cores_clk_state, startbit,
+ apart->range.size.row - 1);
+ if (ret)
+ return ret;
+
+ if (!prev_ops) {
+ prev_range = op_range;
+ prev_ops = AIE_PART_INIT_OPT_ENB_COLCLK_BUFF;
+ continue;
+ }
+ if (prev_ops == AIE_PART_INIT_OPT_ENB_COLCLK_BUFF &&
+ ((prev_range.start.col + prev_range.size.col) == op_range.start.col)) {
+ prev_range.size.col += op_range.size.col;
+ continue;
+ }
+ ret = aie_part_pm_ops(apart, NULL, prev_ops, prev_range, 0);
+ if (ret)
+ return ret;
+ prev_ops = AIE_PART_INIT_OPT_ENB_COLCLK_BUFF;
+ prev_range = op_range;
+ } else {
+ struct aie_range op_range = {
+ .start.col = loc.col + range->start.col,
+ .size.col = 1,
+ };
+
+ ret = aie_resource_clear(&apart->tiles_inuse, startbit,
+ apart->range.size.row - 1);
+ if (ret)
+ return ret;
+ ret = aie_resource_clear(&apart->cores_clk_state, startbit,
+ apart->range.size.row - 1);
+ if (ret)
+ return ret;
+ if (!prev_ops) {
+ prev_range = op_range;
+ prev_ops = AIE_PART_INIT_OPT_DIS_COLCLK_BUFF;
+ continue;
+ }
+ if (prev_ops == AIE_PART_INIT_OPT_DIS_COLCLK_BUFF &&
+ ((prev_range.start.col + prev_range.size.col) == op_range.start.col)) {
+ prev_range.size.col += op_range.size.col;
+ continue;
+ }
+ ret = aie_part_pm_ops(apart, NULL, prev_ops, prev_range, 0);
+ if (ret)
+ return ret;
+ prev_ops = AIE_PART_INIT_OPT_DIS_COLCLK_BUFF;
+ prev_range = op_range;
+ }
+ }
+ if (prev_ops)
+ ret = aie_part_pm_ops(apart, NULL, prev_ops, prev_range, 0);
+ if (ret)
+ return ret;
+ return aie_part_pm_ops_flush(apart);
+}
+
static const struct aie_tile_operations aiemlv2_ops = {
.get_tile_type = aiemlv2_get_tile_type,
+ .scan_part_clocks = aiemlv2_scan_part_clocks,
+ .set_part_clocks = aiemlv2_set_part_clocks,
};
/**
diff --git a/drivers/accel/amd-ai-engine/ai-engine-clock.c b/drivers/accel/amd-ai-engine/ai-engine-clock.c
new file mode 100644
index 000000000000..f2bf373c1da0
--- /dev/null
+++ b/drivers/accel/amd-ai-engine/ai-engine-clock.c
@@ -0,0 +1,154 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * AMD AI Engine clock operations
+ *
+ * Copyright(C) 2026 Advanced Micro Devices, Inc. All rights reserved.
+ */
+
+#include <linux/amd-ai-engine.h>
+#include <linux/clk.h>
+#include <linux/firmware/xlnx-zynqmp.h>
+#include <linux/list.h>
+#include <linux/mutex.h>
+
+#include "ai-engine-internal.h"
+
+/**
+ * aie_part_init_clk_state() - initialize clock state and tiles in use bitmaps
+ * @apart: AI engine partition
+ *
+ * Return: error code for error 0 for success
+ */
+int aie_part_init_clk_state(struct aie_partition *apart)
+{
+ u32 num_tiles;
+ int ret;
+
+ /* SHIM row always enabled so it is not needed in the bitmap */
+ num_tiles = apart->range.size.col * (apart->range.size.row - 1);
+ ret = aie_resource_initialize(&apart->cores_clk_state, num_tiles);
+ if (ret) {
+ dev_err(&apart->dev, "failed to initialize clock state resource.\n");
+ return ret;
+ }
+
+ ret = aie_resource_initialize(&apart->tiles_inuse, num_tiles);
+ if (ret) {
+ dev_err(&apart->dev, "failed to initialize tiles in use resource.\n");
+ aie_resource_uninitialize(&apart->cores_clk_state);
+ return ret;
+ }
+
+ return 0;
+}
+
+/**
+ * aie_part_get_clk_state_bit() - return bit position of the clock state of a
+ * tile
+ * @apart: AI engine partition
+ * @loc: AI engine tile location
+ *
+ * Return: bit position for success, negative value for failure
+ */
+static int aie_part_get_clk_state_bit(struct aie_partition *apart,
+ struct aie_location *loc)
+{
+ u32 ttype = apart->adev->ops->get_tile_type(apart->adev, loc);
+
+ if (ttype != AIE_TILE_TYPE_TILE && ttype != AIE_TILE_TYPE_MEMORY)
+ return -EINVAL;
+
+ if (loc->col < apart->range.start.col)
+ return -EINVAL;
+
+ return (loc->col - apart->range.start.col) *
+ (apart->range.size.row - 1) + loc->row - 1;
+}
+
+/**
+ * aie_part_scan_clk_state() - scan the clock states of tiles of the AI engine
+ * partition
+ * @apart: AI engine partition
+ *
+ * Return: 0 for success, negative value for failure.
+ *
+ * This function will scan the clock status of both the memory and core
+ * modules.
+ */
+int aie_part_scan_clk_state(struct aie_partition *apart)
+{
+ return apart->adev->ops->scan_part_clocks(apart);
+}
+
+/**
+ * aie_part_request_tiles() - request tiles from an AI engine partition.
+ * @apart: AI engine partition
+ * @num_tiles: number of tiles to request. If it is 0, it means all tiles
+ * @locs: the AI engine tiles locations array which will be requested
+ *
+ * Return: 0 for success, negative value for failure.
+ *
+ * This function will enable clocks of the specified tiles.
+ */
+int aie_part_request_tiles(struct aie_partition *apart, u32 num_tiles,
+ struct aie_location *locs)
+{
+ int ret;
+
+ if (num_tiles == 0) {
+ aie_resource_set(&apart->tiles_inuse, 0,
+ apart->tiles_inuse.total);
+ } else {
+ u32 n;
+
+ if (!locs)
+ return -EINVAL;
+
+ for (n = 0; n < num_tiles; n++) {
+ int bit = aie_part_get_clk_state_bit(apart, &locs[n]);
+
+ if (bit >= 0)
+ aie_resource_set(&apart->tiles_inuse, bit, 1);
+ }
+ }
+ ret = apart->adev->ops->set_part_clocks(apart);
+
+ return ret;
+}
+
+/**
+ * aie_part_release_tiles() - release tiles from an AI engine partition.
+ * @apart: AI engine partition
+ * @num_tiles: number of tiles to release. If it is 0, it means all tiles
+ * @locs: the AI engine tiles locations array which will be released
+ *
+ * Return: 0 for success, negative value for failure.
+ *
+ * This function will disable clocks of the specified tiles.
+ */
+int aie_part_release_tiles(struct aie_partition *apart, u32 num_tiles,
+ struct aie_location *locs)
+{
+ int ret;
+
+ if (num_tiles == 0) {
+ aie_resource_clear(&apart->tiles_inuse, 0,
+ apart->tiles_inuse.total);
+ } else {
+ u32 n;
+
+ if (!locs)
+ return -EINVAL;
+
+ for (n = 0; n < num_tiles; n++) {
+ int bit = aie_part_get_clk_state_bit(apart, &locs[n]);
+
+ if (bit >= 0)
+ aie_resource_clear(&apart->tiles_inuse, bit, 1);
+ }
+ }
+
+ ret = apart->adev->ops->set_part_clocks(apart);
+
+ return ret;
+}
diff --git a/drivers/accel/amd-ai-engine/ai-engine-internal.h b/drivers/accel/amd-ai-engine/ai-engine-internal.h
index d2857ec50033..572476c97aad 100644
--- a/drivers/accel/amd-ai-engine/ai-engine-internal.h
+++ b/drivers/accel/amd-ai-engine/ai-engine-internal.h
@@ -37,11 +37,25 @@ struct aie_partition;
/**
* struct aie_tile_operations - AI engine device operations
* @get_tile_type: get type of tile based on tile operation
+ * @scan_part_clocks: scan partition modules to check whether the modules are
+ * clock gated or not, and update the soft clock states
+ * structure. It is required to be called when the partition
+ * is requested so that the driver knows which modules are
+ * clock gated when the partition is requested. This function
+ * expects the caller to apply partition lock before calling
+ * this function.
+ * @set_part_clocks: set partition modules clocks gate registers based on the
+ * partition clock states bitmap. This function expects the
+ * caller to apply partition lock before calling this
+ * function. The caller function will need to set the bitmap
+ * on which tiles are required to be clocked on.
* Different AI engine device version has its own device
* operation.
*/
struct aie_tile_operations {
u32 (*get_tile_type)(struct aie_device *adev, struct aie_location *loc);
+ int (*scan_part_clocks)(struct aie_partition *apart);
+ int (*set_part_clocks)(struct aie_partition *apart);
};
/**
@@ -275,6 +289,8 @@ struct aie_device {
* @dev: AI Engine partition device
* @adev: pointer to AI device instance
* @range: range of partition
+ * @cores_clk_state: bitmap to indicate the power state of core and mem tiles
+ * @tiles_inuse: bitmap to indicate if a tile is in use
* @mlock: protection for AI engine partition operations
* @pm_ops: pm ops pkt and metadata for pm firmware calls
*/
@@ -283,6 +299,8 @@ struct aie_partition {
struct device dev;
struct aie_device *adev;
struct aie_range range;
+ struct aie_resource cores_clk_state;
+ struct aie_resource tiles_inuse;
struct mutex mlock;
struct aie_pm_ops pm_ops;
};
@@ -307,10 +325,32 @@ struct aie_device_cfg {
#define dev_to_aiepart(_dev) container_of((_dev), struct aie_partition, dev)
+/**
+ * aie_cal_regoff() - calculate register offset to the whole AI engine
+ * device start address
+ * @adev: AI engine device
+ * @loc: AI engine tile location
+ * @regoff_intile: register offset within a tile
+ *
+ * Return: register offset to the whole AI engine device start address
+ */
+static inline u32 aie_cal_regoff(struct aie_device *adev,
+ struct aie_location loc, u32 regoff_intile)
+{
+ return regoff_intile + (loc.col << adev->col_shift) +
+ (loc.row << adev->row_shift);
+}
+
void aiemlv2_device_init(struct aie_device *adev);
struct aie_partition *aie_part_create(struct aie_device *adev,
u8 start_col, u8 num_col);
void aie_part_release(struct aie_partition *apart);
+int aie_part_init_clk_state(struct aie_partition *apart);
+int aie_part_scan_clk_state(struct aie_partition *apart);
+int aie_part_request_tiles(struct aie_partition *apart, u32 num_tiles,
+ struct aie_location *locs);
+int aie_part_release_tiles(struct aie_partition *apart, u32 num_tiles,
+ struct aie_location *locs);
int aie_resource_initialize(struct aie_resource *res, int count);
void aie_resource_uninitialize(struct aie_resource *res);
int aie_resource_check_region(struct aie_resource *res, u32 start,
@@ -318,6 +358,9 @@ int aie_resource_check_region(struct aie_resource *res, u32 start,
int aie_resource_get_region(struct aie_resource *res, u32 start,
u32 count);
void aie_resource_put_region(struct aie_resource *res, int start, u32 count);
+int aie_resource_set(struct aie_resource *res, u32 start, u32 count);
+int aie_resource_clear(struct aie_resource *res, u32 start, u32 count);
+bool aie_resource_testbit(struct aie_resource *res, u32 bit);
int aie_part_pm_ops_create(struct aie_partition *apart);
void aie_part_pm_ops_destroy(struct aie_partition *apart);
int aie_part_pm_ops_flush(struct aie_partition *apart);
diff --git a/drivers/accel/amd-ai-engine/ai-engine-part.c b/drivers/accel/amd-ai-engine/ai-engine-part.c
index 51580049f0e7..35451d1ed88a 100644
--- a/drivers/accel/amd-ai-engine/ai-engine-part.c
+++ b/drivers/accel/amd-ai-engine/ai-engine-part.c
@@ -26,6 +26,8 @@ void aie_part_release(struct aie_partition *apart)
apart->range.start.col -
adev->range.start.col,
apart->range.size.col);
+ aie_resource_uninitialize(&apart->cores_clk_state);
+ aie_resource_uninitialize(&apart->tiles_inuse);
device_unregister(&apart->dev);
}
@@ -82,6 +84,22 @@ struct aie_partition *aie_part_create(struct aie_device *adev,
goto err;
}
+ ret = aie_part_init_clk_state(apart);
+ if (ret) {
+ dev_err(&apart->dev, "failed to initialize clock state\n");
+ aie_part_pm_ops_destroy(apart);
+ goto err;
+ }
+
+ ret = aie_part_scan_clk_state(apart);
+ if (ret) {
+ dev_err(&apart->dev, "failed to scan clock state.");
+ aie_part_pm_ops_destroy(apart);
+ aie_resource_uninitialize(&apart->cores_clk_state);
+ aie_resource_uninitialize(&apart->tiles_inuse);
+ goto err;
+ }
+
return apart;
err:
diff --git a/drivers/accel/amd-ai-engine/ai-engine-res.c b/drivers/accel/amd-ai-engine/ai-engine-res.c
index 62df26edf87d..45b9447d896f 100644
--- a/drivers/accel/amd-ai-engine/ai-engine-res.c
+++ b/drivers/accel/amd-ai-engine/ai-engine-res.c
@@ -110,3 +110,59 @@ void aie_resource_put_region(struct aie_resource *res, int start, u32 count)
return;
bitmap_clear(res->bitmap, start, count);
}
+
+/**
+ * aie_resource_set() - set the AI engine resource bits
+ * @res: pointer to AI engine resource
+ * @start: start bit to set
+ * @count: number of bits to set
+ *
+ * Return: 0 for success and negative value for failure
+ *
+ * This function sets the specified number bits in the resource.
+ */
+int aie_resource_set(struct aie_resource *res, u32 start, u32 count)
+{
+ if (!res || !res->bitmap || !count ||
+ start > res->total || count > res->total - start)
+ return -EINVAL;
+
+ bitmap_set(res->bitmap, start, count);
+ return 0;
+}
+
+/**
+ * aie_resource_clear() - clear the AI engine resource bits
+ * @res: pointer to AI engine resource
+ * @start: start bit to set
+ * @count: number of bits to clear
+ *
+ * Return: 0 for success and negative value for failure
+ *
+ * This function clears the specified number bits in the resource.
+ */
+int aie_resource_clear(struct aie_resource *res, u32 start, u32 count)
+{
+ if (!res || !res->bitmap || !count ||
+ start > res->total || count > res->total - start)
+ return -EINVAL;
+
+ bitmap_clear(res->bitmap, start, count);
+ return 0;
+}
+
+/**
+ * aie_resource_testbit() - test if a bit is set in a AI engine resource
+ * @res: pointer to AI engine resource
+ * @bit: bit to check
+ *
+ * Return: true for set, false for not set
+ */
+bool aie_resource_testbit(struct aie_resource *res, u32 bit)
+{
+ if (!res || !res->bitmap || bit >= res->total)
+ return false;
+
+ /* Locate the unsigned long the required bit belongs to */
+ return test_bit(bit, res->bitmap);
+}
diff --git a/include/linux/amd-ai-engine.h b/include/linux/amd-ai-engine.h
index 9df3463985af..229434372fc0 100644
--- a/include/linux/amd-ai-engine.h
+++ b/include/linux/amd-ai-engine.h
@@ -96,5 +96,4 @@ struct aie_op_handshake_data {
struct device *aie_partition_request(struct device *dev, struct aie_partition_req *req);
void aie_partition_release(struct device *dev);
-
#endif
--
2.34.1
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH 15/15] accel/amd-ai-engine: Add reset operations
2026-11-18 23:31 [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Gregory Williams
` (13 preceding siblings ...)
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 ` Gregory Williams
2026-11-19 8:19 ` [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Jerome Brunet
15 siblings, 0 replies; 17+ messages in thread
From: Gregory Williams @ 2026-11-18 23:32 UTC (permalink / raw)
To: Oded Gabbay; +Cc: linux-kernel, dri-devel
Add reset operations partition initialize/teardown.
aie_partition_initialize should be called before application start,
aie_partition_teardown should be called after application has finished.
Initialize will reset the device configuration, clear memories, enable
clocks of used tiles, configure hardware error reporting and NMUs, and
will enable ECC scrubbing.
Teardown will clear tile memories and disable tile clocks.
Signed-off-by: Gregory Williams <gregory.williams@amd.com>
---
drivers/accel/amd-ai-engine/Makefile | 3 +-
.../accel/amd-ai-engine/ai-engine-aiemlv2.c | 244 ++++++++++++++++++
.../accel/amd-ai-engine/ai-engine-internal.h | 8 +
drivers/accel/amd-ai-engine/ai-engine-part.c | 32 +++
drivers/accel/amd-ai-engine/ai-engine-res.c | 16 ++
drivers/accel/amd-ai-engine/ai-engine-reset.c | 69 +++++
include/linux/amd-ai-engine.h | 16 ++
7 files changed, 387 insertions(+), 1 deletion(-)
create mode 100644 drivers/accel/amd-ai-engine/ai-engine-reset.c
diff --git a/drivers/accel/amd-ai-engine/Makefile b/drivers/accel/amd-ai-engine/Makefile
index c6d090257d6e..d5b6ccde0a35 100644
--- a/drivers/accel/amd-ai-engine/Makefile
+++ b/drivers/accel/amd-ai-engine/Makefile
@@ -10,4 +10,5 @@ amd-aie-$(CONFIG_DRM_ACCEL_AMDAIE) := \
ai-engine-clock.o \
ai-engine-part.o \
ai-engine-pm.o \
- ai-engine-res.o
+ ai-engine-res.o \
+ ai-engine-reset.o
diff --git a/drivers/accel/amd-ai-engine/ai-engine-aiemlv2.c b/drivers/accel/amd-ai-engine/ai-engine-aiemlv2.c
index 26dd1d726bfa..910a9bda2305 100644
--- a/drivers/accel/amd-ai-engine/ai-engine-aiemlv2.c
+++ b/drivers/accel/amd-ai-engine/ai-engine-aiemlv2.c
@@ -16,12 +16,16 @@
/*
* Register offsets
*/
+#define AIEMLV2_SHIMNOC_AXI_OUTSTANDING_TX_REGOFF 0x00002120U
#define AIEMLV2_SHIMPL_COLCLOCK_CTRL_REGOFF 0x0007FF20U
+#define AIEMLV2_SHIMUC_AXI_OUTSTANDING_TX_REGOFF 0x000C0024U
/*
* Register masks
*/
+#define AIEMLV2_SHIMNOC_AXI_OUTSTANDING_TX_MASK BIT(0)
#define AIEMLV2_SHIMPL_COLCLOCK_CTRL_MASK GENMASK(1, 0)
+#define AIEMLV2_SHIMUC_AXI_OUTSTANDING_TX_MASK GENMASK(1, 0)
static u32 aiemlv2_get_tile_type(struct aie_device *adev, struct aie_location *loc)
{
@@ -173,10 +177,250 @@ static int aiemlv2_set_part_clocks(struct aie_partition *apart)
return aie_part_pm_ops_flush(apart);
}
+static int aiemlv2_maskpoll_uc_outstanding_aximm_txn(struct aie_partition *apart)
+{
+ u32 end_col = apart->range.start.col + apart->range.size.col;
+ struct aie_location loc = {.row = 0};
+ int ret = 0;
+ u32 regoff;
+
+ for (loc.col = apart->range.start.col; loc.col < end_col; loc.col++) {
+ regoff = aie_cal_regoff(apart->adev, loc,
+ AIEMLV2_SHIMUC_AXI_OUTSTANDING_TX_REGOFF);
+ ret = aie_part_maskpoll_register(apart, regoff, 0x0,
+ AIEMLV2_SHIMUC_AXI_OUTSTANDING_TX_MASK,
+ 2000000);
+ if (ret < 0) {
+ dev_err(&apart->dev,
+ "failed due to outstanding UC AXIMM transactions!\n");
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int aiemlv2_maskpoll_noc_outstanding_aximm_txn(struct aie_partition *apart)
+{
+ u32 end_col = apart->range.start.col + apart->range.size.col;
+ struct aie_location loc = {.row = 0};
+ int ret = 0;
+ u32 regoff;
+
+ for (loc.col = apart->range.start.col; loc.col < end_col; loc.col++) {
+ regoff = aie_cal_regoff(apart->adev, loc,
+ AIEMLV2_SHIMNOC_AXI_OUTSTANDING_TX_REGOFF);
+ ret = aie_part_maskpoll_register(apart, regoff, 0x0,
+ AIEMLV2_SHIMNOC_AXI_OUTSTANDING_TX_MASK,
+ 2000000);
+ if (ret < 0) {
+ dev_err(&apart->dev,
+ "failed due to outstanding NoC AXIMM transactions!\n");
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int aiemlv2_part_init(struct aie_partition *apart,
+ struct aie_partition_init_args *args)
+{
+ u32 opts;
+ int ret;
+
+ mutex_lock(&apart->mlock);
+ opts = AIE_PART_INIT_OPT_ENB_UC_DMA_PAUSE | AIE_PART_INIT_OPT_ENB_NOC_DMA_PAUSE;
+ ret = aie_part_pm_ops(apart, NULL, opts, apart->range, 1);
+ if (ret)
+ goto out;
+
+ ret = aiemlv2_maskpoll_noc_outstanding_aximm_txn(apart);
+ if (ret)
+ goto out;
+
+ ret = aiemlv2_maskpoll_uc_outstanding_aximm_txn(apart);
+ if (ret)
+ goto out;
+
+ aie_resource_clear_all(&apart->tiles_inuse);
+ aie_resource_clear_all(&apart->cores_clk_state);
+
+ /* First lets send non-data aie_op_type_len ops */
+ opts = 0;
+ /* This operation will do first 4 steps of sequence */
+ opts |= (args->init_opts & AIE_PART_INIT_OPT_COLUMN_RST);
+ opts |= (args->init_opts & AIE_PART_INIT_OPT_SHIM_RST);
+ opts |= (args->init_opts & AIE_PART_INIT_OPT_BLOCK_NOCAXIMMERR);
+ opts |= (args->init_opts & AIE_PART_INIT_OPT_ENB_COLCLK_BUFF);
+
+ /*
+ * push opts to pm and flush, these ops need to be completed before we
+ * call the next ones
+ */
+ ret = aie_part_pm_ops(apart, NULL, opts, apart->range, 1);
+ if (ret) {
+ dev_err(&apart->dev, "pm ops: 0x%x failed: %d\n", opts, ret);
+ goto out;
+ }
+
+ if (args->init_opts & AIE_PART_INIT_OPT_ZEROIZEMEM) {
+ opts |= AIE_PART_INIT_OPT_ZEROIZEMEM;
+ ret = aie_part_pm_ops(apart, NULL, AIE_PART_INIT_OPT_ZEROIZEMEM,
+ apart->range, 1);
+ if (ret)
+ goto out;
+ }
+
+ if (args->init_opts & AIE_PART_INIT_OPT_UC_ZEROIZATION) {
+ u16 data = 0x6;
+
+ opts |= AIE_PART_INIT_OPT_UC_ZEROIZATION;
+ ret = aie_part_pm_ops(apart, &data, AIE_PART_INIT_OPT_UC_ZEROIZATION,
+ apart->range, 1);
+ if (ret)
+ goto out;
+ }
+
+ if (args->init_opts & AIE_PART_INIT_OPT_NMU_CONFIG) {
+ struct aie_range range = {0};
+
+ opts |= AIE_PART_INIT_OPT_NMU_CONFIG;
+ if (apart->range.start.col == 0) {
+ range.size.col = 2;
+ ret = aie_part_pm_ops(apart, NULL, AIE_PART_INIT_OPT_NMU_CONFIG,
+ range, 0);
+ if (ret)
+ goto out;
+ }
+ }
+
+ if (args->init_opts & AIE_PART_INIT_OPT_HW_ERR_INT) {
+ u16 data = 0;
+
+ opts |= AIE_PART_INIT_OPT_HW_ERR_INT;
+ ret = aie_part_pm_ops(apart, &data, AIE_PART_INIT_OPT_HW_ERR_INT,
+ apart->range, 0);
+ if (ret)
+ goto out;
+ }
+
+ if (args->init_opts & AIE_PART_INIT_OPT_HW_ERR_MASK) {
+ u16 data = 0x2;
+
+ opts |= AIE_PART_INIT_OPT_HW_ERR_MASK;
+ ret = aie_part_pm_ops(apart, &data, AIE_PART_INIT_OPT_HW_ERR_MASK,
+ apart->range, 0);
+ if (ret)
+ goto out;
+ }
+
+ if (args->init_opts & AIE_PART_INIT_OPT_SET_ECC_SCRUB_PERIOD) {
+ u16 data;
+
+ if (args->ecc_scrub > U16_MAX) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ data = args->ecc_scrub;
+ opts |= AIE_PART_INIT_OPT_SET_ECC_SCRUB_PERIOD;
+ ret = aie_part_pm_ops(apart, &data,
+ AIE_PART_INIT_OPT_SET_ECC_SCRUB_PERIOD,
+ apart->range, 0);
+ if (ret)
+ goto out;
+ }
+
+ if (args->init_opts & AIE_PART_INIT_OPT_UC_ENB_MEM_PRIV) {
+ opts |= AIE_PART_INIT_OPT_UC_ENB_MEM_PRIV;
+
+ ret = aie_part_pm_ops(apart, NULL, AIE_PART_INIT_OPT_UC_ENB_MEM_PRIV,
+ apart->range, 0);
+ if (ret)
+ goto out;
+ }
+
+ /* Request tile locations */
+ ret = aie_part_request_tiles(apart, args->num_tiles, args->locs);
+ if (ret)
+ goto out;
+
+ if (args->init_opts & AIE_PART_INIT_OPT_DIS_TLAST_ERROR) {
+ u16 data = 0;
+
+ opts |= AIE_PART_INIT_OPT_DIS_TLAST_ERROR;
+ ret = aie_part_pm_ops(apart, &data,
+ AIE_PART_INIT_OPT_DIS_TLAST_ERROR,
+ apart->range, 1);
+ if (ret)
+ goto out;
+ }
+
+ if (opts != args->init_opts)
+ dev_warn(&apart->dev, "Invalid init_opts: 0x%x\n", opts ^ args->init_opts);
+
+out:
+ mutex_unlock(&apart->mlock);
+ return ret;
+}
+
+static int aiemlv2_part_teardown(struct aie_partition *apart)
+{
+ u32 opts;
+ u16 data;
+ int ret;
+
+ mutex_lock(&apart->mlock);
+
+ opts = AIE_PART_INIT_OPT_ENB_UC_DMA_PAUSE | AIE_PART_INIT_OPT_ENB_NOC_DMA_PAUSE;
+ ret = aie_part_pm_ops(apart, NULL, opts, apart->range, 1);
+ if (ret)
+ goto out;
+
+ ret = aiemlv2_maskpoll_noc_outstanding_aximm_txn(apart);
+ if (ret)
+ goto out;
+
+ ret = aiemlv2_maskpoll_uc_outstanding_aximm_txn(apart);
+ if (ret)
+ goto out;
+
+ opts = AIE_PART_INIT_OPT_COLUMN_RST |
+ AIE_PART_INIT_OPT_SHIM_RST |
+ AIE_PART_INIT_OPT_ZEROIZEMEM;
+ ret = aie_part_pm_ops(apart, NULL, opts, apart->range, 0);
+ if (ret)
+ goto out;
+
+ /* Zeroizes the uc-DM and uc shared DM */
+ data = 0x6;
+ ret = aie_part_pm_ops(apart, &data, AIE_PART_INIT_OPT_UC_ZEROIZATION, apart->range, 1);
+ if (ret)
+ goto out;
+ ret = aie_part_pm_ops(apart, NULL, AIE_PART_INIT_OPT_DIS_COLCLK_BUFF, apart->range, 0);
+ if (ret)
+ goto out;
+ ret = aie_part_pm_ops_flush(apart);
+ if (ret)
+ goto out;
+
+ /* Clear resources */
+ aie_resource_clear_all(&apart->tiles_inuse);
+ aie_resource_clear_all(&apart->cores_clk_state);
+
+out:
+ mutex_unlock(&apart->mlock);
+
+ return ret;
+}
+
static const struct aie_tile_operations aiemlv2_ops = {
.get_tile_type = aiemlv2_get_tile_type,
.scan_part_clocks = aiemlv2_scan_part_clocks,
.set_part_clocks = aiemlv2_set_part_clocks,
+ .part_init = aiemlv2_part_init,
+ .part_teardown = aiemlv2_part_teardown,
};
/**
diff --git a/drivers/accel/amd-ai-engine/ai-engine-internal.h b/drivers/accel/amd-ai-engine/ai-engine-internal.h
index 572476c97aad..64691223ff9c 100644
--- a/drivers/accel/amd-ai-engine/ai-engine-internal.h
+++ b/drivers/accel/amd-ai-engine/ai-engine-internal.h
@@ -49,6 +49,8 @@ struct aie_partition;
* caller to apply partition lock before calling this
* function. The caller function will need to set the bitmap
* on which tiles are required to be clocked on.
+ * @part_init: initialize partition with user options.
+ * @part_teardown: teardown partition
* Different AI engine device version has its own device
* operation.
*/
@@ -56,6 +58,9 @@ struct aie_tile_operations {
u32 (*get_tile_type)(struct aie_device *adev, struct aie_location *loc);
int (*scan_part_clocks)(struct aie_partition *apart);
int (*set_part_clocks)(struct aie_partition *apart);
+ int (*part_init)(struct aie_partition *apart,
+ struct aie_partition_init_args *args);
+ int (*part_teardown)(struct aie_partition *apart);
};
/**
@@ -360,10 +365,13 @@ int aie_resource_get_region(struct aie_resource *res, u32 start,
void aie_resource_put_region(struct aie_resource *res, int start, u32 count);
int aie_resource_set(struct aie_resource *res, u32 start, u32 count);
int aie_resource_clear(struct aie_resource *res, u32 start, u32 count);
+int aie_resource_clear_all(struct aie_resource *res);
bool aie_resource_testbit(struct aie_resource *res, u32 bit);
int aie_part_pm_ops_create(struct aie_partition *apart);
void aie_part_pm_ops_destroy(struct aie_partition *apart);
int aie_part_pm_ops_flush(struct aie_partition *apart);
int aie_part_pm_ops(struct aie_partition *apart, void *data, u32 type,
struct aie_range range, bool flush);
+int aie_part_maskpoll_register(struct aie_partition *apart, u32 offset, u32 data,
+ u32 mask, u32 timeout);
#endif /* AIE_INTERNAL_H */
diff --git a/drivers/accel/amd-ai-engine/ai-engine-part.c b/drivers/accel/amd-ai-engine/ai-engine-part.c
index 35451d1ed88a..2cd93c02246e 100644
--- a/drivers/accel/amd-ai-engine/ai-engine-part.c
+++ b/drivers/accel/amd-ai-engine/ai-engine-part.c
@@ -6,6 +6,7 @@
*/
#include <linux/amd-ai-engine.h>
+#include <linux/delay.h>
#include <linux/device.h>
#include <linux/list.h>
#include <linux/mutex.h>
@@ -106,3 +107,34 @@ struct aie_partition *aie_part_create(struct aie_device *adev,
device_unregister(&apart->dev);
return ERR_PTR(ret);
}
+
+/**
+ * aie_part_maskpoll_register() - Mask polls an address for a data in a partition.
+ * @apart: AI engine partition.
+ * @offset: AI engine register offset.
+ * @data: data to poll.
+ * @mask: if it is non 0, it is mask read.
+ * @timeout: Timeout in microseconds.
+ *
+ * Return: zero for success, or -EBUSY for failure
+ */
+int aie_part_maskpoll_register(struct aie_partition *apart, u32 offset, u32 data,
+ u32 mask, u32 timeout)
+{
+ u32 usleep_time = 10;
+ u32 value;
+ u32 i;
+
+ for (i = 0; i < timeout; i += usleep_time) {
+ value = readl(apart->adev->base + offset);
+ if ((value & mask) == data)
+ return 0;
+ usleep_range(usleep_time, usleep_time + 10);
+ }
+
+ value = readl(apart->adev->base + offset);
+ if ((value & mask) == data)
+ return 0;
+
+ return -EBUSY;
+}
diff --git a/drivers/accel/amd-ai-engine/ai-engine-res.c b/drivers/accel/amd-ai-engine/ai-engine-res.c
index 45b9447d896f..d35c27141cdd 100644
--- a/drivers/accel/amd-ai-engine/ai-engine-res.c
+++ b/drivers/accel/amd-ai-engine/ai-engine-res.c
@@ -151,6 +151,22 @@ int aie_resource_clear(struct aie_resource *res, u32 start, u32 count)
return 0;
}
+/**
+ * aie_resource_clear_all() - clear all the AI engine resource bits
+ * @res: pointer to AI engine resource
+ * @return: 0 for success and negative value for failure
+ *
+ * This function clears all the bits in the resource.
+ */
+int aie_resource_clear_all(struct aie_resource *res)
+{
+ if (!res || !res->bitmap)
+ return -EINVAL;
+
+ bitmap_clear(res->bitmap, 0, res->total);
+ return 0;
+}
+
/**
* aie_resource_testbit() - test if a bit is set in a AI engine resource
* @res: pointer to AI engine resource
diff --git a/drivers/accel/amd-ai-engine/ai-engine-reset.c b/drivers/accel/amd-ai-engine/ai-engine-reset.c
new file mode 100644
index 000000000000..f34d8d687d0e
--- /dev/null
+++ b/drivers/accel/amd-ai-engine/ai-engine-reset.c
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * AMD AI Engine device driver reset implementation
+ *
+ * Copyright (C) 2025 Advanced Micro Devices, Inc.
+ */
+
+#include <linux/amd-ai-engine.h>
+#include <linux/firmware/xlnx-zynqmp.h>
+#include <linux/io.h>
+#include <linux/mutex.h>
+
+#include "ai-engine-internal.h"
+
+/**
+ * aie_partition_initialize() - AI engine partition initialization
+ * @dev: AI engine partition device
+ * @args: User initialization options
+ *
+ * Return: 0 for success and negative value for failure
+ *
+ * Based on user passed options this function will:
+ * - enable column and shim reset
+ * - ungate all columns
+ * - disable column reset
+ * - zeroize memories
+ * - setup NMU traffic and hardware error reporting
+ */
+int aie_partition_initialize(struct device *dev,
+ struct aie_partition_init_args *args)
+{
+ struct aie_partition *apart;
+
+ if (!dev || !args)
+ return -EINVAL;
+
+ apart = dev_to_aiepart(dev);
+ if (apart->adev->ops->part_init)
+ return apart->adev->ops->part_init(apart, args);
+
+ return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(aie_partition_initialize);
+
+/**
+ * aie_partition_teardown() - AI engine partition teardown
+ * @dev: AI engine partition device
+ *
+ * Return: 0 for success and negative value for failure
+ *
+ * This function will:
+ * - reset columns and shim
+ * - zeroize memories
+ * - gate all columns
+ */
+int aie_partition_teardown(struct device *dev)
+{
+ struct aie_partition *apart;
+
+ if (!dev)
+ return -EINVAL;
+
+ apart = dev_to_aiepart(dev);
+ if (apart->adev->ops->part_teardown)
+ return apart->adev->ops->part_teardown(apart);
+
+ return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(aie_partition_teardown);
diff --git a/include/linux/amd-ai-engine.h b/include/linux/amd-ai-engine.h
index 229434372fc0..95884b782742 100644
--- a/include/linux/amd-ai-engine.h
+++ b/include/linux/amd-ai-engine.h
@@ -94,6 +94,22 @@ struct aie_op_handshake_data {
struct aie_location loc;
};
+/*
+ * struct aie_partition_init_args - AIE partition initialization arguments
+ * @locs: Allocated array of tile locations that will be used
+ * @num_tiles: Number of tiles to use
+ * @init_opts: Partition initialization options
+ * @ecc_scrub: ecc_scrub period.
+ */
+struct aie_partition_init_args {
+ struct aie_location *locs;
+ u32 num_tiles;
+ u32 init_opts;
+ u32 ecc_scrub;
+};
+
struct device *aie_partition_request(struct device *dev, struct aie_partition_req *req);
void aie_partition_release(struct device *dev);
+int aie_partition_initialize(struct device *dev, struct aie_partition_init_args *args);
+int aie_partition_teardown(struct device *dev);
#endif
--
2.34.1
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support)
2026-11-18 23:31 [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Gregory Williams
` (14 preceding siblings ...)
2026-11-18 23:32 ` [PATCH 15/15] accel/amd-ai-engine: Add reset operations Gregory Williams
@ 2026-11-19 8:19 ` Jerome Brunet
15 siblings, 0 replies; 17+ messages in thread
From: Jerome Brunet @ 2026-11-19 8:19 UTC (permalink / raw)
To: Gregory Williams
Cc: Stephen Boyd, Brian Masney, Jerome Brunet, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Michal Simek, Oded Gabbay,
kishore Manne, Izhar Ameer Shaikh, Greg Kroah-Hartman,
Jay Buddhabhatti, Ronak Jain, linux-clk, devicetree,
linux-kernel, linux-arm-kernel, dri-devel
On mer. 18 nov. 2026 at 15:31, Gregory Williams <gregory.williams@amd.com> wrote:
> This series adds a driver for the AMD AI Engine (AIE) found on Versal
> devices, together with the firmware changes the driver depends on. AI Engine
> is a tile array based accelerator used for applications such as beamforming and
> machine learning inference. Tiles are organised in columns, and groups of
> columns form partitions that an application requests, initialises and releases.
>
> Several registers in the AI Engine array (column and shim resets, memory
> zeroisation, tile clock gating, NoC and interrupt routing) are privileged
> and can only be written by the trusted firmware. The driver therefore
> packs operations into a DMA buffer and hands it to the platform firmware,
> which executes them in order.
>
> Firmware patches included
> -------------------------
> Patches 1-10 are not part of the AI Engine driver itself, but the driver
> cannot work without them, so they are included here to keep the series
> self-contained and reviewable in one place:
>
> - 1-5: zynqmp firmware driver refactoring and a va_start()/va_end()
> fix (patch 2 carries Fixes: tags), preparing for the extended
> SMCCC call format.
> - 6-7: Versal Gen 2 compatible string and firmware support, where all
> EEMI APIs use the extended SMCCC payload.
> - 8-9: Versal Gen 2 clock binding and clk driver match entry.
> - 10: firmware IOCTL support for the Versal Gen 2 AIE run time
> operations, used by the driver.
>
> I am happy to split out or reorder the firmware and clock patches if the
> maintainers prefer to take them through their own trees, and would
> appreciate guidance on how the series should be merged.
For the clock, it would defenitely be prefered if you could split out
clock part, especially if you later need an immutable branch.
`b4` makes it very easy to handle series deps, please consider using the
related tags
https://b4.docs.kernel.org/en/latest/contributor/prep.html#working-with-series-dependencies
>
> AI Engine driver
> ----------------
> - 11: devicetree binding for the AI Engine.
> - 12: driver core: device probe, partition request and release.
> - 13: pm ops: building and sending firmware operation packets.
> - 14: enabling and disabling tile clocks.
> - 15: partition initialize and teardown (reset operations).
>
> Previous submission
> -------------------
> This driver was posted for review a little over a year ago:
>
> https://lore.kernel.org/dri-devel/20250702155630.1737227-1-gregory.williams@amd.com/
>
> Since then the scope of what is proposed for upstream has changed, this series
> is considerably different from that posting, in particular targeting only Versal
> Gen 2 support. All comments received on the earlier posting have been addressed
> or in this version.
>
> Abhyuday Godhasara (1):
> drivers: firmware: xilinx: Add IOCTL support for the AIE run time
> operations
>
> Gregory Williams (5):
> dt-bindings: soc: xilinx: Add Versal AI Engine DT binding
> accel/amd-ai-engine: Add AMD AI Engine device driver
> accel/amd-ai-engine: Add pm ops for firmware calls
> accel/amd-ai-engine: Add support to enable/disable tile clocks
> accel/amd-ai-engine: Add reset operations
>
> Naman Trivedi (1):
> dt-bindings: clock: versal: add Versal Gen 2 compatible string
>
> Senthil Nathan Thangaraj (8):
> firmware: xilinx: Separate TF-A checking
> firmware: xilinx: Call va_start after pm feature check
> firmware: xilinx: Add comments about number of arguments
> firmware: xilinx: Use match data for ZynqMP/Versal
> firmware: xilinx: Rename zynqmp_pm_invoke_fw_fn()
> dt-bindings: firmware: xilinx: Add Versal Gen 2 compatible string
> firmware: xilinx: Add support for Versal Gen 2
> clk: zynqmp: Add Versal Gen 2 compatible string
>
> .../bindings/clock/xlnx,versal-clk.yaml | 5 +-
> .../firmware/xilinx/xlnx,zynqmp-firmware.yaml | 3 +
> .../bindings/soc/xilinx/xlnx,ai-engine.yaml | 61 +++
> MAINTAINERS | 9 +
> drivers/accel/Kconfig | 1 +
> drivers/accel/Makefile | 3 +-
> drivers/accel/amd-ai-engine/Kconfig | 15 +
> drivers/accel/amd-ai-engine/Makefile | 14 +
> .../accel/amd-ai-engine/ai-engine-aiemlv2.c | 441 ++++++++++++++++
> drivers/accel/amd-ai-engine/ai-engine-clock.c | 154 ++++++
> drivers/accel/amd-ai-engine/ai-engine-dev.c | 255 ++++++++++
> .../accel/amd-ai-engine/ai-engine-internal.h | 377 ++++++++++++++
> drivers/accel/amd-ai-engine/ai-engine-part.c | 140 ++++++
> drivers/accel/amd-ai-engine/ai-engine-pm.c | 472 ++++++++++++++++++
> drivers/accel/amd-ai-engine/ai-engine-res.c | 184 +++++++
> drivers/accel/amd-ai-engine/ai-engine-reset.c | 69 +++
> drivers/clk/zynqmp/clkc.c | 1 +
> drivers/firmware/xilinx/zynqmp.c | 340 +++++++++++--
> include/linux/amd-ai-engine.h | 115 +++++
> include/linux/firmware/xlnx-zynqmp.h | 65 ++-
> 20 files changed, 2679 insertions(+), 45 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/soc/xilinx/xlnx,ai-engine.yaml
> create mode 100644 drivers/accel/amd-ai-engine/Kconfig
> create mode 100644 drivers/accel/amd-ai-engine/Makefile
> create mode 100644 drivers/accel/amd-ai-engine/ai-engine-aiemlv2.c
> create mode 100644 drivers/accel/amd-ai-engine/ai-engine-clock.c
> create mode 100644 drivers/accel/amd-ai-engine/ai-engine-dev.c
> create mode 100644 drivers/accel/amd-ai-engine/ai-engine-internal.h
> create mode 100644 drivers/accel/amd-ai-engine/ai-engine-part.c
> create mode 100644 drivers/accel/amd-ai-engine/ai-engine-pm.c
> create mode 100644 drivers/accel/amd-ai-engine/ai-engine-res.c
> create mode 100644 drivers/accel/amd-ai-engine/ai-engine-reset.c
> create mode 100644 include/linux/amd-ai-engine.h
>
> --
> 2.34.1
>
--
Jerome
^ permalink raw reply [flat|nested] 17+ messages in thread