From: Pekka Paalanen <ppaalanen@gmail.com>
To: "André Almeida" <andrealmeid@igalia.com>
Cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
linux-kernel@vger.kernel.org, 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" <contact@emersion.fr>,
"Rob Clark" <robdclark@gmail.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
"Daniel Stone" <daniel@fooishbar.org>,
"Marek Olšák" <maraeo@gmail.com>,
"Dave Airlie" <airlied@gmail.com>
Subject: Re: [PATCH v2 1/1] drm/doc: Document DRM device reset expectations
Date: Tue, 28 Feb 2023 12:02:01 +0200 [thread overview]
Message-ID: <20230228120201.7b20519a@eldfell> (raw)
In-Reply-To: <20230227204000.56787-2-andrealmeid@igalia.com>
[-- Attachment #1: Type: text/plain, Size: 5068 bytes --]
On Mon, 27 Feb 2023 15:40:00 -0500
André Almeida <andrealmeid@igalia.com> wrote:
> Create a section that specifies how to deal with DRM device resets for
> kernel and userspace drivers.
>
> Signed-off-by: André Almeida <andrealmeid@igalia.com>
> ---
> Documentation/gpu/drm-uapi.rst | 51 ++++++++++++++++++++++++++++++++++
> 1 file changed, 51 insertions(+)
>
> diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst
> index 65fb3036a580..3d6c3ed392ea 100644
> --- a/Documentation/gpu/drm-uapi.rst
> +++ b/Documentation/gpu/drm-uapi.rst
> @@ -285,6 +285,57 @@ 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 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 section describes what's
> +the expected behaviour from DRM drivers to do in those situations, from usermode
> +drivers and compositors as well. The end goal is to have a seamless experience
> +as possible, either the stack being able to recover itself or resetting to a new
> +stable state.
> +
> +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:
Hi,
the "kill" wording is still here. It feels too harsh to me, like I say
in my comments below, but let's see what others think.
Even the device hot-unplug guide above this does not call for killing
anything and is prepared for userspace to keep going indefinitely if
userspace is broken enough.
> +
> +- OpenGL: KMD signals the abortion of submitted commands and the UMD should then
> + react accordingly and abort the application.
No, not abort. Just return failures and make sure no API call will
block indefinitely.
> +
> +- Vulkan: Assumes that every app is able to deal with ``VK_ERROR_DEVICE_LOST``.
> + If it doesn't do it right, it's considered a broken application and UMD will
> + deal with it, aborting it.
Is it even possible to detect if an app does it right?
What if the app does do it right, but not before it attempts to hammer
a few more jobs in?
> +
> +Kernel mode driver
> +------------------
> +
> +The KMD must 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.
If userspace is in a broken loop repeatedly causing GPU reset, would it
keep using the same (render node) fd? To me it would be more likely to
close the fd and open a new one, then crash again. Robust or not, the
gfx library API would probably require tearing everything down and
starting from scratch. In fact, only robust apps would likely exhibit
this behaviour, and non-robust just get stuck or quit themselves.
I suppose in e.g. EGL, it is possible to just create a new context
instead of a new EGLDisplay, so both re-using and not using the old fd
are possible.
The process identity would usually remain, I believe, except in cases
like Chromium with its separate rendering processes, but then, would
you really want to ban whole Chromium in that case...
> +
Another thing for the kernel mode driver maybe worth mentioning is that
the driver could also pretend a hot-unplug if the GPU crash is so bad
that everything is at risk being lost or corrupted.
> +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 must be terminated.
I think the termination thing probably needs to be much more nuanced,
and also interact with the repeat-offender policy.
Repeat-offender policy could be implemented in userspace too,
especially if userspace keeps using the same device fd which is likely
hidden by the gfx API.
> +
> +Compositors
> +-----------
> +
> +Compositors should be robust as well to properly deal with its errors.
What is the worth of this note? To me as a compositor developer it is
obvious.
Thanks,
pq
> +
> +
> .. _drm_driver_ioctl:
>
> IOCTL Support on Device Nodes
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-02-28 10:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-27 20:39 [PATCH v2 0/1] drm: Add doc about GPU reset André Almeida
2023-02-27 20:40 ` [PATCH v2 1/1] drm/doc: Document DRM device reset expectations André Almeida
2023-02-28 10:02 ` Pekka Paalanen [this message]
2023-02-28 15:26 ` André Almeida
2023-03-01 8:47 ` Pekka Paalanen
2023-02-28 17:20 ` Rob Clark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230228120201.7b20519a@eldfell \
--to=ppaalanen@gmail.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amaranath.somalapuram@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=andrealmeid@igalia.com \
--cc=christian.koenig@amd.com \
--cc=contact@emersion.fr \
--cc=contactshashanksharma@gmail.com \
--cc=daniel@ffwll.ch \
--cc=daniel@fooishbar.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-dev@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maraeo@gmail.com \
--cc=pierre-eric.pelloux-prayer@amd.com \
--cc=robdclark@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox