From: Etienne Carriere <etienne.carriere@linaro.org> To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, james.morse@arm.com, michal.simek@xilinx.com, richard.gong@linux.intel.com, lorenzo.pieralisi@arm.com, mark.rutland@arm.com, jens.wiklander@linaro.org, tee-dev@lists.linaro.org, sudeep.holla@arm.com, Etienne Carriere <etienne.carriere@linaro.org> Subject: [RFC PATCH 6/6] firmware: zynqmp: use SMCCC v1.0 helper functions Date: Sun, 19 Apr 2020 17:05:30 +0200 [thread overview] Message-ID: <20200419150530.20508-7-etienne.carriere@linaro.org> (raw) In-Reply-To: <20200419150530.20508-1-etienne.carriere@linaro.org> Change Xilinx Zynmp driver to use Arm SMCCC v1.0 helper functions and ensure platform consistency on SMCCC conduit method. Main functional change is that SMCCC conduit method for ZynqMP firmware must be consistent with conduit methods registered by PSCI device that is early probed. Another functional change is an addition info trace emitted by the device probe sequence: "probing for conduit method from DT.". Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> --- drivers/firmware/xilinx/zynqmp.c | 87 ++++---------------------------- 1 file changed, 9 insertions(+), 78 deletions(-) diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c index 41b65164a367..1fdc468c9204 100644 --- a/drivers/firmware/xilinx/zynqmp.c +++ b/drivers/firmware/xilinx/zynqmp.c @@ -63,51 +63,11 @@ static int zynqmp_pm_ret_code(u32 ret_status) } } -static noinline int do_fw_call_fail(u64 arg0, u64 arg1, u64 arg2, - u32 *ret_payload) -{ - return -ENODEV; -} - -/* - * PM function call wrapper - * Invoke do_fw_call_smc or do_fw_call_hvc, depending on the configuration - */ -static int (*do_fw_call)(u64, u64, u64, u32 *ret_payload) = do_fw_call_fail; - -/** - * do_fw_call_smc() - Call system-level platform management layer (SMC) - * @arg0: Argument 0 to SMC call - * @arg1: Argument 1 to SMC call - * @arg2: Argument 2 to SMC call - * @ret_payload: Returned value array - * - * Invoke platform management function via SMC call (no hypervisor present). - * - * Return: Returns status, either success or error+reason - */ -static noinline int do_fw_call_smc(u64 arg0, u64 arg1, u64 arg2, - u32 *ret_payload) -{ - struct arm_smccc_res res; - - arm_smccc_smc(arg0, arg1, arg2, 0, 0, 0, 0, 0, &res); - - if (ret_payload) { - ret_payload[0] = lower_32_bits(res.a0); - ret_payload[1] = upper_32_bits(res.a0); - ret_payload[2] = lower_32_bits(res.a1); - ret_payload[3] = upper_32_bits(res.a1); - } - - return zynqmp_pm_ret_code((enum pm_ret_status)res.a0); -} - /** - * do_fw_call_hvc() - Call system-level platform management layer (HVC) - * @arg0: Argument 0 to HVC call - * @arg1: Argument 1 to HVC call - * @arg2: Argument 2 to HVC call + * do_fw_call() - Call system-level platform management layer + * @arg0: Argument 0 to HVC/SMC call + * @arg1: Argument 1 to HVC/SMC call + * @arg2: Argument 2 to HVC/SMC call * @ret_payload: Returned value array * * Invoke platform management function via HVC @@ -116,12 +76,13 @@ static noinline int do_fw_call_smc(u64 arg0, u64 arg1, u64 arg2, * * Return: Returns status, either success or error+reason */ -static noinline int do_fw_call_hvc(u64 arg0, u64 arg1, u64 arg2, - u32 *ret_payload) +static noinline int do_fw_call(u64 arg0, u64 arg1, u64 arg2, u32 *ret_payload) { struct arm_smccc_res res; - arm_smccc_hvc(arg0, arg1, arg2, 0, 0, 0, 0, 0, &res); + if (arm_smccc_1_0_invoke(arg0, arg1, arg2, 0, 0, 0, 0, 0, &res) == + SMCCC_CONDUIT_NONE) + return -ENODEV; if (ret_payload) { ret_payload[0] = lower_32_bits(res.a0); @@ -287,36 +248,6 @@ static int zynqmp_pm_get_trustzone_version(u32 *version) return ret; } -/** - * get_set_conduit_method() - Choose SMC or HVC based communication - * @np: Pointer to the device_node structure - * - * Use SMC or HVC-based functions to communicate with EL2/EL3. - * - * Return: Returns 0 on success or error code - */ -static int get_set_conduit_method(struct device_node *np) -{ - const char *method; - - if (of_property_read_string(np, "method", &method)) { - pr_warn("%s missing \"method\" property\n", __func__); - return -ENXIO; - } - - if (!strcmp("hvc", method)) { - do_fw_call = do_fw_call_hvc; - } else if (!strcmp("smc", method)) { - do_fw_call = do_fw_call_smc; - } else { - pr_warn("%s Invalid \"method\" property: %s\n", - __func__, method); - return -EINVAL; - } - - return 0; -} - /** * zynqmp_pm_query_data() - Get query data from firmware * @qdata: Variable to the zynqmp_pm_query_data structure @@ -790,7 +721,7 @@ static int zynqmp_firmware_probe(struct platform_device *pdev) } of_node_put(np); - ret = get_set_conduit_method(dev->of_node); + ret = devm_arm_smccc_set_conduit(dev); if (ret) return ret; -- 2.17.1
WARNING: multiple messages have this Message-ID (diff)
From: Etienne Carriere <etienne.carriere@linaro.org> To: linux-kernel@vger.kernel.org Cc: mark.rutland@arm.com, lorenzo.pieralisi@arm.com, michal.simek@xilinx.com, tee-dev@lists.linaro.org, Etienne Carriere <etienne.carriere@linaro.org>, james.morse@arm.com, sudeep.holla@arm.com, richard.gong@linux.intel.com, jens.wiklander@linaro.org, linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 6/6] firmware: zynqmp: use SMCCC v1.0 helper functions Date: Sun, 19 Apr 2020 17:05:30 +0200 [thread overview] Message-ID: <20200419150530.20508-7-etienne.carriere@linaro.org> (raw) In-Reply-To: <20200419150530.20508-1-etienne.carriere@linaro.org> Change Xilinx Zynmp driver to use Arm SMCCC v1.0 helper functions and ensure platform consistency on SMCCC conduit method. Main functional change is that SMCCC conduit method for ZynqMP firmware must be consistent with conduit methods registered by PSCI device that is early probed. Another functional change is an addition info trace emitted by the device probe sequence: "probing for conduit method from DT.". Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> --- drivers/firmware/xilinx/zynqmp.c | 87 ++++---------------------------- 1 file changed, 9 insertions(+), 78 deletions(-) diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c index 41b65164a367..1fdc468c9204 100644 --- a/drivers/firmware/xilinx/zynqmp.c +++ b/drivers/firmware/xilinx/zynqmp.c @@ -63,51 +63,11 @@ static int zynqmp_pm_ret_code(u32 ret_status) } } -static noinline int do_fw_call_fail(u64 arg0, u64 arg1, u64 arg2, - u32 *ret_payload) -{ - return -ENODEV; -} - -/* - * PM function call wrapper - * Invoke do_fw_call_smc or do_fw_call_hvc, depending on the configuration - */ -static int (*do_fw_call)(u64, u64, u64, u32 *ret_payload) = do_fw_call_fail; - -/** - * do_fw_call_smc() - Call system-level platform management layer (SMC) - * @arg0: Argument 0 to SMC call - * @arg1: Argument 1 to SMC call - * @arg2: Argument 2 to SMC call - * @ret_payload: Returned value array - * - * Invoke platform management function via SMC call (no hypervisor present). - * - * Return: Returns status, either success or error+reason - */ -static noinline int do_fw_call_smc(u64 arg0, u64 arg1, u64 arg2, - u32 *ret_payload) -{ - struct arm_smccc_res res; - - arm_smccc_smc(arg0, arg1, arg2, 0, 0, 0, 0, 0, &res); - - if (ret_payload) { - ret_payload[0] = lower_32_bits(res.a0); - ret_payload[1] = upper_32_bits(res.a0); - ret_payload[2] = lower_32_bits(res.a1); - ret_payload[3] = upper_32_bits(res.a1); - } - - return zynqmp_pm_ret_code((enum pm_ret_status)res.a0); -} - /** - * do_fw_call_hvc() - Call system-level platform management layer (HVC) - * @arg0: Argument 0 to HVC call - * @arg1: Argument 1 to HVC call - * @arg2: Argument 2 to HVC call + * do_fw_call() - Call system-level platform management layer + * @arg0: Argument 0 to HVC/SMC call + * @arg1: Argument 1 to HVC/SMC call + * @arg2: Argument 2 to HVC/SMC call * @ret_payload: Returned value array * * Invoke platform management function via HVC @@ -116,12 +76,13 @@ static noinline int do_fw_call_smc(u64 arg0, u64 arg1, u64 arg2, * * Return: Returns status, either success or error+reason */ -static noinline int do_fw_call_hvc(u64 arg0, u64 arg1, u64 arg2, - u32 *ret_payload) +static noinline int do_fw_call(u64 arg0, u64 arg1, u64 arg2, u32 *ret_payload) { struct arm_smccc_res res; - arm_smccc_hvc(arg0, arg1, arg2, 0, 0, 0, 0, 0, &res); + if (arm_smccc_1_0_invoke(arg0, arg1, arg2, 0, 0, 0, 0, 0, &res) == + SMCCC_CONDUIT_NONE) + return -ENODEV; if (ret_payload) { ret_payload[0] = lower_32_bits(res.a0); @@ -287,36 +248,6 @@ static int zynqmp_pm_get_trustzone_version(u32 *version) return ret; } -/** - * get_set_conduit_method() - Choose SMC or HVC based communication - * @np: Pointer to the device_node structure - * - * Use SMC or HVC-based functions to communicate with EL2/EL3. - * - * Return: Returns 0 on success or error code - */ -static int get_set_conduit_method(struct device_node *np) -{ - const char *method; - - if (of_property_read_string(np, "method", &method)) { - pr_warn("%s missing \"method\" property\n", __func__); - return -ENXIO; - } - - if (!strcmp("hvc", method)) { - do_fw_call = do_fw_call_hvc; - } else if (!strcmp("smc", method)) { - do_fw_call = do_fw_call_smc; - } else { - pr_warn("%s Invalid \"method\" property: %s\n", - __func__, method); - return -EINVAL; - } - - return 0; -} - /** * zynqmp_pm_query_data() - Get query data from firmware * @qdata: Variable to the zynqmp_pm_query_data structure @@ -790,7 +721,7 @@ static int zynqmp_firmware_probe(struct platform_device *pdev) } of_node_put(np); - ret = get_set_conduit_method(dev->of_node); + ret = devm_arm_smccc_set_conduit(dev); if (ret) return ret; -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-04-19 15:06 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-19 15:05 [RFC PATCH 0/6] firmware: conduit method helpers for SMCCC v1.0 calls Etienne Carriere 2020-04-19 15:05 ` Etienne Carriere 2020-04-19 15:05 ` [RFC PATCH 1/6] firmware: helper functions for SMCCC v1.0 invocation conduit Etienne Carriere 2020-04-19 15:05 ` Etienne Carriere 2020-04-19 15:51 ` Etienne Carriere 2020-04-19 15:51 ` Etienne Carriere 2020-04-21 9:52 ` kbuild test robot 2020-04-19 15:05 ` [RFC PATCH 2/6] firmware: psci: set SMCCC v1.0 conduit and use helpers functions Etienne Carriere 2020-04-19 15:05 ` Etienne Carriere 2020-04-19 15:05 ` [RFC PATCH 3/6] tee: optee: use SMCCC v1.0 helper functions Etienne Carriere 2020-04-19 15:05 ` Etienne Carriere 2020-04-19 15:05 ` [RFC PATCH 4/6] firmware: arm_sdei: " Etienne Carriere 2020-04-19 15:05 ` Etienne Carriere 2020-04-22 0:53 ` kbuild test robot 2020-04-19 15:05 ` [RFC PATCH 5/6] firmware: stratix10: " Etienne Carriere 2020-04-19 15:05 ` Etienne Carriere 2020-04-21 13:31 ` kbuild test robot 2020-04-21 13:50 ` kbuild test robot 2020-04-19 15:05 ` Etienne Carriere [this message] 2020-04-19 15:05 ` [RFC PATCH 6/6] firmware: zynqmp: " Etienne Carriere 2020-04-21 14:38 ` kbuild test robot 2020-04-21 15:14 ` kbuild test robot
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200419150530.20508-7-etienne.carriere@linaro.org \ --to=etienne.carriere@linaro.org \ --cc=james.morse@arm.com \ --cc=jens.wiklander@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=lorenzo.pieralisi@arm.com \ --cc=mark.rutland@arm.com \ --cc=michal.simek@xilinx.com \ --cc=richard.gong@linux.intel.com \ --cc=sudeep.holla@arm.com \ --cc=tee-dev@lists.linaro.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.