drm/i915: Per-engine Timeout detection and recovery on HSW
Subsystems (3)
PATCH 2/3 drm/i915: Per-engine Timeout detection and recovery on HSW
From: "Siluvery, Arun" <[email protected]>
TDR provides per-engine hang detection and recovery. If an engine hangs then the TDR will attempt to reset the engine and advance the command streamer to the next instruction in the ring. If it was in the middle of processing a batch buffer then control returns to the instruction following the batch buffer start command. This provides a less intrusive recovery mechanism because it only impacts the process which caused the hang.
uevents are sent so that user mode can detect that something has gone wrong and take action if required.
Issues:
1) Full GPU resets can leave the system in a state where the display updates intermittently or lock up the system. This problem already existed with the current driver which could only do full GPU resets in response to a hang on any of the rings.
The problem has not been seen with per-engine TDR unless the driver falls back to full GPU reset, either because an individual ring reset fails or because the rings are hanging too quickly.
--- drivers/gpu/drm/i915/i915_debugfs.c | 6 +- drivers/gpu/drm/i915/i915_dma.c | 16 +- drivers/gpu/drm/i915/i915_drv.c | 195 ++++++++++- drivers/gpu/drm/i915/i915_drv.h | 80 ++++- drivers/gpu/drm/i915/i915_gem.c | 77 ++++- drivers/gpu/drm/i915/i915_gpu_error.c | 25 +- drivers/gpu/drm/i915/i915_irq.c | 555 ++++++++++++++++++-------------- drivers/gpu/drm/i915/intel_display.c | 25 +- drivers/gpu/drm/i915/intel_ringbuffer.c | 20 +- drivers/gpu/drm/i915/intel_ringbuffer.h | 2 + drivers/gpu/drm/i915/intel_uncore.c | 6 +- include/drm/drmP.h | 7 + 12 files changed, 724 insertions(+), 290 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +5 -1
@@ -2604,9 +2604,13 @@ static int i915_wedged_set(void *data, u64 val) {struct drm_device *dev = data; +drm_i915_private_t *dev_priv = dev->dev_private;DRM_INFO ("Manually setting wedged to %llu\n" , val); -i915_handle_error (dev, val); +if (val) { +if (!i915_reset_in_progress (&dev_priv->gpu_error)) +i915_handle_error (dev,NULL ); + }return 0 ; }
drivers/gpu/drm/i915/i915_dma.c +15 -1
@@ -1466,6 +1466,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)struct intel_device_info *info;int ret =0 , mmio_bar, mmio_size;uint32_t aperture_size; +uint32_t i; info = (struct intel_device_info *) flags;
@@ -1661,6 +1662,17 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)acpi_video_register (); } +for (i =0 ; i <I915_NUM_RINGS ; i++) { + dev_priv->hangcheck[i].count =0 ; + dev_priv->hangcheck[i].last_acthd =0 ; + dev_priv->hangcheck[i].ringid = i; + dev_priv->hangcheck[i].dev = dev; + +setup_timer (&dev_priv->hangcheck[i].timer, + i915_hangcheck_sample, + (unsigned long ) &dev_priv->hangcheck[i]); + } +if (IS_GEN5 (dev))intel_gpu_ips_init (dev_priv);
@@ -1703,6 +1715,7 @@ int i915_driver_unload(struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;int ret; +uint32_t i;intel_gpu_ips_teardown ();
@@ -1748,9 +1761,10 @@ int i915_driver_unload(struct drm_device *dev) }/* Free error state after interrupts are fully disabled. */ -del_timer_sync (&dev_priv->gpu_error.hangcheck_timer);cancel_work_sync (&dev_priv->gpu_error.work);i915_destroy_error_state (dev); +for (i =0 ; i <I915_NUM_RINGS ; i++) +del_timer_sync (&dev_priv->hangcheck[i].timer);cancel_delayed_work_sync (&dev_priv->pc8.enable_work);
drivers/gpu/drm/i915/i915_drv.c +194 -1
213 lines not on this page · raw message
drivers/gpu/drm/i915/i915_drv.h +75 -5
153 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem.c +60 -17
161 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gpu_error.c +17 -8
@@ -723,7 +723,6 @@ static void i915_record_ring_state(struct drm_device *dev, error->faddr[ring->id] =I915_READ (RING_DMA_FADD (ring->mmio_base)); error->ipeir[ring->id] =I915_READ (RING_IPEIR (ring->mmio_base)); error->ipehr[ring->id] =I915_READ (RING_IPEHR (ring->mmio_base)); - error->instdone[ring->id] =I915_READ (RING_INSTDONE (ring->mmio_base)); error->instps[ring->id] =I915_READ (RING_INSTPS (ring->mmio_base));if (ring->id ==RCS ) error->bbaddr =I915_READ64 (BB_ADDR );
@@ -732,9 +731,10 @@ static void i915_record_ring_state(struct drm_device *dev, error->faddr[ring->id] =I915_READ (DMA_FADD_I8XX ); error->ipeir[ring->id] =I915_READ (IPEIR ); error->ipehr[ring->id] =I915_READ (IPEHR ); - error->instdone[ring->id] =I915_READ (INSTDONE ); } +i915_get_extra_instdone (dev, error->instdone[ring->id], + &dev_priv->ring[ring->id]); error->waiting[ring->id] =waitqueue_active (&ring->irq_queue); error->instpm[ring->id] =I915_READ (RING_INSTPM (ring->mmio_base)); error->seqno[ring->id] = ring->get_seqno (ring, false);
@@ -899,6 +899,7 @@ void i915_capture_error_state(struct drm_device *dev)struct drm_i915_error_state *error;unsigned long flags;int pipe; +int i;spin_lock_irqsave (&dev_priv->gpu_error.lock, flags); error = dev_priv->gpu_error.first_error;
@@ -957,7 +958,9 @@ void i915_capture_error_state(struct drm_device *dev)if (INTEL_INFO (dev)->gen ==7 ) error->err_int =I915_READ (GEN7_ERR_INT ); -i915_get_extra_instdone (dev, error->extra_instdone); +for (i =0 ; i <I915_NUM_RINGS ; i++) +i915_get_extra_instdone (dev, error->instdone[i], + &dev_priv->ring[i]);i915_gem_capture_buffers (dev_priv, error);i915_gem_record_fences (dev, error);
@@ -1026,7 +1029,9 @@ const char *i915_cache_level_str(int type) }/* NB: please notice the memset */ -void i915_get_extra_instdone (struct drm_device *dev,uint32_t *instdone) +void i915_get_extra_instdone (struct drm_device *dev, +uint32_t *instdone, +struct intel_ring_buffer *ring) {struct drm_i915_private *dev_priv = dev->dev_private;memset (instdone,0 ,sizeof (*instdone) *I915_NUM_INSTDONE_REG );
@@ -1046,10 +1051,14 @@ void i915_get_extra_instdone(struct drm_device *dev, uint32_t *instdone)WARN_ONCE (1 ,"Unsupported platform\n" );case 7 :case 8 : - instdone[0 ] =I915_READ (GEN7_INSTDONE_1 ); - instdone[1 ] =I915_READ (GEN7_SC_INSTDONE ); - instdone[2 ] =I915_READ (GEN7_SAMPLER_INSTDONE ); - instdone[3 ] =I915_READ (GEN7_ROW_INSTDONE ); + instdone[0 ] = +I915_READ (RING_INSTDONE (ring->mmio_base)); + +if (ring->id ==RCS ) { + instdone[1 ] =I915_READ (GEN7_SC_INSTDONE ); + instdone[2 ] =I915_READ (GEN7_SAMPLER_INSTDONE ); + instdone[3 ] =I915_READ (GEN7_ROW_INSTDONE ); + }break ; } }
drivers/gpu/drm/i915/i915_irq.c +306 -249
691 lines not on this page · raw message
drivers/gpu/drm/i915/intel_display.c +24 -1
@@ -8484,7 +8484,7 @@ static int intel_gen7_queue_flip(struct drm_device *dev, goto err_unpin; } - len =4 ; + len =12 ;if (ring->id ==RCS ) len +=6 ;
@@ -8512,11 +8512,34 @@ static int intel_gen7_queue_flip(struct drm_device *dev,intel_ring_emit (ring, ring->scratch.gtt_offset +256 ); } +/* Set a flag to indicate that a page flip interrupt is expected. +* The flag is used by the TDR logic to detect whether the blitter hung +* on a page flip command, in which case it will need to manually +* complete the page flip. +* The 'flag' is actually the pipe value associated with this page +* flip + 1 so that the TDR code knows which pipe failed to flip. +* A value of 0 indicates that a flip is not currently in progress on +* the HW.*/ +intel_ring_emit (ring,MI_STORE_DWORD_INDEX ); +intel_ring_emit (ring,I915_GEM_PGFLIP_INDEX << +MI_STORE_DWORD_INDEX_SHIFT ); +intel_ring_emit (ring, intel_crtc->pipe +1 ); +intel_ring_emit (ring,MI_NOOP ); +intel_ring_emit (ring,MI_DISPLAY_FLIP_I915 | plane_bit);intel_ring_emit (ring, (fb->pitches[0 ] | obj->tiling_mode));intel_ring_emit (ring,i915_gem_obj_ggtt_offset (obj) + intel_crtc->dspaddr_offset);intel_ring_emit (ring, (MI_NOOP )); +/* Clear the flag as soon as we pass over the page flip command. +* If we passed over the command without hanging then an interrupt should +* be received to complete the page flip.*/ +intel_ring_emit (ring,MI_STORE_DWORD_INDEX ); +intel_ring_emit (ring,I915_GEM_PGFLIP_INDEX << +MI_STORE_DWORD_INDEX_SHIFT ); +intel_ring_emit (ring,0 ); +intel_ring_emit (ring,MI_NOOP ); +intel_mark_page_flip_active (intel_crtc);__intel_ring_advance (ring);return 0 ;
drivers/gpu/drm/i915/intel_ringbuffer.c +14 -6
@@ -47,6 +47,14 @@ void __intel_ring_advance(struct intel_ring_buffer *ring) ring->tail &= ring->size -1 ; +/* Re-schedule the hangcheck timer each time the ring is given new work +* so that we can detect hangs caused by commands inserted directly +* to the ring as well as bad batch buffers */ +if (!dev_priv->ums.mm_suspended && i915_enable_hangcheck) { +mod_timer (&dev_priv->hangcheck[ring->id].timer, + jiffies +DRM_I915_HANGCHECK_JIFFIES ); + } +if (dev_priv->gpu_error.stop_rings &intel_ring_flag (ring))return ; ring->write_tail (ring, ring->tail);
@@ -1591,7 +1599,7 @@ static int ring_wait_for_space(struct intel_ring_buffer *ring, int n)msleep (1 ); ret =i915_gem_check_wedge (&dev_priv->gpu_error, - dev_priv->mm.interruptible); + dev_priv->mm.interruptible, ring);if (ret)return ret; }while (!time_after (jiffies, end));
@@ -1691,7 +1699,7 @@ int intel_ring_begin(struct intel_ring_buffer *ring,int ret; ret =i915_gem_check_wedge (&dev_priv->gpu_error, - dev_priv->mm.interruptible); + dev_priv->mm.interruptible, ring);if (ret)return ret;
@@ -2010,7 +2018,7 @@ gen6_ring_reset(struct intel_ring_buffer *ring)/* Spin waiting for the device to ack the reset request */ ret =wait_for ((__raw_i915_read32 (dev_priv,GEN6_GDRST ) &GEN6_GRDOM_RENDER ) ==0 ,500 ); -DRM_DEBUG ("RCS Reset\n" ); +DRM_DEBUG_TDR ("RCS Reset\n" );break ;
@@ -2020,7 +2028,7 @@ gen6_ring_reset(struct intel_ring_buffer *ring)/* Spin waiting for the device to ack the reset request */ ret =wait_for ((__raw_i915_read32 (dev_priv,GEN6_GDRST ) &GEN6_GRDOM_BLT ) ==0 ,500 ); -DRM_DEBUG ("BCS Reset\n" ); +DRM_DEBUG_TDR ("BCS Reset\n" );break ;
@@ -2030,7 +2038,7 @@ gen6_ring_reset(struct intel_ring_buffer *ring)/* Spin waiting for the device to ack the reset request */ ret =wait_for ((__raw_i915_read32 (dev_priv,GEN6_GDRST ) &GEN6_GRDOM_MEDIA ) ==0 ,500 ); -DRM_DEBUG ("VCS Reset\n" ); +DRM_DEBUG_TDR ("VCS Reset\n" );break ;case VECS :
@@ -2039,7 +2047,7 @@ gen6_ring_reset(struct intel_ring_buffer *ring)/* Spin waiting for the device to ack the reset request */ ret =wait_for ((__raw_i915_read32 (dev_priv,GEN6_GDRST ) &GEN6_GRDOM_VEBOX ) ==0 ,500 ); -DRM_DEBUG ("VECS Reset\n" ); +DRM_DEBUG_TDR ("VECS Reset\n" );break ;default :
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -0
@@ -198,6 +198,8 @@ struct intel_ring_buffer {u32 saved_state[I915_RING_CONTEXT_SIZE ];struct intel_ring_hangcheck hangcheck; +uint32_t last_irq_seqno; +struct {struct drm_i915_gem_object *obj;u32 gtt_offset;
drivers/gpu/drm/i915/intel_uncore.c +5 -1
@@ -806,9 +806,13 @@ static int gen6_do_reset(struct drm_device *dev)int intel_gpu_reset (struct drm_device *dev) { +drm_i915_private_t *dev_priv = dev->dev_private;switch (INTEL_INFO (dev)->gen) {case 7 : -case 6 :return gen6_do_reset (dev); +case 6 : + dev_priv->total_resets++; +DRM_DEBUG_TDR ("total_resets %d\n" , dev_priv->total_resets); +return gen6_do_reset (dev);case 5 :return ironlake_do_reset (dev);case 4 :return i965_do_reset (dev);default :return -ENODEV ;
include/drm/drmP.h +7 -0
@@ -90,6 +90,7 @@ struct videomode;#define DRM_UT_DRIVER 0x02#define DRM_UT_KMS 0x04#define DRM_UT_PRIME 0x08 +#define DRM_UT_TDR 0x10/* * Three debug levels are defined. * drm_core, drm_driver, drm_kms
@@ -211,6 +212,11 @@ int drm_err(const char *func, const char *format, ...);drm_ut_debug_printk (DRM_UT_PRIME ,DRM_NAME , \ __func__, fmt, ##args); \ }while (0 ) +#define DRM_DEBUG_TDR(fmt, args...) \ +do { \ +drm_ut_debug_printk (DRM_UT_TDR ,DRM_NAME , \ + __func__, fmt, ##args); \ + } while (0) #define DRM_LOG(fmt, args...) \ do { \ drm_ut_debug_printk(DRM_UT_CORE, NULL, \
@@ -235,6 +241,7 @@ int drm_err(const char *func, const char *format, ...); #define DRM_DEBUG_DRIVER(fmt, args...) do { } while (0) #define DRM_DEBUG_KMS(fmt, args...) do { } while (0) #define DRM_DEBUG_PRIME(fmt, args...) do { } while (0) +#define DRM_DEBUG_TDR(fmt, args...) do { } while (0) #define DRM_DEBUG(fmt, arg...) do { } while (0) #define DRM_LOG(fmt, arg...) do { } while (0) #define DRM_LOG_KMS(fmt, args...) do { } while (0)
Signature · 1 line
1.8.4