Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp8640954rwd; Tue, 20 Jun 2023 18:51:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5oXlFWTwuRn8b/lc9mRdmG6CiHzUChDDKtr6UYc/jSFROc52leEaaDgoeTCwj7Smw2H3xh X-Received: by 2002:a05:6358:417:b0:127:f2f6:ef35 with SMTP id 23-20020a056358041700b00127f2f6ef35mr7529322rwd.3.1687312316490; Tue, 20 Jun 2023 18:51:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687312316; cv=none; d=google.com; s=arc-20160816; b=JQ9YCsQ0n6WfXJUfiyKK89pXIpy8NlTotO47WNkNP30IbNr8ukVYbmktvuqsYgBnap NpXU9FgS6pMwJdQZjEb8gwZYBYUchFI0XOUsFCVB3IqhgT0qDFKSVRwfUFBuNa4d0ro5 ZqVfC1GMqvQA0h4akX5EkFSweSERvtTRKZd5Dw8ZKYGiMSmg9XFD5sj5DqdMyWYlBILY NPmjSXruYnEF+0GPS/C0E4brPXBEcuIzBFmmoK6s6g+CpE5qiBKXO9KJxaP2H8anhn0Q 79Imy/Cymjk6F+HjJuLVrTnGDxGc5dVtI58h9lw1Zx7Drthj1u+1O7Cyl2w33Hzcfu8o g4Dg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/U+iXS7cPu32eSBwTnxjvnLVI4LNUEgzC2fiTpf+640=; b=tY8SArujaMLRKpMIeOvPYebG02oaa4oxAiUmLiSJfY0prPn9eDHwyhe+FKBiiU+icg wACouDSXDE3idwC2wnZnWJgSW0m+OjWVn6CcBeAoQ48pX4S6hkYqxxfcMKf2oXlU5QQH tkwGMeVNXLVCICQMmsw+/ZzU4sAOTjkuLDbfqy8IoMsOTC6iSNrI18/S5J6AamGXselY Y5NgAhAnLDHqkvDJqEQTTIxQim+eE1faVd+n0HnaNopeZDENzN1luzE4JEBbXMn46taz 1PFz5naX3t/cdcqvpE9MBFhUs9sbs3FSespO6ucEM5Dr7ST7S/GMA3uyrhah7qFE9+ED 6jsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=ViYBsyZd; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r26-20020aa79eda000000b00655079704afsi2974520pfq.119.2023.06.20.18.51.42; Tue, 20 Jun 2023 18:51:56 -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=ViYBsyZd; 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 S229870AbjFUA6g (ORCPT + 99 others); Tue, 20 Jun 2023 20:58:36 -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: 8bit 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 Create a section that specifies how to deal with DRM device resets for kernel and userspace drivers. Signed-off-by: André 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. +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. To recover +from this kind of state, sometimes is needed to reset the device. This section +describes what's 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 hung is detected when a job gets stuck executing. KMD +then update it's internal reset tracking to be ready when userspace asks the +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 device 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. After +detecting a reset, UMD will then proceed to report it to the application using +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. However, +there's no guarantee that the app will be correctly using such features, and UMD +can implement policies to close the app if it's a repeating offender, likely in +a broken loop. This is done to ensure that it doesn't keeps blocking the user +interface to be correctly displayed. + +OpenGL +~~~~~~ + +Apps using OpenGL can rely on ``GL_ARB_robustness`` to be robust. This extension +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 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 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 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 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 -- 2.41.0