diff mbox

[v2,5/5] drm: Use names of ioctls in debug traces

Message ID 1368105640-26002-1-git-send-email-christopher.e.cummins@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Cummins May 9, 2013, 1:20 p.m. UTC
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: Chris Cummins <christopher.e.cummins@intel.com>
---
 drivers/gpu/drm/drm_drv.c | 20 +++++++++++++-------
 include/drm/drmP.h        |  3 ++-
 2 files changed, 15 insertions(+), 8 deletions(-)

Comments

Alex Deucher May 9, 2013, 1:29 p.m. UTC | #1
On Thu, May 9, 2013 at 9:20 AM, Chris Cummins
<christopher.e.cummins@intel.com> wrote:
> 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: Chris Cummins <christopher.e.cummins@intel.com>

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/drm_drv.c | 20 +++++++++++++-------
>  include/drm/drmP.h        |  3 ++-
>  2 files changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 0ba4dcb..dfa228b 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -57,7 +57,7 @@ static int drm_version(struct drm_device *dev, void *data,
>                        struct drm_file *file_priv);
>
>  #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 */
>  static const struct drm_ioctl_desc drm_ioctls[] = {
> @@ -375,7 +375,7 @@ long drm_ioctl(struct file *filp,
>  {
>         struct drm_file *file_priv = filp->private_data;
>         struct drm_device *dev;
> -       const struct drm_ioctl_desc *ioctl;
> +       const struct drm_ioctl_desc *ioctl = NULL;
>         drm_ioctl_t *func;
>         unsigned int nr = DRM_IOCTL_NR(cmd);
>         int retcode = -EINVAL;
> @@ -392,11 +392,6 @@ long drm_ioctl(struct file *filp,
>         atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
>         ++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) &&
>             ((nr < DRM_COMMAND_BASE) || (nr >= DRM_COMMAND_END)))
>                 goto err_i1;
> @@ -416,6 +411,11 @@ long drm_ioctl(struct file *filp,
>         } else
>                 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 */
>         func = ioctl->func;
>         /* is there a local override? */
> @@ -470,6 +470,12 @@ long drm_ioctl(struct file *filp,
>         }
>
>        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)
>                 kfree(kdata);
>         atomic_dec(&dev->ioctl_count);
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 2d94d74..379787c 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -316,6 +316,7 @@ struct drm_ioctl_desc {
>         int flags;
>         drm_ioctl_t *func;
>         unsigned int cmd_drv;
> +       const char *name;
>  };
>
>  /**
> @@ -324,7 +325,7 @@ struct drm_ioctl_desc {
>   */
>
>  #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 list_head head;
> --
> 1.8.1.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 0ba4dcb..dfa228b 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -57,7 +57,7 @@  static int drm_version(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
 
 #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 */
 static const struct drm_ioctl_desc drm_ioctls[] = {
@@ -375,7 +375,7 @@  long drm_ioctl(struct file *filp,
 {
 	struct drm_file *file_priv = filp->private_data;
 	struct drm_device *dev;
-	const struct drm_ioctl_desc *ioctl;
+	const struct drm_ioctl_desc *ioctl = NULL;
 	drm_ioctl_t *func;
 	unsigned int nr = DRM_IOCTL_NR(cmd);
 	int retcode = -EINVAL;
@@ -392,11 +392,6 @@  long drm_ioctl(struct file *filp,
 	atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
 	++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) &&
 	    ((nr < DRM_COMMAND_BASE) || (nr >= DRM_COMMAND_END)))
 		goto err_i1;
@@ -416,6 +411,11 @@  long drm_ioctl(struct file *filp,
 	} else
 		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 */
 	func = ioctl->func;
 	/* is there a local override? */
@@ -470,6 +470,12 @@  long drm_ioctl(struct file *filp,
 	}
 
       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)
 		kfree(kdata);
 	atomic_dec(&dev->ioctl_count);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 2d94d74..379787c 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -316,6 +316,7 @@  struct drm_ioctl_desc {
 	int flags;
 	drm_ioctl_t *func;
 	unsigned int cmd_drv;
+	const char *name;
 };
 
 /**
@@ -324,7 +325,7 @@  struct drm_ioctl_desc {
  */
 
 #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 list_head head;