#include <linux/cache.h>
#include <linux/memory_group_manager.h>
+#if KERNEL_VERSION(4, 14, 0) > LINUX_VERSION_CODE
+#include <linux/ion.h>
+#else
+#include <linux/ion_exynos.h>
+#endif
+
#include <mali_kbase.h>
#include <mali_kbase_mem_linux.h>
#include <mali_kbase_tracepoints.h>
int kbase_mem_do_sync_imported(struct kbase_context *kctx,
struct kbase_va_region *reg, enum kbase_sync_type sync_fn)
{
- int ret = -EINVAL;
+ int ret = 0;
#ifdef CONFIG_DMA_SHARED_BUFFER
struct dma_buf *dma_buf;
enum dma_data_direction dir = DMA_BIDIRECTIONAL;
/* Currently only handle dma-bufs */
if (reg->gpu_alloc->type != KBASE_MEM_TYPE_IMPORTED_UMM)
- return ret;
+ return -EINVAL;
/*
* Attempting to sync with CONFIG_MALI_DMA_BUF_MAP_ON_DEMAND
* enabled can expose us to a Linux Kernel issue between v4.6 and
*/
if (IS_ENABLED(CONFIG_MALI_DMA_BUF_MAP_ON_DEMAND) &&
!reg->gpu_alloc->imported.umm.current_mapping_usage_count)
- return ret;
+ return -EINVAL;
dma_buf = reg->gpu_alloc->imported.umm.dma_buf;
dev_dbg(kctx->kbdev->dev,
"Syncing imported buffer at GPU VA %llx to GPU\n",
reg->start_pfn);
+
+#if KERNEL_VERSION(4, 14, 0) > LINUX_VERSION_CODE
+ if (ion_cached_needsync_dmabuf(dma_buf)) {
+#else
+ if (ion_cached_dmabuf(dma_buf)) {
+#endif
#ifdef KBASE_MEM_ION_SYNC_WORKAROUND
if (!WARN_ON(!reg->gpu_alloc->imported.umm.dma_attachment)) {
struct dma_buf_attachment *attachment = reg->gpu_alloc->imported.umm.dma_attachment;
dir);
#endif
#endif /* KBASE_MEM_ION_SYNC_WORKAROUND */
+ }
break;
case KBASE_SYNC_TO_CPU:
dev_dbg(kctx->kbdev->dev,
"Syncing imported buffer at GPU VA %llx to CPU\n",
reg->start_pfn);
+
+#if KERNEL_VERSION(4, 14, 0) > LINUX_VERSION_CODE
+ if (ion_cached_needsync_dmabuf(dma_buf)) {
+#else
+ if (ion_cached_dmabuf(dma_buf)) {
+#endif
#ifdef KBASE_MEM_ION_SYNC_WORKAROUND
if (!WARN_ON(!reg->gpu_alloc->imported.umm.dma_attachment)) {
struct dma_buf_attachment *attachment = reg->gpu_alloc->imported.umm.dma_attachment;
#endif
dir);
#endif /* KBASE_MEM_ION_SYNC_WORKAROUND */
+ }
break;
};