aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Gross <andy.gross@linaro.org>2017-02-01 12:28:28 -0500
committerWill Deacon <will.deacon@arm.com>2017-02-03 13:46:33 -0500
commit82bcd087029f6056506ea929f11af02622230901 (patch)
tree650b58791c4043fcfba21b78654723affaaff66a
parent680a0873e193bae666439f4b5e32c758e68f114c (diff)
firmware: qcom: scm: Fix interrupted SCM calls
This patch adds a Qualcomm specific quirk to the arm_smccc_smc call. On Qualcomm ARM64 platforms, the SMC call can return before it has completed. If this occurs, the call can be restarted, but it requires using the returned session ID value from the interrupted SMC call. The quirk stores off the session ID from the interrupted call in the quirk structure so that it can be used by the caller. This patch folds in a fix given by Sricharan R: https://lkml.org/lkml/2016/9/28/272 Signed-off-by: Andy Gross <andy.gross@linaro.org> Reviewed-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r--arch/arm64/kernel/smccc-call.S9
-rw-r--r--drivers/firmware/qcom_scm-64.c13
-rw-r--r--include/linux/arm-smccc.h11
3 files changed, 26 insertions, 7 deletions
diff --git a/arch/arm64/kernel/smccc-call.S b/arch/arm64/kernel/smccc-call.S
index ba60a8cb07d2..62522342e1e4 100644
--- a/arch/arm64/kernel/smccc-call.S
+++ b/arch/arm64/kernel/smccc-call.S
@@ -12,6 +12,7 @@
12 * 12 *
13 */ 13 */
14#include <linux/linkage.h> 14#include <linux/linkage.h>
15#include <linux/arm-smccc.h>
15#include <asm/asm-offsets.h> 16#include <asm/asm-offsets.h>
16 17
17 .macro SMCCC instr 18 .macro SMCCC instr
@@ -20,7 +21,13 @@
20 ldr x4, [sp] 21 ldr x4, [sp]
21 stp x0, x1, [x4, #ARM_SMCCC_RES_X0_OFFS] 22 stp x0, x1, [x4, #ARM_SMCCC_RES_X0_OFFS]
22 stp x2, x3, [x4, #ARM_SMCCC_RES_X2_OFFS] 23 stp x2, x3, [x4, #ARM_SMCCC_RES_X2_OFFS]
23 ret 24 ldr x4, [sp, #8]
25 cbz x4, 1f /* no quirk structure */
26 ldr x9, [x4, #ARM_SMCCC_QUIRK_ID_OFFS]
27 cmp x9, #ARM_SMCCC_QUIRK_QCOM_A6
28 b.ne 1f
29 str x6, [x4, ARM_SMCCC_QUIRK_STATE_OFFS]
301: ret
24 .cfi_endproc 31 .cfi_endproc
25 .endm 32 .endm
26 33
diff --git a/drivers/firmware/qcom_scm-64.c b/drivers/firmware/qcom_scm-64.c
index 4a0f5ead4fb5..1e2e5198db53 100644
--- a/drivers/firmware/qcom_scm-64.c
+++ b/drivers/firmware/qcom_scm-64.c
@@ -91,6 +91,7 @@ static int qcom_scm_call(struct device *dev, u32 svc_id, u32 cmd_id,
91 dma_addr_t args_phys = 0; 91 dma_addr_t args_phys = 0;
92 void *args_virt = NULL; 92 void *args_virt = NULL;
93 size_t alloc_len; 93 size_t alloc_len;
94 struct arm_smccc_quirk quirk = {.id = ARM_SMCCC_QUIRK_QCOM_A6};
94 95
95 if (unlikely(arglen > N_REGISTER_ARGS)) { 96 if (unlikely(arglen > N_REGISTER_ARGS)) {
96 alloc_len = N_EXT_QCOM_SCM_ARGS * sizeof(u64); 97 alloc_len = N_EXT_QCOM_SCM_ARGS * sizeof(u64);
@@ -131,10 +132,16 @@ static int qcom_scm_call(struct device *dev, u32 svc_id, u32 cmd_id,
131 qcom_smccc_convention, 132 qcom_smccc_convention,
132 ARM_SMCCC_OWNER_SIP, fn_id); 133 ARM_SMCCC_OWNER_SIP, fn_id);
133 134
135 quirk.state.a6 = 0;
136
134 do { 137 do {
135 arm_smccc_smc(cmd, desc->arginfo, desc->args[0], 138 arm_smccc_smc_quirk(cmd, desc->arginfo, desc->args[0],
136 desc->args[1], desc->args[2], x5, 0, 0, 139 desc->args[1], desc->args[2], x5,
137 res); 140 quirk.state.a6, 0, res, &quirk);
141
142 if (res->a0 == QCOM_SCM_INTERRUPTED)
143 cmd = res->a0;
144
138 } while (res->a0 == QCOM_SCM_INTERRUPTED); 145 } while (res->a0 == QCOM_SCM_INTERRUPTED);
139 146
140 mutex_unlock(&qcom_scm_lock); 147 mutex_unlock(&qcom_scm_lock);
diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h
index c66f8ae94b5a..b67934164401 100644
--- a/include/linux/arm-smccc.h
+++ b/include/linux/arm-smccc.h
@@ -14,9 +14,6 @@
14#ifndef __LINUX_ARM_SMCCC_H 14#ifndef __LINUX_ARM_SMCCC_H
15#define __LINUX_ARM_SMCCC_H 15#define __LINUX_ARM_SMCCC_H
16 16
17#include <linux/linkage.h>
18#include <linux/types.h>
19
20/* 17/*
21 * This file provides common defines for ARM SMC Calling Convention as 18 * This file provides common defines for ARM SMC Calling Convention as
22 * specified in 19 * specified in
@@ -60,6 +57,13 @@
60#define ARM_SMCCC_OWNER_TRUSTED_OS 50 57#define ARM_SMCCC_OWNER_TRUSTED_OS 50
61#define ARM_SMCCC_OWNER_TRUSTED_OS_END 63 58#define ARM_SMCCC_OWNER_TRUSTED_OS_END 63
62 59
60#define ARM_SMCCC_QUIRK_NONE 0
61#define ARM_SMCCC_QUIRK_QCOM_A6 1 /* Save/restore register a6 */
62
63#ifndef __ASSEMBLY__
64
65#include <linux/linkage.h>
66#include <linux/types.h>
63/** 67/**
64 * struct arm_smccc_res - Result from SMC/HVC call 68 * struct arm_smccc_res - Result from SMC/HVC call
65 * @a0-a3 result values from registers 0 to 3 69 * @a0-a3 result values from registers 0 to 3
@@ -125,4 +129,5 @@ asmlinkage void __arm_smccc_hvc(unsigned long a0, unsigned long a1,
125 129
126#define arm_smccc_hvc_quirk(...) __arm_smccc_hvc(__VA_ARGS__) 130#define arm_smccc_hvc_quirk(...) __arm_smccc_hvc(__VA_ARGS__)
127 131
132#endif /*__ASSEMBLY__*/
128#endif /*__LINUX_ARM_SMCCC_H*/ 133#endif /*__LINUX_ARM_SMCCC_H*/