From patchwork Fri Aug 18 09:21:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 9908141 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9D97960382 for ; Fri, 18 Aug 2017 09:21:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9123F283BD for ; Fri, 18 Aug 2017 09:21:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85CCA28C7C; Fri, 18 Aug 2017 09:21: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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable 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 45070283BD for ; Fri, 18 Aug 2017 09:21:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DDE0E6E6E7; Fri, 18 Aug 2017 09:21:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id A62326E6E7 for ; Fri, 18 Aug 2017 09:21:34 +0000 (UTC) Received: by mail-wr0-x241.google.com with SMTP id z91so9474779wrc.4 for ; Fri, 18 Aug 2017 02:21:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id; bh=YZOSfek6AyTsBZUlxPB8o5y++2mx2cLqUhwibbz8P3I=; b=PkaEGyHjNShjmP7b/0p8hHMuu/Qnif/I0iFrfJhYGKJKLR18zNQgq9jQTuq9I8HvtS nwNs1MW1x+0vHdsiNRFBJ/Ntpiuwso0GlDinLVXQBVjAFGHtAw8+X9klnG2FZRlXbTAD ZUbwCpaaDNVr+HCbUFoycB7Y+bvHUbFxJWAOo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YZOSfek6AyTsBZUlxPB8o5y++2mx2cLqUhwibbz8P3I=; b=l5z6J4GWgFL+t5HK6NLJFq9d+1Zrp27+7LeVi1xI84067Hbv6s4VaJMpgtMbF4kOaR NxsU5M9/TbzhpF485rvBoZVVe2wuNXv2cuXRso5Jou3QJsfWDCCVzU0h8lWW/f8hwsx8 HZU9wYr2XFLphSJO5iIARD/18mDh5MKy2+wAmcsAs1loLI2ZwfvMIeFvPoR8MUFYkKcI ssFQXWqbezMWQPoi0r3kb+h6BbYPXrWWOJH/PgCALq4LI2DvUVGwg0d2pcjPtHtAbmhS rfGhhjVuPChO6a8AnRTp49CYXumfpCzMb3qWKM3T7KMx81Fpt5AWAXtM/RUlQBU+Laeq qGOQ== X-Gm-Message-State: AHYfb5i7OFEYOivI5lSsEdXOu2wwPSW5YhML7bvFiVgrl3BepEok6BUP Sf61rURAfkD1GQGm4cY= X-Received: by 10.80.213.17 with SMTP id u17mr4124081edi.105.1503048093056; Fri, 18 Aug 2017 02:21:33 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:56e6:0:e4bc:76a0:8042:669e]) by smtp.gmail.com with ESMTPSA id t4sm2746665edh.1.2017.08.18.02.21.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Aug 2017 02:21:32 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH] drm/doc: Document ioctl errno value patterns Date: Fri, 18 Aug 2017 11:21:24 +0200 Message-Id: <20170818092124.32339-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.13.3 Cc: Daniel Vetter , Intel Graphics Development , Joonas Lahtinen , "Zhang, Tina" , Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP We're not super-consistent about these, but I think it's worth to document at least the commmon patterns. Cc: Joonas Lahtinen Cc: Chris Wilson Cc: "Zhang, Tina" Signed-off-by: Daniel Vetter Reviewed-by: Chris Wilson --- Documentation/gpu/drm-uapi.rst | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst index 679373b4a03f..f3cc829467b4 100644 --- a/Documentation/gpu/drm-uapi.rst +++ b/Documentation/gpu/drm-uapi.rst @@ -177,6 +177,59 @@ IOCTL Support on Device Nodes .. kernel-doc:: drivers/gpu/drm/drm_ioc32.c :export: +Recommended IOCTL Return Values +=============================== + +In theory a driver's IOCTL callback is only allowed to return very few error +codes. In practice it's good to abuse a few more. This section documents common +practice within the DRM subsystem: + +ENOENT: + Strictly speaking only when you try to open isn't there. We reuse that + to signal any kind of object lookup failure, e.g. for unknown GEM buffer + object handles, unknown KMS object handles and similar cases. + +ENOSPC: + Some drivers use this to differiante "out of kernel memory" from "out + of VRAM". Sometimes also applies to other limited gpu resources used for + rendering (e.g. when you have a special limited compression buffer). + Sometimes resource allocation/reservation issues in command submission + IOCTLs are also signalled through EDEADLK. + + Simply running out of kernel/system memory is signalled through ENOMEM. + +EPERM/EACCESS: + Returned for an operation that is valid, but needs more priviledges. + E.g. root-only or much more common, DRM master-only operations return + this when when called by unpriviledges clients. There's no clear + difference between EACCESS and EPERM. + +ENODEV: + Feature (like PRIME, modesetting, GEM) is not supported by the driver. + +ENXIO: + Remote failure, either a hardware transaction (like i2c), but also used + when the exporting driver of a shared dma-buf or fence doesn't support a + feature needed. + +EINTR: + DRM drivers assume that userspace restarts all IOCTLs. Any DRM IOCTL can + return EINTR and in such a case should be restarted with the IOCTL + parameters left unchanged. + +EIO: + The GPU died and couldn't be resurrected through a reset. Modesetting + hardware failures are signalled through the "link status" connector + property. + +EINVAL: + Catch-all for anything that is an invalid argument combination which + cannot work. + +IOCTL also use other error codes like ETIME, EFAULT, EBUSY, but their usage is +in line with the common meanings. The above list tries to just document DRM +specific patterns. + Testing and validation ======================