1
0

dsp: add cache operations for dma_buf

Add support for querying ION flags for dma_buf and for cache ops
on dma_buf with CACHED Flag on.

Change-Id: I219e564c477af8ba3b8676db1c9555a2b5b9ebab
Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org>
Este cometimento está contido em:
Banajit Goswami
2018-02-02 03:36:46 -08:00
cometido por Gerrit - the friendly Code Review server
ascendente 08bb73698a
cometimento 0f1f3f6d04
2 ficheiros modificados com 69 adições e 6 eliminações

Ver ficheiro

@@ -422,8 +422,7 @@ int msm_audio_ion_import(struct dma_buf **dma_buf, int fd,
if (!dma_buf || !paddr || !vaddr || !plen) {
pr_err("%s: Invalid params\n", __func__);
rc = -EINVAL;
goto err;
return -EINVAL;
}
/* bufsz should be 0 and fd shouldn't be 0 as of now */
@@ -436,10 +435,12 @@ int msm_audio_ion_import(struct dma_buf **dma_buf, int fd,
}
if (ionflag != NULL) {
pr_err("%s: could not get flags for the dma_buf\n",
__func__);
rc = -EOPNOTSUPP;
goto err_ion_flag;
rc = dma_buf_get_flags(*dma_buf, ionflag);
if (rc) {
pr_err("%s: could not get flags for the dma_buf\n",
__func__);
goto err_ion_flag;
}
}
rc = msm_audio_ion_map_buf(*dma_buf, paddr, plen, *vaddr);
@@ -569,6 +570,63 @@ int msm_audio_ion_mmap(struct audio_buffer *abuff,
}
EXPORT_SYMBOL(msm_audio_ion_mmap);
/**
* msm_audio_ion_cache_operations-
* Cache operations on cached Audio ION buffers
*
* @abuff: audio buf pointer
* @cache_op: cache operation to be performed
*
* Returns 0 on success or error on failure
*/
int msm_audio_ion_cache_operations(struct audio_buffer *abuff, int cache_op)
{
unsigned long ionflag = 0;
int rc = 0;
if (!abuff) {
pr_err("%s: Invalid params: %pK\n", __func__, abuff);
return -EINVAL;
}
rc = dma_buf_get_flags(abuff->dma_buf, &ionflag);
if (rc) {
pr_err("%s: dma_buf_get_flags failed: %d\n", __func__, rc);
goto cache_op_failed;
}
/* Has to be CACHED */
if (ionflag & ION_FLAG_CACHED) {
/* MSM_AUDIO_ION_INV_CACHES or MSM_AUDIO_ION_CLEAN_CACHES */
switch (cache_op) {
case MSM_AUDIO_ION_INV_CACHES:
rc = dma_buf_begin_cpu_access(abuff->dma_buf,
DMA_BIDIRECTIONAL);
if (rc)
pr_err("%s: failed to invalidate caches. rc = %d\n",
__func__, rc);
break;
case MSM_AUDIO_ION_CLEAN_CACHES:
rc = dma_buf_end_cpu_access(abuff->dma_buf,
DMA_BIDIRECTIONAL);
if (rc)
pr_err("%s: failed to clean caches. rc = %d\n",
__func__, rc);
break;
default:
pr_err("%s: Invalid cache operation %d\n",
__func__, cache_op);
}
} else {
pr_err("%s: Cache ops called on uncached buffer: %pK\n",
__func__, abuff->dma_buf);
rc = -EINVAL;
}
cache_op_failed:
return rc;
}
EXPORT_SYMBOL(msm_audio_ion_cache_operations);
/**
* msm_audio_populate_upper_32_bits -
* retrieve upper 32bits of 64bit address