@@ -384,32 +384,44 @@ static int gen8_oa_read(struct i915_perf_stream *stream,
384384 tail = I915_READ (GEN8_OATAILPTR ) & GEN8_OATAILPTR_MASK ;
385385 oastatus = I915_READ (GEN8_OASTATUS );
386386
387- if (unlikely (oastatus & (GEN8_OASTATUS_OABUFFER_OVERFLOW |
388- GEN8_OASTATUS_REPORT_LOST ))) {
389-
390- if (oastatus & GEN8_OASTATUS_OABUFFER_OVERFLOW ) {
391- ret = append_oa_status (stream , read_state ,
392- DRM_I915_PERF_RECORD_OA_BUFFER_LOST );
393- if (ret )
394- return ret ;
387+ /* We treat OABUFFER_OVERFLOW as a significant error:
388+ *
389+ * Although theoretically we could handle this more gracefully
390+ * sometimes, some Gens don't correctly suppress certain
391+ * automatically triggered reports in this condition and so we
392+ * have to assume that old reports are now being trampled
393+ * over.
394+ *
395+ * Considering how we don't currently give userspace control
396+ * over the OA buffer size and always configure a large 16MB
397+ * buffer, then a buffer overflow does anyway likely indicate
398+ * that something has gone quite badly wrong.
399+ */
400+ if (oastatus & GEN8_OASTATUS_OABUFFER_OVERFLOW ) {
401+ ret = append_oa_status (stream , read_state ,
402+ DRM_I915_PERF_RECORD_OA_BUFFER_LOST );
403+ if (ret )
404+ return ret ;
395405
396- oastatus &= ~GEN8_OASTATUS_OABUFFER_OVERFLOW ;
397- }
406+ DRM_ERROR ("OA buffer overflow: force restart" );
398407
399- if (oastatus & GEN8_OASTATUS_REPORT_LOST ) {
400- ret = append_oa_status (stream , read_state ,
401- DRM_I915_PERF_RECORD_OA_REPORT_LOST );
402- if (ret == 0 )
403- oastatus &= ~GEN8_OASTATUS_REPORT_LOST ;
404- }
408+ dev_priv -> perf .oa .ops .oa_disable (dev_priv );
409+ dev_priv -> perf .oa .ops .oa_enable (dev_priv );
405410
406- I915_WRITE (GEN8_OASTATUS , oastatus );
411+ oastatus = I915_READ (GEN8_OASTATUS );
407412
408- if ( ret )
409- return ret ;
413+ head = I915_READ ( GEN8_OAHEADPTR ) & GEN8_OAHEADPTR_MASK ;
414+ tail = I915_READ ( GEN8_OATAILPTR ) & GEN8_OATAILPTR_MASK ;
410415 }
411416
412- /* If there is still buffer space */
417+ if (oastatus & GEN8_OASTATUS_REPORT_LOST ) {
418+ ret = append_oa_status (stream , read_state ,
419+ DRM_I915_PERF_RECORD_OA_REPORT_LOST );
420+ if (ret == 0 ) {
421+ I915_WRITE (GEN8_OASTATUS ,
422+ oastatus & ~GEN8_OASTATUS_REPORT_LOST );
423+ }
424+ }
413425
414426 ret = gen8_append_oa_reports (stream , read_state , & head , tail );
415427
0 commit comments