|
@@ -14,7 +14,7 @@
|
|
|
#include <linux/list.h>
|
|
|
#include <linux/dma-mapping.h>
|
|
|
#include <linux/dma-buf.h>
|
|
|
-#include <linux/dma-buf-map.h>
|
|
|
+#include <linux/iosys-map.h>
|
|
|
#include <linux/platform_device.h>
|
|
|
#include <linux/of_device.h>
|
|
|
#include <linux/export.h>
|
|
@@ -29,6 +29,8 @@
|
|
|
#include <linux/msm_audio.h>
|
|
|
#include <soc/qcom/secure_buffer.h>
|
|
|
|
|
|
+MODULE_IMPORT_NS(DMA_BUF);
|
|
|
+
|
|
|
#define MSM_AUDIO_ION_PROBED (1 << 0)
|
|
|
|
|
|
#define MSM_AUDIO_ION_PHYS_ADDR(alloc_data) \
|
|
@@ -59,7 +61,7 @@ struct msm_audio_ion_private {
|
|
|
|
|
|
struct msm_audio_alloc_data {
|
|
|
size_t len;
|
|
|
- struct dma_buf_map *vmap;
|
|
|
+ struct iosys_map *vmap;
|
|
|
struct dma_buf *dma_buf;
|
|
|
struct dma_buf_attachment *attach;
|
|
|
struct sg_table *table;
|
|
@@ -101,7 +103,7 @@ static void msm_audio_ion_add_allocation(
|
|
|
}
|
|
|
|
|
|
static int msm_audio_ion_map_kernel(struct dma_buf *dma_buf,
|
|
|
- struct msm_audio_ion_private *ion_data, struct dma_buf_map *dma_vmap)
|
|
|
+ struct msm_audio_ion_private *ion_data, struct iosys_map *iosys_vmap)
|
|
|
{
|
|
|
int rc = 0;
|
|
|
struct msm_audio_alloc_data *alloc_data = NULL;
|
|
@@ -112,7 +114,7 @@ static int msm_audio_ion_map_kernel(struct dma_buf *dma_buf,
|
|
|
goto exit;
|
|
|
}
|
|
|
|
|
|
- rc = dma_buf_vmap(dma_buf, dma_vmap);
|
|
|
+ rc = dma_buf_vmap(dma_buf, iosys_vmap);
|
|
|
if (rc) {
|
|
|
pr_err("%s: kernel mapping of dma_buf failed\n",
|
|
|
__func__);
|
|
@@ -127,7 +129,7 @@ static int msm_audio_ion_map_kernel(struct dma_buf *dma_buf,
|
|
|
list_for_each_entry(alloc_data, &(ion_data->alloc_list),
|
|
|
list) {
|
|
|
if (alloc_data->dma_buf == dma_buf) {
|
|
|
- alloc_data->vmap = dma_vmap;
|
|
|
+ alloc_data->vmap = iosys_vmap;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -144,16 +146,16 @@ static int msm_audio_dma_buf_map(struct dma_buf *dma_buf,
|
|
|
|
|
|
struct msm_audio_alloc_data *alloc_data = NULL;
|
|
|
int rc = 0;
|
|
|
- struct dma_buf_map *dma_vmap = NULL;
|
|
|
+ struct iosys_map *iosys_vmap = NULL;
|
|
|
struct device *cb_dev = ion_data->cb_dev;
|
|
|
|
|
|
- dma_vmap = kzalloc(sizeof(*dma_vmap), GFP_KERNEL);
|
|
|
- if (!dma_vmap)
|
|
|
+ iosys_vmap = kzalloc(sizeof(*iosys_vmap), GFP_KERNEL);
|
|
|
+ if (!iosys_vmap)
|
|
|
return -ENOMEM;
|
|
|
/* Data required per buffer mapping */
|
|
|
alloc_data = kzalloc(sizeof(*alloc_data), GFP_KERNEL);
|
|
|
if (!alloc_data) {
|
|
|
- kfree(dma_vmap);
|
|
|
+ kfree(iosys_vmap);
|
|
|
return -ENOMEM;
|
|
|
}
|
|
|
alloc_data->dma_buf = dma_buf;
|
|
@@ -190,14 +192,14 @@ static int msm_audio_dma_buf_map(struct dma_buf *dma_buf,
|
|
|
/* physical address from mapping */
|
|
|
if (!is_iova) {
|
|
|
*addr = sg_phys(alloc_data->table->sgl);
|
|
|
- rc = msm_audio_ion_map_kernel((void *)dma_buf, ion_data, dma_vmap);
|
|
|
+ rc = msm_audio_ion_map_kernel((void *)dma_buf, ion_data, iosys_vmap);
|
|
|
if (rc) {
|
|
|
pr_err("%s: ION memory mapping for AUDIO failed, err:%d\n",
|
|
|
__func__, rc);
|
|
|
rc = -ENOMEM;
|
|
|
goto detach_dma_buf;
|
|
|
}
|
|
|
- alloc_data->vmap = dma_vmap;
|
|
|
+ alloc_data->vmap = iosys_vmap;
|
|
|
} else {
|
|
|
*addr = MSM_AUDIO_ION_PHYS_ADDR(alloc_data);
|
|
|
}
|
|
@@ -209,7 +211,7 @@ detach_dma_buf:
|
|
|
dma_buf_detach(alloc_data->dma_buf,
|
|
|
alloc_data->attach);
|
|
|
free_alloc_data:
|
|
|
- kfree(dma_vmap);
|
|
|
+ kfree(iosys_vmap);
|
|
|
kfree(alloc_data);
|
|
|
alloc_data = NULL;
|
|
|
|
|
@@ -291,7 +293,7 @@ err:
|
|
|
static int msm_audio_ion_unmap_kernel(struct dma_buf *dma_buf, struct msm_audio_ion_private *ion_data)
|
|
|
{
|
|
|
int rc = 0;
|
|
|
- struct dma_buf_map *dma_vmap = NULL;
|
|
|
+ struct iosys_map *iosys_vmap = NULL;
|
|
|
struct msm_audio_alloc_data *alloc_data = NULL;
|
|
|
struct device *cb_dev = ion_data->cb_dev;
|
|
|
|
|
@@ -303,13 +305,13 @@ static int msm_audio_ion_unmap_kernel(struct dma_buf *dma_buf, struct msm_audio_
|
|
|
list_for_each_entry(alloc_data, &(ion_data->alloc_list),
|
|
|
list) {
|
|
|
if (alloc_data->dma_buf == dma_buf) {
|
|
|
- dma_vmap = alloc_data->vmap;
|
|
|
+ iosys_vmap = alloc_data->vmap;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
mutex_unlock(&(ion_data->list_mutex));
|
|
|
|
|
|
- if (!dma_vmap) {
|
|
|
+ if (!iosys_vmap) {
|
|
|
dev_err(cb_dev,
|
|
|
"%s: cannot find allocation for dma_buf %pK",
|
|
|
__func__, dma_buf);
|
|
@@ -317,7 +319,7 @@ static int msm_audio_ion_unmap_kernel(struct dma_buf *dma_buf, struct msm_audio_
|
|
|
goto err;
|
|
|
}
|
|
|
|
|
|
- dma_buf_vunmap(dma_buf, dma_vmap);
|
|
|
+ dma_buf_vunmap(dma_buf, iosys_vmap);
|
|
|
|
|
|
rc = dma_buf_end_cpu_access(dma_buf, DMA_BIDIRECTIONAL);
|
|
|
if (rc) {
|
|
@@ -331,7 +333,7 @@ err:
|
|
|
}
|
|
|
|
|
|
static int msm_audio_ion_map_buf(struct dma_buf *dma_buf, dma_addr_t *paddr,
|
|
|
- size_t *plen, struct dma_buf_map *dma_vmap,
|
|
|
+ size_t *plen, struct iosys_map *iosys_vmap,
|
|
|
struct msm_audio_ion_private *ion_data)
|
|
|
{
|
|
|
int rc = 0;
|
|
@@ -350,7 +352,7 @@ static int msm_audio_ion_map_buf(struct dma_buf *dma_buf, dma_addr_t *paddr,
|
|
|
goto err;
|
|
|
}
|
|
|
|
|
|
- rc = msm_audio_ion_map_kernel(dma_buf, ion_data, dma_vmap);
|
|
|
+ rc = msm_audio_ion_map_kernel(dma_buf, ion_data, iosys_vmap);
|
|
|
if (rc) {
|
|
|
pr_err("%s: ION memory mapping for AUDIO failed, err:%d\n",
|
|
|
__func__, rc);
|
|
@@ -489,13 +491,13 @@ void msm_audio_get_handle(int fd, void **handle)
|
|
|
* @bufsz: buffer size
|
|
|
* @paddr: Physical address to be assigned with allocated region
|
|
|
* @plen: length of allocated region to be assigned
|
|
|
- * @dma_vmap: Virtual mapping vmap pointer to be assigned
|
|
|
+ * @iosys_vmap: Virtual mapping vmap pointer to be assigned
|
|
|
*
|
|
|
* Returns 0 on success or error on failure
|
|
|
*/
|
|
|
static int msm_audio_ion_import(struct dma_buf **dma_buf, int fd,
|
|
|
unsigned long *ionflag, size_t bufsz,
|
|
|
- dma_addr_t *paddr, size_t *plen, struct dma_buf_map *dma_vmap,
|
|
|
+ dma_addr_t *paddr, size_t *plen, struct iosys_map *iosys_vmap,
|
|
|
struct msm_audio_ion_private *ion_data)
|
|
|
{
|
|
|
int rc = 0;
|
|
@@ -528,13 +530,13 @@ static int msm_audio_ion_import(struct dma_buf **dma_buf, int fd,
|
|
|
}
|
|
|
}
|
|
|
if (ion_data->smmu_enabled) {
|
|
|
- rc = msm_audio_ion_map_buf(*dma_buf, paddr, plen, dma_vmap, ion_data);
|
|
|
+ rc = msm_audio_ion_map_buf(*dma_buf, paddr, plen, iosys_vmap, ion_data);
|
|
|
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__,
|
|
|
- dma_vmap->vaddr, bufsz);
|
|
|
+ iosys_vmap->vaddr, bufsz);
|
|
|
} else {
|
|
|
msm_audio_dma_buf_map(*dma_buf, paddr, plen, true, ion_data);
|
|
|
}
|
|
@@ -661,7 +663,7 @@ static long msm_audio_ion_ioctl(struct file *file, unsigned int ioctl_num,
|
|
|
void *mem_handle;
|
|
|
dma_addr_t paddr;
|
|
|
size_t pa_len = 0;
|
|
|
- struct dma_buf_map *dma_vmap = NULL;
|
|
|
+ struct iosys_map *iosys_vmap = NULL;
|
|
|
int ret = 0;
|
|
|
int dest_perms_map[2] = {PERM_READ | PERM_WRITE, PERM_READ | PERM_WRITE};
|
|
|
int source_vm_map[1] = {VMID_HLOS};
|
|
@@ -676,20 +678,20 @@ static long msm_audio_ion_ioctl(struct file *file, unsigned int ioctl_num,
|
|
|
pr_debug("%s ioctl num %u\n", __func__, ioctl_num);
|
|
|
switch (ioctl_num) {
|
|
|
case IOCTL_MAP_PHYS_ADDR:
|
|
|
- dma_vmap = kzalloc(sizeof(struct msm_audio_fd_data), GFP_KERNEL);
|
|
|
- if (!dma_vmap)
|
|
|
+ iosys_vmap = kzalloc(sizeof(struct msm_audio_fd_data), GFP_KERNEL);
|
|
|
+ if (!iosys_vmap)
|
|
|
return -ENOMEM;
|
|
|
msm_audio_fd_data = kzalloc((sizeof(struct msm_audio_fd_data)),
|
|
|
GFP_KERNEL);
|
|
|
if (!msm_audio_fd_data) {
|
|
|
- kfree(dma_vmap);
|
|
|
+ kfree(iosys_vmap);
|
|
|
return -ENOMEM;
|
|
|
}
|
|
|
ret = msm_audio_ion_import((struct dma_buf **)&mem_handle, (int)ioctl_param,
|
|
|
- NULL, 0, &paddr, &pa_len, dma_vmap, ion_data);
|
|
|
+ NULL, 0, &paddr, &pa_len, iosys_vmap, ion_data);
|
|
|
if (ret < 0) {
|
|
|
pr_err("%s Memory map Failed %d\n", __func__, ret);
|
|
|
- kfree(dma_vmap);
|
|
|
+ kfree(iosys_vmap);
|
|
|
kfree(msm_audio_fd_data);
|
|
|
return ret;
|
|
|
}
|