From: Rob Clark <robdclark@gmail.com>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH 1/5] drm/gem: add drm_gem_create_mmap_offset_size()
Date: Sun, 7 Jul 2013 14:58:47 -0400 [thread overview]
Message-ID: <1373223531-19058-2-git-send-email-robdclark@gmail.com> (raw)
In-Reply-To: <1373223531-19058-1-git-send-email-robdclark@gmail.com>
Variant of drm_gem_create_mmap_offset() which doesn't make the
assumption that virtual size and physical size (obj->size) are the same.
This is needed in omapdrm to deal with tiled buffers. And lets us get
rid of a duplicated and slightly modified version of
drm_gem_create_mmap_offset() in omapdrm.
Signed-off-by: Rob Clark <robdclark@gmail.com>
---
drivers/gpu/drm/drm_gem.c | 28 ++++++++++++++++++++++++----
include/drm/drmP.h | 1 +
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index cf919e3..443eeff 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -320,18 +320,21 @@ drm_gem_free_mmap_offset(struct drm_gem_object *obj)
EXPORT_SYMBOL(drm_gem_free_mmap_offset);
/**
- * drm_gem_create_mmap_offset - create a fake mmap offset for an object
+ * drm_gem_create_mmap_offset_size - create a fake mmap offset for an object
* @obj: obj in question
+ * @size: the virtual size
*
* GEM memory mapping works by handing back to userspace a fake mmap offset
* it can use in a subsequent mmap(2) call. The DRM core code then looks
* up the object based on the offset and sets up the various memory mapping
* structures.
*
- * This routine allocates and attaches a fake offset for @obj.
+ * This routine allocates and attaches a fake offset for @obj, in cases where
+ * the virtual size differs from the physical size (ie. obj->size). Otherwise
+ * just use drm_gem_create_mmap_offset().
*/
int
-drm_gem_create_mmap_offset(struct drm_gem_object *obj)
+drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size)
{
struct drm_device *dev = obj->dev;
struct drm_gem_mm *mm = dev->mm_private;
@@ -347,7 +350,7 @@ drm_gem_create_mmap_offset(struct drm_gem_object *obj)
map = list->map;
map->type = _DRM_GEM;
- map->size = obj->size;
+ map->size = size;
map->handle = obj;
/* Get a DRM GEM mmap offset allocated... */
@@ -384,6 +387,23 @@ out_free_list:
return ret;
}
+EXPORT_SYMBOL(drm_gem_create_mmap_offset_size);
+
+/**
+ * drm_gem_create_mmap_offset - create a fake mmap offset for an object
+ * @obj: obj in question
+ *
+ * GEM memory mapping works by handing back to userspace a fake mmap offset
+ * it can use in a subsequent mmap(2) call. The DRM core code then looks
+ * up the object based on the offset and sets up the various memory mapping
+ * structures.
+ *
+ * This routine allocates and attaches a fake offset for @obj.
+ */
+int drm_gem_create_mmap_offset(struct drm_gem_object *obj)
+{
+ return drm_gem_create_mmap_offset_size(obj, obj->size);
+}
EXPORT_SYMBOL(drm_gem_create_mmap_offset);
/** Returns a reference to the object named by the handle. */
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 63d17ee..3cb1672 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1728,6 +1728,7 @@ drm_gem_object_handle_unreference_unlocked(struct drm_gem_object *obj)
void drm_gem_free_mmap_offset(struct drm_gem_object *obj);
int drm_gem_create_mmap_offset(struct drm_gem_object *obj);
+int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size);
struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev,
struct drm_file *filp,
--
1.8.1.4
next prev parent reply other threads:[~2013-07-07 18:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-07 18:58 [PATCH 0/5] kill omap_gem_helpers Rob Clark
2013-07-07 18:58 ` Rob Clark [this message]
2013-07-07 18:58 ` [PATCH 2/5] drm/gem: add shmem get/put page helpers Rob Clark
2013-07-08 8:45 ` Patrik Jakobsson
2013-07-08 18:56 ` Rob Clark
2013-07-08 20:18 ` Daniel Vetter
2013-07-08 23:07 ` Rob Clark
2013-07-09 9:03 ` Patrik Jakobsson
2013-07-07 18:58 ` [PATCH 3/5] drm/gma500: use gem " Rob Clark
2013-07-07 18:58 ` [PATCH 4/5] drm/udl: " Rob Clark
2013-07-07 18:58 ` [PATCH 5/5] drm/omap: kill omap_gem_helpers.c Rob Clark
2013-07-07 20:28 ` [PATCH 0/5] kill omap_gem_helpers David Herrmann
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=1373223531-19058-2-git-send-email-robdclark@gmail.com \
--to=robdclark@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
/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).