Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3687961imm; Mon, 8 Oct 2018 08:02:15 -0700 (PDT) X-Google-Smtp-Source: ACcGV62m0o7LpjVcv60KdpiJQpRH4CysI/w+LfhUjZjhVTgmBukjjik31pSwpgba/TWh4RpwhGRy X-Received: by 2002:a63:6342:: with SMTP id x63-v6mr20331250pgb.83.1539010935147; Mon, 08 Oct 2018 08:02:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539010935; cv=none; d=google.com; s=arc-20160816; b=pdSZyfQov0zVt7tkD6HeGAw1GdT5zV1y/hbgHH42gZ/SimgRXds3fMkDE0+sydwer+ SGwrFl5WffEJAanR2Uk7lg8xCkQA+mHtP76MkxCTF1Om3AZX4GgmcVnXO/VxhTQetKtZ ZHpSgwn/ky8lhkIbORvNpwfvWEXONd3w8x1vUZ75TyUH49yv21FQ0gJJoBwLbnbwILcm KcczD6yBBAgp9y35mB6fR8vorvnwNnV6Wa4pgiyAim2FYO/+OX1r0r4jjv7pkN6hPwyg gZbG6C0IFW/kblqzqk6uQijLvC3YQzUBdXkLJZ9j5XwHMVdCt3nsYIZF6tADYhPzT4Pc cxog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version; bh=KwnwVs9I7fb/ldI4SordUwBytjsRVUKXeTz0Y85kt+4=; b=gmGBfq+a4nSMnIitJ1qcbciabn4pYGlH2ppOB0bJk//OABGJAAvp6aBT4X5MAQ/rX3 ibllzj6Q1AfusAAYbA9mPCHlunS+AaJPWirJN9oPQJQK/PCkxDGxtU4awlRM190YaxOh sAU+Hh6VqPHRQwOhtZ4mq74qxWYNPuepz5OHXPgQ182mRDZVanvKjGjt4Idf+LX+bzp2 +J8RBQPpLSFbVa/odt5gtwwaQVarhh2ESo3D2xy8amgPlSChoTm9fXjfufBdlGzoC4a0 d1TOryA1KupCToHZVjwthmjqPVyhGedzRdPq1dXj1LGlJ52VTZAIQBSZuN1CLgBaYZBe 4+uw== 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 16-v6si23299867pfc.21.2018.10.08.08.01.58; Mon, 08 Oct 2018 08:02:15 -0700 (PDT) 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 S1726672AbeJHWMT convert rfc822-to-8bit (ORCPT + 99 others); Mon, 8 Oct 2018 18:12:19 -0400 Received: from mail.fireflyinternet.com ([109.228.58.192]:64832 "EHLO fireflyinternet.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726078AbeJHWMT (ORCPT ); Mon, 8 Oct 2018 18:12:19 -0400 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from localhost (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP (TLS) id 14032428-1500050 for multiple; Mon, 08 Oct 2018 16:00:03 +0100 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Daniel Vetter , David Airlie , Gustavo Padovan , Maarten Lankhorst , Rodrigo Siqueira , Sean Paul From: Chris Wilson In-Reply-To: <20181008145220.p34dllgsiw6rlpod@smtp.gmail.com> Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org References: <20181008145220.p34dllgsiw6rlpod@smtp.gmail.com> Message-ID: <153901080237.31254.10116385737520796385@skylake-alporthouse-com> User-Agent: alot/0.6 Subject: Re: [PATCH] drm/drm_vblank: Change EINVAL by the correct errno Date: Mon, 08 Oct 2018 16:00:02 +0100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Rodrigo Siqueira (2018-10-08 15:52:20) > For historical reason, the function drm_wait_vblank_ioctl always return > -EINVAL if something gets wrong. This scenario limits the flexibility > for the userspace make detailed verification of the problem and take > some action. In particular, the validation of “if (!dev->irq_enabled)” > in the drm_wait_vblank_ioctl is responsible for checking if the driver > support vblank or not. If the driver does not support VBlank, the > function drm_wait_vblank_ioctl returns EINVAL which does not represent > the real issue; this patch changes this behavior by return ENOTTY > (Inappropriate ioctl for device). Additionally, some operations are > unsupported by this function, and returns EINVAL; this patch changes the > return value to EOPNOTSUPP (Operation not supported). Lastly, the > function drm_wait_vblank_ioctl is invoked by libdrm, which is used by > many compositors; because of this, it is important to check if this > change breaks any compositor. In this sense, the following projects were > examined: > > * Drm-hwcomposer > * Kwin > * Sway > * Wlroots > * Wayland-core > * Weston > * Xorg (67 different drivers) > > For each repository the verification happened in three steps: > > * Update the main branch > * Look for any occurrence "drmWaitVBlank" with the command: > git grep -n "drmWaitVBlank" > * Look in the git history of the project with the command: > git log -SdrmWaitVBlank > > Finally, none of the above projects validate the use of EINVAL which > make safe, at least for these projects, to change the return values. > > Signed-off-by: Rodrigo Siqueira > --- > drivers/gpu/drm/drm_vblank.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c > index 98e091175921..88ec6fb49afb 100644 > --- a/drivers/gpu/drm/drm_vblank.c > +++ b/drivers/gpu/drm/drm_vblank.c > @@ -1533,10 +1533,10 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data, > unsigned int flags, pipe, high_pipe; > > if (!dev->irq_enabled) > - return -EINVAL; > + return -ENOTTY; Arguable. > > if (vblwait->request.type & _DRM_VBLANK_SIGNAL) > - return -EINVAL; User error -> einval. > + return -EOPNOTSUPP; > > if (vblwait->request.type & > ~(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK | > @@ -1545,7 +1545,7 @@ int drm_wait_vblank_ioctl(struct drm_device *dev, void *data, > vblwait->request.type, > (_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK | > _DRM_VBLANK_HIGH_CRTC_MASK)); > - return -EINVAL; > + return -EOPNOTSUPP; User error -> einval. -Chris