Commit b6637526 authored by Dave Airlie's avatar Dave Airlie

drm/ttm: fix two bugs in new placement routines.

a) the loops were going to <= not <, leading to illegal memory access
b) the busy placement checks were using the placement arrays not the
   busy placement ones.
Acked-by: default avatarJerome Glisse <jglisse@redhat.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent b8ff7357
...@@ -849,7 +849,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo, ...@@ -849,7 +849,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
int i, ret; int i, ret;
mem->mm_node = NULL; mem->mm_node = NULL;
for (i = 0; i <= placement->num_placement; ++i) { for (i = 0; i < placement->num_placement; ++i) {
ret = ttm_mem_type_from_flags(placement->placement[i], ret = ttm_mem_type_from_flags(placement->placement[i],
&mem_type); &mem_type);
if (ret) if (ret)
...@@ -900,8 +900,8 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo, ...@@ -900,8 +900,8 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
if (!type_found) if (!type_found)
return -EINVAL; return -EINVAL;
for (i = 0; i <= placement->num_busy_placement; ++i) { for (i = 0; i < placement->num_busy_placement; ++i) {
ret = ttm_mem_type_from_flags(placement->placement[i], ret = ttm_mem_type_from_flags(placement->busy_placement[i],
&mem_type); &mem_type);
if (ret) if (ret)
return ret; return ret;
...@@ -911,7 +911,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo, ...@@ -911,7 +911,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
if (!ttm_bo_mt_compatible(man, if (!ttm_bo_mt_compatible(man,
bo->type == ttm_bo_type_user, bo->type == ttm_bo_type_user,
mem_type, mem_type,
placement->placement[i], placement->busy_placement[i],
&cur_flags)) &cur_flags))
continue; continue;
...@@ -921,7 +921,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo, ...@@ -921,7 +921,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
* Use the access and other non-mapping-related flag bits from * Use the access and other non-mapping-related flag bits from
* the memory placement flags to the current flags * the memory placement flags to the current flags
*/ */
ttm_flag_masked(&cur_flags, placement->placement[i], ttm_flag_masked(&cur_flags, placement->busy_placement[i],
~TTM_PL_MASK_MEMTYPE); ~TTM_PL_MASK_MEMTYPE);
ret = ttm_bo_mem_force_space(bo, mem_type, placement, mem, ret = ttm_bo_mem_force_space(bo, mem_type, placement, mem,
......
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