iris: Add iris_bo_set_caching()

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/21688>
This commit is contained in:
José Roberto de Souza 2022-10-21 08:58:11 -07:00 committed by Marge Bot
parent 5dc0f18333
commit 1fecb26634
3 changed files with 23 additions and 5 deletions

View file

@ -42,3 +42,13 @@ iris_i915_bo_madvise(struct iris_bo *bo, enum iris_madvice state)
return madv.retained;
}
int iris_i915_bo_set_caching(struct iris_bo *bo, bool cached)
{
struct drm_i915_gem_caching arg = {
.handle = bo->gem_handle,
.caching = cached ? I915_CACHING_CACHED : I915_CACHING_NONE,
};
return intel_ioctl(iris_bufmgr_get_fd(bo->bufmgr),
DRM_IOCTL_I915_GEM_SET_CACHING, &arg);
}

View file

@ -28,3 +28,4 @@ struct iris_bo;
enum iris_madvice;
bool iris_i915_bo_madvise(struct iris_bo *bo, enum iris_madvice state);
int iris_i915_bo_set_caching(struct iris_bo *bo, bool cached);

View file

@ -1040,6 +1040,17 @@ iris_heap_to_string[IRIS_HEAP_MAX] = {
[IRIS_HEAP_DEVICE_LOCAL_PREFERRED] = "local-preferred",
};
static int iris_bo_set_caching(struct iris_bo *bo, bool cached)
{
switch (iris_bufmgr_get_device_info(bo->bufmgr)->kmd_type) {
case INTEL_KMD_TYPE_I915:
return iris_i915_bo_set_caching(bo, cached);
default:
unreachable("missing");
return 0;
}
}
struct iris_bo *
iris_bo_alloc(struct iris_bufmgr *bufmgr,
const char *name,
@ -1133,11 +1144,7 @@ iris_bo_alloc(struct iris_bufmgr *bufmgr,
*/
if ((flags & BO_ALLOC_COHERENT) &&
!bufmgr->devinfo.has_llc && bufmgr->devinfo.has_caching_uapi) {
struct drm_i915_gem_caching arg = {
.handle = bo->gem_handle,
.caching = 1,
};
if (intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_SET_CACHING, &arg) != 0)
if (iris_bo_set_caching(bo, true) != 0)
goto err_free;
bo->real.reusable = false;