The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] firmware: qcom: scm: fold tzmem into the qcom-scm module
@ 2026-07-13  4:58 Sumit Garg
  2026-07-13 10:37 ` Konrad Dybcio
  0 siblings, 1 reply; 3+ messages in thread
From: Sumit Garg @ 2026-07-13  4:58 UTC (permalink / raw)
  To: linux-arm-msm
  Cc: andersson, konradybcio, linux-kernel, bartosz.golaszewski,
	harshal.dev, Sumit Garg, kernel test robot

From: Sumit Garg <sumit.garg@oss.qualcomm.com>

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().

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202607122327.3zkZCUaB-lkp@intel.com/
Assisted-by: Copilot:claude-opus-4.8
Signed-off-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
---
 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(-)

diff --git a/drivers/firmware/qcom/Makefile b/drivers/firmware/qcom/Makefile
index 48801d18f37b..55751d282689 100644
--- a/drivers/firmware/qcom/Makefile
+++ b/drivers/firmware/qcom/Makefile
@@ -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
diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index 1deee6aea387..3495cd8af715 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -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)
 {
diff --git a/drivers/firmware/qcom/qcom_scm.h b/drivers/firmware/qcom/qcom_scm.h
index caab80a73e17..0e7cd1e31d6f 100644
--- a/drivers/firmware/qcom/qcom_scm.h
+++ b/drivers/firmware/qcom/qcom_scm.h
@@ -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
diff --git a/include/linux/firmware/qcom/qcom_scm.h b/include/linux/firmware/qcom/qcom_scm.h
index a0a6bc0229c4..b7d5f30876e1 100644
--- a/include/linux/firmware/qcom/qcom_scm.h
+++ b/include/linux/firmware/qcom/qcom_scm.h
@@ -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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] firmware: qcom: scm: fold tzmem into the qcom-scm module
  2026-07-13  4:58 [PATCH] firmware: qcom: scm: fold tzmem into the qcom-scm module Sumit Garg
@ 2026-07-13 10:37 ` Konrad Dybcio
  2026-07-13 11:35   ` Sumit Garg
  0 siblings, 1 reply; 3+ messages in thread
From: Konrad Dybcio @ 2026-07-13 10:37 UTC (permalink / raw)
  To: Sumit Garg, linux-arm-msm
  Cc: andersson, konradybcio, linux-kernel, bartosz.golaszewski,
	harshal.dev, Sumit Garg, kernel test robot

On 7/13/26 6:58 AM, Sumit Garg wrote:
> From: Sumit Garg <sumit.garg@oss.qualcomm.com>
> 
> 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().
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202607122327.3zkZCUaB-lkp@intel.com/
> Assisted-by: Copilot:claude-opus-4.8
> Signed-off-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
> ---
>  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(-)
> 
> diff --git a/drivers/firmware/qcom/Makefile b/drivers/firmware/qcom/Makefile
> index 48801d18f37b..55751d282689 100644
> --- a/drivers/firmware/qcom/Makefile
> +++ b/drivers/firmware/qcom/Makefile
> @@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] firmware: qcom: scm: fold tzmem into the qcom-scm module
  2026-07-13 10:37 ` Konrad Dybcio
@ 2026-07-13 11:35   ` Sumit Garg
  0 siblings, 0 replies; 3+ messages in thread
From: Sumit Garg @ 2026-07-13 11:35 UTC (permalink / raw)
  To: Konrad Dybcio
  Cc: Sumit Garg, linux-arm-msm, andersson, konradybcio, linux-kernel,
	bartosz.golaszewski, harshal.dev, kernel test robot

On Mon, Jul 13, 2026 at 4:07 PM Konrad Dybcio
<konrad.dybcio@oss.qualcomm.com> wrote:
>
> On 7/13/26 6:58 AM, Sumit Garg wrote:
> > From: Sumit Garg <sumit.garg@oss.qualcomm.com>
> >
> > 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().
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202607122327.3zkZCUaB-lkp@intel.com/
> > Assisted-by: Copilot:claude-opus-4.8
> > Signed-off-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
> > ---
> >  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(-)
> >
> > diff --git a/drivers/firmware/qcom/Makefile b/drivers/firmware/qcom/Makefile
> > index 48801d18f37b..55751d282689 100644
> > --- a/drivers/firmware/qcom/Makefile
> > +++ b/drivers/firmware/qcom/Makefile
> > @@ -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?
>

Sounds reasonable to me, I can do that for v2.

-Sumit

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-13 11:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-13  4:58 [PATCH] firmware: qcom: scm: fold tzmem into the qcom-scm module Sumit Garg
2026-07-13 10:37 ` Konrad Dybcio
2026-07-13 11:35   ` Sumit Garg

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