From: Stephen Boyd <sboyd@codeaurora.org> To: David Brown <davidb@codeaurora.org>, Kumar Gala <galak@codeaurora.org> Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lina Iyer <lina.iyer@linaro.org> Subject: [PATCH 4/8] msm: scm: Add atomic SCM APIs Date: Mon, 4 Aug 2014 18:31:46 -0700 [thread overview] Message-ID: <1407202310-3359-5-git-send-email-sboyd@codeaurora.org> (raw) In-Reply-To: <1407202310-3359-1-git-send-email-sboyd@codeaurora.org> The atomic SCM APIs are useful for commands that are guaranteed by the secure side to be uninterruptable, atomic and SMP safe. The calling convention use registers for passing parameters and return values between the secure and non-secure side. Support this interface with scm_call_atomic[1-2]() functions corresponding to the number of arguments passed. Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> --- arch/arm/mach-qcom/scm.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-qcom/scm.h | 5 +++- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-qcom/scm.c b/arch/arm/mach-qcom/scm.c index ec37b037e69c..a05cad3fa1c5 100644 --- a/arch/arm/mach-qcom/scm.c +++ b/arch/arm/mach-qcom/scm.c @@ -286,6 +286,79 @@ out: } EXPORT_SYMBOL(scm_call); +#define SCM_CLASS_REGISTER (0x2 << 8) +#define SCM_MASK_IRQS BIT(5) +#define SCM_ATOMIC(svc, cmd, n) (((((svc) << 10)|((cmd) & 0x3ff)) << 12) | \ + SCM_CLASS_REGISTER | \ + SCM_MASK_IRQS | \ + (n & 0xf)) + +/** + * scm_call_atomic1() - Send an atomic SCM command with one argument + * @svc_id: service identifier + * @cmd_id: command identifier + * @arg1: first argument + * + * This shall only be used with commands that are guaranteed to be + * uninterruptable, atomic and SMP safe. + */ +s32 scm_call_atomic1(u32 svc, u32 cmd, u32 arg1) +{ + int context_id; + register u32 r0 asm("r0") = SCM_ATOMIC(svc, cmd, 1); + register u32 r1 asm("r1") = (u32)&context_id; + register u32 r2 asm("r2") = arg1; + + asm volatile( + __asmeq("%0", "r0") + __asmeq("%1", "r0") + __asmeq("%2", "r1") + __asmeq("%3", "r2") +#ifdef REQUIRES_SEC + ".arch_extension sec\n" +#endif + "smc #0 @ switch to secure world\n" + : "=r" (r0) + : "r" (r0), "r" (r1), "r" (r2) + : "r3"); + return r0; +} +EXPORT_SYMBOL(scm_call_atomic1); + +/** + * scm_call_atomic2() - Send an atomic SCM command with two arguments + * @svc_id: service identifier + * @cmd_id: command identifier + * @arg1: first argument + * @arg2: second argument + * + * This shall only be used with commands that are guaranteed to be + * uninterruptable, atomic and SMP safe. + */ +s32 scm_call_atomic2(u32 svc, u32 cmd, u32 arg1, u32 arg2) +{ + int context_id; + register u32 r0 asm("r0") = SCM_ATOMIC(svc, cmd, 2); + register u32 r1 asm("r1") = (u32)&context_id; + register u32 r2 asm("r2") = arg1; + register u32 r3 asm("r3") = arg2; + + asm volatile( + __asmeq("%0", "r0") + __asmeq("%1", "r0") + __asmeq("%2", "r1") + __asmeq("%3", "r2") + __asmeq("%4", "r3") +#ifdef REQUIRES_SEC + ".arch_extension sec\n" +#endif + "smc #0 @ switch to secure world\n" + : "=r" (r0) + : "r" (r0), "r" (r1), "r" (r2), "r" (r3)); + return r0; +} +EXPORT_SYMBOL(scm_call_atomic2); + u32 scm_get_version(void) { int context_id; diff --git a/arch/arm/mach-qcom/scm.h b/arch/arm/mach-qcom/scm.h index 00b31ea58f29..1f0f0180e767 100644 --- a/arch/arm/mach-qcom/scm.h +++ b/arch/arm/mach-qcom/scm.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2010-2014, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -18,6 +18,9 @@ extern int scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf, size_t cmd_len, void *resp_buf, size_t resp_len); +extern s32 scm_call_atomic1(u32 svc, u32 cmd, u32 arg1); +extern s32 scm_call_atomic2(u32 svc, u32 cmd, u32 arg1, u32 arg2); + #define SCM_VERSION(major, minor) (((major) << 16) | ((minor) & 0xFF)) extern u32 scm_get_version(void); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
WARNING: multiple messages have this Message-ID (diff)
From: sboyd@codeaurora.org (Stephen Boyd) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/8] msm: scm: Add atomic SCM APIs Date: Mon, 4 Aug 2014 18:31:46 -0700 [thread overview] Message-ID: <1407202310-3359-5-git-send-email-sboyd@codeaurora.org> (raw) In-Reply-To: <1407202310-3359-1-git-send-email-sboyd@codeaurora.org> The atomic SCM APIs are useful for commands that are guaranteed by the secure side to be uninterruptable, atomic and SMP safe. The calling convention use registers for passing parameters and return values between the secure and non-secure side. Support this interface with scm_call_atomic[1-2]() functions corresponding to the number of arguments passed. Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> --- arch/arm/mach-qcom/scm.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-qcom/scm.h | 5 +++- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-qcom/scm.c b/arch/arm/mach-qcom/scm.c index ec37b037e69c..a05cad3fa1c5 100644 --- a/arch/arm/mach-qcom/scm.c +++ b/arch/arm/mach-qcom/scm.c @@ -286,6 +286,79 @@ out: } EXPORT_SYMBOL(scm_call); +#define SCM_CLASS_REGISTER (0x2 << 8) +#define SCM_MASK_IRQS BIT(5) +#define SCM_ATOMIC(svc, cmd, n) (((((svc) << 10)|((cmd) & 0x3ff)) << 12) | \ + SCM_CLASS_REGISTER | \ + SCM_MASK_IRQS | \ + (n & 0xf)) + +/** + * scm_call_atomic1() - Send an atomic SCM command with one argument + * @svc_id: service identifier + * @cmd_id: command identifier + * @arg1: first argument + * + * This shall only be used with commands that are guaranteed to be + * uninterruptable, atomic and SMP safe. + */ +s32 scm_call_atomic1(u32 svc, u32 cmd, u32 arg1) +{ + int context_id; + register u32 r0 asm("r0") = SCM_ATOMIC(svc, cmd, 1); + register u32 r1 asm("r1") = (u32)&context_id; + register u32 r2 asm("r2") = arg1; + + asm volatile( + __asmeq("%0", "r0") + __asmeq("%1", "r0") + __asmeq("%2", "r1") + __asmeq("%3", "r2") +#ifdef REQUIRES_SEC + ".arch_extension sec\n" +#endif + "smc #0 @ switch to secure world\n" + : "=r" (r0) + : "r" (r0), "r" (r1), "r" (r2) + : "r3"); + return r0; +} +EXPORT_SYMBOL(scm_call_atomic1); + +/** + * scm_call_atomic2() - Send an atomic SCM command with two arguments + * @svc_id: service identifier + * @cmd_id: command identifier + * @arg1: first argument + * @arg2: second argument + * + * This shall only be used with commands that are guaranteed to be + * uninterruptable, atomic and SMP safe. + */ +s32 scm_call_atomic2(u32 svc, u32 cmd, u32 arg1, u32 arg2) +{ + int context_id; + register u32 r0 asm("r0") = SCM_ATOMIC(svc, cmd, 2); + register u32 r1 asm("r1") = (u32)&context_id; + register u32 r2 asm("r2") = arg1; + register u32 r3 asm("r3") = arg2; + + asm volatile( + __asmeq("%0", "r0") + __asmeq("%1", "r0") + __asmeq("%2", "r1") + __asmeq("%3", "r2") + __asmeq("%4", "r3") +#ifdef REQUIRES_SEC + ".arch_extension sec\n" +#endif + "smc #0 @ switch to secure world\n" + : "=r" (r0) + : "r" (r0), "r" (r1), "r" (r2), "r" (r3)); + return r0; +} +EXPORT_SYMBOL(scm_call_atomic2); + u32 scm_get_version(void) { int context_id; diff --git a/arch/arm/mach-qcom/scm.h b/arch/arm/mach-qcom/scm.h index 00b31ea58f29..1f0f0180e767 100644 --- a/arch/arm/mach-qcom/scm.h +++ b/arch/arm/mach-qcom/scm.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2010-2014, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -18,6 +18,9 @@ extern int scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf, size_t cmd_len, void *resp_buf, size_t resp_len); +extern s32 scm_call_atomic1(u32 svc, u32 cmd, u32 arg1); +extern s32 scm_call_atomic2(u32 svc, u32 cmd, u32 arg1, u32 arg2); + #define SCM_VERSION(major, minor) (((major) << 16) | ((minor) & 0xFF)) extern u32 scm_get_version(void); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
next prev parent reply other threads:[~2014-08-05 1:33 UTC|newest] Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-08-05 1:31 [PATCH 0/8] qcom SCM updates Stephen Boyd 2014-08-05 1:31 ` Stephen Boyd 2014-08-05 1:31 ` [PATCH 1/8] msm: scm: Fix incorrect cache invalidation Stephen Boyd 2014-08-05 1:31 ` Stephen Boyd 2014-08-05 1:31 ` [PATCH 2/8] msm: scm: Get cacheline size from CTR Stephen Boyd 2014-08-05 1:31 ` Stephen Boyd 2014-08-05 1:31 ` Stephen Boyd 2014-08-05 1:31 ` [PATCH 3/8] msm: scm: Flush the command buffer only instead of the entire cache Stephen Boyd 2014-08-05 1:31 ` Stephen Boyd 2014-08-05 1:31 ` Stephen Boyd 2014-08-05 1:31 ` Stephen Boyd [this message] 2014-08-05 1:31 ` [PATCH 4/8] msm: scm: Add atomic SCM APIs Stephen Boyd 2014-08-05 1:31 ` [PATCH 5/8] msm: scm: Add API to query for service/command availability Stephen Boyd 2014-08-05 1:31 ` Stephen Boyd 2014-08-05 1:31 ` Stephen Boyd 2014-08-05 1:31 ` [PATCH 6/8] msm: scm: Add a feat version query API Stephen Boyd 2014-08-05 1:31 ` Stephen Boyd 2014-08-05 1:31 ` [PATCH 7/8] msm: scm: Add logging of actual return code from scm call Stephen Boyd 2014-08-05 1:31 ` Stephen Boyd 2014-08-05 1:31 ` [PATCH 8/8] msm: scm: Move the scm driver to drivers/soc/qcom Stephen Boyd 2014-08-05 1:31 ` Stephen Boyd 2014-08-05 4:07 ` Lina Iyer 2014-08-05 4:07 ` Lina Iyer 2014-08-05 20:12 ` Bjorn Andersson 2014-08-05 20:12 ` Bjorn Andersson 2014-08-05 20:12 ` Bjorn Andersson 2014-08-05 20:17 ` Lina Iyer 2014-08-05 20:17 ` Lina Iyer 2014-08-05 20:17 ` Lina Iyer 2015-01-22 1:13 ` Olof Johansson 2015-01-22 1:13 ` Olof Johansson 2015-01-22 1:13 ` Olof Johansson 2015-01-22 1:53 ` Bjorn Andersson 2015-01-22 1:53 ` Bjorn Andersson 2015-01-22 1:53 ` Bjorn Andersson 2015-01-22 16:49 ` Kumar Gala 2015-01-22 16:49 ` Kumar Gala 2015-01-22 16:49 ` Kumar Gala 2015-01-23 1:19 ` Rob Clark 2015-01-23 1:19 ` Rob Clark 2015-01-23 1:19 ` Rob Clark 2014-09-17 22:08 ` [PATCH 0/8] qcom SCM updates Kumar Gala 2014-09-17 22:08 ` Kumar Gala
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=1407202310-3359-5-git-send-email-sboyd@codeaurora.org \ --to=sboyd@codeaurora.org \ --cc=davidb@codeaurora.org \ --cc=galak@codeaurora.org \ --cc=lina.iyer@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-arm-msm@vger.kernel.org \ --cc=linux-kernel@vger.kernel.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.