* [PATCH 1/6] firmware: xilinx: Use late_initcall for pm_init_finalize
2026-11-19 13:17 [PATCH 0/6] firmware: xilinx: cleanups and debugfs fixes Michal Simek
@ 2026-11-19 13:17 ` Michal Simek
2026-11-19 13:17 ` [PATCH 2/6] firmware: xilinx: Call va_start after pm feature check Michal Simek
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Michal Simek @ 2026-11-19 13:17 UTC (permalink / raw)
To: linux-kernel, monstr, michal.simek, git
Cc: Ulf Hansson, moderated list:ARM/ZYNQ ARCHITECTURE
The current implementation uses the driver sync_state callback to call
zynqmp_pm_init_finalize(). This callback only fires when all consumers
of the firmware node have probed their drivers. If any consumer device
has its driver disabled or built as a never-loaded module, sync_state
never fires and pm_init_finalize is never called.
This causes PMUFW to remain in UNINITIALIZED state, leading to IPI
deadlock during CPU idle on ZynqMP platforms.
Replace sync_state with late_initcall to guarantee pm_init_finalize is
called. By late_initcall time, all built-in drivers including the
console UART have probed and requested their power domains, avoiding
any race with early console.
Removing of_genpd_sync_state() from the firmware driver is safe
because the genpd framework automatically sets up its own sync_state
handler on the firmware driver via dev_set_drv_sync_state() when the
PM domain driver registers with of_genpd_add_provider_onecell().
Power domain cleanup continues to work independently without the
firmware driver explicitly calling of_genpd_sync_state().
Fixes: 3da405ead651 ("firmware/pmdomain: xilinx: Move ->sync_state() support to firmware driver")
Signed-off-by: Ronak Jain <ronak.jain@amd.com>
Signed-off-by: Michal Simek <michal.simek@amd.com>
---
drivers/firmware/xilinx/zynqmp.c | 41 ++++++++++++++++++++------------
1 file changed, 26 insertions(+), 15 deletions(-)
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index d76660c55354..22ee6ccdb02c 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -21,7 +21,6 @@
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
-#include <linux/pm_domain.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/hashtable.h>
@@ -2370,19 +2369,6 @@ static void zynqmp_firmware_remove(struct platform_device *pdev)
platform_device_unregister(em_dev);
}
-static void zynqmp_firmware_sync_state(struct device *dev)
-{
- struct device_node *np = dev->of_node;
-
- if (!of_device_is_compatible(np, "xlnx,zynqmp-firmware"))
- return;
-
- of_genpd_sync_state(np);
-
- if (zynqmp_pm_init_finalize())
- dev_warn(dev, "failed to release power management to firmware\n");
-}
-
static const struct platform_fw_data platform_fw_data_versal = {
.family_code = PM_VERSAL_FAMILY_CODE,
};
@@ -2408,10 +2394,35 @@ static struct platform_driver zynqmp_firmware_driver = {
.name = "zynqmp_firmware",
.of_match_table = zynqmp_firmware_of_match,
.dev_groups = zynqmp_firmware_groups,
- .sync_state = zynqmp_firmware_sync_state,
},
.probe = zynqmp_firmware_probe,
.remove = zynqmp_firmware_remove,
.shutdown = zynqmp_firmware_shutdown,
};
module_platform_driver(zynqmp_firmware_driver);
+
+/*
+ * pm_init_finalize was previously called from the firmware driver's
+ * sync_state callback, but sync_state can be blocked indefinitely if
+ * any device consumer never probes. Use late_initcall to ensure
+ * pm_init_finalize is called reliably regardless of consumer
+ * probe status.
+ */
+static int __init zynqmp_pm_init_finalize_late(void)
+{
+ u32 pm_family_code;
+ int ret;
+
+ ret = zynqmp_pm_get_family_info(&pm_family_code);
+ if (ret)
+ return ret;
+
+ if (pm_family_code != PM_ZYNQMP_FAMILY_CODE)
+ return 0;
+
+ if (zynqmp_pm_init_finalize())
+ pr_warn("zynqmp: failed to release power management to firmware\n");
+
+ return 0;
+}
+late_initcall(zynqmp_pm_init_finalize_late);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/6] firmware: xilinx: Call va_start after pm feature check
2026-11-19 13:17 [PATCH 0/6] firmware: xilinx: cleanups and debugfs fixes Michal Simek
2026-11-19 13:17 ` [PATCH 1/6] firmware: xilinx: Use late_initcall for pm_init_finalize Michal Simek
@ 2026-11-19 13:17 ` Michal Simek
2026-11-19 13:17 ` [PATCH 3/6] firmware: xilinx: Add comments about number of arguments Michal Simek
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Michal Simek @ 2026-11-19 13:17 UTC (permalink / raw)
To: linux-kernel, monstr, michal.simek, git
Cc: Senthil Nathan Thangaraj, moderated list:ARM/ZYNQ ARCHITECTURE
There is no reason to start to process va_list before calling pm feature
check which can still fail. Call it at a time when list can be process.
Co-developed-by: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
Signed-off-by: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
Signed-off-by: Michal Simek <michal.simek@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 22ee6ccdb02c..a0ec904b1819 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -391,13 +391,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);
@@ -454,13 +454,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.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 3/6] firmware: xilinx: Add comments about number of arguments
2026-11-19 13:17 [PATCH 0/6] firmware: xilinx: cleanups and debugfs fixes Michal Simek
2026-11-19 13:17 ` [PATCH 1/6] firmware: xilinx: Use late_initcall for pm_init_finalize Michal Simek
2026-11-19 13:17 ` [PATCH 2/6] firmware: xilinx: Call va_start after pm feature check Michal Simek
@ 2026-11-19 13:17 ` Michal Simek
2026-11-19 13:17 ` [PATCH 4/6] firmware: xilinx: Call pm sysfs out of dev_groups Michal Simek
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Michal Simek @ 2026-11-19 13:17 UTC (permalink / raw)
To: linux-kernel, monstr, michal.simek, git
Cc: Senthil Nathan Thangaraj, moderated list:ARM/ZYNQ ARCHITECTURE
The driver is checking number of arguments where it is not exactly clear
what that values are reflecting that's why introduce SMC_ARG_CNT_BASIC_32
macro and add comment to the code.
Co-developed-by: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
Signed-off-by: Senthil Nathan Thangaraj <senthilnathan.thangaraj@amd.com>
Signed-off-by: Michal Simek <michal.simek@amd.com>
---
drivers/firmware/xilinx/zynqmp.c | 18 ++++++++++++++++--
include/linux/firmware/xlnx-zynqmp.h | 3 +++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index a0ec904b1819..597393d5ea69 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -388,6 +388,13 @@ 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;
+ /*
+ * According to the SMCCC: The total number of registers available for
+ * arguments is 16.
+ *
+ * In the Extended SMC format, 3 registers are used for headers, leaving
+ * up to 13 registers for arguments.
+ */
if (num_args > SMC_ARG_CNT_32)
return -EINVAL;
@@ -449,9 +456,16 @@ int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 *ret_payload, u32 num_args, ...)
u64 smc_arg[8];
int ret, i;
va_list arg_list;
- u32 args[14] = {0};
+ u32 args[SMC_ARG_CNT_BASIC_32] = {0};
- if (num_args > 14)
+ /*
+ * According to the SMCCC: The total number of registers available for
+ * arguments is 16.
+ *
+ * In the Basic SMC format, 2 registers are used for headers, leaving
+ * up to 14 registers 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..b489fbd21bd2 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -82,6 +82,9 @@
/* Number of 32bits arguments for SMC call */
#define SMC_ARG_CNT_32 13U
+/* Number of 32bits arguments for Basic SMC call */
+#define SMC_ARG_CNT_BASIC_32 14U
+
/* Number of arguments for a callback */
#define CB_ARG_CNT 4
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 4/6] firmware: xilinx: Call pm sysfs out of dev_groups
2026-11-19 13:17 [PATCH 0/6] firmware: xilinx: cleanups and debugfs fixes Michal Simek
` (2 preceding siblings ...)
2026-11-19 13:17 ` [PATCH 3/6] firmware: xilinx: Add comments about number of arguments Michal Simek
@ 2026-11-19 13:17 ` Michal Simek
2026-11-19 13:17 ` [PATCH 5/6] firmware: xilinx: Change debugfs pm_api_ret size to PAYLOAD_ARG_CNT Michal Simek
2026-11-19 13:17 ` [PATCH 6/6] firmware: xilinx: Bound debugfs clock name formatting Michal Simek
5 siblings, 0 replies; 7+ messages in thread
From: Michal Simek @ 2026-11-19 13:17 UTC (permalink / raw)
To: linux-kernel, monstr, michal.simek, git
Cc: moderated list:ARM/ZYNQ ARCHITECTURE
PM (Power Management) functionality is only one part of firmware interface
that's why move sysfs registration to own function and call it separately
as preparation for spliting functionality based on service type.
Signed-off-by: Michal Simek <michal.simek@amd.com>
---
drivers/firmware/xilinx/zynqmp.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 597393d5ea69..43db81af678c 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -2189,7 +2189,7 @@ static ssize_t feature_config_value_store(struct device *device,
static DEVICE_ATTR_RW(feature_config_value);
-static struct attribute *zynqmp_firmware_attrs[] = {
+static const struct attribute *zynqmp_firmware_attrs[] = {
&dev_attr_ggs0.attr,
&dev_attr_ggs1.attr,
&dev_attr_ggs2.attr,
@@ -2205,7 +2205,18 @@ static struct attribute *zynqmp_firmware_attrs[] = {
NULL,
};
-ATTRIBUTE_GROUPS(zynqmp_firmware);
+static int zynqmp_firmware_pm_sysfs_entry(struct platform_device *pdev)
+{
+ int ret;
+
+ ret = sysfs_create_files(&pdev->dev.kobj, zynqmp_firmware_attrs);
+ if (ret) {
+ pr_err("%s() Failed to create PM firmware attrs, err=%d\n",
+ __func__, ret);
+ }
+
+ return ret;
+}
/**
* zynqmp_clear_pm_state() - Clear subsystem state
@@ -2349,6 +2360,13 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
return ret;
}
+ ret = zynqmp_firmware_pm_sysfs_entry(pdev);
+ if (ret) {
+ pr_err("%s() Failed to create sysfs file with error%d\n",
+ __func__, ret);
+ return ret;
+ }
+
zynqmp_pm_api_debugfs_init();
if (pm_family_code != PM_ZYNQMP_FAMILY_CODE) {
@@ -2407,7 +2425,6 @@ static struct platform_driver zynqmp_firmware_driver = {
.driver = {
.name = "zynqmp_firmware",
.of_match_table = zynqmp_firmware_of_match,
- .dev_groups = zynqmp_firmware_groups,
},
.probe = zynqmp_firmware_probe,
.remove = zynqmp_firmware_remove,
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 5/6] firmware: xilinx: Change debugfs pm_api_ret size to PAYLOAD_ARG_CNT
2026-11-19 13:17 [PATCH 0/6] firmware: xilinx: cleanups and debugfs fixes Michal Simek
` (3 preceding siblings ...)
2026-11-19 13:17 ` [PATCH 4/6] firmware: xilinx: Call pm sysfs out of dev_groups Michal Simek
@ 2026-11-19 13:17 ` Michal Simek
2026-11-19 13:17 ` [PATCH 6/6] firmware: xilinx: Bound debugfs clock name formatting Michal Simek
5 siblings, 0 replies; 7+ messages in thread
From: Michal Simek @ 2026-11-19 13:17 UTC (permalink / raw)
To: linux-kernel, monstr, michal.simek, git
Cc: Jay Buddhabhatti, moderated list:ARM/ZYNQ ARCHITECTURE
From: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
The debugfs PM API handler declared u32 pm_api_ret[4] but passes it as
the ret_payload buffer to zynqmp_pm_invoke_fn() and zynqmp_pm_query_data(),
which unconditionally write PAYLOAD_ARG_CNT (7) u32 values via the SMC/HVC
transport. Size the array to match the firmware call contract.
Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
Signed-off-by: Michal Simek <michal.simek@amd.com>
---
drivers/firmware/xilinx/zynqmp-debug.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/firmware/xilinx/zynqmp-debug.c b/drivers/firmware/xilinx/zynqmp-debug.c
index 36efb827f3da..f7751912d80a 100644
--- a/drivers/firmware/xilinx/zynqmp-debug.c
+++ b/drivers/firmware/xilinx/zynqmp-debug.c
@@ -325,7 +325,7 @@ static ssize_t zynqmp_pm_debugfs_api_write(struct file *file,
u32 pm_id = 0;
u64 pm_api_arg[5] = {0, 0, 0, 0, 0};
/* Return values from PM APIs calls */
- u32 pm_api_ret[4] = {0, 0, 0, 0};
+ u32 pm_api_ret[PAYLOAD_ARG_CNT] = {0};
int ret;
int i = 0;
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 6/6] firmware: xilinx: Bound debugfs clock name formatting
2026-11-19 13:17 [PATCH 0/6] firmware: xilinx: cleanups and debugfs fixes Michal Simek
` (4 preceding siblings ...)
2026-11-19 13:17 ` [PATCH 5/6] firmware: xilinx: Change debugfs pm_api_ret size to PAYLOAD_ARG_CNT Michal Simek
@ 2026-11-19 13:17 ` Michal Simek
5 siblings, 0 replies; 7+ messages in thread
From: Michal Simek @ 2026-11-19 13:17 UTC (permalink / raw)
To: linux-kernel, monstr, michal.simek, git
Cc: Jay Buddhabhatti, Jolly Shah, Rajan Vaja,
moderated list:ARM/ZYNQ ARCHITECTURE
From: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
PM_QID_CLOCK_GET_NAME returns up to 16 name bytes with no guaranteed NUL
terminator. Copy the response into a bounded local buffer before formatting
to prevent kernel stack data from leaking via debugfs.
Fixes: e60f02ddb4d2 ("firmware: xilinx: Add debugfs for query data API")
Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
Signed-off-by: Michal Simek <michal.simek@amd.com>
---
drivers/firmware/xilinx/zynqmp-debug.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/xilinx/zynqmp-debug.c b/drivers/firmware/xilinx/zynqmp-debug.c
index f7751912d80a..77b35a525b96 100644
--- a/drivers/firmware/xilinx/zynqmp-debug.c
+++ b/drivers/firmware/xilinx/zynqmp-debug.c
@@ -21,6 +21,7 @@
#include "zynqmp-debug.h"
#define PM_API_NAME_LEN 50
+#define CLK_GET_NAME_RESP_LEN 16
struct pm_api_info {
u32 api_id;
@@ -279,10 +280,14 @@ static int process_api_request(u32 pm_id, u64 *pm_api_arg, u32 *pm_api_ret)
break;
switch (qdata.qid) {
- case PM_QID_CLOCK_GET_NAME:
- sprintf(debugfs_buf, "Clock name = %s\n",
- (char *)pm_api_ret);
+ case PM_QID_CLOCK_GET_NAME: {
+ char name[CLK_GET_NAME_RESP_LEN + 1];
+
+ memcpy(name, pm_api_ret, CLK_GET_NAME_RESP_LEN);
+ name[CLK_GET_NAME_RESP_LEN] = '\0';
+ sprintf(debugfs_buf, "Clock name = %s\n", name);
break;
+ }
case PM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS:
sprintf(debugfs_buf, "Multiplier = %d, Divider = %d\n",
pm_api_ret[1], pm_api_ret[2]);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread