While testing my upgraded HSF modem support, I find that sometimes the HSF modem is discovered on first boot after installation or "pupdial erase", and other times not detected! I added trace logging to backend_modprobe to monitor its actions. I find that the trace log is identical (except for some of the ordering of unrelated events) whether the modem is detected or not. I suspect that the firmware package and extensive file changes made by the pinstall.hsfmodem script do not get made visible to other processes (i.e., /etc/init.d/hsfmodem) by the time they are needed.
I notice that the "backend_modprobe" script does not contain any 'sync' commands. I understand that command to force writing of file changes to the "device", where it becomes visible to all processes. My "rule of thumb" is to use 'sync' after writing a file that is intended to be used by other processes, on the assumption that the changes are visible only to the current process until the kernel decides to flush the buffers. Considering that several seconds appear to elapse before the initialization (init.d) script runs, it appears that the buffers do not get flushed even when the creating process (backend_modprobe's process) ends.
Because of the random nature of the detection/nondetection cases, it is difficult to verify absolutely that adding 'sync' results in success that could also happen by chance. But, since I added it, I have not seen a repeat of the detection failure.
My recommended fix is to add "sync" after the writing of the "lock1" and "protect1" files, and then after writing the "devpath" file. The latter would be effective for the files affected by a firmware package, which is where I suspect the HSF detection problem originates.
I attach a package containing only "backend_modprobe" with the 2 added 'sync' commands, in case anyone wants to try it. To test it, remove the files copied from the appropriate subdirectory in /lib/modules/all-firmware, from wherever they end up (usually /lib/firmware). Also remove /etc/modules/firmware.dep.inst.* (to cause reloading of the "firmware package"), then reboot.
Here is the unified difference listing:
Code: Select all
# diff -u /initrd/pup_ro2/sbin/pup_event_backend_modprobe /initrd/pup_rw/sbin/pup_event_backend_modprobe
--- /initrd/pup_ro2/sbin/pup_event_backend_modprobe 2012-08-28 03:25:20.000000000 -0400
+++ /initrd/pup_rw/sbin/pup_event_backend_modprobe 2012-09-06 12:03:01.000000000 -0400
@@ -16,6 +16,7 @@
#120823 rerwin: $FIRMPKG always written.
#120823 rerwin: --use-blacklist to apply the blacklist commands in the configuration files (if any) to module names as well.
#120828 rerwin: --use-blacklist again.
+#120906 rerwin: Add sync after writing lock/protect and devpath files to ensure files and firmware packages seen by all immediately.
export LANG=C
. /etc/rc.d/PUPSTATE
@@ -182,6 +183,7 @@
touch /tmp/pup_event_backend/lock1-${$} #start lock region.
mREGEX=" ${MODULE} "
echo "${$} ${MODULE} " > /tmp/pup_event_backend/protect1-${$}
+sync #120906
for NUM in 1 2
do
SIMULT="`cat /tmp/pup_event_backend/protect1-* | grep "${mREGEX}"`"
@@ -216,6 +218,7 @@
#log to file. rc.sysinit needs this info to find out if any modaliases missed (also above)...
echo "MODULE=$MODULE DEVPATH=$DEVPATH MODALIAS=$MODALIAS" >> /tmp/pup_event_backend/pup_event_module_devpath_log${$}
+sync #120906
cd /sbin #v408 rerwin thinks this is needed for slamr module.
exec /sbin/modprobe $MODULE