* Re: pci coldplug
2003-11-05 21:43 pci coldplug Olaf Hering
@ 2003-11-05 23:19 ` Olaf Hering
2003-11-11 20:23 ` Olaf Hering
1 sibling, 0 replies; 3+ messages in thread
From: Olaf Hering @ 2003-11-05 23:19 UTC (permalink / raw)
To: linux-hotplug
On Wed, Nov 05, Olaf Hering wrote:
> 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
diff -u -p -r1.13 pci.agent
--- etc/hotplug/pci.agent 16 Sep 2003 19:42:17 -0000 1.13
+++ etc/hotplug/pci.agent 5 Nov 2003 23:08:02 -0000
@@ -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
diff -u -p -r1.7 pci.rc
--- etc/hotplug/pci.rc 6 Jun 2003 18:27:23 -0000 1.7
+++ etc/hotplug/pci.rc 5 Nov 2003 23:08:02 -0000
@@ -27,32 +27,34 @@ fi
pci_boot_events ()
{
- #
- # FIXME on 2.5, /sys/bus/pci/devices gives some of this
- # information, and more can be gotten with 'lspci'.
- # don't expect pcimodules to exist!!
- #
- LISTER=`type -p pcimodules`
- if [ "$LISTER" = "" -o ! -f /proc/bus/pci/devices -o ! -x pci.agent ]; then
+ if [ ! -x /sbin/lspci -o ! -f /proc/bus/pci/devices -o ! -x pci.agent ]; then
echo $"** can't synthesize pci hotplug events"
return
fi
- # make sure the pci agent will run
- ACTION≠d
- PCI_CLASS=0
- PCI_ID=0:0
- PCI_SLOT=0:0.0
- PCI_SUBSYS_ID=0:0
- export ACTION PCI_CLASS PCI_ID PCI_SLOT PCI_SUBSYS_ID
-
- # these notifications will be handled by pcimodules
- for BUS in `cd /proc/bus/pci;find * -type d -print`; do
- for SLOT_FUNC in `cd /proc/bus/pci/$BUS; echo *`; do
- PCI_SLOT=$BUS:$SLOT_FUNC
- : hotplug pci for $PCI_SLOT
- /sbin/hotplug pci
- done
+ /sbin/lspci -nm | sed 's/"//g' | while read pci_data ; do
+ set - $pci_data ''
+ ACTION≠d
+ PCI_SLOT=$1
+ shift 2
+ PCI_CLASS=$1
+ shift
+ PCI_ID=$1:$2
+ shift 2
+ case "$1" in
+ -r*) shift;;
+ esac
+ case "$1" in
+ -p*) pci_progif=${1#-p} ; shift ;;
+ *) pci_progif\0 ;;
+ esac
+ if [ "$1" = "" ] ; then
+ PCI_SUBSYS_ID=0:0
+ else
+ PCI_SUBSYS_ID=$1:$2
+ fi
+ echo ACTION=$ACTION PCI_CLASS=$PCI_CLASS$pci_progif PCI_ID=$PCI_ID PCI_SLOT=$PCI_SLOT PCI_SUBSYS_ID=$PCI_SUBSYS_ID /sbin/hotplug pci
+ env -i - ACTION=$ACTION PCI_CLASS=$PCI_CLASS$pci_progif PCI_ID=$PCI_ID PCI_SLOT=$PCI_SLOT PCI_SUBSYS_ID=$PCI_SUBSYS_ID /sbin/hotplug pci
done
}
--
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
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: pci coldplug
2003-11-05 21:43 pci coldplug Olaf Hering
2003-11-05 23:19 ` Olaf Hering
@ 2003-11-11 20:23 ` Olaf Hering
1 sibling, 0 replies; 3+ messages in thread
From: Olaf Hering @ 2003-11-11 20:23 UTC (permalink / raw)
To: linux-hotplug
On Thu, Nov 06, Olaf Hering wrote:
> On Wed, Nov 05, Olaf Hering wrote:
>
> > 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
diff -u -p -r1.13 pci.agent
--- etc/hotplug/pci.agent 16 Sep 2003 19:42:17 -0000 1.13
+++ etc/hotplug/pci.agent 10 Nov 2003 12:06:55 -0000
@@ -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
diff -u -p -r1.7 pci.rc
--- etc/hotplug/pci.rc 6 Jun 2003 18:27:23 -0000 1.7
+++ etc/hotplug/pci.rc 10 Nov 2003 12:06:55 -0000
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# vim: syntax=sh
#
# pci.rc mostly to recover lost boot-time pci hotplug events
@@ -10,61 +10,78 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin
cd /etc/hotplug
-# source function library
-if [ -f /etc/init.d/functions ]; then
- . /etc/init.d/functions
-elif [ -f /etc/rc.d/init.d/functions ]; then
- . /etc/rc.d/init.d/functions
-fi
-
-. hotplug.functions
-
-
-# # override any of the defaults?
-# if [ -f /etc/sysconfig/pci ]; then
-# . /etc/sysconfig/pci
-# fi
-
-pci_boot_events ()
-{
- #
- # FIXME on 2.5, /sys/bus/pci/devices gives some of this
- # information, and more can be gotten with 'lspci'.
- # don't expect pcimodules to exist!!
- #
- LISTER=`type -p pcimodules`
- if [ "$LISTER" = "" -o ! -f /proc/bus/pci/devices -o ! -x pci.agent ]; then
- echo $"** can't synthesize pci hotplug events"
+pci_boot_events_24 () {
+
+ if [ ! -x /sbin/lspci -o ! -f /proc/bus/pci/devices ]; then
+ echo $" ** can't synthesize pci hotplug events"
return
fi
+ echo
+ /sbin/lspci -nm | sed 's/"//g' | while read pci_data ; do
+ set - $pci_data ''
+ ACTIONd
+ PCI_SLOT=$1
+ shift 2
+ PCI_CLASS=$1
+ shift
+ PCI_ID=$1:$2
+ shift 2
+ case "$1" in
+ -r*) shift;;
+ esac
+ case "$1" in
+ -p*) pci_progif=${1#-p} ; shift ;;
+ *) pci_progif\0 ;;
+ esac
+ if [ "$1" = "" ] ; then
+ PCI_SUBSYS_ID=0:0
+ else
+ PCI_SUBSYS_ID=$1:$2
+ fi
+ echo PCI_CLASS=$PCI_CLASS$pci_progif PCI_ID=$PCI_ID PCI_SLOT_NAME=$PCI_SLOT PCI_SUBSYS_ID=$PCI_SUBSYS_ID
+ $ENV ACTION=$ACTION PCI_CLASS=$PCI_CLASS$pci_progif PCI_ID=$PCI_ID PCI_SLOT_NAME=$PCI_SLOT PCI_SUBSYS_ID=$PCI_SUBSYS_ID /sbin/hotplug pci
+ done
+}
- # make sure the pci agent will run
- ACTIONd
- PCI_CLASS=0
- PCI_ID=0:0
- PCI_SLOT=0:0.0
- PCI_SUBSYS_ID=0:0
- export ACTION PCI_CLASS PCI_ID PCI_SLOT PCI_SUBSYS_ID
-
- # these notifications will be handled by pcimodules
- for BUS in `cd /proc/bus/pci;find * -type d -print`; do
- for SLOT_FUNC in `cd /proc/bus/pci/$BUS; echo *`; do
- PCI_SLOT=$BUS:$SLOT_FUNC
- : hotplug pci for $PCI_SLOT
- /sbin/hotplug pci
+pci_boot_events_26 () {
+ cd /sys/bus/pci/devices
+ echo
+ for i in * ; do
+ echo PCI_SLOT_NAME=$i PCI_CLASS=$(< $i/class) PCI_ID="$(< $i/vendor):$(< $i/device)" PCI_SUBSYS_ID="$(< $i/subsystem_vendor):$(< $i/subsystem_device)"
+ $ENV ACTIONd PCI_CLASS=$(< $i/class) PCI_ID="$(< $i/vendor):$(< $i/device)" PCI_SLOT_NAME=$i PCI_SUBSYS_ID="$(< $i/subsystem_vendor):$(< $i/subsystem_device)" /sbin/hotplug pci
done
- done
+}
+
+pci_boot_events ()
+{
+ local ENV
+ if [ ! -x pci.agent ]; then
+ echo $" ** can't synthesize pci hotplug events"
+ return
+ fi
+ if [ -x /usr/bin/env ] ; then
+ ENV='env -i - '
+ else
+ ENV+ fi
+ if [ -d /sys/bus/pci/devices ] ; then
+ pci_boot_events_26
+ else
+ pci_boot_events_24
+ fi
}
# See how we were called.
case "$1" in
start)
- pci_boot_events
+ pci_boot_events ; :
;;
stop)
# echo $"pci stop -- ignored"
;;
status)
+ ;;
+ status-verbose)
echo $"PCI Status for kernel: " `uname -srm`
echo ''
@@ -93,4 +110,5 @@ case "$1" in
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 1
+ ;;
esac
--
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
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 3+ messages in thread