Skip to content

Commit 5aa8fe1

Browse files
ifdulutzbichler
authored andcommitted
drm/xe/uapi: Restore flags VM_BIND_FLAG_READONLY and VM_BIND_FLAG_IMMEDIATE
The commit 84a1ed5e6756 ("drm/xe/uapi: Remove unused flags") is partially reverted. At the time, flags not used by user space were removed during cleanup. Some flags now needed by the compute runtime are brought back in this commit: - DRM_XE_VM_BIND_FLAG_READONLY is used to write protect kernel ISA thus preventing accidental overwrites. - DRM_XE_VM_BIND_FLAG_IMMEDIATE is used to trigger mapping at the time of binding in order to prevent faulting at execution time. The changes in the compute runtime are ready and approved, see link below. v2: Include a link to the PR in the commit message (Matthew Brost) v3: Update kernel doc and improve commit message (Lucas De Marchi) Cc: Mateusz Jablonski <[email protected]> Cc: Michal Mrozek <[email protected]> Cc: Matthew Brost <[email protected]> Cc: Lucas De Marchi <[email protected]> Link: intel/compute-runtime#717 Signed-off-by: Francois Dugast <[email protected]> Reviewed-by: Matthew Brost <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Lucas De Marchi <[email protected]>
1 parent 8fe6dbb commit 5aa8fe1

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

drivers/gpu/drm/xe/xe_vm.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,6 +2244,10 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_bo *bo,
22442244
struct xe_vma_op *op = gpuva_op_to_vma_op(__op);
22452245

22462246
if (__op->op == DRM_GPUVA_OP_MAP) {
2247+
op->map.immediate =
2248+
flags & DRM_XE_VM_BIND_FLAG_IMMEDIATE;
2249+
op->map.read_only =
2250+
flags & DRM_XE_VM_BIND_FLAG_READONLY;
22472251
op->map.is_null = flags & DRM_XE_VM_BIND_FLAG_NULL;
22482252
op->map.dumpable = flags & DRM_XE_VM_BIND_FLAG_DUMPABLE;
22492253
op->map.pat_index = pat_index;
@@ -2438,6 +2442,8 @@ static int vm_bind_ioctl_ops_parse(struct xe_vm *vm, struct xe_exec_queue *q,
24382442
switch (op->base.op) {
24392443
case DRM_GPUVA_OP_MAP:
24402444
{
2445+
flags |= op->map.read_only ?
2446+
VMA_CREATE_FLAG_READ_ONLY : 0;
24412447
flags |= op->map.is_null ?
24422448
VMA_CREATE_FLAG_IS_NULL : 0;
24432449
flags |= op->map.dumpable ?
@@ -2582,7 +2588,7 @@ static int op_execute(struct drm_exec *exec, struct xe_vm *vm,
25822588
case DRM_GPUVA_OP_MAP:
25832589
err = xe_vm_bind(vm, vma, op->q, xe_vma_bo(vma),
25842590
op->syncs, op->num_syncs,
2585-
!xe_vm_in_fault_mode(vm),
2591+
op->map.immediate || !xe_vm_in_fault_mode(vm),
25862592
op->flags & XE_VMA_OP_FIRST,
25872593
op->flags & XE_VMA_OP_LAST);
25882594
break;
@@ -2857,7 +2863,10 @@ static int vm_bind_ioctl_ops_execute(struct xe_vm *vm,
28572863
return 0;
28582864
}
28592865

2860-
#define SUPPORTED_FLAGS (DRM_XE_VM_BIND_FLAG_NULL | \
2866+
#define SUPPORTED_FLAGS \
2867+
(DRM_XE_VM_BIND_FLAG_READONLY | \
2868+
DRM_XE_VM_BIND_FLAG_IMMEDIATE | \
2869+
DRM_XE_VM_BIND_FLAG_NULL | \
28612870
DRM_XE_VM_BIND_FLAG_DUMPABLE)
28622871
#define XE_64K_PAGE_MASK 0xffffull
28632872
#define ALL_DRM_XE_SYNCS_FLAGS (DRM_XE_SYNCS_FLAG_WAIT_FOR_OP)

drivers/gpu/drm/xe/xe_vm_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ struct xe_vm {
278278
struct xe_vma_op_map {
279279
/** @vma: VMA to map */
280280
struct xe_vma *vma;
281+
/** @immediate: Immediate bind */
282+
bool immediate;
283+
/** @read_only: Read only */
284+
bool read_only;
281285
/** @is_null: is NULL binding */
282286
bool is_null;
283287
/** @dumpable: whether BO is dumped on GPU hang */

include/uapi/drm/xe_drm.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,12 @@ struct drm_xe_vm_destroy {
871871
* - %DRM_XE_VM_BIND_OP_PREFETCH
872872
*
873873
* and the @flags can be:
874+
* - %DRM_XE_VM_BIND_FLAG_READONLY - Setup the page tables as read-only
875+
* to ensure write protection
876+
* - %DRM_XE_VM_BIND_FLAG_IMMEDIATE - On a faulting VM, do the
877+
* MAP operation immediately rather than deferring the MAP to the page
878+
* fault handler. This is implied on a non-faulting VM as there is no
879+
* fault handler to defer to.
874880
* - %DRM_XE_VM_BIND_FLAG_NULL - When the NULL flag is set, the page
875881
* tables are setup with a special bit which indicates writes are
876882
* dropped and all reads return zero. In the future, the NULL flags
@@ -963,6 +969,8 @@ struct drm_xe_vm_bind_op {
963969
/** @op: Bind operation to perform */
964970
__u32 op;
965971

972+
#define DRM_XE_VM_BIND_FLAG_READONLY (1 << 0)
973+
#define DRM_XE_VM_BIND_FLAG_IMMEDIATE (1 << 1)
966974
#define DRM_XE_VM_BIND_FLAG_NULL (1 << 2)
967975
#define DRM_XE_VM_BIND_FLAG_DUMPABLE (1 << 3)
968976
/** @flags: Bind flags */

0 commit comments

Comments
 (0)