All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Add feature check support in ZU+
@ 2022-04-06 10:55 ` Ronak Jain
  0 siblings, 0 replies; 20+ messages in thread
From: Ronak Jain @ 2022-04-06 10:55 UTC (permalink / raw)
  To: michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys, Ronak Jain

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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 0/4] Add feature check support in ZU+
@ 2022-04-06 10:55 ` Ronak Jain
  0 siblings, 0 replies; 20+ messages in thread
From: Ronak Jain @ 2022-04-06 10:55 UTC (permalink / raw)
  To: michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys, Ronak Jain

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


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/4] firmware: xilinx: add support for IOCTL and QUERY ID feature check
  2022-04-06 10:55 ` Ronak Jain
@ 2022-04-06 10:55   ` Ronak Jain
  -1 siblings, 0 replies; 20+ messages in thread
From: Ronak Jain @ 2022-04-06 10:55 UTC (permalink / raw)
  To: michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys, Ronak Jain

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

Signed-off-by: Ronak Jain <ronak.jain@xilinx.com>
---
 drivers/firmware/xilinx/zynqmp.c     | 62 +++++++++++++++++++++++++++++++++++-
 include/linux/firmware/xlnx-zynqmp.h | 11 +++++++
 2 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index f21ece56695e..41ca41697790 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -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
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index 14f00a7672d1..1ec73d5352c3 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -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;
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 1/4] firmware: xilinx: add support for IOCTL and QUERY ID feature check
@ 2022-04-06 10:55   ` Ronak Jain
  0 siblings, 0 replies; 20+ messages in thread
From: Ronak Jain @ 2022-04-06 10:55 UTC (permalink / raw)
  To: michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys, Ronak Jain

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

Signed-off-by: Ronak Jain <ronak.jain@xilinx.com>
---
 drivers/firmware/xilinx/zynqmp.c     | 62 +++++++++++++++++++++++++++++++++++-
 include/linux/firmware/xlnx-zynqmp.h | 11 +++++++
 2 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index f21ece56695e..41ca41697790 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -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
diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
index 14f00a7672d1..1ec73d5352c3 100644
--- a/include/linux/firmware/xlnx-zynqmp.h
+++ b/include/linux/firmware/xlnx-zynqmp.h
@@ -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;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/4] firmware: xilinx: add new function for do_feature_check_call
  2022-04-06 10:55 ` Ronak Jain
@ 2022-04-06 10:55   ` Ronak Jain
  -1 siblings, 0 replies; 20+ messages in thread
From: Ronak Jain @ 2022-04-06 10:55 UTC (permalink / raw)
  To: michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys, Ronak Jain

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

Signed-off-by: Ronak Jain <ronak.jain@xilinx.com>
---
 drivers/firmware/xilinx/zynqmp.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 41ca41697790..d27a3b20227b 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -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);
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/4] firmware: xilinx: add new function for do_feature_check_call
@ 2022-04-06 10:55   ` Ronak Jain
  0 siblings, 0 replies; 20+ messages in thread
From: Ronak Jain @ 2022-04-06 10:55 UTC (permalink / raw)
  To: michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys, Ronak Jain

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

Signed-off-by: Ronak Jain <ronak.jain@xilinx.com>
---
 drivers/firmware/xilinx/zynqmp.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 41ca41697790..d27a3b20227b 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -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);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/4] firmware: xilinx: always check API version for IOCTL/QUERY
  2022-04-06 10:55 ` Ronak Jain
@ 2022-04-06 10:55   ` Ronak Jain
  -1 siblings, 0 replies; 20+ messages in thread
From: Ronak Jain @ 2022-04-06 10:55 UTC (permalink / raw)
  To: michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys, 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.

Signed-off-by: Ronak Jain <ronak.jain@xilinx.com>
---
 drivers/firmware/xilinx/zynqmp.c | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index d27a3b20227b..6ee94f31ac98 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -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;
 
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/4] firmware: xilinx: always check API version for IOCTL/QUERY
@ 2022-04-06 10:55   ` Ronak Jain
  0 siblings, 0 replies; 20+ messages in thread
From: Ronak Jain @ 2022-04-06 10:55 UTC (permalink / raw)
  To: michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys, 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.

Signed-off-by: Ronak Jain <ronak.jain@xilinx.com>
---
 drivers/firmware/xilinx/zynqmp.c | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index d27a3b20227b..6ee94f31ac98 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -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;
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 4/4] firmware: xilinx: enable feature check for ZynqMP
  2022-04-06 10:55 ` Ronak Jain
@ 2022-04-06 10:55   ` Ronak Jain
  -1 siblings, 0 replies; 20+ messages in thread
From: Ronak Jain @ 2022-04-06 10:55 UTC (permalink / raw)
  To: michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys, 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.

Signed-off-by: Ronak Jain <ronak.jain@xilinx.com>
---
 drivers/firmware/xilinx/zynqmp.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 6ee94f31ac98..7977a494a651 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -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)
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 4/4] firmware: xilinx: enable feature check for ZynqMP
@ 2022-04-06 10:55   ` Ronak Jain
  0 siblings, 0 replies; 20+ messages in thread
From: Ronak Jain @ 2022-04-06 10:55 UTC (permalink / raw)
  To: michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys, 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.

Signed-off-by: Ronak Jain <ronak.jain@xilinx.com>
---
 drivers/firmware/xilinx/zynqmp.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
index 6ee94f31ac98..7977a494a651 100644
--- a/drivers/firmware/xilinx/zynqmp.c
+++ b/drivers/firmware/xilinx/zynqmp.c
@@ -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)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* RE: [PATCH 0/4] Add feature check support in ZU+
  2022-04-06 10:55 ` Ronak Jain
@ 2022-04-22  6:10   ` Ronak Jain
  -1 siblings, 0 replies; 20+ messages in thread
From: Ronak Jain @ 2022-04-22  6:10 UTC (permalink / raw)
  To: Ronak Jain, Michal Simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd, Sai Krishna Potthuri,
	Radhey Shyam Pandey

Hi Team,

Gentle reminder for a review!

Thanks,
Ronak

> -----Original Message-----
> From: Ronak Jain <ronak.jain@xilinx.com>
> Sent: Wednesday, April 6, 2022 4:25 PM
> To: Michal Simek <michals@xilinx.com>; linux-kernel@vger.kernel.org
> Cc: gregkh@linuxfoundation.org; corbet@lwn.net; linux-arm-
> kernel@lists.infradead.org; arnd@arndb.de; Sai Krishna Potthuri
> <lakshmis@xilinx.com>; Radhey Shyam Pandey <radheys@xilinx.com>; Ronak
> Jain <ronakj@xilinx.com>
> 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


^ permalink raw reply	[flat|nested] 20+ messages in thread

* RE: [PATCH 0/4] Add feature check support in ZU+
@ 2022-04-22  6:10   ` Ronak Jain
  0 siblings, 0 replies; 20+ messages in thread
From: Ronak Jain @ 2022-04-22  6:10 UTC (permalink / raw)
  To: Ronak Jain, Michal Simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd, Sai Krishna Potthuri,
	Radhey Shyam Pandey

Hi Team,

Gentle reminder for a review!

Thanks,
Ronak

> -----Original Message-----
> From: Ronak Jain <ronak.jain@xilinx.com>
> Sent: Wednesday, April 6, 2022 4:25 PM
> To: Michal Simek <michals@xilinx.com>; linux-kernel@vger.kernel.org
> Cc: gregkh@linuxfoundation.org; corbet@lwn.net; linux-arm-
> kernel@lists.infradead.org; arnd@arndb.de; Sai Krishna Potthuri
> <lakshmis@xilinx.com>; Radhey Shyam Pandey <radheys@xilinx.com>; Ronak
> Jain <ronakj@xilinx.com>
> 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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/4] firmware: xilinx: add support for IOCTL and QUERY ID feature check
  2022-04-06 10:55   ` Ronak Jain
@ 2022-04-29  8:35     ` Michal Simek
  -1 siblings, 0 replies; 20+ messages in thread
From: Michal Simek @ 2022-04-29  8:35 UTC (permalink / raw)
  To: Ronak Jain, michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys



On 4/6/22 12:55, Ronak Jain wrote:
> Add support to check if IOCTL ID or QUERY ID is supported in firmware
> or not.
> 
> Signed-off-by: Ronak Jain <ronak.jain@xilinx.com>
> ---
>   drivers/firmware/xilinx/zynqmp.c     | 62 +++++++++++++++++++++++++++++++++++-
>   include/linux/firmware/xlnx-zynqmp.h | 11 +++++++
>   2 files changed, 72 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index f21ece56695e..41ca41697790 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -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
> diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
> index 14f00a7672d1..1ec73d5352c3 100644
> --- a/include/linux/firmware/xlnx-zynqmp.h
> +++ b/include/linux/firmware/xlnx-zynqmp.h
> @@ -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;


Acked-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/4] firmware: xilinx: add support for IOCTL and QUERY ID feature check
@ 2022-04-29  8:35     ` Michal Simek
  0 siblings, 0 replies; 20+ messages in thread
From: Michal Simek @ 2022-04-29  8:35 UTC (permalink / raw)
  To: Ronak Jain, michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys



On 4/6/22 12:55, Ronak Jain wrote:
> Add support to check if IOCTL ID or QUERY ID is supported in firmware
> or not.
> 
> Signed-off-by: Ronak Jain <ronak.jain@xilinx.com>
> ---
>   drivers/firmware/xilinx/zynqmp.c     | 62 +++++++++++++++++++++++++++++++++++-
>   include/linux/firmware/xlnx-zynqmp.h | 11 +++++++
>   2 files changed, 72 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index f21ece56695e..41ca41697790 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -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
> diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
> index 14f00a7672d1..1ec73d5352c3 100644
> --- a/include/linux/firmware/xlnx-zynqmp.h
> +++ b/include/linux/firmware/xlnx-zynqmp.h
> @@ -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;


Acked-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/4] firmware: xilinx: add new function for do_feature_check_call
  2022-04-06 10:55   ` Ronak Jain
@ 2022-04-29  8:35     ` Michal Simek
  -1 siblings, 0 replies; 20+ messages in thread
From: Michal Simek @ 2022-04-29  8:35 UTC (permalink / raw)
  To: Ronak Jain, michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys



On 4/6/22 12:55, Ronak Jain wrote:
> Add new function for sending feature check request to firmware and
> call it from zynqmp_pm_feature().
> 
> Signed-off-by: Ronak Jain <ronak.jain@xilinx.com>
> ---
>   drivers/firmware/xilinx/zynqmp.c | 27 ++++++++++++++++++---------
>   1 file changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index 41ca41697790..d27a3b20227b 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -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);

Acked-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/4] firmware: xilinx: add new function for do_feature_check_call
@ 2022-04-29  8:35     ` Michal Simek
  0 siblings, 0 replies; 20+ messages in thread
From: Michal Simek @ 2022-04-29  8:35 UTC (permalink / raw)
  To: Ronak Jain, michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys



On 4/6/22 12:55, Ronak Jain wrote:
> Add new function for sending feature check request to firmware and
> call it from zynqmp_pm_feature().
> 
> Signed-off-by: Ronak Jain <ronak.jain@xilinx.com>
> ---
>   drivers/firmware/xilinx/zynqmp.c | 27 ++++++++++++++++++---------
>   1 file changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index 41ca41697790..d27a3b20227b 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -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);

Acked-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/4] firmware: xilinx: always check API version for IOCTL/QUERY
  2022-04-06 10:55   ` Ronak Jain
@ 2022-04-29  8:35     ` Michal Simek
  -1 siblings, 0 replies; 20+ messages in thread
From: Michal Simek @ 2022-04-29  8:35 UTC (permalink / raw)
  To: Ronak Jain, michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys



On 4/6/22 12:55, Ronak Jain wrote:
> 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.
> 
> Signed-off-by: Ronak Jain <ronak.jain@xilinx.com>
> ---
>   drivers/firmware/xilinx/zynqmp.c | 39 ++++++++++++++++++++++++---------------
>   1 file changed, 24 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index d27a3b20227b..6ee94f31ac98 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -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;
>   


Acked-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/4] firmware: xilinx: always check API version for IOCTL/QUERY
@ 2022-04-29  8:35     ` Michal Simek
  0 siblings, 0 replies; 20+ messages in thread
From: Michal Simek @ 2022-04-29  8:35 UTC (permalink / raw)
  To: Ronak Jain, michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys



On 4/6/22 12:55, Ronak Jain wrote:
> 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.
> 
> Signed-off-by: Ronak Jain <ronak.jain@xilinx.com>
> ---
>   drivers/firmware/xilinx/zynqmp.c | 39 ++++++++++++++++++++++++---------------
>   1 file changed, 24 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index d27a3b20227b..6ee94f31ac98 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -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;
>   


Acked-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/4] firmware: xilinx: enable feature check for ZynqMP
  2022-04-06 10:55   ` Ronak Jain
@ 2022-04-29  8:36     ` Michal Simek
  -1 siblings, 0 replies; 20+ messages in thread
From: Michal Simek @ 2022-04-29  8:36 UTC (permalink / raw)
  To: Ronak Jain, michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys



On 4/6/22 12:55, Ronak Jain wrote:
> 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.
> 
> Signed-off-by: Ronak Jain <ronak.jain@xilinx.com>
> ---
>   drivers/firmware/xilinx/zynqmp.c | 15 +++++++++++----
>   1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index 6ee94f31ac98..7977a494a651 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -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)


Acked-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/4] firmware: xilinx: enable feature check for ZynqMP
@ 2022-04-29  8:36     ` Michal Simek
  0 siblings, 0 replies; 20+ messages in thread
From: Michal Simek @ 2022-04-29  8:36 UTC (permalink / raw)
  To: Ronak Jain, michal.simek, linux-kernel
  Cc: gregkh, corbet, linux-arm-kernel, arnd,
	lakshmi.sai.krishna.potthuri, radheys



On 4/6/22 12:55, Ronak Jain wrote:
> 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.
> 
> Signed-off-by: Ronak Jain <ronak.jain@xilinx.com>
> ---
>   drivers/firmware/xilinx/zynqmp.c | 15 +++++++++++----
>   1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index 6ee94f31ac98..7977a494a651 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -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)


Acked-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2022-04-29  8:38 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06 10:55 [PATCH 0/4] Add feature check support in ZU+ Ronak Jain
2022-04-06 10:55 ` Ronak Jain
2022-04-06 10:55 ` [PATCH 1/4] firmware: xilinx: add support for IOCTL and QUERY ID feature check Ronak Jain
2022-04-06 10:55   ` Ronak Jain
2022-04-29  8:35   ` Michal Simek
2022-04-29  8:35     ` Michal Simek
2022-04-06 10:55 ` [PATCH 2/4] firmware: xilinx: add new function for do_feature_check_call Ronak Jain
2022-04-06 10:55   ` Ronak Jain
2022-04-29  8:35   ` Michal Simek
2022-04-29  8:35     ` Michal Simek
2022-04-06 10:55 ` [PATCH 3/4] firmware: xilinx: always check API version for IOCTL/QUERY Ronak Jain
2022-04-06 10:55   ` Ronak Jain
2022-04-29  8:35   ` Michal Simek
2022-04-29  8:35     ` Michal Simek
2022-04-06 10:55 ` [PATCH 4/4] firmware: xilinx: enable feature check for ZynqMP Ronak Jain
2022-04-06 10:55   ` Ronak Jain
2022-04-29  8:36   ` Michal Simek
2022-04-29  8:36     ` Michal Simek
2022-04-22  6:10 ` [PATCH 0/4] Add feature check support in ZU+ Ronak Jain
2022-04-22  6:10   ` Ronak Jain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.