From patchwork Mon Oct 15 17:05:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10642207 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 D9C1517D2 for ; Mon, 15 Oct 2018 17:05:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3669298E3 for ; Mon, 15 Oct 2018 17:05:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6B5C29A44; Mon, 15 Oct 2018 17:05:38 +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 3781A298E3 for ; Mon, 15 Oct 2018 17:05:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 70D4A89C83; Mon, 15 Oct 2018 17:05:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by gabe.freedesktop.org (Postfix) with ESMTPS id 21CFD89C83 for ; Mon, 15 Oct 2018 17:05:34 +0000 (UTC) Received: by mail-qt1-x844.google.com with SMTP id d8-v6so22266241qtk.13 for ; Mon, 15 Oct 2018 10:05:34 -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=Aj3xniyMbaNesfeXCWFdtvlG8L63AvByL+zrSbdGlTU=; b=PBb8s2YxXUpMuUyw2pDVrSlYNNGtF/FXvLiOImYOJwLk0ZWQzrDHorU+x6o68VQL3y QAmJZOvegUmVFPwyQU4LeJ3NcSXSOwlH+PZso7dW8VwQwihWuJUrFXlhkuKA+EabD/xV cSMfvgGmqaiupR8Bw7/znJ9/4boBk7Ux9VepmnT2t3fSUAm/7ivEKVsslhWmS1X8YuVx xJVpwdedUDz4zsfeuNJAar57rpwNP/tobwkbtnR1qnmsTWM7Ia9MkkfMq6dwjjRRd9u7 o7CEUNcGTf7HMkB1RWD8YYXVNxsrOyVyN5SrJ9qmBRHp7xhZBII5Varppe/XJG1TdXns Aplg== X-Gm-Message-State: ABuFfoiulFUAHGvA9Q7LgP4/eepVv3XGSg1RSncM5kUilI/U9EqyYf5P wcomtGOeXEQM55+m89SgjBNdm49aTbU= X-Google-Smtp-Source: ACcGV62ywlolgVpQs6dotBl+SAmJHbwzwRIvqwwtModOCbrF1jgXznIK0zLnY6NebNavCZtgGHZzwQ== X-Received: by 2002:aed:26e4:: with SMTP id q91-v6mr16568373qtd.280.1539623133207; Mon, 15 Oct 2018 10:05:33 -0700 (PDT) Received: from smtp.gmail.com ([143.107.45.1]) by smtp.gmail.com with ESMTPSA id s28-v6sm7219575qtc.92.2018.10.15.10.05.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Oct 2018 10:05:32 -0700 (PDT) Date: Mon, 15 Oct 2018 14:05:29 -0300 From: Rodrigo Siqueira To: Gustavo Padovan , Maarten Lankhorst , Sean Paul , David Airlie , Daniel Vetter Subject: [PATCH v2] drm/drm_vblank: Change EINVAL by the correct errno Message-ID: <20181015170529.dgzpbm37hbuvqatc@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: kernel-janitors@vger.kernel.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 V1: 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 | 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 |