anv: Add support for ANV_BO_ALLOC_AUX_CCS in anv_slab_bo

This changes allow us to support memory pool of bos with
ANV_BO_ALLOC_AUX_CCS set.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33558>
This commit is contained in:
José Roberto de Souza 2025-03-08 12:00:50 -08:00 committed by Marge Bot
parent dabb012423
commit ea18572ff2
3 changed files with 22 additions and 10 deletions

View file

@ -1601,7 +1601,7 @@ anv_bo_get_mmap_mode(struct anv_device *device, struct anv_bo *bo)
VkResult VkResult
anv_device_alloc_bo(struct anv_device *device, anv_device_alloc_bo(struct anv_device *device,
const char *name, const char *name,
uint64_t size, const uint64_t base_size,
enum anv_bo_alloc_flags alloc_flags, enum anv_bo_alloc_flags alloc_flags,
uint64_t explicit_address, uint64_t explicit_address,
struct anv_bo **bo_out) struct anv_bo **bo_out)
@ -1618,20 +1618,33 @@ anv_device_alloc_bo(struct anv_device *device,
if (device->info->has_llc && ((alloc_flags & not_allowed_promotion) == 0)) if (device->info->has_llc && ((alloc_flags & not_allowed_promotion) == 0))
alloc_flags |= ANV_BO_ALLOC_HOST_COHERENT; alloc_flags |= ANV_BO_ALLOC_HOST_COHERENT;
uint64_t ccs_offset = 0;
uint64_t size = base_size;
if (alloc_flags & ANV_BO_ALLOC_AUX_CCS) {
assert(device->info->has_aux_map);
size = align64(size, 4096);
ccs_offset = size;
size += (size / INTEL_AUX_MAP_MAIN_SIZE_SCALEDOWN);
}
uint32_t alignment = anv_bo_vma_calc_alignment_requirement(device, alloc_flags, size); uint32_t alignment = anv_bo_vma_calc_alignment_requirement(device, alloc_flags, size);
/* calling in here to avoid the 4k size promotion */
/* calling in here to avoid the 4k size promotion but we can only do that
* because ANV_BO_ALLOC_AUX_CCS is not supported by slab
*/
*bo_out = anv_slab_bo_alloc(device, name, size, alignment, alloc_flags); *bo_out = anv_slab_bo_alloc(device, name, size, alignment, alloc_flags);
if (*bo_out) if (*bo_out) {
return VK_SUCCESS; if (alloc_flags & ANV_BO_ALLOC_AUX_CCS)
(*bo_out)->ccs_offset = ccs_offset;
return VK_SUCCESS;
}
/* bo was not allocated in slab, so reset size again to base_size */
size = base_size;
/* The kernel is going to give us whole pages anyway. */ /* The kernel is going to give us whole pages anyway. */
size = align64(size, 4096); size = align64(size, 4096);
const uint64_t ccs_offset = size;
if (alloc_flags & ANV_BO_ALLOC_AUX_CCS) { if (alloc_flags & ANV_BO_ALLOC_AUX_CCS) {
ccs_offset = size;
assert(device->info->has_aux_map); assert(device->info->has_aux_map);
size += size / INTEL_AUX_MAP_MAIN_SIZE_SCALEDOWN; size += size / INTEL_AUX_MAP_MAIN_SIZE_SCALEDOWN;
size = align64(size, 4096); size = align64(size, 4096);

View file

@ -2304,7 +2304,7 @@ anv_sanitize_map_params(struct anv_device *device,
VkResult anv_device_alloc_bo(struct anv_device *device, VkResult anv_device_alloc_bo(struct anv_device *device,
const char *name, uint64_t size, const char *name, const uint64_t size,
enum anv_bo_alloc_flags alloc_flags, enum anv_bo_alloc_flags alloc_flags,
uint64_t explicit_address, uint64_t explicit_address,
struct anv_bo **bo); struct anv_bo **bo);

View file

@ -39,7 +39,6 @@ anv_bo_alloc_flags_to_slab_heap(struct anv_device *device,
ANV_BO_ALLOC_PROTECTED | ANV_BO_ALLOC_PROTECTED |
ANV_BO_ALLOC_DYNAMIC_VISIBLE_POOL | ANV_BO_ALLOC_DYNAMIC_VISIBLE_POOL |
ANV_BO_ALLOC_IMPORTED | ANV_BO_ALLOC_IMPORTED |
ANV_BO_ALLOC_AUX_CCS |
ANV_BO_ALLOC_SLAB_PARENT; ANV_BO_ALLOC_SLAB_PARENT;
if (device->info->kmd_type == INTEL_KMD_TYPE_I915) { if (device->info->kmd_type == INTEL_KMD_TYPE_I915) {