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

Commit 5ea38959 authored by Kyle Yan's avatar Kyle Yan
Browse files

soc: qcom: pil: Signal call to cleanup TZ internal state in failure



On error cases where we fail to bring up the subsystem, we also need
to make sure TZ is aware so that it can clean up its internal state.
Without this call, TZ may incorrectly assume that a memory address from
generic CMA pool belongs to only one particular subsystem.

Change-Id: I150027af3c5dc687f558cd5e5130488096c5a2d2
Signed-off-by: default avatarKyle Yan <kyan@codeaurora.org>
parent d98d9ee8
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -795,6 +795,33 @@ static int pil_shutdown_trusted(struct pil_desc *pil)
	return rc;
}

static int pil_deinit_image_trusted(struct pil_desc *pil)
{
	struct pil_tz_data *d = desc_to_data(pil);
	u32 proc, scm_ret = 0;
	int rc;
	struct scm_desc desc = {0};

	if (d->subsys_desc.no_auth)
		return 0;

	desc.args[0] = proc = d->pas_id;
	desc.arginfo = SCM_ARGS(1);

	if (!is_scm_armv8()) {
		rc = scm_call(SCM_SVC_PIL, PAS_SHUTDOWN_CMD, &proc,
			      sizeof(proc), &scm_ret, sizeof(scm_ret));
	} else {
		rc = scm_call2(SCM_SIP_FNID(SCM_SVC_PIL, PAS_SHUTDOWN_CMD),
			       &desc);
		scm_ret = desc.ret[0];
	}

	if (rc)
		return rc;
	return scm_ret;
}

static struct pil_reset_ops pil_ops_trusted = {
	.init_image = pil_init_image_trusted,
	.mem_setup =  pil_mem_setup_trusted,
@@ -802,6 +829,7 @@ static struct pil_reset_ops pil_ops_trusted = {
	.shutdown = pil_shutdown_trusted,
	.proxy_vote = pil_make_proxy_vote,
	.proxy_unvote = pil_remove_proxy_vote,
	.deinit_image = pil_deinit_image_trusted,
};

static void log_failure_reason(const struct pil_tz_data *d)