Re: [PATCH] drm/ttm: Fix race condition in ttm_bo_delayed_delete

> Would nentry=list_first_entry(&entry->ddestroy, ....) work?
Yes, it seems a bit less intuitive, but if that's the accepted
practice, let's do that instead.
> Here nentry may have been removed from the list by another process, which
> would trigger the unnecessary call, mentioned above.
You are right.
I attached a revised patch.
It's only compile tested, but the changes are small and it should
hopefully work.
Note that in principle we could remove the special-case code for the
list head but that would require pretending the list head is actually
inside a ttm_buffer_object and adding a flag to not do the
unlock/cleanup/put/lock on it, which seems bad.
The whole function seems more complicated than needed, but I can't
find a way to do it with less code. If we could keep glob->lru_lock
while calling ttm_bo_cleanup_refs things would be much simpler, but
that would require intrusive changes and may not be possible.