From patchwork Mon Jan 23 20:26:46 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: 47376 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1804237wrn; Mon, 23 Jan 2023 12:36:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXvR9Eoz6JZTWkVt1VdhboHti1v8f2P3NzFMId1BnwDH0OY3AeA5ZeXY8NsBA9gHajCUKBXV X-Received: by 2002:a17:902:ce8f:b0:195:f3e6:ab9f with SMTP id f15-20020a170902ce8f00b00195f3e6ab9fmr14586864plg.51.1674506176937; Mon, 23 Jan 2023 12:36:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674506176; cv=none; d=google.com; s=arc-20160816; b=kI1i3w17rvL2r48Pn3zfsdXcumzUUibUV7Q3/7XvQx1eM3ykUEccpttwE0NpPbudQE Etj8yfTJSZnIMlt1gTKc1uYVwjIfMHs9CUqEdDDz5yKSviD/AVTTk5asPHfwgl/YaGdV sa2ke/KcEBrzZ92AiBExPdwYjkLYMEpsg1EUUbVe28WatbzPdEvdKbX2miEj+hZceuEs kD4nZuXYnNlcIF/2KlzOeR/Ha5WdqhcnJQc7jPBaM/7KMRAmxNhXIGBKydCCPa0fwa7o xPsAg1nf/v3KMFLIicUbl9csm5/p4F16BeWdL45k46M8Yt5IEHz+985QC0esUWJ3h9Kn vaVA== 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=7CaXIdoI8n3ZxHPPdx/samyORw/Wg8sXLQapZ/RBkNE=; b=fEqks48F8XXWPbLvNsd/Qc1yfBdqHuXDzOBueTsBpHsUc/KCLRqj9mD65yw78+7Goq CBWrhOqdG9hnbdI8VQQ7euaufA/O9YAm5DXdwxsno3eFY2NrLPcopXut4mQATRH9IHGC 3SjgiFBtC1/carbuYwqg8XZe+gpWXSU4s28yA9odgv/jRcuc6oKteVXelPTr8xM4+1UI PzcQnRVe8DipgcuRE8FDdrUQO89vMjWSNO2CNGLVXao6DaKoxbEbq0Qw2iPoxf9ozdu0 3XKxJQlXxXnheqOw1jmSv9VDTo+Rwqv4kx59Pl4YeQgzhcamau3UMulEBt+eT9BYoWtZ E2qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=fCiKDcxt; 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 19-20020a170902ee5300b001931fce6511si287600plo.374.2023.01.23.12.36.04; Mon, 23 Jan 2023 12:36:16 -0800 (PST) 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=fCiKDcxt; 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 S232338AbjAWU1u (ORCPT + 99 others); Mon, 23 Jan 2023 15:27:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232204AbjAWU1s (ORCPT ); Mon, 23 Jan 2023 15:27:48 -0500 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FFDF210F for ; Mon, 23 Jan 2023 12:27:47 -0800 (PST) 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=7CaXIdoI8n3ZxHPPdx/samyORw/Wg8sXLQapZ/RBkNE=; b=fCiKDcxtbjDgmimIhRvRxngTgb 85ecoNKuvlffUrBzca6OUqFTCOLG0GS7Y/xSl3W/9hbE+t0B2gyqmJSYiQuk2LBwWEegoZ3e1Beyv xgJQf92lfA0BDtJdh3VXEeAxhCTdb0SiB9pBHldjMxitNCo+e34ZQXEWuVcZ4CCgM4vOBcvQYSIhW biBOMXlXcpU/lrG4Mtc3zEEXRurpxjeAYqCxY5cs/Dp9scqHc3FsoQLXbr7lS2AIQfZTUxUN1f9wV qm1N6tVbRNqHdsnV/TnFYpgiZceWEIwPCtUflMN62LJnBvC709vFP0uHsyDCThSSeWu6mrVSc4kBS ACFvJknQ==; Received: from [177.102.82.39] (helo=steammachine.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pK3Pt-00GEfP-7R; Mon, 23 Jan 2023 21:27:45 +0100 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, contactshashanksharma@gmail.com, amaranath.somalapuram@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 , "Pierre-Loup A . Griffais" , =?utf-8?q?Andr?= =?utf-8?q?=C3=A9_Almeida?= Subject: [RFC PATCH] drm: Create documentation about device resets Date: Mon, 23 Jan 2023 17:26:46 -0300 Message-Id: <20230123202646.356592-2-andrealmeid@igalia.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230123202646.356592-1-andrealmeid@igalia.com> References: <20230123202646.356592-1-andrealmeid@igalia.com> 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 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?1755846988945048377?= X-GMAIL-MSGID: =?utf-8?q?1755846988945048377?= Create a document that specifies how to deal with DRM device resets for kernel and userspace drivers. Signed-off-by: André Almeida --- Documentation/gpu/drm-reset.rst | 51 +++++++++++++++++++++++++++++++++ Documentation/gpu/index.rst | 1 + 2 files changed, 52 insertions(+) create mode 100644 Documentation/gpu/drm-reset.rst diff --git a/Documentation/gpu/drm-reset.rst b/Documentation/gpu/drm-reset.rst new file mode 100644 index 000000000000..0dd11a469cf9 --- /dev/null +++ b/Documentation/gpu/drm-reset.rst @@ -0,0 +1,51 @@ +================ +DRM Device Reset +================ + +The GPU stack is really complex and is prone to errors, from hardware bugs, +faulty applications and everything in the many layers in between. To recover +from this kind of state, sometimes is needed to reset the GPU. Unproper handling +of GPU resets can lead to an unstable userspace. This page describes what's the +expected behaviour from DRM drivers to do in those situations, from usermode +drivers and compositors as well. + +Robustness +---------- + +First of all, application robust APIs, when available, should be used. This +allows the application to correctly recover and continue to run after a reset. +Apps that doesn't use this should be promptly killed when the kernel driver +detects that it's in broken state. Specifically guidelines for some APIs: + +- OpenGL: During a reset, KMD kill processes that haven't ARB Robustness + enabled, assuming they can't recover. +- Vulkan: Assumes that every app is able to deal with ``VK_ERROR_DEVICE_LOST``, + so KMD doesn't kill any. If it doesn't do it right, it's considered a broken + application and UMD will deal with it. + +Kernel mode driver +------------------ + +The KMD should be able to detect that something is wrong with the application +and that a reset is needed to take place to recover the device (e.g. an endless +wait). It needs to properly track the context that is broken and mark it as +dead, so any other syscalls to that context should be further rejected. The +other contexts should be preserved when possible, avoid crashing the rest of +userspace. KMD can ban a file descriptor that keeps causing resets, as it's +likely in a broken loop. + +User mode driver +---------------- + +During a reset, UMD should be aware that rejected syscalls indicates that the +context is broken and for robust apps the recovery should happen for the +context. Non-robust apps would be already terminated by KMD. If no new context +is created for some time, it is assumed that the recovery didn't work, so UMD +should terminate it. + +Compositors +----------- + +(In the long term) compositors should be robust as well to properly deal with it +errors. Init systems should be aware of the compositor status and reset it if is +broken. diff --git a/Documentation/gpu/index.rst b/Documentation/gpu/index.rst index b99dede9a5b1..300b2529bd39 100644 --- a/Documentation/gpu/index.rst +++ b/Documentation/gpu/index.rst @@ -9,6 +9,7 @@ Linux GPU Driver Developer's Guide drm-mm drm-kms drm-kms-helpers + drm-reset drm-uapi drm-usage-stats driver-uapi