#!/sbin/runscript # read this article to know what to do # http://gentoo.org/doc/en/articles/hardware-stability-p2.xml#doc_chap3_pre2 # report bugs to: http://bugs.gentoo.org/show_bug.cgi?id=173347 depend() { before bootmisc hdparm } checkconfig() { if [ ! -f /etc/conf.d/pciparm ]; then ewarn "/etc/conf.d/pciparm does not exist, skipping" return 1 fi if [ -z "${PCIPARM_BUS_0}" -a -z "${PCIPARM_VENDOR_0}" ]; then ewarn "PCIPARM_BUS_0 or PCIPARM_VENDOR_0 not set in /etc/conf.d/pciparm, skipping" return 1 fi } do_setpci() { #ewarn "do_setpci: /usr/sbin/setpci $SETPCI_OPT $@" SWITCH=$1 if [ "$SWITCH" = "-d" ]; then DESC="(vendor)" else DESC="(bus)" fi shift SPEC_ID=$1 shift ebegin "Setting PCI params for $DESC $SPEC_ID to $@" /usr/sbin/setpci $SETPCI_OPT $SWITCH $SPEC_ID $@ eend $? SWITCH="" SPEC_ID="" } start() { if get_bootparam "nopciparm" ; then ewarn "Skipping pciparm init as requested in kernel cmdline" return 0 fi checkconfig || return 1 SETPCI_OPT="" if [ "$VERBOSE" = "yes" ]; then SETPCI_OPT="$SETPCI_OPT -v" fi if [ -n "$PCIPARM_ALL" ]; then do_setpci -d '*:*' $PCIPARM_ALL fi SEQ_BUS=0 while true; do BUS_OPT=`eval echo '$'PCIPARM_BUS_${SEQ_BUS}` if [ -z "$BUS_OPT" ]; then break fi do_setpci -s $BUS_OPT SEQ_BUS=$(($SEQ_BUS+1)) done SEQ_VENDOR=0 while true; do VENDOR_OPT=`eval echo '$'PCIPARM_VENDOR_${SEQ_VENDOR}` if [ -z "$VENDOR_OPT" ]; then break fi do_setpci -d $VENDOR_OPT SEQ_VENDOR=$(($SEQ_VENDOR+1)) done }