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

Commit b3c1aa05 authored by Urvashi Agrawal's avatar Urvashi Agrawal
Browse files

msm: kgsl: Do not mark all buffers as iocoherent



Add a check to mark only cached buffers as 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>
parent 776e6bfb
Loading
Loading
Loading
Loading
+13 −0
Original line number Original line Diff line number Diff line
@@ -8,6 +8,7 @@
#include <linux/highmem.h>
#include <linux/highmem.h>
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/random.h>
#include <linux/random.h>
#include <linux/bitfield.h>


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


	memset(memdesc, 0, sizeof(*memdesc));
	memset(memdesc, 0, sizeof(*memdesc));
	/* Turn off SVM if the system doesn't support it */
	/* Turn off SVM if the system doesn't support it */
@@ -683,6 +685,17 @@ void kgsl_memdesc_init(struct kgsl_device *device,
	} else if (IS_ENABLED(CONFIG_QCOM_KGSL_IOCOHERENCY_DEFAULT))
	} else if (IS_ENABLED(CONFIG_QCOM_KGSL_IOCOHERENCY_DEFAULT))
		flags |= KGSL_MEMFLAGS_IOCOHERENT;
		flags |= 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))
	if (MMU_FEATURE(mmu, KGSL_MMU_NEED_GUARD_PAGE))
		memdesc->priv |= KGSL_MEMDESC_GUARD_PAGE;
		memdesc->priv |= KGSL_MEMDESC_GUARD_PAGE;