All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/10] omapdrm: GEM objects fixes
@ 2017-04-20 21:33 Laurent Pinchart
  2017-04-20 21:33 ` [PATCH v2 01/10] drm: omapdrm: Remove remap argument to omap_gem_get_paddr() Laurent Pinchart
                   ` (10 more replies)
  0 siblings, 11 replies; 27+ messages in thread
From: Laurent Pinchart @ 2017-04-20 21:33 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

Hello,

This patch series updates and extends the previously posted "[PATCH 1/7]
omapdrm: Fix GEM objects DMA unmapping" series.

Compared to v1, the series now includes an extra cleanup (06/10), a cache
handling performance improvement (09/10) and a dmabuf refcount fix (10/10).

Memory leaks have been reported when allocating a cached omap_bo (with
OMAP_BO_CACHED). Investigation showed that this can only come from the DMA
mapping debug layer, as on ARM32 the non-coherent, non-IOMMU DMA mapping code
doesn't allocate memory to map a page (and the kmemcheck facility is only
available on x86, so it can't be a source of memory leaks either on ARM).

The DMA debug layer pre-allocates DMA debugging entries and stores them in a
list. As the omapdrm driver maps cached buffer page by page, the list of 4096
pre-allocated entries is starved very soon. However, raising the number of DMA
mapping debug entries to 32 * 4096 (through the dma_debug_entries kernel
command line argument) led to more interesting results.

The number of entries being large enough to handle all the pages mapped by
kmstest, monitoring the DMA mapping statistics through
/sys/kernel/debug/dma-api/ showed that the number of free entries dropped
significantly when kmstest was started and didn't raise when it was stopped.
In particular, running kmstest without flipping resulting in a drop of 1266
free entries, which corresponds to one 1440x900 framebuffer in XR24. That
proved that the pages backing the framebuffer, while freed when the
framebuffer was destroyed, were not unmapped.

I've thus started investigating the driver GEM implementation. After a few
confusing moments that resulted in the 01/10 to 07/10 cleanup patches, I wrote
patch 08/10 that fixes the issue. No memory leak is now noticed through
/sys/kernel/debug/dma-api/ or /proc/meminfo running 'kmstest --flip' for 300
frames in a loop for one hour with cached buffers.

Test patches for kms++ and kmstest to support omapdrm cached mappings are
available at

	git://git.ideasonboard.com/renesas/kmsxx.git omap/cache

Patch 09/10 then improves performances by mapping pages for DMA in the correct
direction. As the device never writes to memory, DMA_TO_DEVICE can be used
instead of DMA_BIDIRECTIONAL.

Cache handling is still slow, but I don't think major performance improvements
can easily be achieved. Cache handling is all about trade-offs. The current
driver implementation tracks dirty pages and cleans the cache for them only.
When only a small part of the buffer has been touched this results in a
performance gain compared to cleaning the cache for the whole buffer. In
particular, when the buffer has not been touched by the CPU at all (which is
common when displaying frames captured from a camera device with buffers
shared through dma-buf), no cache clean operation is performed. This has been
verified using the kmscapture application from kms++ from the above branch.

On the other hand, when most of the buffer has been touched, the extra effort
to track dirty pages results in a performance loss. However, measurements with
perf and ftrace showed that the cost of dirty page tracking is small compared
to cache handling.

One optimization I tried resulted in a very large performance improvement
though. Replacing selective cache cleaning (through the DMA mapping API) by
a whole L1+L2 cache clean raised the frame rate from 30 fps to 60 fps when
running 'kmstest --flip' on my Pandaboard. However, as that requires calling

	flush_cache_all();
	local_irq_save(flags);
	outer_flush_all();
	local_irq_restore(flags);

from the omapdrm driver, there is no way this will be accepted upstream as-is.
We could explore the option of adding heuristics to the ARM32 DMA mapping
implementation to clean the whole cache when the buffer is large, but that
belongs to a separate patch series.

To close the patch series, patch 10/10 fixes a GEM object reference count
issue related to dma-buf. It turns out that GEM object dma-buf export has
suffered from a refcount underflow since kernel v3.5 without anyone noticing.

Laurent Pinchart (10):
  drm: omapdrm: Remove remap argument to omap_gem_get_paddr()
  drm: omapdrm: Rename occurrences of paddr to dma_addr
  drm: omapdrm: Rename omap_gem_(get|put)_paddr() to omap_gem_(un)pin()
  drm: omapdrm: Lower indentation level in omap_gem_dma_sync_buffer()
  drm: omapdrm: Rename the omap_gem_object addrs field to dma_addrs
  drm: omapdrm: Rename GEM DMA sync functions
  drm: omapdrm: Fix incorrect usage of the term 'cache coherency'
  drm: omapdrm: DMA-unmap pages for all buffer types when freeing
    buffers
  drm: omapdrm: Map pages for DMA in DMA_TO_DEVICE direction
  drm: omapdrm: Take GEM obj and DRM dev references when exporting
    dmabuf

 drivers/gpu/drm/omapdrm/omap_drv.h        |  13 +-
 drivers/gpu/drm/omapdrm/omap_fb.c         |  27 ++--
 drivers/gpu/drm/omapdrm/omap_fbdev.c      |  15 +--
 drivers/gpu/drm/omapdrm/omap_gem.c        | 209 ++++++++++++++++--------------
 drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |  39 +++---
 5 files changed, 163 insertions(+), 140 deletions(-)

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v2 01/10] drm: omapdrm: Remove remap argument to omap_gem_get_paddr()
  2017-04-20 21:33 [PATCH v2 00/10] omapdrm: GEM objects fixes Laurent Pinchart
@ 2017-04-20 21:33 ` Laurent Pinchart
  2017-04-24 10:09   ` Tomi Valkeinen
  2017-04-20 21:33 ` [PATCH v2 02/10] drm: omapdrm: Rename occurrences of paddr to dma_addr Laurent Pinchart
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Laurent Pinchart @ 2017-04-20 21:33 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The function is always called with the remap argument set to true.
Hardcode that behaviour and remove it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_drv.h        |  3 +--
 drivers/gpu/drm/omapdrm/omap_fb.c         |  2 +-
 drivers/gpu/drm/omapdrm/omap_fbdev.c      |  2 +-
 drivers/gpu/drm/omapdrm/omap_gem.c        | 10 ++++------
 drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |  2 +-
 5 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index 16aa43c6fbc2..2b5e61b7efdf 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -188,8 +188,7 @@ int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
 void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff);
 void omap_gem_dma_sync(struct drm_gem_object *obj,
 		enum dma_data_direction dir);
-int omap_gem_get_paddr(struct drm_gem_object *obj,
-		dma_addr_t *paddr, bool remap);
+int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *paddr);
 void omap_gem_put_paddr(struct drm_gem_object *obj);
 int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
 		bool remap);
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index 29dc677dd4d3..e249c39961df 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -258,7 +258,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
 
 	for (i = 0; i < n; i++) {
 		struct plane *plane = &omap_fb->planes[i];
-		ret = omap_gem_get_paddr(plane->bo, &plane->paddr, true);
+		ret = omap_gem_get_paddr(plane->bo, &plane->paddr);
 		if (ret)
 			goto fail;
 		omap_gem_dma_sync(plane->bo, DMA_TO_DEVICE);
diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c
index 4e89dd537862..d738e5b3ae45 100644
--- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
+++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
@@ -162,7 +162,7 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
 	 * to it).  Then we just need to be sure that we are able to re-
 	 * pin it in case of an opps.
 	 */
-	ret = omap_gem_get_paddr(fbdev->bo, &paddr, true);
+	ret = omap_gem_get_paddr(fbdev->bo, &paddr);
 	if (ret) {
 		dev_err(dev->dev,
 			"could not map (paddr)!  Skipping framebuffer alloc\n");
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 301433392175..2419cacb593b 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -784,12 +784,10 @@ void omap_gem_dma_sync(struct drm_gem_object *obj,
 	}
 }
 
-/* Get physical address for DMA.. if 'remap' is true, and the buffer is not
- * already contiguous, remap it to pin in physically contiguous memory.. (ie.
- * map in TILER)
+/* Get physical address for DMA.. if the buffer is not already contiguous, remap
+ * it to pin in physically contiguous memory.. (ie. map in TILER)
  */
-int omap_gem_get_paddr(struct drm_gem_object *obj,
-		dma_addr_t *paddr, bool remap)
+int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *paddr)
 {
 	struct omap_drm_private *priv = obj->dev->dev_private;
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
@@ -797,7 +795,7 @@ int omap_gem_get_paddr(struct drm_gem_object *obj,
 
 	mutex_lock(&obj->dev->struct_mutex);
 
-	if (!is_contiguous(omap_obj) && remap && priv->has_dmm) {
+	if (!is_contiguous(omap_obj) && priv->has_dmm) {
 		if (omap_obj->paddr_cnt == 0) {
 			struct page **pages;
 			uint32_t npages = obj->size >> PAGE_SHIFT;
diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
index f6af6c987539..eda3c6e93601 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
@@ -41,7 +41,7 @@ static struct sg_table *omap_gem_map_dma_buf(
 	/* camera, etc, need physically contiguous.. but we need a
 	 * better way to know this..
 	 */
-	ret = omap_gem_get_paddr(obj, &paddr, true);
+	ret = omap_gem_get_paddr(obj, &paddr);
 	if (ret)
 		goto out;
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 02/10] drm: omapdrm: Rename occurrences of paddr to dma_addr
  2017-04-20 21:33 [PATCH v2 00/10] omapdrm: GEM objects fixes Laurent Pinchart
  2017-04-20 21:33 ` [PATCH v2 01/10] drm: omapdrm: Remove remap argument to omap_gem_get_paddr() Laurent Pinchart
