mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-07 04:12:04 -04:00
Merge "Revert "Fallback to dma_alloc_coherent if shmbridge is disabled""
This commit is contained in:
commit
e6e68d5386
1 changed files with 7 additions and 33 deletions
|
|
@ -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,19 +320,14 @@ 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);
|
||||
gen_pool_free(default_bridge.genpool, (unsigned long)shm->vaddr,
|
||||
shm->size);
|
||||
}
|
||||
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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue