anv: Print page faults whenever a queue gets banned

Prints the page faults to STDERR whenever a banned queue is detected for
added visibility to developers.

Currently, the only way to get this information without using the device
fault extension is to increase the kernel logging verbosity and check dmesg
after a lost device. In my opinion its a lot more convenient for all parties
involved if the driver could just print this directly to the log instead.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41318>
This commit is contained in:
Calder Young 2026-04-08 14:36:42 -07:00 committed by Marge Bot
parent 249c227fa4
commit 6fd3962cfa

View file

@ -6,6 +6,27 @@
#include "anv_private.h"
static inline void
anv_device_print_vm_faults(struct anv_device *device)
{
struct intel_pagefault_buffer *faults =
anv_device_alloc_get_vm_faults(device);
if (!faults)
return;
for (unsigned i = 0; i < faults->size; ++i) {
mesa_loge("[GPU-VM-FAULT] Page Address: 0x%016"PRIx64", "
"Page Size: 0x%04x, Access: %s, Type: %s, Level: %s",
faults->items[i].address, faults->items[i].precision,
intel_pagefault_access_to_string(faults->items[i].access),
intel_pagefault_type_to_string(faults->items[i].type),
intel_pagefault_level_to_string(faults->items[i].level));
}
free(faults);
}
void
anv_device_update_fault_state(struct anv_device *device,
int device_errno)
@ -29,6 +50,8 @@ anv_queue_update_fault_state(struct anv_queue *queue,
assert(queue_errno != 0);
struct anv_device *device = queue->device;
bool print_vm_faults = false;
mtx_lock(&device->fault.mutex);
struct anv_device_fault_state *state = &device->fault.state;
@ -39,7 +62,11 @@ anv_queue_update_fault_state(struct anv_queue *queue,
state->queue.family = queue->vk.queue_family_index;
state->queue.index = queue->vk.index_in_family;
state->queue.flags = queue->vk.flags;
print_vm_faults = queue_errno == ECANCELED;
}
mtx_unlock(&device->fault.mutex);
if (print_vm_faults)
anv_device_print_vm_faults(device);
}