On Sat, Nov 14, 2026 at 8:40 AM Rob Clark <[email protected]> wrote: > Oh, right. We should probably just update last_fence for VM_BIND in > the same way. (Ie. using dma_fence_unwrap_merge() to deal with the > case that the current last_fence is on a different timeline.) I > overlooked that.
Will do in v4. > I think if last_fence is also accounting for VM_BIND jobs, this should > ensure that all VM_BIND jobs are also finished. It covers their fences, but not the free of a killed job: drm_sched_entity_kill_jobs_work() signals the finished fence and only then calls free_job(), which can drop the last reference to the queue after msm_gem_vm_close() has torn the scheduler down. msm_submitqueue_destroy() then calls drm_sched_entity_destroy(), whose flush reads entity->rq->sched from the run queue that drm_sched_fini() freed. Jobs that ran are freed before drm_sched_fini(), by the scheduler or in drm_sched_stop(). So I'd keep patch 2 on top of the last_fence change. > Yes, userspace must use fences/syncobjs to synchronize VM_BINDs if it > is using multiple VM_BIND queues with overlapping updates. An error > would mark the vm unuseable, and the kernel will stop accepting > SUBMITs and VM_BINDs. But maybe we should also handle errors in the > UNMAP path as well, as that also indicates that userspace is doing > something wrong? Yes, I'll do that, but it only catches an unmap that finds part of its range unmapped, not one that runs while the range still holds the PTEs of an older mapping, e.g. one whose own unmap is still queued on a third queue. The early unmap then succeeds. If the map runs next, before the third queue's unmap, its PTEs belong to no VMA, so nothing keeps the BO alive for them until that unmap removes them, and none of the three ops fails. So instead of making unmaps wait for maps, in v4 I'd also track whether the map of a VMA has been applied, and mark the VM unusable when its unmap runs first. The jobs of a VM run one at a time on vm->sched, but v3 patch 1 applies the unmaps of a killed job from the kill worker, and msm_vma_job_run() reads vm->unusable before taking mmu_lock, so a map waiting for the lock would still be applied. The check has to move under the lock, and the flag has to be set before the unmap path drops the lock. This is all from reading the code; I haven't reproduced it. Thanks, Jiwoo Kim
