Skip to content

Commit 84f5a7b

Browse files
Bartosz Golaszewskiandersson
authored andcommitted
firmware: qcom: add a dedicated TrustZone buffer allocator
We have several SCM calls that require passing buffers to the TrustZone on top of the SMC core which allocates memory for calls that require more than 4 arguments. Currently every user does their own thing which leads to code duplication. Many users call dma_alloc_coherent() for every call which is terribly unperformant (speed- and size-wise). Provide a set of library functions for creating and managing pools of memory which is suitable for sharing with the TrustZone, that is: page-aligned, contiguous and non-cachable as well as provides a way of mapping of kernel virtual addresses to physical space. Make the allocator ready for extending with additional modes of operation which will allow us to support the SHM bridge safety mechanism once all users convert. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Andrew Halaney <ahalaney@redhat.com> Tested-by: Andrew Halaney <ahalaney@redhat.com> # sc8280xp-lenovo-thinkpad-x13s Tested-by: Deepti Jaggi <quic_djaggi@quicinc.com> #sa8775p-ride Reviewed-by: Elliot Berman <quic_eberman@quicinc.com> Link: https://lore.kernel.org/r/20240527-shm-bridge-v10-2-ce7afaa58d3a@linaro.org Signed-off-by: Bjorn Andersson <andersson@kernel.org>
1 parent 9164d2b commit 84f5a7b

File tree

6 files changed

+487
-0
lines changed

6 files changed

+487
-0
lines changed

MAINTAINERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18605,6 +18605,14 @@ F: Documentation/networking/device_drivers/cellular/qualcomm/rmnet.rst
1860518605
F: drivers/net/ethernet/qualcomm/rmnet/
1860618606
F: include/linux/if_rmnet.h
1860718607

18608+
QUALCOMM TRUST ZONE MEMORY ALLOCATOR
18609+
M: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
18610+
L: linux-arm-msm@vger.kernel.org
18611+
S: Maintained
18612+
F: drivers/firmware/qcom/qcom_tzmem.c
18613+
F: drivers/firmware/qcom/qcom_tzmem.h
18614+
F: include/linux/firmware/qcom/qcom_tzmem.h
18615+
1860818616
QUALCOMM TSENS THERMAL DRIVER
1860918617
M: Amit Kucheria <amitk@kernel.org>
1861018618
M: Thara Gopinath <thara.gopinath@gmail.com>

drivers/firmware/qcom/Kconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,26 @@ menu "Qualcomm firmware drivers"
99
config QCOM_SCM
1010
tristate
1111

12+
config QCOM_TZMEM
13+
tristate
14+
select GENERIC_ALLOCATOR
15+
16+
choice
17+
prompt "TrustZone interface memory allocator mode"
18+
default QCOM_TZMEM_MODE_GENERIC
19+
help
20+
Selects the mode of the memory allocator providing memory buffers of
21+
suitable format for sharing with the TrustZone. If in doubt, select
22+
'Generic'.
23+
24+
config QCOM_TZMEM_MODE_GENERIC
25+
bool "Generic"
26+
help
27+
Use the generic allocator mode. The memory is page-aligned, non-cachable
28+
and physically contiguous.
29+
30+
endchoice
31+
1232
config QCOM_SCM_DOWNLOAD_MODE_DEFAULT
1333
bool "Qualcomm download mode enabled by default"
1434
depends on QCOM_SCM

drivers/firmware/qcom/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55

66
obj-$(CONFIG_QCOM_SCM) += qcom-scm.o
77
qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o
8+
obj-$(CONFIG_QCOM_TZMEM) += qcom_tzmem.o
89
obj-$(CONFIG_QCOM_QSEECOM) += qcom_qseecom.o
910
obj-$(CONFIG_QCOM_QSEECOM_UEFISECAPP) += qcom_qseecom_uefisecapp.o

0 commit comments

Comments
 (0)