Skip to contentSkip to conversation

Add feature check support in ZU+

PATCH In review Ronak Jain 3 participants 10 messages Apr 6, 2022 – Apr 29, 2022 Arm/Zynq architecture

lore
Share & tools
lore

Ronak Jain

author
#0 lore raw

cover Add feature check support in ZU+

Add feature check PM API support for QUERY/IOCTL IDs to get individual ids version from the firmware/TF-A if supported and return an error code if the PM API or the QUERY/IOCTL IDs are not supported.

Enable feature check for each PM APIs before executing the functionality.

Ronak Jain (4):
firmware: xilinx: add support for IOCTL and QUERY ID feature check
firmware: xilinx: add new function for do_feature_check_call
firmware: xilinx: always check API version for IOCTL/QUERY
firmware: xilinx: enable feature check for ZynqMP

 drivers/firmware/xilinx/zynqmp.c     | 131 +++++++++++++++++++++++++++++------
 include/linux/firmware/xlnx-zynqmp.h |  11 +++
 2 files changed, 119 insertions(+), 23 deletions(-)
Signature · 7 lines
2.7.4


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#1 lore raw

PATCH 1/4 firmware: xilinx: add support for IOCTL and QUERY ID feature check

Add support to check if IOCTL ID or QUERY ID is supported in firmware or not.

---
 drivers/firmware/xilinx/zynqmp.c     | 62 +++++++++++++++++++++++++++++++++++-
 include/linux/firmware/xlnx-zynqmp.h | 11 +++++++
 2 files changed, 72 insertions(+), 1 deletion(-)
drivers/firmware/xilinx/zynqmp.c +61 -1
index f21ece56695e..41ca41697790 100644
@@ -36,8 +36,16 @@
 /* BOOT_PIN_CTRL_MASK- out_val[11:8], out_en[3:0] */
 #define CRL_APB_BOOTPIN_CTRL_MASK	0xF0FU
 
+/* IOCTL/QUERY feature payload size */
+#define FEATURE_PAYLOAD_SIZE		2
+
+/* Firmware feature check version mask */
+#define FIRMWARE_VERSION_MASK		GENMASK(15, 0)
+
 static bool feature_check_enabled;
 static DEFINE_HASHTABLE(pm_api_features_map, PM_API_FEATURE_CHECK_MAX_ORDER);
+static u32 ioctl_features[FEATURE_PAYLOAD_SIZE];
+static u32 query_features[FEATURE_PAYLOAD_SIZE];
 
 static struct platform_device *em_dev;
 
