Skip to contentSkip to conversation

drm/ttm: Fix hardcoded LRU index in ttm_device_fini()

PATCH New Hongfu Li 1 participant 1 message Aug 6

Subsystems (3)
lore
Share & tools
lore

Hongfu Li

author
#0 lore raw

PATCH v2 1/1 drm/ttm: Fix hardcoded LRU index in ttm_device_fini()

From: Hongfu Li <[email protected]>

When iterating all TTM_MAX_BO_PRIORITY LRU lists using loop variable i, the list_empty() check references man->lru[0] instead of man->lru[i]. The loop therefore relies entirely on the state of priority 0 LRU rather than checking each priority list individually.

Change hardcoded index man->lru[0] to man->lru[i] to correctly inspect every per-priority LRU list.

Fixes cf6c467d67d3 ("drm/ttm: add BO priorities for the LRUs")

---
v2:
- Only the commit message was updated, including the Fixes: tag; no code changes.
- Link to v1: https://lore.kernel.org/all/[email protected]/

---
 drivers/gpu/drm/ttm/ttm_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_device.c +1 -1
index d3bfb9a696a7..e22c77f4228e 100644
@@ -266,7 +266,7 @@ void ttm_device_fini(struct ttm_device *bdev)
 
 	spin_lock(&bdev->lru_lock);
 	for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i)
-		if (list_empty(&man->lru[0]))
+		if (list_empty(&man->lru[i]))
 			pr_debug("Swap list %d was clean\n", i);
 	spin_unlock(&bdev->lru_lock);
 
Signature · 1 line
2.54.0