drm/i915: Move common code out of i915_gpu_error.c
Subsystems (2)
PATCH 1/6 drm/i915: Move common code out of i915_gpu_error.c
In the next patch, I want to conditionally compile i915_gpu_error.c and that requires moving the functions used by debug out of i915_gpu_error.c!
--- drivers/gpu/drm/i915/i915_debugfs.c | 2 +- drivers/gpu/drm/i915/i915_drv.h | 3 - drivers/gpu/drm/i915/i915_gpu_error.c | 106 +------------------------------- drivers/gpu/drm/i915/i915_irq.c | 4 +- drivers/gpu/drm/i915/intel_engine_cs.c | 104 +++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_ringbuffer.h | 3 + 6 files changed, 111 insertions(+), 111 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
@@ -1339,7 +1339,7 @@ static int i915_hangcheck_info(struct seq_file *m, void *unused) seqno[id] =intel_engine_get_seqno (engine); } -i915_get_engine_instdone (dev_priv,RCS , &instdone); +intel_engine_get_instdone (&dev_priv->engine[RCS ], &instdone);intel_runtime_pm_put (dev_priv);
drivers/gpu/drm/i915/i915_drv.h +0 -3
@@ -3564,9 +3564,6 @@ void i915_error_state_get(struct drm_device *dev,void i915_error_state_put (struct i915_error_state_file_priv *error_priv);void i915_destroy_error_state (struct drm_device *dev); -void i915_get_engine_instdone (struct drm_i915_private *dev_priv, -enum intel_engine_id engine_id, -struct intel_instdone *instdone);const char *i915_cache_level_str (struct drm_i915_private *i915,int type);/* i915_cmd_parser.c */
drivers/gpu/drm/i915/i915_gpu_error.c +1 -105
115 lines not on this page · raw message
drivers/gpu/drm/i915/i915_irq.c +2 -2
@@ -2588,7 +2588,7 @@ static void i915_report_and_clear_eir(struct drm_i915_private *dev_priv)pr_err ("render error detected, EIR: 0x%08x\n" , eir); -i915_get_engine_instdone (dev_priv,RCS , &instdone); +intel_engine_get_instdone (&dev_priv->engine[RCS ], &instdone);if (IS_G4X (dev_priv)) {if (eir & (GM45_ERROR_MEM_PRIV |GM45_ERROR_CP_PRIV )) {
@@ -3001,7 +3001,7 @@ static bool subunits_stuck(struct intel_engine_cs *engine)if (engine->id !=RCS )return true; -i915_get_engine_instdone (dev_priv,RCS , &instdone); +intel_engine_get_instdone (engine, &instdone);/* There might be unstable subunit states even when * actual head is not moving. Filter out the unstable ones by
drivers/gpu/drm/i915/intel_engine_cs.c +104 -0
107 lines not on this page · raw message
drivers/gpu/drm/i915/intel_ringbuffer.h +3 -0
@@ -550,6 +550,9 @@ static inline u32 intel_engine_get_seqno(struct intel_engine_cs *engine)int init_workarounds_ring (struct intel_engine_cs *engine); +void intel_engine_get_instdone (struct intel_engine_cs *engine, +struct intel_instdone *instdone); +/* * Arbitrary size for largest possible 'add request' sequence. The code paths * are complex and variable. Empirical measurement shows that the worst case
Signature · 6 lines
2.9.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/6 drm/i915: Allow disabling error capture
We currently capture the GPU state after we detect a hang. This is vital for us to both triage and debug hangs in the wild (post-mortem debugging). However, it comes at the cost of running some potentially dangerous code (since it has to make very few assumption about the state of the driver) that is quite resource intensive.
This patch introduces both a method to disable error capture at runtime (for users who hit bugs at runtime and need a workaround) and to disable error capture at compiletime (for realtime users who want to minimise any possible latency, and never require error capture, saving ~30k of code). The cost is that we now have to be wary of (and test!) a kconfig flag and a module parameter. The effect of the module parameter is easy to verify through code inspection and runtime testing, but a kconfig flag needs regular compile checking.
--- drivers/gpu/drm/i915/Kconfig | 13 +++++++++++++ drivers/gpu/drm/i915/Makefile | 4 +++- drivers/gpu/drm/i915/i915_debugfs.c | 6 ++++++ drivers/gpu/drm/i915/i915_drv.h | 16 ++++++++++++++++ drivers/gpu/drm/i915/i915_gpu_error.c | 3 +++ drivers/gpu/drm/i915/i915_params.c | 9 +++++++++ drivers/gpu/drm/i915/i915_params.h | 1 + drivers/gpu/drm/i915/i915_sysfs.c | 25 ++++++++++++++++++++----- drivers/gpu/drm/i915/intel_display.c | 4 ++++ drivers/gpu/drm/i915/intel_overlay.c | 4 ++++ 10 files changed, 79 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/Kconfig +13 -0
@@ -46,6 +46,19 @@ config DRM_I915_PRELIMINARY_HW_SUPPORT If in doubt, say "N". +config DRM_I915_CAPTURE_ERROR + bool "Enable capturing GPU state following a hang" + depends on DRM_I915 + default y + help + This option enables capturing the GPU state when a hang is detected. + This information is vital for triaging hangs and assists in debugging. + Please report any hang to + https://bugs.freedesktop.org/enter_bug.cgi?product=DRI + for triaging. + + If in doubt, say "Y". + config DRM_I915_USERPTR bool "Always enable userptr support" depends on DRM_I915
drivers/gpu/drm/i915/Makefile +3 -1
@@ -42,7 +42,6 @@ i915-y += i915_cmd_parser.o \ i915_gem_stolen.o \ i915_gem_tiling.o \ i915_gem_userptr.o \ - i915_gpu_error.o \ i915_trace_points.o \ intel_breadcrumbs.o \ intel_engine_cs.o \
@@ -107,6 +106,9 @@ i915-y += dvo_ch7017.o \ intel_sdvo.o \ intel_tv.o +# Post-mortem debug and GPU hang state capture +i915-$(CONFIG_DRM_I915_CAPTURE_ERROR) += i915_gpu_error.o + # virtual gpu code i915-y += i915_vgpu.o
drivers/gpu/drm/i915/i915_debugfs.c +6 -0
@@ -960,6 +960,8 @@ static int i915_hws_info(struct seq_file *m, void *data)return 0 ; } +#if IS_ENABLED (CONFIG_DRM_I915_CAPTURE_ERROR ) + static ssize_t i915_error_state_write(struct file *filp, const char __user *ubuf,
@@ -1042,6 +1044,8 @@ static const struct file_operations i915_error_state_fops = { .release = i915_error_state_release, }; +#endif +static int i915_next_seqno_get (void *data,u64 *val) {
@@ -5398,7 +5402,9 @@ static const struct i915_debugfs_files { {"i915_ring_missed_irq", &i915_ring_missed_irq_fops}, {"i915_ring_test_irq", &i915_ring_test_irq_fops}, {"i915_gem_drop_caches", &i915_drop_caches_fops}, +#if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) {"i915_error_state", &i915_error_state_fops}, +#endif {"i915_next_seqno", &i915_next_seqno_fops}, {"i915_display_crc_ctl", &i915_display_crc_ctl_fops}, {"i915_pri_wm_latency", &i915_pri_wm_latency_fops},
drivers/gpu/drm/i915/i915_drv.h +16 -0
@@ -3544,6 +3544,8 @@ static inline void intel_display_crc_init(struct drm_i915_private *dev_priv) {}#endif /* i915_gpu_error.c */ +#if IS_ENABLED (CONFIG_DRM_I915_CAPTURE_ERROR ) + __printf(2, 3)void i915_error_printf (struct drm_i915_error_state_buf *e,const char *f, ...); int i915_error_state_to_str(struct drm_i915_error_state_buf *estr,
@@ -3564,6 +3566,20 @@ void i915_error_state_get(struct drm_device *dev,void i915_error_state_put (struct i915_error_state_file_priv *error_priv);void i915_destroy_error_state (struct drm_device *dev); +#else + +static inline void i915_capture_error_state (struct drm_i915_private *dev_priv, +u32 engine_mask, +const char *error_msg) +{ +} + +static inline void i915_destroy_error_state (struct drm_device *dev) +{ +} + +#endif +const char *i915_cache_level_str (struct drm_i915_private *i915,int type);/* i915_cmd_parser.c */
drivers/gpu/drm/i915/i915_gpu_error.c +3 -0
@@ -1464,6 +1464,9 @@ void i915_capture_error_state(struct drm_i915_private *dev_priv,struct drm_i915_error_state *error;unsigned long flags; +if (!i915.error_capture) +return ; +if (READ_ONCE (dev_priv->gpu_error.first_error))return ;
drivers/gpu/drm/i915/i915_params.c +9 -0
@@ -47,6 +47,7 @@ struct i915_params i915 __read_mostly = { .load_detect_test = 0, .force_reset_modeset_test = 0, .reset = true, + .error_capture = true, .invert_brightness = 0, .disable_display = 0, .enable_cmd_parser = 1,
@@ -115,6 +116,14 @@ MODULE_PARM_DESC(vbt_sdvo_panel_type,module_param_named_unsafe (reset, i915.reset, bool,0600 );MODULE_PARM_DESC (reset,"Attempt GPU resets (default: true)" ); +#if IS_ENABLED (CONFIG_DRM_I915_CAPTURE_ERROR ) +module_param_named (error_capture, i915.error_capture, bool,0600 ); +MODULE_PARM_DESC (error_capture, +"Record the GPU state following a hang. " +"This information in /sys/class/drm/card<N>/error is vital for " +"triaging and debugging hangs." ); +#endif +module_param_named_unsafe (enable_hangcheck, i915.enable_hangcheck, bool,0644 );MODULE_PARM_DESC (enable_hangcheck, "Periodically check GPU activity for detecting hangs. "
drivers/gpu/drm/i915/i915_params.h +1 -0
@@ -59,6 +59,7 @@ struct i915_params {bool load_detect_test;bool force_reset_modeset_test;bool reset; +bool error_capture;bool disable_display;bool verbose_state_checks;bool nuclear_pageflip;
drivers/gpu/drm/i915/i915_sysfs.c +20 -5
@@ -514,6 +514,8 @@ static const struct attribute *vlv_attrs[] = { NULL, }; +#if IS_ENABLED (CONFIG_DRM_I915_CAPTURE_ERROR ) +static ssize_t error_state_read (struct file *filp,struct kobject *kobj,struct bin_attribute *attr,char *buf,loff_t off,size_t count)
@@ -571,6 +573,21 @@ static struct bin_attribute error_state_attr = { .write = error_state_write, }; +static void i915_setup_error_capture (struct device *kdev) +{ +if (sysfs_create_bin_file (&kdev->kobj, &error_state_attr)) +DRM_ERROR ("error_state sysfs setup failed\n" ); +} + +static void i915_teardown_error_capture (struct device *kdev) +{ +sysfs_remove_bin_file (&kdev->kobj, &error_state_attr); +} +#else +static void i915_setup_error_capture (struct device *kdev) {} +static void i915_teardown_error_capture (struct device *kdev) {} +#endif +void i915_setup_sysfs (struct drm_i915_private *dev_priv) {struct device *kdev = dev_priv->drm.primary->kdev;
@@ -617,17 +634,15 @@ void i915_setup_sysfs(struct drm_i915_private *dev_priv)if (ret)DRM_ERROR ("RPS sysfs setup failed\n" ); - ret =sysfs_create_bin_file (&kdev->kobj, - &error_state_attr); -if (ret) -DRM_ERROR ("error_state sysfs setup failed\n" ); +i915_setup_error_capture (kdev); }void i915_teardown_sysfs (struct drm_i915_private *dev_priv) {struct device *kdev = dev_priv->drm.primary->kdev; -sysfs_remove_bin_file (&kdev->kobj, &error_state_attr); +i915_teardown_error_capture (kdev); +if (IS_VALLEYVIEW (dev_priv) ||IS_CHERRYVIEW (dev_priv))sysfs_remove_files (&kdev->kobj, vlv_attrs);else
drivers/gpu/drm/i915/intel_display.c +4 -0
@@ -17097,6 +17097,8 @@ int intel_modeset_vga_set_state(struct drm_device *dev, bool state)return 0 ; } +#if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) + struct intel_display_error_state { u32 power_well_driver;
@@ -17279,3 +17281,5 @@ intel_display_print_error_state(struct drm_i915_error_state_buf *m, err_printf(m, " VSYNC: %08x\n", error->transcoder[i].vsync); } } + +#endif
drivers/gpu/drm/i915/intel_overlay.c +4 -0
@@ -1470,6 +1470,8 @@ void intel_cleanup_overlay(struct drm_i915_private *dev_priv)kfree (dev_priv->overlay); } +#if IS_ENABLED(CONFIG_DRM_I915_CAPTURE_ERROR) + struct intel_overlay_error_state { struct overlay_registers regs; unsigned long base;
@@ -1587,3 +1589,5 @@ intel_overlay_print_error_state(struct drm_i915_error_state_buf *m,P (UVSCALEV );#undef P } + +#endif
Signature · 6 lines
2.9.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/6 drm/i915: Stop the machine whilst capturing the GPU crash dump
In reply to Chris WilsonThe error state is purposefully racy as we expect it to be called at any time and so have avoided any locking whilst capturing the crash dump. However, with multi-engine GPUs and multiple CPUs, those races can manifest into OOPSes as we attempt to chase dangling pointers freed on other CPUs. Under discussion are lots of ways to slow down normal operation in order to protect the post-mortem error capture, but what it we take the opposite approach and freeze the machine whilst the error capture runs (note the GPU may still running, but as long as we don't process any of the results the driver's bookkeeping will be static).
Note that by of itself, this is not a complete fix. It also depends on the compiler barriers in list_add/list_del to prevent traversing the lists into the void. We also depend that we only require state from carefully controlled sources - i.e. all the state we require for post-mortem debugging should be reachable from the request itself so that we only have to worry about retrieving the request carefully. Once we have the request, we know that all pointers from it are intact.
v2: Avoid drm_clflush_pages() inside stop_machine() as it may use stop_machine() itself for its wbinvd fallback.
--- drivers/gpu/drm/i915/Kconfig | 1 + drivers/gpu/drm/i915/i915_drv.h | 2 ++ drivers/gpu/drm/i915/i915_gpu_error.c | 46 +++++++++++++++++++++-------------- 3 files changed, 31 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/Kconfig +1 -0
@@ -4,6 +4,7 @@ config DRM_I915 depends on X86 && PCI select INTEL_GTT select INTERVAL_TREE + select STOP_MACHINE # we need shmfs for the swappable backing store, and in particular # the shmem_readpage() which depends upon tmpfs select SHMEM
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -746,6 +746,8 @@ struct drm_i915_error_state {struct kref ref;struct timeval time; +struct drm_i915_private *i915; +char error_msg[128 ];bool simulated;int iommu;
drivers/gpu/drm/i915/i915_gpu_error.c +28 -18
87 lines not on this page · raw message
Signature · 6 lines
2.9.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [CI 3/6] drm/i915: Stop the machine whilst capturing the GPU crash dump
Quoted 18 lines · Chris Wilson
The error state is purposefully racy as we expect it to be called at any time and so have avoided any locking whilst capturing the crash dump. However, with multi-engine GPUs and multiple CPUs, those races can manifest into OOPSes as we attempt to chase dangling pointers freed on other CPUs. Under discussion are lots of ways to slow down normal operation in order to protect the post-mortem error capture, but what it we take the opposite approach and freeze the machine whilst the error capture runs (note the GPU may still running, but as long as we don't process any of the results the driver's bookkeeping will be static).
Note that by of itself, this is not a complete fix. It also depends on the compiler barriers in list_add/list_del to prevent traversing the lists into the void. We also depend that we only require state from carefully controlled sources - i.e. all the state we require for post-mortem debugging should be reachable from the request itself so that we only have to worry about retrieving the request carefully. Once we have the request, we know that all pointers from it are intact.
Quoted 2 lines
v2: Avoid
drm_clflush_pages()insidestop_machine()as it may usestop_machine()itself for its wbinvd fallback.
Hm, won't this hurt us real bad on any atom with ppgtt? Maybe a big check gen check with a scary comment about why we can't call drm_clflush_pages on old machines? Iirc gen3+ should all be able to flush without stop_machine.
With that addressed you can upgrade to Reviewed-by: Daniel Vetter <[email protected]>, but I think Mika should ack this too. -Daniel
Quoted 137 lines
Signed-off-by Chris Wilson <[email protected]>Acked-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/i915/Kconfig | 1 + drivers/gpu/drm/i915/i915_drv.h | 2 ++ drivers/gpu/drm/i915/i915_gpu_error.c | 46 +++++++++++++++++++++-------------- 3 files changed, 31 insertions(+), 18 deletions(-)drivers/gpu/drm/i915/Kconfig +1
-0@@ -4,6 +4,7 @@ config DRM_I915 depends on X86 && PCI select INTEL_GTT select INTERVAL_TREE + select STOP_MACHINE # we need shmfs for the swappable backing store, and in particular # the shmem_readpage() which depends upon tmpfs select SHMEMdrivers/gpu/drm/i915/i915_drv.h +2
-0@@ -746,6 +746,8 @@ struct drm_i915_error_state {struct kref ref;struct timeval time; +struct drm_i915_private *i915; +char error_msg[128 ];bool simulated;int iommu;drivers/gpu/drm/i915/i915_gpu_error.c +28
-18@@ -28,6 +28,7 @@*/ #include <generated/utsrelease.h> +#include <linux/stop_machine.h> #include "i915_drv.h" static const char *engine_str (int engine)@@ -744,14 +745,12 @@ i915_error_object_create(struct drm_i915_private *dev_priv, dst->page_count = num_pages;while (num_pages--) { -unsigned long flags;void *d; d =kmalloc (PAGE_SIZE ,GFP_ATOMIC );if (d ==NULL ) goto unwind; -local_irq_save (flags);if (use_ggtt) {void __iomem *s;@@ -770,15 +769,10 @@ i915_error_object_create(struct drm_i915_private *dev_priv, page =i915_gem_object_get_page (src, i); -drm_clflush_pages (&page,1 ); - s =kmap_atomic (page);memcpy (d, s,PAGE_SIZE );kunmap_atomic (s); - -drm_clflush_pages (&page,1 ); } -local_irq_restore (flags); dst->pages[i++] = d; reloc_offset +=PAGE_SIZE ;@@ -1447,6 +1441,31 @@ static void i915_capture_gen_state(struct drm_i915_private *dev_priv, sizeof(error->device_info)); } +static int capture (void *data) +{ +struct drm_i915_error_state *error = data; + +/* Ensure that what we readback from memory matches what the GPU sees */ +wbinvd (); + +i915_capture_gen_state (error->i915, error); +i915_capture_reg_state (error->i915, error); +i915_gem_record_fences (error->i915, error); +i915_gem_record_rings (error->i915, error); +i915_capture_active_buffers (error->i915, error); +i915_capture_pinned_buffers (error->i915, error); + +do_gettimeofday (&error->time); + + error->overlay =intel_overlay_capture_error_state (error->i915); + error->display =intel_display_capture_error_state (error->i915); + +/* And make sure we don't leave trash in the CPU cache */ +wbinvd (); + +return 0 ; +} +/** * i915_capture_error_state - capture an error record for later analysis * @dev: drm device @@ -1478,18 +1497,9 @@ void i915_capture_error_state(struct drm_i915_private *dev_priv, }kref_init (&error->ref); + error->i915 = dev_priv; -i915_capture_gen_state (dev_priv, error); -i915_capture_reg_state (dev_priv, error); -i915_gem_record_fences (dev_priv, error); -i915_gem_record_rings (dev_priv, error); -i915_capture_active_buffers (dev_priv, error); -i915_capture_pinned_buffers (dev_priv, error); - -do_gettimeofday (&error->time); - - error->overlay =intel_overlay_capture_error_state (dev_priv); - error->display =intel_display_capture_error_state (dev_priv); +stop_machine (capture, error,NULL );i915_error_capture_msg (dev_priv, error, engine_mask, error_msg);DRM_INFO ("%s\n" , error->error_msg);Signature · 6 lines
2.9.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [CI 3/6] drm/i915: Stop the machine whilst capturing the GPU crash dump
Quoted 19 lines · Daniel Vetter
Quoted 18 lines · Chris Wilson
The error state is purposefully racy as we expect it to be called at any time and so have avoided any locking whilst capturing the crash dump. However, with multi-engine GPUs and multiple CPUs, those races can manifest into OOPSes as we attempt to chase dangling pointers freed on other CPUs. Under discussion are lots of ways to slow down normal operation in order to protect the post-mortem error capture, but what it we take the opposite approach and freeze the machine whilst the error capture runs (note the GPU may still running, but as long as we don't process any of the results the driver's bookkeeping will be static).
Note that by of itself, this is not a complete fix. It also depends on the compiler barriers in list_add/list_del to prevent traversing the lists into the void. We also depend that we only require state from carefully controlled sources - i.e. all the state we require for post-mortem debugging should be reachable from the request itself so that we only have to worry about retrieving the request carefully. Once we have the request, we know that all pointers from it are intact.
Quoted 7 lines
Quoted 2 lines
v2: Avoid
drm_clflush_pages()insidestop_machine()as it may usestop_machine()itself for its wbinvd fallback.Hm, won't this hurt us real bad on any atom with ppgtt? Maybe a big check gen check with a scary comment about why we can't call
drm_clflush_pageson old machines? Iirc gen3+ should all be able to flush withoutstop_machine.
:) Patch 2 switched to using coherent reads through the GTT for all. Everyone is now equal (and the nice part about that was that it uncovered the WC bug from kernel 4.0!)
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/6 drm/i915: Always use the GTT for error capture
In reply to Chris WilsonSince the GTT provides universal access to any GPU page, we can use it to reduce our plethora of read methods to just one. It also has the important characteristic of being exactly what the GPU sees - if there are incoherency problems, seeing the batch as executed (rather than as trapped inside the cpu cache) is important.
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 43 ++++++++---- drivers/gpu/drm/i915/i915_gem_gtt.h | 2 + drivers/gpu/drm/i915/i915_gpu_error.c | 120 ++++++++++++---------------------- 3 files changed, 74 insertions(+), 91 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +30 -13
@@ -2717,6 +2717,7 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv)*/ struct i915_ggtt *ggtt = &dev_priv->ggtt;unsigned long hole_start, hole_end; +struct i915_hw_ppgtt *ppgtt;struct drm_mm_node *entry;int ret;
@@ -2724,6 +2725,15 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv)if (ret)return ret; +/* Reserve a mappable slot for our lockless error capture */ + ret =drm_mm_insert_node_in_range_generic (&ggtt->base.mm, + &ggtt->error_capture, +4096 ,0 ,-1 , +0 , ggtt->mappable_end, +0 ,0 ); +if (ret) +return ret; +/* Clear any non-preallocated blocks */ drm_mm_for_each_hole (entry, &ggtt->base.mm, hole_start, hole_end) { DRM_DEBUG_KMS("clearing unused GTT space: [%lx, %lx]\n",
@@ -2738,25 +2748,21 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv) true);if (USES_PPGTT (dev_priv) && !USES_FULL_PPGTT (dev_priv)) { -struct i915_hw_ppgtt *ppgtt; - ppgtt =kzalloc (sizeof (*ppgtt),GFP_KERNEL ); -if (!ppgtt) -return -ENOMEM ; +if (!ppgtt) { + ret = -ENOMEM ; + goto err; + } ret =__hw_ppgtt_init (ppgtt, dev_priv); -if (ret) { -kfree (ppgtt); -return ret; - } +if (ret) + goto err_ppgtt; -if (ppgtt->base.allocate_va_range) +if (ppgtt->base.allocate_va_range) { ret = ppgtt->base.allocate_va_range (&ppgtt->base,0 , ppgtt->base.total); -if (ret) { - ppgtt->base.cleanup (&ppgtt->base); -kfree (ppgtt); -return ret; +if (ret) + goto err_ppgtt_cleanup; } ppgtt->base.clear_range(&ppgtt->base,
@@ -2770,6 +2776,14 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv) }return 0 ; + +err_ppgtt_cleanup: + ppgtt->base.cleanup (&ppgtt->base); +err_ppgtt: +kfree (ppgtt); +err: +drm_mm_remove_node (&ggtt->error_capture); +return ret; }/**
@@ -2788,6 +2802,9 @@ void i915_ggtt_cleanup_hw(struct drm_i915_private *dev_priv)i915_gem_cleanup_stolen (&dev_priv->drm); +if (drm_mm_node_allocated (&ggtt->error_capture)) +drm_mm_remove_node (&ggtt->error_capture); +if (drm_mm_initialized (&ggtt->base.mm)) {intel_vgt_deballoon (dev_priv);
drivers/gpu/drm/i915/i915_gem_gtt.h +2 -0
@@ -450,6 +450,8 @@ struct i915_ggtt {bool do_idle_maps;int mtrr; + +struct drm_mm_node error_capture; };struct i915_hw_ppgtt {
drivers/gpu/drm/i915/i915_gpu_error.c +42 -78
172 lines not on this page · raw message
Signature · 6 lines
2.9.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [CI 4/6] drm/i915: Always use the GTT for error capture
Quoted 8 lines · Chris Wilson
Since the GTT provides universal access to any GPU page, we can use it to reduce our plethora of read methods to just one. It also has the important characteristic of being exactly what the GPU sees - if there are incoherency problems, seeing the batch as executed (rather than as trapped inside the cpu cache) is important.
Signed-off-by Chris Wilson <[email protected]>Reviewed-by Joonas Lahtinen <[email protected]>
Meh, so much for me reading patches in order ;-)
Please reorder this one before the previous one and I'll be happy too.
Quoted 121 lines
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 43 ++++++++---- drivers/gpu/drm/i915/i915_gem_gtt.h | 2 + drivers/gpu/drm/i915/i915_gpu_error.c | 120 ++++++++++++---------------------- 3 files changed, 74 insertions(+), 91 deletions(-)drivers/gpu/drm/i915/i915_gem_gtt.c +30
-13@@ -2717,6 +2717,7 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv)*/ struct i915_ggtt *ggtt = &dev_priv->ggtt;unsigned long hole_start, hole_end; +struct i915_hw_ppgtt *ppgtt;struct drm_mm_node *entry;int ret;@@ -2724,6 +2725,15 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv)if (ret)return ret; +/* Reserve a mappable slot for our lockless error capture */ + ret =drm_mm_insert_node_in_range_generic (&ggtt->base.mm, + &ggtt->error_capture, +4096 ,0 ,-1 , +0 , ggtt->mappable_end, +0 ,0 ); +if (ret) +return ret; +/* Clear any non-preallocated blocks */ drm_mm_for_each_hole (entry, &ggtt->base.mm, hole_start, hole_end) { DRM_DEBUG_KMS("clearing unused GTT space: [%lx, %lx]\n",@@ -2738,25 +2748,21 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv) true);if (USES_PPGTT (dev_priv) && !USES_FULL_PPGTT (dev_priv)) { -struct i915_hw_ppgtt *ppgtt; - ppgtt =kzalloc (sizeof (*ppgtt),GFP_KERNEL ); -if (!ppgtt) -return -ENOMEM ; +if (!ppgtt) { + ret = -ENOMEM ; + goto err; + } ret =__hw_ppgtt_init (ppgtt, dev_priv); -if (ret) { -kfree (ppgtt); -return ret; - } +if (ret) + goto err_ppgtt; -if (ppgtt->base.allocate_va_range) +if (ppgtt->base.allocate_va_range) { ret = ppgtt->base.allocate_va_range (&ppgtt->base,0 , ppgtt->base.total); -if (ret) { - ppgtt->base.cleanup (&ppgtt->base); -kfree (ppgtt); -return ret; +if (ret) + goto err_ppgtt_cleanup; } ppgtt->base.clear_range(&ppgtt->base,@@ -2770,6 +2776,14 @@ int i915_gem_init_ggtt(struct drm_i915_private *dev_priv) }return 0 ; + +err_ppgtt_cleanup: + ppgtt->base.cleanup (&ppgtt->base); +err_ppgtt: +kfree (ppgtt); +err: +drm_mm_remove_node (&ggtt->error_capture); +return ret; }/** @@ -2788,6 +2802,9 @@ void i915_ggtt_cleanup_hw(struct drm_i915_private *dev_priv)i915_gem_cleanup_stolen (&dev_priv->drm); +if (drm_mm_node_allocated (&ggtt->error_capture)) +drm_mm_remove_node (&ggtt->error_capture); +if (drm_mm_initialized (&ggtt->base.mm)) {intel_vgt_deballoon (dev_priv);drivers/gpu/drm/i915/i915_gem_gtt.h +2
-0@@ -450,6 +450,8 @@ struct i915_ggtt {bool do_idle_maps;int mtrr; + +struct drm_mm_node error_capture; };struct i915_hw_ppgtt {drivers/gpu/drm/i915/i915_gpu_error.c +1
-1@@ -656,7 +656,7 @@ static void i915_error_object_free(struct drm_i915_error_object *obj)return ;for (page =0 ; page < obj->page_count; page++) -kfree (obj->pages[page]); +free_page ((unsigned long )obj->pages[page]);kfree (obj); }
drivers/gpu/drm/i915/i915_gpu_error.c static void i915_error_state_free(struct kref *error_ref) · line 696
Quoted 4 lines
drivers/gpu/drm/i915/i915_gpu_error.c +1
-0@@ -693,98 +693,69 @@ static void i915_error_state_free(struct kref *error_ref)kfree (error); } +static int compress_page (void *src,struct drm_i915_error_object *dst)
Jumping ahead a bit with the name, but imo ok ...
Quoted 156 lines
drivers/gpu/drm/i915/i915_gpu_error.c +40
-76+{ +unsigned long page; + + page =__get_free_page (GFP_ATOMIC | __GFP_NOWARN); +if (!page) +return -ENOMEM ; + + dst->pages[dst->page_count++] = (void *)page; + +memcpy ((void *)page, src,PAGE_SIZE ); +return 0 ; +} +static struct drm_i915_error_object * -i915_error_object_create (struct drm_i915_private *dev_priv, +i915_error_object_create (struct drm_i915_private *i915,struct i915_vma *vma) { -struct i915_ggtt *ggtt = &dev_priv->ggtt; -struct drm_i915_gem_object *src; +struct i915_ggtt *ggtt = &i915->ggtt; +const u64 slot = ggtt->error_capture.start;struct drm_i915_error_object *dst; -int num_pages; -bool use_ggtt; -int i =0 ; -u64 reloc_offset; +unsigned long num_pages; +struct sgt_iter iter; +dma_addr_t dma;if (!vma)return NULL ; - src = vma->obj; -if (!src->pages) -return NULL ; - - num_pages = src->base.size >>PAGE_SHIFT ; - - dst =kmalloc (sizeof (*dst) + num_pages *sizeof (u32 *),GFP_ATOMIC ); + num_pages =min_t (u64, vma->size, vma->obj->base.size) >>PAGE_SHIFT ; + dst =kmalloc (sizeof (*dst) + num_pages *sizeof (u32 *), +GFP_ATOMIC | __GFP_NOWARN);if (!dst)return NULL ; dst->gtt_offset = vma->node.start; dst->gtt_size = vma->node.size; + dst->page_count =0 ; - reloc_offset = dst->gtt_offset; - use_ggtt = (src->cache_level ==I915_CACHE_NONE && - (vma->flags &I915_VMA_GLOBAL_BIND ) && - reloc_offset + num_pages *PAGE_SIZE <= ggtt->mappable_end); - -/* Cannot access stolen address directly, try to use the aperture */ -if (src->stolen) { - use_ggtt = true; - -if (!(vma->flags &I915_VMA_GLOBAL_BIND )) - goto unwind; - - reloc_offset = vma->node.start; -if (reloc_offset + num_pages *PAGE_SIZE > ggtt->mappable_end) - goto unwind; - } +for_each_sgt_dma (dma, iter, vma->pages) { +void __iomem *s; +int ret; -/* Cannot access snooped pages through the aperture */ -if (use_ggtt && src->cache_level !=I915_CACHE_NONE && - !HAS_LLC (dev_priv)) - goto unwind; + ggtt->base.insert_page (&ggtt->base, dma, slot, +I915_CACHE_NONE ,0 ); - dst->page_count = num_pages; -while (num_pages--) { -void *d; + s =io_mapping_map_atomic_wc (&ggtt->mappable, slot); + ret =compress_page ((void *__force )s, dst); +io_mapping_unmap_atomic (s); - d =kmalloc (PAGE_SIZE ,GFP_ATOMIC ); -if (d ==NULL ) +if (ret) goto unwind; - -if (use_ggtt) { -void __iomem *s; - -/* Simply ignore tiling or any overlapping fence. -* It's part of the error state, and this hopefully -* captures what the GPU read. -*/ - - s =io_mapping_map_atomic_wc (&ggtt->mappable, - reloc_offset); -memcpy_fromio (d, s,PAGE_SIZE ); -io_mapping_unmap_atomic (s); - }else { -struct page *page; -void *s; - - page =i915_gem_object_get_page (src, i); - - s =kmap_atomic (page); -memcpy (d, s,PAGE_SIZE ); -kunmap_atomic (s); - } - - dst->pages[i++] = d; - reloc_offset +=PAGE_SIZE ; } - -return dst; + goto out; unwind: -while (i--) -kfree (dst->pages[i]); +while (dst->page_count--) +free_page ((unsigned long )dst->pages[dst->page_count]);kfree (dst); -return NULL ; + dst =NULL ; + +out: + ggtt->base.clear_range (&ggtt->base, slot,PAGE_SIZE , true); +return dst; }/* The error capture is special as tries to run underneath the normal @@ -1445,9 +1416,6 @@ static int capture(void *data) {struct drm_i915_error_state *error = data; -/* Ensure that what we readback from memory matches what the GPU sees */ -wbinvd (); -i915_capture_gen_state (error->i915, error);i915_capture_reg_state (error->i915, error);i915_gem_record_fences (error->i915, error);@@ -1460,9 +1428,6 @@ static int capture(void *data) error->overlay =intel_overlay_capture_error_state (error->i915); error->display =intel_display_capture_error_state (error->i915); -/* And make sure we don't leave trash in the CPU cache */ -wbinvd (); -return 0 ; }
drivers/gpu/drm/i915/i915_gpu_error.c void i915_error_state_get(struct drm_device *dev, · line 1507
Quoted 5 lines
drivers/gpu/drm/i915/i915_gpu_error.c +0
-1@@ -1539,7 +1504,6 @@ void i915_error_state_get(struct drm_device *dev,if (error_priv->error)kref_get (&error_priv->error->ref);spin_unlock_irq (&dev_priv->gpu_error.lock); - }
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [CI 4/6] drm/i915: Always use the GTT for error capture
Quoted 7 lines · Daniel Vetter
Quoted 6 lines · Chris Wilson
Since the GTT provides universal access to any GPU page, we can use it to reduce our plethora of read methods to just one. It also has the important characteristic of being exactly what the GPU sees - if there are incoherency problems, seeing the batch as executed (rather than as trapped inside the cpu cache) is important.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Chris Wilson <[email protected]>Reviewed-by Joonas Lahtinen <[email protected]>Meh, so much for me reading patches in order ;-)
Please reorder this one before the previous one and I'll be happy too.
Hmm, I actually thought this was. Shows what I remember about my series.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/6 drm/i915: Consolidate error object printing
In reply to Chris WilsonLeave all the pretty printing to userspace and simplify the error capture to only have a single common object printer. It makes the kernel code more compact, and the refactoring allows us to apply more complex transformations like compressing the output.
--- drivers/gpu/drm/i915/i915_gpu_error.c | 100 +++++++++------------------------- 1 file changed, 25 insertions(+), 75 deletions(-)
drivers/gpu/drm/i915/i915_gpu_error.c +25 -75
@@ -341,10 +341,22 @@ void i915_error_printf(struct drm_i915_error_state_buf *e, const char *f, ...) }static void print_error_obj (struct drm_i915_error_state_buf *m, +struct intel_engine_cs *engine, +const char *name,struct drm_i915_error_object *obj) {int page, offset, elt; +if (!obj) +return ; + +if (name) { +err_printf (m,"%s --- %s = 0x%08x %08x\n" , + engine ? engine->name :"global" , name, +upper_32_bits (obj->gtt_offset), +lower_32_bits (obj->gtt_offset)); + } +for (page = offset =0 ; page < obj->page_count; page++) {for (elt =0 ; elt <PAGE_SIZE /4 ; elt++) { err_printf(m, "%08x : %08x\n", offset,
@@ -370,8 +382,8 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m,struct pci_dev *pdev = dev_priv->drm.pdev;struct drm_i915_error_state *error = error_priv->error;struct drm_i915_error_object *obj; -int i, j, offset, elt;int max_hangcheck_score; +int i, j;if (!error) {err_printf (m,"no error state collected\n" );
@@ -491,15 +503,7 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m,err_printf (m," --- gtt_offset = 0x%08x %08x\n" ,upper_32_bits (obj->gtt_offset),lower_32_bits (obj->gtt_offset)); -print_error_obj (m, obj); - } - - obj = ee->wa_batchbuffer; -if (obj) { -err_printf (m,"%s (w/a) --- gtt_offset = 0x%08x\n" , - dev_priv->engine[i].name, -lower_32_bits (obj->gtt_offset)); -print_error_obj (m, obj); +print_error_obj (m, &dev_priv->engine[i],NULL , obj); }if (ee->num_requests) {
@@ -531,77 +535,23 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m, } } -if ((obj = ee->ringbuffer)) { -err_printf (m,"%s --- ringbuffer = 0x%08x\n" , - dev_priv->engine[i].name, -lower_32_bits (obj->gtt_offset)); -print_error_obj (m, obj); - } +print_error_obj (m, &dev_priv->engine[i], +"ringbuffer" , ee->ringbuffer); -if ((obj = ee->hws_page)) { -u64 hws_offset = obj->gtt_offset; -u32 *hws_page = &obj->pages[0 ][0 ]; +print_error_obj (m, &dev_priv->engine[i], +"HW Status" , ee->hws_page); -if (i915.enable_execlists) { - hws_offset +=LRC_PPHWSP_PN *PAGE_SIZE ; - hws_page = &obj->pages[LRC_PPHWSP_PN ][0 ]; - } -err_printf (m,"%s --- HW Status = 0x%08llx\n" , - dev_priv->engine[i].name, hws_offset); - offset =0 ; -for (elt =0 ; elt <PAGE_SIZE /16 ; elt +=4 ) { -err_printf (m,"[%04x] %08x %08x %08x %08x\n" , - offset, - hws_page[elt], - hws_page[elt+1 ], - hws_page[elt+2 ], - hws_page[elt+3 ]); - offset +=16 ; - } - } +print_error_obj (m, &dev_priv->engine[i], +"HW context" , ee->ctx); - obj = ee->wa_ctx; -if (obj) { -u64 wa_ctx_offset = obj->gtt_offset; -u32 *wa_ctx_page = &obj->pages[0 ][0 ]; -struct intel_engine_cs *engine = &dev_priv->engine[RCS ]; -u32 wa_ctx_size = (engine->wa_ctx.indirect_ctx.size + - engine->wa_ctx.per_ctx.size); - -err_printf (m,"%s --- WA ctx batch buffer = 0x%08llx\n" , - dev_priv->engine[i].name, wa_ctx_offset); - offset =0 ; -for (elt =0 ; elt < wa_ctx_size; elt +=4 ) { -err_printf (m,"[%04x] %08x %08x %08x %08x\n" , - offset, - wa_ctx_page[elt +0 ], - wa_ctx_page[elt +1 ], - wa_ctx_page[elt +2 ], - wa_ctx_page[elt +3 ]); - offset +=16 ; - } - } +print_error_obj (m, &dev_priv->engine[i], +"WA context" , ee->wa_ctx); -if ((obj = ee->ctx)) { -err_printf (m,"%s --- HW Context = 0x%08x\n" , - dev_priv->engine[i].name, -lower_32_bits (obj->gtt_offset)); -print_error_obj (m, obj); - } +print_error_obj (m, &dev_priv->engine[i], +"WA batchbuffer" , ee->wa_batchbuffer); } -if ((obj = error->semaphore)) { -err_printf (m,"Semaphore page = 0x%08x\n" , -lower_32_bits (obj->gtt_offset)); -for (elt =0 ; elt <PAGE_SIZE /16 ; elt +=4 ) { -err_printf (m,"[%04x] %08x %08x %08x %08x\n" , - elt *4 , - obj->pages[0 ][elt], - obj->pages[0 ][elt+1 ], - obj->pages[0 ][elt+2 ], - obj->pages[0 ][elt+3 ]); - } - } +print_error_obj (m,NULL ,"Semaphores" , error->semaphore);if (error->overlay)intel_overlay_print_error_state (m, error->overlay);
Signature · 6 lines
2.9.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 6/6 drm/i915: Compress GPU objects in error state
In reply to Chris WilsonOur error states are quickly growing, pinning kernel memory with them. The majority of the space is taken up by the error objects. These compress well using zlib and without decode are mostly meaningless, so encoding them does not hinder quickly parsing the error state for familiarity.
v2: Make the zlib dependency optional
--- drivers/gpu/drm/i915/Kconfig | 12 +++ drivers/gpu/drm/i915/i915_drv.h | 3 +- drivers/gpu/drm/i915/i915_gpu_error.c | 176 ++++++++++++++++++++++++++++++---- 3 files changed, 169 insertions(+), 22 deletions(-)
drivers/gpu/drm/i915/Kconfig +12 -0
@@ -60,6 +60,18 @@ config DRM_I915_CAPTURE_ERROR If in doubt, say "Y". +config DRM_I915_COMPRESS_ERROR + bool "Compress GPU error state" + depends on DRM_I915_CAPTURE_ERROR + select ZLIB_DEFLATE + default y + help + This option selects ZLIB_DEFLATE if it isn't already + selected and causes any error state captured upon a GPU hang + to be compressed using zlib. + + If in doubt, say "Y". + config DRM_I915_USERPTR bool "Always enable userptr support" depends on DRM_I915
drivers/gpu/drm/i915/i915_drv.h +2 -1
@@ -820,9 +820,10 @@ struct drm_i915_error_state {struct intel_instdone instdone;struct drm_i915_error_object { -int page_count;u64 gtt_offset;u64 gtt_size; +int page_count; +int unused;u32 *pages[0 ]; } *ringbuffer, *batchbuffer, *wa_batchbuffer, *ctx, *hws_page;
drivers/gpu/drm/i915/i915_gpu_error.c +155 -21
243 lines not on this page · raw message
Signature · 6 lines
2.9.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: failure for series starting with [CI,1/6] drm/i915: Move common code out of i915_gpu_error.c
In reply to Chris Wilson== Series Details ==
== Series Details ==
Series: series starting with [CI,1/6] drm/i915: Move common code out of i915_gpu_error.c
URL : https://patchwork.freedesktop.org/series/13630/
State : failure
== Summary ==
Series 13630v1 Series without cover letter
https://patchwork.freedesktop.org/api/1.0/series/13630/revisions/1/mbox/
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-b:
pass -> DMESG-WARN (fi-byt-j1900)
Test kms_psr_sink_crc:
Subgroup psr_basic:
pass -> DMESG-WARN (fi-skl-6700hq)
Test vgem_basic:
Subgroup unload:
pass -> SKIP (fi-hsw-4770)
skip -> PASS (fi-kbl-7200u)
Test vgem_reload_basic:
pass -> FAIL (fi-hsw-4770)fi-bdw-5557u total:248 pass:232 dwarn:0 dfail:0 fail:0 skip:16 fi-bsw-n3050 total:248 pass:205 dwarn:0 dfail:0 fail:0 skip:43 fi-bxt-t5700 total:248 pass:217 dwarn:0 dfail:0 fail:0 skip:31 fi-byt-j1900 total:248 pass:213 dwarn:2 dfail:0 fail:1 skip:32 fi-byt-n2820 total:248 pass:211 dwarn:0 dfail:0 fail:1 skip:36 fi-hsw-4770 total:248 pass:223 dwarn:0 dfail:0 fail:1 skip:24 fi-hsw-4770r total:248 pass:225 dwarn:0 dfail:0 fail:0 skip:23 fi-ilk-650 total:248 pass:185 dwarn:0 dfail:0 fail:2 skip:61 fi-ivb-3520m total:248 pass:222 dwarn:0 dfail:0 fail:0 skip:26 fi-ivb-3770 total:248 pass:222 dwarn:0 dfail:0 fail:0 skip:26 fi-kbl-7200u total:248 pass:223 dwarn:0 dfail:0 fail:0 skip:25 fi-skl-6260u total:248 pass:233 dwarn:0 dfail:0 fail:0 skip:15 fi-skl-6700hq total:248 pass:224 dwarn:1 dfail:0 fail:0 skip:23 fi-skl-6700k total:248 pass:222 dwarn:1 dfail:0 fail:0 skip:25 fi-skl-6770hq total:248 pass:231 dwarn:1 dfail:0 fail:1 skip:15 fi-snb-2520m total:248 pass:211 dwarn:0 dfail:0 fail:0 skip:37 fi-snb-2600 total:248 pass:210 dwarn:0 dfail:0 fail:0 skip:38
Results at /archive/results/CI_IGT_test/Patchwork_2680/
f766f3683894b41737352df7e0c0b7aaddd739e3 drm-intel-nightly: 2016y-10m-12d-08h-02m-34s UTC integration manifest c9a5e10 drm/i915: Compress GPU objects in error state
a70a22b drm/i915: Consolidate error object printing
b34f237 drm/i915: Always use the GTT for error capture
e9ac889 drm/i915: Stop the machine whilst capturing the GPU crash dump
c3d6a7a drm/i915: Allow disabling error capture
1d727df drm/i915: Move common code out of i915_gpu_error.c
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx