All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: DRI Development <dri-devel@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Subject: [PATCH] drm: Enforce unlocked ioctl operation for kms driver ioctls
Date: Mon, 28 Sep 2015 21:42:40 +0200	[thread overview]
Message-ID: <1443469360-17902-1-git-send-email-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <1441713391-24732-9-git-send-email-daniel.vetter@ffwll.ch>

With the prep patches for i915 all kms drivers either have
DRM_UNLOCKED on all their ioctls. Or the ioctl always directly returns
with an invariant return value when in modeset mode. But that's only
the case for i915 and radeon. The drm core ioctls are unfortunately
too much a mess still to dare this.

Follow-up patches will remove DRM_UNLOCKED from all kms drivers to
prove that this is indeed the case.

Also update the documentation.

v2: Really only do this for driver ioctls, spotted by David Herrmann.
And drop spurious whitespace change.

Cc: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 Documentation/DocBook/drm.tmpl |  4 +++-
 drivers/gpu/drm/drm_ioctl.c    | 10 ++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 8c654866e1a2..5395cde6905e 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -3747,7 +3747,9 @@ int num_ioctls;</synopsis>
 	    </para></listitem>
             <listitem><para>
 	      DRM_UNLOCKED - The ioctl handler will be called without locking
-	      the DRM global mutex
+	      the DRM global mutex. This is the enforced default for kms drivers
+	      (i.e. using the DRIVER_MODESET flag) and hence shouldn't be used
+	      any more for new drivers.
 	    </para></listitem>
 	  </itemizedlist>
 	</para>
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 530c501422fd..8ce2a0c59116 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -691,13 +691,16 @@ long drm_ioctl(struct file *filp,
 	char stack_kdata[128];
 	char *kdata = NULL;
 	unsigned int usize, asize, drv_size;
+	bool is_driver_ioctl;
 
 	dev = file_priv->minor->dev;
 
 	if (drm_device_is_unplugged(dev))
 		return -ENODEV;
 
-	if (nr >= DRM_COMMAND_BASE && nr < DRM_COMMAND_END) {
+	is_driver_ioctl = nr >= DRM_COMMAND_BASE && nr < DRM_COMMAND_END;
+
+	if (is_driver_ioctl) {
 		/* driver ioctl */
 		if (nr - DRM_COMMAND_BASE >= dev->driver->num_ioctls)
 			goto err_i1;
@@ -756,7 +759,10 @@ long drm_ioctl(struct file *filp,
 		memset(kdata, 0, usize);
 	}
 
-	if (ioctl->flags & DRM_UNLOCKED)
+	/* Enforce sane locking for kms driver ioctls. Core ioctls are
+	 * too messy still. */
+	if ((drm_core_check_feature(dev, DRIVER_MODESET) && is_driver_ioctl) ||
+	    (ioctl->flags & DRM_UNLOCKED))
 		retcode = func(dev, kdata, file_priv);
 	else {
 		mutex_lock(&drm_global_mutex);
-- 
2.5.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2015-09-28 19:39 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-08 11:56 [PATCH 00/11] Mixed bag of ioctl and agp cleanups Daniel Vetter
2015-09-08 11:56 ` [PATCH 01/11] drm: Remove __OS_HAS_AGP Daniel Vetter
2015-09-09 12:53   ` Ville Syrjälä
2015-09-09 14:45   ` [PATCH] " Daniel Vetter
2015-09-28 15:05     ` David Herrmann
2015-09-08 11:56 ` [PATCH 02/11] drm/i915: Kill cross-module option depencies Daniel Vetter
2015-09-08 11:56 ` [PATCH 03/11] drm/i915: Mark debug mod options as _unsafe Daniel Vetter
2015-09-22  9:34   ` Jani Nikula
2015-09-22  9:54     ` Daniel Vetter
2015-09-08 11:56 ` [PATCH 04/11] drm/i915: Remove setparam ioctl Daniel Vetter
2015-09-09 13:02   ` Ville Syrjälä
2015-09-09 14:46   ` [PATCH] drm/i915: Mark getparam ioctl as DRM_UNLOCKED Daniel Vetter
2015-09-30  8:46   ` [PATCH] drm/i915: Remove setparam ioctl Daniel Vetter
2015-09-30  8:50     ` Chris Wilson
2015-09-30 13:40     ` Ville Syrjälä
2015-09-08 11:56 ` [PATCH 05/11] drm/i915: Mark getparam ioctl as DRM_UNLOCKED Daniel Vetter
2015-10-09 10:00   ` Chris Wilson
2015-09-08 11:56 ` [PATCH 06/11] drm: Define a drm_invalid_op ioctl implementation Daniel Vetter
2015-09-09 12:28   ` David Herrmann
2015-09-08 11:56 ` [PATCH 07/11] drm/drm_ioctl.c: kerneldoc Daniel Vetter
2015-09-28 15:07   ` David Herrmann
2015-09-08 11:56 ` [PATCH 08/11] drm: Enforce unlocked ioctl operation for kms driver ioctls Daniel Vetter
2015-09-08 18:45   ` Gustavo Padovan
2015-09-28 15:21   ` David Herrmann
2015-09-28 19:42   ` Daniel Vetter [this message]
2015-09-08 11:56 ` [PATCH 09/11] drm/vmwgfx: Stop checking for DRM_UNLOCKED Daniel Vetter
2015-09-28 15:22   ` David Herrmann
2015-09-08 11:56 ` [PATCH 10/11] drm/<drivers>: Drop DRM_UNLOCKED from modeset drivers Daniel Vetter
2015-09-08 18:46   ` [Intel-gfx] " Gustavo Padovan
2015-09-28 15:24   ` David Herrmann
2015-09-08 11:56 ` [PATCH 11/11] drm: Remove dummy agp ioctl wrappers Daniel Vetter
2015-09-28 15:25   ` David Herrmann
2015-09-08 12:58 ` [PATCH 00/11] Mixed bag of ioctl and agp cleanups Christian König
2015-10-08 17:01   ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1443469360-17902-1-git-send-email-daniel.vetter@ffwll.ch \
    --to=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.