drm/amdgpu: remove the WAIT_FOR_SUBMIT flag under lock context
Subsystems (2)
PATCH 1/1 drm/amdgpu: remove the WAIT_FOR_SUBMIT flag under lock context
In the userq fence gather and emit IOCTL path we acquire BO locks (via drm_exec/dma_resv_lock)before calling drm_syncobj_find_fence(). This causes drm_syncobj_find_fence() to complain because it is entered with locks held while the WAIT_FOR_SUBMIT flag is set in the calling context.
However, the userq userspace path does not rely on DRM_IOCTL_SYNCOBJ_WAIT to wait on fences that are dependencies of userq submissions. All waiting is handled separately, so the WAIT_FOR_SUBMIT flag is effectively unused for this IOCTL.
Therefore, we simply clear the WAIT_FOR_SUBMIT flag for this path. This avoids the lockdep / drm_syncobj_find_fence() warning about being called under a locked context, and has no functional impact on userq behavior since DRM_IOCTL_SYNCOBJ_WAIT is not part of the userq synchronization model.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +4 -4
@@ -708,7 +708,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data,for (i =0 ; i < num_points; i++) { r =drm_syncobj_find_fence (filp, timeline_handles[i], timeline_points[i], -DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT , +0 , &fence);if (r) goto exec_fini;
@@ -726,7 +726,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data, r =drm_syncobj_find_fence (filp, syncobj_handles[i],0 , -DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT , +0 , &fence);if (r) goto exec_fini;
@@ -818,7 +818,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data,for (i =0 ; i < num_points; i++) { r =drm_syncobj_find_fence (filp, timeline_handles[i], timeline_points[i], -DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT , +0 , &fence);if (r) goto free_fences;
@@ -844,7 +844,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data, r =drm_syncobj_find_fence (filp, syncobj_handles[i],0 , -DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT , +0 , &fence);if (r) goto free_fences;
Signature · 1 line
2.34.1
Christian König
maintainerQuoted 7 lines · Prike Liang
In the userq fence gather and emit IOCTL path we acquire BO locks (via drm_exec/dma_resv_lock)before calling
drm_syncobj_find_fence(). This causesdrm_syncobj_find_fence()to complain because it is entered with locks held while theWAIT_FOR_SUBMITflag is set in the calling context.However, the userq userspace path does not rely on
DRM_IOCTL_SYNCOBJ_WAITto wait on fences that are dependencies of userq submissions.
That's not correct.
Quoted 8 lines
All waiting is
handled separately, so theWAIT_FOR_SUBMITflag is effectively unused for this IOCTL.Therefore, we simply clear the
WAIT_FOR_SUBMITflag for this path. This avoids the lockdep /drm_syncobj_find_fence()warning about being called under a locked context, and has no functional impact on userq behavior sinceDRM_IOCTL_SYNCOBJ_WAITis not part of the userq synchronization model.
That doesn't event remotely work.
See the patches I've send out a month ago or so for the correct fix.
Regards,
Christian.
Quoted 46 lines
Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +4
-4@@ -708,7 +708,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data,for (i =0 ; i < num_points; i++) { r =drm_syncobj_find_fence (filp, timeline_handles[i], timeline_points[i], -DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT , +0 , &fence);if (r) goto exec_fini;@@ -726,7 +726,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data, r =drm_syncobj_find_fence (filp, syncobj_handles[i],0 , -DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT , +0 , &fence);if (r) goto exec_fini;@@ -818,7 +818,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data,for (i =0 ; i < num_points; i++) { r =drm_syncobj_find_fence (filp, timeline_handles[i], timeline_points[i], -DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT , +0 , &fence);if (r) goto free_fences;@@ -844,7 +844,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data, r =drm_syncobj_find_fence (filp, syncobj_handles[i],0 , -DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT , +0 , &fence);if (r) goto free_fences;
[Public]
Regards,
Prike
Quoted 27 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Tuesday, March 10, 2026 4:22 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: remove theWAIT_FOR_SUBMITflag under lock contextQuoted 7 lines · Prike Liang
In the userq fence gather and emit IOCTL path we acquire BO locks (via drm_exec/dma_resv_lock)before calling
drm_syncobj_find_fence(). This causesdrm_syncobj_find_fence()to complain because it is entered with locks held while theWAIT_FOR_SUBMITflag is set in the calling context.However, the userq userspace path does not rely on
DRM_IOCTL_SYNCOBJ_WAITto wait on fences that are dependencies of userqsubmissions.
That's not correct.
Quoted 8 lines
All waiting is
handled separately, so theWAIT_FOR_SUBMITflag is effectively unused for this IOCTL.Therefore, we simply clear the
WAIT_FOR_SUBMITflag for this path. This avoids the lockdep /drm_syncobj_find_fence()warning about being called under a locked context, and has no functional impact on userq behavior sinceDRM_IOCTL_SYNCOBJ_WAITis not part of the userq
Quoted 5 lines
synchronization model.
That doesn't event remotely work.
See the patches I've send out a month ago or so for the correct fix.
OK, after checking the Mesa code, DRM_IOCTL_SYNCOBJ_WAIT is still invoked before creating the userq. I had already considered resolving the syncobj-dependent fences before taking the context lock; now given that this flag is still used for syncobj wait fences, I’ll go with that approach instead and drop this patch.
Quoted 59 lines
Regards,
Christian.drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void
Quoted 12 lines
Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-0@@ -708,7 +708,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void*data,
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data,
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-1for (i =0 ; i < num_points; i++) { r = drm_syncobj_find_fence(filp, timeline_handles[i], timeline_points[i], -
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device · line 730
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +1
-1+0 , &fence);if (r) goto exec_fini;@@ -726,7 +726,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data, r = drm_syncobj_find_fence(filp, syncobj_handles[i], 0, -
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +1
-0+0 , &fence);if (r)goto exec_fini;drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-0@@ -818,7 +818,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void*data,
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data,
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-1for (i =0 ; i < num_points; i++) { r = drm_syncobj_find_fence(filp, timeline_handles[i], timeline_points[i], -
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device · line 848
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +1
-1+0 , &fence);if (r) goto free_fences;@@ -844,7 +844,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data, r = drm_syncobj_find_fence(filp, syncobj_handles[i], 0, -
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +1
-0+0 , &fence);if (r)goto free_fences;
Christian König
maintainerQuoted 34 lines · Prike
[Public]
Regards,
PrikeQuoted 29 lines
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Tuesday, March 10, 2026 4:22 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: remove theWAIT_FOR_SUBMITflag under lock contextQuoted 7 lines · Prike Liang
In the userq fence gather and emit IOCTL path we acquire BO locks (via drm_exec/dma_resv_lock)before calling
drm_syncobj_find_fence(). This causesdrm_syncobj_find_fence()to complain because it is entered with locks held while theWAIT_FOR_SUBMITflag is set in the calling context.However, the userq userspace path does not rely on
DRM_IOCTL_SYNCOBJ_WAITto wait on fences that are dependencies of userqsubmissions.
That's not correct.
Quoted 8 lines
All waiting is
handled separately, so theWAIT_FOR_SUBMITflag is effectively unused for this IOCTL.Therefore, we simply clear the
WAIT_FOR_SUBMITflag for this path. This avoids the lockdep /drm_syncobj_find_fence()warning about being called under a locked context, and has no functional impact on userq behavior sinceDRM_IOCTL_SYNCOBJ_WAITis not part of the userqsynchronization model.
Quoted 7 lines
Quoted 3 lines
That doesn't event remotely work.
See the patches I've send out a month ago or so for the correct fix.
OK, after checking the Mesa code,
DRM_IOCTL_SYNCOBJ_WAITis still invoked before creating the userq. I had already considered resolving the syncobj-dependent fences before taking the context lock; now given that this flag is still used for syncobj wait fences, I’ll go with that approach instead and drop this patch.
We actually just need to take the locks in the correct order, it's a bit code re-structuring but not much of an issue.
Regards,
Christian.
Quoted 61 lines
Quoted 60 lines
Regards,
Christian.drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void
Quoted 12 lines
Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-0@@ -708,7 +708,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void*data,
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data,
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-1for (i =0 ; i < num_points; i++) { r = drm_syncobj_find_fence(filp, timeline_handles[i], timeline_points[i], -
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device · line 730
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +1
-1+0 , &fence);if (r) goto exec_fini;@@ -726,7 +726,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data, r = drm_syncobj_find_fence(filp, syncobj_handles[i], 0, -
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +1
-0+0 , &fence);if (r)goto exec_fini;drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-0@@ -818,7 +818,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void*data,
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data,
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +0
-1for (i =0 ; i < num_points; i++) { r = drm_syncobj_find_fence(filp, timeline_handles[i], timeline_points[i], -
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c int amdgpu_userq_wait_ioctl(struct drm_device · line 848
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +1
-1+0 , &fence);if (r) goto free_fences;@@ -844,7 +844,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data, r = drm_syncobj_find_fence(filp, syncobj_handles[i], 0, -
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT,Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +1
-0+0 , &fence);if (r)goto free_fences;