LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 09-16-2011, 05:25 AM   #16
ecd102
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Rep: Reputation: Disabled
mkinitrd patch to include firmware loader


Hi all,

I made a patch to mkinitrd script to solve the first issue.

(The diff is made for Slackware64-13.37.)
Code:
diff -upr mkinitrd.orig/mkinitrd mkinitrd/mkinitrd
--- mkinitrd.orig/mkinitrd	2011-04-05 04:36:00.000000000 +0900
+++ mkinitrd/mkinitrd	2011-09-16 17:52:06.024479791 +0900
@@ -237,6 +237,48 @@ copy_modconf() {
   mkdir -p $SOURCE_TREE/etc
   cp -a /etc/modprobe.d $SOURCE_TREE/etc
 }
+
+#
+# Create /sbin/hotplug script
+#
+create_hotplug() {
+echo '#!/bin/sh
+
+# only respond to firmware requests
+if [ "$SUBSYSTEM" = "firmware" -a "$ACTION" = "add" -a -n "$FIRMWARE" ]; then
+	# make sure sysfs is mounted
+	SYSFS_MOUNTED=
+	if [ ! -d /sys ]; then
+		mkdir /sys
+	fi
+	if [ ! -d /sys/kernel ]; then
+		mount -t sysfs -o nodev,noexec,nosuid none /sys
+		SYSFS_MOUNTED=1
+	fi
+
+	# use udev firmware loader if exists
+	if [ -x /lib/udev/firmware ]; then
+		/lib/udev/firmware --firmware=$FIRMWARE --devpath=$DEVPATH
+	else
+		# loader script
+		if [ -r /lib/firmware/$FIRMWARE ]; then
+			echo 1 > /sys/$DEVPATH/loading
+			cat /lib/firmware/$FIRMWARE > /sys/$DEVPATH/data
+			echo 0 > /sys/$DEVPATH/loading
+		else
+			echo -1 > /sys/$DEVPATH/loading
+		fi
+	fi
+
+	# unmount if I mount sysfs
+	if [ -n "$SYSFS_MOUNTED" ]; then
+		umount /sys
+	fi
+fi
+
+exit 0'>$SOURCE_TREE/sbin/hotplug
+chmod 0755 $SOURCE_TREE/sbin/hotplug
+}
      
 # If --help is given, print_usage and exit:
 if echo $* | grep -wq '\--help' ; then
@@ -611,6 +653,16 @@ if [ ! -z "$MODULE_LIST" ]; then
       # replacement.
       if cp -a --parents $SRCMOD $SOURCE_TREE 2>/dev/null; then
         echo "OK: $SRCMOD added."
+        # Copy firmware in the module
+        /sbin/modinfo -F firmware "$SRCMOD"|sed 's/^/\/lib\/firmware\//'|
+        while read SRCFW; do
+          if cp -a --parents "$SRCFW" $SOURCE_TREE 2>/dev/null; then
+            echo "OK: $SRCFW added."
+            touch $SOURCE_TREE/sbin/hotplug
+          else
+            echo "WARNING:  Could not find module \"$SRCFW\""
+          fi
+        done
       else
         echo "WARNING:  Could not find module \"$SRCMOD\""
       fi
@@ -626,6 +678,12 @@ if [ ! -z "$MODULE_LIST" ]; then
     copy_modconf
   fi
 
+  # Create /sbin/hotplug
+  if [ -e $SOURCE_TREE/sbin/hotplug ]; then
+    echo "Create: /sbin/hotplug"
+    create_hotplug
+  fi
+
 fi
 
 # Copy needed libraries
When copying modules, this patch also copies firmwares needed by the modules.
And if any firmwares are copied, it also creates the firmware loader to respond the kernel's firmware request.

Regenerate initrd.gz with the patched script and this should solve the first issue - one minute blank screen.
For my case, "-m radeon" works fine.
 
1 members found this post helpful.
Old 09-16-2011, 01:10 PM   #17
rworkman
Slackware Contributor
 
Registered: Oct 2004
Location: Tuscaloosa, Alabama (USA)
Distribution: Slackware
Posts: 1,913

Rep: Reputation: Disabled
I'm glad to see that works, but it's a step backwards in that it requires /sbin/hotplug. That shouldn't be needed, and in fact, it isn't present on a real system these days, so something else is needed instead; I just haven't figured out what that something is...

I *do* like the part of the patch that copies firmware into the initrd image, so I might take that :-)

I have fixed up mkinitrd to start udevd earlier (good catch on that, Richa7d), and I've made a few other tweaks to that package for other reasons, but I haven't tested the radeon firmware loading again (yet) since that laptop is currently in storage.

Last edited by rworkman; 09-16-2011 at 01:11 PM.
 
Old 09-17-2011, 07:56 PM   #18
ecd102
LQ Newbie
 
Registered: Sep 2011
Posts: 2

Rep: Reputation: Disabled
Quote:
Originally Posted by rworkman View Post
I'm glad to see that works, but it's a step backwards in that it requires /sbin/hotplug. That shouldn't be needed, and in fact, it isn't present on a real system these days, so something else is needed instead; I just haven't figured out what that something is...

I *do* like the part of the patch that copies firmware into the initrd image, so I might take that :-)

I have fixed up mkinitrd to start udevd earlier (good catch on that, Richa7d), and I've made a few other tweaks to that package for other reasons, but I haven't tested the radeon firmware loading again (yet) since that laptop is currently in storage.
OK, I have confirmed if I load udev earlier than kernel modules in init script, udevd can handle the firmware request.
But hotplug is still needed if udev is not included, or is it better to use udev when module needs firmware ?
 
1 members found this post helpful.
Old 09-17-2011, 09:21 PM   #19
rworkman
Slackware Contributor
 
Registered: Oct 2004
Location: Tuscaloosa, Alabama (USA)
Distribution: Slackware
Posts: 1,913

Rep: Reputation: Disabled
We'll be including udevd in the initrd by default in the future (in fact, we already do), so that shouldn't be an issue. At this point, I'm not sure it's worth the time and effort to bother with even attempting to support omitting it, but that's not my call to make. Even so, it's worth checking on whether mdev also handles that (probably not), and if not, then perhaps we add the /sbin/hotplug script if udevd is not included in the initrd.

Thanks for following up on all of this -- your help is greatly appreciated :-)
 
Old 09-18-2011, 01:43 AM   #20
rworkman
Slackware Contributor
 
Registered: Oct 2004
Location: Tuscaloosa, Alabama (USA)
Distribution: Slackware
Posts: 1,913

Rep: Reputation: Disabled
Okay, I've just confirmed that the udev move and the firmware copying (btw, that added "OK: " line should say "firmware" instead of "module"), along with the other changes I've got queued up here, do indeed result in the desired behavior.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Radeon kms works! dolphin77 Slackware 147 01-05-2012 05:32 AM
[SOLVED] 640x480 resolution with radeon and KMS bamdad Linux - Hardware 7 08-25-2010 07:07 PM
[SOLVED] Which user space should I have for radeon KMS? Josh000 Slackware 2 04-22-2010 07:20 PM
[SOLVED] Radeon KMS and console question Josh000 Slackware 29 04-16-2010 02:24 PM
KMS with radeon gives garbled screen with x onlyolli Linux - Software 0 06-29-2009 04:14 PM


All times are GMT -5. The time now is 09:54 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration