Loading Documentation/devicetree/bindings/sound/qcom-audio-dev.txt +12 −0 Original line number Diff line number Diff line Loading @@ -1069,11 +1069,23 @@ Optional properties: A phandle parsed by smmu driver. Number of entries will vary across targets. - qcom,scm-mp-enabled: It is possible that some MDMs need audio memory protection enabled through SMC ID in TZ. To enable this functionality, this flag should be present. Presence of this flag makes the msm-audio-ion driver call SCM driver API for memory protection. - memory-region: Provide reference to memory region allocated for audio in reserved-memory node. Example: qcom,msm-audio-ion { compatible = "qcom,msm-audio-ion; qcom,smmu-enabled; qcom,scm-mp-enabled; memory-region = <&audio_mem>; }; * MSM8994 ASoC Machine driver Loading arch/arm/boot/dts/qcom/mdm9607.dtsi +2 −0 Original line number Diff line number Diff line Loading @@ -958,6 +958,8 @@ qcom,msm-audio-ion { compatible = "qcom,msm-audio-ion"; qcom,scm-mp-enabled; memory-region = <&audio_mem>; }; pcm0: qcom,msm-pcm { Loading drivers/soc/qcom/qdsp6v2/msm_audio_ion.c +48 −1 Original line number Diff line number Diff line /* * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading @@ -20,6 +20,7 @@ #include <linux/mutex.h> #include <linux/list.h> #include <linux/dma-mapping.h> #include <linux/dma-contiguous.h> #include <linux/dma-buf.h> #include <linux/iommu.h> #include <linux/platform_device.h> Loading @@ -28,7 +29,9 @@ #include <linux/msm_audio_ion.h> #include <linux/export.h> #include <linux/qcom_iommu.h> #include <linux/cma.h> #include <asm/dma-iommu.h> #include <soc/qcom/scm.h> #define MSM_AUDIO_ION_PROBED (1 << 0) Loading @@ -40,6 +43,8 @@ #define MSM_AUDIO_SMMU_SID_OFFSET 32 #define TZBSP_MEM_PROTECT_AUDIO_CMD_ID 0x00000005 struct addr_range { dma_addr_t start; size_t size; Loading @@ -52,6 +57,7 @@ struct context_bank_info { struct msm_audio_ion_private { bool smmu_enabled; bool scm_mp_enabled; bool audioheap_enabled; struct device *cb_dev; struct dma_iommu_mapping *mapping; Loading @@ -72,6 +78,15 @@ struct msm_audio_alloc_data { struct list_head list; }; struct tz_mem_protect_cmd_buf { phys_addr_t phys_addr; unsigned long size; }; struct tz_resp { int32_t ret; }; static struct msm_audio_ion_private msm_audio_ion_data = {0,}; static int msm_audio_ion_get_phys(struct ion_client *client, Loading Loading @@ -796,12 +811,37 @@ u32 msm_audio_populate_upper_32_bits(ion_phys_addr_t pa) return upper_32_bits(pa); } static void msm_audio_protect_memory_region(struct device *dev) { int ret = 0; unsigned long size = 0; phys_addr_t phys_addr = 0; struct tz_mem_protect_cmd_buf desc = {0}; struct tz_resp resp = {0}; phys_addr = cma_get_base(dev_get_cma_area(dev)); size = cma_get_size(dev_get_cma_area(dev)); pr_debug("%s: cma_audio_mem_addr %pK with size %lu\n", __func__, &phys_addr, size); desc.phys_addr = phys_addr; desc.size = size; ret = scm_call(SCM_SVC_MP, TZBSP_MEM_PROTECT_AUDIO_CMD_ID, (void *)&desc , sizeof(desc), (void *)&resp, sizeof(resp)); if (ret < 0) pr_err("%s: SCM call failed, scm_call_ret %d tz_resp %d\n", __func__, ret, resp.ret); } static int msm_audio_ion_probe(struct platform_device *pdev) { int rc = 0; const char *msm_audio_ion_dt = "qcom,smmu-enabled"; const char *msm_audio_ion_smmu = "qcom,smmu-version"; const char *mdm_audio_ion_scm = "qcom,scm-mp-enabled"; bool smmu_enabled; bool scm_mp_enabled; enum apr_subsys_state q6_state; struct device *dev = &pdev->dev; Loading @@ -813,6 +853,13 @@ static int msm_audio_ion_probe(struct platform_device *pdev) return 0; } scm_mp_enabled = of_property_read_bool(dev->of_node, mdm_audio_ion_scm); msm_audio_ion_data.scm_mp_enabled = scm_mp_enabled; if (scm_mp_enabled) msm_audio_protect_memory_region(dev); smmu_enabled = of_property_read_bool(dev->of_node, msm_audio_ion_dt); msm_audio_ion_data.smmu_enabled = smmu_enabled; Loading Loading
Documentation/devicetree/bindings/sound/qcom-audio-dev.txt +12 −0 Original line number Diff line number Diff line Loading @@ -1069,11 +1069,23 @@ Optional properties: A phandle parsed by smmu driver. Number of entries will vary across targets. - qcom,scm-mp-enabled: It is possible that some MDMs need audio memory protection enabled through SMC ID in TZ. To enable this functionality, this flag should be present. Presence of this flag makes the msm-audio-ion driver call SCM driver API for memory protection. - memory-region: Provide reference to memory region allocated for audio in reserved-memory node. Example: qcom,msm-audio-ion { compatible = "qcom,msm-audio-ion; qcom,smmu-enabled; qcom,scm-mp-enabled; memory-region = <&audio_mem>; }; * MSM8994 ASoC Machine driver Loading
arch/arm/boot/dts/qcom/mdm9607.dtsi +2 −0 Original line number Diff line number Diff line Loading @@ -958,6 +958,8 @@ qcom,msm-audio-ion { compatible = "qcom,msm-audio-ion"; qcom,scm-mp-enabled; memory-region = <&audio_mem>; }; pcm0: qcom,msm-pcm { Loading
drivers/soc/qcom/qdsp6v2/msm_audio_ion.c +48 −1 Original line number Diff line number Diff line /* * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading @@ -20,6 +20,7 @@ #include <linux/mutex.h> #include <linux/list.h> #include <linux/dma-mapping.h> #include <linux/dma-contiguous.h> #include <linux/dma-buf.h> #include <linux/iommu.h> #include <linux/platform_device.h> Loading @@ -28,7 +29,9 @@ #include <linux/msm_audio_ion.h> #include <linux/export.h> #include <linux/qcom_iommu.h> #include <linux/cma.h> #include <asm/dma-iommu.h> #include <soc/qcom/scm.h> #define MSM_AUDIO_ION_PROBED (1 << 0) Loading @@ -40,6 +43,8 @@ #define MSM_AUDIO_SMMU_SID_OFFSET 32 #define TZBSP_MEM_PROTECT_AUDIO_CMD_ID 0x00000005 struct addr_range { dma_addr_t start; size_t size; Loading @@ -52,6 +57,7 @@ struct context_bank_info { struct msm_audio_ion_private { bool smmu_enabled; bool scm_mp_enabled; bool audioheap_enabled; struct device *cb_dev; struct dma_iommu_mapping *mapping; Loading @@ -72,6 +78,15 @@ struct msm_audio_alloc_data { struct list_head list; }; struct tz_mem_protect_cmd_buf { phys_addr_t phys_addr; unsigned long size; }; struct tz_resp { int32_t ret; }; static struct msm_audio_ion_private msm_audio_ion_data = {0,}; static int msm_audio_ion_get_phys(struct ion_client *client, Loading Loading @@ -796,12 +811,37 @@ u32 msm_audio_populate_upper_32_bits(ion_phys_addr_t pa) return upper_32_bits(pa); } static void msm_audio_protect_memory_region(struct device *dev) { int ret = 0; unsigned long size = 0; phys_addr_t phys_addr = 0; struct tz_mem_protect_cmd_buf desc = {0}; struct tz_resp resp = {0}; phys_addr = cma_get_base(dev_get_cma_area(dev)); size = cma_get_size(dev_get_cma_area(dev)); pr_debug("%s: cma_audio_mem_addr %pK with size %lu\n", __func__, &phys_addr, size); desc.phys_addr = phys_addr; desc.size = size; ret = scm_call(SCM_SVC_MP, TZBSP_MEM_PROTECT_AUDIO_CMD_ID, (void *)&desc , sizeof(desc), (void *)&resp, sizeof(resp)); if (ret < 0) pr_err("%s: SCM call failed, scm_call_ret %d tz_resp %d\n", __func__, ret, resp.ret); } static int msm_audio_ion_probe(struct platform_device *pdev) { int rc = 0; const char *msm_audio_ion_dt = "qcom,smmu-enabled"; const char *msm_audio_ion_smmu = "qcom,smmu-version"; const char *mdm_audio_ion_scm = "qcom,scm-mp-enabled"; bool smmu_enabled; bool scm_mp_enabled; enum apr_subsys_state q6_state; struct device *dev = &pdev->dev; Loading @@ -813,6 +853,13 @@ static int msm_audio_ion_probe(struct platform_device *pdev) return 0; } scm_mp_enabled = of_property_read_bool(dev->of_node, mdm_audio_ion_scm); msm_audio_ion_data.scm_mp_enabled = scm_mp_enabled; if (scm_mp_enabled) msm_audio_protect_memory_region(dev); smmu_enabled = of_property_read_bool(dev->of_node, msm_audio_ion_dt); msm_audio_ion_data.smmu_enabled = smmu_enabled; Loading