[PATCH 1/2] drm/ttm: allow zero sized kernel allocations
Christian König
deathsimple at vodafone.de
Tue Aug 12 05:32:11 PDT 2014
From: Christian König <christian.koenig at amd.com>
This patch allows to create zero sized TTM buffer
objects for driver internal use.
Signed-off-by: Christian König <christian.koenig at amd.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 4 ++--
drivers/gpu/drm/ttm/ttm_bo_util.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 3da89d5..0b96a3b 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -309,7 +309,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
if (ret)
goto out_err;
- if (mem->mem_type != TTM_PL_SYSTEM) {
+ if (bo->ttm->num_pages && mem->mem_type != TTM_PL_SYSTEM) {
ret = ttm_tt_bind(bo->ttm, mem);
if (ret)
goto out_err;
@@ -1107,7 +1107,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
}
num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
- if (num_pages == 0) {
+ if (type != ttm_bo_type_kernel && num_pages == 0) {
pr_err("Illegal buffer object size\n");
if (destroy)
(*destroy)(bo);
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 30e5d90..8354195 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -63,7 +63,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
if (unlikely(ret != 0))
return ret;
- if (new_mem->mem_type != TTM_PL_SYSTEM) {
+ if (ttm->num_pages && new_mem->mem_type != TTM_PL_SYSTEM) {
ret = ttm_tt_bind(ttm, new_mem);
if (unlikely(ret != 0))
return ret;
--
1.9.1
More information about the dri-devel
mailing list