Skip to contentSkip to conversation

pci coldplug

DISCUSSION Olaf Hering 1 participant 3 messages Nov 5, 2003 – Nov 11, 2003

lore
Share & tools
lore
#0 lore raw

Hello,

what is the purpose of pci_boot_events() in pci.rc? I mean, how can that ever work in the current cvs? I did it that way and it appears to work ok for a 2.4 kernel (probably also for 2.6):

pci_boot_events ()

{
    if [ ! -x /sbin/lspci -o ! -f /proc/bus/pci/devices -o ! -x pci.agent ]; then
            echo $"** can't synthesize pci hotplug events"
            return
    fi

    # these notifications will be handled by pcimodules
    /sbin/lspci -nm | sed 's/"//g' | while read pci_data ; do
        set - $pci_data
        : pci_slot=$1
        : pci_class=$3
        : pci_vendor=$4
        : pci_device=$5
        : pci_revision=$6
        : pci_svendor=$7
        : pci_sdevice=$8
# make sure the pci agent will run
        ACTION­d
        PCI_CLASS=$3
        PCI_ID=$4:$5
        PCI_SLOT=$1
        if [ "$pci_svendor" = "" ] ; then
                PCI_SUBSYS_ID=0:0
        else
                PCI_SUBSYS_ID=$7:$8
        fi
        export ACTION PCI_CLASS PCI_ID PCI_SLOT PCI_SUBSYS_ID
        echo ACTION=$ACTION PCI_CLASS=$PCI_CLASS PCI_ID=$PCI_ID PCI_SLOT=$PCI_SLOT PCI_SUBSYS_ID=$PCI_SUBSYS_ID /sbin/hotplug-beta pci
        env -i - ACTION=$ACTION PCI_CLASS=$PCI_CLASS PCI_ID=$PCI_ID PCI_SLOT=$PCI_SLOT PCI_SUBSYS_ID=$PCI_SUBSYS_ID /sbin/hotplug-beta pci
    done
}

I ran into one problem with ohci1394 and I cant find an answer:
an OHCI controller has PCI class 0x0c00. The modules.pcimap entry is generated via this define in ohci1394.c:
#define PCI_CLASS_FIREWIRE_OHCI ((PCI_CLASS_SERIAL_FIREWIRE << 8) | 0x10)

Why is there a '| 0x10'? How can this line of code in pci.agent ever match?

if [ $class_temp -eq $class ]; then

$class comes from the modules.pcimap, pci_class from the hotplug event. I have looked for the kernel event env variable $PCI_CLASS. This is a %04X in run_sbin_hotplug() in drivers/pci/pci.c, the comment in %pci.agent states it is a %06X (which would make sense, but where is the lowbyte filled?)

Maybe I got that all wrong, I cant see how the current code is supposed to load drivers at boot time. 2.4 does somehow work with the pcimodules binary which is shipped by some distros, but this doesnt work at all for 2.6.
What is supposed to happen in pci.rc?

Signature · 14 lines
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#1 lore raw
Quoted 5 lines · Olaf Hering

Hello,

what is the purpose of pci_boot_events() in pci.rc? I mean, how can that ever work in the current cvs? I did it that way and it appears to work ok for a 2.4 kernel (probably also for 2.6):

Something that could work for 2.4:

Index: etc/hotplug/pci.agent
=================================RCS file: /cvsroot/linux-hotplug/admin/etc/hotplug/pci.agent,v retrieving revision 1.13

hotplug/pci.agent +23 -6
diff -u -p -r1.13 pci.agent
@@ -9,7 +9,7 @@
 # Kernel Cardbus/PCI params are:
 #	
 #	ACTION=%s [add or remove]
-#	PCI_CLASS=%06X
+#	PCI_CLASS=%04X
 #	PCI_ID=%04X:%04X
 #	PCI_SLOT_NAME=%s
 #	PCI_SUBSYS_ID=%04X:%04X
@@ -41,7 +41,7 @@ MAP_CURRENT=$MODULE_DIR/modules.pcimap
 # accumulates list of modules we may care about
 DRIVERS 
-if [ "$PCI_CLASS" = ""  -o "$PCI_CLASS" = "" ]; then
+if [ "$PCI_CLASS" = "" ]; then
     mesg Bad PCI agent invocation
     exit 1
 fi
@@ -69,13 +69,30 @@ pci_convert_vars ()
 	exit 1
     fi
 
