From patchwork Wed Oct 17 22:44:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10646165 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 15A4B1508 for ; Wed, 17 Oct 2018 22:44:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9A8A288E4 for ; Wed, 17 Oct 2018 22:44:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE36C288E7; Wed, 17 Oct 2018 22:44:40 +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 78A09288C7 for ; Wed, 17 Oct 2018 22:44:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 08C726E3AD; Wed, 17 Oct 2018 22:44:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by gabe.freedesktop.org (Postfix) with ESMTPS id C307A6E3AD; Wed, 17 Oct 2018 22:44:36 +0000 (UTC) Received: by mail-qk1-x741.google.com with SMTP id v68-v6so17616026qka.2; Wed, 17 Oct 2018 15:44:36 -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=q2d2+eto/UT1viycFSpXhEOFe0u6zGB2ruedvOuZknY=; b=sc/JY94Pu8S/nL1FB3GoEqFzvPnVq64AY6vWiTifOOYjNPfcmcErkgcpaEet1+vzMD Hb8P2fC5BLA1ZQYYcwPeuKMNb9K4n3wWrXPoXlFug009PSX4D024l/34RZRrGx5tjHVv Bmr8DKqT1Q0cyRY+CBMNM/RXt84c3m3afWf98/gGfs9SkTFrF54li0ReDDFOcwZpjN7z TFdmzjDGBENtj1hxy6UH5hwR5jEvvOtXh+XGvy3dlLV7Lf5xP5vE/3zgg7rxPkozM0DQ Q2XHswHfXzRxUAGWng8MHCDKggkOOfUNCEH0zgELb7F8+bE8ZOpcFa1wq+1FnV6+TOEb L9EA== X-Gm-Message-State: ABuFfogzaEZNMlh3fhDjTGZY8WYxRjKtQhakBe0sxh8qkgvjPNC9KbSn E2f3GzUTMNETpH+PpE/ih6s= X-Google-Smtp-Source: ACcGV62kFqiZiDhquOEXE6KJ0KrWXB9Pl2cmjC3TXyY3BlZEiPhPiCII7z490lMRHRBJIafGtY/3kA== X-Received: by 2002:ae9:c21a:: with SMTP id j26-v6mr25846519qkg.52.1539816275880; Wed, 17 Oct 2018 15:44:35 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id 128-v6sm10067075qko.7.2018.10.17.15.44.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Oct 2018 15:44:35 -0700 (PDT) Date: Wed, 17 Oct 2018 19:44:31 -0300 From: Rodrigo Siqueira To: Gustavo Padovan , Maarten Lankhorst , Sean Paul , David Airlie , Daniel Vetter Subject: [FOR CI] drm/drm_vblank: Change EINVAL by the correct errno Message-ID: <20181017224431.hctq3crhxculykvu@smtp.gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20180716 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 V2: Daniel Vetter and Chris Wilson - Replace ENOTTY by EOPNOTSUPP - Return EINVAL if the parameters are wrong Signed-off-by: Rodrigo Siqueira --- 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 98e091175921..80f5a3bb427e 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 -EOPNOTSUPP; if (vblwait->request.type & _DRM_VBLANK_SIGNAL) - return -EINVAL; + return -EOPNOTSUPP; if (vblwait->request.type & ~(_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK |