From patchwork Tue Jun 27 13:23:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 113434 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8207425vqr; Tue, 27 Jun 2023 06:43:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zqCPrIbp5DSrCPROeizh6EpmUBcfHd4FfyIn2G9sHtgLrffxq5hD4w6qCsyqA/xqiC1nO X-Received: by 2002:a2e:8644:0:b0:2b6:364:c153 with SMTP id i4-20020a2e8644000000b002b60364c153mr5904850ljj.14.1687873423130; Tue, 27 Jun 2023 06:43:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687873423; cv=none; d=google.com; s=arc-20160816; b=ey37WiQE8/vrFVU7XIyViD4vyLMMYW5PwrY2gTDpg0oxTUKYD7e0fiCgUUpYdAntjQ fneR0gqPQZji+kPjgRD7LOi5OoZ9HxjCAXhxztj/wPQCTE2XElqIat2VqnaesD/hNBGT D9ZA99IuktCGo006IHVyD87cpmaIkU54FI8D1w7t3XlnwVNX/1QfKyHlGORUafCx7gWa 99+b7XajtPuqXdTMXhH+GPxPpsSpYl9cSGECA/l8f8mr6kAlTfDsid/w8p29raxf+Z+h w4YD6XT3suMC35Ir2ZwLhnekqCFbuuUBcy+xZalMkC0Zp4ZQtlnnunHZ2q/b23MQiVH7 UjXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=XXhdTWoMk14blpQJORYtPE+5yfyz5ZqdWBj8yIkLzts=; fh=jTIhVy10tIr8dre1sB+LuCufIvDXfqSOFF9O76J9MdQ=; b=KUzdh2/Hogt6hxPVrBGGJMPUcVgI3yJGHF6T7To65grpL3nn2v0J7WlSHZ/kfuslko 2tWDdjWgkbwvKeDU8wpOXHmOPB6d3ckmjkn7yolzU4F8ppwajJi8Of90oujuNIV32+WA OauLwVsNxL2ouAQvPpBxmJWSKRPWBns2hdbl4uy0sk82RpFZlKze1HyuPgBYmiPkuSkQ Fck2PWJe1u6KI2FychZ/R4MCruLutcov+75yGnS8t4M0050v/UBV+b3Wju6sQbrfYT0G Rlq1DFrO6367TBEcVyztrF0MwT+o9+k8Q9rPOq7sx02O7/QdEcWeXPSOGrn1UjOxl8du f1lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b="GVtsM/JA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s13-20020a170906354d00b0098e38b3b7e3si3226283eja.793.2023.06.27.06.43.18; Tue, 27 Jun 2023 06:43:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b="GVtsM/JA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229987AbjF0NYH (ORCPT + 99 others); Tue, 27 Jun 2023 09:24:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbjF0NXl (ORCPT ); Tue, 27 Jun 2023 09:23:41 -0400 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDDE1199C for ; Tue, 27 Jun 2023 06:23:38 -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: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: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=XXhdTWoMk14blpQJORYtPE+5yfyz5ZqdWBj8yIkLzts=; b=GVtsM/JAeN+WVIVK5y8d9+UwbL vQvr+6+K0y1KIV1qun0KL0TPobxoP4ch9FaLw2AcFV+RiUHM4eUbU2aJOAEHPs6lTnlI/UGB3x9Q0 uHSyXWF1fI9dwNyrB+U5o8H4JRk7ajOxpvMdqI0gF++zcTN4Y06KyLNyKTRwz1v5Mh/IiapsMswEf UNJtlpWufkEyzBNENgpCLTvPOgiWgj6MZA6/9VJVumIeeElrAEoFV+Gs5PR0lToOPlshD0/SkVCpu 7t5eMnMIKmw5ryXFHhP6kjt7TigQ9cxnS0I55bG3WO+68FWUhmlpRbIpvTxGdHdEnwvk0f8V3IV9v DQ5bGx5A==; 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 1qE8fM-004Yyb-Bb; Tue, 27 Jun 2023 15:23:32 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= 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?b?J01hcmVrIE9sxaHDoWsn?= , Dave Airlie , =?utf-8?q?Michel_D=C3=A4nzer?= , Samuel Pitoiset , =?utf-8?q?Timur_Krist=C3=B3f?= , Bas Nieuwenhuizen , Randy Dunlap , =?utf-8?q?Andr=C3=A9_Almeida?= , Pekka Paalanen Subject: [PATCH v5 1/1] drm/doc: Document DRM device reset expectations Date: Tue, 27 Jun 2023 10:23:23 -0300 Message-ID: <20230627132323.115440-1-andrealmeid@igalia.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769863562427205736?= X-GMAIL-MSGID: =?utf-8?q?1769863562427205736?= Create a section that specifies how to deal with DRM device resets for kernel and userspace drivers. Acked-by: Pekka Paalanen Signed-off-by: André Almeida Reviewed-by: Randy Dunlap Acked-by: Daniel Vetter --- v4: https://lore.kernel.org/lkml/20230626183347.55118-1-andrealmeid@igalia.com/ Changes: - Grammar fixes (Randy) Documentation/gpu/drm-uapi.rst | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst index 65fb3036a580..3cbffa25ed93 100644 --- a/Documentation/gpu/drm-uapi.rst +++ b/Documentation/gpu/drm-uapi.rst @@ -285,6 +285,74 @@ for GPU1 and GPU2 from different vendors, and a third handler for mmapped regular files. Threads cause additional pain with signal handling as well. +Device reset +============ + +The GPU stack is really complex and is prone to errors, from hardware bugs, +faulty applications and everything in between the many layers. Some errors +require resetting the device in order to make the device usable again. This +sections describes the expectations for DRM and usermode drivers when a +device 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 perform +it as needed. Usually a hang is detected when a job gets stuck executing. KMD +should keep track of resets, because userspace can query any time about the +reset stats for an specific context. This is needed to propagate to the rest of +the stack that a reset has happened. Currently, this is implemented by each +driver separately, with no common DRM interface. + +User Mode Driver +---------------- + +The UMD should check before submitting new commands to the KMD if the device has +been reset, and this can be checked more often if the UMD requires it. After +detecting a reset, UMD will then proceed to report it to the application using +the appropriate API error code, as explained in the section below 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 it is using. + +Graphical APIs provide ways to applications to deal with device resets. However, +there is no guarantee that the app will use such features correctly, and the +UMD can implement policies to close the app if it is a repeating offender, +likely in a broken loop. This is done to ensure that it does not keep blocking +the user interface from being correctly displayed. This should be done even if +the app is correct but happens to trigger some bug in the hardware/driver. + +OpenGL +~~~~~~ + +Apps using OpenGL should use the available robust interfaces, like the +extension ``GL_ARB_robustness`` (or ``GL_EXT_robustness`` for OpenGL ES). This +interface tells if a reset has happened, and if so, all the context state is +considered lost and the app proceeds by creating new ones. If it is possible to +determine that robustness is not in use, the 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 contexts. + +Vulkan +~~~~~~ + +Apps using Vulkan should check for ``VK_ERROR_DEVICE_LOST`` for submissions. +This error code means, among other things, that a device reset has happened and +it needs to recreate the contexts to keep going. + +Reporting causes of resets +-------------------------- + +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 reset 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: IOCTL Support on Device Nodes