summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/iris
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2019-05-26 13:43:32 -0700
committerKenneth Graunke <[email protected]>2019-05-29 19:41:22 -0700
commit042f8514e67315b74cccf3692d34e5b2d32a6c14 (patch)
tree66f5db2c77cf79de5263fb0bb4961edc08004336 /src/gallium/drivers/iris
parent06421e5be72a3893b48d9f0b98cd847803bbb167 (diff)
iris: Move fresh BO allocation into a helper function.
There's enough going on here to warrant a helper. More cleaning coming. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Diffstat (limited to 'src/gallium/drivers/iris')
-rw-r--r--src/gallium/drivers/iris/iris_bufmgr.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
index 64dd73adaaa..e6c61a7a14c 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.c
+++ b/src/gallium/drivers/iris/iris_bufmgr.c
@@ -361,6 +361,34 @@ bo_calloc(void)
}
static struct iris_bo *
+alloc_fresh_bo(struct iris_bufmgr *bufmgr, uint64_t bo_size)
+{
+ struct iris_bo *bo = bo_calloc();
+ if (!bo)
+ return NULL;
+
+ struct drm_i915_gem_create create = { .size = bo_size };
+
+ /* All new BOs we get from the kernel are zeroed, so we don't need to
+ * worry about that here.
+ */
+ if (drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CREATE, &create) != 0) {
+ free(bo);
+ return NULL;
+ }
+
+ bo->gem_handle = create.handle;
+ bo->bufmgr = bufmgr;
+ bo->size = bo_size;
+ bo->idle = true;
+ bo->tiling_mode = I915_TILING_NONE;
+ bo->swizzle_mode = I915_BIT_6_SWIZZLE_NONE;
+ bo->stride = 0;
+
+ return bo;
+}
+
+static struct iris_bo *
bo_alloc_internal(struct iris_bufmgr *bufmgr,
const char *name,
uint64_t size,
@@ -371,7 +399,6 @@ bo_alloc_internal(struct iris_bufmgr *bufmgr,
{
struct iris_bo *bo;
unsigned int page_size = getpagesize();
- int ret;
struct bo_cache_bucket *bucket;
bool alloc_from_cache;
uint64_t bo_size;
@@ -434,33 +461,10 @@ retry:
bo->gtt_offset = 0ull;
}
} else {
- bo = bo_calloc();
+ alloc_pages = true;
+ bo = alloc_fresh_bo(bufmgr, bo_size);
if (!bo)
goto err;
-
- bo->size = bo_size;
- bo->idle = true;
-
- struct drm_i915_gem_create create = { .size = bo_size };
-
- /* All new BOs we get from the kernel are zeroed, so we don't need to
- * worry about that here.
- */
- ret = drm_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CREATE, &create);
- if (ret != 0) {
- free(bo);
- goto err;
- }
-
- bo->gem_handle = create.handle;
-
- bo->bufmgr = bufmgr;
-
- bo->tiling_mode = I915_TILING_NONE;
- bo->swizzle_mode = I915_BIT_6_SWIZZLE_NONE;
- bo->stride = 0;
-
- alloc_pages = true;
}
bo->name = name;