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

Commit 276f27d3 authored by Tharun Kumar Merugu's avatar Tharun Kumar Merugu Committed by Gerrit - the friendly Code Review server
Browse files

msm: adsprpc: maintain local copy of rpra offloaded to DSP



Since DSP is not supposed to modify the base pointer rpra of the
input/output arguments offloaded to DSP, maintain a local copy of
the pointer and use it after receiving interrupt from DSP.

Change-Id: I4afade7184cb2aca148060fb0cda06c6174f3b55
Acked-by: default avatarMaitreyi Gupta <maitreyi@qti.qualcomm.com>
Signed-off-by: default avatarTharun Kumar Merugu <mtharu@codeaurora.org>
Signed-off-by: default avatarMohammed Nayeem Ur Rahman <mohara@codeaurora.org>
parent 8a87752a
Loading
Loading
Loading
Loading
+35 −16
Original line number Diff line number Diff line
@@ -225,9 +225,11 @@ struct smq_invoke_ctx {
	int tgid;
	remote_arg_t *lpra;
	remote_arg64_t *rpra;
	remote_arg64_t *lrpra;		/* Local copy of rpra for put_args */
	int *fds;
	struct fastrpc_mmap **maps;
	struct fastrpc_buf *buf;
	struct fastrpc_buf *lbuf;
	size_t used;
	struct fastrpc_file *fl;
	uint32_t sc;
@@ -1273,6 +1275,7 @@ static void context_free(struct smq_invoke_ctx *ctx)

	mutex_unlock(&ctx->fl->fl_map_mutex);
	fastrpc_buf_free(ctx->buf, 1);
	fastrpc_buf_free(ctx->lbuf, 1);
	ctx->magic = 0;
	ctx->ctxid = 0;

@@ -1419,7 +1422,7 @@ static void fastrpc_file_list_dtor(struct fastrpc_apps *me)
static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx)
{
	struct fastrpc_apps *me = &gfa;
	remote_arg64_t *rpra;
	remote_arg64_t *rpra, *lrpra;
	remote_arg_t *lpra = ctx->lpra;
	struct smq_invoke_buf *list;
	struct smq_phy_page *pages, *ipage;
@@ -1428,7 +1431,7 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx)
	int outbufs = REMOTE_SCALARS_OUTBUFS(sc);
	int handles, bufs = inbufs + outbufs;
	uintptr_t args;
	size_t rlen = 0, copylen = 0, metalen = 0;
	size_t rlen = 0, copylen = 0, metalen = 0, lrpralen = 0;
	int i, oix;
	int err = 0;
	int mflags = 0;
@@ -1486,7 +1489,20 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx)
		metalen = copylen = (size_t)&ipage[0];
	}

	/* calculate len requreed for copying */
	/* allocate new local rpra buffer */
	lrpralen = (size_t)&list[0];
	if (lrpralen) {
		err = fastrpc_buf_alloc(ctx->fl, lrpralen, 0, 0, 0, &ctx->lbuf);
		if (err)
			goto bail;
	}
	if (ctx->lbuf->virt)
		memset(ctx->lbuf->virt, 0, lrpralen);

	lrpra = ctx->lbuf->virt;
	ctx->lrpra = lrpra;

	/* calculate len required for copying */
	for (oix = 0; oix < inbufs + outbufs; ++oix) {
		int i = ctx->overps[oix]->raix;
		uintptr_t mstart, mend;
@@ -1537,13 +1553,13 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx)

	/* map ion buffers */
	PERF(ctx->fl->profile, GET_COUNTER(perf_counter, PERF_MAP),
	for (i = 0; rpra && i < inbufs + outbufs; ++i) {
	for (i = 0; rpra && lrpra && i < inbufs + outbufs; ++i) {
		struct fastrpc_mmap *map = ctx->maps[i];
		uint64_t buf = ptr_to_uint64(lpra[i].buf.pv);
		size_t len = lpra[i].buf.len;

		rpra[i].buf.pv = 0;
		rpra[i].buf.len = len;
		rpra[i].buf.pv = lrpra[i].buf.pv = 0;
		rpra[i].buf.len = lrpra[i].buf.len = len;
		if (!len)
			continue;
		if (map) {
@@ -1571,7 +1587,7 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx)
			pages[idx].addr = map->phys + offset;
			pages[idx].size = num << PAGE_SHIFT;
		}
		rpra[i].buf.pv = buf;
		rpra[i].buf.pv = lrpra[i].buf.pv = buf;
	}
	PERF_END);
	for (i = bufs; i < bufs + handles; ++i) {
@@ -1591,7 +1607,7 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx)
	/* copy non ion buffers */
	PERF(ctx->fl->profile, GET_COUNTER(perf_counter, PERF_COPY),
	rlen = copylen - metalen;
	for (oix = 0; rpra && oix < inbufs + outbufs; ++oix) {
	for (oix = 0; rpra && lrpra && oix < inbufs + outbufs; ++oix) {
		int i = ctx->overps[oix]->raix;
		struct fastrpc_mmap *map = ctx->maps[i];
		size_t mlen;
@@ -1610,7 +1626,8 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx)
		VERIFY(err, rlen >= mlen);
		if (err)
			goto bail;
		rpra[i].buf.pv = (args - ctx->overps[oix]->offset);
		rpra[i].buf.pv = lrpra[i].buf.pv =
			 (args - ctx->overps[oix]->offset);
		pages[list[i].pgidx].addr = ctx->buf->phys -
					    ctx->overps[oix]->offset +
					    (copylen - rlen);
@@ -1642,7 +1659,8 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx)
		if (map && (map->attr & FASTRPC_ATTR_COHERENT))
			continue;

		if (rpra && rpra[i].buf.len && ctx->overps[oix]->mstart) {
		if (rpra && lrpra && rpra[i].buf.len &&
			ctx->overps[oix]->mstart) {
			if (map && map->handle)
				msm_ion_do_cache_op(ctx->fl->apps->client,
					map->handle,
@@ -1656,10 +1674,11 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx)
		}
	}
	PERF_END);
	for (i = bufs; rpra && i < bufs + handles; i++) {
		rpra[i].dma.fd = ctx->fds[i];
		rpra[i].dma.len = (uint32_t)lpra[i].buf.len;
		rpra[i].dma.offset = (uint32_t)(uintptr_t)lpra[i].buf.pv;
	for (i = bufs; rpra && lrpra && i < bufs + handles; i++) {
		rpra[i].dma.fd = lrpra[i].dma.fd = ctx->fds[i];
		rpra[i].dma.len = lrpra[i].dma.len = (uint32_t)lpra[i].buf.len;
		rpra[i].dma.offset = lrpra[i].dma.offset =
			 (uint32_t)(uintptr_t)lpra[i].buf.pv;
	}

 bail:
@@ -1677,7 +1696,7 @@ static int put_args(uint32_t kernel, struct smq_invoke_ctx *ctx,
	uint64_t *fdlist = NULL;
	uint32_t *crclist = NULL;

	remote_arg64_t *rpra = ctx->rpra;
	remote_arg64_t *rpra = ctx->lrpra;
	int i, inbufs, outbufs, handles;
	int err = 0;

@@ -1784,7 +1803,7 @@ static void inv_args(struct smq_invoke_ctx *ctx)
{
	int i, inbufs, outbufs;
	uint32_t sc = ctx->sc;
	remote_arg64_t *rpra = ctx->rpra;
	remote_arg64_t *rpra = ctx->lrpra;

	inbufs = REMOTE_SCALARS_INBUFS(sc);
	outbufs = REMOTE_SCALARS_OUTBUFS(sc);