@ 2017-04-20 21:33 ` Laurent Pinchart
  2017-04-24 10:13   ` Tomi Valkeinen
  2017-04-20 21:33 ` [PATCH v2 03/10] drm: omapdrm: Rename omap_gem_(get|put)_paddr() to omap_gem_(un)pin() Laurent Pinchart
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Laurent Pinchart @ 2017-04-20 21:33 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The fields, variables and functions deal with DMA addresses, name them
accordingly. The omap_gem_get_paddr() and omap_gem_put_paddr() will be
addressed differently separately.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_drv.h        |  6 +--
 drivers/gpu/drm/omapdrm/omap_fb.c         | 21 +++++-----
 drivers/gpu/drm/omapdrm/omap_fbdev.c      |  8 ++--
 drivers/gpu/drm/omapdrm/omap_gem.c        | 70 +++++++++++++++----------------
 drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |  8 ++--
 5 files changed, 57 insertions(+), 56 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index 2b5e61b7efdf..ef5001f1f5c8 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -188,14 +188,14 @@ int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
 void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff);
 void omap_gem_dma_sync(struct drm_gem_object *obj,
 		enum dma_data_direction dir);
-int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *paddr);
+int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *dma_addr);
 void omap_gem_put_paddr(struct drm_gem_object *obj);
 int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
 		bool remap);
 int omap_gem_put_pages(struct drm_gem_object *obj);
 uint32_t omap_gem_flags(struct drm_gem_object *obj);
-int omap_gem_rotated_paddr(struct drm_gem_object *obj, uint32_t orient,
-		int x, int y, dma_addr_t *paddr);
+int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, uint32_t orient,
+		int x, int y, dma_addr_t *dma_addr);
 uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
 size_t omap_gem_mmap_size(struct drm_gem_object *obj);
 int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient);
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index e249c39961df..0cac20a4bdcd 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -74,7 +74,7 @@ struct plane {
 	struct drm_gem_object *bo;
 	uint32_t pitch;
 	uint32_t offset;
-	dma_addr_t paddr;
+	dma_addr_t dma_addr;
 };
 
 #define to_omap_framebuffer(x) container_of(x, struct omap_framebuffer, base)
@@ -85,7 +85,7 @@ struct omap_framebuffer {
 	const struct drm_format_info *format;
 	enum omap_color_mode dss_format;
 	struct plane planes[2];
-	/* lock for pinning (pin_count and planes.paddr) */
+	/* lock for pinning (pin_count and planes.dma_addr) */
 	struct mutex lock;
 };
 
@@ -130,7 +130,7 @@ static uint32_t get_linear_addr(struct plane *plane,
 	       + (x * format->cpp[n] / (n == 0 ? 1 : format->hsub))
 	       + (y * plane->pitch / (n == 0 ? 1 : format->vsub));
 
-	return plane->paddr + offset;
+	return plane->dma_addr + offset;
 }
 
 bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb)
@@ -201,7 +201,8 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
 		if (orient & MASK_X_INVERT)
 			x += w - 1;
 
-		omap_gem_rotated_paddr(plane->bo, orient, x, y, &info->paddr);
+		omap_gem_rotated_dma_addr(plane->bo, orient, x, y,
+					  &info->paddr);
 		info->rotation_type = OMAP_DSS_ROT_TILER;
 		info->screen_width  = omap_gem_tiled_stride(plane->bo, orient);
 	} else {
@@ -232,8 +233,8 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
 
 		if (info->rotation_type == OMAP_DSS_ROT_TILER) {
 			WARN_ON(!(omap_gem_flags(plane->bo) & OMAP_BO_TILED));
-			omap_gem_rotated_paddr(plane->bo, orient,
-					x/2, y/2, &info->p_uv_addr);
+			omap_gem_rotated_dma_addr(plane->bo, orient, x/2, y/2,
+						  &info->p_uv_addr);
 		} else {
 			info->p_uv_addr = get_linear_addr(plane, format, 1, x, y);
 		}
@@ -258,7 +259,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
 
 	for (i = 0; i < n; i++) {
 		struct plane *plane = &omap_fb->planes[i];
-		ret = omap_gem_get_paddr(plane->bo, &plane->paddr);
+		ret = omap_gem_get_paddr(plane->bo, &plane->dma_addr);
 		if (ret)
 			goto fail;
 		omap_gem_dma_sync(plane->bo, DMA_TO_DEVICE);
@@ -274,7 +275,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
 	for (i--; i >= 0; i--) {
 		struct plane *plane = &omap_fb->planes[i];
 		omap_gem_put_paddr(plane->bo);
-		plane->paddr = 0;
+		plane->dma_addr = 0;
 	}
 
 	mutex_unlock(&omap_fb->lock);
@@ -300,7 +301,7 @@ void omap_framebuffer_unpin(struct drm_framebuffer *fb)
 	for (i = 0; i < n; i++) {
 		struct plane *plane = &omap_fb->planes[i];
 		omap_gem_put_paddr(plane->bo);
-		plane->paddr = 0;
+		plane->dma_addr = 0;
 	}
 
 	mutex_unlock(&omap_fb->lock);
@@ -458,7 +459,7 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
 		plane->bo     = bos[i];
 		plane->offset = mode_cmd->offsets[i];
 		plane->pitch  = pitch;
-		plane->paddr  = 0;
+		plane->dma_addr  = 0;
 	}
 
 	drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c
index d738e5b3ae45..dabb1affa2ca 100644
--- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
+++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
@@ -106,7 +106,7 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
 	union omap_gem_size gsize;
 	struct fb_info *fbi = NULL;
 	struct drm_mode_fb_cmd2 mode_cmd = {0};
-	dma_addr_t paddr;
+	dma_addr_t dma_addr;
 	int ret;
 
 	sizes->surface_bpp = 32;
@@ -162,7 +162,7 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
 	 * to it).  Then we just need to be sure that we are able to re-
 	 * pin it in case of an opps.
 	 */
-	ret = omap_gem_get_paddr(fbdev->bo, &paddr);
+	ret = omap_gem_get_paddr(fbdev->bo, &dma_addr);
 	if (ret) {
 		dev_err(dev->dev,
 			"could not map (paddr)!  Skipping framebuffer alloc\n");
@@ -193,11 +193,11 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
 	drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->format->depth);
 	drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
 
-	dev->mode_config.fb_base = paddr;
+	dev->mode_config.fb_base = dma_addr;
 
 	fbi->screen_base = omap_gem_vaddr(fbdev->bo);
 	fbi->screen_size = fbdev->bo->size;
-	fbi->fix.smem_start = paddr;
+	fbi->fix.smem_start = dma_addr;
 	fbi->fix.smem_len = fbdev->bo->size;
 
 	/* if we have DMM, then we can use it for scrolling by just
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 2419cacb593b..c38121cd6337 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -50,7 +50,7 @@ struct omap_gem_object {
 	uint32_t roll;
 
 	/**
-	 * paddr contains the buffer DMA address. It is valid for
+	 * dma_addr contains the buffer DMA address. It is valid for
 	 *
 	 * - buffers allocated through the DMA mapping API (with the
 	 *   OMAP_BO_MEM_DMA_API flag set)
@@ -58,24 +58,24 @@ struct omap_gem_object {
 	 * - buffers imported from dmabuf (with the OMAP_BO_MEM_DMABUF flag set)
 	 *   if they are physically contiguous (when sgt->orig_nents == 1)
 	 *
-	 * - buffers mapped through the TILER when paddr_cnt is not zero, in
+	 * - buffers mapped through the TILER when dma_addr_cnt is not zero, in
 	 *   which case the DMA address points to the TILER aperture
 	 *
 	 * Physically contiguous buffers have their DMA address equal to the
 	 * physical address as we don't remap those buffers through the TILER.
 	 *
 	 * Buffers mapped to the TILER have their DMA address pointing to the
-	 * TILER aperture. As TILER mappings are refcounted (through paddr_cnt)
-	 * the DMA address must be accessed through omap_get_get_paddr() to
-	 * ensure that the mapping won't disappear unexpectedly. References must
-	 * be released with omap_gem_put_paddr().
+	 * TILER aperture. As TILER mappings are refcounted (through
+	 * dma_addr_cnt) the DMA address must be accessed through
+	 * omap_get_get_paddr() to ensure that the mapping won't disappear
+	 * unexpectedly. References must be released with omap_gem_put_paddr().
 	 */
-	dma_addr_t paddr;
+	dma_addr_t dma_addr;
 
 	/**
-	 * # of users of paddr
+	 * # of users of dma_addr
 	 */
-	uint32_t paddr_cnt;
+	uint32_t dma_addr_cnt;
 
 	/**
 	 * If the buffer has been imported from a dmabuf the OMAP_DB_DMABUF flag
@@ -119,7 +119,7 @@ struct omap_gem_object {
 #define NUM_USERGART_ENTRIES 2
 struct omap_drm_usergart_entry {
 	struct tiler_block *block;	/* the reserved tiler block */
-	dma_addr_t paddr;
+	dma_addr_t dma_addr;
 	struct drm_gem_object *obj;	/* the current pinned obj */
 	pgoff_t obj_pgoff;		/* page offset of obj currently
 					   mapped in */
@@ -392,7 +392,7 @@ static int fault_1d(struct drm_gem_object *obj,
 		pfn = page_to_pfn(omap_obj->pages[pgoff]);
 	} else {
 		BUG_ON(!is_contiguous(omap_obj));
-		pfn = (omap_obj->paddr >> PAGE_SHIFT) + pgoff;
+		pfn = (omap_obj->dma_addr >> PAGE_SHIFT) + pgoff;
 	}
 
 	VERB("Inserting %p pfn %lx, pa %lx", (void *)vmf->address,
@@ -485,7 +485,7 @@ static int fault_2d(struct drm_gem_object *obj,
 		return ret;
 	}
 
-	pfn = entry->paddr >> PAGE_SHIFT;
+	pfn = entry->dma_addr >> PAGE_SHIFT;
 
 	VERB("Inserting %p pfn %lx, pa %lx", (void *)vmf->address,
 			pfn, pfn << PAGE_SHIFT);
@@ -787,7 +787,7 @@ void omap_gem_dma_sync(struct drm_gem_object *obj,
 /* Get physical address for DMA.. if the buffer is not already contiguous, remap
  * it to pin in physically contiguous memory.. (ie. map in TILER)
  */
-int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *paddr)
+int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *dma_addr)
 {
 	struct omap_drm_private *priv = obj->dev->dev_private;
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
@@ -796,7 +796,7 @@ int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *paddr)
 	mutex_lock(&obj->dev->struct_mutex);
 
 	if (!is_contiguous(omap_obj) && priv->has_dmm) {
-		if (omap_obj->paddr_cnt == 0) {
+		if (omap_obj->dma_addr_cnt == 0) {
 			struct page **pages;
 			uint32_t npages = obj->size >> PAGE_SHIFT;
 			enum tiler_fmt fmt = gem2fmt(omap_obj->flags);
@@ -833,17 +833,17 @@ int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *paddr)
 				goto fail;
 			}
 
-			omap_obj->paddr = tiler_ssptr(block);
+			omap_obj->dma_addr = tiler_ssptr(block);
 			omap_obj->block = block;
 
-			DBG("got paddr: %pad", &omap_obj->paddr);
+			DBG("got dma address: %pad", &omap_obj->dma_addr);
 		}
 
-		omap_obj->paddr_cnt++;
+		omap_obj->dma_addr_cnt++;
 
-		*paddr = omap_obj->paddr;
+		*dma_addr = omap_obj->dma_addr;
 	} else if (is_contiguous(omap_obj)) {
-		*paddr = omap_obj->paddr;
+		*dma_addr = omap_obj->dma_addr;
 	} else {
 		ret = -EINVAL;
 		goto fail;
@@ -864,9 +864,9 @@ void omap_gem_put_paddr(struct drm_gem_object *obj)
 	int ret;
 
 	mutex_lock(&obj->dev->struct_mutex);
-	if (omap_obj->paddr_cnt > 0) {
-		omap_obj->paddr_cnt--;
-		if (omap_obj->paddr_cnt == 0) {
+	if (omap_obj->dma_addr_cnt > 0) {
+		omap_obj->dma_addr_cnt--;
+		if (omap_obj->dma_addr_cnt == 0) {
 			ret = tiler_unpin(omap_obj->block);
 			if (ret) {
 				dev_err(obj->dev->dev,
@@ -877,7 +877,7 @@ void omap_gem_put_paddr(struct drm_gem_object *obj)
 				dev_err(obj->dev->dev,
 					"could not release unmap: %d\n", ret);
 			}
-			omap_obj->paddr = 0;
+			omap_obj->dma_addr = 0;
 			omap_obj->block = NULL;
 		}
 	}
@@ -889,16 +889,16 @@ void omap_gem_put_paddr(struct drm_gem_object *obj)
  * specified orientation and x,y offset from top-left corner of buffer
  * (only valid for tiled 2d buffers)
  */
-int omap_gem_rotated_paddr(struct drm_gem_object *obj, uint32_t orient,
-		int x, int y, dma_addr_t *paddr)
+int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, uint32_t orient,
+		int x, int y, dma_addr_t *dma_addr)
 {
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
 	int ret = -EINVAL;
 
 	mutex_lock(&obj->dev->struct_mutex);
-	if ((omap_obj->paddr_cnt > 0) && omap_obj->block &&
+	if ((omap_obj->dma_addr_cnt > 0) && omap_obj->block &&
 			(omap_obj->flags & OMAP_BO_TILED)) {
-		*paddr = tiler_tsptr(omap_obj->block, orient, x, y);
+		*dma_addr = tiler_tsptr(omap_obj->block, orient, x, y);
 		ret = 0;
 	}
 	mutex_unlock(&obj->dev->struct_mutex);
@@ -1017,7 +1017,7 @@ void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m)
 
 	seq_printf(m, "%08x: %2d (%2d) %08llx %pad (%2d) %p %4d",
 			omap_obj->flags, obj->name, kref_read(&obj->refcount),
-			off, &omap_obj->paddr, omap_obj->paddr_cnt,
+			off, &omap_obj->dma_addr, omap_obj->dma_addr_cnt,
 			omap_obj->vaddr, omap_obj->roll);
 
 	if (omap_obj->flags & OMAP_BO_TILED) {
@@ -1074,7 +1074,7 @@ void omap_gem_free_object(struct drm_gem_object *obj)
 	/* this means the object is still pinned.. which really should
 	 * not happen.  I think..
 	 */
-	WARN_ON(omap_obj->paddr_cnt > 0);
+	WARN_ON(omap_obj->dma_addr_cnt > 0);
 
 	if (omap_obj->pages) {
 		if (omap_obj->flags & OMAP_BO_MEM_DMABUF)
@@ -1085,7 +1085,7 @@ void omap_gem_free_object(struct drm_gem_object *obj)
 
 	if (omap_obj->flags & OMAP_BO_MEM_DMA_API) {
 		dma_free_wc(dev->dev, obj->size, omap_obj->vaddr,
-			    omap_obj->paddr);
+			    omap_obj->dma_addr);
 	} else if (omap_obj->vaddr) {
 		vunmap(omap_obj->vaddr);
 	} else if (obj->import_attach) {
@@ -1182,7 +1182,7 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev,
 	/* Allocate memory if needed. */
 	if (flags & OMAP_BO_MEM_DMA_API) {
 		omap_obj->vaddr = dma_alloc_wc(dev->dev, size,
-					       &omap_obj->paddr,
+					       &omap_obj->dma_addr,
 					       GFP_KERNEL);
 		if (!omap_obj->vaddr)
 			goto err_release;
@@ -1226,7 +1226,7 @@ struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
 	omap_obj->sgt = sgt;
 
 	if (sgt->orig_nents == 1) {
-		omap_obj->paddr = sg_dma_address(sgt->sgl);
+		omap_obj->dma_addr = sg_dma_address(sgt->sgl);
 	} else {
 		/* Create pages list from sgt */
 		struct sg_page_iter iter;
@@ -1333,11 +1333,11 @@ void omap_gem_init(struct drm_device *dev)
 						i, j, PTR_ERR(block));
 				return;
 			}
-			entry->paddr = tiler_ssptr(block);
+			entry->dma_addr = tiler_ssptr(block);
 			entry->block = block;
 
-			DBG("%d:%d: %dx%d: paddr=%pad stride=%d", i, j, w, h,
-					&entry->paddr,
+			DBG("%d:%d: %dx%d: dma_addr=%pad stride=%d", i, j, w, h,
+					&entry->dma_addr,
 					usergart[i].stride_pfn << PAGE_SHIFT);
 		}
 	}
diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
index eda3c6e93601..0e527c9eaee9 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
@@ -31,7 +31,7 @@ static struct sg_table *omap_gem_map_dma_buf(
 {
 	struct drm_gem_object *obj = attachment->dmabuf->priv;
 	struct sg_table *sg;
-	dma_addr_t paddr;
+	dma_addr_t dma_addr;
 	int ret;
 
 	sg = kzalloc(sizeof(*sg), GFP_KERNEL);
@@ -41,7 +41,7 @@ static struct sg_table *omap_gem_map_dma_buf(
 	/* camera, etc, need physically contiguous.. but we need a
 	 * better way to know this..
 	 */
-	ret = omap_gem_get_paddr(obj, &paddr);
+	ret = omap_gem_get_paddr(obj, &dma_addr);
 	if (ret)
 		goto out;
 
@@ -51,8 +51,8 @@ static struct sg_table *omap_gem_map_dma_buf(
 
 	sg_init_table(sg->sgl, 1);
 	sg_dma_len(sg->sgl) = obj->size;
-	sg_set_page(sg->sgl, pfn_to_page(PFN_DOWN(paddr)), obj->size, 0);
-	sg_dma_address(sg->sgl) = paddr;
+	sg_set_page(sg->sgl, pfn_to_page(PFN_DOWN(dma_addr)), obj->size, 0);
+	sg_dma_address(sg->sgl) = dma_addr;
 
 	/* this should be after _get_paddr() to ensure we have pages attached */
 	omap_gem_dma_sync(obj, dir);
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 03/10] drm: omapdrm: Rename omap_gem_(get|put)_paddr() to omap_gem_(un)pin()
  2017-04-20 21:33 [PATCH v2 00/10] omapdrm: GEM objects fixes Laurent Pinchart
  2017-04-20 21:33 ` [PATCH v2 01/10] drm: omapdrm: Remove remap argument to omap_gem_get_paddr() Laurent Pinchart
  2017-04-20 21:33 ` [PATCH v2 02/10] drm: omapdrm: Rename occurrences of paddr to dma_addr Laurent Pinchart
@ 2017-04-20 21:33 ` Laurent Pinchart
  2017-04-24 10:16   ` Tomi Valkeinen
  2017-04-20 21:33 ` [PATCH v2 04/10] drm: omapdrm: Lower indentation level in omap_gem_dma_sync_buffer() Laurent Pinchart
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Laurent Pinchart @ 2017-04-20 21:33 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The reflects the purpose of the function better.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_drv.h        |  4 ++--
 drivers/gpu/drm/omapdrm/omap_fb.c         |  6 ++---
 drivers/gpu/drm/omapdrm/omap_fbdev.c      |  9 ++++----
 drivers/gpu/drm/omapdrm/omap_gem.c        | 38 ++++++++++++++++++++++---------
 drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |  6 ++---
 5 files changed, 39 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index ef5001f1f5c8..f2db84767bf8 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -188,8 +188,8 @@ int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
 void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff);
 void omap_gem_dma_sync(struct drm_gem_object *obj,
 		enum dma_data_direction dir);
-int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *dma_addr);
-void omap_gem_put_paddr(struct drm_gem_object *obj);
+int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr);
+void omap_gem_unpin(struct drm_gem_object *obj);
 int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
 		bool remap);
 int omap_gem_put_pages(struct drm_gem_object *obj);
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index 0cac20a4bdcd..a25a99fc6a34 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -259,7 +259,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
 
 	for (i = 0; i < n; i++) {
 		struct plane *plane = &omap_fb->planes[i];
-		ret = omap_gem_get_paddr(plane->bo, &plane->dma_addr);
+		ret = omap_gem_pin(plane->bo, &plane->dma_addr);
 		if (ret)
 			goto fail;
 		omap_gem_dma_sync(plane->bo, DMA_TO_DEVICE);
@@ -274,7 +274,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
 fail:
 	for (i--; i >= 0; i--) {
 		struct plane *plane = &omap_fb->planes[i];
-		omap_gem_put_paddr(plane->bo);
+		omap_gem_unpin(plane->bo);
 		plane->dma_addr = 0;
 	}
 
@@ -300,7 +300,7 @@ void omap_framebuffer_unpin(struct drm_framebuffer *fb)
 
 	for (i = 0; i < n; i++) {
 		struct plane *plane = &omap_fb->planes[i];
-		omap_gem_put_paddr(plane->bo);
+		omap_gem_unpin(plane->bo);
 		plane->dma_addr = 0;
 	}
 
diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c
index dabb1affa2ca..daf81a0a2899 100644
--- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
+++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
@@ -162,10 +162,9 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
 	 * to it).  Then we just need to be sure that we are able to re-
 	 * pin it in case of an opps.
 	 */
-	ret = omap_gem_get_paddr(fbdev->bo, &dma_addr);
+	ret = omap_gem_pin(fbdev->bo, &dma_addr);
 	if (ret) {
-		dev_err(dev->dev,
-			"could not map (paddr)!  Skipping framebuffer alloc\n");
+		dev_err(dev->dev, "could not pin framebuffer\n");
 		ret = -ENOMEM;
 		goto fail;
 	}
@@ -303,8 +302,8 @@ void omap_fbdev_free(struct drm_device *dev)
 
 	fbdev = to_omap_fbdev(priv->fbdev);
 
-	/* release the ref taken in omap_fbdev_create() */
-	omap_gem_put_paddr(fbdev->bo);
+	/* unpin the GEM object pinned in omap_fbdev_create() */
+	omap_gem_unpin(fbdev->bo);
 
 	/* this will free the backing object */
 	if (fbdev->fb)
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index c38121cd6337..121de88c2ad3 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -66,9 +66,9 @@ struct omap_gem_object {
 	 *
 	 * Buffers mapped to the TILER have their DMA address pointing to the
 	 * TILER aperture. As TILER mappings are refcounted (through
-	 * dma_addr_cnt) the DMA address must be accessed through
-	 * omap_get_get_paddr() to ensure that the mapping won't disappear
-	 * unexpectedly. References must be released with omap_gem_put_paddr().
+	 * dma_addr_cnt) the DMA address must be accessed through omap_gem_pin()
+	 * to ensure that the mapping won't disappear unexpectedly. References
+	 * must be released with omap_gem_unpin().
 	 */
 	dma_addr_t dma_addr;
 
@@ -784,10 +784,21 @@ void omap_gem_dma_sync(struct drm_gem_object *obj,
 	}
 }
 
-/* Get physical address for DMA.. if the buffer is not already contiguous, remap
- * it to pin in physically contiguous memory.. (ie. map in TILER)
+/**
+ * omap_gem_pin() - Pin a GEM object in memory
+ * @obj: the GEM object
+ * @dma_addr: the DMA address
+ *
+ * Pin the given GEM object in memory and fill the dma_addr pointer with the
+ * object's DMA address. If the buffer is not physically contiguous it will be
+ * remapped through the TILER to provide a contiguous view.
+ *
+ * Pins are reference-counted, calling this function multiple times is allowed
+ * as long the corresponding omap_gem_unpin() calls are balanced.
+ *
+ * Return 0 on success or a negative error code otherwise.
  */
-int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *dma_addr)
+int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr)
 {
 	struct omap_drm_private *priv = obj->dev->dev_private;
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
@@ -855,10 +866,15 @@ int omap_gem_get_paddr(struct drm_gem_object *obj, dma_addr_t *dma_addr)
 	return ret;
 }
 
-/* Release physical address, when DMA is no longer being performed.. this
- * could potentially unpin and unmap buffers from TILER
+/**
+ * omap_gem_unpin() - Unpin a GEM object from memory
+ * @obj: the GEM object
+ *
+ * Unpin the given GEM object previously pinned with omap_gem_pin(). Pins are
+ * reference-counted, the actualy unpin will only be performed when the number
+ * of calls to this function matches the number of calls to omap_gem_pin().
  */
