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

Commit 13391ef0 authored by Merugu Tharun Kumar's avatar Merugu Tharun Kumar
Browse files

msm: adsprpc: Cache flush operation optimization



Instead of flushing whole buffer use partial cache maintenance apis
to flush only for length user passed. Introducing offset based flush,
when buffers have partial or full overlap, avoiding flush for overlap.

Change-Id: Ifcdcaab112522ee3abf842e9e305665f9a7ddd7e
Acked-by: default avatarDeepika Singh <dsi@qti.qualcomm.com>
Signed-off-by: default avatarMerugu Tharun Kumar <mtharu@codeaurora.org>
parent e9d103fe
Loading
Loading
Loading
Loading
+32 −5
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
 */
#include <linux/dma-buf.h>
#include <linux/dma-mapping.h>
@@ -1859,10 +1859,37 @@ static int get_args(uint32_t kernel, struct smq_invoke_ctx *ctx)
		if (rpra && rpra[i].buf.len &&
			ctx->overps[oix]->mstart) {
			if (map && map->buf) {
				if ((buf_page_size(ctx->overps[oix]->mend -
				ctx->overps[oix]->mstart)) == map->size) {
					dma_buf_begin_cpu_access(map->buf,
						DMA_TO_DEVICE);
					dma_buf_end_cpu_access(map->buf,
						DMA_TO_DEVICE);
				} else {
					uintptr_t offset;
					struct vm_area_struct *vma;

					down_read(&current->mm->mmap_sem);
					VERIFY(err, NULL != (vma = find_vma(
						current->mm,
						ctx->overps[oix]->mstart)));
					if (err) {
						up_read(&current->mm->mmap_sem);
						goto bail;
					}
					offset = buf_page_start(
						rpra[i].buf.pv) -
						vma->vm_start;
					up_read(&current->mm->mmap_sem);
					dma_buf_begin_cpu_access_partial(
						map->buf, DMA_TO_DEVICE, offset,
						ctx->overps[oix]->mend -
						ctx->overps[oix]->mstart);
					dma_buf_end_cpu_access_partial(
						map->buf, DMA_TO_DEVICE, offset,
						ctx->overps[oix]->mend -
						ctx->overps[oix]->mstart);
				}
			} else
				dmac_flush_range(uint64_to_ptr(rpra[i].buf.pv),
					uint64_to_ptr(rpra[i].buf.pv