|
@@ -13,13 +13,11 @@
|
|
#include <linux/list.h>
|
|
#include <linux/list.h>
|
|
#include <linux/dma-mapping.h>
|
|
#include <linux/dma-mapping.h>
|
|
#include <linux/dma-buf.h>
|
|
#include <linux/dma-buf.h>
|
|
-#include <linux/iommu.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/of_device.h>
|
|
#include <linux/of_device.h>
|
|
#include <linux/export.h>
|
|
#include <linux/export.h>
|
|
#include <linux/ion_kernel.h>
|
|
#include <linux/ion_kernel.h>
|
|
#include <ipc/apr.h>
|
|
#include <ipc/apr.h>
|
|
-#include <asm/dma-iommu.h>
|
|
|
|
#include <dsp/msm_audio_ion.h>
|
|
#include <dsp/msm_audio_ion.h>
|
|
|
|
|
|
#define MSM_AUDIO_ION_PROBED (1 << 0)
|
|
#define MSM_AUDIO_ION_PROBED (1 << 0)
|
|
@@ -27,21 +25,16 @@
|
|
#define MSM_AUDIO_ION_PHYS_ADDR(alloc_data) \
|
|
#define MSM_AUDIO_ION_PHYS_ADDR(alloc_data) \
|
|
alloc_data->table->sgl->dma_address
|
|
alloc_data->table->sgl->dma_address
|
|
|
|
|
|
-#define MSM_AUDIO_ION_VA_START 0x10000000
|
|
|
|
-#define MSM_AUDIO_ION_VA_LEN 0x0FFFFFFF
|
|
|
|
-
|
|
|
|
#define MSM_AUDIO_SMMU_SID_OFFSET 32
|
|
#define MSM_AUDIO_SMMU_SID_OFFSET 32
|
|
|
|
|
|
struct msm_audio_ion_private {
|
|
struct msm_audio_ion_private {
|
|
bool smmu_enabled;
|
|
bool smmu_enabled;
|
|
struct device *cb_dev;
|
|
struct device *cb_dev;
|
|
- struct dma_iommu_mapping *mapping;
|
|
|
|
u8 device_status;
|
|
u8 device_status;
|
|
struct list_head alloc_list;
|
|
struct list_head alloc_list;
|
|
struct mutex list_mutex;
|
|
struct mutex list_mutex;
|
|
u64 smmu_sid_bits;
|
|
u64 smmu_sid_bits;
|
|
u32 smmu_version;
|
|
u32 smmu_version;
|
|
- u32 iova_start_addr;
|
|
|
|
};
|
|
};
|
|
|
|
|
|
struct msm_audio_alloc_data {
|
|
struct msm_audio_alloc_data {
|
|
@@ -654,31 +647,10 @@ EXPORT_SYMBOL(msm_audio_populate_upper_32_bits);
|
|
|
|
|
|
static int msm_audio_smmu_init(struct device *dev)
|
|
static int msm_audio_smmu_init(struct device *dev)
|
|
{
|
|
{
|
|
- struct dma_iommu_mapping *mapping;
|
|
|
|
- int ret;
|
|
|
|
-
|
|
|
|
- mapping = arm_iommu_create_mapping(&platform_bus_type,
|
|
|
|
- msm_audio_ion_data.iova_start_addr,
|
|
|
|
- MSM_AUDIO_ION_VA_LEN);
|
|
|
|
- if (IS_ERR(mapping))
|
|
|
|
- return PTR_ERR(mapping);
|
|
|
|
-
|
|
|
|
- ret = arm_iommu_attach_device(dev, mapping);
|
|
|
|
- if (ret) {
|
|
|
|
- dev_err(dev, "%s: Attach failed, err = %d\n",
|
|
|
|
- __func__, ret);
|
|
|
|
- goto fail_attach;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- msm_audio_ion_data.mapping = mapping;
|
|
|
|
INIT_LIST_HEAD(&msm_audio_ion_data.alloc_list);
|
|
INIT_LIST_HEAD(&msm_audio_ion_data.alloc_list);
|
|
mutex_init(&(msm_audio_ion_data.list_mutex));
|
|
mutex_init(&(msm_audio_ion_data.list_mutex));
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
-
|
|
|
|
-fail_attach:
|
|
|
|
- arm_iommu_release_mapping(mapping);
|
|
|
|
- return ret;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
static const struct of_device_id msm_audio_ion_dt_match[] = {
|
|
static const struct of_device_id msm_audio_ion_dt_match[] = {
|
|
@@ -694,7 +666,6 @@ static int msm_audio_ion_probe(struct platform_device *pdev)
|
|
u64 smmu_sid_mask = 0;
|
|
u64 smmu_sid_mask = 0;
|
|
const char *msm_audio_ion_dt = "qcom,smmu-enabled";
|
|
const char *msm_audio_ion_dt = "qcom,smmu-enabled";
|
|
const char *msm_audio_ion_smmu = "qcom,smmu-version";
|
|
const char *msm_audio_ion_smmu = "qcom,smmu-version";
|
|
- const char *msm_audio_ion_iova_start_addr = "qcom,iova-start-addr";
|
|
|
|
const char *msm_audio_ion_smmu_sid_mask = "qcom,smmu-sid-mask";
|
|
const char *msm_audio_ion_smmu_sid_mask = "qcom,smmu-sid-mask";
|
|
bool smmu_enabled;
|
|
bool smmu_enabled;
|
|
enum apr_subsys_state q6_state;
|
|
enum apr_subsys_state q6_state;
|
|
@@ -740,18 +711,6 @@ static int msm_audio_ion_probe(struct platform_device *pdev)
|
|
dev_dbg(dev, "%s: SMMU is Enabled. SMMU version is (%d)",
|
|
dev_dbg(dev, "%s: SMMU is Enabled. SMMU version is (%d)",
|
|
__func__, msm_audio_ion_data.smmu_version);
|
|
__func__, msm_audio_ion_data.smmu_version);
|
|
|
|
|
|
- rc = of_property_read_u32(dev->of_node,
|
|
|
|
- msm_audio_ion_iova_start_addr,
|
|
|
|
- &msm_audio_ion_data.iova_start_addr);
|
|
|
|
- if (rc) {
|
|
|
|
- dev_dbg(dev,
|
|
|
|
- "%s: qcom,iova_start_addr missing in DT node, initialize with default val\n",
|
|
|
|
- __func__);
|
|
|
|
- msm_audio_ion_data.iova_start_addr = MSM_AUDIO_ION_VA_START;
|
|
|
|
- } else {
|
|
|
|
- dev_dbg(dev, "%s:IOVA start addr: 0x%x\n",
|
|
|
|
- __func__, msm_audio_ion_data.iova_start_addr);
|
|
|
|
- }
|
|
|
|
/* Get SMMU SID information from Devicetree */
|
|
/* Get SMMU SID information from Devicetree */
|
|
rc = of_property_read_u64(dev->of_node,
|
|
rc = of_property_read_u64(dev->of_node,
|
|
msm_audio_ion_smmu_sid_mask,
|
|
msm_audio_ion_smmu_sid_mask,
|
|
@@ -796,17 +755,10 @@ exit:
|
|
|
|
|
|
static int msm_audio_ion_remove(struct platform_device *pdev)
|
|
static int msm_audio_ion_remove(struct platform_device *pdev)
|
|
{
|
|
{
|
|
- struct dma_iommu_mapping *mapping;
|
|
|
|
struct device *audio_cb_dev;
|
|
struct device *audio_cb_dev;
|
|
|
|
|
|
- mapping = msm_audio_ion_data.mapping;
|
|
|
|
audio_cb_dev = msm_audio_ion_data.cb_dev;
|
|
audio_cb_dev = msm_audio_ion_data.cb_dev;
|
|
|
|
|
|
- if (audio_cb_dev && mapping) {
|
|
|
|
- arm_iommu_detach_device(audio_cb_dev);
|
|
|
|
- arm_iommu_release_mapping(mapping);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
msm_audio_ion_data.smmu_enabled = 0;
|
|
msm_audio_ion_data.smmu_enabled = 0;
|
|
msm_audio_ion_data.device_status = 0;
|
|
msm_audio_ion_data.device_status = 0;
|
|
return 0;
|
|
return 0;
|