This series of patches adds support for memory-region assignment, so the
access region of DMA engine could be restricted.
Patches are based on broonie tree "for-next" branch.
Trevor Wu (2):
ASoC: mediatek: mt8195: support reserved memory assignment
dt-bindings: mediatek: mt8195: add memory-region property
.../devicetree/bindings/sound/mt8195-afe-pcm.yaml | 8 ++++++++
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c | 7 +++++++
2 files changed, 15 insertions(+)
--
2.18.0
Add a required property "memory-region", which is used to specify memory
for DMA usage.
Signed-off-by: Trevor Wu <[email protected]>
---
.../devicetree/bindings/sound/mt8195-afe-pcm.yaml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/mt8195-afe-pcm.yaml b/Documentation/devicetree/bindings/sound/mt8195-afe-pcm.yaml
index dcf790b053d2..6d0975b33d15 100644
--- a/Documentation/devicetree/bindings/sound/mt8195-afe-pcm.yaml
+++ b/Documentation/devicetree/bindings/sound/mt8195-afe-pcm.yaml
@@ -19,6 +19,12 @@ properties:
interrupts:
maxItems: 1
+ memory-region:
+ maxItems: 1
+ description: |
+ Shared memory region for AFE memif. A "shared-dma-pool".
+ See ../reserved-memory/reserved-memory.txt for details.
+
mediatek,topckgen:
$ref: "/schemas/types.yaml#/definitions/phandle"
description: The phandle of the mediatek topckgen controller
@@ -125,6 +131,7 @@ required:
- power-domains
- clocks
- clock-names
+ - memory-region
additionalProperties: false
@@ -139,6 +146,7 @@ examples:
interrupts = <GIC_SPI 822 IRQ_TYPE_LEVEL_HIGH 0>;
mediatek,topckgen = <&topckgen>;
power-domains = <&spm 7>; //MT8195_POWER_DOMAIN_AUDIO
+ memory-region = <&snd_dma_mem_reserved>;
clocks = <&clk26m>,
<&topckgen 163>, //CLK_TOP_APLL1
<&topckgen 166>, //CLK_TOP_APLL2
--
2.18.0
For security purpose, restrict the memory assess region of AFE memif.
The specified memory region should be assigned from DTS.
Signed-off-by: Trevor Wu <[email protected]>
---
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c
index 2bb05a828e8d..8a6db24116e3 100644
--- a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c
+++ b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c
@@ -14,6 +14,7 @@
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_platform.h>
+#include <linux/of_reserved_mem.h>
#include <linux/pm_runtime.h>
#include "mt8195-afe-common.h"
#include "mt8195-afe-clk.h"
@@ -3061,6 +3062,12 @@ static int mt8195_afe_pcm_dev_probe(struct platform_device *pdev)
int i, irq_id, ret;
struct snd_soc_component *component;
+ ret = of_reserved_mem_device_init(dev);
+ if (ret) {
+ dev_err(dev, "failed to assign memory region: %d\n", ret);
+ return ret;
+ }
+
ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(33));
if (ret)
return ret;
--
2.18.0
On Tue, 30 Nov 2021 13:39:03 +0800, Trevor Wu wrote:
> This series of patches adds support for memory-region assignment, so the
> access region of DMA engine could be restricted.
> Patches are based on broonie tree "for-next" branch.
>
> Trevor Wu (2):
> ASoC: mediatek: mt8195: support reserved memory assignment
> dt-bindings: mediatek: mt8195: add memory-region property
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/2] ASoC: mediatek: mt8195: support reserved memory assignment
commit: 4d408ea0282c374a304ce402866cb7b8a56c6b05
[2/2] dt-bindings: mediatek: mt8195: add memory-region property
commit: 2da636247bb6f4fc3a9842ade04757790753fd2c
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark