Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing DMA Buf detach #87

Open
wants to merge 29 commits into
base: optee
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9e38023
Add upstream-tee-subsys-patches.txt
jenswi-linaro Apr 4, 2018
9d5c773
tee: new ioctl to a register tee_shm from a dmabuf file descriptor
etienne-lms Oct 27, 2016
595188c
arm64: dt: Remove timer from mt8173 **not for mainline**
jbech-linaro Apr 1, 2016
1d5f2c3
arm64: dt: OP-TEE for foundation-v8 **not for mainline**
jenswi-linaro Aug 17, 2016
ef79f9e
arm64: dt: OP-TEE for Juno **not for mainline**
jenswi-linaro Mar 29, 2016
767ffb6
arm64: dt: Add no-map to the reserved-memory node for OP-TEE for foun…
jenswi-linaro Dec 2, 2016
c9108c8
arm64: dt: Add no-map to the reserved-memory node for OP-TEE for juno…
jenswi-linaro Jan 3, 2017
f9029fe
arm64: dt: Add OP-TEE firmware to mt8173 **not for mainline**
jbech-linaro Mar 24, 2016
9f5731c
OP-TEE Benchmark **not for mainline**
Oct 25, 2016
41e9290
tee: support of allocating DMA shared buffers **not for mainline**
Feb 5, 2018
0b1c103
upstream-tee-subsys-patches.txt: patches up to v4.20-rc1
jenswi-linaro Nov 5, 2018
f795a4f
upstream-tee-subsys-patches.txt: patches up to v5.0
jforissier Mar 4, 2019
578ce3c
upstream-tee-subsys-patches.txt: patches up to v5.1
jforissier May 7, 2019
fa11127
staging/ion: add Allwinner ION "secure" heap
etienne-lms Aug 14, 2017
11ed7ae
ion: "unmapped" heap for secure data path
etienne-lms Aug 14, 2017
366e674
staging/ion: condition unmapped heap to supported architectures
etienne-lms Sep 8, 2017
05790c9
staging/ion: ARM64 supports ION_UNMAPPED_HEAP
etienne-lms Sep 14, 2017
6af0afc
staging:ion: add a no-map property to ion dmabuf attachment
etienne-lms Oct 9, 2017
816b967
staging: android: ion: do not clear dma_address of unmapped heap
jforissier Aug 31, 2018
bfc70e1
upstream-tee-subsys-patches.txt: patches up to v5.4-rc7
jforissier Nov 15, 2019
10ef4b8
upstream-tee-subsys-patches.txt: patches up to v5.5
jforissier Nov 15, 2019
185d754
driver: tee: Handle NULL pointer indication from client
cneveux Mar 4, 2019
4b38a0a
arm64: dts: hi3798cv200-poplar: memreserve for bootloader
igoropaniuk May 11, 2020
50c5965
arm64: dts: hi3798cv200-poplar: add optee node
igoropaniuk May 11, 2020
bc1e135
ARM: dts: stm32: Define OP-TEE resources on stm32mp15 and enable on DK2
etienne-lms May 27, 2020
d297719
upstream-tee-subsys-patches.txt: patches up to v5.9
jforissier Nov 15, 2019
a1f8ac0
tee: client UUID: Skip REE kernel login method as well
b49020 Sep 17, 2020
28676a5
checkpatch: add --kconfig-prefix
jforissier Oct 16, 2020
2f283bb
Add missing DMA Buf detach
omasse-linaro Jan 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions arch/arm/boot/dts/stm32mp151.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
method = "smc";
};

firmware {
optee: optee {
compatible = "linaro,optee-tz";
method = "smc";
status = "disabled";
};
};

intc: interrupt-controller@a0021000 {
compatible = "arm,cortex-a7-gic";
#interrupt-cells = <3>;
Expand Down
11 changes: 11 additions & 0 deletions arch/arm/boot/dts/stm32mp157c-dk2.dts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
model = "STMicroelectronics STM32MP157C-DK2 Discovery Board";
compatible = "st,stm32mp157c-dk2", "st,stm32mp157";

reserved-memory {
optee_memory: optee@0xde000000 {
reg = <0xde000000 0x02000000>;
no-map;
};
};

aliases {
ethernet0 = &ethernet0;
serial0 = &uart4;
Expand Down Expand Up @@ -95,3 +102,7 @@
pinctrl-2 = <&usart2_idle_pins_c>;
status = "disabled";
};

&optee {
status = "okay";
};
28 changes: 19 additions & 9 deletions arch/arm64/boot/dts/arm/foundation-v8.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

aliases {
serial0 = &v2m_serial0;
serial1 = &v2m_serial1;
serial2 = &v2m_serial2;
serial3 = &v2m_serial3;
};
Expand Down Expand Up @@ -67,6 +66,17 @@
<0x00000008 0x80000000 0 0x80000000>;
};

reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;

optee@0x83000000 {
reg = <0x00000000 0x83000000 0 0x01000000>;
no-map;
};
};

timer {
compatible = "arm,armv8-timer";
interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
Expand Down Expand Up @@ -197,14 +207,6 @@
clock-names = "uartclk", "apb_pclk";
};

v2m_serial1: serial@a0000 {
compatible = "arm,pl011", "arm,primecell";
reg = <0x0a0000 0x1000>;
interrupts = <6>;
clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>;
clock-names = "uartclk", "apb_pclk";
};

v2m_serial2: serial@b0000 {
compatible = "arm,pl011", "arm,primecell";
reg = <0x0b0000 0x1000>;
Expand All @@ -228,4 +230,12 @@
};
};
};

firmware {
optee {
compatible = "linaro,optee-tz";
method = "smc";
};
};

};
19 changes: 19 additions & 0 deletions arch/arm64/boot/dts/arm/juno-base.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,18 @@
<0x00000008 0x80000000 0x1 0x80000000>;
};

reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;

/* Shared memory between secure and non-secure world */
optee@0xfee00000 {
reg = <0x00000000 0xfee00000 0 0x00200000>;
no-map;
};
};

bus@8000000 {
compatible = "simple-bus";
#address-cells = <2>;
Expand Down Expand Up @@ -837,4 +849,11 @@
interrupt-map-mask = <0 0>;
interrupt-map = <0 0 &gic 0 GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>;
};

firmware {
optee {
compatible = "linaro,optee-tz";
method = "smc";
};
};
};
8 changes: 8 additions & 0 deletions arch/arm64/boot/dts/hisilicon/hi3798cv200-poplar.dts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

/dts-v1/;
/memreserve/ 0x00000000 0x04080000;

#include <dt-bindings/gpio/gpio.h>
#include "hi3798cv200.dtsi"
Expand Down Expand Up @@ -70,6 +71,13 @@
gpio = <&gpio6 7 0>;
enable-active-high;
};

firmware {
optee {
compatible = "linaro,optee-tz";
method = "smc";
};
};
};

&ehci {
Expand Down
7 changes: 7 additions & 0 deletions arch/arm64/boot/dts/mediatek/mt8173-evb.dts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
gpio = <&pio 9 GPIO_ACTIVE_HIGH>;
enable-active-high;
};

firmware {
optee {
compatible = "linaro,optee-tz";
method = "smc";
};
};
};

&cec {
Expand Down
9 changes: 0 additions & 9 deletions arch/arm64/boot/dts/mediatek/mt8173.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -468,15 +468,6 @@
reg = <0 0x10007000 0 0x100>;
};

timer: timer@10008000 {
compatible = "mediatek,mt8173-timer",
"mediatek,mt6577-timer";
reg = <0 0x10008000 0 0x1000>;
interrupts = <GIC_SPI 144 IRQ_TYPE_LEVEL_LOW>;
clocks = <&infracfg CLK_INFRA_CLK_13M>,
<&topckgen CLK_TOP_RTC_SEL>;
};

