Skip to contentSkip to conversation

firmware: arm_scmi: Enable building SCMI as module

PATCH Applied Sudeep Holla 2 participants 10 messages Sep 7, 2020 – Sep 14, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover firmware: arm_scmi: Enable building SCMI as module

Hi,

Though it was initially developed as module, so some reason(I can't recollect why apart from some structuring arounf the way bus and protocols were initialised), it was merged as a built-in only driver.

Now, there is a need to build this as modules. This is mainly needed by virtio transport. This also aligns well with GKI modularisation efforts.

Regards,
Sudeep

v1[1]->v2:
- Added missing smccc functions exports
- Moved scmi_driver_init to subsys_initcall
- Reorder exit function calls
- Renamed protocol_init/exit to register/unregister
- Rebased on [2]

[1] https://lore.kernel.org/r/[email protected]/
[2] git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux.git for-next/scmi (contains system protocol implementation)

Sudeep Holla (4):
firmware: smccc: export both smccc functions
firmware: arm_scmi: Move scmi bus init and exit calls into the driver
firmware: arm_scmi: Move scmi protocols registration into the driver
firmware: arm_scmi: Enable building as a single module

 drivers/firmware/Kconfig            |  2 +-
 drivers/firmware/Makefile           |  2 +-
 drivers/firmware/arm_scmi/Makefile  |  4 +++-
 drivers/firmware/arm_scmi/bus.c     |  6 ++----
 drivers/firmware/arm_scmi/clock.c   |  7 +------
 drivers/firmware/arm_scmi/common.h  | 24 +++++++++++++++++++++++
 drivers/firmware/arm_scmi/driver.c  | 30 ++++++++++++++++++++++++++++-
 drivers/firmware/arm_scmi/perf.c    |  7 +------
 drivers/firmware/arm_scmi/power.c   |  7 +------
 drivers/firmware/arm_scmi/reset.c   |  7 +------
 drivers/firmware/arm_scmi/sensors.c |  7 +------
 drivers/firmware/arm_scmi/system.c  |  7 +------
 drivers/firmware/smccc/smccc.c      |  2 ++
 include/linux/scmi_protocol.h       |  2 +-
 14 files changed, 69 insertions(+), 45 deletions(-)

--
2.17.1

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#1 lore raw

PATCH v2 1/4 firmware: smccc: export both smccc functions

We need to export both arm_smccc_1_1_get_conduit and arm_smccc_get_version to allow several modules make use of them. Arm FFA, Arm SCMI and PTP drivers are few drivers that are planning to use these functions.

Let us export them in preparation to add support for SCMI as module.

---
 drivers/firmware/smccc/smccc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/firmware/smccc/smccc.c +2 -0
index 4e80921ee212..00c88b809c0c 100644
@@ -24,8 +24,10 @@ enum arm_smccc_conduit arm_smccc_1_1_get_conduit(void)
 
 	return smccc_conduit;
 }
+EXPORT_SYMBOL_GPL(arm_smccc_1_1_get_conduit);
 
 u32 arm_smccc_get_version(void)
 {
 	return smccc_version;
 }
+EXPORT_SYMBOL_GPL(arm_smccc_get_version);
Signature · 7 lines
2.17.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#2 lore raw

PATCH v2 2/4 firmware: arm_scmi: Move scmi bus init and exit calls into the driver

In reply to Sudeep Holla

In preparation to enable building scmi as a single module, let us move the scmi bus {de-,}initialisation call into the driver.

The main reason for this is to keep it simple instead of maintaining it as separate modules and dealing with all possible initcall races and deferred probe handling. We can move it as separate modules if needed in future.

---
 drivers/firmware/arm_scmi/bus.c    |  6 ++----
 drivers/firmware/arm_scmi/common.h |  3 +++
 drivers/firmware/arm_scmi/driver.c | 16 +++++++++++++++-
 3 files changed, 20 insertions(+), 5 deletions(-)
