dsp: clean up unnecessary apis
Change-Id: I6e92fcea9a7185bd1bc7c47ca16270641fd471de
This commit is contained in:

committed by
Gerrit - the friendly Code Review server

parent
f2532546f1
commit
3f099a7afc
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2013-2021, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/init.h>
|
||||
@@ -293,28 +293,6 @@ err:
|
||||
return rc;
|
||||
}
|
||||
|
||||
int msm_audio_ion_get_smmu_info(struct device **cb_dev,
|
||||
u64 *smmu_sid)
|
||||
{
|
||||
if (!cb_dev || !smmu_sid) {
|
||||
pr_err("%s: Invalid params\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!msm_audio_ion_data.cb_dev ||
|
||||
!msm_audio_ion_data.smmu_sid_bits) {
|
||||
pr_err("%s: Params not initialized\n",
|
||||
__func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*cb_dev = msm_audio_ion_data.cb_dev;
|
||||
*smmu_sid = msm_audio_ion_data.smmu_sid_bits;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int msm_audio_ion_unmap_kernel(struct dma_buf *dma_buf)
|
||||
{
|
||||
int rc = 0;
|
||||
@@ -388,98 +366,6 @@ err:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static u32 msm_audio_ion_get_smmu_sid_mode32(void)
|
||||
{
|
||||
if (msm_audio_ion_data.smmu_enabled)
|
||||
return upper_32_bits(msm_audio_ion_data.smmu_sid_bits);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* msm_audio_ion_alloc -
|
||||
* Allocs ION memory for given client name
|
||||
*
|
||||
* @dma_buf: dma_buf for the ION memory
|
||||
* @bufsz: buffer size
|
||||
* @paddr: Physical address to be assigned with allocated region
|
||||
* @plen: length of allocated region to be assigned
|
||||
* vaddr: virtual address to be assigned
|
||||
*
|
||||
* Returns 0 on success or error on failure
|
||||
*/
|
||||
int msm_audio_ion_alloc(struct dma_buf **dma_buf, size_t bufsz,
|
||||
dma_addr_t *paddr, size_t *plen, void **vaddr)
|
||||
{
|
||||
int rc = -EINVAL;
|
||||
unsigned long err_ion_ptr = 0;
|
||||
|
||||
if (!(msm_audio_ion_data.device_status & MSM_AUDIO_ION_PROBED)) {
|
||||
pr_debug("%s:probe is not done, deferred\n", __func__);
|
||||
return -EPROBE_DEFER;
|
||||
}
|
||||
if (!dma_buf || !paddr || !vaddr || !bufsz || !plen) {
|
||||
pr_err("%s: Invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (msm_audio_ion_data.smmu_enabled == true) {
|
||||
pr_debug("%s: system heap is used\n", __func__);
|
||||
*dma_buf = ion_alloc(bufsz, ION_HEAP(ION_SYSTEM_HEAP_ID), 0);
|
||||
} else {
|
||||
pr_debug("%s: audio heap is used\n", __func__);
|
||||
*dma_buf = ion_alloc(bufsz, ION_HEAP(ION_AUDIO_HEAP_ID), 0);
|
||||
}
|
||||
if (IS_ERR_OR_NULL((void *)(*dma_buf))) {
|
||||
if (IS_ERR((void *)(*dma_buf)))
|
||||
err_ion_ptr = PTR_ERR((int *)(*dma_buf));
|
||||
pr_err("%s: ION alloc fail err ptr=%ld, smmu_enabled=%d\n",
|
||||
__func__, err_ion_ptr, msm_audio_ion_data.smmu_enabled);
|
||||
rc = -ENOMEM;
|
||||
goto err;
|
||||
}
|
||||
|
||||
rc = msm_audio_ion_map_buf(*dma_buf, paddr, plen, vaddr);
|
||||
if (rc) {
|
||||
pr_err("%s: failed to map ION buf, rc = %d\n", __func__, rc);
|
||||
goto err;
|
||||
}
|
||||
pr_debug("%s: mapped address = %pK, size=%zd\n", __func__,
|
||||
*vaddr, bufsz);
|
||||
|
||||
memset(*vaddr, 0, bufsz);
|
||||
|
||||
// Cleanp dmabuf if error?
|
||||
err:
|
||||
return rc;
|
||||
}
|
||||
EXPORT_SYMBOL(msm_audio_ion_alloc);
|
||||
|
||||
int msm_audio_ion_phys_free(void *handle,
|
||||
dma_addr_t *paddr,
|
||||
size_t *pa_len,
|
||||
u8 assign_type,
|
||||
int id,
|
||||
int key)
|
||||
{
|
||||
handle = NULL;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(msm_audio_ion_phys_free);
|
||||
|
||||
int msm_audio_ion_phys_assign(void **handle, int fd,
|
||||
dma_addr_t *paddr, size_t *pa_len, u8 assign_type, int id)
|
||||
{
|
||||
*handle = NULL;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(msm_audio_ion_phys_assign);
|
||||
|
||||
bool msm_audio_is_hypervisor_supported(void)
|
||||
{
|
||||
return !(msm_audio_ion_data.is_non_hypervisor);
|
||||
}
|
||||
EXPORT_SYMBOL(msm_audio_is_hypervisor_supported);
|
||||
/**
|
||||
* msm_audio_ion_dma_map -
|
||||
* Memory maps for a given DMA buffer
|
||||
@@ -678,67 +564,6 @@ err:
|
||||
}
|
||||
EXPORT_SYMBOL(msm_audio_ion_import);
|
||||
|
||||
/**
|
||||
* msm_audio_ion_import_cma-
|
||||
* Import ION buffer with given file descriptor
|
||||
*
|
||||
* @dma_buf: dma_buf for the ION memory
|
||||
* @fd: file descriptor for the ION memory
|
||||
* @ionflag: flags associated with ION buffer
|
||||
* @bufsz: buffer size
|
||||
* @paddr: Physical address to be assigned with allocated region
|
||||
* @plen: length of allocated region to be assigned
|
||||
* vaddr: virtual address to be assigned
|
||||
*
|
||||
* Returns 0 on success or error on failure
|
||||
*/
|
||||
int msm_audio_ion_import_cma(struct dma_buf **dma_buf, int fd,
|
||||
unsigned long *ionflag, size_t bufsz,
|
||||
dma_addr_t *paddr, size_t *plen, void **vaddr)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (!(msm_audio_ion_data.device_status & MSM_AUDIO_ION_PROBED)) {
|
||||
pr_debug("%s: probe is not done, deferred\n", __func__);
|
||||
return -EPROBE_DEFER;
|
||||
}
|
||||
|
||||
if (!dma_buf || !paddr || !vaddr || !plen ||
|
||||
!msm_audio_ion_data.cb_cma_dev) {
|
||||
pr_err("%s: Invalid params\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* bufsz should be 0 and fd shouldn't be 0 as of now */
|
||||
*dma_buf = dma_buf_get(fd);
|
||||
pr_debug("%s: dma_buf =%pK, fd=%d\n", __func__, *dma_buf, fd);
|
||||
if (IS_ERR_OR_NULL((void *)(*dma_buf))) {
|
||||
pr_err("%s: dma_buf_get failed\n", __func__);
|
||||
rc = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (ionflag != NULL) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
msm_audio_dma_buf_map(*dma_buf, paddr, plen, true, true);
|
||||
|
||||
return 0;
|
||||
|
||||
err_ion_flag:
|
||||
dma_buf_put(*dma_buf);
|
||||
err:
|
||||
*dma_buf = NULL;
|
||||
return rc;
|
||||
}
|
||||
EXPORT_SYMBOL(msm_audio_ion_import_cma);
|
||||
|
||||
/**
|
||||
* msm_audio_ion_free -
|
||||
* fress ION memory for given client and handle
|
||||
@@ -794,179 +619,6 @@ void msm_audio_ion_crash_handler(void)
|
||||
}
|
||||
EXPORT_SYMBOL(msm_audio_ion_crash_handler);
|
||||
|
||||
/**
|
||||
* msm_audio_ion_free_cma -
|
||||
* fress ION memory for given client and handle
|
||||
*
|
||||
* @dma_buf: dma_buf for the ION memory
|
||||
*
|
||||
* Returns 0 on success or error on failure
|
||||
*/
|
||||
int msm_audio_ion_free_cma(struct dma_buf *dma_buf)
|
||||
{
|
||||
if (!dma_buf) {
|
||||
pr_err("%s: dma_buf invalid\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
msm_audio_dma_buf_unmap(dma_buf, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(msm_audio_ion_free_cma);
|
||||
|
||||
/**
|
||||
* msm_audio_ion_mmap -
|
||||
* Audio ION memory map
|
||||
*
|
||||
* @abuff: audio buf pointer
|
||||
* @vma: virtual mem area
|
||||
*
|
||||
* Returns 0 on success or error on failure
|
||||
*/
|
||||
int msm_audio_ion_mmap(struct audio_buffer *abuff,
|
||||
struct vm_area_struct *vma)
|
||||
{
|
||||
struct msm_audio_alloc_data *alloc_data = NULL;
|
||||
struct sg_table *table;
|
||||
unsigned long addr = vma->vm_start;
|
||||
unsigned long offset = vma->vm_pgoff * PAGE_SIZE;
|
||||
struct scatterlist *sg;
|
||||
unsigned int i;
|
||||
struct page *page;
|
||||
int ret = 0;
|
||||
bool found = false;
|
||||
struct device *cb_dev = msm_audio_ion_data.cb_dev;
|
||||
|
||||
mutex_lock(&(msm_audio_ion_data.list_mutex));
|
||||
list_for_each_entry(alloc_data, &(msm_audio_ion_data.alloc_list),
|
||||
list) {
|
||||
if (alloc_data->dma_buf == abuff->dma_buf) {
|
||||
found = true;
|
||||
table = alloc_data->table;
|
||||
break;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&(msm_audio_ion_data.list_mutex));
|
||||
|
||||
if (!found) {
|
||||
dev_err(cb_dev,
|
||||
"%s: cannot find allocation, dma_buf %pK",
|
||||
__func__, abuff->dma_buf);
|
||||
return -EINVAL;
|
||||
}
|
||||
/* uncached */
|
||||
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
|
||||
|
||||
/* We need to check if a page is associated with this sg list because:
|
||||
* If the allocation came from a carveout we currently don't have
|
||||
* pages associated with carved out memory. This might change in the
|
||||
* future and we can remove this check and the else statement.
|
||||
*/
|
||||
page = sg_page(table->sgl);
|
||||
if (page) {
|
||||
pr_debug("%s: page is NOT null\n", __func__);
|
||||
for_each_sg(table->sgl, sg, table->nents, i) {
|
||||
unsigned long remainder = vma->vm_end - addr;
|
||||
unsigned long len = sg->length;
|
||||
|
||||
page = sg_page(sg);
|
||||
|
||||
if (offset >= len) {
|
||||
offset -= len;
|
||||
continue;
|
||||
} else if (offset) {
|
||||
page += offset / PAGE_SIZE;
|
||||
len -= offset;
|
||||
offset = 0;
|
||||
}
|
||||
len = min(len, remainder);
|
||||
pr_debug("vma=%pK, addr=%x len=%ld vm_start=%x vm_end=%x vm_page_prot=%lu\n",
|
||||
vma, (unsigned int)addr, len,
|
||||
(unsigned int)vma->vm_start,
|
||||
(unsigned int)vma->vm_end,
|
||||
(unsigned long)pgprot_val(vma->vm_page_prot));
|
||||
remap_pfn_range(vma, addr, page_to_pfn(page), len,
|
||||
vma->vm_page_prot);
|
||||
addr += len;
|
||||
if (addr >= vma->vm_end)
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
pr_debug("%s: page is NULL\n", __func__);
|
||||
ret = -EINVAL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
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:
|
||||
case MSM_AUDIO_ION_CLEAN_CACHES:
|
||||
dma_buf_begin_cpu_access(abuff->dma_buf,
|
||||
DMA_BIDIRECTIONAL);
|
||||
dma_buf_end_cpu_access(abuff->dma_buf,
|
||||
DMA_BIDIRECTIONAL);
|
||||
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
|
||||
*
|
||||
* @pa: 64bit physical address
|
||||
*
|
||||
*/
|
||||
u32 msm_audio_populate_upper_32_bits(dma_addr_t pa)
|
||||
{
|
||||
if (sizeof(dma_addr_t) == sizeof(u32))
|
||||
return msm_audio_ion_get_smmu_sid_mode32();
|
||||
else
|
||||
return upper_32_bits(pa);
|
||||
}
|
||||
EXPORT_SYMBOL(msm_audio_populate_upper_32_bits);
|
||||
|
||||
static int msm_audio_ion_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
int ret = 0;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2013-2015, 2017-2020, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2013-2015, 2017-2021, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_MSM_AUDIO_ION_H
|
||||
@@ -27,30 +27,8 @@ struct audio_buffer {
|
||||
uint32_t actual_size; /* actual number of bytes read by DSP */
|
||||
struct dma_buf *dma_buf;
|
||||
};
|
||||
int msm_audio_ion_alloc(struct dma_buf **dma_buf, size_t bufsz,
|
||||
dma_addr_t *paddr, size_t *pa_len, void **vaddr);
|
||||
|
||||
int msm_audio_ion_import(struct dma_buf **dma_buf, int fd,
|
||||
unsigned long *ionflag, size_t bufsz,
|
||||
dma_addr_t *paddr, size_t *pa_len, void **vaddr);
|
||||
int msm_audio_ion_free(struct dma_buf *dma_buf);
|
||||
int msm_audio_ion_import_cma(struct dma_buf **dma_buf, int fd,
|
||||
unsigned long *ionflag, size_t bufsz,
|
||||
dma_addr_t *paddr, size_t *pa_len, void **vaddr);
|
||||
int msm_audio_ion_free_cma(struct dma_buf *dma_buf);
|
||||
int msm_audio_ion_mmap(struct audio_buffer *abuff, struct vm_area_struct *vma);
|
||||
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);
|
||||
int msm_audio_ion_phys_assign(void **mem_hdl, int fd, dma_addr_t *paddr,
|
||||
size_t *pa_len, u8 assign_type, int id);
|
||||
int msm_audio_ion_phys_free(void *mem_hdl, dma_addr_t *paddr,
|
||||
size_t *pa_len, u8 assign_type, int id, int key);
|
||||
bool msm_audio_is_hypervisor_supported(void);
|
||||
int msm_audio_get_phy_addr(int fd, dma_addr_t *paddr);
|
||||
void msm_audio_ion_crash_handler(void);
|
||||
#endif /* _LINUX_MSM_AUDIO_ION_H */
|
||||
|
Reference in New Issue
Block a user