dsp: add dma map resource cmd

Add a new API for mapping DMA resources
that needs to be attached to existing
SMMU SID.

Change-Id: I7a513d24ea30a5ead318e856e4c5317743fd0021
Signed-off-by: Vikram Panduranga <vpandura@codeaurora.org>
This commit is contained in:
Vikram Panduranga 2018-12-12 14:25:06 -08:00
commit 24efd2a62e
2 changed files with 43 additions and 2 deletions

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
*/
#include <linux/init.h>
@ -400,6 +400,43 @@ err:
}
EXPORT_SYMBOL(msm_audio_ion_alloc);
/**
* msm_audio_ion_dma_map -
* Memory maps for a given DMA buffer
*
* @phys_addr: Physical address of DMA buffer to be mapped
* @iova_base: IOVA address of memory mapped DMA buffer
* @size: buffer size
* @dir: DMA direction
* Returns 0 on success or error on failure
*/
int msm_audio_ion_dma_map(dma_addr_t *phys_addr, dma_addr_t *iova_base,
u32 size, enum dma_data_direction dir)
{
dma_addr_t iova;
struct device *cb_dev = msm_audio_ion_data.cb_dev;
if (!phys_addr || !iova_base || !size)
return -EINVAL;
iova = dma_map_resource(cb_dev, *phys_addr, size,
dir, 0);
if (dma_mapping_error(cb_dev, iova)) {
pr_err("%s: dma_mapping_error\n", __func__);
return -EIO;
}
pr_debug("%s: dma_mapping_success iova:0x%lx\n", __func__,
(unsigned long)iova);
if (msm_audio_ion_data.smmu_enabled)
/* Append the SMMU SID information to the IOVA address */
iova |= msm_audio_ion_data.smmu_sid_bits;
*iova_base = iova;
return 0;
}
EXPORT_SYMBOL(msm_audio_ion_dma_map);
/**
* msm_audio_ion_import-
* Import ION buffer with given file descriptor

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2013-2015, 2017-2018, The Linux Foundation. All rights reserved.
* Copyright (c) 2013-2015, 2017-2019, The Linux Foundation. All rights reserved.
*/
#ifndef _LINUX_MSM_AUDIO_ION_H
@ -8,6 +8,7 @@
#include <dsp/q6asm-v2.h>
#include <sound/pcm.h>
#include <linux/msm_ion.h>
#include <linux/dma-mapping.h>
enum {
MSM_AUDIO_ION_INV_CACHES = 0,
@ -26,4 +27,7 @@ int msm_audio_ion_cache_operations(struct audio_buffer *abuff, int cache_op);
u32 msm_audio_populate_upper_32_bits(dma_addr_t pa);
int msm_audio_ion_get_smmu_info(struct device **cb_dev, u64 *smmu_sid);
int msm_audio_ion_dma_map(dma_addr_t *phys_addr, dma_addr_t *iova_base,
u32 size, enum dma_data_direction dir);
#endif /* _LINUX_MSM_AUDIO_ION_H */