Skip to contentSkip to conversation

drm/exynos: fix allocation and cache mapping type

PATCH New Inki Dae 1 participant 2 messages Dec 14, 2012

Subsystems (3)
lore
Share & tools
lore

Inki Dae

author maintainer
#0 lore raw

This patch fixes memory alloction(contiguous or not) and cache mapping types(cachable or not).
For this, it converts each type from user request into dma attribute properly.

---
 drivers/gpu/drm/exynos/exynos_drm_buf.c |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_buf.c +18 -2
index 7dc1309..e05fcfe 100644
@@ -61,7 +61,7 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
 		unsigned int flags, struct exynos_drm_gem_buf *buf)
 {
 	int ret = 0;
-	enum dma_attr attr = DMA_ATTR_FORCE_CONTIGUOUS;
+	enum dma_attr attr;
 	unsigned int nr_pages;
 
 	DRM_DEBUG_KMS("%s\n", __FILE__);
@@ -73,8 +73,24 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
 
 	init_dma_attrs(&buf->dma_attrs);
 
-	if (flags & EXYNOS_BO_NONCONTIG)
+	/*
+	 * if EXYNOS_BO_CONTIG, fully physically contiguous memory
+	 * region will be allocated else physically contiguous
+	 * as possible.
+	 */
+	if (flags & EXYNOS_BO_CONTIG) {
+		attr = DMA_ATTR_FORCE_CONTIGUOUS;
+		dma_set_attr(attr, &buf->dma_attrs);
+	}
+
+	/*
+	 * if EXYNOS_BO_WC or EXYNOS_BO_NONCACHABLE, writecombine mapping
+	 * else cachable mapping.
+	 */
+	if (flags & EXYNOS_BO_WC || !(flags & EXYNOS_BO_CACHABLE))
 		attr = DMA_ATTR_WRITE_COMBINE;
+	else
+		attr = DMA_ATTR_NON_CONSISTENT;
 
 	dma_set_attr(attr, &buf->dma_attrs);
 	dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &buf->dma_attrs);
Signature · 1 line
1.7.4.1
author maintainer
#1 lore raw

PATCH v2 1/1 drm/exynos: fix allocation and cache mapping type

This patch fixes memory alloction(contiguous or not) and cache mapping types(cachable or not).
For this, it converts each type from user request into dma attribute properly.

Changelog v2:
- just code cleanup.

---
 drivers/gpu/drm/exynos/exynos_drm_buf.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_buf.c +16 -2
index 9732043..9601bad 100644
@@ -34,7 +34,7 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
 		unsigned int flags, struct exynos_drm_gem_buf *buf)
 {
 	int ret = 0;
-	enum dma_attr attr = DMA_ATTR_FORCE_CONTIGUOUS;
+	enum dma_attr attr;
 	unsigned int nr_pages;
 
 	DRM_DEBUG_KMS("%s\n", __FILE__);
@@ -46,8 +46,22 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
 
 	init_dma_attrs(&buf->dma_attrs);
 
-	if (flags & EXYNOS_BO_NONCONTIG)
+	/*
+	 * if EXYNOS_BO_CONTIG, fully physically contiguous memory
+	 * region will be allocated else physically contiguous
+	 * as possible.
+	 */
+	if (flags & EXYNOS_BO_CONTIG)
+		dma_set_attr(DMA_ATTR_FORCE_CONTIGUOUS, &buf->dma_attrs);
+
+	/*
+	 * if EXYNOS_BO_WC or EXYNOS_BO_NONCACHABLE, writecombine mapping
+	 * else cachable mapping.
+	 */
+	if (flags & EXYNOS_BO_WC || !(flags & EXYNOS_BO_CACHABLE))
 		attr = DMA_ATTR_WRITE_COMBINE;
+	else
+		attr = DMA_ATTR_NON_CONSISTENT;
 
 	dma_set_attr(attr, &buf->dma_attrs);
 	dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &buf->dma_attrs);
Signature · 1 line
1.7.4.1