mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] firmware: qcom: Build the TrustZone memory allocator into qcom-scm
@ 2026-11-24 13:59 Sasha Levin
  0 siblings, 0 replies; only message in thread
From: Sasha Levin @ 2026-11-24 13:59 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio
  Cc: Bartosz Golaszewski, Abel Vesa, Nathan Chancellor, Julian Braha,
	Arnd Bergmann, Sumit Garg, Geert Uytterhoeven, linux-arm-msm,
	linux-kernel

With QCOM_TZMEM_MODE_SHMBRIDGE=y, qcom_tzmem.ko calls
qcom_scm_shm_bridge_enable(), qcom_scm_shm_bridge_create() and
qcom_scm_shm_bridge_delete() in qcom-scm.ko, and qcom-scm.ko calls
qcom_tzmem_alloc() and friends. With QCOM_SCM=m the two modules depend
on each other, neither can be loaded first, and modules_install fails:

  depmod: ERROR: Cycle detected: qcom_scm -> qcom_tzmem -> qcom_scm
  depmod: ERROR: Found 2 modules in dependency cycles!

This has been possible since SHM Bridge mode was added. Since commit
35abc3cd8ab6 ("tee: remove TZMEM_MODE_GENERIC") it also happens for
every QCOMTEE=m build with QCOM_SCM=m, because QCOMTEE's select of
QCOM_TZMEM_MODE_SHMBRIDGE now takes effect.

QCOM_TZMEM is selected only by QCOM_SCM, so the two always have the
same value. Build qcom_tzmem.o into qcom-scm.ko and remove the
QCOM_TZMEM symbol: QCOM_SCM selects GENERIC_ALLOCATOR itself, and
QCOM_TZMEM_MODE_SHMBRIDGE depends on QCOM_SCM. Drop the
MODULE_DESCRIPTION() and MODULE_LICENSE() that qcom-scm already has.

Fixes: f86c61498a57 ("firmware: qcom: tzmem: enable SHM Bridge support")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Closes: https://lore.kernel.org/all/20261122051636.GA2630332@ax162/
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

Changes in v2:
- Remove QCOM_TZMEM: QCOM_SCM selects GENERIC_ALLOCATOR, and
  QCOM_TZMEM_MODE_SHMBRIDGE depends on QCOM_SCM (Nathan)

v1: https://lore.kernel.org/all/20261122152843.1113882-1-sashal@kernel.org/

Tested on arm64 with allnoconfig plus: Nathan's fragment (COMPILE_TEST,
QCOM_SCM=m, SHMBRIDGE=y); ARCH_QCOM=y QCOM_SCM=m SHMBRIDGE=y; ARCH_QCOM=y
QCOM_SCM=m QCOMTEE=m; QCOM_SCM=y QCOMTEE=m; QCOM_SCM=m SHMBRIDGE=n. All
build without new W=1 warnings and pass modules_install.

 drivers/firmware/qcom/Kconfig      | 8 ++------
 drivers/firmware/qcom/Makefile     | 3 +--
 drivers/firmware/qcom/qcom_tzmem.c | 2 --
 3 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/firmware/qcom/Kconfig b/drivers/firmware/qcom/Kconfig
index 3ad22f8fc3e5f..54b9abfb6aadf 100644
--- a/drivers/firmware/qcom/Kconfig
+++ b/drivers/firmware/qcom/Kconfig
@@ -28,16 +28,12 @@ config QCOM_PAS_TEE
 config QCOM_SCM
 	tristate "Qualcomm PAS SCM interface driver" if ARCH_QCOM || COMPILE_TEST
 	select QCOM_PAS
-	select QCOM_TZMEM
-	default y if ARCH_QCOM
-
-config QCOM_TZMEM
-	tristate
 	select GENERIC_ALLOCATOR
+	default y if ARCH_QCOM
 
 config QCOM_TZMEM_MODE_SHMBRIDGE
 	bool "TrustZone interface memory allocator: SHM Bridge"
-	depends on QCOM_TZMEM
+	depends on QCOM_SCM
 	help
 	  Use Qualcomm Shared Memory Bridge as memory allocator. The memory has the
 	  same alignment as in the 'Generic' allocator, which is used when this option
diff --git a/drivers/firmware/qcom/Makefile b/drivers/firmware/qcom/Makefile
index 88ce74d74c3e2..74c655856b0c2 100644
--- a/drivers/firmware/qcom/Makefile
+++ b/drivers/firmware/qcom/Makefile
@@ -4,9 +4,8 @@
 #
 
 obj-$(CONFIG_QCOM_SCM)		+= qcom-scm.o
-qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o
+qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o qcom_tzmem.o
 CFLAGS_qcom_scm-smc.o := -I$(src)
-obj-$(CONFIG_QCOM_TZMEM)	+= qcom_tzmem.o
 obj-$(CONFIG_QCOM_QSEECOM)	+= qcom_qseecom.o
 obj-$(CONFIG_QCOM_QSEECOM_UEFISECAPP) += qcom_qseecom_uefisecapp.o
 obj-$(CONFIG_QCOM_PAS)		+= qcom_pas.o
diff --git a/drivers/firmware/qcom/qcom_tzmem.c b/drivers/firmware/qcom/qcom_tzmem.c
index e1d944d0eb63f..9330cd428205e 100644
--- a/drivers/firmware/qcom/qcom_tzmem.c
+++ b/drivers/firmware/qcom/qcom_tzmem.c
@@ -522,6 +522,4 @@ int qcom_tzmem_enable(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(qcom_tzmem_enable);
 
-MODULE_DESCRIPTION("TrustZone memory allocator for Qualcomm firmware drivers");
 MODULE_AUTHOR("Bartosz Golaszewski <bartosz.golaszewski@linaro.org>");
-MODULE_LICENSE("GPL");

base-commit: 8d7fe9885c62fc9a95bf55d9db244d9672a8aadc
-- 
2.53.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-24 13:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 13:59 [PATCH v2] firmware: qcom: Build the TrustZone memory allocator into qcom-scm Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®