ADSPRPC: Use msm_ion_do_cache_op to flush userspace buffers

Remove the use of dmac_flush_range for userspace buffers and add
msm_ion_do_cache_op for flushing user space buffers.

Change-Id: Ice73eafac840bd1cabee0a2bfc8a641832a7d0c8
Acked-by: Bharath Kumar <bkumar@qti.qualcomm.com>
Signed-off-by: Tharun Kumar Merugu <mtharu@codeaurora.org>
This commit is contained in:
Tharun Kumar Merugu 2019-07-10 12:42:04 +05:30 committed by syphyr
parent fe72269ca7
commit 55f2ac015a
1 changed files with 50 additions and 16 deletions

View File

@ -178,6 +178,7 @@ struct fastrpc_apps {
dev_t dev_no;
int compat;
struct hlist_head drivers;
struct ion_client *client;
spinlock_t hlock;
int32_t domain_id;
struct device *adsp_mem_device;
@ -199,6 +200,7 @@ struct fastrpc_mmap {
uintptr_t va;
size_t len;
int refs;
int uncached;
uintptr_t raddr;
struct ion_handle *handle;
struct ion_client *client;
@ -912,10 +914,24 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx)
rlen -= mlen;
}
for (i = 0; i < inbufs; ++i) {
if (rpra && lrpra && rpra[i].buf.len)
dmac_flush_range(uint64_to_ptr(rpra[i].buf.pv),
uint64_to_ptr(rpra[i].buf.pv + rpra[i].buf.len));
for (oix = 0; oix < inbufs + outbufs; ++oix) {
int i = ctx->overps[oix]->raix;
struct fastrpc_mmap *map = ctx->maps[i];
if (map && map->uncached)
continue;
if (rpra[i].buf.len && ctx->overps[oix]->mstart) {
if (map && map->handle)
msm_ion_do_cache_op(ctx->fl->apps->client,
map->handle,
uint64_to_ptr(rpra[i].buf.pv),
rpra[i].buf.len,
ION_IOC_CLEAN_INV_CACHES);
else
dmac_flush_range(uint64_to_ptr(rpra[i].buf.pv),
uint64_to_ptr(rpra[i].buf.pv
+ rpra[i].buf.len));
}
}
inh = inbufs + outbufs;
for (i = 0; rpra && lrpra && i < REMOTE_SCALARS_INHANDLES(sc); i++) {
@ -926,7 +942,6 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx)
rpra[inh + i].h = lrpra[inh + i].h =
ctx->lpra[inh + i].h;
}
dmac_flush_range((char *)rpra, (char *)rpra + ctx->used);
bail:
return err;
}
@ -966,27 +981,49 @@ static int put_args(uint32_t kernel, struct smq_invoke_ctx *ctx,
return err;
}
static void inv_args_pre(uint32_t sc, remote_arg64_t *rpra)
static void inv_args_pre(struct smq_invoke_ctx *ctx)
{
int i, inbufs, outbufs;
uint32_t sc = ctx->sc;
remote_arg64_t *rpra = ctx->rpra;
uintptr_t end;
inbufs = REMOTE_SCALARS_INBUFS(sc);
outbufs = REMOTE_SCALARS_OUTBUFS(sc);
for (i = inbufs; i < inbufs + outbufs; ++i) {
struct fastrpc_mmap *map = ctx->maps[i];
if (!rpra[i].buf.len)
continue;
if (buf_page_start(ptr_to_uint64((void *)rpra)) ==
buf_page_start(rpra[i].buf.pv))
continue;
if (!IS_CACHE_ALIGNED((uintptr_t)uint64_to_ptr(rpra[i].buf.pv)))
dmac_flush_range(uint64_to_ptr(rpra[i].buf.pv),
(char *)(uint64_to_ptr(rpra[i].buf.pv + 1)));
if (!IS_CACHE_ALIGNED((uintptr_t)
uint64_to_ptr(rpra[i].buf.pv))) {
if (map && map->handle)
msm_ion_do_cache_op(ctx->fl->apps->client,
map->handle,
uint64_to_ptr(rpra[i].buf.pv),
sizeof(uintptr_t),
ION_IOC_CLEAN_INV_CACHES);
else
dmac_flush_range(
uint64_to_ptr(rpra[i].buf.pv), (char *)
uint64_to_ptr(rpra[i].buf.pv + 1));
}
end = (uintptr_t)uint64_to_ptr(rpra[i].buf.pv +
rpra[i].buf.len);
if (!IS_CACHE_ALIGNED(end))
dmac_flush_range((char *)end,
(char *)end + 1);
if (!IS_CACHE_ALIGNED(end)) {
if (map && map->handle)
msm_ion_do_cache_op(ctx->fl->apps->client,
map->handle,
uint64_to_ptr(end),
sizeof(uintptr_t),
ION_IOC_CLEAN_INV_CACHES);
else
dmac_flush_range((char *)end,
(char *)end + 1);
}
}
}
@ -995,7 +1032,6 @@ static void inv_args(struct smq_invoke_ctx* ctx)
int i, inbufs, outbufs;
uint32_t sc = ctx->sc;
remote_arg64_t *rpra = ctx->lrpra;
int used = ctx->used;
int inv = 0;
inbufs = REMOTE_SCALARS_INBUFS(sc);
@ -1020,8 +1056,6 @@ static void inv_args(struct smq_invoke_ctx* ctx)
+ rpra[i].buf.len));
}
if (inv || REMOTE_SCALARS_OUTHANDLES(sc))
dmac_inv_range(rpra, (char *)rpra + used);
}
static int fastrpc_invoke_send(struct smq_invoke_ctx *ctx,
@ -1171,7 +1205,7 @@ static int fastrpc_internal_invoke(struct fastrpc_file *fl, uint32_t mode,
goto bail;
}
inv_args_pre(ctx->sc, ctx->rpra);
inv_args_pre(ctx);
if (FASTRPC_MODE_SERIAL == mode)
inv_args(ctx);
VERIFY(err, 0 == fastrpc_invoke_send(ctx, kernel, invoke->handle));