Commit f05c83e7 authored by Rob Clark's avatar Rob Clark

drm/msm: add uapi to get/set debug name

Add UAPI to get/set GEM objects' debug name.
Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
parent 789d2e5a
......@@ -23,6 +23,7 @@
#include "msm_drv.h"
#include "msm_debugfs.h"
#include "msm_fence.h"
#include "msm_gem.h"
#include "msm_gpu.h"
#include "msm_kms.h"
......@@ -880,7 +881,8 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data,
{
struct drm_msm_gem_info *args = data;
struct drm_gem_object *obj;
int ret = 0;
struct msm_gem_object *msm_obj;
int i, ret = 0;
if (args->pad)
return -EINVAL;
......@@ -892,6 +894,9 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data,
if (args->len)
return -EINVAL;
break;
case MSM_INFO_SET_NAME:
case MSM_INFO_GET_NAME:
break;
default:
return -EINVAL;
}
......@@ -900,6 +905,8 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data,
if (!obj)
return -ENOENT;
msm_obj = to_msm_bo(obj);
switch (args->info) {
case MSM_INFO_GET_OFFSET:
args->value = msm_gem_mmap_offset(obj);
......@@ -907,6 +914,33 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data,
case MSM_INFO_GET_IOVA:
ret = msm_ioctl_gem_info_iova(dev, obj, &args->value);
break;
case MSM_INFO_SET_NAME:
/* length check should leave room for terminating null: */
if (args->len >= sizeof(msm_obj->name)) {
ret = -EINVAL;
break;
}
ret = copy_from_user(msm_obj->name,
u64_to_user_ptr(args->value), args->len);
msm_obj->name[args->len] = '\0';
for (i = 0; i < args->len; i++) {
if (!isprint(msm_obj->name[i])) {
msm_obj->name[i] = '\0';
break;
}
}
break;
case MSM_INFO_GET_NAME:
if (args->value && (args->len < strlen(msm_obj->name))) {
ret = -EINVAL;
break;
}
args->len = strlen(msm_obj->name);
if (args->value) {
ret = copy_to_user(u64_to_user_ptr(args->value),
msm_obj->name, args->len);
}
break;
}
drm_gem_object_put_unlocked(obj);
......
......@@ -114,6 +114,8 @@ struct drm_msm_gem_new {
*/
#define MSM_INFO_GET_OFFSET 0x00 /* get mmap() offset, returned by value */
#define MSM_INFO_GET_IOVA 0x01 /* get iova, returned by value */
#define MSM_INFO_SET_NAME 0x02 /* set the debug name (by pointer) */
#define MSM_INFO_GET_NAME 0x03 /* get debug name, returned by pointer */
struct drm_msm_gem_info {
__u32 handle; /* in */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment