Module: Mesa
Branch: main
Commit: 2863e720f03fccbba6258e54c10e129ddc8a5c12
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2863e720f03fccbba6258e54c10e129ddc8a5c12

Author: Jordan Justen <[email protected]>
Date:   Fri Jun 10 18:20:30 2022 -0700

intel/dev: Determine the amount of free vram using small BAR uapi

Signed-off-by: Jordan Justen <[email protected]>
Reviewed-by: Lionel Landwerlin <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16739>

---

 src/intel/dev/intel_device_info.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/intel/dev/intel_device_info.c 
b/src/intel/dev/intel_device_info.c
index 29cbb849cad..1e70ff5f7cf 100644
--- a/src/intel/dev/intel_device_info.c
+++ b/src/intel/dev/intel_device_info.c
@@ -1643,8 +1643,22 @@ query_regions(struct intel_device_info *devinfo, int fd, 
bool update)
             assert((devinfo->mem.vram.mappable.size +
                     devinfo->mem.vram.unmappable.size) == mem->probed_size);
          }
-         if (mem->unallocated_size != -1)
-            devinfo->mem.vram.mappable.free = mem->unallocated_size;
+         if (mem->unallocated_cpu_visible_size > 0) {
+            if (mem->unallocated_size != -1) {
+               devinfo->mem.vram.mappable.free = 
mem->unallocated_cpu_visible_size;
+               devinfo->mem.vram.unmappable.free =
+                  mem->unallocated_size - mem->unallocated_cpu_visible_size;
+            }
+         } else {
+            /* We are running on an older kernel without support for the
+             * small-bar uapi. These kernels only support systems where the
+             * entire vram is mappable.
+             */
+            if (mem->unallocated_size != -1) {
+               devinfo->mem.vram.mappable.free = mem->unallocated_size;
+               devinfo->mem.vram.unmappable.free = 0;
+            }
+         }
          break;
       default:
          break;

Reply via email to