[Libva] [Libva-intel-driver PATCH 2/6] Decode: Add one debug option to debug which frame triggers GPU hang
Zhao, Yakui
yakui.zhao at intel.com
Sun Aug 17 19:50:51 PDT 2014
From: Zhao Yakui <yakui.zhao at intel.com>
export VA_INTEL_DEBUG=0x04 to turn on this debug option
Signed-off-by: Zhao Yakui <yakui.zhao at intel.com>
---
src/i965_drv_video.c | 32 +++++++++++++++++++++++++++++++-
src/i965_drv_video.h | 3 +++
src/intel_driver.h | 2 ++
3 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index 32a7c72..be9edff 100755
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -2305,6 +2305,8 @@ i965_BeginPicture(VADriverContextP ctx,
obj_context->codec_state.decode.num_slice_params = 0;
obj_context->codec_state.decode.num_slice_datas = 0;
+ if (g_intel_debug_option_flags & VA_INTEL_DEBUG_DECODE_GPUHANG)
+ clock_gettime(CLOCK_MONOTONIC, &obj_context->codec_state.decode.frame_begin_time);
}
return vaStatus;
@@ -2753,6 +2755,7 @@ i965_EndPicture(VADriverContextP ctx, VAContextID context)
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct object_context *obj_context = CONTEXT(context);
struct object_config *obj_config;
+ VAStatus vastatus;
ASSERT_RET(obj_context, VA_STATUS_ERROR_INVALID_CONTEXT);
obj_config = obj_context->obj_config;
@@ -2806,7 +2809,34 @@ i965_EndPicture(VADriverContextP ctx, VAContextID context)
}
ASSERT_RET(obj_context->hw_context->run, VA_STATUS_ERROR_OPERATION_FAILED);
- return obj_context->hw_context->run(ctx, obj_config->profile, &obj_context->codec_state, obj_context->hw_context);
+ vastatus = obj_context->hw_context->run(ctx, obj_config->profile, &obj_context->codec_state, obj_context->hw_context);
+
+ if ((vastatus == VA_STATUS_SUCCESS) &&
+ (obj_context->codec_type == CODEC_DEC) &&
+ (g_intel_debug_option_flags & VA_INTEL_DEBUG_DECODE_GPUHANG)) {
+ struct timespec end_time;
+ double f_begin_time, f_end_time;
+
+ i965_SyncSurface(ctx, obj_context->codec_state.decode.current_render_target);
+ clock_gettime(CLOCK_MONOTONIC, &end_time);
+
+ /* convert it to *.*s */
+ f_begin_time = obj_context->codec_state.decode.frame_begin_time.tv_nsec;
+ f_begin_time = f_begin_time / 1000000000 +
+ (obj_context->codec_state.decode.frame_begin_time.tv_sec);
+ f_end_time = end_time.tv_nsec;
+ f_end_time = f_end_time / 1000000000 + end_time.tv_sec;
+
+ if ((f_end_time - f_begin_time) >= 2.0) {
+ fprintf(stderr, "GPU hang is triggered on frame %d \t\n",
+ obj_context->codec_state.decode.frame_no);
+
+ }
+
+ obj_context->codec_state.decode.frame_no++;
+ }
+
+ return vastatus;
}
VAStatus
diff --git a/src/i965_drv_video.h b/src/i965_drv_video.h
index ee4b163..d12f696 100644
--- a/src/i965_drv_video.h
+++ b/src/i965_drv_video.h
@@ -128,6 +128,9 @@ struct decode_state
struct object_surface *render_object;
struct object_surface *reference_objects[16]; /* Up to 2 reference surfaces are valid for MPEG-2,*/
+
+ int frame_no;
+ struct timespec frame_begin_time;
};
#define SLICE_PACKED_DATA_INDEX_TYPE 0x80000000
diff --git a/src/intel_driver.h b/src/intel_driver.h
index 487bf03..5d7d043 100644
--- a/src/intel_driver.h
+++ b/src/intel_driver.h
@@ -80,6 +80,8 @@ extern uint32_t g_intel_debug_option_flags;
#define VA_INTEL_DEBUG_OPTION_ASSERT (1 << 0)
#define VA_INTEL_DEBUG_OPTION_BENCH (1 << 1)
+#define VA_INTEL_DEBUG_DECODE_GPUHANG (1 << 2)
+
#define ASSERT_RET(value, fail_ret) do { \
if (!(value)) { \
if (g_intel_debug_option_flags & VA_INTEL_DEBUG_OPTION_ASSERT) \
--
1.7.10.1
More information about the Libva
mailing list