diff mbox

package/busybox: support automatic module loading with mdev

Message ID 1457478205-18515-1-git-send-email-peter@korsgaard.com
State Accepted
Commit 07f46c2b6daec44a6176039c90be67e66c4c2e42
Headers show

Commit Message

Peter Korsgaard March 8, 2016, 11:03 p.m. UTC
A recently discussed on the mailing list:
http://lists.busybox.net/pipermail/buildroot/2016-February/154189.html

Our mdev configuration currently doesn't handle module loading. Fix that by:

- Telling mdev to run modprobe on hotplug events providing MODALIAS

- Adjust the init script to handle coldplug modalias events (E.G. modules
  for which the devices were already present before mdev was added as the
  hotplug handler). mdev -s should arguable handle this, but it doesn't.

Cc: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
---
 package/busybox/S10mdev   | 2 ++
 package/busybox/mdev.conf | 3 +++
 2 files changed, 5 insertions(+)

Comments

Yann E. MORIN March 8, 2016, 11:16 p.m. UTC | #1
Peter, All,

On 2016-03-09 00:03 +0100, Peter Korsgaard spake thusly:
> A recently discussed on the mailing list:
> http://lists.busybox.net/pipermail/buildroot/2016-February/154189.html
> 
> Our mdev configuration currently doesn't handle module loading. Fix that by:
> 
> - Telling mdev to run modprobe on hotplug events providing MODALIAS
> 
> - Adjust the init script to handle coldplug modalias events (E.G. modules
>   for which the devices were already present before mdev was added as the
>   hotplug handler). mdev -s should arguable handle this, but it doesn't.
> 
> Cc: Arnout Vandecappelle <arnout@mind.be>
> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>

Acked-by: "Yann E. MORIN" <yann.morin.1998@free.fr>

Regards,
Yann E. MORIN.

> ---
>  package/busybox/S10mdev   | 2 ++
>  package/busybox/mdev.conf | 3 +++
>  2 files changed, 5 insertions(+)
> 
> diff --git a/package/busybox/S10mdev b/package/busybox/S10mdev
> index d386d42..4cb31de 100644
> --- a/package/busybox/S10mdev
> +++ b/package/busybox/S10mdev
> @@ -8,6 +8,8 @@ case "$1" in
>  	echo "Starting mdev..."
>  	echo /sbin/mdev >/proc/sys/kernel/hotplug
>  	/sbin/mdev -s
> +	# coldplug modules
> +	find /sys/ -name modalias | xargs sort -u | xargs modprobe -abq
>  	;;
>    stop)
>  	;;
> diff --git a/package/busybox/mdev.conf b/package/busybox/mdev.conf
> index 247c0ed..4fafe63 100644
> --- a/package/busybox/mdev.conf
> +++ b/package/busybox/mdev.conf
> @@ -33,3 +33,6 @@ event[0-9]+	root:root 640 =input/
>  mice		root:root 640 =input/
>  mouse[0-9]	root:root 640 =input/
>  ts[0-9]		root:root 600 =input/
> +
> +# load modules
> +$MODALIAS=.*	root:root 660 @modprobe "$MODALIAS"
> -- 
> 2.7.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Peter Korsgaard March 9, 2016, 10:08 p.m. UTC | #2
>>>>> "Peter" == Peter Korsgaard <peter@korsgaard.com> writes:

 > A recently discussed on the mailing list:
 > http://lists.busybox.net/pipermail/buildroot/2016-February/154189.html

 > Our mdev configuration currently doesn't handle module loading. Fix that by:

 > - Telling mdev to run modprobe on hotplug events providing MODALIAS

 > - Adjust the init script to handle coldplug modalias events (E.G. modules
 >   for which the devices were already present before mdev was added as the
 >   hotplug handler). mdev -s should arguable handle this, but it doesn't.

 > Cc: Arnout Vandecappelle <arnout@mind.be>
 > Signed-off-by: Peter Korsgaard <peter@korsgaard.com>

Committed, thanks.
Andy Shevchenko Dec. 2, 2016, 12:52 p.m. UTC | #3
On Wed, 2016-03-09 at 23:08 +0100, Peter Korsgaard wrote:
> > > > > > "Peter" == Peter Korsgaard <peter@korsgaard.com> writes:
> 
>  > A recently discussed on the mailing list:
>  > http://lists.busybox.net/pipermail/buildroot/2016-February/154189.h
> tml
> 
>  > Our mdev configuration currently doesn't handle module loading. Fix
> that by:
> 
>  > - Telling mdev to run modprobe on hotplug events providing MODALIAS
> 
>  > - Adjust the init script to handle coldplug modalias events (E.G.
> modules
>  >   for which the devices were already present before mdev was added
> as the
>  >   hotplug handler). mdev -s should arguable handle this, but it
> doesn't.
> 
>  > Cc: Arnout Vandecappelle <arnout@mind.be>
>  > Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
> 
> Committed, thanks.
> 

Sorry for bring this topic back, but this script still doesn't work
properly.

Among modaliases I have the following:
 of:Neep0TCatmel,at25

And with the script:
# find /sys/ -name modalias -print0 | xargs -0 sort -u -z | xargs -0
modprobe -abq
# 

Manually:
# modprobe -abq of:Neep0TCatmel,at25
[  988.523305] at25 spi-PRP0001:00: 1 KByte at25 eeprom, pagesize 32

I'm afraid my (or similar) solution would do job better, i.e. serialize
probing one-by-one.
diff mbox

Patch

diff --git a/package/busybox/S10mdev b/package/busybox/S10mdev
index d386d42..4cb31de 100644
--- a/package/busybox/S10mdev
+++ b/package/busybox/S10mdev
@@ -8,6 +8,8 @@  case "$1" in
 	echo "Starting mdev..."
 	echo /sbin/mdev >/proc/sys/kernel/hotplug
 	/sbin/mdev -s
+	# coldplug modules
+	find /sys/ -name modalias | xargs sort -u | xargs modprobe -abq
 	;;
   stop)
 	;;
diff --git a/package/busybox/mdev.conf b/package/busybox/mdev.conf
index 247c0ed..4fafe63 100644
--- a/package/busybox/mdev.conf
+++ b/package/busybox/mdev.conf
@@ -33,3 +33,6 @@  event[0-9]+	root:root 640 =input/
 mice		root:root 640 =input/
 mouse[0-9]	root:root 640 =input/
 ts[0-9]		root:root 600 =input/
+
+# load modules
+$MODALIAS=.*	root:root 660 @modprobe "$MODALIAS"