-    pci_class=0x$PCI_CLASS
-
-    set `echo $PCI_ID | $AWK -F: '{print "0x" $1, "0x" $2 }'` ''
+    case "$PCI_CLASS" in
+    	0x*) pci_class=$PCI_CLASS ;;
+	*) pci_class=0x$PCI_CLASS ;;
+    esac
+
+    case "$PCI_ID" in
+    	0x*)
+	set `echo $PCI_ID | $AWK -F: '{print $1, $2 }'` ''
+	;;
+	*)
+	set `echo $PCI_ID | $AWK -F: '{print "0x" $1, "0x" $2 }'` ''
+    	;;
+    esac
     pci_id_vendor=$1
     pci_id_device=$2
 
-    set `echo $PCI_SUBSYS_ID | $AWK -F: '{print "0x" $1, "0x" $2 }'` ''
+    case "$PCI_SUBSYS_ID" in
+	0x*)
+	set `echo $PCI_SUBSYS_ID | $AWK -F: '{print $1, $2 }'` ''
+	;;
+	*)
+	set `echo $PCI_SUBSYS_ID | $AWK -F: '{print "0x" $1, "0x" $2 }'` ''
+	;;
+    esac
     pci_subid_vendor=$1
     pci_subid_device=$2
 }

Index: etc/hotplug/pci.rc
=================================RCS file: /cvsroot/linux-hotplug/admin/etc/hotplug/pci.rc,v retrieving revision 1.7

hotplug/pci.rc +24 -22

56 lines not on this page · raw message

Signature · 14 lines
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#2 lore raw
In reply to Olaf Hering
Quoted 7 lines · Olaf Hering
Quoted 5 lines · Olaf Hering

Hello,

what is the purpose of pci_boot_events() in pci.rc? I mean, how can that ever work in the current cvs? I did it that way and it appears to work ok for a 2.4 kernel (probably also for 2.6):

Here is another try:

modules will be loaded during boot, should work for 2.4 and 2.6 make pcimodules obsolete
PCI_CLASS is matched twice
PCI_CLASS is passed as 4 digit value from the kernel. some pci variables already have the 0x prefix in sysfs

Index: etc/hotplug/pci.agent
=================================RCS file: /cvsroot/linux-hotplug/admin/etc/hotplug/pci.agent,v retrieving revision 1.13

hotplug/pci.agent +23 -6
diff -u -p -r1.13 pci.agent
@@ -9,7 +9,7 @@
 # Kernel Cardbus/PCI params are:
 #	
 #	ACTION=%s [add or remove]
-#	PCI_CLASS=%06X
+#	PCI_CLASS=%04X
 #	PCI_ID=%04X:%04X
 #	PCI_SLOT_NAME=%s
 #	PCI_SUBSYS_ID=%04X:%04X
@@ -41,7 +41,7 @@ MAP_CURRENT=$MODULE_DIR/modules.pcimap
 # accumulates list of modules we may care about
 DRIVERS 
-if [ "$PCI_CLASS" = ""  -o "$PCI_CLASS" = "" ]; then
+if [ "$PCI_CLASS" = "" ]; then
     mesg Bad PCI agent invocation
     exit 1
 fi
@@ -69,13 +69,30 @@ pci_convert_vars ()
 	exit 1
     fi
 
-    pci_class=0x$PCI_CLASS
-
-    set `echo $PCI_ID | $AWK -F: '{print "0x" $1, "0x" $2 }'` ''
+    case "$PCI_CLASS" in
+    	0x*) pci_class=$PCI_CLASS ;;
+	*) pci_class=0x$PCI_CLASS ;;
+    esac
+
+    case "$PCI_ID" in
+    	0x*)
+	set `echo $PCI_ID | $AWK -F: '{print $1, $2 }'` ''
+	;;
+	*)
+	set `echo $PCI_ID | $AWK -F: '{print "0x" $1, "0x" $2 }'` ''
+    	;;
+    esac
     pci_id_vendor=$1
     pci_id_device=$2
 
-    set `echo $PCI_SUBSYS_ID | $AWK -F: '{print "0x" $1, "0x" $2 }'` ''
+    case "$PCI_SUBSYS_ID" in
+	0x*)
+	set `echo $PCI_SUBSYS_ID | $AWK -F: '{print $1, $2 }'` ''
+	;;
+	*)
+	set `echo $PCI_SUBSYS_ID | $AWK -F: '{print "0x" $1, "0x" $2 }'` ''
+	;;
+    esac
     pci_subid_vendor=$1
     pci_subid_device=$2
 }

Index: etc/hotplug/pci.rc
=================================RCS file: /cvsroot/linux-hotplug/admin/etc/hotplug/pci.rc,v retrieving revision 1.7

hotplug/pci.rc +59 -42

128 lines not on this page · raw message

Signature · 14 lines
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG


-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel