[PATCH v4 14/20] drm/xe/svm: Support DRM_XE_SVM_ATTR_PAT memory attribute
Himal Prasad Ghimiray
himal.prasad.ghimiray at intel.com
Fri Jun 13 12:55:52 UTC 2025
This attributes sets the pat_index for the svm used vma range, which is
utilized to ascertain the coherence.
v2 (Matthew Brost)
- Pat index sanity check
Cc: Matthew Brost <matthew.brost at intel.com>
Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray at intel.com>
---
drivers/gpu/drm/xe/xe_vm_madvise.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_vm_madvise.c b/drivers/gpu/drm/xe/xe_vm_madvise.c
index 64352fbebd25..973627edb23c 100644
--- a/drivers/gpu/drm/xe/xe_vm_madvise.c
+++ b/drivers/gpu/drm/xe/xe_vm_madvise.c
@@ -11,6 +11,7 @@
#include "xe_bo.h"
#include "xe_gt_tlb_invalidation.h"
+#include "xe_pat.h"
#include "xe_pt.h"
#include "xe_svm.h"
@@ -115,7 +116,13 @@ static void madvise_pat_index(struct xe_device *xe, struct xe_vm *vm,
struct xe_vma **vmas, int num_vmas,
struct drm_xe_madvise *op)
{
- /* Implementation pending */
+ int i;
+
+ xe_assert(vm->xe, op->type == DRM_XE_VMA_ATTR_PAT);
+
+ for (i = 0; i < num_vmas; i++)
+ vmas[i]->attr.pat_index = op->pat_index.val;
+
}
typedef void (*madvise_func)(struct xe_device *xe, struct xe_vm *vm,
@@ -195,7 +202,13 @@ static int drm_xe_madvise_args_are_sane(struct xe_device *xe, const struct drm_x
return -EINVAL;
break;
case DRM_XE_VMA_ATTR_PAT:
- /*TODO: Add valid pat check */
+ u16 coh_mode = xe_pat_index_get_coh_mode(xe, args->pat_index.val);
+
+ if (XE_IOCTL_DBG(xe, !coh_mode))
+ return -EINVAL;
+
+ if (XE_WARN_ON(coh_mode > XE_COH_AT_LEAST_1WAY))
+ return -EINVAL;
break;
case DRM_XE_VMA_ATTR_PREFERRED_LOC:
s32 fd = (s32)args->preferred_mem_loc.devmem_fd;
--
2.34.1
More information about the Intel-xe
mailing list