Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1911953imm; Thu, 11 Oct 2018 01:44:52 -0700 (PDT) X-Google-Smtp-Source: ACcGV61yTRkhe/8hPyvGBcwzDN6gn/hA4yRgwDcqb6Tqb9dgWhH8aY9fE1ckZkCsM1+FSWxnXvmN X-Received: by 2002:a63:7c5e:: with SMTP id l30-v6mr587545pgn.45.1539247492636; Thu, 11 Oct 2018 01:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539247492; cv=none; d=google.com; s=arc-20160816; b=umTvctpRf4UBwAZa6Tz5I6odj8CXXoajtpwKeQewmCMl2ZKvoTrck0NH7rxUW3B/Ux t8y93cA+zJiBtmmGqqwNlTU+O86bhLC2liDqIyCL2bqWMG4PvTg3Za1RpHvN0GDOfvHA GErHi73uT7Vn6Ogt9rJEyZ/r4CNG9WK2SrdFOf8HBTC0JbRMnt9z0h1od/BHRw4+7T9a g0zmWscaBz0WiioFOozdXv/HEKnk7afb8+rr5UVxPgZkbroGFG9+qGLTq2r6WlgJADDz f7BI9cFwIJJH5h2YZqE+sOIwl4XD34evla5gP43FPjqCRSSrce+mCK1NUghVwQfSSgmm Ggig== 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; bh=Kw1LF5tD5rxGhDP2RzfzQC8MbUK5ux1QNSzTZN4cPGM=; b=xgFJwcgN24EN7PPbrX9EwQdVCcas7D/hT2zAQ6PfCoZCDkBgUs14o9ueCa4osQQw8T sp2ZTM8BLREf3PTyF8q+LbcQlqw60cBjYqGmDN+Fz2qhgJ+I5BME6esJMXzFOa1KUc0T Gzt8BWk8EEEqzIPnfMl+pjLyLL7e9fBs7/kye4apeC22QrBAUlS/Lrwg/3yQgDiv7d6j nLwO7EtfpBcz/oLM4IZkHx2slhPtO8qUSva6qfjfO78Lgan2kNYfApiSselCZ6LDj7LS fnzrQNihprZoEBDVQ9UIlU79/5EjY1RK1j+5DcPBt4zvIs7HyYBPUZmU3oFMCRL+Y4Li 7EOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=eR1sSpec; 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 u192-v6si26009515pgu.449.2018.10.11.01.44.37; Thu, 11 Oct 2018 01:44:52 -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; dkim=fail header.i=@ffwll.ch header.s=google header.b=eR1sSpec; 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 S1727589AbeJKQEl (ORCPT + 99 others); Thu, 11 Oct 2018 12:04:41 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:32970 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbeJKQEl (ORCPT ); Thu, 11 Oct 2018 12:04:41 -0400 Received: by mail-ed1-f68.google.com with SMTP id h13-v6so7473356edq.0 for ; Thu, 11 Oct 2018 01:38:24 -0700 (PDT) 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=Kw1LF5tD5rxGhDP2RzfzQC8MbUK5ux1QNSzTZN4cPGM=; b=eR1sSpecg8vbs0DbwGRSrOfOzASjmapk0RnDGd49f3MJuqIn2W4KGMdyuF7DyNmiZC edsnvWRsvjEZcnRWUpXNcZZva/ueB6FrQHSFvPoxzOmPJ8imfjqVhjtjM9ix8/tzGVVB NZkMNupKe7Xdw02zKxNOIVvFlOvzgknvRhfqM= 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=Kw1LF5tD5rxGhDP2RzfzQC8MbUK5ux1QNSzTZN4cPGM=; b=dXRB5AA1h4k83iMjQYOrlA+awQfs0L0GUrimvORKAWwK+SCc5Evg9c2pr6tkIxH0jc 1VmDab4IfUGfOqa98fjZngsAlP9O12TXp5DA+CJbVN3I6CvK1oKYsid/HcAexKRdEuZr JarXC7KZTMasUkyLfaGoJwVPvZTF15BPWjUhj6axHi5nm7Lz2YbdM+G0oTOhGgRx6hYL blzJ899SFlAXa6GVLXJrYBcAhJ9vk2ecNwz+29JPzwK3T+InSZLNIfmVA4dnMYNT54B3 RkFXOCY6DYpWjXxvSZSg1Q0cwmQkWY9qSVRBGjQ36P5p0/hIdtoBjTj6A5TWdkEJ/l0n MAlQ== X-Gm-Message-State: ABuFfoh/ljRwNQgnL1d+5TzhotFNaiip+N/aAQMnE6VJ9M6Sgl2gxo8C rRS/1y4FssEC9GhV7uHKowcFgg== X-Received: by 2002:a50:a1c6:: with SMTP id 64-v6mr1410558edk.88.1539247103998; Thu, 11 Oct 2018 01:38:23 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id e5-v6sm4638865ejc.47.2018.10.11.01.38.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Oct 2018 01:38:21 -0700 (PDT) Date: Thu, 11 Oct 2018 10:38:19 +0200 From: Daniel Vetter To: Rodrigo Siqueira Cc: Chris Wilson , Daniel Vetter , David Airlie , Gustavo Padovan , Maarten Lankhorst , Sean Paul , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: Re: [PATCH] drm/drm_vblank: Change EINVAL by the correct errno Message-ID: <20181011083818.GW31561@phenom.ffwll.local> Mail-Followup-To: Rodrigo Siqueira , Chris Wilson , David Airlie , Gustavo Padovan , Maarten Lankhorst , Sean Paul , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org References: <20181008145220.p34dllgsiw6rlpod@smtp.gmail.com> <153901080237.31254.10116385737520796385@skylake-alporthouse-com> <20181008165213.vejfqe6ohiejeeq2@smtp.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181008165213.vejfqe6ohiejeeq2@smtp.gmail.com> X-Operating-System: Linux phenom 4.14.0-1-amd64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 08, 2018 at 01:52:13PM -0300, Rodrigo Siqueira wrote: > On 10/08, Chris Wilson wrote: > > 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. > > Hi Chris, thanks for your review :) > > Originally, I noticed that DRM does not provide a mechanism for checking > if VBlank is supported or not by the driver. IMHO return ENOTTY can be > useful for virtual drivers and some specific devices; the userspace can > take this information and infer some information about the device, > consequently, handling different scenarios. This issue was raised when I > was working to implement the virtual mode in the VKMS (no vblank) and > tried to patch IGT to handle modules that do not support Vblank. > Finally, I believe that ENOTTY precisely describes the condition > "if (!dev->irq_enabled)". Make sense? I Chris' recent series to do the same for all kms ioctls we've generally agreed on EOPNOTSUPP as the errno for "this feature isn't supported on this driver". And ENOTTY for the "I have no idea what this ioctl even is" kind of stuff. So I'm leaning towards EOPNOTSUPP here. > > > > > > > if (vblwait->request.type & _DRM_VBLANK_SIGNAL) > > > - return -EINVAL; > > > > User error -> einval. > > Here, my primary motivation to add EOPNOTSUPP came from the comment in > _DRM_VBLANK_SIGNAL, which says: > > _DRM_VBLANK_SIGNAL = 0x40000000 /**< Send signal instead of blocking, unsupported */ > > Then I thought that EOPNOTSUPP could better describe this situation. I think either is an ok choice. EINVAL since afaik upstream never supported this flag, so it's not different from any other flag with on meaning - just another userspace programming bug. > > > + 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. > > About this one, you are right. Sorry, I misunderstood that part of the > code. Agreed, EINVAL. Cheers, Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch