drm/xe/devcoredump: Print errno if VM snapshot was not captured

My testing machine has only 8GB of RAM and while running piglit tests
I can reach the OOM cache in xe_vm_snapshot_capture() snap allocaiton
sometimes.

So to differentiate the OOM from race between capture and UMDs
unbinbind VMs here I'm adding a '[0].error: -12' to devcoredump.

v2:
- fix returned errno values

Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240307135229.41973-2-jose.souza@intel.com
parent 241dea21
...@@ -120,10 +120,8 @@ static ssize_t xe_devcoredump_read(char *buffer, loff_t offset, ...@@ -120,10 +120,8 @@ static ssize_t xe_devcoredump_read(char *buffer, loff_t offset,
if (coredump->snapshot.hwe[i]) if (coredump->snapshot.hwe[i])
xe_hw_engine_snapshot_print(coredump->snapshot.hwe[i], xe_hw_engine_snapshot_print(coredump->snapshot.hwe[i],
&p); &p);
if (coredump->snapshot.vm) { drm_printf(&p, "\n**** VM state ****\n");
drm_printf(&p, "\n**** VM state ****\n"); xe_vm_snapshot_print(coredump->snapshot.vm, &p);
xe_vm_snapshot_print(coredump->snapshot.vm, &p);
}
return count - iter.remain; return count - iter.remain;
} }
......
...@@ -3359,8 +3359,10 @@ struct xe_vm_snapshot *xe_vm_snapshot_capture(struct xe_vm *vm) ...@@ -3359,8 +3359,10 @@ struct xe_vm_snapshot *xe_vm_snapshot_capture(struct xe_vm *vm)
if (num_snaps) if (num_snaps)
snap = kvzalloc(offsetof(struct xe_vm_snapshot, snap[num_snaps]), GFP_NOWAIT); snap = kvzalloc(offsetof(struct xe_vm_snapshot, snap[num_snaps]), GFP_NOWAIT);
if (!snap) if (!snap) {
snap = num_snaps ? ERR_PTR(-ENOMEM) : ERR_PTR(-ENODEV);
goto out_unlock; goto out_unlock;
}
snap->num_snaps = num_snaps; snap->num_snaps = num_snaps;
i = 0; i = 0;
...@@ -3400,7 +3402,7 @@ struct xe_vm_snapshot *xe_vm_snapshot_capture(struct xe_vm *vm) ...@@ -3400,7 +3402,7 @@ struct xe_vm_snapshot *xe_vm_snapshot_capture(struct xe_vm *vm)
void xe_vm_snapshot_capture_delayed(struct xe_vm_snapshot *snap) void xe_vm_snapshot_capture_delayed(struct xe_vm_snapshot *snap)
{ {
if (!snap) if (IS_ERR(snap))
return; return;
for (int i = 0; i < snap->num_snaps; i++) { for (int i = 0; i < snap->num_snaps; i++) {
...@@ -3457,6 +3459,11 @@ void xe_vm_snapshot_print(struct xe_vm_snapshot *snap, struct drm_printer *p) ...@@ -3457,6 +3459,11 @@ void xe_vm_snapshot_print(struct xe_vm_snapshot *snap, struct drm_printer *p)
{ {
unsigned long i, j; unsigned long i, j;
if (IS_ERR(snap)) {
drm_printf(p, "[0].error: %li\n", PTR_ERR(snap));
return;
}
for (i = 0; i < snap->num_snaps; i++) { for (i = 0; i < snap->num_snaps; i++) {
drm_printf(p, "[%llx].length: 0x%lx\n", snap->snap[i].ofs, snap->snap[i].len); drm_printf(p, "[%llx].length: 0x%lx\n", snap->snap[i].ofs, snap->snap[i].len);
...@@ -3483,7 +3490,7 @@ void xe_vm_snapshot_free(struct xe_vm_snapshot *snap) ...@@ -3483,7 +3490,7 @@ void xe_vm_snapshot_free(struct xe_vm_snapshot *snap)
{ {
unsigned long i; unsigned long i;
if (!snap) if (IS_ERR(snap))
return; return;
for (i = 0; i < snap->num_snaps; i++) { for (i = 0; i < snap->num_snaps; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment