Commit d9c148cf authored by Tomi Valkeinen's avatar Tomi Valkeinen

drm/omap: fix dma_addr refcounting

cec4fa75 ("drm/omap: use refcount API to
track the number of users of dma_addr") changed omap_gem.c to use
refcounting API to track dma_addr uses.  However, the driver only tracks
the refcounts for non-contiguous buffers, and the patch didn't fully
take this in account.

After the patch, the driver always decreased refcount in omap_gem_unpin,
instead of decreasing the refcount only for non-contiguous buffers. This
leads to refcounting mismatch.

As for the contiguous cases the refcount is never increased, fix this
issue by returning from omap_gem_unpin if the buffer being unpinned is
contiguous.
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191114080343.30704-1-tomi.valkeinen@ti.com
Fixes: cec4fa75 ("drm/omap: use refcount API to track the number of users of dma_addr")
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
parent d6d07ca1
...@@ -843,9 +843,13 @@ int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr) ...@@ -843,9 +843,13 @@ int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr)
*/ */
static void omap_gem_unpin_locked(struct drm_gem_object *obj) static void omap_gem_unpin_locked(struct drm_gem_object *obj)
{ {
struct omap_drm_private *priv = obj->dev->dev_private;
struct omap_gem_object *omap_obj = to_omap_bo(obj); struct omap_gem_object *omap_obj = to_omap_bo(obj);
int ret; int ret;
if (omap_gem_is_contiguous(omap_obj) || !priv->has_dmm)
return;
if (refcount_dec_and_test(&omap_obj->dma_addr_cnt)) { if (refcount_dec_and_test(&omap_obj->dma_addr_cnt)) {
ret = tiler_unpin(omap_obj->block); ret = tiler_unpin(omap_obj->block);
if (ret) { if (ret) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment