]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/msm: Add hint to DRM_IOCTL_MSM_GEM_INFO to return an object IOVA
authorJordan Crouse <jcrouse@codeaurora.org>
Mon, 8 May 2017 20:35:01 +0000 (14:35 -0600)
committerRob Clark <robdclark@gmail.com>
Fri, 16 Jun 2017 15:15:47 +0000 (11:15 -0400)
Modify the 'pad' member of struct drm_msm_gem_info to 'flags'. If the
user sets 'flags' to non-zero it means that they want a IOVA for the
GEM object instead of a mmap() offset. Return the iova in the 'offset'
member.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
[robclark: s/hint/flags in commit msg]
Signed-off-by: Rob Clark <robdclark@gmail.com>
drivers/gpu/drm/msm/msm_drv.c
include/uapi/drm/msm_drm.h

index 18d02ccb6c9bc57e9025fff3591c9f9008faaf83..beb4f6b3ac70e20f0bceadc692b2640c9b446aa6 100644 (file)
@@ -699,6 +699,17 @@ static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data,
        return ret;
 }
 
+static int msm_ioctl_gem_info_iova(struct drm_device *dev,
+               struct drm_gem_object *obj, uint64_t *iova)
+{
+       struct msm_drm_private *priv = dev->dev_private;
+
+       if (!priv->gpu)
+               return -EINVAL;
+
+       return msm_gem_get_iova(obj, priv->gpu->id, iova);
+}
+
 static int msm_ioctl_gem_info(struct drm_device *dev, void *data,
                struct drm_file *file)
 {
@@ -706,14 +717,22 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data,
        struct drm_gem_object *obj;
        int ret = 0;
 
-       if (args->pad)
+       if (args->flags & ~MSM_INFO_FLAGS)
                return -EINVAL;
 
        obj = drm_gem_object_lookup(file, args->handle);
        if (!obj)
                return -ENOENT;
 
-       args->offset = msm_gem_mmap_offset(obj);
+       if (args->flags & MSM_INFO_IOVA) {
+               uint64_t iova;
+
+               ret = msm_ioctl_gem_info_iova(dev, obj, &iova);
+               if (!ret)
+                       args->offset = iova;
+       } else {
+               args->offset = msm_gem_mmap_offset(obj);
+       }
 
        drm_gem_object_unreference_unlocked(obj);
 
index a9985fe6efcd8b893e05e121049e9b8ee975d3b8..26c54f6d595d4070c7708ef22daf7533468404a2 100644 (file)
@@ -104,10 +104,14 @@ struct drm_msm_gem_new {
        __u32 handle;         /* out */
 };
 
+#define MSM_INFO_IOVA  0x01
+
+#define MSM_INFO_FLAGS (MSM_INFO_IOVA)
+
 struct drm_msm_gem_info {
        __u32 handle;         /* in */
-       __u32 pad;
-       __u64 offset;         /* out, offset to pass to mmap() */
+       __u32 flags;          /* in - combination of MSM_INFO_* flags */
+       __u64 offset;         /* out, mmap() offset or iova */
 };
 
 #define MSM_PREP_READ        0x01