summaryrefslogtreecommitdiff
path: root/lib/xe/xe_ioctl.c
diff options
context:
space:
mode:
authorRodrigo Vivi <rodrigo.vivi@intel.com>2023-10-05 23:21:51 -0400
committerFrancois Dugast <francois.dugast@intel.com>2023-12-05 09:26:37 +0100
commitedd4b9325c4ec436440274f5872c4524d70915e8 (patch)
treee95a9ec306a79117138b37c59638eae2e16bedfe /lib/xe/xe_ioctl.c
parent405e1569a002dccf29513f4c810e95d918be0647 (diff)
xe_query: Kill visible_vram_if_possible
Let the caller set the flag and the xe_bo_query clear if not needed. Although the current helper makes the code cleaner, the goal is to split the flags into placement and flags as two different arguments on xe_bo_create. So, the flag decision cannot be hidden under the helper. v2: Fix one comment (Kamil Konieczny) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Signed-off-by: Francois Dugast <francois.dugast@intel.com> Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Diffstat (limited to 'lib/xe/xe_ioctl.c')
-rw-r--r--lib/xe/xe_ioctl.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/xe/xe_ioctl.c b/lib/xe/xe_ioctl.c
index 69443cfd8..1d51eb60f 100644
--- a/lib/xe/xe_ioctl.c
+++ b/lib/xe/xe_ioctl.c
@@ -240,6 +240,18 @@ uint16_t __xe_default_cpu_caching_from_flags(int fd, uint32_t flags)
return DRM_XE_GEM_CPU_CACHING_WB;
}
+static bool vram_selected(int fd, uint32_t selected_regions)
+{
+ uint64_t regions = all_memory_regions(fd) & selected_regions;
+ uint64_t region;
+
+ xe_for_each_mem_region(fd, regions, region)
+ if (xe_mem_region(fd, region)->mem_class == DRM_XE_MEM_REGION_CLASS_VRAM)
+ return true;
+
+ return false;
+}
+
static uint32_t ___xe_bo_create(int fd, uint32_t vm, uint64_t size, uint32_t flags,
uint16_t cpu_caching, uint32_t *handle)
{
@@ -251,6 +263,13 @@ static uint32_t ___xe_bo_create(int fd, uint32_t vm, uint64_t size, uint32_t fla
};
int err;
+ /*
+ * In case vram_if_possible returned system_memory,
+ * visible VRAM cannot be requested through flags
+ */
+ if (!vram_selected(fd, flags))
+ create.flags &= ~DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM;
+
err = igt_ioctl(fd, DRM_IOCTL_XE_GEM_CREATE, &create);
if (err)
return err;