anv: Add ANV_BO_ALLOC_IMPORTED

The next patch will replace anv_bo.is_vram by a anv_bo.alloc_flags
check but to that actually work we can't use ANV_BO_ALLOC_NO_LOCAL_MEM
for imported bos, so here adding it.

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10291
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/26711>
This commit is contained in:
José Roberto de Souza
2023-12-15 08:07:32 -08:00
committed by Marge Bot
parent 5683c54d8f
commit 060439bdf0
3 changed files with 12 additions and 6 deletions

View File

@@ -1431,7 +1431,8 @@ anv_bo_get_mmap_mode(struct anv_device *device, struct anv_bo *bo)
return anv_device_get_pat_entry(device, alloc_flags)->mmap;
if (anv_physical_device_has_vram(device->physical)) {
if (alloc_flags & ANV_BO_ALLOC_NO_LOCAL_MEM)
if ((alloc_flags & ANV_BO_ALLOC_NO_LOCAL_MEM) ||
(alloc_flags & ANV_BO_ALLOC_IMPORTED))
return INTEL_DEVICE_INFO_MMAP_MODE_WB;
return INTEL_DEVICE_INFO_MMAP_MODE_WC;
@@ -1665,8 +1666,7 @@ anv_device_import_bo_from_host_ptr(struct anv_device *device,
__sync_fetch_and_add(&bo->refcount, 1);
} else {
/* Makes sure that userptr gets WB+1way host caching */
alloc_flags |= (ANV_BO_ALLOC_HOST_CACHED_COHERENT | ANV_BO_ALLOC_NO_LOCAL_MEM);
alloc_flags |= ANV_BO_ALLOC_IMPORTED;
struct anv_bo new_bo = {
.name = "host-ptr",
.gem_handle = gem_handle,
@@ -1756,8 +1756,7 @@ anv_device_import_bo(struct anv_device *device,
__sync_fetch_and_add(&bo->refcount, 1);
} else {
/* so imported bos get WB+1way host caching */
alloc_flags |= (ANV_BO_ALLOC_HOST_CACHED_COHERENT | ANV_BO_ALLOC_NO_LOCAL_MEM);
alloc_flags |= ANV_BO_ALLOC_IMPORTED;
struct anv_bo new_bo = {
.name = "imported",
.gem_handle = gem_handle,

View File

@@ -5112,7 +5112,8 @@ anv_device_get_pat_entry(struct anv_device *device,
* This might change in future discrete platforms.
*/
if (anv_physical_device_has_vram(device->physical)) {
if (alloc_flags & ANV_BO_ALLOC_NO_LOCAL_MEM)
if ((alloc_flags & ANV_BO_ALLOC_NO_LOCAL_MEM) ||
(alloc_flags & ANV_BO_ALLOC_IMPORTED))
return &device->info->pat.cached_coherent;
return &device->info->pat.writecombining;
}

View File

@@ -436,6 +436,12 @@ enum anv_bo_alloc_flags {
/** For sampler pools */
ANV_BO_ALLOC_SAMPLER_POOL = (1 << 17),
/** Specifies that the BO is imported.
*
* Imported BOs must also be marked as ANV_BO_ALLOC_EXTERNAL
*/
ANV_BO_ALLOC_IMPORTED = (1 << 18),
/** Specifies that the BO should be cached and coherent. */
ANV_BO_ALLOC_HOST_CACHED_COHERENT = (ANV_BO_ALLOC_HOST_COHERENT | ANV_BO_ALLOC_HOST_CACHED),
};