Skip to content

Commit a4394b6

Browse files
fxkamdChristianKoenigAMD
authored andcommitted
drm/ttm: Don't count pages in SG BOs against pages_limit
Pages in SG BOs were not allocated by TTM. So don't count them against TTM's pages limit. Signed-off-by: Felix Kuehling <[email protected]> Reviewed-by: Christian König <[email protected]> Signed-off-by: Christian König <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 8a9d24f commit a4394b6

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

drivers/gpu/drm/ttm/ttm_tt.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,12 @@ int ttm_tt_populate(struct ttm_device *bdev,
317317
if (ttm_tt_is_populated(ttm))
318318
return 0;
319319

320-
atomic_long_add(ttm->num_pages, &ttm_pages_allocated);
321-
if (bdev->pool.use_dma32)
322-
atomic_long_add(ttm->num_pages, &ttm_dma32_pages_allocated);
320+
if (!(ttm->page_flags & TTM_PAGE_FLAG_SG)) {
321+
atomic_long_add(ttm->num_pages, &ttm_pages_allocated);
322+
if (bdev->pool.use_dma32)
323+
atomic_long_add(ttm->num_pages,
324+
&ttm_dma32_pages_allocated);
325+
}
323326

324327
while (atomic_long_read(&ttm_pages_allocated) > ttm_pages_limit ||
325328
atomic_long_read(&ttm_dma32_pages_allocated) >
@@ -350,9 +353,12 @@ int ttm_tt_populate(struct ttm_device *bdev,
350353
return 0;
351354

352355
error:
353-
atomic_long_sub(ttm->num_pages, &ttm_pages_allocated);
354-
if (bdev->pool.use_dma32)
355-
atomic_long_sub(ttm->num_pages, &ttm_dma32_pages_allocated);
356+
if (!(ttm->page_flags & TTM_PAGE_FLAG_SG)) {
357+
atomic_long_sub(ttm->num_pages, &ttm_pages_allocated);
358+
if (bdev->pool.use_dma32)
359+
atomic_long_sub(ttm->num_pages,
360+
&ttm_dma32_pages_allocated);
361+
}
356362
return ret;
357363
}
358364
EXPORT_SYMBOL(ttm_tt_populate);
@@ -382,9 +388,12 @@ void ttm_tt_unpopulate(struct ttm_device *bdev, struct ttm_tt *ttm)
382388
else
383389
ttm_pool_free(&bdev->pool, ttm);
384390

385-
atomic_long_sub(ttm->num_pages, &ttm_pages_allocated);
386-
if (bdev->pool.use_dma32)
387-
atomic_long_sub(ttm->num_pages, &ttm_dma32_pages_allocated);
391+
if (!(ttm->page_flags & TTM_PAGE_FLAG_SG)) {
392+
atomic_long_sub(ttm->num_pages, &ttm_pages_allocated);
393+
if (bdev->pool.use_dma32)
394+
atomic_long_sub(ttm->num_pages,
395+
&ttm_dma32_pages_allocated);
396+
}
388397

389398
ttm->page_flags &= ~TTM_PAGE_FLAG_PRIV_POPULATED;
390399
}

0 commit comments

Comments
 (0)