Merge drm/drm-next into drm-misc-next
[linux-2.6-microblaze.git] / drivers / gpu / drm / nouveau / nouveau_bo.c
index 00cc7d1..56dcd25 100644 (file)
@@ -404,27 +404,6 @@ nouveau_bo_new(struct nouveau_cli *cli, u64 size, int align,
        return 0;
 }
 
-static void
-set_placement_list(struct ttm_place *pl, unsigned *n, uint32_t domain)
-{
-       *n = 0;
-
-       if (domain & NOUVEAU_GEM_DOMAIN_VRAM) {
-               pl[*n].mem_type = TTM_PL_VRAM;
-               pl[*n].flags = 0;
-               (*n)++;
-       }
-       if (domain & NOUVEAU_GEM_DOMAIN_GART) {
-               pl[*n].mem_type = TTM_PL_TT;
-               pl[*n].flags = 0;
-               (*n)++;
-       }
-       if (domain & NOUVEAU_GEM_DOMAIN_CPU) {
-               pl[*n].mem_type = TTM_PL_SYSTEM;
-               pl[(*n)++].flags = 0;
-       }
-}
-
 static void
 set_placement_range(struct nouveau_bo *nvbo, uint32_t domain)
 {
@@ -452,10 +431,6 @@ set_placement_range(struct nouveau_bo *nvbo, uint32_t domain)
                        nvbo->placements[i].fpfn = fpfn;
                        nvbo->placements[i].lpfn = lpfn;
                }
-               for (i = 0; i < nvbo->placement.num_busy_placement; ++i) {
-                       nvbo->busy_placements[i].fpfn = fpfn;
-                       nvbo->busy_placements[i].lpfn = lpfn;
-               }
        }
 }
 
@@ -463,15 +438,32 @@ void
 nouveau_bo_placement_set(struct nouveau_bo *nvbo, uint32_t domain,
                         uint32_t busy)
 {
-       struct ttm_placement *pl = &nvbo->placement;
+       unsigned int *n = &nvbo->placement.num_placement;
+       struct ttm_place *pl = nvbo->placements;
 
-       pl->placement = nvbo->placements;
-       set_placement_list(nvbo->placements, &pl->num_placement, domain);
+       domain |= busy;
 
-       pl->busy_placement = nvbo->busy_placements;
-       set_placement_list(nvbo->busy_placements, &pl->num_busy_placement,
-                          domain | busy);
+       *n = 0;
+       if (domain & NOUVEAU_GEM_DOMAIN_VRAM) {
+               pl[*n].mem_type = TTM_PL_VRAM;
+               pl[*n].flags = busy & NOUVEAU_GEM_DOMAIN_VRAM ?
+                       TTM_PL_FLAG_FALLBACK : 0;
+               (*n)++;
+       }
+       if (domain & NOUVEAU_GEM_DOMAIN_GART) {
+               pl[*n].mem_type = TTM_PL_TT;
+               pl[*n].flags = busy & NOUVEAU_GEM_DOMAIN_GART ?
+                       TTM_PL_FLAG_FALLBACK : 0;
+               (*n)++;
+       }
+       if (domain & NOUVEAU_GEM_DOMAIN_CPU) {
+               pl[*n].mem_type = TTM_PL_SYSTEM;
+               pl[*n].flags = busy & NOUVEAU_GEM_DOMAIN_CPU ?
+                       TTM_PL_FLAG_FALLBACK : 0;
+               (*n)++;
+       }
 
+       nvbo->placement.placement = nvbo->placements;
        set_placement_range(nvbo, domain);
 }
 
@@ -1314,11 +1306,6 @@ vm_fault_t nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
                        nvbo->placements[i].lpfn = mappable;
                }
 
-               for (i = 0; i < nvbo->placement.num_busy_placement; ++i) {
-                       nvbo->busy_placements[i].fpfn = 0;
-                       nvbo->busy_placements[i].lpfn = mappable;
-               }
-
                nouveau_bo_placement_set(nvbo, NOUVEAU_GEM_DOMAIN_VRAM, 0);
        }