radeonsi: adjust and simplify max_alloc_size determination
authorMarek Olšák <marek.olsak@amd.com>
Tue, 28 Aug 2018 23:13:18 +0000 (19:13 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 10 Sep 2018 19:19:56 +0000 (15:19 -0400)
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
src/amd/common/ac_gpu_info.c
src/gallium/winsys/radeon/drm/radeon_drm_winsys.c

index bfaff45219f01eecfbf19412501058152ed79f4a..766ad835476d64066a443fa0dc98abe10972ad8f 100644 (file)
@@ -255,9 +255,6 @@ bool ac_query_gpu_info(int fd, amdgpu_device_handle dev,
                info->gart_size = meminfo.gtt.total_heap_size;
                info->vram_size = meminfo.vram.total_heap_size;
                info->vram_vis_size = meminfo.cpu_accessible_vram.total_heap_size;
-
-               info->max_alloc_size = MAX2(meminfo.vram.max_allocation,
-                                           meminfo.gtt.max_allocation);
        } else {
                /* This is a deprecated interface, which reports usable sizes
                 * (total minus pinned), but the pinned size computation is
@@ -289,11 +286,6 @@ bool ac_query_gpu_info(int fd, amdgpu_device_handle dev,
                info->gart_size = gtt.heap_size;
                info->vram_size = vram.heap_size;
                info->vram_vis_size = vram_vis.heap_size;
-
-               /* The kernel can split large buffers in VRAM but not in GTT, so large
-                * allocations can fail or cause buffer movement failures in the kernel.
-                */
-               info->max_alloc_size = MAX2(info->vram_size * 0.9, info->gart_size * 0.7);
        }
 
        /* Set chip identification. */
@@ -331,6 +323,14 @@ bool ac_query_gpu_info(int fd, amdgpu_device_handle dev,
        info->has_dedicated_vram =
                !(amdinfo->ids_flags & AMDGPU_IDS_FLAGS_FUSION);
 
+       /* The kernel can split large buffers in VRAM but not in GTT, so large
+        * allocations can fail or cause buffer movement failures in the kernel.
+        */
+       if (info->has_dedicated_vram)
+               info->max_alloc_size = info->vram_size * 0.8;
+       else
+               info->max_alloc_size = info->gart_size * 0.7;
+
        /* Set hardware information. */
        info->gds_size = gds.gds_total_size;
        info->gds_gfx_partition_size = gds.gds_gfx_partition_size;
index 3560c34c17a9dba77589b5ff1094e97099d1d4da..cf07a8d8e266ca319290a73dbc5535e73354b0f3 100644 (file)
@@ -362,11 +362,13 @@ static bool do_winsys_init(struct radeon_drm_winsys *ws)
     if (ws->info.drm_minor < 49)
         ws->info.vram_vis_size = MIN2(ws->info.vram_vis_size, 256*1024*1024);
 
-    /* Radeon allocates all buffers as contigous, which makes large allocations
+    /* Radeon allocates all buffers contiguously, which makes large allocations
      * unlikely to succeed. */
-    ws->info.max_alloc_size = MAX2(ws->info.vram_size, ws->info.gart_size) * 0.7;
     if (ws->info.has_dedicated_vram)
-        ws->info.max_alloc_size = MIN2(ws->info.vram_size * 0.7, ws->info.max_alloc_size);
+           ws->info.max_alloc_size = ws->info.vram_size * 0.7;
+    else
+           ws->info.max_alloc_size = ws->info.gart_size * 0.7;
+
     if (ws->info.drm_minor < 40)
         ws->info.max_alloc_size = MIN2(ws->info.max_alloc_size, 256*1024*1024);
     /* Both 32-bit and 64-bit address spaces only have 4GB. */