From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: DRI Development <dri-devel@lists.freedesktop.org>
Cc: Sam Ravnborg <sam@ravnborg.org>,
Daniel Vetter <daniel.vetter@ffwll.ch>,
Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
Gerd Hoffmann <kraxel@redhat.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
Daniel Vetter <daniel.vetter@intel.com>,
Alex Deucher <alexander.deucher@amd.com>,
Dave Airlie <airlied@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>, Sean Paul <sean@poorly.run>
Subject: [PATCH 5/9] drm/udl: Don't call get/put_pages on imported dma-buf
Date: Mon, 11 May 2020 11:35:50 +0200 [thread overview]
Message-ID: <20200511093554.211493-6-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <20200511093554.211493-1-daniel.vetter@ffwll.ch>
There's no direct harm, because for the shmem helpers these are noops
on imported buffers. The trouble is in the locks these take - I want
to change dma_buf_vmap locking, and so need to make sure that we only
ever take certain locks on one side of the dma-buf interface: Either
for exporters, or for importers.
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Sam Ravnborg <sam@ravnborg.org>
---
drivers/gpu/drm/udl/udl_gem.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
index b6e26f98aa0a..c68d3e265329 100644
--- a/drivers/gpu/drm/udl/udl_gem.c
+++ b/drivers/gpu/drm/udl/udl_gem.c
@@ -46,29 +46,31 @@ static void *udl_gem_object_vmap(struct drm_gem_object *obj)
if (shmem->vmap_use_count++ > 0)
goto out;
- ret = drm_gem_shmem_get_pages(shmem);
- if (ret)
- goto err_zero_use;
-
- if (obj->import_attach)
+ if (obj->import_attach) {
shmem->vaddr = dma_buf_vmap(obj->import_attach->dmabuf);
- else
+ } else {
+ ret = drm_gem_shmem_get_pages(shmem);
+ if (ret)
+ goto err;
+
shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT,
VM_MAP, PAGE_KERNEL);
+ if (!shmem->vaddr)
+ drm_gem_shmem_put_pages(shmem);
+ }
+
if (!shmem->vaddr) {
DRM_DEBUG_KMS("Failed to vmap pages\n");
ret = -ENOMEM;
- goto err_put_pages;
+ goto err;
}
out:
mutex_unlock(&shmem->vmap_lock);
return shmem->vaddr;
-err_put_pages:
- drm_gem_shmem_put_pages(shmem);
-err_zero_use:
+err:
shmem->vmap_use_count = 0;
mutex_unlock(&shmem->vmap_lock);
return ERR_PTR(ret);
--
2.26.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-05-11 9:36 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-11 9:35 [PATCH 0/9] shmem helper untangling Daniel Vetter
2020-05-11 9:35 ` [PATCH 1/9] drm/msm: Don't call dma_buf_vunmap without _vmap Daniel Vetter
2020-05-11 15:24 ` Rob Clark
2020-05-11 15:28 ` Daniel Vetter
2020-05-11 20:36 ` Rob Clark
2020-05-14 20:11 ` [PATCH] " Daniel Vetter
2020-05-28 8:29 ` Daniel Vetter
2020-05-31 16:02 ` Rob Clark
2020-06-03 12:46 ` Daniel Vetter
2020-05-11 9:35 ` [PATCH 2/9] drm/gem: WARN if drm_gem_get_pages is called on a private obj Daniel Vetter
2020-05-14 7:45 ` Thomas Zimmermann
2020-05-11 9:35 ` [PATCH 3/9] drm/doc: Some polish for shmem helpers Daniel Vetter
2020-05-11 11:12 ` Thomas Zimmermann
2020-05-14 20:05 ` Daniel Vetter
2020-05-15 6:26 ` Thomas Zimmermann
2020-05-11 9:35 ` [PATCH 4/9] drm/virtio: Call the right " Daniel Vetter
2020-05-14 7:46 ` Thomas Zimmermann
2020-05-11 9:35 ` Daniel Vetter [this message]
2020-05-11 11:23 ` [PATCH 5/9] drm/udl: Don't call get/put_pages on imported dma-buf Thomas Zimmermann
2020-05-11 11:37 ` Daniel Vetter
2020-05-11 12:04 ` Thomas Zimmermann
2020-05-14 7:25 ` Thomas Zimmermann
2020-05-14 12:47 ` Daniel Vetter
2020-06-03 12:57 ` Daniel Vetter
2020-05-11 9:35 ` [PATCH 6/9] drm/shmem-helpers: Don't call get/put_pages on imported dma-buf in vmap Daniel Vetter
2020-05-14 7:16 ` Thomas Zimmermann
2020-05-14 12:49 ` Daniel Vetter
2020-05-14 20:22 ` [PATCH] " Daniel Vetter
2020-05-11 9:35 ` [PATCH 7/9] drm/shmem-helpers: Redirect mmap for imported dma-buf Daniel Vetter
2020-05-14 7:23 ` Thomas Zimmermann
2020-05-14 12:47 ` Daniel Vetter
2020-05-27 18:32 ` Thomas Zimmermann
2020-05-27 19:34 ` Daniel Vetter
2020-05-28 12:53 ` Thomas Zimmermann
2020-05-11 9:35 ` [PATCH 8/9] drm/shmem-helpers: Ensure get_pages is not called on " Daniel Vetter
2020-05-14 7:30 ` Thomas Zimmermann
2020-06-03 13:12 ` Daniel Vetter
2020-06-08 14:40 ` Thomas Zimmermann
2020-06-08 15:04 ` Daniel Vetter
2020-05-11 9:35 ` [PATCH 9/9] drm/shmem-helpers: Simplify dma-buf importing Daniel Vetter
2020-05-14 7:44 ` Thomas Zimmermann
2020-05-14 12:55 ` Daniel Vetter
2020-05-14 15:26 ` Thomas Zimmermann
2020-05-20 18:02 ` [PATCH] " Daniel Vetter
2020-05-29 13:34 ` Boris Brezillon
2020-05-29 13:35 ` Boris Brezillon
2020-05-29 13:49 ` Boris Brezillon
2020-05-29 14:05 ` Daniel Vetter
2020-05-29 14:36 ` Boris Brezillon
2020-06-15 8:23 ` [PATCH 9/9] " Thomas Zimmermann
2020-05-29 13:52 ` [PATCH 0/9] shmem helper untangling Boris Brezillon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200511093554.211493-6-daniel.vetter@ffwll.ch \
--to=daniel.vetter@ffwll.ch \
--cc=airlied@redhat.com \
--cc=alexander.deucher@amd.com \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=kraxel@redhat.com \
--cc=sam@ravnborg.org \
--cc=sean@poorly.run \
--cc=tglx@linutronix.de \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).