[PATCH 4/5] drivers: firmware: xilinx: Localize firmware version caches

Jay Buddhabhatti jay.buddhabhatti at amd.com
Fri Nov 27 03:48:38 PST 2026


Keep the PM API version cache local to its getter and populate it after
a successful query. The firmware probe now keeps the returned version in
a local variable instead of passing the address of a file-wide cache.

The firmware probe is the only caller of
zynqmp_pm_get_trustzone_version(). Remove the unnecessary trustzone
version cache and keep the returned version local to the probe.

Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti at amd.com>
---
 drivers/firmware/xilinx/zynqmp.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 619ead2069c5..374d39f34480 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -488,9 +488,6 @@ 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]);
 }
 
-static u32 pm_api_version;
-static u32 pm_tz_version;
-
 int zynqmp_pm_register_sgi(u32 sgi_num, u32 reset)
 {
 	int ret;
@@ -512,6 +509,7 @@ int zynqmp_pm_register_sgi(u32 sgi_num, u32 reset)
 int zynqmp_pm_get_api_version(u32 *version)
 {
 	u32 ret_payload[PAYLOAD_ARG_CNT];
+	static u32 pm_api_version;
 	int ret;
 
 	if (!version)
@@ -524,6 +522,8 @@ int zynqmp_pm_get_api_version(u32 *version)
 	}
 	ret = zynqmp_pm_invoke_fn(PM_GET_API_VERSION, ret_payload, 0);
 	*version = ret_payload[1];
+	if (!ret)
+		pm_api_version = ret_payload[1];
 
 	return ret;
 }
@@ -616,11 +616,6 @@ static int zynqmp_pm_get_trustzone_version(u32 *version)
 	if (!version)
 		return -EINVAL;
 
-	/* Check is PM trustzone version already verified */
-	if (pm_tz_version > 0) {
-		*version = pm_tz_version;
-		return 0;
-	}
 	ret = zynqmp_pm_invoke_fn(PM_GET_TRUSTZONE_VERSION, ret_payload, 0);
 	*version = ret_payload[1];
 
@@ -2178,9 +2173,9 @@ static int zynqmp_clear_pm_state(struct device *dev)
 
 static int zynqmp_firmware_probe(struct platform_device *pdev)
 {
+	u32 pm_api_version, pm_family_code, pm_tz_version;
 	struct device *dev = &pdev->dev;
 	struct zynqmp_devinfo *devinfo;
-	u32 pm_family_code;
 	int ret;
 
 	ret = get_set_conduit_method(dev->of_node);
-- 
2.43.0




More information about the linux-arm-kernel mailing list