From patchwork Wed Jun 19 02:07:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 11003275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1852E112C for ; Wed, 19 Jun 2019 02:08:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00CF328A97 for ; Wed, 19 Jun 2019 02:08:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E915D28A9D; Wed, 19 Jun 2019 02:08:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9CD4728A97 for ; Wed, 19 Jun 2019 02:08:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BBBB16E27A; Wed, 19 Jun 2019 02:08:01 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5622A6E27A; Wed, 19 Jun 2019 02:08:00 +0000 (UTC) Received: by mail-ed1-x544.google.com with SMTP id k8so24616447eds.7; Tue, 18 Jun 2019 19:08:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:user-agent; bh=s9lpMBH/IugmiFXNYI6ZpyhR++3sMpJb2daAAUrg87c=; b=DQMibW+YiMo7/lataS4vUvT3P4DtZqaIDjUt8Odt+ZddSYvG2kcSqK5mJWPtBDu49H pqB8gTb/xhNg7HwSaw/dAA8saugTO/2yih5hhoLj2k+mCtK7HLBoCVM/WE1ze+M1yTzK sFY3D9OXscq0rEM2vtzE+WsymoZsasIkdzg6Lj8snjVZI3WewMGORaPaP674OsJw8obg snD5l/w/3cmRvJM053pOlUkofgV4NyqpZZnUQEobHD+97i0BTJHdvi4pIcMcZb1+MRTo 4sSkuuPK5Q1mO+QNKe/3VrFSbWTPLyCUu1nEzbDOzSwJizBWvYTFz/UNZPeA0jZDrgG8 3jAg== X-Gm-Message-State: APjAAAViltHv5KIgqwzhvr70hTkT18w8bYkAmlc3YbDIA8ulQL7sJpGy KW0H/6uW1X8gVkDjdBl81O0= X-Google-Smtp-Source: APXvYqyV3lljKw+wProWO8jUjFZkqDRUPrpL6ShZ5xRp5iz2PaEe1L1taSJ0vgFMnRqhprl/oGHqww== X-Received: by 2002:a17:906:2301:: with SMTP id l1mr54424834eja.92.1560910077820; Tue, 18 Jun 2019 19:07:57 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.146]) by smtp.gmail.com with ESMTPSA id k11sm1974837edq.54.2019.06.18.19.07.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 18 Jun 2019 19:07:57 -0700 (PDT) Date: Tue, 18 Jun 2019 23:07:50 -0300 From: Rodrigo Siqueira To: Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter Message-ID: <20190619020750.swzerehjbvx6sbk2@smtp.gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20180716 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:user-agent; bh=s9lpMBH/IugmiFXNYI6ZpyhR++3sMpJb2daAAUrg87c=; b=pWuu1Ni7Pj1W/hQq6vtS/AHazRgRHRM9Y7pAnxIHlPNPp6BXKMhcu6/Tn5/pJhbGQ5 vPGGQLKsfjVFADDj+ujB57FNC1EWIjbJTvto5xsdO4cvQVbAfVinkdDrBbRPrbdw9F+I jklYuAY0LP1WIV2QiiCA36FGAMYk+MswrcAPW/Sfze4f491rr9WEqVlAqgB6+dQEJddA IuCq61M1lW1DJKw84V3pP9YP41wIR/AuOw4qzzZyWaRfjXQbl6ps/M5QAILuNMM5cVTE ehUjrIf8MRNDvanyPP30lFjG79ieh+IhvWp7g9VERKAKow8gzilKfGkm8C5LTnWFkUbm c7Dg== Subject: [Intel-gfx] [PATCH V4] drm/drm_vblank: Change EINVAL by the correct errno X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP 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 V3: - Return EINVAL for _DRM_VBLANK_SIGNAL (Daniel) Change since V2: Daniel Vetter and Chris Wilson - Replace ENOTTY by EOPNOTSUPP - Return EINVAL if the parameters are wrong Signed-off-by: Rodrigo Siqueira Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_vblank.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index 603ab105125d..bed233361614 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -1582,7 +1582,7 @@ 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;