-void omap_gem_put_paddr(struct drm_gem_object *obj)
+void omap_gem_unpin(struct drm_gem_object *obj)
 {
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
 	int ret;
@@ -919,9 +935,9 @@ int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient)
  * increasing the pin count (which we don't really do yet anyways,
  * because we don't support swapping pages back out).  And 'remap'
  * might not be quite the right name, but I wanted to keep it working
- * similarly to omap_gem_get_paddr().  Note though that mutex is not
+ * similarly to omap_gem_pin().  Note though that mutex is not
  * aquired if !remap (because this can be called in atomic ctxt),
- * but probably omap_gem_get_paddr() should be changed to work in the
+ * but probably omap_gem_unpin() should be changed to work in the
  * same way.  If !remap, a matching omap_gem_put_pages() call is not
  * required (and should not be made).
  */
diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
index 0e527c9eaee9..f4cff432bab9 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
@@ -41,7 +41,7 @@ static struct sg_table *omap_gem_map_dma_buf(
 	/* camera, etc, need physically contiguous.. but we need a
 	 * better way to know this..
 	 */
-	ret = omap_gem_get_paddr(obj, &dma_addr);
+	ret = omap_gem_pin(obj, &dma_addr);
 	if (ret)
 		goto out;
 
@@ -54,7 +54,7 @@ static struct sg_table *omap_gem_map_dma_buf(
 	sg_set_page(sg->sgl, pfn_to_page(PFN_DOWN(dma_addr)), obj->size, 0);
 	sg_dma_address(sg->sgl) = dma_addr;
 
-	/* this should be after _get_paddr() to ensure we have pages attached */
+	/* this must be after omap_gem_pin() to ensure we have pages attached */
 	omap_gem_dma_sync(obj, dir);
 
 	return sg;
@@ -67,7 +67,7 @@ static void omap_gem_unmap_dma_buf(struct dma_buf_attachment *attachment,
 		struct sg_table *sg, enum dma_data_direction dir)
 {
 	struct drm_gem_object *obj = attachment->dmabuf->priv;
-	omap_gem_put_paddr(obj);
+	omap_gem_unpin(obj);
 	sg_free_table(sg);
 	kfree(sg);
 }
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 04/10] drm: omapdrm: Lower indentation level in omap_gem_dma_sync_buffer()
  2017-04-20 21:33 [PATCH v2 00/10] omapdrm: GEM objects fixes Laurent Pinchart
                   ` (2 preceding siblings ...)
  2017-04-20 21:33 ` [PATCH v2 03/10] drm: omapdrm: Rename omap_gem_(get|put)_paddr() to omap_gem_(un)pin() Laurent Pinchart
@ 2017-04-20 21:33 ` Laurent Pinchart
  2017-04-24 10:22   ` Tomi Valkeinen
  2017-04-20 21:33 ` [PATCH v2 05/10] drm: omapdrm: Rename the omap_gem_object addrs field to dma_addrs Laurent Pinchart
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Laurent Pinchart @ 2017-04-20 21:33 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

This makes the function more readable.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_gem.c | 43 +++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 121de88c2ad3..37ac3832c208 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -752,36 +752,35 @@ void omap_gem_dma_sync(struct drm_gem_object *obj,
 {
 	struct drm_device *dev = obj->dev;
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
+	int i, npages = obj->size >> PAGE_SHIFT;
+	struct page **pages = omap_obj->pages;
+	bool dirty = false;
 
-	if (is_cached_coherent(obj)) {
-		int i, npages = obj->size >> PAGE_SHIFT;
-		struct page **pages = omap_obj->pages;
-		bool dirty = false;
-
-		for (i = 0; i < npages; i++) {
-			if (!omap_obj->addrs[i]) {
-				dma_addr_t addr;
+	if (!is_cached_coherent(obj))
+		return;
 
-				addr = dma_map_page(dev->dev, pages[i], 0,
-						PAGE_SIZE, DMA_BIDIRECTIONAL);
+	for (i = 0; i < npages; i++) {
+		if (!omap_obj->addrs[i]) {
+			dma_addr_t addr;
 
-				if (dma_mapping_error(dev->dev, addr)) {
-					dev_warn(dev->dev,
-						"%s: failed to map page\n",
-						__func__);
-					break;
-				}
+			addr = dma_map_page(dev->dev, pages[i], 0,
+					    PAGE_SIZE, DMA_BIDIRECTIONAL);
 
-				dirty = true;
-				omap_obj->addrs[i] = addr;
+			if (dma_mapping_error(dev->dev, addr)) {
+				dev_warn(dev->dev, "%s: failed to map page\n",
+					__func__);
+				break;
 			}
-		}
 
-		if (dirty) {
-			unmap_mapping_range(obj->filp->f_mapping, 0,
-					omap_gem_mmap_size(obj), 1);
+			dirty = true;
+			omap_obj->addrs[i] = addr;
 		}
 	}
+
+	if (dirty) {
+		unmap_mapping_range(obj->filp->f_mapping, 0,
+				    omap_gem_mmap_size(obj), 1);
+	}
 }
 
 /**
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 05/10] drm: omapdrm: Rename the omap_gem_object addrs field to dma_addrs
  2017-04-20 21:33 [PATCH v2 00/10] omapdrm: GEM objects fixes Laurent Pinchart
                   ` (3 preceding siblings ...)
  2017-04-20 21:33 ` [PATCH v2 04/10] drm: omapdrm: Lower indentation level in omap_gem_dma_sync_buffer() Laurent Pinchart
@ 2017-04-20 21:33 ` Laurent Pinchart
  2017-04-24 10:24   ` Tomi Valkeinen
  2017-04-20 21:33 ` [PATCH v2 06/10] drm: omapdrm: Rename GEM DMA sync functions Laurent Pinchart
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Laurent Pinchart @ 2017-04-20 21:33 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The field contains DMA addresses, clarify that by renaming it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_gem.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 37ac3832c208..055a0c886ab1 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -95,7 +95,7 @@ struct omap_gem_object {
 	struct page **pages;
 
 	/** addresses corresponding to pages in above array */
-	dma_addr_t *addrs;
+	dma_addr_t *dma_addrs;
 
 	/**
 	 * Virtual address, if mapped.
@@ -277,7 +277,7 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
 		}
 	}
 
-	omap_obj->addrs = addrs;
+	omap_obj->dma_addrs = addrs;
 	omap_obj->pages = pages;
 
 	return 0;
@@ -323,15 +323,15 @@ static void omap_gem_detach_pages(struct drm_gem_object *obj)
 	if (omap_obj->flags & (OMAP_BO_WC|OMAP_BO_UNCACHED)) {
 		int i, npages = obj->size >> PAGE_SHIFT;
 		for (i = 0; i < npages; i++) {
-			if (omap_obj->addrs[i])
+			if (omap_obj->dma_addrs[i])
 				dma_unmap_page(obj->dev->dev,
-					       omap_obj->addrs[i],
+					       omap_obj->dma_addrs[i],
 					       PAGE_SIZE, DMA_BIDIRECTIONAL);
 		}
 	}
 
-	kfree(omap_obj->addrs);
-	omap_obj->addrs = NULL;
+	kfree(omap_obj->dma_addrs);
+	omap_obj->dma_addrs = NULL;
 
 	drm_gem_put_pages(obj, omap_obj->pages, true, false);
 	omap_obj->pages = NULL;
@@ -739,10 +739,10 @@ void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff)
 	struct drm_device *dev = obj->dev;
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
 
-	if (is_cached_coherent(obj) && omap_obj->addrs[pgoff]) {
-		dma_unmap_page(dev->dev, omap_obj->addrs[pgoff],
+	if (is_cached_coherent(obj) && omap_obj->dma_addrs[pgoff]) {
+		dma_unmap_page(dev->dev, omap_obj->dma_addrs[pgoff],
 				PAGE_SIZE, DMA_BIDIRECTIONAL);
-		omap_obj->addrs[pgoff] = 0;
+		omap_obj->dma_addrs[pgoff] = 0;
 	}
 }
 
@@ -760,7 +760,7 @@ void omap_gem_dma_sync(struct drm_gem_object *obj,
 		return;
 
 	for (i = 0; i < npages; i++) {
-		if (!omap_obj->addrs[i]) {
+		if (!omap_obj->dma_addrs[i]) {
 			dma_addr_t addr;
 
 			addr = dma_map_page(dev->dev, pages[i], 0,
@@ -773,7 +773,7 @@ void omap_gem_dma_sync(struct drm_gem_object *obj,
 			}
 
 			dirty = true;
-			omap_obj->addrs[i] = addr;
+			omap_obj->dma_addrs[i] = addr;
 		}
 	}
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 06/10] drm: omapdrm: Rename GEM DMA sync functions
  2017-04-20 21:33 [PATCH v2 00/10] omapdrm: GEM objects fixes Laurent Pinchart
                   ` (4 preceding siblings ...)
  2017-04-20 21:33 ` [PATCH v2 05/10] drm: omapdrm: Rename the omap_gem_object addrs field to dma_addrs Laurent Pinchart
@ 2017-04-20 21:33 ` Laurent Pinchart
  2017-04-24 10:32   ` Tomi Valkeinen
  2017-04-20 21:33 ` [PATCH v2 07/10] drm: omapdrm: Fix incorrect usage of the term 'cache coherency' Laurent Pinchart
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Laurent Pinchart @ 2017-04-20 21:33 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The omap_gem_cpu_sync() function operates at a page level, while the
omap_gem_dma_sync() function operates at a buffer level. Rename them to
omap_gem_cpu_sync_page() and omap_gem_dma_sync_buffer() respectively to
avoid confusion.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_drv.h        | 4 ++--
 drivers/gpu/drm/omapdrm/omap_fb.c         | 2 +-
 drivers/gpu/drm/omapdrm/omap_gem.c        | 6 +++---
 drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 6 +++---
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index f2db84767bf8..621f5aa0142f 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -185,8 +185,8 @@ int omap_gem_mmap_obj(struct drm_gem_object *obj,
 		struct vm_area_struct *vma);
 int omap_gem_fault(struct vm_fault *vmf);
 int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
-void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff);
-void omap_gem_dma_sync(struct drm_gem_object *obj,
+void omap_gem_cpu_sync_page(struct drm_gem_object *obj, int pgoff);
+void omap_gem_dma_sync_buffer(struct drm_gem_object *obj,
 		enum dma_data_direction dir);
 int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr);
 void omap_gem_unpin(struct drm_gem_object *obj);
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index a25a99fc6a34..981b415d856f 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -262,7 +262,7 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
 		ret = omap_gem_pin(plane->bo, &plane->dma_addr);
 		if (ret)
 			goto fail;
-		omap_gem_dma_sync(plane->bo, DMA_TO_DEVICE);
+		omap_gem_dma_sync_buffer(plane->bo, DMA_TO_DEVICE);
 	}
 
 	omap_fb->pin_count++;
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 055a0c886ab1..d6d38e569fff 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -388,7 +388,7 @@ static int fault_1d(struct drm_gem_object *obj,
 	pgoff = (vmf->address - vma->vm_start) >> PAGE_SHIFT;
 
 	if (omap_obj->pages) {
-		omap_gem_cpu_sync(obj, pgoff);
+		omap_gem_cpu_sync_page(obj, pgoff);
 		pfn = page_to_pfn(omap_obj->pages[pgoff]);
 	} else {
 		BUG_ON(!is_contiguous(omap_obj));
@@ -734,7 +734,7 @@ static inline bool is_cached_coherent(struct drm_gem_object *obj)
 /* Sync the buffer for CPU access.. note pages should already be
  * attached, ie. omap_gem_get_pages()
  */
-void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff)
+void omap_gem_cpu_sync_page(struct drm_gem_object *obj, int pgoff)
 {
 	struct drm_device *dev = obj->dev;
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
@@ -747,7 +747,7 @@ void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff)
 }
 
 /* sync the buffer for DMA access */
-void omap_gem_dma_sync(struct drm_gem_object *obj,
+void omap_gem_dma_sync_buffer(struct drm_gem_object *obj,
 		enum dma_data_direction dir)
 {
 	struct drm_device *dev = obj->dev;
diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
index f4cff432bab9..fdf878b8c51a 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
@@ -55,7 +55,7 @@ static struct sg_table *omap_gem_map_dma_buf(
 	sg_dma_address(sg->sgl) = dma_addr;
 
 	/* this must be after omap_gem_pin() to ensure we have pages attached */
-	omap_gem_dma_sync(obj, dir);
+	omap_gem_dma_sync_buffer(obj, dir);
 
 	return sg;
 out:
@@ -112,7 +112,7 @@ static void *omap_gem_dmabuf_kmap_atomic(struct dma_buf *buffer,
 	struct drm_gem_object *obj = buffer->priv;
 	struct page **pages;
 	omap_gem_get_pages(obj, &pages, false);
-	omap_gem_cpu_sync(obj, page_num);
+	omap_gem_cpu_sync_page(obj, page_num);
 	return kmap_atomic(pages[page_num]);
 }
 
@@ -128,7 +128,7 @@ static void *omap_gem_dmabuf_kmap(struct dma_buf *buffer,
 	struct drm_gem_object *obj = buffer->priv;
 	struct page **pages;
 	omap_gem_get_pages(obj, &pages, false);
-	omap_gem_cpu_sync(obj, page_num);
+	omap_gem_cpu_sync_page(obj, page_num);
 	return kmap(pages[page_num]);
 }
 
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 07/10] drm: omapdrm: Fix incorrect usage of the term 'cache coherency'
  2017-04-20 21:33 [PATCH v2 00/10] omapdrm: GEM objects fixes Laurent Pinchart
                   ` (5 preceding siblings ...)
  2017-04-20 21:33 ` [PATCH v2 06/10] drm: omapdrm: Rename GEM DMA sync functions Laurent Pinchart
@ 2017-04-20 21:33 ` Laurent Pinchart
  2017-04-24 10:44   ` Tomi Valkeinen
  2017-04-20 21:33 ` [PATCH v2 08/10] drm: omapdrm: DMA-unmap pages for all buffer types when freeing buffers Laurent Pinchart
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Laurent Pinchart @ 2017-04-20 21:33 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The is_cache_coherent() function currently returns true when the mapping
is not cache-coherent. This isn't a bug as such as the callers interpret
cache-coherent as meaning that the driver has to handle the coherency
manually, but it is nonetheless very confusing. Fix it and add a bit
more documentation to explain how cached buffers are handled.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
Changes since v1:

- Fixed one mistakenly inverted cache coherency check
---
 drivers/gpu/drm/omapdrm/omap_gem.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index d6d38e569fff..43b60a146edf 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -719,16 +719,21 @@ int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll)
  * Memory Management & DMA Sync
  */
 
-/**
- * shmem buffers that are mapped cached can simulate coherency via using
- * page faulting to keep track of dirty pages
+/*
+ * shmem buffers that are mapped cached are not coherent.
+ *
+ * We keep track of dirty pages using page faulting to perform cache management.
+ * When a page is mapped to the CPU in read/write mode the device can't access
+ * it and omap_obj->dma_addrs[i] is NULL. When a page is mapped to the device
+ * the omap_obj->dma_addrs[i] is set to the DMA address, and the page is
+ * unmapped from the CPU.
  */
 static inline bool is_cached_coherent(struct drm_gem_object *obj)
 {
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
 
-	return (omap_obj->flags & OMAP_BO_MEM_SHMEM) &&
-		((omap_obj->flags & OMAP_BO_CACHE_MASK) == OMAP_BO_CACHED);
+	return !((omap_obj->flags & OMAP_BO_MEM_SHMEM) &&
+		((omap_obj->flags & OMAP_BO_CACHE_MASK) == OMAP_BO_CACHED));
 }
 
 /* Sync the buffer for CPU access.. note pages should already be
@@ -739,7 +744,10 @@ void omap_gem_cpu_sync_page(struct drm_gem_object *obj, int pgoff)
 	struct drm_device *dev = obj->dev;
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
 
-	if (is_cached_coherent(obj) && omap_obj->dma_addrs[pgoff]) {
+	if (is_cached_coherent(obj))
+		return;
+
+	if (omap_obj->dma_addrs[pgoff]) {
 		dma_unmap_page(dev->dev, omap_obj->dma_addrs[pgoff],
 				PAGE_SIZE, DMA_BIDIRECTIONAL);
 		omap_obj->dma_addrs[pgoff] = 0;
@@ -756,7 +764,7 @@ void omap_gem_dma_sync_buffer(struct drm_gem_object *obj,
 	struct page **pages = omap_obj->pages;
 	bool dirty = false;
 
-	if (!is_cached_coherent(obj))
+	if (is_cached_coherent(obj))
 		return;
 
 	for (i = 0; i < npages; i++) {
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 08/10] drm: omapdrm: DMA-unmap pages for all buffer types when freeing buffers
  2017-04-20 21:33 [PATCH v2 00/10] omapdrm: GEM objects fixes Laurent Pinchart
                   ` (6 preceding siblings ...)
  2017-04-20 21:33 ` [PATCH v2 07/10] drm: omapdrm: Fix incorrect usage of the term 'cache coherency' Laurent Pinchart
@ 2017-04-20 21:33 ` Laurent Pinchart
  2017-04-27 10:48   ` Tomi Valkeinen
  2017-04-20 21:33 ` [PATCH v2 09/10] drm: omapdrm: Map pages for DMA in DMA_TO_DEVICE direction Laurent Pinchart
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Laurent Pinchart @ 2017-04-20 21:33 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

Both coherent (uncached) and non-coherent (cached) buffers can have
their pages mapped to the device through the DMA mapping API. Make sure
to unmap any mapped page when freeing a buffer, regardless of its type.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_gem.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 43b60a146edf..7fcf607ca0b6 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -316,18 +316,13 @@ static int get_pages(struct drm_gem_object *obj, struct page ***pages)
 static void omap_gem_detach_pages(struct drm_gem_object *obj)
 {
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
+	unsigned int npages = obj->size >> PAGE_SHIFT;
+	unsigned int i;
 
-	/* for non-cached buffers, ensure the new pages are clean because
-	 * DSS, GPU, etc. are not cache coherent:
-	 */
-	if (omap_obj->flags & (OMAP_BO_WC|OMAP_BO_UNCACHED)) {
-		int i, npages = obj->size >> PAGE_SHIFT;
-		for (i = 0; i < npages; i++) {
-			if (omap_obj->dma_addrs[i])
-				dma_unmap_page(obj->dev->dev,
-					       omap_obj->dma_addrs[i],
-					       PAGE_SIZE, DMA_BIDIRECTIONAL);
-		}
+	for (i = 0; i < npages; i++) {
+		if (omap_obj->dma_addrs[i])
+			dma_unmap_page(obj->dev->dev, omap_obj->dma_addrs[i],
+				       PAGE_SIZE, DMA_BIDIRECTIONAL);
 	}
 
 	kfree(omap_obj->dma_addrs);
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 09/10] drm: omapdrm: Map pages for DMA in DMA_TO_DEVICE direction
  2017-04-20 21:33 [PATCH v2 00/10] omapdrm: GEM objects fixes Laurent Pinchart
                   ` (7 preceding siblings ...)
  2017-04-20 21:33 ` [PATCH v2 08/10] drm: omapdrm: DMA-unmap pages for all buffer types when freeing buffers Laurent Pinchart
@ 2017-04-20 21:33 ` Laurent Pinchart
  2017-04-27 10:48   ` Tomi Valkeinen
  2017-04-20 21:33 ` [PATCH v2 10/10] drm: omapdrm: Take GEM obj and DRM dev references when exporting dmabuf Laurent Pinchart
  2017-05-09  8:14 ` [PATCH v2 00/10] omapdrm: GEM objects fixes Tomi Valkeinen
  10 siblings, 1 reply; 27+ messages in thread
From: Laurent Pinchart @ 2017-04-20 21:33 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

The display engine only reads from memory, there's no need to use
bidirectional DMA mappings. Use DMA_TO_DEVICE instead.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_gem.c        | 11 +++++------
 drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |  4 ++--
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 7fcf607ca0b6..030a1f45d0a1 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -254,7 +254,7 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
 
 		for (i = 0; i < npages; i++) {
 			addrs[i] = dma_map_page(dev->dev, pages[i],
-					0, PAGE_SIZE, DMA_BIDIRECTIONAL);
+					0, PAGE_SIZE, DMA_TO_DEVICE);
 
 			if (dma_mapping_error(dev->dev, addrs[i])) {
 				dev_warn(dev->dev,
@@ -262,7 +262,7 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
 
 				for (i = i - 1; i >= 0; --i) {
 					dma_unmap_page(dev->dev, addrs[i],
-						PAGE_SIZE, DMA_BIDIRECTIONAL);
+						PAGE_SIZE, DMA_TO_DEVICE);
 				}
 
 				ret = -ENOMEM;
@@ -322,7 +322,7 @@ static void omap_gem_detach_pages(struct drm_gem_object *obj)
 	for (i = 0; i < npages; i++) {
 		if (omap_obj->dma_addrs[i])
 			dma_unmap_page(obj->dev->dev, omap_obj->dma_addrs[i],
-				       PAGE_SIZE, DMA_BIDIRECTIONAL);
+				       PAGE_SIZE, DMA_TO_DEVICE);
 	}
 
 	kfree(omap_obj->dma_addrs);
@@ -744,7 +744,7 @@ void omap_gem_cpu_sync_page(struct drm_gem_object *obj, int pgoff)
 
 	if (omap_obj->dma_addrs[pgoff]) {
 		dma_unmap_page(dev->dev, omap_obj->dma_addrs[pgoff],
-				PAGE_SIZE, DMA_BIDIRECTIONAL);
+				PAGE_SIZE, DMA_TO_DEVICE);
 		omap_obj->dma_addrs[pgoff] = 0;
 	}
 }
@@ -767,8 +767,7 @@ void omap_gem_dma_sync_buffer(struct drm_gem_object *obj,
 			dma_addr_t addr;
 
 			addr = dma_map_page(dev->dev, pages[i], 0,
-					    PAGE_SIZE, DMA_BIDIRECTIONAL);
-
+					    PAGE_SIZE, dir);
 			if (dma_mapping_error(dev->dev, addr)) {
 				dev_warn(dev->dev, "%s: failed to map page\n",
 					__func__);
diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
index fdf878b8c51a..79dfded9613c 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
@@ -223,7 +223,7 @@ struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev,
 
 	get_dma_buf(dma_buf);
 
-	sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
+	sgt = dma_buf_map_attachment(attach, DMA_TO_DEVICE);
 	if (IS_ERR(sgt)) {
 		ret = PTR_ERR(sgt);
 		goto fail_detach;
@@ -240,7 +240,7 @@ struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev,
 	return obj;
 
 fail_unmap:
-	dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL);
+	dma_buf_unmap_attachment(attach, sgt, DMA_TO_DEVICE);
 fail_detach:
 	dma_buf_detach(dma_buf, attach);
 	dma_buf_put(dma_buf);
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 10/10] drm: omapdrm: Take GEM obj and DRM dev references when exporting dmabuf
  2017-04-20 21:33 [PATCH v2 00/10] omapdrm: GEM objects fixes Laurent Pinchart
                   ` (8 preceding siblings ...)
  2017-04-20 21:33 ` [PATCH v2 09/10] drm: omapdrm: Map pages for DMA in DMA_TO_DEVICE direction Laurent Pinchart
@ 2017-04-20 21:33 ` Laurent Pinchart
  2017-04-20 23:08   ` Chris Wilson
  2017-05-09  8:14 ` [PATCH v2 00/10] omapdrm: GEM objects fixes Tomi Valkeinen
  10 siblings, 1 reply; 27+ messages in thread
From: Laurent Pinchart @ 2017-04-20 21:33 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

To ensure that neither the GEM object nor the DRM device goes away while
a GEM object exported through dma-buf is still accessible, take a
reference to both the GEM object and the DRM device at export time. The
dma-buf release handler already releases the GEM object (which resulted
in a refcount underflow) and now also releases the DRM device.

Fixes: 6ad11bc3a0b8 ("staging: drm/omap: dmabuf/prime support")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
index 79dfded9613c..88ad723b3044 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
@@ -75,10 +75,11 @@ static void omap_gem_unmap_dma_buf(struct dma_buf_attachment *attachment,
 static void omap_gem_dmabuf_release(struct dma_buf *buffer)
 {
 	struct drm_gem_object *obj = buffer->priv;
-	/* release reference that was taken when dmabuf was exported
-	 * in omap_gem_prime_set()..
-	 */
+	struct drm_device *dev = obj->dev;
+
+	/* Release references taken by omap_gem_prime_export(). */
 	drm_gem_object_unreference_unlocked(obj);
+	drm_dev_ref(dev);
 }
 
 
@@ -184,13 +185,21 @@ struct dma_buf *omap_gem_prime_export(struct drm_device *dev,
 		struct drm_gem_object *obj, int flags)
 {
 	DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
+	struct dma_buf *dma_buf;
 
 	exp_info.ops = &omap_dmabuf_ops;
 	exp_info.size = obj->size;
 	exp_info.flags = flags;
 	exp_info.priv = obj;
 
-	return dma_buf_export(&exp_info);
+	dma_buf = dma_buf_export(&exp_info);
+	if (IS_ERR(dma_buf))
+		return dma_buf;
+
+	drm_dev_ref(dev);
+	drm_gem_object_reference(obj);
+
+	return dma_buf;
 }
 
 /* -----------------------------------------------------------------------------
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 10/10] drm: omapdrm: Take GEM obj and DRM dev references when exporting dmabuf
  2017-04-20 21:33 ` [PATCH v2 10/10] drm: omapdrm: Take GEM obj and DRM dev references when exporting dmabuf Laurent Pinchart
@ 2017-04-20 23:08   ` Chris Wilson
  2017-04-21  8:49     ` Laurent Pinchart
  0 siblings, 1 reply; 27+ messages in thread
From: Chris Wilson @ 2017-04-20 23:08 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: Tomi Valkeinen, dri-devel

On Fri, Apr 21, 2017 at 12:33:59AM +0300, Laurent Pinchart wrote:
> To ensure that neither the GEM object nor the DRM device goes away while
> a GEM object exported through dma-buf is still accessible, take a
> reference to both the GEM object and the DRM device at export time. The
> dma-buf release handler already releases the GEM object (which resulted
> in a refcount underflow) and now also releases the DRM device.
> 
> Fixes: 6ad11bc3a0b8 ("staging: drm/omap: dmabuf/prime support")
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
> index 79dfded9613c..88ad723b3044 100644
> --- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
> +++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
> @@ -75,10 +75,11 @@ static void omap_gem_unmap_dma_buf(struct dma_buf_attachment *attachment,
>  static void omap_gem_dmabuf_release(struct dma_buf *buffer)
>  {
>  	struct drm_gem_object *obj = buffer->priv;
> -	/* release reference that was taken when dmabuf was exported
> -	 * in omap_gem_prime_set()..
> -	 */
> +	struct drm_device *dev = obj->dev;
> +
> +	/* Release references taken by omap_gem_prime_export(). */
>  	drm_gem_object_unreference_unlocked(obj);
> +	drm_dev_ref(dev);
>  }
>  
>  
> @@ -184,13 +185,21 @@ struct dma_buf *omap_gem_prime_export(struct drm_device *dev,
>  		struct drm_gem_object *obj, int flags)
>  {
>  	DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
> +	struct dma_buf *dma_buf;
>  
>  	exp_info.ops = &omap_dmabuf_ops;
>  	exp_info.size = obj->size;
>  	exp_info.flags = flags;
>  	exp_info.priv = obj;
>  
> -	return dma_buf_export(&exp_info);
> +	dma_buf = dma_buf_export(&exp_info);
> +	if (IS_ERR(dma_buf))
> +		return dma_buf;
> +
> +	drm_dev_ref(dev);
> +	drm_gem_object_reference(obj);
> +
> +	return dma_buf;
>  }

Please see drm_gem_dmabuf_export() and drm_gem_dmabuf_release() - unless
the double drm_dev_ref() wasn't an accident...
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 10/10] drm: omapdrm: Take GEM obj and DRM dev references when exporting dmabuf
  2017-04-20 23:08   ` Chris Wilson
@ 2017-04-21  8:49     ` Laurent Pinchart
  2017-05-08 18:59       ` [PATCH v2.1 10/10] drm: omapdrm: Take GEM object reference " Laurent Pinchart
  0 siblings, 1 reply; 27+ messages in thread
From: Laurent Pinchart @ 2017-04-21  8:49 UTC (permalink / raw)
  To: Chris Wilson; +Cc: Tomi Valkeinen, dri-devel

Hi Chris,

On Friday 21 Apr 2017 00:08:21 Chris Wilson wrote:
> On Fri, Apr 21, 2017 at 12:33:59AM +0300, Laurent Pinchart wrote:
> > To ensure that neither the GEM object nor the DRM device goes away while
> > a GEM object exported through dma-buf is still accessible, take a
> > reference to both the GEM object and the DRM device at export time. The
> > dma-buf release handler already releases the GEM object (which resulted
> > in a refcount underflow) and now also releases the DRM device.
> > 
> > Fixes: 6ad11bc3a0b8 ("staging: drm/omap: dmabuf/prime support")
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > 
> >  drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 17 +++++++++++++----
> >  1 file changed, 13 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
> > b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c index
> > 79dfded9613c..88ad723b3044 100644
> > --- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
> > +++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
> > @@ -75,10 +75,11 @@ static void omap_gem_unmap_dma_buf(struct
> > dma_buf_attachment *attachment,> 
> >  static void omap_gem_dmabuf_release(struct dma_buf *buffer)
> >  {
> >  
> >  	struct drm_gem_object *obj = buffer->priv;
> > 
> > -	/* release reference that was taken when dmabuf was exported
> > -	 * in omap_gem_prime_set()..
> > -	 */
> > +	struct drm_device *dev = obj->dev;
> > +
> > +	/* Release references taken by omap_gem_prime_export(). */
> > 
> >  	drm_gem_object_unreference_unlocked(obj);
> > 
> > +	drm_dev_ref(dev);
> > 
> >  }
> > 
> > @@ -184,13 +185,21 @@ struct dma_buf *omap_gem_prime_export(struct
> > drm_device *dev,> 
> >  		struct drm_gem_object *obj, int flags)
> >  
> >  {
> >  
> >  	DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
> > 
> > +	struct dma_buf *dma_buf;
> > 
> >  	exp_info.ops = &omap_dmabuf_ops;
> >  	exp_info.size = obj->size;
> >  	exp_info.flags = flags;
> >  	exp_info.priv = obj;
> > 
> > -	return dma_buf_export(&exp_info);
> > +	dma_buf = dma_buf_export(&exp_info);
> > +	if (IS_ERR(dma_buf))
> > +		return dma_buf;
> > +
> > +	drm_dev_ref(dev);
> > +	drm_gem_object_reference(obj);
> > +
> > +	return dma_buf;
> > 
> >  }
> 
> Please see drm_gem_dmabuf_export() and drm_gem_dmabuf_release()

Good point, I'll replace the custom implementation by those functions. I had 
noticed drm_gem_dmabuf_release() but for some reason failed to see that 
drm_gem_dmabuf_export() was exported.

> - unless the double drm_dev_ref() wasn't an accident...

Oops :-/ Thank you for catching that.

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 01/10] drm: omapdrm: Remove remap argument to omap_gem_get_paddr()
  2017-04-20 21:33 ` [PATCH v2 01/10] drm: omapdrm: Remove remap argument to omap_gem_get_paddr() Laurent Pinchart
@ 2017-04-24 10:09   ` Tomi Valkeinen
  0 siblings, 0 replies; 27+ messages in thread
From: Tomi Valkeinen @ 2017-04-24 10:09 UTC (permalink / raw)
  To: Laurent Pinchart, dri-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 637 bytes --]

On 21/04/17 00:33, Laurent Pinchart wrote:
> The function is always called with the remap argument set to true.
> Hardcode that behaviour and remove it.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/omapdrm/omap_drv.h        |  3 +--
>  drivers/gpu/drm/omapdrm/omap_fb.c         |  2 +-
>  drivers/gpu/drm/omapdrm/omap_fbdev.c      |  2 +-
>  drivers/gpu/drm/omapdrm/omap_gem.c        | 10 ++++------
>  drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |  2 +-
>  5 files changed, 8 insertions(+), 11 deletions(-)

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

 Tomi


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 02/10] drm: omapdrm: Rename occurrences of paddr to dma_addr
  2017-04-20 21:33 ` [PATCH v2 02/10] drm: omapdrm: Rename occurrences of paddr to dma_addr Laurent Pinchart
@ 2017-04-24 10:13   ` Tomi Valkeinen
  0 siblings, 0 replies; 27+ messages in thread
From: Tomi Valkeinen @ 2017-04-24 10:13 UTC (permalink / raw)
  To: Laurent Pinchart, dri-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 744 bytes --]

On 21/04/17 00:33, Laurent Pinchart wrote:
> The fields, variables and functions deal with DMA addresses, name them
> accordingly. The omap_gem_get_paddr() and omap_gem_put_paddr() will be
> addressed differently separately.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/omapdrm/omap_drv.h        |  6 +--
>  drivers/gpu/drm/omapdrm/omap_fb.c         | 21 +++++-----
>  drivers/gpu/drm/omapdrm/omap_fbdev.c      |  8 ++--
>  drivers/gpu/drm/omapdrm/omap_gem.c        | 70 +++++++++++++++----------------
>  drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |  8 ++--
>  5 files changed, 57 insertions(+), 56 deletions(-)

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

 Tomi


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 03/10] drm: omapdrm: Rename omap_gem_(get|put)_paddr() to omap_gem_(un)pin()
  2017-04-20 21:33 ` [PATCH v2 03/10] drm: omapdrm: Rename omap_gem_(get|put)_paddr() to omap_gem_(un)pin() Laurent Pinchart
@ 2017-04-24 10:16   ` Tomi Valkeinen
  2017-04-24 14:08     ` Laurent Pinchart
  0 siblings, 1 reply; 27+ messages in thread
From: Tomi Valkeinen @ 2017-04-24 10:16 UTC (permalink / raw)
  To: Laurent Pinchart, dri-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 696 bytes --]

On 21/04/17 00:33, Laurent Pinchart wrote:
> The reflects the purpose of the function better.

s/The/This/?

Btw, I usually use "drm/omap" as the subject prefix, it's shorter.

> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/omapdrm/omap_drv.h        |  4 ++--
>  drivers/gpu/drm/omapdrm/omap_fb.c         |  6 ++---
>  drivers/gpu/drm/omapdrm/omap_fbdev.c      |  9 ++++----
>  drivers/gpu/drm/omapdrm/omap_gem.c        | 38 ++++++++++++++++++++++---------
>  drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |  6 ++---
>  5 files changed, 39 insertions(+), 24 deletions(-)

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

 Tomi


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 04/10] drm: omapdrm: Lower indentation level in omap_gem_dma_sync_buffer()
  2017-04-20 21:33 ` [PATCH v2 04/10] drm: omapdrm: Lower indentation level in omap_gem_dma_sync_buffer() Laurent Pinchart
@ 2017-04-24 10:22   ` Tomi Valkeinen
  0 siblings, 0 replies; 27+ messages in thread
From: Tomi Valkeinen @ 2017-04-24 10:22 UTC (permalink / raw)
  To: Laurent Pinchart, dri-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 371 bytes --]

On 21/04/17 00:33, Laurent Pinchart wrote:
> This makes the function more readable.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/omapdrm/omap_gem.c | 43 +++++++++++++++++++-------------------
>  1 file changed, 21 insertions(+), 22 deletions(-)

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

 Tomi


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 05/10] drm: omapdrm: Rename the omap_gem_object addrs field to dma_addrs
  2017-04-20 21:33 ` [PATCH v2 05/10] drm: omapdrm: Rename the omap_gem_object addrs field to dma_addrs Laurent Pinchart
@ 2017-04-24 10:24   ` Tomi Valkeinen
  0 siblings, 0 replies; 27+ messages in thread
From: Tomi Valkeinen @ 2017-04-24 10:24 UTC (permalink / raw)
  To: Laurent Pinchart, dri-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 379 bytes --]

On 21/04/17 00:33, Laurent Pinchart wrote:
> The field contains DMA addresses, clarify that by renaming it.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/omapdrm/omap_gem.c | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

 Tomi


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 06/10] drm: omapdrm: Rename GEM DMA sync functions
  2017-04-20 21:33 ` [PATCH v2 06/10] drm: omapdrm: Rename GEM DMA sync functions Laurent Pinchart
@ 2017-04-24 10:32   ` Tomi Valkeinen
  0 siblings, 0 replies; 27+ messages in thread
From: Tomi Valkeinen @ 2017-04-24 10:32 UTC (permalink / raw)
  To: Laurent Pinchart, dri-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 709 bytes --]

On 21/04/17 00:33, Laurent Pinchart wrote:
> The omap_gem_cpu_sync() function operates at a page level, while the
> omap_gem_dma_sync() function operates at a buffer level. Rename them to
> omap_gem_cpu_sync_page() and omap_gem_dma_sync_buffer() respectively to
> avoid confusion.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/omapdrm/omap_drv.h        | 4 ++--
>  drivers/gpu/drm/omapdrm/omap_fb.c         | 2 +-
>  drivers/gpu/drm/omapdrm/omap_gem.c        | 6 +++---
>  drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 6 +++---
>  4 files changed, 9 insertions(+), 9 deletions(-)

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

 Tomi


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 07/10] drm: omapdrm: Fix incorrect usage of the term 'cache coherency'
  2017-04-20 21:33 ` [PATCH v2 07/10] drm: omapdrm: Fix incorrect usage of the term 'cache coherency' Laurent Pinchart
@ 2017-04-24 10:44   ` Tomi Valkeinen
  2017-04-24 14:25     ` Laurent Pinchart
  0 siblings, 1 reply; 27+ messages in thread
From: Tomi Valkeinen @ 2017-04-24 10:44 UTC (permalink / raw)
  To: Laurent Pinchart, dri-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 2723 bytes --]

On 21/04/17 00:33, Laurent Pinchart wrote:
> The is_cache_coherent() function currently returns true when the mapping
> is not cache-coherent. This isn't a bug as such as the callers interpret
> cache-coherent as meaning that the driver has to handle the coherency
> manually, but it is nonetheless very confusing. Fix it and add a bit
> more documentation to explain how cached buffers are handled.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> Changes since v1:
> 
> - Fixed one mistakenly inverted cache coherency check
> ---
>  drivers/gpu/drm/omapdrm/omap_gem.c | 22 +++++++++++++++-------
>  1 file changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
> index d6d38e569fff..43b60a146edf 100644
> --- a/drivers/gpu/drm/omapdrm/omap_gem.c
> +++ b/drivers/gpu/drm/omapdrm/omap_gem.c
> @@ -719,16 +719,21 @@ int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll)
>   * Memory Management & DMA Sync
>   */
>  
> -/**
> - * shmem buffers that are mapped cached can simulate coherency via using
> - * page faulting to keep track of dirty pages
> +/*
> + * shmem buffers that are mapped cached are not coherent.

We use shmem only with TILER. Not all SoCs have TILER (and you can
disable TILER on the SoCs that have it).

As this patch is more or less a cleanup, I'm not sure if the above
should be part of this patch. But it makes me wonder: if we don't use
shmem, we use dma_alloc_writecombine. Do we still end up mapping it to
the userspace as cached? I think having two different caching types for
the same memory is illegal.

> + *
> + * We keep track of dirty pages using page faulting to perform cache management.
> + * When a page is mapped to the CPU in read/write mode the device can't access
> + * it and omap_obj->dma_addrs[i] is NULL. When a page is mapped to the device
> + * the omap_obj->dma_addrs[i] is set to the DMA address, and the page is
> + * unmapped from the CPU.
>   */
>  static inline bool is_cached_coherent(struct drm_gem_object *obj)
>  {
>  	struct omap_gem_object *omap_obj = to_omap_bo(obj);
>  
> -	return (omap_obj->flags & OMAP_BO_MEM_SHMEM) &&
> -		((omap_obj->flags & OMAP_BO_CACHE_MASK) == OMAP_BO_CACHED);
> +	return !((omap_obj->flags & OMAP_BO_MEM_SHMEM) &&
> +		((omap_obj->flags & OMAP_BO_CACHE_MASK) == OMAP_BO_CACHED));

Regardless of whether we support non-shmem cached buffers, isn't the
above overly complex? Why can't we just check for OMAP_BO_CACHED? Isn't
that the only case where the buffer is not coherent? At the moment this
function sounds more like "is_shmem_cached_coherent".

 Tomi


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 03/10] drm: omapdrm: Rename omap_gem_(get|put)_paddr() to omap_gem_(un)pin()
  2017-04-24 10:16   ` Tomi Valkeinen
