From: Kaitao Cheng <[email protected]>

A later change will make list_for_each_entry() cache the next element
before entering the loop body. ttm_eu_reserve_buffers() may move the
current validation buffer to the duplicates list and then rewinds the
cursor before continuing.

Keep the reservation walk open-coded so the loop step uses the cursor
selected by that duplicate handling. This preserves the existing
traversal semantics and prepares the code for the list iterator update.

Signed-off-by: Kaitao Cheng <[email protected]>
---
 drivers/gpu/drm/ttm/ttm_execbuf_util.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_execbuf_util.c 
b/drivers/gpu/drm/ttm/ttm_execbuf_util.c
index bc7a83a9fe44..8072f07d5557 100644
--- a/drivers/gpu/drm/ttm/ttm_execbuf_util.c
+++ b/drivers/gpu/drm/ttm/ttm_execbuf_util.c
@@ -86,7 +86,9 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket,
        if (ticket)
                ww_acquire_init(ticket, &reservation_ww_class);
 
-       list_for_each_entry(entry, list, head) {
+       for (entry = list_first_entry(list, typeof(*entry), head);
+            !list_entry_is_head(entry, list, head);
+            entry = list_next_entry(entry, head)) {
                struct ttm_buffer_object *bo = entry->bo;
                unsigned int num_fences;
 
-- 
2.43.0

Reply via email to