Skip to content

Commit efeff7b

Browse files
mbrost05Thomas Hellström
authored andcommitted
drm/xe: Only allow 1 ufence per exec / bind IOCTL
The way exec ufences are coded only 1 ufence per IOCTL will be signaled. It is possible to fix this but for current use cases 1 ufence per IOCTL is sufficient. Enforce a limit of 1 ufence per IOCTL (both exec and bind to be uniform). v2: - Add fixes tag (Thomas) Fixes: dd08ebf ("drm/xe: Introduce a new DRM driver for Intel GPUs") Cc: Mika Kahola <[email protected]> Cc: Thomas Hellström <[email protected]> Signed-off-by: Matthew Brost <[email protected]> Reviewed-by: Brian Welty <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit d1df9bf) Signed-off-by: Thomas Hellström <[email protected]>
1 parent 6d20962 commit efeff7b

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

drivers/gpu/drm/xe/xe_exec.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
111111
u64 addresses[XE_HW_ENGINE_MAX_INSTANCE];
112112
struct drm_gpuvm_exec vm_exec = {.extra.fn = xe_exec_fn};
113113
struct drm_exec *exec = &vm_exec.exec;
114-
u32 i, num_syncs = 0;
114+
u32 i, num_syncs = 0, num_ufence = 0;
115115
struct xe_sched_job *job;
116116
struct dma_fence *rebind_fence;
117117
struct xe_vm *vm;
@@ -157,6 +157,14 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
157157
SYNC_PARSE_FLAG_LR_MODE : 0));
158158
if (err)
159159
goto err_syncs;
160+
161+
if (xe_sync_is_ufence(&syncs[i]))
162+
num_ufence++;
163+
}
164+
165+
if (XE_IOCTL_DBG(xe, num_ufence > 1)) {
166+
err = -EINVAL;
167+
goto err_syncs;
160168
}
161169

162170
if (xe_exec_queue_is_parallel(q)) {

drivers/gpu/drm/xe/xe_sync.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,9 @@ struct dma_fence *
3333
xe_sync_in_fence_get(struct xe_sync_entry *sync, int num_sync,
3434
struct xe_exec_queue *q, struct xe_vm *vm);
3535

36+
static inline bool xe_sync_is_ufence(struct xe_sync_entry *sync)
37+
{
38+
return !!sync->ufence;
39+
}
40+
3641
#endif

drivers/gpu/drm/xe/xe_vm.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2851,7 +2851,7 @@ int xe_vm_bind_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
28512851
struct drm_gpuva_ops **ops = NULL;
28522852
struct xe_vm *vm;
28532853
struct xe_exec_queue *q = NULL;
2854-
u32 num_syncs;
2854+
u32 num_syncs, num_ufence = 0;
28552855
struct xe_sync_entry *syncs = NULL;
28562856
struct drm_xe_vm_bind_op *bind_ops;
28572857
LIST_HEAD(ops_list);
@@ -2988,6 +2988,14 @@ int xe_vm_bind_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
29882988
SYNC_PARSE_FLAG_DISALLOW_USER_FENCE : 0));
29892989
if (err)
29902990
goto free_syncs;
2991+
2992+
if (xe_sync_is_ufence(&syncs[num_syncs]))
2993+
num_ufence++;
2994+
}
2995+
2996+
if (XE_IOCTL_DBG(xe, num_ufence > 1)) {
2997+
err = -EINVAL;
2998+
goto free_syncs;
29912999
}
29923000

29933001
if (!args->num_binds) {

0 commit comments

Comments
 (0)