OSDN Git Service

drm: add debug logs for drm_mode_atomic_ioctl errors
authorSimon Ser <contact@emersion.fr>
Wed, 11 Nov 2020 09:07:39 +0000 (09:07 +0000)
committerSimon Ser <contact@emersion.fr>
Sat, 14 Nov 2020 13:40:44 +0000 (14:40 +0100)
Be nice to user-space and log what happened when returning EINVAL in
drm_mode_atomic_ioctl.

v2:

- Migrate to drm_dbg_atomic (Sam)
- Add debug log for arg->reserved (Ville)
- Drop redundant "atomic" word in log messages (Ville)

Signed-off-by: Simon Ser <contact@emersion.fr>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/AVFi5ZzKwRVLtY8AQyxvqgIbcUfVgNebOtGVwSNMKvs@cp4-web-038.plabs.ch
drivers/gpu/drm/drm_atomic_uapi.c

index efab3d5..9df7f2a 100644 (file)
@@ -1330,22 +1330,35 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,
         * though this may be a bit overkill, since legacy userspace
         * wouldn't know how to call this ioctl)
         */
-       if (!file_priv->atomic)
+       if (!file_priv->atomic) {
+               drm_dbg_atomic(dev,
+                              "commit failed: atomic cap not enabled\n");
                return -EINVAL;
+       }
 
-       if (arg->flags & ~DRM_MODE_ATOMIC_FLAGS)
+       if (arg->flags & ~DRM_MODE_ATOMIC_FLAGS) {
+               drm_dbg_atomic(dev, "commit failed: invalid flag\n");
                return -EINVAL;
+       }
 
-       if (arg->reserved)
+       if (arg->reserved) {
+               drm_dbg_atomic(dev, "commit failed: reserved field set\n");
                return -EINVAL;
+       }
 
-       if (arg->flags & DRM_MODE_PAGE_FLIP_ASYNC)
+       if (arg->flags & DRM_MODE_PAGE_FLIP_ASYNC) {
+               drm_dbg_atomic(dev,
+                              "commit failed: invalid flag DRM_MODE_PAGE_FLIP_ASYNC\n");
                return -EINVAL;
+       }
 
        /* can't test and expect an event at the same time. */
        if ((arg->flags & DRM_MODE_ATOMIC_TEST_ONLY) &&
-                       (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
+                       (arg->flags & DRM_MODE_PAGE_FLIP_EVENT)) {
+               drm_dbg_atomic(dev,
+                              "commit failed: page-flip event requested with test-only commit\n");
                return -EINVAL;
+       }
 
        state = drm_atomic_state_alloc(dev);
        if (!state)