pwrap: pwrap@1000d000 {
compatible = "mediatek,mt8173-pwrap";
reg = <0 0x1000d000 0 0x1000>;
Expand Down
32 changes: 32 additions & 0 deletions drivers/staging/android/ion/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,35 @@ config ION_CMA_HEAP
Choose this option to enable CMA heaps with Ion. This heap is backed
by the Contiguous Memory Allocator (CMA). If your system has these
regions, you should say Y here.

config ION_UNMAPPED_HEAP
bool "ION unmapped heap support"
depends on ION && (ARM || ARM64)
help
Choose this option to enable UNMAPPED heaps with Ion. This heap is
backed in specific memory pools, carveout from the Linux memory.
Unless you know your system has these regions, you should say N here.

config ION_DUMMY_UNMAPPED_HEAP
bool "ION dummy driver define an ION unmapped heap"
depends on ION_UNMAPPED_HEAP
help
Dummy ION driver will create a unmapped heap from physical
location provided through CONFIG_ION_DUMMY_UNMAPPED_BASE and
CONFIG_ION_DUMMY_UNMAPPED_SIZE.

config ION_DUMMY_UNMAPPED_BASE
hex "Physical base address of the ION unmapped heap"
depends on ION_DUMMY_UNMAPPED_HEAP
default 0
help
Allows one the statically define an unmapped heap from the
ION dummy driver to exercice unamped heaps buffer managment.

config ION_DUMMY_UNMAPPED_SIZE
hex "Physical byte size of the ION unmapped heap"
depends on ION_DUMMY_UNMAPPED_HEAP
default 0
help
Allows one the statically define an unmapped heap from the
ION dummy driver to exercice unamped heaps buffer managment.
1 change: 1 addition & 0 deletions drivers/staging/android/ion/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
obj-$(CONFIG_ION) += ion.o ion_heap.o
obj-$(CONFIG_ION_SYSTEM_HEAP) += ion_system_heap.o ion_page_pool.o
obj-$(CONFIG_ION_CMA_HEAP) += ion_cma_heap.o
obj-$(CONFIG_ION_UNMAPPED_HEAP) += ion_unmapped_heap.o
20 changes: 17 additions & 3 deletions drivers/staging/android/ion/ion.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ static void ion_buffer_kmap_put(struct ion_buffer *buffer)
}
}

static struct sg_table *dup_sg_table(struct sg_table *table)
static struct sg_table *dup_sg_table(struct sg_table *table,
bool preserve_dma_address)
{
struct sg_table *new_table;
int ret, i;
Expand All @@ -156,7 +157,8 @@ static struct sg_table *dup_sg_table(struct sg_table *table)
new_sg = new_table->sgl;
for_each_sgtable_sg(table, sg, i) {
memcpy(new_sg, sg, sizeof(*sg));
new_sg->dma_address = 0;
if (!preserve_dma_address)
new_sg->dma_address = 0;
new_sg = sg_next(new_sg);
}

Expand All @@ -173,6 +175,7 @@ struct ion_dma_buf_attachment {
struct device *dev;
struct sg_table *table;
struct list_head list;
bool no_map;
};

static int ion_dma_buf_attach(struct dma_buf *dmabuf,
Expand All @@ -186,7 +189,10 @@ static int ion_dma_buf_attach(struct dma_buf *dmabuf,
if (!a)
return -ENOMEM;

table = dup_sg_table(buffer->sg_table);
if (buffer->heap->type == ION_HEAP_TYPE_UNMAPPED)
a->no_map = true;

table = dup_sg_table(buffer->sg_table, a->no_map);
if (IS_ERR(table)) {
kfree(a);
return -ENOMEM;
Expand Down Expand Up @@ -228,6 +234,9 @@ static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment,

table = a->table;

if (a->no_map)
return table;

ret = dma_map_sgtable(attachment->dev, table, direction, 0);
if (ret)
return ERR_PTR(ret);
Expand All @@ -239,6 +248,11 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment,
struct sg_table *table,
enum dma_data_direction direction)
{
struct ion_dma_buf_attachment *a = attachment->priv;

if (a->no_map)
return;

dma_unmap_sgtable(attachment->dev, table, direction, 0);
}

Expand Down
Loading