} drm_bacon_bufmgr;
static int
-drm_bacon_gem_bo_set_tiling_internal(drm_bacon_bo *bo,
- uint32_t tiling_mode,
- uint32_t stride);
+bo_set_tiling_internal(drm_bacon_bo *bo, uint32_t tiling_mode, uint32_t stride);
-static void drm_bacon_gem_bo_free(drm_bacon_bo *bo);
+static void bo_free(drm_bacon_bo *bo);
static uint32_t
key_hash_uint(const void *key)
}
static unsigned long
-drm_bacon_gem_bo_tile_size(drm_bacon_bufmgr *bufmgr, unsigned long size,
- uint32_t *tiling_mode)
+bo_tile_size(drm_bacon_bufmgr *bufmgr, unsigned long size,
+ uint32_t *tiling_mode)
{
if (*tiling_mode == I915_TILING_NONE)
return size;
* change.
*/
static unsigned long
-drm_bacon_gem_bo_tile_pitch(drm_bacon_bufmgr *bufmgr,
- unsigned long pitch, uint32_t *tiling_mode)
+bo_tile_pitch(drm_bacon_bufmgr *bufmgr,
+ unsigned long pitch, uint32_t *tiling_mode)
{
unsigned long tile_width;
}
static struct drm_bacon_gem_bo_bucket *
-drm_bacon_gem_bo_bucket_for_size(drm_bacon_bufmgr *bufmgr,
- unsigned long size)
+bucket_for_size(drm_bacon_bufmgr *bufmgr, unsigned long size)
{
int i;
break;
list_del(&bo->head);
- drm_bacon_gem_bo_free(bo);
+ bo_free(bo);
}
}
static drm_bacon_bo *
-drm_bacon_gem_bo_alloc_internal(drm_bacon_bufmgr *bufmgr,
- const char *name,
- unsigned long size,
- unsigned long flags,
- uint32_t tiling_mode,
- unsigned long stride,
- unsigned int alignment)
+bo_alloc_internal(drm_bacon_bufmgr *bufmgr,
+ const char *name,
+ unsigned long size,
+ unsigned long flags,
+ uint32_t tiling_mode,
+ unsigned long stride,
+ unsigned int alignment)
{
drm_bacon_bo *bo;
unsigned int page_size = getpagesize();
for_render = true;
/* Round the allocated size up to a power of two number of pages. */
- bucket = drm_bacon_gem_bo_bucket_for_size(bufmgr, size);
+ bucket = bucket_for_size(bufmgr, size);
/* If we don't have caching at this size, don't actually round the
* allocation up.
if (alloc_from_cache) {
if (!drm_bacon_bo_madvise(bo, I915_MADV_WILLNEED)) {
- drm_bacon_gem_bo_free(bo);
+ bo_free(bo);
drm_bacon_gem_bo_cache_purge_bucket(bufmgr,
bucket);
goto retry;
}
- if (drm_bacon_gem_bo_set_tiling_internal(bo,
- tiling_mode,
- stride)) {
- drm_bacon_gem_bo_free(bo);
+ if (bo_set_tiling_internal(bo, tiling_mode, stride)) {
+ bo_free(bo);
goto retry;
}
}
if (!bo)
goto err;
- /* drm_bacon_gem_bo_free calls list_del() for an uninitialized
+ /* bo_free calls list_del() for an uninitialized
list (vma_list), so better set the list head here */
list_inithead(&bo->vma_list);
bo->swizzle_mode = I915_BIT_6_SWIZZLE_NONE;
bo->stride = 0;
- if (drm_bacon_gem_bo_set_tiling_internal(bo,
- tiling_mode,
- stride))
+ if (bo_set_tiling_internal(bo, tiling_mode, stride))
goto err_free;
}
return bo;
err_free:
- drm_bacon_gem_bo_free(bo);
+ bo_free(bo);
err:
pthread_mutex_unlock(&bufmgr->lock);
return NULL;
unsigned long size,
unsigned int alignment)
{
- return drm_bacon_gem_bo_alloc_internal(bufmgr, name, size,
- BO_ALLOC_FOR_RENDER,
- I915_TILING_NONE, 0,
- alignment);
+ return bo_alloc_internal(bufmgr, name, size, BO_ALLOC_FOR_RENDER,
+ I915_TILING_NONE, 0, alignment);
}
drm_bacon_bo *
unsigned long size,
unsigned int alignment)
{
- return drm_bacon_gem_bo_alloc_internal(bufmgr, name, size, 0,
- I915_TILING_NONE, 0, 0);
+ return bo_alloc_internal(bufmgr, name, size, 0, I915_TILING_NONE, 0, 0);
}
drm_bacon_bo *
aligned_y = ALIGN(y, height_alignment);
stride = x * cpp;
- stride = drm_bacon_gem_bo_tile_pitch(bufmgr, stride, tiling_mode);
+ stride = bo_tile_pitch(bufmgr, stride, tiling_mode);
size = stride * aligned_y;
- size = drm_bacon_gem_bo_tile_size(bufmgr, size, tiling_mode);
+ size = bo_tile_size(bufmgr, size, tiling_mode);
} while (*tiling_mode != tiling);
*pitch = stride;
if (tiling == I915_TILING_NONE)
stride = 0;
- return drm_bacon_gem_bo_alloc_internal(bufmgr, name, size, flags,
- tiling, stride, 0);
+ return bo_alloc_internal(bufmgr, name, size, flags, tiling, stride, 0);
}
/**
return bo;
err_unref:
- drm_bacon_gem_bo_free(bo);
+ bo_free(bo);
pthread_mutex_unlock(&bufmgr->lock);
return NULL;
}
static void
-drm_bacon_gem_bo_free(drm_bacon_bo *bo)
+bo_free(drm_bacon_bo *bo)
{
drm_bacon_bufmgr *bufmgr = bo->bufmgr;
struct drm_gem_close close;
}
static void
-drm_bacon_gem_bo_mark_mmaps_incoherent(drm_bacon_bo *bo)
+bo_mark_mmaps_incoherent(drm_bacon_bo *bo)
{
#if HAVE_VALGRIND
if (bo->mem_virtual)
/** Frees all cached buffers significantly older than @time. */
static void
-drm_bacon_gem_cleanup_bo_cache(drm_bacon_bufmgr *bufmgr, time_t time)
+cleanup_bo_cache(drm_bacon_bufmgr *bufmgr, time_t time)
{
int i;
list_del(&bo->head);
- drm_bacon_gem_bo_free(bo);
+ bo_free(bo);
}
}
bufmgr->time = time;
}
-static void drm_bacon_gem_bo_purge_vma_cache(drm_bacon_bufmgr *bufmgr)
+static void
+bo_purge_vma_cache(drm_bacon_bufmgr *bufmgr)
{
int limit;
}
}
-static void drm_bacon_gem_bo_close_vma(drm_bacon_bufmgr *bufmgr,
- drm_bacon_bo *bo)
+static void
+bo_close_vma(drm_bacon_bufmgr *bufmgr, drm_bacon_bo *bo)
{
bufmgr->vma_open--;
list_addtail(&bo->vma_list, &bufmgr->vma_cache);
bufmgr->vma_count++;
if (bo->gtt_virtual)
bufmgr->vma_count++;
- drm_bacon_gem_bo_purge_vma_cache(bufmgr);
+ bo_purge_vma_cache(bufmgr);
}
-static void drm_bacon_gem_bo_open_vma(drm_bacon_bufmgr *bufmgr,
- drm_bacon_bo *bo)
+static void
+bo_open_vma(drm_bacon_bufmgr *bufmgr, drm_bacon_bo *bo)
{
bufmgr->vma_open++;
list_del(&bo->vma_list);
bufmgr->vma_count--;
if (bo->gtt_virtual)
bufmgr->vma_count--;
- drm_bacon_gem_bo_purge_vma_cache(bufmgr);
+ bo_purge_vma_cache(bufmgr);
}
static void
-drm_bacon_gem_bo_unreference_final(drm_bacon_bo *bo, time_t time)
+bo_unreference_final(drm_bacon_bo *bo, time_t time)
{
drm_bacon_bufmgr *bufmgr = bo->bufmgr;
struct drm_bacon_gem_bo_bucket *bucket;
if (bo->map_count) {
DBG("bo freed with non-zero map-count %d\n", bo->map_count);
bo->map_count = 0;
- drm_bacon_gem_bo_close_vma(bufmgr, bo);
- drm_bacon_gem_bo_mark_mmaps_incoherent(bo);
+ bo_close_vma(bufmgr, bo);
+ bo_mark_mmaps_incoherent(bo);
}
- bucket = drm_bacon_gem_bo_bucket_for_size(bufmgr, bo->size);
+ bucket = bucket_for_size(bufmgr, bo->size);
/* Put the buffer into our internal cache for reuse if we can. */
if (bufmgr->bo_reuse && bo->reusable && bucket != NULL &&
drm_bacon_bo_madvise(bo, I915_MADV_DONTNEED)) {
list_addtail(&bo->head, &bucket->head);
} else {
- drm_bacon_gem_bo_free(bo);
+ bo_free(bo);
}
}
pthread_mutex_lock(&bufmgr->lock);
if (p_atomic_dec_zero(&bo->refcount)) {
- drm_bacon_gem_bo_unreference_final(bo, time.tv_sec);
- drm_bacon_gem_cleanup_bo_cache(bufmgr, time.tv_sec);
+ bo_unreference_final(bo, time.tv_sec);
+ cleanup_bo_cache(bufmgr, time.tv_sec);
}
pthread_mutex_unlock(&bufmgr->lock);
pthread_mutex_lock(&bufmgr->lock);
if (bo->map_count++ == 0)
- drm_bacon_gem_bo_open_vma(bufmgr, bo);
+ bo_open_vma(bufmgr, bo);
if (!bo->mem_virtual) {
struct drm_i915_gem_mmap mmap_arg;
__FILE__, __LINE__, bo->gem_handle,
bo->name, strerror(errno));
if (--bo->map_count == 0)
- drm_bacon_gem_bo_close_vma(bufmgr, bo);
+ bo_close_vma(bufmgr, bo);
pthread_mutex_unlock(&bufmgr->lock);
return ret;
}
strerror(errno));
}
- drm_bacon_gem_bo_mark_mmaps_incoherent(bo);
+ bo_mark_mmaps_incoherent(bo);
VG(VALGRIND_MAKE_MEM_DEFINED(bo->mem_virtual, bo->size));
pthread_mutex_unlock(&bufmgr->lock);
int ret;
if (bo->map_count++ == 0)
- drm_bacon_gem_bo_open_vma(bufmgr, bo);
+ bo_open_vma(bufmgr, bo);
/* Get a mapping of the buffer if we haven't before. */
if (bo->gtt_virtual == NULL) {
bo->gem_handle, bo->name,
strerror(errno));
if (--bo->map_count == 0)
- drm_bacon_gem_bo_close_vma(bufmgr, bo);
+ bo_close_vma(bufmgr, bo);
return ret;
}
bo->gem_handle, bo->name,
strerror(errno));
if (--bo->map_count == 0)
- drm_bacon_gem_bo_close_vma(bufmgr, bo);
+ bo_close_vma(bufmgr, bo);
return ret;
}
}
strerror(errno));
}
- drm_bacon_gem_bo_mark_mmaps_incoherent(bo);
+ bo_mark_mmaps_incoherent(bo);
VG(VALGRIND_MAKE_MEM_DEFINED(bo->gtt_virtual, bo->size));
pthread_mutex_unlock(&bufmgr->lock);
ret = map_gtt(bo);
if (ret == 0) {
- drm_bacon_gem_bo_mark_mmaps_incoherent(bo);
+ bo_mark_mmaps_incoherent(bo);
VG(VALGRIND_MAKE_MEM_DEFINED(bo->gtt_virtual, bo->size));
}
* limits and cause later failures.
*/
if (--bo->map_count == 0) {
- drm_bacon_gem_bo_close_vma(bufmgr, bo);
- drm_bacon_gem_bo_mark_mmaps_incoherent(bo);
+ bo_close_vma(bufmgr, bo);
+ bo_mark_mmaps_incoherent(bo);
bo->virtual = NULL;
}
pthread_mutex_unlock(&bufmgr->lock);
bo = LIST_ENTRY(drm_bacon_bo, bucket->head.next, head);
list_del(&bo->head);
- drm_bacon_gem_bo_free(bo);
+ bo_free(bo);
}
}
}
static int
-drm_bacon_gem_bo_set_tiling_internal(drm_bacon_bo *bo,
- uint32_t tiling_mode,
- uint32_t stride)
+bo_set_tiling_internal(drm_bacon_bo *bo, uint32_t tiling_mode, uint32_t stride)
{
drm_bacon_bufmgr *bufmgr = bo->bufmgr;
struct drm_i915_gem_set_tiling set_tiling;
if (*tiling_mode == I915_TILING_NONE)
stride = 0;
- ret = drm_bacon_gem_bo_set_tiling_internal(bo, *tiling_mode, stride);
+ ret = bo_set_tiling_internal(bo, *tiling_mode, stride);
*tiling_mode = bo->tiling_mode;
return ret;
return bo;
err:
- drm_bacon_gem_bo_free(bo);
+ bo_free(bo);
pthread_mutex_unlock(&bufmgr->lock);
return NULL;
}
{
bufmgr->vma_max = limit;
- drm_bacon_gem_bo_purge_vma_cache(bufmgr);
+ bo_purge_vma_cache(bufmgr);
}
drm_bacon_context *
bo->gem_handle, bo->name, bo->map_count);
if (bo->map_count++ == 0)
- drm_bacon_gem_bo_open_vma(bufmgr, bo);
+ bo_open_vma(bufmgr, bo);
memclear(mmap_arg);
mmap_arg.handle = bo->gem_handle;
}
if (ptr == MAP_FAILED) {
if (--bo->map_count == 0)
- drm_bacon_gem_bo_close_vma(bufmgr, bo);
+ bo_close_vma(bufmgr, bo);
ptr = NULL;
}
struct drm_i915_gem_mmap mmap_arg;
if (bo->map_count++ == 0)
- drm_bacon_gem_bo_open_vma(bufmgr, bo);
+ bo_open_vma(bufmgr, bo);
DBG("bo_map: %d (%s), map_count=%d\n",
bo->gem_handle, bo->name, bo->map_count);
__FILE__, __LINE__, bo->gem_handle,
bo->name, strerror(errno));
if (--bo->map_count == 0)
- drm_bacon_gem_bo_close_vma(bufmgr, bo);
+ bo_close_vma(bufmgr, bo);
} else {
VG(VALGRIND_MALLOCLIKE_BLOCK(mmap_arg.addr_ptr, mmap_arg.size, 0, 1));
bo->mem_virtual = (void *)(uintptr_t) mmap_arg.addr_ptr;
struct drm_i915_gem_mmap mmap_arg;
if (bo->map_count++ == 0)
- drm_bacon_gem_bo_open_vma(bufmgr, bo);
+ bo_open_vma(bufmgr, bo);
DBG("bo_map: %d (%s), map_count=%d\n",
bo->gem_handle, bo->name, bo->map_count);
__FILE__, __LINE__, bo->gem_handle,
bo->name, strerror(errno));
if (--bo->map_count == 0)
- drm_bacon_gem_bo_close_vma(bufmgr, bo);
+ bo_close_vma(bufmgr, bo);
} else {
VG(VALGRIND_MALLOCLIKE_BLOCK(mmap_arg.addr_ptr, mmap_arg.size, 0, 1));
bo->wc_virtual = (void *)(uintptr_t) mmap_arg.addr_ptr;