anv: Disable scratch page by default on Xe KMD

Page faults will now cause the device to be lost instead of being ignored.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40149>
This commit is contained in:
Calder Young 2026-02-06 16:13:26 -08:00 committed by Marge Bot
parent 4120ae4963
commit 04bfdb287b
5 changed files with 18 additions and 1 deletions

View file

@ -108,6 +108,7 @@ static const driOptionDescription anv_dri_options[] = {
DRI_CONF_VK_REQUIRE_ASTC(false)
#endif
DRI_CONF_ANV_VF_COMPONENT_PACKING(true)
DRI_CONF_ANV_ENABLE_SCRATCH_PAGE(false)
DRI_CONF_SECTION_END
DRI_CONF_SECTION_QUALITY

View file

@ -2845,6 +2845,14 @@ anv_physical_device_try_create(struct vk_instance *vk_instance,
device->always_flush_cache = INTEL_DEBUG(DEBUG_STALL) ||
driQueryOptionb(&instance->dri_options, "always_flush_cache");
/* The ring buffer mechanism for page fault reporting is not supported until
* PVC (unsupported by our Mesa driver), so we keep the scratch page enabled
* for anything before Xe2 since debugging it would be impossible.
*/
device->has_scratch_page =
device->info.ver < 20 || device->info.kmd_type == INTEL_KMD_TYPE_I915 ||
driQueryOptionb(&instance->dri_options, "anv_enable_scratch_page");
device->compiler = brw_compiler_create(NULL, &device->info);
if (device->compiler == NULL) {
result = vk_error(instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@ -2861,6 +2869,7 @@ anv_physical_device_try_create(struct vk_instance *vk_instance,
driQueryOptionb(&instance->dri_options, "intel_sampler_route_to_lsc");
device->isl_dev.l1_storage_wt =
driQueryOptionb(&instance->dri_options, "intel_storage_cache_policy_wt");
device->isl_dev.requires_padding = !device->has_scratch_page;
result = anv_physical_device_init_uuids(device);
if (result != VK_SUCCESS)

View file

@ -1617,6 +1617,8 @@ struct anv_physical_device {
*/
bool rt_change_needs_flush;
bool has_scratch_page;
struct {
uint32_t family_count;
struct anv_queue_family families[ANV_MAX_QUEUE_FAMILIES];

View file

@ -43,7 +43,8 @@ bool anv_xe_device_destroy_vm(struct anv_device *device)
VkResult anv_xe_device_setup_vm(struct anv_device *device)
{
struct drm_xe_vm_create create = {
.flags = DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE,
.flags = device->physical->has_scratch_page ?
DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE : 0
};
if (intel_ioctl(device->fd, DRM_IOCTL_XE_VM_CREATE, &create) != 0)
return vk_errorf(device, VK_ERROR_INITIALIZATION_FAILED,

View file

@ -968,6 +968,10 @@
DRI_CONF_OPT_B(anv_brw_disable_subgroup_size_control, def, \
"Disable EXT_subgroup_size_control support when using brw compiler.")
#define DRI_CONF_ANV_ENABLE_SCRATCH_PAGE(def) \
DRI_CONF_OPT_B(anv_enable_scratch_page, def, \
"Disables surface padding and suppresses all page faults, drops writes and returns zeros on reads.")
/**
* \brief HASVK specific configuration options
*/