Commit a4394b6d authored by Felix Kuehling's avatar Felix Kuehling Committed by Christian König

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: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210414064804.29356-9-Felix.Kuehling@amd.com
parent 8a9d24f2
...@@ -317,9 +317,12 @@ int ttm_tt_populate(struct ttm_device *bdev, ...@@ -317,9 +317,12 @@ int ttm_tt_populate(struct ttm_device *bdev,
if (ttm_tt_is_populated(ttm)) if (ttm_tt_is_populated(ttm))
return 0; return 0;
if (!(ttm->page_flags & TTM_PAGE_FLAG_SG)) {
atomic_long_add(ttm->num_pages, &ttm_pages_allocated); atomic_long_add(ttm->num_pages, &ttm_pages_allocated);
if (bdev->pool.use_dma32) if (bdev->pool.use_dma32)
atomic_long_add(ttm->num_pages, &ttm_dma32_pages_allocated); atomic_long_add(ttm->num_pages,
&ttm_dma32_pages_allocated);
}
while (atomic_long_read(&ttm_pages_allocated) > ttm_pages_limit || while (atomic_long_read(&ttm_pages_allocated) > ttm_pages_limit ||
atomic_long_read(&ttm_dma32_pages_allocated) > atomic_long_read(&ttm_dma32_pages_allocated) >
...@@ -350,9 +353,12 @@ int ttm_tt_populate(struct ttm_device *bdev, ...@@ -350,9 +353,12 @@ int ttm_tt_populate(struct ttm_device *bdev,
return 0; return 0;
error: error:
if (!(ttm->page_flags & TTM_PAGE_FLAG_SG)) {
atomic_long_sub(ttm->num_pages, &ttm_pages_allocated); atomic_long_sub(ttm->num_pages, &ttm_pages_allocated);
if (bdev->pool.use_dma32) if (bdev->pool.use_dma32)
atomic_long_sub(ttm->num_pages, &ttm_dma32_pages_allocated); atomic_long_sub(ttm->num_pages,
&ttm_dma32_pages_allocated);
}
return ret; return ret;
} }
EXPORT_SYMBOL(ttm_tt_populate); EXPORT_SYMBOL(ttm_tt_populate);
...@@ -382,9 +388,12 @@ void ttm_tt_unpopulate(struct ttm_device *bdev, struct ttm_tt *ttm) ...@@ -382,9 +388,12 @@ void ttm_tt_unpopulate(struct ttm_device *bdev, struct ttm_tt *ttm)
else else
ttm_pool_free(&bdev->pool, ttm); ttm_pool_free(&bdev->pool, ttm);
if (!(ttm->page_flags & TTM_PAGE_FLAG_SG)) {
atomic_long_sub(ttm->num_pages, &ttm_pages_allocated); atomic_long_sub(ttm->num_pages, &ttm_pages_allocated);
if (bdev->pool.use_dma32) if (bdev->pool.use_dma32)
atomic_long_sub(ttm->num_pages, &ttm_dma32_pages_allocated); atomic_long_sub(ttm->num_pages,
&ttm_dma32_pages_allocated);
}
ttm->page_flags &= ~TTM_PAGE_FLAG_PRIV_POPULATED; ttm->page_flags &= ~TTM_PAGE_FLAG_PRIV_POPULATED;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment