Commit b9434d0f authored by Chris Cummins's avatar Chris Cummins Committed by Dave Airlie

drm: Use names of ioctls in debug traces

The intention here is to make the output of dmesg with full verbosity a
bit easier for a human to parse. This commit transforms:

[drm:drm_ioctl], pid=699, cmd=0x6458, nr=0x58, dev 0xe200, auth=1
[drm:drm_ioctl], pid=699, cmd=0xc010645b, nr=0x5b, dev 0xe200, auth=1
[drm:drm_ioctl], pid=699, cmd=0xc0106461, nr=0x61, dev 0xe200, auth=1
[drm:drm_ioctl], pid=699, cmd=0xc01c64ae, nr=0xae, dev 0xe200, auth=1
[drm:drm_mode_addfb], [FB:32]
[drm:drm_ioctl], pid=699, cmd=0xc0106464, nr=0x64, dev 0xe200, auth=1
[drm:drm_vm_open_locked], 0x7fd9302fe000,0x00a00000
[drm:drm_ioctl], pid=699, cmd=0x400c645f, nr=0x5f, dev 0xe200, auth=1
[drm:drm_ioctl], pid=699, cmd=0xc00464af, nr=0xaf, dev 0xe200, auth=1
[drm:intel_crtc_set_config], [CRTC:3] [NOFB]

into:

[drm:drm_ioctl], pid=699, dev=0xe200, auth=1, I915_GEM_THROTTLE
[drm:drm_ioctl], pid=699, dev=0xe200, auth=1, I915_GEM_CREATE
[drm:drm_ioctl], pid=699, dev=0xe200, auth=1, I915_GEM_SET_TILING
[drm:drm_ioctl], pid=699, dev=0xe200, auth=1, IOCTL_MODE_ADDFB
[drm:drm_mode_addfb], [FB:32]
[drm:drm_ioctl], pid=699, dev=0xe200, auth=1, I915_GEM_MMAP_GTT
[drm:drm_vm_open_locked], 0x7fd9302fe000,0x00a00000
[drm:drm_ioctl], pid=699, dev=0xe200, auth=1, I915_GEM_SET_DOMAIN
[drm:drm_ioctl], pid=699, dev=0xe200, auth=1, DRM_IOCTL_MODE_RMFB
[drm:intel_crtc_set_config], [CRTC:3] [NOFB]

v2: drm_ioctls is now a constant (Ville Syrjälä)
Signed-off-by: default avatarChris Cummins <christopher.e.cummins@intel.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 7b97936f
...@@ -57,7 +57,7 @@ static int drm_version(struct drm_device *dev, void *data, ...@@ -57,7 +57,7 @@ static int drm_version(struct drm_device *dev, void *data,
struct drm_file *file_priv); struct drm_file *file_priv);
#define DRM_IOCTL_DEF(ioctl, _func, _flags) \ #define DRM_IOCTL_DEF(ioctl, _func, _flags) \
[DRM_IOCTL_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, .cmd_drv = 0} [DRM_IOCTL_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, .cmd_drv = 0, .name = #ioctl}
/** Ioctl table */ /** Ioctl table */
static const struct drm_ioctl_desc drm_ioctls[] = { static const struct drm_ioctl_desc drm_ioctls[] = {
...@@ -375,7 +375,7 @@ long drm_ioctl(struct file *filp, ...@@ -375,7 +375,7 @@ long drm_ioctl(struct file *filp,
{ {
struct drm_file *file_priv = filp->private_data; struct drm_file *file_priv = filp->private_data;
struct drm_device *dev; struct drm_device *dev;
const struct drm_ioctl_desc *ioctl; const struct drm_ioctl_desc *ioctl = NULL;
drm_ioctl_t *func; drm_ioctl_t *func;
unsigned int nr = DRM_IOCTL_NR(cmd); unsigned int nr = DRM_IOCTL_NR(cmd);
int retcode = -EINVAL; int retcode = -EINVAL;
...@@ -392,11 +392,6 @@ long drm_ioctl(struct file *filp, ...@@ -392,11 +392,6 @@ long drm_ioctl(struct file *filp,
atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]); atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
++file_priv->ioctl_count; ++file_priv->ioctl_count;
DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
task_pid_nr(current), cmd, nr,
(long)old_encode_dev(file_priv->minor->device),
file_priv->authenticated);
if ((nr >= DRM_CORE_IOCTL_COUNT) && if ((nr >= DRM_CORE_IOCTL_COUNT) &&
((nr < DRM_COMMAND_BASE) || (nr >= DRM_COMMAND_END))) ((nr < DRM_COMMAND_BASE) || (nr >= DRM_COMMAND_END)))
goto err_i1; goto err_i1;
...@@ -417,6 +412,11 @@ long drm_ioctl(struct file *filp, ...@@ -417,6 +412,11 @@ long drm_ioctl(struct file *filp,
} else } else
goto err_i1; goto err_i1;
DRM_DEBUG("pid=%d, dev=0x%lx, auth=%d, %s\n",
task_pid_nr(current),
(long)old_encode_dev(file_priv->minor->device),
file_priv->authenticated, ioctl->name);
/* Do not trust userspace, use our own definition */ /* Do not trust userspace, use our own definition */
func = ioctl->func; func = ioctl->func;
/* is there a local override? */ /* is there a local override? */
...@@ -471,6 +471,12 @@ long drm_ioctl(struct file *filp, ...@@ -471,6 +471,12 @@ long drm_ioctl(struct file *filp,
} }
err_i1: err_i1:
if (!ioctl)
DRM_DEBUG("invalid iotcl: pid=%d, dev=0x%lx, auth=%d, cmd=0x%02x, nr=0x%02x\n",
task_pid_nr(current),
(long)old_encode_dev(file_priv->minor->device),
file_priv->authenticated, cmd, nr);
if (kdata != stack_kdata) if (kdata != stack_kdata)
kfree(kdata); kfree(kdata);
atomic_dec(&dev->ioctl_count); atomic_dec(&dev->ioctl_count);
......
...@@ -316,6 +316,7 @@ struct drm_ioctl_desc { ...@@ -316,6 +316,7 @@ struct drm_ioctl_desc {
int flags; int flags;
drm_ioctl_t *func; drm_ioctl_t *func;
unsigned int cmd_drv; unsigned int cmd_drv;
const char *name;
}; };
/** /**
...@@ -324,7 +325,7 @@ struct drm_ioctl_desc { ...@@ -324,7 +325,7 @@ struct drm_ioctl_desc {
*/ */
#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \ #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \
[DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl} [DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl, .name = #ioctl}
struct drm_magic_entry { struct drm_magic_entry {
struct list_head head; struct list_head head;
......
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