mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] tee: remove TZMEM_MODE_GENERIC
@ 2026-07-29 20:38 Julian Braha
  2026-07-29 20:44 ` Arnd Bergmann
  2026-08-04  4:29 ` Amirreza Zarrabi
  0 siblings, 2 replies; 4+ messages in thread
From: Julian Braha @ 2026-07-29 20:38 UTC (permalink / raw)
  To: amirreza.zarrabi, jenswi
  Cc: sumit.garg, arnd, geert+renesas, amirreza.zarrabi, op-tee,
	linux-kernel, quic_eberman, andersson, brgl, harshal.dev,
	Julian Braha

'select' does not work on config options in a 'choice', so currently it is
possible to enable QCOMTEE without QCOM_TZMEM_MODE_SHMBRIDGE, even though
this is needed at runtime.

There are no users of the generic allocator option,
QCOM_TZMEM_MODE_GENERIC, so let's remove it. Then, we can remove the
containing choice..endchoice, which allows the 'select' to work as
intended.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Julian Braha <julianbraha@gmail.com>
---
Changes since v1:
- remove TZMEM_MODE_GENERIC instead of removing the dead select

Link:
https://lore.kernel.org/all/20260715092539.18384-1-julianbraha@gmail.com/
---
 drivers/firmware/qcom/Kconfig      | 26 +++++---------------------
 drivers/firmware/qcom/qcom_tzmem.c | 21 ---------------------
 2 files changed, 5 insertions(+), 42 deletions(-)

diff --git a/drivers/firmware/qcom/Kconfig b/drivers/firmware/qcom/Kconfig
index c7f8413ab996..d99e09c5fa18 100644
--- a/drivers/firmware/qcom/Kconfig
+++ b/drivers/firmware/qcom/Kconfig
@@ -34,33 +34,17 @@ config QCOM_TZMEM
 	tristate
 	select GENERIC_ALLOCATOR
 
-choice
-	prompt "TrustZone interface memory allocator mode"
-	depends on QCOM_TZMEM
-	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.
-
 config QCOM_TZMEM_MODE_SHMBRIDGE
-	bool "SHM Bridge"
+	bool "TrustZone interface memory allocator: SHM Bridge"
+	depends on QCOM_TZMEM
 	help
-	  Use Qualcomm Shared Memory Bridge. The memory has the same alignment as
-	  in the 'Generic' allocator but is also explicitly marked as an SHM Bridge
-	  buffer.
+	  Use Qualcomm Shared Memory Bridge as memory allocator. The memory has the
+	  same alignment as in the 'Generic' allocator but is also explicitly marked
+	  as an SHM Bridge buffer.
 
 	  With this selected, all buffers passed to the TrustZone must be allocated
 	  using the TZMem allocator or else the TrustZone will refuse to use them.
 
-endchoice
-
 config QCOM_QSEECOM
 	bool "Qualcomm QSEECOM interface driver"
 	depends on QCOM_SCM=y
diff --git a/drivers/firmware/qcom/qcom_tzmem.c b/drivers/firmware/qcom/qcom_tzmem.c
index 0635cbeacfc8..5b3e5a3ad1ae 100644
--- a/drivers/firmware/qcom/qcom_tzmem.c
+++ b/drivers/firmware/qcom/qcom_tzmem.c
@@ -49,25 +49,6 @@ static struct device *qcom_tzmem_dev;
 static RADIX_TREE(qcom_tzmem_chunks, GFP_ATOMIC);
 static DEFINE_SPINLOCK(qcom_tzmem_chunks_lock);
 
-#if IS_ENABLED(CONFIG_QCOM_TZMEM_MODE_GENERIC)
-
-static int qcom_tzmem_init(void)
-{
-	return 0;
-}
-
-static int qcom_tzmem_init_area(struct qcom_tzmem_area *area)
-{
-	return 0;
-}
-
-static void qcom_tzmem_cleanup_area(struct qcom_tzmem_area *area)
-{
-
-}
-
-#elif IS_ENABLED(CONFIG_QCOM_TZMEM_MODE_SHMBRIDGE)
-
 #include <linux/firmware/qcom/qcom_scm.h>
 #include <linux/of.h>
 
@@ -189,8 +170,6 @@ static void qcom_tzmem_cleanup_area(struct qcom_tzmem_area *area)
 	kfree(handle);
 }
 