@@ -168,7 +176,8 @@ static noinline int do_fw_call_hvc(u64 arg0, u64 arg1, u64 arg2,
 }
 
 /**
- * zynqmp_pm_feature() - Check weather given feature is supported or not
+ * zynqmp_pm_feature() - Check whether given feature is supported or not and
+ *			 store supported IOCTL/QUERY ID mask
  * @api_id:		API ID to check
  *
  * Return: Returns status, either success or error+reason
@@ -208,11 +217,62 @@ int zynqmp_pm_feature(const u32 api_id)
 	feature_data->feature_status = ret;
 	hash_add(pm_api_features_map, &feature_data->hentry, api_id);
 
+	if (api_id == PM_IOCTL)
+		/* Store supported IOCTL IDs mask */
+		memcpy(ioctl_features, &ret_payload[2], FEATURE_PAYLOAD_SIZE * 4);
+	else if (api_id == PM_QUERY_DATA)
+		/* Store supported QUERY IDs mask */
+		memcpy(query_features, &ret_payload[2], FEATURE_PAYLOAD_SIZE * 4);
+
 	return ret;
 }
 EXPORT_SYMBOL_GPL(zynqmp_pm_feature);
 
 /**
+ * zynqmp_pm_is_function_supported() - Check whether given IOCTL/QUERY function
+ *				       is supported or not
+ * @api_id:		PM_IOCTL or PM_QUERY_DATA
+ * @id:			IOCTL or QUERY function IDs
+ *
+ * Return: Returns status, either success or error+reason
+ */
+int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id)
+{
+	int ret;
+	u32 *bit_mask;
+
+	/* Input arguments validation */
+	if (id >= 64 || (api_id != PM_IOCTL && api_id != PM_QUERY_DATA))
+		return -EINVAL;
+
+	/* Check feature check API version */
+	ret = zynqmp_pm_feature(PM_FEATURE_CHECK);
+	if (ret < 0)
+		return ret;
+
+	/* Check if feature check version 2 is supported or not */
+	if ((ret & FIRMWARE_VERSION_MASK) == PM_API_VERSION_2) {
+		/*
+		 * Call feature check for IOCTL/QUERY API to get IOCTL ID or
+		 * QUERY ID feature status.
+		 */
+		ret = zynqmp_pm_feature(api_id);
+		if (ret < 0)
+			return ret;
+
+		bit_mask = (api_id == PM_IOCTL) ? ioctl_features : query_features;
+
+		if ((bit_mask[(id / 32)] & BIT((id % 32))) == 0U)
+			return -EOPNOTSUPP;
+	} else {
+		return -ENODATA;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_is_function_supported);
+
+/**
  * zynqmp_pm_invoke_fn() - Invoke the system-level platform management layer
  *			   caller function depending on the configuration
  * @pm_api_id:		Requested PM-API call
include/linux/firmware/xlnx-zynqmp.h +11 -0
index 14f00a7672d1..1ec73d5352c3 100644
@@ -29,6 +29,11 @@
 
 /* SMC SIP service Call Function Identifier Prefix */
 #define PM_SIP_SVC			0xC2000000
+
+/* PM API versions */
+#define PM_API_VERSION_2	2
+
+/* ATF only commands */
 #define PM_GET_TRUSTZONE_VERSION	0xa03
 #define PM_SET_SUSPEND_MODE		0xa02
 #define GET_CALLBACK_DATA		0xa01
@@ -460,6 +465,7 @@ int zynqmp_pm_load_pdi(const u32 src, const u64 address);
 int zynqmp_pm_register_notifier(const u32 node, const u32 event,
 				const u32 wake, const u32 enable);
 int zynqmp_pm_feature(const u32 api_id);
+int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id);
 int zynqmp_pm_set_feature_config(enum pm_feature_config_id id, u32 value);
 int zynqmp_pm_get_feature_config(enum pm_feature_config_id id, u32 *payload);
 #else
@@ -678,6 +684,11 @@ static inline int zynqmp_pm_pinctrl_get_function(const u32 pin, u32 *id)
 	return -ENODEV;
 }
 
+static inline int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id)
+{
+	return -ENODEV;
+}
+
 static inline int zynqmp_pm_pinctrl_set_function(const u32 pin, const u32 id)
 {
 	return -ENODEV;
Signature · 7 lines
2.7.4


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Acked-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] firmware: xilinx: add support for IOCTL and QUERY ID feature check

Quoted 129 lines · Ronak Jain

Add support to check if IOCTL ID or QUERY ID is supported in firmware or not.

---
  drivers/firmware/xilinx/zynqmp.c     | 62 +++++++++++++++++++++++++++++++++++-
  include/linux/firmware/xlnx-zynqmp.h | 11 +++++++
  2 files changed, 72 insertions(+), 1 deletion(-)
drivers/firmware/xilinx/zynqmp.c +61 -1
index f21ece56695e..41ca41697790 100644
@@ -36,8 +36,16 @@
  /* BOOT_PIN_CTRL_MASK- out_val[11:8], out_en[3:0] */
  #define CRL_APB_BOOTPIN_CTRL_MASK	0xF0FU
 
+/* IOCTL/QUERY feature payload size */
+#define FEATURE_PAYLOAD_SIZE		2
+
+/* Firmware feature check version mask */
+#define FIRMWARE_VERSION_MASK		GENMASK(15, 0)
+
  static bool feature_check_enabled;
  static DEFINE_HASHTABLE(pm_api_features_map, PM_API_FEATURE_CHECK_MAX_ORDER);
+static u32 ioctl_features[FEATURE_PAYLOAD_SIZE];
+static u32 query_features[FEATURE_PAYLOAD_SIZE];
 
  static struct platform_device *em_dev;
 
@@ -168,7 +176,8 @@ static noinline int do_fw_call_hvc(u64 arg0, u64 arg1, u64 arg2,
  }
 
  /**
- * zynqmp_pm_feature() - Check weather given feature is supported or not
+ * zynqmp_pm_feature() - Check whether given feature is supported or not and
+ *			 store supported IOCTL/QUERY ID mask
   * @api_id:		API ID to check
   *
   * Return: Returns status, either success or error+reason
@@ -208,11 +217,62 @@ int zynqmp_pm_feature(const u32 api_id)
  	feature_data->feature_status = ret;
  	hash_add(pm_api_features_map, &feature_data->hentry, api_id);
 
+	if (api_id == PM_IOCTL)
+		/* Store supported IOCTL IDs mask */
+		memcpy(ioctl_features, &ret_payload[2], FEATURE_PAYLOAD_SIZE * 4);
+	else if (api_id == PM_QUERY_DATA)
+		/* Store supported QUERY IDs mask */
+		memcpy(query_features, &ret_payload[2], FEATURE_PAYLOAD_SIZE * 4);
+
  	return ret;
  }
  EXPORT_SYMBOL_GPL(zynqmp_pm_feature);
 
  /**
+ * zynqmp_pm_is_function_supported() - Check whether given IOCTL/QUERY function
+ *				       is supported or not
+ * @api_id:		PM_IOCTL or PM_QUERY_DATA
+ * @id:			IOCTL or QUERY function IDs
+ *
+ * Return: Returns status, either success or error+reason
+ */
+int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id)
+{
+	int ret;
+	u32 *bit_mask;
+
+	/* Input arguments validation */
+	if (id >= 64 || (api_id != PM_IOCTL && api_id != PM_QUERY_DATA))
+		return -EINVAL;
+
+	/* Check feature check API version */
+	ret = zynqmp_pm_feature(PM_FEATURE_CHECK);
+	if (ret < 0)
+		return ret;
+
+	/* Check if feature check version 2 is supported or not */
+	if ((ret & FIRMWARE_VERSION_MASK) == PM_API_VERSION_2) {
+		/*
+		 * Call feature check for IOCTL/QUERY API to get IOCTL ID or
+		 * QUERY ID feature status.
+		 */
+		ret = zynqmp_pm_feature(api_id);
+		if (ret < 0)
+			return ret;
+
+		bit_mask = (api_id == PM_IOCTL) ? ioctl_features : query_features;
+
+		if ((bit_mask[(id / 32)] & BIT((id % 32))) == 0U)
+			return -EOPNOTSUPP;
+	} else {
+		return -ENODATA;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(zynqmp_pm_is_function_supported);
+
+/**
   * zynqmp_pm_invoke_fn() - Invoke the system-level platform management layer
   *			   caller function depending on the configuration
   * @pm_api_id:		Requested PM-API call
include/linux/firmware/xlnx-zynqmp.h +6 -0
index 14f00a7672d1..1ec73d5352c3 100644
@@ -29,6 +29,11 @@
 
  /* SMC SIP service Call Function Identifier Prefix */
  #define PM_SIP_SVC			0xC2000000
+
+/* PM API versions */
+#define PM_API_VERSION_2	2
+
+/* ATF only commands */
  #define PM_GET_TRUSTZONE_VERSION	0xa03
  #define PM_SET_SUSPEND_MODE		0xa02
  #define GET_CALLBACK_DATA		0xa01
@@ -460,6 +465,7 @@ int zynqmp_pm_load_pdi(const u32 src, const u64 address);
  int zynqmp_pm_register_notifier(const u32 node, const u32 event,
  				const u32 wake, const u32 enable);
  int zynqmp_pm_feature(const u32 api_id);
+int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id);
  int zynqmp_pm_set_feature_config(enum pm_feature_config_id id, u32 value);
  int zynqmp_pm_get_feature_config(enum pm_feature_config_id id, u32 *payload);
  #else
@@ -678,6 +684,11 @@ static inline int zynqmp_pm_pinctrl_get_function(const u32 pin, u32 *id)
  	return -ENODEV;

include/linux/firmware/xlnx-zynqmp.h static inline int zynqmp_pm_pinctrl_get_function(const u32 pin, u32 *id) · line 694

Quoted 10 lines
include/linux/firmware/xlnx-zynqmp.h +5 -0
  }
 
+static inline int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id)
+{
+	return -ENODEV;
+}
+
  static inline int zynqmp_pm_pinctrl_set_function(const u32 pin, const u32 id)
  {
  	return -ENODEV;

Thanks,
Michal

author
#3 lore raw

PATCH 2/4 firmware: xilinx: add new function for do_feature_check_call

In reply to Ronak Jain

Add new function for sending feature check request to firmware and call it from zynqmp_pm_feature().

---
 drivers/firmware/xilinx/zynqmp.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/firmware/xilinx/zynqmp.c +18 -9
index 41ca41697790..d27a3b20227b 100644
@@ -175,6 +175,23 @@ static noinline int do_fw_call_hvc(u64 arg0, u64 arg1, u64 arg2,
 	return zynqmp_pm_ret_code((enum pm_ret_status)res.a0);
 }
 
+static int do_feature_check_call(const u32 api_id, u32 *ret_payload)
+{
+	int ret;
+	u64 smc_arg[2];
+
+	smc_arg[0] = PM_SIP_SVC | PM_FEATURE_CHECK;
+	smc_arg[1] = api_id;
+
+	ret = do_fw_call(smc_arg[0], smc_arg[1], 0, ret_payload);
+	if (ret)
+		ret = -EOPNOTSUPP;
+	else
+		ret = ret_payload[1];
+
+	return ret;
+}
+
 /**
  * zynqmp_pm_feature() - Check whether given feature is supported or not and
  *			 store supported IOCTL/QUERY ID mask
@@ -186,7 +203,6 @@ int zynqmp_pm_feature(const u32 api_id)
 {
 	int ret;
 	u32 ret_payload[PAYLOAD_ARG_CNT];
-	u64 smc_arg[2];
 	struct pm_api_feature_data *feature_data;
 
 	if (!feature_check_enabled)
@@ -205,14 +221,7 @@ int zynqmp_pm_feature(const u32 api_id)
 		return -ENOMEM;
 
 	feature_data->pm_api_id = api_id;
-	smc_arg[0] = PM_SIP_SVC | PM_FEATURE_CHECK;
-	smc_arg[1] = api_id;
-
-	ret = do_fw_call(smc_arg[0], smc_arg[1], 0, ret_payload);
-	if (ret)
-		ret = -EOPNOTSUPP;
-	else
-		ret = ret_payload[1];
+	ret = do_feature_check_call(api_id, ret_payload);
 
 	feature_data->feature_status = ret;
 	hash_add(pm_api_features_map, &feature_data->hentry, api_id);
Signature · 7 lines
2.7.4


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Acked-by on v1 2/4
#4 lore raw

Re: [PATCH 2/4] firmware: xilinx: add new function for do_feature_check_call

Quoted 50 lines · Ronak Jain

Add new function for sending feature check request to firmware and call it from zynqmp_pm_feature().

---
  drivers/firmware/xilinx/zynqmp.c | 27 ++++++++++++++++++---------
  1 file changed, 18 insertions(+), 9 deletions(-)
drivers/firmware/xilinx/zynqmp.c +17 -3
index 41ca41697790..d27a3b20227b 100644
@@ -175,6 +175,23 @@ static noinline int do_fw_call_hvc(u64 arg0, u64 arg1, u64 arg2,
  	return zynqmp_pm_ret_code((enum pm_ret_status)res.a0);
  }
 
+static int do_feature_check_call(const u32 api_id, u32 *ret_payload)
+{
+	int ret;
+	u64 smc_arg[2];
+
+	smc_arg[0] = PM_SIP_SVC | PM_FEATURE_CHECK;
+	smc_arg[1] = api_id;
+
+	ret = do_fw_call(smc_arg[0], smc_arg[1], 0, ret_payload);
+	if (ret)
+		ret = -EOPNOTSUPP;
+	else
+		ret = ret_payload[1];
+
+	return ret;
+}
+
  /**
   * zynqmp_pm_feature() - Check whether given feature is supported or not and
   *			 store supported IOCTL/QUERY ID mask
@@ -186,7 +203,6 @@ int zynqmp_pm_feature(const u32 api_id)
  {
  	int ret;
  	u32 ret_payload[PAYLOAD_ARG_CNT];
-	u64 smc_arg[2];
  	struct pm_api_feature_data *feature_data;
 
  	if (!feature_check_enabled)
@@ -205,14 +221,7 @@ int zynqmp_pm_feature(const u32 api_id)
  		return -ENOMEM;
 
  	feature_data->pm_api_id = api_id;
-	smc_arg[0] = PM_SIP_SVC | PM_FEATURE_CHECK;
-	smc_arg[1] = api_id;

drivers/firmware/xilinx/zynqmp.c int zynqmp_pm_feature(const u32 api_id) · line 227

Quoted 10 lines
drivers/firmware/xilinx/zynqmp.c +1 -6
-
-	ret = do_fw_call(smc_arg[0], smc_arg[1], 0, ret_payload);
-	if (ret)
-		ret = -EOPNOTSUPP;
-	else
-		ret = ret_payload[1];
+	ret = do_feature_check_call(api_id, ret_payload);
 
  	feature_data->feature_status = ret;
  	hash_add(pm_api_features_map, &feature_data->hentry, api_id);

Thanks,
Michal

author
#5 lore raw

PATCH 3/4 firmware: xilinx: always check API version for IOCTL/QUERY

In reply to Ronak Jain

Currently, we are not checking feature check version for PM APIs as the support may or may not there in the firmware. To check the whether the feature check API is supported or not in the firmware, allow checking for its own version.

---
 drivers/firmware/xilinx/zynqmp.c | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)
drivers/firmware/xilinx/zynqmp.c +24 -15
index d27a3b20227b..6ee94f31ac98 100644
@@ -175,7 +175,7 @@ static noinline int do_fw_call_hvc(u64 arg0, u64 arg1, u64 arg2,
 	return zynqmp_pm_ret_code((enum pm_ret_status)res.a0);
 }
 
-static int do_feature_check_call(const u32 api_id, u32 *ret_payload)
+static int __do_feature_check_call(const u32 api_id, u32 *ret_payload)
 {
 	int ret;
 	u64 smc_arg[2];
@@ -192,22 +192,12 @@ static int do_feature_check_call(const u32 api_id, u32 *ret_payload)
 	return ret;
 }
 
-/**
- * zynqmp_pm_feature() - Check whether given feature is supported or not and
- *			 store supported IOCTL/QUERY ID mask
- * @api_id:		API ID to check
- *
- * Return: Returns status, either success or error+reason
- */
-int zynqmp_pm_feature(const u32 api_id)
+static int do_feature_check_call(const u32 api_id)
 {
 	int ret;
 	u32 ret_payload[PAYLOAD_ARG_CNT];
 	struct pm_api_feature_data *feature_data;
 
-	if (!feature_check_enabled)
-		return 0;
-
 	/* Check for existing entry in hash table for given api */
 	hash_for_each_possible(pm_api_features_map, feature_data, hentry,
 			       api_id) {
@@ -221,7 +211,7 @@ int zynqmp_pm_feature(const u32 api_id)
 		return -ENOMEM;
 
 	feature_data->pm_api_id = api_id;
-	ret = do_feature_check_call(api_id, ret_payload);
+	ret = __do_feature_check_call(api_id, ret_payload);
 
 	feature_data->feature_status = ret;
 	hash_add(pm_api_features_map, &feature_data->hentry, api_id);
@@ -238,6 +228,25 @@ int zynqmp_pm_feature(const u32 api_id)
 EXPORT_SYMBOL_GPL(zynqmp_pm_feature);
 
 /**
+ * zynqmp_pm_feature() - Check whether given feature is supported or not and
+ *			 store supported IOCTL/QUERY ID mask
+ * @api_id:		API ID to check
+ *
+ * Return: Returns status, either success or error+reason
+ */
+int zynqmp_pm_feature(const u32 api_id)
+{
+	int ret;
+
+	if (!feature_check_enabled)
+		return 0;
+
+	ret = do_feature_check_call(api_id);
+
+	return ret;
+}
+
+/**
  * zynqmp_pm_is_function_supported() - Check whether given IOCTL/QUERY function
  *				       is supported or not
  * @api_id:		PM_IOCTL or PM_QUERY_DATA
@@ -255,7 +264,7 @@ int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id)
 		return -EINVAL;
 
 	/* Check feature check API version */
-	ret = zynqmp_pm_feature(PM_FEATURE_CHECK);
+	ret = do_feature_check_call(PM_FEATURE_CHECK);
 	if (ret < 0)
 		return ret;
 
@@ -265,7 +274,7 @@ int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id)
 		 * Call feature check for IOCTL/QUERY API to get IOCTL ID or
 		 * QUERY ID feature status.
 		 */
-		ret = zynqmp_pm_feature(api_id);
+		ret = do_feature_check_call(api_id);
 		if (ret < 0)
 			return ret;
 
Signature · 7 lines
2.7.4


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Acked-by on v1 3/4
#6 lore raw

Re: [PATCH 3/4] firmware: xilinx: always check API version for IOCTL/QUERY

Quoted 92 lines · Ronak Jain

Currently, we are not checking feature check version for PM APIs as the support may or may not there in the firmware. To check the whether the feature check API is supported or not in the firmware, allow checking for its own version.

---
  drivers/firmware/xilinx/zynqmp.c | 39 ++++++++++++++++++++++++---------------
  1 file changed, 24 insertions(+), 15 deletions(-)
drivers/firmware/xilinx/zynqmp.c +23 -14
index d27a3b20227b..6ee94f31ac98 100644
@@ -175,7 +175,7 @@ static noinline int do_fw_call_hvc(u64 arg0, u64 arg1, u64 arg2,
  	return zynqmp_pm_ret_code((enum pm_ret_status)res.a0);
  }
 
-static int do_feature_check_call(const u32 api_id, u32 *ret_payload)
+static int __do_feature_check_call(const u32 api_id, u32 *ret_payload)
  {
  	int ret;
  	u64 smc_arg[2];
@@ -192,22 +192,12 @@ static int do_feature_check_call(const u32 api_id, u32 *ret_payload)
  	return ret;
  }
 
-/**
- * zynqmp_pm_feature() - Check whether given feature is supported or not and
- *			 store supported IOCTL/QUERY ID mask
- * @api_id:		API ID to check
- *
- * Return: Returns status, either success or error+reason
- */
-int zynqmp_pm_feature(const u32 api_id)
+static int do_feature_check_call(const u32 api_id)
  {
  	int ret;
  	u32 ret_payload[PAYLOAD_ARG_CNT];
  	struct pm_api_feature_data *feature_data;
 
-	if (!feature_check_enabled)
-		return 0;
-
  	/* Check for existing entry in hash table for given api */
  	hash_for_each_possible(pm_api_features_map, feature_data, hentry,
  			       api_id) {
@@ -221,7 +211,7 @@ int zynqmp_pm_feature(const u32 api_id)
  		return -ENOMEM;
 
  	feature_data->pm_api_id = api_id;
-	ret = do_feature_check_call(api_id, ret_payload);
+	ret = __do_feature_check_call(api_id, ret_payload);
 
  	feature_data->feature_status = ret;
  	hash_add(pm_api_features_map, &feature_data->hentry, api_id);
@@ -238,6 +228,25 @@ int zynqmp_pm_feature(const u32 api_id)
  EXPORT_SYMBOL_GPL(zynqmp_pm_feature);
 
  /**
+ * zynqmp_pm_feature() - Check whether given feature is supported or not and
+ *			 store supported IOCTL/QUERY ID mask
+ * @api_id:		API ID to check
+ *
+ * Return: Returns status, either success or error+reason
+ */
+int zynqmp_pm_feature(const u32 api_id)
+{
+	int ret;
+
+	if (!feature_check_enabled)
+		return 0;
+
+	ret = do_feature_check_call(api_id);
+
+	return ret;
+}
+
+/**
   * zynqmp_pm_is_function_supported() - Check whether given IOCTL/QUERY function
   *				       is supported or not
   * @api_id:		PM_IOCTL or PM_QUERY_DATA
@@ -255,7 +264,7 @@ int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id)
  		return -EINVAL;
 
  	/* Check feature check API version */
-	ret = zynqmp_pm_feature(PM_FEATURE_CHECK);
+	ret = do_feature_check_call(PM_FEATURE_CHECK);
  	if (ret < 0)
  		return ret;
 

drivers/firmware/xilinx/zynqmp.c int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id) · line 280

Quoted 8 lines
drivers/firmware/xilinx/zynqmp.c +1 -1
@@ -265,7 +274,7 @@ int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id)
  		 * Call feature check for IOCTL/QUERY API to get IOCTL ID or
  		 * QUERY ID feature status.
  		 */
-		ret = zynqmp_pm_feature(api_id);
+		ret = do_feature_check_call(api_id);
  		if (ret < 0)
  			return ret;
 

Thanks,
Michal

author
#7 lore raw

PATCH 4/4 firmware: xilinx: enable feature check for ZynqMP

In reply to Ronak Jain

Enable the feature check if the PM_FEATURE_CHECK API returns success with the supported version for the ZynqMP. Currently, it is enabled for Versal only.

Move get_set_conduit_method() at the beginning as the Linux is requesting to TF-A for the PM_FEATURE_CHECK API version for which the interface should be enabled with TF-A.

---
 drivers/firmware/xilinx/zynqmp.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/firmware/xilinx/zynqmp.c +11 -4
index 6ee94f31ac98..7977a494a651 100644
@@ -1662,6 +1662,10 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
 	struct zynqmp_devinfo *devinfo;
 	int ret;
 
+	ret = get_set_conduit_method(dev->of_node);
+	if (ret)
+		return ret;
+
 	np = of_find_compatible_node(NULL, NULL, "xlnx,zynqmp");
 	if (!np) {
 		np = of_find_compatible_node(NULL, NULL, "xlnx,versal");
@@ -1670,11 +1674,14 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
 
 		feature_check_enabled = true;
 	}
-	of_node_put(np);
 
-	ret = get_set_conduit_method(dev->of_node);
-	if (ret)
-		return ret;
+	if (!feature_check_enabled) {
+		ret = do_feature_check_call(PM_FEATURE_CHECK);
+		if (ret >= 0)
+			feature_check_enabled = true;
+	}
+
+	of_node_put(np);
 
 	devinfo = devm_kzalloc(dev, sizeof(*devinfo), GFP_KERNEL);
 	if (!devinfo)
Signature · 7 lines
2.7.4


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Acked-by on v1 4/4
#8 lore raw

Re: [PATCH 4/4] firmware: xilinx: enable feature check for ZynqMP

Quoted 37 lines · Ronak Jain

Enable the feature check if the PM_FEATURE_CHECK API returns success with the supported version for the ZynqMP. Currently, it is enabled for Versal only.

Move get_set_conduit_method() at the beginning as the Linux is requesting to TF-A for the PM_FEATURE_CHECK API version for which the interface should be enabled with TF-A.

---
  drivers/firmware/xilinx/zynqmp.c | 15 +++++++++++----
  1 file changed, 11 insertions(+), 4 deletions(-)
drivers/firmware/xilinx/zynqmp.c +4 -4
index 6ee94f31ac98..7977a494a651 100644
@@ -1662,6 +1662,10 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
  	struct zynqmp_devinfo *devinfo;
  	int ret;
 
+	ret = get_set_conduit_method(dev->of_node);
+	if (ret)
+		return ret;
+
  	np = of_find_compatible_node(NULL, NULL, "xlnx,zynqmp");
  	if (!np) {
  		np = of_find_compatible_node(NULL, NULL, "xlnx,versal");
@@ -1670,11 +1674,14 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
 
  		feature_check_enabled = true;
  	}
-	of_node_put(np);
 
-	ret = get_set_conduit_method(dev->of_node);
-	if (ret)
-		return ret;

drivers/firmware/xilinx/zynqmp.c static int zynqmp_firmware_probe(struct platform_device *pdev) · line 1687

Quoted 10 lines
drivers/firmware/xilinx/zynqmp.c +7 -0
+	if (!feature_check_enabled) {
+		ret = do_feature_check_call(PM_FEATURE_CHECK);
+		if (ret >= 0)
+			feature_check_enabled = true;
+	}
+
+	of_node_put(np);
 
  	devinfo = devm_kzalloc(dev, sizeof(*devinfo), GFP_KERNEL);
  	if (!devinfo)

Thanks,
Michal

#9 lore raw
In reply to Ronak Jain

Hi Team,

Gentle reminder for a review!

Thanks,
Ronak

Quoted 29 lines

-----Original Message-----
From: Ronak Jain <[email protected]>
Sent: Wednesday, April 6, 2022 4:25 PM
To: Michal Simek <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; linux-arm- [email protected]; [email protected]; Sai Krishna Potthuri <[email protected]>; Radhey Shyam Pandey <[email protected]>; Ronak Jain <[email protected]>
Subject: [PATCH 0/4] Add feature check support in ZU+

Add feature check PM API support for QUERY/IOCTL IDs to get individual ids version from the firmware/TF-A if supported and return an error code if the PM API or the QUERY/IOCTL IDs are not supported.

Enable feature check for each PM APIs before executing the functionality.

Ronak Jain (4):
firmware: xilinx: add support for IOCTL and QUERY ID feature check
firmware: xilinx: add new function for do_feature_check_call
firmware: xilinx: always check API version for IOCTL/QUERY
firmware: xilinx: enable feature check for ZynqMP

 drivers/firmware/xilinx/zynqmp.c     | 131 +++++++++++++++++++++++++++++-
-----
 include/linux/firmware/xlnx-zynqmp.h |  11 +++
 2 files changed, 119 insertions(+), 23 deletions(-)

--
2.7.4