Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4165650imm; Mon, 15 Oct 2018 10:06:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV60VJ4lAJAO1tnx+JwWAAX1Msj0QtHZ+6QWjxSRq5oQZfo8qodfKDDhDvRZmd4MLnNauZ0Nz X-Received: by 2002:a63:e256:: with SMTP id y22-v6mr16667431pgj.439.1539623176758; Mon, 15 Oct 2018 10:06:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539623176; cv=none; d=google.com; s=arc-20160816; b=ecDpyKB0ht8Vp9O0KPM7NaVFzG3rbRWLVpnasRXkYWQEwwRIq352+CxlMip6rh6tQj 3jZ7ZXkY8Ti6ujASdR8VW936ghloHOmr71DD9WyS3C+cuabpzXIQu75K4a3cSMc4aogL 0JEP96PGIlfdwG/nicTcDeGGaKyHslENRoX99TddIGnY2JqrhDQ2dJMPCxKsQCZQNcX0 Fa6uZ6MObi+h/C/xpXA+dXzbbVCUR3EWOil0EmcNLmnlWeATYpV/UcY+FQCmqrndJ1Hv bAaRJoOpbtbKDr4z0uYOe0LCMivAG9GbakwszdWdUHfBMZAs3kav3hkLzZNRSxh81S2L r8Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-transfer-encoding :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=Aj3xniyMbaNesfeXCWFdtvlG8L63AvByL+zrSbdGlTU=; b=j6c4CbbkpRKQPM8SAnBWOX+OiugDYxwQ1C77NTl2LI6Eze3oztcDLcN7LFVV+a7l6d D8R4TFAG9NHbczsPSvHmBbsAhpYf7W8YagkLyuckTyS2eXQBYLilbLhC4Aa/6LwZtVlo r5ykW1dE6tLD8BbWjz/l5dNyk0J0q3pB7fqUhhtYJgU0GJyAbZmWwOE+l7XA/Kur+G5I l1QWHqm/T4KtTXt5dai+u5KIzRMasZEIwO6zGEqlkZ/2YcEGpJjlWhVfQK3UvpnQUE6X zejA6QHaJz1W5ASDzWse9HO+UUy1vJxl9zmZbh7GsUGtzWwU0UtQxgq2pAp2FdXfIHIo ihPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JoyjaCk7; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 185-v6si11322494pge.516.2018.10.15.10.06.01; Mon, 15 Oct 2018 10:06:16 -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=pass header.i=@gmail.com header.s=20161025 header.b=JoyjaCk7; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726880AbeJPAvj (ORCPT + 99 others); Mon, 15 Oct 2018 20:51:39 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:32912 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726594AbeJPAvj (ORCPT ); Mon, 15 Oct 2018 20:51:39 -0400 Received: by mail-qt1-f196.google.com with SMTP id q40-v6so22319473qte.0; Mon, 15 Oct 2018 10:05:33 -0700 (PDT) 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=Aj3xniyMbaNesfeXCWFdtvlG8L63AvByL+zrSbdGlTU=; b=JoyjaCk7hyN9Oy7O/cuC6ZPMBfZpGHERa9h5Y3WGxEATMo3w665A5aeN8sy5ChHSU7 dK0czBH3F1RkirZZspP/5m52KWd2c8KdNuWAV2L40xteaoLOMpKNCy15ULCDCmgcX4rX 8D3fwNnbDv5TWl6VLxmym/ddNb4MjXQ05EPv+HMhsibELw/GdjQfezyCMovr7tVkh78f g9N0HeY2cFkO76mgw+/wEKvUQ2o0MB5oXFOj7pr/Pl/OzV0z2koWngULDwoSUdft4rco +tHrtDodDDMREhFUGjXyLJJDIxVVAdl8YKCyEEtF/kUzM3+43X7PRDLwoUlPdKHM3DRp jl2Q== 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=DYNq/usE4UUf2qMWwdfWTj5jhqrC9WaaRdpqiYIgwajw+lsQE3ta0G86h9QamWPelG Kj/P3UD6oaEkgZJgqx3ZpIMN+T9zqJbLi8NvmiOuyl0RtFfEwYRqFlae/ZKnyH8Itt4u 8NCRQwjzlw5Gd+OLlQlt19J6QUDvTDs0uJRSlJ1hl6oHxUE30zR1xKKvwPj8dClMAcPE X8PPvLOXZQ7UrgbYAPU0lgB2Ip+4w/jYmsncYO82XvAAhd4WhaAaISpSKsGq7eH4qpAk qkyhHzHIC3W8cfAyaIKG4ekGY4s+PigGSNSXJRKAjRnhcUxKq6rTnkMr/zMnPmR98Ssf r8Nw== X-Gm-Message-State: ABuFfojV1GEhgdoVkodEJwnBjC/NVumoC40N2/vLNGph3w1io0ABWYI/ ccc2L9KUPSdhVp/Y7RuuK3w= 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 Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH v2] drm/drm_vblank: Change EINVAL by the correct errno Message-ID: <20181015170529.dgzpbm37hbuvqatc@smtp.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 | -- 2.19.1