Received: by 10.223.185.116 with SMTP id b49csp6387948wrg; Wed, 28 Feb 2018 08:35:25 -0800 (PST) X-Google-Smtp-Source: AH8x2253aOKpbJWLsny5n0BafI6/8bfIoBFOS92kBeGLmSUZxEpYCCgu0Y8mSmSkysU9DAW+2qs2 X-Received: by 10.101.75.140 with SMTP id t12mr15123897pgq.442.1519835724920; Wed, 28 Feb 2018 08:35:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519835724; cv=none; d=google.com; s=arc-20160816; b=lfFKf8rTEQjtKQCJcXcrXKQnspAjvXh8ZYVQzzQM0vv4TVVfurOwG2xj2iT0zIk8DG ydDim2kENbZK48D9pJQf/D8SX66xuGFjz0mkLyBFTS100WJ9WqXCJP3mwJ6uCn4qdGwt Knh1EEeMp6CUPMvs6HXGpIi/FpFABlgNtGVU7icU8TeYlnyYVbOUni/dWUdSfbxosy1p VXt1HXbWwI+MYM/x2Rqf1Pq3op4P3M8ElI7A8AF3MUkuysl+y/rJ12OHyzRHrlAbM0te jFxC1UxCs220bc5dpp+vrQjKzDJlbb/2LbiO5Jp7U6LOSOJc2+yMNeYKoHHbRzRHVTSv j4zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=b1MBvhYEH54E0fMy6od6vcsnwllq+4w/Q4wzX0eWzt4=; b=jJoTSufOEjAZwFeZAvKbhGs9ABsAyJnKP2MM5EEMnVxS0KCEpzruOSc4PhFP3hgJDZ uM922ubCYZJZMTKy1tqPQ0n1LwU+w1ldhOp3dGXHTsJD01sUNKrUHDGxu2rZzIxiFAru V7lEWztRSMuNUmhahb2+WN8Q6CWfzChQCj19nR5vEtcRua7mVVofVlFZXK9HALhySM5R vqD+WIgTCSJInhp9ObzI1vy012NvRAlxu7B9bpXDnS73ScbDaKZQFE67NQ1uv197jhE3 MHnteAZ0NJW1Ctm1EAsY0sMp4GKpG3LlLmXaeF7kXBQb4cmqZ0yLrsf1TUCN/cuPnXgA RPYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e89-v6si1516194plb.557.2018.02.28.08.35.10; Wed, 28 Feb 2018 08:35:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934728AbeB1Qef (ORCPT + 99 others); Wed, 28 Feb 2018 11:34:35 -0500 Received: from foss.arm.com ([217.140.101.70]:53524 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932358AbeB1Qec (ORCPT ); Wed, 28 Feb 2018 11:34:32 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 821BB1529; Wed, 28 Feb 2018 08:34:32 -0800 (PST) Received: from e110455-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2FBCE3F318; Wed, 28 Feb 2018 08:34:32 -0800 (PST) Received: by e110455-lin.cambridge.arm.com (Postfix, from userid 1000) id 8322C680262; Wed, 28 Feb 2018 16:34:30 +0000 (GMT) Date: Wed, 28 Feb 2018 16:34:30 +0000 From: Liviu Dudau To: Ville =?utf-8?B?U3lyasOkbMOk?= Cc: DRI-devel , David Airlie , Daniel Vetter , LKML Subject: Re: [PATCH] drm/drm_ioctl.c: Test client capability value early when setting. Message-ID: <20180228163430.GB20827@e110455-lin.cambridge.arm.com> References: <20180228152741.22507-1-Liviu.Dudau@arm.com> <20180228154041.GK5453@intel.com> <20180228154444.GA20827@e110455-lin.cambridge.arm.com> <20180228155715.GL5453@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180228155715.GL5453@intel.com> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 28, 2018 at 05:57:15PM +0200, Ville Syrjälä wrote: > On Wed, Feb 28, 2018 at 03:44:44PM +0000, Liviu Dudau wrote: > > On Wed, Feb 28, 2018 at 05:40:41PM +0200, Ville Syrjälä wrote: > > > On Wed, Feb 28, 2018 at 03:27:41PM +0000, Liviu Dudau wrote: > > > > The drm_setclientcap() function implementing the DRM_IOCTL_SET_CLIENT_CAP > > > > ioctl expects that any capability set by the client will have a value of 1. > > > > Make the check early so that we don't have to test the value for each > > > > capability. > > > > > > What if we want a a non-boolean capability at some point? > > > > Well, I'm adding another boolean capability soon, so you will be going > > against the trend :) > > Plenty of non-bools in driver specific counterparts I believe. So, is that a NACK? > > > I guess you will have 2 options: revert the patch or add a condition to > > the test. > > > > I don't have strong feelings, just felt like too much copying when > > adding another capability so I thought to do some "cleanup". > > > > Best regards, > > Liviu > > > > > > > > > > > > > Signed-off-by: Liviu Dudau > > > > --- > > > > drivers/gpu/drm/drm_ioctl.c | 9 +++------ > > > > 1 file changed, 3 insertions(+), 6 deletions(-) > > > > > > > > diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c > > > > index af782911c505..02ffa0e8d77b 100644 > > > > --- a/drivers/gpu/drm/drm_ioctl.c > > > > +++ b/drivers/gpu/drm/drm_ioctl.c > > > > @@ -306,22 +306,19 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv) > > > > { > > > > struct drm_set_client_cap *req = data; > > > > > > > > + if (req->value > 1) > > > > + return -EINVAL; > > > > + > > > > switch (req->capability) { > > > > case DRM_CLIENT_CAP_STEREO_3D: > > > > - if (req->value > 1) > > > > - return -EINVAL; > > > > file_priv->stereo_allowed = req->value; > > > > break; > > > > case DRM_CLIENT_CAP_UNIVERSAL_PLANES: > > > > - if (req->value > 1) > > > > - return -EINVAL; > > > > file_priv->universal_planes = req->value; > > > > break; > > > > case DRM_CLIENT_CAP_ATOMIC: > > > > if (!drm_core_check_feature(dev, DRIVER_ATOMIC)) > > > > return -EINVAL; > > > > - if (req->value > 1) > > > > - return -EINVAL; > > > > file_priv->atomic = req->value; > > > > file_priv->universal_planes = req->value; > > > > break; > > > > -- > > > > 2.16.2 > > > > > > > > _______________________________________________ > > > > dri-devel mailing list > > > > dri-devel@lists.freedesktop.org > > > > https://lists.freedesktop.org/mailman/listinfo/dri-devel > > > > > > -- > > > Ville Syrjälä > > > Intel OTC > > > > -- > > ==================== > > | I would like to | > > | fix the world, | > > | but they're not | > > | giving me the | > > \ source code! / > > --------------- > > ¯\_(ツ)_/¯ > > -- > Ville Syrjälä > Intel OTC -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