firmware: qcom: scm: fold tzmem into the qcom-scm module
Subsystems (2)
PATCH 1/1 firmware: qcom: scm: fold tzmem into the qcom-scm module
From: Sumit Garg <[email protected]>
qcom_scm and qcom_tzmem have a mutual symbol dependency: qcom_tzmem calls qcom_scm_shm_bridge_{enable,create,delete}() while qcom_scm calls qcom_tzmem_{alloc,free,to_phys}() and qcom_scm_get_tzmem_pool(). When both are built as modules this results in a circular module dependency and depmod fails:
depmod: ERROR: Cycle detected: qcom_scm -> qcom_tzmem -> qcom_scm
QCOM_TZMEM is an invisible tristate that is only ever selected by QCOM_SCM, so the two are always enabled together. Build qcom_tzmem.o as part of the qcom-scm composite module instead of as a separate module. This breaks the cycle since the mutual symbol references become intra-module.
With tzmem now internal to qcom-scm, the shm_bridge helpers are no longer used outside the module, so drop their EXPORT_SYMBOL_GPL() and move the declarations from the public header to the private one, alongside qcom_scm_shm_bridge_enable().
--- drivers/firmware/qcom/Makefile | 2 +- drivers/firmware/qcom/qcom_scm.c | 3 --- drivers/firmware/qcom/qcom_scm.h | 4 ++++ include/linux/firmware/qcom/qcom_scm.h | 5 ----- 4 files changed, 5 insertions(+), 9 deletions(-)
drivers/firmware/qcom/Makefile +1 -1
@@ -5,7 +5,7 @@ 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 +qcom-scm-$(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
drivers/firmware/qcom/qcom_scm.c +0 -3
@@ -1813,7 +1813,6 @@ int qcom_scm_shm_bridge_enable(struct device *scm_dev)return res.result[0 ]; } -EXPORT_SYMBOL_GPL (qcom_scm_shm_bridge_enable); int qcom_scm_shm_bridge_create(u64 pfn_and_ns_perm_flags, u64 ipfn_and_s_perm_flags, u64 size_and_flags,
@@ -1841,7 +1840,6 @@ int qcom_scm_shm_bridge_create(u64 pfn_and_ns_perm_flags,return ret ?: res.result[0 ]; } -EXPORT_SYMBOL_GPL (qcom_scm_shm_bridge_create);int qcom_scm_shm_bridge_delete (u64 handle) {
@@ -1855,7 +1853,6 @@ int qcom_scm_shm_bridge_delete(u64 handle)return qcom_scm_call (__scm->dev, &desc,NULL ); } -EXPORT_SYMBOL_GPL (qcom_scm_shm_bridge_delete);int qcom_scm_lmh_profile_change (u32 profile_id) {
drivers/firmware/qcom/qcom_scm.h +4 -0
@@ -84,6 +84,10 @@ int scm_legacy_call(struct device *dev, const struct qcom_scm_desc *desc,struct qcom_tzmem_pool *qcom_scm_get_tzmem_pool (void );int qcom_scm_shm_bridge_enable (struct device *scm_dev); +int qcom_scm_shm_bridge_create (u64 pfn_and_ns_perm_flags, +u64 ipfn_and_s_perm_flags,u64 size_and_flags, +u64 ns_vmids,u64 *handle); +int qcom_scm_shm_bridge_delete (u64 handle);#define QCOM_SCM_SVC_BOOT 0x01#define QCOM_SCM_BOOT_SET_ADDR 0x01
include/linux/firmware/qcom/qcom_scm.h +0 -5
@@ -133,11 +133,6 @@ bool qcom_scm_lmh_dcvsh_available(void);int qcom_scm_gpu_init_regs (u32 gpu_req); -int qcom_scm_shm_bridge_create (u64 pfn_and_ns_perm_flags, -u64 ipfn_and_s_perm_flags,u64 size_and_flags, -u64 ns_vmids,u64 *handle); -int qcom_scm_shm_bridge_delete (u64 handle); -#ifdef CONFIG_QCOM_QSEECOM int qcom_scm_qseecom_app_get_id (const char *app_name,u32 *app_id);
Signature · 1 line
2.53.0
Quoted 37 lines · Sumit Garg
From: Sumit Garg <[email protected]>
qcom_scmandqcom_tzmemhave a mutual symbol dependency:qcom_tzmemcalls qcom_scm_shm_bridge_{enable,create,delete}() whileqcom_scmcalls qcom_tzmem_{alloc,free,to_phys}() andqcom_scm_get_tzmem_pool(). When both are built as modules this results in a circular module dependency and depmod fails:depmod: ERROR: Cycle detected:
qcom_scm->qcom_tzmem->qcom_scm
QCOM_TZMEMis an invisible tristate that is only ever selected byQCOM_SCM, so the two are always enabled together. Build qcom_tzmem.o as part of the qcom-scm composite module instead of as a separate module. This breaks the cycle since the mutual symbol references become intra-module.With tzmem now internal to qcom-scm, the
shm_bridgehelpers are no longer used outside the module, so drop theirEXPORT_SYMBOL_GPL()and move the declarations from the public header to the private one, alongsideqcom_scm_shm_bridge_enable().Reported-by kernel test robot <[email protected]>Assisted-by Copilot:claude-opus-4.8Signed-off-by Sumit Garg <[email protected]>--- drivers/firmware/qcom/Makefile | 2 +- drivers/firmware/qcom/qcom_scm.c | 3 --- drivers/firmware/qcom/qcom_scm.h | 4 ++++ include/linux/firmware/qcom/qcom_scm.h | 5 ----- 4 files changed, 5 insertions(+), 9 deletions(-)drivers/firmware/qcom/Makefile +0
-0
drivers/firmware/qcom/Makefile line 8
Quoted 5 lines
drivers/firmware/qcom/Makefile +1
-1@@ -5,7 +5,7 @@ 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 +qcom-scm-$(CONFIG_QCOM_TZMEM) += qcom_tzmem.o
Does it make sense to squash the kconfig entries too now?
Konrad
Quoted 40 lines · Konrad Dybcio
Quoted 38 lines · Sumit Garg
From: Sumit Garg <[email protected]>
qcom_scmandqcom_tzmemhave a mutual symbol dependency:qcom_tzmemcalls qcom_scm_shm_bridge_{enable,create,delete}() whileqcom_scmcalls qcom_tzmem_{alloc,free,to_phys}() andqcom_scm_get_tzmem_pool(). When both are built as modules this results in a circular module dependency and depmod fails:depmod: ERROR: Cycle detected:
qcom_scm->qcom_tzmem->qcom_scm
QCOM_TZMEMis an invisible tristate that is only ever selected byQCOM_SCM, so the two are always enabled together. Build qcom_tzmem.o as part of the qcom-scm composite module instead of as a separate module. This breaks the cycle since the mutual symbol references become intra-module.With tzmem now internal to qcom-scm, the
shm_bridgehelpers are no longer used outside the module, so drop theirEXPORT_SYMBOL_GPL()and move the declarations from the public header to the private one, alongsideqcom_scm_shm_bridge_enable().Reported-by kernel test robot <[email protected]>Assisted-by Copilot:claude-opus-4.8Signed-off-by Sumit Garg <[email protected]>--- drivers/firmware/qcom/Makefile | 2 +- drivers/firmware/qcom/qcom_scm.c | 3 --- drivers/firmware/qcom/qcom_scm.h | 4 ++++ include/linux/firmware/qcom/qcom_scm.h | 5 ----- 4 files changed, 5 insertions(+), 9 deletions(-)drivers/firmware/qcom/Makefile +0
-0@@ -5,7 +5,7 @@
Quoted 7 lines
drivers/firmware/qcom/Makefile line 8
Quoted 4 lines
drivers/firmware/qcom/Makefile +1
-1obj-$(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 +qcom-scm-$(CONFIG_QCOM_TZMEM) += qcom_tzmem.oDoes it make sense to squash the kconfig entries too now?
Sounds reasonable to me, I can do that for v2.
-Sumit
Hi,
Quoted 50 lines · Sumit Garg
Quoted 40 lines · Konrad Dybcio
Quoted 38 lines · Sumit Garg
From: Sumit Garg <[email protected]>
qcom_scmandqcom_tzmemhave a mutual symbol dependency:qcom_tzmemcalls qcom_scm_shm_bridge_{enable,create,delete}() whileqcom_scmcalls qcom_tzmem_{alloc,free,to_phys}() andqcom_scm_get_tzmem_pool(). When both are built as modules this results in a circular module dependency and depmod fails:depmod: ERROR: Cycle detected:
qcom_scm->qcom_tzmem->qcom_scm
QCOM_TZMEMis an invisible tristate that is only ever selected byQCOM_SCM, so the two are always enabled together. Build qcom_tzmem.o as part of the qcom-scm composite module instead of as a separate module. This breaks the cycle since the mutual symbol references become intra-module.With tzmem now internal to qcom-scm, the
shm_bridgehelpers are no longer used outside the module, so drop theirEXPORT_SYMBOL_GPL()and move the declarations from the public header to the private one, alongsideqcom_scm_shm_bridge_enable().Reported-by kernel test robot <[email protected]>Assisted-by Copilot:claude-opus-4.8Signed-off-by Sumit Garg <[email protected]>--- drivers/firmware/qcom/Makefile | 2 +- drivers/firmware/qcom/qcom_scm.c | 3 --- drivers/firmware/qcom/qcom_scm.h | 4 ++++ include/linux/firmware/qcom/qcom_scm.h | 5 ----- 4 files changed, 5 insertions(+), 9 deletions(-)drivers/firmware/qcom/Makefile +0
-0@@ -5,7 +5,7 @@Quoted 7 lines
drivers/firmware/qcom/Makefile line 8
Quoted 4 lines
drivers/firmware/qcom/Makefile +1
-1obj-$(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 +qcom-scm-$(CONFIG_QCOM_TZMEM) += qcom_tzmem.oDoes it make sense to squash the kconfig entries too now?
Quoted 1 line
Sounds reasonable to me, I can do that for v2.
What kind of squash are we thinking about here? Moving the TZMEM_MODE* choice to QCOM_SCM and removing QCOM_TZMEM? I think we should keep the QCOM_TZMEM Kconfig around for when we boot with OPTEE and want to disable TZMEM since SHMBridge is QTEE specific.
Regards,
Harshal
Quoted 2 lines
-Sumit
Quoted 8 lines · Harshal Dev
Hi,
Quoted 5 lines · Sumit Garg
Quoted 3 lines · Konrad Dybcio
Quoted 1 line · Sumit Garg
From: Sumit Garg <[email protected]>
[...]
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
drivers/firmware/qcom/Makefile line 8
Quoted 8 lines
drivers/firmware/qcom/Makefile +1
-1@@ -5,7 +5,7 @@ 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 +qcom-scm-$(CONFIG_QCOM_TZMEM) += qcom_tzmem.oDoes it make sense to squash the kconfig entries too now?
Quoted 6 lines
Quoted 1 line
Sounds reasonable to me, I can do that for v2.
What kind of squash are we thinking about here? Moving the TZMEM_MODE* choice to
QCOM_SCMand removingQCOM_TZMEM? I think we should keep theQCOM_TZMEMKconfigaround for when we boot with OPTEE and want to disable TZMEM since SHMBridge is QTEE specific.
Hmm, fair.
Konrad
Harshal Dev
Reviewed-byHi Sumit,
Quoted 24 lines · Konrad Dybcio
Quoted 8 lines · Harshal Dev
Hi,
Quoted 5 lines · Sumit Garg
Quoted 3 lines · Konrad Dybcio
Quoted 1 line · Sumit Garg
From: Sumit Garg <[email protected]>
[...]
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
drivers/firmware/qcom/Makefile line 8
Quoted 8 lines
drivers/firmware/qcom/Makefile +1
-1@@ -5,7 +5,7 @@ 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 +qcom-scm-$(CONFIG_QCOM_TZMEM) += qcom_tzmem.oDoes it make sense to squash the kconfig entries too now?
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Sounds reasonable to me, I can do that for v2.
What kind of squash are we thinking about here? Moving the TZMEM_MODE* choice to
QCOM_SCMand removingQCOM_TZMEM? I think we should keep theQCOM_TZMEMKconfigaround for when we boot with OPTEE and want to disable TZMEM since SHMBridge is QTEE specific.Hmm, fair.
If you are aligned with not performing any Kconfig squashes for now feel free to add my tag:
Regards,
Harshal
Quoted 2 lines
Konrad
Quoted 35 lines · Harshal Dev
Hi Sumit,
Quoted 31 lines · Konrad Dybcio
Quoted 8 lines · Harshal Dev
Hi,
Quoted 5 lines · Sumit Garg
Quoted 3 lines · Konrad Dybcio
Quoted 1 line · Sumit Garg
From: Sumit Garg <[email protected]>
[...]
Quoted 18 lines
Quoted 12 lines
Quoted 11 lines
drivers/firmware/qcom/Makefile line 8
Quoted 8 lines
drivers/firmware/qcom/Makefile +1
-1@@ -5,7 +5,7 @@ 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 +qcom-scm-$(CONFIG_QCOM_TZMEM) += qcom_tzmem.oDoes it make sense to squash the kconfig entries too now?
Quoted 1 line
Sounds reasonable to me, I can do that for v2.
What kind of squash are we thinking about here? Moving the TZMEM_MODE* choice to
QCOM_SCMand removingQCOM_TZMEM? I think we should keep theQCOM_TZMEMKconfigaround for when we boot with OPTEE and want to disable TZMEM since SHMBridge is QTEE specific.
Quoted 6 lines
Quoted 1 line
Hmm, fair.
If you are aligned with not performing any
Kconfigsquashes for now feel free to add my tag:Reviewed-by Harshal Dev <[email protected]>
Thanks, I don't have any v2 plan for this until I get any further comments to address.
-Sumit
Hey Bjorn,
Quoted 26 lines · Sumit Garg
From: Sumit Garg <[email protected]>
qcom_scmandqcom_tzmemhave a mutual symbol dependency:qcom_tzmemcalls qcom_scm_shm_bridge_{enable,create,delete}() whileqcom_scmcalls qcom_tzmem_{alloc,free,to_phys}() andqcom_scm_get_tzmem_pool(). When both are built as modules this results in a circular module dependency and depmod fails:depmod: ERROR: Cycle detected:
qcom_scm->qcom_tzmem->qcom_scm
QCOM_TZMEMis an invisible tristate that is only ever selected byQCOM_SCM, so the two are always enabled together. Build qcom_tzmem.o as part of the qcom-scm composite module instead of as a separate module. This breaks the cycle since the mutual symbol references become intra-module.With tzmem now internal to qcom-scm, the
shm_bridgehelpers are no longer used outside the module, so drop theirEXPORT_SYMBOL_GPL()and move the declarations from the public header to the private one, alongsideqcom_scm_shm_bridge_enable().Reported-by kernel test robot <[email protected]>Assisted-by Copilot:claude-opus-4.8Signed-off-by Sumit Garg <[email protected]>
Quoted 6 lines
--- drivers/firmware/qcom/Makefile | 2 +- drivers/firmware/qcom/qcom_scm.c | 3 --- drivers/firmware/qcom/qcom_scm.h | 4 ++++ include/linux/firmware/qcom/qcom_scm.h | 5 ----- 4 files changed, 5 insertions(+), 9 deletions(-)
Can you pick this fix for v7.3?
-Sumit
Quoted 76 lines
drivers/firmware/qcom/Makefile +1
-1@@ -5,7 +5,7 @@ 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 +qcom-scm-$(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.odrivers/firmware/qcom/qcom_scm.c +0
-3@@ -1813,7 +1813,6 @@ int qcom_scm_shm_bridge_enable(struct device *scm_dev)return res.result[0 ]; } -EXPORT_SYMBOL_GPL (qcom_scm_shm_bridge_enable); int qcom_scm_shm_bridge_create(u64 pfn_and_ns_perm_flags, u64 ipfn_and_s_perm_flags, u64 size_and_flags,@@ -1841,7 +1840,6 @@ int qcom_scm_shm_bridge_create(u64 pfn_and_ns_perm_flags,return ret ?: res.result[0 ]; } -EXPORT_SYMBOL_GPL (qcom_scm_shm_bridge_create);int qcom_scm_shm_bridge_delete (u64 handle) {@@ -1855,7 +1853,6 @@ int qcom_scm_shm_bridge_delete(u64 handle)return qcom_scm_call (__scm->dev, &desc,NULL ); } -EXPORT_SYMBOL_GPL (qcom_scm_shm_bridge_delete);int qcom_scm_lmh_profile_change (u32 profile_id) {drivers/firmware/qcom/qcom_scm.h +4
-0@@ -84,6 +84,10 @@ int scm_legacy_call(struct device *dev, const struct qcom_scm_desc *desc,struct qcom_tzmem_pool *qcom_scm_get_tzmem_pool (void );int qcom_scm_shm_bridge_enable (struct device *scm_dev); +int qcom_scm_shm_bridge_create (u64 pfn_and_ns_perm_flags, +u64 ipfn_and_s_perm_flags,u64 size_and_flags, +u64 ns_vmids,u64 *handle); +int qcom_scm_shm_bridge_delete (u64 handle);#define QCOM_SCM_SVC_BOOT 0x01#define QCOM_SCM_BOOT_SET_ADDR 0x01include/linux/firmware/qcom/qcom_scm.h +0
-6@@ -133,11 +133,6 @@ bool qcom_scm_lmh_dcvsh_available(void);int qcom_scm_gpu_init_regs (u32 gpu_req); -int qcom_scm_shm_bridge_create (u64 pfn_and_ns_perm_flags, -u64 ipfn_and_s_perm_flags,u64 size_and_flags, -u64 ns_vmids,u64 *handle); -int qcom_scm_shm_bridge_delete (u64 handle); -#ifdef CONFIG_QCOM_QSEECOM int qcom_scm_qseecom_app_get_id (const char *app_name,u32 *app_id); --2.53.0