Subject: [Patch] Add more check of H264 slice param to avoid GPU hang --- src/gen6_mfd.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) Index: intel-driver/src/gen6_mfd.c =================================================================== --- intel-driver.orig/src/gen6_mfd.c 2014-07-22 09:36:07.000000000 +0800 +++ intel-driver/src/gen6_mfd.c 2014-07-22 17:42:45.747189358 +0800 @@ -899,6 +899,7 @@ VASliceParameterBufferH264 *slice_param, *next_slice_param, *next_slice_group_param; dri_bo *slice_data_bo; int i, j; + int incorrect_slice; assert(decode_state->pic_param && decode_state->pic_param->buffer); pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer; @@ -913,6 +914,8 @@ gen6_mfd_avc_img_state(ctx, decode_state, gen6_mfd_context); gen6_mfd_avc_qm_state(ctx, decode_state, gen6_mfd_context); + incorrect_slice = 0; + for (j = 0; j < decode_state->num_slice_params; j++) { assert(decode_state->slice_params && decode_state->slice_params[j]->buffer); slice_param = (VASliceParameterBufferH264 *)decode_state->slice_params[j]->buffer; @@ -941,15 +944,28 @@ else next_slice_param = next_slice_group_param; + if (next_slice_param != NULL) { + /* If the mb position of next_slice is less than or equal to the current slice, + * ignore the following sequence. + */ + if (next_slice_param->first_mb_in_slice <= slice_param->first_mb_in_slice) { + next_slice_param = NULL; + incorrect_slice = 1; + } + } gen6_mfd_avc_directmode_state(ctx, decode_state, pic_param, slice_param, gen6_mfd_context); gen6_mfd_avc_slice_state(ctx, pic_param, slice_param, next_slice_param, gen6_mfd_context); gen6_mfd_avc_ref_idx_state(ctx, pic_param, slice_param, gen6_mfd_context); gen6_mfd_avc_weightoffset_state(ctx, pic_param, slice_param, gen6_mfd_context); gen6_mfd_avc_bsd_object(ctx, pic_param, slice_param, slice_data_bo, gen6_mfd_context); slice_param++; + + if (incorrect_slice) + goto slice_param_done; } } - + +slice_param_done: gen6_mfd_avc_phantom_slice_last(ctx, pic_param, gen6_mfd_context); intel_batchbuffer_end_atomic(batch); intel_batchbuffer_flush(batch);