[PATCH v5 9/9] drm/xe: Implement capture of HWSP and HWCTX

Souza, Jose jose.souza at intel.com
Wed Feb 21 17:45:02 UTC 2024


On Wed, 2024-02-21 at 14:30 +0100, Maarten Lankhorst wrote:
> Capture both the HWSP and the HW ctx page to allow easier replaying of
> error dumps for debugging.

Another fresh warning with this patch:


[  305.125972] loop0: detected capacity change from 0 to 8
[  562.377734] irq event stamp: 574727
[  562.377735] stack segment: 0000 [#1] PREEMPT SMP
[  562.377745] CPU: 1 PID: 21 Comm: kworker/1:0 Not tainted 6.8.0-rc5-zeh-xe+ #1233
[  562.377786] hardirqs last  enabled at (574727): [<ffffffff81381e06>] d_walk+0x336/0x500
[  562.377826] Hardware name: Dell Inc. Latitude 5420/01M3M4, BIOS 1.27.0 03/17/2023
[  562.377862] hardirqs last disabled at (574726): [<ffffffff81381dce>] d_walk+0x2fe/0x500
[  562.377897] Workqueue: events devcd_del
[  562.377929] softirqs last  enabled at (574694): [<ffffffff81131982>] irq_exit_rcu+0x82/0xe0

[  562.377981] softirqs last disabled at (574677): [<ffffffff81131982>] irq_exit_rcu+0x82/0xe0
[  562.378013] RIP: 0010:dma_resv_iter_first_unlocked+0x4b/0x220
[  562.378025] Code: 31 f6 48 c7 c7 c0 a7 74 82 e8 21 1f 8b ff e8 bc 38 42 00 5a 85 c0 74 45 e9 50 01 00 00 48 89 6b 20 48 85 ed 0f 84 10 01 00 00
<8b> 45 10 c6 43 2c 01 48 89 df 89 43 28 e8 f3 fd ff ff 48 8b 2b 4c
[  562.378171] RSP: 0018:ffffc900001a3cd0 EFLAGS: 00010202
[  562.378206] RAX: 0000000000000001 RBX: ffffc900001a3cf0 RCX: 0000000000000000
[  562.378236] RDX: 0000000080000000 RSI: ffffffff8239d70d RDI: ffffffff823c33ad
[  562.378265] RBP: 6b6b6b6b6b6b6b6b R08: 000000005332c191 R09: 0000000000000000
[  562.378298] R10: 0000000000000001 R11: 0000000000000003 R12: ffff88812fd1c140
[  562.378334] R13: ffff88813d43a140 R14: 0000000000000000 R15: ffffffff8114e2bd
[  562.378364] FS:  0000000000000000(0000) GS:ffff888287880000(0000) knlGS:0000000000000000
[  562.378415] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  562.378450] CR2: 00007fe76c011048 CR3: 000000000564a001 CR4: 0000000000770ef0
[  562.378484] PKRU: 55555554
[  562.378508] Call Trace:
[  562.378531]  <TASK>
[  562.378550]  ? die+0x2d/0x80
[  562.378583]  ? do_trap+0xcd/0xf0
[  562.378619]  ? do_error_trap+0x78/0x100
[  562.378660]  ? exc_stack_segment+0x33/0x50
[  562.378702]  ? asm_exc_stack_segment+0x22/0x30
[  562.378747]  ? process_one_work+0x18d/0x4d0
[  562.378793]  ? dma_resv_iter_first_unlocked+0x4b/0x220
[  562.378846]  dma_resv_copy_fences+0x4d/0x230
[  562.378894]  ttm_bo_release+0xab/0x330 [ttm]
[  562.378958]  ? process_one_work+0x18d/0x4d0
[  562.379001]  xe_lrc_snapshot_free+0x47/0x50 [xe]
[  562.379217]  xe_guc_exec_queue_snapshot_free+0x29/0x60 [xe]
[  562.379398]  xe_devcoredump_free+0x47/0xd0 [xe]
[  562.379534]  devcd_dev_release+0x11/0x50
[  562.379560]  device_release+0x2b/0x80
[  562.379584]  kobject_put+0x79/0x1b0
[  562.379609]  process_one_work+0x1f4/0x4d0
[  562.379638]  worker_thread+0x1d8/0x3c0
[  562.379662]  ? rescuer_thread+0x390/0x390
[  562.379687]  kthread+0xfb/0x130
[  562.379709]  ? kthread_complete_and_exit+0x20/0x20
[  562.379737]  ret_from_fork+0x28/0x40
[  562.379762]  ? kthread_complete_and_exit+0x20/0x20
[  562.379788]  ret_from_fork_asm+0x11/0x20
[  562.379815]  </TASK>
[  562.379828] Modules linked in: snd_hda_codec_hdmi snd_ctl_led ledtrig_audio snd_hda_codec_realtek snd_hda_codec_generic xe drm_ttm_helper gpu_sched
drm_suballoc_helper drm_gpuvm drm_exec i2c_algo_bit drm_buddy drm_display_helper ttm mei_hdcp mei_pxp x86_pkg_temp_thermal wmi_bmof snd_hda_intel
snd_intel_dspcfg coretemp snd_hda_codec crct10dif_pclmul snd_hwdep crc32_pclmul e1000e snd_hda_core video ptp ghash_clmulni_intel kvm_intel snd_pcm
mei_me pps_core i2c_i801 i2c_smbus mei intel_pmc_core intel_vsec wmi pmt_telemetry pmt_class fuse
[  562.380129] ---[ end trace 0000000000000000 ]---
[  562.769574] RIP: 0010:dma_resv_iter_first_unlocked+0x4b/0x220
[  562.769620] Code: 31 f6 48 c7 c7 c0 a7 74 82 e8 21 1f 8b ff e8 bc 38 42 00 5a 85 c0 74 45 e9 50 01 00 00 48 89 6b 20 48 85 ed 0f 84 10 01 00 00
<8b> 45 10 c6 43 2c 01 48 89 df 89 43 28 e8 f3 fd ff ff 48 8b 2b 4c
[  562.769693] RSP: 0018:ffffc900001a3cd0 EFLAGS: 00010202
[  562.769712] RAX: 0000000000000001 RBX: ffffc900001a3cf0 RCX: 0000000000000000
[  562.769737] RDX: 0000000080000000 RSI: ffffffff8239d70d RDI: ffffffff823c33ad
[  562.769763] RBP: 6b6b6b6b6b6b6b6b R08: 000000005332c191 R09: 0000000000000000
[  562.769792] R10: 0000000000000001 R11: 0000000000000003 R12: ffff88812fd1c140
[  562.769821] R13: ffff88813d43a140 R14: 0000000000000000 R15: ffffffff8114e2bd
[  562.769842] FS:  0000000000000000(0000) GS:ffff888287880000(0000) knlGS:0000000000000000
[  562.769861] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  562.769875] CR2: 00007fe76c011048 CR3: 000000010d893003 CR4: 0000000000770ef0
[  562.771018] PKRU: 55555554
[  562.772286] BUG: sleeping function called from invalid context at include/linux/percpu-rwsem.h:49
[  562.773445] in_atomic(): 0, irqs_disabled(): 0, non_block: 0, pid: 21, name: kworker/1:0
[  562.774685] preempt_count: 0, expected: 0
[  562.775814] RCU nest depth: 1, expected: 0
[  562.776958] INFO: lockdep is turned off.
[  562.778194] CPU: 1 PID: 21 Comm: kworker/1:0 Tainted: G      D            6.8.0-rc5-zeh-xe+ #1233
[  562.779480] Hardware name: Dell Inc. Latitude 5420/01M3M4, BIOS 1.27.0 03/17/2023
[  562.780790] Workqueue: events devcd_del
[  562.782094] Call Trace:
[  562.783389]  <TASK>
[  562.784671]  dump_stack_lvl+0x7a/0xb0
[  562.785931]  __might_resched+0x19e/0x2b0
[  562.787179]  exit_signals+0x15/0x350
[  562.788396]  do_exit+0x175/0xbb0
[  562.789581]  ? rescuer_thread+0x390/0x390
[  562.790749]  make_task_dead+0x76/0x160
[  562.791948]  rewind_stack_and_make_dead+0x17/0x20
[  562.793120] RIP: 0000:0x0
[  562.794282] Code: Unable to access opcode bytes at 0xffffffffffffffd6.
[  562.795456] RSP: 0000:0000000000000000 EFLAGS: 00000000 ORIG_RAX: 0000000000000000
[  562.796636] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
[  562.797805] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
[  562.798952] RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
[  562.800102] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
[  562.801348] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
[  562.802521]  </TASK>
[  605.098663] loop0: detected capacity change from 0 to 8




> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
> ---
>  drivers/gpu/drm/xe/xe_lrc.c | 60 ++++++++++++++++++++++++++++++++++++-
>  1 file changed, 59 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
> index 20f235cdaca34..93c139f8d4fed 100644
> --- a/drivers/gpu/drm/xe/xe_lrc.c
> +++ b/drivers/gpu/drm/xe/xe_lrc.c
> @@ -5,6 +5,8 @@
>  
>  #include "xe_lrc.h"
>  
> +#include <linux/ascii85.h>
> +
>  #include "instructions/xe_mi_commands.h"
>  #include "instructions/xe_gfxpipe_commands.h"
>  #include "regs/xe_engine_regs.h"
> @@ -32,6 +34,10 @@
>  #define ENGINE_INSTANCE_SHIFT			48
>  
>  struct xe_lrc_snapshot {
> +	struct xe_bo *lrc_bo;
> +	void *lrc_snapshot;
> +	unsigned long lrc_size, lrc_offset;
> +
>  	u32 context_desc;
>  	u32 head;
>  	struct {
> @@ -1333,19 +1339,43 @@ struct xe_lrc_snapshot *xe_lrc_snapshot_capture(struct xe_lrc *lrc)
>  	snapshot->tail.memory = xe_lrc_read_ctx_reg(lrc, CTX_RING_TAIL);
>  	snapshot->start_seqno = xe_lrc_start_seqno(lrc);
>  	snapshot->seqno = xe_lrc_seqno(lrc);
> +	snapshot->lrc_bo = xe_bo_get(lrc->bo);
> +	snapshot->lrc_offset = xe_lrc_pphwsp_offset(lrc);
> +	snapshot->lrc_size = lrc->bo->size - snapshot->lrc_offset;
> +	snapshot->lrc_snapshot = NULL;
>  	return snapshot;
>  }
>  
>  void xe_lrc_snapshot_capture_delayed(struct xe_lrc_snapshot *snapshot)
>  {
> +	struct xe_bo *bo;
> +	struct iosys_map src;
> +
>  	if (!snapshot)
>  		return;
>  
> -	/* TODO: Copy status page */
> +	bo = snapshot->lrc_bo;
> +	snapshot->lrc_snapshot = kvmalloc(snapshot->lrc_size, GFP_KERNEL);
> +	if (!snapshot->lrc_snapshot)
> +		return;
> +
> +	dma_resv_lock(bo->ttm.base.resv, NULL);
> +	if (!ttm_bo_vmap(&bo->ttm, &src)) {
> +		xe_map_memcpy_from(xe_bo_device(bo),
> +				   snapshot->lrc_snapshot, &src, snapshot->lrc_offset,
> +				   snapshot->lrc_size);
> +		ttm_bo_vunmap(&bo->ttm, &src);
> +	} else {
> +		kvfree(snapshot->lrc_snapshot);
> +		snapshot->lrc_snapshot = NULL;
> +	}
> +	dma_resv_unlock(bo->ttm.base.resv);
>  }
>  
>  void xe_lrc_snapshot_print(struct xe_lrc_snapshot *snapshot, struct drm_printer *p)
>  {
> +	unsigned long i;
> +
>  	if (!snapshot)
>  		return;
>  
> @@ -1355,9 +1385,37 @@ void xe_lrc_snapshot_print(struct xe_lrc_snapshot *snapshot, struct drm_printer
>  		   snapshot->tail.internal, snapshot->tail.memory);
>  	drm_printf(p, "\tStart seqno: (memory) %d\n", snapshot->start_seqno);
>  	drm_printf(p, "\tSeqno: (memory) %d\n", snapshot->seqno);
> +
> +	if (!snapshot->lrc_snapshot)
> +		return;
> +
> +	drm_printf(p, "\t HWSP length: 0x%x\n", LRC_PPHWSP_SIZE);
> +	drm_puts(p, "\tHWSP data: ");
> +
> +	for (i = 0; i < LRC_PPHWSP_SIZE; i += sizeof(u32)) {
> +		u32 *val = snapshot->lrc_snapshot + i;
> +		char dumped[ASCII85_BUFSZ];
> +
> +		drm_puts(p, ascii85_encode(*val, dumped));
> +	}
> +	drm_printf(p, "\n\tHWCTX length: 0x%lx\n", snapshot->lrc_size - LRC_PPHWSP_SIZE);
> +	drm_puts(p, "\tHWCTX data: ");
> +	for (; i < snapshot->lrc_size; i += sizeof(u32)) {
> +		u32 *val = snapshot->lrc_snapshot + i;
> +		char dumped[ASCII85_BUFSZ];
> +
> +		drm_puts(p, ascii85_encode(*val, dumped));
> +	}
> +	drm_puts(p, "\n");
>  }
>  
>  void xe_lrc_snapshot_free(struct xe_lrc_snapshot *snapshot)
>  {
> +	if (!snapshot)
> +		return;
> +
> +	kvfree(snapshot->lrc_snapshot);
> +	if (snapshot->lrc_bo)
> +		xe_bo_put(snapshot->lrc_bo);
>  	kfree(snapshot);
>  }



More information about the Intel-xe mailing list