@ 2017-04-24 14:08     ` Laurent Pinchart
  0 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2017-04-24 14:08 UTC (permalink / raw)
  To: Tomi Valkeinen; +Cc: dri-devel

Hi Tomi,

On Monday 24 Apr 2017 13:16:18 Tomi Valkeinen wrote:
> On 21/04/17 00:33, Laurent Pinchart wrote:
> > The reflects the purpose of the function better.
> 
> s/The/This/?

Yes, my bad, sorry. I'll fix it in my branch.

> Btw, I usually use "drm/omap" as the subject prefix, it's shorter.

I can do so if you like it better.

> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > 
> >  drivers/gpu/drm/omapdrm/omap_drv.h        |  4 ++--
> >  drivers/gpu/drm/omapdrm/omap_fb.c         |  6 ++---
> >  drivers/gpu/drm/omapdrm/omap_fbdev.c      |  9 ++++----
> >  drivers/gpu/drm/omapdrm/omap_gem.c        | 38 ++++++++++++++++++-------
> >  drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |  6 ++---
> >  5 files changed, 39 insertions(+), 24 deletions(-)
> 
> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> 
>  Tomi

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 07/10] drm: omapdrm: Fix incorrect usage of the term 'cache coherency'
  2017-04-24 10:44   ` Tomi Valkeinen
@ 2017-04-24 14:25     ` Laurent Pinchart
  2017-04-25  9:07       ` Tomi Valkeinen
  0 siblings, 1 reply; 27+ messages in thread
From: Laurent Pinchart @ 2017-04-24 14:25 UTC (permalink / raw)
  To: Tomi Valkeinen; +Cc: dri-devel

Hi Tomi,

On Monday 24 Apr 2017 13:44:23 Tomi Valkeinen wrote:
> On 21/04/17 00:33, Laurent Pinchart wrote:
> > The is_cache_coherent() function currently returns true when the mapping
> > is not cache-coherent. This isn't a bug as such as the callers interpret
> > cache-coherent as meaning that the driver has to handle the coherency
> > manually, but it is nonetheless very confusing. Fix it and add a bit
> > more documentation to explain how cached buffers are handled.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > Changes since v1:
> > 
> > - Fixed one mistakenly inverted cache coherency check
> > ---
> > 
> >  drivers/gpu/drm/omapdrm/omap_gem.c | 22 +++++++++++++++-------
> >  1 file changed, 15 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c
> > b/drivers/gpu/drm/omapdrm/omap_gem.c index d6d38e569fff..43b60a146edf
> > 100644
> > --- a/drivers/gpu/drm/omapdrm/omap_gem.c
> > +++ b/drivers/gpu/drm/omapdrm/omap_gem.c
> > @@ -719,16 +719,21 @@ int omap_gem_roll(struct drm_gem_object *obj,
> > uint32_t roll)> 
> >   * Memory Management & DMA Sync
> >   */
> > 
> > -/**
> > - * shmem buffers that are mapped cached can simulate coherency via using
> > - * page faulting to keep track of dirty pages
> > +/*
> > + * shmem buffers that are mapped cached are not coherent.
> 
> We use shmem only with TILER. Not all SoCs have TILER (and you can
> disable TILER on the SoCs that have it).
> 
> As this patch is more or less a cleanup, I'm not sure if the above
> should be part of this patch. But it makes me wonder: if we don't use
> shmem, we use dma_alloc_writecombine.

Only for OMAP_BO_SCANOUT buffers. Other buffers will still be allocated 
through shmem.

> Do we still end up mapping it to the userspace as cached?

Well, in that case, we actually end up not mapping it at all if the user 
requests cached mapping :-) omap_gem_mmap_obj() will return with a WARN_ON() 
and omap_gem_pin() (which used to be omap_gem_get_paddr()) will return -
EINVAL.

I believe we should disallow non-contiguous buffers without a DMM at 
allocation time. As for cached mapping of contiguous buffers, the dirty page 
tracking implementation requires shmem at the moment. This could be fixed, but 
isn't trivial. Do you see value in doing so, or should cached mappings of 
contiguous buffers be disallowed for the time being ?

> I think having two different caching types for the same memory is illegal.

It used to be documented as leading to unspecified behaviour in the ARM ARM, 
but I think that has been changed. If I'm not mistaken it doesn't cause any 
problem in practice, at least on the TI platforms I tested back when dealing 
with cache on OMAP3 :-)

> > + *
> > + * We keep track of dirty pages using page faulting to perform cache
> > management.
> > + * When a page is mapped to the CPU in read/write mode the device can't
> > access
> > + * it and omap_obj->dma_addrs[i] is NULL. When a page is mapped to the
> > device
> > + * the omap_obj->dma_addrs[i] is set to the DMA address, and the page is
> > + * unmapped from the CPU.
> >   */
> >  
> >  static inline bool is_cached_coherent(struct drm_gem_object *obj)
> >  {
> >  	struct omap_gem_object *omap_obj = to_omap_bo(obj);
> > 
> > -	return (omap_obj->flags & OMAP_BO_MEM_SHMEM) &&
> > -		((omap_obj->flags & OMAP_BO_CACHE_MASK) == OMAP_BO_CACHED);
> > +	return !((omap_obj->flags & OMAP_BO_MEM_SHMEM) &&
> > +		((omap_obj->flags & OMAP_BO_CACHE_MASK) == OMAP_BO_CACHED));
> 
> Regardless of whether we support non-shmem cached buffers, isn't the
> above overly complex? Why can't we just check for OMAP_BO_CACHED? Isn't
> that the only case where the buffer is not coherent? At the moment this
> function sounds more like "is_shmem_cached_coherent".

You're right. I propose fixing that in an additional patch to avoid potential 
changes to the behaviour in this one.

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 07/10] drm: omapdrm: Fix incorrect usage of the term 'cache coherency'
  2017-04-24 14:25     ` Laurent Pinchart
@ 2017-04-25  9:07       ` Tomi Valkeinen
  0 siblings, 0 replies; 27+ messages in thread
From: Tomi Valkeinen @ 2017-04-25  9:07 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: dri-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 3694 bytes --]

