Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 21f9099c authored by Vikram Mulukutla's avatar Vikram Mulukutla
Browse files

soc: qcom: scm: Add LMH specific mutex lock



It is required on some hardware that the Limits Management
secure API be executed in mutual exclusion with certain
other hardware-accessing drivers. Provide a mutex to achieve
this.

Change-Id: Ie0db516e335c29b79e959a0a6e6fb76231af6bf4
Signed-off-by: default avatarVikram Mulukutla <markivx@codeaurora.org>
parent 66f4f85a
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -35,6 +35,13 @@

static DEFINE_MUTEX(scm_lock);

/*
 * MSM8996 V2 requires a lock to protect against
 * concurrent accesses between the limits management
 * driver and the clock controller
 */
DEFINE_MUTEX(scm_lmh_lock);

#define SCM_EBUSY_WAIT_MS 30
#define SCM_EBUSY_MAX_RETRY 20

@@ -634,6 +641,9 @@ int scm_call2(u32 fn_id, struct scm_desc *desc)
	do {
		mutex_lock(&scm_lock);

		if (SCM_SVC_ID(fn_id) == SCM_SVC_LMH)
			mutex_lock(&scm_lmh_lock);

		desc->ret[0] = desc->ret[1] = desc->ret[2] = 0;

		pr_debug("scm_call: func id %#llx, args: %#x, %#llx, %#llx, %#llx, %#llx\n",
@@ -652,6 +662,10 @@ int scm_call2(u32 fn_id, struct scm_desc *desc)
						  desc->args[2], desc->x5,
						  &desc->ret[0], &desc->ret[1],
						  &desc->ret[2]);

		if (SCM_SVC_ID(fn_id) == SCM_SVC_LMH)
			mutex_unlock(&scm_lmh_lock);

		mutex_unlock(&scm_lock);

		if (ret == SCM_V2_EBUSY)
+3 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ static char __n[PAGE_SIZE] __aligned(PAGE_SIZE);
#define SCM_SIP_FNID(s, c) (((((s) & 0xFF) << 8) | ((c) & 0xFF)) | 0x02000000)
#define SCM_QSEEOS_FNID(s, c) (((((s) & 0xFF) << 8) | ((c) & 0xFF)) | \
			      0x32000000)
#define SCM_SVC_ID(s) (((s) & 0xFF00) >> 8)

#define MAX_SCM_ARGS 10
#define MAX_SCM_RETS 3
@@ -130,6 +131,8 @@ struct scm_hdcp_req {
	u32 val;
};

extern struct mutex scm_lmh_lock;

#else

static inline int scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf,