anv: Request Xe KMD to place BOs to CPU visible VRAM when required

This is required to support discrete GPUs placed in systems with large
PCI bar or resizeble PCI bar not available or disabled.

Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23781>
This commit is contained in:
José Roberto de Souza 2023-06-13 11:12:48 -07:00 committed by Marge Bot
parent f9fcd7168a
commit f59d272e93

View file

@ -40,6 +40,14 @@ xe_gem_create(struct anv_device *device,
enum anv_bo_alloc_flags alloc_flags,
uint64_t *actual_size)
{
uint32_t flags = 0;
if (alloc_flags & ANV_BO_ALLOC_SCANOUT)
flags |= XE_GEM_CREATE_FLAG_SCANOUT;
if ((alloc_flags & (ANV_BO_ALLOC_MAPPED | ANV_BO_ALLOC_LOCAL_MEM_CPU_VISIBLE)) &&
!(alloc_flags & ANV_BO_ALLOC_NO_LOCAL_MEM) &&
device->physical->vram_non_mappable.size > 0)
flags |= XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM;
struct drm_xe_gem_create gem_create = {
/* From xe_drm.h: If a VM is specified, this BO must:
* 1. Only ever be bound to that VM.
@ -47,7 +55,7 @@ xe_gem_create(struct anv_device *device,
*/
.vm_id = alloc_flags & ANV_BO_ALLOC_EXTERNAL ? 0 : device->vm_id,
.size = align64(size, device->info->mem_alignment),
.flags = alloc_flags & ANV_BO_ALLOC_SCANOUT ? XE_GEM_CREATE_FLAG_SCANOUT : 0,
.flags = flags,
};
for (uint16_t i = 0; i < regions_count; i++)
gem_create.flags |= BITFIELD_BIT(regions[i]->instance);