anv: Use DRM_IOCTL_I915_GEM_CREATE_EXT in all supported kernels
As we continue to refactor the code base to support Xe KMD here I'm dropping anv_gem_create() and unifying all graphics memory allocation calls to anv_gem_create_regions(). anv_gem_create_regions() will call DRM_IOCTL_I915_GEM_CREATE_EXT for integrated platforms too only leaving DRM_IOCTL_I915_GEM_CREATE calls to kernel versions that do not support DRM_IOCTL_I915_GEM_CREATE_EXT. This can be detected by devinfo->mem.use_class_instance as DRM_I915_QUERY_MEMORY_REGIONS uAPI landed in the same kernel version as DRM_IOCTL_I915_GEM_CREATE_EXT. 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
099b9e5058
commit
eaeda2107e
@@ -1451,15 +1451,13 @@ anv_device_alloc_bo(struct anv_device *device,
|
||||
ccs_size = align64(DIV_ROUND_UP(size, aux_ratio), 4096);
|
||||
}
|
||||
|
||||
uint32_t gem_handle;
|
||||
const struct intel_memory_class_instance *regions[2];
|
||||
uint32_t nregions = 0, flags = 0;
|
||||
|
||||
/* If we have vram size, we have multiple memory regions and should choose
|
||||
* one of them.
|
||||
*/
|
||||
if (anv_physical_device_has_vram(device->physical)) {
|
||||
const struct intel_memory_class_instance *regions[2];
|
||||
uint32_t nregions = 0;
|
||||
|
||||
/* This always try to put the object in local memory. Here
|
||||
* vram_non_mappable & vram_mappable actually are the same region.
|
||||
*/
|
||||
@@ -1472,7 +1470,6 @@ anv_device_alloc_bo(struct anv_device *device,
|
||||
* This ensures that if the buffer cannot live in mappable local memory,
|
||||
* it can be spilled to system memory.
|
||||
*/
|
||||
uint32_t flags = 0;
|
||||
if (!(alloc_flags & ANV_BO_ALLOC_NO_LOCAL_MEM) &&
|
||||
((alloc_flags & ANV_BO_ALLOC_MAPPED) ||
|
||||
(alloc_flags & ANV_BO_ALLOC_LOCAL_MEM_CPU_VISIBLE))) {
|
||||
@@ -1480,13 +1477,12 @@ anv_device_alloc_bo(struct anv_device *device,
|
||||
if (device->physical->vram_non_mappable.size > 0)
|
||||
flags |= I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS;
|
||||
}
|
||||
|
||||
gem_handle = anv_gem_create_regions(device, size + ccs_size,
|
||||
flags, nregions, regions);
|
||||
} else {
|
||||
gem_handle = anv_gem_create(device, size + ccs_size);
|
||||
regions[nregions++] = device->physical->sys.region;
|
||||
}
|
||||
|
||||
uint32_t gem_handle = anv_gem_create_regions(device, size + ccs_size,
|
||||
flags, nregions, regions);
|
||||
if (gem_handle == 0)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
|
||||
|
@@ -32,27 +32,6 @@
|
||||
#include "anv_private.h"
|
||||
#include "common/intel_gem.h"
|
||||
|
||||
/**
|
||||
* Wrapper around DRM_IOCTL_I915_GEM_CREATE.
|
||||
*
|
||||
* Return gem handle, or 0 on failure. Gem handles are never 0.
|
||||
*/
|
||||
uint32_t
|
||||
anv_gem_create(struct anv_device *device, uint64_t size)
|
||||
{
|
||||
struct drm_i915_gem_create gem_create = {
|
||||
.size = size,
|
||||
};
|
||||
|
||||
int ret = intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_CREATE, &gem_create);
|
||||
if (ret != 0) {
|
||||
/* FIXME: What do we do if this fails? */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return gem_create.handle;
|
||||
}
|
||||
|
||||
void
|
||||
anv_gem_close(struct anv_device *device, uint32_t gem_handle)
|
||||
{
|
||||
@@ -68,8 +47,20 @@ anv_gem_create_regions(struct anv_device *device, uint64_t anv_bo_size,
|
||||
uint32_t flags, uint32_t num_regions,
|
||||
const struct intel_memory_class_instance **regions)
|
||||
{
|
||||
struct drm_i915_gem_memory_class_instance i915_regions[2];
|
||||
if (unlikely(!device->info->mem.use_class_instance)) {
|
||||
assert(num_regions == 1 &&
|
||||
device->physical->sys.region == regions[0] &&
|
||||
flags == 0);
|
||||
|
||||
struct drm_i915_gem_create gem_create = {
|
||||
.size = anv_bo_size,
|
||||
};
|
||||
if (intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_CREATE, &gem_create))
|
||||
return 0;
|
||||
return gem_create.handle;
|
||||
}
|
||||
|
||||
struct drm_i915_gem_memory_class_instance i915_regions[2];
|
||||
/* Check for invalid flags */
|
||||
assert((flags & ~I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS) == 0);
|
||||
assert(num_regions <= ARRAY_SIZE(i915_regions));
|
||||
|
@@ -27,8 +27,16 @@
|
||||
#include "util/anon_file.h"
|
||||
#include "anv_private.h"
|
||||
|
||||
void
|
||||
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)
|
||||
anv_gem_create_regions(struct anv_device *device, uint64_t size,
|
||||
uint32_t flags, uint32_t num_regions,
|
||||
const struct intel_memory_class_instance **regions)
|
||||
{
|
||||
int fd = os_create_anonymous_file(size, "fake bo");
|
||||
if (fd == -1)
|
||||
@@ -39,20 +47,6 @@ anv_gem_create(struct anv_device *device, uint64_t size)
|
||||
return fd;
|
||||
}
|
||||
|
||||
void
|
||||
anv_gem_close(struct anv_device *device, uint32_t gem_handle)
|
||||
{
|
||||
close(gem_handle);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
anv_gem_create_regions(struct anv_device *device, uint64_t anv_bo_size,
|
||||
uint32_t flags, uint32_t num_regions,
|
||||
const struct intel_memory_class_instance **regions)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void*
|
||||
anv_gem_mmap(struct anv_device *device, struct anv_bo *bo,
|
||||
uint64_t offset, uint64_t size, uint32_t flags)
|
||||
|
@@ -1345,7 +1345,6 @@ VkResult anv_queue_submit_simple_batch(struct anv_queue *queue,
|
||||
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);
|
||||
uint32_t anv_gem_create(struct anv_device *device, uint64_t size);
|
||||
void anv_gem_close(struct anv_device *device, uint32_t gem_handle);
|
||||
uint32_t anv_gem_create_regions(struct anv_device *device, uint64_t anv_bo_size,
|
||||
uint32_t flags, uint32_t num_regions,
|
||||
|
Reference in New Issue
Block a user