Skip to content

Commit 642c8a7

Browse files
committed
drm/i915: Capture module parameters for the GPU error state
They include useful material such as what mode the VM address space is running in, what submission mode, extra quirks, etc. v2: Undef the right macro, use type specific pretty printers v3: Use strcmp(TYPENAME) rather than creating per-type pretty printers v4: Use __always_inline to force GCC to eliminate the calls to strcmp and generate the right call to seq_printf for each parameter. v5: With the strcmp elimination, we can now use BUILD_BUG to ensure there are no unhandled types, also use __builtin_strcmp to make it look even more magic. Signed-off-by: Chris Wilson <[email protected]> Reviewed-by: Joonas Lahtinen <[email protected]> Acked-by: Mika Kuoppala <[email protected]> Acked-by: Jani Nikula <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 1a2010c commit 642c8a7

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

drivers/gpu/drm/i915/i915_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ struct drm_i915_error_state {
904904
u32 reset_count;
905905
u32 suspend_count;
906906
struct intel_device_info device_info;
907+
struct i915_params params;
907908

908909
/* Generic register state */
909910
u32 eir;

drivers/gpu/drm/i915/i915_gpu_error.c

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,29 @@ static void err_print_capabilities(struct drm_i915_error_state_buf *m,
546546
#undef PRINT_FLAG
547547
}
548548

549+
static __always_inline void err_print_param(struct drm_i915_error_state_buf *m,
550+
const char *name,
551+
const char *type,
552+
const void *x)
553+
{
554+
if (!__builtin_strcmp(type, "bool"))
555+
err_printf(m, "i915.%s=%s\n", name, yesno(*(const bool *)x));
556+
else if (!__builtin_strcmp(type, "int"))
557+
err_printf(m, "i915.%s=%d\n", name, *(const int *)x);
558+
else if (!__builtin_strcmp(type, "unsigned int"))
559+
err_printf(m, "i915.%s=%u\n", name, *(const unsigned int *)x);
560+
else
561+
BUILD_BUG();
562+
}
563+
564+
static void err_print_params(struct drm_i915_error_state_buf *m,
565+
const struct i915_params *p)
566+
{
567+
#define PRINT(T, x) err_print_param(m, #x, #T, &p->x);
568+
I915_PARAMS_FOR_EACH(PRINT);
569+
#undef PRINT
570+
}
571+
549572
int i915_error_state_to_str(struct drm_i915_error_state_buf *m,
550573
const struct i915_error_state_file_priv *error_priv)
551574
{
@@ -568,7 +591,6 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m,
568591
error->boottime.tv_sec, error->boottime.tv_usec);
569592
err_printf(m, "Uptime: %ld s %ld us\n",
570593
error->uptime.tv_sec, error->uptime.tv_usec);
571-
err_print_capabilities(m, &error->device_info);
572594

573595
for (i = 0; i < ARRAY_SIZE(error->engine); i++) {
574596
if (error->engine[i].hangcheck_stalled &&
@@ -588,6 +610,7 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m,
588610
err_printf(m, "PCI Subsystem: %04x:%04x\n",
589611
pdev->subsystem_vendor,
590612
pdev->subsystem_device);
613+
591614
err_printf(m, "IOMMU enabled?: %d\n", error->iommu);
592615

593616
if (HAS_CSR(dev_priv)) {
@@ -730,6 +753,9 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m,
730753
if (error->display)
731754
intel_display_print_error_state(m, dev_priv, error->display);
732755

756+
err_print_capabilities(m, &error->device_info);
757+
err_print_params(m, &error->params);
758+
733759
out:
734760
if (m->bytes == 0 && m->err)
735761
return m->err;
@@ -1587,6 +1613,14 @@ static int capture(void *data)
15871613
{
15881614
struct drm_i915_error_state *error = data;
15891615

1616+
do_gettimeofday(&error->time);
1617+
error->boottime = ktime_to_timeval(ktime_get_boottime());
1618+
error->uptime =
1619+
ktime_to_timeval(ktime_sub(ktime_get(),
1620+
error->i915->gt.last_init_time));
1621+
1622+
error->params = i915;
1623+
15901624
i915_capture_gen_state(error->i915, error);
15911625
i915_capture_reg_state(error->i915, error);
15921626
i915_gem_record_fences(error->i915, error);
@@ -1595,12 +1629,6 @@ static int capture(void *data)
15951629
i915_capture_pinned_buffers(error->i915, error);
15961630
i915_gem_capture_guc_log_buffer(error->i915, error);
15971631

1598-
do_gettimeofday(&error->time);
1599-
error->boottime = ktime_to_timeval(ktime_get_boottime());
1600-
error->uptime =
1601-
ktime_to_timeval(ktime_sub(ktime_get(),
1602-
error->i915->gt.last_init_time));
1603-
16041632
error->overlay = intel_overlay_capture_error_state(error->i915);
16051633
error->display = intel_display_capture_error_state(error->i915);
16061634

0 commit comments

Comments
 (0)