-#endif /* CONFIG_QCOM_TZMEM_MODE_SHMBRIDGE */
-
 static int qcom_tzmem_pool_add_memory(struct qcom_tzmem_pool *pool,
 				      size_t size, gfp_t gfp)
 {
-- 
2.55.0


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

* Re: [PATCH v2] tee: remove TZMEM_MODE_GENERIC
  2026-07-29 20:38 [PATCH v2] tee: remove TZMEM_MODE_GENERIC Julian Braha
@ 2026-07-29 20:44 ` Arnd Bergmann
  2026-08-04  4:29 ` Amirreza Zarrabi
  1 sibling, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2026-07-29 20:44 UTC (permalink / raw)
  To: Julian Braha, Amirreza Zarrabi, jenswi
  Cc: Sumit Garg, Geert Uytterhoeven, amirreza.zarrabi, op-tee,
	linux-kernel, Elliot Berman, Bjorn Andersson,
	Bartosz Golaszewski, Harshal Dev

On Wed, Jul 29, 2026, at 22:38, Julian Braha wrote:
> 'select' does not work on config options in a 'choice', so currently it is
> possible to enable QCOMTEE without QCOM_TZMEM_MODE_SHMBRIDGE, even though
> this is needed at runtime.
>
> There are no users of the generic allocator option,
> QCOM_TZMEM_MODE_GENERIC, so let's remove it. Then, we can remove the
> containing choice..endchoice, which allows the 'select' to work as
> intended.
>
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Julian Braha <julianbraha@gmail.com>

Looks good to me,

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

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

* Re: [PATCH v2] tee: remove TZMEM_MODE_GENERIC
  2026-07-29 20:38 [PATCH v2] tee: remove TZMEM_MODE_GENERIC Julian Braha
  2026-07-29 20:44 ` Arnd Bergmann
@ 2026-08-04  4:29 ` Amirreza Zarrabi
  2026-08-04  7:40   ` Arnd Bergmann
  1 sibling, 1 reply; 4+ messages in thread
From: Amirreza Zarrabi @ 2026-08-04  4:29 UTC (permalink / raw)
  To: Julian Braha, jenswi
  Cc: sumit.garg, arnd, geert+renesas, amirreza.zarrabi, op-tee,
	linux-kernel, quic_eberman, andersson, brgl, harshal.dev

Hi Julian,

With this change, is QCOM_TZMEM_MODE_SHMBRIDGE still needed?

I think QCOM_TZMEM_MODE_SHMBRIDGE can therefore be removed entirely,
along with the conditional declarations and stubs in qcom_tzmem.h and
the corresponding select in the qcomtee Kconfig.

Regards,
Amir

On 7/30/2026 6:38 AM, Julian Braha wrote:
> 'select' does not work on config options in a 'choice', so currently it is
> possible to enable QCOMTEE without QCOM_TZMEM_MODE_SHMBRIDGE, even though
> this is needed at runtime.
> 
> There are no users of the generic allocator option,
> QCOM_TZMEM_MODE_GENERIC, so let's remove it. Then, we can remove the
> containing choice..endchoice, which allows the 'select' to work as
> intended.
> 
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Julian Braha <julianbraha@gmail.com>
> ---
> Changes since v1:
> - remove TZMEM_MODE_GENERIC instead of removing the dead select
> 
> Link:
> https://lore.kernel.org/all/20260715092539.18384-1-julianbraha@gmail.com/
> ---
>  drivers/firmware/qcom/Kconfig      | 26 +++++---------------------
>  drivers/firmware/qcom/qcom_tzmem.c | 21 ---------------------
>  2 files changed, 5 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/firmware/qcom/Kconfig b/drivers/firmware/qcom/Kconfig
> index c7f8413ab996..d99e09c5fa18 100644
> --- a/drivers/firmware/qcom/Kconfig
> +++ b/drivers/firmware/qcom/Kconfig
> @@ -34,33 +34,17 @@ config QCOM_TZMEM
>  	tristate
>  	select GENERIC_ALLOCATOR
>  
> -choice
> -	prompt "TrustZone interface memory allocator mode"
> -	depends on QCOM_TZMEM
> -	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.
> -
>  config QCOM_TZMEM_MODE_SHMBRIDGE
> -	bool "SHM Bridge"
> +	bool "TrustZone interface memory allocator: SHM Bridge"
> +	depends on QCOM_TZMEM
>  	help
> -	  Use Qualcomm Shared Memory Bridge. The memory has the same alignment as
> -	  in the 'Generic' allocator but is also explicitly marked as an SHM Bridge
> -	  buffer.
> +	  Use Qualcomm Shared Memory Bridge as memory allocator. The memory has the
> +	  same alignment as in the 'Generic' allocator but is also explicitly marked
> +	  as an SHM Bridge buffer.
>  
>  	  With this selected, all buffers passed to the TrustZone must be allocated
>  	  using the TZMem allocator or else the TrustZone will refuse to use them.
>  
> -endchoice
> -
>  config QCOM_QSEECOM
>  	bool "Qualcomm QSEECOM interface driver"
>  	depends on QCOM_SCM=y
> diff --git a/drivers/firmware/qcom/qcom_tzmem.c b/drivers/firmware/qcom/qcom_tzmem.c
> index 0635cbeacfc8..5b3e5a3ad1ae 100644
> --- a/drivers/firmware/qcom/qcom_tzmem.c
> +++ b/drivers/firmware/qcom/qcom_tzmem.c
> @@ -49,25 +49,6 @@ static struct device *qcom_tzmem_dev;
>  static RADIX_TREE(qcom_tzmem_chunks, GFP_ATOMIC);
>  static DEFINE_SPINLOCK(qcom_tzmem_chunks_lock);
>  
> -#if IS_ENABLED(CONFIG_QCOM_TZMEM_MODE_GENERIC)
> -
> -static int qcom_tzmem_init(void)
> -{
> -	return 0;
> -}
> -
> -static int qcom_tzmem_init_area(struct qcom_tzmem_area *area)
> -{
> -	return 0;
> -}
> -
> -static void qcom_tzmem_cleanup_area(struct qcom_tzmem_area *area)
> -{
> -
> -}
> -
> -#elif IS_ENABLED(CONFIG_QCOM_TZMEM_MODE_SHMBRIDGE)
> -
>  #include <linux/firmware/qcom/qcom_scm.h>
>  #include <linux/of.h>
>  
> @@ -189,8 +170,6 @@ static void qcom_tzmem_cleanup_area(struct qcom_tzmem_area *area)
>  	kfree(handle);
>  }
>  
> -#endif /* CONFIG_QCOM_TZMEM_MODE_SHMBRIDGE */
> -
>  static int qcom_tzmem_pool_add_memory(struct qcom_tzmem_pool *pool,
>  				      size_t size, gfp_t gfp)
>  {


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

* Re: [PATCH v2] tee: remove TZMEM_MODE_GENERIC
  2026-08-04  4:29 ` Amirreza Zarrabi
@ 2026-08-04  7:40   ` Arnd Bergmann
  0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2026-08-04  7:40 UTC (permalink / raw)
  To: Amirreza Zarrabi, Julian Braha, jenswi
  Cc: Sumit Garg, Geert Uytterhoeven, amirreza.zarrabi, op-tee,
	linux-kernel, Elliot Berman, Bjorn Andersson,
	Bartosz Golaszewski, Harshal Dev

On Tue, Aug 4, 2026, at 06:29, Amirreza Zarrabi wrote:
> Hi Julian,
>
> With this change, is QCOM_TZMEM_MODE_SHMBRIDGE still needed?
>
> I think QCOM_TZMEM_MODE_SHMBRIDGE can therefore be removed entirely,
> along with the conditional declarations and stubs in qcom_tzmem.h and
> the corresponding select in the qcomtee Kconfig.

Looking at it again, I see that the patch does not actually do
what I had expected. As you say the option no longer has any
effect at all, when I thought the tzmem driver would just default
back to generic mode without shmbridge being enabled.

What we probably want here is to change it to

#ifndef CONFIG_QCOM_TZMEM_MODE_SHMBRIDGE
   ...
#else
   ...
#endif

to keep the behavior unchanged and just fix the Kconfig logic.

    Arnd

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

end of thread, other threads:[~2026-08-04  7:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-29 20:38 [PATCH v2] tee: remove TZMEM_MODE_GENERIC Julian Braha
2026-07-29 20:44 ` Arnd Bergmann
2026-08-04  4:29 ` Amirreza Zarrabi
2026-08-04  7:40   ` Arnd Bergmann

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®