Esempio n. 1
0
void fd_bo_del(struct fd_bo *bo)
{
	struct fd_device *dev = bo->dev;

	if (!atomic_dec_and_test(&bo->refcnt))
		return;

	pthread_mutex_lock(&table_lock);

	if (bo->bo_reuse) {
		struct fd_bo_bucket *bucket = get_bucket(dev, bo->size);

		/* see if we can be green and recycle: */
		if (bucket) {
			struct timespec time;

			clock_gettime(CLOCK_MONOTONIC, &time);

			bo->free_time = time.tv_sec;
			list_addtail(&bo->list, &bucket->list);
			fd_cleanup_bo_cache(dev, time.tv_sec);

			/* bo's in the bucket cache don't have a ref and
			 * don't hold a ref to the dev:
			 */

			goto out;
		}
	}

	bo_del(bo);
out:
	fd_device_del_locked(dev);
	pthread_mutex_unlock(&table_lock);
}
Esempio n. 2
0
void fd_bo_del(struct fd_bo *bo)
{
	struct fd_device *dev = bo->dev;

	if (!atomic_dec_and_test(&bo->refcnt))
		return;

	pthread_mutex_lock(&table_lock);

	if (bo->bo_reuse && (fd_bo_cache_free(&dev->bo_cache, bo) == 0))
		goto out;

	bo_del(bo);
	fd_device_del_locked(dev);
out:
	pthread_mutex_unlock(&table_lock);
}