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

Commit 5d77b7e0 authored by Urvashi Agrawal's avatar Urvashi Agrawal Committed by Gerrit - the friendly Code Review server
Browse files

msm: kgsl: Do not allow uncached buffers to be marked iocoherent



Add a check to allow only cached buffers to be marked iocoherent.
We can't enable io-coherency for uncached buffers because of
situations where hardware might snoop the cpu caches which can
have stale data. This happens primarily due to the limitations
of dma caching APIs available on arm64.

Change-Id: Iafad086d38559139cb45f6a290071ec6d58ad3a3
Signed-off-by: default avatarUrvashi Agrawal <urvaagra@codeaurora.org>
Signed-off-by: default avatarDeepak Kumar <dkumar@codeaurora.org>
parent 17d718ca
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#include <soc/qcom/scm.h>
#include <soc/qcom/secure_buffer.h>
#include <linux/shmem_fs.h>
#include <linux/bitfield.h>

#include "kgsl_device.h"
#include "kgsl_sharedmem.h"
@@ -847,6 +848,7 @@ void kgsl_memdesc_init(struct kgsl_device *device,
{
	struct kgsl_mmu *mmu = &device->mmu;
	unsigned int align;
	u32 cachemode;

	memset(memdesc, 0, sizeof(*memdesc));
	/* Turn off SVM if the system doesn't support it */
@@ -861,6 +863,17 @@ void kgsl_memdesc_init(struct kgsl_device *device,
	if (!MMU_FEATURE(mmu, KGSL_MMU_IO_COHERENT))
		flags &= ~((uint64_t) KGSL_MEMFLAGS_IOCOHERENT);

	/*
	 * We can't enable I/O coherency on uncached surfaces because of
	 * situations where hardware might snoop the cpu caches which can
	 * have stale data. This happens primarily due to the limitations
	 * of dma caching APIs available on arm64
	 */
	cachemode = FIELD_GET(KGSL_CACHEMODE_MASK, flags);
	if ((cachemode == KGSL_CACHEMODE_WRITECOMBINE ||
		cachemode == KGSL_CACHEMODE_UNCACHED))
		flags &= ~((u64) KGSL_MEMFLAGS_IOCOHERENT);

	if (MMU_FEATURE(mmu, KGSL_MMU_NEED_GUARD_PAGE))
		memdesc->priv |= KGSL_MEMDESC_GUARD_PAGE;