drm/doc: Document DRM device reset expectations
Subsystems (3)
v4 cover drm/doc: Document DRM device reset expectations
This v4 removes the common DRM ioctl, and adds just the documentation for now, giving the lack of a common "DRM context" infrascture make it hard to implement.
v3: https://lore.kernel.org/lkml/[email protected]/
Changes:
- Drop the ioctl
- Addresed comments com Pekka, as making the documentation more clear and consistent.
André Almeida (1):
drm/doc: Document DRM device reset expectations
Documentation/gpu/drm-uapi.rst | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)
Signature · 1 line
2.41.0
PATCH v4 1/1 drm/doc: Document DRM device reset expectations
Create a section that specifies how to deal with DRM device resets for kernel and userspace drivers.
--- Documentation/gpu/drm-uapi.rst | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)
Documentation/gpu/drm-uapi.rst +68 -0
@@ -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 +section describes what is 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 it requires to. After +detecting a reset, UMD will then proceed to report it to the application using +the appropriated API error code, as explained in the below 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 it is using. + +Graphical APIs provide ways to application to deal with device resets. However, +there is no guarantee that the app will be correctly using such features, and +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 keeps 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 is possible to +determine that robustness is not 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
Signature · 1 line
2.41.0
Randy Dunlap
reviewerHi,
Quoted 13 lines · André Almeida
Create a section that specifies how to deal with DRM device resets for kernel and userspace drivers.
Signed-off-by André Almeida <[email protected]>--- Documentation/gpu/drm-uapi.rst | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)Documentation/gpu/drm-uapi.rst +0
-0
Documentation/gpu/drm-uapi.rst for GPU1 and GPU2 from different vendors, and a third handler for · line 294
Quoted 10 lines
Documentation/gpu/drm-uapi.rst +7
-0@@ -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 +section describes what is the expectations for DRM and usermode drivers when a
sections describes the expectations for DRM and usermode drivers when a
Quoted 7 lines
Documentation/gpu/drm-uapi.rst +7
-0+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
Documentation/gpu/drm-uapi.rst for GPU1 and GPU2 from different vendors, and a third handler for · line 311
Quoted 10 lines
Documentation/gpu/drm-uapi.rst +10
-0+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 it requires to. After
more often if the UMD requires it. After
Documentation/gpu/drm-uapi.rst for GPU1 and GPU2 from different vendors, and a third handler for · line 313
Quoted 2 lines
Documentation/gpu/drm-uapi.rst +2
-0+detecting a reset, UMD will then proceed to report it to the application using +the appropriated API error code, as explained in the below section about
appropriate the section below about
Documentation/gpu/drm-uapi.rst for GPU1 and GPU2 from different vendors, and a third handler for · line 322
Quoted 9 lines
Documentation/gpu/drm-uapi.rst +9
-0+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 application to deal with device resets. However,
to applications
Documentation/gpu/drm-uapi.rst for GPU1 and GPU2 from different vendors, and a third handler for · line 323
Quoted 1 line
Documentation/gpu/drm-uapi.rst +1
-0+there is no guarantee that the app will be correctly using such features, and
will use such features correctly, and a // or "and the"
Documentation/gpu/drm-uapi.rst for GPU1 and GPU2 from different vendors, and a third handler for · line 325
Quoted 2 lines
Documentation/gpu/drm-uapi.rst +2
-0+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 keeps blocking
keep
Documentation/gpu/drm-uapi.rst for GPU1 and GPU2 from different vendors, and a third handler for · line 335
Quoted 10 lines
Documentation/gpu/drm-uapi.rst +10
-0+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 is possible to
If it is possible to
Documentation/gpu/drm-uapi.rst for GPU1 and GPU2 from different vendors, and a third handler for · line 336
Quoted 1 line
Documentation/gpu/drm-uapi.rst +1
-0+determine that robustness is not in use, UMD will terminate the app when a reset
the UMD
Documentation/gpu/drm-uapi.rst for GPU1 and GPU2 from different vendors, and a third handler for · line 347
Quoted 11 lines
Documentation/gpu/drm-uapi.rst +11
-0+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
That's an awkward heading. How about:
Reporting causes of resets
--------------------------
Documentation/gpu/drm-uapi.rst for GPU1 and GPU2 from different vendors, and a third handler for · line 358
Quoted 11 lines
Documentation/gpu/drm-uapi.rst +8
-0+----------------------- + +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
thanks for the documentation.
Signature · 1 line
~Randy
Quoted 7 lines · On Mon, 26 Jun 2023 15:33:47 -0300 André Almeida <[email protected]> wrote:
Create a section that specifies how to deal with DRM device resets for kernel and userspace drivers.
Signed-off-by André Almeida <[email protected]>--- Documentation/gpu/drm-uapi.rst | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)
Hi,
grammar nitpicks notwithstanding, I'm happy with the contents now, so
Thanks,
pq
Quoted 80 lines
Documentation/gpu/drm-uapi.rst +68
-0@@ -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 +section describes what is 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 it requires to. After +detecting a reset, UMD will then proceed to report it to the application using +the appropriated API error code, as explained in the below 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 it is using. + +Graphical APIs provide ways to application to deal with device resets. However, +there is no guarantee that the app will be correctly using such features, and +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 keeps 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 is possible to +determine that robustness is not 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