From: Gerd Hoffmann <kraxel@redhat.com>
To: dri-devel@lists.freedesktop.org
Cc: Gerd Hoffmann <kraxel@redhat.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <maxime.ripard@bootlin.com>,
Sean Paul <sean@poorly.run>, David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH 1/3] drm: add mmap() to drm_gem_object_funcs
Date: Thu, 20 Jun 2019 08:15:45 +0200 [thread overview]
Message-ID: <20190620061547.8664-2-kraxel@redhat.com> (raw)
In-Reply-To: <20190620061547.8664-1-kraxel@redhat.com>
drm_gem_object_funcs->vm_ops alone can't handle
everything mmap() needs. Add a new callback for it.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/drm/drm_gem.h | 9 +++++++++
drivers/gpu/drm/drm_gem.c | 4 ++++
2 files changed, 13 insertions(+)
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
index a9121fe66ea2..2e680a065470 100644
--- a/include/drm/drm_gem.h
+++ b/include/drm/drm_gem.h
@@ -144,6 +144,15 @@ struct drm_gem_object_funcs {
*/
void (*vunmap)(struct drm_gem_object *obj, void *vaddr);
+ /**
+ * @mmap:
+ *
+ * Called by drm_gem_mmap() for additional checks/setup.
+ *
+ * This callback is optional.
+ */
+ int (*mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma);
+
/**
* @vm_ops:
*
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index a8c4468f03d9..1deae1b70f39 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -1192,6 +1192,10 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
ret = drm_gem_mmap_obj(obj, drm_vma_node_size(node) << PAGE_SHIFT,
vma);
+ if (ret == 0)
+ if (obj->funcs->mmap)
+ ret = obj->funcs->mmap(obj, vma);
+
drm_gem_object_put_unlocked(obj);
return ret;
--
2.18.1
next parent reply other threads:[~2019-06-20 6:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190620061547.8664-1-kraxel@redhat.com>
2019-06-20 6:15 ` Gerd Hoffmann [this message]
2019-06-20 6:15 ` [PATCH 2/3] drm: switch shmem helper to drm_gem_object_funcs->mmap Gerd Hoffmann
2019-06-20 6:15 ` [PATCH 3/3] drm: drop DEFINE_DRM_GEM_SHMEM_FOPS Gerd Hoffmann
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=20190620061547.8664-2-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=maxime.ripard@bootlin.com \
--cc=sean@poorly.run \
/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
all inboxes | Powered by JetHome®