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

Commit 4e76b1c1 authored by Anuj's avatar Anuj
Browse files

adsprpc: Enabling the hibernation support



The change will not reclaim the secure buffer memory using hyp assign
to HLOS in hibernation restore

After hibernation the secure memory is with HLOS as TZ encountered a
coldboot sequence.

Change-Id: I50fb169ca4cb28f3fb589aa7f3fa7cf3d69d445f
Signed-off-by: default avatarAnuj <anujgarg@codeaurora.org>
parent 83553255
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -308,6 +308,7 @@ struct fastrpc_apps {
	spinlock_t ctxlock;
	struct smq_invoke_ctx *ctxtable[FASTRPC_CTX_MAX];
	bool legacy_remote_heap;
	int in_hib;
};

struct fastrpc_mmap {
@@ -501,6 +502,7 @@ static void fastrpc_buf_free(struct fastrpc_buf *buf, int cache)
{
	struct fastrpc_file *fl = buf == NULL ? NULL : buf->fl;
	int vmid;
	struct fastrpc_apps *me = &gfa;

	if (!fl)
		return;
@@ -524,7 +526,7 @@ static void fastrpc_buf_free(struct fastrpc_buf *buf, int cache)
		if (fl->sctx->smmu.cb && fl->cid != SDSP_DOMAIN_ID)
			buf->phys &= ~((uint64_t)fl->sctx->smmu.cb << 32);
		vmid = fl->apps->channel[fl->cid].vmid;
		if (vmid) {
		if ((vmid) && (me->in_hib == 0)) {
			int srcVM[2] = {VMID_HLOS, vmid};

			hyp_assign_phys(buf->phys, buf_page_size(buf->size),
@@ -752,7 +754,7 @@ static void fastrpc_mmap_free(struct fastrpc_mmap *map, uint32_t flags)
			sess = fl->sctx;

		vmid = fl->apps->channel[fl->cid].vmid;
		if (vmid && map->phys) {
		if (vmid && map->phys && me->in_hib == 0) {
			int srcVM[2] = {VMID_HLOS, vmid};

			hyp_assign_phys(map->phys, buf_page_size(map->size),
@@ -2243,7 +2245,8 @@ static int fastrpc_init_process(struct fastrpc_file *fl,
		me->staticpd_flags = 0;
	if (mem && err) {
		if (mem->flags == ADSP_MMAP_REMOTE_HEAP_ADDR
			&& me->channel[fl->cid].rhvm.vmid)
			&& me->channel[fl->cid].rhvm.vmid
			&& me->in_hib == 0)
			hyp_assign_phys(mem->phys, (uint64_t)mem->size,
					me->channel[fl->cid].rhvm.vmid,
					me->channel[fl->cid].rhvm.vmcount,
@@ -2412,7 +2415,7 @@ static int fastrpc_munmap_on_dsp_rh(struct fastrpc_file *fl, uint64_t phys,
		err = scm_call2(SCM_SIP_FNID(SCM_SVC_PIL,
			TZ_PIL_CLEAR_PROTECT_MEM_SUBSYS_ID), &desc);
	} else if (flags == ADSP_MMAP_REMOTE_HEAP_ADDR) {
		if (me->channel[fl->cid].rhvm.vmid) {
		if ((me->channel[fl->cid].rhvm.vmid) && (me->in_hib == 0)) {
			VERIFY(err, !hyp_assign_phys(phys,
					(uint64_t)size,
					me->channel[fl->cid].rhvm.vmid,
@@ -3254,6 +3257,7 @@ static int fastrpc_channel_open(struct fastrpc_file *fl)
		me->channel[cid].prevssrcount =
					me->channel[cid].ssrcount;
	}
	me->in_hib = 0;
	mutex_unlock(&me->channel[cid].smd_mutex);

bail:
@@ -4147,6 +4151,7 @@ static int fastrpc_restore(struct device *dev)
	uint32_t val;

	pr_info("adsprpc: restore enter\n");
	me->in_hib = 1;
	if (of_device_is_compatible(dev->of_node,
					"qcom,msm-adsprpc-mem-region")) {
		me->dev = dev;
@@ -4244,6 +4249,7 @@ static int __init fastrpc_device_init(void)
	fastrpc_init(me);
	me->dev = NULL;
	me->legacy_remote_heap = 0;
	me->in_hib = 0;
	VERIFY(err, 0 == platform_driver_register(&fastrpc_driver));
	if (err)
		goto register_bail;