From 04bfdb287be6248fb44162df248968426907f0bd Mon Sep 17 00:00:00 2001 From: Calder Young Date: Fri, 6 Feb 2026 16:13:26 -0800 Subject: [PATCH] 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 Part-of: --- src/intel/vulkan/anv_instance.c | 1 + src/intel/vulkan/anv_physical_device.c | 9 +++++++++ src/intel/vulkan/anv_private.h | 2 ++ src/intel/vulkan/xe/anv_device.c | 3 ++- src/util/driconf.h | 4 ++++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/intel/vulkan/anv_instance.c b/src/intel/vulkan/anv_instance.c index 89d52005b01..719e7b9f587 100644 --- a/src/intel/vulkan/anv_instance.c +++ b/src/intel/vulkan/anv_instance.c @@ -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 diff --git a/src/intel/vulkan/anv_physical_device.c b/src/intel/vulkan/anv_physical_device.c index 6f5d47dda4b..5c0bafffe65 100644 --- a/src/intel/vulkan/anv_physical_device.c +++ b/src/intel/vulkan/anv_physical_device.c @@ -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) diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 983a9c48145..d1adc113ba2 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -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]; diff --git a/src/intel/vulkan/xe/anv_device.c b/src/intel/vulkan/xe/anv_device.c index ff113cf4ca6..4a5e01c37b4 100644 --- a/src/intel/vulkan/xe/anv_device.c +++ b/src/intel/vulkan/xe/anv_device.c @@ -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, diff --git a/src/util/driconf.h b/src/util/driconf.h index fc669e82e91..98e53529ae7 100644 --- a/src/util/driconf.h +++ b/src/util/driconf.h @@ -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 */