winsys/radeon: clear the buffer cache on mmap failure and try again
authorMarek Olšák <marek.olsak@amd.com>
Wed, 9 Dec 2015 21:45:56 +0000 (22:45 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 11 Dec 2015 14:25:13 +0000 (15:25 +0100)
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/winsys/radeon/drm/radeon_drm_bo.c

index b9716e50229f52aa13219adcf8e79c473f11d21a..ee61e54803f5742bef56cfdc2e17c61c0a54ca35 100644 (file)
@@ -361,9 +361,16 @@ void *radeon_bo_do_map(struct radeon_bo *bo)
     ptr = os_mmap(0, args.size, PROT_READ|PROT_WRITE, MAP_SHARED,
                bo->rws->fd, args.addr_ptr);
     if (ptr == MAP_FAILED) {
-        pipe_mutex_unlock(bo->map_mutex);
-        fprintf(stderr, "radeon: mmap failed, errno: %i\n", errno);
-        return NULL;
+        /* Clear the cache and try again. */
+        pb_cache_release_all_buffers(&bo->rws->bo_cache);
+
+        ptr = os_mmap(0, args.size, PROT_READ|PROT_WRITE, MAP_SHARED,
+                      bo->rws->fd, args.addr_ptr);
+        if (ptr == MAP_FAILED) {
+            pipe_mutex_unlock(bo->map_mutex);
+            fprintf(stderr, "radeon: mmap failed, errno: %i\n", errno);
+            return NULL;
+        }
     }
     bo->ptr = ptr;
     bo->map_count = 1;