Gentoo Archives: gentoo-commits

From: "Robin H. Johnson (robbat2)" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in sys-apps/pciutils/files: conf.d-pciparm init.d-pciparm
Date: Tue, 07 Oct 2008 11:07:20
Message-Id: E1KnAPF-00081T-M4@stork.gentoo.org
1 robbat2 08/10/07 11:07:09
2
3 Added: conf.d-pciparm init.d-pciparm
4 Log:
5 Implement pciparm init.d per bug #173347.
6 (Portage version: 2.2_rc11/cvs/Linux 2.6.27-rc1-10246-gca5de40 x86_64)
7
8 Revision Changes Path
9 1.1 sys-apps/pciutils/files/conf.d-pciparm
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-apps/pciutils/files/conf.d-pciparm?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-apps/pciutils/files/conf.d-pciparm?rev=1.1&content-type=text/plain
13
14 Index: conf.d-pciparm
15 ===================================================================
16 # PCI tweaking article:
17 # http://www.gentoo.org/doc/en/articles/hardware-stability-p2.xml
18 #
19 # Apply to all devices:
20 # PCIPARM_ALL="...."
21 # Cards also can be addressed by vid:pid or by bus:slot.func
22 # (see setpci man page relative to -d and -s options)
23 # PCIPARM_(BUS|VENDOR)_#="...."
24 # Where # is sequentially numbered from zero.
25
26 # Examples:
27 # "open up" the PCI bus by allowing fairly long bursts
28 # for all devices, increasing performance
29 # (equivalent to: setpci -v -d *:* latency_timer=b0)
30 #PCIPARM_ALL="latency_timer=b0"
31
32 # maximize latency timers for network and audio,
33 # allowing them to transmit more data per burst,
34 # preventing buffer over/under-run conditions
35 #PCIPARM_BUS_0="00:04.0 latency_timer=ff"
36 #PCIPARM_BUS_1="01:04.0 latency_timer=ff"
37 #PCIPARM_VENDOR_0="1057:3410 latency_timer=ff"
38
39 # -v : whether to be verbose about changes
40 # -D : dry-run, no commit
41 # -f : do not warn if the change is already set
42 # (see the setpci manpage for more advanced options)
43 SETPCI_OPT="-f"
44
45
46
47 1.1 sys-apps/pciutils/files/init.d-pciparm
48
49 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-apps/pciutils/files/init.d-pciparm?rev=1.1&view=markup
50 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-apps/pciutils/files/init.d-pciparm?rev=1.1&content-type=text/plain
51
52 Index: init.d-pciparm
53 ===================================================================
54 #!/sbin/runscript
55 # Copyright 1999-2004 Gentoo Foundation
56 # Distributed under the terms of the GNU General Public License v2
57 # $Header: /var/cvsroot/gentoo-x86/sys-apps/pciutils/files/init.d-pciparm,v 1.1 2008/10/07 11:07:09 robbat2 Exp $
58
59 depend() {
60 before bootmisc hdparm
61 after localmount
62 }
63
64 checkconfig() {
65 if [ ! -f /etc/conf.d/pciparm ]; then
66 ewarn "/etc/conf.d/pciparm does not exist, skipping"
67 return 1
68 fi
69
70 if [ -z "${PCIPARM_ALL}" -a -z "${PCIPARM_BUS_0}" -a -z "${PCIPARM_VENDOR_0}" ]; then
71 ewarn "None of PCIPARM_ALL, PCIPARM_BUS_* or PCIPARM_VENDOR_* set in /etc/conf.d/pciparm"
72 return 1
73 fi
74 }
75
76 do_setpci() {
77 #ewarn "do_setpci: /usr/sbin/setpci $SETPCI_OPT $@"
78 SWITCH=$1
79 case "$SWITCH" in
80 -d) DESC="(vendor)" ;;
81 -s) DESC="(bus)" ;;
82 *) eerror "Unknown setpci type!" ; return 1 ;;
83 esac
84 shift
85 SPEC_ID=$1
86 shift
87 if [[ -z "$SPEC_ID" ]]; then
88 eerror "Missing device specifier!"
89 return 1
90 fi
91 if [[ -z "$@" ]]; then
92 eerror "Missing configuration to set for $DESC $SPEC_ID!"
93 return 1
94 fi
95 ebegin "Setting PCI params for $DESC $SPEC_ID to $@"
96 /usr/sbin/setpci $SETPCI_OPT $SWITCH $SPEC_ID "$@"
97 eend $?
98 SWITCH=""
99 SPEC_ID=""
100 }
101
102 start() {
103 if get_bootparam "nopciparm" ; then
104 ewarn "Skipping pciparm init as requested in kernel cmdline"
105 return 0
106 fi
107
108 checkconfig || return 1
109
110 if [ -n "$PCIPARM_ALL" ]; then
111 do_setpci -d '*:*' $PCIPARM_ALL
112 fi
113
114 SEQ_BUS=0
115 while true; do
116 BUS_OPT=`eval echo '$'PCIPARM_BUS_${SEQ_BUS}`
117 [[ -z "$BUS_OPT" ]] && break
118 do_setpci -s $BUS_OPT
119 SEQ_BUS=$(($SEQ_BUS+1))
120 done
121
122 SEQ_VENDOR=0
123 while true; do
124 VENDOR_OPT=`eval echo '$'PCIPARM_VENDOR_${SEQ_VENDOR}`
125 [[ -z "$VENDOR_OPT" ]] && break
126 do_setpci -d $VENDOR_OPT
127 SEQ_VENDOR=$(($SEQ_VENDOR+1))
128 done
129 }