From 7aff6beb37c91df85c46372d44ae4a5fefae5ae8 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 1 Jul 2013 17:57:49 +0100 Subject: [PATCH] sna: Improve the message about where to find the hang state Search the few canonical locations for our hang state so that we can be more explicit to the user about what to include. Signed-off-by: Chris Wilson --- src/sna/kgem.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/sna/kgem.c b/src/sna/kgem.c index aadc5f23..e905f209 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -2833,6 +2833,32 @@ void _kgem_submit(struct kgem *kgem) assert(kgem->next_request != NULL); } +static void find_hang_state(struct kgem *kgem, char *path, int maxlen) +{ + int i; + + /* Search for our hang state in a few canonical locations. + * In the unlikely event of having multiple devices, we + * will need to check which minor actually corresponds to ours. + */ + + for (i = 0; i < DRM_MAX_MINOR; i++) { + snprintf(path, maxlen, "/sys/class/drm/card%d/error", i); + if (access(path, R_OK) == 0) + return; + + snprintf(path, maxlen, "/sys/kernel/debug/dri%d/i915_error_state", i); + if (access(path, R_OK) == 0) + return; + + snprintf(path, maxlen, "/debug/dri%d/i915_error_state", i); + if (access(path, R_OK) == 0) + return; + } + + path[0] = '\0'; +} + void kgem_throttle(struct kgem *kgem) { kgem->need_throttle = 0; @@ -2841,10 +2867,16 @@ void kgem_throttle(struct kgem *kgem) kgem->wedged = __kgem_throttle(kgem); if (kgem->wedged) { + char path[128]; + + find_hang_state(kgem, path, sizeof(path)); + xf86DrvMsg(kgem_get_screen_index(kgem), X_ERROR, "Detected a hung GPU, disabling acceleration.\n"); - xf86DrvMsg(kgem_get_screen_index(kgem), X_ERROR, - "When reporting this, please include i915_error_state from debugfs and the full dmesg.\n"); + if (*path != '\0') + xf86DrvMsg(kgem_get_screen_index(kgem), X_ERROR, + "When reporting this, please include %s and the full dmesg.\n", + path); } }