anv: Move i915 specific gem_set_caching to backend

Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Sagar Ghuge <sagar.ghuge@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25212>
This commit is contained in:
José Roberto de Souza
2023-09-04 10:14:23 -07:00
committed by Marge Bot
parent b8a9c72561
commit fc0acf6d90
5 changed files with 31 additions and 46 deletions

View File

@@ -1534,26 +1534,6 @@ anv_device_alloc_bo(struct anv_device *device,
}
}
if (alloc_flags & ANV_BO_ALLOC_SNOOPED) {
assert(alloc_flags & ANV_BO_ALLOC_MAPPED);
/* We don't want to change these defaults if it's going to be shared
* with another process.
*/
assert(!(alloc_flags & ANV_BO_ALLOC_EXTERNAL));
/* Regular objects are created I915_CACHING_CACHED on LLC platforms and
* I915_CACHING_NONE on non-LLC platforms. For many internal state
* objects, we'd rather take the snooping overhead than risk forgetting
* a CLFLUSH somewhere. Userptr objects are always created as
* I915_CACHING_CACHED, which on non-LLC means snooped so there's no
* need to do this there.
*/
if (device->info->has_caching_uapi && !device->info->has_llc) {
anv_gem_set_caching(device, new_bo.gem_handle,
I915_CACHING_CACHED);
}
}
VkResult result = anv_bo_vma_alloc_or_close(device, &new_bo,
alloc_flags,
explicit_address);

View File

@@ -55,24 +55,6 @@ anv_gem_munmap(struct anv_device *device, void *p, uint64_t size)
munmap(p, size);
}
int
anv_gem_set_caching(struct anv_device *device,
uint32_t gem_handle, uint32_t caching)
{
/* Guard by has_caching_uapi */
if (unlikely(device->info->kmd_type != INTEL_KMD_TYPE_I915)) {
assert(!"Missing implementation of anv_gem_set_caching\n");
return -1;
}
struct drm_i915_gem_caching gem_caching = {
.handle = gem_handle,
.caching = caching,
};
return intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_SET_CACHING, &gem_caching);
}
/**
* On error, \a timeout_ns holds the remaining time.
*/

View File

@@ -132,13 +132,6 @@ anv_gem_get_tiling(struct anv_device *device, uint32_t gem_handle)
return 0;
}
int
anv_gem_set_caching(struct anv_device *device, uint32_t gem_handle,
uint32_t caching)
{
return 0;
}
int
anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle)
{

View File

@@ -1791,7 +1791,6 @@ int anv_gem_set_tiling(struct anv_device *device, uint32_t gem_handle,
int anv_gem_get_tiling(struct anv_device *device, uint32_t gem_handle);
int anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle);
uint32_t anv_gem_fd_to_handle(struct anv_device *device, int fd);
int anv_gem_set_caching(struct anv_device *device, uint32_t gem_handle, uint32_t caching);
int anv_gem_set_context_param(int fd, uint32_t context, uint32_t param,
uint64_t value);

View File

@@ -30,6 +30,18 @@
#include "drm-uapi/i915_drm.h"
#include "intel/common/i915/intel_gem.h"
static int
i915_gem_set_caching(struct anv_device *device,
uint32_t gem_handle, uint32_t caching)
{
struct drm_i915_gem_caching gem_caching = {
.handle = gem_handle,
.caching = caching,
};
return intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_SET_CACHING, &gem_caching);
}
static uint32_t
i915_gem_create(struct anv_device *device,
const struct intel_memory_class_instance **regions,
@@ -94,6 +106,25 @@ i915_gem_create(struct anv_device *device,
return 0;
*actual_size = gem_create.size;
if (alloc_flags & ANV_BO_ALLOC_SNOOPED) {
assert(alloc_flags & ANV_BO_ALLOC_MAPPED);
/* We don't want to change these defaults if it's going to be shared
* with another process.
*/
assert(!(alloc_flags & ANV_BO_ALLOC_EXTERNAL));
/* Regular objects are created I915_CACHING_CACHED on LLC platforms and
* I915_CACHING_NONE on non-LLC platforms. For many internal state
* objects, we'd rather take the snooping overhead than risk forgetting
* a CLFLUSH somewhere. Userptr objects are always created as
* I915_CACHING_CACHED, which on non-LLC means snooped so there's no
* need to do this there.
*/
if (device->info->has_caching_uapi && !device->info->has_llc)
i915_gem_set_caching(device, gem_create.handle, I915_CACHING_CACHED);
}
return gem_create.handle;
}