]> Git Repo - linux.git/commitdiff
drm/omap: fix dma_addr refcounting
authorTomi Valkeinen <[email protected]>
Thu, 14 Nov 2019 08:03:43 +0000 (10:03 +0200)
committerTomi Valkeinen <[email protected]>
Wed, 4 Dec 2019 17:11:28 +0000 (19:11 +0200)
cec4fa7511ef7a73eb635834e9d85b25a5b47a98 ("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: Tomi Valkeinen <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Fixes: cec4fa7511ef ("drm/omap: use refcount API to track the number of users of dma_addr")
Reviewed-by: Laurent Pinchart <[email protected]>
drivers/gpu/drm/omapdrm/omap_gem.c

index e518d93ca6df27fa0ec8028ccf5b7a28f6632443..d08ae95ecc0ac2aed1d90ebc87c904729b2eed36 100644 (file)
@@ -843,9 +843,13 @@ fail:
  */
 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);
        int ret;
 
+       if (omap_gem_is_contiguous(omap_obj) || !priv->has_dmm)
+               return;
+
        if (refcount_dec_and_test(&omap_obj->dma_addr_cnt)) {
                ret = tiler_unpin(omap_obj->block);
                if (ret) {
This page took 0.06117 seconds and 4 git commands to generate.