From 12295de757156469edf37f41e28da656d3e51844 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com>
Date: Fri, 26 Jan 2018 14:01:51 +0100
Subject: [PATCH] drm/ttm: alloc only one memory allocation operation at a time
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 3 +++
include/drm/ttm/ttm_bo_driver.h | 2 ++
2 files changed, 5 insertions(+)
@@ -1053,7 +1053,9 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
/*
* Determine where to move the buffer.
*/
+ mutex_lock(&bo->bdev->mem_alloc);
ret = ttm_bo_mem_space(bo, placement, &mem, ctx);
+ mutex_unlock(&bo->bdev->mem_alloc);
if (ret)
goto out_unlock;
ret = ttm_bo_handle_move_mem(bo, &mem, false, ctx);
@@ -1594,6 +1596,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
0x10000000);
INIT_DELAYED_WORK(&bdev->wq, ttm_bo_delayed_workqueue);
INIT_LIST_HEAD(&bdev->ddestroy);
+ mutex_init(&bdev->mem_alloc);
bdev->dev_mapping = mapping;
bdev->glob = glob;
bdev->need_dma32 = need_dma32;
@@ -596,6 +596,8 @@ struct ttm_bo_device {
bool need_dma32;
bool no_retry;
+
+ struct mutex mem_alloc;
};
/**
--
2.14.1