[IRIS_HEAP_DEVICE_LOCAL_PREFERRED] = "local-preferred",
};
+static enum iris_mmap_mode
+iris_bo_alloc_get_mmap_mode(struct iris_bufmgr *bufmgr, enum iris_heap heap,
+ unsigned flags)
+{
+ if (bufmgr->devinfo.kmd_type == INTEL_KMD_TYPE_XE)
+ return iris_xe_bo_flags_to_mmap_mode(bufmgr, heap, flags);
+
+ /* i915 */
+ const bool local = heap != IRIS_HEAP_SYSTEM_MEMORY;
+ const bool is_coherent = bufmgr->devinfo.has_llc ||
+ (bufmgr->vram.size > 0 && !local) ||
+ (flags & BO_ALLOC_COHERENT);
+ const bool is_scanout = (flags & BO_ALLOC_SCANOUT) != 0;
+ enum iris_mmap_mode mmap_mode;
+
+ if (!intel_vram_all_mappable(&bufmgr->devinfo) && heap == IRIS_HEAP_DEVICE_LOCAL)
+ mmap_mode = IRIS_MMAP_NONE;
+ else if (!local && is_coherent && !is_scanout)
+ mmap_mode = IRIS_MMAP_WB;
+ else
+ mmap_mode = IRIS_MMAP_WC;
+
+ return mmap_mode;
+}
+
struct iris_bo *
iris_bo_alloc(struct iris_bufmgr *bufmgr,
const char *name,
struct iris_bo *bo;
unsigned int page_size = getpagesize();
enum iris_heap heap = flags_to_heap(bufmgr, flags);
- bool local = heap != IRIS_HEAP_SYSTEM_MEMORY;
struct bo_cache_bucket *bucket = bucket_for_size(bufmgr, size, heap, flags);
if (memzone != IRIS_MEMZONE_OTHER || (flags & BO_ALLOC_COHERENT))
*/
uint64_t bo_size =
bucket ? bucket->size : MAX2(ALIGN(size, page_size), page_size);
-
- bool is_coherent = bufmgr->devinfo.has_llc ||
- (bufmgr->vram.size > 0 && !local) ||
- (flags & BO_ALLOC_COHERENT);
- bool is_scanout = (flags & BO_ALLOC_SCANOUT) != 0;
-
- enum iris_mmap_mode mmap_mode;
- if (!intel_vram_all_mappable(&bufmgr->devinfo) && heap == IRIS_HEAP_DEVICE_LOCAL)
- mmap_mode = IRIS_MMAP_NONE;
- else if (!local && is_coherent && !is_scanout)
- mmap_mode = IRIS_MMAP_WB;
- else
- mmap_mode = IRIS_MMAP_WC;
+ enum iris_mmap_mode mmap_mode = iris_bo_alloc_get_mmap_mode(bufmgr, heap, flags);
simple_mtx_lock(&bufmgr->lock);
return intel_ioctl(iris_bufmgr_get_fd(bufmgr), DRM_IOCTL_XE_VM_DESTROY,
&destroy) == 0;
}
+
+/*
+ * Xe kmd has fixed caching modes for each heap, only scanout bos can change
+ * it.
+ */
+enum iris_mmap_mode
+iris_xe_bo_flags_to_mmap_mode(struct iris_bufmgr *bufmgr, enum iris_heap heap,
+ unsigned flags)
+{
+ /* TODO: might be different for MTL/platforms without LLC */
+ switch (heap) {
+ case IRIS_HEAP_DEVICE_LOCAL_PREFERRED:
+ /* TODO: Can vary on current placement?! */
+ return IRIS_MMAP_WC;
+ case IRIS_HEAP_DEVICE_LOCAL:
+ return IRIS_MMAP_WC;
+ case IRIS_HEAP_SYSTEM_MEMORY:
+ if (flags & BO_ALLOC_SCANOUT)
+ return IRIS_MMAP_WC;
+ return IRIS_MMAP_WB;
+ default:
+ return IRIS_MMAP_NONE;
+ }
+}