Received: by 10.223.185.116 with SMTP id b49csp3630237wrg; Tue, 6 Mar 2018 02:15:42 -0800 (PST) X-Google-Smtp-Source: AG47ELvvyLZVU9owDTcmjewGcMnTxlkxnYClMhbRuPLYmwSSOTNpW3VjGEX9Kvl4iYCzaIeYwSOL X-Received: by 10.98.74.140 with SMTP id c12mr18694114pfj.44.1520331342877; Tue, 06 Mar 2018 02:15:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520331342; cv=none; d=google.com; s=arc-20160816; b=UvjK83xY3cYp3rlgkLP7TgEMASF6zDW6seNFsT6xYDsoXMrA7UUWX/mP6CZZn86usF qc7oNmyPWDccgumoLOI5nQpr/ahUdWpWB/NM6zbSQ4p+nC+kNts0VT81zLR4eI7EvkC8 jqCTLsppRsORo0opsqQKhiARRcCU+WUK/ziHP+zL0qitkKjUCmNgcr+l/wMYGFxSYdU8 VNZm3Wsaw33IYT2LQCAl73sDrxR8m7H33Qmg8jPl5O/y1Y5fYQY1rWUYcmpNpTEYmtSJ yQbVNAu8+67Y3PU/x6OshN1CLkBqBFzPF5WGXMppZtlKC902I2+C4jzxd+2LiC6OmWFm IbXw== 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:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=pqUxDpe0C3N/5ugJJbPkYweAjcrUxfViXTaUEGHN5xk=; b=coN2JhzvTQftP3idsEGbBw4XOdWWjnpYjaq3YxhSfHmUOC1OZhvvN6gHbtYYr2l8AM t0ml8vvSbGWO/nDEvp42ZpHV7h/Nvo5/N6HtGRfX7n7qZUv7ir9Y2F6JgvvPDH7jI9rU lt8LWa01zj+lBRxAhT1VRpsVbR3IAgscfT413ZCGYSxZF3aYSMwN7ShrvJNd6UGEWUFB y6h3Af9zS3NiRlj08YSpk4x6S5PJBaBop6RxMwgipoWJi4yU1rT9tuEKs3L/5OSEmVcN 8p/ae4rFaw10KWE3DJk2LR/VJNKTb92391OyochdTK5J54rurl1q5vFCMGBKBEIKh2Cs qffA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=lgerkcQ4; 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 z3si9692086pgs.71.2018.03.06.02.15.28; Tue, 06 Mar 2018 02:15:42 -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; dkim=fail header.i=@ffwll.ch header.s=google header.b=lgerkcQ4; 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 S1753305AbeCFKNh (ORCPT + 99 others); Tue, 6 Mar 2018 05:13:37 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:53162 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750838AbeCFKNf (ORCPT ); Tue, 6 Mar 2018 05:13:35 -0500 Received: by mail-wm0-f65.google.com with SMTP id t3so21557097wmc.2 for ; Tue, 06 Mar 2018 02:13:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=pqUxDpe0C3N/5ugJJbPkYweAjcrUxfViXTaUEGHN5xk=; b=lgerkcQ4tZXQE44/ycZKX81kILNrv9A3WHiHlwEbK7cl1m5Xgg1aaoplHPinU3KrM/ qvNaYJkhj0h/WEAFluTXNH/ER8oH5ENHLxEyg2c4dPQ8ElVHsH6bnAHlSLx+Vub7lZyp 7+wCvz+FJRgp90vZ2DmNg9yodCDTBk6LsRj94= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=pqUxDpe0C3N/5ugJJbPkYweAjcrUxfViXTaUEGHN5xk=; b=GxtQLDLQA6YkEhwd/IEIVDIjFwgGQKOnTTe+9l/t5bgCiLHAhytfFb43yf5+hALNPg QffFZfbOByoSQnkQLTEn9nM5DjqfDt1hCkyiohkKoDuol2vbriOZUOiuAYhsPnd0ktFS a2YtttmsjQy6vYaKvWIPmFtyw4bUd1oYyukdzEsb3FoKk5U6ECTlt64xSUDTG0r5jJNS r/aMct7Y0Jt2tOEWwG6PYKP3GkaWTNEbLul9PiEWIHOIDjC9j0DU2XjBBsv/iDXt4sDy 69CS/2VURnUIHfb/2Dn6UuMywJOXi4G3+v5zak1gNplEzzsKLjUPevWg8Yb92P0zMdSN OdAg== X-Gm-Message-State: APf1xPAiArkYL8PONyDHbDaH+F3jByE4WE22ay/j/rqnKtLi4tldN8Kz /YUHs+GCVvM6ogpwCW0UyNkQUA== X-Received: by 10.80.183.175 with SMTP id h44mr22199015ede.287.1520331214196; Tue, 06 Mar 2018 02:13:34 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:5635:0:39d2:f87e:2033:9f6]) by smtp.gmail.com with ESMTPSA id w2sm12990041edb.25.2018.03.06.02.13.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Mar 2018 02:13:33 -0800 (PST) Date: Tue, 6 Mar 2018 11:13:31 +0100 From: Daniel Vetter To: Liviu Dudau Cc: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= , DRI-devel , David Airlie , Daniel Vetter , LKML Subject: Re: [PATCH] drm/drm_ioctl.c: Test client capability value early when setting. Message-ID: <20180306101331.GD22212@phenom.ffwll.local> Mail-Followup-To: Liviu Dudau , Ville =?iso-8859-1?Q?Syrj=E4l=E4?= , DRI-devel , David Airlie , LKML References: <20180228152741.22507-1-Liviu.Dudau@arm.com> <20180228154041.GK5453@intel.com> <20180228154444.GA20827@e110455-lin.cambridge.arm.com> <20180228155715.GL5453@intel.com> <20180228163430.GB20827@e110455-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180228163430.GB20827@e110455-lin.cambridge.arm.com> X-Operating-System: Linux phenom 4.14.0-3-amd64 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 04:34:30PM +0000, Liviu Dudau wrote: > 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? Yeah I think this is overoptimizing for not repeating code. -Daniel > > > > > > > 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! / > --------------- > ¯\_(ツ)_/¯ -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch