Skip to content

deps: deterministic driver initialization order

Alexander Holler linux-arm-kernel linux-devicetree linux-mtd lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest16 patches 9 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/16deps: dtc: Automatically add new property 'dependencies' which contains a list of referenced phandlesscripts/dtc/Makefile scripts/dtc/Makefile.dtc scripts/dtc/dependencies.c +2 more+125 -20 replies
2/16deps: dtc: Add option to print initialization orderscripts/dtc/dependencies.c scripts/dtc/dtc.c scripts/dtc/dtc.h+369 -10 replies
3/16deps: dtc: Add option to print dependency graph as dot (Graphviz)scripts/dtc/dependencies.c scripts/dtc/dtc.c scripts/dtc/dtc.h+60 -100 replies
4/16deps: dtc: introduce new (virtual) property no-dependenciesscripts/dtc/dependencies.c+33 -00 replies
5/16deps: introduce initcalls annotated with a struct device_driverarch/arm/kernel/vmlinux.lds.S include/asm-generic/vmlinux.lds.h include/linux/device.h +5 more+70 -50 replies
6/16deps: deterministic driver initialization sequence based on dependencies from the DTdrivers/of/Kconfig drivers/of/Makefile drivers/of/of_dependencies.c +2 more+453 -10 replies
7/16deps: add debug configuration optionsdrivers/of/Kconfig drivers/of/of_dependencies.c+73 -20 replies
8/16deps: dts: kirkwood: dockstar: add dependency ehci -> usb power regulatorarch/arm/boot/dts/kirkwood-dockstar.dts+4 -00 replies
9/16deps: dts: imx6q: make some remote-endpoints non-dependenciesarch/arm/boot/dts/imx6q.dtsi arch/arm/boot/dts/imx6qdl.dtsi+6 -00 replies
10/16deps: dts: omap: beagle: make some remote-endpoints non-dependenciesarch/arm/boot/dts/omap3-beagle.dts+4 -00 replies
11/16deps: WIP: generic: annotate some initcallsdrivers/input/keyboard/gpio_keys.c drivers/misc/sram.c drivers/regulator/fixed.c +1 more+5 -40 replies
12/16deps: WIP: imx: annotate some initcallsarch/arm/mach-imx/gpc.c arch/arm/mach-imx/mmdc.c drivers/dma/mxs-dma.c +8 more+12 -110 replies
13/16deps: WIP: omap: annotate some initcallsarch/arm/common/edma.c drivers/bus/omap_l3_smx.c drivers/dma/omap-dma.c +17 more+20 -200 replies
14/16deps: WIP: kirkwood: annotate some initcallsdrivers/dma/mv_xor.c drivers/net/ethernet/marvell/mv643xx_eth.c drivers/usb/host/ehci-orion.c+4 -30 replies
15/16mtd: mtdcore: fix initcall leveldrivers/mtd/mtdcore.c+1 -14 replies
16/16phy: phy-core: fix initcall leveldrivers/phy/phy-core.c+1 -12 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/16] deps: deterministic driver initialization order

Hello,

I've already written a lot on that topic, therefor this introductory mail doesn't explain everything.

Please have a look at the threads

"dt: dependencies (for deterministic driver initialization order based on the DT)"

and

"On-demand device registration"

on LKML for previous discussions.

In short, the current init system is quiet old and doesn't really match todays HW which needs much more drivers than 20 years ago.

As I've mentioned in those threads, initcalls should be identifiable in order to sort them. My previous attempt intercepted the driver registrations in order to do that, which unfortunately ended up with having to deal how drivers are creating devices.

I've now spend some more time and this partly new approach now annotates the initcalls directly, by storing a pointer to a struct device_driver in addition to the pointer to the initcall.

This makes my previous patches smaller, cleaner and better to understand, the result which you can see in this little patch series.

The whole patch series is made up of several parts.

The first 4 patches are modifying dtc to include dependencies (type information for phandles).

The next 3 patches are the ones which are implementing those annotated initcalls and the driver sort algorithm.

Then there are 3 patches with small changes on some dts.

The following 4 patches with the WIP (Work In Progress) are changing some initcalls to annotated initcalls. I would split them up in a bunch of patches (one for each driver), if I get the promise that the other patches will be merged into mainline (but not without that promise).

The final 2 patches are fixes which should end up in mainline, regardless if this feature is merged or not.

Some numbers (5 boots on each board, without and with ordering drivers), all times are seconds.

Kirkwood (dockstar, armv5):

Boot to "Freeing unused kernel memory" (includes mounting the rootfs), unordered:
4.456016 3.937801 4.114788 4.114526 3.949480 (average 4.1145222) ordered:
3.173054 3.164045 3.141418 3.480679 3.459298 (3.2836988) Time needed to sort (of_init_build_order()):
0.003024
Time needed to match drivers to the order (without calling them):
0.002884

Beagleboard (rev C4, armv7):

unordered:
6.706024 6.821746 6.696014 6.673675 6.769866 (6.733465) ordered:
5.544860 5.514160 5.505859 5.527374 5.496795 (5.5178096)
sorting: 0.021209
matching: 0.006165

Beaglebone Black (rev A5, armv7):

unordered:
3.826531 3.825662 3.826648 3.825434 3.825263 (3.8259076) ordered:
2.838554 2.838322 2.839459 2.838467 2.838421 (2.8386446)
sorting: 0.004769
matching: 0.004860

imx6q (armv7):

unordered:
3.451998 3.418864 3.446952 3.429974 3.440996 (3.4377568) ordered:
3.538312 3.549019 3.538105 3.515916 3.555715 (3.5394134)
sorting: 0.004622
matching: 0.003868

Because I'm using different configuration options on these boards, the absolute times aren't comparable.

But in conclusion, most boards are booting faster when the initcalls have been ordered.

In addition, ordering the initcalls makes the initialization sequence more deterministic (it can even be seen without booting a machine).

But I still think the most benefit of these little series is by not having to use in-driver hacks or that ugly brute force trial-and-error deferred probing in order to fix a wrong default call order of initcalls.

Further improvements could be to initialize drivers in parallel (using multiple cores) and/or to use this stuff on x86 (ACPI) too (e.g. by using a minimal DT which just includes dependencies).

To test this series with any other DT enabled board, look at which drivers are referenced in the DT (see patch 2 or 3), annotate these drivers (trivial, see patch 5 or the examples with WIP in the subject), turn on CONFIG_OF_DEPENDENCIES, compile and boot.

Just to mention it, unless CONFIG_OF_DEPENDENCIES is turned on (which is marked as experimental), nothing will change, even if you've annotated some drivers (the new macros will just map to the old ones).

Regards,

Alexander Holler

PS: Please keep in mind that these patches are an offer. I'm already 100+ patches above mainline and don't really care to maintain some more for myself.