The OpenGL robustness extensions (GL_KHR_robustness) and Vulkan (VK_ERROR_DEVICE_LOST) let an application detect a GPU reset and check whether its own context caused it, so it can throw away the broken context and build a new one. etnaviv already resets the GPU after a hang, but userspace has no way to learn about it.
This series adds two counters, exposed through GET_PARAM, following the model already used by msm and v3d: - ETNAVIV_PARAM_GLOBAL_RESET_COUNTER counts every reset of a GPU core. - ETNAVIV_PARAM_CONTEXT_RESET_COUNTER counts only the resets the calling context was guilty of. Userspace samples both values and compares them later: if the context counter moved the context was guilty, if only the global counter moved the context was an innocent victim. That is all that is needed to implement glGetGraphicsResetStatus() and Vulkan device loss. The global counter is kept per GPU core and not per device, so a hang on one pipe does not look like an innocent reset to contexts that only use another pipe. The first patch is preparation: the counters are updated from the scheduler timeout worker, which can race with the DRM file being closed, so struct etnaviv_file_private becomes reference counted and every submit holds a reference. Link to the Mesa MR implementing the userspace side: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42826 Signed-off-by: Christian Gmeiner <[email protected]> --- Christian Gmeiner (2): drm/etnaviv: Reference count struct etnaviv_file_private drm/etnaviv: Add GPU reset counters drivers/gpu/drm/etnaviv/etnaviv_drv.c | 22 +++++++++++++++++++--- drivers/gpu/drm/etnaviv/etnaviv_drv.h | 12 ++++++++++++ drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 5 ++++- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 12 +++++++++++- drivers/gpu/drm/etnaviv/etnaviv_gpu.h | 6 +++++- drivers/gpu/drm/etnaviv/etnaviv_sched.c | 3 +++ include/uapi/drm/etnaviv_drm.h | 2 ++ 7 files changed, 56 insertions(+), 6 deletions(-) --- base-commit: 8cdeaa50eae8dad34885515f62559ee83e7e8dda change-id: 20260708-etnaviv-reset-notification-b037153a1aab Best regards, -- Christian Gmeiner <[email protected]>
