2

I am experimenting with boot optimization on my Raspberry Pi 4 - Yocto based embedded Linux system and would like to set when vc4-drm kernel module is loaded.

I would like to make vc4-drm kernel module loaded earlier so that /dev/fb0 is ready earlier. Now, it exceeds my user space boot time, therefore I am not able to display anything on it for about 9 seconds. However, if I move it so that it is initialized earlier, I'm thinking it will be better.

Below is an image that shows major kernel modules that are loaded on my system, in a complete debug mode (bootchart+initcall_debug+serial+printk enabled). You will see that vc4_drm_register is almost at the end.

enter image description here

In order to approach the issue, I found these: What is the Linux built-in driver load order? and How does Linux determine the order of module init calls?. Yasushi Shoji states;

put your init function in the higher level, or put your device driver at the higher position in Makefile

For the first method, in the kernel that I'm compiling, I found the module in drivers/gpu/drm/vc4, then replaced module_init(vc4_drm_register) with both early_initcall(vc4_drm_register) and subsys_initcall(vc4_drm_register). Both attempts made absolutely no difference, vc4 still loads at around ~9th second. Either I'm missing something here, or this is being handled differently.

Second method suggested is to adjust the order in drivers/Makefile. However, to me gpu/ drivers seems already pretty early stage.

obj-y               += irqchip/
obj-y               += bus/

obj-$(CONFIG_GENERIC_PHY)   += phy/

# GPIO must come after pinctrl as gpios may need to mux pins etc
obj-$(CONFIG_PINCTRL)       += pinctrl/
obj-$(CONFIG_GPIOLIB)       += gpio/
obj-y               += pwm/

obj-y               += pci/

obj-$(CONFIG_PARISC)        += parisc/
obj-$(CONFIG_RAPIDIO)       += rapidio/
obj-y               += video/
obj-y               += idle/

# IPMI must come before ACPI in order to provide IPMI opregion support
obj-y               += char/ipmi/

obj-$(CONFIG_ACPI)      += acpi/
obj-$(CONFIG_SFI)       += sfi/
# PnP must come after ACPI since it will eventually need to check if acpi
# was used and do nothing if so
obj-$(CONFIG_PNP)       += pnp/
obj-y               += amba/

obj-y               += clk/
# Many drivers will want to use DMA so this has to be made available
# really early.
obj-$(CONFIG_DMADEVICES)    += dma/

# SOC specific infrastructure drivers.
obj-y               += soc/

obj-$(CONFIG_VIRTIO)        += virtio/
obj-$(CONFIG_XEN)       += xen/

# regulators early, since some subsystems rely on them to initialize
obj-$(CONFIG_REGULATOR)     += regulator/

# reset controllers early, since gpu drivers might rely on them to initialize
obj-$(CONFIG_RESET_CONTROLLER)  += reset/

# tty/ comes before char/ so that the VT console is the boot-time
# default.
obj-y               += tty/
obj-y               += char/

# iommu/ comes before gpu as gpu are using iommu controllers
obj-$(CONFIG_IOMMU_SUPPORT) += iommu/

# gpu/ comes after char for AGP vs DRM startup and after iommu
obj-y               += gpu/
# ...
# ...
# ...
# Continues with a lot more drivers here...

Therefore, I am in need of help to figure this out. How do I make sure that vc4 is loaded earlier than it is now? If I am missing anything, please let me know. Thank you very much.

NOTE: vc4-drm dmesg

root@raspberrypi4-64:~# dmesg | grep vc4                                            
[    9.123494] calling  vc4_drm_register+0x0/0x1000 [vc4] @ 299                     
[    9.184440] vc4-drm soc:gpu: bound fe600000.firmwarekms (ops vc4_fkms_ops [vc4]) 
[    9.192810] [drm] Initialized vc4 0.0.0 20140616 for soc:gpu on minor 1          
[    9.380513] vc4-drm soc:gpu: fb0: DRM emulated frame buffer device               
[    9.393112] initcall vc4_drm_register+0x0/0x1000 [vc4] returned 0 after 187677 us
ecs 
mozcelikors
  • 2,582
  • 8
  • 43
  • 77

1 Answers1

5

I was able to solve the problem. It turns out that order to make *_initcall()'s work, the module should be statically linked, therefore, I set;

CONFIG_DRM_VC4=y
CONFIG_SND=y
CONFIG_SNC_SOC=y

This loses a couple of milliseconds of boot time, but now /dev/fb0 loads at around ~0.3 seconds, rather than ~9 seconds.

mozcelikors
  • 2,582
  • 8
  • 43
  • 77