From nobody Mon Feb 9 22:18:44 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6879BEB64D7 for ; Wed, 21 Jun 2023 00:58:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229935AbjFUA6h (ORCPT ); Tue, 20 Jun 2023 20:58:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229628AbjFUA6d (ORCPT ); Tue, 20 Jun 2023 20:58:33 -0400 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FFFF10CE for ; Tue, 20 Jun 2023 17:58:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=/U+iXS7cPu32eSBwTnxjvnLVI4LNUEgzC2fiTpf+640=; b=ViYBsyZduSvJIePE3SHI9Xcseq ZUGzW4FIeLj6u40vb7Mut5GmR+n+ppjsfMBRmCJauD8lwHce6uWkVLA4p0l7j9xhwZT0ECXhrIWT7 UPL10h29Wx2SGRQe44eJHve6Y9Ho1ZOcuZZJnYXeqoPcPejsj46pXh7CcLPHEoOKfHKRqUei5OfTp heAeYym/HcDNnNGapEkznLmRZ1gA3kvbLGamL9Gyh9JcOUQJswEbq6KL9O8EHF50qBeb8hgNMazRh LoyI85oR2Mu0idXEWvjbf/BHvEsbLvzG3ixyv1NVSv4hzYhVGmg0cp1s1SvlgF4A2QA076u0ty0Ef tlxTUvyQ==; Received: from [179.113.218.86] (helo=steammachine.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1qBmB4-0011pg-5q; Wed, 21 Jun 2023 02:58:30 +0200 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: kernel-dev@igalia.com, alexander.deucher@amd.com, christian.koenig@amd.com, pierre-eric.pelloux-prayer@amd.com, Simon Ser , Rob Clark , Pekka Paalanen , Daniel Vetter , Daniel Stone , =?UTF-8?q?=27Marek=20Ol=C5=A1=C3=A1k=27?= , Dave Airlie , =?UTF-8?q?Michel=20D=C3=A4nzer?= , Samuel Pitoiset , =?UTF-8?q?Timur=20Krist=C3=B3f?= , Bas Nieuwenhuizen , =?UTF-8?q?Andr=C3=A9=20Almeida?= Subject: [RFC PATCH v3 1/4] drm/doc: Document DRM device reset expectations Date: Tue, 20 Jun 2023 21:57:16 -0300 Message-ID: <20230621005719.836857-2-andrealmeid@igalia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230621005719.836857-1-andrealmeid@igalia.com> References: <20230621005719.836857-1-andrealmeid@igalia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Create a section that specifies how to deal with DRM device resets for kernel and userspace drivers. Signed-off-by: Andr=C3=A9 Almeida --- Documentation/gpu/drm-uapi.rst | 65 ++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst index 65fb3036a580..da4f8a694d8d 100644 --- a/Documentation/gpu/drm-uapi.rst +++ b/Documentation/gpu/drm-uapi.rst @@ -285,6 +285,71 @@ for GPU1 and GPU2 from different vendors, and a third = handler for mmapped regular files. Threads cause additional pain with signal handling as well. =20 +Device reset +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The GPU stack is really complex and is prone to errors, from hardware bugs, +faulty applications and everything in between the many layers. To recover +from this kind of state, sometimes is needed to reset the device. This sec= tion +describes what's the expectations for DRM and usermode drivers when a devi= ce +resets and how to propagate the reset status. + +Kernel Mode Driver +------------------ + +The KMD is responsible for checking if the device needs a reset, and to pe= rform +it as needed. Usually a hung is detected when a job gets stuck executing. = KMD +then update it's internal reset tracking to be ready when userspace asks t= he +kernel about reset information. Drivers should implement the DRM_IOCTL_GET= _RESET +for that. + +User Mode Driver +---------------- + +The UMD should check before submitting new commands to the KMD if the devi= ce has +been reset, and this can be checked more often if it requires to. The +DRM_IOCTL_GET_RESET is the default interface for those kind of checks. Aft= er +detecting a reset, UMD will then proceed to report it to the application u= sing +the appropriated API error code, as explained in the bellow section about +robustness. + +Robustness +---------- + +The only way to try to keep an application working after a reset is if it +complies with the robustness aspects of the graphical API that is using. + +Graphical APIs provide ways to application to deal with device resets. How= ever, +there's no guarantee that the app will be correctly using such features, a= nd UMD +can implement policies to close the app if it's a repeating offender, like= ly in +a broken loop. This is done to ensure that it doesn't keeps blocking the u= ser +interface to be correctly displayed. + +OpenGL +~~~~~~ + +Apps using OpenGL can rely on ``GL_ARB_robustness`` to be robust. This ext= ension +tells if a reset has happened, and if so, all the context state is conside= red +lost and the app proceeds by creating new ones. If robustness isn't in use= , UMD +will terminate the app when a reset is detected, giving that the contexts = are +lost and the app won't be able to figure this out and recreate the context= s. + +Vulkan +~~~~~~ + +Apps using Vulkan should check for ``VK_ERROR_DEVICE_LOST`` for submission= s. +This error code means, among other things, that a device reset has happene= d and +it needs to recreate the contexts to keep going. + +Reporting resets causes +----------------------- + +Apart from propagating the reset through the stack so apps can recover, it= 's +really useful for driver developers to learn more about what caused the re= set in +first place. DRM devices should make use of devcoredump to store relevant +information about the reset, so this information can be added to user bug +reports. + .. _drm_driver_ioctl: =20 IOCTL Support on Device Nodes --=20 2.41.0