Skip to content

Commit

Permalink
firmware: qcom: add a dedicated TrustZone buffer allocator
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Bartosz Golaszewski authored and Bjorn Andersson committed Jun 23, 2024
1 parent 9164d2b commit 84f5a7b
Show file tree
Hide file tree
Showing 6 changed files with 487 additions and 0 deletions.
8 changes: 8 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -18605,6 +18605,14 @@ F: Documentation/networking/device_drivers/cellular/qualcomm/rmnet.rst
F: drivers/net/ethernet/qualcomm/rmnet/
F: include/linux/if_rmnet.h

QUALCOMM TRUST ZONE MEMORY ALLOCATOR
M: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
L: linux-arm-msm@vger.kernel.org
S: Maintained
F: drivers/firmware/qcom/qcom_tzmem.c
F: drivers/firmware/qcom/qcom_tzmem.h
F: include/linux/firmware/qcom/qcom_tzmem.h

QUALCOMM TSENS THERMAL DRIVER
M: Amit Kucheria <amitk@kernel.org>
M: Thara Gopinath <thara.gopinath@gmail.com>
Expand Down
20 changes: 20 additions & 0 deletions drivers/firmware/qcom/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@ menu "Qualcomm firmware drivers"
config QCOM_SCM
tristate

config QCOM_TZMEM
tristate
select GENERIC_ALLOCATOR

choice
prompt "TrustZone interface memory allocator mode"
default QCOM_TZMEM_MODE_GENERIC
help
Selects the mode of the memory allocator providing memory buffers of
suitable format for sharing with the TrustZone. If in doubt, select
'Generic'.

config QCOM_TZMEM_MODE_GENERIC
bool "Generic"
help
Use the generic allocator mode. The memory is page-aligned, non-cachable
and physically contiguous.

endchoice

config QCOM_SCM_DOWNLOAD_MODE_DEFAULT
bool "Qualcomm download mode enabled by default"
depends on QCOM_SCM
Expand Down
1 change: 1 addition & 0 deletions drivers/firmware/qcom/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@

obj-$(CONFIG_QCOM_SCM) += qcom-scm.o
qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o
obj-$(CONFIG_QCOM_TZMEM) += qcom_tzmem.o
obj-$(CONFIG_QCOM_QSEECOM) += qcom_qseecom.o
obj-$(CONFIG_QCOM_QSEECOM_UEFISECAPP) += qcom_qseecom_uefisecapp.o
Loading

0 comments on commit 84f5a7b

Please sign in to comment.