Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6e68d53 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Revert "Fallback to dma_alloc_coherent if shmbridge is disabled""

parents 245bc24c a7450876
Loading
Loading
Loading
Loading
+7 −33
Original line number Diff line number Diff line
@@ -280,30 +280,6 @@ int32_t qtee_shmbridge_allocate_shm(size_t size, struct qtee_shm *shm)
	int32_t ret = 0;
	unsigned long va;

	if (IS_ERR_OR_NULL(shm)) {
		pr_err("qtee_shm is NULL\n");
		ret = -EINVAL;
		goto exit;
	}

	if (!qtee_shmbridge_is_enabled()) {
		void *buf = NULL;
		dma_addr_t coh_pmem;

		pr_err("shmbridge is not enabled, allocating via dma_aloc\n");

		size = (size + PAGE_SIZE) & PAGE_MASK;
		buf = dma_alloc_coherent(default_bridge.dev, size, &coh_pmem, GFP_KERNEL);

		if (buf == NULL)
			return -ENOMEM;

		shm->vaddr = buf;
		shm->paddr = coh_pmem;
		shm->size = size;
		goto exit;
	}

	if (size > DEFAULT_BRIDGE_SIZE) {
		pr_err("requestd size %zu is larger than bridge size %d\n",
			size, DEFAULT_BRIDGE_SIZE);
@@ -311,6 +287,11 @@ int32_t qtee_shmbridge_allocate_shm(size_t size, struct qtee_shm *shm)
		goto exit;
	}

	if (IS_ERR_OR_NULL(shm)) {
		pr_err("qtee_shm is NULL\n");
		ret = -EINVAL;
		goto exit;
	}
	size = roundup(size, 1 << default_bridge.min_alloc_order);

	va = gen_pool_alloc(default_bridge.genpool, size);
@@ -339,9 +320,6 @@ void qtee_shmbridge_free_shm(struct qtee_shm *shm)
{
	if (IS_ERR_OR_NULL(shm) || !shm->vaddr)
		return;
	if (!qtee_shmbridge_is_enabled())
		dma_free_coherent(default_bridge.dev, shm->size, shm->vaddr, shm->paddr);
	else
	gen_pool_free(default_bridge.genpool, (unsigned long)shm->vaddr,
		      shm->size);
}
@@ -350,8 +328,6 @@ EXPORT_SYMBOL(qtee_shmbridge_free_shm);
/* cache clean operation for buffer sub-allocated from default bridge */
void qtee_shmbridge_flush_shm_buf(struct qtee_shm *shm)
{
	if (!qtee_shmbridge_is_enabled())
		return;
	if (shm)
		return dma_sync_single_for_device(default_bridge.dev,
				shm->paddr, shm->size, DMA_TO_DEVICE);
@@ -361,8 +337,6 @@ EXPORT_SYMBOL(qtee_shmbridge_flush_shm_buf);
/* cache invalidation operation for buffer sub-allocated from default bridge */
void qtee_shmbridge_inv_shm_buf(struct qtee_shm *shm)
{
	if (!qtee_shmbridge_is_enabled())
		return;
	if (shm)
		return dma_sync_single_for_cpu(default_bridge.dev,
				shm->paddr, shm->size, DMA_FROM_DEVICE);