drm/ttm: Don't deadlock on recursive multi-bo reservations

Add an aid for the driver to detect deadlocks on multi-bo reservations
Update documentation.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jerome Glisse <j.glisse@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
Thomas Hellstrom
2010-11-17 12:28:28 +00:00
committed by Dave Airlie
parent 68c4fa31aa
commit 96726fe50f
2 changed files with 34 additions and 6 deletions

View File

@@ -223,9 +223,18 @@ int ttm_bo_reserve_locked(struct ttm_buffer_object *bo,
/**
* Deadlock avoidance for multi-bo reserving.
*/
if (use_sequence && bo->seq_valid &&
(sequence - bo->val_seq < (1 << 31))) {
return -EAGAIN;
if (use_sequence && bo->seq_valid) {
/**
* We've already reserved this one.
*/
if (unlikely(sequence == bo->val_seq))
return -EDEADLK;
/**
* Already reserved by a thread that will not back
* off for us. We need to back off.
*/
if (unlikely(sequence - bo->val_seq < (1 << 31)))
return -EAGAIN;
}
if (no_wait)