Skip to contentSkip to conversation

firmware: xilinx: Feature check improvements

PATCH Applied Jay Buddhabhatti 2 participants 4 messages Jul 24 – Aug 6 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

cover firmware: xilinx: Feature check improvements

This series contains two independent improvements to the feature check logic in the Xilinx firmware driver:

1. Use the TF-A dedicated PM_API_FEATURES mechanism to validate TF-A-specific APIs instead of routing them through PM_FEATURE_CHECK. Falls back to the legacy PM_FEATURE_CHECK for backward compatibility.

2. When do_fw_call() fails in the feature check path, propagate the actual errno from zynqmp_pm_ret_code() instead of always returning -EOPNOTSUPP.

These were previously part of the kexec cleanup series
([PATCH 0/4] firmware: xilinx: Clean up firmware and TF-A state on kexec) as patch 4/4 but are split out as they are general improvements independent of the kexec functionality.

Jay Buddhabhatti (2):
firmware: xilinx: Use TF-A feature check for TF-A-specific APIs
firmware: xilinx: Propagate actual error from feature check

 drivers/firmware/xilinx/zynqmp.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/2 firmware: xilinx: Use TF-A feature check for TF-A-specific APIs

Currently, TF-A-specific APIs are validated using the firmware PM_FEATURE_CHECK API, even though TF-A provides a dedicated mechanism via PM_API_FEATURES API. Update the feature check logic for TF-A-specific API calls to use PM_API_FEATURES. If this check fails, fall back to the legacy PM_FEATURE_CHECK to support backward compatibility.

---
 drivers/firmware/xilinx/zynqmp.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)
drivers/firmware/xilinx/zynqmp.c +15 -10
index fc7212f554ee..95f5941c5ca8 100644
@@ -224,28 +224,33 @@ static int __do_feature_check_call(const u32 api_id, u32 *ret_payload)
 	module_id = FIELD_GET(MODULE_ID_MASK, api_id);
 
 	/*
-	 * Feature check of APIs belonging to PM, XSEM, and TF-A are handled by calling
+	 * 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 || module_id == TF_A_MODULE_ID)
+	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;
 
-	/*
-	 * Feature check of TF-A APIs is done in the TF-A layer and it expects for
-	 * MODULE_ID_MASK bits of SMC's arg[0] to be the same as PM_MODULE_ID.
-	 */
-	if (module_id == TF_A_MODULE_ID) {
-		module_id = PM_MODULE_ID;
+	if (module_id == TF_A_MODULE_ID)
 		smc_arg[1] = api_id;
-	} else {
+	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;
 
 	ret = do_fw_call(ret_payload, 2, smc_arg[0], smc_arg[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]);
+	}
+
 	if (ret)
 		ret = -EOPNOTSUPP;
 	else
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/2 firmware: xilinx: Propagate actual error from feature check

In reply to Jay Buddhabhatti

When do_fw_call() fails in __do_feature_check_call(), propagate the actual errno from zynqmp_pm_ret_code() instead of always returning -EOPNOTSUPP. This gives callers more precise error information. Existing callers only test ret < 0 and are unchanged by this.

---
 drivers/firmware/xilinx/zynqmp.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/firmware/xilinx/zynqmp.c +2 -4
index 95f5941c5ca8..0b6c20a1d8be 100644
@@ -252,11 +252,9 @@ static int __do_feature_check_call(const u32 api_id, u32 *ret_payload)
 	}
 
 	if (ret)
-		ret = -EOPNOTSUPP;
-	else
-		ret = ret_payload[1];
+		return ret;
 
-	return ret;
+	return ret_payload[1];
 }
 
 static int do_feature_check_call(const u32 api_id)
Signature · 1 line
2.34.1
maintainer Applied
#3 lore raw
In reply to Jay Buddhabhatti
Quoted 17 lines · Jay Buddhabhatti

This series contains two independent improvements to the feature check logic in the Xilinx firmware driver:

1. Use the TF-A dedicated PM_API_FEATURES mechanism to validate TF-A-specific APIs instead of routing them through PM_FEATURE_CHECK. Falls back to the legacy PM_FEATURE_CHECK for backward compatibility.

2. When do_fw_call() fails in the feature check path, propagate the actual errno from zynqmp_pm_ret_code() instead of always returning -EOPNOTSUPP.

These were previously part of the kexec cleanup series
([PATCH 0/4] firmware: xilinx: Clean up firmware and TF-A state on kexec) as patch 4/4 but are split out as they are general improvements independent of the kexec functionality.

Quoted 7 lines

Jay Buddhabhatti (2):
firmware: xilinx: Use TF-A feature check for TF-A-specific APIs
firmware: xilinx: Propagate actual error from feature check

  drivers/firmware/xilinx/zynqmp.c | 31 +++++++++++++++++--------------
  1 file changed, 17 insertions(+), 14 deletions(-)

applied.
M