Loading dsp/msm_audio_ion.c +38 −1 Original line number Diff line number Diff line // 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> Loading Loading @@ -400,6 +400,43 @@ int msm_audio_ion_alloc(struct dma_buf **dma_buf, size_t bufsz, } 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 Loading include/dsp/msm_audio_ion.h +5 −1 Original line number Diff line number Diff line /* 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 Loading @@ -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, Loading @@ -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 */ Loading
dsp/msm_audio_ion.c +38 −1 Original line number Diff line number Diff line // 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> Loading Loading @@ -400,6 +400,43 @@ int msm_audio_ion_alloc(struct dma_buf **dma_buf, size_t bufsz, } 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 Loading
include/dsp/msm_audio_ion.h +5 −1 Original line number Diff line number Diff line /* 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 Loading @@ -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, Loading @@ -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 */