summaryrefslogtreecommitdiff
path: root/drivers/soc/qcom
diff options
context:
space:
mode:
authorVidyakumar Athota <vathota@codeaurora.org>2017-08-17 20:40:40 -0700
committerVidyakumar Athota <vathota@codeaurora.org>2017-08-21 10:56:56 -0700
commite4faef1e35f316f78d218323c12d0bbcec51d98e (patch)
tree3e46431dbdd325f6cece50adb1b2d3403749a025 /drivers/soc/qcom
parenta49bb61510b938152025049730fa922c5da950a1 (diff)
ASoC: msm: qdspv2: add an API to destroy ion client
Currently ion fd is used to extract ion handle to free ion client. ION FD is not valid if user-space application is crashed so ion handle is returned to the client during msm_audio_ion_phys_assign() API which is used to destroy ion client in msm_audio_ion_phys_free() API. Change-Id: Idcc4ca838741aac26662a679117af9d9c935e630 Signed-off-by: Vidyakumar Athota <vathota@codeaurora.org>
Diffstat (limited to 'drivers/soc/qcom')
-rw-r--r--drivers/soc/qcom/qdsp6v2/msm_audio_ion.c60
1 files changed, 48 insertions, 12 deletions
diff --git a/drivers/soc/qcom/qdsp6v2/msm_audio_ion.c b/drivers/soc/qcom/qdsp6v2/msm_audio_ion.c
index b119c7a8441d..9e61ff1ebfcc 100644
--- a/drivers/soc/qcom/qdsp6v2/msm_audio_ion.c
+++ b/drivers/soc/qcom/qdsp6v2/msm_audio_ion.c
@@ -210,11 +210,44 @@ done:
return ret;
}
-int msm_audio_ion_phys_assign(const char *name, int fd, ion_phys_addr_t *paddr,
+int msm_audio_ion_phys_free(struct ion_client *client,
+ struct ion_handle *handle,
+ ion_phys_addr_t *paddr,
+ size_t *pa_len, u8 assign_type)
+{
+ int ret;
+
+ 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 (!client || !handle || !paddr || !pa_len) {
+ pr_err("%s: Invalid params\n", __func__);
+ return -EINVAL;
+ }
+
+ ret = ion_phys(client, handle, paddr, pa_len);
+ if (ret) {
+ pr_err("%s: could not get physical address for handle, ret = %d\n",
+ __func__, ret);
+ goto err_ion_handle;
+ }
+
+ ret = msm_audio_hyp_assign(paddr, pa_len, assign_type);
+
+err_ion_handle:
+ ion_free(client, handle);
+ ion_client_destroy(client);
+
+ return ret;
+}
+
+int msm_audio_ion_phys_assign(const char *name, struct ion_client **client,
+ struct ion_handle **handle, int fd,
+ ion_phys_addr_t *paddr,
size_t *pa_len, u8 assign_type)
{
- struct ion_client *client;
- struct ion_handle *handle;
int ret;
if (!(msm_audio_ion_data.device_status & MSM_AUDIO_ION_PROBED)) {
@@ -222,40 +255,43 @@ int msm_audio_ion_phys_assign(const char *name, int fd, ion_phys_addr_t *paddr,
return -EPROBE_DEFER;
}
- if (!name || !paddr || !pa_len) {
+ if (!name || !client || !handle || !paddr || !pa_len) {
pr_err("%s: Invalid params\n", __func__);
return -EINVAL;
}
- client = msm_audio_ion_client_create(name);
- if (IS_ERR_OR_NULL((void *)(client))) {
+ *client = msm_audio_ion_client_create(name);
+ if (IS_ERR_OR_NULL((void *)(*client))) {
pr_err("%s: ION create client failed\n", __func__);
return -EINVAL;
}
- handle = ion_import_dma_buf(client, fd);
- if (IS_ERR_OR_NULL((void *) (handle))) {
+ *handle = ion_import_dma_buf(*client, fd);
+ if (IS_ERR_OR_NULL((void *) (*handle))) {
pr_err("%s: ion import dma buffer failed\n",
__func__);
ret = -EINVAL;
goto err_destroy_client;
}
- ret = ion_phys(client, handle, paddr, pa_len);
+ ret = ion_phys(*client, *handle, paddr, pa_len);
if (ret) {
pr_err("%s: could not get physical address for handle, ret = %d\n",
__func__, ret);
goto err_ion_handle;
}
- pr_debug("%s: ION Physical address is %x\n", __func__, (u32)*paddr);
ret = msm_audio_hyp_assign(paddr, pa_len, assign_type);
+ return ret;
+
err_ion_handle:
- ion_free(client, handle);
+ ion_free(*client, *handle);
err_destroy_client:
- ion_client_destroy(client);
+ ion_client_destroy(*client);
+ *client = NULL;
+ *handle = NULL;
return ret;
}