Skip to content

Commit e3f2027

Browse files
ChristianKoenigAMDairlied
authored andcommitted
drm/ttm: fix handling of TTM_PL_FLAG_TOPDOWN v2
bo->mem.placement is not initialized when ttm_bo_man_get_node is called, so the flag had no effect at all. v2: change nouveau and vmwgfx as well Signed-off-by: Christian König <christian.koenig@amd.com> Cc: stable@vger.kernel.org Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent 4e4e7dc commit e3f2027

5 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎drivers/gpu/drm/nouveau/nouveau_ttm.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ static int
7676
nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
7777
struct ttm_buffer_object *bo,
7878
struct ttm_placement *placement,
79+
uint32_t flags,
7980
struct ttm_mem_reg *mem)
8081
{
8182
struct nouveau_drm *drm = nouveau_bdev(man->bdev);
@@ -162,6 +163,7 @@ static int
162163
nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
163164
struct ttm_buffer_object *bo,
164165
struct ttm_placement *placement,
166+
uint32_t flags,
165167
struct ttm_mem_reg *mem)
166168
{
167169
struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
@@ -242,6 +244,7 @@ static int
242244
nv04_gart_manager_new(struct ttm_mem_type_manager *man,
243245
struct ttm_buffer_object *bo,
244246
struct ttm_placement *placement,
247+
uint32_t flags,
245248
struct ttm_mem_reg *mem)
246249
{
247250
struct nouveau_mem *node;

‎drivers/gpu/drm/ttm/ttm_bo.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
784784
int ret;
785785

786786
do {
787-
ret = (*man->func->get_node)(man, bo, placement, mem);
787+
ret = (*man->func->get_node)(man, bo, placement, 0, mem);
788788
if (unlikely(ret != 0))
789789
return ret;
790790
if (mem->mm_node)
@@ -897,7 +897,8 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
897897

898898
if (man->has_type && man->use_type) {
899899
type_found = true;
900-
ret = (*man->func->get_node)(man, bo, placement, mem);
900+
ret = (*man->func->get_node)(man, bo, placement,
901+
cur_flags, mem);
901902
if (unlikely(ret))
902903
return ret;
903904
}
@@ -937,7 +938,6 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
937938
ttm_flag_masked(&cur_flags, placement->busy_placement[i],
938939
~TTM_PL_MASK_MEMTYPE);
939940

940-
941941
if (mem_type == TTM_PL_SYSTEM) {
942942
mem->mem_type = mem_type;
943943
mem->placement = cur_flags;

‎drivers/gpu/drm/ttm/ttm_bo_manager.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct ttm_range_manager {
5050
static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,
5151
struct ttm_buffer_object *bo,
5252
struct ttm_placement *placement,
53+
uint32_t flags,
5354
struct ttm_mem_reg *mem)
5455
{
5556
struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
@@ -67,7 +68,7 @@ static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,
6768
if (!node)
6869
return -ENOMEM;
6970

70-
if (bo->mem.placement & TTM_PL_FLAG_TOPDOWN)
71+
if (flags & TTM_PL_FLAG_TOPDOWN)
7172
aflags = DRM_MM_CREATE_TOP;
7273

7374
spin_lock(&rman->lock);

‎drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct vmwgfx_gmrid_man {
4747
static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man,
4848
struct ttm_buffer_object *bo,
4949
struct ttm_placement *placement,
50+
uint32_t flags,
5051
struct ttm_mem_reg *mem)
5152
{
5253
struct vmwgfx_gmrid_man *gman =

‎include/drm/ttm/ttm_bo_driver.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ struct ttm_mem_type_manager_func {
182182
* @man: Pointer to a memory type manager.
183183
* @bo: Pointer to the buffer object we're allocating space for.
184184
* @placement: Placement details.
185+
* @flags: Additional placement flags.
185186
* @mem: Pointer to a struct ttm_mem_reg to be filled in.
186187
*
187188
* This function should allocate space in the memory type managed
@@ -206,6 +207,7 @@ struct ttm_mem_type_manager_func {
206207
int (*get_node)(struct ttm_mem_type_manager *man,
207208
struct ttm_buffer_object *bo,
208209
struct ttm_placement *placement,
210+
uint32_t flags,
209211
struct ttm_mem_reg *mem);
210212

211213
/**

0 commit comments

Comments
 (0)