On 24/04/17 17:25, Laurent Pinchart wrote:
> Hi Tomi,
> 
> On Monday 24 Apr 2017 13:44:23 Tomi Valkeinen wrote:
>> On 21/04/17 00:33, Laurent Pinchart wrote:
>>> The is_cache_coherent() function currently returns true when the mapping
>>> is not cache-coherent. This isn't a bug as such as the callers interpret
>>> cache-coherent as meaning that the driver has to handle the coherency
>>> manually, but it is nonetheless very confusing. Fix it and add a bit
>>> more documentation to explain how cached buffers are handled.
>>>
>>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>> ---
>>> Changes since v1:
>>>
>>> - Fixed one mistakenly inverted cache coherency check
>>> ---
>>>
>>>  drivers/gpu/drm/omapdrm/omap_gem.c | 22 +++++++++++++++-------
>>>  1 file changed, 15 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c
>>> b/drivers/gpu/drm/omapdrm/omap_gem.c index d6d38e569fff..43b60a146edf
>>> 100644
>>> --- a/drivers/gpu/drm/omapdrm/omap_gem.c
>>> +++ b/drivers/gpu/drm/omapdrm/omap_gem.c
>>> @@ -719,16 +719,21 @@ int omap_gem_roll(struct drm_gem_object *obj,
>>> uint32_t roll)> 
>>>   * Memory Management & DMA Sync
>>>   */
>>>
>>> -/**
>>> - * shmem buffers that are mapped cached can simulate coherency via using
>>> - * page faulting to keep track of dirty pages
>>> +/*
>>> + * shmem buffers that are mapped cached are not coherent.
>>
>> We use shmem only with TILER. Not all SoCs have TILER (and you can
>> disable TILER on the SoCs that have it).
>>
>> As this patch is more or less a cleanup, I'm not sure if the above
>> should be part of this patch. But it makes me wonder: if we don't use
>> shmem, we use dma_alloc_writecombine.
> 
> Only for OMAP_BO_SCANOUT buffers. Other buffers will still be allocated 
> through shmem.

Right... I hope nobody allocates those. omapdrm should be used for dss
buffers, which means scanout...

>> Do we still end up mapping it to the userspace as cached?
> 
> Well, in that case, we actually end up not mapping it at all if the user 
> requests cached mapping :-) omap_gem_mmap_obj() will return with a WARN_ON() 
> and omap_gem_pin() (which used to be omap_gem_get_paddr()) will return -
> EINVAL.
> 
> I believe we should disallow non-contiguous buffers without a DMM at 
> allocation time. As for cached mapping of contiguous buffers, the dirty page 
> tracking implementation requires shmem at the moment. This could be fixed, but 
> isn't trivial. Do you see value in doing so, or should cached mappings of 
> contiguous buffers be disallowed for the time being ?

I think the answer depends on whether cached buffers are usable
(performance-wise). If not, we should drop cached buffer support
totally. If yes, then we should support them for contiguous buffers too.

>>>  static inline bool is_cached_coherent(struct drm_gem_object *obj)
>>>  {
>>>  	struct omap_gem_object *omap_obj = to_omap_bo(obj);
>>>
>>> -	return (omap_obj->flags & OMAP_BO_MEM_SHMEM) &&
>>> -		((omap_obj->flags & OMAP_BO_CACHE_MASK) == OMAP_BO_CACHED);
>>> +	return !((omap_obj->flags & OMAP_BO_MEM_SHMEM) &&
>>> +		((omap_obj->flags & OMAP_BO_CACHE_MASK) == OMAP_BO_CACHED));
>>
>> Regardless of whether we support non-shmem cached buffers, isn't the
>> above overly complex? Why can't we just check for OMAP_BO_CACHED? Isn't
>> that the only case where the buffer is not coherent? At the moment this
>> function sounds more like "is_shmem_cached_coherent".
> 
> You're right. I propose fixing that in an additional patch to avoid potential 
> changes to the behaviour in this one.

Sounds good.

 Tomi


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 08/10] drm: omapdrm: DMA-unmap pages for all buffer types when freeing buffers
  2017-04-20 21:33 ` [PATCH v2 08/10] drm: omapdrm: DMA-unmap pages for all buffer types when freeing buffers Laurent Pinchart
@ 2017-04-27 10:48   ` Tomi Valkeinen
  0 siblings, 0 replies; 27+ messages in thread
From: Tomi Valkeinen @ 2017-04-27 10:48 UTC (permalink / raw)
  To: Laurent Pinchart, dri-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 528 bytes --]

On 21/04/17 00:33, Laurent Pinchart wrote:
> Both coherent (uncached) and non-coherent (cached) buffers can have
> their pages mapped to the device through the DMA mapping API. Make sure
> to unmap any mapped page when freeing a buffer, regardless of its type.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/omapdrm/omap_gem.c | 17 ++++++-----------
>  1 file changed, 6 insertions(+), 11 deletions(-)

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

 Tomi


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 09/10] drm: omapdrm: Map pages for DMA in DMA_TO_DEVICE direction
  2017-04-20 21:33 ` [PATCH v2 09/10] drm: omapdrm: Map pages for DMA in DMA_TO_DEVICE direction Laurent Pinchart
@ 2017-04-27 10:48   ` Tomi Valkeinen
  0 siblings, 0 replies; 27+ messages in thread
From: Tomi Valkeinen @ 2017-04-27 10:48 UTC (permalink / raw)
  To: Laurent Pinchart, dri-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 491 bytes --]

On 21/04/17 00:33, Laurent Pinchart wrote:
> The display engine only reads from memory, there's no need to use
> bidirectional DMA mappings. Use DMA_TO_DEVICE instead.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  drivers/gpu/drm/omapdrm/omap_gem.c        | 11 +++++------
>  drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |  4 ++--
>  2 files changed, 7 insertions(+), 8 deletions(-)

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

 Tomi


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v2.1 10/10] drm: omapdrm: Take GEM object reference when exporting dmabuf
  2017-04-21  8:49     ` Laurent Pinchart
@ 2017-05-08 18:59       ` Laurent Pinchart
  0 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2017-05-08 18:59 UTC (permalink / raw)
  To: dri-devel; +Cc: Tomi Valkeinen

To ensure that neither the GEM object nor the DRM device goes away while
a GEM object exported through dma-buf is still accessible, references
must be taken to both the GEM object and the DRM device at export time.
The dma-buf release handler already releases the GEM object, but the
export handler doesn't take a corresponding reference, which results in
a refcount underflow.

Fix this by replacing the custom implementation by
drm_gem_dmabuf_export() and drm_gem_dmabuf_release() that handle
reference counting for us.

Fixes: 6ad11bc3a0b8 ("staging: drm/omap: dmabuf/prime support")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
Changes since v2:

- Use drm_gem_dmabuf_export() and drm_gem_dmabuf_release() instead of
implementing them manually. This fixes a refcount bug present in v2.
---
 drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
index b196ab4f5d5a..33382b26d0d4 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
@@ -72,16 +72,6 @@ static void omap_gem_unmap_dma_buf(struct dma_buf_attachment *attachment,
 	kfree(sg);
 }
 
-static void omap_gem_dmabuf_release(struct dma_buf *buffer)
-{
-	struct drm_gem_object *obj = buffer->priv;
-	/* release reference that was taken when dmabuf was exported
-	 * in omap_gem_prime_set()..
-	 */
-	drm_gem_object_unreference_unlocked(obj);
-}
-
-
 static int omap_gem_dmabuf_begin_cpu_access(struct dma_buf *buffer,
 		enum dma_data_direction dir)
 {
@@ -157,7 +147,7 @@ static int omap_gem_dmabuf_mmap(struct dma_buf *buffer,
 static struct dma_buf_ops omap_dmabuf_ops = {
 	.map_dma_buf = omap_gem_map_dma_buf,
 	.unmap_dma_buf = omap_gem_unmap_dma_buf,
-	.release = omap_gem_dmabuf_release,
+	.release = drm_gem_dmabuf_release,
 	.begin_cpu_access = omap_gem_dmabuf_begin_cpu_access,
 	.end_cpu_access = omap_gem_dmabuf_end_cpu_access,
 	.kmap_atomic = omap_gem_dmabuf_kmap_atomic,
@@ -177,7 +167,7 @@ struct dma_buf *omap_gem_prime_export(struct drm_device *dev,
 	exp_info.flags = flags;
 	exp_info.priv = obj;
 
-	return dma_buf_export(&exp_info);
+	return drm_gem_dmabuf_export(dev, &exp_info);
 }
 
 /* -----------------------------------------------------------------------------
-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 00/10] omapdrm: GEM objects fixes
  2017-04-20 21:33 [PATCH v2 00/10] omapdrm: GEM objects fixes Laurent Pinchart
                   ` (9 preceding siblings ...)
  2017-04-20 21:33 ` [PATCH v2 10/10] drm: omapdrm: Take GEM obj and DRM dev references when exporting dmabuf Laurent Pinchart
@ 2017-05-09  8:14 ` Tomi Valkeinen
  10 siblings, 0 replies; 27+ messages in thread
From: Tomi Valkeinen @ 2017-05-09  8:14 UTC (permalink / raw)
  To: Laurent Pinchart, dri-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 263 bytes --]

On 21/04/17 00:33, Laurent Pinchart wrote:
> Hello,
> 
> This patch series updates and extends the previously posted "[PATCH 1/7]
> omapdrm: Fix GEM objects DMA unmapping" series.

Thanks, I have applied this series (with the PATCH v2.1 10/10).

 Tomi


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2017-05-09  8:14 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-20 21:33 [PATCH v2 00/10] omapdrm: GEM objects fixes Laurent Pinchart
2017-04-20 21:33 ` [PATCH v2 01/10] drm: omapdrm: Remove remap argument to omap_gem_get_paddr() Laurent Pinchart
2017-04-24 10:09   ` Tomi Valkeinen
2017-04-20 21:33 ` [PATCH v2 02/10] drm: omapdrm: Rename occurrences of paddr to dma_addr Laurent Pinchart
2017-04-24 10:13   ` Tomi Valkeinen
2017-04-20 21:33 ` [PATCH v2 03/10] drm: omapdrm: Rename omap_gem_(get|put)_paddr() to omap_gem_(un)pin() Laurent Pinchart
2017-04-24 10:16   ` Tomi Valkeinen
2017-04-24 14:08     ` Laurent Pinchart
2017-04-20 21:33 ` [PATCH v2 04/10] drm: omapdrm: Lower indentation level in omap_gem_dma_sync_buffer() Laurent Pinchart
2017-04-24 10:22   ` Tomi Valkeinen
2017-04-20 21:33 ` [PATCH v2 05/10] drm: omapdrm: Rename the omap_gem_object addrs field to dma_addrs Laurent Pinchart
2017-04-24 10:24   ` Tomi Valkeinen
2017-04-20 21:33 ` [PATCH v2 06/10] drm: omapdrm: Rename GEM DMA sync functions Laurent Pinchart
2017-04-24 10:32   ` Tomi Valkeinen
2017-04-20 21:33 ` [PATCH v2 07/10] drm: omapdrm: Fix incorrect usage of the term 'cache coherency' Laurent Pinchart
2017-04-24 10:44   ` Tomi Valkeinen
2017-04-24 14:25     ` Laurent Pinchart
2017-04-25  9:07       ` Tomi Valkeinen
2017-04-20 21:33 ` [PATCH v2 08/10] drm: omapdrm: DMA-unmap pages for all buffer types when freeing buffers Laurent Pinchart
2017-04-27 10:48   ` Tomi Valkeinen
2017-04-20 21:33 ` [PATCH v2 09/10] drm: omapdrm: Map pages for DMA in DMA_TO_DEVICE direction Laurent Pinchart
2017-04-27 10:48   ` Tomi Valkeinen
2017-04-20 21:33 ` [PATCH v2 10/10] drm: omapdrm: Take GEM obj and DRM dev references when exporting dmabuf Laurent Pinchart
2017-04-20 23:08   ` Chris Wilson
2017-04-21  8:49     ` Laurent Pinchart
2017-05-08 18:59       ` [PATCH v2.1 10/10] drm: omapdrm: Take GEM object reference " Laurent Pinchart
2017-05-09  8:14 ` [PATCH v2 00/10] omapdrm: GEM objects fixes Tomi Valkeinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.