Android: Problem loading kernel modules from vendor partition (init.rc)

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Android: Problem loading kernel modules from vendor partition (init.rc)

2,459件の閲覧回数
OliW
Contributor III

I am using Anmdroid 14.0.0_1.2.0 on an i.MX 8MM custom hardware.

On the hardware there are some peripheral chips where the kernel driver needs to load a firmware from eMMC when the driver module gets loaded.

The related kernel modules are all placed in vendor_dklm partition (passed to the BOARD_VENDOR_KERNEL_MODULES makefile variable) so that they get loaded by the init.rc script when vendor partition is already mounted.

Because of programming firmwares some of these driver take a long to time to load. But system already start while the modules are still in loading process. This might lead to conditions where HAL services get loaded but the related hardware is not ready on driver level yet.

The problem is how the modules get loaded from init.rc script. The loading process is declared as a service. The init.rc file is located in device directory (e.g. device/nxp/imx8m/evk_8mm\init.rc)

service early_init_sh /vendor/bin/init.insmod.sh /vendor/etc/early.init.cfg vendor.all.early_init.ready
class main
user root
group root system
disabled
oneshot

This service is started in early_init phase (see same init.rc file):

on early-init
    start early_init_sh
   # Set the host name which used in console
    export HOSTNAME evk_8mm

When the service as started via the "start" command it is started in the background and init goes on without waiting. So the HAL services are already loaded while the load kernel modules script is still busy in loading the modules.

I would like to propose to start the kernel module loading script with the "exec_start" command. This will make init process wait until the module load service (or the script) terminates and all modules are loaded before going on loading HAL services.

So this is the patch to apply to all related init.rc files which use the same scheme for laoding the kernel modules:

diff --git a/imx8m/evk_8mm/init.rc b/imx8m/evk_8mm/init.rc
index d1d2c1a5..06edc59d 100644
--- a/imx8m/evk_8mm/init.rc
+++ b/imx8m/evk_8mm/init.rc
@@ -7,7 +7,7 @@ on early-init
mount debugfs none /sys/kernel/debug/ mode=0755

on early-init
- start early_init_sh
+ exec_start early_init_sh
# Set the host name which used in console
export HOSTNAME evk_8mm

 

タグ(1)
0 件の賞賛
返信
2 返答(返信)

2,430件の閲覧回数
Bio_TICFSL
NXP TechSupport
NXP TechSupport
0 件の賞賛
返信

2,418件の閲覧回数
OliW
Contributor III

In this documentation

 

it is proposed to load the modules using the exec command of Android's init process:

on early-init
exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d \
/vendor/lib/modules module_a module_b module_c ...

The exec commands load the modules blocking (wait until all modules are loading). The approach in the NXP i.MX Android distribution uses service start command which starts the module loading script as a service in the background not waiting for it to terminate. This leads to the situation that modules and HAL services are loaded at the same time which may cause race conditions.

So I want to propse that you change this in future Android distributions to use "exec_start" command which waits for the service to terminate.

0 件の賞賛
返信