aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys/amdgpu
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2018-11-21 00:22:48 -0500
committerMarek Olšák <[email protected]>2018-11-28 20:20:27 -0500
commit9576266a3761d4005162380967d33a6c2b70b1dd (patch)
tree469a7cbbd995869094b62f332cb4b1ff47226d24 /src/gallium/winsys/amdgpu
parent015061beb3dc17ed7834e61ab9f2113ddc4758a3 (diff)
winsys/amdgpu: always reclaim/release slabs if there is not enough memory
Diffstat (limited to 'src/gallium/winsys/amdgpu')
-rw-r--r--src/gallium/winsys/amdgpu/drm/amdgpu_bo.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index 73336dd3e01..1402e5c2ec2 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -218,13 +218,19 @@ static void amdgpu_bo_destroy_or_cache(struct pb_buffer *_buf)
amdgpu_bo_destroy(_buf);
}
+static void amdgpu_clean_up_buffer_managers(struct amdgpu_winsys *ws)
+{
+ pb_slabs_reclaim(&ws->bo_slabs);
+ pb_cache_release_all_buffers(&ws->bo_cache);
+}
+
static bool amdgpu_bo_do_map(struct amdgpu_winsys_bo *bo, void **cpu)
{
assert(!bo->sparse && bo->bo && !bo->is_user_ptr);
int r = amdgpu_bo_cpu_map(bo->bo, cpu);
if (r) {
- /* Clear the cache and try again. */
- pb_cache_release_all_buffers(&bo->ws->bo_cache);
+ /* Clean up buffer managers and try again. */
+ amdgpu_clean_up_buffer_managers(bo->ws);
r = amdgpu_bo_cpu_map(bo->bo, cpu);
if (r)
return false;
@@ -1241,8 +1247,8 @@ amdgpu_bo_create(struct radeon_winsys *rws,
entry = pb_slab_alloc(&ws->bo_slabs, size, heap);
if (!entry) {
- /* Clear the cache and try again. */
- pb_cache_release_all_buffers(&ws->bo_cache);
+ /* Clean up buffer managers and try again. */
+ amdgpu_clean_up_buffer_managers(ws);
entry = pb_slab_alloc(&ws->bo_slabs, size, heap);
}
@@ -1290,9 +1296,9 @@ no_slab:
/* Create a new one. */
bo = amdgpu_create_bo(ws, size, alignment, domain, flags, heap);
if (!bo) {
- /* Clear the cache and try again. */
- pb_slabs_reclaim(&ws->bo_slabs);
- pb_cache_release_all_buffers(&ws->bo_cache);
+ /* Clean up buffer managers and try again. */
+ amdgpu_clean_up_buffer_managers(ws);
+
bo = amdgpu_create_bo(ws, size, alignment, domain, flags, heap);
if (!bo)
return NULL;