Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7099579ybi; Thu, 13 Jun 2019 09:32:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjT/rDTzpgxt/rI6/+dMh8N+UUu4uV1eV8VBlWuaHIet8+OJeD8bpTDyDQuU6vlZPuSi7N X-Received: by 2002:a62:1990:: with SMTP id 138mr94113015pfz.133.1560443538613; Thu, 13 Jun 2019 09:32:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560443538; cv=none; d=google.com; s=arc-20160816; b=dw10VAvokr01urwTx/nT8g0QizoYveRdOVNsRSJ8U0Tlmwd0jivPKy3mLEplGXNzh0 tM4wqK8DH6LzXYpWp06Nyv5KD1Y8cPnziCBY9yxSMUxlUPxFxtVzIifN1XHKIKKKY+Cv cGJOzgefleeCIjgU3Wa7AdHDDvgjjweQqQ9TsHm5/q1LsvC7Hk1nBehwxHCsSv8Fc4sw MeS5bfVDHZ1eV+rkvUjHxA/PuYP8yX8bRm74hOoO4mqnExJ1qGHmbWwh3FRGu9qsdkZy GV390lM7jLUe5cNBh1Tf2e2XiFGneUFCtFv/fXqpw0iupNdISRRTmoRLhJUgqBH4lXpc 5FmQ== 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=/5Q5aUaRAcEEPNriaL09NE2LBrtuC+UfFWkB6hD3AL0=; b=yxuV9fADnL7rtLpTc/rdKB0XM5V4Q2GUnctwb810d6oGdwl1ctSTBfXlbFQFQJxMIO qfGkEluJNcz+BySLjSJm8xZUqKvN0C7emC7eqPJpitzUPZ7Q6CqhlyDrLOY8FHAanqLS pWymRlTLVEEE/8RdBSyd0P+UKZeMLO3vMMQGbnhvbssbXfqDTHAFHCSHMNKWsysE9FZ3 3sVgFgc1MpCJV++YOXhVYPMuBXxnBwVwZ+AsPU9HzrwOCYvyvdrulffjCbfqlJNE3/rE OBhkRoNRj75zPHMXUfZO212HZq4iigKUeHaRw5QfkpcqcHOwubDbRbgEAoJwU+KtN/OE XQCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=CNPZ9BSa; 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 59si84476plp.90.2019.06.13.09.32.03; Thu, 13 Jun 2019 09:32:18 -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=CNPZ9BSa; 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 S2392091AbfFMQbt (ORCPT + 99 others); Thu, 13 Jun 2019 12:31:49 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:41294 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730865AbfFMIVw (ORCPT ); Thu, 13 Jun 2019 04:21:52 -0400 Received: by mail-ed1-f65.google.com with SMTP id p15so29927377eds.8 for ; Thu, 13 Jun 2019 01:21:51 -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=/5Q5aUaRAcEEPNriaL09NE2LBrtuC+UfFWkB6hD3AL0=; b=CNPZ9BSaAlskYq9oJPK3nw+RHvlOS+kmhCaPVmRqdv2KGR7tiu8aOdrFbya1btWYrV /LL4gCUeCIqqlSTrQRyon/4otVWW808zDERPOuLa1zZ/UvAr46hYZgQ5D+TFonXqs0e5 6FRikD9geEaT5shYlUm40D03a+O3W7C6AcYwE= 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=/5Q5aUaRAcEEPNriaL09NE2LBrtuC+UfFWkB6hD3AL0=; b=OuRrZmrY6OGj6TzpY1rK/PztSonddOSzDsINl9yHBQ8WFXVfejBfLLrmXdSNpurAyY nvhSmht3LzhFKtfgICnX6q1+mTHmnYz66zdoyk4MlQp08zVGi7ENS7lCP8MzmGJEhO6Z XzILWKWQtmtgLSSyuQrb/zQfINU/fbeq6QC/2hqbntt86dtxztOwLcCzDXl/6OG3zKks 5gbo1hE2kF3CKXTAijS+vLgP8XtSQQFh9fSHqd8OP+Y2GIbsjpFoxg/33tMirbJ2xcMG V++YASkZshgj7JT5pwrqNEyXtTtRZZIG3qtJD6V4nvxExQFJosvmMkuCOBkU9Pg8aKHx zzig== X-Gm-Message-State: APjAAAWm4uOfxd1FR5pcxwW7cGvPrFS2njLbGBm2BFpLcLSi8cdL1/AX 01xNmlLPRcAiXwCSLw/5goQw+Q== X-Received: by 2002:a50:97c8:: with SMTP id f8mr45283000edb.176.1560414110413; Thu, 13 Jun 2019 01:21:50 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id z10sm684614edl.35.2019.06.13.01.21.49 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 13 Jun 2019 01:21:49 -0700 (PDT) Date: Thu, 13 Jun 2019 10:21:47 +0200 From: Daniel Vetter To: Rodrigo Siqueira Cc: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, intel-gfx@lists.freedesktop.org Subject: Re: [RESEND PATCH V3] drm/drm_vblank: Change EINVAL by the correct errno Message-ID: <20190613082147.GG23020@phenom.ffwll.local> Mail-Followup-To: Rodrigo Siqueira , Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, intel-gfx@lists.freedesktop.org References: <20190613021054.cdewdb3azy6zuoyw@smtp.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190613021054.cdewdb3azy6zuoyw@smtp.gmail.com> X-Operating-System: Linux phenom 4.19.0-5-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 Wed, Jun 12, 2019 at 11:10:54PM -0300, Rodrigo Siqueira wrote: > 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 EOPNOTSUPP. > Additionally, some operations are unsupported by this function, and > returns EINVAL; this patch also changes the return value to EOPNOTSUPP > in this case. 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. > > Change since V2: > Daniel Vetter and Chris Wilson > - Replace ENOTTY by EOPNOTSUPP > - Return EINVAL if the parameters are wrong > > Signed-off-by: Rodrigo Siqueira > --- > Update: > Now IGT has a way to validate if a driver has vblank support or not. > See: https://gitlab.freedesktop.org/drm/igt-gpu-tools/commit/2d244aed69165753f3adbbd6468db073dc1acf9A > > drivers/gpu/drm/drm_vblank.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c > index 0d704bddb1a6..d76a783a7d4b 100644 > --- a/drivers/gpu/drm/drm_vblank.c > +++ b/drivers/gpu/drm/drm_vblank.c > @@ -1578,10 +1578,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 -EOPNOTSUPP; > > if (vblwait->request.type & _DRM_VBLANK_SIGNAL) > - return -EINVAL; > + return -EOPNOTSUPP; Not sure we want EINVAL here, that's kinda a "parameters are wrong" version too. With that changed: Reviewed-by: Daniel Vetter > > if (vblwait->request.type & > ~(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK | > -- > 2.21.0 -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch