From: Olaf Hering <olh@suse.de>
To: linux-hotplug@vger.kernel.org
Subject: Re: pci coldplug
Date: Tue, 11 Nov 2003 20:23:05 +0000 [thread overview]
Message-ID: <marc-linux-hotplug-106858226431741@msgid-missing> (raw)
In-Reply-To: <marc-linux-hotplug-106806874232064@msgid-missing>
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
prev parent reply other threads:[~2003-11-11 20:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-05 21:43 pci coldplug Olaf Hering
2003-11-05 23:19 ` Olaf Hering
2003-11-11 20:23 ` Olaf Hering [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-linux-hotplug-106858226431741@msgid-missing \
--to=olh@suse.de \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.