ion: change ion buffer flags
This syncs up our ion buffer flags in ion.h with upstream (using
ION_FLAG_CACHED instead of CACHED and UNCACHED).
Change-Id: I2e07a3acba230a86817182677fa2394fa846fd7e
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c
index dfb2ca4..2e89829 100644
--- a/drivers/gpu/ion/ion.c
+++ b/drivers/gpu/ion/ion.c
@@ -1214,9 +1214,12 @@
{
struct ion_buffer *buffer;
bool valid_handle;
- unsigned long ion_flags = ION_SET_CACHE(CACHED);
+ unsigned long ion_flags = 0;
if (flags & O_DSYNC)
- ion_flags = ION_SET_CACHE(UNCACHED);
+ ion_flags = ION_SET_UNCACHED(ion_flags);
+ else
+ ion_flags = ION_SET_CACHED(ion_flags);
+
mutex_lock(&client->lock);
valid_handle = ion_handle_validate(client, handle);
diff --git a/drivers/media/video/msm_vidc/msm_smem.c b/drivers/media/video/msm_vidc/msm_smem.c
index 76d8068..6f850ba 100644
--- a/drivers/media/video/msm_vidc/msm_smem.c
+++ b/drivers/media/video/msm_vidc/msm_smem.c
@@ -111,17 +111,23 @@
struct ion_handle *hndl;
unsigned long iova = 0;
unsigned long buffer_size = 0;
+ unsigned long ionflags = 0;
int rc = 0;
- flags = flags | ION_HEAP(ION_CP_MM_HEAP_ID);
+ if (flags == SMEM_CACHED)
+ ionflags = ION_SET_CACHED(ionflags);
+ else
+ ionflags = ION_SET_UNCACHED(ionflags);
+
+ ionflags = ionflags | ION_HEAP(ION_CP_MM_HEAP_ID);
if (align < 4096)
align = 4096;
size = (size + 4095) & (~4095);
pr_debug("\n in %s domain: %d, Partition: %d\n",
__func__, domain, partition);
- hndl = ion_alloc(client->clnt, size, align, flags);
+ hndl = ion_alloc(client->clnt, size, align, ionflags);
if (IS_ERR_OR_NULL(hndl)) {
pr_err("Failed to allocate shared memory = %p, %d, %d, 0x%x\n",
- client, size, align, flags);
+ client, size, align, ionflags);
rc = -ENOMEM;
goto fail_shared_mem_alloc;
}
diff --git a/include/linux/ion.h b/include/linux/ion.h
index 4a0e138..e3cc112 100644
--- a/include/linux/ion.h
+++ b/include/linux/ion.h
@@ -51,6 +51,14 @@
#define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT)
#define ION_HEAP_CP_MASK (1 << ION_HEAP_TYPE_CP)
+/**
+ * heap flags - the lower 16 bits are used by core ion, the upper 16
+ * bits are reserved for use by the heaps themselves.
+ */
+#define ION_FLAG_CACHED 1 /* mappings of this buffer should be
+ cached, ion will do cache
+ maintenance when the buffer is
+ mapped for dma */
/**
* These are the only ids that should be used for Ion heap ids.
@@ -118,11 +126,11 @@
#define CACHED 1
#define UNCACHED 0
-#define ION_CACHE_SHIFT 0
+#define ION_SET_CACHED(__cache) (__cache | ION_FLAG_CACHED)
+#define ION_SET_UNCACHED(__cache) (__cache & ~ION_FLAG_CACHED)
-#define ION_SET_CACHE(__cache) ((__cache) << ION_CACHE_SHIFT)
+#define ION_IS_CACHED(__flags) ((__flags) & ION_FLAG_CACHED)
-#define ION_IS_CACHED(__flags) ((__flags) & (1 << ION_CACHE_SHIFT))
/*
* This flag allows clients when mapping into the IOMMU to specify to