drivers/firmware/arm_scmi/bus.c +2 -4
index db55c43a2cbd..1377ec76a45d 100644
@@ -230,7 +230,7 @@ static void scmi_devices_unregister(void)
 	bus_for_each_dev(&scmi_bus_type, NULL, NULL, __scmi_devices_unregister);
 }
 
-static int __init scmi_bus_init(void)
+int __init scmi_bus_init(void)
 {
 	int retval;
 
@@ -240,12 +240,10 @@ static int __init scmi_bus_init(void)
 
 	return retval;
 }
-subsys_initcall(scmi_bus_init);
 
-static void __exit scmi_bus_exit(void)
+void __exit scmi_bus_exit(void)
 {
 	scmi_devices_unregister();
 	bus_unregister(&scmi_bus_type);
 	ida_destroy(&scmi_bus_id);
 }
-module_exit(scmi_bus_exit);
drivers/firmware/arm_scmi/common.h +3 -0
index 233700a42bff..a940c6cf1e51 100644
@@ -156,6 +156,9 @@ void scmi_setup_protocol_implemented(const struct scmi_handle *handle,
 
 int scmi_base_protocol_init(struct scmi_handle *h);
 
+int __init scmi_bus_init(void);
+void __exit scmi_bus_exit(void);
+
 /* SCMI Transport */
 /**
  * struct scmi_chan_info - Structure representing a SCMI channel information
drivers/firmware/arm_scmi/driver.c +15 -1
index dbec34423f72..b293ee1f25f7 100644
@@ -929,7 +929,21 @@ static struct platform_driver scmi_driver = {
 	.remove = scmi_remove,
 };
 
-module_platform_driver(scmi_driver);
+static int __init scmi_driver_init(void)
+{
+	scmi_bus_init();
+
+	return platform_driver_register(&scmi_driver);
+}
+module_init(scmi_driver_init);
+
+static void __exit scmi_driver_exit(void)
+{
+	platform_driver_unregister(&scmi_driver);
+
+	scmi_bus_exit();
+}
+module_exit(scmi_driver_exit);
 
 MODULE_ALIAS("platform: arm-scmi");
 MODULE_AUTHOR("Sudeep Holla <[email protected]>");
Signature · 7 lines
2.17.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#3 lore raw

PATCH v2 3/4 firmware: arm_scmi: Move scmi protocols registration into the driver

In reply to Sudeep Holla

In preparation to enable building SCMI as a single module, let us move the SCMI protocol registration call into the driver. This enables us to also add unregistration of the SCMI protocols.

The main reason for this is to keep it simple instead of maintaining it as separate modules and dealing with all possible initcall races and deferred probe handling. We can move it as separate modules if needed in future.

---
 drivers/firmware/arm_scmi/clock.c   |  7 +------
 drivers/firmware/arm_scmi/common.h  | 21 +++++++++++++++++++++
 drivers/firmware/arm_scmi/driver.c  | 16 +++++++++++++++-
 drivers/firmware/arm_scmi/perf.c    |  7 +------
 drivers/firmware/arm_scmi/power.c   |  7 +------
 drivers/firmware/arm_scmi/reset.c   |  7 +------
 drivers/firmware/arm_scmi/sensors.c |  7 +------
 drivers/firmware/arm_scmi/system.c  |  7 +------
 8 files changed, 42 insertions(+), 37 deletions(-)
drivers/firmware/arm_scmi/clock.c +1 -6
index a3b90be28009..c1cfe3ee3d55 100644
@@ -364,9 +364,4 @@ static int scmi_clock_protocol_init(struct scmi_handle *handle)
 	return 0;
 }
 
-static int __init scmi_clock_init(void)
-{
-	return scmi_protocol_register(SCMI_PROTOCOL_CLOCK,
-				      &scmi_clock_protocol_init);
-}
-subsys_initcall(scmi_clock_init);
+DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(SCMI_PROTOCOL_CLOCK, clock)
drivers/firmware/arm_scmi/common.h +21 -0
index a940c6cf1e51..37fb583f1bf5 100644
@@ -159,6 +159,27 @@ int scmi_base_protocol_init(struct scmi_handle *h);
 int __init scmi_bus_init(void);
 void __exit scmi_bus_exit(void);
 
+#define DECLARE_SCMI_REGISTER_UNREGISTER(func)		\
+	int __init scmi_##func##_register(void);	\
+	void __exit scmi_##func##_unregister(void)
+DECLARE_SCMI_REGISTER_UNREGISTER(clock);
+DECLARE_SCMI_REGISTER_UNREGISTER(perf);
+DECLARE_SCMI_REGISTER_UNREGISTER(power);
+DECLARE_SCMI_REGISTER_UNREGISTER(reset);
+DECLARE_SCMI_REGISTER_UNREGISTER(sensors);
+DECLARE_SCMI_REGISTER_UNREGISTER(system);
+
+#define DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(id, name) \
+int __init scmi_##name##_register(void) \
+{ \
+	return scmi_protocol_register((id), &scmi_##name##_protocol_init); \
+} \
+\
+void __exit scmi_##name##_unregister(void) \
+{ \
+	scmi_protocol_unregister((id)); \
+}
+
 /* SCMI Transport */
 /**
  * struct scmi_chan_info - Structure representing a SCMI channel information
drivers/firmware/arm_scmi/driver.c +15 -1
index b293ee1f25f7..98b03f9dfc6c 100644
@@ -933,14 +933,28 @@ static int __init scmi_driver_init(void)
 {
 	scmi_bus_init();
 
+	scmi_clock_register();
+	scmi_perf_register();
+	scmi_power_register();
+	scmi_reset_register();
+	scmi_sensors_register();
+	scmi_system_register();
+
 	return platform_driver_register(&scmi_driver);
 }
-module_init(scmi_driver_init);
+subsys_initcall(scmi_driver_init);
 
 static void __exit scmi_driver_exit(void)
 {
 	platform_driver_unregister(&scmi_driver);
 
+	scmi_clock_unregister();
+	scmi_perf_unregister();
+	scmi_power_unregister();
+	scmi_reset_unregister();
+	scmi_sensors_unregister();
+	scmi_system_unregister();
+
 	scmi_bus_exit();
 }
 module_exit(scmi_driver_exit);
drivers/firmware/arm_scmi/perf.c +1 -6
index a3e7b1bfab00..ed475b40bd08 100644
@@ -890,9 +890,4 @@ static int scmi_perf_protocol_init(struct scmi_handle *handle)
 	return 0;
 }
 
-static int __init scmi_perf_init(void)
-{
-	return scmi_protocol_register(SCMI_PROTOCOL_PERF,
-				      &scmi_perf_protocol_init);
-}
-subsys_initcall(scmi_perf_init);
+DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(SCMI_PROTOCOL_PERF, perf)
drivers/firmware/arm_scmi/power.c +1 -6
index 32bcf5821ea9..1f37258e9bee 100644
@@ -301,9 +301,4 @@ static int scmi_power_protocol_init(struct scmi_handle *handle)
 	return 0;
 }
 
-static int __init scmi_power_init(void)
-{
-	return scmi_protocol_register(SCMI_PROTOCOL_POWER,
-				      &scmi_power_protocol_init);
-}
-subsys_initcall(scmi_power_init);
+DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(SCMI_PROTOCOL_POWER, power)
drivers/firmware/arm_scmi/reset.c +1 -6
index 4e2dc5fc43d9..f063cfe17e02 100644
@@ -313,9 +313,4 @@ static int scmi_reset_protocol_init(struct scmi_handle *handle)
 	return 0;
 }
 
-static int __init scmi_reset_init(void)
-{
-	return scmi_protocol_register(SCMI_PROTOCOL_RESET,
-				      &scmi_reset_protocol_init);
-}
-subsys_initcall(scmi_reset_init);
+DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(SCMI_PROTOCOL_RESET, reset)
drivers/firmware/arm_scmi/sensors.c +1 -6
index 7d83680198de..9703cf6356a0 100644
@@ -365,9 +365,4 @@ static int scmi_sensors_protocol_init(struct scmi_handle *handle)
 	return 0;
 }
 
-static int __init scmi_sensors_init(void)
-{
-	return scmi_protocol_register(SCMI_PROTOCOL_SENSOR,
-				      &scmi_sensors_protocol_init);
-}
-subsys_initcall(scmi_sensors_init);
+DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(SCMI_PROTOCOL_SENSOR, sensors)
drivers/firmware/arm_scmi/system.c +1 -6
index aa1e74f066a0..283e12d5f24b 100644
@@ -128,9 +128,4 @@ static int scmi_system_protocol_init(struct scmi_handle *handle)
 	return 0;
 }
 
-static int __init scmi_system_init(void)
-{
-	return scmi_protocol_register(SCMI_PROTOCOL_SYSTEM,
-				      &scmi_system_protocol_init);
-}
-subsys_initcall(scmi_system_init);
+DEFINE_SCMI_PROTOCOL_REGISTER_UNREGISTER(SCMI_PROTOCOL_SYSTEM, system)
Signature · 7 lines
2.17.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#4 lore raw

PATCH v2 4/4 firmware: arm_scmi: Enable building as a single module

In reply to Sudeep Holla

Now, with all the plumbing in place to enable building scmi as a module instead of built-in modules, let us enable the same.

---
 drivers/firmware/Kconfig           | 2 +-
 drivers/firmware/Makefile          | 2 +-
 drivers/firmware/arm_scmi/Makefile | 4 +++-
 include/linux/scmi_protocol.h      | 2 +-
 4 files changed, 6 insertions(+), 4 deletions(-)
drivers/firmware/Kconfig +1 -1
index fbd785dd0513..afdbebba628a 100644
@@ -7,7 +7,7 @@
 menu "Firmware Drivers"
 
 config ARM_SCMI_PROTOCOL
-	bool "ARM System Control and Management Interface (SCMI) Message Protocol"
+	tristate "ARM System Control and Management Interface (SCMI) Message Protocol"
 	depends on ARM || ARM64 || COMPILE_TEST
 	depends on MAILBOX
 	help
drivers/firmware/Makefile +1 -1
index 99510be9f5ed..5e013b6a3692 100644
@@ -22,7 +22,7 @@ obj-$(CONFIG_TI_SCI_PROTOCOL)	+= ti_sci.o
 obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o
 obj-$(CONFIG_TURRIS_MOX_RWTM)	+= turris-mox-rwtm.o
 
-obj-$(CONFIG_ARM_SCMI_PROTOCOL)	+= arm_scmi/
+obj-y				+= arm_scmi/
 obj-y				+= broadcom/
 obj-y				+= meson/
 obj-$(CONFIG_GOOGLE_FIRMWARE)	+= google/
drivers/firmware/arm_scmi/Makefile +3 -1
index 643f2320f976..bc0d54f8e861 100644
@@ -1,9 +1,11 @@
 # SPDX-License-Identifier: GPL-2.0-only
-obj-y	= scmi-bus.o scmi-driver.o scmi-protocols.o scmi-transport.o
 scmi-bus-y = bus.o
 scmi-driver-y = driver.o notify.o
 scmi-transport-y = shmem.o
 scmi-transport-$(CONFIG_MAILBOX) += mailbox.o
 scmi-transport-$(CONFIG_HAVE_ARM_SMCCC_DISCOVERY) += smc.o
 scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o system.o
+scmi-module-objs := $(scmi-bus-y) $(scmi-driver-y) $(scmi-protocols-y) \
+		    $(scmi-transport-y)
+obj-$(CONFIG_ARM_SCMI_PROTOCOL) += scmi-module.o
 obj-$(CONFIG_ARM_SCMI_POWER_DOMAIN) += scmi_pm_domain.o
include/linux/scmi_protocol.h +1 -1
index 4b10093ad671..9cd312a1ff92 100644
@@ -345,7 +345,7 @@ struct scmi_driver {
 
 #define to_scmi_driver(d) container_of(d, struct scmi_driver, driver)
 
-#ifdef CONFIG_ARM_SCMI_PROTOCOL
+#if IS_REACHABLE(CONFIG_ARM_SCMI_PROTOCOL)
 int scmi_driver_register(struct scmi_driver *driver,
 			 struct module *owner, const char *mod_name);
 void scmi_driver_unregister(struct scmi_driver *driver);
Signature · 7 lines
2.17.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#5 lore raw
In reply to Sudeep Holla

Hi Sudeep

Quoted 6 lines · Sudeep Holla

Hi,

Though it was initially developed as module, so some reason(I can't recollect why apart from some structuring arounf the way bus and protocols were initialised), it was merged as a built-in only driver.

Quoted 7 lines

Now, there is a need to build this as modules. This is mainly needed by virtio transport. This also aligns well with GKI modularisation efforts.

Regards,
Sudeep

I re-tested this v2 (also regarding some interactions with notifications) and works generally fine for me, both builtin or modularized, BUT I've seen an issue on core module load/unload/load.
Basically doing this:

(debian-arm64)root@debarm64:~# insmod ./scmi-module.ko 
(debian-arm64)root@debarm64:~# insmod ./scmi-cpufreq.ko 
(debian-arm64)root@debarm64:~# rmmod ./scmi-cpufreq.ko 
(debian-arm64)root@debarm64:~# rmmod ./scmi-module.ko 
(debian-arm64)root@debarm64:~# lsmod 
Module                  Size  Used by
(debian-arm64)root@debarm64:~# insmod ./scmi-module.ko 

I've got this:

[  146.982413] mhu 2b1f0000.mhu: Channel in use
[  146.982433] arm-scmi firmware:scmi: failed to request SCMI Tx mailbox
[  146.982472] arm-scmi: probe of firmware:scmi failed with error -16

and SCMI is broken then after reloading.

Now this is an issue I've seen already in my ongoing WIP on full SCMI Protocols modularization for custom protocols, and it is related to the fact the the underlying transport init is bound to the SCMI device creation and not the protocol initialization, and we are not destroying and re-creating such devices properly. (things that I'm going to address in that WIP)

Given that the solution to this is not so simple as of now, and given that unloading of the core as a whole module does not make so much sense anyway (while it will be needed for single custom protocols modules), couldn't we just make scmi-module a permanent by droppping module_exit() ?

Thanks

Cristian

Quoted 33 lines

v1[1]->v2:
- Added missing smccc functions exports
- Moved scmi_driver_init to subsys_initcall
- Reorder exit function calls
- Renamed protocol_init/exit to register/unregister
- Rebased on [2]

[1] https://lore.kernel.org/r/[email protected]/
[2] git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux.git for-next/scmi (contains system protocol implementation)

Sudeep Holla (4):
firmware: smccc: export both smccc functions
firmware: arm_scmi: Move scmi bus init and exit calls into the driver
firmware: arm_scmi: Move scmi protocols registration into the driver
firmware: arm_scmi: Enable building as a single module

 drivers/firmware/Kconfig            |  2 +-
 drivers/firmware/Makefile           |  2 +-
 drivers/firmware/arm_scmi/Makefile  |  4 +++-
 drivers/firmware/arm_scmi/bus.c     |  6 ++----
 drivers/firmware/arm_scmi/clock.c   |  7 +------
 drivers/firmware/arm_scmi/common.h  | 24 +++++++++++++++++++++++
 drivers/firmware/arm_scmi/driver.c  | 30 ++++++++++++++++++++++++++++-
 drivers/firmware/arm_scmi/perf.c    |  7 +------
 drivers/firmware/arm_scmi/power.c   |  7 +------
 drivers/firmware/arm_scmi/reset.c   |  7 +------
 drivers/firmware/arm_scmi/sensors.c |  7 +------
 drivers/firmware/arm_scmi/system.c  |  7 +------
 drivers/firmware/smccc/smccc.c      |  2 ++
 include/linux/scmi_protocol.h       |  2 +-
 14 files changed, 69 insertions(+), 45 deletions(-)
Quoted 3 lines

--
2.17.1

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#6 lore raw
Quoted 46 lines · Cristian Marussi

Hi Sudeep

Quoted 6 lines · Sudeep Holla

Hi,

Though it was initially developed as module, so some reason(I can't recollect why apart from some structuring arounf the way bus and protocols were initialised), it was merged as a built-in only driver.

Quoted 7 lines

Now, there is a need to build this as modules. This is mainly needed by virtio transport. This also aligns well with GKI modularisation efforts.

Regards,
Sudeep

I re-tested this v2 (also regarding some interactions with notifications) and works generally fine for me, both builtin or modularized, BUT I've seen an issue on core module load/unload/load.
Basically doing this:

(debian-arm64)root@debarm64:~# insmod ./scmi-module.ko
(debian-arm64)root@debarm64:~# insmod ./scmi-cpufreq.ko
(debian-arm64)root@debarm64:~# rmmod ./scmi-cpufreq.ko
(debian-arm64)root@debarm64:~# rmmod ./scmi-module.ko
(debian-arm64)root@debarm64:~# lsmod
Module                  Size  Used by
(debian-arm64)root@debarm64:~# insmod ./scmi-module.ko

I've got this:

[  146.982413] mhu 2b1f0000.mhu: Channel in use
[  146.982433] arm-scmi firmware:scmi: failed to request SCMI Tx mailbox
[  146.982472] arm-scmi: probe of firmware:scmi failed with error -16

and SCMI is broken then after reloading.

Now this is an issue I've seen already in my ongoing WIP on full SCMI Protocols modularization for custom protocols, and it is related to the fact the the underlying transport init is bound to the SCMI device creation and not the protocol initialization, and we are not destroying and re-creating such devices properly. (things that I'm going to address in that WIP)

Quoted 4 lines

Given that the solution to this is not so simple as of now, and given that unloading of the core as a whole module does not make so much sense anyway (while it will be needed for single custom protocols modules), couldn't we just make scmi-module a permanent by droppping module_exit() ?

Now I remember why I had bus_exit before unregistering the driver. I think that should fix the issue. Let me know.

--
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#7 lore raw
Quoted 47 lines · Sudeep Holla
Quoted 46 lines · Cristian Marussi

Hi Sudeep

Quoted 6 lines · Sudeep Holla

Hi,

Though it was initially developed as module, so some reason(I can't recollect why apart from some structuring arounf the way bus and protocols were initialised), it was merged as a built-in only driver.

Quoted 7 lines

Now, there is a need to build this as modules. This is mainly needed by virtio transport. This also aligns well with GKI modularisation efforts.

Regards,
Sudeep

I re-tested this v2 (also regarding some interactions with notifications) and works generally fine for me, both builtin or modularized, BUT I've seen an issue on core module load/unload/load.
Basically doing this:

(debian-arm64)root@debarm64:~# insmod ./scmi-module.ko
(debian-arm64)root@debarm64:~# insmod ./scmi-cpufreq.ko
(debian-arm64)root@debarm64:~# rmmod ./scmi-cpufreq.ko
(debian-arm64)root@debarm64:~# rmmod ./scmi-module.ko
(debian-arm64)root@debarm64:~# lsmod
Module                  Size  Used by
(debian-arm64)root@debarm64:~# insmod ./scmi-module.ko

I've got this:

[  146.982413] mhu 2b1f0000.mhu: Channel in use
[  146.982433] arm-scmi firmware:scmi: failed to request SCMI Tx mailbox
[  146.982472] arm-scmi: probe of firmware:scmi failed with error -16

and SCMI is broken then after reloading.

Now this is an issue I've seen already in my ongoing WIP on full SCMI Protocols modularization for custom protocols, and it is related to the fact the the underlying transport init is bound to the SCMI device creation and not the protocol initialization, and we are not destroying and re-creating such devices properly. (things that I'm going to address in that WIP)

Quoted 8 lines
Quoted 4 lines

Given that the solution to this is not so simple as of now, and given that unloading of the core as a whole module does not make so much sense anyway (while it will be needed for single custom protocols modules), couldn't we just make scmi-module a permanent by droppping module_exit() ?

Now I remember why I had bus_exit before unregistering the driver. I think that should fix the issue. Let me know.

Yes that works for me, both as builtin or as a module now.

Cristian

Quoted 3 lines

--
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author Tested-by Cristian Marussi
#8 lore raw
Quoted 53 lines · Cristian Marussi
Quoted 52 lines · Sudeep Holla
Quoted 50 lines · Cristian Marussi

Hi Sudeep

Quoted 6 lines · Sudeep Holla

Hi,

Though it was initially developed as module, so some reason(I can't recollect why apart from some structuring arounf the way bus and protocols were initialised), it was merged as a built-in only driver.

Quoted 7 lines

Now, there is a need to build this as modules. This is mainly needed by virtio transport. This also aligns well with GKI modularisation efforts.

Regards,
Sudeep

I re-tested this v2 (also regarding some interactions with notifications) and works generally fine for me, both builtin or modularized, BUT I've seen an issue on core module load/unload/load.
Basically doing this:

(debian-arm64)root@debarm64:~# insmod ./scmi-module.ko
(debian-arm64)root@debarm64:~# insmod ./scmi-cpufreq.ko
(debian-arm64)root@debarm64:~# rmmod ./scmi-cpufreq.ko
(debian-arm64)root@debarm64:~# rmmod ./scmi-module.ko
(debian-arm64)root@debarm64:~# lsmod
Module                  Size  Used by
(debian-arm64)root@debarm64:~# insmod ./scmi-module.ko

I've got this:

[  146.982413] mhu 2b1f0000.mhu: Channel in use
[  146.982433] arm-scmi firmware:scmi: failed to request SCMI Tx mailbox
[  146.982472] arm-scmi: probe of firmware:scmi failed with error -16

and SCMI is broken then after reloading.

Now this is an issue I've seen already in my ongoing WIP on full SCMI Protocols modularization for custom protocols, and it is related to the fact the the underlying transport init is bound to the SCMI device creation and not the protocol initialization, and we are not destroying and re-creating such devices properly. (things that I'm going to address in that WIP)

Given that the solution to this is not so simple as of now, and given that unloading of the core as a whole module does not make so much sense anyway (while it will be needed for single custom protocols modules), couldn't we just make scmi-module a permanent by droppping module_exit() ?

Quoted 6 lines
Quoted 3 lines

Now I remember why I had bus_exit before unregistering the driver. I think that should fix the issue. Let me know.

Yes that works for me, both as builtin or as a module now.

With that fix, can I take this as:

Signature · 7 lines
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author Applied
#9 lore raw
In reply to Sudeep Holla
Quoted 9 lines · Sudeep Holla

Though it was initially developed as module, so some reason(I can't recollect why apart from some structuring arounf the way bus and protocols were initialised), it was merged as a built-in only driver.

Now, there is a need to build this as modules. This is mainly needed by virtio transport. This also aligns well with GKI modularisation efforts.

[...]

Applied to sudeep.holla/linux (for-next/scmi), thanks!

[1/4] firmware: smccc: Export both smccc functions

      https://git.kernel.org/sudeep.holla/c/6825f17c95
[2/4] firmware: arm_scmi: Move scmi bus init and exit calls into the driver
      https://git.kernel.org/sudeep.holla/c/5a2f0a0bdf
[3/4] firmware: arm_scmi: Move scmi protocols registration into the driver
      https://git.kernel.org/sudeep.holla/c/1eaf18e35a
[4/4] (HEAD -> for-next/scmi) firmware: arm_scmi: Enable building as a single module
      https://git.kernel.org/sudeep.holla/c/66d90f6ece

--

Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel