2022-04-06 15:32:47

by Ronak Jain

[permalink] [raw]
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


2022-04-06 15:33:02

by Ronak Jain

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

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 <[email protected]>
---
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

2022-04-06 16:08:53

by Ronak Jain

[permalink] [raw]
Subject: [PATCH 4/4] firmware: xilinx: enable feature check for ZynqMP

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 <[email protected]>
---
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

2022-04-22 21:20:05

by Ronak Jain

[permalink] [raw]
Subject: RE: [PATCH 0/4] Add feature check support in ZU+

Hi Team,

Gentle reminder for a review!

Thanks,
Ronak

> -----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

2022-05-02 23:23:15

by Michal Simek

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



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 <[email protected]>
> ---
> 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 <[email protected]>

Thanks,
Michal

2022-05-03 00:36:24

by Michal Simek

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



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 <[email protected]>
> ---
> 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 <[email protected]>

Thanks,
Michal