Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: ufs: rpmb: register and unregister the ufs_rpmb bus
@ 2026-09-20 14:50 Dmitry Baryshkov
  2026-09-20 14:59 ` sashiko-bot
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Dmitry Baryshkov @ 2026-09-20 14:50 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, Bart Van Assche, James E.J. Bottomley,
	Martin K. Petersen, Can Guo, Bean Huo
  Cc: linux-scsi, linux-kernel, linux-arm-msm

The ufs_rpmb bus isn't registered in the device framework, so any
attempt to register RPMB devices on UFS will fail with:

 bus_add_device: cannot add device 'ufs_rpmb0' to unregistered bus 'ufs_rpmb'
 ufshcd-qcom 1d84000.ufshc: Failed to register UFS RPMB device 0

Add module_init() / exit() functions to handle bus registration and
unregistration.

Fixes: b06b8c421485 ("scsi: ufs: core: Add OP-TEE based RPMB driver for UFS devices")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
 drivers/ufs/core/ufs-rpmb.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/ufs/core/ufs-rpmb.c b/drivers/ufs/core/ufs-rpmb.c
index 50ef63afd528..8ae917adbc98 100644
--- a/drivers/ufs/core/ufs-rpmb.c
+++ b/drivers/ufs/core/ufs-rpmb.c
@@ -275,5 +275,18 @@ void ufs_rpmb_remove(struct ufs_hba *hba)
 	dev_info(hba->dev, "All UFS RPMB devices unregistered\n");
 }
 
+static int __init ufs_rpmb_init(void)
+{
+	return bus_register(&ufs_rpmb_bus_type);
+}
+
+static void __exit ufs_rpmb_exit(void)
+{
+	bus_unregister(&ufs_rpmb_bus_type);
+}
+
+module_init(ufs_rpmb_init);
+module_exit(ufs_rpmb_exit);
+
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("OP-TEE UFS RPMB driver");

---
base-commit: 3f2425f5b5bbbdd991ca9cdfd5502e68d8895998
change-id: 20260511-fix-ufs-rpmb-487d73d091b7

Best regards,
--  
With best wishes
Dmitry


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

* Re: [PATCH] scsi: ufs: rpmb: register and unregister the ufs_rpmb bus
  2026-09-20 14:50 [PATCH] scsi: ufs: rpmb: register and unregister the ufs_rpmb bus Dmitry Baryshkov
@ 2026-09-20 14:59 ` sashiko-bot
  2026-09-20 17:05 ` Stanley Jhu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-09-20 14:59 UTC (permalink / raw)
  To: Dmitry Baryshkov; +Cc: linux-scsi

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] scsi: ufs: multiple module_init definitions cause linker error in ufshcd-core
--

commit c4238766f6e56be8464c4760e2cccf9cdc5bd928
Author: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>

scsi: ufs: rpmb: register and unregister the ufs_rpmb bus

This patch adds module_init() and module_exit() functions to handle
ufs_rpmb bus registration and unregistration, fixing an issue where
attempting to register RPMB devices fails because the bus is unregistered.

> diff --git a/drivers/ufs/core/ufs-rpmb.c b/drivers/ufs/core/ufs-rpmb.c
> index 50ef63afd5283..8ae917adbc98b 100644
> --- a/drivers/ufs/core/ufs-rpmb.c
> +++ b/drivers/ufs/core/ufs-rpmb.c
[ ... ]
> @@ -275,5 +275,18 @@ void ufs_rpmb_remove(struct ufs_hba *hba)
>  	dev_info(hba->dev, "All UFS RPMB devices unregistered\n");
>  }
>  
> +static int __init ufs_rpmb_init(void)
> +{
> +	return bus_register(&ufs_rpmb_bus_type);
> +}
> +
> +static void __exit ufs_rpmb_exit(void)
> +{
> +	bus_unregister(&ufs_rpmb_bus_type);
> +}
> +
> +module_init(ufs_rpmb_init);
> +module_exit(ufs_rpmb_exit);

[Severity: Low]
Does this cause a build failure when built as a loadable module?

The ufs-rpmb.c file is compiled and linked directly into the composite
ufshcd-core module when CONFIG_SCSI_UFSHCD=m and CONFIG_RPMB are enabled:

drivers/ufs/core/Makefile:
    ufshcd-core-$(CONFIG_RPMB) += ufs-rpmb.o

However, drivers/ufs/core/ufshcd.c already contains the module_init hook
for the ufshcd-core module with module_init(ufshcd_core_init).

Because module_init() expands to a global alias for init_module, combining
multiple object files with their own module_init() declarations into a single
loadable kernel module produces a fatal linker error due to multiple
definitions.

Could the bus registration be handled by calling ufs_rpmb_init() directly
from ufshcd_core_init() instead?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260920-fix-tcpm-vbus-bis-v1-0-bc9a7c72e5d0@oss.qualcomm.com?part=1

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

* Re: [PATCH] scsi: ufs: rpmb: register and unregister the ufs_rpmb bus
  2026-09-20 14:50 [PATCH] scsi: ufs: rpmb: register and unregister the ufs_rpmb bus Dmitry Baryshkov
  2026-09-20 14:59 ` sashiko-bot
@ 2026-09-20 17:05 ` Stanley Jhu
  2026-09-25 22:36 ` kernel test robot
  2026-09-26  1:49 ` kernel test robot
  3 siblings, 0 replies; 5+ messages in thread
From: Stanley Jhu @ 2026-09-20 17:05 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Stanley Jhu, Alim Akhtar, Avri Altman, Bart Van Assche,
	James E.J. Bottomley, Martin K. Petersen, Can Guo, Bean Huo,
	Jens Wiklander, linux-scsi, linux-kernel, linux-arm-msm

On Sun, 20 Sep 2026 17:50:18 +0300, Dmitry Baryshkov wrote:
> The ufs_rpmb bus isn't registered in the device framework, so any
> attempt to register RPMB devices on UFS will fail with:
>
>  bus_add_device: cannot add device 'ufs_rpmb0' to unregistered bus 'ufs_rpmb'
>  ufshcd-qcom 1d84000.ufshc: Failed to register UFS RPMB device 0
>
> Add module_init() / exit() functions to handle bus registration and
> unregistration.

We have an existing patch on the list addressing this from the opposite
direction (`[PATCH v5 3/3]`, Reviewed-by Bean Huo) [1]:

Since ufs_rpmb_bus_type declares no .match and no .probe and consumers
access RPMB devices via /sys/class/rpmb/, patch 3/3 drops
ufs_rpmb_bus_type (leaving ufs_rpmb->dev.bus NULL) rather than
registering an empty bus.

Could you take a look at [1] and let us know which approach you prefer?

[1] https://lore.kernel.org/linux-scsi/20260914144943.2571104-1-stanleyjhu@google.com/

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

* Re: [PATCH] scsi: ufs: rpmb: register and unregister the ufs_rpmb bus
  2026-09-20 14:50 [PATCH] scsi: ufs: rpmb: register and unregister the ufs_rpmb bus Dmitry Baryshkov
  2026-09-20 14:59 ` sashiko-bot
  2026-09-20 17:05 ` Stanley Jhu
@ 2026-09-25 22:36 ` kernel test robot
  2026-09-26  1:49 ` kernel test robot
  3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-09-25 22:36 UTC (permalink / raw)
  To: Dmitry Baryshkov, Alim Akhtar, Avri Altman, Bart Van Assche,
	James E.J. Bottomley, Martin K. Petersen, Can Guo, Bean Huo
  Cc: oe-kbuild-all, linux-scsi, linux-kernel, linux-arm-msm

Hi Dmitry,

kernel test robot noticed the following build errors:

[auto build test ERROR on 3f2425f5b5bbbdd991ca9cdfd5502e68d8895998]

url:    https://github.com/intel-lab-lkp/linux/commits/Dmitry-Baryshkov/scsi-ufs-rpmb-register-and-unregister-the-ufs_rpmb-bus/20260920-175018
base:   3f2425f5b5bbbdd991ca9cdfd5502e68d8895998
patch link:    https://lore.kernel.org/r/20260920-fix-ufs-rpmb-v1-1-560b842c589d%40oss.qualcomm.com
patch subject: [PATCH] scsi: ufs: rpmb: register and unregister the ufs_rpmb bus
config: sparc64-randconfig-1001-20260926 (https://download.01.org/0day-ci/archive/20260926/202609260636.G8CEOXSF-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 9.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260926/202609260636.G8CEOXSF-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202609260636.G8CEOXSF-lkp@intel.com/

All errors (new ones prefixed by >>):

   sparc64-linux-ld: drivers/ufs/core/ufs-rpmb.o: in function `ufs_rpmb_init':
>> ufs-rpmb.c:(.init.text+0x0): multiple definition of `init_module'; drivers/ufs/core/ufshcd.o:ufshcd.c:(.init.text+0x0): first defined here
   sparc64-linux-ld: drivers/ufs/core/ufs-rpmb.o: in function `ufs_rpmb_exit':
>> ufs-rpmb.c:(.exit.text+0x0): multiple definition of `cleanup_module'; drivers/ufs/core/ufshcd.o:ufshcd.c:(.exit.text+0x0): first defined here

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH] scsi: ufs: rpmb: register and unregister the ufs_rpmb bus
  2026-09-20 14:50 [PATCH] scsi: ufs: rpmb: register and unregister the ufs_rpmb bus Dmitry Baryshkov
                   ` (2 preceding siblings ...)
  2026-09-25 22:36 ` kernel test robot
@ 2026-09-26  1:49 ` kernel test robot
  3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-09-26  1:49 UTC (permalink / raw)
  To: Dmitry Baryshkov, Alim Akhtar, Avri Altman, Bart Van Assche,
	James E.J. Bottomley, Martin K. Petersen, Can Guo, Bean Huo
  Cc: oe-kbuild-all, linux-scsi, linux-kernel, linux-arm-msm

Hi Dmitry,

kernel test robot noticed the following build errors:

[auto build test ERROR on 3f2425f5b5bbbdd991ca9cdfd5502e68d8895998]

url:    https://github.com/intel-lab-lkp/linux/commits/Dmitry-Baryshkov/scsi-ufs-rpmb-register-and-unregister-the-ufs_rpmb-bus/20260920-175018
base:   3f2425f5b5bbbdd991ca9cdfd5502e68d8895998
patch link:    https://lore.kernel.org/r/20260920-fix-ufs-rpmb-v1-1-560b842c589d%40oss.qualcomm.com
patch subject: [PATCH] scsi: ufs: rpmb: register and unregister the ufs_rpmb bus
config: arc-randconfig-1001-20260926 (https://download.01.org/0day-ci/archive/20260926/202609260913.FY1vuM99-lkp@intel.com/config)
compiler: arc-linux-gcc (GCC) 12.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260926/202609260913.FY1vuM99-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202609260913.FY1vuM99-lkp@intel.com/

All errors (new ones prefixed by >>):

   arc-linux-ld: drivers/ufs/core/ufs-rpmb.o: in function `ufs_rpmb_init':
>> drivers/ufs/core/ufs-rpmb.c:280: multiple definition of `init_module'; drivers/ufs/core/ufshcd.o:drivers/ufs/core/ufshcd.c:11609: first defined here
   arc-linux-ld: drivers/ufs/core/ufs-rpmb.o: in function `ufs_rpmb_exit':
>> drivers/ufs/core/ufs-rpmb.c:285: multiple definition of `cleanup_module'; drivers/ufs/core/ufshcd.o:drivers/ufs/core/ufshcd.c:11623: first defined here


vim +280 drivers/ufs/core/ufs-rpmb.c

   277	
   278	static int __init ufs_rpmb_init(void)
   279	{
 > 280		return bus_register(&ufs_rpmb_bus_type);
   281	}
   282	
   283	static void __exit ufs_rpmb_exit(void)
   284	{
 > 285		bus_unregister(&ufs_rpmb_bus_type);
   286	}
   287	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2026-09-26  1:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-20 14:50 [PATCH] scsi: ufs: rpmb: register and unregister the ufs_rpmb bus Dmitry Baryshkov
2026-09-20 14:59 ` sashiko-bot
2026-09-20 17:05 ` Stanley Jhu
2026-09-25 22:36 ` kernel test robot
2026-09-26  1:49 ` kernel test robot

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