mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: "André Almeida" <andrealmeid@igalia.com>,
	dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Cc: pierre-eric.pelloux-prayer@amd.com,
	"Sebastian Wick" <sebastian.wick@redhat.com>,
	"Randy Dunlap" <rdunlap@infradead.org>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Marek Olšák" <maraeo@gmail.com>,
	"Michel Dänzer" <michel.daenzer@mailbox.org>,
	"Simon Ser" <contact@emersion.fr>,
	amaranath.somalapuram@amd.com,
	"Pekka Paalanen" <ppaalanen@gmail.com>,
	"Daniel Stone" <daniel@fooishbar.org>,
	"Rob Clark" <robdclark@gmail.com>,
	kernel-dev@igalia.com, "Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	alexander.deucher@amd.com,
	"Pekka Paalanen" <pekka.paalanen@collabora.com>,
	contactshashanksharma@gmail.com,
	"Dave Airlie" <airlied@gmail.com>,
	christian.koenig@amd.com
Subject: Re: [PATCH v8] drm/doc: Document DRM device reset expectations
Date: Fri, 29 Sep 2023 12:32:22 +0200	[thread overview]
Message-ID: <6c937706-d171-817d-806f-602a939d5cb3@gmail.com> (raw)
In-Reply-To: <20230929092509.42042-1-andrealmeid@igalia.com>

Am 29.09.23 um 11:25 schrieb André Almeida:
> Create a section that specifies how to deal with DRM device resets for
> kernel and userspace drivers.
>
> Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
> Acked-by: Sebastian Wick <sebastian.wick@redhat.com>
> Signed-off-by: André Almeida <andrealmeid@igalia.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

I think that is now ready to be pushed. Do you have commit rights to 
drm-misc-next? If not please ping me.

Regards,
Christian.

> ---
> v8 changes:
> - Add acked-by tags
>
> v7: https://lore.kernel.org/dri-devel/20230818200642.276735-1-andrealmeid@igalia.com/
>
> v7 changes:
>   - s/application/graphical API contex/ in the robustness part (Michel)
>   - Grammar fixes (Randy)
>
> v6: https://lore.kernel.org/lkml/20230815185710.159779-1-andrealmeid@igalia.com/
>
> v6 changes:
>   - Due to substantial changes in the content, dropped Pekka's Acked-by
>   - Grammar fixes (Randy)
>   - Add paragraph about disabling device resets
>   - Add note about integrating reset tracking in drm/sched
>   - Add note that KMD should return failure for contexts affected by
>     resets and UMD should check for this
>   - Add note about lack of consensus around what to do about non-robust
>     apps
>
> v5: https://lore.kernel.org/dri-devel/20230627132323.115440-1-andrealmeid@igalia.com/
> ---
>   Documentation/gpu/drm-uapi.rst | 77 ++++++++++++++++++++++++++++++++++
>   1 file changed, 77 insertions(+)
>
> diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst
> index eef5fd19bc92..632989df3727 100644
> --- a/Documentation/gpu/drm-uapi.rst
> +++ b/Documentation/gpu/drm-uapi.rst
> @@ -285,6 +285,83 @@ 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
> +section describes the expectations for DRM and usermode drivers when a
> +device resets and how to propagate the reset status.
> +
> +Device resets can not be disabled without tainting the kernel, which can lead to
> +hanging the entire kernel through shrinkers/mmu_notifiers. Userspace role in
> +device resets is to propagate the message to the application and apply any
> +special policy for blocking guilty applications, if any. Corollary is that
> +debugging a hung GPU context require hardware support to be able to preempt such
> +a GPU context while it's stopped.
> +
> +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 status for a 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. Ideally this should be properly
> +integrated at DRM scheduler to provide a common ground for all drivers. After a
> +reset, KMD should reject new command submissions for affected contexts.
> +
> +User Mode Driver
> +----------------
> +
> +After command submission, UMD should check if the submission was accepted or
> +rejected. After a reset, KMD should reject submissions, and UMD can issue an
> +ioctl to the KMD to check the reset status, 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 a graphical API context 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 a
> +userspace that doesn't support robust interfaces (like a non-robust
> +OpenGL context or API without any robustness support like libva) leave the
> +robustness handling entirely to the userspace driver. There is no strong
> +community consensus on what the userspace driver should do in that case,
> +since all reasonable approaches have some clear downsides.
> +
> +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. There's no consensus
> +on what to do to if robustness is not in use.
> +
> +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
> +the 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


      reply	other threads:[~2023-09-29 10:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-29  9:25 André Almeida
2023-09-29 10:32 ` Christian König [this message]

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=6c937706-d171-817d-806f-602a939d5cb3@gmail.com \
    --to=ckoenig.leichtzumerken@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=michel.daenzer@mailbox.org \
    --cc=pekka.paalanen@collabora.com \
    --cc=pierre-eric.pelloux-prayer@amd.com \
    --cc=ppaalanen@gmail.com \
    --cc=rdunlap@infradead.org \
    --cc=robdclark@gmail.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=sebastian.wick@redhat.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

all inboxes | Powered by JetHome®