mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 02:24:24 +02:00
drm/xe/xe_sync: avoid race during ufence signaling
Marking ufence as signalled after copy_to_user() is too late. Worker thread which signals ufence by memory write might be raced with another userspace vm-bind call. In map/unmap scenario unmap may still see ufence is not signalled causing -EBUSY. Change the order of marking / write to user-fence fixes this issue. Fixes:977e5b82e0("drm/xe: Expose user fence from xe_sync_entry") Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/5536 Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Cc: Matthew Brost <matthew.brost@intel.com> Cc: Matthew Auld <matthew.auld@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Signed-off-by: Matthew Brost <matthew.brost@intel.com> Link: https://lore.kernel.org/r/20250820083903.2109891-2-zbigniew.kempczynski@intel.com (cherry picked from commit8ae04fe9ff) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
This commit is contained in:
parent
1b237f190e
commit
04e1f683cd
|
|
@ -77,6 +77,7 @@ static void user_fence_worker(struct work_struct *w)
|
|||
{
|
||||
struct xe_user_fence *ufence = container_of(w, struct xe_user_fence, worker);
|
||||
|
||||
WRITE_ONCE(ufence->signalled, 1);
|
||||
if (mmget_not_zero(ufence->mm)) {
|
||||
kthread_use_mm(ufence->mm);
|
||||
if (copy_to_user(ufence->addr, &ufence->value, sizeof(ufence->value)))
|
||||
|
|
@ -91,7 +92,6 @@ static void user_fence_worker(struct work_struct *w)
|
|||
* Wake up waiters only after updating the ufence state, allowing the UMD
|
||||
* to safely reuse the same ufence without encountering -EBUSY errors.
|
||||
*/
|
||||
WRITE_ONCE(ufence->signalled, 1);
|
||||
wake_up_all(&ufence->xe->ufence_wq);
|
||||
user_fence_put(ufence);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user