Skip to content

drm/xe: Formalize and document page-table protection

Thomas Hellström requested to merge thomash/kernel:pt_protection into xe

The current scheme of protecting the page-table with the vm lock in read mode for rebinds and write mode for binds and unbinds isn't ideal, because we don't know at locking time what operations we're going to need. This is partly caused by vmas ending up on the rebind list even after the vma is unbound, and also because it may end up on the rebind list before it is actually bound.

If we look at CPU page-tables, the vmas are protected by an outer rw semaphore, but the page-tables themselves are protected by finer-granularity page-table locks. Similarly VM_BIND on i915 is protected by an outer vm-bind lock, but the pagetables are protected by the vm->mutex which is safe to lock from reclaim context. However for i915 there has been plans for a long time to move the vm->mutex to a per-vm resv for various reasons. Advantage of a reclaim-safe vm->mutex is that it is lockable from reclaim and from the move notifier. Drawback is that it is in the way of sleeping resv locks for GTT eviction.

In any case, we have a vm resv ready to serve the purpose of also protecting the page-tables, so use that instead of the vm lock. Update asserts and documentation accordingly. This is done in patch 1.

In patch 2 we make sure we don't put any vmas on the rebind list if they aren't bound.

Edited by Thomas Hellström

Merge request reports