anv: Start to move anv_gem_stubs.c to kmd backend
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/20948>
This commit is contained in:

committed by
Marge Bot

parent
de79cf0512
commit
c8626a20bb
@@ -26,6 +26,7 @@
|
||||
enum intel_kmd_type {
|
||||
INTEL_KMD_TYPE_INVALID = 0,
|
||||
INTEL_KMD_TYPE_I915,
|
||||
INTEL_KMD_TYPE_STUB, /* Only used by ANV to run tests */
|
||||
INTEL_KMD_TYPE_LAST
|
||||
};
|
||||
|
||||
|
@@ -1478,8 +1478,10 @@ anv_device_alloc_bo(struct anv_device *device,
|
||||
regions[nregions++] = device->physical->sys.region;
|
||||
}
|
||||
|
||||
uint32_t gem_handle = anv_gem_create(device, size + ccs_size, alloc_flags,
|
||||
nregions, regions);
|
||||
uint32_t gem_handle = device->kmd_backend->gem_create(device, regions,
|
||||
nregions,
|
||||
size + ccs_size,
|
||||
alloc_flags);
|
||||
if (gem_handle == 0)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
|
||||
|
@@ -42,15 +42,6 @@ anv_gem_close(struct anv_device *device, uint32_t gem_handle)
|
||||
intel_ioctl(device->fd, DRM_IOCTL_GEM_CLOSE, &close);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
anv_gem_create(struct anv_device *device, uint64_t anv_bo_size,
|
||||
enum anv_bo_alloc_flags alloc_flags, uint32_t num_regions,
|
||||
const struct intel_memory_class_instance **regions)
|
||||
{
|
||||
return device->kmd_backend->gem_create(device, regions, num_regions,
|
||||
anv_bo_size, alloc_flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper around DRM_IOCTL_I915_GEM_MMAP. Returns MAP_FAILED on error.
|
||||
*/
|
||||
@@ -255,3 +246,8 @@ anv_gem_fd_to_handle(struct anv_device *device, int fd)
|
||||
|
||||
return args.handle;
|
||||
}
|
||||
|
||||
const struct anv_kmd_backend *anv_stub_kmd_backend_get(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -33,10 +33,11 @@ anv_gem_close(struct anv_device *device, uint32_t gem_handle)
|
||||
close(gem_handle);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
anv_gem_create(struct anv_device *device, uint64_t size,
|
||||
enum anv_bo_alloc_flags alloc_flags, uint32_t num_regions,
|
||||
const struct intel_memory_class_instance **regions)
|
||||
static uint32_t
|
||||
stub_gem_create(struct anv_device *device,
|
||||
const struct intel_memory_class_instance **regions,
|
||||
uint16_t num_regions, uint64_t size,
|
||||
enum anv_bo_alloc_flags alloc_flags)
|
||||
{
|
||||
int fd = os_create_anonymous_file(size, "fake bo");
|
||||
if (fd == -1)
|
||||
@@ -123,3 +124,11 @@ anv_i915_query(int fd, uint64_t query_id, void *buffer,
|
||||
{
|
||||
unreachable("Unused");
|
||||
}
|
||||
|
||||
const struct anv_kmd_backend *anv_stub_kmd_backend_get(void)
|
||||
{
|
||||
static const struct anv_kmd_backend stub_backend = {
|
||||
.gem_create = stub_gem_create,
|
||||
};
|
||||
return &stub_backend;
|
||||
}
|
||||
|
@@ -31,6 +31,8 @@ anv_kmd_backend_get(enum intel_kmd_type type)
|
||||
switch (type) {
|
||||
case INTEL_KMD_TYPE_I915:
|
||||
return anv_i915_kmd_backend_get();
|
||||
case INTEL_KMD_TYPE_STUB:
|
||||
return anv_stub_kmd_backend_get();
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -46,3 +46,4 @@ const struct anv_kmd_backend *anv_kmd_backend_get(enum intel_kmd_type type);
|
||||
|
||||
/* Internal functions, should only be called by anv_kmd_backend_get() */
|
||||
const struct anv_kmd_backend *anv_i915_kmd_backend_get(void);
|
||||
const struct anv_kmd_backend *anv_stub_kmd_backend_get(void);
|
||||
|
@@ -1348,9 +1348,6 @@ void* anv_gem_mmap(struct anv_device *device, struct anv_bo *bo,
|
||||
uint64_t offset, uint64_t size, uint32_t flags);
|
||||
void anv_gem_munmap(struct anv_device *device, void *p, uint64_t size);
|
||||
void anv_gem_close(struct anv_device *device, uint32_t gem_handle);
|
||||
uint32_t anv_gem_create(struct anv_device *device, uint64_t anv_bo_size,
|
||||
enum anv_bo_alloc_flags alloc_flags, uint32_t num_regions,
|
||||
const struct intel_memory_class_instance **regions);
|
||||
uint32_t anv_gem_userptr(struct anv_device *device, void *mem, size_t size);
|
||||
int anv_gem_wait(struct anv_device *device, uint32_t gem_handle, int64_t *timeout_ns);
|
||||
int anv_gem_set_tiling(struct anv_device *device, uint32_t gem_handle,
|
||||
|
@@ -37,6 +37,7 @@ int main(void)
|
||||
const uint32_t initial_size = block_size / 2;
|
||||
|
||||
anv_device_set_physical(&device, &physical_device);
|
||||
device.kmd_backend = anv_kmd_backend_get(INTEL_KMD_TYPE_STUB);
|
||||
pthread_mutex_init(&device.mutex, NULL);
|
||||
anv_bo_cache_init(&device.bo_cache, &device);
|
||||
anv_block_pool_init(&pool, &device, "test", 4096, initial_size);
|
||||
|
@@ -105,6 +105,7 @@ static void run_test()
|
||||
struct anv_block_pool pool;
|
||||
|
||||
anv_device_set_physical(&device, &physical_device);
|
||||
device.kmd_backend = anv_kmd_backend_get(INTEL_KMD_TYPE_STUB);
|
||||
pthread_mutex_init(&device.mutex, NULL);
|
||||
anv_bo_cache_init(&device.bo_cache, &device);
|
||||
anv_block_pool_init(&pool, &device, "test", 4096, 4096);
|
||||
|
@@ -40,6 +40,7 @@ int main(void)
|
||||
struct anv_state_pool state_pool;
|
||||
|
||||
anv_device_set_physical(&device, &physical_device);
|
||||
device.kmd_backend = anv_kmd_backend_get(INTEL_KMD_TYPE_STUB);
|
||||
pthread_mutex_init(&device.mutex, NULL);
|
||||
anv_bo_cache_init(&device.bo_cache, &device);
|
||||
|
||||
|
@@ -39,6 +39,7 @@ int main(void)
|
||||
struct anv_state_pool state_pool;
|
||||
|
||||
anv_device_set_physical(&device, &physical_device);
|
||||
device.kmd_backend = anv_kmd_backend_get(INTEL_KMD_TYPE_STUB);
|
||||
pthread_mutex_init(&device.mutex, NULL);
|
||||
anv_bo_cache_init(&device.bo_cache, &device);
|
||||
anv_state_pool_init(&state_pool, &device, "test", 4096, 0, 4096);
|
||||
|
@@ -60,6 +60,7 @@ static void run_test()
|
||||
struct anv_state_pool state_pool;
|
||||
|
||||
anv_device_set_physical(&device, &physical_device);
|
||||
device.kmd_backend = anv_kmd_backend_get(INTEL_KMD_TYPE_STUB);
|
||||
pthread_mutex_init(&device.mutex, NULL);
|
||||
anv_bo_cache_init(&device.bo_cache, &device);
|
||||
anv_state_pool_init(&state_pool, &device, "test", 4096, 0, 64);
|
||||
|
@@ -31,6 +31,7 @@ int main(void)
|
||||
struct anv_state_pool state_pool;
|
||||
|
||||
anv_device_set_physical(&device, &physical_device);
|
||||
device.kmd_backend = anv_kmd_backend_get(INTEL_KMD_TYPE_STUB);
|
||||
pthread_mutex_init(&device.mutex, NULL);
|
||||
anv_bo_cache_init(&device.bo_cache, &device);
|
||||
anv_state_pool_init(&state_pool, &device, "test", 4096, 0, 4096);
|
||||
|
Reference in New Issue
Block a user