Переглянути джерело

dsp: support ION memory allocation from audio heap

* Add support to allocate memory from the ION audio heap
  once smmu enabled.

Change-Id: Ic1686c7a3225b723811cbbd35f08d0ac123d1f78
Signed-off-by: Viraja Kommaraju <[email protected]>
Viraja Kommaraju 4 роки тому
батько
коміт
8c623f54c4
1 змінених файлів з 10 додано та 4 видалено
  1. 10 4
      dsp/msm_audio_ion_vm.c

+ 10 - 4
dsp/msm_audio_ion_vm.c

@@ -562,12 +562,18 @@ int msm_audio_ion_alloc(struct dma_buf **dma_buf, size_t bufsz,
 		pr_err("%s: Invalid params\n", __func__);
 		return -EINVAL;
 	}
-
+	pr_debug("%s: audio heap is used\n", __func__);
 	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);
+		*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_debug("%s: ION alloc failed for audio heap err ptr=%ld, smmu_enabled=%d,"
+					"trying system heap..\n",
+					__func__, err_ion_ptr, msm_audio_ion_data.smmu_enabled);
+			*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))) {