How can we customize the built-in driver load order (to make some built-in driver module load first, and the dependent module load later)?
How can we customize the built-in driver load order (to make some built-in driver
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Built-in drivers wont be loaded, hence built-in. Their initialization functions are called and the drivers are activated when kernel sets up itself. These init functions are called in
init/main.c::do_initcalls(). All init calls are classified in levels, which are defined ininitcall_levelsandinclude/linux/init.hThese levels are actuall symbols defined in linker script (
arch/*/kernel/vmlinux.lds.*). At kernel compile time, the linker collects all function markedmodule_init()or other*_initcall(), classify in levels, put all functions in the same level together in the same place, and create like an array of function pointers.What do_initcall_level() does in the run-time is to call each function pointed by the pointers in the array. There is no calling policy, except levels, in do_initcall_level, but the order in the array is decided in the link time.
So, now you can see that the driver’s initiation order is fixed at the link time, but what can you do?
MakefileThe first one is clear if you’ve read the above. ie) use early_initcall() instead if it is appropriate.
The second one needs a bit more explanation. The reason why the order in a
Makefilematter is how the current kernel build system works and how the linkers works. To make a long story short, the build system takes all object files inobj-yand link them together. It is highly environment dependent but there is high probability that the linker place first object file in theobj-yin lower address, thus, called earlier.If you just want your driver to be called earlier than other drivers in the same directory, this is simplest way to do it.