From: Cho KyongHo Date: Mon, 12 Feb 2018 05:48:49 +0000 (+0900) Subject: android: ion: add ION_FLAG_MAY_HWRENDER X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=062548b54ecfb952e79b9403146588e4519de985;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git android: ion: add ION_FLAG_MAY_HWRENDER Clients of ION in userland can specify if the allocated buffer is written by H/W like GPU before S/W initializes it. If the cache maintenance is fully supported by all H/Ws that touch the buffer or all H/Ws touching the buffer are in the same cache coherency domain, everything goes right. But the problem occurs due to the drivers that does not perform cache maintenance due to the performance reason. For the the different H/Ws that touch the same buffer in the different cache coherency domain, the drivers should care when creating IO memory mapping. ION_FLAG_MAY_HWRENDER and ion_hwrender_dmabuf() helper give information to such drivers if the buffer is initialized by H/W. ION_FLAG_MAY_HWRENDER effects nonthing in ION. Just documentation purpose. Change-Id: Iab6293f2c5d6017cf67378356721de4256f049b9 Signed-off-by: Cho KyongHo --- diff --git a/drivers/staging/android/ion/ion_exynos.c b/drivers/staging/android/ion/ion_exynos.c index 72350f8bce3e..11f18675fade 100644 --- a/drivers/staging/android/ion/ion_exynos.c +++ b/drivers/staging/android/ion/ion_exynos.c @@ -39,6 +39,13 @@ bool ion_cached_dmabuf(struct dma_buf *dmabuf) return ion_buffer_cached(dmabuf->priv); } +bool ion_hwrender_dmabuf(struct dma_buf *dmabuf) +{ + struct ion_buffer *buffer = dmabuf->priv; + + return !!(buffer->flags & ION_FLAG_MAY_HWRENDER); +} + struct ion_iovm_map { struct list_head list; struct device *dev; diff --git a/drivers/staging/android/uapi/ion.h b/drivers/staging/android/uapi/ion.h index d480b4f754b9..7c111bbf54ab 100644 --- a/drivers/staging/android/uapi/ion.h +++ b/drivers/staging/android/uapi/ion.h @@ -76,6 +76,11 @@ enum ion_heap_type { * overhead by explicit cache maintenance. */ #define ION_FLAG_SYNC_FORCE 32 +/* + * the allocated buffer is possibly written by H/W(GPU) before initializing by + * S/W except buffer initialization by ION on allocation. + */ +#define ION_FLAG_MAY_HWRENDER 64 /** * DOC: Ion Userspace API diff --git a/include/linux/ion_exynos.h b/include/linux/ion_exynos.h index 8a40bc385490..bde99e7b6e72 100644 --- a/include/linux/ion_exynos.h +++ b/include/linux/ion_exynos.h @@ -27,16 +27,23 @@ struct dma_buf_attachment; struct dma_buf *ion_alloc_dmabuf(const char *heap_name, size_t len, unsigned int flags); bool ion_cached_dmabuf(struct dma_buf *dmabuf); +bool ion_hwrender_dmabuf(struct dma_buf *dmabuf); #else static inline struct dma_buf *ion_alloc_dmabuf(const char *heap_name, size_t len, unsigned int flags) { return ERR_PTR(-ENODEV); } + static inline bool ion_cached_dmabuf(struct dma_buf *dmabuf) { return false; } + +static inline bool ion_cached_hwrender(struct dma_buf *dmabuf) +{ + return false; +} #endif #if defined(CONFIG_EXYNOS_IOVMM) && defined(CONFIG_ION_EXYNOS)