iris: Move bo_set_caching to kmd backend
authorJosé Roberto de Souza <jose.souza@intel.com>
Mon, 6 Mar 2023 17:11:00 +0000 (09:11 -0800)
committerMarge Bot <emma+marge@anholt.net>
Tue, 7 Mar 2023 16:16:10 +0000 (16:16 +0000)
For the platforms that call it, it a function in the hot path so
moving it to kmd backend.

After this patch i915/iris_bufmgr.c is empty but not removing it
as next patch will add functions to it.

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/21494>

src/gallium/drivers/iris/i915/iris_bufmgr.c
src/gallium/drivers/iris/i915/iris_bufmgr.h
src/gallium/drivers/iris/i915/iris_kmd_backend.c
src/gallium/drivers/iris/iris_bufmgr.c
src/gallium/drivers/iris/iris_kmd_backend.h

index e269c57..ba9e948 100644 (file)
 
 #include "drm-uapi/i915_drm.h"
 
-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);
-}
index 0278a26..1dcb270 100644 (file)
@@ -26,4 +26,3 @@
 
 struct iris_bo;
 
-int iris_i915_bo_set_caching(struct iris_bo *bo, bool cached);
index b67b2ea..b20e68c 100644 (file)
@@ -107,11 +107,23 @@ i915_bo_madvise(struct iris_bo *bo, enum iris_madvice state)
    return madv.retained;
 }
 
+static int
+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);
+}
+
 const struct iris_kmd_backend *i915_get_backend(void)
 {
    static const struct iris_kmd_backend i915_backend = {
       .gem_create = i915_gem_create,
       .bo_madvise = i915_bo_madvise,
+      .bo_set_caching = i915_bo_set_caching,
    };
    return &i915_backend;
 }
index e48bcd5..aa17bf6 100644 (file)
@@ -1034,17 +1034,6 @@ 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,
@@ -1138,7 +1127,7 @@ iris_bo_alloc(struct iris_bufmgr *bufmgr,
     */
    if ((flags & BO_ALLOC_COHERENT) &&
        !bufmgr->devinfo.has_llc && bufmgr->devinfo.has_caching_uapi) {
-      if (iris_bo_set_caching(bo, true) != 0)
+      if (bufmgr->kmd_backend->bo_set_caching(bo, true) != 0)
          goto err_free;
 
       bo->real.reusable = false;
index 7013dd3..8280247 100644 (file)
@@ -39,6 +39,7 @@ struct iris_kmd_backend {
                           uint16_t regions_count, uint64_t size,
                           enum iris_heap heap_flags, unsigned alloc_flags);
    bool (*bo_madvise)(struct iris_bo *bo, enum iris_madvice state);
+   int (*bo_set_caching)(struct iris_bo *bo, bool cached);
 };
 
 const struct iris_kmd_backend *