drm/ttm: fix handling of TTM_PL_FLAG_TOPDOWN v2
authorChristian König <christian.koenig@amd.com>
Thu, 3 Jul 2014 07:02:23 +0000 (09:02 +0200)
committerDave Airlie <airlied@redhat.com>
Tue, 8 Jul 2014 01:15:58 +0000 (11:15 +1000)
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>
drivers/gpu/drm/nouveau/nouveau_ttm.c
drivers/gpu/drm/ttm/ttm_bo.c
drivers/gpu/drm/ttm/ttm_bo_manager.c
drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
include/drm/ttm/ttm_bo_driver.h

index ab0228f640a5e86f1554402bcf5816d2e8a9a986..7e185c122750347c4a214782f095cb6d3dda6b0d 100644 (file)
@@ -76,6 +76,7 @@ static int
 nouveau_vram_manager_new(struct ttm_mem_type_manager *man,
                         struct ttm_buffer_object *bo,
                         struct ttm_placement *placement,
+                        uint32_t flags,
                         struct ttm_mem_reg *mem)
 {
        struct nouveau_drm *drm = nouveau_bdev(man->bdev);
@@ -162,6 +163,7 @@ static int
 nouveau_gart_manager_new(struct ttm_mem_type_manager *man,
                         struct ttm_buffer_object *bo,
                         struct ttm_placement *placement,
+                        uint32_t flags,
                         struct ttm_mem_reg *mem)
 {
        struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
@@ -242,6 +244,7 @@ static int
 nv04_gart_manager_new(struct ttm_mem_type_manager *man,
                      struct ttm_buffer_object *bo,
                      struct ttm_placement *placement,
+                     uint32_t flags,
                      struct ttm_mem_reg *mem)
 {
        struct nouveau_mem *node;
index 4ab9f7171c4ff04a539a8bde7fc8a9dec2b9b817..a13a10025ec7f2e047f83895204c1b1a7fa9590c 100644 (file)
@@ -784,7 +784,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
        int ret;
 
        do {
-               ret = (*man->func->get_node)(man, bo, placement, mem);
+               ret = (*man->func->get_node)(man, bo, placement, 0, mem);
                if (unlikely(ret != 0))
                        return ret;
                if (mem->mm_node)
@@ -897,7 +897,8 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
 
                if (man->has_type && man->use_type) {
                        type_found = true;
-                       ret = (*man->func->get_node)(man, bo, placement, mem);
+                       ret = (*man->func->get_node)(man, bo, placement,
+                                                    cur_flags, mem);
                        if (unlikely(ret))
                                return ret;
                }
@@ -937,7 +938,6 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
                ttm_flag_masked(&cur_flags, placement->busy_placement[i],
                                ~TTM_PL_MASK_MEMTYPE);
 
-
                if (mem_type == TTM_PL_SYSTEM) {
                        mem->mem_type = mem_type;
                        mem->placement = cur_flags;
index bd850c9f4bca64975e38bb25e429dfa0f614882d..9e103a4875c820d07d8a99484a865e40f9ec3850 100644 (file)
@@ -50,6 +50,7 @@ struct ttm_range_manager {
 static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,
                               struct ttm_buffer_object *bo,
                               struct ttm_placement *placement,
+                              uint32_t flags,
                               struct ttm_mem_reg *mem)
 {
        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,
        if (!node)
                return -ENOMEM;
 
-       if (bo->mem.placement & TTM_PL_FLAG_TOPDOWN)
+       if (flags & TTM_PL_FLAG_TOPDOWN)
                aflags = DRM_MM_CREATE_TOP;
 
        spin_lock(&rman->lock);
index b1273e8e9a6903e2d15d3b153177e9a99c806859..26f8bdde3529b8a5b222a52aa34ebc8da185232a 100644 (file)
@@ -47,6 +47,7 @@ struct vmwgfx_gmrid_man {
 static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man,
                                  struct ttm_buffer_object *bo,
                                  struct ttm_placement *placement,
+                                 uint32_t flags,
                                  struct ttm_mem_reg *mem)
 {
        struct vmwgfx_gmrid_man *gman =
index e3f8c99a8a9d2490bbcc0b0a0263e888aab2e1b1..202f0a7171e85a2c5ea93ef9c9e2768d561e8d6e 100644 (file)
@@ -182,6 +182,7 @@ struct ttm_mem_type_manager_func {
         * @man: Pointer to a memory type manager.
         * @bo: Pointer to the buffer object we're allocating space for.
         * @placement: Placement details.
+        * @flags: Additional placement flags.
         * @mem: Pointer to a struct ttm_mem_reg to be filled in.
         *
         * This function should allocate space in the memory type managed
@@ -206,6 +207,7 @@ struct ttm_mem_type_manager_func {
        int  (*get_node)(struct ttm_mem_type_manager *man,
                         struct ttm_buffer_object *bo,
                         struct ttm_placement *placement,
+                        uint32_t flags,
                         struct ttm_mem_reg *mem);
 
        /**