iris: Handle allocation of exported buffers in Xe kmd

Bos that will be exported need to be allocated with vm_id = 0 in Xe,
so don't try to get a bo from cache that was allocated with a
valid vm_id.

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/22060>
This commit is contained in:
José Roberto de Souza 2023-02-14 11:49:17 -08:00 committed by Marge Bot
parent 41ddecc8b2
commit ccffcec03e
2 changed files with 10 additions and 3 deletions

View file

@ -313,8 +313,12 @@ static struct bo_cache_bucket *
bucket_for_size(struct iris_bufmgr *bufmgr, uint64_t size,
enum iris_heap heap, unsigned flags)
{
/* Protected bo needs special handling during allocation */
if (flags & BO_ALLOC_PROTECTED)
/* Protected bo needs special handling during allocation.
* Exported bo also need special handling during allocation in Xe KMD
*/
if ((flags & BO_ALLOC_PROTECTED) ||
((flags & BO_ALLOC_SHARED) && bufmgr->devinfo.kmd_type == INTEL_KMD_TYPE_XE))
return NULL;
/* Calculating the pages and rounding up to the page size. */

View file

@ -42,8 +42,11 @@ xe_gem_create(struct iris_bufmgr *bufmgr,
if (alloc_flags & BO_ALLOC_PROTECTED)
return -EINVAL;
uint32_t vm_id = iris_bufmgr_get_global_vm_id(bufmgr);
vm_id = alloc_flags & BO_ALLOC_SHARED ? 0 : vm_id;
struct drm_xe_gem_create gem_create = {
.vm_id = iris_bufmgr_get_global_vm_id(bufmgr),
.vm_id = vm_id,
.size = align64(size, iris_bufmgr_get_device_info(bufmgr)->mem_alignment),
};
for (uint16_t i = 0; i < regions_count; i++)