mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-11 15:11:48 -04:00
msm: adsprpc: Cache invalidate optimization
Avoid double invalidate operation by changing flags in cache maintenance apis. Instead of invalidating whole buffer use partial cache maintenance apis to invalidate only for length user passed. Introducing offset based invalidate, when buffers have partial or full overlap, avoid invalidation for overlap. Cleaning inv_args_pre as there is no need for handling unaligned buffers separately. Change-Id: I7b38c3cfd924ab4f327c6dd664a087a4c9055dbb Acked-by: Deepika Singh <dsi@qti.qualcomm.com> Signed-off-by: Merugu Tharun Kumar <mtharu@codeaurora.org> Signed-off-by: Edgar Flores <edgarf@codeaurora.org>
This commit is contained in:
parent
1c22c901ac
commit
6403a163ef
1 changed files with 45 additions and 64 deletions
|
|
@ -1987,70 +1987,25 @@ static int put_args(uint32_t kernel, struct smq_invoke_ctx *ctx,
|
|||
return err;
|
||||
}
|
||||
|
||||
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 (map && map->uncached)
|
||||
continue;
|
||||
if (!rpra[i].buf.len)
|
||||
continue;
|
||||
if (ctx->fl->sctx->smmu.coherent &&
|
||||
!(map && (map->attr & FASTRPC_ATTR_NON_COHERENT)))
|
||||
continue;
|
||||
if (map && (map->attr & FASTRPC_ATTR_COHERENT))
|
||||
continue;
|
||||
if (map && (map->attr & FASTRPC_ATTR_FORCE_NOINVALIDATE))
|
||||
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))) {
|
||||
if (map && map->buf) {
|
||||
dma_buf_begin_cpu_access(map->buf,
|
||||
DMA_BIDIRECTIONAL);
|
||||
dma_buf_end_cpu_access(map->buf,
|
||||
DMA_BIDIRECTIONAL);
|
||||
}
|
||||
}
|
||||
|
||||
end = (uintptr_t)uint64_to_ptr(rpra[i].buf.pv +
|
||||
rpra[i].buf.len);
|
||||
if (!IS_CACHE_ALIGNED(end)) {
|
||||
if (map && map->buf) {
|
||||
dma_buf_begin_cpu_access(map->buf,
|
||||
DMA_BIDIRECTIONAL);
|
||||
dma_buf_end_cpu_access(map->buf,
|
||||
DMA_BIDIRECTIONAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 err = 0;
|
||||
|
||||
inbufs = REMOTE_SCALARS_INBUFS(sc);
|
||||
outbufs = REMOTE_SCALARS_OUTBUFS(sc);
|
||||
for (i = inbufs; i < inbufs + outbufs; ++i) {
|
||||
struct fastrpc_mmap *map = ctx->maps[i];
|
||||
for (i = 0; i < inbufs + outbufs; ++i) {
|
||||
int over = ctx->overps[i]->raix;
|
||||
struct fastrpc_mmap *map = ctx->maps[over];
|
||||
|
||||
if ((over + 1 <= inbufs))
|
||||
continue;
|
||||
|
||||
if (map && map->uncached)
|
||||
continue;
|
||||
if (!rpra[i].buf.len)
|
||||
if (!rpra[over].buf.len)
|
||||
continue;
|
||||
if (ctx->fl->sctx->smmu.coherent &&
|
||||
!(map && (map->attr & FASTRPC_ATTR_NON_COHERENT)))
|
||||
|
|
@ -2061,17 +2016,47 @@ static void inv_args(struct smq_invoke_ctx *ctx)
|
|||
continue;
|
||||
|
||||
if (buf_page_start(ptr_to_uint64((void *)rpra)) ==
|
||||
buf_page_start(rpra[i].buf.pv)) {
|
||||
buf_page_start(rpra[over].buf.pv)) {
|
||||
continue;
|
||||
}
|
||||
if (map && map->buf) {
|
||||
dma_buf_begin_cpu_access(map->buf,
|
||||
DMA_FROM_DEVICE);
|
||||
dma_buf_end_cpu_access(map->buf,
|
||||
DMA_FROM_DEVICE);
|
||||
if (ctx->overps[i]->mstart) {
|
||||
if (map && map->buf) {
|
||||
if ((buf_page_size(ctx->overps[i]->mend -
|
||||
ctx->overps[i]->mstart)) == map->size) {
|
||||
dma_buf_begin_cpu_access(map->buf,
|
||||
DMA_TO_DEVICE);
|
||||
dma_buf_end_cpu_access(map->buf,
|
||||
DMA_FROM_DEVICE);
|
||||
} else {
|
||||
uintptr_t offset;
|
||||
struct vm_area_struct *vma;
|
||||
|
||||
down_read(¤t->mm->mmap_sem);
|
||||
VERIFY(err, NULL != (vma = find_vma(
|
||||
current->mm,
|
||||
ctx->overps[i]->mstart)));
|
||||
if (err) {
|
||||
up_read(¤t->mm->mmap_sem);
|
||||
goto bail;
|
||||
}
|
||||
offset = buf_page_start(
|
||||
rpra[over].buf.pv) -
|
||||
vma->vm_start;
|
||||
up_read(¤t->mm->mmap_sem);
|
||||
dma_buf_begin_cpu_access_partial(
|
||||
map->buf, DMA_TO_DEVICE, offset,
|
||||
ctx->overps[i]->mend -
|
||||
ctx->overps[i]->mstart);
|
||||
dma_buf_end_cpu_access_partial(map->buf,
|
||||
DMA_FROM_DEVICE, offset,
|
||||
ctx->overps[i]->mend -
|
||||
ctx->overps[i]->mstart);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bail:
|
||||
return;
|
||||
}
|
||||
|
||||
static int fastrpc_invoke_send(struct smq_invoke_ctx *ctx,
|
||||
|
|
@ -2341,10 +2326,6 @@ static int fastrpc_internal_invoke(struct fastrpc_file *fl, uint32_t mode,
|
|||
goto bail;
|
||||
}
|
||||
|
||||
PERF(fl->profile, GET_COUNTER(perf_counter, PERF_INVARGS),
|
||||
inv_args_pre(ctx);
|
||||
PERF_END);
|
||||
|
||||
PERF(fl->profile, GET_COUNTER(perf_counter, PERF_INVARGS),
|
||||
inv_args(ctx);
|
||||
PERF_END);
|
||||
|
|
|
|||
Loading…
Reference in a new issue