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

Commit 7e54c564 authored by Sushmita Susheelendra's avatar Sushmita Susheelendra Committed by Lynus Vaz
Browse files

msm: kgsl: Record the cacheability attribute of ion buffers



Query whether an ion buffer is cached using the dmabuf API
dma_buf_get_flags. Record this information in the memdesc
so that any cache operations requested on the ion buffer
can be honored.

Change-Id: Ie763047260108a8b5b2073b60d7a6e51408ae543
Signed-off-by: default avatarSushmita Susheelendra <ssusheel@codeaurora.org>
parent 34e53ec4
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include <linux/compat.h>
#include <linux/ctype.h>
#include <linux/mm.h>
#include <linux/ion.h>
#include <asm/cacheflush.h>
#include <uapi/linux/sched/types.h>

@@ -2352,6 +2353,7 @@ static long _gpuobj_map_dma_buf(struct kgsl_device *device,
{
	struct kgsl_gpuobj_import_dma_buf buf;
	struct dma_buf *dmabuf;
	unsigned long flags = 0;
	int ret;

	/*
@@ -2382,6 +2384,16 @@ static long _gpuobj_map_dma_buf(struct kgsl_device *device,
	if (IS_ERR_OR_NULL(dmabuf))
		return (dmabuf == NULL) ? -EINVAL : PTR_ERR(dmabuf);

	/*
	 * ION cache ops are routed through kgsl, so record if the dmabuf is
	 * cached or not in the memdesc. Assume uncached if dma_buf_get_flags
	 * fails.
	 */
	dma_buf_get_flags(dmabuf, &flags);
	if (flags & ION_FLAG_CACHED)
		entry->memdesc.flags |=
			KGSL_CACHEMODE_WRITEBACK << KGSL_CACHEMODE_SHIFT;

	ret = kgsl_setup_dma_buf(device, pagetable, entry, dmabuf);
	if (ret)
		dma_buf_put(dmabuf);