From patchwork Tue Sep 8 11:56:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 7140481 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A813DBF036 for ; Tue, 8 Sep 2015 11:54:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C9641206F4 for ; Tue, 8 Sep 2015 11:54:12 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id EA8F2206EB for ; Tue, 8 Sep 2015 11:54:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0AD146E78A; Tue, 8 Sep 2015 04:54:06 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by gabe.freedesktop.org (Postfix) with ESMTPS id F2A166E7FA for ; Tue, 8 Sep 2015 04:54:00 -0700 (PDT) Received: by wiclk2 with SMTP id lk2so112377464wic.1 for ; Tue, 08 Sep 2015 04:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5/SZhVmTR2D8vCsvoBbUK1HWMoYFz8kPIlzoBxjx6pI=; b=OQKPQ79ylZOmB1jvsiC54U4Sf8MUFhz7prSdp4637ZEtPO266GfNMbse+0/MSHejaz tK7yuBBCZLwePKH3j9fctFAdcfcFVpjanUgdY5NHRDouIEToWXKxKg99bmQTjRi3QMcY NaS4g+7Td4ihapp9qIRhTmsg7RGLXwMmdX0Sw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5/SZhVmTR2D8vCsvoBbUK1HWMoYFz8kPIlzoBxjx6pI=; b=U4q9GETBiK5ejWS505cww9vXGPPGrS4RfCjgFhweMPFWEfCgzad6PZwksXJONpfK58 YIDnHpUEOVLk9gHK7NA2BLBogeRfOymORtnrhauuzrikCEXR0Zwg6+phE6tEG1IC9h7g s1eCliI40ntzf5gufpuoY64yU40SvQbMuLIKQFTEiUYCoShjIDkZLeGnU28r1sBSy49i E1XtvcvUxRrGXtYWu9Z4XvQYvHqcLTRN4x7avl13BHQVFnsb5VoW/tjF3VtJujNfU4CI Q70lN29UjIWwh6hPN4sK3uPH/hQJFtGVnPu8gxnJ9NuYL8/5oeI9h+eGMKvmmAPA04dT aEmA== X-Gm-Message-State: ALoCoQkOkdQmqX3upNDpsLTpmhYaB00+QBcTFvAPViHWcM3lRN+0m9OdpI14naZrY2B1zZ+cz2oq X-Received: by 10.194.78.34 with SMTP id y2mr41579410wjw.91.1441713239617; Tue, 08 Sep 2015 04:53:59 -0700 (PDT) Received: from phenom.ffwll.local (212-51-149-109.fiber7.init7.net. [212.51.149.109]) by smtp.gmail.com with ESMTPSA id o10sm4480145wia.4.2015.09.08.04.53.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Sep 2015 04:53:59 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 08/11] drm: Enforce unlocked ioctl operation for kms driver ioctls Date: Tue, 8 Sep 2015 13:56:28 +0200 Message-Id: <1441713391-24732-9-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.5.1 In-Reply-To: <1441713391-24732-1-git-send-email-daniel.vetter@ffwll.ch> References: <1441713391-24732-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Daniel Vetter Reviewed-by: Gustavo Padovan --- Documentation/DocBook/drm.tmpl | 4 +++- drivers/gpu/drm/drm_ioctl.c | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index cfb43203a6a7..55dc106686df 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -3747,7 +3747,9 @@ int num_ioctls; 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. diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 75df8ea87cd7..a5a4aa89b1b4 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -728,6 +728,7 @@ long drm_ioctl(struct file *filp, } retcode = drm_ioctl_permit(ioctl->flags, file_priv); + if (unlikely(retcode)) goto err_i1; @@ -755,7 +756,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) || + (ioctl->flags & DRM_UNLOCKED)) retcode = func(dev, kdata, file_priv); else { mutex_lock(&drm_global_mutex);