diff options
author | Anton Altaparmakov <aia21@cantab.net> | 2005-06-08 10:45:45 -0400 |
---|---|---|
committer | Anton Altaparmakov <aia21@cantab.net> | 2005-06-08 10:45:45 -0400 |
commit | 364f6c717deef4a3ac4982e670fa9846b43cd060 (patch) | |
tree | 47e3967d6e2220130f2c070e300c97709143b28f | |
parent | 4ff4258a3e558814a3d48c50a59cd22f56bbea2f (diff) | |
parent | 1d6757fbff5bc86e94e59ab0d7bdd7e71351d839 (diff) |
Automatic merge with /usr/src/ntfs-2.6.git
172 files changed, 5252 insertions, 2286 deletions
diff --git a/Documentation/DocBook/libata.tmpl b/Documentation/DocBook/libata.tmpl index cf2fce7707da..6df1dfd18b65 100644 --- a/Documentation/DocBook/libata.tmpl +++ b/Documentation/DocBook/libata.tmpl | |||
@@ -14,7 +14,7 @@ | |||
14 | </authorgroup> | 14 | </authorgroup> |
15 | 15 | ||
16 | <copyright> | 16 | <copyright> |
17 | <year>2003</year> | 17 | <year>2003-2005</year> |
18 | <holder>Jeff Garzik</holder> | 18 | <holder>Jeff Garzik</holder> |
19 | </copyright> | 19 | </copyright> |
20 | 20 | ||
@@ -44,30 +44,38 @@ | |||
44 | 44 | ||
45 | <toc></toc> | 45 | <toc></toc> |
46 | 46 | ||
47 | <chapter id="libataThanks"> | 47 | <chapter id="libataIntroduction"> |
48 | <title>Thanks</title> | 48 | <title>Introduction</title> |
49 | <para> | 49 | <para> |
50 | The bulk of the ATA knowledge comes thanks to long conversations with | 50 | libATA is a library used inside the Linux kernel to support ATA host |
51 | Andre Hedrick (www.linux-ide.org). | 51 | controllers and devices. libATA provides an ATA driver API, class |
52 | transports for ATA and ATAPI devices, and SCSI<->ATA translation | ||
53 | for ATA devices according to the T10 SAT specification. | ||
52 | </para> | 54 | </para> |
53 | <para> | 55 | <para> |
54 | Thanks to Alan Cox for pointing out similarities | 56 | This Guide documents the libATA driver API, library functions, library |
55 | between SATA and SCSI, and in general for motivation to hack on | 57 | internals, and a couple sample ATA low-level drivers. |
56 | libata. | ||
57 | </para> | ||
58 | <para> | ||
59 | libata's device detection | ||
60 | method, ata_pio_devchk, and in general all the early probing was | ||
61 | based on extensive study of Hale Landis's probe/reset code in his | ||
62 | ATADRVR driver (www.ata-atapi.com). | ||
63 | </para> | 58 | </para> |
64 | </chapter> | 59 | </chapter> |
65 | 60 | ||
66 | <chapter id="libataDriverApi"> | 61 | <chapter id="libataDriverApi"> |
67 | <title>libata Driver API</title> | 62 | <title>libata Driver API</title> |
63 | <para> | ||
64 | struct ata_port_operations is defined for every low-level libata | ||
65 | hardware driver, and it controls how the low-level driver | ||
66 | interfaces with the ATA and SCSI layers. | ||
67 | </para> | ||
68 | <para> | ||
69 | FIS-based drivers will hook into the system with ->qc_prep() and | ||
70 | ->qc_issue() high-level hooks. Hardware which behaves in a manner | ||
71 | similar to PCI IDE hardware may utilize several generic helpers, | ||
72 | defining at a bare minimum the bus I/O addresses of the ATA shadow | ||
73 | register blocks. | ||
74 | </para> | ||
68 | <sect1> | 75 | <sect1> |
69 | <title>struct ata_port_operations</title> | 76 | <title>struct ata_port_operations</title> |
70 | 77 | ||
78 | <sect2><title>Disable ATA port</title> | ||
71 | <programlisting> | 79 | <programlisting> |
72 | void (*port_disable) (struct ata_port *); | 80 | void (*port_disable) (struct ata_port *); |
73 | </programlisting> | 81 | </programlisting> |
@@ -78,6 +86,9 @@ void (*port_disable) (struct ata_port *); | |||
78 | unplug). | 86 | unplug). |
79 | </para> | 87 | </para> |
80 | 88 | ||
89 | </sect2> | ||
90 | |||
91 | <sect2><title>Post-IDENTIFY device configuration</title> | ||
81 | <programlisting> | 92 | <programlisting> |
82 | void (*dev_config) (struct ata_port *, struct ata_device *); | 93 | void (*dev_config) (struct ata_port *, struct ata_device *); |
83 | </programlisting> | 94 | </programlisting> |
@@ -88,6 +99,9 @@ void (*dev_config) (struct ata_port *, struct ata_device *); | |||
88 | issue of SET FEATURES - XFER MODE, and prior to operation. | 99 | issue of SET FEATURES - XFER MODE, and prior to operation. |
89 | </para> | 100 | </para> |
90 | 101 | ||
102 | </sect2> | ||
103 | |||
104 | <sect2><title>Set PIO/DMA mode</title> | ||
91 | <programlisting> | 105 | <programlisting> |
92 | void (*set_piomode) (struct ata_port *, struct ata_device *); | 106 | void (*set_piomode) (struct ata_port *, struct ata_device *); |
93 | void (*set_dmamode) (struct ata_port *, struct ata_device *); | 107 | void (*set_dmamode) (struct ata_port *, struct ata_device *); |
@@ -108,6 +122,9 @@ void (*post_set_mode) (struct ata_port *ap); | |||
108 | ->set_dma_mode() is only called if DMA is possible. | 122 | ->set_dma_mode() is only called if DMA is possible. |
109 | </para> | 123 | </para> |
110 | 124 | ||
125 | </sect2> | ||
126 | |||
127 | <sect2><title>Taskfile read/write</title> | ||
111 | <programlisting> | 128 | <programlisting> |
112 | void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf); | 129 | void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf); |
113 | void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); | 130 | void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); |
@@ -120,6 +137,9 @@ void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); | |||
120 | taskfile register values. | 137 | taskfile register values. |
121 | </para> | 138 | </para> |
122 | 139 | ||
140 | </sect2> | ||
141 | |||
142 | <sect2><title>ATA command execute</title> | ||
123 | <programlisting> | 143 | <programlisting> |
124 | void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf); | 144 | void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf); |
125 | </programlisting> | 145 | </programlisting> |
@@ -129,17 +149,37 @@ void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf); | |||
129 | ->tf_load(), to be initiated in hardware. | 149 | ->tf_load(), to be initiated in hardware. |
130 | </para> | 150 | </para> |
131 | 151 | ||
152 | </sect2> | ||
153 | |||
154 | <sect2><title>Per-cmd ATAPI DMA capabilities filter</title> | ||
155 | <programlisting> | ||
156 | int (*check_atapi_dma) (struct ata_queued_cmd *qc); | ||
157 | </programlisting> | ||
158 | |||
159 | <para> | ||
160 | Allow low-level driver to filter ATA PACKET commands, returning a status | ||
161 | indicating whether or not it is OK to use DMA for the supplied PACKET | ||
162 | command. | ||
163 | </para> | ||
164 | |||
165 | </sect2> | ||
166 | |||
167 | <sect2><title>Read specific ATA shadow registers</title> | ||
132 | <programlisting> | 168 | <programlisting> |
133 | u8 (*check_status)(struct ata_port *ap); | 169 | u8 (*check_status)(struct ata_port *ap); |
134 | void (*dev_select)(struct ata_port *ap, unsigned int device); | 170 | u8 (*check_altstatus)(struct ata_port *ap); |
171 | u8 (*check_err)(struct ata_port *ap); | ||
135 | </programlisting> | 172 | </programlisting> |
136 | 173 | ||
137 | <para> | 174 | <para> |
138 | Reads the Status ATA shadow register from hardware. On some | 175 | Reads the Status/AltStatus/Error ATA shadow register from |
139 | hardware, this has the side effect of clearing the interrupt | 176 | hardware. On some hardware, reading the Status register has |
140 | condition. | 177 | the side effect of clearing the interrupt condition. |
141 | </para> | 178 | </para> |
142 | 179 | ||
180 | </sect2> | ||
181 | |||
182 | <sect2><title>Select ATA device on bus</title> | ||
143 | <programlisting> | 183 | <programlisting> |
144 | void (*dev_select)(struct ata_port *ap, unsigned int device); | 184 | void (*dev_select)(struct ata_port *ap, unsigned int device); |
145 | </programlisting> | 185 | </programlisting> |
@@ -147,9 +187,13 @@ void (*dev_select)(struct ata_port *ap, unsigned int device); | |||
147 | <para> | 187 | <para> |
148 | Issues the low-level hardware command(s) that causes one of N | 188 | Issues the low-level hardware command(s) that causes one of N |
149 | hardware devices to be considered 'selected' (active and | 189 | hardware devices to be considered 'selected' (active and |
150 | available for use) on the ATA bus. | 190 | available for use) on the ATA bus. This generally has no |
191 | meaning on FIS-based devices. | ||
151 | </para> | 192 | </para> |
152 | 193 | ||
194 | </sect2> | ||
195 | |||
196 | <sect2><title>Reset ATA bus</title> | ||
153 | <programlisting> | 197 | <programlisting> |
154 | void (*phy_reset) (struct ata_port *ap); | 198 | void (*phy_reset) (struct ata_port *ap); |
155 | </programlisting> | 199 | </programlisting> |
@@ -162,17 +206,31 @@ void (*phy_reset) (struct ata_port *ap); | |||
162 | functions ata_bus_reset() or sata_phy_reset() for this hook. | 206 | functions ata_bus_reset() or sata_phy_reset() for this hook. |
163 | </para> | 207 | </para> |
164 | 208 | ||
209 | </sect2> | ||
210 | |||
211 | <sect2><title>Control PCI IDE BMDMA engine</title> | ||
165 | <programlisting> | 212 | <programlisting> |
166 | void (*bmdma_setup) (struct ata_queued_cmd *qc); | 213 | void (*bmdma_setup) (struct ata_queued_cmd *qc); |
167 | void (*bmdma_start) (struct ata_queued_cmd *qc); | 214 | void (*bmdma_start) (struct ata_queued_cmd *qc); |
215 | void (*bmdma_stop) (struct ata_port *ap); | ||
216 | u8 (*bmdma_status) (struct ata_port *ap); | ||
168 | </programlisting> | 217 | </programlisting> |
169 | 218 | ||
170 | <para> | 219 | <para> |
171 | When setting up an IDE BMDMA transaction, these hooks arm | 220 | When setting up an IDE BMDMA transaction, these hooks arm |
172 | (->bmdma_setup) and fire (->bmdma_start) the hardware's DMA | 221 | (->bmdma_setup), fire (->bmdma_start), and halt (->bmdma_stop) |
173 | engine. | 222 | the hardware's DMA engine. ->bmdma_status is used to read the standard |
223 | PCI IDE DMA Status register. | ||
174 | </para> | 224 | </para> |
175 | 225 | ||
226 | <para> | ||
227 | These hooks are typically either no-ops, or simply not implemented, in | ||
228 | FIS-based drivers. | ||
229 | </para> | ||
230 | |||
231 | </sect2> | ||
232 | |||
233 | <sect2><title>High-level taskfile hooks</title> | ||
176 | <programlisting> | 234 | <programlisting> |
177 | void (*qc_prep) (struct ata_queued_cmd *qc); | 235 | void (*qc_prep) (struct ata_queued_cmd *qc); |
178 | int (*qc_issue) (struct ata_queued_cmd *qc); | 236 | int (*qc_issue) (struct ata_queued_cmd *qc); |
@@ -190,20 +248,26 @@ int (*qc_issue) (struct ata_queued_cmd *qc); | |||
190 | ->qc_issue is used to make a command active, once the hardware | 248 | ->qc_issue is used to make a command active, once the hardware |
191 | and S/G tables have been prepared. IDE BMDMA drivers use the | 249 | and S/G tables have been prepared. IDE BMDMA drivers use the |
192 | helper function ata_qc_issue_prot() for taskfile protocol-based | 250 | helper function ata_qc_issue_prot() for taskfile protocol-based |
193 | dispatch. More advanced drivers roll their own ->qc_issue | 251 | dispatch. More advanced drivers implement their own ->qc_issue. |
194 | implementation, using this as the "issue new ATA command to | ||
195 | hardware" hook. | ||
196 | </para> | 252 | </para> |
197 | 253 | ||
254 | </sect2> | ||
255 | |||
256 | <sect2><title>Timeout (error) handling</title> | ||
198 | <programlisting> | 257 | <programlisting> |
199 | void (*eng_timeout) (struct ata_port *ap); | 258 | void (*eng_timeout) (struct ata_port *ap); |
200 | </programlisting> | 259 | </programlisting> |
201 | 260 | ||
202 | <para> | 261 | <para> |
203 | This is a high level error handling function, called from the | 262 | This is a high level error handling function, called from the |
204 | error handling thread, when a command times out. | 263 | error handling thread, when a command times out. Most newer |
264 | hardware will implement its own error handling code here. IDE BMDMA | ||
265 | drivers may use the helper function ata_eng_timeout(). | ||
205 | </para> | 266 | </para> |
206 | 267 | ||
268 | </sect2> | ||
269 | |||
270 | <sect2><title>Hardware interrupt handling</title> | ||
207 | <programlisting> | 271 | <programlisting> |
208 | irqreturn_t (*irq_handler)(int, void *, struct pt_regs *); | 272 | irqreturn_t (*irq_handler)(int, void *, struct pt_regs *); |
209 | void (*irq_clear) (struct ata_port *); | 273 | void (*irq_clear) (struct ata_port *); |
@@ -216,6 +280,9 @@ void (*irq_clear) (struct ata_port *); | |||
216 | is quiet. | 280 | is quiet. |
217 | </para> | 281 | </para> |
218 | 282 | ||
283 | </sect2> | ||
284 | |||
285 | <sect2><title>SATA phy read/write</title> | ||
219 | <programlisting> | 286 | <programlisting> |
220 | u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg); | 287 | u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg); |
221 | void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, | 288 | void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, |
@@ -227,6 +294,9 @@ void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, | |||
227 | if ->phy_reset hook called the sata_phy_reset() helper function. | 294 | if ->phy_reset hook called the sata_phy_reset() helper function. |
228 | </para> | 295 | </para> |
229 | 296 | ||
297 | </sect2> | ||
298 | |||
299 | <sect2><title>Init and shutdown</title> | ||
230 | <programlisting> | 300 | <programlisting> |
231 | int (*port_start) (struct ata_port *ap); | 301 | int (*port_start) (struct ata_port *ap); |
232 | void (*port_stop) (struct ata_port *ap); | 302 | void (*port_stop) (struct ata_port *ap); |
@@ -240,15 +310,17 @@ void (*host_stop) (struct ata_host_set *host_set); | |||
240 | tasks. | 310 | tasks. |
241 | </para> | 311 | </para> |
242 | <para> | 312 | <para> |
243 | ->host_stop() is called when the rmmod or hot unplug process | ||
244 | begins. The hook must stop all hardware interrupts, DMA | ||
245 | engines, etc. | ||
246 | </para> | ||
247 | <para> | ||
248 | ->port_stop() is called after ->host_stop(). It's sole function | 313 | ->port_stop() is called after ->host_stop(). It's sole function |
249 | is to release DMA/memory resources, now that they are no longer | 314 | is to release DMA/memory resources, now that they are no longer |
250 | actively being used. | 315 | actively being used. |
251 | </para> | 316 | </para> |
317 | <para> | ||
318 | ->host_stop() is called after all ->port_stop() calls | ||
319 | have completed. The hook must finalize hardware shutdown, release DMA | ||
320 | and other resources, etc. | ||
321 | </para> | ||
322 | |||
323 | </sect2> | ||
252 | 324 | ||
253 | </sect1> | 325 | </sect1> |
254 | </chapter> | 326 | </chapter> |
@@ -279,4 +351,24 @@ void (*host_stop) (struct ata_host_set *host_set); | |||
279 | !Idrivers/scsi/sata_sil.c | 351 | !Idrivers/scsi/sata_sil.c |
280 | </chapter> | 352 | </chapter> |
281 | 353 | ||
354 | <chapter id="libataThanks"> | ||
355 | <title>Thanks</title> | ||
356 | <para> | ||
357 | The bulk of the ATA knowledge comes thanks to long conversations with | ||
358 | Andre Hedrick (www.linux-ide.org), and long hours pondering the ATA | ||
359 | and SCSI specifications. | ||
360 | </para> | ||
361 | <para> | ||
362 | Thanks to Alan Cox for pointing out similarities | ||
363 | between SATA and SCSI, and in general for motivation to hack on | ||
364 | libata. | ||
365 | </para> | ||
366 | <para> | ||
367 | libata's device detection | ||
368 | method, ata_pio_devchk, and in general all the early probing was | ||
369 | based on extensive study of Hale Landis's probe/reset code in his | ||
370 | ATADRVR driver (www.ata-atapi.com). | ||
371 | </para> | ||
372 | </chapter> | ||
373 | |||
282 | </book> | 374 | </book> |
diff --git a/Documentation/cpu-freq/cpufreq-stats.txt b/Documentation/cpu-freq/cpufreq-stats.txt new file mode 100644 index 000000000000..e2d1e760b4ba --- /dev/null +++ b/Documentation/cpu-freq/cpufreq-stats.txt | |||
@@ -0,0 +1,128 @@ | |||
1 | |||
2 | CPU frequency and voltage scaling statictics in the Linux(TM) kernel | ||
3 | |||
4 | |||
5 | L i n u x c p u f r e q - s t a t s d r i v e r | ||
6 | |||
7 | - information for users - | ||
8 | |||
9 | |||
10 | Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> | ||
11 | |||
12 | Contents | ||
13 | 1. Introduction | ||
14 | 2. Statistics Provided (with example) | ||
15 | 3. Configuring cpufreq-stats | ||
16 | |||
17 | |||
18 | 1. Introduction | ||
19 | |||
20 | cpufreq-stats is a driver that provices CPU frequency statistics for each CPU. | ||
21 | This statistics is provided in /sysfs as a bunch of read_only interfaces. This | ||
22 | interface (when configured) will appear in a seperate directory under cpufreq | ||
23 | in /sysfs (<sysfs root>/devices/system/cpu/cpuX/cpufreq/stats/) for each CPU. | ||
24 | Various statistics will form read_only files under this directory. | ||
25 | |||
26 | This driver is designed to be independent of any particular cpufreq_driver | ||
27 | that may be running on your CPU. So, it will work with any cpufreq_driver. | ||
28 | |||
29 | |||
30 | 2. Statistics Provided (with example) | ||
31 | |||
32 | cpufreq stats provides following statistics (explained in detail below). | ||
33 | - time_in_state | ||
34 | - total_trans | ||
35 | - trans_table | ||
36 | |||
37 | All the statistics will be from the time the stats driver has been inserted | ||
38 | to the time when a read of a particular statistic is done. Obviously, stats | ||
39 | driver will not have any information about the the frequcny transitions before | ||
40 | the stats driver insertion. | ||
41 | |||
42 | -------------------------------------------------------------------------------- | ||
43 | <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # ls -l | ||
44 | total 0 | ||
45 | drwxr-xr-x 2 root root 0 May 14 16:06 . | ||
46 | drwxr-xr-x 3 root root 0 May 14 15:58 .. | ||
47 | -r--r--r-- 1 root root 4096 May 14 16:06 time_in_state | ||
48 | -r--r--r-- 1 root root 4096 May 14 16:06 total_trans | ||
49 | -r--r--r-- 1 root root 4096 May 14 16:06 trans_table | ||
50 | -------------------------------------------------------------------------------- | ||
51 | |||
52 | - time_in_state | ||
53 | This gives the amount of time spent in each of the frequencies supported by | ||
54 | this CPU. The cat output will have "<frequency> <time>" pair in each line, which | ||
55 | will mean this CPU spent <time> usertime units of time at <frequency>. Output | ||
56 | will have one line for each of the supported freuencies. usertime units here | ||
57 | is 10mS (similar to other time exported in /proc). | ||
58 | |||
59 | -------------------------------------------------------------------------------- | ||
60 | <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat time_in_state | ||
61 | 3600000 2089 | ||
62 | 3400000 136 | ||
63 | 3200000 34 | ||
64 | 3000000 67 | ||
65 | 2800000 172488 | ||
66 | -------------------------------------------------------------------------------- | ||
67 | |||
68 | |||
69 | - total_trans | ||
70 | This gives the total number of frequency transitions on this CPU. The cat | ||
71 | output will have a single count which is the total number of frequency | ||
72 | transitions. | ||
73 | |||
74 | -------------------------------------------------------------------------------- | ||
75 | <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat total_trans | ||
76 | 20 | ||
77 | -------------------------------------------------------------------------------- | ||
78 | |||
79 | - trans_table | ||
80 | This will give a fine grained information about all the CPU frequency | ||
81 | transitions. The cat output here is a two dimensional matrix, where an entry | ||
82 | <i,j> (row i, column j) represents the count of number of transitions from | ||
83 | Freq_i to Freq_j. Freq_i is in descending order with increasing rows and | ||
84 | Freq_j is in descending order with increasing columns. The output here also | ||
85 | contains the actual freq values for each row and column for better readability. | ||
86 | |||
87 | -------------------------------------------------------------------------------- | ||
88 | <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # cat trans_table | ||
89 | From : To | ||
90 | : 3600000 3400000 3200000 3000000 2800000 | ||
91 | 3600000: 0 5 0 0 0 | ||
92 | 3400000: 4 0 2 0 0 | ||
93 | 3200000: 0 1 0 2 0 | ||
94 | 3000000: 0 0 1 0 3 | ||
95 | 2800000: 0 0 0 2 0 | ||
96 | -------------------------------------------------------------------------------- | ||
97 | |||
98 | |||
99 | 3. Configuring cpufreq-stats | ||
100 | |||
101 | To configure cpufreq-stats in your kernel | ||
102 | Config Main Menu | ||
103 | Power management options (ACPI, APM) ---> | ||
104 | CPU Frequency scaling ---> | ||
105 | [*] CPU Frequency scaling | ||
106 | <*> CPU frequency translation statistics | ||
107 | [*] CPU frequency translation statistics details | ||
108 | |||
109 | |||
110 | "CPU Frequency scaling" (CONFIG_CPU_FREQ) should be enabled to configure | ||
111 | cpufreq-stats. | ||
112 | |||
113 | "CPU frequency translation statistics" (CONFIG_CPU_FREQ_STAT) provides the | ||
114 | basic statistics which includes time_in_state and total_trans. | ||
115 | |||
116 | "CPU frequency translation statistics details" (CONFIG_CPU_FREQ_STAT_DETAILS) | ||
117 | provides fine grained cpufreq stats by trans_table. The reason for having a | ||
118 | seperate config option for trans_table is: | ||
119 | - trans_table goes against the traditional /sysfs rule of one value per | ||
120 | interface. It provides a whole bunch of value in a 2 dimensional matrix | ||
121 | form. | ||
122 | |||
123 | Once these two options are enabled and your CPU supports cpufrequency, you | ||
124 | will be able to see the CPU frequency statistics in /sysfs. | ||
125 | |||
126 | |||
127 | |||
128 | |||
diff --git a/MAINTAINERS b/MAINTAINERS index 5b8483334de1..65ad8251e4bc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -239,6 +239,12 @@ L: linux-usb-devel@lists.sourceforge.net | |||
239 | W: http://www.linux-usb.org/SpeedTouch/ | 239 | W: http://www.linux-usb.org/SpeedTouch/ |
240 | S: Maintained | 240 | S: Maintained |
241 | 241 | ||
242 | ALI1563 I2C DRIVER | ||
243 | P: Rudolf Marek | ||
244 | M: r.marek@sh.cvut.cz | ||
245 | L: sensors@stimpy.netroedge.com | ||
246 | S: Maintained | ||
247 | |||
242 | ALPHA PORT | 248 | ALPHA PORT |
243 | P: Richard Henderson | 249 | P: Richard Henderson |
244 | M: rth@twiddle.net | 250 | M: rth@twiddle.net |
@@ -1023,8 +1029,8 @@ W: http://www.ia64-linux.org/ | |||
1023 | S: Maintained | 1029 | S: Maintained |
1024 | 1030 | ||
1025 | SN-IA64 (Itanium) SUB-PLATFORM | 1031 | SN-IA64 (Itanium) SUB-PLATFORM |
1026 | P: Jesse Barnes | 1032 | P: Greg Edwards |
1027 | M: jbarnes@sgi.com | 1033 | M: edwardsg@sgi.com |
1028 | L: linux-altix@sgi.com | 1034 | L: linux-altix@sgi.com |
1029 | L: linux-ia64@vger.kernel.org | 1035 | L: linux-ia64@vger.kernel.org |
1030 | W: http://www.sgi.com/altix | 1036 | W: http://www.sgi.com/altix |
@@ -1,7 +1,7 @@ | |||
1 | VERSION = 2 | 1 | VERSION = 2 |
2 | PATCHLEVEL = 6 | 2 | PATCHLEVEL = 6 |
3 | SUBLEVEL = 12 | 3 | SUBLEVEL = 12 |
4 | EXTRAVERSION =-rc5 | 4 | EXTRAVERSION =-rc6 |
5 | NAME=Woozy Numbat | 5 | NAME=Woozy Numbat |
6 | 6 | ||
7 | # *DOCUMENTATION* | 7 | # *DOCUMENTATION* |
diff --git a/arch/h8300/kernel/process.c b/arch/h8300/kernel/process.c index 134aec1c6d19..b5f83e9f04db 100644 --- a/arch/h8300/kernel/process.c +++ b/arch/h8300/kernel/process.c | |||
@@ -54,7 +54,7 @@ asmlinkage void ret_from_fork(void); | |||
54 | void default_idle(void) | 54 | void default_idle(void) |
55 | { | 55 | { |
56 | while(1) { | 56 | while(1) { |
57 | if (need_resched()) { | 57 | if (!need_resched()) { |
58 | local_irq_enable(); | 58 | local_irq_enable(); |
59 | __asm__("sleep"); | 59 | __asm__("sleep"); |
60 | local_irq_disable(); | 60 | local_irq_disable(); |
diff --git a/arch/i386/kernel/cpu/cpufreq/Kconfig b/arch/i386/kernel/cpu/cpufreq/Kconfig index f25ffd74235c..0f1eb507233b 100644 --- a/arch/i386/kernel/cpu/cpufreq/Kconfig +++ b/arch/i386/kernel/cpu/cpufreq/Kconfig | |||
@@ -23,7 +23,7 @@ config X86_ACPI_CPUFREQ | |||
23 | If in doubt, say N. | 23 | If in doubt, say N. |
24 | 24 | ||
25 | config ELAN_CPUFREQ | 25 | config ELAN_CPUFREQ |
26 | tristate "AMD Elan" | 26 | tristate "AMD Elan SC400 and SC410" |
27 | select CPU_FREQ_TABLE | 27 | select CPU_FREQ_TABLE |
28 | depends on X86_ELAN | 28 | depends on X86_ELAN |
29 | ---help--- | 29 | ---help--- |
@@ -38,6 +38,18 @@ config ELAN_CPUFREQ | |||
38 | 38 | ||
39 | If in doubt, say N. | 39 | If in doubt, say N. |
40 | 40 | ||
41 | config SC520_CPUFREQ | ||
42 | tristate "AMD Elan SC520" | ||
43 | select CPU_FREQ_TABLE | ||
44 | depends on X86_ELAN | ||
45 | ---help--- | ||
46 | This adds the CPUFreq driver for AMD Elan SC520 processor. | ||
47 | |||
48 | For details, take a look at <file:Documentation/cpu-freq/>. | ||
49 | |||
50 | If in doubt, say N. | ||
51 | |||
52 | |||
41 | config X86_POWERNOW_K6 | 53 | config X86_POWERNOW_K6 |
42 | tristate "AMD Mobile K6-2/K6-3 PowerNow!" | 54 | tristate "AMD Mobile K6-2/K6-3 PowerNow!" |
43 | select CPU_FREQ_TABLE | 55 | select CPU_FREQ_TABLE |
diff --git a/arch/i386/kernel/cpu/cpufreq/Makefile b/arch/i386/kernel/cpu/cpufreq/Makefile index a922e97aeedd..2e894f1c8910 100644 --- a/arch/i386/kernel/cpu/cpufreq/Makefile +++ b/arch/i386/kernel/cpu/cpufreq/Makefile | |||
@@ -3,6 +3,7 @@ obj-$(CONFIG_X86_POWERNOW_K7) += powernow-k7.o | |||
3 | obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o | 3 | obj-$(CONFIG_X86_POWERNOW_K8) += powernow-k8.o |
4 | obj-$(CONFIG_X86_LONGHAUL) += longhaul.o | 4 | obj-$(CONFIG_X86_LONGHAUL) += longhaul.o |
5 | obj-$(CONFIG_ELAN_CPUFREQ) += elanfreq.o | 5 | obj-$(CONFIG_ELAN_CPUFREQ) += elanfreq.o |
6 | obj-$(CONFIG_SC520_CPUFREQ) += sc520_freq.o | ||
6 | obj-$(CONFIG_X86_LONGRUN) += longrun.o | 7 | obj-$(CONFIG_X86_LONGRUN) += longrun.o |
7 | obj-$(CONFIG_X86_GX_SUSPMOD) += gx-suspmod.o | 8 | obj-$(CONFIG_X86_GX_SUSPMOD) += gx-suspmod.o |
8 | obj-$(CONFIG_X86_SPEEDSTEP_ICH) += speedstep-ich.o | 9 | obj-$(CONFIG_X86_SPEEDSTEP_ICH) += speedstep-ich.o |
diff --git a/arch/i386/kernel/cpu/cpufreq/longhaul.c b/arch/i386/kernel/cpu/cpufreq/longhaul.c index ab0f9f5aac11..04e3563da4fe 100644 --- a/arch/i386/kernel/cpu/cpufreq/longhaul.c +++ b/arch/i386/kernel/cpu/cpufreq/longhaul.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/cpufreq.h> | 29 | #include <linux/cpufreq.h> |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/string.h> | 31 | #include <linux/string.h> |
32 | #include <linux/pci.h> | ||
32 | 33 | ||
33 | #include <asm/msr.h> | 34 | #include <asm/msr.h> |
34 | #include <asm/timex.h> | 35 | #include <asm/timex.h> |
@@ -119,7 +120,13 @@ static int longhaul_get_cpu_mult(void) | |||
119 | static void do_powersaver(union msr_longhaul *longhaul, | 120 | static void do_powersaver(union msr_longhaul *longhaul, |
120 | unsigned int clock_ratio_index) | 121 | unsigned int clock_ratio_index) |
121 | { | 122 | { |
123 | struct pci_dev *dev; | ||
124 | unsigned long flags; | ||
125 | unsigned int tmp_mask; | ||
122 | int version; | 126 | int version; |
127 | int i; | ||
128 | u16 pci_cmd; | ||
129 | u16 cmd_state[64]; | ||
123 | 130 | ||
124 | switch (cpu_model) { | 131 | switch (cpu_model) { |
125 | case CPU_EZRA_T: | 132 | case CPU_EZRA_T: |
@@ -137,17 +144,58 @@ static void do_powersaver(union msr_longhaul *longhaul, | |||
137 | longhaul->bits.SoftBusRatio4 = (clock_ratio_index & 0x10) >> 4; | 144 | longhaul->bits.SoftBusRatio4 = (clock_ratio_index & 0x10) >> 4; |
138 | longhaul->bits.EnableSoftBusRatio = 1; | 145 | longhaul->bits.EnableSoftBusRatio = 1; |
139 | longhaul->bits.RevisionKey = 0; | 146 | longhaul->bits.RevisionKey = 0; |
140 | local_irq_disable(); | 147 | |
141 | wrmsrl(MSR_VIA_LONGHAUL, longhaul->val); | 148 | preempt_disable(); |
149 | local_irq_save(flags); | ||
150 | |||
151 | /* | ||
152 | * get current pci bus master state for all devices | ||
153 | * and clear bus master bit | ||
154 | */ | ||
155 | dev = NULL; | ||
156 | i = 0; | ||
157 | do { | ||
158 | dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev); | ||
159 | if (dev != NULL) { | ||
160 | pci_read_config_word(dev, PCI_COMMAND, &pci_cmd); | ||
161 | cmd_state[i++] = pci_cmd; | ||
162 | pci_cmd &= ~PCI_COMMAND_MASTER; | ||
163 | pci_write_config_word(dev, PCI_COMMAND, pci_cmd); | ||
164 | } | ||
165 | } while (dev != NULL); | ||
166 | |||
167 | tmp_mask=inb(0x21); /* works on C3. save mask. */ | ||
168 | outb(0xFE,0x21); /* TMR0 only */ | ||
169 | outb(0xFF,0x80); /* delay */ | ||
170 | |||
142 | local_irq_enable(); | 171 | local_irq_enable(); |
172 | |||
173 | __hlt(); | ||
174 | wrmsrl(MSR_VIA_LONGHAUL, longhaul->val); | ||
143 | __hlt(); | 175 | __hlt(); |
144 | 176 | ||
177 | local_irq_disable(); | ||
178 | |||
179 | outb(tmp_mask,0x21); /* restore mask */ | ||
180 | |||
181 | /* restore pci bus master state for all devices */ | ||
182 | dev = NULL; | ||
183 | i = 0; | ||
184 | do { | ||
185 | dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev); | ||
186 | if (dev != NULL) { | ||
187 | pci_cmd = cmd_state[i++]; | ||
188 | pci_write_config_byte(dev, PCI_COMMAND, pci_cmd); | ||
189 | } | ||
190 | } while (dev != NULL); | ||
191 | local_irq_restore(flags); | ||
192 | preempt_enable(); | ||
193 | |||
194 | /* disable bus ratio bit */ | ||
145 | rdmsrl(MSR_VIA_LONGHAUL, longhaul->val); | 195 | rdmsrl(MSR_VIA_LONGHAUL, longhaul->val); |
146 | longhaul->bits.EnableSoftBusRatio = 0; | 196 | longhaul->bits.EnableSoftBusRatio = 0; |
147 | longhaul->bits.RevisionKey = version; | 197 | longhaul->bits.RevisionKey = version; |
148 | local_irq_disable(); | ||
149 | wrmsrl(MSR_VIA_LONGHAUL, longhaul->val); | 198 | wrmsrl(MSR_VIA_LONGHAUL, longhaul->val); |
150 | local_irq_enable(); | ||
151 | } | 199 | } |
152 | 200 | ||
153 | /** | 201 | /** |
@@ -578,7 +626,7 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy) | |||
578 | longhaul_setup_voltagescaling(); | 626 | longhaul_setup_voltagescaling(); |
579 | 627 | ||
580 | policy->governor = CPUFREQ_DEFAULT_GOVERNOR; | 628 | policy->governor = CPUFREQ_DEFAULT_GOVERNOR; |
581 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | 629 | policy->cpuinfo.transition_latency = 200000; /* nsec */ |
582 | policy->cur = calc_speed(longhaul_get_cpu_mult()); | 630 | policy->cur = calc_speed(longhaul_get_cpu_mult()); |
583 | 631 | ||
584 | ret = cpufreq_frequency_table_cpuinfo(policy, longhaul_table); | 632 | ret = cpufreq_frequency_table_cpuinfo(policy, longhaul_table); |
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k7.c b/arch/i386/kernel/cpu/cpufreq/powernow-k7.c index 913f652623d9..5c530064eb74 100644 --- a/arch/i386/kernel/cpu/cpufreq/powernow-k7.c +++ b/arch/i386/kernel/cpu/cpufreq/powernow-k7.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/dmi.h> | 23 | #include <linux/dmi.h> |
24 | 24 | ||
25 | #include <asm/msr.h> | 25 | #include <asm/msr.h> |
26 | #include <asm/timer.h> | ||
26 | #include <asm/timex.h> | 27 | #include <asm/timex.h> |
27 | #include <asm/io.h> | 28 | #include <asm/io.h> |
28 | #include <asm/system.h> | 29 | #include <asm/system.h> |
@@ -586,13 +587,17 @@ static int __init powernow_cpu_init (struct cpufreq_policy *policy) | |||
586 | 587 | ||
587 | rdmsrl (MSR_K7_FID_VID_STATUS, fidvidstatus.val); | 588 | rdmsrl (MSR_K7_FID_VID_STATUS, fidvidstatus.val); |
588 | 589 | ||
589 | /* A K7 with powernow technology is set to max frequency by BIOS */ | 590 | /* recalibrate cpu_khz */ |
590 | fsb = (10 * cpu_khz) / fid_codes[fidvidstatus.bits.MFID]; | 591 | result = recalibrate_cpu_khz(); |
592 | if (result) | ||
593 | return result; | ||
594 | |||
595 | fsb = (10 * cpu_khz) / fid_codes[fidvidstatus.bits.CFID]; | ||
591 | if (!fsb) { | 596 | if (!fsb) { |
592 | printk(KERN_WARNING PFX "can not determine bus frequency\n"); | 597 | printk(KERN_WARNING PFX "can not determine bus frequency\n"); |
593 | return -EINVAL; | 598 | return -EINVAL; |
594 | } | 599 | } |
595 | dprintk("FSB: %3d.%03d MHz\n", fsb/1000, fsb%1000); | 600 | dprintk("FSB: %3dMHz\n", fsb/1000); |
596 | 601 | ||
597 | if (dmi_check_system(powernow_dmi_table) || acpi_force) { | 602 | if (dmi_check_system(powernow_dmi_table) || acpi_force) { |
598 | printk (KERN_INFO PFX "PSB/PST known to be broken. Trying ACPI instead\n"); | 603 | printk (KERN_INFO PFX "PSB/PST known to be broken. Trying ACPI instead\n"); |
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c index a65ff7e32e5d..10cc096c0ade 100644 --- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c +++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * GNU general public license version 2. See "COPYING" or | 4 | * GNU general public license version 2. See "COPYING" or |
5 | * http://www.gnu.org/licenses/gpl.html | 5 | * http://www.gnu.org/licenses/gpl.html |
6 | * | 6 | * |
7 | * Support : paul.devriendt@amd.com | 7 | * Support : mark.langsdorf@amd.com |
8 | * | 8 | * |
9 | * Based on the powernow-k7.c module written by Dave Jones. | 9 | * Based on the powernow-k7.c module written by Dave Jones. |
10 | * (C) 2003 Dave Jones <davej@codemonkey.org.uk> on behalf of SuSE Labs | 10 | * (C) 2003 Dave Jones <davej@codemonkey.org.uk> on behalf of SuSE Labs |
@@ -15,12 +15,13 @@ | |||
15 | * | 15 | * |
16 | * Valuable input gratefully received from Dave Jones, Pavel Machek, | 16 | * Valuable input gratefully received from Dave Jones, Pavel Machek, |
17 | * Dominik Brodowski, and others. | 17 | * Dominik Brodowski, and others. |
18 | * Originally developed by Paul Devriendt. | ||
18 | * Processor information obtained from Chapter 9 (Power and Thermal Management) | 19 | * Processor information obtained from Chapter 9 (Power and Thermal Management) |
19 | * of the "BIOS and Kernel Developer's Guide for the AMD Athlon 64 and AMD | 20 | * of the "BIOS and Kernel Developer's Guide for the AMD Athlon 64 and AMD |
20 | * Opteron Processors" available for download from www.amd.com | 21 | * Opteron Processors" available for download from www.amd.com |
21 | * | 22 | * |
22 | * Tables for specific CPUs can be infrerred from | 23 | * Tables for specific CPUs can be infrerred from |
23 | * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/30430.pdf | 24 | * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/30430.pdf |
24 | */ | 25 | */ |
25 | 26 | ||
26 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
@@ -30,6 +31,7 @@ | |||
30 | #include <linux/cpufreq.h> | 31 | #include <linux/cpufreq.h> |
31 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
32 | #include <linux/string.h> | 33 | #include <linux/string.h> |
34 | #include <linux/cpumask.h> | ||
33 | 35 | ||
34 | #include <asm/msr.h> | 36 | #include <asm/msr.h> |
35 | #include <asm/io.h> | 37 | #include <asm/io.h> |
@@ -42,7 +44,7 @@ | |||
42 | 44 | ||
43 | #define PFX "powernow-k8: " | 45 | #define PFX "powernow-k8: " |
44 | #define BFX PFX "BIOS error: " | 46 | #define BFX PFX "BIOS error: " |
45 | #define VERSION "version 1.00.09e" | 47 | #define VERSION "version 1.40.2" |
46 | #include "powernow-k8.h" | 48 | #include "powernow-k8.h" |
47 | 49 | ||
48 | /* serialize freq changes */ | 50 | /* serialize freq changes */ |
@@ -50,6 +52,10 @@ static DECLARE_MUTEX(fidvid_sem); | |||
50 | 52 | ||
51 | static struct powernow_k8_data *powernow_data[NR_CPUS]; | 53 | static struct powernow_k8_data *powernow_data[NR_CPUS]; |
52 | 54 | ||
55 | #ifndef CONFIG_SMP | ||
56 | static cpumask_t cpu_core_map[1]; | ||
57 | #endif | ||
58 | |||
53 | /* Return a frequency in MHz, given an input fid */ | 59 | /* Return a frequency in MHz, given an input fid */ |
54 | static u32 find_freq_from_fid(u32 fid) | 60 | static u32 find_freq_from_fid(u32 fid) |
55 | { | 61 | { |
@@ -274,11 +280,18 @@ static int core_voltage_pre_transition(struct powernow_k8_data *data, u32 reqvid | |||
274 | { | 280 | { |
275 | u32 rvosteps = data->rvo; | 281 | u32 rvosteps = data->rvo; |
276 | u32 savefid = data->currfid; | 282 | u32 savefid = data->currfid; |
283 | u32 maxvid, lo; | ||
277 | 284 | ||
278 | dprintk("ph1 (cpu%d): start, currfid 0x%x, currvid 0x%x, reqvid 0x%x, rvo 0x%x\n", | 285 | dprintk("ph1 (cpu%d): start, currfid 0x%x, currvid 0x%x, reqvid 0x%x, rvo 0x%x\n", |
279 | smp_processor_id(), | 286 | smp_processor_id(), |
280 | data->currfid, data->currvid, reqvid, data->rvo); | 287 | data->currfid, data->currvid, reqvid, data->rvo); |
281 | 288 | ||
289 | rdmsr(MSR_FIDVID_STATUS, lo, maxvid); | ||
290 | maxvid = 0x1f & (maxvid >> 16); | ||
291 | dprintk("ph1 maxvid=0x%x\n", maxvid); | ||
292 | if (reqvid < maxvid) /* lower numbers are higher voltages */ | ||
293 | reqvid = maxvid; | ||
294 | |||
282 | while (data->currvid > reqvid) { | 295 | while (data->currvid > reqvid) { |
283 | dprintk("ph1: curr 0x%x, req vid 0x%x\n", | 296 | dprintk("ph1: curr 0x%x, req vid 0x%x\n", |
284 | data->currvid, reqvid); | 297 | data->currvid, reqvid); |
@@ -286,8 +299,8 @@ static int core_voltage_pre_transition(struct powernow_k8_data *data, u32 reqvid | |||
286 | return 1; | 299 | return 1; |
287 | } | 300 | } |
288 | 301 | ||
289 | while ((rvosteps > 0) && ((data->rvo + data->currvid) > reqvid)) { | 302 | while ((rvosteps > 0) && ((data->rvo + data->currvid) > reqvid)) { |
290 | if (data->currvid == 0) { | 303 | if (data->currvid == maxvid) { |
291 | rvosteps = 0; | 304 | rvosteps = 0; |
292 | } else { | 305 | } else { |
293 | dprintk("ph1: changing vid for rvo, req 0x%x\n", | 306 | dprintk("ph1: changing vid for rvo, req 0x%x\n", |
@@ -671,7 +684,7 @@ static int find_psb_table(struct powernow_k8_data *data) | |||
671 | * BIOS and Kernel Developer's Guide, which is available on | 684 | * BIOS and Kernel Developer's Guide, which is available on |
672 | * www.amd.com | 685 | * www.amd.com |
673 | */ | 686 | */ |
674 | printk(KERN_ERR PFX "BIOS error - no PSB\n"); | 687 | printk(KERN_INFO PFX "BIOS error - no PSB or ACPI _PSS objects\n"); |
675 | return -ENODEV; | 688 | return -ENODEV; |
676 | } | 689 | } |
677 | 690 | ||
@@ -695,7 +708,7 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) | |||
695 | struct cpufreq_frequency_table *powernow_table; | 708 | struct cpufreq_frequency_table *powernow_table; |
696 | 709 | ||
697 | if (acpi_processor_register_performance(&data->acpi_data, data->cpu)) { | 710 | if (acpi_processor_register_performance(&data->acpi_data, data->cpu)) { |
698 | dprintk("register performance failed\n"); | 711 | dprintk("register performance failed: bad ACPI data\n"); |
699 | return -EIO; | 712 | return -EIO; |
700 | } | 713 | } |
701 | 714 | ||
@@ -746,22 +759,23 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) | |||
746 | continue; | 759 | continue; |
747 | } | 760 | } |
748 | 761 | ||
749 | if (fid < HI_FID_TABLE_BOTTOM) { | 762 | /* verify only 1 entry from the lo frequency table */ |
750 | if (cntlofreq) { | 763 | if (fid < HI_FID_TABLE_BOTTOM) { |
751 | /* if both entries are the same, ignore this | 764 | if (cntlofreq) { |
752 | * one... | 765 | /* if both entries are the same, ignore this |
753 | */ | 766 | * one... |
754 | if ((powernow_table[i].frequency != powernow_table[cntlofreq].frequency) || | 767 | */ |
755 | (powernow_table[i].index != powernow_table[cntlofreq].index)) { | 768 | if ((powernow_table[i].frequency != powernow_table[cntlofreq].frequency) || |
756 | printk(KERN_ERR PFX "Too many lo freq table entries\n"); | 769 | (powernow_table[i].index != powernow_table[cntlofreq].index)) { |
757 | goto err_out_mem; | 770 | printk(KERN_ERR PFX "Too many lo freq table entries\n"); |
758 | } | 771 | goto err_out_mem; |
759 | 772 | } | |
760 | dprintk("double low frequency table entry, ignoring it.\n"); | 773 | |
761 | powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID; | 774 | dprintk("double low frequency table entry, ignoring it.\n"); |
762 | continue; | 775 | powernow_table[i].frequency = CPUFREQ_ENTRY_INVALID; |
763 | } else | 776 | continue; |
764 | cntlofreq = i; | 777 | } else |
778 | cntlofreq = i; | ||
765 | } | 779 | } |
766 | 780 | ||
767 | if (powernow_table[i].frequency != (data->acpi_data.states[i].core_frequency * 1000)) { | 781 | if (powernow_table[i].frequency != (data->acpi_data.states[i].core_frequency * 1000)) { |
@@ -816,7 +830,7 @@ static int transition_frequency(struct powernow_k8_data *data, unsigned int inde | |||
816 | { | 830 | { |
817 | u32 fid; | 831 | u32 fid; |
818 | u32 vid; | 832 | u32 vid; |
819 | int res; | 833 | int res, i; |
820 | struct cpufreq_freqs freqs; | 834 | struct cpufreq_freqs freqs; |
821 | 835 | ||
822 | dprintk("cpu %d transition to index %u\n", smp_processor_id(), index); | 836 | dprintk("cpu %d transition to index %u\n", smp_processor_id(), index); |
@@ -841,7 +855,8 @@ static int transition_frequency(struct powernow_k8_data *data, unsigned int inde | |||
841 | } | 855 | } |
842 | 856 | ||
843 | if ((fid < HI_FID_TABLE_BOTTOM) && (data->currfid < HI_FID_TABLE_BOTTOM)) { | 857 | if ((fid < HI_FID_TABLE_BOTTOM) && (data->currfid < HI_FID_TABLE_BOTTOM)) { |
844 | printk("ignoring illegal change in lo freq table-%x to 0x%x\n", | 858 | printk(KERN_ERR PFX |
859 | "ignoring illegal change in lo freq table-%x to 0x%x\n", | ||
845 | data->currfid, fid); | 860 | data->currfid, fid); |
846 | return 1; | 861 | return 1; |
847 | } | 862 | } |
@@ -850,18 +865,20 @@ static int transition_frequency(struct powernow_k8_data *data, unsigned int inde | |||
850 | smp_processor_id(), fid, vid); | 865 | smp_processor_id(), fid, vid); |
851 | 866 | ||
852 | freqs.cpu = data->cpu; | 867 | freqs.cpu = data->cpu; |
853 | |||
854 | freqs.old = find_khz_freq_from_fid(data->currfid); | 868 | freqs.old = find_khz_freq_from_fid(data->currfid); |
855 | freqs.new = find_khz_freq_from_fid(fid); | 869 | freqs.new = find_khz_freq_from_fid(fid); |
856 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 870 | for_each_cpu_mask(i, cpu_core_map[data->cpu]) { |
871 | freqs.cpu = i; | ||
872 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
873 | } | ||
857 | 874 | ||
858 | down(&fidvid_sem); | ||
859 | res = transition_fid_vid(data, fid, vid); | 875 | res = transition_fid_vid(data, fid, vid); |
860 | up(&fidvid_sem); | ||
861 | 876 | ||
862 | freqs.new = find_khz_freq_from_fid(data->currfid); | 877 | freqs.new = find_khz_freq_from_fid(data->currfid); |
863 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 878 | for_each_cpu_mask(i, cpu_core_map[data->cpu]) { |
864 | 879 | freqs.cpu = i; | |
880 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | ||
881 | } | ||
865 | return res; | 882 | return res; |
866 | } | 883 | } |
867 | 884 | ||
@@ -874,6 +891,7 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi | |||
874 | u32 checkvid = data->currvid; | 891 | u32 checkvid = data->currvid; |
875 | unsigned int newstate; | 892 | unsigned int newstate; |
876 | int ret = -EIO; | 893 | int ret = -EIO; |
894 | int i; | ||
877 | 895 | ||
878 | /* only run on specific CPU from here on */ | 896 | /* only run on specific CPU from here on */ |
879 | oldmask = current->cpus_allowed; | 897 | oldmask = current->cpus_allowed; |
@@ -902,22 +920,41 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi | |||
902 | data->currfid, data->currvid); | 920 | data->currfid, data->currvid); |
903 | 921 | ||
904 | if ((checkvid != data->currvid) || (checkfid != data->currfid)) { | 922 | if ((checkvid != data->currvid) || (checkfid != data->currfid)) { |
905 | printk(KERN_ERR PFX | 923 | printk(KERN_INFO PFX |
906 | "error - out of sync, fid 0x%x 0x%x, vid 0x%x 0x%x\n", | 924 | "error - out of sync, fix 0x%x 0x%x, vid 0x%x 0x%x\n", |
907 | checkfid, data->currfid, checkvid, data->currvid); | 925 | checkfid, data->currfid, checkvid, data->currvid); |
908 | } | 926 | } |
909 | 927 | ||
910 | if (cpufreq_frequency_table_target(pol, data->powernow_table, targfreq, relation, &newstate)) | 928 | if (cpufreq_frequency_table_target(pol, data->powernow_table, targfreq, relation, &newstate)) |
911 | goto err_out; | 929 | goto err_out; |
912 | 930 | ||
931 | down(&fidvid_sem); | ||
932 | |||
933 | for_each_cpu_mask(i, cpu_core_map[pol->cpu]) { | ||
934 | /* make sure the sibling is initialized */ | ||
935 | if (!powernow_data[i]) { | ||
936 | ret = 0; | ||
937 | up(&fidvid_sem); | ||
938 | goto err_out; | ||
939 | } | ||
940 | } | ||
941 | |||
913 | powernow_k8_acpi_pst_values(data, newstate); | 942 | powernow_k8_acpi_pst_values(data, newstate); |
914 | 943 | ||
915 | if (transition_frequency(data, newstate)) { | 944 | if (transition_frequency(data, newstate)) { |
916 | printk(KERN_ERR PFX "transition frequency failed\n"); | 945 | printk(KERN_ERR PFX "transition frequency failed\n"); |
917 | ret = 1; | 946 | ret = 1; |
947 | up(&fidvid_sem); | ||
918 | goto err_out; | 948 | goto err_out; |
919 | } | 949 | } |
920 | 950 | ||
951 | /* Update all the fid/vids of our siblings */ | ||
952 | for_each_cpu_mask(i, cpu_core_map[pol->cpu]) { | ||
953 | powernow_data[i]->currvid = data->currvid; | ||
954 | powernow_data[i]->currfid = data->currfid; | ||
955 | } | ||
956 | up(&fidvid_sem); | ||
957 | |||
921 | pol->cur = find_khz_freq_from_fid(data->currfid); | 958 | pol->cur = find_khz_freq_from_fid(data->currfid); |
922 | ret = 0; | 959 | ret = 0; |
923 | 960 | ||
@@ -962,7 +999,7 @@ static int __init powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
962 | */ | 999 | */ |
963 | 1000 | ||
964 | if ((num_online_cpus() != 1) || (num_possible_cpus() != 1)) { | 1001 | if ((num_online_cpus() != 1) || (num_possible_cpus() != 1)) { |
965 | printk(KERN_INFO PFX "MP systems not supported by PSB BIOS structure\n"); | 1002 | printk(KERN_ERR PFX "MP systems not supported by PSB BIOS structure\n"); |
966 | kfree(data); | 1003 | kfree(data); |
967 | return -ENODEV; | 1004 | return -ENODEV; |
968 | } | 1005 | } |
@@ -1003,6 +1040,7 @@ static int __init powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
1003 | schedule(); | 1040 | schedule(); |
1004 | 1041 | ||
1005 | pol->governor = CPUFREQ_DEFAULT_GOVERNOR; | 1042 | pol->governor = CPUFREQ_DEFAULT_GOVERNOR; |
1043 | pol->cpus = cpu_core_map[pol->cpu]; | ||
1006 | 1044 | ||
1007 | /* Take a crude guess here. | 1045 | /* Take a crude guess here. |
1008 | * That guess was in microseconds, so multiply with 1000 */ | 1046 | * That guess was in microseconds, so multiply with 1000 */ |
@@ -1069,7 +1107,7 @@ static unsigned int powernowk8_get (unsigned int cpu) | |||
1069 | return 0; | 1107 | return 0; |
1070 | } | 1108 | } |
1071 | preempt_disable(); | 1109 | preempt_disable(); |
1072 | 1110 | ||
1073 | if (query_current_values_with_pending_wait(data)) | 1111 | if (query_current_values_with_pending_wait(data)) |
1074 | goto out; | 1112 | goto out; |
1075 | 1113 | ||
@@ -1127,9 +1165,10 @@ static void __exit powernowk8_exit(void) | |||
1127 | cpufreq_unregister_driver(&cpufreq_amd64_driver); | 1165 | cpufreq_unregister_driver(&cpufreq_amd64_driver); |
1128 | } | 1166 | } |
1129 | 1167 | ||
1130 | MODULE_AUTHOR("Paul Devriendt <paul.devriendt@amd.com>"); | 1168 | MODULE_AUTHOR("Paul Devriendt <paul.devriendt@amd.com> and Mark Langsdorf <mark.langsdorf@amd.com."); |
1131 | MODULE_DESCRIPTION("AMD Athlon 64 and Opteron processor frequency driver."); | 1169 | MODULE_DESCRIPTION("AMD Athlon 64 and Opteron processor frequency driver."); |
1132 | MODULE_LICENSE("GPL"); | 1170 | MODULE_LICENSE("GPL"); |
1133 | 1171 | ||
1134 | late_initcall(powernowk8_init); | 1172 | late_initcall(powernowk8_init); |
1135 | module_exit(powernowk8_exit); | 1173 | module_exit(powernowk8_exit); |
1174 | |||
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.h b/arch/i386/kernel/cpu/cpufreq/powernow-k8.h index 63ebc8470f52..9ed5bf221cb7 100644 --- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.h +++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.h | |||
@@ -174,3 +174,18 @@ static int core_voltage_post_transition(struct powernow_k8_data *data, u32 reqvi | |||
174 | static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid); | 174 | static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid); |
175 | 175 | ||
176 | static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index); | 176 | static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index); |
177 | |||
178 | #ifndef for_each_cpu_mask | ||
179 | #define for_each_cpu_mask(i,mask) for (i=0;i<1;i++) | ||
180 | #endif | ||
181 | |||
182 | #ifdef CONFIG_SMP | ||
183 | static inline void define_siblings(int cpu, cpumask_t cpu_sharedcore_mask[]) | ||
184 | { | ||
185 | } | ||
186 | #else | ||
187 | static inline void define_siblings(int cpu, cpumask_t cpu_sharedcore_mask[]) | ||
188 | { | ||
189 | cpu_set(0, cpu_sharedcore_mask[0]); | ||
190 | } | ||
191 | #endif | ||
diff --git a/arch/i386/kernel/cpu/cpufreq/sc520_freq.c b/arch/i386/kernel/cpu/cpufreq/sc520_freq.c new file mode 100644 index 000000000000..ef457d50f4ac --- /dev/null +++ b/arch/i386/kernel/cpu/cpufreq/sc520_freq.c | |||
@@ -0,0 +1,186 @@ | |||
1 | /* | ||
2 | * sc520_freq.c: cpufreq driver for the AMD Elan sc520 | ||
3 | * | ||
4 | * Copyright (C) 2005 Sean Young <sean@mess.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * Based on elanfreq.c | ||
12 | * | ||
13 | * 2005-03-30: - initial revision | ||
14 | */ | ||
15 | |||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/init.h> | ||
19 | |||
20 | #include <linux/delay.h> | ||
21 | #include <linux/cpufreq.h> | ||
22 | |||
23 | #include <asm/msr.h> | ||
24 | #include <asm/timex.h> | ||
25 | #include <asm/io.h> | ||
26 | |||
27 | #define MMCR_BASE 0xfffef000 /* The default base address */ | ||
28 | #define OFFS_CPUCTL 0x2 /* CPU Control Register */ | ||
29 | |||
30 | static __u8 __iomem *cpuctl; | ||
31 | |||
32 | #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, "sc520_freq", msg) | ||
33 | |||
34 | static struct cpufreq_frequency_table sc520_freq_table[] = { | ||
35 | {0x01, 100000}, | ||
36 | {0x02, 133000}, | ||
37 | {0, CPUFREQ_TABLE_END}, | ||
38 | }; | ||
39 | |||
40 | static unsigned int sc520_freq_get_cpu_frequency(unsigned int cpu) | ||
41 | { | ||
42 | u8 clockspeed_reg = *cpuctl; | ||
43 | |||
44 | switch (clockspeed_reg & 0x03) { | ||
45 | default: | ||
46 | printk(KERN_ERR "sc520_freq: error: cpuctl register has unexpected value %02x\n", clockspeed_reg); | ||
47 | case 0x01: | ||
48 | return 100000; | ||
49 | case 0x02: | ||
50 | return 133000; | ||
51 | } | ||
52 | } | ||
53 | |||
54 | static void sc520_freq_set_cpu_state (unsigned int state) | ||
55 | { | ||
56 | |||
57 | struct cpufreq_freqs freqs; | ||
58 | u8 clockspeed_reg; | ||
59 | |||
60 | freqs.old = sc520_freq_get_cpu_frequency(0); | ||
61 | freqs.new = sc520_freq_table[state].frequency; | ||
62 | freqs.cpu = 0; /* AMD Elan is UP */ | ||
63 | |||
64 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | ||
65 | |||
66 | dprintk("attempting to set frequency to %i kHz\n", | ||
67 | sc520_freq_table[state].frequency); | ||
68 | |||
69 | local_irq_disable(); | ||
70 | |||
71 | clockspeed_reg = *cpuctl & ~0x03; | ||
72 | *cpuctl = clockspeed_reg | sc520_freq_table[state].index; | ||
73 | |||
74 | local_irq_enable(); | ||
75 | |||
76 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | ||
77 | }; | ||
78 | |||
79 | static int sc520_freq_verify (struct cpufreq_policy *policy) | ||
80 | { | ||
81 | return cpufreq_frequency_table_verify(policy, &sc520_freq_table[0]); | ||
82 | } | ||
83 | |||
84 | static int sc520_freq_target (struct cpufreq_policy *policy, | ||
85 | unsigned int target_freq, | ||
86 | unsigned int relation) | ||
87 | { | ||
88 | unsigned int newstate = 0; | ||
89 | |||
90 | if (cpufreq_frequency_table_target(policy, sc520_freq_table, target_freq, relation, &newstate)) | ||
91 | return -EINVAL; | ||
92 | |||
93 | sc520_freq_set_cpu_state(newstate); | ||
94 | |||
95 | return 0; | ||
96 | } | ||
97 | |||
98 | |||
99 | /* | ||
100 | * Module init and exit code | ||
101 | */ | ||
102 | |||
103 | static int sc520_freq_cpu_init(struct cpufreq_policy *policy) | ||
104 | { | ||
105 | struct cpuinfo_x86 *c = cpu_data; | ||
106 | int result; | ||
107 | |||
108 | /* capability check */ | ||
109 | if (c->x86_vendor != X86_VENDOR_AMD || | ||
110 | c->x86 != 4 || c->x86_model != 9) | ||
111 | return -ENODEV; | ||
112 | |||
113 | /* cpuinfo and default policy values */ | ||
114 | policy->governor = CPUFREQ_DEFAULT_GOVERNOR; | ||
115 | policy->cpuinfo.transition_latency = 1000000; /* 1ms */ | ||
116 | policy->cur = sc520_freq_get_cpu_frequency(0); | ||
117 | |||
118 | result = cpufreq_frequency_table_cpuinfo(policy, sc520_freq_table); | ||
119 | if (result) | ||
120 | return (result); | ||
121 | |||
122 | cpufreq_frequency_table_get_attr(sc520_freq_table, policy->cpu); | ||
123 | |||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | |||
128 | static int sc520_freq_cpu_exit(struct cpufreq_policy *policy) | ||
129 | { | ||
130 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | |||
135 | static struct freq_attr* sc520_freq_attr[] = { | ||
136 | &cpufreq_freq_attr_scaling_available_freqs, | ||
137 | NULL, | ||
138 | }; | ||
139 | |||
140 | |||
141 | static struct cpufreq_driver sc520_freq_driver = { | ||
142 | .get = sc520_freq_get_cpu_frequency, | ||
143 | .verify = sc520_freq_verify, | ||
144 | .target = sc520_freq_target, | ||
145 | .init = sc520_freq_cpu_init, | ||
146 | .exit = sc520_freq_cpu_exit, | ||
147 | .name = "sc520_freq", | ||
148 | .owner = THIS_MODULE, | ||
149 | .attr = sc520_freq_attr, | ||
150 | }; | ||
151 | |||
152 | |||
153 | static int __init sc520_freq_init(void) | ||
154 | { | ||
155 | struct cpuinfo_x86 *c = cpu_data; | ||
156 | |||
157 | /* Test if we have the right hardware */ | ||
158 | if(c->x86_vendor != X86_VENDOR_AMD || | ||
159 | c->x86 != 4 || c->x86_model != 9) { | ||
160 | dprintk("no Elan SC520 processor found!\n"); | ||
161 | return -ENODEV; | ||
162 | } | ||
163 | cpuctl = ioremap((unsigned long)(MMCR_BASE + OFFS_CPUCTL), 1); | ||
164 | if(!cpuctl) { | ||
165 | printk(KERN_ERR "sc520_freq: error: failed to remap memory\n"); | ||
166 | return -ENOMEM; | ||
167 | } | ||
168 | |||
169 | return cpufreq_register_driver(&sc520_freq_driver); | ||
170 | } | ||
171 | |||
172 | |||
173 | static void __exit sc520_freq_exit(void) | ||
174 | { | ||
175 | cpufreq_unregister_driver(&sc520_freq_driver); | ||
176 | iounmap(cpuctl); | ||
177 | } | ||
178 | |||
179 | |||
180 | MODULE_LICENSE("GPL"); | ||
181 | MODULE_AUTHOR("Sean Young <sean@mess.org>"); | ||
182 | MODULE_DESCRIPTION("cpufreq driver for AMD's Elan sc520 CPU"); | ||
183 | |||
184 | module_init(sc520_freq_init); | ||
185 | module_exit(sc520_freq_exit); | ||
186 | |||
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c index 07d5612dc00f..7dcbf70fc16f 100644 --- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c +++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c | |||
@@ -54,6 +54,8 @@ enum { | |||
54 | CPU_DOTHAN_A1, | 54 | CPU_DOTHAN_A1, |
55 | CPU_DOTHAN_A2, | 55 | CPU_DOTHAN_A2, |
56 | CPU_DOTHAN_B0, | 56 | CPU_DOTHAN_B0, |
57 | CPU_MP4HT_D0, | ||
58 | CPU_MP4HT_E0, | ||
57 | }; | 59 | }; |
58 | 60 | ||
59 | static const struct cpu_id cpu_ids[] = { | 61 | static const struct cpu_id cpu_ids[] = { |
@@ -61,6 +63,8 @@ static const struct cpu_id cpu_ids[] = { | |||
61 | [CPU_DOTHAN_A1] = { 6, 13, 1 }, | 63 | [CPU_DOTHAN_A1] = { 6, 13, 1 }, |
62 | [CPU_DOTHAN_A2] = { 6, 13, 2 }, | 64 | [CPU_DOTHAN_A2] = { 6, 13, 2 }, |
63 | [CPU_DOTHAN_B0] = { 6, 13, 6 }, | 65 | [CPU_DOTHAN_B0] = { 6, 13, 6 }, |
66 | [CPU_MP4HT_D0] = {15, 3, 4 }, | ||
67 | [CPU_MP4HT_E0] = {15, 4, 1 }, | ||
64 | }; | 68 | }; |
65 | #define N_IDS (sizeof(cpu_ids)/sizeof(cpu_ids[0])) | 69 | #define N_IDS (sizeof(cpu_ids)/sizeof(cpu_ids[0])) |
66 | 70 | ||
@@ -226,6 +230,8 @@ static struct cpu_model models[] = | |||
226 | { &cpu_ids[CPU_DOTHAN_A1], NULL, 0, NULL }, | 230 | { &cpu_ids[CPU_DOTHAN_A1], NULL, 0, NULL }, |
227 | { &cpu_ids[CPU_DOTHAN_A2], NULL, 0, NULL }, | 231 | { &cpu_ids[CPU_DOTHAN_A2], NULL, 0, NULL }, |
228 | { &cpu_ids[CPU_DOTHAN_B0], NULL, 0, NULL }, | 232 | { &cpu_ids[CPU_DOTHAN_B0], NULL, 0, NULL }, |
233 | { &cpu_ids[CPU_MP4HT_D0], NULL, 0, NULL }, | ||
234 | { &cpu_ids[CPU_MP4HT_E0], NULL, 0, NULL }, | ||
229 | 235 | ||
230 | { NULL, } | 236 | { NULL, } |
231 | }; | 237 | }; |
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c index 8ba430a9c3a2..d368b3f5fce8 100644 --- a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c +++ b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c | |||
@@ -336,7 +336,7 @@ unsigned int speedstep_get_freqs(unsigned int processor, | |||
336 | if (!prev_speed) | 336 | if (!prev_speed) |
337 | return -EIO; | 337 | return -EIO; |
338 | 338 | ||
339 | dprintk("previous seped is %u\n", prev_speed); | 339 | dprintk("previous speed is %u\n", prev_speed); |
340 | 340 | ||
341 | local_irq_save(flags); | 341 | local_irq_save(flags); |
342 | 342 | ||
@@ -348,7 +348,7 @@ unsigned int speedstep_get_freqs(unsigned int processor, | |||
348 | goto out; | 348 | goto out; |
349 | } | 349 | } |
350 | 350 | ||
351 | dprintk("low seped is %u\n", *low_speed); | 351 | dprintk("low speed is %u\n", *low_speed); |
352 | 352 | ||
353 | /* switch to high state */ | 353 | /* switch to high state */ |
354 | set_state(SPEEDSTEP_HIGH); | 354 | set_state(SPEEDSTEP_HIGH); |
@@ -358,7 +358,7 @@ unsigned int speedstep_get_freqs(unsigned int processor, | |||
358 | goto out; | 358 | goto out; |
359 | } | 359 | } |
360 | 360 | ||
361 | dprintk("high seped is %u\n", *high_speed); | 361 | dprintk("high speed is %u\n", *high_speed); |
362 | 362 | ||
363 | if (*low_speed == *high_speed) { | 363 | if (*low_speed == *high_speed) { |
364 | ret = -ENODEV; | 364 | ret = -ENODEV; |
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c index 79440b3f087e..b25fb6b635ae 100644 --- a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c +++ b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c | |||
@@ -357,6 +357,9 @@ static int __init speedstep_init(void) | |||
357 | case SPEEDSTEP_PROCESSOR_PIII_C: | 357 | case SPEEDSTEP_PROCESSOR_PIII_C: |
358 | case SPEEDSTEP_PROCESSOR_PIII_C_EARLY: | 358 | case SPEEDSTEP_PROCESSOR_PIII_C_EARLY: |
359 | break; | 359 | break; |
360 | case SPEEDSTEP_PROCESSOR_P4M: | ||
361 | printk(KERN_INFO "speedstep-smi: you're trying to use this cpufreq driver on a Pentium 4-based CPU. Most likely it will not work.\n"); | ||
362 | break; | ||
360 | default: | 363 | default: |
361 | speedstep_processor = 0; | 364 | speedstep_processor = 0; |
362 | } | 365 | } |
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c index 945ec73163c8..2bfbddebdbf8 100644 --- a/arch/i386/kernel/setup.c +++ b/arch/i386/kernel/setup.c | |||
@@ -1502,11 +1502,13 @@ void __init setup_arch(char **cmdline_p) | |||
1502 | if (efi_enabled) | 1502 | if (efi_enabled) |
1503 | efi_map_memmap(); | 1503 | efi_map_memmap(); |
1504 | 1504 | ||
1505 | #ifdef CONFIG_ACPI_BOOT | ||
1505 | /* | 1506 | /* |
1506 | * Parse the ACPI tables for possible boot-time SMP configuration. | 1507 | * Parse the ACPI tables for possible boot-time SMP configuration. |
1507 | */ | 1508 | */ |
1508 | acpi_boot_table_init(); | 1509 | acpi_boot_table_init(); |
1509 | acpi_boot_init(); | 1510 | acpi_boot_init(); |
1511 | #endif | ||
1510 | 1512 | ||
1511 | #ifdef CONFIG_X86_LOCAL_APIC | 1513 | #ifdef CONFIG_X86_LOCAL_APIC |
1512 | if (smp_found_config) | 1514 | if (smp_found_config) |
diff --git a/arch/i386/kernel/timers/common.c b/arch/i386/kernel/timers/common.c index f7f90005e22e..8e201219f525 100644 --- a/arch/i386/kernel/timers/common.c +++ b/arch/i386/kernel/timers/common.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <linux/timex.h> | 6 | #include <linux/timex.h> |
7 | #include <linux/errno.h> | 7 | #include <linux/errno.h> |
8 | #include <linux/jiffies.h> | 8 | #include <linux/jiffies.h> |
9 | #include <linux/module.h> | ||
9 | 10 | ||
10 | #include <asm/io.h> | 11 | #include <asm/io.h> |
11 | #include <asm/timer.h> | 12 | #include <asm/timer.h> |
@@ -24,7 +25,7 @@ | |||
24 | 25 | ||
25 | #define CALIBRATE_TIME (5 * 1000020/HZ) | 26 | #define CALIBRATE_TIME (5 * 1000020/HZ) |
26 | 27 | ||
27 | unsigned long __init calibrate_tsc(void) | 28 | unsigned long calibrate_tsc(void) |
28 | { | 29 | { |
29 | mach_prepare_counter(); | 30 | mach_prepare_counter(); |
30 | 31 | ||
@@ -139,7 +140,7 @@ bad_calibration: | |||
139 | #endif | 140 | #endif |
140 | 141 | ||
141 | /* calculate cpu_khz */ | 142 | /* calculate cpu_khz */ |
142 | void __init init_cpu_khz(void) | 143 | void init_cpu_khz(void) |
143 | { | 144 | { |
144 | if (cpu_has_tsc) { | 145 | if (cpu_has_tsc) { |
145 | unsigned long tsc_quotient = calibrate_tsc(); | 146 | unsigned long tsc_quotient = calibrate_tsc(); |
@@ -158,3 +159,4 @@ void __init init_cpu_khz(void) | |||
158 | } | 159 | } |
159 | } | 160 | } |
160 | } | 161 | } |
162 | |||
diff --git a/arch/i386/kernel/timers/timer_tsc.c b/arch/i386/kernel/timers/timer_tsc.c index 7926d967be00..180444d87824 100644 --- a/arch/i386/kernel/timers/timer_tsc.c +++ b/arch/i386/kernel/timers/timer_tsc.c | |||
@@ -320,6 +320,26 @@ core_initcall(cpufreq_tsc); | |||
320 | static inline void cpufreq_delayed_get(void) { return; } | 320 | static inline void cpufreq_delayed_get(void) { return; } |
321 | #endif | 321 | #endif |
322 | 322 | ||
323 | int recalibrate_cpu_khz(void) | ||
324 | { | ||
325 | #ifndef CONFIG_SMP | ||
326 | unsigned long cpu_khz_old = cpu_khz; | ||
327 | |||
328 | if (cpu_has_tsc) { | ||
329 | init_cpu_khz(); | ||
330 | cpu_data[0].loops_per_jiffy = | ||
331 | cpufreq_scale(cpu_data[0].loops_per_jiffy, | ||
332 | cpu_khz_old, | ||
333 | cpu_khz); | ||
334 | return 0; | ||
335 | } else | ||
336 | return -ENODEV; | ||
337 | #else | ||
338 | return -ENODEV; | ||
339 | #endif | ||
340 | } | ||
341 | EXPORT_SYMBOL(recalibrate_cpu_khz); | ||
342 | |||
323 | static void mark_offset_tsc(void) | 343 | static void mark_offset_tsc(void) |
324 | { | 344 | { |
325 | unsigned long lost,delay; | 345 | unsigned long lost,delay; |
diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c index 247a21c64aea..c1e20d65dd6c 100644 --- a/arch/ia64/ia32/sys_ia32.c +++ b/arch/ia64/ia32/sys_ia32.c | |||
@@ -2427,7 +2427,7 @@ sys32_epoll_wait(int epfd, struct epoll_event32 __user * events, int maxevents, | |||
2427 | { | 2427 | { |
2428 | struct epoll_event *events64 = NULL; | 2428 | struct epoll_event *events64 = NULL; |
2429 | mm_segment_t old_fs = get_fs(); | 2429 | mm_segment_t old_fs = get_fs(); |
2430 | int error, numevents, size; | 2430 | int numevents, size; |
2431 | int evt_idx; | 2431 | int evt_idx; |
2432 | int do_free_pages = 0; | 2432 | int do_free_pages = 0; |
2433 | 2433 | ||
diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S index 81c45d447394..d99316c9be28 100644 --- a/arch/ia64/kernel/entry.S +++ b/arch/ia64/kernel/entry.S | |||
@@ -1182,7 +1182,7 @@ ENTRY(notify_resume_user) | |||
1182 | ;; | 1182 | ;; |
1183 | (pNonSys) mov out2=0 // out2==0 => not a syscall | 1183 | (pNonSys) mov out2=0 // out2==0 => not a syscall |
1184 | .fframe 16 | 1184 | .fframe 16 |
1185 | .spillpsp ar.unat, 16 // (note that offset is relative to psp+0x10!) | 1185 | .spillsp ar.unat, 16 |
1186 | st8 [sp]=r9,-16 // allocate space for ar.unat and save it | 1186 | st8 [sp]=r9,-16 // allocate space for ar.unat and save it |
1187 | st8 [out1]=loc1,-8 // save ar.pfs, out1=&sigscratch | 1187 | st8 [out1]=loc1,-8 // save ar.pfs, out1=&sigscratch |
1188 | .body | 1188 | .body |
@@ -1208,7 +1208,7 @@ GLOBAL_ENTRY(sys_rt_sigsuspend) | |||
1208 | adds out2=8,sp // out2=&sigscratch->ar_pfs | 1208 | adds out2=8,sp // out2=&sigscratch->ar_pfs |
1209 | ;; | 1209 | ;; |
1210 | .fframe 16 | 1210 | .fframe 16 |
1211 | .spillpsp ar.unat, 16 // (note that offset is relative to psp+0x10!) | 1211 | .spillsp ar.unat, 16 |
1212 | st8 [sp]=r9,-16 // allocate space for ar.unat and save it | 1212 | st8 [sp]=r9,-16 // allocate space for ar.unat and save it |
1213 | st8 [out2]=loc1,-8 // save ar.pfs, out2=&sigscratch | 1213 | st8 [out2]=loc1,-8 // save ar.pfs, out2=&sigscratch |
1214 | .body | 1214 | .body |
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c index 4d6c7b8f667b..736e328b5e61 100644 --- a/arch/ia64/kernel/mca.c +++ b/arch/ia64/kernel/mca.c | |||
@@ -1103,8 +1103,6 @@ ia64_mca_cpe_int_caller(int cpe_irq, void *arg, struct pt_regs *ptregs) | |||
1103 | return IRQ_HANDLED; | 1103 | return IRQ_HANDLED; |
1104 | } | 1104 | } |
1105 | 1105 | ||
1106 | #endif /* CONFIG_ACPI */ | ||
1107 | |||
1108 | /* | 1106 | /* |
1109 | * ia64_mca_cpe_poll | 1107 | * ia64_mca_cpe_poll |
1110 | * | 1108 | * |
@@ -1122,6 +1120,8 @@ ia64_mca_cpe_poll (unsigned long dummy) | |||
1122 | platform_send_ipi(first_cpu(cpu_online_map), IA64_CPEP_VECTOR, IA64_IPI_DM_INT, 0); | 1120 | platform_send_ipi(first_cpu(cpu_online_map), IA64_CPEP_VECTOR, IA64_IPI_DM_INT, 0); |
1123 | } | 1121 | } |
1124 | 1122 | ||
1123 | #endif /* CONFIG_ACPI */ | ||
1124 | |||
1125 | /* | 1125 | /* |
1126 | * C portion of the OS INIT handler | 1126 | * C portion of the OS INIT handler |
1127 | * | 1127 | * |
@@ -1390,8 +1390,7 @@ ia64_mca_init(void) | |||
1390 | register_percpu_irq(IA64_MCA_WAKEUP_VECTOR, &mca_wkup_irqaction); | 1390 | register_percpu_irq(IA64_MCA_WAKEUP_VECTOR, &mca_wkup_irqaction); |
1391 | 1391 | ||
1392 | #ifdef CONFIG_ACPI | 1392 | #ifdef CONFIG_ACPI |
1393 | /* Setup the CPEI/P vector and handler */ | 1393 | /* Setup the CPEI/P handler */ |
1394 | cpe_vector = acpi_request_vector(ACPI_INTERRUPT_CPEI); | ||
1395 | register_percpu_irq(IA64_CPEP_VECTOR, &mca_cpep_irqaction); | 1394 | register_percpu_irq(IA64_CPEP_VECTOR, &mca_cpep_irqaction); |
1396 | #endif | 1395 | #endif |
1397 | 1396 | ||
@@ -1436,6 +1435,7 @@ ia64_mca_late_init(void) | |||
1436 | 1435 | ||
1437 | #ifdef CONFIG_ACPI | 1436 | #ifdef CONFIG_ACPI |
1438 | /* Setup the CPEI/P vector and handler */ | 1437 | /* Setup the CPEI/P vector and handler */ |
1438 | cpe_vector = acpi_request_vector(ACPI_INTERRUPT_CPEI); | ||
1439 | init_timer(&cpe_poll_timer); | 1439 | init_timer(&cpe_poll_timer); |
1440 | cpe_poll_timer.function = ia64_mca_cpe_poll; | 1440 | cpe_poll_timer.function = ia64_mca_cpe_poll; |
1441 | 1441 | ||
diff --git a/arch/ia64/kernel/minstate.h b/arch/ia64/kernel/minstate.h index 1dbc7b2497c9..f6d8a010d99b 100644 --- a/arch/ia64/kernel/minstate.h +++ b/arch/ia64/kernel/minstate.h | |||
@@ -41,7 +41,7 @@ | |||
41 | (pKStk) addl r3=THIS_CPU(ia64_mca_data),r3;; \ | 41 | (pKStk) addl r3=THIS_CPU(ia64_mca_data),r3;; \ |
42 | (pKStk) ld8 r3 = [r3];; \ | 42 | (pKStk) ld8 r3 = [r3];; \ |
43 | (pKStk) addl r3=IA64_MCA_CPU_INIT_STACK_OFFSET,r3;; \ | 43 | (pKStk) addl r3=IA64_MCA_CPU_INIT_STACK_OFFSET,r3;; \ |
44 | (pKStk) addl sp=IA64_STK_OFFSET-IA64_PT_REGS_SIZE,r3; \ | 44 | (pKStk) addl r1=IA64_STK_OFFSET-IA64_PT_REGS_SIZE,r3; \ |
45 | (pUStk) mov ar.rsc=0; /* set enforced lazy mode, pl 0, little-endian, loadrs=0 */ \ | 45 | (pUStk) mov ar.rsc=0; /* set enforced lazy mode, pl 0, little-endian, loadrs=0 */ \ |
46 | (pUStk) addl r22=IA64_RBS_OFFSET,r1; /* compute base of register backing store */ \ | 46 | (pUStk) addl r22=IA64_RBS_OFFSET,r1; /* compute base of register backing store */ \ |
47 | ;; \ | 47 | ;; \ |
@@ -50,7 +50,6 @@ | |||
50 | (pUStk) mov r23=ar.bspstore; /* save ar.bspstore */ \ | 50 | (pUStk) mov r23=ar.bspstore; /* save ar.bspstore */ \ |
51 | (pUStk) dep r22=-1,r22,61,3; /* compute kernel virtual addr of RBS */ \ | 51 | (pUStk) dep r22=-1,r22,61,3; /* compute kernel virtual addr of RBS */ \ |
52 | ;; \ | 52 | ;; \ |
53 | (pKStk) addl r1=-IA64_PT_REGS_SIZE,r1; /* if in kernel mode, use sp (r12) */ \ | ||
54 | (pUStk) mov ar.bspstore=r22; /* switch to kernel RBS */ \ | 53 | (pUStk) mov ar.bspstore=r22; /* switch to kernel RBS */ \ |
55 | ;; \ | 54 | ;; \ |
56 | (pUStk) mov r18=ar.bsp; \ | 55 | (pUStk) mov r18=ar.bsp; \ |
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c index 71c101601e3e..6407bff6bfd7 100644 --- a/arch/ia64/kernel/perfmon.c +++ b/arch/ia64/kernel/perfmon.c | |||
@@ -11,7 +11,7 @@ | |||
11 | * Version Perfmon-2.x is a rewrite of perfmon-1.x | 11 | * Version Perfmon-2.x is a rewrite of perfmon-1.x |
12 | * by Stephane Eranian, Hewlett Packard Co. | 12 | * by Stephane Eranian, Hewlett Packard Co. |
13 | * | 13 | * |
14 | * Copyright (C) 1999-2003, 2005 Hewlett Packard Co | 14 | * Copyright (C) 1999-2005 Hewlett Packard Co |
15 | * Stephane Eranian <eranian@hpl.hp.com> | 15 | * Stephane Eranian <eranian@hpl.hp.com> |
16 | * David Mosberger-Tang <davidm@hpl.hp.com> | 16 | * David Mosberger-Tang <davidm@hpl.hp.com> |
17 | * | 17 | * |
@@ -497,6 +497,9 @@ typedef struct { | |||
497 | static pfm_stats_t pfm_stats[NR_CPUS]; | 497 | static pfm_stats_t pfm_stats[NR_CPUS]; |
498 | static pfm_session_t pfm_sessions; /* global sessions information */ | 498 | static pfm_session_t pfm_sessions; /* global sessions information */ |
499 | 499 | ||
500 | static spinlock_t pfm_alt_install_check = SPIN_LOCK_UNLOCKED; | ||
501 | static pfm_intr_handler_desc_t *pfm_alt_intr_handler; | ||
502 | |||
500 | static struct proc_dir_entry *perfmon_dir; | 503 | static struct proc_dir_entry *perfmon_dir; |
501 | static pfm_uuid_t pfm_null_uuid = {0,}; | 504 | static pfm_uuid_t pfm_null_uuid = {0,}; |
502 | 505 | ||
@@ -606,6 +609,7 @@ DEFINE_PER_CPU(unsigned long, pfm_syst_info); | |||
606 | DEFINE_PER_CPU(struct task_struct *, pmu_owner); | 609 | DEFINE_PER_CPU(struct task_struct *, pmu_owner); |
607 | DEFINE_PER_CPU(pfm_context_t *, pmu_ctx); | 610 | DEFINE_PER_CPU(pfm_context_t *, pmu_ctx); |
608 | DEFINE_PER_CPU(unsigned long, pmu_activation_number); | 611 | DEFINE_PER_CPU(unsigned long, pmu_activation_number); |
612 | EXPORT_PER_CPU_SYMBOL_GPL(pfm_syst_info); | ||
609 | 613 | ||
610 | 614 | ||
611 | /* forward declaration */ | 615 | /* forward declaration */ |
@@ -1325,7 +1329,7 @@ pfm_reserve_session(struct task_struct *task, int is_syswide, unsigned int cpu) | |||
1325 | error_conflict: | 1329 | error_conflict: |
1326 | DPRINT(("system wide not possible, conflicting session [%d] on CPU%d\n", | 1330 | DPRINT(("system wide not possible, conflicting session [%d] on CPU%d\n", |
1327 | pfm_sessions.pfs_sys_session[cpu]->pid, | 1331 | pfm_sessions.pfs_sys_session[cpu]->pid, |
1328 | smp_processor_id())); | 1332 | cpu)); |
1329 | abort: | 1333 | abort: |
1330 | UNLOCK_PFS(flags); | 1334 | UNLOCK_PFS(flags); |
1331 | 1335 | ||
@@ -5555,26 +5559,32 @@ pfm_interrupt_handler(int irq, void *arg, struct pt_regs *regs) | |||
5555 | int ret; | 5559 | int ret; |
5556 | 5560 | ||
5557 | this_cpu = get_cpu(); | 5561 | this_cpu = get_cpu(); |
5558 | min = pfm_stats[this_cpu].pfm_ovfl_intr_cycles_min; | 5562 | if (likely(!pfm_alt_intr_handler)) { |
5559 | max = pfm_stats[this_cpu].pfm_ovfl_intr_cycles_max; | 5563 | min = pfm_stats[this_cpu].pfm_ovfl_intr_cycles_min; |
5564 | max = pfm_stats[this_cpu].pfm_ovfl_intr_cycles_max; | ||
5560 | 5565 | ||
5561 | start_cycles = ia64_get_itc(); | 5566 | start_cycles = ia64_get_itc(); |
5562 | 5567 | ||
5563 | ret = pfm_do_interrupt_handler(irq, arg, regs); | 5568 | ret = pfm_do_interrupt_handler(irq, arg, regs); |
5564 | 5569 | ||
5565 | total_cycles = ia64_get_itc(); | 5570 | total_cycles = ia64_get_itc(); |
5566 | 5571 | ||
5567 | /* | 5572 | /* |
5568 | * don't measure spurious interrupts | 5573 | * don't measure spurious interrupts |
5569 | */ | 5574 | */ |
5570 | if (likely(ret == 0)) { | 5575 | if (likely(ret == 0)) { |
5571 | total_cycles -= start_cycles; | 5576 | total_cycles -= start_cycles; |
5572 | 5577 | ||
5573 | if (total_cycles < min) pfm_stats[this_cpu].pfm_ovfl_intr_cycles_min = total_cycles; | 5578 | if (total_cycles < min) pfm_stats[this_cpu].pfm_ovfl_intr_cycles_min = total_cycles; |
5574 | if (total_cycles > max) pfm_stats[this_cpu].pfm_ovfl_intr_cycles_max = total_cycles; | 5579 | if (total_cycles > max) pfm_stats[this_cpu].pfm_ovfl_intr_cycles_max = total_cycles; |
5575 | 5580 | ||
5576 | pfm_stats[this_cpu].pfm_ovfl_intr_cycles += total_cycles; | 5581 | pfm_stats[this_cpu].pfm_ovfl_intr_cycles += total_cycles; |
5582 | } | ||
5583 | } | ||
5584 | else { | ||
5585 | (*pfm_alt_intr_handler->handler)(irq, arg, regs); | ||
5577 | } | 5586 | } |
5587 | |||
5578 | put_cpu_no_resched(); | 5588 | put_cpu_no_resched(); |
5579 | return IRQ_HANDLED; | 5589 | return IRQ_HANDLED; |
5580 | } | 5590 | } |
@@ -6425,6 +6435,141 @@ static struct irqaction perfmon_irqaction = { | |||
6425 | .name = "perfmon" | 6435 | .name = "perfmon" |
6426 | }; | 6436 | }; |
6427 | 6437 | ||
6438 | static void | ||
6439 | pfm_alt_save_pmu_state(void *data) | ||
6440 | { | ||
6441 | struct pt_regs *regs; | ||
6442 | |||
6443 | regs = ia64_task_regs(current); | ||
6444 | |||
6445 | DPRINT(("called\n")); | ||
6446 | |||
6447 | /* | ||
6448 | * should not be necessary but | ||
6449 | * let's take not risk | ||
6450 | */ | ||
6451 | pfm_clear_psr_up(); | ||
6452 | pfm_clear_psr_pp(); | ||
6453 | ia64_psr(regs)->pp = 0; | ||
6454 | |||
6455 | /* | ||
6456 | * This call is required | ||
6457 | * May cause a spurious interrupt on some processors | ||
6458 | */ | ||
6459 | pfm_freeze_pmu(); | ||
6460 | |||
6461 | ia64_srlz_d(); | ||
6462 | } | ||
6463 | |||
6464 | void | ||
6465 | pfm_alt_restore_pmu_state(void *data) | ||
6466 | { | ||
6467 | struct pt_regs *regs; | ||
6468 | |||
6469 | regs = ia64_task_regs(current); | ||
6470 | |||
6471 | DPRINT(("called\n")); | ||
6472 | |||
6473 | /* | ||
6474 | * put PMU back in state expected | ||
6475 | * by perfmon | ||
6476 | */ | ||
6477 | pfm_clear_psr_up(); | ||
6478 | pfm_clear_psr_pp(); | ||
6479 | ia64_psr(regs)->pp = 0; | ||
6480 | |||
6481 | /* | ||
6482 | * perfmon runs with PMU unfrozen at all times | ||
6483 | */ | ||
6484 | pfm_unfreeze_pmu(); | ||
6485 | |||
6486 | ia64_srlz_d(); | ||
6487 | } | ||
6488 | |||
6489 | int | ||
6490 | pfm_install_alt_pmu_interrupt(pfm_intr_handler_desc_t *hdl) | ||
6491 | { | ||
6492 | int ret, i; | ||
6493 | int reserve_cpu; | ||
6494 | |||
6495 | /* some sanity checks */ | ||
6496 | if (hdl == NULL || hdl->handler == NULL) return -EINVAL; | ||
6497 | |||
6498 | /* do the easy test first */ | ||
6499 | if (pfm_alt_intr_handler) return -EBUSY; | ||
6500 | |||
6501 | /* one at a time in the install or remove, just fail the others */ | ||
6502 | if (!spin_trylock(&pfm_alt_install_check)) { | ||
6503 | return -EBUSY; | ||
6504 | } | ||
6505 | |||
6506 | /* reserve our session */ | ||
6507 | for_each_online_cpu(reserve_cpu) { | ||
6508 | ret = pfm_reserve_session(NULL, 1, reserve_cpu); | ||
6509 | if (ret) goto cleanup_reserve; | ||
6510 | } | ||
6511 | |||
6512 | /* save the current system wide pmu states */ | ||
6513 | ret = on_each_cpu(pfm_alt_save_pmu_state, NULL, 0, 1); | ||
6514 | if (ret) { | ||
6515 | DPRINT(("on_each_cpu() failed: %d\n", ret)); | ||
6516 | goto cleanup_reserve; | ||
6517 | } | ||
6518 | |||
6519 | /* officially change to the alternate interrupt handler */ | ||
6520 | pfm_alt_intr_handler = hdl; | ||
6521 | |||
6522 | spin_unlock(&pfm_alt_install_check); | ||
6523 | |||
6524 | return 0; | ||
6525 | |||
6526 | cleanup_reserve: | ||
6527 | for_each_online_cpu(i) { | ||
6528 | /* don't unreserve more than we reserved */ | ||
6529 | if (i >= reserve_cpu) break; | ||
6530 | |||
6531 | pfm_unreserve_session(NULL, 1, i); | ||
6532 | } | ||
6533 | |||
6534 | spin_unlock(&pfm_alt_install_check); | ||
6535 | |||
6536 | return ret; | ||
6537 | } | ||
6538 | EXPORT_SYMBOL_GPL(pfm_install_alt_pmu_interrupt); | ||
6539 | |||
6540 | int | ||
6541 | pfm_remove_alt_pmu_interrupt(pfm_intr_handler_desc_t *hdl) | ||
6542 | { | ||
6543 | int i; | ||
6544 | int ret; | ||
6545 | |||
6546 | if (hdl == NULL) return -EINVAL; | ||
6547 | |||
6548 | /* cannot remove someone else's handler! */ | ||
6549 | if (pfm_alt_intr_handler != hdl) return -EINVAL; | ||
6550 | |||
6551 | /* one at a time in the install or remove, just fail the others */ | ||
6552 | if (!spin_trylock(&pfm_alt_install_check)) { | ||
6553 | return -EBUSY; | ||
6554 | } | ||
6555 | |||
6556 | pfm_alt_intr_handler = NULL; | ||
6557 | |||
6558 | ret = on_each_cpu(pfm_alt_restore_pmu_state, NULL, 0, 1); | ||
6559 | if (ret) { | ||
6560 | DPRINT(("on_each_cpu() failed: %d\n", ret)); | ||
6561 | } | ||
6562 | |||
6563 | for_each_online_cpu(i) { | ||
6564 | pfm_unreserve_session(NULL, 1, i); | ||
6565 | } | ||
6566 | |||
6567 | spin_unlock(&pfm_alt_install_check); | ||
6568 | |||
6569 | return 0; | ||
6570 | } | ||
6571 | EXPORT_SYMBOL_GPL(pfm_remove_alt_pmu_interrupt); | ||
6572 | |||
6428 | /* | 6573 | /* |
6429 | * perfmon initialization routine, called from the initcall() table | 6574 | * perfmon initialization routine, called from the initcall() table |
6430 | */ | 6575 | */ |
diff --git a/arch/ia64/kernel/ptrace.c b/arch/ia64/kernel/ptrace.c index 907464ee7273..08c8a5eb25ab 100644 --- a/arch/ia64/kernel/ptrace.c +++ b/arch/ia64/kernel/ptrace.c | |||
@@ -692,16 +692,30 @@ convert_to_non_syscall (struct task_struct *child, struct pt_regs *pt, | |||
692 | unsigned long cfm) | 692 | unsigned long cfm) |
693 | { | 693 | { |
694 | struct unw_frame_info info, prev_info; | 694 | struct unw_frame_info info, prev_info; |
695 | unsigned long ip, pr; | 695 | unsigned long ip, sp, pr; |
696 | 696 | ||
697 | unw_init_from_blocked_task(&info, child); | 697 | unw_init_from_blocked_task(&info, child); |
698 | while (1) { | 698 | while (1) { |
699 | prev_info = info; | 699 | prev_info = info; |
700 | if (unw_unwind(&info) < 0) | 700 | if (unw_unwind(&info) < 0) |
701 | return; | 701 | return; |
702 | if (unw_get_rp(&info, &ip) < 0) | 702 | |
703 | unw_get_sp(&info, &sp); | ||
704 | if ((long)((unsigned long)child + IA64_STK_OFFSET - sp) | ||
705 | < IA64_PT_REGS_SIZE) { | ||
706 | dprintk("ptrace.%s: ran off the top of the kernel " | ||
707 | "stack\n", __FUNCTION__); | ||
708 | return; | ||
709 | } | ||
710 | if (unw_get_pr (&prev_info, &pr) < 0) { | ||
711 | unw_get_rp(&prev_info, &ip); | ||
712 | dprintk("ptrace.%s: failed to read " | ||
713 | "predicate register (ip=0x%lx)\n", | ||
714 | __FUNCTION__, ip); | ||
703 | return; | 715 | return; |
704 | if (ip < FIXADDR_USER_END) | 716 | } |
717 | if (unw_is_intr_frame(&info) | ||
718 | && (pr & (1UL << PRED_USER_STACK))) | ||
705 | break; | 719 | break; |
706 | } | 720 | } |
707 | 721 | ||
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c index 0d5ee57c9865..3865f088ffa2 100644 --- a/arch/ia64/kernel/smpboot.c +++ b/arch/ia64/kernel/smpboot.c | |||
@@ -624,7 +624,7 @@ static struct { | |||
624 | __u16 thread_id; | 624 | __u16 thread_id; |
625 | __u16 proc_fixed_addr; | 625 | __u16 proc_fixed_addr; |
626 | __u8 valid; | 626 | __u8 valid; |
627 | }mt_info[NR_CPUS] __devinit; | 627 | } mt_info[NR_CPUS] __devinitdata; |
628 | 628 | ||
629 | #ifdef CONFIG_HOTPLUG_CPU | 629 | #ifdef CONFIG_HOTPLUG_CPU |
630 | static inline void | 630 | static inline void |
diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c index a8cf6d8a509c..770fab37928e 100644 --- a/arch/ia64/kernel/sys_ia64.c +++ b/arch/ia64/kernel/sys_ia64.c | |||
@@ -182,13 +182,6 @@ do_mmap2 (unsigned long addr, unsigned long len, int prot, int flags, int fd, un | |||
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
185 | /* | ||
186 | * A zero mmap always succeeds in Linux, independent of whether or not the | ||
187 | * remaining arguments are valid. | ||
188 | */ | ||
189 | if (len == 0) | ||
190 | goto out; | ||
191 | |||
192 | /* Careful about overflows.. */ | 185 | /* Careful about overflows.. */ |
193 | len = PAGE_ALIGN(len); | 186 | len = PAGE_ALIGN(len); |
194 | if (!len || len > TASK_SIZE) { | 187 | if (!len || len > TASK_SIZE) { |
diff --git a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c index 4fb44984afe6..e64cb8175f7a 100644 --- a/arch/ia64/sn/kernel/setup.c +++ b/arch/ia64/sn/kernel/setup.c | |||
@@ -271,6 +271,8 @@ void __init sn_setup(char **cmdline_p) | |||
271 | int major = sn_sal_rev_major(), minor = sn_sal_rev_minor(); | 271 | int major = sn_sal_rev_major(), minor = sn_sal_rev_minor(); |
272 | extern void sn_cpu_init(void); | 272 | extern void sn_cpu_init(void); |
273 | 273 | ||
274 | ia64_sn_plat_set_error_handling_features(); | ||
275 | |||
274 | /* | 276 | /* |
275 | * If the generic code has enabled vga console support - lets | 277 | * If the generic code has enabled vga console support - lets |
276 | * get rid of it again. This is a kludge for the fact that ACPI | 278 | * get rid of it again. This is a kludge for the fact that ACPI |
diff --git a/arch/m68knommu/kernel/process.c b/arch/m68knommu/kernel/process.c index 2b6c9d32b7a6..c4a33f265dc0 100644 --- a/arch/m68knommu/kernel/process.c +++ b/arch/m68knommu/kernel/process.c | |||
@@ -45,11 +45,13 @@ asmlinkage void ret_from_fork(void); | |||
45 | */ | 45 | */ |
46 | void default_idle(void) | 46 | void default_idle(void) |
47 | { | 47 | { |
48 | while(1) { | 48 | local_irq_disable(); |
49 | if (need_resched()) | 49 | while (!need_resched()) { |
50 | __asm__("stop #0x2000" : : : "cc"); | 50 | /* This stop will re-enable interrupts */ |
51 | schedule(); | 51 | __asm__("stop #0x2000" : : : "cc"); |
52 | local_irq_disable(); | ||
52 | } | 53 | } |
54 | local_irq_enable(); | ||
53 | } | 55 | } |
54 | 56 | ||
55 | void (*idle)(void) = default_idle; | 57 | void (*idle)(void) = default_idle; |
@@ -63,7 +65,12 @@ void (*idle)(void) = default_idle; | |||
63 | void cpu_idle(void) | 65 | void cpu_idle(void) |
64 | { | 66 | { |
65 | /* endless idle loop with no priority at all */ | 67 | /* endless idle loop with no priority at all */ |
66 | idle(); | 68 | while (1) { |
69 | idle(); | ||
70 | preempt_enable_no_resched(); | ||
71 | schedule(); | ||
72 | preempt_disable(); | ||
73 | } | ||
67 | } | 74 | } |
68 | 75 | ||
69 | void machine_restart(char * __unused) | 76 | void machine_restart(char * __unused) |
diff --git a/arch/ppc/kernel/cputable.c b/arch/ppc/kernel/cputable.c index 8aa5e8c69009..d44b7dc5390a 100644 --- a/arch/ppc/kernel/cputable.c +++ b/arch/ppc/kernel/cputable.c | |||
@@ -838,6 +838,17 @@ struct cpu_spec cpu_specs[] = { | |||
838 | .icache_bsize = 32, | 838 | .icache_bsize = 32, |
839 | .dcache_bsize = 32, | 839 | .dcache_bsize = 32, |
840 | }, | 840 | }, |
841 | { /* 405EP */ | ||
842 | .pvr_mask = 0xffff0000, | ||
843 | .pvr_value = 0x51210000, | ||
844 | .cpu_name = "405EP", | ||
845 | .cpu_features = CPU_FTR_SPLIT_ID_CACHE | | ||
846 | CPU_FTR_USE_TB, | ||
847 | .cpu_user_features = PPC_FEATURE_32 | | ||
848 | PPC_FEATURE_HAS_MMU | PPC_FEATURE_HAS_4xxMAC, | ||
849 | .icache_bsize = 32, | ||
850 | .dcache_bsize = 32, | ||
851 | }, | ||
841 | 852 | ||
842 | #endif /* CONFIG_40x */ | 853 | #endif /* CONFIG_40x */ |
843 | #ifdef CONFIG_44x | 854 | #ifdef CONFIG_44x |
diff --git a/arch/ppc/kernel/misc.S b/arch/ppc/kernel/misc.S index e4f1615ec13f..7329ef177a18 100644 --- a/arch/ppc/kernel/misc.S +++ b/arch/ppc/kernel/misc.S | |||
@@ -619,7 +619,7 @@ _GLOBAL(flush_instruction_cache) | |||
619 | _GLOBAL(flush_icache_range) | 619 | _GLOBAL(flush_icache_range) |
620 | BEGIN_FTR_SECTION | 620 | BEGIN_FTR_SECTION |
621 | blr /* for 601, do nothing */ | 621 | blr /* for 601, do nothing */ |
622 | END_FTR_SECTION_IFSET(PPC_FEATURE_UNIFIED_CACHE) | 622 | END_FTR_SECTION_IFCLR(CPU_FTR_SPLIT_ID_CACHE) |
623 | li r5,L1_CACHE_LINE_SIZE-1 | 623 | li r5,L1_CACHE_LINE_SIZE-1 |
624 | andc r3,r3,r5 | 624 | andc r3,r3,r5 |
625 | subf r4,r3,r4 | 625 | subf r4,r3,r4 |
@@ -736,7 +736,7 @@ _GLOBAL(flush_dcache_all) | |||
736 | _GLOBAL(__flush_dcache_icache) | 736 | _GLOBAL(__flush_dcache_icache) |
737 | BEGIN_FTR_SECTION | 737 | BEGIN_FTR_SECTION |
738 | blr /* for 601, do nothing */ | 738 | blr /* for 601, do nothing */ |
739 | END_FTR_SECTION_IFSET(PPC_FEATURE_UNIFIED_CACHE) | 739 | END_FTR_SECTION_IFCLR(CPU_FTR_SPLIT_ID_CACHE) |
740 | rlwinm r3,r3,0,0,19 /* Get page base address */ | 740 | rlwinm r3,r3,0,0,19 /* Get page base address */ |
741 | li r4,4096/L1_CACHE_LINE_SIZE /* Number of lines in a page */ | 741 | li r4,4096/L1_CACHE_LINE_SIZE /* Number of lines in a page */ |
742 | mtctr r4 | 742 | mtctr r4 |
@@ -764,7 +764,7 @@ END_FTR_SECTION_IFSET(PPC_FEATURE_UNIFIED_CACHE) | |||
764 | _GLOBAL(__flush_dcache_icache_phys) | 764 | _GLOBAL(__flush_dcache_icache_phys) |
765 | BEGIN_FTR_SECTION | 765 | BEGIN_FTR_SECTION |
766 | blr /* for 601, do nothing */ | 766 | blr /* for 601, do nothing */ |
767 | END_FTR_SECTION_IFSET(PPC_FEATURE_UNIFIED_CACHE) | 767 | END_FTR_SECTION_IFCLR(CPU_FTR_SPLIT_ID_CACHE) |
768 | mfmsr r10 | 768 | mfmsr r10 |
769 | rlwinm r0,r10,0,28,26 /* clear DR */ | 769 | rlwinm r0,r10,0,28,26 /* clear DR */ |
770 | mtmsr r0 | 770 | mtmsr r0 |
diff --git a/arch/ppc/syslib/prom_init.c b/arch/ppc/syslib/prom_init.c index 2cee87137f2e..7f15136830f4 100644 --- a/arch/ppc/syslib/prom_init.c +++ b/arch/ppc/syslib/prom_init.c | |||
@@ -626,8 +626,18 @@ inspect_node(phandle node, struct device_node *dad, | |||
626 | l = call_prom("package-to-path", 3, 1, node, | 626 | l = call_prom("package-to-path", 3, 1, node, |
627 | mem_start, mem_end - mem_start); | 627 | mem_start, mem_end - mem_start); |
628 | if (l >= 0) { | 628 | if (l >= 0) { |
629 | char *p, *ep; | ||
630 | |||
629 | np->full_name = PTRUNRELOC((char *) mem_start); | 631 | np->full_name = PTRUNRELOC((char *) mem_start); |
630 | *(char *)(mem_start + l) = 0; | 632 | *(char *)(mem_start + l) = 0; |
633 | /* Fixup an Apple bug where they have bogus \0 chars in the | ||
634 | * middle of the path in some properties | ||
635 | */ | ||
636 | for (p = (char *)mem_start, ep = p + l; p < ep; p++) | ||
637 | if ((*p) == '\0') { | ||
638 | memmove(p, p+1, ep - p); | ||
639 | ep--; | ||
640 | } | ||
631 | mem_start = ALIGNUL(mem_start + l + 1); | 641 | mem_start = ALIGNUL(mem_start + l + 1); |
632 | } | 642 | } |
633 | 643 | ||
diff --git a/arch/ppc64/kernel/entry.S b/arch/ppc64/kernel/entry.S index d3604056e1a9..b61572eb2a71 100644 --- a/arch/ppc64/kernel/entry.S +++ b/arch/ppc64/kernel/entry.S | |||
@@ -436,15 +436,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) | |||
436 | REST_8GPRS(14, r1) | 436 | REST_8GPRS(14, r1) |
437 | REST_10GPRS(22, r1) | 437 | REST_10GPRS(22, r1) |
438 | 438 | ||
439 | #ifdef CONFIG_PPC_ISERIES | ||
440 | clrrdi r7,r1,THREAD_SHIFT /* get current_thread_info() */ | ||
441 | ld r7,TI_FLAGS(r7) /* Get run light flag */ | ||
442 | mfspr r9,CTRLF | ||
443 | srdi r7,r7,TIF_RUN_LIGHT | ||
444 | insrdi r9,r7,1,63 /* Insert run light into CTRL */ | ||
445 | mtspr CTRLT,r9 | ||
446 | #endif | ||
447 | |||
448 | /* convert old thread to its task_struct for return value */ | 439 | /* convert old thread to its task_struct for return value */ |
449 | addi r3,r3,-THREAD | 440 | addi r3,r3,-THREAD |
450 | ld r7,_NIP(r1) /* Return to _switch caller in new task */ | 441 | ld r7,_NIP(r1) /* Return to _switch caller in new task */ |
diff --git a/arch/ppc64/kernel/head.S b/arch/ppc64/kernel/head.S index 92a744c31ab1..346dbf606b5d 100644 --- a/arch/ppc64/kernel/head.S +++ b/arch/ppc64/kernel/head.S | |||
@@ -626,10 +626,10 @@ system_reset_iSeries: | |||
626 | lhz r24,PACAPACAINDEX(r13) /* Get processor # */ | 626 | lhz r24,PACAPACAINDEX(r13) /* Get processor # */ |
627 | cmpwi 0,r24,0 /* Are we processor 0? */ | 627 | cmpwi 0,r24,0 /* Are we processor 0? */ |
628 | beq .__start_initialization_iSeries /* Start up the first processor */ | 628 | beq .__start_initialization_iSeries /* Start up the first processor */ |
629 | mfspr r4,CTRLF | 629 | mfspr r4,SPRN_CTRLF |
630 | li r5,RUNLATCH /* Turn off the run light */ | 630 | li r5,CTRL_RUNLATCH /* Turn off the run light */ |
631 | andc r4,r4,r5 | 631 | andc r4,r4,r5 |
632 | mtspr CTRLT,r4 | 632 | mtspr SPRN_CTRLT,r4 |
633 | 633 | ||
634 | 1: | 634 | 1: |
635 | HMT_LOW | 635 | HMT_LOW |
@@ -2082,9 +2082,9 @@ _GLOBAL(hmt_start_secondary) | |||
2082 | mfspr r4, HID0 | 2082 | mfspr r4, HID0 |
2083 | ori r4, r4, 0x1 | 2083 | ori r4, r4, 0x1 |
2084 | mtspr HID0, r4 | 2084 | mtspr HID0, r4 |
2085 | mfspr r4, CTRLF | 2085 | mfspr r4, SPRN_CTRLF |
2086 | oris r4, r4, 0x40 | 2086 | oris r4, r4, 0x40 |
2087 | mtspr CTRLT, r4 | 2087 | mtspr SPRN_CTRLT, r4 |
2088 | blr | 2088 | blr |
2089 | #endif | 2089 | #endif |
2090 | 2090 | ||
diff --git a/arch/ppc64/kernel/iSeries_setup.c b/arch/ppc64/kernel/iSeries_setup.c index da20120f2261..6d06eb550a3f 100644 --- a/arch/ppc64/kernel/iSeries_setup.c +++ b/arch/ppc64/kernel/iSeries_setup.c | |||
@@ -852,6 +852,28 @@ static int __init iSeries_src_init(void) | |||
852 | 852 | ||
853 | late_initcall(iSeries_src_init); | 853 | late_initcall(iSeries_src_init); |
854 | 854 | ||
855 | static int set_spread_lpevents(char *str) | ||
856 | { | ||
857 | unsigned long i; | ||
858 | unsigned long val = simple_strtoul(str, NULL, 0); | ||
859 | |||
860 | /* | ||
861 | * The parameter is the number of processors to share in processing | ||
862 | * lp events. | ||
863 | */ | ||
864 | if (( val > 0) && (val <= NR_CPUS)) { | ||
865 | for (i = 1; i < val; ++i) | ||
866 | paca[i].lpqueue_ptr = paca[0].lpqueue_ptr; | ||
867 | |||
868 | printk("lpevent processing spread over %ld processors\n", val); | ||
869 | } else { | ||
870 | printk("invalid spread_lpevents %ld\n", val); | ||
871 | } | ||
872 | |||
873 | return 1; | ||
874 | } | ||
875 | __setup("spread_lpevents=", set_spread_lpevents); | ||
876 | |||
855 | void __init iSeries_early_setup(void) | 877 | void __init iSeries_early_setup(void) |
856 | { | 878 | { |
857 | iSeries_fixup_klimit(); | 879 | iSeries_fixup_klimit(); |
diff --git a/arch/ppc64/kernel/idle.c b/arch/ppc64/kernel/idle.c index 6abc621d3ba0..f24ce2b87200 100644 --- a/arch/ppc64/kernel/idle.c +++ b/arch/ppc64/kernel/idle.c | |||
@@ -75,13 +75,9 @@ static int iSeries_idle(void) | |||
75 | { | 75 | { |
76 | struct paca_struct *lpaca; | 76 | struct paca_struct *lpaca; |
77 | long oldval; | 77 | long oldval; |
78 | unsigned long CTRL; | ||
79 | 78 | ||
80 | /* ensure iSeries run light will be out when idle */ | 79 | /* ensure iSeries run light will be out when idle */ |
81 | clear_thread_flag(TIF_RUN_LIGHT); | 80 | ppc64_runlatch_off(); |
82 | CTRL = mfspr(CTRLF); | ||
83 | CTRL &= ~RUNLATCH; | ||
84 | mtspr(CTRLT, CTRL); | ||
85 | 81 | ||
86 | lpaca = get_paca(); | 82 | lpaca = get_paca(); |
87 | 83 | ||
@@ -111,7 +107,9 @@ static int iSeries_idle(void) | |||
111 | } | 107 | } |
112 | } | 108 | } |
113 | 109 | ||
110 | ppc64_runlatch_on(); | ||
114 | schedule(); | 111 | schedule(); |
112 | ppc64_runlatch_off(); | ||
115 | } | 113 | } |
116 | 114 | ||
117 | return 0; | 115 | return 0; |
diff --git a/arch/ppc64/kernel/pSeries_reconfig.c b/arch/ppc64/kernel/pSeries_reconfig.c index cb5443f2e49b..dc2a69d412a2 100644 --- a/arch/ppc64/kernel/pSeries_reconfig.c +++ b/arch/ppc64/kernel/pSeries_reconfig.c | |||
@@ -47,14 +47,6 @@ static void remove_node_proc_entries(struct device_node *np) | |||
47 | remove_proc_entry(pp->name, np->pde); | 47 | remove_proc_entry(pp->name, np->pde); |
48 | pp = pp->next; | 48 | pp = pp->next; |
49 | } | 49 | } |
50 | |||
51 | /* Assuming that symlinks have the same parent directory as | ||
52 | * np->pde. | ||
53 | */ | ||
54 | if (np->name_link) | ||
55 | remove_proc_entry(np->name_link->name, parent->pde); | ||
56 | if (np->addr_link) | ||
57 | remove_proc_entry(np->addr_link->name, parent->pde); | ||
58 | if (np->pde) | 50 | if (np->pde) |
59 | remove_proc_entry(np->pde->name, parent->pde); | 51 | remove_proc_entry(np->pde->name, parent->pde); |
60 | } | 52 | } |
diff --git a/arch/ppc64/kernel/process.c b/arch/ppc64/kernel/process.c index 8b0686122738..cdfecbeb331f 100644 --- a/arch/ppc64/kernel/process.c +++ b/arch/ppc64/kernel/process.c | |||
@@ -378,9 +378,6 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long usp, | |||
378 | childregs->gpr[1] = sp + sizeof(struct pt_regs); | 378 | childregs->gpr[1] = sp + sizeof(struct pt_regs); |
379 | p->thread.regs = NULL; /* no user register state */ | 379 | p->thread.regs = NULL; /* no user register state */ |
380 | clear_ti_thread_flag(p->thread_info, TIF_32BIT); | 380 | clear_ti_thread_flag(p->thread_info, TIF_32BIT); |
381 | #ifdef CONFIG_PPC_ISERIES | ||
382 | set_ti_thread_flag(p->thread_info, TIF_RUN_LIGHT); | ||
383 | #endif | ||
384 | } else { | 381 | } else { |
385 | childregs->gpr[1] = usp; | 382 | childregs->gpr[1] = usp; |
386 | p->thread.regs = childregs; | 383 | p->thread.regs = childregs; |
diff --git a/arch/ppc64/kernel/prom_init.c b/arch/ppc64/kernel/prom_init.c index 6f79b7b9b445..b7683abfbe6a 100644 --- a/arch/ppc64/kernel/prom_init.c +++ b/arch/ppc64/kernel/prom_init.c | |||
@@ -211,13 +211,23 @@ struct { | |||
211 | */ | 211 | */ |
212 | #define ADDR(x) (u32) ((unsigned long)(x) - offset) | 212 | #define ADDR(x) (u32) ((unsigned long)(x) - offset) |
213 | 213 | ||
214 | /* | ||
215 | * Error results ... some OF calls will return "-1" on error, some | ||
216 | * will return 0, some will return either. To simplify, here are | ||
217 | * macros to use with any ihandle or phandle return value to check if | ||
218 | * it is valid | ||
219 | */ | ||
220 | |||
221 | #define PROM_ERROR (-1u) | ||
222 | #define PHANDLE_VALID(p) ((p) != 0 && (p) != PROM_ERROR) | ||
223 | #define IHANDLE_VALID(i) ((i) != 0 && (i) != PROM_ERROR) | ||
224 | |||
225 | |||
214 | /* This is the one and *ONLY* place where we actually call open | 226 | /* This is the one and *ONLY* place where we actually call open |
215 | * firmware from, since we need to make sure we're running in 32b | 227 | * firmware from, since we need to make sure we're running in 32b |
216 | * mode when we do. We switch back to 64b mode upon return. | 228 | * mode when we do. We switch back to 64b mode upon return. |
217 | */ | 229 | */ |
218 | 230 | ||
219 | #define PROM_ERROR (-1) | ||
220 | |||
221 | static int __init call_prom(const char *service, int nargs, int nret, ...) | 231 | static int __init call_prom(const char *service, int nargs, int nret, ...) |
222 | { | 232 | { |
223 | int i; | 233 | int i; |
@@ -587,14 +597,13 @@ static void __init prom_send_capabilities(void) | |||
587 | { | 597 | { |
588 | unsigned long offset = reloc_offset(); | 598 | unsigned long offset = reloc_offset(); |
589 | ihandle elfloader; | 599 | ihandle elfloader; |
590 | int ret; | ||
591 | 600 | ||
592 | elfloader = call_prom("open", 1, 1, ADDR("/packages/elf-loader")); | 601 | elfloader = call_prom("open", 1, 1, ADDR("/packages/elf-loader")); |
593 | if (elfloader == 0) { | 602 | if (elfloader == 0) { |
594 | prom_printf("couldn't open /packages/elf-loader\n"); | 603 | prom_printf("couldn't open /packages/elf-loader\n"); |
595 | return; | 604 | return; |
596 | } | 605 | } |
597 | ret = call_prom("call-method", 3, 1, ADDR("process-elf-header"), | 606 | call_prom("call-method", 3, 1, ADDR("process-elf-header"), |
598 | elfloader, ADDR(&fake_elf)); | 607 | elfloader, ADDR(&fake_elf)); |
599 | call_prom("close", 1, 0, elfloader); | 608 | call_prom("close", 1, 0, elfloader); |
600 | } | 609 | } |
@@ -646,7 +655,7 @@ static unsigned long __init alloc_up(unsigned long size, unsigned long align) | |||
646 | base = _ALIGN_UP(base + 0x100000, align)) { | 655 | base = _ALIGN_UP(base + 0x100000, align)) { |
647 | prom_debug(" trying: 0x%x\n\r", base); | 656 | prom_debug(" trying: 0x%x\n\r", base); |
648 | addr = (unsigned long)prom_claim(base, size, 0); | 657 | addr = (unsigned long)prom_claim(base, size, 0); |
649 | if ((int)addr != PROM_ERROR) | 658 | if (addr != PROM_ERROR) |
650 | break; | 659 | break; |
651 | addr = 0; | 660 | addr = 0; |
652 | if (align == 0) | 661 | if (align == 0) |
@@ -708,7 +717,7 @@ static unsigned long __init alloc_down(unsigned long size, unsigned long align, | |||
708 | for(; base > RELOC(alloc_bottom); base = _ALIGN_DOWN(base - 0x100000, align)) { | 717 | for(; base > RELOC(alloc_bottom); base = _ALIGN_DOWN(base - 0x100000, align)) { |
709 | prom_debug(" trying: 0x%x\n\r", base); | 718 | prom_debug(" trying: 0x%x\n\r", base); |
710 | addr = (unsigned long)prom_claim(base, size, 0); | 719 | addr = (unsigned long)prom_claim(base, size, 0); |
711 | if ((int)addr != PROM_ERROR) | 720 | if (addr != PROM_ERROR) |
712 | break; | 721 | break; |
713 | addr = 0; | 722 | addr = 0; |
714 | } | 723 | } |
@@ -902,18 +911,19 @@ static void __init prom_instantiate_rtas(void) | |||
902 | { | 911 | { |
903 | unsigned long offset = reloc_offset(); | 912 | unsigned long offset = reloc_offset(); |
904 | struct prom_t *_prom = PTRRELOC(&prom); | 913 | struct prom_t *_prom = PTRRELOC(&prom); |
905 | phandle prom_rtas, rtas_node; | 914 | phandle rtas_node; |
915 | ihandle rtas_inst; | ||
906 | u32 base, entry = 0; | 916 | u32 base, entry = 0; |
907 | u32 size = 0; | 917 | u32 size = 0; |
908 | 918 | ||
909 | prom_debug("prom_instantiate_rtas: start...\n"); | 919 | prom_debug("prom_instantiate_rtas: start...\n"); |
910 | 920 | ||
911 | prom_rtas = call_prom("finddevice", 1, 1, ADDR("/rtas")); | 921 | rtas_node = call_prom("finddevice", 1, 1, ADDR("/rtas")); |
912 | prom_debug("prom_rtas: %x\n", prom_rtas); | 922 | prom_debug("rtas_node: %x\n", rtas_node); |
913 | if (prom_rtas == (phandle) -1) | 923 | if (!PHANDLE_VALID(rtas_node)) |
914 | return; | 924 | return; |
915 | 925 | ||
916 | prom_getprop(prom_rtas, "rtas-size", &size, sizeof(size)); | 926 | prom_getprop(rtas_node, "rtas-size", &size, sizeof(size)); |
917 | if (size == 0) | 927 | if (size == 0) |
918 | return; | 928 | return; |
919 | 929 | ||
@@ -922,14 +932,18 @@ static void __init prom_instantiate_rtas(void) | |||
922 | prom_printf("RTAS allocation failed !\n"); | 932 | prom_printf("RTAS allocation failed !\n"); |
923 | return; | 933 | return; |
924 | } | 934 | } |
925 | prom_printf("instantiating rtas at 0x%x", base); | ||
926 | 935 | ||
927 | rtas_node = call_prom("open", 1, 1, ADDR("/rtas")); | 936 | rtas_inst = call_prom("open", 1, 1, ADDR("/rtas")); |
928 | prom_printf("..."); | 937 | if (!IHANDLE_VALID(rtas_inst)) { |
938 | prom_printf("opening rtas package failed"); | ||
939 | return; | ||
940 | } | ||
941 | |||
942 | prom_printf("instantiating rtas at 0x%x ...", base); | ||
929 | 943 | ||
930 | if (call_prom("call-method", 3, 2, | 944 | if (call_prom("call-method", 3, 2, |
931 | ADDR("instantiate-rtas"), | 945 | ADDR("instantiate-rtas"), |
932 | rtas_node, base) != PROM_ERROR) { | 946 | rtas_inst, base) != PROM_ERROR) { |
933 | entry = (long)_prom->args.rets[1]; | 947 | entry = (long)_prom->args.rets[1]; |
934 | } | 948 | } |
935 | if (entry == 0) { | 949 | if (entry == 0) { |
@@ -940,8 +954,8 @@ static void __init prom_instantiate_rtas(void) | |||
940 | 954 | ||
941 | reserve_mem(base, size); | 955 | reserve_mem(base, size); |
942 | 956 | ||
943 | prom_setprop(prom_rtas, "linux,rtas-base", &base, sizeof(base)); | 957 | prom_setprop(rtas_node, "linux,rtas-base", &base, sizeof(base)); |
944 | prom_setprop(prom_rtas, "linux,rtas-entry", &entry, sizeof(entry)); | 958 | prom_setprop(rtas_node, "linux,rtas-entry", &entry, sizeof(entry)); |
945 | 959 | ||
946 | prom_debug("rtas base = 0x%x\n", base); | 960 | prom_debug("rtas base = 0x%x\n", base); |
947 | prom_debug("rtas entry = 0x%x\n", entry); | 961 | prom_debug("rtas entry = 0x%x\n", entry); |
@@ -1062,7 +1076,7 @@ static void __init prom_initialize_tce_table(void) | |||
1062 | 1076 | ||
1063 | prom_printf("opening PHB %s", path); | 1077 | prom_printf("opening PHB %s", path); |
1064 | phb_node = call_prom("open", 1, 1, path); | 1078 | phb_node = call_prom("open", 1, 1, path); |
1065 | if ( (long)phb_node <= 0) | 1079 | if (phb_node == 0) |
1066 | prom_printf("... failed\n"); | 1080 | prom_printf("... failed\n"); |
1067 | else | 1081 | else |
1068 | prom_printf("... done\n"); | 1082 | prom_printf("... done\n"); |
@@ -1279,12 +1293,12 @@ static void __init prom_init_client_services(unsigned long pp) | |||
1279 | 1293 | ||
1280 | /* get a handle for the stdout device */ | 1294 | /* get a handle for the stdout device */ |
1281 | _prom->chosen = call_prom("finddevice", 1, 1, ADDR("/chosen")); | 1295 | _prom->chosen = call_prom("finddevice", 1, 1, ADDR("/chosen")); |
1282 | if ((long)_prom->chosen <= 0) | 1296 | if (!PHANDLE_VALID(_prom->chosen)) |
1283 | prom_panic("cannot find chosen"); /* msg won't be printed :( */ | 1297 | prom_panic("cannot find chosen"); /* msg won't be printed :( */ |
1284 | 1298 | ||
1285 | /* get device tree root */ | 1299 | /* get device tree root */ |
1286 | _prom->root = call_prom("finddevice", 1, 1, ADDR("/")); | 1300 | _prom->root = call_prom("finddevice", 1, 1, ADDR("/")); |
1287 | if ((long)_prom->root <= 0) | 1301 | if (!PHANDLE_VALID(_prom->root)) |
1288 | prom_panic("cannot find device tree root"); /* msg won't be printed :( */ | 1302 | prom_panic("cannot find device tree root"); /* msg won't be printed :( */ |
1289 | } | 1303 | } |
1290 | 1304 | ||
@@ -1356,9 +1370,8 @@ static int __init prom_find_machine_type(void) | |||
1356 | } | 1370 | } |
1357 | /* Default to pSeries. We need to know if we are running LPAR */ | 1371 | /* Default to pSeries. We need to know if we are running LPAR */ |
1358 | rtas = call_prom("finddevice", 1, 1, ADDR("/rtas")); | 1372 | rtas = call_prom("finddevice", 1, 1, ADDR("/rtas")); |
1359 | if (rtas != (phandle) -1) { | 1373 | if (PHANDLE_VALID(rtas)) { |
1360 | unsigned long x; | 1374 | int x = prom_getproplen(rtas, "ibm,hypertas-functions"); |
1361 | x = prom_getproplen(rtas, "ibm,hypertas-functions"); | ||
1362 | if (x != PROM_ERROR) { | 1375 | if (x != PROM_ERROR) { |
1363 | prom_printf("Hypertas detected, assuming LPAR !\n"); | 1376 | prom_printf("Hypertas detected, assuming LPAR !\n"); |
1364 | return PLATFORM_PSERIES_LPAR; | 1377 | return PLATFORM_PSERIES_LPAR; |
@@ -1426,12 +1439,13 @@ static void __init prom_check_displays(void) | |||
1426 | * leave some room at the end of the path for appending extra | 1439 | * leave some room at the end of the path for appending extra |
1427 | * arguments | 1440 | * arguments |
1428 | */ | 1441 | */ |
1429 | if (call_prom("package-to-path", 3, 1, node, path, PROM_SCRATCH_SIZE-10) < 0) | 1442 | if (call_prom("package-to-path", 3, 1, node, path, |
1443 | PROM_SCRATCH_SIZE-10) == PROM_ERROR) | ||
1430 | continue; | 1444 | continue; |
1431 | prom_printf("found display : %s, opening ... ", path); | 1445 | prom_printf("found display : %s, opening ... ", path); |
1432 | 1446 | ||
1433 | ih = call_prom("open", 1, 1, path); | 1447 | ih = call_prom("open", 1, 1, path); |
1434 | if (ih == (ihandle)0 || ih == (ihandle)-1) { | 1448 | if (ih == 0) { |
1435 | prom_printf("failed\n"); | 1449 | prom_printf("failed\n"); |
1436 | continue; | 1450 | continue; |
1437 | } | 1451 | } |
@@ -1514,6 +1528,12 @@ static unsigned long __init dt_find_string(char *str) | |||
1514 | return 0; | 1528 | return 0; |
1515 | } | 1529 | } |
1516 | 1530 | ||
1531 | /* | ||
1532 | * The Open Firmware 1275 specification states properties must be 31 bytes or | ||
1533 | * less, however not all firmwares obey this. Make it 64 bytes to be safe. | ||
1534 | */ | ||
1535 | #define MAX_PROPERTY_NAME 64 | ||
1536 | |||
1517 | static void __init scan_dt_build_strings(phandle node, unsigned long *mem_start, | 1537 | static void __init scan_dt_build_strings(phandle node, unsigned long *mem_start, |
1518 | unsigned long *mem_end) | 1538 | unsigned long *mem_end) |
1519 | { | 1539 | { |
@@ -1527,10 +1547,12 @@ static void __init scan_dt_build_strings(phandle node, unsigned long *mem_start, | |||
1527 | /* get and store all property names */ | 1547 | /* get and store all property names */ |
1528 | prev_name = RELOC(""); | 1548 | prev_name = RELOC(""); |
1529 | for (;;) { | 1549 | for (;;) { |
1530 | 1550 | int rc; | |
1531 | /* 32 is max len of name including nul. */ | 1551 | |
1532 | namep = make_room(mem_start, mem_end, 32, 1); | 1552 | /* 64 is max len of name including nul. */ |
1533 | if (call_prom("nextprop", 3, 1, node, prev_name, namep) <= 0) { | 1553 | namep = make_room(mem_start, mem_end, MAX_PROPERTY_NAME, 1); |
1554 | rc = call_prom("nextprop", 3, 1, node, prev_name, namep); | ||
1555 | if (rc != 1) { | ||
1534 | /* No more nodes: unwind alloc */ | 1556 | /* No more nodes: unwind alloc */ |
1535 | *mem_start = (unsigned long)namep; | 1557 | *mem_start = (unsigned long)namep; |
1536 | break; | 1558 | break; |
@@ -1555,18 +1577,12 @@ static void __init scan_dt_build_strings(phandle node, unsigned long *mem_start, | |||
1555 | } | 1577 | } |
1556 | } | 1578 | } |
1557 | 1579 | ||
1558 | /* | ||
1559 | * The Open Firmware 1275 specification states properties must be 31 bytes or | ||
1560 | * less, however not all firmwares obey this. Make it 64 bytes to be safe. | ||
1561 | */ | ||
1562 | #define MAX_PROPERTY_NAME 64 | ||
1563 | |||
1564 | static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start, | 1580 | static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start, |
1565 | unsigned long *mem_end) | 1581 | unsigned long *mem_end) |
1566 | { | 1582 | { |
1567 | int l, align; | 1583 | int l, align; |
1568 | phandle child; | 1584 | phandle child; |
1569 | char *namep, *prev_name, *sstart; | 1585 | char *namep, *prev_name, *sstart, *p, *ep; |
1570 | unsigned long soff; | 1586 | unsigned long soff; |
1571 | unsigned char *valp; | 1587 | unsigned char *valp; |
1572 | unsigned long offset = reloc_offset(); | 1588 | unsigned long offset = reloc_offset(); |
@@ -1588,6 +1604,14 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start, | |||
1588 | call_prom("package-to-path", 3, 1, node, namep, l); | 1604 | call_prom("package-to-path", 3, 1, node, namep, l); |
1589 | } | 1605 | } |
1590 | namep[l] = '\0'; | 1606 | namep[l] = '\0'; |
1607 | /* Fixup an Apple bug where they have bogus \0 chars in the | ||
1608 | * middle of the path in some properties | ||
1609 | */ | ||
1610 | for (p = namep, ep = namep + l; p < ep; p++) | ||
1611 | if (*p == '\0') { | ||
1612 | memmove(p, p+1, ep - p); | ||
1613 | ep--; l--; | ||
1614 | } | ||
1591 | *mem_start = _ALIGN(((unsigned long) namep) + strlen(namep) + 1, 4); | 1615 | *mem_start = _ALIGN(((unsigned long) namep) + strlen(namep) + 1, 4); |
1592 | } | 1616 | } |
1593 | 1617 | ||
@@ -1599,7 +1623,10 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start, | |||
1599 | prev_name = RELOC(""); | 1623 | prev_name = RELOC(""); |
1600 | sstart = (char *)RELOC(dt_string_start); | 1624 | sstart = (char *)RELOC(dt_string_start); |
1601 | for (;;) { | 1625 | for (;;) { |
1602 | if (call_prom("nextprop", 3, 1, node, prev_name, pname) <= 0) | 1626 | int rc; |
1627 | |||
1628 | rc = call_prom("nextprop", 3, 1, node, prev_name, pname); | ||
1629 | if (rc != 1) | ||
1603 | break; | 1630 | break; |
1604 | 1631 | ||
1605 | /* find string offset */ | 1632 | /* find string offset */ |
@@ -1615,7 +1642,7 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start, | |||
1615 | l = call_prom("getproplen", 2, 1, node, pname); | 1642 | l = call_prom("getproplen", 2, 1, node, pname); |
1616 | 1643 | ||
1617 | /* sanity checks */ | 1644 | /* sanity checks */ |
1618 | if (l < 0) | 1645 | if (l == PROM_ERROR) |
1619 | continue; | 1646 | continue; |
1620 | if (l > MAX_PROPERTY_LENGTH) { | 1647 | if (l > MAX_PROPERTY_LENGTH) { |
1621 | prom_printf("WARNING: ignoring large property "); | 1648 | prom_printf("WARNING: ignoring large property "); |
@@ -1763,17 +1790,18 @@ static void __init fixup_device_tree(void) | |||
1763 | 1790 | ||
1764 | /* Some G5s have a missing interrupt definition, fix it up here */ | 1791 | /* Some G5s have a missing interrupt definition, fix it up here */ |
1765 | u3 = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000")); | 1792 | u3 = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000")); |
1766 | if ((long)u3 <= 0) | 1793 | if (!PHANDLE_VALID(u3)) |
1767 | return; | 1794 | return; |
1768 | i2c = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000/i2c@f8001000")); | 1795 | i2c = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000/i2c@f8001000")); |
1769 | if ((long)i2c <= 0) | 1796 | if (!PHANDLE_VALID(i2c)) |
1770 | return; | 1797 | return; |
1771 | mpic = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000/mpic@f8040000")); | 1798 | mpic = call_prom("finddevice", 1, 1, ADDR("/u3@0,f8000000/mpic@f8040000")); |
1772 | if ((long)mpic <= 0) | 1799 | if (!PHANDLE_VALID(mpic)) |
1773 | return; | 1800 | return; |
1774 | 1801 | ||
1775 | /* check if proper rev of u3 */ | 1802 | /* check if proper rev of u3 */ |
1776 | if (prom_getprop(u3, "device-rev", &u3_rev, sizeof(u3_rev)) <= 0) | 1803 | if (prom_getprop(u3, "device-rev", &u3_rev, sizeof(u3_rev)) |
1804 | == PROM_ERROR) | ||
1777 | return; | 1805 | return; |
1778 | if (u3_rev != 0x35) | 1806 | if (u3_rev != 0x35) |
1779 | return; | 1807 | return; |
@@ -1881,6 +1909,12 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4, unsigned long | |||
1881 | &getprop_rval, sizeof(getprop_rval)); | 1909 | &getprop_rval, sizeof(getprop_rval)); |
1882 | 1910 | ||
1883 | /* | 1911 | /* |
1912 | * On pSeries, inform the firmware about our capabilities | ||
1913 | */ | ||
1914 | if (RELOC(of_platform) & PLATFORM_PSERIES) | ||
1915 | prom_send_capabilities(); | ||
1916 | |||
1917 | /* | ||
1884 | * On pSeries, copy the CPU hold code | 1918 | * On pSeries, copy the CPU hold code |
1885 | */ | 1919 | */ |
1886 | if (RELOC(of_platform) & PLATFORM_PSERIES) | 1920 | if (RELOC(of_platform) & PLATFORM_PSERIES) |
diff --git a/arch/ppc64/kernel/setup.c b/arch/ppc64/kernel/setup.c index 21c57f539c29..dce198d39328 100644 --- a/arch/ppc64/kernel/setup.c +++ b/arch/ppc64/kernel/setup.c | |||
@@ -103,11 +103,6 @@ extern void unflatten_device_tree(void); | |||
103 | 103 | ||
104 | extern void smp_release_cpus(void); | 104 | extern void smp_release_cpus(void); |
105 | 105 | ||
106 | unsigned long decr_overclock = 1; | ||
107 | unsigned long decr_overclock_proc0 = 1; | ||
108 | unsigned long decr_overclock_set = 0; | ||
109 | unsigned long decr_overclock_proc0_set = 0; | ||
110 | |||
111 | int have_of = 1; | 106 | int have_of = 1; |
112 | int boot_cpuid = 0; | 107 | int boot_cpuid = 0; |
113 | int boot_cpuid_phys = 0; | 108 | int boot_cpuid_phys = 0; |
@@ -1120,64 +1115,15 @@ void ppc64_dump_msg(unsigned int src, const char *msg) | |||
1120 | printk("[dump]%04x %s\n", src, msg); | 1115 | printk("[dump]%04x %s\n", src, msg); |
1121 | } | 1116 | } |
1122 | 1117 | ||
1123 | int set_spread_lpevents( char * str ) | ||
1124 | { | ||
1125 | /* The parameter is the number of processors to share in processing lp events */ | ||
1126 | unsigned long i; | ||
1127 | unsigned long val = simple_strtoul( str, NULL, 0 ); | ||
1128 | if ( ( val > 0 ) && ( val <= NR_CPUS ) ) { | ||
1129 | for ( i=1; i<val; ++i ) | ||
1130 | paca[i].lpqueue_ptr = paca[0].lpqueue_ptr; | ||
1131 | printk("lpevent processing spread over %ld processors\n", val); | ||
1132 | } | ||
1133 | else | ||
1134 | printk("invalid spreaqd_lpevents %ld\n", val); | ||
1135 | return 1; | ||
1136 | } | ||
1137 | |||
1138 | /* This should only be called on processor 0 during calibrate decr */ | 1118 | /* This should only be called on processor 0 during calibrate decr */ |
1139 | void setup_default_decr(void) | 1119 | void setup_default_decr(void) |
1140 | { | 1120 | { |
1141 | struct paca_struct *lpaca = get_paca(); | 1121 | struct paca_struct *lpaca = get_paca(); |
1142 | 1122 | ||
1143 | if ( decr_overclock_set && !decr_overclock_proc0_set ) | 1123 | lpaca->default_decr = tb_ticks_per_jiffy; |
1144 | decr_overclock_proc0 = decr_overclock; | ||
1145 | |||
1146 | lpaca->default_decr = tb_ticks_per_jiffy / decr_overclock_proc0; | ||
1147 | lpaca->next_jiffy_update_tb = get_tb() + tb_ticks_per_jiffy; | 1124 | lpaca->next_jiffy_update_tb = get_tb() + tb_ticks_per_jiffy; |
1148 | } | 1125 | } |
1149 | 1126 | ||
1150 | int set_decr_overclock_proc0( char * str ) | ||
1151 | { | ||
1152 | unsigned long val = simple_strtoul( str, NULL, 0 ); | ||
1153 | if ( ( val >= 1 ) && ( val <= 48 ) ) { | ||
1154 | decr_overclock_proc0_set = 1; | ||
1155 | decr_overclock_proc0 = val; | ||
1156 | printk("proc 0 decrementer overclock factor of %ld\n", val); | ||
1157 | } | ||
1158 | else | ||
1159 | printk("invalid proc 0 decrementer overclock factor of %ld\n", val); | ||
1160 | return 1; | ||
1161 | } | ||
1162 | |||
1163 | int set_decr_overclock( char * str ) | ||
1164 | { | ||
1165 | unsigned long val = simple_strtoul( str, NULL, 0 ); | ||
1166 | if ( ( val >= 1 ) && ( val <= 48 ) ) { | ||
1167 | decr_overclock_set = 1; | ||
1168 | decr_overclock = val; | ||
1169 | printk("decrementer overclock factor of %ld\n", val); | ||
1170 | } | ||
1171 | else | ||
1172 | printk("invalid decrementer overclock factor of %ld\n", val); | ||
1173 | return 1; | ||
1174 | |||
1175 | } | ||
1176 | |||
1177 | __setup("spread_lpevents=", set_spread_lpevents ); | ||
1178 | __setup("decr_overclock_proc0=", set_decr_overclock_proc0 ); | ||
1179 | __setup("decr_overclock=", set_decr_overclock ); | ||
1180 | |||
1181 | #ifndef CONFIG_PPC_ISERIES | 1127 | #ifndef CONFIG_PPC_ISERIES |
1182 | /* | 1128 | /* |
1183 | * This function can be used by platforms to "find" legacy serial ports. | 1129 | * This function can be used by platforms to "find" legacy serial ports. |
diff --git a/arch/ppc64/kernel/smp.c b/arch/ppc64/kernel/smp.c index 3b906cd94037..9ef5d36d6b25 100644 --- a/arch/ppc64/kernel/smp.c +++ b/arch/ppc64/kernel/smp.c | |||
@@ -334,7 +334,6 @@ void smp_call_function_interrupt(void) | |||
334 | } | 334 | } |
335 | } | 335 | } |
336 | 336 | ||
337 | extern unsigned long decr_overclock; | ||
338 | extern struct gettimeofday_struct do_gtod; | 337 | extern struct gettimeofday_struct do_gtod; |
339 | 338 | ||
340 | struct thread_info *current_set[NR_CPUS]; | 339 | struct thread_info *current_set[NR_CPUS]; |
@@ -491,7 +490,7 @@ int __devinit __cpu_up(unsigned int cpu) | |||
491 | if (smp_ops->cpu_bootable && !smp_ops->cpu_bootable(cpu)) | 490 | if (smp_ops->cpu_bootable && !smp_ops->cpu_bootable(cpu)) |
492 | return -EINVAL; | 491 | return -EINVAL; |
493 | 492 | ||
494 | paca[cpu].default_decr = tb_ticks_per_jiffy / decr_overclock; | 493 | paca[cpu].default_decr = tb_ticks_per_jiffy; |
495 | 494 | ||
496 | if (!cpu_has_feature(CPU_FTR_SLB)) { | 495 | if (!cpu_has_feature(CPU_FTR_SLB)) { |
497 | void *tmp; | 496 | void *tmp; |
diff --git a/arch/ppc64/kernel/sysfs.c b/arch/ppc64/kernel/sysfs.c index 0925694c3ce5..c8fa6569b2fd 100644 --- a/arch/ppc64/kernel/sysfs.c +++ b/arch/ppc64/kernel/sysfs.c | |||
@@ -113,7 +113,6 @@ void ppc64_enable_pmcs(void) | |||
113 | #ifdef CONFIG_PPC_PSERIES | 113 | #ifdef CONFIG_PPC_PSERIES |
114 | unsigned long set, reset; | 114 | unsigned long set, reset; |
115 | int ret; | 115 | int ret; |
116 | unsigned int ctrl; | ||
117 | #endif /* CONFIG_PPC_PSERIES */ | 116 | #endif /* CONFIG_PPC_PSERIES */ |
118 | 117 | ||
119 | /* Only need to enable them once */ | 118 | /* Only need to enable them once */ |
@@ -167,11 +166,8 @@ void ppc64_enable_pmcs(void) | |||
167 | * On SMT machines we have to set the run latch in the ctrl register | 166 | * On SMT machines we have to set the run latch in the ctrl register |
168 | * in order to make PMC6 spin. | 167 | * in order to make PMC6 spin. |
169 | */ | 168 | */ |
170 | if (cpu_has_feature(CPU_FTR_SMT)) { | 169 | if (cpu_has_feature(CPU_FTR_SMT)) |
171 | ctrl = mfspr(CTRLF); | 170 | ppc64_runlatch_on(); |
172 | ctrl |= RUNLATCH; | ||
173 | mtspr(CTRLT, ctrl); | ||
174 | } | ||
175 | #endif /* CONFIG_PPC_PSERIES */ | 171 | #endif /* CONFIG_PPC_PSERIES */ |
176 | } | 172 | } |
177 | 173 | ||
diff --git a/arch/ppc64/kernel/time.c b/arch/ppc64/kernel/time.c index 3d54745108c7..33364a7d2cd2 100644 --- a/arch/ppc64/kernel/time.c +++ b/arch/ppc64/kernel/time.c | |||
@@ -325,9 +325,7 @@ int timer_interrupt(struct pt_regs * regs) | |||
325 | 325 | ||
326 | irq_enter(); | 326 | irq_enter(); |
327 | 327 | ||
328 | #ifndef CONFIG_PPC_ISERIES | ||
329 | profile_tick(CPU_PROFILING, regs); | 328 | profile_tick(CPU_PROFILING, regs); |
330 | #endif | ||
331 | 329 | ||
332 | lpaca->lppaca.int_dword.fields.decr_int = 0; | 330 | lpaca->lppaca.int_dword.fields.decr_int = 0; |
333 | 331 | ||
diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c index 01ae1964c938..c067435bae45 100644 --- a/arch/s390/appldata/appldata_base.c +++ b/arch/s390/appldata/appldata_base.c | |||
@@ -28,6 +28,7 @@ | |||
28 | //#include <linux/kernel_stat.h> | 28 | //#include <linux/kernel_stat.h> |
29 | #include <linux/notifier.h> | 29 | #include <linux/notifier.h> |
30 | #include <linux/cpu.h> | 30 | #include <linux/cpu.h> |
31 | #include <linux/workqueue.h> | ||
31 | 32 | ||
32 | #include "appldata.h" | 33 | #include "appldata.h" |
33 | 34 | ||
@@ -133,9 +134,12 @@ static int appldata_interval = APPLDATA_CPU_INTERVAL; | |||
133 | static int appldata_timer_active; | 134 | static int appldata_timer_active; |
134 | 135 | ||
135 | /* | 136 | /* |
136 | * Tasklet | 137 | * Work queue |
137 | */ | 138 | */ |
138 | static struct tasklet_struct appldata_tasklet_struct; | 139 | static struct workqueue_struct *appldata_wq; |
140 | static void appldata_work_fn(void *data); | ||
141 | static DECLARE_WORK(appldata_work, appldata_work_fn, NULL); | ||
142 | |||
139 | 143 | ||
140 | /* | 144 | /* |
141 | * Ops list | 145 | * Ops list |
@@ -144,11 +148,11 @@ static DEFINE_SPINLOCK(appldata_ops_lock); | |||
144 | static LIST_HEAD(appldata_ops_list); | 148 | static LIST_HEAD(appldata_ops_list); |
145 | 149 | ||
146 | 150 | ||
147 | /************************* timer, tasklet, DIAG ******************************/ | 151 | /*************************** timer, work, DIAG *******************************/ |
148 | /* | 152 | /* |
149 | * appldata_timer_function() | 153 | * appldata_timer_function() |
150 | * | 154 | * |
151 | * schedule tasklet and reschedule timer | 155 | * schedule work and reschedule timer |
152 | */ | 156 | */ |
153 | static void appldata_timer_function(unsigned long data, struct pt_regs *regs) | 157 | static void appldata_timer_function(unsigned long data, struct pt_regs *regs) |
154 | { | 158 | { |
@@ -157,22 +161,22 @@ static void appldata_timer_function(unsigned long data, struct pt_regs *regs) | |||
157 | atomic_read(&appldata_expire_count)); | 161 | atomic_read(&appldata_expire_count)); |
158 | if (atomic_dec_and_test(&appldata_expire_count)) { | 162 | if (atomic_dec_and_test(&appldata_expire_count)) { |
159 | atomic_set(&appldata_expire_count, num_online_cpus()); | 163 | atomic_set(&appldata_expire_count, num_online_cpus()); |
160 | tasklet_schedule((struct tasklet_struct *) data); | 164 | queue_work(appldata_wq, (struct work_struct *) data); |
161 | } | 165 | } |
162 | } | 166 | } |
163 | 167 | ||
164 | /* | 168 | /* |
165 | * appldata_tasklet_function() | 169 | * appldata_work_fn() |
166 | * | 170 | * |
167 | * call data gathering function for each (active) module | 171 | * call data gathering function for each (active) module |
168 | */ | 172 | */ |
169 | static void appldata_tasklet_function(unsigned long data) | 173 | static void appldata_work_fn(void *data) |
170 | { | 174 | { |
171 | struct list_head *lh; | 175 | struct list_head *lh; |
172 | struct appldata_ops *ops; | 176 | struct appldata_ops *ops; |
173 | int i; | 177 | int i; |
174 | 178 | ||
175 | P_DEBUG(" -= Tasklet =-\n"); | 179 | P_DEBUG(" -= Work Queue =-\n"); |
176 | i = 0; | 180 | i = 0; |
177 | spin_lock(&appldata_ops_lock); | 181 | spin_lock(&appldata_ops_lock); |
178 | list_for_each(lh, &appldata_ops_list) { | 182 | list_for_each(lh, &appldata_ops_list) { |
@@ -231,7 +235,7 @@ static int appldata_diag(char record_nr, u16 function, unsigned long buffer, | |||
231 | : "=d" (ry) : "d" (&(appldata_parameter_list)) : "cc"); | 235 | : "=d" (ry) : "d" (&(appldata_parameter_list)) : "cc"); |
232 | return (int) ry; | 236 | return (int) ry; |
233 | } | 237 | } |
234 | /********************** timer, tasklet, DIAG <END> ***************************/ | 238 | /************************ timer, work, DIAG <END> ****************************/ |
235 | 239 | ||
236 | 240 | ||
237 | /****************************** /proc stuff **********************************/ | 241 | /****************************** /proc stuff **********************************/ |
@@ -411,7 +415,7 @@ appldata_generic_handler(ctl_table *ctl, int write, struct file *filp, | |||
411 | struct list_head *lh; | 415 | struct list_head *lh; |
412 | 416 | ||
413 | found = 0; | 417 | found = 0; |
414 | spin_lock_bh(&appldata_ops_lock); | 418 | spin_lock(&appldata_ops_lock); |
415 | list_for_each(lh, &appldata_ops_list) { | 419 | list_for_each(lh, &appldata_ops_list) { |
416 | tmp_ops = list_entry(lh, struct appldata_ops, list); | 420 | tmp_ops = list_entry(lh, struct appldata_ops, list); |
417 | if (&tmp_ops->ctl_table[2] == ctl) { | 421 | if (&tmp_ops->ctl_table[2] == ctl) { |
@@ -419,15 +423,15 @@ appldata_generic_handler(ctl_table *ctl, int write, struct file *filp, | |||
419 | } | 423 | } |
420 | } | 424 | } |
421 | if (!found) { | 425 | if (!found) { |
422 | spin_unlock_bh(&appldata_ops_lock); | 426 | spin_unlock(&appldata_ops_lock); |
423 | return -ENODEV; | 427 | return -ENODEV; |
424 | } | 428 | } |
425 | ops = ctl->data; | 429 | ops = ctl->data; |
426 | if (!try_module_get(ops->owner)) { // protect this function | 430 | if (!try_module_get(ops->owner)) { // protect this function |
427 | spin_unlock_bh(&appldata_ops_lock); | 431 | spin_unlock(&appldata_ops_lock); |
428 | return -ENODEV; | 432 | return -ENODEV; |
429 | } | 433 | } |
430 | spin_unlock_bh(&appldata_ops_lock); | 434 | spin_unlock(&appldata_ops_lock); |
431 | 435 | ||
432 | if (!*lenp || *ppos) { | 436 | if (!*lenp || *ppos) { |
433 | *lenp = 0; | 437 | *lenp = 0; |
@@ -451,10 +455,11 @@ appldata_generic_handler(ctl_table *ctl, int write, struct file *filp, | |||
451 | return -EFAULT; | 455 | return -EFAULT; |
452 | } | 456 | } |
453 | 457 | ||
454 | spin_lock_bh(&appldata_ops_lock); | 458 | spin_lock(&appldata_ops_lock); |
455 | if ((buf[0] == '1') && (ops->active == 0)) { | 459 | if ((buf[0] == '1') && (ops->active == 0)) { |
456 | if (!try_module_get(ops->owner)) { // protect tasklet | 460 | // protect work queue callback |
457 | spin_unlock_bh(&appldata_ops_lock); | 461 | if (!try_module_get(ops->owner)) { |
462 | spin_unlock(&appldata_ops_lock); | ||
458 | module_put(ops->owner); | 463 | module_put(ops->owner); |
459 | return -ENODEV; | 464 | return -ENODEV; |
460 | } | 465 | } |
@@ -485,7 +490,7 @@ appldata_generic_handler(ctl_table *ctl, int write, struct file *filp, | |||
485 | } | 490 | } |
486 | module_put(ops->owner); | 491 | module_put(ops->owner); |
487 | } | 492 | } |
488 | spin_unlock_bh(&appldata_ops_lock); | 493 | spin_unlock(&appldata_ops_lock); |
489 | out: | 494 | out: |
490 | *lenp = len; | 495 | *lenp = len; |
491 | *ppos += len; | 496 | *ppos += len; |
@@ -529,7 +534,7 @@ int appldata_register_ops(struct appldata_ops *ops) | |||
529 | } | 534 | } |
530 | memset(ops->ctl_table, 0, 4*sizeof(struct ctl_table)); | 535 | memset(ops->ctl_table, 0, 4*sizeof(struct ctl_table)); |
531 | 536 | ||
532 | spin_lock_bh(&appldata_ops_lock); | 537 | spin_lock(&appldata_ops_lock); |
533 | list_for_each(lh, &appldata_ops_list) { | 538 | list_for_each(lh, &appldata_ops_list) { |
534 | tmp_ops = list_entry(lh, struct appldata_ops, list); | 539 | tmp_ops = list_entry(lh, struct appldata_ops, list); |
535 | P_DEBUG("register_ops loop: %i) name = %s, ctl = %i\n", | 540 | P_DEBUG("register_ops loop: %i) name = %s, ctl = %i\n", |
@@ -541,18 +546,18 @@ int appldata_register_ops(struct appldata_ops *ops) | |||
541 | APPLDATA_PROC_NAME_LENGTH) == 0) { | 546 | APPLDATA_PROC_NAME_LENGTH) == 0) { |
542 | P_ERROR("Name \"%s\" already registered!\n", ops->name); | 547 | P_ERROR("Name \"%s\" already registered!\n", ops->name); |
543 | kfree(ops->ctl_table); | 548 | kfree(ops->ctl_table); |
544 | spin_unlock_bh(&appldata_ops_lock); | 549 | spin_unlock(&appldata_ops_lock); |
545 | return -EBUSY; | 550 | return -EBUSY; |
546 | } | 551 | } |
547 | if (tmp_ops->ctl_nr == ops->ctl_nr) { | 552 | if (tmp_ops->ctl_nr == ops->ctl_nr) { |
548 | P_ERROR("ctl_nr %i already registered!\n", ops->ctl_nr); | 553 | P_ERROR("ctl_nr %i already registered!\n", ops->ctl_nr); |
549 | kfree(ops->ctl_table); | 554 | kfree(ops->ctl_table); |
550 | spin_unlock_bh(&appldata_ops_lock); | 555 | spin_unlock(&appldata_ops_lock); |
551 | return -EBUSY; | 556 | return -EBUSY; |
552 | } | 557 | } |
553 | } | 558 | } |
554 | list_add(&ops->list, &appldata_ops_list); | 559 | list_add(&ops->list, &appldata_ops_list); |
555 | spin_unlock_bh(&appldata_ops_lock); | 560 | spin_unlock(&appldata_ops_lock); |
556 | 561 | ||
557 | ops->ctl_table[0].ctl_name = CTL_APPLDATA; | 562 | ops->ctl_table[0].ctl_name = CTL_APPLDATA; |
558 | ops->ctl_table[0].procname = appldata_proc_name; | 563 | ops->ctl_table[0].procname = appldata_proc_name; |
@@ -583,12 +588,12 @@ int appldata_register_ops(struct appldata_ops *ops) | |||
583 | */ | 588 | */ |
584 | void appldata_unregister_ops(struct appldata_ops *ops) | 589 | void appldata_unregister_ops(struct appldata_ops *ops) |
585 | { | 590 | { |
586 | spin_lock_bh(&appldata_ops_lock); | 591 | spin_lock(&appldata_ops_lock); |
587 | unregister_sysctl_table(ops->sysctl_header); | 592 | unregister_sysctl_table(ops->sysctl_header); |
588 | list_del(&ops->list); | 593 | list_del(&ops->list); |
589 | kfree(ops->ctl_table); | 594 | kfree(ops->ctl_table); |
590 | ops->ctl_table = NULL; | 595 | ops->ctl_table = NULL; |
591 | spin_unlock_bh(&appldata_ops_lock); | 596 | spin_unlock(&appldata_ops_lock); |
592 | P_INFO("%s-ops unregistered!\n", ops->name); | 597 | P_INFO("%s-ops unregistered!\n", ops->name); |
593 | } | 598 | } |
594 | /********************** module-ops management <END> **************************/ | 599 | /********************** module-ops management <END> **************************/ |
@@ -602,7 +607,7 @@ appldata_online_cpu(int cpu) | |||
602 | init_virt_timer(&per_cpu(appldata_timer, cpu)); | 607 | init_virt_timer(&per_cpu(appldata_timer, cpu)); |
603 | per_cpu(appldata_timer, cpu).function = appldata_timer_function; | 608 | per_cpu(appldata_timer, cpu).function = appldata_timer_function; |
604 | per_cpu(appldata_timer, cpu).data = (unsigned long) | 609 | per_cpu(appldata_timer, cpu).data = (unsigned long) |
605 | &appldata_tasklet_struct; | 610 | &appldata_work; |
606 | atomic_inc(&appldata_expire_count); | 611 | atomic_inc(&appldata_expire_count); |
607 | spin_lock(&appldata_timer_lock); | 612 | spin_lock(&appldata_timer_lock); |
608 | __appldata_vtimer_setup(APPLDATA_MOD_TIMER); | 613 | __appldata_vtimer_setup(APPLDATA_MOD_TIMER); |
@@ -615,7 +620,7 @@ appldata_offline_cpu(int cpu) | |||
615 | del_virt_timer(&per_cpu(appldata_timer, cpu)); | 620 | del_virt_timer(&per_cpu(appldata_timer, cpu)); |
616 | if (atomic_dec_and_test(&appldata_expire_count)) { | 621 | if (atomic_dec_and_test(&appldata_expire_count)) { |
617 | atomic_set(&appldata_expire_count, num_online_cpus()); | 622 | atomic_set(&appldata_expire_count, num_online_cpus()); |
618 | tasklet_schedule(&appldata_tasklet_struct); | 623 | queue_work(appldata_wq, &appldata_work); |
619 | } | 624 | } |
620 | spin_lock(&appldata_timer_lock); | 625 | spin_lock(&appldata_timer_lock); |
621 | __appldata_vtimer_setup(APPLDATA_MOD_TIMER); | 626 | __appldata_vtimer_setup(APPLDATA_MOD_TIMER); |
@@ -648,7 +653,7 @@ static struct notifier_block __devinitdata appldata_nb = { | |||
648 | /* | 653 | /* |
649 | * appldata_init() | 654 | * appldata_init() |
650 | * | 655 | * |
651 | * init timer and tasklet, register /proc entries | 656 | * init timer, register /proc entries |
652 | */ | 657 | */ |
653 | static int __init appldata_init(void) | 658 | static int __init appldata_init(void) |
654 | { | 659 | { |
@@ -657,6 +662,12 @@ static int __init appldata_init(void) | |||
657 | P_DEBUG("sizeof(parameter_list) = %lu\n", | 662 | P_DEBUG("sizeof(parameter_list) = %lu\n", |
658 | sizeof(struct appldata_parameter_list)); | 663 | sizeof(struct appldata_parameter_list)); |
659 | 664 | ||
665 | appldata_wq = create_singlethread_workqueue("appldata"); | ||
666 | if (!appldata_wq) { | ||
667 | P_ERROR("Could not create work queue\n"); | ||
668 | return -ENOMEM; | ||
669 | } | ||
670 | |||
660 | for_each_online_cpu(i) | 671 | for_each_online_cpu(i) |
661 | appldata_online_cpu(i); | 672 | appldata_online_cpu(i); |
662 | 673 | ||
@@ -670,7 +681,6 @@ static int __init appldata_init(void) | |||
670 | appldata_table[1].de->owner = THIS_MODULE; | 681 | appldata_table[1].de->owner = THIS_MODULE; |
671 | #endif | 682 | #endif |
672 | 683 | ||
673 | tasklet_init(&appldata_tasklet_struct, appldata_tasklet_function, 0); | ||
674 | P_DEBUG("Base interface initialized.\n"); | 684 | P_DEBUG("Base interface initialized.\n"); |
675 | return 0; | 685 | return 0; |
676 | } | 686 | } |
@@ -678,7 +688,7 @@ static int __init appldata_init(void) | |||
678 | /* | 688 | /* |
679 | * appldata_exit() | 689 | * appldata_exit() |
680 | * | 690 | * |
681 | * stop timer and tasklet, unregister /proc entries | 691 | * stop timer, unregister /proc entries |
682 | */ | 692 | */ |
683 | static void __exit appldata_exit(void) | 693 | static void __exit appldata_exit(void) |
684 | { | 694 | { |
@@ -690,7 +700,7 @@ static void __exit appldata_exit(void) | |||
690 | /* | 700 | /* |
691 | * ops list should be empty, but just in case something went wrong... | 701 | * ops list should be empty, but just in case something went wrong... |
692 | */ | 702 | */ |
693 | spin_lock_bh(&appldata_ops_lock); | 703 | spin_lock(&appldata_ops_lock); |
694 | list_for_each(lh, &appldata_ops_list) { | 704 | list_for_each(lh, &appldata_ops_list) { |
695 | ops = list_entry(lh, struct appldata_ops, list); | 705 | ops = list_entry(lh, struct appldata_ops, list); |
696 | rc = appldata_diag(ops->record_nr, APPLDATA_STOP_REC, | 706 | rc = appldata_diag(ops->record_nr, APPLDATA_STOP_REC, |
@@ -700,7 +710,7 @@ static void __exit appldata_exit(void) | |||
700 | "return code: %d\n", ops->name, rc); | 710 | "return code: %d\n", ops->name, rc); |
701 | } | 711 | } |
702 | } | 712 | } |
703 | spin_unlock_bh(&appldata_ops_lock); | 713 | spin_unlock(&appldata_ops_lock); |
704 | 714 | ||
705 | for_each_online_cpu(i) | 715 | for_each_online_cpu(i) |
706 | appldata_offline_cpu(i); | 716 | appldata_offline_cpu(i); |
@@ -709,7 +719,7 @@ static void __exit appldata_exit(void) | |||
709 | 719 | ||
710 | unregister_sysctl_table(appldata_sysctl_header); | 720 | unregister_sysctl_table(appldata_sysctl_header); |
711 | 721 | ||
712 | tasklet_kill(&appldata_tasklet_struct); | 722 | destroy_workqueue(appldata_wq); |
713 | P_DEBUG("... module unloaded!\n"); | 723 | P_DEBUG("... module unloaded!\n"); |
714 | } | 724 | } |
715 | /**************************** init / exit <END> ******************************/ | 725 | /**************************** init / exit <END> ******************************/ |
diff --git a/arch/s390/appldata/appldata_mem.c b/arch/s390/appldata/appldata_mem.c index 462ee9a84e76..f0e2fbed3d4c 100644 --- a/arch/s390/appldata/appldata_mem.c +++ b/arch/s390/appldata/appldata_mem.c | |||
@@ -68,7 +68,7 @@ struct appldata_mem_data { | |||
68 | u64 pgmajfault; /* page faults (major only) */ | 68 | u64 pgmajfault; /* page faults (major only) */ |
69 | // <-- New in 2.6 | 69 | // <-- New in 2.6 |
70 | 70 | ||
71 | } appldata_mem_data; | 71 | } __attribute__((packed)) appldata_mem_data; |
72 | 72 | ||
73 | 73 | ||
74 | static inline void appldata_debug_print(struct appldata_mem_data *mem_data) | 74 | static inline void appldata_debug_print(struct appldata_mem_data *mem_data) |
diff --git a/arch/s390/appldata/appldata_net_sum.c b/arch/s390/appldata/appldata_net_sum.c index dd61638d3027..2a4c7432db4a 100644 --- a/arch/s390/appldata/appldata_net_sum.c +++ b/arch/s390/appldata/appldata_net_sum.c | |||
@@ -57,7 +57,7 @@ struct appldata_net_sum_data { | |||
57 | u64 rx_dropped; /* no space in linux buffers */ | 57 | u64 rx_dropped; /* no space in linux buffers */ |
58 | u64 tx_dropped; /* no space available in linux */ | 58 | u64 tx_dropped; /* no space available in linux */ |
59 | u64 collisions; /* collisions while transmitting */ | 59 | u64 collisions; /* collisions while transmitting */ |
60 | } appldata_net_sum_data; | 60 | } __attribute__((packed)) appldata_net_sum_data; |
61 | 61 | ||
62 | 62 | ||
63 | static inline void appldata_print_debug(struct appldata_net_sum_data *net_data) | 63 | static inline void appldata_print_debug(struct appldata_net_sum_data *net_data) |
diff --git a/arch/s390/appldata/appldata_os.c b/arch/s390/appldata/appldata_os.c index b83f07484551..e0a476bf4fd6 100644 --- a/arch/s390/appldata/appldata_os.c +++ b/arch/s390/appldata/appldata_os.c | |||
@@ -49,7 +49,7 @@ struct appldata_os_per_cpu { | |||
49 | u32 per_cpu_softirq; /* ... spent in softirqs */ | 49 | u32 per_cpu_softirq; /* ... spent in softirqs */ |
50 | u32 per_cpu_iowait; /* ... spent while waiting for I/O */ | 50 | u32 per_cpu_iowait; /* ... spent while waiting for I/O */ |
51 | // <-- New in 2.6 | 51 | // <-- New in 2.6 |
52 | }; | 52 | } __attribute__((packed)); |
53 | 53 | ||
54 | struct appldata_os_data { | 54 | struct appldata_os_data { |
55 | u64 timestamp; | 55 | u64 timestamp; |
@@ -75,7 +75,7 @@ struct appldata_os_data { | |||
75 | 75 | ||
76 | /* per cpu data */ | 76 | /* per cpu data */ |
77 | struct appldata_os_per_cpu os_cpu[0]; | 77 | struct appldata_os_per_cpu os_cpu[0]; |
78 | }; | 78 | } __attribute__((packed)); |
79 | 79 | ||
80 | static struct appldata_os_data *appldata_os_data; | 80 | static struct appldata_os_data *appldata_os_data; |
81 | 81 | ||
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c index 26889366929a..06afa3103ace 100644 --- a/arch/s390/kernel/ptrace.c +++ b/arch/s390/kernel/ptrace.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <asm/pgalloc.h> | 40 | #include <asm/pgalloc.h> |
41 | #include <asm/system.h> | 41 | #include <asm/system.h> |
42 | #include <asm/uaccess.h> | 42 | #include <asm/uaccess.h> |
43 | #include <asm/unistd.h> | ||
43 | 44 | ||
44 | #ifdef CONFIG_S390_SUPPORT | 45 | #ifdef CONFIG_S390_SUPPORT |
45 | #include "compat_ptrace.h" | 46 | #include "compat_ptrace.h" |
@@ -130,13 +131,19 @@ static int | |||
130 | peek_user(struct task_struct *child, addr_t addr, addr_t data) | 131 | peek_user(struct task_struct *child, addr_t addr, addr_t data) |
131 | { | 132 | { |
132 | struct user *dummy = NULL; | 133 | struct user *dummy = NULL; |
133 | addr_t offset, tmp; | 134 | addr_t offset, tmp, mask; |
134 | 135 | ||
135 | /* | 136 | /* |
136 | * Stupid gdb peeks/pokes the access registers in 64 bit with | 137 | * Stupid gdb peeks/pokes the access registers in 64 bit with |
137 | * an alignment of 4. Programmers from hell... | 138 | * an alignment of 4. Programmers from hell... |
138 | */ | 139 | */ |
139 | if ((addr & 3) || addr > sizeof(struct user) - __ADDR_MASK) | 140 | mask = __ADDR_MASK; |
141 | #ifdef CONFIG_ARCH_S390X | ||
142 | if (addr >= (addr_t) &dummy->regs.acrs && | ||
143 | addr < (addr_t) &dummy->regs.orig_gpr2) | ||
144 | mask = 3; | ||
145 | #endif | ||
146 | if ((addr & mask) || addr > sizeof(struct user) - __ADDR_MASK) | ||
140 | return -EIO; | 147 | return -EIO; |
141 | 148 | ||
142 | if (addr < (addr_t) &dummy->regs.acrs) { | 149 | if (addr < (addr_t) &dummy->regs.acrs) { |
@@ -153,6 +160,16 @@ peek_user(struct task_struct *child, addr_t addr, addr_t data) | |||
153 | * access registers are stored in the thread structure | 160 | * access registers are stored in the thread structure |
154 | */ | 161 | */ |
155 | offset = addr - (addr_t) &dummy->regs.acrs; | 162 | offset = addr - (addr_t) &dummy->regs.acrs; |
163 | #ifdef CONFIG_ARCH_S390X | ||
164 | /* | ||
165 | * Very special case: old & broken 64 bit gdb reading | ||
166 | * from acrs[15]. Result is a 64 bit value. Read the | ||
167 | * 32 bit acrs[15] value and shift it by 32. Sick... | ||
168 | */ | ||
169 | if (addr == (addr_t) &dummy->regs.acrs[15]) | ||
170 | tmp = ((unsigned long) child->thread.acrs[15]) << 32; | ||
171 | else | ||
172 | #endif | ||
156 | tmp = *(addr_t *)((addr_t) &child->thread.acrs + offset); | 173 | tmp = *(addr_t *)((addr_t) &child->thread.acrs + offset); |
157 | 174 | ||
158 | } else if (addr == (addr_t) &dummy->regs.orig_gpr2) { | 175 | } else if (addr == (addr_t) &dummy->regs.orig_gpr2) { |
@@ -167,6 +184,9 @@ peek_user(struct task_struct *child, addr_t addr, addr_t data) | |||
167 | */ | 184 | */ |
168 | offset = addr - (addr_t) &dummy->regs.fp_regs; | 185 | offset = addr - (addr_t) &dummy->regs.fp_regs; |
169 | tmp = *(addr_t *)((addr_t) &child->thread.fp_regs + offset); | 186 | tmp = *(addr_t *)((addr_t) &child->thread.fp_regs + offset); |
187 | if (addr == (addr_t) &dummy->regs.fp_regs.fpc) | ||
188 | tmp &= (unsigned long) FPC_VALID_MASK | ||
189 | << (BITS_PER_LONG - 32); | ||
170 | 190 | ||
171 | } else if (addr < (addr_t) (&dummy->regs.per_info + 1)) { | 191 | } else if (addr < (addr_t) (&dummy->regs.per_info + 1)) { |
172 | /* | 192 | /* |
@@ -191,13 +211,19 @@ static int | |||
191 | poke_user(struct task_struct *child, addr_t addr, addr_t data) | 211 | poke_user(struct task_struct *child, addr_t addr, addr_t data) |
192 | { | 212 | { |
193 | struct user *dummy = NULL; | 213 | struct user *dummy = NULL; |
194 | addr_t offset; | 214 | addr_t offset, mask; |
195 | 215 | ||
196 | /* | 216 | /* |
197 | * Stupid gdb peeks/pokes the access registers in 64 bit with | 217 | * Stupid gdb peeks/pokes the access registers in 64 bit with |
198 | * an alignment of 4. Programmers from hell indeed... | 218 | * an alignment of 4. Programmers from hell indeed... |
199 | */ | 219 | */ |
200 | if ((addr & 3) || addr > sizeof(struct user) - __ADDR_MASK) | 220 | mask = __ADDR_MASK; |
221 | #ifdef CONFIG_ARCH_S390X | ||
222 | if (addr >= (addr_t) &dummy->regs.acrs && | ||
223 | addr < (addr_t) &dummy->regs.orig_gpr2) | ||
224 | mask = 3; | ||
225 | #endif | ||
226 | if ((addr & mask) || addr > sizeof(struct user) - __ADDR_MASK) | ||
201 | return -EIO; | 227 | return -EIO; |
202 | 228 | ||
203 | if (addr < (addr_t) &dummy->regs.acrs) { | 229 | if (addr < (addr_t) &dummy->regs.acrs) { |
@@ -224,6 +250,17 @@ poke_user(struct task_struct *child, addr_t addr, addr_t data) | |||
224 | * access registers are stored in the thread structure | 250 | * access registers are stored in the thread structure |
225 | */ | 251 | */ |
226 | offset = addr - (addr_t) &dummy->regs.acrs; | 252 | offset = addr - (addr_t) &dummy->regs.acrs; |
253 | #ifdef CONFIG_ARCH_S390X | ||
254 | /* | ||
255 | * Very special case: old & broken 64 bit gdb writing | ||
256 | * to acrs[15] with a 64 bit value. Ignore the lower | ||
257 | * half of the value and write the upper 32 bit to | ||
258 | * acrs[15]. Sick... | ||
259 | */ | ||
260 | if (addr == (addr_t) &dummy->regs.acrs[15]) | ||
261 | child->thread.acrs[15] = (unsigned int) (data >> 32); | ||
262 | else | ||
263 | #endif | ||
227 | *(addr_t *)((addr_t) &child->thread.acrs + offset) = data; | 264 | *(addr_t *)((addr_t) &child->thread.acrs + offset) = data; |
228 | 265 | ||
229 | } else if (addr == (addr_t) &dummy->regs.orig_gpr2) { | 266 | } else if (addr == (addr_t) &dummy->regs.orig_gpr2) { |
@@ -237,7 +274,8 @@ poke_user(struct task_struct *child, addr_t addr, addr_t data) | |||
237 | * floating point regs. are stored in the thread structure | 274 | * floating point regs. are stored in the thread structure |
238 | */ | 275 | */ |
239 | if (addr == (addr_t) &dummy->regs.fp_regs.fpc && | 276 | if (addr == (addr_t) &dummy->regs.fp_regs.fpc && |
240 | (data & ~FPC_VALID_MASK) != 0) | 277 | (data & ~((unsigned long) FPC_VALID_MASK |
278 | << (BITS_PER_LONG - 32))) != 0) | ||
241 | return -EINVAL; | 279 | return -EINVAL; |
242 | offset = addr - (addr_t) &dummy->regs.fp_regs; | 280 | offset = addr - (addr_t) &dummy->regs.fp_regs; |
243 | *(addr_t *)((addr_t) &child->thread.fp_regs + offset) = data; | 281 | *(addr_t *)((addr_t) &child->thread.fp_regs + offset) = data; |
@@ -723,6 +761,13 @@ syscall_trace(struct pt_regs *regs, int entryexit) | |||
723 | ? 0x80 : 0)); | 761 | ? 0x80 : 0)); |
724 | 762 | ||
725 | /* | 763 | /* |
764 | * If the debuffer has set an invalid system call number, | ||
765 | * we prepare to skip the system call restart handling. | ||
766 | */ | ||
767 | if (!entryexit && regs->gprs[2] >= NR_syscalls) | ||
768 | regs->trap = -1; | ||
769 | |||
770 | /* | ||
726 | * this isn't the same as continuing with a signal, but it will do | 771 | * this isn't the same as continuing with a signal, but it will do |
727 | * for normal use. strace only continues with a signal if the | 772 | * for normal use. strace only continues with a signal if the |
728 | * stopping signal is not SIGTRAP. -brl | 773 | * stopping signal is not SIGTRAP. -brl |
diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index 80306bc8c799..75fde949d125 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c | |||
@@ -207,7 +207,7 @@ do_exception(struct pt_regs *regs, unsigned long error_code, int is_protection) | |||
207 | * we are not in an interrupt and that there is a | 207 | * we are not in an interrupt and that there is a |
208 | * user context. | 208 | * user context. |
209 | */ | 209 | */ |
210 | if (user_address == 0 || in_interrupt() || !mm) | 210 | if (user_address == 0 || in_atomic() || !mm) |
211 | goto no_context; | 211 | goto no_context; |
212 | 212 | ||
213 | /* | 213 | /* |
diff --git a/arch/sparc64/kernel/pci_iommu.c b/arch/sparc64/kernel/pci_iommu.c index 33ca56c90da2..2803bc7c2c79 100644 --- a/arch/sparc64/kernel/pci_iommu.c +++ b/arch/sparc64/kernel/pci_iommu.c | |||
@@ -196,6 +196,34 @@ static iopte_t *alloc_consistent_cluster(struct pci_iommu *iommu, unsigned long | |||
196 | return NULL; | 196 | return NULL; |
197 | } | 197 | } |
198 | 198 | ||
199 | static int iommu_alloc_ctx(struct pci_iommu *iommu) | ||
200 | { | ||
201 | int lowest = iommu->ctx_lowest_free; | ||
202 | int sz = IOMMU_NUM_CTXS - lowest; | ||
203 | int n = find_next_zero_bit(iommu->ctx_bitmap, sz, lowest); | ||
204 | |||
205 | if (unlikely(n == sz)) { | ||
206 | n = find_next_zero_bit(iommu->ctx_bitmap, lowest, 1); | ||
207 | if (unlikely(n == lowest)) { | ||
208 | printk(KERN_WARNING "IOMMU: Ran out of contexts.\n"); | ||
209 | n = 0; | ||
210 | } | ||
211 | } | ||
212 | if (n) | ||
213 | __set_bit(n, iommu->ctx_bitmap); | ||
214 | |||
215 | return n; | ||
216 | } | ||
217 | |||
218 | static inline void iommu_free_ctx(struct pci_iommu *iommu, int ctx) | ||
219 | { | ||
220 | if (likely(ctx)) { | ||
221 | __clear_bit(ctx, iommu->ctx_bitmap); | ||
222 | if (ctx < iommu->ctx_lowest_free) | ||
223 | iommu->ctx_lowest_free = ctx; | ||
224 | } | ||
225 | } | ||
226 | |||
199 | /* Allocate and map kernel buffer of size SIZE using consistent mode | 227 | /* Allocate and map kernel buffer of size SIZE using consistent mode |
200 | * DMA for PCI device PDEV. Return non-NULL cpu-side address if | 228 | * DMA for PCI device PDEV. Return non-NULL cpu-side address if |
201 | * successful and set *DMA_ADDRP to the PCI side dma address. | 229 | * successful and set *DMA_ADDRP to the PCI side dma address. |
@@ -236,7 +264,7 @@ void *pci_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_ad | |||
236 | npages = size >> IO_PAGE_SHIFT; | 264 | npages = size >> IO_PAGE_SHIFT; |
237 | ctx = 0; | 265 | ctx = 0; |
238 | if (iommu->iommu_ctxflush) | 266 | if (iommu->iommu_ctxflush) |
239 | ctx = iommu->iommu_cur_ctx++; | 267 | ctx = iommu_alloc_ctx(iommu); |
240 | first_page = __pa(first_page); | 268 | first_page = __pa(first_page); |
241 | while (npages--) { | 269 | while (npages--) { |
242 | iopte_val(*iopte) = (IOPTE_CONSISTENT(ctx) | | 270 | iopte_val(*iopte) = (IOPTE_CONSISTENT(ctx) | |
@@ -317,6 +345,8 @@ void pci_free_consistent(struct pci_dev *pdev, size_t size, void *cpu, dma_addr_ | |||
317 | } | 345 | } |
318 | } | 346 | } |
319 | 347 | ||
348 | iommu_free_ctx(iommu, ctx); | ||
349 | |||
320 | spin_unlock_irqrestore(&iommu->lock, flags); | 350 | spin_unlock_irqrestore(&iommu->lock, flags); |
321 | 351 | ||
322 | order = get_order(size); | 352 | order = get_order(size); |
@@ -360,7 +390,7 @@ dma_addr_t pci_map_single(struct pci_dev *pdev, void *ptr, size_t sz, int direct | |||
360 | base_paddr = __pa(oaddr & IO_PAGE_MASK); | 390 | base_paddr = __pa(oaddr & IO_PAGE_MASK); |
361 | ctx = 0; | 391 | ctx = 0; |
362 | if (iommu->iommu_ctxflush) | 392 | if (iommu->iommu_ctxflush) |
363 | ctx = iommu->iommu_cur_ctx++; | 393 | ctx = iommu_alloc_ctx(iommu); |
364 | if (strbuf->strbuf_enabled) | 394 | if (strbuf->strbuf_enabled) |
365 | iopte_protection = IOPTE_STREAMING(ctx); | 395 | iopte_protection = IOPTE_STREAMING(ctx); |
366 | else | 396 | else |
@@ -380,39 +410,53 @@ bad: | |||
380 | return PCI_DMA_ERROR_CODE; | 410 | return PCI_DMA_ERROR_CODE; |
381 | } | 411 | } |
382 | 412 | ||
383 | static void pci_strbuf_flush(struct pci_strbuf *strbuf, struct pci_iommu *iommu, u32 vaddr, unsigned long ctx, unsigned long npages) | 413 | static void pci_strbuf_flush(struct pci_strbuf *strbuf, struct pci_iommu *iommu, u32 vaddr, unsigned long ctx, unsigned long npages, int direction) |
384 | { | 414 | { |
385 | int limit; | 415 | int limit; |
386 | 416 | ||
387 | PCI_STC_FLUSHFLAG_INIT(strbuf); | ||
388 | if (strbuf->strbuf_ctxflush && | 417 | if (strbuf->strbuf_ctxflush && |
389 | iommu->iommu_ctxflush) { | 418 | iommu->iommu_ctxflush) { |
390 | unsigned long matchreg, flushreg; | 419 | unsigned long matchreg, flushreg; |
420 | u64 val; | ||
391 | 421 | ||
392 | flushreg = strbuf->strbuf_ctxflush; | 422 | flushreg = strbuf->strbuf_ctxflush; |
393 | matchreg = PCI_STC_CTXMATCH_ADDR(strbuf, ctx); | 423 | matchreg = PCI_STC_CTXMATCH_ADDR(strbuf, ctx); |
394 | 424 | ||
395 | limit = 100000; | ||
396 | pci_iommu_write(flushreg, ctx); | 425 | pci_iommu_write(flushreg, ctx); |
397 | for(;;) { | 426 | val = pci_iommu_read(matchreg); |
398 | if (((long)pci_iommu_read(matchreg)) >= 0L) | 427 | val &= 0xffff; |
399 | break; | 428 | if (!val) |
400 | limit--; | 429 | goto do_flush_sync; |
401 | if (!limit) | 430 | |
402 | break; | 431 | while (val) { |
403 | udelay(1); | 432 | if (val & 0x1) |
433 | pci_iommu_write(flushreg, ctx); | ||
434 | val >>= 1; | ||
404 | } | 435 | } |
405 | if (!limit) | 436 | val = pci_iommu_read(matchreg); |
437 | if (unlikely(val)) { | ||
406 | printk(KERN_WARNING "pci_strbuf_flush: ctx flush " | 438 | printk(KERN_WARNING "pci_strbuf_flush: ctx flush " |
407 | "timeout vaddr[%08x] ctx[%lx]\n", | 439 | "timeout matchreg[%lx] ctx[%lx]\n", |
408 | vaddr, ctx); | 440 | val, ctx); |
441 | goto do_page_flush; | ||
442 | } | ||
409 | } else { | 443 | } else { |
410 | unsigned long i; | 444 | unsigned long i; |
411 | 445 | ||
446 | do_page_flush: | ||
412 | for (i = 0; i < npages; i++, vaddr += IO_PAGE_SIZE) | 447 | for (i = 0; i < npages; i++, vaddr += IO_PAGE_SIZE) |
413 | pci_iommu_write(strbuf->strbuf_pflush, vaddr); | 448 | pci_iommu_write(strbuf->strbuf_pflush, vaddr); |
414 | } | 449 | } |
415 | 450 | ||
451 | do_flush_sync: | ||
452 | /* If the device could not have possibly put dirty data into | ||
453 | * the streaming cache, no flush-flag synchronization needs | ||
454 | * to be performed. | ||
455 | */ | ||
456 | if (direction == PCI_DMA_TODEVICE) | ||
457 | return; | ||
458 | |||
459 | PCI_STC_FLUSHFLAG_INIT(strbuf); | ||
416 | pci_iommu_write(strbuf->strbuf_fsync, strbuf->strbuf_flushflag_pa); | 460 | pci_iommu_write(strbuf->strbuf_fsync, strbuf->strbuf_flushflag_pa); |
417 | (void) pci_iommu_read(iommu->write_complete_reg); | 461 | (void) pci_iommu_read(iommu->write_complete_reg); |
418 | 462 | ||
@@ -466,7 +510,7 @@ void pci_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int | |||
466 | 510 | ||
467 | /* Step 1: Kick data out of streaming buffers if necessary. */ | 511 | /* Step 1: Kick data out of streaming buffers if necessary. */ |
468 | if (strbuf->strbuf_enabled) | 512 | if (strbuf->strbuf_enabled) |
469 | pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages); | 513 | pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages, direction); |
470 | 514 | ||
471 | /* Step 2: Clear out first TSB entry. */ | 515 | /* Step 2: Clear out first TSB entry. */ |
472 | iopte_make_dummy(iommu, base); | 516 | iopte_make_dummy(iommu, base); |
@@ -474,6 +518,8 @@ void pci_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int | |||
474 | free_streaming_cluster(iommu, bus_addr - iommu->page_table_map_base, | 518 | free_streaming_cluster(iommu, bus_addr - iommu->page_table_map_base, |
475 | npages, ctx); | 519 | npages, ctx); |
476 | 520 | ||
521 | iommu_free_ctx(iommu, ctx); | ||
522 | |||
477 | spin_unlock_irqrestore(&iommu->lock, flags); | 523 | spin_unlock_irqrestore(&iommu->lock, flags); |
478 | } | 524 | } |
479 | 525 | ||
@@ -613,7 +659,7 @@ int pci_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int | |||
613 | /* Step 4: Choose a context if necessary. */ | 659 | /* Step 4: Choose a context if necessary. */ |
614 | ctx = 0; | 660 | ctx = 0; |
615 | if (iommu->iommu_ctxflush) | 661 | if (iommu->iommu_ctxflush) |
616 | ctx = iommu->iommu_cur_ctx++; | 662 | ctx = iommu_alloc_ctx(iommu); |
617 | 663 | ||
618 | /* Step 5: Create the mappings. */ | 664 | /* Step 5: Create the mappings. */ |
619 | if (strbuf->strbuf_enabled) | 665 | if (strbuf->strbuf_enabled) |
@@ -678,7 +724,7 @@ void pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, | |||
678 | 724 | ||
679 | /* Step 1: Kick data out of streaming buffers if necessary. */ | 725 | /* Step 1: Kick data out of streaming buffers if necessary. */ |
680 | if (strbuf->strbuf_enabled) | 726 | if (strbuf->strbuf_enabled) |
681 | pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages); | 727 | pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages, direction); |
682 | 728 | ||
683 | /* Step 2: Clear out first TSB entry. */ | 729 | /* Step 2: Clear out first TSB entry. */ |
684 | iopte_make_dummy(iommu, base); | 730 | iopte_make_dummy(iommu, base); |
@@ -686,6 +732,8 @@ void pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, | |||
686 | free_streaming_cluster(iommu, bus_addr - iommu->page_table_map_base, | 732 | free_streaming_cluster(iommu, bus_addr - iommu->page_table_map_base, |
687 | npages, ctx); | 733 | npages, ctx); |
688 | 734 | ||
735 | iommu_free_ctx(iommu, ctx); | ||
736 | |||
689 | spin_unlock_irqrestore(&iommu->lock, flags); | 737 | spin_unlock_irqrestore(&iommu->lock, flags); |
690 | } | 738 | } |
691 | 739 | ||
@@ -724,7 +772,7 @@ void pci_dma_sync_single_for_cpu(struct pci_dev *pdev, dma_addr_t bus_addr, size | |||
724 | } | 772 | } |
725 | 773 | ||
726 | /* Step 2: Kick data out of streaming buffers. */ | 774 | /* Step 2: Kick data out of streaming buffers. */ |
727 | pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages); | 775 | pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages, direction); |
728 | 776 | ||
729 | spin_unlock_irqrestore(&iommu->lock, flags); | 777 | spin_unlock_irqrestore(&iommu->lock, flags); |
730 | } | 778 | } |
@@ -768,7 +816,7 @@ void pci_dma_sync_sg_for_cpu(struct pci_dev *pdev, struct scatterlist *sglist, i | |||
768 | i--; | 816 | i--; |
769 | npages = (IO_PAGE_ALIGN(sglist[i].dma_address + sglist[i].dma_length) | 817 | npages = (IO_PAGE_ALIGN(sglist[i].dma_address + sglist[i].dma_length) |
770 | - bus_addr) >> IO_PAGE_SHIFT; | 818 | - bus_addr) >> IO_PAGE_SHIFT; |
771 | pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages); | 819 | pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages, direction); |
772 | 820 | ||
773 | spin_unlock_irqrestore(&iommu->lock, flags); | 821 | spin_unlock_irqrestore(&iommu->lock, flags); |
774 | } | 822 | } |
diff --git a/arch/sparc64/kernel/pci_psycho.c b/arch/sparc64/kernel/pci_psycho.c index 3567fa879e1f..534320ef0db2 100644 --- a/arch/sparc64/kernel/pci_psycho.c +++ b/arch/sparc64/kernel/pci_psycho.c | |||
@@ -1212,7 +1212,7 @@ static void __init psycho_iommu_init(struct pci_controller_info *p) | |||
1212 | 1212 | ||
1213 | /* Setup initial software IOMMU state. */ | 1213 | /* Setup initial software IOMMU state. */ |
1214 | spin_lock_init(&iommu->lock); | 1214 | spin_lock_init(&iommu->lock); |
1215 | iommu->iommu_cur_ctx = 0; | 1215 | iommu->ctx_lowest_free = 1; |
1216 | 1216 | ||
1217 | /* Register addresses. */ | 1217 | /* Register addresses. */ |
1218 | iommu->iommu_control = p->pbm_A.controller_regs + PSYCHO_IOMMU_CONTROL; | 1218 | iommu->iommu_control = p->pbm_A.controller_regs + PSYCHO_IOMMU_CONTROL; |
diff --git a/arch/sparc64/kernel/pci_sabre.c b/arch/sparc64/kernel/pci_sabre.c index 5525d1ec4af8..53d333b4a4e8 100644 --- a/arch/sparc64/kernel/pci_sabre.c +++ b/arch/sparc64/kernel/pci_sabre.c | |||
@@ -1265,7 +1265,7 @@ static void __init sabre_iommu_init(struct pci_controller_info *p, | |||
1265 | 1265 | ||
1266 | /* Setup initial software IOMMU state. */ | 1266 | /* Setup initial software IOMMU state. */ |
1267 | spin_lock_init(&iommu->lock); | 1267 | spin_lock_init(&iommu->lock); |
1268 | iommu->iommu_cur_ctx = 0; | 1268 | iommu->ctx_lowest_free = 1; |
1269 | 1269 | ||
1270 | /* Register addresses. */ | 1270 | /* Register addresses. */ |
1271 | iommu->iommu_control = p->pbm_A.controller_regs + SABRE_IOMMU_CONTROL; | 1271 | iommu->iommu_control = p->pbm_A.controller_regs + SABRE_IOMMU_CONTROL; |
diff --git a/arch/sparc64/kernel/pci_schizo.c b/arch/sparc64/kernel/pci_schizo.c index e93fcadc3722..5753175b94e6 100644 --- a/arch/sparc64/kernel/pci_schizo.c +++ b/arch/sparc64/kernel/pci_schizo.c | |||
@@ -1753,7 +1753,7 @@ static void schizo_pbm_iommu_init(struct pci_pbm_info *pbm) | |||
1753 | 1753 | ||
1754 | /* Setup initial software IOMMU state. */ | 1754 | /* Setup initial software IOMMU state. */ |
1755 | spin_lock_init(&iommu->lock); | 1755 | spin_lock_init(&iommu->lock); |
1756 | iommu->iommu_cur_ctx = 0; | 1756 | iommu->ctx_lowest_free = 1; |
1757 | 1757 | ||
1758 | /* Register addresses, SCHIZO has iommu ctx flushing. */ | 1758 | /* Register addresses, SCHIZO has iommu ctx flushing. */ |
1759 | iommu->iommu_control = pbm->pbm_regs + SCHIZO_IOMMU_CONTROL; | 1759 | iommu->iommu_control = pbm->pbm_regs + SCHIZO_IOMMU_CONTROL; |
diff --git a/arch/sparc64/kernel/sbus.c b/arch/sparc64/kernel/sbus.c index 76ea6455433f..89f5e019f24c 100644 --- a/arch/sparc64/kernel/sbus.c +++ b/arch/sparc64/kernel/sbus.c | |||
@@ -117,17 +117,25 @@ static void iommu_flush(struct sbus_iommu *iommu, u32 base, unsigned long npages | |||
117 | 117 | ||
118 | #define STRBUF_TAG_VALID 0x02UL | 118 | #define STRBUF_TAG_VALID 0x02UL |
119 | 119 | ||
120 | static void sbus_strbuf_flush(struct sbus_iommu *iommu, u32 base, unsigned long npages) | 120 | static void sbus_strbuf_flush(struct sbus_iommu *iommu, u32 base, unsigned long npages, int direction) |
121 | { | 121 | { |
122 | unsigned long n; | 122 | unsigned long n; |
123 | int limit; | 123 | int limit; |
124 | 124 | ||
125 | iommu->strbuf_flushflag = 0UL; | ||
126 | n = npages; | 125 | n = npages; |
127 | while (n--) | 126 | while (n--) |
128 | upa_writeq(base + (n << IO_PAGE_SHIFT), | 127 | upa_writeq(base + (n << IO_PAGE_SHIFT), |
129 | iommu->strbuf_regs + STRBUF_PFLUSH); | 128 | iommu->strbuf_regs + STRBUF_PFLUSH); |
130 | 129 | ||
130 | /* If the device could not have possibly put dirty data into | ||
131 | * the streaming cache, no flush-flag synchronization needs | ||
132 | * to be performed. | ||
133 | */ | ||
134 | if (direction == SBUS_DMA_TODEVICE) | ||
135 | return; | ||
136 | |||
137 | iommu->strbuf_flushflag = 0UL; | ||
138 | |||
131 | /* Whoopee cushion! */ | 139 | /* Whoopee cushion! */ |
132 | upa_writeq(__pa(&iommu->strbuf_flushflag), | 140 | upa_writeq(__pa(&iommu->strbuf_flushflag), |
133 | iommu->strbuf_regs + STRBUF_FSYNC); | 141 | iommu->strbuf_regs + STRBUF_FSYNC); |
@@ -421,7 +429,7 @@ void sbus_unmap_single(struct sbus_dev *sdev, dma_addr_t dma_addr, size_t size, | |||
421 | 429 | ||
422 | spin_lock_irqsave(&iommu->lock, flags); | 430 | spin_lock_irqsave(&iommu->lock, flags); |
423 | free_streaming_cluster(iommu, dma_base, size >> IO_PAGE_SHIFT); | 431 | free_streaming_cluster(iommu, dma_base, size >> IO_PAGE_SHIFT); |
424 | sbus_strbuf_flush(iommu, dma_base, size >> IO_PAGE_SHIFT); | 432 | sbus_strbuf_flush(iommu, dma_base, size >> IO_PAGE_SHIFT, direction); |
425 | spin_unlock_irqrestore(&iommu->lock, flags); | 433 | spin_unlock_irqrestore(&iommu->lock, flags); |
426 | } | 434 | } |
427 | 435 | ||
@@ -584,7 +592,7 @@ void sbus_unmap_sg(struct sbus_dev *sdev, struct scatterlist *sg, int nents, int | |||
584 | iommu = sdev->bus->iommu; | 592 | iommu = sdev->bus->iommu; |
585 | spin_lock_irqsave(&iommu->lock, flags); | 593 | spin_lock_irqsave(&iommu->lock, flags); |
586 | free_streaming_cluster(iommu, dvma_base, size >> IO_PAGE_SHIFT); | 594 | free_streaming_cluster(iommu, dvma_base, size >> IO_PAGE_SHIFT); |
587 | sbus_strbuf_flush(iommu, dvma_base, size >> IO_PAGE_SHIFT); | 595 | sbus_strbuf_flush(iommu, dvma_base, size >> IO_PAGE_SHIFT, direction); |
588 | spin_unlock_irqrestore(&iommu->lock, flags); | 596 | spin_unlock_irqrestore(&iommu->lock, flags); |
589 | } | 597 | } |
590 | 598 | ||
@@ -596,7 +604,7 @@ void sbus_dma_sync_single_for_cpu(struct sbus_dev *sdev, dma_addr_t base, size_t | |||
596 | size = (IO_PAGE_ALIGN(base + size) - (base & IO_PAGE_MASK)); | 604 | size = (IO_PAGE_ALIGN(base + size) - (base & IO_PAGE_MASK)); |
597 | 605 | ||
598 | spin_lock_irqsave(&iommu->lock, flags); | 606 | spin_lock_irqsave(&iommu->lock, flags); |
599 | sbus_strbuf_flush(iommu, base & IO_PAGE_MASK, size >> IO_PAGE_SHIFT); | 607 | sbus_strbuf_flush(iommu, base & IO_PAGE_MASK, size >> IO_PAGE_SHIFT, direction); |
600 | spin_unlock_irqrestore(&iommu->lock, flags); | 608 | spin_unlock_irqrestore(&iommu->lock, flags); |
601 | } | 609 | } |
602 | 610 | ||
@@ -620,7 +628,7 @@ void sbus_dma_sync_sg_for_cpu(struct sbus_dev *sdev, struct scatterlist *sg, int | |||
620 | size = IO_PAGE_ALIGN(sg[i].dma_address + sg[i].dma_length) - base; | 628 | size = IO_PAGE_ALIGN(sg[i].dma_address + sg[i].dma_length) - base; |
621 | 629 | ||
622 | spin_lock_irqsave(&iommu->lock, flags); | 630 | spin_lock_irqsave(&iommu->lock, flags); |
623 | sbus_strbuf_flush(iommu, base, size >> IO_PAGE_SHIFT); | 631 | sbus_strbuf_flush(iommu, base, size >> IO_PAGE_SHIFT, direction); |
624 | spin_unlock_irqrestore(&iommu->lock, flags); | 632 | spin_unlock_irqrestore(&iommu->lock, flags); |
625 | } | 633 | } |
626 | 634 | ||
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig index 0f430d9d3632..289f448ac89c 100644 --- a/arch/x86_64/Kconfig +++ b/arch/x86_64/Kconfig | |||
@@ -305,6 +305,7 @@ config HPET_TIMER | |||
305 | 305 | ||
306 | config X86_PM_TIMER | 306 | config X86_PM_TIMER |
307 | bool "PM timer" | 307 | bool "PM timer" |
308 | depends on ACPI | ||
308 | default y | 309 | default y |
309 | help | 310 | help |
310 | Support the ACPI PM timer for time keeping. This is slow, | 311 | Support the ACPI PM timer for time keeping. This is slow, |
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c index 80e9b498c443..afd87e64d0a8 100644 --- a/arch/x86_64/kernel/io_apic.c +++ b/arch/x86_64/kernel/io_apic.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <asm/desc.h> | 37 | #include <asm/desc.h> |
38 | #include <asm/proto.h> | 38 | #include <asm/proto.h> |
39 | #include <asm/mach_apic.h> | 39 | #include <asm/mach_apic.h> |
40 | #include <asm/acpi.h> | ||
40 | 41 | ||
41 | #define __apicdebuginit __init | 42 | #define __apicdebuginit __init |
42 | 43 | ||
diff --git a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c index f86d9db94bfc..61a63be6b294 100644 --- a/arch/x86_64/kernel/mpparse.c +++ b/arch/x86_64/kernel/mpparse.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <asm/pgalloc.h> | 30 | #include <asm/pgalloc.h> |
31 | #include <asm/io_apic.h> | 31 | #include <asm/io_apic.h> |
32 | #include <asm/proto.h> | 32 | #include <asm/proto.h> |
33 | #include <asm/acpi.h> | ||
33 | 34 | ||
34 | /* Have we found an MP table */ | 35 | /* Have we found an MP table */ |
35 | int smp_found_config; | 36 | int smp_found_config; |
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c index 735b6767c8ed..fb8c809b4cd9 100644 --- a/arch/x86_64/kernel/time.c +++ b/arch/x86_64/kernel/time.c | |||
@@ -27,7 +27,9 @@ | |||
27 | #include <linux/bcd.h> | 27 | #include <linux/bcd.h> |
28 | #include <linux/kallsyms.h> | 28 | #include <linux/kallsyms.h> |
29 | #include <linux/acpi.h> | 29 | #include <linux/acpi.h> |
30 | #ifdef CONFIG_ACPI | ||
30 | #include <acpi/achware.h> /* for PM timer frequency */ | 31 | #include <acpi/achware.h> /* for PM timer frequency */ |
32 | #endif | ||
31 | #include <asm/8253pit.h> | 33 | #include <asm/8253pit.h> |
32 | #include <asm/pgtable.h> | 34 | #include <asm/pgtable.h> |
33 | #include <asm/vsyscall.h> | 35 | #include <asm/vsyscall.h> |
diff --git a/drivers/atm/Makefile b/drivers/atm/Makefile index d1dcd8eae3c9..5b77188527a9 100644 --- a/drivers/atm/Makefile +++ b/drivers/atm/Makefile | |||
@@ -39,7 +39,8 @@ ifeq ($(CONFIG_ATM_FORE200E_PCA),y) | |||
39 | fore_200e-objs += fore200e_pca_fw.o | 39 | fore_200e-objs += fore200e_pca_fw.o |
40 | # guess the target endianess to choose the right PCA-200E firmware image | 40 | # guess the target endianess to choose the right PCA-200E firmware image |
41 | ifeq ($(CONFIG_ATM_FORE200E_PCA_DEFAULT_FW),y) | 41 | ifeq ($(CONFIG_ATM_FORE200E_PCA_DEFAULT_FW),y) |
42 | CONFIG_ATM_FORE200E_PCA_FW = $(shell if test -n "`$(CC) -E -dM $(src)/../../include/asm/byteorder.h | grep ' __LITTLE_ENDIAN '`"; then echo $(obj)/pca200e.bin; else echo $(obj)/pca200e_ecd.bin2; fi) | 42 | byteorder.h := include$(if $(patsubst $(srctree),,$(objtree)),2)/asm/byteorder.h |
43 | CONFIG_ATM_FORE200E_PCA_FW := $(obj)/pca200e$(if $(shell $(CC) -E -dM $(byteorder.h) | grep ' __LITTLE_ENDIAN '),.bin,_ecd.bin2) | ||
43 | endif | 44 | endif |
44 | endif | 45 | endif |
45 | 46 | ||
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c index 9e65bfb85ba3..5f702199543a 100644 --- a/drivers/atm/fore200e.c +++ b/drivers/atm/fore200e.c | |||
@@ -383,8 +383,7 @@ fore200e_shutdown(struct fore200e* fore200e) | |||
383 | switch(fore200e->state) { | 383 | switch(fore200e->state) { |
384 | 384 | ||
385 | case FORE200E_STATE_COMPLETE: | 385 | case FORE200E_STATE_COMPLETE: |
386 | if (fore200e->stats) | 386 | kfree(fore200e->stats); |
387 | kfree(fore200e->stats); | ||
388 | 387 | ||
389 | case FORE200E_STATE_IRQ: | 388 | case FORE200E_STATE_IRQ: |
390 | free_irq(fore200e->irq, fore200e->atm_dev); | 389 | free_irq(fore200e->irq, fore200e->atm_dev); |
@@ -963,8 +962,7 @@ fore200e_tx_irq(struct fore200e* fore200e) | |||
963 | entry, txq->tail, entry->vc_map, entry->skb); | 962 | entry, txq->tail, entry->vc_map, entry->skb); |
964 | 963 | ||
965 | /* free copy of misaligned data */ | 964 | /* free copy of misaligned data */ |
966 | if (entry->data) | 965 | kfree(entry->data); |
967 | kfree(entry->data); | ||
968 | 966 | ||
969 | /* remove DMA mapping */ | 967 | /* remove DMA mapping */ |
970 | fore200e->bus->dma_unmap(fore200e, entry->tpd->tsd[ 0 ].buffer, entry->tpd->tsd[ 0 ].length, | 968 | fore200e->bus->dma_unmap(fore200e, entry->tpd->tsd[ 0 ].buffer, entry->tpd->tsd[ 0 ].length, |
diff --git a/drivers/atm/he.c b/drivers/atm/he.c index 3022c548a132..df2c83fd5496 100644 --- a/drivers/atm/he.c +++ b/drivers/atm/he.c | |||
@@ -412,8 +412,7 @@ he_init_one(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent) | |||
412 | init_one_failure: | 412 | init_one_failure: |
413 | if (atm_dev) | 413 | if (atm_dev) |
414 | atm_dev_deregister(atm_dev); | 414 | atm_dev_deregister(atm_dev); |
415 | if (he_dev) | 415 | kfree(he_dev); |
416 | kfree(he_dev); | ||
417 | pci_disable_device(pci_dev); | 416 | pci_disable_device(pci_dev); |
418 | return err; | 417 | return err; |
419 | } | 418 | } |
@@ -2534,8 +2533,7 @@ he_open(struct atm_vcc *vcc) | |||
2534 | open_failed: | 2533 | open_failed: |
2535 | 2534 | ||
2536 | if (err) { | 2535 | if (err) { |
2537 | if (he_vcc) | 2536 | kfree(he_vcc); |
2538 | kfree(he_vcc); | ||
2539 | clear_bit(ATM_VF_ADDR, &vcc->flags); | 2537 | clear_bit(ATM_VF_ADDR, &vcc->flags); |
2540 | } | 2538 | } |
2541 | else | 2539 | else |
diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c index 85bf5c8442b0..b2a7b754fd14 100644 --- a/drivers/atm/nicstar.c +++ b/drivers/atm/nicstar.c | |||
@@ -676,10 +676,10 @@ static int __devinit ns_init_card(int i, struct pci_dev *pcidev) | |||
676 | PRINTK("nicstar%d: RSQ base at 0x%x.\n", i, (u32) card->rsq.base); | 676 | PRINTK("nicstar%d: RSQ base at 0x%x.\n", i, (u32) card->rsq.base); |
677 | 677 | ||
678 | /* Initialize SCQ0, the only VBR SCQ used */ | 678 | /* Initialize SCQ0, the only VBR SCQ used */ |
679 | card->scq1 = (scq_info *) NULL; | 679 | card->scq1 = NULL; |
680 | card->scq2 = (scq_info *) NULL; | 680 | card->scq2 = NULL; |
681 | card->scq0 = get_scq(VBR_SCQSIZE, NS_VRSCD0); | 681 | card->scq0 = get_scq(VBR_SCQSIZE, NS_VRSCD0); |
682 | if (card->scq0 == (scq_info *) NULL) | 682 | if (card->scq0 == NULL) |
683 | { | 683 | { |
684 | printk("nicstar%d: can't get SCQ0.\n", i); | 684 | printk("nicstar%d: can't get SCQ0.\n", i); |
685 | error = 12; | 685 | error = 12; |
@@ -993,24 +993,24 @@ static scq_info *get_scq(int size, u32 scd) | |||
993 | int i; | 993 | int i; |
994 | 994 | ||
995 | if (size != VBR_SCQSIZE && size != CBR_SCQSIZE) | 995 | if (size != VBR_SCQSIZE && size != CBR_SCQSIZE) |
996 | return (scq_info *) NULL; | 996 | return NULL; |
997 | 997 | ||
998 | scq = (scq_info *) kmalloc(sizeof(scq_info), GFP_KERNEL); | 998 | scq = (scq_info *) kmalloc(sizeof(scq_info), GFP_KERNEL); |
999 | if (scq == (scq_info *) NULL) | 999 | if (scq == NULL) |
1000 | return (scq_info *) NULL; | 1000 | return NULL; |
1001 | scq->org = kmalloc(2 * size, GFP_KERNEL); | 1001 | scq->org = kmalloc(2 * size, GFP_KERNEL); |
1002 | if (scq->org == NULL) | 1002 | if (scq->org == NULL) |
1003 | { | 1003 | { |
1004 | kfree(scq); | 1004 | kfree(scq); |
1005 | return (scq_info *) NULL; | 1005 | return NULL; |
1006 | } | 1006 | } |
1007 | scq->skb = (struct sk_buff **) kmalloc(sizeof(struct sk_buff *) * | 1007 | scq->skb = (struct sk_buff **) kmalloc(sizeof(struct sk_buff *) * |
1008 | (size / NS_SCQE_SIZE), GFP_KERNEL); | 1008 | (size / NS_SCQE_SIZE), GFP_KERNEL); |
1009 | if (scq->skb == (struct sk_buff **) NULL) | 1009 | if (scq->skb == NULL) |
1010 | { | 1010 | { |
1011 | kfree(scq->org); | 1011 | kfree(scq->org); |
1012 | kfree(scq); | 1012 | kfree(scq); |
1013 | return (scq_info *) NULL; | 1013 | return NULL; |
1014 | } | 1014 | } |
1015 | scq->num_entries = size / NS_SCQE_SIZE; | 1015 | scq->num_entries = size / NS_SCQE_SIZE; |
1016 | scq->base = (ns_scqe *) ALIGN_ADDRESS(scq->org, size); | 1016 | scq->base = (ns_scqe *) ALIGN_ADDRESS(scq->org, size); |
@@ -1498,7 +1498,7 @@ static int ns_open(struct atm_vcc *vcc) | |||
1498 | vc->cbr_scd = NS_FRSCD + frscdi * NS_FRSCD_SIZE; | 1498 | vc->cbr_scd = NS_FRSCD + frscdi * NS_FRSCD_SIZE; |
1499 | 1499 | ||
1500 | scq = get_scq(CBR_SCQSIZE, vc->cbr_scd); | 1500 | scq = get_scq(CBR_SCQSIZE, vc->cbr_scd); |
1501 | if (scq == (scq_info *) NULL) | 1501 | if (scq == NULL) |
1502 | { | 1502 | { |
1503 | PRINTK("nicstar%d: can't get fixed rate SCQ.\n", card->index); | 1503 | PRINTK("nicstar%d: can't get fixed rate SCQ.\n", card->index); |
1504 | card->scd2vc[frscdi] = NULL; | 1504 | card->scd2vc[frscdi] = NULL; |
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c index 47a800519ad0..8d5e65cb9755 100644 --- a/drivers/atm/zatm.c +++ b/drivers/atm/zatm.c | |||
@@ -902,7 +902,7 @@ static void close_tx(struct atm_vcc *vcc) | |||
902 | zatm_dev->tx_bw += vcc->qos.txtp.min_pcr; | 902 | zatm_dev->tx_bw += vcc->qos.txtp.min_pcr; |
903 | dealloc_shaper(vcc->dev,zatm_vcc->shaper); | 903 | dealloc_shaper(vcc->dev,zatm_vcc->shaper); |
904 | } | 904 | } |
905 | if (zatm_vcc->ring) kfree(zatm_vcc->ring); | 905 | kfree(zatm_vcc->ring); |
906 | } | 906 | } |
907 | 907 | ||
908 | 908 | ||
@@ -1339,12 +1339,9 @@ static int __init zatm_start(struct atm_dev *dev) | |||
1339 | return 0; | 1339 | return 0; |
1340 | out: | 1340 | out: |
1341 | for (i = 0; i < NR_MBX; i++) | 1341 | for (i = 0; i < NR_MBX; i++) |
1342 | if (zatm_dev->mbx_start[i] != 0) | 1342 | kfree(zatm_dev->mbx_start[i]); |
1343 | kfree((void *) zatm_dev->mbx_start[i]); | 1343 | kfree(zatm_dev->rx_map); |
1344 | if (zatm_dev->rx_map != NULL) | 1344 | kfree(zatm_dev->tx_map); |
1345 | kfree(zatm_dev->rx_map); | ||
1346 | if (zatm_dev->tx_map != NULL) | ||
1347 | kfree(zatm_dev->tx_map); | ||
1348 | free_irq(zatm_dev->irq, dev); | 1345 | free_irq(zatm_dev->irq, dev); |
1349 | return error; | 1346 | return error; |
1350 | } | 1347 | } |
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index ce42889f98fb..adc4dcc306f4 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
@@ -8,13 +8,12 @@ | |||
8 | * and is not licensed separately. See file COPYING for details. | 8 | * and is not licensed separately. See file COPYING for details. |
9 | * | 9 | * |
10 | * TODO (sorted by decreasing priority) | 10 | * TODO (sorted by decreasing priority) |
11 | * -- Kill first_open (Al Viro fixed the block layer now) | ||
11 | * -- Do resets with usb_device_reset (needs a thread context, use khubd) | 12 | * -- Do resets with usb_device_reset (needs a thread context, use khubd) |
12 | * -- set readonly flag for CDs, set removable flag for CF readers | 13 | * -- set readonly flag for CDs, set removable flag for CF readers |
13 | * -- do inquiry and verify we got a disk and not a tape (for LUN mismatch) | 14 | * -- do inquiry and verify we got a disk and not a tape (for LUN mismatch) |
14 | * -- support pphaneuf's SDDR-75 with two LUNs (also broken capacity...) | ||
15 | * -- special case some senses, e.g. 3a/0 -> no media present, reduce retries | 15 | * -- special case some senses, e.g. 3a/0 -> no media present, reduce retries |
16 | * -- verify the 13 conditions and do bulk resets | 16 | * -- verify the 13 conditions and do bulk resets |
17 | * -- normal pool of commands instead of cmdv[]? | ||
18 | * -- kill last_pipe and simply do two-state clearing on both pipes | 17 | * -- kill last_pipe and simply do two-state clearing on both pipes |
19 | * -- verify protocol (bulk) from USB descriptors (maybe...) | 18 | * -- verify protocol (bulk) from USB descriptors (maybe...) |
20 | * -- highmem and sg | 19 | * -- highmem and sg |
@@ -49,7 +48,14 @@ | |||
49 | #define US_SC_SCSI 0x06 /* Transparent */ | 48 | #define US_SC_SCSI 0x06 /* Transparent */ |
50 | 49 | ||
51 | /* | 50 | /* |
51 | * This many LUNs per USB device. | ||
52 | * Every one of them takes a host, see UB_MAX_HOSTS. | ||
52 | */ | 53 | */ |
54 | #define UB_MAX_LUNS 4 | ||
55 | |||
56 | /* | ||
57 | */ | ||
58 | |||
53 | #define UB_MINORS_PER_MAJOR 8 | 59 | #define UB_MINORS_PER_MAJOR 8 |
54 | 60 | ||
55 | #define UB_MAX_CDB_SIZE 16 /* Corresponds to Bulk */ | 61 | #define UB_MAX_CDB_SIZE 16 /* Corresponds to Bulk */ |
@@ -65,7 +71,7 @@ struct bulk_cb_wrap { | |||
65 | u32 Tag; /* unique per command id */ | 71 | u32 Tag; /* unique per command id */ |
66 | __le32 DataTransferLength; /* size of data */ | 72 | __le32 DataTransferLength; /* size of data */ |
67 | u8 Flags; /* direction in bit 0 */ | 73 | u8 Flags; /* direction in bit 0 */ |
68 | u8 Lun; /* LUN normally 0 */ | 74 | u8 Lun; /* LUN */ |
69 | u8 Length; /* of of the CDB */ | 75 | u8 Length; /* of of the CDB */ |
70 | u8 CDB[UB_MAX_CDB_SIZE]; /* max command */ | 76 | u8 CDB[UB_MAX_CDB_SIZE]; /* max command */ |
71 | }; | 77 | }; |
@@ -168,6 +174,7 @@ struct ub_scsi_cmd { | |||
168 | unsigned int len; /* Requested length */ | 174 | unsigned int len; /* Requested length */ |
169 | // struct scatterlist sgv[UB_MAX_REQ_SG]; | 175 | // struct scatterlist sgv[UB_MAX_REQ_SG]; |
170 | 176 | ||
177 | struct ub_lun *lun; | ||
171 | void (*done)(struct ub_dev *, struct ub_scsi_cmd *); | 178 | void (*done)(struct ub_dev *, struct ub_scsi_cmd *); |
172 | void *back; | 179 | void *back; |
173 | }; | 180 | }; |
@@ -252,25 +259,47 @@ struct ub_scsi_cmd_queue { | |||
252 | }; | 259 | }; |
253 | 260 | ||
254 | /* | 261 | /* |
255 | * The UB device instance. | 262 | * The block device instance (one per LUN). |
263 | */ | ||
264 | struct ub_lun { | ||
265 | struct ub_dev *udev; | ||
266 | struct list_head link; | ||
267 | struct gendisk *disk; | ||
268 | int id; /* Host index */ | ||
269 | int num; /* LUN number */ | ||
270 | char name[16]; | ||
271 | |||
272 | int changed; /* Media was changed */ | ||
273 | int removable; | ||
274 | int readonly; | ||
275 | int first_open; /* Kludge. See ub_bd_open. */ | ||
276 | |||
277 | /* Use Ingo's mempool if or when we have more than one command. */ | ||
278 | /* | ||
279 | * Currently we never need more than one command for the whole device. | ||
280 | * However, giving every LUN a command is a cheap and automatic way | ||
281 | * to enforce fairness between them. | ||
282 | */ | ||
283 | int cmda[1]; | ||
284 | struct ub_scsi_cmd cmdv[1]; | ||
285 | |||
286 | struct ub_capacity capacity; | ||
287 | }; | ||
288 | |||
289 | /* | ||
290 | * The USB device instance. | ||
256 | */ | 291 | */ |
257 | struct ub_dev { | 292 | struct ub_dev { |
258 | spinlock_t lock; | 293 | spinlock_t lock; |
259 | int id; /* Number among ub's */ | ||
260 | atomic_t poison; /* The USB device is disconnected */ | 294 | atomic_t poison; /* The USB device is disconnected */ |
261 | int openc; /* protected by ub_lock! */ | 295 | int openc; /* protected by ub_lock! */ |
262 | /* kref is too implicit for our taste */ | 296 | /* kref is too implicit for our taste */ |
263 | unsigned int tagcnt; | 297 | unsigned int tagcnt; |
264 | int changed; /* Media was changed */ | 298 | char name[12]; |
265 | int removable; | ||
266 | int readonly; | ||
267 | int first_open; /* Kludge. See ub_bd_open. */ | ||
268 | char name[8]; | ||
269 | struct usb_device *dev; | 299 | struct usb_device *dev; |
270 | struct usb_interface *intf; | 300 | struct usb_interface *intf; |
271 | 301 | ||
272 | struct ub_capacity capacity; | 302 | struct list_head luns; |
273 | struct gendisk *disk; | ||
274 | 303 | ||
275 | unsigned int send_bulk_pipe; /* cached pipe values */ | 304 | unsigned int send_bulk_pipe; /* cached pipe values */ |
276 | unsigned int recv_bulk_pipe; | 305 | unsigned int recv_bulk_pipe; |
@@ -279,10 +308,6 @@ struct ub_dev { | |||
279 | 308 | ||
280 | struct tasklet_struct tasklet; | 309 | struct tasklet_struct tasklet; |
281 | 310 | ||
282 | /* XXX Use Ingo's mempool (once we have more than one) */ | ||
283 | int cmda[1]; | ||
284 | struct ub_scsi_cmd cmdv[1]; | ||
285 | |||
286 | struct ub_scsi_cmd_queue cmd_queue; | 311 | struct ub_scsi_cmd_queue cmd_queue; |
287 | struct ub_scsi_cmd top_rqs_cmd; /* REQUEST SENSE */ | 312 | struct ub_scsi_cmd top_rqs_cmd; /* REQUEST SENSE */ |
288 | unsigned char top_sense[UB_SENSE_SIZE]; | 313 | unsigned char top_sense[UB_SENSE_SIZE]; |
@@ -301,9 +326,9 @@ struct ub_dev { | |||
301 | /* | 326 | /* |
302 | */ | 327 | */ |
303 | static void ub_cleanup(struct ub_dev *sc); | 328 | static void ub_cleanup(struct ub_dev *sc); |
304 | static int ub_bd_rq_fn_1(struct ub_dev *sc, struct request *rq); | 329 | static int ub_bd_rq_fn_1(struct ub_lun *lun, struct request *rq); |
305 | static int ub_cmd_build_block(struct ub_dev *sc, struct ub_scsi_cmd *cmd, | 330 | static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, |
306 | struct request *rq); | 331 | struct ub_scsi_cmd *cmd, struct request *rq); |
307 | static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_scsi_cmd *cmd, | 332 | static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_scsi_cmd *cmd, |
308 | struct request *rq); | 333 | struct request *rq); |
309 | static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd); | 334 | static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd); |
@@ -320,8 +345,10 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd); | |||
320 | static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd, | 345 | static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd, |
321 | int stalled_pipe); | 346 | int stalled_pipe); |
322 | static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd); | 347 | static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd); |
323 | static int ub_sync_tur(struct ub_dev *sc); | 348 | static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun); |
324 | static int ub_sync_read_cap(struct ub_dev *sc, struct ub_capacity *ret); | 349 | static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, |
350 | struct ub_capacity *ret); | ||
351 | static int ub_probe_lun(struct ub_dev *sc, int lnum); | ||
325 | 352 | ||
326 | /* | 353 | /* |
327 | */ | 354 | */ |
@@ -342,6 +369,7 @@ MODULE_DEVICE_TABLE(usb, ub_usb_ids); | |||
342 | */ | 369 | */ |
343 | #define UB_MAX_HOSTS 26 | 370 | #define UB_MAX_HOSTS 26 |
344 | static char ub_hostv[UB_MAX_HOSTS]; | 371 | static char ub_hostv[UB_MAX_HOSTS]; |
372 | |||
345 | static DEFINE_SPINLOCK(ub_lock); /* Locks globals and ->openc */ | 373 | static DEFINE_SPINLOCK(ub_lock); /* Locks globals and ->openc */ |
346 | 374 | ||
347 | /* | 375 | /* |
@@ -406,6 +434,8 @@ static ssize_t ub_diag_show(struct device *dev, char *page) | |||
406 | { | 434 | { |
407 | struct usb_interface *intf; | 435 | struct usb_interface *intf; |
408 | struct ub_dev *sc; | 436 | struct ub_dev *sc; |
437 | struct list_head *p; | ||
438 | struct ub_lun *lun; | ||
409 | int cnt; | 439 | int cnt; |
410 | unsigned long flags; | 440 | unsigned long flags; |
411 | int nc, nh; | 441 | int nc, nh; |
@@ -421,9 +451,15 @@ static ssize_t ub_diag_show(struct device *dev, char *page) | |||
421 | spin_lock_irqsave(&sc->lock, flags); | 451 | spin_lock_irqsave(&sc->lock, flags); |
422 | 452 | ||
423 | cnt += sprintf(page + cnt, | 453 | cnt += sprintf(page + cnt, |
424 | "qlen %d qmax %d changed %d removable %d readonly %d\n", | 454 | "qlen %d qmax %d\n", |
425 | sc->cmd_queue.qlen, sc->cmd_queue.qmax, | 455 | sc->cmd_queue.qlen, sc->cmd_queue.qmax); |
426 | sc->changed, sc->removable, sc->readonly); | 456 | |
457 | list_for_each (p, &sc->luns) { | ||
458 | lun = list_entry(p, struct ub_lun, link); | ||
459 | cnt += sprintf(page + cnt, | ||
460 | "lun %u changed %d removable %d readonly %d\n", | ||
461 | lun->num, lun->changed, lun->removable, lun->readonly); | ||
462 | } | ||
427 | 463 | ||
428 | if ((nc = sc->tr.cur + 1) == SCMD_TRACE_SZ) nc = 0; | 464 | if ((nc = sc->tr.cur + 1) == SCMD_TRACE_SZ) nc = 0; |
429 | for (j = 0; j < SCMD_TRACE_SZ; j++) { | 465 | for (j = 0; j < SCMD_TRACE_SZ; j++) { |
@@ -523,53 +559,63 @@ static void ub_put(struct ub_dev *sc) | |||
523 | */ | 559 | */ |
524 | static void ub_cleanup(struct ub_dev *sc) | 560 | static void ub_cleanup(struct ub_dev *sc) |
525 | { | 561 | { |
562 | struct list_head *p; | ||
563 | struct ub_lun *lun; | ||
526 | request_queue_t *q; | 564 | request_queue_t *q; |
527 | 565 | ||
528 | /* I don't think queue can be NULL. But... Stolen from sx8.c */ | 566 | while (!list_empty(&sc->luns)) { |
529 | if ((q = sc->disk->queue) != NULL) | 567 | p = sc->luns.next; |
530 | blk_cleanup_queue(q); | 568 | lun = list_entry(p, struct ub_lun, link); |
569 | list_del(p); | ||
531 | 570 | ||
532 | /* | 571 | /* I don't think queue can be NULL. But... Stolen from sx8.c */ |
533 | * If we zero disk->private_data BEFORE put_disk, we have to check | 572 | if ((q = lun->disk->queue) != NULL) |
534 | * for NULL all over the place in open, release, check_media and | 573 | blk_cleanup_queue(q); |
535 | * revalidate, because the block level semaphore is well inside the | 574 | /* |
536 | * put_disk. But we cannot zero after the call, because *disk is gone. | 575 | * If we zero disk->private_data BEFORE put_disk, we have |
537 | * The sd.c is blatantly racy in this area. | 576 | * to check for NULL all over the place in open, release, |
538 | */ | 577 | * check_media and revalidate, because the block level |
539 | /* disk->private_data = NULL; */ | 578 | * semaphore is well inside the put_disk. |
540 | put_disk(sc->disk); | 579 | * But we cannot zero after the call, because *disk is gone. |
541 | sc->disk = NULL; | 580 | * The sd.c is blatantly racy in this area. |
581 | */ | ||
582 | /* disk->private_data = NULL; */ | ||
583 | put_disk(lun->disk); | ||
584 | lun->disk = NULL; | ||
585 | |||
586 | ub_id_put(lun->id); | ||
587 | kfree(lun); | ||
588 | } | ||
542 | 589 | ||
543 | ub_id_put(sc->id); | ||
544 | kfree(sc); | 590 | kfree(sc); |
545 | } | 591 | } |
546 | 592 | ||
547 | /* | 593 | /* |
548 | * The "command allocator". | 594 | * The "command allocator". |
549 | */ | 595 | */ |
550 | static struct ub_scsi_cmd *ub_get_cmd(struct ub_dev *sc) | 596 | static struct ub_scsi_cmd *ub_get_cmd(struct ub_lun *lun) |
551 | { | 597 | { |
552 | struct ub_scsi_cmd *ret; | 598 | struct ub_scsi_cmd *ret; |
553 | 599 | ||
554 | if (sc->cmda[0]) | 600 | if (lun->cmda[0]) |
555 | return NULL; | 601 | return NULL; |
556 | ret = &sc->cmdv[0]; | 602 | ret = &lun->cmdv[0]; |
557 | sc->cmda[0] = 1; | 603 | lun->cmda[0] = 1; |
558 | return ret; | 604 | return ret; |
559 | } | 605 | } |
560 | 606 | ||
561 | static void ub_put_cmd(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | 607 | static void ub_put_cmd(struct ub_lun *lun, struct ub_scsi_cmd *cmd) |
562 | { | 608 | { |
563 | if (cmd != &sc->cmdv[0]) { | 609 | if (cmd != &lun->cmdv[0]) { |
564 | printk(KERN_WARNING "%s: releasing a foreign cmd %p\n", | 610 | printk(KERN_WARNING "%s: releasing a foreign cmd %p\n", |
565 | sc->name, cmd); | 611 | lun->name, cmd); |
566 | return; | 612 | return; |
567 | } | 613 | } |
568 | if (!sc->cmda[0]) { | 614 | if (!lun->cmda[0]) { |
569 | printk(KERN_WARNING "%s: releasing a free cmd\n", sc->name); | 615 | printk(KERN_WARNING "%s: releasing a free cmd\n", lun->name); |
570 | return; | 616 | return; |
571 | } | 617 | } |
572 | sc->cmda[0] = 0; | 618 | lun->cmda[0] = 0; |
573 | } | 619 | } |
574 | 620 | ||
575 | /* | 621 | /* |
@@ -630,29 +676,30 @@ static struct ub_scsi_cmd *ub_cmdq_pop(struct ub_dev *sc) | |||
630 | 676 | ||
631 | static void ub_bd_rq_fn(request_queue_t *q) | 677 | static void ub_bd_rq_fn(request_queue_t *q) |
632 | { | 678 | { |
633 | struct ub_dev *sc = q->queuedata; | 679 | struct ub_lun *lun = q->queuedata; |
634 | struct request *rq; | 680 | struct request *rq; |
635 | 681 | ||
636 | while ((rq = elv_next_request(q)) != NULL) { | 682 | while ((rq = elv_next_request(q)) != NULL) { |
637 | if (ub_bd_rq_fn_1(sc, rq) != 0) { | 683 | if (ub_bd_rq_fn_1(lun, rq) != 0) { |
638 | blk_stop_queue(q); | 684 | blk_stop_queue(q); |
639 | break; | 685 | break; |
640 | } | 686 | } |
641 | } | 687 | } |
642 | } | 688 | } |
643 | 689 | ||
644 | static int ub_bd_rq_fn_1(struct ub_dev *sc, struct request *rq) | 690 | static int ub_bd_rq_fn_1(struct ub_lun *lun, struct request *rq) |
645 | { | 691 | { |
692 | struct ub_dev *sc = lun->udev; | ||
646 | struct ub_scsi_cmd *cmd; | 693 | struct ub_scsi_cmd *cmd; |
647 | int rc; | 694 | int rc; |
648 | 695 | ||
649 | if (atomic_read(&sc->poison) || sc->changed) { | 696 | if (atomic_read(&sc->poison) || lun->changed) { |
650 | blkdev_dequeue_request(rq); | 697 | blkdev_dequeue_request(rq); |
651 | ub_end_rq(rq, 0); | 698 | ub_end_rq(rq, 0); |
652 | return 0; | 699 | return 0; |
653 | } | 700 | } |
654 | 701 | ||
655 | if ((cmd = ub_get_cmd(sc)) == NULL) | 702 | if ((cmd = ub_get_cmd(lun)) == NULL) |
656 | return -1; | 703 | return -1; |
657 | memset(cmd, 0, sizeof(struct ub_scsi_cmd)); | 704 | memset(cmd, 0, sizeof(struct ub_scsi_cmd)); |
658 | 705 | ||
@@ -661,32 +708,30 @@ static int ub_bd_rq_fn_1(struct ub_dev *sc, struct request *rq) | |||
661 | if (blk_pc_request(rq)) { | 708 | if (blk_pc_request(rq)) { |
662 | rc = ub_cmd_build_packet(sc, cmd, rq); | 709 | rc = ub_cmd_build_packet(sc, cmd, rq); |
663 | } else { | 710 | } else { |
664 | rc = ub_cmd_build_block(sc, cmd, rq); | 711 | rc = ub_cmd_build_block(sc, lun, cmd, rq); |
665 | } | 712 | } |
666 | if (rc != 0) { | 713 | if (rc != 0) { |
667 | ub_put_cmd(sc, cmd); | 714 | ub_put_cmd(lun, cmd); |
668 | ub_end_rq(rq, 0); | 715 | ub_end_rq(rq, 0); |
669 | blk_start_queue(sc->disk->queue); | ||
670 | return 0; | 716 | return 0; |
671 | } | 717 | } |
672 | |||
673 | cmd->state = UB_CMDST_INIT; | 718 | cmd->state = UB_CMDST_INIT; |
719 | cmd->lun = lun; | ||
674 | cmd->done = ub_rw_cmd_done; | 720 | cmd->done = ub_rw_cmd_done; |
675 | cmd->back = rq; | 721 | cmd->back = rq; |
676 | 722 | ||
677 | cmd->tag = sc->tagcnt++; | 723 | cmd->tag = sc->tagcnt++; |
678 | if ((rc = ub_submit_scsi(sc, cmd)) != 0) { | 724 | if ((rc = ub_submit_scsi(sc, cmd)) != 0) { |
679 | ub_put_cmd(sc, cmd); | 725 | ub_put_cmd(lun, cmd); |
680 | ub_end_rq(rq, 0); | 726 | ub_end_rq(rq, 0); |
681 | blk_start_queue(sc->disk->queue); | ||
682 | return 0; | 727 | return 0; |
683 | } | 728 | } |
684 | 729 | ||
685 | return 0; | 730 | return 0; |
686 | } | 731 | } |
687 | 732 | ||
688 | static int ub_cmd_build_block(struct ub_dev *sc, struct ub_scsi_cmd *cmd, | 733 | static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, |
689 | struct request *rq) | 734 | struct ub_scsi_cmd *cmd, struct request *rq) |
690 | { | 735 | { |
691 | int ub_dir; | 736 | int ub_dir; |
692 | #if 0 /* We use rq->buffer for now */ | 737 | #if 0 /* We use rq->buffer for now */ |
@@ -707,7 +752,7 @@ static int ub_cmd_build_block(struct ub_dev *sc, struct ub_scsi_cmd *cmd, | |||
707 | sg = &cmd->sgv[0]; | 752 | sg = &cmd->sgv[0]; |
708 | n_elem = blk_rq_map_sg(q, rq, sg); | 753 | n_elem = blk_rq_map_sg(q, rq, sg); |
709 | if (n_elem <= 0) { | 754 | if (n_elem <= 0) { |
710 | ub_put_cmd(sc, cmd); | 755 | ub_put_cmd(lun, cmd); |
711 | ub_end_rq(rq, 0); | 756 | ub_end_rq(rq, 0); |
712 | blk_start_queue(q); | 757 | blk_start_queue(q); |
713 | return 0; /* request with no s/g entries? */ | 758 | return 0; /* request with no s/g entries? */ |
@@ -716,7 +761,7 @@ static int ub_cmd_build_block(struct ub_dev *sc, struct ub_scsi_cmd *cmd, | |||
716 | if (n_elem != 1) { /* Paranoia */ | 761 | if (n_elem != 1) { /* Paranoia */ |
717 | printk(KERN_WARNING "%s: request with %d segments\n", | 762 | printk(KERN_WARNING "%s: request with %d segments\n", |
718 | sc->name, n_elem); | 763 | sc->name, n_elem); |
719 | ub_put_cmd(sc, cmd); | 764 | ub_put_cmd(lun, cmd); |
720 | ub_end_rq(rq, 0); | 765 | ub_end_rq(rq, 0); |
721 | blk_start_queue(q); | 766 | blk_start_queue(q); |
722 | return 0; | 767 | return 0; |
@@ -748,8 +793,8 @@ static int ub_cmd_build_block(struct ub_dev *sc, struct ub_scsi_cmd *cmd, | |||
748 | * The call to blk_queue_hardsect_size() guarantees that request | 793 | * The call to blk_queue_hardsect_size() guarantees that request |
749 | * is aligned, but it is given in terms of 512 byte units, always. | 794 | * is aligned, but it is given in terms of 512 byte units, always. |
750 | */ | 795 | */ |
751 | block = rq->sector >> sc->capacity.bshift; | 796 | block = rq->sector >> lun->capacity.bshift; |
752 | nblks = rq->nr_sectors >> sc->capacity.bshift; | 797 | nblks = rq->nr_sectors >> lun->capacity.bshift; |
753 | 798 | ||
754 | cmd->cdb[0] = (ub_dir == UB_DIR_READ)? READ_10: WRITE_10; | 799 | cmd->cdb[0] = (ub_dir == UB_DIR_READ)? READ_10: WRITE_10; |
755 | /* 10-byte uses 4 bytes of LBA: 2147483648KB, 2097152MB, 2048GB */ | 800 | /* 10-byte uses 4 bytes of LBA: 2147483648KB, 2097152MB, 2048GB */ |
@@ -803,7 +848,8 @@ static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_scsi_cmd *cmd, | |||
803 | static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | 848 | static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) |
804 | { | 849 | { |
805 | struct request *rq = cmd->back; | 850 | struct request *rq = cmd->back; |
806 | struct gendisk *disk = sc->disk; | 851 | struct ub_lun *lun = cmd->lun; |
852 | struct gendisk *disk = lun->disk; | ||
807 | request_queue_t *q = disk->queue; | 853 | request_queue_t *q = disk->queue; |
808 | int uptodate; | 854 | int uptodate; |
809 | 855 | ||
@@ -818,7 +864,7 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
818 | else | 864 | else |
819 | uptodate = 0; | 865 | uptodate = 0; |
820 | 866 | ||
821 | ub_put_cmd(sc, cmd); | 867 | ub_put_cmd(lun, cmd); |
822 | ub_end_rq(rq, uptodate); | 868 | ub_end_rq(rq, uptodate); |
823 | blk_start_queue(q); | 869 | blk_start_queue(q); |
824 | } | 870 | } |
@@ -887,7 +933,7 @@ static int ub_scsi_cmd_start(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
887 | bcb->Tag = cmd->tag; /* Endianness is not important */ | 933 | bcb->Tag = cmd->tag; /* Endianness is not important */ |
888 | bcb->DataTransferLength = cpu_to_le32(cmd->len); | 934 | bcb->DataTransferLength = cpu_to_le32(cmd->len); |
889 | bcb->Flags = (cmd->dir == UB_DIR_READ) ? 0x80 : 0; | 935 | bcb->Flags = (cmd->dir == UB_DIR_READ) ? 0x80 : 0; |
890 | bcb->Lun = 0; /* No multi-LUN yet */ | 936 | bcb->Lun = (cmd->lun != NULL) ? cmd->lun->num : 0; |
891 | bcb->Length = cmd->cdb_len; | 937 | bcb->Length = cmd->cdb_len; |
892 | 938 | ||
893 | /* copy the command payload */ | 939 | /* copy the command payload */ |
@@ -1002,9 +1048,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1002 | * The control pipe clears itself - nothing to do. | 1048 | * The control pipe clears itself - nothing to do. |
1003 | * XXX Might try to reset the device here and retry. | 1049 | * XXX Might try to reset the device here and retry. |
1004 | */ | 1050 | */ |
1005 | printk(KERN_NOTICE "%s: " | 1051 | printk(KERN_NOTICE "%s: stall on control pipe\n", |
1006 | "stall on control pipe for device %u\n", | 1052 | sc->name); |
1007 | sc->name, sc->dev->devnum); | ||
1008 | goto Bad_End; | 1053 | goto Bad_End; |
1009 | } | 1054 | } |
1010 | 1055 | ||
@@ -1025,9 +1070,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1025 | * The control pipe clears itself - nothing to do. | 1070 | * The control pipe clears itself - nothing to do. |
1026 | * XXX Might try to reset the device here and retry. | 1071 | * XXX Might try to reset the device here and retry. |
1027 | */ | 1072 | */ |
1028 | printk(KERN_NOTICE "%s: " | 1073 | printk(KERN_NOTICE "%s: stall on control pipe\n", |
1029 | "stall on control pipe for device %u\n", | 1074 | sc->name); |
1030 | sc->name, sc->dev->devnum); | ||
1031 | goto Bad_End; | 1075 | goto Bad_End; |
1032 | } | 1076 | } |
1033 | 1077 | ||
@@ -1046,9 +1090,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1046 | rc = ub_submit_clear_stall(sc, cmd, sc->last_pipe); | 1090 | rc = ub_submit_clear_stall(sc, cmd, sc->last_pipe); |
1047 | if (rc != 0) { | 1091 | if (rc != 0) { |
1048 | printk(KERN_NOTICE "%s: " | 1092 | printk(KERN_NOTICE "%s: " |
1049 | "unable to submit clear for device %u" | 1093 | "unable to submit clear (%d)\n", |
1050 | " (code %d)\n", | 1094 | sc->name, rc); |
1051 | sc->name, sc->dev->devnum, rc); | ||
1052 | /* | 1095 | /* |
1053 | * This is typically ENOMEM or some other such shit. | 1096 | * This is typically ENOMEM or some other such shit. |
1054 | * Retrying is pointless. Just do Bad End on it... | 1097 | * Retrying is pointless. Just do Bad End on it... |
@@ -1107,9 +1150,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1107 | rc = ub_submit_clear_stall(sc, cmd, sc->last_pipe); | 1150 | rc = ub_submit_clear_stall(sc, cmd, sc->last_pipe); |
1108 | if (rc != 0) { | 1151 | if (rc != 0) { |
1109 | printk(KERN_NOTICE "%s: " | 1152 | printk(KERN_NOTICE "%s: " |
1110 | "unable to submit clear for device %u" | 1153 | "unable to submit clear (%d)\n", |
1111 | " (code %d)\n", | 1154 | sc->name, rc); |
1112 | sc->name, sc->dev->devnum, rc); | ||
1113 | /* | 1155 | /* |
1114 | * This is typically ENOMEM or some other such shit. | 1156 | * This is typically ENOMEM or some other such shit. |
1115 | * Retrying is pointless. Just do Bad End on it... | 1157 | * Retrying is pointless. Just do Bad End on it... |
@@ -1140,9 +1182,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1140 | rc = ub_submit_clear_stall(sc, cmd, sc->last_pipe); | 1182 | rc = ub_submit_clear_stall(sc, cmd, sc->last_pipe); |
1141 | if (rc != 0) { | 1183 | if (rc != 0) { |
1142 | printk(KERN_NOTICE "%s: " | 1184 | printk(KERN_NOTICE "%s: " |
1143 | "unable to submit clear for device %u" | 1185 | "unable to submit clear (%d)\n", |
1144 | " (code %d)\n", | 1186 | sc->name, rc); |
1145 | sc->name, sc->dev->devnum, rc); | ||
1146 | /* | 1187 | /* |
1147 | * This is typically ENOMEM or some other such shit. | 1188 | * This is typically ENOMEM or some other such shit. |
1148 | * Retrying is pointless. Just do Bad End on it... | 1189 | * Retrying is pointless. Just do Bad End on it... |
@@ -1164,9 +1205,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1164 | * encounter such a thing, try to read the CSW again. | 1205 | * encounter such a thing, try to read the CSW again. |
1165 | */ | 1206 | */ |
1166 | if (++cmd->stat_count >= 4) { | 1207 | if (++cmd->stat_count >= 4) { |
1167 | printk(KERN_NOTICE "%s: " | 1208 | printk(KERN_NOTICE "%s: unable to get CSW\n", |
1168 | "unable to get CSW on device %u\n", | 1209 | sc->name); |
1169 | sc->name, sc->dev->devnum); | ||
1170 | goto Bad_End; | 1210 | goto Bad_End; |
1171 | } | 1211 | } |
1172 | __ub_state_stat(sc, cmd); | 1212 | __ub_state_stat(sc, cmd); |
@@ -1207,10 +1247,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1207 | */ | 1247 | */ |
1208 | if (++cmd->stat_count >= 4) { | 1248 | if (++cmd->stat_count >= 4) { |
1209 | printk(KERN_NOTICE "%s: " | 1249 | printk(KERN_NOTICE "%s: " |
1210 | "tag mismatch orig 0x%x reply 0x%x " | 1250 | "tag mismatch orig 0x%x reply 0x%x\n", |
1211 | "on device %u\n", | 1251 | sc->name, cmd->tag, bcs->Tag); |
1212 | sc->name, cmd->tag, bcs->Tag, | ||
1213 | sc->dev->devnum); | ||
1214 | goto Bad_End; | 1252 | goto Bad_End; |
1215 | } | 1253 | } |
1216 | __ub_state_stat(sc, cmd); | 1254 | __ub_state_stat(sc, cmd); |
@@ -1244,8 +1282,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1244 | 1282 | ||
1245 | } else { | 1283 | } else { |
1246 | printk(KERN_WARNING "%s: " | 1284 | printk(KERN_WARNING "%s: " |
1247 | "wrong command state %d on device %u\n", | 1285 | "wrong command state %d\n", |
1248 | sc->name, cmd->state, sc->dev->devnum); | 1286 | sc->name, cmd->state); |
1249 | goto Bad_End; | 1287 | goto Bad_End; |
1250 | } | 1288 | } |
1251 | return; | 1289 | return; |
@@ -1288,7 +1326,6 @@ static void __ub_state_stat(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1288 | 1326 | ||
1289 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { | 1327 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) { |
1290 | /* XXX Clear stalls */ | 1328 | /* XXX Clear stalls */ |
1291 | printk("%s: CSW #%d submit failed (%d)\n", sc->name, cmd->tag, rc); /* P3 */ | ||
1292 | ub_complete(&sc->work_done); | 1329 | ub_complete(&sc->work_done); |
1293 | ub_state_done(sc, cmd, rc); | 1330 | ub_state_done(sc, cmd, rc); |
1294 | return; | 1331 | return; |
@@ -1333,6 +1370,7 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1333 | scmd->state = UB_CMDST_INIT; | 1370 | scmd->state = UB_CMDST_INIT; |
1334 | scmd->data = sc->top_sense; | 1371 | scmd->data = sc->top_sense; |
1335 | scmd->len = UB_SENSE_SIZE; | 1372 | scmd->len = UB_SENSE_SIZE; |
1373 | scmd->lun = cmd->lun; | ||
1336 | scmd->done = ub_top_sense_done; | 1374 | scmd->done = ub_top_sense_done; |
1337 | scmd->back = cmd; | 1375 | scmd->back = cmd; |
1338 | 1376 | ||
@@ -1411,14 +1449,14 @@ static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd) | |||
1411 | } | 1449 | } |
1412 | if (cmd != scmd->back) { | 1450 | if (cmd != scmd->back) { |
1413 | printk(KERN_WARNING "%s: " | 1451 | printk(KERN_WARNING "%s: " |
1414 | "sense done for wrong command 0x%x on device %u\n", | 1452 | "sense done for wrong command 0x%x\n", |
1415 | sc->name, cmd->tag, sc->dev->devnum); | 1453 | sc->name, cmd->tag); |
1416 | return; | 1454 | return; |
1417 | } | 1455 | } |
1418 | if (cmd->state != UB_CMDST_SENSE) { | 1456 | if (cmd->state != UB_CMDST_SENSE) { |
1419 | printk(KERN_WARNING "%s: " | 1457 | printk(KERN_WARNING "%s: " |
1420 | "sense done with bad cmd state %d on device %u\n", | 1458 | "sense done with bad cmd state %d\n", |
1421 | sc->name, cmd->state, sc->dev->devnum); | 1459 | sc->name, cmd->state); |
1422 | return; | 1460 | return; |
1423 | } | 1461 | } |
1424 | 1462 | ||
@@ -1429,68 +1467,32 @@ static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd) | |||
1429 | ub_scsi_urb_compl(sc, cmd); | 1467 | ub_scsi_urb_compl(sc, cmd); |
1430 | } | 1468 | } |
1431 | 1469 | ||
1432 | #if 0 | ||
1433 | /* Determine what the maximum LUN supported is */ | ||
1434 | int usb_stor_Bulk_max_lun(struct us_data *us) | ||
1435 | { | ||
1436 | int result; | ||
1437 | |||
1438 | /* issue the command */ | ||
1439 | result = usb_stor_control_msg(us, us->recv_ctrl_pipe, | ||
1440 | US_BULK_GET_MAX_LUN, | ||
1441 | USB_DIR_IN | USB_TYPE_CLASS | | ||
1442 | USB_RECIP_INTERFACE, | ||
1443 | 0, us->ifnum, us->iobuf, 1, HZ); | ||
1444 | |||
1445 | /* | ||
1446 | * Some devices (i.e. Iomega Zip100) need this -- apparently | ||
1447 | * the bulk pipes get STALLed when the GetMaxLUN request is | ||
1448 | * processed. This is, in theory, harmless to all other devices | ||
1449 | * (regardless of if they stall or not). | ||
1450 | */ | ||
1451 | if (result < 0) { | ||
1452 | usb_stor_clear_halt(us, us->recv_bulk_pipe); | ||
1453 | usb_stor_clear_halt(us, us->send_bulk_pipe); | ||
1454 | } | ||
1455 | |||
1456 | US_DEBUGP("GetMaxLUN command result is %d, data is %d\n", | ||
1457 | result, us->iobuf[0]); | ||
1458 | |||
1459 | /* if we have a successful request, return the result */ | ||
1460 | if (result == 1) | ||
1461 | return us->iobuf[0]; | ||
1462 | |||
1463 | /* return the default -- no LUNs */ | ||
1464 | return 0; | ||
1465 | } | ||
1466 | #endif | ||
1467 | |||
1468 | /* | 1470 | /* |
1469 | * This is called from a process context. | 1471 | * This is called from a process context. |
1470 | */ | 1472 | */ |
1471 | static void ub_revalidate(struct ub_dev *sc) | 1473 | static void ub_revalidate(struct ub_dev *sc, struct ub_lun *lun) |
1472 | { | 1474 | { |
1473 | 1475 | ||
1474 | sc->readonly = 0; /* XXX Query this from the device */ | 1476 | lun->readonly = 0; /* XXX Query this from the device */ |
1475 | 1477 | ||
1476 | sc->capacity.nsec = 0; | 1478 | lun->capacity.nsec = 0; |
1477 | sc->capacity.bsize = 512; | 1479 | lun->capacity.bsize = 512; |
1478 | sc->capacity.bshift = 0; | 1480 | lun->capacity.bshift = 0; |
1479 | 1481 | ||
1480 | if (ub_sync_tur(sc) != 0) | 1482 | if (ub_sync_tur(sc, lun) != 0) |
1481 | return; /* Not ready */ | 1483 | return; /* Not ready */ |
1482 | sc->changed = 0; | 1484 | lun->changed = 0; |
1483 | 1485 | ||
1484 | if (ub_sync_read_cap(sc, &sc->capacity) != 0) { | 1486 | if (ub_sync_read_cap(sc, lun, &lun->capacity) != 0) { |
1485 | /* | 1487 | /* |
1486 | * The retry here means something is wrong, either with the | 1488 | * The retry here means something is wrong, either with the |
1487 | * device, with the transport, or with our code. | 1489 | * device, with the transport, or with our code. |
1488 | * We keep this because sd.c has retries for capacity. | 1490 | * We keep this because sd.c has retries for capacity. |
1489 | */ | 1491 | */ |
1490 | if (ub_sync_read_cap(sc, &sc->capacity) != 0) { | 1492 | if (ub_sync_read_cap(sc, lun, &lun->capacity) != 0) { |
1491 | sc->capacity.nsec = 0; | 1493 | lun->capacity.nsec = 0; |
1492 | sc->capacity.bsize = 512; | 1494 | lun->capacity.bsize = 512; |
1493 | sc->capacity.bshift = 0; | 1495 | lun->capacity.bshift = 0; |
1494 | } | 1496 | } |
1495 | } | 1497 | } |
1496 | } | 1498 | } |
@@ -1503,12 +1505,15 @@ static void ub_revalidate(struct ub_dev *sc) | |||
1503 | static int ub_bd_open(struct inode *inode, struct file *filp) | 1505 | static int ub_bd_open(struct inode *inode, struct file *filp) |
1504 | { | 1506 | { |
1505 | struct gendisk *disk = inode->i_bdev->bd_disk; | 1507 | struct gendisk *disk = inode->i_bdev->bd_disk; |
1508 | struct ub_lun *lun; | ||
1506 | struct ub_dev *sc; | 1509 | struct ub_dev *sc; |
1507 | unsigned long flags; | 1510 | unsigned long flags; |
1508 | int rc; | 1511 | int rc; |
1509 | 1512 | ||
1510 | if ((sc = disk->private_data) == NULL) | 1513 | if ((lun = disk->private_data) == NULL) |
1511 | return -ENXIO; | 1514 | return -ENXIO; |
1515 | sc = lun->udev; | ||
1516 | |||
1512 | spin_lock_irqsave(&ub_lock, flags); | 1517 | spin_lock_irqsave(&ub_lock, flags); |
1513 | if (atomic_read(&sc->poison)) { | 1518 | if (atomic_read(&sc->poison)) { |
1514 | spin_unlock_irqrestore(&ub_lock, flags); | 1519 | spin_unlock_irqrestore(&ub_lock, flags); |
@@ -1529,15 +1534,15 @@ static int ub_bd_open(struct inode *inode, struct file *filp) | |||
1529 | * The bottom line is, Al Viro says that we should not allow | 1534 | * The bottom line is, Al Viro says that we should not allow |
1530 | * bdev->bd_invalidated to be set when doing add_disk no matter what. | 1535 | * bdev->bd_invalidated to be set when doing add_disk no matter what. |
1531 | */ | 1536 | */ |
1532 | if (sc->first_open) { | 1537 | if (lun->first_open) { |
1533 | if (sc->changed) { | 1538 | lun->first_open = 0; |
1534 | sc->first_open = 0; | 1539 | if (lun->changed) { |
1535 | rc = -ENOMEDIUM; | 1540 | rc = -ENOMEDIUM; |
1536 | goto err_open; | 1541 | goto err_open; |
1537 | } | 1542 | } |
1538 | } | 1543 | } |
1539 | 1544 | ||
1540 | if (sc->removable || sc->readonly) | 1545 | if (lun->removable || lun->readonly) |
1541 | check_disk_change(inode->i_bdev); | 1546 | check_disk_change(inode->i_bdev); |
1542 | 1547 | ||
1543 | /* | 1548 | /* |
@@ -1545,12 +1550,12 @@ static int ub_bd_open(struct inode *inode, struct file *filp) | |||
1545 | * under some pretty murky conditions (a failure of READ CAPACITY). | 1550 | * under some pretty murky conditions (a failure of READ CAPACITY). |
1546 | * We may need it one day. | 1551 | * We may need it one day. |
1547 | */ | 1552 | */ |
1548 | if (sc->removable && sc->changed && !(filp->f_flags & O_NDELAY)) { | 1553 | if (lun->removable && lun->changed && !(filp->f_flags & O_NDELAY)) { |
1549 | rc = -ENOMEDIUM; | 1554 | rc = -ENOMEDIUM; |
1550 | goto err_open; | 1555 | goto err_open; |
1551 | } | 1556 | } |
1552 | 1557 | ||
1553 | if (sc->readonly && (filp->f_mode & FMODE_WRITE)) { | 1558 | if (lun->readonly && (filp->f_mode & FMODE_WRITE)) { |
1554 | rc = -EROFS; | 1559 | rc = -EROFS; |
1555 | goto err_open; | 1560 | goto err_open; |
1556 | } | 1561 | } |
@@ -1567,7 +1572,8 @@ err_open: | |||
1567 | static int ub_bd_release(struct inode *inode, struct file *filp) | 1572 | static int ub_bd_release(struct inode *inode, struct file *filp) |
1568 | { | 1573 | { |
1569 | struct gendisk *disk = inode->i_bdev->bd_disk; | 1574 | struct gendisk *disk = inode->i_bdev->bd_disk; |
1570 | struct ub_dev *sc = disk->private_data; | 1575 | struct ub_lun *lun = disk->private_data; |
1576 | struct ub_dev *sc = lun->udev; | ||
1571 | 1577 | ||
1572 | ub_put(sc); | 1578 | ub_put(sc); |
1573 | return 0; | 1579 | return 0; |
@@ -1597,20 +1603,14 @@ static int ub_bd_ioctl(struct inode *inode, struct file *filp, | |||
1597 | */ | 1603 | */ |
1598 | static int ub_bd_revalidate(struct gendisk *disk) | 1604 | static int ub_bd_revalidate(struct gendisk *disk) |
1599 | { | 1605 | { |
1600 | struct ub_dev *sc = disk->private_data; | 1606 | struct ub_lun *lun = disk->private_data; |
1601 | 1607 | ||
1602 | ub_revalidate(sc); | 1608 | ub_revalidate(lun->udev, lun); |
1603 | /* This is pretty much a long term P3 */ | ||
1604 | if (!atomic_read(&sc->poison)) { /* Cover sc->dev */ | ||
1605 | printk(KERN_INFO "%s: device %u capacity nsec %ld bsize %u\n", | ||
1606 | sc->name, sc->dev->devnum, | ||
1607 | sc->capacity.nsec, sc->capacity.bsize); | ||
1608 | } | ||
1609 | 1609 | ||
1610 | /* XXX Support sector size switching like in sr.c */ | 1610 | /* XXX Support sector size switching like in sr.c */ |
1611 | blk_queue_hardsect_size(disk->queue, sc->capacity.bsize); | 1611 | blk_queue_hardsect_size(disk->queue, lun->capacity.bsize); |
1612 | set_capacity(disk, sc->capacity.nsec); | 1612 | set_capacity(disk, lun->capacity.nsec); |
1613 | // set_disk_ro(sdkp->disk, sc->readonly); | 1613 | // set_disk_ro(sdkp->disk, lun->readonly); |
1614 | 1614 | ||
1615 | return 0; | 1615 | return 0; |
1616 | } | 1616 | } |
@@ -1626,9 +1626,9 @@ static int ub_bd_revalidate(struct gendisk *disk) | |||
1626 | */ | 1626 | */ |
1627 | static int ub_bd_media_changed(struct gendisk *disk) | 1627 | static int ub_bd_media_changed(struct gendisk *disk) |
1628 | { | 1628 | { |
1629 | struct ub_dev *sc = disk->private_data; | 1629 | struct ub_lun *lun = disk->private_data; |
1630 | 1630 | ||
1631 | if (!sc->removable) | 1631 | if (!lun->removable) |
1632 | return 0; | 1632 | return 0; |
1633 | 1633 | ||
1634 | /* | 1634 | /* |
@@ -1640,12 +1640,12 @@ static int ub_bd_media_changed(struct gendisk *disk) | |||
1640 | * will fail, then block layer discards the data. Since we never | 1640 | * will fail, then block layer discards the data. Since we never |
1641 | * spin drives up, such devices simply cannot be used with ub anyway. | 1641 | * spin drives up, such devices simply cannot be used with ub anyway. |
1642 | */ | 1642 | */ |
1643 | if (ub_sync_tur(sc) != 0) { | 1643 | if (ub_sync_tur(lun->udev, lun) != 0) { |
1644 | sc->changed = 1; | 1644 | lun->changed = 1; |
1645 | return 1; | 1645 | return 1; |
1646 | } | 1646 | } |
1647 | 1647 | ||
1648 | return sc->changed; | 1648 | return lun->changed; |
1649 | } | 1649 | } |
1650 | 1650 | ||
1651 | static struct block_device_operations ub_bd_fops = { | 1651 | static struct block_device_operations ub_bd_fops = { |
@@ -1669,7 +1669,7 @@ static void ub_probe_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
1669 | /* | 1669 | /* |
1670 | * Test if the device has a check condition on it, synchronously. | 1670 | * Test if the device has a check condition on it, synchronously. |
1671 | */ | 1671 | */ |
1672 | static int ub_sync_tur(struct ub_dev *sc) | 1672 | static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun) |
1673 | { | 1673 | { |
1674 | struct ub_scsi_cmd *cmd; | 1674 | struct ub_scsi_cmd *cmd; |
1675 | enum { ALLOC_SIZE = sizeof(struct ub_scsi_cmd) }; | 1675 | enum { ALLOC_SIZE = sizeof(struct ub_scsi_cmd) }; |
@@ -1688,6 +1688,7 @@ static int ub_sync_tur(struct ub_dev *sc) | |||
1688 | cmd->cdb_len = 6; | 1688 | cmd->cdb_len = 6; |
1689 | cmd->dir = UB_DIR_NONE; | 1689 | cmd->dir = UB_DIR_NONE; |
1690 | cmd->state = UB_CMDST_INIT; | 1690 | cmd->state = UB_CMDST_INIT; |
1691 | cmd->lun = lun; /* This may be NULL, but that's ok */ | ||
1691 | cmd->done = ub_probe_done; | 1692 | cmd->done = ub_probe_done; |
1692 | cmd->back = &compl; | 1693 | cmd->back = &compl; |
1693 | 1694 | ||
@@ -1718,7 +1719,8 @@ err_alloc: | |||
1718 | /* | 1719 | /* |
1719 | * Read the SCSI capacity synchronously (for probing). | 1720 | * Read the SCSI capacity synchronously (for probing). |
1720 | */ | 1721 | */ |
1721 | static int ub_sync_read_cap(struct ub_dev *sc, struct ub_capacity *ret) | 1722 | static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, |
1723 | struct ub_capacity *ret) | ||
1722 | { | 1724 | { |
1723 | struct ub_scsi_cmd *cmd; | 1725 | struct ub_scsi_cmd *cmd; |
1724 | char *p; | 1726 | char *p; |
@@ -1743,6 +1745,7 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_capacity *ret) | |||
1743 | cmd->state = UB_CMDST_INIT; | 1745 | cmd->state = UB_CMDST_INIT; |
1744 | cmd->data = p; | 1746 | cmd->data = p; |
1745 | cmd->len = 8; | 1747 | cmd->len = 8; |
1748 | cmd->lun = lun; | ||
1746 | cmd->done = ub_probe_done; | 1749 | cmd->done = ub_probe_done; |
1747 | cmd->back = &compl; | 1750 | cmd->back = &compl; |
1748 | 1751 | ||
@@ -1812,6 +1815,90 @@ static void ub_probe_timeout(unsigned long arg) | |||
1812 | } | 1815 | } |
1813 | 1816 | ||
1814 | /* | 1817 | /* |
1818 | * Get number of LUNs by the way of Bulk GetMaxLUN command. | ||
1819 | */ | ||
1820 | static int ub_sync_getmaxlun(struct ub_dev *sc) | ||
1821 | { | ||
1822 | int ifnum = sc->intf->cur_altsetting->desc.bInterfaceNumber; | ||
1823 | unsigned char *p; | ||
1824 | enum { ALLOC_SIZE = 1 }; | ||
1825 | struct usb_ctrlrequest *cr; | ||
1826 | struct completion compl; | ||
1827 | struct timer_list timer; | ||
1828 | int nluns; | ||
1829 | int rc; | ||
1830 | |||
1831 | init_completion(&compl); | ||
1832 | |||
1833 | rc = -ENOMEM; | ||
1834 | if ((p = kmalloc(ALLOC_SIZE, GFP_KERNEL)) == NULL) | ||
1835 | goto err_alloc; | ||
1836 | *p = 55; | ||
1837 | |||
1838 | cr = &sc->work_cr; | ||
1839 | cr->bRequestType = USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE; | ||
1840 | cr->bRequest = US_BULK_GET_MAX_LUN; | ||
1841 | cr->wValue = cpu_to_le16(0); | ||
1842 | cr->wIndex = cpu_to_le16(ifnum); | ||
1843 | cr->wLength = cpu_to_le16(1); | ||
1844 | |||
1845 | usb_fill_control_urb(&sc->work_urb, sc->dev, sc->recv_ctrl_pipe, | ||
1846 | (unsigned char*) cr, p, 1, ub_probe_urb_complete, &compl); | ||
1847 | sc->work_urb.transfer_flags = 0; | ||
1848 | sc->work_urb.actual_length = 0; | ||
1849 | sc->work_urb.error_count = 0; | ||
1850 | sc->work_urb.status = 0; | ||
1851 | |||
1852 | if ((rc = usb_submit_urb(&sc->work_urb, GFP_KERNEL)) != 0) { | ||
1853 | if (rc == -EPIPE) { | ||
1854 | printk("%s: Stall at GetMaxLUN, using 1 LUN\n", | ||
1855 | sc->name); /* P3 */ | ||
1856 | } else { | ||
1857 | printk(KERN_WARNING | ||
1858 | "%s: Unable to submit GetMaxLUN (%d)\n", | ||
1859 | sc->name, rc); | ||
1860 | } | ||
1861 | goto err_submit; | ||
1862 | } | ||
1863 | |||
1864 | init_timer(&timer); | ||
1865 | timer.function = ub_probe_timeout; | ||
1866 | timer.data = (unsigned long) &compl; | ||
1867 | timer.expires = jiffies + UB_CTRL_TIMEOUT; | ||
1868 | add_timer(&timer); | ||
1869 | |||
1870 | wait_for_completion(&compl); | ||
1871 | |||
1872 | del_timer_sync(&timer); | ||
1873 | usb_kill_urb(&sc->work_urb); | ||
1874 | |||
1875 | if (sc->work_urb.actual_length != 1) { | ||
1876 | printk("%s: GetMaxLUN returned %d bytes\n", sc->name, | ||
1877 | sc->work_urb.actual_length); /* P3 */ | ||
1878 | nluns = 0; | ||
1879 | } else { | ||
1880 | if ((nluns = *p) == 55) { | ||
1881 | nluns = 0; | ||
1882 | } else { | ||
1883 | /* GetMaxLUN returns the maximum LUN number */ | ||
1884 | nluns += 1; | ||
1885 | if (nluns > UB_MAX_LUNS) | ||
1886 | nluns = UB_MAX_LUNS; | ||
1887 | } | ||
1888 | printk("%s: GetMaxLUN returned %d, using %d LUNs\n", sc->name, | ||
1889 | *p, nluns); /* P3 */ | ||
1890 | } | ||
1891 | |||
1892 | kfree(p); | ||
1893 | return nluns; | ||
1894 | |||
1895 | err_submit: | ||
1896 | kfree(p); | ||
1897 | err_alloc: | ||
1898 | return rc; | ||
1899 | } | ||
1900 | |||
1901 | /* | ||
1815 | * Clear initial stalls. | 1902 | * Clear initial stalls. |
1816 | */ | 1903 | */ |
1817 | static int ub_probe_clear_stall(struct ub_dev *sc, int stalled_pipe) | 1904 | static int ub_probe_clear_stall(struct ub_dev *sc, int stalled_pipe) |
@@ -1897,8 +1984,8 @@ static int ub_get_pipes(struct ub_dev *sc, struct usb_device *dev, | |||
1897 | } | 1984 | } |
1898 | 1985 | ||
1899 | if (ep_in == NULL || ep_out == NULL) { | 1986 | if (ep_in == NULL || ep_out == NULL) { |
1900 | printk(KERN_NOTICE "%s: device %u failed endpoint check\n", | 1987 | printk(KERN_NOTICE "%s: failed endpoint check\n", |
1901 | sc->name, sc->dev->devnum); | 1988 | sc->name); |
1902 | return -EIO; | 1989 | return -EIO; |
1903 | } | 1990 | } |
1904 | 1991 | ||
@@ -1921,8 +2008,7 @@ static int ub_probe(struct usb_interface *intf, | |||
1921 | const struct usb_device_id *dev_id) | 2008 | const struct usb_device_id *dev_id) |
1922 | { | 2009 | { |
1923 | struct ub_dev *sc; | 2010 | struct ub_dev *sc; |
1924 | request_queue_t *q; | 2011 | int nluns; |
1925 | struct gendisk *disk; | ||
1926 | int rc; | 2012 | int rc; |
1927 | int i; | 2013 | int i; |
1928 | 2014 | ||
@@ -1931,6 +2017,7 @@ static int ub_probe(struct usb_interface *intf, | |||
1931 | goto err_core; | 2017 | goto err_core; |
1932 | memset(sc, 0, sizeof(struct ub_dev)); | 2018 | memset(sc, 0, sizeof(struct ub_dev)); |
1933 | spin_lock_init(&sc->lock); | 2019 | spin_lock_init(&sc->lock); |
2020 | INIT_LIST_HEAD(&sc->luns); | ||
1934 | usb_init_urb(&sc->work_urb); | 2021 | usb_init_urb(&sc->work_urb); |
1935 | tasklet_init(&sc->tasklet, ub_scsi_action, (unsigned long)sc); | 2022 | tasklet_init(&sc->tasklet, ub_scsi_action, (unsigned long)sc); |
1936 | atomic_set(&sc->poison, 0); | 2023 | atomic_set(&sc->poison, 0); |
@@ -1942,19 +2029,16 @@ static int ub_probe(struct usb_interface *intf, | |||
1942 | ub_init_completion(&sc->work_done); | 2029 | ub_init_completion(&sc->work_done); |
1943 | sc->work_done.done = 1; /* A little yuk, but oh well... */ | 2030 | sc->work_done.done = 1; /* A little yuk, but oh well... */ |
1944 | 2031 | ||
1945 | rc = -ENOSR; | ||
1946 | if ((sc->id = ub_id_get()) == -1) | ||
1947 | goto err_id; | ||
1948 | snprintf(sc->name, 8, DRV_NAME "%c", sc->id + 'a'); | ||
1949 | |||
1950 | sc->dev = interface_to_usbdev(intf); | 2032 | sc->dev = interface_to_usbdev(intf); |
1951 | sc->intf = intf; | 2033 | sc->intf = intf; |
1952 | // sc->ifnum = intf->cur_altsetting->desc.bInterfaceNumber; | 2034 | // sc->ifnum = intf->cur_altsetting->desc.bInterfaceNumber; |
1953 | |||
1954 | usb_set_intfdata(intf, sc); | 2035 | usb_set_intfdata(intf, sc); |
1955 | usb_get_dev(sc->dev); | 2036 | usb_get_dev(sc->dev); |
1956 | // usb_get_intf(sc->intf); /* Do we need this? */ | 2037 | // usb_get_intf(sc->intf); /* Do we need this? */ |
1957 | 2038 | ||
2039 | snprintf(sc->name, 12, DRV_NAME "(%d.%d)", | ||
2040 | sc->dev->bus->busnum, sc->dev->devnum); | ||
2041 | |||
1958 | /* XXX Verify that we can handle the device (from descriptors) */ | 2042 | /* XXX Verify that we can handle the device (from descriptors) */ |
1959 | 2043 | ||
1960 | ub_get_pipes(sc, sc->dev, intf); | 2044 | ub_get_pipes(sc, sc->dev, intf); |
@@ -1992,35 +2076,88 @@ static int ub_probe(struct usb_interface *intf, | |||
1992 | * In any case it's not our business how revaliadation is implemented. | 2076 | * In any case it's not our business how revaliadation is implemented. |
1993 | */ | 2077 | */ |
1994 | for (i = 0; i < 3; i++) { /* Retries for benh's key */ | 2078 | for (i = 0; i < 3; i++) { /* Retries for benh's key */ |
1995 | if ((rc = ub_sync_tur(sc)) <= 0) break; | 2079 | if ((rc = ub_sync_tur(sc, NULL)) <= 0) break; |
1996 | if (rc != 0x6) break; | 2080 | if (rc != 0x6) break; |
1997 | msleep(10); | 2081 | msleep(10); |
1998 | } | 2082 | } |
1999 | 2083 | ||
2000 | sc->removable = 1; /* XXX Query this from the device */ | 2084 | nluns = 1; |
2001 | sc->changed = 1; /* ub_revalidate clears only */ | 2085 | for (i = 0; i < 3; i++) { |
2002 | sc->first_open = 1; | 2086 | if ((rc = ub_sync_getmaxlun(sc)) < 0) { |
2087 | /* | ||
2088 | * Some devices (i.e. Iomega Zip100) need this -- | ||
2089 | * apparently the bulk pipes get STALLed when the | ||
2090 | * GetMaxLUN request is processed. | ||
2091 | * XXX I have a ZIP-100, verify it does this. | ||
2092 | */ | ||
2093 | if (rc == -EPIPE) { | ||
2094 | ub_probe_clear_stall(sc, sc->recv_bulk_pipe); | ||
2095 | ub_probe_clear_stall(sc, sc->send_bulk_pipe); | ||
2096 | } | ||
2097 | break; | ||
2098 | } | ||
2099 | if (rc != 0) { | ||
2100 | nluns = rc; | ||
2101 | break; | ||
2102 | } | ||
2103 | mdelay(100); | ||
2104 | } | ||
2003 | 2105 | ||
2004 | ub_revalidate(sc); | 2106 | for (i = 0; i < nluns; i++) { |
2005 | /* This is pretty much a long term P3 */ | 2107 | ub_probe_lun(sc, i); |
2006 | printk(KERN_INFO "%s: device %u capacity nsec %ld bsize %u\n", | 2108 | } |
2007 | sc->name, sc->dev->devnum, sc->capacity.nsec, sc->capacity.bsize); | 2109 | return 0; |
2110 | |||
2111 | /* device_remove_file(&sc->intf->dev, &dev_attr_diag); */ | ||
2112 | err_diag: | ||
2113 | usb_set_intfdata(intf, NULL); | ||
2114 | // usb_put_intf(sc->intf); | ||
2115 | usb_put_dev(sc->dev); | ||
2116 | kfree(sc); | ||
2117 | err_core: | ||
2118 | return rc; | ||
2119 | } | ||
2120 | |||
2121 | static int ub_probe_lun(struct ub_dev *sc, int lnum) | ||
2122 | { | ||
2123 | struct ub_lun *lun; | ||
2124 | request_queue_t *q; | ||
2125 | struct gendisk *disk; | ||
2126 | int rc; | ||
2127 | |||
2128 | rc = -ENOMEM; | ||
2129 | if ((lun = kmalloc(sizeof(struct ub_lun), GFP_KERNEL)) == NULL) | ||
2130 | goto err_alloc; | ||
2131 | memset(lun, 0, sizeof(struct ub_lun)); | ||
2132 | lun->num = lnum; | ||
2133 | |||
2134 | rc = -ENOSR; | ||
2135 | if ((lun->id = ub_id_get()) == -1) | ||
2136 | goto err_id; | ||
2137 | |||
2138 | lun->udev = sc; | ||
2139 | list_add(&lun->link, &sc->luns); | ||
2140 | |||
2141 | snprintf(lun->name, 16, DRV_NAME "%c(%d.%d.%d)", | ||
2142 | lun->id + 'a', sc->dev->bus->busnum, sc->dev->devnum, lun->num); | ||
2143 | |||
2144 | lun->removable = 1; /* XXX Query this from the device */ | ||
2145 | lun->changed = 1; /* ub_revalidate clears only */ | ||
2146 | lun->first_open = 1; | ||
2147 | ub_revalidate(sc, lun); | ||
2008 | 2148 | ||
2009 | /* | ||
2010 | * Just one disk per sc currently, but maybe more. | ||
2011 | */ | ||
2012 | rc = -ENOMEM; | 2149 | rc = -ENOMEM; |
2013 | if ((disk = alloc_disk(UB_MINORS_PER_MAJOR)) == NULL) | 2150 | if ((disk = alloc_disk(UB_MINORS_PER_MAJOR)) == NULL) |
2014 | goto err_diskalloc; | 2151 | goto err_diskalloc; |
2015 | 2152 | ||
2016 | sc->disk = disk; | 2153 | lun->disk = disk; |
2017 | sprintf(disk->disk_name, DRV_NAME "%c", sc->id + 'a'); | 2154 | sprintf(disk->disk_name, DRV_NAME "%c", lun->id + 'a'); |
2018 | sprintf(disk->devfs_name, DEVFS_NAME "/%c", sc->id + 'a'); | 2155 | sprintf(disk->devfs_name, DEVFS_NAME "/%c", lun->id + 'a'); |
2019 | disk->major = UB_MAJOR; | 2156 | disk->major = UB_MAJOR; |
2020 | disk->first_minor = sc->id * UB_MINORS_PER_MAJOR; | 2157 | disk->first_minor = lun->id * UB_MINORS_PER_MAJOR; |
2021 | disk->fops = &ub_bd_fops; | 2158 | disk->fops = &ub_bd_fops; |
2022 | disk->private_data = sc; | 2159 | disk->private_data = lun; |
2023 | disk->driverfs_dev = &intf->dev; | 2160 | disk->driverfs_dev = &sc->intf->dev; /* XXX Many to one ok? */ |
2024 | 2161 | ||
2025 | rc = -ENOMEM; | 2162 | rc = -ENOMEM; |
2026 | if ((q = blk_init_queue(ub_bd_rq_fn, &sc->lock)) == NULL) | 2163 | if ((q = blk_init_queue(ub_bd_rq_fn, &sc->lock)) == NULL) |
@@ -2028,28 +2165,17 @@ static int ub_probe(struct usb_interface *intf, | |||
2028 | 2165 | ||
2029 | disk->queue = q; | 2166 | disk->queue = q; |
2030 | 2167 | ||
2031 | // blk_queue_bounce_limit(q, hba[i]->pdev->dma_mask); | 2168 | blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH); |
2032 | blk_queue_max_hw_segments(q, UB_MAX_REQ_SG); | 2169 | blk_queue_max_hw_segments(q, UB_MAX_REQ_SG); |
2033 | blk_queue_max_phys_segments(q, UB_MAX_REQ_SG); | 2170 | blk_queue_max_phys_segments(q, UB_MAX_REQ_SG); |
2034 | // blk_queue_segment_boundary(q, CARM_SG_BOUNDARY); | 2171 | blk_queue_segment_boundary(q, 0xffffffff); /* Dubious. */ |
2035 | blk_queue_max_sectors(q, UB_MAX_SECTORS); | 2172 | blk_queue_max_sectors(q, UB_MAX_SECTORS); |
2036 | blk_queue_hardsect_size(q, sc->capacity.bsize); | 2173 | blk_queue_hardsect_size(q, lun->capacity.bsize); |
2037 | |||
2038 | /* | ||
2039 | * This is a serious infraction, caused by a deficiency in the | ||
2040 | * USB sg interface (usb_sg_wait()). We plan to remove this once | ||
2041 | * we get mileage on the driver and can justify a change to USB API. | ||
2042 | * See blk_queue_bounce_limit() to understand this part. | ||
2043 | * | ||
2044 | * XXX And I still need to be aware of the DMA mask in the HC. | ||
2045 | */ | ||
2046 | q->bounce_pfn = blk_max_low_pfn; | ||
2047 | q->bounce_gfp = GFP_NOIO; | ||
2048 | 2174 | ||
2049 | q->queuedata = sc; | 2175 | q->queuedata = lun; |
2050 | 2176 | ||
2051 | set_capacity(disk, sc->capacity.nsec); | 2177 | set_capacity(disk, lun->capacity.nsec); |
2052 | if (sc->removable) | 2178 | if (lun->removable) |
2053 | disk->flags |= GENHD_FL_REMOVABLE; | 2179 | disk->flags |= GENHD_FL_REMOVABLE; |
2054 | 2180 | ||
2055 | add_disk(disk); | 2181 | add_disk(disk); |
@@ -2059,22 +2185,20 @@ static int ub_probe(struct usb_interface *intf, | |||
2059 | err_blkqinit: | 2185 | err_blkqinit: |
2060 | put_disk(disk); | 2186 | put_disk(disk); |
2061 | err_diskalloc: | 2187 | err_diskalloc: |
2062 | device_remove_file(&sc->intf->dev, &dev_attr_diag); | 2188 | list_del(&lun->link); |
2063 | err_diag: | 2189 | ub_id_put(lun->id); |
2064 | usb_set_intfdata(intf, NULL); | ||
2065 | // usb_put_intf(sc->intf); | ||
2066 | usb_put_dev(sc->dev); | ||
2067 | ub_id_put(sc->id); | ||
2068 | err_id: | 2190 | err_id: |
2069 | kfree(sc); | 2191 | kfree(lun); |
2070 | err_core: | 2192 | err_alloc: |
2071 | return rc; | 2193 | return rc; |
2072 | } | 2194 | } |
2073 | 2195 | ||
2074 | static void ub_disconnect(struct usb_interface *intf) | 2196 | static void ub_disconnect(struct usb_interface *intf) |
2075 | { | 2197 | { |
2076 | struct ub_dev *sc = usb_get_intfdata(intf); | 2198 | struct ub_dev *sc = usb_get_intfdata(intf); |
2077 | struct gendisk *disk = sc->disk; | 2199 | struct list_head *p; |
2200 | struct ub_lun *lun; | ||
2201 | struct gendisk *disk; | ||
2078 | unsigned long flags; | 2202 | unsigned long flags; |
2079 | 2203 | ||
2080 | /* | 2204 | /* |
@@ -2124,14 +2248,18 @@ static void ub_disconnect(struct usb_interface *intf) | |||
2124 | /* | 2248 | /* |
2125 | * Unregister the upper layer. | 2249 | * Unregister the upper layer. |
2126 | */ | 2250 | */ |
2127 | if (disk->flags & GENHD_FL_UP) | 2251 | list_for_each (p, &sc->luns) { |
2128 | del_gendisk(disk); | 2252 | lun = list_entry(p, struct ub_lun, link); |
2129 | /* | 2253 | disk = lun->disk; |
2130 | * I wish I could do: | 2254 | if (disk->flags & GENHD_FL_UP) |
2131 | * set_bit(QUEUE_FLAG_DEAD, &q->queue_flags); | 2255 | del_gendisk(disk); |
2132 | * As it is, we rely on our internal poisoning and let | 2256 | /* |
2133 | * the upper levels to spin furiously failing all the I/O. | 2257 | * I wish I could do: |
2134 | */ | 2258 | * set_bit(QUEUE_FLAG_DEAD, &q->queue_flags); |
2259 | * As it is, we rely on our internal poisoning and let | ||
2260 | * the upper levels to spin furiously failing all the I/O. | ||
2261 | */ | ||
2262 | } | ||
2135 | 2263 | ||
2136 | /* | 2264 | /* |
2137 | * Taking a lock on a structure which is about to be freed | 2265 | * Taking a lock on a structure which is about to be freed |
@@ -2182,8 +2310,8 @@ static int __init ub_init(void) | |||
2182 | { | 2310 | { |
2183 | int rc; | 2311 | int rc; |
2184 | 2312 | ||
2185 | /* P3 */ printk("ub: sizeof ub_scsi_cmd %zu ub_dev %zu\n", | 2313 | /* P3 */ printk("ub: sizeof ub_scsi_cmd %zu ub_dev %zu ub_lun %zu\n", |
2186 | sizeof(struct ub_scsi_cmd), sizeof(struct ub_dev)); | 2314 | sizeof(struct ub_scsi_cmd), sizeof(struct ub_dev), sizeof(struct ub_lun)); |
2187 | 2315 | ||
2188 | if ((rc = register_blkdev(UB_MAJOR, DRV_NAME)) != 0) | 2316 | if ((rc = register_blkdev(UB_MAJOR, DRV_NAME)) != 0) |
2189 | goto err_regblkdev; | 2317 | goto err_regblkdev; |
diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h index ad9c11391d81..c1fe013c64f3 100644 --- a/drivers/char/agp/agp.h +++ b/drivers/char/agp/agp.h | |||
@@ -278,6 +278,8 @@ void agp3_generic_cleanup(void); | |||
278 | #define AGP_GENERIC_SIZES_ENTRIES 11 | 278 | #define AGP_GENERIC_SIZES_ENTRIES 11 |
279 | extern struct aper_size_info_16 agp3_generic_sizes[]; | 279 | extern struct aper_size_info_16 agp3_generic_sizes[]; |
280 | 280 | ||
281 | #define virt_to_gart(x) (phys_to_gart(virt_to_phys(x))) | ||
282 | #define gart_to_virt(x) (phys_to_virt(gart_to_phys(x))) | ||
281 | 283 | ||
282 | extern int agp_off; | 284 | extern int agp_off; |
283 | extern int agp_try_unsupported_boot; | 285 | extern int agp_try_unsupported_boot; |
diff --git a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c index 0212febda654..9c9c9c2247ce 100644 --- a/drivers/char/agp/ali-agp.c +++ b/drivers/char/agp/ali-agp.c | |||
@@ -150,7 +150,7 @@ static void *m1541_alloc_page(struct agp_bridge_data *bridge) | |||
150 | pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp); | 150 | pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp); |
151 | pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, | 151 | pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, |
152 | (((temp & ALI_CACHE_FLUSH_ADDR_MASK) | | 152 | (((temp & ALI_CACHE_FLUSH_ADDR_MASK) | |
153 | virt_to_phys(addr)) | ALI_CACHE_FLUSH_EN )); | 153 | virt_to_gart(addr)) | ALI_CACHE_FLUSH_EN )); |
154 | return addr; | 154 | return addr; |
155 | } | 155 | } |
156 | 156 | ||
@@ -174,7 +174,7 @@ static void m1541_destroy_page(void * addr) | |||
174 | pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp); | 174 | pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp); |
175 | pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, | 175 | pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, |
176 | (((temp & ALI_CACHE_FLUSH_ADDR_MASK) | | 176 | (((temp & ALI_CACHE_FLUSH_ADDR_MASK) | |
177 | virt_to_phys(addr)) | ALI_CACHE_FLUSH_EN)); | 177 | virt_to_gart(addr)) | ALI_CACHE_FLUSH_EN)); |
178 | agp_generic_destroy_page(addr); | 178 | agp_generic_destroy_page(addr); |
179 | } | 179 | } |
180 | 180 | ||
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c index e62a3c2c44a9..3a41672e4d66 100644 --- a/drivers/char/agp/amd-k7-agp.c +++ b/drivers/char/agp/amd-k7-agp.c | |||
@@ -43,7 +43,7 @@ static int amd_create_page_map(struct amd_page_map *page_map) | |||
43 | 43 | ||
44 | SetPageReserved(virt_to_page(page_map->real)); | 44 | SetPageReserved(virt_to_page(page_map->real)); |
45 | global_cache_flush(); | 45 | global_cache_flush(); |
46 | page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real), | 46 | page_map->remapped = ioremap_nocache(virt_to_gart(page_map->real), |
47 | PAGE_SIZE); | 47 | PAGE_SIZE); |
48 | if (page_map->remapped == NULL) { | 48 | if (page_map->remapped == NULL) { |
49 | ClearPageReserved(virt_to_page(page_map->real)); | 49 | ClearPageReserved(virt_to_page(page_map->real)); |
@@ -154,7 +154,7 @@ static int amd_create_gatt_table(struct agp_bridge_data *bridge) | |||
154 | 154 | ||
155 | agp_bridge->gatt_table_real = (u32 *)page_dir.real; | 155 | agp_bridge->gatt_table_real = (u32 *)page_dir.real; |
156 | agp_bridge->gatt_table = (u32 __iomem *)page_dir.remapped; | 156 | agp_bridge->gatt_table = (u32 __iomem *)page_dir.remapped; |
157 | agp_bridge->gatt_bus_addr = virt_to_phys(page_dir.real); | 157 | agp_bridge->gatt_bus_addr = virt_to_gart(page_dir.real); |
158 | 158 | ||
159 | /* Get the address for the gart region. | 159 | /* Get the address for the gart region. |
160 | * This is a bus address even on the alpha, b/c its | 160 | * This is a bus address even on the alpha, b/c its |
@@ -167,7 +167,7 @@ static int amd_create_gatt_table(struct agp_bridge_data *bridge) | |||
167 | 167 | ||
168 | /* Calculate the agp offset */ | 168 | /* Calculate the agp offset */ |
169 | for (i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) { | 169 | for (i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) { |
170 | writel(virt_to_phys(amd_irongate_private.gatt_pages[i]->real) | 1, | 170 | writel(virt_to_gart(amd_irongate_private.gatt_pages[i]->real) | 1, |
171 | page_dir.remapped+GET_PAGE_DIR_OFF(addr)); | 171 | page_dir.remapped+GET_PAGE_DIR_OFF(addr)); |
172 | readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */ | 172 | readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */ |
173 | } | 173 | } |
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c index 399c042f68f0..1407945a5892 100644 --- a/drivers/char/agp/amd64-agp.c +++ b/drivers/char/agp/amd64-agp.c | |||
@@ -219,7 +219,7 @@ static struct aper_size_info_32 amd_8151_sizes[7] = | |||
219 | 219 | ||
220 | static int amd_8151_configure(void) | 220 | static int amd_8151_configure(void) |
221 | { | 221 | { |
222 | unsigned long gatt_bus = virt_to_phys(agp_bridge->gatt_table_real); | 222 | unsigned long gatt_bus = virt_to_gart(agp_bridge->gatt_table_real); |
223 | 223 | ||
224 | /* Configure AGP regs in each x86-64 host bridge. */ | 224 | /* Configure AGP regs in each x86-64 host bridge. */ |
225 | for_each_nb() { | 225 | for_each_nb() { |
@@ -591,7 +591,7 @@ static void __devexit agp_amd64_remove(struct pci_dev *pdev) | |||
591 | { | 591 | { |
592 | struct agp_bridge_data *bridge = pci_get_drvdata(pdev); | 592 | struct agp_bridge_data *bridge = pci_get_drvdata(pdev); |
593 | 593 | ||
594 | release_mem_region(virt_to_phys(bridge->gatt_table_real), | 594 | release_mem_region(virt_to_gart(bridge->gatt_table_real), |
595 | amd64_aperture_sizes[bridge->aperture_size_idx].size); | 595 | amd64_aperture_sizes[bridge->aperture_size_idx].size); |
596 | agp_remove_bridge(bridge); | 596 | agp_remove_bridge(bridge); |
597 | agp_put_bridge(bridge); | 597 | agp_put_bridge(bridge); |
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c index a65f8827c283..e572ced9100a 100644 --- a/drivers/char/agp/ati-agp.c +++ b/drivers/char/agp/ati-agp.c | |||
@@ -61,7 +61,7 @@ static int ati_create_page_map(ati_page_map *page_map) | |||
61 | 61 | ||
62 | SetPageReserved(virt_to_page(page_map->real)); | 62 | SetPageReserved(virt_to_page(page_map->real)); |
63 | err = map_page_into_agp(virt_to_page(page_map->real)); | 63 | err = map_page_into_agp(virt_to_page(page_map->real)); |
64 | page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real), | 64 | page_map->remapped = ioremap_nocache(virt_to_gart(page_map->real), |
65 | PAGE_SIZE); | 65 | PAGE_SIZE); |
66 | if (page_map->remapped == NULL || err) { | 66 | if (page_map->remapped == NULL || err) { |
67 | ClearPageReserved(virt_to_page(page_map->real)); | 67 | ClearPageReserved(virt_to_page(page_map->real)); |
@@ -343,7 +343,7 @@ static int ati_create_gatt_table(struct agp_bridge_data *bridge) | |||
343 | 343 | ||
344 | agp_bridge->gatt_table_real = (u32 *)page_dir.real; | 344 | agp_bridge->gatt_table_real = (u32 *)page_dir.real; |
345 | agp_bridge->gatt_table = (u32 __iomem *) page_dir.remapped; | 345 | agp_bridge->gatt_table = (u32 __iomem *) page_dir.remapped; |
346 | agp_bridge->gatt_bus_addr = virt_to_bus(page_dir.real); | 346 | agp_bridge->gatt_bus_addr = virt_to_gart(page_dir.real); |
347 | 347 | ||
348 | /* Write out the size register */ | 348 | /* Write out the size register */ |
349 | current_size = A_SIZE_LVL2(agp_bridge->current_size); | 349 | current_size = A_SIZE_LVL2(agp_bridge->current_size); |
@@ -373,7 +373,7 @@ static int ati_create_gatt_table(struct agp_bridge_data *bridge) | |||
373 | 373 | ||
374 | /* Calculate the agp offset */ | 374 | /* Calculate the agp offset */ |
375 | for(i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) { | 375 | for(i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) { |
376 | writel(virt_to_bus(ati_generic_private.gatt_pages[i]->real) | 1, | 376 | writel(virt_to_gart(ati_generic_private.gatt_pages[i]->real) | 1, |
377 | page_dir.remapped+GET_PAGE_DIR_OFF(addr)); | 377 | page_dir.remapped+GET_PAGE_DIR_OFF(addr)); |
378 | readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */ | 378 | readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */ |
379 | } | 379 | } |
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c index 2f3dfb63bdc6..4d4e602fdc7e 100644 --- a/drivers/char/agp/backend.c +++ b/drivers/char/agp/backend.c | |||
@@ -148,7 +148,7 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge) | |||
148 | return -ENOMEM; | 148 | return -ENOMEM; |
149 | } | 149 | } |
150 | 150 | ||
151 | bridge->scratch_page_real = virt_to_phys(addr); | 151 | bridge->scratch_page_real = virt_to_gart(addr); |
152 | bridge->scratch_page = | 152 | bridge->scratch_page = |
153 | bridge->driver->mask_memory(bridge, bridge->scratch_page_real, 0); | 153 | bridge->driver->mask_memory(bridge, bridge->scratch_page_real, 0); |
154 | } | 154 | } |
@@ -189,7 +189,7 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge) | |||
189 | err_out: | 189 | err_out: |
190 | if (bridge->driver->needs_scratch_page) | 190 | if (bridge->driver->needs_scratch_page) |
191 | bridge->driver->agp_destroy_page( | 191 | bridge->driver->agp_destroy_page( |
192 | phys_to_virt(bridge->scratch_page_real)); | 192 | gart_to_virt(bridge->scratch_page_real)); |
193 | if (got_gatt) | 193 | if (got_gatt) |
194 | bridge->driver->free_gatt_table(bridge); | 194 | bridge->driver->free_gatt_table(bridge); |
195 | if (got_keylist) { | 195 | if (got_keylist) { |
@@ -214,7 +214,7 @@ static void agp_backend_cleanup(struct agp_bridge_data *bridge) | |||
214 | if (bridge->driver->agp_destroy_page && | 214 | if (bridge->driver->agp_destroy_page && |
215 | bridge->driver->needs_scratch_page) | 215 | bridge->driver->needs_scratch_page) |
216 | bridge->driver->agp_destroy_page( | 216 | bridge->driver->agp_destroy_page( |
217 | phys_to_virt(bridge->scratch_page_real)); | 217 | gart_to_virt(bridge->scratch_page_real)); |
218 | } | 218 | } |
219 | 219 | ||
220 | /* When we remove the global variable agp_bridge from all drivers | 220 | /* When we remove the global variable agp_bridge from all drivers |
diff --git a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c index 1383c3165ea1..ac19fdcd21c1 100644 --- a/drivers/char/agp/efficeon-agp.c +++ b/drivers/char/agp/efficeon-agp.c | |||
@@ -219,7 +219,7 @@ static int efficeon_create_gatt_table(struct agp_bridge_data *bridge) | |||
219 | 219 | ||
220 | efficeon_private.l1_table[index] = page; | 220 | efficeon_private.l1_table[index] = page; |
221 | 221 | ||
222 | value = __pa(page) | pati | present | index; | 222 | value = virt_to_gart(page) | pati | present | index; |
223 | 223 | ||
224 | pci_write_config_dword(agp_bridge->dev, | 224 | pci_write_config_dword(agp_bridge->dev, |
225 | EFFICEON_ATTPAGE, value); | 225 | EFFICEON_ATTPAGE, value); |
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c index c321a924e38a..f0079e991bdc 100644 --- a/drivers/char/agp/generic.c +++ b/drivers/char/agp/generic.c | |||
@@ -153,7 +153,7 @@ void agp_free_memory(struct agp_memory *curr) | |||
153 | } | 153 | } |
154 | if (curr->page_count != 0) { | 154 | if (curr->page_count != 0) { |
155 | for (i = 0; i < curr->page_count; i++) { | 155 | for (i = 0; i < curr->page_count; i++) { |
156 | curr->bridge->driver->agp_destroy_page(phys_to_virt(curr->memory[i])); | 156 | curr->bridge->driver->agp_destroy_page(gart_to_virt(curr->memory[i])); |
157 | } | 157 | } |
158 | } | 158 | } |
159 | agp_free_key(curr->key); | 159 | agp_free_key(curr->key); |
@@ -209,7 +209,7 @@ struct agp_memory *agp_allocate_memory(struct agp_bridge_data *bridge, | |||
209 | agp_free_memory(new); | 209 | agp_free_memory(new); |
210 | return NULL; | 210 | return NULL; |
211 | } | 211 | } |
212 | new->memory[i] = virt_to_phys(addr); | 212 | new->memory[i] = virt_to_gart(addr); |
213 | new->page_count++; | 213 | new->page_count++; |
214 | } | 214 | } |
215 | new->bridge = bridge; | 215 | new->bridge = bridge; |
@@ -295,19 +295,6 @@ int agp_num_entries(void) | |||
295 | EXPORT_SYMBOL_GPL(agp_num_entries); | 295 | EXPORT_SYMBOL_GPL(agp_num_entries); |
296 | 296 | ||
297 | 297 | ||
298 | static int check_bridge_mode(struct pci_dev *dev) | ||
299 | { | ||
300 | u32 agp3; | ||
301 | u8 cap_ptr; | ||
302 | |||
303 | cap_ptr = pci_find_capability(dev, PCI_CAP_ID_AGP); | ||
304 | pci_read_config_dword(dev, cap_ptr+AGPSTAT, &agp3); | ||
305 | if (agp3 & AGPSTAT_MODE_3_0) | ||
306 | return 1; | ||
307 | return 0; | ||
308 | } | ||
309 | |||
310 | |||
311 | /** | 298 | /** |
312 | * agp_copy_info - copy bridge state information | 299 | * agp_copy_info - copy bridge state information |
313 | * | 300 | * |
@@ -328,7 +315,7 @@ int agp_copy_info(struct agp_bridge_data *bridge, struct agp_kern_info *info) | |||
328 | info->version.minor = bridge->version->minor; | 315 | info->version.minor = bridge->version->minor; |
329 | info->chipset = SUPPORTED; | 316 | info->chipset = SUPPORTED; |
330 | info->device = bridge->dev; | 317 | info->device = bridge->dev; |
331 | if (check_bridge_mode(bridge->dev)) | 318 | if (bridge->mode & AGPSTAT_MODE_3_0) |
332 | info->mode = bridge->mode & ~AGP3_RESERVED_MASK; | 319 | info->mode = bridge->mode & ~AGP3_RESERVED_MASK; |
333 | else | 320 | else |
334 | info->mode = bridge->mode & ~AGP2_RESERVED_MASK; | 321 | info->mode = bridge->mode & ~AGP2_RESERVED_MASK; |
@@ -661,7 +648,7 @@ u32 agp_collect_device_status(struct agp_bridge_data *bridge, u32 requested_mode | |||
661 | bridge_agpstat &= ~AGPSTAT_FW; | 648 | bridge_agpstat &= ~AGPSTAT_FW; |
662 | 649 | ||
663 | /* Check to see if we are operating in 3.0 mode */ | 650 | /* Check to see if we are operating in 3.0 mode */ |
664 | if (check_bridge_mode(agp_bridge->dev)) | 651 | if (agp_bridge->mode & AGPSTAT_MODE_3_0) |
665 | agp_v3_parse_one(&requested_mode, &bridge_agpstat, &vga_agpstat); | 652 | agp_v3_parse_one(&requested_mode, &bridge_agpstat, &vga_agpstat); |
666 | else | 653 | else |
667 | agp_v2_parse_one(&requested_mode, &bridge_agpstat, &vga_agpstat); | 654 | agp_v2_parse_one(&requested_mode, &bridge_agpstat, &vga_agpstat); |
@@ -732,7 +719,7 @@ void agp_generic_enable(struct agp_bridge_data *bridge, u32 requested_mode) | |||
732 | 719 | ||
733 | /* Do AGP version specific frobbing. */ | 720 | /* Do AGP version specific frobbing. */ |
734 | if (bridge->major_version >= 3) { | 721 | if (bridge->major_version >= 3) { |
735 | if (check_bridge_mode(bridge->dev)) { | 722 | if (bridge->mode & AGPSTAT_MODE_3_0) { |
736 | /* If we have 3.5, we can do the isoch stuff. */ | 723 | /* If we have 3.5, we can do the isoch stuff. */ |
737 | if (bridge->minor_version >= 5) | 724 | if (bridge->minor_version >= 5) |
738 | agp_3_5_enable(bridge); | 725 | agp_3_5_enable(bridge); |
@@ -806,8 +793,7 @@ int agp_generic_create_gatt_table(struct agp_bridge_data *bridge) | |||
806 | break; | 793 | break; |
807 | } | 794 | } |
808 | 795 | ||
809 | table = (char *) __get_free_pages(GFP_KERNEL, | 796 | table = alloc_gatt_pages(page_order); |
810 | page_order); | ||
811 | 797 | ||
812 | if (table == NULL) { | 798 | if (table == NULL) { |
813 | i++; | 799 | i++; |
@@ -838,7 +824,7 @@ int agp_generic_create_gatt_table(struct agp_bridge_data *bridge) | |||
838 | size = ((struct aper_size_info_fixed *) temp)->size; | 824 | size = ((struct aper_size_info_fixed *) temp)->size; |
839 | page_order = ((struct aper_size_info_fixed *) temp)->page_order; | 825 | page_order = ((struct aper_size_info_fixed *) temp)->page_order; |
840 | num_entries = ((struct aper_size_info_fixed *) temp)->num_entries; | 826 | num_entries = ((struct aper_size_info_fixed *) temp)->num_entries; |
841 | table = (char *) __get_free_pages(GFP_KERNEL, page_order); | 827 | table = alloc_gatt_pages(page_order); |
842 | } | 828 | } |
843 | 829 | ||
844 | if (table == NULL) | 830 | if (table == NULL) |
@@ -853,7 +839,7 @@ int agp_generic_create_gatt_table(struct agp_bridge_data *bridge) | |||
853 | agp_gatt_table = (void *)table; | 839 | agp_gatt_table = (void *)table; |
854 | 840 | ||
855 | bridge->driver->cache_flush(); | 841 | bridge->driver->cache_flush(); |
856 | bridge->gatt_table = ioremap_nocache(virt_to_phys(table), | 842 | bridge->gatt_table = ioremap_nocache(virt_to_gart(table), |
857 | (PAGE_SIZE * (1 << page_order))); | 843 | (PAGE_SIZE * (1 << page_order))); |
858 | bridge->driver->cache_flush(); | 844 | bridge->driver->cache_flush(); |
859 | 845 | ||
@@ -861,11 +847,11 @@ int agp_generic_create_gatt_table(struct agp_bridge_data *bridge) | |||
861 | for (page = virt_to_page(table); page <= virt_to_page(table_end); page++) | 847 | for (page = virt_to_page(table); page <= virt_to_page(table_end); page++) |
862 | ClearPageReserved(page); | 848 | ClearPageReserved(page); |
863 | 849 | ||
864 | free_pages((unsigned long) table, page_order); | 850 | free_gatt_pages(table, page_order); |
865 | 851 | ||
866 | return -ENOMEM; | 852 | return -ENOMEM; |
867 | } | 853 | } |
868 | bridge->gatt_bus_addr = virt_to_phys(bridge->gatt_table_real); | 854 | bridge->gatt_bus_addr = virt_to_gart(bridge->gatt_table_real); |
869 | 855 | ||
870 | /* AK: bogus, should encode addresses > 4GB */ | 856 | /* AK: bogus, should encode addresses > 4GB */ |
871 | for (i = 0; i < num_entries; i++) { | 857 | for (i = 0; i < num_entries; i++) { |
@@ -919,7 +905,7 @@ int agp_generic_free_gatt_table(struct agp_bridge_data *bridge) | |||
919 | for (page = virt_to_page(table); page <= virt_to_page(table_end); page++) | 905 | for (page = virt_to_page(table); page <= virt_to_page(table_end); page++) |
920 | ClearPageReserved(page); | 906 | ClearPageReserved(page); |
921 | 907 | ||
922 | free_pages((unsigned long) bridge->gatt_table_real, page_order); | 908 | free_gatt_pages(bridge->gatt_table_real, page_order); |
923 | 909 | ||
924 | agp_gatt_table = NULL; | 910 | agp_gatt_table = NULL; |
925 | bridge->gatt_table = NULL; | 911 | bridge->gatt_table = NULL; |
diff --git a/drivers/char/agp/hp-agp.c b/drivers/char/agp/hp-agp.c index 6052bfa04c72..99762b6c19ae 100644 --- a/drivers/char/agp/hp-agp.c +++ b/drivers/char/agp/hp-agp.c | |||
@@ -110,7 +110,7 @@ static int __init hp_zx1_ioc_shared(void) | |||
110 | hp->gart_size = HP_ZX1_GART_SIZE; | 110 | hp->gart_size = HP_ZX1_GART_SIZE; |
111 | hp->gatt_entries = hp->gart_size / hp->io_page_size; | 111 | hp->gatt_entries = hp->gart_size / hp->io_page_size; |
112 | 112 | ||
113 | hp->io_pdir = phys_to_virt(readq(hp->ioc_regs+HP_ZX1_PDIR_BASE)); | 113 | hp->io_pdir = gart_to_virt(readq(hp->ioc_regs+HP_ZX1_PDIR_BASE)); |
114 | hp->gatt = &hp->io_pdir[HP_ZX1_IOVA_TO_PDIR(hp->gart_base)]; | 114 | hp->gatt = &hp->io_pdir[HP_ZX1_IOVA_TO_PDIR(hp->gart_base)]; |
115 | 115 | ||
116 | if (hp->gatt[0] != HP_ZX1_SBA_IOMMU_COOKIE) { | 116 | if (hp->gatt[0] != HP_ZX1_SBA_IOMMU_COOKIE) { |
@@ -248,7 +248,7 @@ hp_zx1_configure (void) | |||
248 | agp_bridge->mode = readl(hp->lba_regs+hp->lba_cap_offset+PCI_AGP_STATUS); | 248 | agp_bridge->mode = readl(hp->lba_regs+hp->lba_cap_offset+PCI_AGP_STATUS); |
249 | 249 | ||
250 | if (hp->io_pdir_owner) { | 250 | if (hp->io_pdir_owner) { |
251 | writel(virt_to_phys(hp->io_pdir), hp->ioc_regs+HP_ZX1_PDIR_BASE); | 251 | writel(virt_to_gart(hp->io_pdir), hp->ioc_regs+HP_ZX1_PDIR_BASE); |
252 | readl(hp->ioc_regs+HP_ZX1_PDIR_BASE); | 252 | readl(hp->ioc_regs+HP_ZX1_PDIR_BASE); |
253 | writel(hp->io_tlb_ps, hp->ioc_regs+HP_ZX1_TCNFG); | 253 | writel(hp->io_tlb_ps, hp->ioc_regs+HP_ZX1_TCNFG); |
254 | readl(hp->ioc_regs+HP_ZX1_TCNFG); | 254 | readl(hp->ioc_regs+HP_ZX1_TCNFG); |
diff --git a/drivers/char/agp/i460-agp.c b/drivers/char/agp/i460-agp.c index adbea896c0d2..94943298c03e 100644 --- a/drivers/char/agp/i460-agp.c +++ b/drivers/char/agp/i460-agp.c | |||
@@ -372,7 +372,7 @@ static int i460_alloc_large_page (struct lp_desc *lp) | |||
372 | } | 372 | } |
373 | memset(lp->alloced_map, 0, map_size); | 373 | memset(lp->alloced_map, 0, map_size); |
374 | 374 | ||
375 | lp->paddr = virt_to_phys(lpage); | 375 | lp->paddr = virt_to_gart(lpage); |
376 | lp->refcount = 0; | 376 | lp->refcount = 0; |
377 | atomic_add(I460_KPAGES_PER_IOPAGE, &agp_bridge->current_memory_agp); | 377 | atomic_add(I460_KPAGES_PER_IOPAGE, &agp_bridge->current_memory_agp); |
378 | return 0; | 378 | return 0; |
@@ -383,7 +383,7 @@ static void i460_free_large_page (struct lp_desc *lp) | |||
383 | kfree(lp->alloced_map); | 383 | kfree(lp->alloced_map); |
384 | lp->alloced_map = NULL; | 384 | lp->alloced_map = NULL; |
385 | 385 | ||
386 | free_pages((unsigned long) phys_to_virt(lp->paddr), I460_IO_PAGE_SHIFT - PAGE_SHIFT); | 386 | free_pages((unsigned long) gart_to_virt(lp->paddr), I460_IO_PAGE_SHIFT - PAGE_SHIFT); |
387 | atomic_sub(I460_KPAGES_PER_IOPAGE, &agp_bridge->current_memory_agp); | 387 | atomic_sub(I460_KPAGES_PER_IOPAGE, &agp_bridge->current_memory_agp); |
388 | } | 388 | } |
389 | 389 | ||
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c index 8c7d727432bb..51266d6b4d78 100644 --- a/drivers/char/agp/intel-agp.c +++ b/drivers/char/agp/intel-agp.c | |||
@@ -286,7 +286,7 @@ static struct agp_memory *alloc_agpphysmem_i8xx(size_t pg_count, int type) | |||
286 | if (new == NULL) | 286 | if (new == NULL) |
287 | return NULL; | 287 | return NULL; |
288 | 288 | ||
289 | new->memory[0] = virt_to_phys(addr); | 289 | new->memory[0] = virt_to_gart(addr); |
290 | if (pg_count == 4) { | 290 | if (pg_count == 4) { |
291 | /* kludge to get 4 physical pages for ARGB cursor */ | 291 | /* kludge to get 4 physical pages for ARGB cursor */ |
292 | new->memory[1] = new->memory[0] + PAGE_SIZE; | 292 | new->memory[1] = new->memory[0] + PAGE_SIZE; |
@@ -329,10 +329,10 @@ static void intel_i810_free_by_type(struct agp_memory *curr) | |||
329 | agp_free_key(curr->key); | 329 | agp_free_key(curr->key); |
330 | if(curr->type == AGP_PHYS_MEMORY) { | 330 | if(curr->type == AGP_PHYS_MEMORY) { |
331 | if (curr->page_count == 4) | 331 | if (curr->page_count == 4) |
332 | i8xx_destroy_pages(phys_to_virt(curr->memory[0])); | 332 | i8xx_destroy_pages(gart_to_virt(curr->memory[0])); |
333 | else | 333 | else |
334 | agp_bridge->driver->agp_destroy_page( | 334 | agp_bridge->driver->agp_destroy_page( |
335 | phys_to_virt(curr->memory[0])); | 335 | gart_to_virt(curr->memory[0])); |
336 | vfree(curr->memory); | 336 | vfree(curr->memory); |
337 | } | 337 | } |
338 | kfree(curr); | 338 | kfree(curr); |
@@ -418,7 +418,8 @@ static void intel_i830_init_gtt_entries(void) | |||
418 | case I915_GMCH_GMS_STOLEN_48M: | 418 | case I915_GMCH_GMS_STOLEN_48M: |
419 | /* Check it's really I915G */ | 419 | /* Check it's really I915G */ |
420 | if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || | 420 | if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || |
421 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB) | 421 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || |
422 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB) | ||
422 | gtt_entries = MB(48) - KB(size); | 423 | gtt_entries = MB(48) - KB(size); |
423 | else | 424 | else |
424 | gtt_entries = 0; | 425 | gtt_entries = 0; |
@@ -426,7 +427,8 @@ static void intel_i830_init_gtt_entries(void) | |||
426 | case I915_GMCH_GMS_STOLEN_64M: | 427 | case I915_GMCH_GMS_STOLEN_64M: |
427 | /* Check it's really I915G */ | 428 | /* Check it's really I915G */ |
428 | if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || | 429 | if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || |
429 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB) | 430 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || |
431 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB) | ||
430 | gtt_entries = MB(64) - KB(size); | 432 | gtt_entries = MB(64) - KB(size); |
431 | else | 433 | else |
432 | gtt_entries = 0; | 434 | gtt_entries = 0; |
@@ -1662,6 +1664,14 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev, | |||
1662 | } | 1664 | } |
1663 | name = "915GM"; | 1665 | name = "915GM"; |
1664 | break; | 1666 | break; |
1667 | case PCI_DEVICE_ID_INTEL_82945G_HB: | ||
1668 | if (find_i830(PCI_DEVICE_ID_INTEL_82945G_IG)) { | ||
1669 | bridge->driver = &intel_915_driver; | ||
1670 | } else { | ||
1671 | bridge->driver = &intel_845_driver; | ||
1672 | } | ||
1673 | name = "945G"; | ||
1674 | break; | ||
1665 | case PCI_DEVICE_ID_INTEL_7505_0: | 1675 | case PCI_DEVICE_ID_INTEL_7505_0: |
1666 | bridge->driver = &intel_7505_driver; | 1676 | bridge->driver = &intel_7505_driver; |
1667 | name = "E7505"; | 1677 | name = "E7505"; |
@@ -1801,6 +1811,7 @@ static struct pci_device_id agp_intel_pci_table[] = { | |||
1801 | ID(PCI_DEVICE_ID_INTEL_7205_0), | 1811 | ID(PCI_DEVICE_ID_INTEL_7205_0), |
1802 | ID(PCI_DEVICE_ID_INTEL_82915G_HB), | 1812 | ID(PCI_DEVICE_ID_INTEL_82915G_HB), |
1803 | ID(PCI_DEVICE_ID_INTEL_82915GM_HB), | 1813 | ID(PCI_DEVICE_ID_INTEL_82915GM_HB), |
1814 | ID(PCI_DEVICE_ID_INTEL_82945G_HB), | ||
1804 | { } | 1815 | { } |
1805 | }; | 1816 | }; |
1806 | 1817 | ||
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c index 4b3eda267976..d3aa159c9dec 100644 --- a/drivers/char/agp/sgi-agp.c +++ b/drivers/char/agp/sgi-agp.c | |||
@@ -133,11 +133,14 @@ static int sgi_tioca_insert_memory(struct agp_memory *mem, off_t pg_start, | |||
133 | off_t j; | 133 | off_t j; |
134 | void *temp; | 134 | void *temp; |
135 | struct agp_bridge_data *bridge; | 135 | struct agp_bridge_data *bridge; |
136 | u64 *table; | ||
136 | 137 | ||
137 | bridge = mem->bridge; | 138 | bridge = mem->bridge; |
138 | if (!bridge) | 139 | if (!bridge) |
139 | return -EINVAL; | 140 | return -EINVAL; |
140 | 141 | ||
142 | table = (u64 *)bridge->gatt_table; | ||
143 | |||
141 | temp = bridge->current_size; | 144 | temp = bridge->current_size; |
142 | 145 | ||
143 | switch (bridge->driver->size_type) { | 146 | switch (bridge->driver->size_type) { |
@@ -175,7 +178,7 @@ static int sgi_tioca_insert_memory(struct agp_memory *mem, off_t pg_start, | |||
175 | j = pg_start; | 178 | j = pg_start; |
176 | 179 | ||
177 | while (j < (pg_start + mem->page_count)) { | 180 | while (j < (pg_start + mem->page_count)) { |
178 | if (*(bridge->gatt_table + j)) | 181 | if (table[j]) |
179 | return -EBUSY; | 182 | return -EBUSY; |
180 | j++; | 183 | j++; |
181 | } | 184 | } |
@@ -186,7 +189,7 @@ static int sgi_tioca_insert_memory(struct agp_memory *mem, off_t pg_start, | |||
186 | } | 189 | } |
187 | 190 | ||
188 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | 191 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { |
189 | *(bridge->gatt_table + j) = | 192 | table[j] = |
190 | bridge->driver->mask_memory(bridge, mem->memory[i], | 193 | bridge->driver->mask_memory(bridge, mem->memory[i], |
191 | mem->type); | 194 | mem->type); |
192 | } | 195 | } |
@@ -200,6 +203,7 @@ static int sgi_tioca_remove_memory(struct agp_memory *mem, off_t pg_start, | |||
200 | { | 203 | { |
201 | size_t i; | 204 | size_t i; |
202 | struct agp_bridge_data *bridge; | 205 | struct agp_bridge_data *bridge; |
206 | u64 *table; | ||
203 | 207 | ||
204 | bridge = mem->bridge; | 208 | bridge = mem->bridge; |
205 | if (!bridge) | 209 | if (!bridge) |
@@ -209,8 +213,10 @@ static int sgi_tioca_remove_memory(struct agp_memory *mem, off_t pg_start, | |||
209 | return -EINVAL; | 213 | return -EINVAL; |
210 | } | 214 | } |
211 | 215 | ||
216 | table = (u64 *)bridge->gatt_table; | ||
217 | |||
212 | for (i = pg_start; i < (mem->page_count + pg_start); i++) { | 218 | for (i = pg_start; i < (mem->page_count + pg_start); i++) { |
213 | *(bridge->gatt_table + i) = 0; | 219 | table[i] = 0; |
214 | } | 220 | } |
215 | 221 | ||
216 | bridge->driver->tlb_flush(mem); | 222 | bridge->driver->tlb_flush(mem); |
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c index 10c23302dd84..a9fb12c20eb7 100644 --- a/drivers/char/agp/sworks-agp.c +++ b/drivers/char/agp/sworks-agp.c | |||
@@ -51,7 +51,7 @@ static int serverworks_create_page_map(struct serverworks_page_map *page_map) | |||
51 | } | 51 | } |
52 | SetPageReserved(virt_to_page(page_map->real)); | 52 | SetPageReserved(virt_to_page(page_map->real)); |
53 | global_cache_flush(); | 53 | global_cache_flush(); |
54 | page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real), | 54 | page_map->remapped = ioremap_nocache(virt_to_gart(page_map->real), |
55 | PAGE_SIZE); | 55 | PAGE_SIZE); |
56 | if (page_map->remapped == NULL) { | 56 | if (page_map->remapped == NULL) { |
57 | ClearPageReserved(virt_to_page(page_map->real)); | 57 | ClearPageReserved(virt_to_page(page_map->real)); |
@@ -162,7 +162,7 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge) | |||
162 | /* Create a fake scratch directory */ | 162 | /* Create a fake scratch directory */ |
163 | for(i = 0; i < 1024; i++) { | 163 | for(i = 0; i < 1024; i++) { |
164 | writel(agp_bridge->scratch_page, serverworks_private.scratch_dir.remapped+i); | 164 | writel(agp_bridge->scratch_page, serverworks_private.scratch_dir.remapped+i); |
165 | writel(virt_to_phys(serverworks_private.scratch_dir.real) | 1, page_dir.remapped+i); | 165 | writel(virt_to_gart(serverworks_private.scratch_dir.real) | 1, page_dir.remapped+i); |
166 | } | 166 | } |
167 | 167 | ||
168 | retval = serverworks_create_gatt_pages(value->num_entries / 1024); | 168 | retval = serverworks_create_gatt_pages(value->num_entries / 1024); |
@@ -174,7 +174,7 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge) | |||
174 | 174 | ||
175 | agp_bridge->gatt_table_real = (u32 *)page_dir.real; | 175 | agp_bridge->gatt_table_real = (u32 *)page_dir.real; |
176 | agp_bridge->gatt_table = (u32 __iomem *)page_dir.remapped; | 176 | agp_bridge->gatt_table = (u32 __iomem *)page_dir.remapped; |
177 | agp_bridge->gatt_bus_addr = virt_to_phys(page_dir.real); | 177 | agp_bridge->gatt_bus_addr = virt_to_gart(page_dir.real); |
178 | 178 | ||
179 | /* Get the address for the gart region. | 179 | /* Get the address for the gart region. |
180 | * This is a bus address even on the alpha, b/c its | 180 | * This is a bus address even on the alpha, b/c its |
@@ -187,7 +187,7 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge) | |||
187 | /* Calculate the agp offset */ | 187 | /* Calculate the agp offset */ |
188 | 188 | ||
189 | for(i = 0; i < value->num_entries / 1024; i++) | 189 | for(i = 0; i < value->num_entries / 1024; i++) |
190 | writel(virt_to_phys(serverworks_private.gatt_pages[i]->real)|1, page_dir.remapped+i); | 190 | writel(virt_to_gart(serverworks_private.gatt_pages[i]->real)|1, page_dir.remapped+i); |
191 | 191 | ||
192 | return 0; | 192 | return 0; |
193 | } | 193 | } |
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c index a673971f2a90..c8255312b8c1 100644 --- a/drivers/char/agp/uninorth-agp.c +++ b/drivers/char/agp/uninorth-agp.c | |||
@@ -407,7 +407,7 @@ static int uninorth_create_gatt_table(struct agp_bridge_data *bridge) | |||
407 | 407 | ||
408 | bridge->gatt_table_real = (u32 *) table; | 408 | bridge->gatt_table_real = (u32 *) table; |
409 | bridge->gatt_table = (u32 *)table; | 409 | bridge->gatt_table = (u32 *)table; |
410 | bridge->gatt_bus_addr = virt_to_phys(table); | 410 | bridge->gatt_bus_addr = virt_to_gart(table); |
411 | 411 | ||
412 | for (i = 0; i < num_entries; i++) | 412 | for (i = 0; i < num_entries; i++) |
413 | bridge->gatt_table[i] = 0; | 413 | bridge->gatt_table[i] = 0; |
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index 7a245068e3e5..f022f0944434 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c | |||
@@ -1995,9 +1995,6 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status) | |||
1995 | unsigned char ch, gdl; | 1995 | unsigned char ch, gdl; |
1996 | int ignored = 0; | 1996 | int ignored = 0; |
1997 | int cnt = 0; | 1997 | int cnt = 0; |
1998 | unsigned char *cp; | ||
1999 | char *fp; | ||
2000 | int count; | ||
2001 | int recv_room; | 1998 | int recv_room; |
2002 | int max = 256; | 1999 | int max = 256; |
2003 | unsigned long flags; | 2000 | unsigned long flags; |
@@ -2011,10 +2008,6 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status) | |||
2011 | //return; | 2008 | //return; |
2012 | } | 2009 | } |
2013 | 2010 | ||
2014 | cp = tty->flip.char_buf; | ||
2015 | fp = tty->flip.flag_buf; | ||
2016 | count = 0; | ||
2017 | |||
2018 | // following add by Victor Yu. 09-02-2002 | 2011 | // following add by Victor Yu. 09-02-2002 |
2019 | if (info->IsMoxaMustChipFlag != MOXA_OTHER_UART) { | 2012 | if (info->IsMoxaMustChipFlag != MOXA_OTHER_UART) { |
2020 | 2013 | ||
@@ -2041,12 +2034,10 @@ static void mxser_receive_chars(struct mxser_struct *info, int *status) | |||
2041 | } | 2034 | } |
2042 | while (gdl--) { | 2035 | while (gdl--) { |
2043 | ch = inb(info->base + UART_RX); | 2036 | ch = inb(info->base + UART_RX); |
2044 | count++; | 2037 | tty_insert_flip_char(tty, ch, 0); |
2045 | *cp++ = ch; | ||
2046 | *fp++ = 0; | ||
2047 | cnt++; | 2038 | cnt++; |
2048 | /* | 2039 | /* |
2049 | if((count>=HI_WATER) && (info->stop_rx==0)){ | 2040 | if((cnt>=HI_WATER) && (info->stop_rx==0)){ |
2050 | mxser_stoprx(tty); | 2041 | mxser_stoprx(tty); |
2051 | info->stop_rx=1; | 2042 | info->stop_rx=1; |
2052 | break; | 2043 | break; |
@@ -2061,7 +2052,7 @@ intr_old: | |||
2061 | if (max-- < 0) | 2052 | if (max-- < 0) |
2062 | break; | 2053 | break; |
2063 | /* | 2054 | /* |
2064 | if((count>=HI_WATER) && (info->stop_rx==0)){ | 2055 | if((cnt>=HI_WATER) && (info->stop_rx==0)){ |
2065 | mxser_stoprx(tty); | 2056 | mxser_stoprx(tty); |
2066 | info->stop_rx=1; | 2057 | info->stop_rx=1; |
2067 | break; | 2058 | break; |
@@ -2078,36 +2069,33 @@ intr_old: | |||
2078 | if (++ignored > 100) | 2069 | if (++ignored > 100) |
2079 | break; | 2070 | break; |
2080 | } else { | 2071 | } else { |
2081 | count++; | 2072 | char flag = 0; |
2082 | if (*status & UART_LSR_SPECIAL) { | 2073 | if (*status & UART_LSR_SPECIAL) { |
2083 | if (*status & UART_LSR_BI) { | 2074 | if (*status & UART_LSR_BI) { |
2084 | *fp++ = TTY_BREAK; | 2075 | flag = TTY_BREAK; |
2085 | /* added by casper 1/11/2000 */ | 2076 | /* added by casper 1/11/2000 */ |
2086 | info->icount.brk++; | 2077 | info->icount.brk++; |
2087 | |||
2088 | /* */ | 2078 | /* */ |
2089 | if (info->flags & ASYNC_SAK) | 2079 | if (info->flags & ASYNC_SAK) |
2090 | do_SAK(tty); | 2080 | do_SAK(tty); |
2091 | } else if (*status & UART_LSR_PE) { | 2081 | } else if (*status & UART_LSR_PE) { |
2092 | *fp++ = TTY_PARITY; | 2082 | flag = TTY_PARITY; |
2093 | /* added by casper 1/11/2000 */ | 2083 | /* added by casper 1/11/2000 */ |
2094 | info->icount.parity++; | 2084 | info->icount.parity++; |
2095 | /* */ | 2085 | /* */ |
2096 | } else if (*status & UART_LSR_FE) { | 2086 | } else if (*status & UART_LSR_FE) { |
2097 | *fp++ = TTY_FRAME; | 2087 | flag = TTY_FRAME; |
2098 | /* added by casper 1/11/2000 */ | 2088 | /* added by casper 1/11/2000 */ |
2099 | info->icount.frame++; | 2089 | info->icount.frame++; |
2100 | /* */ | 2090 | /* */ |
2101 | } else if (*status & UART_LSR_OE) { | 2091 | } else if (*status & UART_LSR_OE) { |
2102 | *fp++ = TTY_OVERRUN; | 2092 | flag = TTY_OVERRUN; |
2103 | /* added by casper 1/11/2000 */ | 2093 | /* added by casper 1/11/2000 */ |
2104 | info->icount.overrun++; | 2094 | info->icount.overrun++; |
2105 | /* */ | 2095 | /* */ |
2106 | } else | 2096 | } |
2107 | *fp++ = 0; | 2097 | } |
2108 | } else | 2098 | tty_insert_flip_char(tty, ch, flag); |
2109 | *fp++ = 0; | ||
2110 | *cp++ = ch; | ||
2111 | cnt++; | 2099 | cnt++; |
2112 | if (cnt >= recv_room) { | 2100 | if (cnt >= recv_room) { |
2113 | if (!info->ldisc_stop_rx) { | 2101 | if (!info->ldisc_stop_rx) { |
@@ -2132,13 +2120,13 @@ intr_old: | |||
2132 | // above add by Victor Yu. 09-02-2002 | 2120 | // above add by Victor Yu. 09-02-2002 |
2133 | } while (*status & UART_LSR_DR); | 2121 | } while (*status & UART_LSR_DR); |
2134 | 2122 | ||
2135 | end_intr: // add by Victor Yu. 09-02-2002 | 2123 | end_intr: // add by Victor Yu. 09-02-2002 |
2136 | 2124 | ||
2137 | mxvar_log.rxcnt[info->port] += cnt; | 2125 | mxvar_log.rxcnt[info->port] += cnt; |
2138 | info->mon_data.rxcnt += cnt; | 2126 | info->mon_data.rxcnt += cnt; |
2139 | info->mon_data.up_rxcnt += cnt; | 2127 | info->mon_data.up_rxcnt += cnt; |
2140 | spin_unlock_irqrestore(&info->slock, flags); | 2128 | spin_unlock_irqrestore(&info->slock, flags); |
2141 | 2129 | ||
2142 | tty_flip_buffer_push(tty); | 2130 | tty_flip_buffer_push(tty); |
2143 | } | 2131 | } |
2144 | 2132 | ||
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig index 95882bb1950e..60c9be99c6d9 100644 --- a/drivers/cpufreq/Kconfig +++ b/drivers/cpufreq/Kconfig | |||
@@ -46,6 +46,10 @@ config CPU_FREQ_STAT_DETAILS | |||
46 | This will show detail CPU frequency translation table in sysfs file | 46 | This will show detail CPU frequency translation table in sysfs file |
47 | system | 47 | system |
48 | 48 | ||
49 | # Note that it is not currently possible to set the other governors (such as ondemand) | ||
50 | # as the default, since if they fail to initialise, cpufreq will be | ||
51 | # left in an undefined state. | ||
52 | |||
49 | choice | 53 | choice |
50 | prompt "Default CPUFreq governor" | 54 | prompt "Default CPUFreq governor" |
51 | default CPU_FREQ_DEFAULT_GOV_USERSPACE if CPU_FREQ_SA1100 || CPU_FREQ_SA1110 | 55 | default CPU_FREQ_DEFAULT_GOV_USERSPACE if CPU_FREQ_SA1100 || CPU_FREQ_SA1110 |
@@ -115,4 +119,24 @@ config CPU_FREQ_GOV_ONDEMAND | |||
115 | 119 | ||
116 | If in doubt, say N. | 120 | If in doubt, say N. |
117 | 121 | ||
122 | config CPU_FREQ_GOV_CONSERVATIVE | ||
123 | tristate "'conservative' cpufreq governor" | ||
124 | depends on CPU_FREQ | ||
125 | help | ||
126 | 'conservative' - this driver is rather similar to the 'ondemand' | ||
127 | governor both in its source code and its purpose, the difference is | ||
128 | its optimisation for better suitability in a battery powered | ||
129 | environment. The frequency is gracefully increased and decreased | ||
130 | rather than jumping to 100% when speed is required. | ||
131 | |||
132 | If you have a desktop machine then you should really be considering | ||
133 | the 'ondemand' governor instead, however if you are using a laptop, | ||
134 | PDA or even an AMD64 based computer (due to the unacceptable | ||
135 | step-by-step latency issues between the minimum and maximum frequency | ||
136 | transitions in the CPU) you will probably want to use this governor. | ||
137 | |||
138 | For details, take a look at linux/Documentation/cpu-freq. | ||
139 | |||
140 | If in doubt, say N. | ||
141 | |||
118 | endif # CPU_FREQ | 142 | endif # CPU_FREQ |
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index 67b16e5a41a7..71fc3b4173f1 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile | |||
@@ -8,6 +8,7 @@ obj-$(CONFIG_CPU_FREQ_GOV_PERFORMANCE) += cpufreq_performance.o | |||
8 | obj-$(CONFIG_CPU_FREQ_GOV_POWERSAVE) += cpufreq_powersave.o | 8 | obj-$(CONFIG_CPU_FREQ_GOV_POWERSAVE) += cpufreq_powersave.o |
9 | obj-$(CONFIG_CPU_FREQ_GOV_USERSPACE) += cpufreq_userspace.o | 9 | obj-$(CONFIG_CPU_FREQ_GOV_USERSPACE) += cpufreq_userspace.o |
10 | obj-$(CONFIG_CPU_FREQ_GOV_ONDEMAND) += cpufreq_ondemand.o | 10 | obj-$(CONFIG_CPU_FREQ_GOV_ONDEMAND) += cpufreq_ondemand.o |
11 | obj-$(CONFIG_CPU_FREQ_GOV_CONSERVATIVE) += cpufreq_conservative.o | ||
11 | 12 | ||
12 | # CPUfreq cross-arch helpers | 13 | # CPUfreq cross-arch helpers |
13 | obj-$(CONFIG_CPU_FREQ_TABLE) += freq_table.o | 14 | obj-$(CONFIG_CPU_FREQ_TABLE) += freq_table.o |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 8e561313d094..03b5fb2ddcf4 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -258,7 +258,7 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state) | |||
258 | (likely(cpufreq_cpu_data[freqs->cpu]->cur)) && | 258 | (likely(cpufreq_cpu_data[freqs->cpu]->cur)) && |
259 | (unlikely(freqs->old != cpufreq_cpu_data[freqs->cpu]->cur))) | 259 | (unlikely(freqs->old != cpufreq_cpu_data[freqs->cpu]->cur))) |
260 | { | 260 | { |
261 | printk(KERN_WARNING "Warning: CPU frequency is %u, " | 261 | dprintk(KERN_WARNING "Warning: CPU frequency is %u, " |
262 | "cpufreq assumed %u kHz.\n", freqs->old, cpufreq_cpu_data[freqs->cpu]->cur); | 262 | "cpufreq assumed %u kHz.\n", freqs->old, cpufreq_cpu_data[freqs->cpu]->cur); |
263 | freqs->old = cpufreq_cpu_data[freqs->cpu]->cur; | 263 | freqs->old = cpufreq_cpu_data[freqs->cpu]->cur; |
264 | } | 264 | } |
@@ -814,7 +814,7 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, unsigne | |||
814 | { | 814 | { |
815 | struct cpufreq_freqs freqs; | 815 | struct cpufreq_freqs freqs; |
816 | 816 | ||
817 | printk(KERN_WARNING "Warning: CPU frequency out of sync: cpufreq and timing " | 817 | dprintk(KERN_WARNING "Warning: CPU frequency out of sync: cpufreq and timing " |
818 | "core thinks of %u, is %u kHz.\n", old_freq, new_freq); | 818 | "core thinks of %u, is %u kHz.\n", old_freq, new_freq); |
819 | 819 | ||
820 | freqs.cpu = cpu; | 820 | freqs.cpu = cpu; |
@@ -923,7 +923,7 @@ static int cpufreq_suspend(struct sys_device * sysdev, u32 state) | |||
923 | struct cpufreq_freqs freqs; | 923 | struct cpufreq_freqs freqs; |
924 | 924 | ||
925 | if (!(cpufreq_driver->flags & CPUFREQ_PM_NO_WARN)) | 925 | if (!(cpufreq_driver->flags & CPUFREQ_PM_NO_WARN)) |
926 | printk(KERN_DEBUG "Warning: CPU frequency is %u, " | 926 | dprintk(KERN_DEBUG "Warning: CPU frequency is %u, " |
927 | "cpufreq assumed %u kHz.\n", | 927 | "cpufreq assumed %u kHz.\n", |
928 | cur_freq, cpu_policy->cur); | 928 | cur_freq, cpu_policy->cur); |
929 | 929 | ||
@@ -1004,7 +1004,7 @@ static int cpufreq_resume(struct sys_device * sysdev) | |||
1004 | struct cpufreq_freqs freqs; | 1004 | struct cpufreq_freqs freqs; |
1005 | 1005 | ||
1006 | if (!(cpufreq_driver->flags & CPUFREQ_PM_NO_WARN)) | 1006 | if (!(cpufreq_driver->flags & CPUFREQ_PM_NO_WARN)) |
1007 | printk(KERN_WARNING "Warning: CPU frequency" | 1007 | dprintk(KERN_WARNING "Warning: CPU frequency" |
1008 | "is %u, cpufreq assumed %u kHz.\n", | 1008 | "is %u, cpufreq assumed %u kHz.\n", |
1009 | cur_freq, cpu_policy->cur); | 1009 | cur_freq, cpu_policy->cur); |
1010 | 1010 | ||
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c new file mode 100644 index 000000000000..e1df376e709e --- /dev/null +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
@@ -0,0 +1,586 @@ | |||
1 | /* | ||
2 | * drivers/cpufreq/cpufreq_conservative.c | ||
3 | * | ||
4 | * Copyright (C) 2001 Russell King | ||
5 | * (C) 2003 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>. | ||
6 | * Jun Nakajima <jun.nakajima@intel.com> | ||
7 | * (C) 2004 Alexander Clouter <alex-kernel@digriz.org.uk> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/smp.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/interrupt.h> | ||
19 | #include <linux/ctype.h> | ||
20 | #include <linux/cpufreq.h> | ||
21 | #include <linux/sysctl.h> | ||
22 | #include <linux/types.h> | ||
23 | #include <linux/fs.h> | ||
24 | #include <linux/sysfs.h> | ||
25 | #include <linux/sched.h> | ||
26 | #include <linux/kmod.h> | ||
27 | #include <linux/workqueue.h> | ||
28 | #include <linux/jiffies.h> | ||
29 | #include <linux/kernel_stat.h> | ||
30 | #include <linux/percpu.h> | ||
31 | |||
32 | /* | ||
33 | * dbs is used in this file as a shortform for demandbased switching | ||
34 | * It helps to keep variable names smaller, simpler | ||
35 | */ | ||
36 | |||
37 | #define DEF_FREQUENCY_UP_THRESHOLD (80) | ||
38 | #define MIN_FREQUENCY_UP_THRESHOLD (0) | ||
39 | #define MAX_FREQUENCY_UP_THRESHOLD (100) | ||
40 | |||
41 | #define DEF_FREQUENCY_DOWN_THRESHOLD (20) | ||
42 | #define MIN_FREQUENCY_DOWN_THRESHOLD (0) | ||
43 | #define MAX_FREQUENCY_DOWN_THRESHOLD (100) | ||
44 | |||
45 | /* | ||
46 | * The polling frequency of this governor depends on the capability of | ||
47 | * the processor. Default polling frequency is 1000 times the transition | ||
48 | * latency of the processor. The governor will work on any processor with | ||
49 | * transition latency <= 10mS, using appropriate sampling | ||
50 | * rate. | ||
51 | * For CPUs with transition latency > 10mS (mostly drivers with CPUFREQ_ETERNAL) | ||
52 | * this governor will not work. | ||
53 | * All times here are in uS. | ||
54 | */ | ||
55 | static unsigned int def_sampling_rate; | ||
56 | #define MIN_SAMPLING_RATE (def_sampling_rate / 2) | ||
57 | #define MAX_SAMPLING_RATE (500 * def_sampling_rate) | ||
58 | #define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (100000) | ||
59 | #define DEF_SAMPLING_DOWN_FACTOR (5) | ||
60 | #define TRANSITION_LATENCY_LIMIT (10 * 1000) | ||
61 | |||
62 | static void do_dbs_timer(void *data); | ||
63 | |||
64 | struct cpu_dbs_info_s { | ||
65 | struct cpufreq_policy *cur_policy; | ||
66 | unsigned int prev_cpu_idle_up; | ||
67 | unsigned int prev_cpu_idle_down; | ||
68 | unsigned int enable; | ||
69 | }; | ||
70 | static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info); | ||
71 | |||
72 | static unsigned int dbs_enable; /* number of CPUs using this policy */ | ||
73 | |||
74 | static DECLARE_MUTEX (dbs_sem); | ||
75 | static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); | ||
76 | |||
77 | struct dbs_tuners { | ||
78 | unsigned int sampling_rate; | ||
79 | unsigned int sampling_down_factor; | ||
80 | unsigned int up_threshold; | ||
81 | unsigned int down_threshold; | ||
82 | unsigned int ignore_nice; | ||
83 | unsigned int freq_step; | ||
84 | }; | ||
85 | |||
86 | static struct dbs_tuners dbs_tuners_ins = { | ||
87 | .up_threshold = DEF_FREQUENCY_UP_THRESHOLD, | ||
88 | .down_threshold = DEF_FREQUENCY_DOWN_THRESHOLD, | ||
89 | .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR, | ||
90 | }; | ||
91 | |||
92 | static inline unsigned int get_cpu_idle_time(unsigned int cpu) | ||
93 | { | ||
94 | return kstat_cpu(cpu).cpustat.idle + | ||
95 | kstat_cpu(cpu).cpustat.iowait + | ||
96 | ( !dbs_tuners_ins.ignore_nice ? | ||
97 | kstat_cpu(cpu).cpustat.nice : | ||
98 | 0); | ||
99 | } | ||
100 | |||
101 | /************************** sysfs interface ************************/ | ||
102 | static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf) | ||
103 | { | ||
104 | return sprintf (buf, "%u\n", MAX_SAMPLING_RATE); | ||
105 | } | ||
106 | |||
107 | static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) | ||
108 | { | ||
109 | return sprintf (buf, "%u\n", MIN_SAMPLING_RATE); | ||
110 | } | ||
111 | |||
112 | #define define_one_ro(_name) \ | ||
113 | static struct freq_attr _name = \ | ||
114 | __ATTR(_name, 0444, show_##_name, NULL) | ||
115 | |||
116 | define_one_ro(sampling_rate_max); | ||
117 | define_one_ro(sampling_rate_min); | ||
118 | |||
119 | /* cpufreq_conservative Governor Tunables */ | ||
120 | #define show_one(file_name, object) \ | ||
121 | static ssize_t show_##file_name \ | ||
122 | (struct cpufreq_policy *unused, char *buf) \ | ||
123 | { \ | ||
124 | return sprintf(buf, "%u\n", dbs_tuners_ins.object); \ | ||
125 | } | ||
126 | show_one(sampling_rate, sampling_rate); | ||
127 | show_one(sampling_down_factor, sampling_down_factor); | ||
128 | show_one(up_threshold, up_threshold); | ||
129 | show_one(down_threshold, down_threshold); | ||
130 | show_one(ignore_nice, ignore_nice); | ||
131 | show_one(freq_step, freq_step); | ||
132 | |||
133 | static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, | ||
134 | const char *buf, size_t count) | ||
135 | { | ||
136 | unsigned int input; | ||
137 | int ret; | ||
138 | ret = sscanf (buf, "%u", &input); | ||
139 | if (ret != 1 ) | ||
140 | return -EINVAL; | ||
141 | |||
142 | down(&dbs_sem); | ||
143 | dbs_tuners_ins.sampling_down_factor = input; | ||
144 | up(&dbs_sem); | ||
145 | |||
146 | return count; | ||
147 | } | ||
148 | |||
149 | static ssize_t store_sampling_rate(struct cpufreq_policy *unused, | ||
150 | const char *buf, size_t count) | ||
151 | { | ||
152 | unsigned int input; | ||
153 | int ret; | ||
154 | ret = sscanf (buf, "%u", &input); | ||
155 | |||
156 | down(&dbs_sem); | ||
157 | if (ret != 1 || input > MAX_SAMPLING_RATE || input < MIN_SAMPLING_RATE) { | ||
158 | up(&dbs_sem); | ||
159 | return -EINVAL; | ||
160 | } | ||
161 | |||
162 | dbs_tuners_ins.sampling_rate = input; | ||
163 | up(&dbs_sem); | ||
164 | |||
165 | return count; | ||
166 | } | ||
167 | |||
168 | static ssize_t store_up_threshold(struct cpufreq_policy *unused, | ||
169 | const char *buf, size_t count) | ||
170 | { | ||
171 | unsigned int input; | ||
172 | int ret; | ||
173 | ret = sscanf (buf, "%u", &input); | ||
174 | |||
175 | down(&dbs_sem); | ||
176 | if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD || | ||
177 | input < MIN_FREQUENCY_UP_THRESHOLD || | ||
178 | input <= dbs_tuners_ins.down_threshold) { | ||
179 | up(&dbs_sem); | ||
180 | return -EINVAL; | ||
181 | } | ||
182 | |||
183 | dbs_tuners_ins.up_threshold = input; | ||
184 | up(&dbs_sem); | ||
185 | |||
186 | return count; | ||
187 | } | ||
188 | |||
189 | static ssize_t store_down_threshold(struct cpufreq_policy *unused, | ||
190 | const char *buf, size_t count) | ||
191 | { | ||
192 | unsigned int input; | ||
193 | int ret; | ||
194 | ret = sscanf (buf, "%u", &input); | ||
195 | |||
196 | down(&dbs_sem); | ||
197 | if (ret != 1 || input > MAX_FREQUENCY_DOWN_THRESHOLD || | ||
198 | input < MIN_FREQUENCY_DOWN_THRESHOLD || | ||
199 | input >= dbs_tuners_ins.up_threshold) { | ||
200 | up(&dbs_sem); | ||
201 | return -EINVAL; | ||
202 | } | ||
203 | |||
204 | dbs_tuners_ins.down_threshold = input; | ||
205 | up(&dbs_sem); | ||
206 | |||
207 | return count; | ||
208 | } | ||
209 | |||
210 | static ssize_t store_ignore_nice(struct cpufreq_policy *policy, | ||
211 | const char *buf, size_t count) | ||
212 | { | ||
213 | unsigned int input; | ||
214 | int ret; | ||
215 | |||
216 | unsigned int j; | ||
217 | |||
218 | ret = sscanf (buf, "%u", &input); | ||
219 | if ( ret != 1 ) | ||
220 | return -EINVAL; | ||
221 | |||
222 | if ( input > 1 ) | ||
223 | input = 1; | ||
224 | |||
225 | down(&dbs_sem); | ||
226 | if ( input == dbs_tuners_ins.ignore_nice ) { /* nothing to do */ | ||
227 | up(&dbs_sem); | ||
228 | return count; | ||
229 | } | ||
230 | dbs_tuners_ins.ignore_nice = input; | ||
231 | |||
232 | /* we need to re-evaluate prev_cpu_idle_up and prev_cpu_idle_down */ | ||
233 | for_each_online_cpu(j) { | ||
234 | struct cpu_dbs_info_s *j_dbs_info; | ||
235 | j_dbs_info = &per_cpu(cpu_dbs_info, j); | ||
236 | j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(j); | ||
237 | j_dbs_info->prev_cpu_idle_down = j_dbs_info->prev_cpu_idle_up; | ||
238 | } | ||
239 | up(&dbs_sem); | ||
240 | |||
241 | return count; | ||
242 | } | ||
243 | |||
244 | static ssize_t store_freq_step(struct cpufreq_policy *policy, | ||
245 | const char *buf, size_t count) | ||
246 | { | ||
247 | unsigned int input; | ||
248 | int ret; | ||
249 | |||
250 | ret = sscanf (buf, "%u", &input); | ||
251 | |||
252 | if ( ret != 1 ) | ||
253 | return -EINVAL; | ||
254 | |||
255 | if ( input > 100 ) | ||
256 | input = 100; | ||
257 | |||
258 | /* no need to test here if freq_step is zero as the user might actually | ||
259 | * want this, they would be crazy though :) */ | ||
260 | down(&dbs_sem); | ||
261 | dbs_tuners_ins.freq_step = input; | ||
262 | up(&dbs_sem); | ||
263 | |||
264 | return count; | ||
265 | } | ||
266 | |||
267 | #define define_one_rw(_name) \ | ||
268 | static struct freq_attr _name = \ | ||
269 | __ATTR(_name, 0644, show_##_name, store_##_name) | ||
270 | |||
271 | define_one_rw(sampling_rate); | ||
272 | define_one_rw(sampling_down_factor); | ||
273 | define_one_rw(up_threshold); | ||
274 | define_one_rw(down_threshold); | ||
275 | define_one_rw(ignore_nice); | ||
276 | define_one_rw(freq_step); | ||
277 | |||
278 | static struct attribute * dbs_attributes[] = { | ||
279 | &sampling_rate_max.attr, | ||
280 | &sampling_rate_min.attr, | ||
281 | &sampling_rate.attr, | ||
282 | &sampling_down_factor.attr, | ||
283 | &up_threshold.attr, | ||
284 | &down_threshold.attr, | ||
285 | &ignore_nice.attr, | ||
286 | &freq_step.attr, | ||
287 | NULL | ||
288 | }; | ||
289 | |||
290 | static struct attribute_group dbs_attr_group = { | ||
291 | .attrs = dbs_attributes, | ||
292 | .name = "conservative", | ||
293 | }; | ||
294 | |||
295 | /************************** sysfs end ************************/ | ||
296 | |||
297 | static void dbs_check_cpu(int cpu) | ||
298 | { | ||
299 | unsigned int idle_ticks, up_idle_ticks, down_idle_ticks; | ||
300 | unsigned int freq_step; | ||
301 | unsigned int freq_down_sampling_rate; | ||
302 | static int down_skip[NR_CPUS]; | ||
303 | static int requested_freq[NR_CPUS]; | ||
304 | static unsigned short init_flag = 0; | ||
305 | struct cpu_dbs_info_s *this_dbs_info; | ||
306 | struct cpu_dbs_info_s *dbs_info; | ||
307 | |||
308 | struct cpufreq_policy *policy; | ||
309 | unsigned int j; | ||
310 | |||
311 | this_dbs_info = &per_cpu(cpu_dbs_info, cpu); | ||
312 | if (!this_dbs_info->enable) | ||
313 | return; | ||
314 | |||
315 | policy = this_dbs_info->cur_policy; | ||
316 | |||
317 | if ( init_flag == 0 ) { | ||
318 | for ( /* NULL */; init_flag < NR_CPUS; init_flag++ ) { | ||
319 | dbs_info = &per_cpu(cpu_dbs_info, init_flag); | ||
320 | requested_freq[cpu] = dbs_info->cur_policy->cur; | ||
321 | } | ||
322 | init_flag = 1; | ||
323 | } | ||
324 | |||
325 | /* | ||
326 | * The default safe range is 20% to 80% | ||
327 | * Every sampling_rate, we check | ||
328 | * - If current idle time is less than 20%, then we try to | ||
329 | * increase frequency | ||
330 | * Every sampling_rate*sampling_down_factor, we check | ||
331 | * - If current idle time is more than 80%, then we try to | ||
332 | * decrease frequency | ||
333 | * | ||
334 | * Any frequency increase takes it to the maximum frequency. | ||
335 | * Frequency reduction happens at minimum steps of | ||
336 | * 5% (default) of max_frequency | ||
337 | */ | ||
338 | |||
339 | /* Check for frequency increase */ | ||
340 | |||
341 | idle_ticks = UINT_MAX; | ||
342 | for_each_cpu_mask(j, policy->cpus) { | ||
343 | unsigned int tmp_idle_ticks, total_idle_ticks; | ||
344 | struct cpu_dbs_info_s *j_dbs_info; | ||
345 | |||
346 | j_dbs_info = &per_cpu(cpu_dbs_info, j); | ||
347 | /* Check for frequency increase */ | ||
348 | total_idle_ticks = get_cpu_idle_time(j); | ||
349 | tmp_idle_ticks = total_idle_ticks - | ||
350 | j_dbs_info->prev_cpu_idle_up; | ||
351 | j_dbs_info->prev_cpu_idle_up = total_idle_ticks; | ||
352 | |||
353 | if (tmp_idle_ticks < idle_ticks) | ||
354 | idle_ticks = tmp_idle_ticks; | ||
355 | } | ||
356 | |||
357 | /* Scale idle ticks by 100 and compare with up and down ticks */ | ||
358 | idle_ticks *= 100; | ||
359 | up_idle_ticks = (100 - dbs_tuners_ins.up_threshold) * | ||
360 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate); | ||
361 | |||
362 | if (idle_ticks < up_idle_ticks) { | ||
363 | down_skip[cpu] = 0; | ||
364 | for_each_cpu_mask(j, policy->cpus) { | ||
365 | struct cpu_dbs_info_s *j_dbs_info; | ||
366 | |||
367 | j_dbs_info = &per_cpu(cpu_dbs_info, j); | ||
368 | j_dbs_info->prev_cpu_idle_down = | ||
369 | j_dbs_info->prev_cpu_idle_up; | ||
370 | } | ||
371 | /* if we are already at full speed then break out early */ | ||
372 | if (requested_freq[cpu] == policy->max) | ||
373 | return; | ||
374 | |||
375 | freq_step = (dbs_tuners_ins.freq_step * policy->max) / 100; | ||
376 | |||
377 | /* max freq cannot be less than 100. But who knows.... */ | ||
378 | if (unlikely(freq_step == 0)) | ||
379 | freq_step = 5; | ||
380 | |||
381 | requested_freq[cpu] += freq_step; | ||
382 | if (requested_freq[cpu] > policy->max) | ||
383 | requested_freq[cpu] = policy->max; | ||
384 | |||
385 | __cpufreq_driver_target(policy, requested_freq[cpu], | ||
386 | CPUFREQ_RELATION_H); | ||
387 | return; | ||
388 | } | ||
389 | |||
390 | /* Check for frequency decrease */ | ||
391 | down_skip[cpu]++; | ||
392 | if (down_skip[cpu] < dbs_tuners_ins.sampling_down_factor) | ||
393 | return; | ||
394 | |||
395 | idle_ticks = UINT_MAX; | ||
396 | for_each_cpu_mask(j, policy->cpus) { | ||
397 | unsigned int tmp_idle_ticks, total_idle_ticks; | ||
398 | struct cpu_dbs_info_s *j_dbs_info; | ||
399 | |||
400 | j_dbs_info = &per_cpu(cpu_dbs_info, j); | ||
401 | total_idle_ticks = j_dbs_info->prev_cpu_idle_up; | ||
402 | tmp_idle_ticks = total_idle_ticks - | ||
403 | j_dbs_info->prev_cpu_idle_down; | ||
404 | j_dbs_info->prev_cpu_idle_down = total_idle_ticks; | ||
405 | |||
406 | if (tmp_idle_ticks < idle_ticks) | ||
407 | idle_ticks = tmp_idle_ticks; | ||
408 | } | ||
409 | |||
410 | /* Scale idle ticks by 100 and compare with up and down ticks */ | ||
411 | idle_ticks *= 100; | ||
412 | down_skip[cpu] = 0; | ||
413 | |||
414 | freq_down_sampling_rate = dbs_tuners_ins.sampling_rate * | ||
415 | dbs_tuners_ins.sampling_down_factor; | ||
416 | down_idle_ticks = (100 - dbs_tuners_ins.down_threshold) * | ||
417 | usecs_to_jiffies(freq_down_sampling_rate); | ||
418 | |||
419 | if (idle_ticks > down_idle_ticks) { | ||
420 | /* if we are already at the lowest speed then break out early | ||
421 | * or if we 'cannot' reduce the speed as the user might want | ||
422 | * freq_step to be zero */ | ||
423 | if (requested_freq[cpu] == policy->min | ||
424 | || dbs_tuners_ins.freq_step == 0) | ||
425 | return; | ||
426 | |||
427 | freq_step = (dbs_tuners_ins.freq_step * policy->max) / 100; | ||
428 | |||
429 | /* max freq cannot be less than 100. But who knows.... */ | ||
430 | if (unlikely(freq_step == 0)) | ||
431 | freq_step = 5; | ||
432 | |||
433 | requested_freq[cpu] -= freq_step; | ||
434 | if (requested_freq[cpu] < policy->min) | ||
435 | requested_freq[cpu] = policy->min; | ||
436 | |||
437 | __cpufreq_driver_target(policy, | ||
438 | requested_freq[cpu], | ||
439 | CPUFREQ_RELATION_H); | ||
440 | return; | ||
441 | } | ||
442 | } | ||
443 | |||
444 | static void do_dbs_timer(void *data) | ||
445 | { | ||
446 | int i; | ||
447 | down(&dbs_sem); | ||
448 | for_each_online_cpu(i) | ||
449 | dbs_check_cpu(i); | ||
450 | schedule_delayed_work(&dbs_work, | ||
451 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); | ||
452 | up(&dbs_sem); | ||
453 | } | ||
454 | |||
455 | static inline void dbs_timer_init(void) | ||
456 | { | ||
457 | INIT_WORK(&dbs_work, do_dbs_timer, NULL); | ||
458 | schedule_delayed_work(&dbs_work, | ||
459 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); | ||
460 | return; | ||
461 | } | ||
462 | |||
463 | static inline void dbs_timer_exit(void) | ||
464 | { | ||
465 | cancel_delayed_work(&dbs_work); | ||
466 | return; | ||
467 | } | ||
468 | |||
469 | static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | ||
470 | unsigned int event) | ||
471 | { | ||
472 | unsigned int cpu = policy->cpu; | ||
473 | struct cpu_dbs_info_s *this_dbs_info; | ||
474 | unsigned int j; | ||
475 | |||
476 | this_dbs_info = &per_cpu(cpu_dbs_info, cpu); | ||
477 | |||
478 | switch (event) { | ||
479 | case CPUFREQ_GOV_START: | ||
480 | if ((!cpu_online(cpu)) || | ||
481 | (!policy->cur)) | ||
482 | return -EINVAL; | ||
483 | |||
484 | if (policy->cpuinfo.transition_latency > | ||
485 | (TRANSITION_LATENCY_LIMIT * 1000)) | ||
486 | return -EINVAL; | ||
487 | if (this_dbs_info->enable) /* Already enabled */ | ||
488 | break; | ||
489 | |||
490 | down(&dbs_sem); | ||
491 | for_each_cpu_mask(j, policy->cpus) { | ||
492 | struct cpu_dbs_info_s *j_dbs_info; | ||
493 | j_dbs_info = &per_cpu(cpu_dbs_info, j); | ||
494 | j_dbs_info->cur_policy = policy; | ||
495 | |||
496 | j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(j); | ||
497 | j_dbs_info->prev_cpu_idle_down | ||
498 | = j_dbs_info->prev_cpu_idle_up; | ||
499 | } | ||
500 | this_dbs_info->enable = 1; | ||
501 | sysfs_create_group(&policy->kobj, &dbs_attr_group); | ||
502 | dbs_enable++; | ||
503 | /* | ||
504 | * Start the timerschedule work, when this governor | ||
505 | * is used for first time | ||
506 | */ | ||
507 | if (dbs_enable == 1) { | ||
508 | unsigned int latency; | ||
509 | /* policy latency is in nS. Convert it to uS first */ | ||
510 | |||
511 | latency = policy->cpuinfo.transition_latency; | ||
512 | if (latency < 1000) | ||
513 | latency = 1000; | ||
514 | |||
515 | def_sampling_rate = (latency / 1000) * | ||
516 | DEF_SAMPLING_RATE_LATENCY_MULTIPLIER; | ||
517 | dbs_tuners_ins.sampling_rate = def_sampling_rate; | ||
518 | dbs_tuners_ins.ignore_nice = 0; | ||
519 | dbs_tuners_ins.freq_step = 5; | ||
520 | |||
521 | dbs_timer_init(); | ||
522 | } | ||
523 | |||
524 | up(&dbs_sem); | ||
525 | break; | ||
526 | |||
527 | case CPUFREQ_GOV_STOP: | ||
528 | down(&dbs_sem); | ||
529 | this_dbs_info->enable = 0; | ||
530 | sysfs_remove_group(&policy->kobj, &dbs_attr_group); | ||
531 | dbs_enable--; | ||
532 | /* | ||
533 | * Stop the timerschedule work, when this governor | ||
534 | * is used for first time | ||
535 | */ | ||
536 | if (dbs_enable == 0) | ||
537 | dbs_timer_exit(); | ||
538 | |||
539 | up(&dbs_sem); | ||
540 | |||
541 | break; | ||
542 | |||
543 | case CPUFREQ_GOV_LIMITS: | ||
544 | down(&dbs_sem); | ||
545 | if (policy->max < this_dbs_info->cur_policy->cur) | ||
546 | __cpufreq_driver_target( | ||
547 | this_dbs_info->cur_policy, | ||
548 | policy->max, CPUFREQ_RELATION_H); | ||
549 | else if (policy->min > this_dbs_info->cur_policy->cur) | ||
550 | __cpufreq_driver_target( | ||
551 | this_dbs_info->cur_policy, | ||
552 | policy->min, CPUFREQ_RELATION_L); | ||
553 | up(&dbs_sem); | ||
554 | break; | ||
555 | } | ||
556 | return 0; | ||
557 | } | ||
558 | |||
559 | static struct cpufreq_governor cpufreq_gov_dbs = { | ||
560 | .name = "conservative", | ||
561 | .governor = cpufreq_governor_dbs, | ||
562 | .owner = THIS_MODULE, | ||
563 | }; | ||
564 | |||
565 | static int __init cpufreq_gov_dbs_init(void) | ||
566 | { | ||
567 | return cpufreq_register_governor(&cpufreq_gov_dbs); | ||
568 | } | ||
569 | |||
570 | static void __exit cpufreq_gov_dbs_exit(void) | ||
571 | { | ||
572 | /* Make sure that the scheduled work is indeed not running */ | ||
573 | flush_scheduled_work(); | ||
574 | |||
575 | cpufreq_unregister_governor(&cpufreq_gov_dbs); | ||
576 | } | ||
577 | |||
578 | |||
579 | MODULE_AUTHOR ("Alexander Clouter <alex-kernel@digriz.org.uk>"); | ||
580 | MODULE_DESCRIPTION ("'cpufreq_conservative' - A dynamic cpufreq governor for " | ||
581 | "Low Latency Frequency Transition capable processors " | ||
582 | "optimised for use in a battery environment"); | ||
583 | MODULE_LICENSE ("GPL"); | ||
584 | |||
585 | module_init(cpufreq_gov_dbs_init); | ||
586 | module_exit(cpufreq_gov_dbs_exit); | ||
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 8d83a21c6477..c1fc9c62bb51 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -34,13 +34,9 @@ | |||
34 | */ | 34 | */ |
35 | 35 | ||
36 | #define DEF_FREQUENCY_UP_THRESHOLD (80) | 36 | #define DEF_FREQUENCY_UP_THRESHOLD (80) |
37 | #define MIN_FREQUENCY_UP_THRESHOLD (0) | 37 | #define MIN_FREQUENCY_UP_THRESHOLD (11) |
38 | #define MAX_FREQUENCY_UP_THRESHOLD (100) | 38 | #define MAX_FREQUENCY_UP_THRESHOLD (100) |
39 | 39 | ||
40 | #define DEF_FREQUENCY_DOWN_THRESHOLD (20) | ||
41 | #define MIN_FREQUENCY_DOWN_THRESHOLD (0) | ||
42 | #define MAX_FREQUENCY_DOWN_THRESHOLD (100) | ||
43 | |||
44 | /* | 40 | /* |
45 | * The polling frequency of this governor depends on the capability of | 41 | * The polling frequency of this governor depends on the capability of |
46 | * the processor. Default polling frequency is 1000 times the transition | 42 | * the processor. Default polling frequency is 1000 times the transition |
@@ -55,9 +51,9 @@ static unsigned int def_sampling_rate; | |||
55 | #define MIN_SAMPLING_RATE (def_sampling_rate / 2) | 51 | #define MIN_SAMPLING_RATE (def_sampling_rate / 2) |
56 | #define MAX_SAMPLING_RATE (500 * def_sampling_rate) | 52 | #define MAX_SAMPLING_RATE (500 * def_sampling_rate) |
57 | #define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) | 53 | #define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) |
58 | #define DEF_SAMPLING_DOWN_FACTOR (10) | 54 | #define DEF_SAMPLING_DOWN_FACTOR (1) |
55 | #define MAX_SAMPLING_DOWN_FACTOR (10) | ||
59 | #define TRANSITION_LATENCY_LIMIT (10 * 1000) | 56 | #define TRANSITION_LATENCY_LIMIT (10 * 1000) |
60 | #define sampling_rate_in_HZ(x) (((x * HZ) < (1000 * 1000))?1:((x * HZ) / (1000 * 1000))) | ||
61 | 57 | ||
62 | static void do_dbs_timer(void *data); | 58 | static void do_dbs_timer(void *data); |
63 | 59 | ||
@@ -78,15 +74,23 @@ struct dbs_tuners { | |||
78 | unsigned int sampling_rate; | 74 | unsigned int sampling_rate; |
79 | unsigned int sampling_down_factor; | 75 | unsigned int sampling_down_factor; |
80 | unsigned int up_threshold; | 76 | unsigned int up_threshold; |
81 | unsigned int down_threshold; | 77 | unsigned int ignore_nice; |
82 | }; | 78 | }; |
83 | 79 | ||
84 | static struct dbs_tuners dbs_tuners_ins = { | 80 | static struct dbs_tuners dbs_tuners_ins = { |
85 | .up_threshold = DEF_FREQUENCY_UP_THRESHOLD, | 81 | .up_threshold = DEF_FREQUENCY_UP_THRESHOLD, |
86 | .down_threshold = DEF_FREQUENCY_DOWN_THRESHOLD, | ||
87 | .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR, | 82 | .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR, |
88 | }; | 83 | }; |
89 | 84 | ||
85 | static inline unsigned int get_cpu_idle_time(unsigned int cpu) | ||
86 | { | ||
87 | return kstat_cpu(cpu).cpustat.idle + | ||
88 | kstat_cpu(cpu).cpustat.iowait + | ||
89 | ( !dbs_tuners_ins.ignore_nice ? | ||
90 | kstat_cpu(cpu).cpustat.nice : | ||
91 | 0); | ||
92 | } | ||
93 | |||
90 | /************************** sysfs interface ************************/ | 94 | /************************** sysfs interface ************************/ |
91 | static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf) | 95 | static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf) |
92 | { | 96 | { |
@@ -115,7 +119,7 @@ static ssize_t show_##file_name \ | |||
115 | show_one(sampling_rate, sampling_rate); | 119 | show_one(sampling_rate, sampling_rate); |
116 | show_one(sampling_down_factor, sampling_down_factor); | 120 | show_one(sampling_down_factor, sampling_down_factor); |
117 | show_one(up_threshold, up_threshold); | 121 | show_one(up_threshold, up_threshold); |
118 | show_one(down_threshold, down_threshold); | 122 | show_one(ignore_nice, ignore_nice); |
119 | 123 | ||
120 | static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, | 124 | static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, |
121 | const char *buf, size_t count) | 125 | const char *buf, size_t count) |
@@ -126,6 +130,9 @@ static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, | |||
126 | if (ret != 1 ) | 130 | if (ret != 1 ) |
127 | return -EINVAL; | 131 | return -EINVAL; |
128 | 132 | ||
133 | if (input > MAX_SAMPLING_DOWN_FACTOR || input < 1) | ||
134 | return -EINVAL; | ||
135 | |||
129 | down(&dbs_sem); | 136 | down(&dbs_sem); |
130 | dbs_tuners_ins.sampling_down_factor = input; | 137 | dbs_tuners_ins.sampling_down_factor = input; |
131 | up(&dbs_sem); | 138 | up(&dbs_sem); |
@@ -161,8 +168,7 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused, | |||
161 | 168 | ||
162 | down(&dbs_sem); | 169 | down(&dbs_sem); |
163 | if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD || | 170 | if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD || |
164 | input < MIN_FREQUENCY_UP_THRESHOLD || | 171 | input < MIN_FREQUENCY_UP_THRESHOLD) { |
165 | input <= dbs_tuners_ins.down_threshold) { | ||
166 | up(&dbs_sem); | 172 | up(&dbs_sem); |
167 | return -EINVAL; | 173 | return -EINVAL; |
168 | } | 174 | } |
@@ -173,22 +179,35 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused, | |||
173 | return count; | 179 | return count; |
174 | } | 180 | } |
175 | 181 | ||
176 | static ssize_t store_down_threshold(struct cpufreq_policy *unused, | 182 | static ssize_t store_ignore_nice(struct cpufreq_policy *policy, |
177 | const char *buf, size_t count) | 183 | const char *buf, size_t count) |
178 | { | 184 | { |
179 | unsigned int input; | 185 | unsigned int input; |
180 | int ret; | 186 | int ret; |
187 | |||
188 | unsigned int j; | ||
189 | |||
181 | ret = sscanf (buf, "%u", &input); | 190 | ret = sscanf (buf, "%u", &input); |
191 | if ( ret != 1 ) | ||
192 | return -EINVAL; | ||
182 | 193 | ||
194 | if ( input > 1 ) | ||
195 | input = 1; | ||
196 | |||
183 | down(&dbs_sem); | 197 | down(&dbs_sem); |
184 | if (ret != 1 || input > MAX_FREQUENCY_DOWN_THRESHOLD || | 198 | if ( input == dbs_tuners_ins.ignore_nice ) { /* nothing to do */ |
185 | input < MIN_FREQUENCY_DOWN_THRESHOLD || | ||
186 | input >= dbs_tuners_ins.up_threshold) { | ||
187 | up(&dbs_sem); | 199 | up(&dbs_sem); |
188 | return -EINVAL; | 200 | return count; |
189 | } | 201 | } |
202 | dbs_tuners_ins.ignore_nice = input; | ||
190 | 203 | ||
191 | dbs_tuners_ins.down_threshold = input; | 204 | /* we need to re-evaluate prev_cpu_idle_up and prev_cpu_idle_down */ |
205 | for_each_online_cpu(j) { | ||
206 | struct cpu_dbs_info_s *j_dbs_info; | ||
207 | j_dbs_info = &per_cpu(cpu_dbs_info, j); | ||
208 | j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(j); | ||
209 | j_dbs_info->prev_cpu_idle_down = j_dbs_info->prev_cpu_idle_up; | ||
210 | } | ||
192 | up(&dbs_sem); | 211 | up(&dbs_sem); |
193 | 212 | ||
194 | return count; | 213 | return count; |
@@ -201,7 +220,7 @@ __ATTR(_name, 0644, show_##_name, store_##_name) | |||
201 | define_one_rw(sampling_rate); | 220 | define_one_rw(sampling_rate); |
202 | define_one_rw(sampling_down_factor); | 221 | define_one_rw(sampling_down_factor); |
203 | define_one_rw(up_threshold); | 222 | define_one_rw(up_threshold); |
204 | define_one_rw(down_threshold); | 223 | define_one_rw(ignore_nice); |
205 | 224 | ||
206 | static struct attribute * dbs_attributes[] = { | 225 | static struct attribute * dbs_attributes[] = { |
207 | &sampling_rate_max.attr, | 226 | &sampling_rate_max.attr, |
@@ -209,7 +228,7 @@ static struct attribute * dbs_attributes[] = { | |||
209 | &sampling_rate.attr, | 228 | &sampling_rate.attr, |
210 | &sampling_down_factor.attr, | 229 | &sampling_down_factor.attr, |
211 | &up_threshold.attr, | 230 | &up_threshold.attr, |
212 | &down_threshold.attr, | 231 | &ignore_nice.attr, |
213 | NULL | 232 | NULL |
214 | }; | 233 | }; |
215 | 234 | ||
@@ -222,9 +241,8 @@ static struct attribute_group dbs_attr_group = { | |||
222 | 241 | ||
223 | static void dbs_check_cpu(int cpu) | 242 | static void dbs_check_cpu(int cpu) |
224 | { | 243 | { |
225 | unsigned int idle_ticks, up_idle_ticks, down_idle_ticks; | 244 | unsigned int idle_ticks, up_idle_ticks, total_ticks; |
226 | unsigned int total_idle_ticks; | 245 | unsigned int freq_next; |
227 | unsigned int freq_down_step; | ||
228 | unsigned int freq_down_sampling_rate; | 246 | unsigned int freq_down_sampling_rate; |
229 | static int down_skip[NR_CPUS]; | 247 | static int down_skip[NR_CPUS]; |
230 | struct cpu_dbs_info_s *this_dbs_info; | 248 | struct cpu_dbs_info_s *this_dbs_info; |
@@ -238,38 +256,25 @@ static void dbs_check_cpu(int cpu) | |||
238 | 256 | ||
239 | policy = this_dbs_info->cur_policy; | 257 | policy = this_dbs_info->cur_policy; |
240 | /* | 258 | /* |
241 | * The default safe range is 20% to 80% | 259 | * Every sampling_rate, we check, if current idle time is less |
242 | * Every sampling_rate, we check | 260 | * than 20% (default), then we try to increase frequency |
243 | * - If current idle time is less than 20%, then we try to | 261 | * Every sampling_rate*sampling_down_factor, we look for a the lowest |
244 | * increase frequency | 262 | * frequency which can sustain the load while keeping idle time over |
245 | * Every sampling_rate*sampling_down_factor, we check | 263 | * 30%. If such a frequency exist, we try to decrease to this frequency. |
246 | * - If current idle time is more than 80%, then we try to | ||
247 | * decrease frequency | ||
248 | * | 264 | * |
249 | * Any frequency increase takes it to the maximum frequency. | 265 | * Any frequency increase takes it to the maximum frequency. |
250 | * Frequency reduction happens at minimum steps of | 266 | * Frequency reduction happens at minimum steps of |
251 | * 5% of max_frequency | 267 | * 5% (default) of current frequency |
252 | */ | 268 | */ |
253 | 269 | ||
254 | /* Check for frequency increase */ | 270 | /* Check for frequency increase */ |
255 | total_idle_ticks = kstat_cpu(cpu).cpustat.idle + | 271 | idle_ticks = UINT_MAX; |
256 | kstat_cpu(cpu).cpustat.iowait; | ||
257 | idle_ticks = total_idle_ticks - | ||
258 | this_dbs_info->prev_cpu_idle_up; | ||
259 | this_dbs_info->prev_cpu_idle_up = total_idle_ticks; | ||
260 | |||
261 | |||
262 | for_each_cpu_mask(j, policy->cpus) { | 272 | for_each_cpu_mask(j, policy->cpus) { |
263 | unsigned int tmp_idle_ticks; | 273 | unsigned int tmp_idle_ticks, total_idle_ticks; |
264 | struct cpu_dbs_info_s *j_dbs_info; | 274 | struct cpu_dbs_info_s *j_dbs_info; |
265 | 275 | ||
266 | if (j == cpu) | ||
267 | continue; | ||
268 | |||
269 | j_dbs_info = &per_cpu(cpu_dbs_info, j); | 276 | j_dbs_info = &per_cpu(cpu_dbs_info, j); |
270 | /* Check for frequency increase */ | 277 | total_idle_ticks = get_cpu_idle_time(j); |
271 | total_idle_ticks = kstat_cpu(j).cpustat.idle + | ||
272 | kstat_cpu(j).cpustat.iowait; | ||
273 | tmp_idle_ticks = total_idle_ticks - | 278 | tmp_idle_ticks = total_idle_ticks - |
274 | j_dbs_info->prev_cpu_idle_up; | 279 | j_dbs_info->prev_cpu_idle_up; |
275 | j_dbs_info->prev_cpu_idle_up = total_idle_ticks; | 280 | j_dbs_info->prev_cpu_idle_up = total_idle_ticks; |
@@ -281,13 +286,23 @@ static void dbs_check_cpu(int cpu) | |||
281 | /* Scale idle ticks by 100 and compare with up and down ticks */ | 286 | /* Scale idle ticks by 100 and compare with up and down ticks */ |
282 | idle_ticks *= 100; | 287 | idle_ticks *= 100; |
283 | up_idle_ticks = (100 - dbs_tuners_ins.up_threshold) * | 288 | up_idle_ticks = (100 - dbs_tuners_ins.up_threshold) * |
284 | sampling_rate_in_HZ(dbs_tuners_ins.sampling_rate); | 289 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate); |
285 | 290 | ||
286 | if (idle_ticks < up_idle_ticks) { | 291 | if (idle_ticks < up_idle_ticks) { |
292 | down_skip[cpu] = 0; | ||
293 | for_each_cpu_mask(j, policy->cpus) { | ||
294 | struct cpu_dbs_info_s *j_dbs_info; | ||
295 | |||
296 | j_dbs_info = &per_cpu(cpu_dbs_info, j); | ||
297 | j_dbs_info->prev_cpu_idle_down = | ||
298 | j_dbs_info->prev_cpu_idle_up; | ||
299 | } | ||
300 | /* if we are already at full speed then break out early */ | ||
301 | if (policy->cur == policy->max) | ||
302 | return; | ||
303 | |||
287 | __cpufreq_driver_target(policy, policy->max, | 304 | __cpufreq_driver_target(policy, policy->max, |
288 | CPUFREQ_RELATION_H); | 305 | CPUFREQ_RELATION_H); |
289 | down_skip[cpu] = 0; | ||
290 | this_dbs_info->prev_cpu_idle_down = total_idle_ticks; | ||
291 | return; | 306 | return; |
292 | } | 307 | } |
293 | 308 | ||
@@ -296,23 +311,14 @@ static void dbs_check_cpu(int cpu) | |||
296 | if (down_skip[cpu] < dbs_tuners_ins.sampling_down_factor) | 311 | if (down_skip[cpu] < dbs_tuners_ins.sampling_down_factor) |
297 | return; | 312 | return; |
298 | 313 | ||
299 | total_idle_ticks = kstat_cpu(cpu).cpustat.idle + | 314 | idle_ticks = UINT_MAX; |
300 | kstat_cpu(cpu).cpustat.iowait; | ||
301 | idle_ticks = total_idle_ticks - | ||
302 | this_dbs_info->prev_cpu_idle_down; | ||
303 | this_dbs_info->prev_cpu_idle_down = total_idle_ticks; | ||
304 | |||
305 | for_each_cpu_mask(j, policy->cpus) { | 315 | for_each_cpu_mask(j, policy->cpus) { |
306 | unsigned int tmp_idle_ticks; | 316 | unsigned int tmp_idle_ticks, total_idle_ticks; |
307 | struct cpu_dbs_info_s *j_dbs_info; | 317 | struct cpu_dbs_info_s *j_dbs_info; |
308 | 318 | ||
309 | if (j == cpu) | ||
310 | continue; | ||
311 | |||
312 | j_dbs_info = &per_cpu(cpu_dbs_info, j); | 319 | j_dbs_info = &per_cpu(cpu_dbs_info, j); |
313 | /* Check for frequency increase */ | 320 | /* Check for frequency decrease */ |
314 | total_idle_ticks = kstat_cpu(j).cpustat.idle + | 321 | total_idle_ticks = j_dbs_info->prev_cpu_idle_up; |
315 | kstat_cpu(j).cpustat.iowait; | ||
316 | tmp_idle_ticks = total_idle_ticks - | 322 | tmp_idle_ticks = total_idle_ticks - |
317 | j_dbs_info->prev_cpu_idle_down; | 323 | j_dbs_info->prev_cpu_idle_down; |
318 | j_dbs_info->prev_cpu_idle_down = total_idle_ticks; | 324 | j_dbs_info->prev_cpu_idle_down = total_idle_ticks; |
@@ -321,38 +327,37 @@ static void dbs_check_cpu(int cpu) | |||
321 | idle_ticks = tmp_idle_ticks; | 327 | idle_ticks = tmp_idle_ticks; |
322 | } | 328 | } |
323 | 329 | ||
324 | /* Scale idle ticks by 100 and compare with up and down ticks */ | ||
325 | idle_ticks *= 100; | ||
326 | down_skip[cpu] = 0; | 330 | down_skip[cpu] = 0; |
331 | /* if we cannot reduce the frequency anymore, break out early */ | ||
332 | if (policy->cur == policy->min) | ||
333 | return; | ||
327 | 334 | ||
335 | /* Compute how many ticks there are between two measurements */ | ||
328 | freq_down_sampling_rate = dbs_tuners_ins.sampling_rate * | 336 | freq_down_sampling_rate = dbs_tuners_ins.sampling_rate * |
329 | dbs_tuners_ins.sampling_down_factor; | 337 | dbs_tuners_ins.sampling_down_factor; |
330 | down_idle_ticks = (100 - dbs_tuners_ins.down_threshold) * | 338 | total_ticks = usecs_to_jiffies(freq_down_sampling_rate); |
331 | sampling_rate_in_HZ(freq_down_sampling_rate); | ||
332 | 339 | ||
333 | if (idle_ticks > down_idle_ticks ) { | 340 | /* |
334 | freq_down_step = (5 * policy->max) / 100; | 341 | * The optimal frequency is the frequency that is the lowest that |
335 | 342 | * can support the current CPU usage without triggering the up | |
336 | /* max freq cannot be less than 100. But who knows.... */ | 343 | * policy. To be safe, we focus 10 points under the threshold. |
337 | if (unlikely(freq_down_step == 0)) | 344 | */ |
338 | freq_down_step = 5; | 345 | freq_next = ((total_ticks - idle_ticks) * 100) / total_ticks; |
346 | freq_next = (freq_next * policy->cur) / | ||
347 | (dbs_tuners_ins.up_threshold - 10); | ||
339 | 348 | ||
340 | __cpufreq_driver_target(policy, | 349 | if (freq_next <= ((policy->cur * 95) / 100)) |
341 | policy->cur - freq_down_step, | 350 | __cpufreq_driver_target(policy, freq_next, CPUFREQ_RELATION_L); |
342 | CPUFREQ_RELATION_H); | ||
343 | return; | ||
344 | } | ||
345 | } | 351 | } |
346 | 352 | ||
347 | static void do_dbs_timer(void *data) | 353 | static void do_dbs_timer(void *data) |
348 | { | 354 | { |
349 | int i; | 355 | int i; |
350 | down(&dbs_sem); | 356 | down(&dbs_sem); |
351 | for (i = 0; i < NR_CPUS; i++) | 357 | for_each_online_cpu(i) |
352 | if (cpu_online(i)) | 358 | dbs_check_cpu(i); |
353 | dbs_check_cpu(i); | ||
354 | schedule_delayed_work(&dbs_work, | 359 | schedule_delayed_work(&dbs_work, |
355 | sampling_rate_in_HZ(dbs_tuners_ins.sampling_rate)); | 360 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); |
356 | up(&dbs_sem); | 361 | up(&dbs_sem); |
357 | } | 362 | } |
358 | 363 | ||
@@ -360,7 +365,7 @@ static inline void dbs_timer_init(void) | |||
360 | { | 365 | { |
361 | INIT_WORK(&dbs_work, do_dbs_timer, NULL); | 366 | INIT_WORK(&dbs_work, do_dbs_timer, NULL); |
362 | schedule_delayed_work(&dbs_work, | 367 | schedule_delayed_work(&dbs_work, |
363 | sampling_rate_in_HZ(dbs_tuners_ins.sampling_rate)); | 368 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); |
364 | return; | 369 | return; |
365 | } | 370 | } |
366 | 371 | ||
@@ -397,12 +402,9 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
397 | j_dbs_info = &per_cpu(cpu_dbs_info, j); | 402 | j_dbs_info = &per_cpu(cpu_dbs_info, j); |
398 | j_dbs_info->cur_policy = policy; | 403 | j_dbs_info->cur_policy = policy; |
399 | 404 | ||
400 | j_dbs_info->prev_cpu_idle_up = | 405 | j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(j); |
401 | kstat_cpu(j).cpustat.idle + | 406 | j_dbs_info->prev_cpu_idle_down |
402 | kstat_cpu(j).cpustat.iowait; | 407 | = j_dbs_info->prev_cpu_idle_up; |
403 | j_dbs_info->prev_cpu_idle_down = | ||
404 | kstat_cpu(j).cpustat.idle + | ||
405 | kstat_cpu(j).cpustat.iowait; | ||
406 | } | 408 | } |
407 | this_dbs_info->enable = 1; | 409 | this_dbs_info->enable = 1; |
408 | sysfs_create_group(&policy->kobj, &dbs_attr_group); | 410 | sysfs_create_group(&policy->kobj, &dbs_attr_group); |
@@ -422,6 +424,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
422 | def_sampling_rate = (latency / 1000) * | 424 | def_sampling_rate = (latency / 1000) * |
423 | DEF_SAMPLING_RATE_LATENCY_MULTIPLIER; | 425 | DEF_SAMPLING_RATE_LATENCY_MULTIPLIER; |
424 | dbs_tuners_ins.sampling_rate = def_sampling_rate; | 426 | dbs_tuners_ins.sampling_rate = def_sampling_rate; |
427 | dbs_tuners_ins.ignore_nice = 0; | ||
425 | 428 | ||
426 | dbs_timer_init(); | 429 | dbs_timer_init(); |
427 | } | 430 | } |
@@ -461,12 +464,11 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
461 | return 0; | 464 | return 0; |
462 | } | 465 | } |
463 | 466 | ||
464 | struct cpufreq_governor cpufreq_gov_dbs = { | 467 | static struct cpufreq_governor cpufreq_gov_dbs = { |
465 | .name = "ondemand", | 468 | .name = "ondemand", |
466 | .governor = cpufreq_governor_dbs, | 469 | .governor = cpufreq_governor_dbs, |
467 | .owner = THIS_MODULE, | 470 | .owner = THIS_MODULE, |
468 | }; | 471 | }; |
469 | EXPORT_SYMBOL(cpufreq_gov_dbs); | ||
470 | 472 | ||
471 | static int __init cpufreq_gov_dbs_init(void) | 473 | static int __init cpufreq_gov_dbs_init(void) |
472 | { | 474 | { |
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 2084593937c6..741b6b191e6a 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/percpu.h> | 19 | #include <linux/percpu.h> |
20 | #include <linux/kobject.h> | 20 | #include <linux/kobject.h> |
21 | #include <linux/spinlock.h> | 21 | #include <linux/spinlock.h> |
22 | #include <asm/cputime.h> | ||
22 | 23 | ||
23 | static spinlock_t cpufreq_stats_lock; | 24 | static spinlock_t cpufreq_stats_lock; |
24 | 25 | ||
@@ -29,20 +30,14 @@ static struct freq_attr _attr_##_name = {\ | |||
29 | .show = _show,\ | 30 | .show = _show,\ |
30 | }; | 31 | }; |
31 | 32 | ||
32 | static unsigned long | ||
33 | delta_time(unsigned long old, unsigned long new) | ||
34 | { | ||
35 | return (old > new) ? (old - new): (new + ~old + 1); | ||
36 | } | ||
37 | |||
38 | struct cpufreq_stats { | 33 | struct cpufreq_stats { |
39 | unsigned int cpu; | 34 | unsigned int cpu; |
40 | unsigned int total_trans; | 35 | unsigned int total_trans; |
41 | unsigned long long last_time; | 36 | unsigned long long last_time; |
42 | unsigned int max_state; | 37 | unsigned int max_state; |
43 | unsigned int state_num; | 38 | unsigned int state_num; |
44 | unsigned int last_index; | 39 | unsigned int last_index; |
45 | unsigned long long *time_in_state; | 40 | cputime64_t *time_in_state; |
46 | unsigned int *freq_table; | 41 | unsigned int *freq_table; |
47 | #ifdef CONFIG_CPU_FREQ_STAT_DETAILS | 42 | #ifdef CONFIG_CPU_FREQ_STAT_DETAILS |
48 | unsigned int *trans_table; | 43 | unsigned int *trans_table; |
@@ -60,12 +55,16 @@ static int | |||
60 | cpufreq_stats_update (unsigned int cpu) | 55 | cpufreq_stats_update (unsigned int cpu) |
61 | { | 56 | { |
62 | struct cpufreq_stats *stat; | 57 | struct cpufreq_stats *stat; |
58 | unsigned long long cur_time; | ||
59 | |||
60 | cur_time = get_jiffies_64(); | ||
63 | spin_lock(&cpufreq_stats_lock); | 61 | spin_lock(&cpufreq_stats_lock); |
64 | stat = cpufreq_stats_table[cpu]; | 62 | stat = cpufreq_stats_table[cpu]; |
65 | if (stat->time_in_state) | 63 | if (stat->time_in_state) |
66 | stat->time_in_state[stat->last_index] += | 64 | stat->time_in_state[stat->last_index] = |
67 | delta_time(stat->last_time, jiffies); | 65 | cputime64_add(stat->time_in_state[stat->last_index], |
68 | stat->last_time = jiffies; | 66 | cputime_sub(cur_time, stat->last_time)); |
67 | stat->last_time = cur_time; | ||
69 | spin_unlock(&cpufreq_stats_lock); | 68 | spin_unlock(&cpufreq_stats_lock); |
70 | return 0; | 69 | return 0; |
71 | } | 70 | } |
@@ -90,8 +89,8 @@ show_time_in_state(struct cpufreq_policy *policy, char *buf) | |||
90 | return 0; | 89 | return 0; |
91 | cpufreq_stats_update(stat->cpu); | 90 | cpufreq_stats_update(stat->cpu); |
92 | for (i = 0; i < stat->state_num; i++) { | 91 | for (i = 0; i < stat->state_num; i++) { |
93 | len += sprintf(buf + len, "%u %llu\n", | 92 | len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i], |
94 | stat->freq_table[i], stat->time_in_state[i]); | 93 | (unsigned long long)cputime64_to_clock_t(stat->time_in_state[i])); |
95 | } | 94 | } |
96 | return len; | 95 | return len; |
97 | } | 96 | } |
@@ -107,16 +106,30 @@ show_trans_table(struct cpufreq_policy *policy, char *buf) | |||
107 | if(!stat) | 106 | if(!stat) |
108 | return 0; | 107 | return 0; |
109 | cpufreq_stats_update(stat->cpu); | 108 | cpufreq_stats_update(stat->cpu); |
109 | len += snprintf(buf + len, PAGE_SIZE - len, " From : To\n"); | ||
110 | len += snprintf(buf + len, PAGE_SIZE - len, " : "); | ||
111 | for (i = 0; i < stat->state_num; i++) { | ||
112 | if (len >= PAGE_SIZE) | ||
113 | break; | ||
114 | len += snprintf(buf + len, PAGE_SIZE - len, "%9u ", | ||
115 | stat->freq_table[i]); | ||
116 | } | ||
117 | if (len >= PAGE_SIZE) | ||
118 | return len; | ||
119 | |||
120 | len += snprintf(buf + len, PAGE_SIZE - len, "\n"); | ||
121 | |||
110 | for (i = 0; i < stat->state_num; i++) { | 122 | for (i = 0; i < stat->state_num; i++) { |
111 | if (len >= PAGE_SIZE) | 123 | if (len >= PAGE_SIZE) |
112 | break; | 124 | break; |
113 | len += snprintf(buf + len, PAGE_SIZE - len, "%9u:\t", | 125 | |
126 | len += snprintf(buf + len, PAGE_SIZE - len, "%9u: ", | ||
114 | stat->freq_table[i]); | 127 | stat->freq_table[i]); |
115 | 128 | ||
116 | for (j = 0; j < stat->state_num; j++) { | 129 | for (j = 0; j < stat->state_num; j++) { |
117 | if (len >= PAGE_SIZE) | 130 | if (len >= PAGE_SIZE) |
118 | break; | 131 | break; |
119 | len += snprintf(buf + len, PAGE_SIZE - len, "%u\t", | 132 | len += snprintf(buf + len, PAGE_SIZE - len, "%9u ", |
120 | stat->trans_table[i*stat->max_state+j]); | 133 | stat->trans_table[i*stat->max_state+j]); |
121 | } | 134 | } |
122 | len += snprintf(buf + len, PAGE_SIZE - len, "\n"); | 135 | len += snprintf(buf + len, PAGE_SIZE - len, "\n"); |
@@ -197,7 +210,7 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy, | |||
197 | count++; | 210 | count++; |
198 | } | 211 | } |
199 | 212 | ||
200 | alloc_size = count * sizeof(int) + count * sizeof(long long); | 213 | alloc_size = count * sizeof(int) + count * sizeof(cputime64_t); |
201 | 214 | ||
202 | #ifdef CONFIG_CPU_FREQ_STAT_DETAILS | 215 | #ifdef CONFIG_CPU_FREQ_STAT_DETAILS |
203 | alloc_size += count * count * sizeof(int); | 216 | alloc_size += count * count * sizeof(int); |
@@ -224,7 +237,7 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy, | |||
224 | } | 237 | } |
225 | stat->state_num = j; | 238 | stat->state_num = j; |
226 | spin_lock(&cpufreq_stats_lock); | 239 | spin_lock(&cpufreq_stats_lock); |
227 | stat->last_time = jiffies; | 240 | stat->last_time = get_jiffies_64(); |
228 | stat->last_index = freq_table_get_index(stat, policy->cur); | 241 | stat->last_index = freq_table_get_index(stat, policy->cur); |
229 | spin_unlock(&cpufreq_stats_lock); | 242 | spin_unlock(&cpufreq_stats_lock); |
230 | cpufreq_cpu_put(data); | 243 | cpufreq_cpu_put(data); |
diff --git a/drivers/firmware/pcdp.c b/drivers/firmware/pcdp.c index 6d5df6c2efa2..df1b721154d2 100644 --- a/drivers/firmware/pcdp.c +++ b/drivers/firmware/pcdp.c | |||
@@ -11,6 +11,7 @@ | |||
11 | * published by the Free Software Foundation. | 11 | * published by the Free Software Foundation. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/config.h> | ||
14 | #include <linux/acpi.h> | 15 | #include <linux/acpi.h> |
15 | #include <linux/console.h> | 16 | #include <linux/console.h> |
16 | #include <linux/efi.h> | 17 | #include <linux/efi.h> |
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c index 35710818fe47..fdd881aee618 100644 --- a/drivers/i2c/busses/i2c-ali1563.c +++ b/drivers/i2c/busses/i2c-ali1563.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge | 2 | * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge |
3 | * | 3 | * |
4 | * Copyright (C) 2004 Patrick Mochel | 4 | * Copyright (C) 2004 Patrick Mochel |
5 | * 2005 Rudolf Marek <r.marek@sh.cvut.cz> | ||
5 | * | 6 | * |
6 | * The 1563 southbridge is deceptively similar to the 1533, with a | 7 | * The 1563 southbridge is deceptively similar to the 1533, with a |
7 | * few notable exceptions. One of those happens to be the fact they | 8 | * few notable exceptions. One of those happens to be the fact they |
@@ -57,10 +58,11 @@ | |||
57 | #define HST_CNTL2_BLOCK 0x05 | 58 | #define HST_CNTL2_BLOCK 0x05 |
58 | 59 | ||
59 | 60 | ||
61 | #define HST_CNTL2_SIZEMASK 0x38 | ||
60 | 62 | ||
61 | static unsigned short ali1563_smba; | 63 | static unsigned short ali1563_smba; |
62 | 64 | ||
63 | static int ali1563_transaction(struct i2c_adapter * a) | 65 | static int ali1563_transaction(struct i2c_adapter * a, int size) |
64 | { | 66 | { |
65 | u32 data; | 67 | u32 data; |
66 | int timeout; | 68 | int timeout; |
@@ -73,7 +75,7 @@ static int ali1563_transaction(struct i2c_adapter * a) | |||
73 | 75 | ||
74 | data = inb_p(SMB_HST_STS); | 76 | data = inb_p(SMB_HST_STS); |
75 | if (data & HST_STS_BAD) { | 77 | if (data & HST_STS_BAD) { |
76 | dev_warn(&a->dev,"ali1563: Trying to reset busy device\n"); | 78 | dev_err(&a->dev, "ali1563: Trying to reset busy device\n"); |
77 | outb_p(data | HST_STS_BAD,SMB_HST_STS); | 79 | outb_p(data | HST_STS_BAD,SMB_HST_STS); |
78 | data = inb_p(SMB_HST_STS); | 80 | data = inb_p(SMB_HST_STS); |
79 | if (data & HST_STS_BAD) | 81 | if (data & HST_STS_BAD) |
@@ -94,19 +96,31 @@ static int ali1563_transaction(struct i2c_adapter * a) | |||
94 | 96 | ||
95 | if (timeout && !(data & HST_STS_BAD)) | 97 | if (timeout && !(data & HST_STS_BAD)) |
96 | return 0; | 98 | return 0; |
97 | dev_warn(&a->dev, "SMBus Error: %s%s%s%s%s\n", | ||
98 | timeout ? "Timeout " : "", | ||
99 | data & HST_STS_FAIL ? "Transaction Failed " : "", | ||
100 | data & HST_STS_BUSERR ? "No response or Bus Collision " : "", | ||
101 | data & HST_STS_DEVERR ? "Device Error " : "", | ||
102 | !(data & HST_STS_DONE) ? "Transaction Never Finished " : ""); | ||
103 | 99 | ||
104 | if (!(data & HST_STS_DONE)) | 100 | if (!timeout) { |
101 | dev_err(&a->dev, "Timeout - Trying to KILL transaction!\n"); | ||
105 | /* Issue 'kill' to host controller */ | 102 | /* Issue 'kill' to host controller */ |
106 | outb_p(HST_CNTL2_KILL,SMB_HST_CNTL2); | 103 | outb_p(HST_CNTL2_KILL,SMB_HST_CNTL2); |
107 | else | 104 | data = inb_p(SMB_HST_STS); |
108 | /* Issue timeout to reset all devices on bus */ | 105 | } |
106 | |||
107 | /* device error - no response, ignore the autodetection case */ | ||
108 | if ((data & HST_STS_DEVERR) && (size != HST_CNTL2_QUICK)) { | ||
109 | dev_err(&a->dev, "Device error!\n"); | ||
110 | } | ||
111 | |||
112 | /* bus collision */ | ||
113 | if (data & HST_STS_BUSERR) { | ||
114 | dev_err(&a->dev, "Bus collision!\n"); | ||
115 | /* Issue timeout, hoping it helps */ | ||
109 | outb_p(HST_CNTL1_TIMEOUT,SMB_HST_CNTL1); | 116 | outb_p(HST_CNTL1_TIMEOUT,SMB_HST_CNTL1); |
117 | } | ||
118 | |||
119 | if (data & HST_STS_FAIL) { | ||
120 | dev_err(&a->dev, "Cleaning fail after KILL!\n"); | ||
121 | outb_p(0x0,SMB_HST_CNTL2); | ||
122 | } | ||
123 | |||
110 | return -1; | 124 | return -1; |
111 | } | 125 | } |
112 | 126 | ||
@@ -149,7 +163,7 @@ static int ali1563_block_start(struct i2c_adapter * a) | |||
149 | 163 | ||
150 | if (timeout && !(data & HST_STS_BAD)) | 164 | if (timeout && !(data & HST_STS_BAD)) |
151 | return 0; | 165 | return 0; |
152 | dev_warn(&a->dev, "SMBus Error: %s%s%s%s%s\n", | 166 | dev_err(&a->dev, "SMBus Error: %s%s%s%s%s\n", |
153 | timeout ? "Timeout " : "", | 167 | timeout ? "Timeout " : "", |
154 | data & HST_STS_FAIL ? "Transaction Failed " : "", | 168 | data & HST_STS_FAIL ? "Transaction Failed " : "", |
155 | data & HST_STS_BUSERR ? "No response or Bus Collision " : "", | 169 | data & HST_STS_BUSERR ? "No response or Bus Collision " : "", |
@@ -242,13 +256,15 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr, | |||
242 | } | 256 | } |
243 | 257 | ||
244 | outb_p(((addr & 0x7f) << 1) | (rw & 0x01), SMB_HST_ADD); | 258 | outb_p(((addr & 0x7f) << 1) | (rw & 0x01), SMB_HST_ADD); |
245 | outb_p(inb_p(SMB_HST_CNTL2) | (size << 3), SMB_HST_CNTL2); | 259 | outb_p((inb_p(SMB_HST_CNTL2) & ~HST_CNTL2_SIZEMASK) | (size << 3), SMB_HST_CNTL2); |
246 | 260 | ||
247 | /* Write the command register */ | 261 | /* Write the command register */ |
262 | |||
248 | switch(size) { | 263 | switch(size) { |
249 | case HST_CNTL2_BYTE: | 264 | case HST_CNTL2_BYTE: |
250 | if (rw== I2C_SMBUS_WRITE) | 265 | if (rw== I2C_SMBUS_WRITE) |
251 | outb_p(cmd, SMB_HST_CMD); | 266 | /* Beware it uses DAT0 register and not CMD! */ |
267 | outb_p(cmd, SMB_HST_DAT0); | ||
252 | break; | 268 | break; |
253 | case HST_CNTL2_BYTE_DATA: | 269 | case HST_CNTL2_BYTE_DATA: |
254 | outb_p(cmd, SMB_HST_CMD); | 270 | outb_p(cmd, SMB_HST_CMD); |
@@ -268,7 +284,7 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr, | |||
268 | goto Done; | 284 | goto Done; |
269 | } | 285 | } |
270 | 286 | ||
271 | if ((error = ali1563_transaction(a))) | 287 | if ((error = ali1563_transaction(a, size))) |
272 | goto Done; | 288 | goto Done; |
273 | 289 | ||
274 | if ((rw == I2C_SMBUS_WRITE) || (size == HST_CNTL2_QUICK)) | 290 | if ((rw == I2C_SMBUS_WRITE) || (size == HST_CNTL2_QUICK)) |
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 78e3e7b24d7d..39f3e9101ed4 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -1936,7 +1936,7 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
1936 | * NOTE! The "len" and "addr" checks should possibly have | 1936 | * NOTE! The "len" and "addr" checks should possibly have |
1937 | * separate masks. | 1937 | * separate masks. |
1938 | */ | 1938 | */ |
1939 | if ((rq->data_len & mask) || (addr & mask)) | 1939 | if ((rq->data_len & 15) || (addr & mask)) |
1940 | info->dma = 0; | 1940 | info->dma = 0; |
1941 | } | 1941 | } |
1942 | 1942 | ||
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c index 47225e324356..4e0f13d1d060 100644 --- a/drivers/ide/pci/amd74xx.c +++ b/drivers/ide/pci/amd74xx.c | |||
@@ -72,6 +72,7 @@ static struct amd_ide_chip { | |||
72 | { PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2, 0x50, AMD_UDMA_133 }, | 72 | { PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2, 0x50, AMD_UDMA_133 }, |
73 | { PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE, 0x50, AMD_UDMA_133 }, | 73 | { PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE, 0x50, AMD_UDMA_133 }, |
74 | { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE, 0x50, AMD_UDMA_133 }, | 74 | { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE, 0x50, AMD_UDMA_133 }, |
75 | { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE, 0x50, AMD_UDMA_133 }, | ||
75 | { 0 } | 76 | { 0 } |
76 | }; | 77 | }; |
77 | 78 | ||
@@ -487,6 +488,7 @@ static ide_pci_device_t amd74xx_chipsets[] __devinitdata = { | |||
487 | /* 12 */ DECLARE_NV_DEV("NFORCE3-250-SATA2"), | 488 | /* 12 */ DECLARE_NV_DEV("NFORCE3-250-SATA2"), |
488 | /* 13 */ DECLARE_NV_DEV("NFORCE-CK804"), | 489 | /* 13 */ DECLARE_NV_DEV("NFORCE-CK804"), |
489 | /* 14 */ DECLARE_NV_DEV("NFORCE-MCP04"), | 490 | /* 14 */ DECLARE_NV_DEV("NFORCE-MCP04"), |
491 | /* 15 */ DECLARE_NV_DEV("NFORCE-MCP51"), | ||
490 | }; | 492 | }; |
491 | 493 | ||
492 | static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) | 494 | static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) |
@@ -521,6 +523,7 @@ static struct pci_device_id amd74xx_pci_tbl[] = { | |||
521 | #endif | 523 | #endif |
522 | { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13 }, | 524 | { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13 }, |
523 | { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14 }, | 525 | { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14 }, |
526 | { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 15 }, | ||
524 | { 0, }, | 527 | { 0, }, |
525 | }; | 528 | }; |
526 | MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); | 529 | MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); |
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index af0446c6de82..48fdf1e517cf 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c | |||
@@ -54,7 +54,7 @@ static int atkbd_softraw = 1; | |||
54 | module_param_named(softraw, atkbd_softraw, bool, 0); | 54 | module_param_named(softraw, atkbd_softraw, bool, 0); |
55 | MODULE_PARM_DESC(softraw, "Use software generated rawmode"); | 55 | MODULE_PARM_DESC(softraw, "Use software generated rawmode"); |
56 | 56 | ||
57 | static int atkbd_scroll = 1; | 57 | static int atkbd_scroll = 0; |
58 | module_param_named(scroll, atkbd_scroll, bool, 0); | 58 | module_param_named(scroll, atkbd_scroll, bool, 0); |
59 | MODULE_PARM_DESC(scroll, "Enable scroll-wheel on MS Office and similar keyboards"); | 59 | MODULE_PARM_DESC(scroll, "Enable scroll-wheel on MS Office and similar keyboards"); |
60 | 60 | ||
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c index 1c563f905a59..a7f15d9f13e5 100644 --- a/drivers/net/hamradio/baycom_epp.c +++ b/drivers/net/hamradio/baycom_epp.c | |||
@@ -374,29 +374,6 @@ static inline void do_kiss_params(struct baycom_state *bc, | |||
374 | } | 374 | } |
375 | 375 | ||
376 | /* --------------------------------------------------------------------- */ | 376 | /* --------------------------------------------------------------------- */ |
377 | /* | ||
378 | * high performance HDLC encoder | ||
379 | * yes, it's ugly, but generates pretty good code | ||
380 | */ | ||
381 | |||
382 | #define ENCODEITERA(j) \ | ||
383 | ({ \ | ||
384 | if (!(notbitstream & (0x1f0 << j))) \ | ||
385 | goto stuff##j; \ | ||
386 | encodeend##j: ; \ | ||
387 | }) | ||
388 | |||
389 | #define ENCODEITERB(j) \ | ||
390 | ({ \ | ||
391 | stuff##j: \ | ||
392 | bitstream &= ~(0x100 << j); \ | ||
393 | bitbuf = (bitbuf & (((2 << j) << numbit) - 1)) | \ | ||
394 | ((bitbuf & ~(((2 << j) << numbit) - 1)) << 1); \ | ||
395 | numbit++; \ | ||
396 | notbitstream = ~bitstream; \ | ||
397 | goto encodeend##j; \ | ||
398 | }) | ||
399 | |||
400 | 377 | ||
401 | static void encode_hdlc(struct baycom_state *bc) | 378 | static void encode_hdlc(struct baycom_state *bc) |
402 | { | 379 | { |
@@ -405,6 +382,7 @@ static void encode_hdlc(struct baycom_state *bc) | |||
405 | int pkt_len; | 382 | int pkt_len; |
406 | unsigned bitstream, notbitstream, bitbuf, numbit, crc; | 383 | unsigned bitstream, notbitstream, bitbuf, numbit, crc; |
407 | unsigned char crcarr[2]; | 384 | unsigned char crcarr[2]; |
385 | int j; | ||
408 | 386 | ||
409 | if (bc->hdlctx.bufcnt > 0) | 387 | if (bc->hdlctx.bufcnt > 0) |
410 | return; | 388 | return; |
@@ -429,24 +407,14 @@ static void encode_hdlc(struct baycom_state *bc) | |||
429 | pkt_len--; | 407 | pkt_len--; |
430 | if (!pkt_len) | 408 | if (!pkt_len) |
431 | bp = crcarr; | 409 | bp = crcarr; |
432 | ENCODEITERA(0); | 410 | for (j = 0; j < 8; j++) |
433 | ENCODEITERA(1); | 411 | if (unlikely(!(notbitstream & (0x1f0 << j)))) { |
434 | ENCODEITERA(2); | 412 | bitstream &= ~(0x100 << j); |
435 | ENCODEITERA(3); | 413 | bitbuf = (bitbuf & (((2 << j) << numbit) - 1)) | |
436 | ENCODEITERA(4); | 414 | ((bitbuf & ~(((2 << j) << numbit) - 1)) << 1); |
437 | ENCODEITERA(5); | 415 | numbit++; |
438 | ENCODEITERA(6); | 416 | notbitstream = ~bitstream; |
439 | ENCODEITERA(7); | 417 | } |
440 | goto enditer; | ||
441 | ENCODEITERB(0); | ||
442 | ENCODEITERB(1); | ||
443 | ENCODEITERB(2); | ||
444 | ENCODEITERB(3); | ||
445 | ENCODEITERB(4); | ||
446 | ENCODEITERB(5); | ||
447 | ENCODEITERB(6); | ||
448 | ENCODEITERB(7); | ||
449 | enditer: | ||
450 | numbit += 8; | 418 | numbit += 8; |
451 | while (numbit >= 8) { | 419 | while (numbit >= 8) { |
452 | *wp++ = bitbuf; | 420 | *wp++ = bitbuf; |
@@ -610,37 +578,6 @@ static void do_rxpacket(struct net_device *dev) | |||
610 | bc->stats.rx_packets++; | 578 | bc->stats.rx_packets++; |
611 | } | 579 | } |
612 | 580 | ||
613 | #define DECODEITERA(j) \ | ||
614 | ({ \ | ||
615 | if (!(notbitstream & (0x0fc << j))) /* flag or abort */ \ | ||
616 | goto flgabrt##j; \ | ||
617 | if ((bitstream & (0x1f8 << j)) == (0xf8 << j)) /* stuffed bit */ \ | ||
618 | goto stuff##j; \ | ||
619 | enditer##j: ; \ | ||
620 | }) | ||
621 | |||
622 | #define DECODEITERB(j) \ | ||
623 | ({ \ | ||
624 | flgabrt##j: \ | ||
625 | if (!(notbitstream & (0x1fc << j))) { /* abort received */ \ | ||
626 | state = 0; \ | ||
627 | goto enditer##j; \ | ||
628 | } \ | ||
629 | if ((bitstream & (0x1fe << j)) != (0x0fc << j)) /* flag received */ \ | ||
630 | goto enditer##j; \ | ||
631 | if (state) \ | ||
632 | do_rxpacket(dev); \ | ||
633 | bc->hdlcrx.bufcnt = 0; \ | ||
634 | bc->hdlcrx.bufptr = bc->hdlcrx.buf; \ | ||
635 | state = 1; \ | ||
636 | numbits = 7-j; \ | ||
637 | goto enditer##j; \ | ||
638 | stuff##j: \ | ||
639 | numbits--; \ | ||
640 | bitbuf = (bitbuf & ((~0xff) << j)) | ((bitbuf & ~((~0xff) << j)) << 1); \ | ||
641 | goto enditer##j; \ | ||
642 | }) | ||
643 | |||
644 | static int receive(struct net_device *dev, int cnt) | 581 | static int receive(struct net_device *dev, int cnt) |
645 | { | 582 | { |
646 | struct baycom_state *bc = netdev_priv(dev); | 583 | struct baycom_state *bc = netdev_priv(dev); |
@@ -649,6 +586,7 @@ static int receive(struct net_device *dev, int cnt) | |||
649 | unsigned char tmp[128]; | 586 | unsigned char tmp[128]; |
650 | unsigned char *cp; | 587 | unsigned char *cp; |
651 | int cnt2, ret = 0; | 588 | int cnt2, ret = 0; |
589 | int j; | ||
652 | 590 | ||
653 | numbits = bc->hdlcrx.numbits; | 591 | numbits = bc->hdlcrx.numbits; |
654 | state = bc->hdlcrx.state; | 592 | state = bc->hdlcrx.state; |
@@ -669,24 +607,32 @@ static int receive(struct net_device *dev, int cnt) | |||
669 | bitbuf |= (*cp) << 8; | 607 | bitbuf |= (*cp) << 8; |
670 | numbits += 8; | 608 | numbits += 8; |
671 | notbitstream = ~bitstream; | 609 | notbitstream = ~bitstream; |
672 | DECODEITERA(0); | 610 | for (j = 0; j < 8; j++) { |
673 | DECODEITERA(1); | 611 | |
674 | DECODEITERA(2); | 612 | /* flag or abort */ |
675 | DECODEITERA(3); | 613 | if (unlikely(!(notbitstream & (0x0fc << j)))) { |
676 | DECODEITERA(4); | 614 | |
677 | DECODEITERA(5); | 615 | /* abort received */ |
678 | DECODEITERA(6); | 616 | if (!(notbitstream & (0x1fc << j))) |
679 | DECODEITERA(7); | 617 | state = 0; |
680 | goto enddec; | 618 | |
681 | DECODEITERB(0); | 619 | /* not flag received */ |
682 | DECODEITERB(1); | 620 | else if (!(bitstream & (0x1fe << j)) != (0x0fc << j)) { |
683 | DECODEITERB(2); | 621 | if (state) |
684 | DECODEITERB(3); | 622 | do_rxpacket(dev); |
685 | DECODEITERB(4); | 623 | bc->hdlcrx.bufcnt = 0; |
686 | DECODEITERB(5); | 624 | bc->hdlcrx.bufptr = bc->hdlcrx.buf; |
687 | DECODEITERB(6); | 625 | state = 1; |
688 | DECODEITERB(7); | 626 | numbits = 7-j; |
689 | enddec: | 627 | } |
628 | } | ||
629 | |||
630 | /* stuffed bit */ | ||
631 | else if (unlikely((bitstream & (0x1f8 << j)) == (0xf8 << j))) { | ||
632 | numbits--; | ||
633 | bitbuf = (bitbuf & ((~0xff) << j)) | ((bitbuf & ~((~0xff) << j)) << 1); | ||
634 | } | ||
635 | } | ||
690 | while (state && numbits >= 8) { | 636 | while (state && numbits >= 8) { |
691 | if (bc->hdlcrx.bufcnt >= TXBUFFER_SIZE) { | 637 | if (bc->hdlcrx.bufcnt >= TXBUFFER_SIZE) { |
692 | state = 0; | 638 | state = 0; |
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c index 41e517114807..c6e8b25f9685 100644 --- a/drivers/net/pcmcia/3c574_cs.c +++ b/drivers/net/pcmcia/3c574_cs.c | |||
@@ -1274,6 +1274,9 @@ static int el3_close(struct net_device *dev) | |||
1274 | spin_lock_irqsave(&lp->window_lock, flags); | 1274 | spin_lock_irqsave(&lp->window_lock, flags); |
1275 | update_stats(dev); | 1275 | update_stats(dev); |
1276 | spin_unlock_irqrestore(&lp->window_lock, flags); | 1276 | spin_unlock_irqrestore(&lp->window_lock, flags); |
1277 | |||
1278 | /* force interrupts off */ | ||
1279 | outw(SetIntrEnb | 0x0000, ioaddr + EL3_CMD); | ||
1277 | } | 1280 | } |
1278 | 1281 | ||
1279 | link->open--; | 1282 | link->open--; |
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index c59507f8a76b..b3768d844747 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -1585,8 +1585,8 @@ rtl8169_hw_start(struct net_device *dev) | |||
1585 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); | 1585 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); |
1586 | RTL_W8(EarlyTxThres, EarlyTxThld); | 1586 | RTL_W8(EarlyTxThres, EarlyTxThld); |
1587 | 1587 | ||
1588 | /* For gigabit rtl8169, MTU + header + CRC + VLAN */ | 1588 | /* Low hurts. Let's disable the filtering. */ |
1589 | RTL_W16(RxMaxSize, tp->rx_buf_sz); | 1589 | RTL_W16(RxMaxSize, 16383); |
1590 | 1590 | ||
1591 | /* Set Rx Config register */ | 1591 | /* Set Rx Config register */ |
1592 | i = rtl8169_rx_config | | 1592 | i = rtl8169_rx_config | |
@@ -2127,6 +2127,11 @@ rtl8169_tx_interrupt(struct net_device *dev, struct rtl8169_private *tp, | |||
2127 | } | 2127 | } |
2128 | } | 2128 | } |
2129 | 2129 | ||
2130 | static inline int rtl8169_fragmented_frame(u32 status) | ||
2131 | { | ||
2132 | return (status & (FirstFrag | LastFrag)) != (FirstFrag | LastFrag); | ||
2133 | } | ||
2134 | |||
2130 | static inline void rtl8169_rx_csum(struct sk_buff *skb, struct RxDesc *desc) | 2135 | static inline void rtl8169_rx_csum(struct sk_buff *skb, struct RxDesc *desc) |
2131 | { | 2136 | { |
2132 | u32 opts1 = le32_to_cpu(desc->opts1); | 2137 | u32 opts1 = le32_to_cpu(desc->opts1); |
@@ -2177,27 +2182,41 @@ rtl8169_rx_interrupt(struct net_device *dev, struct rtl8169_private *tp, | |||
2177 | 2182 | ||
2178 | while (rx_left > 0) { | 2183 | while (rx_left > 0) { |
2179 | unsigned int entry = cur_rx % NUM_RX_DESC; | 2184 | unsigned int entry = cur_rx % NUM_RX_DESC; |
2185 | struct RxDesc *desc = tp->RxDescArray + entry; | ||
2180 | u32 status; | 2186 | u32 status; |
2181 | 2187 | ||
2182 | rmb(); | 2188 | rmb(); |
2183 | status = le32_to_cpu(tp->RxDescArray[entry].opts1); | 2189 | status = le32_to_cpu(desc->opts1); |
2184 | 2190 | ||
2185 | if (status & DescOwn) | 2191 | if (status & DescOwn) |
2186 | break; | 2192 | break; |
2187 | if (status & RxRES) { | 2193 | if (status & RxRES) { |
2188 | printk(KERN_INFO "%s: Rx ERROR!!!\n", dev->name); | 2194 | printk(KERN_INFO "%s: Rx ERROR. status = %08x\n", |
2195 | dev->name, status); | ||
2189 | tp->stats.rx_errors++; | 2196 | tp->stats.rx_errors++; |
2190 | if (status & (RxRWT | RxRUNT)) | 2197 | if (status & (RxRWT | RxRUNT)) |
2191 | tp->stats.rx_length_errors++; | 2198 | tp->stats.rx_length_errors++; |
2192 | if (status & RxCRC) | 2199 | if (status & RxCRC) |
2193 | tp->stats.rx_crc_errors++; | 2200 | tp->stats.rx_crc_errors++; |
2201 | rtl8169_mark_to_asic(desc, tp->rx_buf_sz); | ||
2194 | } else { | 2202 | } else { |
2195 | struct RxDesc *desc = tp->RxDescArray + entry; | ||
2196 | struct sk_buff *skb = tp->Rx_skbuff[entry]; | 2203 | struct sk_buff *skb = tp->Rx_skbuff[entry]; |
2197 | int pkt_size = (status & 0x00001FFF) - 4; | 2204 | int pkt_size = (status & 0x00001FFF) - 4; |
2198 | void (*pci_action)(struct pci_dev *, dma_addr_t, | 2205 | void (*pci_action)(struct pci_dev *, dma_addr_t, |
2199 | size_t, int) = pci_dma_sync_single_for_device; | 2206 | size_t, int) = pci_dma_sync_single_for_device; |
2200 | 2207 | ||
2208 | /* | ||
2209 | * The driver does not support incoming fragmented | ||
2210 | * frames. They are seen as a symptom of over-mtu | ||
2211 | * sized frames. | ||
2212 | */ | ||
2213 | if (unlikely(rtl8169_fragmented_frame(status))) { | ||
2214 | tp->stats.rx_dropped++; | ||
2215 | tp->stats.rx_length_errors++; | ||
2216 | rtl8169_mark_to_asic(desc, tp->rx_buf_sz); | ||
2217 | goto move_on; | ||
2218 | } | ||
2219 | |||
2201 | rtl8169_rx_csum(skb, desc); | 2220 | rtl8169_rx_csum(skb, desc); |
2202 | 2221 | ||
2203 | pci_dma_sync_single_for_cpu(tp->pci_dev, | 2222 | pci_dma_sync_single_for_cpu(tp->pci_dev, |
@@ -2224,7 +2243,7 @@ rtl8169_rx_interrupt(struct net_device *dev, struct rtl8169_private *tp, | |||
2224 | tp->stats.rx_bytes += pkt_size; | 2243 | tp->stats.rx_bytes += pkt_size; |
2225 | tp->stats.rx_packets++; | 2244 | tp->stats.rx_packets++; |
2226 | } | 2245 | } |
2227 | 2246 | move_on: | |
2228 | cur_rx++; | 2247 | cur_rx++; |
2229 | rx_left--; | 2248 | rx_left--; |
2230 | } | 2249 | } |
diff --git a/drivers/net/shaper.c b/drivers/net/shaper.c index e68cf5fb4920..20edeb345792 100644 --- a/drivers/net/shaper.c +++ b/drivers/net/shaper.c | |||
@@ -100,35 +100,8 @@ static int sh_debug; /* Debug flag */ | |||
100 | 100 | ||
101 | #define SHAPER_BANNER "CymruNet Traffic Shaper BETA 0.04 for Linux 2.1\n" | 101 | #define SHAPER_BANNER "CymruNet Traffic Shaper BETA 0.04 for Linux 2.1\n" |
102 | 102 | ||
103 | /* | ||
104 | * Locking | ||
105 | */ | ||
106 | |||
107 | static int shaper_lock(struct shaper *sh) | ||
108 | { | ||
109 | /* | ||
110 | * Lock in an interrupt must fail | ||
111 | */ | ||
112 | while (test_and_set_bit(0, &sh->locked)) | ||
113 | { | ||
114 | if (!in_interrupt()) | ||
115 | sleep_on(&sh->wait_queue); | ||
116 | else | ||
117 | return 0; | ||
118 | |||
119 | } | ||
120 | return 1; | ||
121 | } | ||
122 | |||
123 | static void shaper_kick(struct shaper *sh); | 103 | static void shaper_kick(struct shaper *sh); |
124 | 104 | ||
125 | static void shaper_unlock(struct shaper *sh) | ||
126 | { | ||
127 | clear_bit(0, &sh->locked); | ||
128 | wake_up(&sh->wait_queue); | ||
129 | shaper_kick(sh); | ||
130 | } | ||
131 | |||
132 | /* | 105 | /* |
133 | * Compute clocks on a buffer | 106 | * Compute clocks on a buffer |
134 | */ | 107 | */ |
@@ -157,17 +130,15 @@ static void shaper_setspeed(struct shaper *shaper, int bitspersec) | |||
157 | * Throw a frame at a shaper. | 130 | * Throw a frame at a shaper. |
158 | */ | 131 | */ |
159 | 132 | ||
160 | static int shaper_qframe(struct shaper *shaper, struct sk_buff *skb) | 133 | |
134 | static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev) | ||
161 | { | 135 | { |
136 | struct shaper *shaper = dev->priv; | ||
162 | struct sk_buff *ptr; | 137 | struct sk_buff *ptr; |
163 | 138 | ||
164 | /* | 139 | if (down_trylock(&shaper->sem)) |
165 | * Get ready to work on this shaper. Lock may fail if its | 140 | return -1; |
166 | * an interrupt and locked. | 141 | |
167 | */ | ||
168 | |||
169 | if(!shaper_lock(shaper)) | ||
170 | return -1; | ||
171 | ptr=shaper->sendq.prev; | 142 | ptr=shaper->sendq.prev; |
172 | 143 | ||
173 | /* | 144 | /* |
@@ -260,7 +231,8 @@ static int shaper_qframe(struct shaper *shaper, struct sk_buff *skb) | |||
260 | dev_kfree_skb(ptr); | 231 | dev_kfree_skb(ptr); |
261 | shaper->stats.collisions++; | 232 | shaper->stats.collisions++; |
262 | } | 233 | } |
263 | shaper_unlock(shaper); | 234 | shaper_kick(shaper); |
235 | up(&shaper->sem); | ||
264 | return 0; | 236 | return 0; |
265 | } | 237 | } |
266 | 238 | ||
@@ -297,8 +269,13 @@ static void shaper_queue_xmit(struct shaper *shaper, struct sk_buff *skb) | |||
297 | 269 | ||
298 | static void shaper_timer(unsigned long data) | 270 | static void shaper_timer(unsigned long data) |
299 | { | 271 | { |
300 | struct shaper *sh=(struct shaper *)data; | 272 | struct shaper *shaper = (struct shaper *)data; |
301 | shaper_kick(sh); | 273 | |
274 | if (!down_trylock(&shaper->sem)) { | ||
275 | shaper_kick(shaper); | ||
276 | up(&shaper->sem); | ||
277 | } else | ||
278 | mod_timer(&shaper->timer, jiffies); | ||
302 | } | 279 | } |
303 | 280 | ||
304 | /* | 281 | /* |
@@ -311,19 +288,6 @@ static void shaper_kick(struct shaper *shaper) | |||
311 | struct sk_buff *skb; | 288 | struct sk_buff *skb; |
312 | 289 | ||
313 | /* | 290 | /* |
314 | * Shaper unlock will kick | ||
315 | */ | ||
316 | |||
317 | if (test_and_set_bit(0, &shaper->locked)) | ||
318 | { | ||
319 | if(sh_debug) | ||
320 | printk("Shaper locked.\n"); | ||
321 | mod_timer(&shaper->timer, jiffies); | ||
322 | return; | ||
323 | } | ||
324 | |||
325 | |||
326 | /* | ||
327 | * Walk the list (may be empty) | 291 | * Walk the list (may be empty) |
328 | */ | 292 | */ |
329 | 293 | ||
@@ -364,8 +328,6 @@ static void shaper_kick(struct shaper *shaper) | |||
364 | 328 | ||
365 | if(skb!=NULL) | 329 | if(skb!=NULL) |
366 | mod_timer(&shaper->timer, SHAPERCB(skb)->shapeclock); | 330 | mod_timer(&shaper->timer, SHAPERCB(skb)->shapeclock); |
367 | |||
368 | clear_bit(0, &shaper->locked); | ||
369 | } | 331 | } |
370 | 332 | ||
371 | 333 | ||
@@ -376,14 +338,12 @@ static void shaper_kick(struct shaper *shaper) | |||
376 | static void shaper_flush(struct shaper *shaper) | 338 | static void shaper_flush(struct shaper *shaper) |
377 | { | 339 | { |
378 | struct sk_buff *skb; | 340 | struct sk_buff *skb; |
379 | if(!shaper_lock(shaper)) | 341 | |
380 | { | 342 | down(&shaper->sem); |
381 | printk(KERN_ERR "shaper: shaper_flush() called by an irq!\n"); | ||
382 | return; | ||
383 | } | ||
384 | while((skb=skb_dequeue(&shaper->sendq))!=NULL) | 343 | while((skb=skb_dequeue(&shaper->sendq))!=NULL) |
385 | dev_kfree_skb(skb); | 344 | dev_kfree_skb(skb); |
386 | shaper_unlock(shaper); | 345 | shaper_kick(shaper); |
346 | up(&shaper->sem); | ||
387 | } | 347 | } |
388 | 348 | ||
389 | /* | 349 | /* |
@@ -426,13 +386,6 @@ static int shaper_close(struct net_device *dev) | |||
426 | * ARP and other resolutions and not before. | 386 | * ARP and other resolutions and not before. |
427 | */ | 387 | */ |
428 | 388 | ||
429 | |||
430 | static int shaper_start_xmit(struct sk_buff *skb, struct net_device *dev) | ||
431 | { | ||
432 | struct shaper *sh=dev->priv; | ||
433 | return shaper_qframe(sh, skb); | ||
434 | } | ||
435 | |||
436 | static struct net_device_stats *shaper_get_stats(struct net_device *dev) | 389 | static struct net_device_stats *shaper_get_stats(struct net_device *dev) |
437 | { | 390 | { |
438 | struct shaper *sh=dev->priv; | 391 | struct shaper *sh=dev->priv; |
@@ -623,7 +576,6 @@ static void shaper_init_priv(struct net_device *dev) | |||
623 | init_timer(&sh->timer); | 576 | init_timer(&sh->timer); |
624 | sh->timer.function=shaper_timer; | 577 | sh->timer.function=shaper_timer; |
625 | sh->timer.data=(unsigned long)sh; | 578 | sh->timer.data=(unsigned long)sh; |
626 | init_waitqueue_head(&sh->wait_queue); | ||
627 | } | 579 | } |
628 | 580 | ||
629 | /* | 581 | /* |
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index fc9b5cd957aa..e944aac258e3 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -7,7 +7,12 @@ | |||
7 | * Copyright (C) 2005 Broadcom Corporation. | 7 | * Copyright (C) 2005 Broadcom Corporation. |
8 | * | 8 | * |
9 | * Firmware is: | 9 | * Firmware is: |
10 | * Copyright (C) 2000-2003 Broadcom Corporation. | 10 | * Derived from proprietary unpublished source code, |
11 | * Copyright (C) 2000-2003 Broadcom Corporation. | ||
12 | * | ||
13 | * Permission is hereby granted for the distribution of this firmware | ||
14 | * data in hexadecimal or equivalent format, provided this copyright | ||
15 | * notice is accompanying it. | ||
11 | */ | 16 | */ |
12 | 17 | ||
13 | #include <linux/config.h> | 18 | #include <linux/config.h> |
@@ -61,8 +66,8 @@ | |||
61 | 66 | ||
62 | #define DRV_MODULE_NAME "tg3" | 67 | #define DRV_MODULE_NAME "tg3" |
63 | #define PFX DRV_MODULE_NAME ": " | 68 | #define PFX DRV_MODULE_NAME ": " |
64 | #define DRV_MODULE_VERSION "3.29" | 69 | #define DRV_MODULE_VERSION "3.30" |
65 | #define DRV_MODULE_RELDATE "May 23, 2005" | 70 | #define DRV_MODULE_RELDATE "June 6, 2005" |
66 | 71 | ||
67 | #define TG3_DEF_MAC_MODE 0 | 72 | #define TG3_DEF_MAC_MODE 0 |
68 | #define TG3_DEF_RX_MODE 0 | 73 | #define TG3_DEF_RX_MODE 0 |
@@ -8555,6 +8560,16 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp) | |||
8555 | 8560 | ||
8556 | case NIC_SRAM_DATA_CFG_LED_MODE_MAC: | 8561 | case NIC_SRAM_DATA_CFG_LED_MODE_MAC: |
8557 | tp->led_ctrl = LED_CTRL_MODE_MAC; | 8562 | tp->led_ctrl = LED_CTRL_MODE_MAC; |
8563 | |||
8564 | /* Default to PHY_1_MODE if 0 (MAC_MODE) is | ||
8565 | * read on some older 5700/5701 bootcode. | ||
8566 | */ | ||
8567 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == | ||
8568 | ASIC_REV_5700 || | ||
8569 | GET_ASIC_REV(tp->pci_chip_rev_id) == | ||
8570 | ASIC_REV_5701) | ||
8571 | tp->led_ctrl = LED_CTRL_MODE_PHY_1; | ||
8572 | |||
8558 | break; | 8573 | break; |
8559 | 8574 | ||
8560 | case SHASTA_EXT_LED_SHARED: | 8575 | case SHASTA_EXT_LED_SHARED: |
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c index 9e9dab7fe86a..8132d946c384 100644 --- a/drivers/pci/hotplug/cpci_hotplug_core.c +++ b/drivers/pci/hotplug/cpci_hotplug_core.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * CompactPCI Hot Plug Driver | 2 | * CompactPCI Hot Plug Driver |
3 | * | 3 | * |
4 | * Copyright (C) 2002 SOMA Networks, Inc. | 4 | * Copyright (C) 2002,2005 SOMA Networks, Inc. |
5 | * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com) | 5 | * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com) |
6 | * Copyright (C) 2001 IBM Corp. | 6 | * Copyright (C) 2001 IBM Corp. |
7 | * | 7 | * |
@@ -45,10 +45,10 @@ | |||
45 | 45 | ||
46 | #define dbg(format, arg...) \ | 46 | #define dbg(format, arg...) \ |
47 | do { \ | 47 | do { \ |
48 | if(cpci_debug) \ | 48 | if (cpci_debug) \ |
49 | printk (KERN_DEBUG "%s: " format "\n", \ | 49 | printk (KERN_DEBUG "%s: " format "\n", \ |
50 | MY_NAME , ## arg); \ | 50 | MY_NAME , ## arg); \ |
51 | } while(0) | 51 | } while (0) |
52 | #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) | 52 | #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) |
53 | #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) | 53 | #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) |
54 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) | 54 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) |
@@ -111,10 +111,8 @@ enable_slot(struct hotplug_slot *hotplug_slot) | |||
111 | 111 | ||
112 | dbg("%s - physical_slot = %s", __FUNCTION__, hotplug_slot->name); | 112 | dbg("%s - physical_slot = %s", __FUNCTION__, hotplug_slot->name); |
113 | 113 | ||
114 | if(controller->ops->set_power) { | 114 | if (controller->ops->set_power) |
115 | retval = controller->ops->set_power(slot, 1); | 115 | retval = controller->ops->set_power(slot, 1); |
116 | } | ||
117 | |||
118 | return retval; | 116 | return retval; |
119 | } | 117 | } |
120 | 118 | ||
@@ -126,37 +124,41 @@ disable_slot(struct hotplug_slot *hotplug_slot) | |||
126 | 124 | ||
127 | dbg("%s - physical_slot = %s", __FUNCTION__, hotplug_slot->name); | 125 | dbg("%s - physical_slot = %s", __FUNCTION__, hotplug_slot->name); |
128 | 126 | ||
127 | down_write(&list_rwsem); | ||
128 | |||
129 | /* Unconfigure device */ | 129 | /* Unconfigure device */ |
130 | dbg("%s - unconfiguring slot %s", | 130 | dbg("%s - unconfiguring slot %s", |
131 | __FUNCTION__, slot->hotplug_slot->name); | 131 | __FUNCTION__, slot->hotplug_slot->name); |
132 | if((retval = cpci_unconfigure_slot(slot))) { | 132 | if ((retval = cpci_unconfigure_slot(slot))) { |
133 | err("%s - could not unconfigure slot %s", | 133 | err("%s - could not unconfigure slot %s", |
134 | __FUNCTION__, slot->hotplug_slot->name); | 134 | __FUNCTION__, slot->hotplug_slot->name); |
135 | return retval; | 135 | goto disable_error; |
136 | } | 136 | } |
137 | dbg("%s - finished unconfiguring slot %s", | 137 | dbg("%s - finished unconfiguring slot %s", |
138 | __FUNCTION__, slot->hotplug_slot->name); | 138 | __FUNCTION__, slot->hotplug_slot->name); |
139 | 139 | ||
140 | /* Clear EXT (by setting it) */ | 140 | /* Clear EXT (by setting it) */ |
141 | if(cpci_clear_ext(slot)) { | 141 | if (cpci_clear_ext(slot)) { |
142 | err("%s - could not clear EXT for slot %s", | 142 | err("%s - could not clear EXT for slot %s", |
143 | __FUNCTION__, slot->hotplug_slot->name); | 143 | __FUNCTION__, slot->hotplug_slot->name); |
144 | retval = -ENODEV; | 144 | retval = -ENODEV; |
145 | goto disable_error; | ||
145 | } | 146 | } |
146 | cpci_led_on(slot); | 147 | cpci_led_on(slot); |
147 | 148 | ||
148 | if(controller->ops->set_power) { | 149 | if (controller->ops->set_power) |
149 | retval = controller->ops->set_power(slot, 0); | 150 | if ((retval = controller->ops->set_power(slot, 0))) |
150 | } | 151 | goto disable_error; |
151 | 152 | ||
152 | if(update_adapter_status(slot->hotplug_slot, 0)) { | 153 | if (update_adapter_status(slot->hotplug_slot, 0)) |
153 | warn("failure to update adapter file"); | 154 | warn("failure to update adapter file"); |
154 | } | ||
155 | 155 | ||
156 | if(slot->extracting) { | 156 | if (slot->extracting) { |
157 | slot->extracting = 0; | 157 | slot->extracting = 0; |
158 | atomic_dec(&extracting); | 158 | atomic_dec(&extracting); |
159 | } | 159 | } |
160 | disable_error: | ||
161 | up_write(&list_rwsem); | ||
160 | return retval; | 162 | return retval; |
161 | } | 163 | } |
162 | 164 | ||
@@ -165,9 +167,8 @@ cpci_get_power_status(struct slot *slot) | |||
165 | { | 167 | { |
166 | u8 power = 1; | 168 | u8 power = 1; |
167 | 169 | ||
168 | if(controller->ops->get_power) { | 170 | if (controller->ops->get_power) |
169 | power = controller->ops->get_power(slot); | 171 | power = controller->ops->get_power(slot); |
170 | } | ||
171 | return power; | 172 | return power; |
172 | } | 173 | } |
173 | 174 | ||
@@ -237,9 +238,8 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last) | |||
237 | int status = -ENOMEM; | 238 | int status = -ENOMEM; |
238 | int i; | 239 | int i; |
239 | 240 | ||
240 | if(!(controller && bus)) { | 241 | if (!(controller && bus)) |
241 | return -ENODEV; | 242 | return -ENODEV; |
242 | } | ||
243 | 243 | ||
244 | /* | 244 | /* |
245 | * Create a structure for each slot, and register that slot | 245 | * Create a structure for each slot, and register that slot |
@@ -316,32 +316,30 @@ int | |||
316 | cpci_hp_unregister_bus(struct pci_bus *bus) | 316 | cpci_hp_unregister_bus(struct pci_bus *bus) |
317 | { | 317 | { |
318 | struct slot *slot; | 318 | struct slot *slot; |
319 | struct list_head *tmp; | 319 | struct slot *tmp; |
320 | struct list_head *next; | 320 | int status = 0; |
321 | int status; | ||
322 | 321 | ||
323 | down_write(&list_rwsem); | 322 | down_write(&list_rwsem); |
324 | if(!slots) { | 323 | if (!slots) { |
325 | up_write(&list_rwsem); | 324 | up_write(&list_rwsem); |
326 | return -1; | 325 | return -1; |
327 | } | 326 | } |
328 | list_for_each_safe(tmp, next, &slot_list) { | 327 | list_for_each_entry_safe(slot, tmp, &slot_list, slot_list) { |
329 | slot = list_entry(tmp, struct slot, slot_list); | 328 | if (slot->bus == bus) { |
330 | if(slot->bus == bus) { | 329 | list_del(&slot->slot_list); |
330 | slots--; | ||
331 | |||
331 | dbg("deregistering slot %s", slot->hotplug_slot->name); | 332 | dbg("deregistering slot %s", slot->hotplug_slot->name); |
332 | status = pci_hp_deregister(slot->hotplug_slot); | 333 | status = pci_hp_deregister(slot->hotplug_slot); |
333 | if(status) { | 334 | if (status) { |
334 | err("pci_hp_deregister failed with error %d", | 335 | err("pci_hp_deregister failed with error %d", |
335 | status); | 336 | status); |
336 | return status; | 337 | break; |
337 | } | 338 | } |
338 | |||
339 | list_del(&slot->slot_list); | ||
340 | slots--; | ||
341 | } | 339 | } |
342 | } | 340 | } |
343 | up_write(&list_rwsem); | 341 | up_write(&list_rwsem); |
344 | return 0; | 342 | return status; |
345 | } | 343 | } |
346 | 344 | ||
347 | /* This is the interrupt mode interrupt handler */ | 345 | /* This is the interrupt mode interrupt handler */ |
@@ -351,7 +349,7 @@ cpci_hp_intr(int irq, void *data, struct pt_regs *regs) | |||
351 | dbg("entered cpci_hp_intr"); | 349 | dbg("entered cpci_hp_intr"); |
352 | 350 | ||
353 | /* Check to see if it was our interrupt */ | 351 | /* Check to see if it was our interrupt */ |
354 | if((controller->irq_flags & SA_SHIRQ) && | 352 | if ((controller->irq_flags & SA_SHIRQ) && |
355 | !controller->ops->check_irq(controller->dev_id)) { | 353 | !controller->ops->check_irq(controller->dev_id)) { |
356 | dbg("exited cpci_hp_intr, not our interrupt"); | 354 | dbg("exited cpci_hp_intr, not our interrupt"); |
357 | return IRQ_NONE; | 355 | return IRQ_NONE; |
@@ -373,38 +371,30 @@ cpci_hp_intr(int irq, void *data, struct pt_regs *regs) | |||
373 | * INS bits of the cold-inserted devices. | 371 | * INS bits of the cold-inserted devices. |
374 | */ | 372 | */ |
375 | static int | 373 | static int |
376 | init_slots(void) | 374 | init_slots(int clear_ins) |
377 | { | 375 | { |
378 | struct slot *slot; | 376 | struct slot *slot; |
379 | struct list_head *tmp; | ||
380 | struct pci_dev* dev; | 377 | struct pci_dev* dev; |
381 | 378 | ||
382 | dbg("%s - enter", __FUNCTION__); | 379 | dbg("%s - enter", __FUNCTION__); |
383 | down_read(&list_rwsem); | 380 | down_read(&list_rwsem); |
384 | if(!slots) { | 381 | if (!slots) { |
385 | up_read(&list_rwsem); | 382 | up_read(&list_rwsem); |
386 | return -1; | 383 | return -1; |
387 | } | 384 | } |
388 | list_for_each(tmp, &slot_list) { | 385 | list_for_each_entry(slot, &slot_list, slot_list) { |
389 | slot = list_entry(tmp, struct slot, slot_list); | ||
390 | dbg("%s - looking at slot %s", | 386 | dbg("%s - looking at slot %s", |
391 | __FUNCTION__, slot->hotplug_slot->name); | 387 | __FUNCTION__, slot->hotplug_slot->name); |
392 | if(cpci_check_and_clear_ins(slot)) { | 388 | if (clear_ins && cpci_check_and_clear_ins(slot)) |
393 | dbg("%s - cleared INS for slot %s", | 389 | dbg("%s - cleared INS for slot %s", |
394 | __FUNCTION__, slot->hotplug_slot->name); | 390 | __FUNCTION__, slot->hotplug_slot->name); |
395 | dev = pci_find_slot(slot->bus->number, PCI_DEVFN(slot->number, 0)); | 391 | dev = pci_get_slot(slot->bus, PCI_DEVFN(slot->number, 0)); |
396 | if(dev) { | 392 | if (dev) { |
397 | if(update_adapter_status(slot->hotplug_slot, 1)) { | 393 | if (update_adapter_status(slot->hotplug_slot, 1)) |
398 | warn("failure to update adapter file"); | 394 | warn("failure to update adapter file"); |
399 | } | 395 | if (update_latch_status(slot->hotplug_slot, 1)) |
400 | if(update_latch_status(slot->hotplug_slot, 1)) { | 396 | warn("failure to update latch file"); |
401 | warn("failure to update latch file"); | 397 | slot->dev = dev; |
402 | } | ||
403 | slot->dev = dev; | ||
404 | } else { | ||
405 | err("%s - no driver attached to device in slot %s", | ||
406 | __FUNCTION__, slot->hotplug_slot->name); | ||
407 | } | ||
408 | } | 398 | } |
409 | } | 399 | } |
410 | up_read(&list_rwsem); | 400 | up_read(&list_rwsem); |
@@ -416,26 +406,28 @@ static int | |||
416 | check_slots(void) | 406 | check_slots(void) |
417 | { | 407 | { |
418 | struct slot *slot; | 408 | struct slot *slot; |
419 | struct list_head *tmp; | ||
420 | int extracted; | 409 | int extracted; |
421 | int inserted; | 410 | int inserted; |
422 | u16 hs_csr; | 411 | u16 hs_csr; |
423 | 412 | ||
424 | down_read(&list_rwsem); | 413 | down_read(&list_rwsem); |
425 | if(!slots) { | 414 | if (!slots) { |
426 | up_read(&list_rwsem); | 415 | up_read(&list_rwsem); |
427 | err("no slots registered, shutting down"); | 416 | err("no slots registered, shutting down"); |
428 | return -1; | 417 | return -1; |
429 | } | 418 | } |
430 | extracted = inserted = 0; | 419 | extracted = inserted = 0; |
431 | list_for_each(tmp, &slot_list) { | 420 | list_for_each_entry(slot, &slot_list, slot_list) { |
432 | slot = list_entry(tmp, struct slot, slot_list); | ||
433 | dbg("%s - looking at slot %s", | 421 | dbg("%s - looking at slot %s", |
434 | __FUNCTION__, slot->hotplug_slot->name); | 422 | __FUNCTION__, slot->hotplug_slot->name); |
435 | if(cpci_check_and_clear_ins(slot)) { | 423 | if (cpci_check_and_clear_ins(slot)) { |
436 | /* Some broken hardware (e.g. PLX 9054AB) asserts ENUM# twice... */ | 424 | /* |
437 | if(slot->dev) { | 425 | * Some broken hardware (e.g. PLX 9054AB) asserts |
438 | warn("slot %s already inserted", slot->hotplug_slot->name); | 426 | * ENUM# twice... |
427 | */ | ||
428 | if (slot->dev) { | ||
429 | warn("slot %s already inserted", | ||
430 | slot->hotplug_slot->name); | ||
439 | inserted++; | 431 | inserted++; |
440 | continue; | 432 | continue; |
441 | } | 433 | } |
@@ -452,7 +444,7 @@ check_slots(void) | |||
452 | /* Configure device */ | 444 | /* Configure device */ |
453 | dbg("%s - configuring slot %s", | 445 | dbg("%s - configuring slot %s", |
454 | __FUNCTION__, slot->hotplug_slot->name); | 446 | __FUNCTION__, slot->hotplug_slot->name); |
455 | if(cpci_configure_slot(slot)) { | 447 | if (cpci_configure_slot(slot)) { |
456 | err("%s - could not configure slot %s", | 448 | err("%s - could not configure slot %s", |
457 | __FUNCTION__, slot->hotplug_slot->name); | 449 | __FUNCTION__, slot->hotplug_slot->name); |
458 | continue; | 450 | continue; |
@@ -465,13 +457,11 @@ check_slots(void) | |||
465 | dbg("%s - slot %s HS_CSR (2) = %04x", | 457 | dbg("%s - slot %s HS_CSR (2) = %04x", |
466 | __FUNCTION__, slot->hotplug_slot->name, hs_csr); | 458 | __FUNCTION__, slot->hotplug_slot->name, hs_csr); |
467 | 459 | ||
468 | if(update_latch_status(slot->hotplug_slot, 1)) { | 460 | if (update_latch_status(slot->hotplug_slot, 1)) |
469 | warn("failure to update latch file"); | 461 | warn("failure to update latch file"); |
470 | } | ||
471 | 462 | ||
472 | if(update_adapter_status(slot->hotplug_slot, 1)) { | 463 | if (update_adapter_status(slot->hotplug_slot, 1)) |
473 | warn("failure to update adapter file"); | 464 | warn("failure to update adapter file"); |
474 | } | ||
475 | 465 | ||
476 | cpci_led_off(slot); | 466 | cpci_led_off(slot); |
477 | 467 | ||
@@ -481,7 +471,7 @@ check_slots(void) | |||
481 | __FUNCTION__, slot->hotplug_slot->name, hs_csr); | 471 | __FUNCTION__, slot->hotplug_slot->name, hs_csr); |
482 | 472 | ||
483 | inserted++; | 473 | inserted++; |
484 | } else if(cpci_check_ext(slot)) { | 474 | } else if (cpci_check_ext(slot)) { |
485 | /* Process extraction request */ | 475 | /* Process extraction request */ |
486 | dbg("%s - slot %s extracted", | 476 | dbg("%s - slot %s extracted", |
487 | __FUNCTION__, slot->hotplug_slot->name); | 477 | __FUNCTION__, slot->hotplug_slot->name); |
@@ -491,27 +481,25 @@ check_slots(void) | |||
491 | dbg("%s - slot %s HS_CSR = %04x", | 481 | dbg("%s - slot %s HS_CSR = %04x", |
492 | __FUNCTION__, slot->hotplug_slot->name, hs_csr); | 482 | __FUNCTION__, slot->hotplug_slot->name, hs_csr); |
493 | 483 | ||
494 | if(!slot->extracting) { | 484 | if (!slot->extracting) { |
495 | if(update_latch_status(slot->hotplug_slot, 0)) { | 485 | if (update_latch_status(slot->hotplug_slot, 0)) { |
496 | warn("failure to update latch file"); | 486 | warn("failure to update latch file"); |
497 | |||
498 | } | 487 | } |
499 | atomic_inc(&extracting); | ||
500 | slot->extracting = 1; | 488 | slot->extracting = 1; |
489 | atomic_inc(&extracting); | ||
501 | } | 490 | } |
502 | extracted++; | 491 | extracted++; |
503 | } else if(slot->extracting) { | 492 | } else if (slot->extracting) { |
504 | hs_csr = cpci_get_hs_csr(slot); | 493 | hs_csr = cpci_get_hs_csr(slot); |
505 | if(hs_csr == 0xffff) { | 494 | if (hs_csr == 0xffff) { |
506 | /* | 495 | /* |
507 | * Hmmm, we're likely hosed at this point, should we | 496 | * Hmmm, we're likely hosed at this point, should we |
508 | * bother trying to tell the driver or not? | 497 | * bother trying to tell the driver or not? |
509 | */ | 498 | */ |
510 | err("card in slot %s was improperly removed", | 499 | err("card in slot %s was improperly removed", |
511 | slot->hotplug_slot->name); | 500 | slot->hotplug_slot->name); |
512 | if(update_adapter_status(slot->hotplug_slot, 0)) { | 501 | if (update_adapter_status(slot->hotplug_slot, 0)) |
513 | warn("failure to update adapter file"); | 502 | warn("failure to update adapter file"); |
514 | } | ||
515 | slot->extracting = 0; | 503 | slot->extracting = 0; |
516 | atomic_dec(&extracting); | 504 | atomic_dec(&extracting); |
517 | } | 505 | } |
@@ -520,10 +508,9 @@ check_slots(void) | |||
520 | up_read(&list_rwsem); | 508 | up_read(&list_rwsem); |
521 | dbg("inserted=%d, extracted=%d, extracting=%d", | 509 | dbg("inserted=%d, extracted=%d, extracting=%d", |
522 | inserted, extracted, atomic_read(&extracting)); | 510 | inserted, extracted, atomic_read(&extracting)); |
523 | if(inserted || extracted) { | 511 | if (inserted || extracted) |
524 | return extracted; | 512 | return extracted; |
525 | } | 513 | else if (!atomic_read(&extracting)) { |
526 | else if(!atomic_read(&extracting)) { | ||
527 | err("cannot find ENUM# source, shutting down"); | 514 | err("cannot find ENUM# source, shutting down"); |
528 | return -1; | 515 | return -1; |
529 | } | 516 | } |
@@ -541,12 +528,12 @@ event_thread(void *data) | |||
541 | unlock_kernel(); | 528 | unlock_kernel(); |
542 | 529 | ||
543 | dbg("%s - event thread started", __FUNCTION__); | 530 | dbg("%s - event thread started", __FUNCTION__); |
544 | while(1) { | 531 | while (1) { |
545 | dbg("event thread sleeping"); | 532 | dbg("event thread sleeping"); |
546 | down_interruptible(&event_semaphore); | 533 | down_interruptible(&event_semaphore); |
547 | dbg("event thread woken, thread_finished = %d", | 534 | dbg("event thread woken, thread_finished = %d", |
548 | thread_finished); | 535 | thread_finished); |
549 | if(thread_finished || signal_pending(current)) | 536 | if (thread_finished || signal_pending(current)) |
550 | break; | 537 | break; |
551 | do { | 538 | do { |
552 | rc = check_slots(); | 539 | rc = check_slots(); |
@@ -558,7 +545,9 @@ event_thread(void *data) | |||
558 | thread_finished = 1; | 545 | thread_finished = 1; |
559 | break; | 546 | break; |
560 | } | 547 | } |
561 | } while(atomic_read(&extracting) != 0); | 548 | } while (atomic_read(&extracting) && !thread_finished); |
549 | if (thread_finished) | ||
550 | break; | ||
562 | 551 | ||
563 | /* Re-enable ENUM# interrupt */ | 552 | /* Re-enable ENUM# interrupt */ |
564 | dbg("%s - re-enabling irq", __FUNCTION__); | 553 | dbg("%s - re-enabling irq", __FUNCTION__); |
@@ -579,21 +568,21 @@ poll_thread(void *data) | |||
579 | daemonize("cpci_hp_polld"); | 568 | daemonize("cpci_hp_polld"); |
580 | unlock_kernel(); | 569 | unlock_kernel(); |
581 | 570 | ||
582 | while(1) { | 571 | while (1) { |
583 | if(thread_finished || signal_pending(current)) | 572 | if (thread_finished || signal_pending(current)) |
584 | break; | 573 | break; |
585 | if(controller->ops->query_enum()) { | 574 | if (controller->ops->query_enum()) { |
586 | do { | 575 | do { |
587 | rc = check_slots(); | 576 | rc = check_slots(); |
588 | if(rc > 0) { | 577 | if (rc > 0) { |
589 | /* Give userspace a chance to handle extraction */ | 578 | /* Give userspace a chance to handle extraction */ |
590 | msleep(500); | 579 | msleep(500); |
591 | } else if(rc < 0) { | 580 | } else if (rc < 0) { |
592 | dbg("%s - error checking slots", __FUNCTION__); | 581 | dbg("%s - error checking slots", __FUNCTION__); |
593 | thread_finished = 1; | 582 | thread_finished = 1; |
594 | break; | 583 | break; |
595 | } | 584 | } |
596 | } while(atomic_read(&extracting) != 0); | 585 | } while (atomic_read(&extracting) && !thread_finished); |
597 | } | 586 | } |
598 | msleep(100); | 587 | msleep(100); |
599 | } | 588 | } |
@@ -612,12 +601,11 @@ cpci_start_thread(void) | |||
612 | init_MUTEX_LOCKED(&thread_exit); | 601 | init_MUTEX_LOCKED(&thread_exit); |
613 | thread_finished = 0; | 602 | thread_finished = 0; |
614 | 603 | ||
615 | if(controller->irq) { | 604 | if (controller->irq) |
616 | pid = kernel_thread(event_thread, NULL, 0); | 605 | pid = kernel_thread(event_thread, NULL, 0); |
617 | } else { | 606 | else |
618 | pid = kernel_thread(poll_thread, NULL, 0); | 607 | pid = kernel_thread(poll_thread, NULL, 0); |
619 | } | 608 | if (pid < 0) { |
620 | if(pid < 0) { | ||
621 | err("Can't start up our thread"); | 609 | err("Can't start up our thread"); |
622 | return -1; | 610 | return -1; |
623 | } | 611 | } |
@@ -630,9 +618,8 @@ cpci_stop_thread(void) | |||
630 | { | 618 | { |
631 | thread_finished = 1; | 619 | thread_finished = 1; |
632 | dbg("thread finish command given"); | 620 | dbg("thread finish command given"); |
633 | if(controller->irq) { | 621 | if (controller->irq) |
634 | up(&event_semaphore); | 622 | up(&event_semaphore); |
635 | } | ||
636 | dbg("wait for thread to exit"); | 623 | dbg("wait for thread to exit"); |
637 | down(&thread_exit); | 624 | down(&thread_exit); |
638 | } | 625 | } |
@@ -642,45 +629,67 @@ cpci_hp_register_controller(struct cpci_hp_controller *new_controller) | |||
642 | { | 629 | { |
643 | int status = 0; | 630 | int status = 0; |
644 | 631 | ||
645 | if(!controller) { | 632 | if (controller) |
646 | controller = new_controller; | 633 | return -1; |
647 | if(controller->irq) { | 634 | if (!(new_controller && new_controller->ops)) |
648 | if(request_irq(controller->irq, | 635 | return -EINVAL; |
649 | cpci_hp_intr, | 636 | if (new_controller->irq) { |
650 | controller->irq_flags, | 637 | if (!(new_controller->ops->enable_irq && |
651 | MY_NAME, controller->dev_id)) { | 638 | new_controller->ops->disable_irq)) |
652 | err("Can't get irq %d for the hotplug cPCI controller", controller->irq); | 639 | status = -EINVAL; |
653 | status = -ENODEV; | 640 | if (request_irq(new_controller->irq, |
654 | } | 641 | cpci_hp_intr, |
655 | dbg("%s - acquired controller irq %d", __FUNCTION__, | 642 | new_controller->irq_flags, |
656 | controller->irq); | 643 | MY_NAME, |
644 | new_controller->dev_id)) { | ||
645 | err("Can't get irq %d for the hotplug cPCI controller", | ||
646 | new_controller->irq); | ||
647 | status = -ENODEV; | ||
657 | } | 648 | } |
658 | } else { | 649 | dbg("%s - acquired controller irq %d", |
659 | err("cPCI hotplug controller already registered"); | 650 | __FUNCTION__, new_controller->irq); |
660 | status = -1; | ||
661 | } | 651 | } |
652 | if (!status) | ||
653 | controller = new_controller; | ||
662 | return status; | 654 | return status; |
663 | } | 655 | } |
664 | 656 | ||
657 | static void | ||
658 | cleanup_slots(void) | ||
659 | { | ||
660 | struct slot *slot; | ||
661 | struct slot *tmp; | ||
662 | |||
663 | /* | ||
664 | * Unregister all of our slots with the pci_hotplug subsystem, | ||
665 | * and free up all memory that we had allocated. | ||
666 | */ | ||
667 | down_write(&list_rwsem); | ||
668 | if (!slots) | ||
669 | goto cleanup_null; | ||
670 | list_for_each_entry_safe(slot, tmp, &slot_list, slot_list) { | ||
671 | list_del(&slot->slot_list); | ||
672 | pci_hp_deregister(slot->hotplug_slot); | ||
673 | } | ||
674 | cleanup_null: | ||
675 | up_write(&list_rwsem); | ||
676 | return; | ||
677 | } | ||
678 | |||
665 | int | 679 | int |
666 | cpci_hp_unregister_controller(struct cpci_hp_controller *old_controller) | 680 | cpci_hp_unregister_controller(struct cpci_hp_controller *old_controller) |
667 | { | 681 | { |
668 | int status = 0; | 682 | int status = 0; |
669 | 683 | ||
670 | if(controller) { | 684 | if (controller) { |
671 | if(atomic_read(&extracting) != 0) { | 685 | if (!thread_finished) |
672 | return -EBUSY; | ||
673 | } | ||
674 | if(!thread_finished) { | ||
675 | cpci_stop_thread(); | 686 | cpci_stop_thread(); |
676 | } | 687 | if (controller->irq) |
677 | if(controller->irq) { | ||
678 | free_irq(controller->irq, controller->dev_id); | 688 | free_irq(controller->irq, controller->dev_id); |
679 | } | ||
680 | controller = NULL; | 689 | controller = NULL; |
681 | } else { | 690 | cleanup_slots(); |
691 | } else | ||
682 | status = -ENODEV; | 692 | status = -ENODEV; |
683 | } | ||
684 | return status; | 693 | return status; |
685 | } | 694 | } |
686 | 695 | ||
@@ -691,32 +700,28 @@ cpci_hp_start(void) | |||
691 | int status; | 700 | int status; |
692 | 701 | ||
693 | dbg("%s - enter", __FUNCTION__); | 702 | dbg("%s - enter", __FUNCTION__); |
694 | if(!controller) { | 703 | if (!controller) |
695 | return -ENODEV; | 704 | return -ENODEV; |
696 | } | ||
697 | 705 | ||
698 | down_read(&list_rwsem); | 706 | down_read(&list_rwsem); |
699 | if(list_empty(&slot_list)) { | 707 | if (list_empty(&slot_list)) { |
700 | up_read(&list_rwsem); | 708 | up_read(&list_rwsem); |
701 | return -ENODEV; | 709 | return -ENODEV; |
702 | } | 710 | } |
703 | up_read(&list_rwsem); | 711 | up_read(&list_rwsem); |
704 | 712 | ||
705 | if(first) { | 713 | status = init_slots(first); |
706 | status = init_slots(); | 714 | if (first) |
707 | if(status) { | ||
708 | return status; | ||
709 | } | ||
710 | first = 0; | 715 | first = 0; |
711 | } | 716 | if (status) |
717 | return status; | ||
712 | 718 | ||
713 | status = cpci_start_thread(); | 719 | status = cpci_start_thread(); |
714 | if(status) { | 720 | if (status) |
715 | return status; | 721 | return status; |
716 | } | ||
717 | dbg("%s - thread started", __FUNCTION__); | 722 | dbg("%s - thread started", __FUNCTION__); |
718 | 723 | ||
719 | if(controller->irq) { | 724 | if (controller->irq) { |
720 | /* Start enum interrupt processing */ | 725 | /* Start enum interrupt processing */ |
721 | dbg("%s - enabling irq", __FUNCTION__); | 726 | dbg("%s - enabling irq", __FUNCTION__); |
722 | controller->ops->enable_irq(); | 727 | controller->ops->enable_irq(); |
@@ -728,13 +733,9 @@ cpci_hp_start(void) | |||
728 | int | 733 | int |
729 | cpci_hp_stop(void) | 734 | cpci_hp_stop(void) |
730 | { | 735 | { |
731 | if(!controller) { | 736 | if (!controller) |
732 | return -ENODEV; | 737 | return -ENODEV; |
733 | } | 738 | if (controller->irq) { |
734 | if(atomic_read(&extracting) != 0) { | ||
735 | return -EBUSY; | ||
736 | } | ||
737 | if(controller->irq) { | ||
738 | /* Stop enum interrupt processing */ | 739 | /* Stop enum interrupt processing */ |
739 | dbg("%s - disabling irq", __FUNCTION__); | 740 | dbg("%s - disabling irq", __FUNCTION__); |
740 | controller->ops->disable_irq(); | 741 | controller->ops->disable_irq(); |
@@ -743,34 +744,6 @@ cpci_hp_stop(void) | |||
743 | return 0; | 744 | return 0; |
744 | } | 745 | } |
745 | 746 | ||
746 | static void __exit | ||
747 | cleanup_slots(void) | ||
748 | { | ||
749 | struct list_head *tmp; | ||
750 | struct slot *slot; | ||
751 | |||
752 | /* | ||
753 | * Unregister all of our slots with the pci_hotplug subsystem, | ||
754 | * and free up all memory that we had allocated. | ||
755 | */ | ||
756 | down_write(&list_rwsem); | ||
757 | if(!slots) { | ||
758 | goto null_cleanup; | ||
759 | } | ||
760 | list_for_each(tmp, &slot_list) { | ||
761 | slot = list_entry(tmp, struct slot, slot_list); | ||
762 | list_del(&slot->slot_list); | ||
763 | pci_hp_deregister(slot->hotplug_slot); | ||
764 | kfree(slot->hotplug_slot->info); | ||
765 | kfree(slot->hotplug_slot->name); | ||
766 | kfree(slot->hotplug_slot); | ||
767 | kfree(slot); | ||
768 | } | ||
769 | null_cleanup: | ||
770 | up_write(&list_rwsem); | ||
771 | return; | ||
772 | } | ||
773 | |||
774 | int __init | 747 | int __init |
775 | cpci_hotplug_init(int debug) | 748 | cpci_hotplug_init(int debug) |
776 | { | 749 | { |
@@ -784,7 +757,8 @@ cpci_hotplug_exit(void) | |||
784 | /* | 757 | /* |
785 | * Clean everything up. | 758 | * Clean everything up. |
786 | */ | 759 | */ |
787 | cleanup_slots(); | 760 | cpci_hp_stop(); |
761 | cpci_hp_unregister_controller(controller); | ||
788 | } | 762 | } |
789 | 763 | ||
790 | EXPORT_SYMBOL_GPL(cpci_hp_register_controller); | 764 | EXPORT_SYMBOL_GPL(cpci_hp_register_controller); |
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c index 69eb4fc54f2f..c878028ad215 100644 --- a/drivers/pci/hotplug/cpci_hotplug_pci.c +++ b/drivers/pci/hotplug/cpci_hotplug_pci.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * CompactPCI Hot Plug Driver PCI functions | 2 | * CompactPCI Hot Plug Driver PCI functions |
3 | * | 3 | * |
4 | * Copyright (C) 2002 by SOMA Networks, Inc. | 4 | * Copyright (C) 2002,2005 by SOMA Networks, Inc. |
5 | * | 5 | * |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
@@ -38,10 +38,10 @@ extern int cpci_debug; | |||
38 | 38 | ||
39 | #define dbg(format, arg...) \ | 39 | #define dbg(format, arg...) \ |
40 | do { \ | 40 | do { \ |
41 | if(cpci_debug) \ | 41 | if (cpci_debug) \ |
42 | printk (KERN_DEBUG "%s: " format "\n", \ | 42 | printk (KERN_DEBUG "%s: " format "\n", \ |
43 | MY_NAME , ## arg); \ | 43 | MY_NAME , ## arg); \ |
44 | } while(0) | 44 | } while (0) |
45 | #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) | 45 | #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) |
46 | #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) | 46 | #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) |
47 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) | 47 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) |
@@ -57,16 +57,15 @@ u8 cpci_get_attention_status(struct slot* slot) | |||
57 | hs_cap = pci_bus_find_capability(slot->bus, | 57 | hs_cap = pci_bus_find_capability(slot->bus, |
58 | slot->devfn, | 58 | slot->devfn, |
59 | PCI_CAP_ID_CHSWP); | 59 | PCI_CAP_ID_CHSWP); |
60 | if(!hs_cap) { | 60 | if (!hs_cap) |
61 | return 0; | 61 | return 0; |
62 | } | ||
63 | 62 | ||
64 | if(pci_bus_read_config_word(slot->bus, | 63 | if (pci_bus_read_config_word(slot->bus, |
65 | slot->devfn, | 64 | slot->devfn, |
66 | hs_cap + 2, | 65 | hs_cap + 2, |
67 | &hs_csr)) { | 66 | &hs_csr)) |
68 | return 0; | 67 | return 0; |
69 | } | 68 | |
70 | return hs_csr & 0x0008 ? 1 : 0; | 69 | return hs_csr & 0x0008 ? 1 : 0; |
71 | } | 70 | } |
72 | 71 | ||
@@ -78,27 +77,22 @@ int cpci_set_attention_status(struct slot* slot, int status) | |||
78 | hs_cap = pci_bus_find_capability(slot->bus, | 77 | hs_cap = pci_bus_find_capability(slot->bus, |
79 | slot->devfn, | 78 | slot->devfn, |
80 | PCI_CAP_ID_CHSWP); | 79 | PCI_CAP_ID_CHSWP); |
81 | if(!hs_cap) { | 80 | if (!hs_cap) |
82 | return 0; | 81 | return 0; |
83 | } | 82 | if (pci_bus_read_config_word(slot->bus, |
84 | |||
85 | if(pci_bus_read_config_word(slot->bus, | ||
86 | slot->devfn, | 83 | slot->devfn, |
87 | hs_cap + 2, | 84 | hs_cap + 2, |
88 | &hs_csr)) { | 85 | &hs_csr)) |
89 | return 0; | 86 | return 0; |
90 | } | 87 | if (status) |
91 | if(status) { | ||
92 | hs_csr |= HS_CSR_LOO; | 88 | hs_csr |= HS_CSR_LOO; |
93 | } else { | 89 | else |
94 | hs_csr &= ~HS_CSR_LOO; | 90 | hs_csr &= ~HS_CSR_LOO; |
95 | } | 91 | if (pci_bus_write_config_word(slot->bus, |
96 | if(pci_bus_write_config_word(slot->bus, | ||
97 | slot->devfn, | 92 | slot->devfn, |
98 | hs_cap + 2, | 93 | hs_cap + 2, |
99 | hs_csr)) { | 94 | hs_csr)) |
100 | return 0; | 95 | return 0; |
101 | } | ||
102 | return 1; | 96 | return 1; |
103 | } | 97 | } |
104 | 98 | ||
@@ -110,16 +104,13 @@ u16 cpci_get_hs_csr(struct slot* slot) | |||
110 | hs_cap = pci_bus_find_capability(slot->bus, | 104 | hs_cap = pci_bus_find_capability(slot->bus, |
111 | slot->devfn, | 105 | slot->devfn, |
112 | PCI_CAP_ID_CHSWP); | 106 | PCI_CAP_ID_CHSWP); |
113 | if(!hs_cap) { | 107 | if (!hs_cap) |
114 | return 0xFFFF; | 108 | return 0xFFFF; |
115 | } | 109 | if (pci_bus_read_config_word(slot->bus, |
116 | |||
117 | if(pci_bus_read_config_word(slot->bus, | ||
118 | slot->devfn, | 110 | slot->devfn, |
119 | hs_cap + 2, | 111 | hs_cap + 2, |
120 | &hs_csr)) { | 112 | &hs_csr)) |
121 | return 0xFFFF; | 113 | return 0xFFFF; |
122 | } | ||
123 | return hs_csr; | 114 | return hs_csr; |
124 | } | 115 | } |
125 | 116 | ||
@@ -132,24 +123,22 @@ int cpci_check_and_clear_ins(struct slot* slot) | |||
132 | hs_cap = pci_bus_find_capability(slot->bus, | 123 | hs_cap = pci_bus_find_capability(slot->bus, |
133 | slot->devfn, | 124 | slot->devfn, |
134 | PCI_CAP_ID_CHSWP); | 125 | PCI_CAP_ID_CHSWP); |
135 | if(!hs_cap) { | 126 | if (!hs_cap) |
136 | return 0; | 127 | return 0; |
137 | } | 128 | if (pci_bus_read_config_word(slot->bus, |
138 | if(pci_bus_read_config_word(slot->bus, | ||
139 | slot->devfn, | 129 | slot->devfn, |
140 | hs_cap + 2, | 130 | hs_cap + 2, |
141 | &hs_csr)) { | 131 | &hs_csr)) |
142 | return 0; | 132 | return 0; |
143 | } | 133 | if (hs_csr & HS_CSR_INS) { |
144 | if(hs_csr & HS_CSR_INS) { | ||
145 | /* Clear INS (by setting it) */ | 134 | /* Clear INS (by setting it) */ |
146 | if(pci_bus_write_config_word(slot->bus, | 135 | if (pci_bus_write_config_word(slot->bus, |
147 | slot->devfn, | 136 | slot->devfn, |
148 | hs_cap + 2, | 137 | hs_cap + 2, |
149 | hs_csr)) { | 138 | hs_csr)) |
150 | ins = 0; | 139 | ins = 0; |
151 | } | 140 | else |
152 | ins = 1; | 141 | ins = 1; |
153 | } | 142 | } |
154 | return ins; | 143 | return ins; |
155 | } | 144 | } |
@@ -163,18 +152,15 @@ int cpci_check_ext(struct slot* slot) | |||
163 | hs_cap = pci_bus_find_capability(slot->bus, | 152 | hs_cap = pci_bus_find_capability(slot->bus, |
164 | slot->devfn, | 153 | slot->devfn, |
165 | PCI_CAP_ID_CHSWP); | 154 | PCI_CAP_ID_CHSWP); |
166 | if(!hs_cap) { | 155 | if (!hs_cap) |
167 | return 0; | 156 | return 0; |
168 | } | 157 | if (pci_bus_read_config_word(slot->bus, |
169 | if(pci_bus_read_config_word(slot->bus, | ||
170 | slot->devfn, | 158 | slot->devfn, |
171 | hs_cap + 2, | 159 | hs_cap + 2, |
172 | &hs_csr)) { | 160 | &hs_csr)) |
173 | return 0; | 161 | return 0; |
174 | } | 162 | if (hs_csr & HS_CSR_EXT) |
175 | if(hs_csr & HS_CSR_EXT) { | ||
176 | ext = 1; | 163 | ext = 1; |
177 | } | ||
178 | return ext; | 164 | return ext; |
179 | } | 165 | } |
180 | 166 | ||
@@ -186,23 +172,20 @@ int cpci_clear_ext(struct slot* slot) | |||
186 | hs_cap = pci_bus_find_capability(slot->bus, | 172 | hs_cap = pci_bus_find_capability(slot->bus, |
187 | slot->devfn, | 173 | slot->devfn, |
188 | PCI_CAP_ID_CHSWP); | 174 | PCI_CAP_ID_CHSWP); |
189 | if(!hs_cap) { | 175 | if (!hs_cap) |
190 | return -ENODEV; | 176 | return -ENODEV; |
191 | } | 177 | if (pci_bus_read_config_word(slot->bus, |
192 | if(pci_bus_read_config_word(slot->bus, | ||
193 | slot->devfn, | 178 | slot->devfn, |
194 | hs_cap + 2, | 179 | hs_cap + 2, |
195 | &hs_csr)) { | 180 | &hs_csr)) |
196 | return -ENODEV; | 181 | return -ENODEV; |
197 | } | 182 | if (hs_csr & HS_CSR_EXT) { |
198 | if(hs_csr & HS_CSR_EXT) { | ||
199 | /* Clear EXT (by setting it) */ | 183 | /* Clear EXT (by setting it) */ |
200 | if(pci_bus_write_config_word(slot->bus, | 184 | if (pci_bus_write_config_word(slot->bus, |
201 | slot->devfn, | 185 | slot->devfn, |
202 | hs_cap + 2, | 186 | hs_cap + 2, |
203 | hs_csr)) { | 187 | hs_csr)) |
204 | return -ENODEV; | 188 | return -ENODEV; |
205 | } | ||
206 | } | 189 | } |
207 | return 0; | 190 | return 0; |
208 | } | 191 | } |
@@ -215,18 +198,16 @@ int cpci_led_on(struct slot* slot) | |||
215 | hs_cap = pci_bus_find_capability(slot->bus, | 198 | hs_cap = pci_bus_find_capability(slot->bus, |
216 | slot->devfn, | 199 | slot->devfn, |
217 | PCI_CAP_ID_CHSWP); | 200 | PCI_CAP_ID_CHSWP); |
218 | if(!hs_cap) { | 201 | if (!hs_cap) |
219 | return -ENODEV; | 202 | return -ENODEV; |
220 | } | 203 | if (pci_bus_read_config_word(slot->bus, |
221 | if(pci_bus_read_config_word(slot->bus, | ||
222 | slot->devfn, | 204 | slot->devfn, |
223 | hs_cap + 2, | 205 | hs_cap + 2, |
224 | &hs_csr)) { | 206 | &hs_csr)) |
225 | return -ENODEV; | 207 | return -ENODEV; |
226 | } | 208 | if ((hs_csr & HS_CSR_LOO) != HS_CSR_LOO) { |
227 | if((hs_csr & HS_CSR_LOO) != HS_CSR_LOO) { | ||
228 | hs_csr |= HS_CSR_LOO; | 209 | hs_csr |= HS_CSR_LOO; |
229 | if(pci_bus_write_config_word(slot->bus, | 210 | if (pci_bus_write_config_word(slot->bus, |
230 | slot->devfn, | 211 | slot->devfn, |
231 | hs_cap + 2, | 212 | hs_cap + 2, |
232 | hs_csr)) { | 213 | hs_csr)) { |
@@ -246,18 +227,16 @@ int cpci_led_off(struct slot* slot) | |||
246 | hs_cap = pci_bus_find_capability(slot->bus, | 227 | hs_cap = pci_bus_find_capability(slot->bus, |
247 | slot->devfn, | 228 | slot->devfn, |
248 | PCI_CAP_ID_CHSWP); | 229 | PCI_CAP_ID_CHSWP); |
249 | if(!hs_cap) { | 230 | if (!hs_cap) |
250 | return -ENODEV; | 231 | return -ENODEV; |
251 | } | 232 | if (pci_bus_read_config_word(slot->bus, |
252 | if(pci_bus_read_config_word(slot->bus, | ||
253 | slot->devfn, | 233 | slot->devfn, |
254 | hs_cap + 2, | 234 | hs_cap + 2, |
255 | &hs_csr)) { | 235 | &hs_csr)) |
256 | return -ENODEV; | 236 | return -ENODEV; |
257 | } | 237 | if (hs_csr & HS_CSR_LOO) { |
258 | if(hs_csr & HS_CSR_LOO) { | ||
259 | hs_csr &= ~HS_CSR_LOO; | 238 | hs_csr &= ~HS_CSR_LOO; |
260 | if(pci_bus_write_config_word(slot->bus, | 239 | if (pci_bus_write_config_word(slot->bus, |
261 | slot->devfn, | 240 | slot->devfn, |
262 | hs_cap + 2, | 241 | hs_cap + 2, |
263 | hs_csr)) { | 242 | hs_csr)) { |
@@ -274,19 +253,6 @@ int cpci_led_off(struct slot* slot) | |||
274 | * Device configuration functions | 253 | * Device configuration functions |
275 | */ | 254 | */ |
276 | 255 | ||
277 | static void cpci_enable_device(struct pci_dev *dev) | ||
278 | { | ||
279 | struct pci_bus *bus; | ||
280 | |||
281 | pci_enable_device(dev); | ||
282 | if(dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { | ||
283 | bus = dev->subordinate; | ||
284 | list_for_each_entry(dev, &bus->devices, bus_list) { | ||
285 | cpci_enable_device(dev); | ||
286 | } | ||
287 | } | ||
288 | } | ||
289 | |||
290 | int cpci_configure_slot(struct slot* slot) | 256 | int cpci_configure_slot(struct slot* slot) |
291 | { | 257 | { |
292 | unsigned char busnr; | 258 | unsigned char busnr; |
@@ -294,14 +260,14 @@ int cpci_configure_slot(struct slot* slot) | |||
294 | 260 | ||
295 | dbg("%s - enter", __FUNCTION__); | 261 | dbg("%s - enter", __FUNCTION__); |
296 | 262 | ||
297 | if(slot->dev == NULL) { | 263 | if (slot->dev == NULL) { |
298 | dbg("pci_dev null, finding %02x:%02x:%x", | 264 | dbg("pci_dev null, finding %02x:%02x:%x", |
299 | slot->bus->number, PCI_SLOT(slot->devfn), PCI_FUNC(slot->devfn)); | 265 | slot->bus->number, PCI_SLOT(slot->devfn), PCI_FUNC(slot->devfn)); |
300 | slot->dev = pci_find_slot(slot->bus->number, slot->devfn); | 266 | slot->dev = pci_get_slot(slot->bus, slot->devfn); |
301 | } | 267 | } |
302 | 268 | ||
303 | /* Still NULL? Well then scan for it! */ | 269 | /* Still NULL? Well then scan for it! */ |
304 | if(slot->dev == NULL) { | 270 | if (slot->dev == NULL) { |
305 | int n; | 271 | int n; |
306 | dbg("pci_dev still null"); | 272 | dbg("pci_dev still null"); |
307 | 273 | ||
@@ -311,10 +277,10 @@ int cpci_configure_slot(struct slot* slot) | |||
311 | */ | 277 | */ |
312 | n = pci_scan_slot(slot->bus, slot->devfn); | 278 | n = pci_scan_slot(slot->bus, slot->devfn); |
313 | dbg("%s: pci_scan_slot returned %d", __FUNCTION__, n); | 279 | dbg("%s: pci_scan_slot returned %d", __FUNCTION__, n); |
314 | if(n > 0) | 280 | if (n > 0) |
315 | pci_bus_add_devices(slot->bus); | 281 | pci_bus_add_devices(slot->bus); |
316 | slot->dev = pci_find_slot(slot->bus->number, slot->devfn); | 282 | slot->dev = pci_get_slot(slot->bus, slot->devfn); |
317 | if(slot->dev == NULL) { | 283 | if (slot->dev == NULL) { |
318 | err("Could not find PCI device for slot %02x", slot->number); | 284 | err("Could not find PCI device for slot %02x", slot->number); |
319 | return 1; | 285 | return 1; |
320 | } | 286 | } |
@@ -329,8 +295,6 @@ int cpci_configure_slot(struct slot* slot) | |||
329 | 295 | ||
330 | pci_bus_assign_resources(slot->dev->bus); | 296 | pci_bus_assign_resources(slot->dev->bus); |
331 | 297 | ||
332 | cpci_enable_device(slot->dev); | ||
333 | |||
334 | dbg("%s - exit", __FUNCTION__); | 298 | dbg("%s - exit", __FUNCTION__); |
335 | return 0; | 299 | return 0; |
336 | } | 300 | } |
@@ -341,15 +305,15 @@ int cpci_unconfigure_slot(struct slot* slot) | |||
341 | struct pci_dev *dev; | 305 | struct pci_dev *dev; |
342 | 306 | ||
343 | dbg("%s - enter", __FUNCTION__); | 307 | dbg("%s - enter", __FUNCTION__); |
344 | if(!slot->dev) { | 308 | if (!slot->dev) { |
345 | err("No device for slot %02x\n", slot->number); | 309 | err("No device for slot %02x\n", slot->number); |
346 | return -ENODEV; | 310 | return -ENODEV; |
347 | } | 311 | } |
348 | 312 | ||
349 | for (i = 0; i < 8; i++) { | 313 | for (i = 0; i < 8; i++) { |
350 | dev = pci_find_slot(slot->bus->number, | 314 | dev = pci_get_slot(slot->bus, |
351 | PCI_DEVFN(PCI_SLOT(slot->devfn), i)); | 315 | PCI_DEVFN(PCI_SLOT(slot->devfn), i)); |
352 | if(dev) { | 316 | if (dev) { |
353 | pci_remove_bus_device(dev); | 317 | pci_remove_bus_device(dev); |
354 | slot->dev = NULL; | 318 | slot->dev = NULL; |
355 | } | 319 | } |
diff --git a/drivers/pci/hotplug/shpchprm_acpi.c b/drivers/pci/hotplug/shpchprm_acpi.c index 243a51d88b86..7957cdc72cd0 100644 --- a/drivers/pci/hotplug/shpchprm_acpi.c +++ b/drivers/pci/hotplug/shpchprm_acpi.c | |||
@@ -1626,7 +1626,7 @@ int shpchprm_set_hpp( | |||
1626 | pci_bus->number = func->bus; | 1626 | pci_bus->number = func->bus; |
1627 | devfn = PCI_DEVFN(func->device, func->function); | 1627 | devfn = PCI_DEVFN(func->device, func->function); |
1628 | 1628 | ||
1629 | ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->bus); | 1629 | ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->slot_bus); |
1630 | 1630 | ||
1631 | if (ab) { | 1631 | if (ab) { |
1632 | if (ab->_hpp) { | 1632 | if (ab->_hpp) { |
@@ -1681,7 +1681,7 @@ void shpchprm_enable_card( | |||
1681 | | PCI_COMMAND_IO | PCI_COMMAND_MEMORY; | 1681 | | PCI_COMMAND_IO | PCI_COMMAND_MEMORY; |
1682 | bcmd = bcommand = bcommand | PCI_BRIDGE_CTL_NO_ISA; | 1682 | bcmd = bcommand = bcommand | PCI_BRIDGE_CTL_NO_ISA; |
1683 | 1683 | ||
1684 | ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->bus); | 1684 | ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->slot_bus); |
1685 | if (ab) { | 1685 | if (ab) { |
1686 | if (ab->_hpp) { | 1686 | if (ab->_hpp) { |
1687 | if (ab->_hpp->enable_perr) { | 1687 | if (ab->_hpp->enable_perr) { |
diff --git a/drivers/pci/pci.ids b/drivers/pci/pci.ids index 93481b41b613..1d2ef1e2ffc6 100644 --- a/drivers/pci/pci.ids +++ b/drivers/pci/pci.ids | |||
@@ -7173,6 +7173,7 @@ | |||
7173 | 080f Sentry5 DDR/SDR RAM Controller | 7173 | 080f Sentry5 DDR/SDR RAM Controller |
7174 | 0811 Sentry5 External Interface Core | 7174 | 0811 Sentry5 External Interface Core |
7175 | 0816 BCM3302 Sentry5 MIPS32 CPU | 7175 | 0816 BCM3302 Sentry5 MIPS32 CPU |
7176 | 1600 NetXtreme BCM5752 Gigabit Ethernet PCI Express | ||
7176 | 1644 NetXtreme BCM5700 Gigabit Ethernet | 7177 | 1644 NetXtreme BCM5700 Gigabit Ethernet |
7177 | 1014 0277 Broadcom Vigil B5700 1000Base-T | 7178 | 1014 0277 Broadcom Vigil B5700 1000Base-T |
7178 | 1028 00d1 Broadcom BCM5700 | 7179 | 1028 00d1 Broadcom BCM5700 |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 637e9493034b..2194669300bf 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -460,17 +460,6 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_APIC, | |||
460 | 460 | ||
461 | 461 | ||
462 | /* | 462 | /* |
463 | * Via 686A/B: The PCI_INTERRUPT_LINE register for the on-chip | ||
464 | * devices, USB0/1, AC97, MC97, and ACPI, has an unusual feature: | ||
465 | * when written, it makes an internal connection to the PIC. | ||
466 | * For these devices, this register is defined to be 4 bits wide. | ||
467 | * Normally this is fine. However for IO-APIC motherboards, or | ||
468 | * non-x86 architectures (yes Via exists on PPC among other places), | ||
469 | * we must mask the PCI_INTERRUPT_LINE value versus 0xf to get | ||
470 | * interrupts delivered properly. | ||
471 | */ | ||
472 | |||
473 | /* | ||
474 | * FIXME: it is questionable that quirk_via_acpi | 463 | * FIXME: it is questionable that quirk_via_acpi |
475 | * is needed. It shows up as an ISA bridge, and does not | 464 | * is needed. It shows up as an ISA bridge, and does not |
476 | * support the PCI_INTERRUPT_LINE register at all. Therefore | 465 | * support the PCI_INTERRUPT_LINE register at all. Therefore |
@@ -492,28 +481,30 @@ static void __devinit quirk_via_acpi(struct pci_dev *d) | |||
492 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, quirk_via_acpi ); | 481 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, quirk_via_acpi ); |
493 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_via_acpi ); | 482 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_via_acpi ); |
494 | 483 | ||
495 | static void quirk_via_irqpic(struct pci_dev *dev) | 484 | /* |
485 | * Via 686A/B: The PCI_INTERRUPT_LINE register for the on-chip | ||
486 | * devices, USB0/1, AC97, MC97, and ACPI, has an unusual feature: | ||
487 | * when written, it makes an internal connection to the PIC. | ||
488 | * For these devices, this register is defined to be 4 bits wide. | ||
489 | * Normally this is fine. However for IO-APIC motherboards, or | ||
490 | * non-x86 architectures (yes Via exists on PPC among other places), | ||
491 | * we must mask the PCI_INTERRUPT_LINE value versus 0xf to get | ||
492 | * interrupts delivered properly. | ||
493 | */ | ||
494 | static void quirk_via_irq(struct pci_dev *dev) | ||
496 | { | 495 | { |
497 | u8 irq, new_irq; | 496 | u8 irq, new_irq; |
498 | 497 | ||
499 | #ifdef CONFIG_X86_IO_APIC | ||
500 | if (nr_ioapics && !skip_ioapic_setup) | ||
501 | return; | ||
502 | #endif | ||
503 | #ifdef CONFIG_ACPI | ||
504 | if (acpi_irq_model != ACPI_IRQ_MODEL_PIC) | ||
505 | return; | ||
506 | #endif | ||
507 | new_irq = dev->irq & 0xf; | 498 | new_irq = dev->irq & 0xf; |
508 | pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq); | 499 | pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq); |
509 | if (new_irq != irq) { | 500 | if (new_irq != irq) { |
510 | printk(KERN_INFO "PCI: Via PIC IRQ fixup for %s, from %d to %d\n", | 501 | printk(KERN_INFO "PCI: Via IRQ fixup for %s, from %d to %d\n", |
511 | pci_name(dev), irq, new_irq); | 502 | pci_name(dev), irq, new_irq); |
512 | udelay(15); /* unknown if delay really needed */ | 503 | udelay(15); /* unknown if delay really needed */ |
513 | pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq); | 504 | pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq); |
514 | } | 505 | } |
515 | } | 506 | } |
516 | DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_ANY_ID, quirk_via_irqpic); | 507 | DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_ANY_ID, quirk_via_irq); |
517 | 508 | ||
518 | /* | 509 | /* |
519 | * PIIX3 USB: We have to disable USB interrupts that are | 510 | * PIIX3 USB: We have to disable USB interrupts that are |
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index 54c52349adc5..3be546439252 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c | |||
@@ -665,15 +665,6 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
665 | return ata_pci_init_one(pdev, port_info, n_ports); | 665 | return ata_pci_init_one(pdev, port_info, n_ports); |
666 | } | 666 | } |
667 | 667 | ||
668 | /** | ||
669 | * piix_init - | ||
670 | * | ||
671 | * LOCKING: | ||
672 | * | ||
673 | * RETURNS: | ||
674 | * | ||
675 | */ | ||
676 | |||
677 | static int __init piix_init(void) | 668 | static int __init piix_init(void) |
678 | { | 669 | { |
679 | int rc; | 670 | int rc; |
@@ -689,13 +680,6 @@ static int __init piix_init(void) | |||
689 | return 0; | 680 | return 0; |
690 | } | 681 | } |
691 | 682 | ||
692 | /** | ||
693 | * piix_exit - | ||
694 | * | ||
695 | * LOCKING: | ||
696 | * | ||
697 | */ | ||
698 | |||
699 | static void __exit piix_exit(void) | 683 | static void __exit piix_exit(void) |
700 | { | 684 | { |
701 | pci_unregister_driver(&piix_pci_driver); | 685 | pci_unregister_driver(&piix_pci_driver); |
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 30a88f0e7bd6..21d194c6ace3 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -186,6 +186,28 @@ static void ata_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf) | |||
186 | ata_wait_idle(ap); | 186 | ata_wait_idle(ap); |
187 | } | 187 | } |
188 | 188 | ||
189 | |||
190 | /** | ||
191 | * ata_tf_load - send taskfile registers to host controller | ||
192 | * @ap: Port to which output is sent | ||
193 | * @tf: ATA taskfile register set | ||
194 | * | ||
195 | * Outputs ATA taskfile to standard ATA host controller using MMIO | ||
196 | * or PIO as indicated by the ATA_FLAG_MMIO flag. | ||
197 | * Writes the control, feature, nsect, lbal, lbam, and lbah registers. | ||
198 | * Optionally (ATA_TFLAG_LBA48) writes hob_feature, hob_nsect, | ||
199 | * hob_lbal, hob_lbam, and hob_lbah. | ||
200 | * | ||
201 | * This function waits for idle (!BUSY and !DRQ) after writing | ||
202 | * registers. If the control register has a new value, this | ||
203 | * function also waits for idle after writing control and before | ||
204 | * writing the remaining registers. | ||
205 | * | ||
206 | * May be used as the tf_load() entry in ata_port_operations. | ||
207 | * | ||
208 | * LOCKING: | ||
209 | * Inherited from caller. | ||
210 | */ | ||
189 | void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf) | 211 | void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf) |
190 | { | 212 | { |
191 | if (ap->flags & ATA_FLAG_MMIO) | 213 | if (ap->flags & ATA_FLAG_MMIO) |
@@ -195,11 +217,11 @@ void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf) | |||
195 | } | 217 | } |
196 | 218 | ||
197 | /** | 219 | /** |
198 | * ata_exec_command - issue ATA command to host controller | 220 | * ata_exec_command_pio - issue ATA command to host controller |
199 | * @ap: port to which command is being issued | 221 | * @ap: port to which command is being issued |
200 | * @tf: ATA taskfile register set | 222 | * @tf: ATA taskfile register set |
201 | * | 223 | * |
202 | * Issues PIO/MMIO write to ATA command register, with proper | 224 | * Issues PIO write to ATA command register, with proper |
203 | * synchronization with interrupt handler / other threads. | 225 | * synchronization with interrupt handler / other threads. |
204 | * | 226 | * |
205 | * LOCKING: | 227 | * LOCKING: |
@@ -235,6 +257,18 @@ static void ata_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf) | |||
235 | ata_pause(ap); | 257 | ata_pause(ap); |
236 | } | 258 | } |
237 | 259 | ||
260 | |||
261 | /** | ||
262 | * ata_exec_command - issue ATA command to host controller | ||
263 | * @ap: port to which command is being issued | ||
264 | * @tf: ATA taskfile register set | ||
265 | * | ||
266 | * Issues PIO/MMIO write to ATA command register, with proper | ||
267 | * synchronization with interrupt handler / other threads. | ||
268 | * | ||
269 | * LOCKING: | ||
270 | * spin_lock_irqsave(host_set lock) | ||
271 | */ | ||
238 | void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf) | 272 | void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf) |
239 | { | 273 | { |
240 | if (ap->flags & ATA_FLAG_MMIO) | 274 | if (ap->flags & ATA_FLAG_MMIO) |
@@ -305,7 +339,7 @@ void ata_tf_to_host_nolock(struct ata_port *ap, struct ata_taskfile *tf) | |||
305 | } | 339 | } |
306 | 340 | ||
307 | /** | 341 | /** |
308 | * ata_tf_read - input device's ATA taskfile shadow registers | 342 | * ata_tf_read_pio - input device's ATA taskfile shadow registers |
309 | * @ap: Port from which input is read | 343 | * @ap: Port from which input is read |
310 | * @tf: ATA taskfile register set for storing input | 344 | * @tf: ATA taskfile register set for storing input |
311 | * | 345 | * |
@@ -368,6 +402,23 @@ static void ata_tf_read_mmio(struct ata_port *ap, struct ata_taskfile *tf) | |||
368 | } | 402 | } |
369 | } | 403 | } |
370 | 404 | ||
405 | |||
406 | /** | ||
407 | * ata_tf_read - input device's ATA taskfile shadow registers | ||
408 | * @ap: Port from which input is read | ||
409 | * @tf: ATA taskfile register set for storing input | ||
410 | * | ||
411 | * Reads ATA taskfile registers for currently-selected device | ||
412 | * into @tf. | ||
413 | * | ||
414 | * Reads nsect, lbal, lbam, lbah, and device. If ATA_TFLAG_LBA48 | ||
415 | * is set, also reads the hob registers. | ||
416 | * | ||
417 | * May be used as the tf_read() entry in ata_port_operations. | ||
418 | * | ||
419 | * LOCKING: | ||
420 | * Inherited from caller. | ||
421 | */ | ||
371 | void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | 422 | void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) |
372 | { | 423 | { |
373 | if (ap->flags & ATA_FLAG_MMIO) | 424 | if (ap->flags & ATA_FLAG_MMIO) |
@@ -381,7 +432,7 @@ void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | |||
381 | * @ap: port where the device is | 432 | * @ap: port where the device is |
382 | * | 433 | * |
383 | * Reads ATA taskfile status register for currently-selected device | 434 | * Reads ATA taskfile status register for currently-selected device |
384 | * and return it's value. This also clears pending interrupts | 435 | * and return its value. This also clears pending interrupts |
385 | * from this device | 436 | * from this device |
386 | * | 437 | * |
387 | * LOCKING: | 438 | * LOCKING: |
@@ -397,7 +448,7 @@ static u8 ata_check_status_pio(struct ata_port *ap) | |||
397 | * @ap: port where the device is | 448 | * @ap: port where the device is |
398 | * | 449 | * |
399 | * Reads ATA taskfile status register for currently-selected device | 450 | * Reads ATA taskfile status register for currently-selected device |
400 | * via MMIO and return it's value. This also clears pending interrupts | 451 | * via MMIO and return its value. This also clears pending interrupts |
401 | * from this device | 452 | * from this device |
402 | * | 453 | * |
403 | * LOCKING: | 454 | * LOCKING: |
@@ -408,6 +459,20 @@ static u8 ata_check_status_mmio(struct ata_port *ap) | |||
408 | return readb((void __iomem *) ap->ioaddr.status_addr); | 459 | return readb((void __iomem *) ap->ioaddr.status_addr); |
409 | } | 460 | } |
410 | 461 | ||
462 | |||
463 | /** | ||
464 | * ata_check_status - Read device status reg & clear interrupt | ||
465 | * @ap: port where the device is | ||
466 | * | ||
467 | * Reads ATA taskfile status register for currently-selected device | ||
468 | * and return its value. This also clears pending interrupts | ||
469 | * from this device | ||
470 | * | ||
471 | * May be used as the check_status() entry in ata_port_operations. | ||
472 | * | ||
473 | * LOCKING: | ||
474 | * Inherited from caller. | ||
475 | */ | ||
411 | u8 ata_check_status(struct ata_port *ap) | 476 | u8 ata_check_status(struct ata_port *ap) |
412 | { | 477 | { |
413 | if (ap->flags & ATA_FLAG_MMIO) | 478 | if (ap->flags & ATA_FLAG_MMIO) |
@@ -415,6 +480,20 @@ u8 ata_check_status(struct ata_port *ap) | |||
415 | return ata_check_status_pio(ap); | 480 | return ata_check_status_pio(ap); |
416 | } | 481 | } |
417 | 482 | ||
483 | |||
484 | /** | ||
485 | * ata_altstatus - Read device alternate status reg | ||
486 | * @ap: port where the device is | ||
487 | * | ||
488 | * Reads ATA taskfile alternate status register for | ||
489 | * currently-selected device and return its value. | ||
490 | * | ||
491 | * Note: may NOT be used as the check_altstatus() entry in | ||
492 | * ata_port_operations. | ||
493 | * | ||
494 | * LOCKING: | ||
495 | * Inherited from caller. | ||
496 | */ | ||
418 | u8 ata_altstatus(struct ata_port *ap) | 497 | u8 ata_altstatus(struct ata_port *ap) |
419 | { | 498 | { |
420 | if (ap->ops->check_altstatus) | 499 | if (ap->ops->check_altstatus) |
@@ -425,6 +504,20 @@ u8 ata_altstatus(struct ata_port *ap) | |||
425 | return inb(ap->ioaddr.altstatus_addr); | 504 | return inb(ap->ioaddr.altstatus_addr); |
426 | } | 505 | } |
427 | 506 | ||
507 | |||
508 | /** | ||
509 | * ata_chk_err - Read device error reg | ||
510 | * @ap: port where the device is | ||
511 | * | ||
512 | * Reads ATA taskfile error register for | ||
513 | * currently-selected device and return its value. | ||
514 | * | ||
515 | * Note: may NOT be used as the check_err() entry in | ||
516 | * ata_port_operations. | ||
517 | * | ||
518 | * LOCKING: | ||
519 | * Inherited from caller. | ||
520 | */ | ||
428 | u8 ata_chk_err(struct ata_port *ap) | 521 | u8 ata_chk_err(struct ata_port *ap) |
429 | { | 522 | { |
430 | if (ap->ops->check_err) | 523 | if (ap->ops->check_err) |
@@ -873,10 +966,24 @@ void ata_dev_id_string(u16 *id, unsigned char *s, | |||
873 | } | 966 | } |
874 | } | 967 | } |
875 | 968 | ||
969 | |||
970 | /** | ||
971 | * ata_noop_dev_select - Select device 0/1 on ATA bus | ||
972 | * @ap: ATA channel to manipulate | ||
973 | * @device: ATA device (numbered from zero) to select | ||
974 | * | ||
975 | * This function performs no actual function. | ||
976 | * | ||
977 | * May be used as the dev_select() entry in ata_port_operations. | ||
978 | * | ||
979 | * LOCKING: | ||
980 | * caller. | ||
981 | */ | ||
876 | void ata_noop_dev_select (struct ata_port *ap, unsigned int device) | 982 | void ata_noop_dev_select (struct ata_port *ap, unsigned int device) |
877 | { | 983 | { |
878 | } | 984 | } |
879 | 985 | ||
986 | |||
880 | /** | 987 | /** |
881 | * ata_std_dev_select - Select device 0/1 on ATA bus | 988 | * ata_std_dev_select - Select device 0/1 on ATA bus |
882 | * @ap: ATA channel to manipulate | 989 | * @ap: ATA channel to manipulate |
@@ -884,7 +991,9 @@ void ata_noop_dev_select (struct ata_port *ap, unsigned int device) | |||
884 | * | 991 | * |
885 | * Use the method defined in the ATA specification to | 992 | * Use the method defined in the ATA specification to |
886 | * make either device 0, or device 1, active on the | 993 | * make either device 0, or device 1, active on the |
887 | * ATA channel. | 994 | * ATA channel. Works with both PIO and MMIO. |
995 | * | ||
996 | * May be used as the dev_select() entry in ata_port_operations. | ||
888 | * | 997 | * |
889 | * LOCKING: | 998 | * LOCKING: |
890 | * caller. | 999 | * caller. |
@@ -1190,7 +1299,12 @@ err_out: | |||
1190 | * ata_bus_probe - Reset and probe ATA bus | 1299 | * ata_bus_probe - Reset and probe ATA bus |
1191 | * @ap: Bus to probe | 1300 | * @ap: Bus to probe |
1192 | * | 1301 | * |
1302 | * Master ATA bus probing function. Initiates a hardware-dependent | ||
1303 | * bus reset, then attempts to identify any devices found on | ||
1304 | * the bus. | ||
1305 | * | ||
1193 | * LOCKING: | 1306 | * LOCKING: |
1307 | * PCI/etc. bus probe sem. | ||
1194 | * | 1308 | * |
1195 | * RETURNS: | 1309 | * RETURNS: |
1196 | * Zero on success, non-zero on error. | 1310 | * Zero on success, non-zero on error. |
@@ -1229,10 +1343,14 @@ err_out: | |||
1229 | } | 1343 | } |
1230 | 1344 | ||
1231 | /** | 1345 | /** |
1232 | * ata_port_probe - | 1346 | * ata_port_probe - Mark port as enabled |
1233 | * @ap: | 1347 | * @ap: Port for which we indicate enablement |
1234 | * | 1348 | * |
1235 | * LOCKING: | 1349 | * Modify @ap data structure such that the system |
1350 | * thinks that the entire port is enabled. | ||
1351 | * | ||
1352 | * LOCKING: host_set lock, or some other form of | ||
1353 | * serialization. | ||
1236 | */ | 1354 | */ |
1237 | 1355 | ||
1238 | void ata_port_probe(struct ata_port *ap) | 1356 | void ata_port_probe(struct ata_port *ap) |
@@ -1241,10 +1359,15 @@ void ata_port_probe(struct ata_port *ap) | |||
1241 | } | 1359 | } |
1242 | 1360 | ||
1243 | /** | 1361 | /** |
1244 | * __sata_phy_reset - | 1362 | * __sata_phy_reset - Wake/reset a low-level SATA PHY |
1245 | * @ap: | 1363 | * @ap: SATA port associated with target SATA PHY. |
1364 | * | ||
1365 | * This function issues commands to standard SATA Sxxx | ||
1366 | * PHY registers, to wake up the phy (and device), and | ||
1367 | * clear any reset condition. | ||
1246 | * | 1368 | * |
1247 | * LOCKING: | 1369 | * LOCKING: |
1370 | * PCI/etc. bus probe sem. | ||
1248 | * | 1371 | * |
1249 | */ | 1372 | */ |
1250 | void __sata_phy_reset(struct ata_port *ap) | 1373 | void __sata_phy_reset(struct ata_port *ap) |
@@ -1289,10 +1412,14 @@ void __sata_phy_reset(struct ata_port *ap) | |||
1289 | } | 1412 | } |
1290 | 1413 | ||
1291 | /** | 1414 | /** |
1292 | * __sata_phy_reset - | 1415 | * sata_phy_reset - Reset SATA bus. |
1293 | * @ap: | 1416 | * @ap: SATA port associated with target SATA PHY. |
1417 | * | ||
1418 | * This function resets the SATA bus, and then probes | ||
1419 | * the bus for devices. | ||
1294 | * | 1420 | * |
1295 | * LOCKING: | 1421 | * LOCKING: |
1422 | * PCI/etc. bus probe sem. | ||
1296 | * | 1423 | * |
1297 | */ | 1424 | */ |
1298 | void sata_phy_reset(struct ata_port *ap) | 1425 | void sata_phy_reset(struct ata_port *ap) |
@@ -1304,10 +1431,16 @@ void sata_phy_reset(struct ata_port *ap) | |||
1304 | } | 1431 | } |
1305 | 1432 | ||
1306 | /** | 1433 | /** |
1307 | * ata_port_disable - | 1434 | * ata_port_disable - Disable port. |
1308 | * @ap: | 1435 | * @ap: Port to be disabled. |
1309 | * | 1436 | * |
1310 | * LOCKING: | 1437 | * Modify @ap data structure such that the system |
1438 | * thinks that the entire port is disabled, and should | ||
1439 | * never attempt to probe or communicate with devices | ||
1440 | * on this port. | ||
1441 | * | ||
1442 | * LOCKING: host_set lock, or some other form of | ||
1443 | * serialization. | ||
1311 | */ | 1444 | */ |
1312 | 1445 | ||
1313 | void ata_port_disable(struct ata_port *ap) | 1446 | void ata_port_disable(struct ata_port *ap) |
@@ -1416,7 +1549,10 @@ static void ata_host_set_dma(struct ata_port *ap, u8 xfer_mode, | |||
1416 | * ata_set_mode - Program timings and issue SET FEATURES - XFER | 1549 | * ata_set_mode - Program timings and issue SET FEATURES - XFER |
1417 | * @ap: port on which timings will be programmed | 1550 | * @ap: port on which timings will be programmed |
1418 | * | 1551 | * |
1552 | * Set ATA device disk transfer mode (PIO3, UDMA6, etc.). | ||
1553 | * | ||
1419 | * LOCKING: | 1554 | * LOCKING: |
1555 | * PCI/etc. bus probe sem. | ||
1420 | * | 1556 | * |
1421 | */ | 1557 | */ |
1422 | static void ata_set_mode(struct ata_port *ap) | 1558 | static void ata_set_mode(struct ata_port *ap) |
@@ -1467,7 +1603,10 @@ err_out: | |||
1467 | * @tmout_pat: impatience timeout | 1603 | * @tmout_pat: impatience timeout |
1468 | * @tmout: overall timeout | 1604 | * @tmout: overall timeout |
1469 | * | 1605 | * |
1470 | * LOCKING: | 1606 | * Sleep until ATA Status register bit BSY clears, |
1607 | * or a timeout occurs. | ||
1608 | * | ||
1609 | * LOCKING: None. | ||
1471 | * | 1610 | * |
1472 | */ | 1611 | */ |
1473 | 1612 | ||
@@ -1553,10 +1692,14 @@ static void ata_bus_post_reset(struct ata_port *ap, unsigned int devmask) | |||
1553 | } | 1692 | } |
1554 | 1693 | ||
1555 | /** | 1694 | /** |
1556 | * ata_bus_edd - | 1695 | * ata_bus_edd - Issue EXECUTE DEVICE DIAGNOSTIC command. |
1557 | * @ap: | 1696 | * @ap: Port to reset and probe |
1697 | * | ||
1698 | * Use the EXECUTE DEVICE DIAGNOSTIC command to reset and | ||
1699 | * probe the bus. Not often used these days. | ||
1558 | * | 1700 | * |
1559 | * LOCKING: | 1701 | * LOCKING: |
1702 | * PCI/etc. bus probe sem. | ||
1560 | * | 1703 | * |
1561 | */ | 1704 | */ |
1562 | 1705 | ||
@@ -1633,8 +1776,8 @@ static unsigned int ata_bus_softreset(struct ata_port *ap, | |||
1633 | * the device is ATA or ATAPI. | 1776 | * the device is ATA or ATAPI. |
1634 | * | 1777 | * |
1635 | * LOCKING: | 1778 | * LOCKING: |
1636 | * Inherited from caller. Some functions called by this function | 1779 | * PCI/etc. bus probe sem. |
1637 | * obtain the host_set lock. | 1780 | * Obtains host_set lock. |
1638 | * | 1781 | * |
1639 | * SIDE EFFECTS: | 1782 | * SIDE EFFECTS: |
1640 | * Sets ATA_FLAG_PORT_DISABLED if bus reset fails. | 1783 | * Sets ATA_FLAG_PORT_DISABLED if bus reset fails. |
@@ -1876,7 +2019,11 @@ static int fgb(u32 bitmap) | |||
1876 | * @xfer_mode_out: (output) SET FEATURES - XFER MODE code | 2019 | * @xfer_mode_out: (output) SET FEATURES - XFER MODE code |
1877 | * @xfer_shift_out: (output) bit shift that selects this mode | 2020 | * @xfer_shift_out: (output) bit shift that selects this mode |
1878 | * | 2021 | * |
2022 | * Based on host and device capabilities, determine the | ||
2023 | * maximum transfer mode that is amenable to all. | ||
2024 | * | ||
1879 | * LOCKING: | 2025 | * LOCKING: |
2026 | * PCI/etc. bus probe sem. | ||
1880 | * | 2027 | * |
1881 | * RETURNS: | 2028 | * RETURNS: |
1882 | * Zero on success, negative on error. | 2029 | * Zero on success, negative on error. |
@@ -1909,7 +2056,11 @@ static int ata_choose_xfer_mode(struct ata_port *ap, | |||
1909 | * @ap: Port associated with device @dev | 2056 | * @ap: Port associated with device @dev |
1910 | * @dev: Device to which command will be sent | 2057 | * @dev: Device to which command will be sent |
1911 | * | 2058 | * |
2059 | * Issue SET FEATURES - XFER MODE command to device @dev | ||
2060 | * on port @ap. | ||
2061 | * | ||
1912 | * LOCKING: | 2062 | * LOCKING: |
2063 | * PCI/etc. bus probe sem. | ||
1913 | */ | 2064 | */ |
1914 | 2065 | ||
1915 | static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) | 2066 | static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) |
@@ -1947,10 +2098,13 @@ static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) | |||
1947 | } | 2098 | } |
1948 | 2099 | ||
1949 | /** | 2100 | /** |
1950 | * ata_sg_clean - | 2101 | * ata_sg_clean - Unmap DMA memory associated with command |
1951 | * @qc: | 2102 | * @qc: Command containing DMA memory to be released |
2103 | * | ||
2104 | * Unmap all mapped DMA memory associated with this command. | ||
1952 | * | 2105 | * |
1953 | * LOCKING: | 2106 | * LOCKING: |
2107 | * spin_lock_irqsave(host_set lock) | ||
1954 | */ | 2108 | */ |
1955 | 2109 | ||
1956 | static void ata_sg_clean(struct ata_queued_cmd *qc) | 2110 | static void ata_sg_clean(struct ata_queued_cmd *qc) |
@@ -1981,7 +2135,11 @@ static void ata_sg_clean(struct ata_queued_cmd *qc) | |||
1981 | * ata_fill_sg - Fill PCI IDE PRD table | 2135 | * ata_fill_sg - Fill PCI IDE PRD table |
1982 | * @qc: Metadata associated with taskfile to be transferred | 2136 | * @qc: Metadata associated with taskfile to be transferred |
1983 | * | 2137 | * |
2138 | * Fill PCI IDE PRD (scatter-gather) table with segments | ||
2139 | * associated with the current disk command. | ||
2140 | * | ||
1984 | * LOCKING: | 2141 | * LOCKING: |
2142 | * spin_lock_irqsave(host_set lock) | ||
1985 | * | 2143 | * |
1986 | */ | 2144 | */ |
1987 | static void ata_fill_sg(struct ata_queued_cmd *qc) | 2145 | static void ata_fill_sg(struct ata_queued_cmd *qc) |
@@ -2028,7 +2186,13 @@ static void ata_fill_sg(struct ata_queued_cmd *qc) | |||
2028 | * ata_check_atapi_dma - Check whether ATAPI DMA can be supported | 2186 | * ata_check_atapi_dma - Check whether ATAPI DMA can be supported |
2029 | * @qc: Metadata associated with taskfile to check | 2187 | * @qc: Metadata associated with taskfile to check |
2030 | * | 2188 | * |
2189 | * Allow low-level driver to filter ATA PACKET commands, returning | ||
2190 | * a status indicating whether or not it is OK to use DMA for the | ||
2191 | * supplied PACKET command. | ||
2192 | * | ||
2031 | * LOCKING: | 2193 | * LOCKING: |
2194 | * spin_lock_irqsave(host_set lock) | ||
2195 | * | ||
2032 | * RETURNS: 0 when ATAPI DMA can be used | 2196 | * RETURNS: 0 when ATAPI DMA can be used |
2033 | * nonzero otherwise | 2197 | * nonzero otherwise |
2034 | */ | 2198 | */ |
@@ -2046,6 +2210,8 @@ int ata_check_atapi_dma(struct ata_queued_cmd *qc) | |||
2046 | * ata_qc_prep - Prepare taskfile for submission | 2210 | * ata_qc_prep - Prepare taskfile for submission |
2047 | * @qc: Metadata associated with taskfile to be prepared | 2211 | * @qc: Metadata associated with taskfile to be prepared |
2048 | * | 2212 | * |
2213 | * Prepare ATA taskfile for submission. | ||
2214 | * | ||
2049 | * LOCKING: | 2215 | * LOCKING: |
2050 | * spin_lock_irqsave(host_set lock) | 2216 | * spin_lock_irqsave(host_set lock) |
2051 | */ | 2217 | */ |
@@ -2057,6 +2223,32 @@ void ata_qc_prep(struct ata_queued_cmd *qc) | |||
2057 | ata_fill_sg(qc); | 2223 | ata_fill_sg(qc); |
2058 | } | 2224 | } |
2059 | 2225 | ||
2226 | /** | ||
2227 | * ata_sg_init_one - Associate command with memory buffer | ||
2228 | * @qc: Command to be associated | ||
2229 | * @buf: Memory buffer | ||
2230 | * @buflen: Length of memory buffer, in bytes. | ||
2231 | * | ||
2232 | * Initialize the data-related elements of queued_cmd @qc | ||
2233 | * to point to a single memory buffer, @buf of byte length @buflen. | ||
2234 | * | ||
2235 | * LOCKING: | ||
2236 | * spin_lock_irqsave(host_set lock) | ||
2237 | */ | ||
2238 | |||
2239 | |||
2240 | |||
2241 | /** | ||
2242 | * ata_sg_init_one - Prepare a one-entry scatter-gather list. | ||
2243 | * @qc: Queued command | ||
2244 | * @buf: transfer buffer | ||
2245 | * @buflen: length of buf | ||
2246 | * | ||
2247 | * Builds a single-entry scatter-gather list to initiate a | ||
2248 | * transfer utilizing the specified buffer. | ||
2249 | * | ||
2250 | * LOCKING: | ||
2251 | */ | ||
2060 | void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) | 2252 | void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) |
2061 | { | 2253 | { |
2062 | struct scatterlist *sg; | 2254 | struct scatterlist *sg; |
@@ -2074,6 +2266,32 @@ void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, unsigned int buflen) | |||
2074 | sg->length = buflen; | 2266 | sg->length = buflen; |
2075 | } | 2267 | } |
2076 | 2268 | ||
2269 | /** | ||
2270 | * ata_sg_init - Associate command with scatter-gather table. | ||
2271 | * @qc: Command to be associated | ||
2272 | * @sg: Scatter-gather table. | ||
2273 | * @n_elem: Number of elements in s/g table. | ||
2274 | * | ||
2275 | * Initialize the data-related elements of queued_cmd @qc | ||
2276 | * to point to a scatter-gather table @sg, containing @n_elem | ||
2277 | * elements. | ||
2278 | * | ||
2279 | * LOCKING: | ||
2280 | * spin_lock_irqsave(host_set lock) | ||
2281 | */ | ||
2282 | |||
2283 | |||
2284 | /** | ||
2285 | * ata_sg_init - Assign a scatter gather list to a queued command | ||
2286 | * @qc: Queued command | ||
2287 | * @sg: Scatter-gather list | ||
2288 | * @n_elem: length of sg list | ||
2289 | * | ||
2290 | * Attaches a scatter-gather list to a queued command. | ||
2291 | * | ||
2292 | * LOCKING: | ||
2293 | */ | ||
2294 | |||
2077 | void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, | 2295 | void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, |
2078 | unsigned int n_elem) | 2296 | unsigned int n_elem) |
2079 | { | 2297 | { |
@@ -2083,14 +2301,16 @@ void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, | |||
2083 | } | 2301 | } |
2084 | 2302 | ||
2085 | /** | 2303 | /** |
2086 | * ata_sg_setup_one - | 2304 | * ata_sg_setup_one - DMA-map the memory buffer associated with a command. |
2087 | * @qc: | 2305 | * @qc: Command with memory buffer to be mapped. |
2306 | * | ||
2307 | * DMA-map the memory buffer associated with queued_cmd @qc. | ||
2088 | * | 2308 | * |
2089 | * LOCKING: | 2309 | * LOCKING: |
2090 | * spin_lock_irqsave(host_set lock) | 2310 | * spin_lock_irqsave(host_set lock) |
2091 | * | 2311 | * |
2092 | * RETURNS: | 2312 | * RETURNS: |
2093 | * | 2313 | * Zero on success, negative on error. |
2094 | */ | 2314 | */ |
2095 | 2315 | ||
2096 | static int ata_sg_setup_one(struct ata_queued_cmd *qc) | 2316 | static int ata_sg_setup_one(struct ata_queued_cmd *qc) |
@@ -2115,13 +2335,16 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc) | |||
2115 | } | 2335 | } |
2116 | 2336 | ||
2117 | /** | 2337 | /** |
2118 | * ata_sg_setup - | 2338 | * ata_sg_setup - DMA-map the scatter-gather table associated with a command. |
2119 | * @qc: | 2339 | * @qc: Command with scatter-gather table to be mapped. |
2340 | * | ||
2341 | * DMA-map the scatter-gather table associated with queued_cmd @qc. | ||
2120 | * | 2342 | * |
2121 | * LOCKING: | 2343 | * LOCKING: |
2122 | * spin_lock_irqsave(host_set lock) | 2344 | * spin_lock_irqsave(host_set lock) |
2123 | * | 2345 | * |
2124 | * RETURNS: | 2346 | * RETURNS: |
2347 | * Zero on success, negative on error. | ||
2125 | * | 2348 | * |
2126 | */ | 2349 | */ |
2127 | 2350 | ||
@@ -2151,6 +2374,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
2151 | * @ap: | 2374 | * @ap: |
2152 | * | 2375 | * |
2153 | * LOCKING: | 2376 | * LOCKING: |
2377 | * None. (executing in kernel thread context) | ||
2154 | * | 2378 | * |
2155 | * RETURNS: | 2379 | * RETURNS: |
2156 | * | 2380 | * |
@@ -2198,6 +2422,7 @@ static unsigned long ata_pio_poll(struct ata_port *ap) | |||
2198 | * @ap: | 2422 | * @ap: |
2199 | * | 2423 | * |
2200 | * LOCKING: | 2424 | * LOCKING: |
2425 | * None. (executing in kernel thread context) | ||
2201 | */ | 2426 | */ |
2202 | 2427 | ||
2203 | static void ata_pio_complete (struct ata_port *ap) | 2428 | static void ata_pio_complete (struct ata_port *ap) |
@@ -2240,6 +2465,18 @@ static void ata_pio_complete (struct ata_port *ap) | |||
2240 | ata_qc_complete(qc, drv_stat); | 2465 | ata_qc_complete(qc, drv_stat); |
2241 | } | 2466 | } |
2242 | 2467 | ||
2468 | |||
2469 | /** | ||
2470 | * swap_buf_le16 - | ||
2471 | * @buf: Buffer to swap | ||
2472 | * @buf_words: Number of 16-bit words in buffer. | ||
2473 | * | ||
2474 | * Swap halves of 16-bit words if needed to convert from | ||
2475 | * little-endian byte order to native cpu byte order, or | ||
2476 | * vice-versa. | ||
2477 | * | ||
2478 | * LOCKING: | ||
2479 | */ | ||
2243 | void swap_buf_le16(u16 *buf, unsigned int buf_words) | 2480 | void swap_buf_le16(u16 *buf, unsigned int buf_words) |
2244 | { | 2481 | { |
2245 | #ifdef __BIG_ENDIAN | 2482 | #ifdef __BIG_ENDIAN |
@@ -2415,6 +2652,7 @@ err_out: | |||
2415 | * @ap: | 2652 | * @ap: |
2416 | * | 2653 | * |
2417 | * LOCKING: | 2654 | * LOCKING: |
2655 | * None. (executing in kernel thread context) | ||
2418 | */ | 2656 | */ |
2419 | 2657 | ||
2420 | static void ata_pio_block(struct ata_port *ap) | 2658 | static void ata_pio_block(struct ata_port *ap) |
@@ -2583,6 +2821,7 @@ static void atapi_request_sense(struct ata_port *ap, struct ata_device *dev, | |||
2583 | * transaction completed successfully. | 2821 | * transaction completed successfully. |
2584 | * | 2822 | * |
2585 | * LOCKING: | 2823 | * LOCKING: |
2824 | * Inherited from SCSI layer (none, can sleep) | ||
2586 | */ | 2825 | */ |
2587 | 2826 | ||
2588 | static void ata_qc_timeout(struct ata_queued_cmd *qc) | 2827 | static void ata_qc_timeout(struct ata_queued_cmd *qc) |
@@ -2692,6 +2931,7 @@ out: | |||
2692 | * @dev: Device from whom we request an available command structure | 2931 | * @dev: Device from whom we request an available command structure |
2693 | * | 2932 | * |
2694 | * LOCKING: | 2933 | * LOCKING: |
2934 | * None. | ||
2695 | */ | 2935 | */ |
2696 | 2936 | ||
2697 | static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap) | 2937 | static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap) |
@@ -2717,6 +2957,7 @@ static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap) | |||
2717 | * @dev: Device from whom we request an available command structure | 2957 | * @dev: Device from whom we request an available command structure |
2718 | * | 2958 | * |
2719 | * LOCKING: | 2959 | * LOCKING: |
2960 | * None. | ||
2720 | */ | 2961 | */ |
2721 | 2962 | ||
2722 | struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, | 2963 | struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, |
@@ -2781,6 +3022,7 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc) | |||
2781 | * in case something prevents using it. | 3022 | * in case something prevents using it. |
2782 | * | 3023 | * |
2783 | * LOCKING: | 3024 | * LOCKING: |
3025 | * spin_lock_irqsave(host_set lock) | ||
2784 | * | 3026 | * |
2785 | */ | 3027 | */ |
2786 | void ata_qc_free(struct ata_queued_cmd *qc) | 3028 | void ata_qc_free(struct ata_queued_cmd *qc) |
@@ -2794,9 +3036,13 @@ void ata_qc_free(struct ata_queued_cmd *qc) | |||
2794 | /** | 3036 | /** |
2795 | * ata_qc_complete - Complete an active ATA command | 3037 | * ata_qc_complete - Complete an active ATA command |
2796 | * @qc: Command to complete | 3038 | * @qc: Command to complete |
2797 | * @drv_stat: ATA status register contents | 3039 | * @drv_stat: ATA Status register contents |
3040 | * | ||
3041 | * Indicate to the mid and upper layers that an ATA | ||
3042 | * command has completed, with either an ok or not-ok status. | ||
2798 | * | 3043 | * |
2799 | * LOCKING: | 3044 | * LOCKING: |
3045 | * spin_lock_irqsave(host_set lock) | ||
2800 | * | 3046 | * |
2801 | */ | 3047 | */ |
2802 | 3048 | ||
@@ -2892,6 +3138,7 @@ err_out: | |||
2892 | return -1; | 3138 | return -1; |
2893 | } | 3139 | } |
2894 | 3140 | ||
3141 | |||
2895 | /** | 3142 | /** |
2896 | * ata_qc_issue_prot - issue taskfile to device in proto-dependent manner | 3143 | * ata_qc_issue_prot - issue taskfile to device in proto-dependent manner |
2897 | * @qc: command to issue to device | 3144 | * @qc: command to issue to device |
@@ -2901,6 +3148,8 @@ err_out: | |||
2901 | * classes called "protocols", and issuing each type of protocol | 3148 | * classes called "protocols", and issuing each type of protocol |
2902 | * is slightly different. | 3149 | * is slightly different. |
2903 | * | 3150 | * |
3151 | * May be used as the qc_issue() entry in ata_port_operations. | ||
3152 | * | ||
2904 | * LOCKING: | 3153 | * LOCKING: |
2905 | * spin_lock_irqsave(host_set lock) | 3154 | * spin_lock_irqsave(host_set lock) |
2906 | * | 3155 | * |
@@ -2958,7 +3207,7 @@ int ata_qc_issue_prot(struct ata_queued_cmd *qc) | |||
2958 | } | 3207 | } |
2959 | 3208 | ||
2960 | /** | 3209 | /** |
2961 | * ata_bmdma_setup - Set up PCI IDE BMDMA transaction | 3210 | * ata_bmdma_setup_mmio - Set up PCI IDE BMDMA transaction |
2962 | * @qc: Info associated with this ATA transaction. | 3211 | * @qc: Info associated with this ATA transaction. |
2963 | * | 3212 | * |
2964 | * LOCKING: | 3213 | * LOCKING: |
@@ -3065,6 +3314,18 @@ static void ata_bmdma_start_pio (struct ata_queued_cmd *qc) | |||
3065 | ap->ioaddr.bmdma_addr + ATA_DMA_CMD); | 3314 | ap->ioaddr.bmdma_addr + ATA_DMA_CMD); |
3066 | } | 3315 | } |
3067 | 3316 | ||
3317 | |||
3318 | /** | ||
3319 | * ata_bmdma_start - Start a PCI IDE BMDMA transaction | ||
3320 | * @qc: Info associated with this ATA transaction. | ||
3321 | * | ||
3322 | * Writes the ATA_DMA_START flag to the DMA command register. | ||
3323 | * | ||
3324 | * May be used as the bmdma_start() entry in ata_port_operations. | ||
3325 | * | ||
3326 | * LOCKING: | ||
3327 | * spin_lock_irqsave(host_set lock) | ||
3328 | */ | ||
3068 | void ata_bmdma_start(struct ata_queued_cmd *qc) | 3329 | void ata_bmdma_start(struct ata_queued_cmd *qc) |
3069 | { | 3330 | { |
3070 | if (qc->ap->flags & ATA_FLAG_MMIO) | 3331 | if (qc->ap->flags & ATA_FLAG_MMIO) |
@@ -3073,6 +3334,20 @@ void ata_bmdma_start(struct ata_queued_cmd *qc) | |||
3073 | ata_bmdma_start_pio(qc); | 3334 | ata_bmdma_start_pio(qc); |
3074 | } | 3335 | } |
3075 | 3336 | ||
3337 | |||
3338 | /** | ||
3339 | * ata_bmdma_setup - Set up PCI IDE BMDMA transaction | ||
3340 | * @qc: Info associated with this ATA transaction. | ||
3341 | * | ||
3342 | * Writes address of PRD table to device's PRD Table Address | ||
3343 | * register, sets the DMA control register, and calls | ||
3344 | * ops->exec_command() to start the transfer. | ||
3345 | * | ||
3346 | * May be used as the bmdma_setup() entry in ata_port_operations. | ||
3347 | * | ||
3348 | * LOCKING: | ||
3349 | * spin_lock_irqsave(host_set lock) | ||
3350 | */ | ||
3076 | void ata_bmdma_setup(struct ata_queued_cmd *qc) | 3351 | void ata_bmdma_setup(struct ata_queued_cmd *qc) |
3077 | { | 3352 | { |
3078 | if (qc->ap->flags & ATA_FLAG_MMIO) | 3353 | if (qc->ap->flags & ATA_FLAG_MMIO) |
@@ -3081,6 +3356,19 @@ void ata_bmdma_setup(struct ata_queued_cmd *qc) | |||
3081 | ata_bmdma_setup_pio(qc); | 3356 | ata_bmdma_setup_pio(qc); |
3082 | } | 3357 | } |
3083 | 3358 | ||
3359 | |||
3360 | /** | ||
3361 | * ata_bmdma_irq_clear - Clear PCI IDE BMDMA interrupt. | ||
3362 | * @ap: Port associated with this ATA transaction. | ||
3363 | * | ||
3364 | * Clear interrupt and error flags in DMA status register. | ||
3365 | * | ||
3366 | * May be used as the irq_clear() entry in ata_port_operations. | ||
3367 | * | ||
3368 | * LOCKING: | ||
3369 | * spin_lock_irqsave(host_set lock) | ||
3370 | */ | ||
3371 | |||
3084 | void ata_bmdma_irq_clear(struct ata_port *ap) | 3372 | void ata_bmdma_irq_clear(struct ata_port *ap) |
3085 | { | 3373 | { |
3086 | if (ap->flags & ATA_FLAG_MMIO) { | 3374 | if (ap->flags & ATA_FLAG_MMIO) { |
@@ -3093,6 +3381,19 @@ void ata_bmdma_irq_clear(struct ata_port *ap) | |||
3093 | 3381 | ||
3094 | } | 3382 | } |
3095 | 3383 | ||
3384 | |||
3385 | /** | ||
3386 | * ata_bmdma_status - Read PCI IDE BMDMA status | ||
3387 | * @ap: Port associated with this ATA transaction. | ||
3388 | * | ||
3389 | * Read and return BMDMA status register. | ||
3390 | * | ||
3391 | * May be used as the bmdma_status() entry in ata_port_operations. | ||
3392 | * | ||
3393 | * LOCKING: | ||
3394 | * spin_lock_irqsave(host_set lock) | ||
3395 | */ | ||
3396 | |||
3096 | u8 ata_bmdma_status(struct ata_port *ap) | 3397 | u8 ata_bmdma_status(struct ata_port *ap) |
3097 | { | 3398 | { |
3098 | u8 host_stat; | 3399 | u8 host_stat; |
@@ -3104,6 +3405,19 @@ u8 ata_bmdma_status(struct ata_port *ap) | |||
3104 | return host_stat; | 3405 | return host_stat; |
3105 | } | 3406 | } |
3106 | 3407 | ||
3408 | |||
3409 | /** | ||
3410 | * ata_bmdma_stop - Stop PCI IDE BMDMA transfer | ||
3411 | * @ap: Port associated with this ATA transaction. | ||
3412 | * | ||
3413 | * Clears the ATA_DMA_START flag in the dma control register | ||
3414 | * | ||
3415 | * May be used as the bmdma_stop() entry in ata_port_operations. | ||
3416 | * | ||
3417 | * LOCKING: | ||
3418 | * spin_lock_irqsave(host_set lock) | ||
3419 | */ | ||
3420 | |||
3107 | void ata_bmdma_stop(struct ata_port *ap) | 3421 | void ata_bmdma_stop(struct ata_port *ap) |
3108 | { | 3422 | { |
3109 | if (ap->flags & ATA_FLAG_MMIO) { | 3423 | if (ap->flags & ATA_FLAG_MMIO) { |
@@ -3203,13 +3517,18 @@ idle_irq: | |||
3203 | 3517 | ||
3204 | /** | 3518 | /** |
3205 | * ata_interrupt - Default ATA host interrupt handler | 3519 | * ata_interrupt - Default ATA host interrupt handler |
3206 | * @irq: irq line | 3520 | * @irq: irq line (unused) |
3207 | * @dev_instance: pointer to our host information structure | 3521 | * @dev_instance: pointer to our ata_host_set information structure |
3208 | * @regs: unused | 3522 | * @regs: unused |
3209 | * | 3523 | * |
3524 | * Default interrupt handler for PCI IDE devices. Calls | ||
3525 | * ata_host_intr() for each port that is not disabled. | ||
3526 | * | ||
3210 | * LOCKING: | 3527 | * LOCKING: |
3528 | * Obtains host_set lock during operation. | ||
3211 | * | 3529 | * |
3212 | * RETURNS: | 3530 | * RETURNS: |
3531 | * IRQ_NONE or IRQ_HANDLED. | ||
3213 | * | 3532 | * |
3214 | */ | 3533 | */ |
3215 | 3534 | ||
@@ -3302,6 +3621,19 @@ err_out: | |||
3302 | ata_qc_complete(qc, ATA_ERR); | 3621 | ata_qc_complete(qc, ATA_ERR); |
3303 | } | 3622 | } |
3304 | 3623 | ||
3624 | |||
3625 | /** | ||
3626 | * ata_port_start - Set port up for dma. | ||
3627 | * @ap: Port to initialize | ||
3628 | * | ||
3629 | * Called just after data structures for each port are | ||
3630 | * initialized. Allocates space for PRD table. | ||
3631 | * | ||
3632 | * May be used as the port_start() entry in ata_port_operations. | ||
3633 | * | ||
3634 | * LOCKING: | ||
3635 | */ | ||
3636 | |||
3305 | int ata_port_start (struct ata_port *ap) | 3637 | int ata_port_start (struct ata_port *ap) |
3306 | { | 3638 | { |
3307 | struct device *dev = ap->host_set->dev; | 3639 | struct device *dev = ap->host_set->dev; |
@@ -3315,6 +3647,18 @@ int ata_port_start (struct ata_port *ap) | |||
3315 | return 0; | 3647 | return 0; |
3316 | } | 3648 | } |
3317 | 3649 | ||
3650 | |||
3651 | /** | ||
3652 | * ata_port_stop - Undo ata_port_start() | ||
3653 | * @ap: Port to shut down | ||
3654 | * | ||
3655 | * Frees the PRD table. | ||
3656 | * | ||
3657 | * May be used as the port_stop() entry in ata_port_operations. | ||
3658 | * | ||
3659 | * LOCKING: | ||
3660 | */ | ||
3661 | |||
3318 | void ata_port_stop (struct ata_port *ap) | 3662 | void ata_port_stop (struct ata_port *ap) |
3319 | { | 3663 | { |
3320 | struct device *dev = ap->host_set->dev; | 3664 | struct device *dev = ap->host_set->dev; |
@@ -3357,7 +3701,11 @@ static void ata_host_remove(struct ata_port *ap, unsigned int do_unregister) | |||
3357 | * @ent: Probe information provided by low-level driver | 3701 | * @ent: Probe information provided by low-level driver |
3358 | * @port_no: Port number associated with this ata_port | 3702 | * @port_no: Port number associated with this ata_port |
3359 | * | 3703 | * |
3704 | * Initialize a new ata_port structure, and its associated | ||
3705 | * scsi_host. | ||
3706 | * | ||
3360 | * LOCKING: | 3707 | * LOCKING: |
3708 | * Inherited from caller. | ||
3361 | * | 3709 | * |
3362 | */ | 3710 | */ |
3363 | 3711 | ||
@@ -3412,9 +3760,13 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, | |||
3412 | * @host_set: Collections of ports to which we add | 3760 | * @host_set: Collections of ports to which we add |
3413 | * @port_no: Port number associated with this host | 3761 | * @port_no: Port number associated with this host |
3414 | * | 3762 | * |
3763 | * Attach low-level ATA driver to system. | ||
3764 | * | ||
3415 | * LOCKING: | 3765 | * LOCKING: |
3766 | * PCI/etc. bus probe sem. | ||
3416 | * | 3767 | * |
3417 | * RETURNS: | 3768 | * RETURNS: |
3769 | * New ata_port on success, for NULL on error. | ||
3418 | * | 3770 | * |
3419 | */ | 3771 | */ |
3420 | 3772 | ||
@@ -3447,12 +3799,22 @@ err_out: | |||
3447 | } | 3799 | } |
3448 | 3800 | ||
3449 | /** | 3801 | /** |
3450 | * ata_device_add - | 3802 | * ata_device_add - Register hardware device with ATA and SCSI layers |
3451 | * @ent: | 3803 | * @ent: Probe information describing hardware device to be registered |
3804 | * | ||
3805 | * This function processes the information provided in the probe | ||
3806 | * information struct @ent, allocates the necessary ATA and SCSI | ||
3807 | * host information structures, initializes them, and registers | ||
3808 | * everything with requisite kernel subsystems. | ||
3809 | * | ||
3810 | * This function requests irqs, probes the ATA bus, and probes | ||
3811 | * the SCSI bus. | ||
3452 | * | 3812 | * |
3453 | * LOCKING: | 3813 | * LOCKING: |
3814 | * PCI/etc. bus probe sem. | ||
3454 | * | 3815 | * |
3455 | * RETURNS: | 3816 | * RETURNS: |
3817 | * Number of ports registered. Zero on error (no ports registered). | ||
3456 | * | 3818 | * |
3457 | */ | 3819 | */ |
3458 | 3820 | ||
@@ -3604,7 +3966,15 @@ int ata_scsi_release(struct Scsi_Host *host) | |||
3604 | /** | 3966 | /** |
3605 | * ata_std_ports - initialize ioaddr with standard port offsets. | 3967 | * ata_std_ports - initialize ioaddr with standard port offsets. |
3606 | * @ioaddr: IO address structure to be initialized | 3968 | * @ioaddr: IO address structure to be initialized |
3969 | * | ||
3970 | * Utility function which initializes data_addr, error_addr, | ||
3971 | * feature_addr, nsect_addr, lbal_addr, lbam_addr, lbah_addr, | ||
3972 | * device_addr, status_addr, and command_addr to standard offsets | ||
3973 | * relative to cmd_addr. | ||
3974 | * | ||
3975 | * Does not set ctl_addr, altstatus_addr, bmdma_addr, or scr_addr. | ||
3607 | */ | 3976 | */ |
3977 | |||
3608 | void ata_std_ports(struct ata_ioports *ioaddr) | 3978 | void ata_std_ports(struct ata_ioports *ioaddr) |
3609 | { | 3979 | { |
3610 | ioaddr->data_addr = ioaddr->cmd_addr + ATA_REG_DATA; | 3980 | ioaddr->data_addr = ioaddr->cmd_addr + ATA_REG_DATA; |
@@ -3646,6 +4016,20 @@ ata_probe_ent_alloc(struct device *dev, struct ata_port_info *port) | |||
3646 | return probe_ent; | 4016 | return probe_ent; |
3647 | } | 4017 | } |
3648 | 4018 | ||
4019 | |||
4020 | |||
4021 | /** | ||
4022 | * ata_pci_init_native_mode - Initialize native-mode driver | ||
4023 | * @pdev: pci device to be initialized | ||
4024 | * @port: array[2] of pointers to port info structures. | ||
4025 | * | ||
4026 | * Utility function which allocates and initializes an | ||
4027 | * ata_probe_ent structure for a standard dual-port | ||
4028 | * PIO-based IDE controller. The returned ata_probe_ent | ||
4029 | * structure can be passed to ata_device_add(). The returned | ||
4030 | * ata_probe_ent structure should then be freed with kfree(). | ||
4031 | */ | ||
4032 | |||
3649 | #ifdef CONFIG_PCI | 4033 | #ifdef CONFIG_PCI |
3650 | struct ata_probe_ent * | 4034 | struct ata_probe_ent * |
3651 | ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port) | 4035 | ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port) |
@@ -3727,10 +4111,19 @@ ata_pci_init_legacy_mode(struct pci_dev *pdev, struct ata_port_info **port, | |||
3727 | * @port_info: Information from low-level host driver | 4111 | * @port_info: Information from low-level host driver |
3728 | * @n_ports: Number of ports attached to host controller | 4112 | * @n_ports: Number of ports attached to host controller |
3729 | * | 4113 | * |
4114 | * This is a helper function which can be called from a driver's | ||
4115 | * xxx_init_one() probe function if the hardware uses traditional | ||
4116 | * IDE taskfile registers. | ||
4117 | * | ||
4118 | * This function calls pci_enable_device(), reserves its register | ||
4119 | * regions, sets the dma mask, enables bus master mode, and calls | ||
4120 | * ata_device_add() | ||
4121 | * | ||
3730 | * LOCKING: | 4122 | * LOCKING: |
3731 | * Inherited from PCI layer (may sleep). | 4123 | * Inherited from PCI layer (may sleep). |
3732 | * | 4124 | * |
3733 | * RETURNS: | 4125 | * RETURNS: |
4126 | * Zero on success, negative on errno-based value on error. | ||
3734 | * | 4127 | * |
3735 | */ | 4128 | */ |
3736 | 4129 | ||
@@ -3949,15 +4342,6 @@ int pci_test_config_bits(struct pci_dev *pdev, struct pci_bits *bits) | |||
3949 | #endif /* CONFIG_PCI */ | 4342 | #endif /* CONFIG_PCI */ |
3950 | 4343 | ||
3951 | 4344 | ||
3952 | /** | ||
3953 | * ata_init - | ||
3954 | * | ||
3955 | * LOCKING: | ||
3956 | * | ||
3957 | * RETURNS: | ||
3958 | * | ||
3959 | */ | ||
3960 | |||
3961 | static int __init ata_init(void) | 4345 | static int __init ata_init(void) |
3962 | { | 4346 | { |
3963 | ata_wq = create_workqueue("ata"); | 4347 | ata_wq = create_workqueue("ata"); |
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 416ba67ba9ee..7a4adc4c8f09 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -947,7 +947,7 @@ unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf, | |||
947 | } | 947 | } |
948 | 948 | ||
949 | /** | 949 | /** |
950 | * ata_scsiop_noop - | 950 | * ata_scsiop_noop - Command handler that simply returns success. |
951 | * @args: device IDENTIFY data / SCSI command of interest. | 951 | * @args: device IDENTIFY data / SCSI command of interest. |
952 | * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. | 952 | * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. |
953 | * @buflen: Response buffer length. | 953 | * @buflen: Response buffer length. |
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 579448222d69..3c97aa45772d 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c | |||
@@ -507,6 +507,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) | |||
507 | int ret, i; | 507 | int ret, i; |
508 | unsigned int id, lun; | 508 | unsigned int id, lun; |
509 | unsigned long serial; | 509 | unsigned long serial; |
510 | unsigned long flags; | ||
510 | 511 | ||
511 | if (!CMD_SP(cmd)) | 512 | if (!CMD_SP(cmd)) |
512 | return FAILED; | 513 | return FAILED; |
@@ -519,7 +520,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) | |||
519 | 520 | ||
520 | /* Check active list for command command. */ | 521 | /* Check active list for command command. */ |
521 | spin_unlock_irq(ha->host->host_lock); | 522 | spin_unlock_irq(ha->host->host_lock); |
522 | spin_lock(&ha->hardware_lock); | 523 | spin_lock_irqsave(&ha->hardware_lock, flags); |
523 | for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) { | 524 | for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) { |
524 | sp = ha->outstanding_cmds[i]; | 525 | sp = ha->outstanding_cmds[i]; |
525 | 526 | ||
@@ -534,7 +535,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) | |||
534 | sp->state)); | 535 | sp->state)); |
535 | DEBUG3(qla2x00_print_scsi_cmd(cmd);) | 536 | DEBUG3(qla2x00_print_scsi_cmd(cmd);) |
536 | 537 | ||
537 | spin_unlock(&ha->hardware_lock); | 538 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
538 | if (qla2x00_abort_command(ha, sp)) { | 539 | if (qla2x00_abort_command(ha, sp)) { |
539 | DEBUG2(printk("%s(%ld): abort_command " | 540 | DEBUG2(printk("%s(%ld): abort_command " |
540 | "mbx failed.\n", __func__, ha->host_no)); | 541 | "mbx failed.\n", __func__, ha->host_no)); |
@@ -543,20 +544,19 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) | |||
543 | "mbx success.\n", __func__, ha->host_no)); | 544 | "mbx success.\n", __func__, ha->host_no)); |
544 | ret = SUCCESS; | 545 | ret = SUCCESS; |
545 | } | 546 | } |
546 | spin_lock(&ha->hardware_lock); | 547 | spin_lock_irqsave(&ha->hardware_lock, flags); |
547 | 548 | ||
548 | break; | 549 | break; |
549 | } | 550 | } |
551 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | ||
550 | 552 | ||
551 | /* Wait for the command to be returned. */ | 553 | /* Wait for the command to be returned. */ |
552 | if (ret == SUCCESS) { | 554 | if (ret == SUCCESS) { |
553 | spin_unlock(&ha->hardware_lock); | ||
554 | if (qla2x00_eh_wait_on_command(ha, cmd) != QLA_SUCCESS) { | 555 | if (qla2x00_eh_wait_on_command(ha, cmd) != QLA_SUCCESS) { |
555 | qla_printk(KERN_ERR, ha, | 556 | qla_printk(KERN_ERR, ha, |
556 | "scsi(%ld:%d:%d): Abort handler timed out -- %lx " | 557 | "scsi(%ld:%d:%d): Abort handler timed out -- %lx " |
557 | "%x.\n", ha->host_no, id, lun, serial, ret); | 558 | "%x.\n", ha->host_no, id, lun, serial, ret); |
558 | } | 559 | } |
559 | spin_lock(&ha->hardware_lock); | ||
560 | } | 560 | } |
561 | spin_lock_irq(ha->host->host_lock); | 561 | spin_lock_irq(ha->host->host_lock); |
562 | 562 | ||
@@ -588,6 +588,7 @@ qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t) | |||
588 | int status; | 588 | int status; |
589 | srb_t *sp; | 589 | srb_t *sp; |
590 | struct scsi_cmnd *cmd; | 590 | struct scsi_cmnd *cmd; |
591 | unsigned long flags; | ||
591 | 592 | ||
592 | status = 0; | 593 | status = 0; |
593 | 594 | ||
@@ -596,11 +597,11 @@ qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t) | |||
596 | * array | 597 | * array |
597 | */ | 598 | */ |
598 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { | 599 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { |
599 | spin_lock(&ha->hardware_lock); | 600 | spin_lock_irqsave(&ha->hardware_lock, flags); |
600 | sp = ha->outstanding_cmds[cnt]; | 601 | sp = ha->outstanding_cmds[cnt]; |
601 | if (sp) { | 602 | if (sp) { |
602 | cmd = sp->cmd; | 603 | cmd = sp->cmd; |
603 | spin_unlock(&ha->hardware_lock); | 604 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
604 | if (cmd->device->id == t) { | 605 | if (cmd->device->id == t) { |
605 | if (!qla2x00_eh_wait_on_command(ha, cmd)) { | 606 | if (!qla2x00_eh_wait_on_command(ha, cmd)) { |
606 | status = 1; | 607 | status = 1; |
@@ -608,7 +609,7 @@ qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t) | |||
608 | } | 609 | } |
609 | } | 610 | } |
610 | } else { | 611 | } else { |
611 | spin_unlock(&ha->hardware_lock); | 612 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
612 | } | 613 | } |
613 | } | 614 | } |
614 | return (status); | 615 | return (status); |
@@ -740,6 +741,7 @@ qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *ha) | |||
740 | int status; | 741 | int status; |
741 | srb_t *sp; | 742 | srb_t *sp; |
742 | struct scsi_cmnd *cmd; | 743 | struct scsi_cmnd *cmd; |
744 | unsigned long flags; | ||
743 | 745 | ||
744 | status = 1; | 746 | status = 1; |
745 | 747 | ||
@@ -748,17 +750,17 @@ qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *ha) | |||
748 | * array | 750 | * array |
749 | */ | 751 | */ |
750 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { | 752 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { |
751 | spin_lock(&ha->hardware_lock); | 753 | spin_lock_irqsave(&ha->hardware_lock, flags); |
752 | sp = ha->outstanding_cmds[cnt]; | 754 | sp = ha->outstanding_cmds[cnt]; |
753 | if (sp) { | 755 | if (sp) { |
754 | cmd = sp->cmd; | 756 | cmd = sp->cmd; |
755 | spin_unlock(&ha->hardware_lock); | 757 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
756 | status = qla2x00_eh_wait_on_command(ha, cmd); | 758 | status = qla2x00_eh_wait_on_command(ha, cmd); |
757 | if (status == 0) | 759 | if (status == 0) |
758 | break; | 760 | break; |
759 | } | 761 | } |
760 | else { | 762 | else { |
761 | spin_unlock(&ha->hardware_lock); | 763 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
762 | } | 764 | } |
763 | } | 765 | } |
764 | return (status); | 766 | return (status); |
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index cca772624ae7..8d0d302844a1 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
@@ -1197,6 +1197,7 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel, | |||
1197 | if (!starget) | 1197 | if (!starget) |
1198 | return ERR_PTR(-ENOMEM); | 1198 | return ERR_PTR(-ENOMEM); |
1199 | 1199 | ||
1200 | get_device(&starget->dev); | ||
1200 | down(&shost->scan_mutex); | 1201 | down(&shost->scan_mutex); |
1201 | res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata); | 1202 | res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata); |
1202 | if (res != SCSI_SCAN_LUN_PRESENT) | 1203 | if (res != SCSI_SCAN_LUN_PRESENT) |
diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c index 5d2ceb623e6f..1f985327b0d4 100644 --- a/drivers/serial/vr41xx_siu.c +++ b/drivers/serial/vr41xx_siu.c | |||
@@ -234,7 +234,7 @@ static inline const char *siu_type_name(struct uart_port *port) | |||
234 | return "DSIU"; | 234 | return "DSIU"; |
235 | } | 235 | } |
236 | 236 | ||
237 | return "unknown"; | 237 | return NULL; |
238 | } | 238 | } |
239 | 239 | ||
240 | static unsigned int siu_tx_empty(struct uart_port *port) | 240 | static unsigned int siu_tx_empty(struct uart_port *port) |
@@ -482,9 +482,6 @@ static irqreturn_t siu_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
482 | struct uart_port *port; | 482 | struct uart_port *port; |
483 | uint8_t iir, lsr; | 483 | uint8_t iir, lsr; |
484 | 484 | ||
485 | if (dev_id == NULL) | ||
486 | return IRQ_NONE; | ||
487 | |||
488 | port = (struct uart_port *)dev_id; | 485 | port = (struct uart_port *)dev_id; |
489 | 486 | ||
490 | iir = siu_read(port, UART_IIR); | 487 | iir = siu_read(port, UART_IIR); |
@@ -507,6 +504,9 @@ static int siu_startup(struct uart_port *port) | |||
507 | { | 504 | { |
508 | int retval; | 505 | int retval; |
509 | 506 | ||
507 | if (port->membase == NULL) | ||
508 | return -ENODEV; | ||
509 | |||
510 | siu_clear_fifo(port); | 510 | siu_clear_fifo(port); |
511 | 511 | ||
512 | (void)siu_read(port, UART_LSR); | 512 | (void)siu_read(port, UART_LSR); |
@@ -545,9 +545,6 @@ static void siu_shutdown(struct uart_port *port) | |||
545 | unsigned long flags; | 545 | unsigned long flags; |
546 | uint8_t lcr; | 546 | uint8_t lcr; |
547 | 547 | ||
548 | if (port->membase == NULL) | ||
549 | return; | ||
550 | |||
551 | siu_write(port, UART_IER, 0); | 548 | siu_write(port, UART_IER, 0); |
552 | 549 | ||
553 | spin_lock_irqsave(&port->lock, flags); | 550 | spin_lock_irqsave(&port->lock, flags); |
@@ -802,53 +799,6 @@ static int siu_init_ports(void) | |||
802 | 799 | ||
803 | #ifdef CONFIG_SERIAL_VR41XX_CONSOLE | 800 | #ifdef CONFIG_SERIAL_VR41XX_CONSOLE |
804 | 801 | ||
805 | static void early_set_termios(struct uart_port *port, struct termios *new, | ||
806 | struct termios *old) | ||
807 | { | ||
808 | tcflag_t c_cflag; | ||
809 | uint8_t lcr; | ||
810 | unsigned int baud, quot; | ||
811 | |||
812 | c_cflag = new->c_cflag; | ||
813 | switch (c_cflag & CSIZE) { | ||
814 | case CS5: | ||
815 | lcr = UART_LCR_WLEN5; | ||
816 | break; | ||
817 | case CS6: | ||
818 | lcr = UART_LCR_WLEN6; | ||
819 | break; | ||
820 | case CS7: | ||
821 | lcr = UART_LCR_WLEN7; | ||
822 | break; | ||
823 | default: | ||
824 | lcr = UART_LCR_WLEN8; | ||
825 | break; | ||
826 | } | ||
827 | |||
828 | if (c_cflag & CSTOPB) | ||
829 | lcr |= UART_LCR_STOP; | ||
830 | if (c_cflag & PARENB) | ||
831 | lcr |= UART_LCR_PARITY; | ||
832 | if ((c_cflag & PARODD) != PARODD) | ||
833 | lcr |= UART_LCR_EPAR; | ||
834 | if (c_cflag & CMSPAR) | ||
835 | lcr |= UART_LCR_SPAR; | ||
836 | |||
837 | baud = uart_get_baud_rate(port, new, old, 0, port->uartclk/16); | ||
838 | quot = uart_get_divisor(port, baud); | ||
839 | |||
840 | siu_write(port, UART_LCR, lcr | UART_LCR_DLAB); | ||
841 | |||
842 | siu_write(port, UART_DLL, (uint8_t)quot); | ||
843 | siu_write(port, UART_DLM, (uint8_t)(quot >> 8)); | ||
844 | |||
845 | siu_write(port, UART_LCR, lcr); | ||
846 | } | ||
847 | |||
848 | static struct uart_ops early_uart_ops = { | ||
849 | .set_termios = early_set_termios, | ||
850 | }; | ||
851 | |||
852 | #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) | 802 | #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) |
853 | 803 | ||
854 | static void wait_for_xmitr(struct uart_port *port) | 804 | static void wait_for_xmitr(struct uart_port *port) |
@@ -915,7 +865,7 @@ static int siu_console_setup(struct console *con, char *options) | |||
915 | if (port->membase == NULL) { | 865 | if (port->membase == NULL) { |
916 | if (port->mapbase == 0) | 866 | if (port->mapbase == 0) |
917 | return -ENODEV; | 867 | return -ENODEV; |
918 | port->membase = (unsigned char __iomem *)KSEG1ADDR(port->mapbase); | 868 | port->membase = ioremap(port->mapbase, siu_port_size(port)); |
919 | } | 869 | } |
920 | 870 | ||
921 | vr41xx_select_siu_interface(SIU_INTERFACE_RS232C); | 871 | vr41xx_select_siu_interface(SIU_INTERFACE_RS232C); |
@@ -949,7 +899,7 @@ static int __devinit siu_console_init(void) | |||
949 | 899 | ||
950 | for (i = 0; i < num; i++) { | 900 | for (i = 0; i < num; i++) { |
951 | port = &siu_uart_ports[i]; | 901 | port = &siu_uart_ports[i]; |
952 | port->ops = &early_uart_ops; | 902 | port->ops = &siu_uart_ops; |
953 | } | 903 | } |
954 | 904 | ||
955 | register_console(&siu_console); | 905 | register_console(&siu_console); |
@@ -994,8 +944,10 @@ static int siu_probe(struct device *dev) | |||
994 | port->dev = dev; | 944 | port->dev = dev; |
995 | 945 | ||
996 | retval = uart_add_one_port(&siu_uart_driver, port); | 946 | retval = uart_add_one_port(&siu_uart_driver, port); |
997 | if (retval) | 947 | if (retval < 0) { |
948 | port->dev = NULL; | ||
998 | break; | 949 | break; |
950 | } | ||
999 | } | 951 | } |
1000 | 952 | ||
1001 | if (i == 0 && retval < 0) { | 953 | if (i == 0 && retval < 0) { |
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 4ab50009291d..4d0c9e65cd03 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -290,32 +290,30 @@ static ssize_t show_modalias(struct device *dev, char *buf) | |||
290 | { | 290 | { |
291 | struct usb_interface *intf; | 291 | struct usb_interface *intf; |
292 | struct usb_device *udev; | 292 | struct usb_device *udev; |
293 | int len; | ||
293 | 294 | ||
294 | intf = to_usb_interface(dev); | 295 | intf = to_usb_interface(dev); |
295 | udev = interface_to_usbdev(intf); | 296 | udev = interface_to_usbdev(intf); |
296 | if (udev->descriptor.bDeviceClass == 0) { | ||
297 | struct usb_host_interface *alt = intf->cur_altsetting; | ||
298 | 297 | ||
299 | return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X\n", | 298 | len = sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic", |
300 | le16_to_cpu(udev->descriptor.idVendor), | 299 | le16_to_cpu(udev->descriptor.idVendor), |
301 | le16_to_cpu(udev->descriptor.idProduct), | 300 | le16_to_cpu(udev->descriptor.idProduct), |
302 | le16_to_cpu(udev->descriptor.bcdDevice), | 301 | le16_to_cpu(udev->descriptor.bcdDevice), |
303 | udev->descriptor.bDeviceClass, | 302 | udev->descriptor.bDeviceClass, |
304 | udev->descriptor.bDeviceSubClass, | 303 | udev->descriptor.bDeviceSubClass, |
305 | udev->descriptor.bDeviceProtocol, | 304 | udev->descriptor.bDeviceProtocol); |
305 | buf += len; | ||
306 | |||
307 | if (udev->descriptor.bDeviceClass == 0) { | ||
308 | struct usb_host_interface *alt = intf->cur_altsetting; | ||
309 | |||
310 | return len + sprintf(buf, "%02Xisc%02Xip%02X\n", | ||
306 | alt->desc.bInterfaceClass, | 311 | alt->desc.bInterfaceClass, |
307 | alt->desc.bInterfaceSubClass, | 312 | alt->desc.bInterfaceSubClass, |
308 | alt->desc.bInterfaceProtocol); | 313 | alt->desc.bInterfaceProtocol); |
309 | } else { | 314 | } else { |
310 | return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*\n", | 315 | return len + sprintf(buf, "*isc*ip*\n"); |
311 | le16_to_cpu(udev->descriptor.idVendor), | ||
312 | le16_to_cpu(udev->descriptor.idProduct), | ||
313 | le16_to_cpu(udev->descriptor.bcdDevice), | ||
314 | udev->descriptor.bDeviceClass, | ||
315 | udev->descriptor.bDeviceSubClass, | ||
316 | udev->descriptor.bDeviceProtocol); | ||
317 | } | 316 | } |
318 | |||
319 | } | 317 | } |
320 | static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); | 318 | static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); |
321 | 319 | ||
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 3196c3265ff5..19e598c9641f 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -124,3 +124,14 @@ config USB_SL811_HCD | |||
124 | To compile this driver as a module, choose M here: the | 124 | To compile this driver as a module, choose M here: the |
125 | module will be called sl811-hcd. | 125 | module will be called sl811-hcd. |
126 | 126 | ||
127 | config USB_SL811_CS | ||
128 | tristate "CF/PCMCIA support for SL811HS HCD" | ||
129 | depends on USB_SL811_HCD && PCMCIA | ||
130 | default N | ||
131 | help | ||
132 | Wraps a PCMCIA driver around the SL811HS HCD, supporting the RATOC | ||
133 | REX-CFU1U CF card (often used with PDAs). If unsure, say N. | ||
134 | |||
135 | To compile this driver as a module, choose M here: the | ||
136 | module will be called "sl811_cs". | ||
137 | |||
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index a574ca06cf6b..5dbd3e7a27c7 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile | |||
@@ -7,4 +7,5 @@ obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o | |||
7 | obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o | 7 | obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o |
8 | obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o | 8 | obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o |
9 | obj-$(CONFIG_USB_SL811_HCD) += sl811-hcd.o | 9 | obj-$(CONFIG_USB_SL811_HCD) += sl811-hcd.o |
10 | obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o | ||
10 | obj-$(CONFIG_ETRAX_ARCH_V10) += hc_crisv10.o | 11 | obj-$(CONFIG_ETRAX_ARCH_V10) += hc_crisv10.o |
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index a374b7692073..99d43f758ad0 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
@@ -2,8 +2,8 @@ | |||
2 | * SL811HS HCD (Host Controller Driver) for USB. | 2 | * SL811HS HCD (Host Controller Driver) for USB. |
3 | * | 3 | * |
4 | * Copyright (C) 2004 Psion Teklogix (for NetBook PRO) | 4 | * Copyright (C) 2004 Psion Teklogix (for NetBook PRO) |
5 | * Copyright (C) 2004 David Brownell | 5 | * Copyright (C) 2004-2005 David Brownell |
6 | * | 6 | * |
7 | * Periodic scheduling is based on Roman's OHCI code | 7 | * Periodic scheduling is based on Roman's OHCI code |
8 | * Copyright (C) 1999 Roman Weissgaerber | 8 | * Copyright (C) 1999 Roman Weissgaerber |
9 | * | 9 | * |
@@ -15,7 +15,7 @@ | |||
15 | * For documentation, see the SL811HS spec and the "SL811HS Embedded Host" | 15 | * For documentation, see the SL811HS spec and the "SL811HS Embedded Host" |
16 | * document (providing significant pieces missing from that spec); plus | 16 | * document (providing significant pieces missing from that spec); plus |
17 | * the SL811S spec if you want peripheral side info. | 17 | * the SL811S spec if you want peripheral side info. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | /* | 20 | /* |
21 | * Status: Passed basic stress testing, works with hubs, mice, keyboards, | 21 | * Status: Passed basic stress testing, works with hubs, mice, keyboards, |
@@ -67,7 +67,7 @@ | |||
67 | MODULE_DESCRIPTION("SL811HS USB Host Controller Driver"); | 67 | MODULE_DESCRIPTION("SL811HS USB Host Controller Driver"); |
68 | MODULE_LICENSE("GPL"); | 68 | MODULE_LICENSE("GPL"); |
69 | 69 | ||
70 | #define DRIVER_VERSION "15 Dec 2004" | 70 | #define DRIVER_VERSION "19 May 2005" |
71 | 71 | ||
72 | 72 | ||
73 | #ifndef DEBUG | 73 | #ifndef DEBUG |
@@ -121,6 +121,10 @@ static void port_power(struct sl811 *sl811, int is_on) | |||
121 | /* reset as thoroughly as we can */ | 121 | /* reset as thoroughly as we can */ |
122 | if (sl811->board && sl811->board->reset) | 122 | if (sl811->board && sl811->board->reset) |
123 | sl811->board->reset(hcd->self.controller); | 123 | sl811->board->reset(hcd->self.controller); |
124 | else { | ||
125 | sl811_write(sl811, SL11H_CTLREG1, SL11H_CTL1MASK_SE0); | ||
126 | mdelay(20); | ||
127 | } | ||
124 | 128 | ||
125 | sl811_write(sl811, SL11H_IRQ_ENABLE, 0); | 129 | sl811_write(sl811, SL11H_IRQ_ENABLE, 0); |
126 | sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1); | 130 | sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1); |
@@ -443,6 +447,7 @@ static void finish_request( | |||
443 | spin_lock(&urb->lock); | 447 | spin_lock(&urb->lock); |
444 | if (urb->status == -EINPROGRESS) | 448 | if (urb->status == -EINPROGRESS) |
445 | urb->status = status; | 449 | urb->status = status; |
450 | urb->hcpriv = NULL; | ||
446 | spin_unlock(&urb->lock); | 451 | spin_unlock(&urb->lock); |
447 | 452 | ||
448 | spin_unlock(&sl811->lock); | 453 | spin_unlock(&sl811->lock); |
@@ -472,7 +477,7 @@ static void finish_request( | |||
472 | if (*prev) | 477 | if (*prev) |
473 | *prev = ep->next; | 478 | *prev = ep->next; |
474 | sl811->load[i] -= ep->load; | 479 | sl811->load[i] -= ep->load; |
475 | } | 480 | } |
476 | ep->branch = PERIODIC_SIZE; | 481 | ep->branch = PERIODIC_SIZE; |
477 | sl811->periodic_count--; | 482 | sl811->periodic_count--; |
478 | sl811_to_hcd(sl811)->self.bandwidth_allocated | 483 | sl811_to_hcd(sl811)->self.bandwidth_allocated |
@@ -661,9 +666,9 @@ retry: | |||
661 | 666 | ||
662 | #ifdef QUIRK2 | 667 | #ifdef QUIRK2 |
663 | /* this may no longer be necessary ... */ | 668 | /* this may no longer be necessary ... */ |
664 | if (irqstat == 0 && ret == IRQ_NONE) { | 669 | if (irqstat == 0) { |
665 | irqstat = checkdone(sl811); | 670 | irqstat = checkdone(sl811); |
666 | if (irqstat /* && irq != ~0 */ ) | 671 | if (irqstat) |
667 | sl811->stat_lost++; | 672 | sl811->stat_lost++; |
668 | } | 673 | } |
669 | #endif | 674 | #endif |
@@ -722,7 +727,8 @@ retry: | |||
722 | if (sl811->active_a) { | 727 | if (sl811->active_a) { |
723 | sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG), 0); | 728 | sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG), 0); |
724 | finish_request(sl811, sl811->active_a, | 729 | finish_request(sl811, sl811->active_a, |
725 | container_of(sl811->active_a->hep->urb_list.next, | 730 | container_of(sl811->active_a |
731 | ->hep->urb_list.next, | ||
726 | struct urb, urb_list), | 732 | struct urb, urb_list), |
727 | NULL, -ESHUTDOWN); | 733 | NULL, -ESHUTDOWN); |
728 | sl811->active_a = NULL; | 734 | sl811->active_a = NULL; |
@@ -731,7 +737,8 @@ retry: | |||
731 | if (sl811->active_b) { | 737 | if (sl811->active_b) { |
732 | sl811_write(sl811, SL811_EP_B(SL11H_HOSTCTLREG), 0); | 738 | sl811_write(sl811, SL811_EP_B(SL11H_HOSTCTLREG), 0); |
733 | finish_request(sl811, sl811->active_b, | 739 | finish_request(sl811, sl811->active_b, |
734 | container_of(sl811->active_b->hep->urb_list.next, | 740 | container_of(sl811->active_b |
741 | ->hep->urb_list.next, | ||
735 | struct urb, urb_list), | 742 | struct urb, urb_list), |
736 | NULL, -ESHUTDOWN); | 743 | NULL, -ESHUTDOWN); |
737 | sl811->active_b = NULL; | 744 | sl811->active_b = NULL; |
@@ -761,7 +768,7 @@ retry: | |||
761 | goto retry; | 768 | goto retry; |
762 | } | 769 | } |
763 | 770 | ||
764 | if (sl811->periodic_count == 0 && list_empty(&sl811->async)) | 771 | if (sl811->periodic_count == 0 && list_empty(&sl811->async)) |
765 | sofirq_off(sl811); | 772 | sofirq_off(sl811); |
766 | sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable); | 773 | sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable); |
767 | 774 | ||
@@ -796,7 +803,7 @@ static int balance(struct sl811 *sl811, u16 period, u16 load) | |||
796 | } | 803 | } |
797 | if (j < PERIODIC_SIZE) | 804 | if (j < PERIODIC_SIZE) |
798 | continue; | 805 | continue; |
799 | branch = i; | 806 | branch = i; |
800 | } | 807 | } |
801 | } | 808 | } |
802 | return branch; | 809 | return branch; |
@@ -890,6 +897,7 @@ static int sl811h_urb_enqueue( | |||
890 | break; | 897 | break; |
891 | } | 898 | } |
892 | 899 | ||
900 | ep->hep = hep; | ||
893 | hep->hcpriv = ep; | 901 | hep->hcpriv = ep; |
894 | } | 902 | } |
895 | 903 | ||
@@ -961,15 +969,16 @@ fail: | |||
961 | static int sl811h_urb_dequeue(struct usb_hcd *hcd, struct urb *urb) | 969 | static int sl811h_urb_dequeue(struct usb_hcd *hcd, struct urb *urb) |
962 | { | 970 | { |
963 | struct sl811 *sl811 = hcd_to_sl811(hcd); | 971 | struct sl811 *sl811 = hcd_to_sl811(hcd); |
964 | struct usb_host_endpoint *hep = urb->hcpriv; | 972 | struct usb_host_endpoint *hep; |
965 | unsigned long flags; | 973 | unsigned long flags; |
966 | struct sl811h_ep *ep; | 974 | struct sl811h_ep *ep; |
967 | int retval = 0; | 975 | int retval = 0; |
968 | 976 | ||
977 | spin_lock_irqsave(&sl811->lock, flags); | ||
978 | hep = urb->hcpriv; | ||
969 | if (!hep) | 979 | if (!hep) |
970 | return -EINVAL; | 980 | goto fail; |
971 | 981 | ||
972 | spin_lock_irqsave(&sl811->lock, flags); | ||
973 | ep = hep->hcpriv; | 982 | ep = hep->hcpriv; |
974 | if (ep) { | 983 | if (ep) { |
975 | /* finish right away if this urb can't be active ... | 984 | /* finish right away if this urb can't be active ... |
@@ -1017,6 +1026,7 @@ static int sl811h_urb_dequeue(struct usb_hcd *hcd, struct urb *urb) | |||
1017 | VDBG("dequeue, urb %p active %s; wait4irq\n", urb, | 1026 | VDBG("dequeue, urb %p active %s; wait4irq\n", urb, |
1018 | (sl811->active_a == ep) ? "A" : "B"); | 1027 | (sl811->active_a == ep) ? "A" : "B"); |
1019 | } else | 1028 | } else |
1029 | fail: | ||
1020 | retval = -EINVAL; | 1030 | retval = -EINVAL; |
1021 | spin_unlock_irqrestore(&sl811->lock, flags); | 1031 | spin_unlock_irqrestore(&sl811->lock, flags); |
1022 | return retval; | 1032 | return retval; |
@@ -1576,6 +1586,9 @@ sl811h_start(struct usb_hcd *hcd) | |||
1576 | if (sl811->board && sl811->board->power) | 1586 | if (sl811->board && sl811->board->power) |
1577 | hub_set_power_budget(udev, sl811->board->power * 2); | 1587 | hub_set_power_budget(udev, sl811->board->power * 2); |
1578 | 1588 | ||
1589 | /* enable power and interupts */ | ||
1590 | port_power(sl811, 1); | ||
1591 | |||
1579 | return 0; | 1592 | return 0; |
1580 | } | 1593 | } |
1581 | 1594 | ||
@@ -1618,7 +1631,7 @@ static struct hc_driver sl811h_hc_driver = { | |||
1618 | 1631 | ||
1619 | /*-------------------------------------------------------------------------*/ | 1632 | /*-------------------------------------------------------------------------*/ |
1620 | 1633 | ||
1621 | static int __init_or_module | 1634 | static int __devexit |
1622 | sl811h_remove(struct device *dev) | 1635 | sl811h_remove(struct device *dev) |
1623 | { | 1636 | { |
1624 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 1637 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
@@ -1631,21 +1644,20 @@ sl811h_remove(struct device *dev) | |||
1631 | remove_debug_file(sl811); | 1644 | remove_debug_file(sl811); |
1632 | usb_remove_hcd(hcd); | 1645 | usb_remove_hcd(hcd); |
1633 | 1646 | ||
1634 | iounmap(sl811->data_reg); | 1647 | /* some platforms may use IORESOURCE_IO */ |
1635 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 1648 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
1636 | release_mem_region(res->start, 1); | 1649 | if (res) |
1650 | iounmap(sl811->data_reg); | ||
1637 | 1651 | ||
1638 | iounmap(sl811->addr_reg); | ||
1639 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1652 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1640 | release_mem_region(res->start, 1); | 1653 | if (res) |
1654 | iounmap(sl811->addr_reg); | ||
1641 | 1655 | ||
1642 | usb_put_hcd(hcd); | 1656 | usb_put_hcd(hcd); |
1643 | return 0; | 1657 | return 0; |
1644 | } | 1658 | } |
1645 | 1659 | ||
1646 | #define resource_len(r) (((r)->end - (r)->start) + 1) | 1660 | static int __devinit |
1647 | |||
1648 | static int __init | ||
1649 | sl811h_probe(struct device *dev) | 1661 | sl811h_probe(struct device *dev) |
1650 | { | 1662 | { |
1651 | struct usb_hcd *hcd; | 1663 | struct usb_hcd *hcd; |
@@ -1656,7 +1668,7 @@ sl811h_probe(struct device *dev) | |||
1656 | void __iomem *addr_reg; | 1668 | void __iomem *addr_reg; |
1657 | void __iomem *data_reg; | 1669 | void __iomem *data_reg; |
1658 | int retval; | 1670 | int retval; |
1659 | u8 tmp; | 1671 | u8 tmp, ioaddr = 0; |
1660 | 1672 | ||
1661 | /* basic sanity checks first. board-specific init logic should | 1673 | /* basic sanity checks first. board-specific init logic should |
1662 | * have initialized these three resources and probably board | 1674 | * have initialized these three resources and probably board |
@@ -1664,13 +1676,8 @@ sl811h_probe(struct device *dev) | |||
1664 | * minimal sanity checking. | 1676 | * minimal sanity checking. |
1665 | */ | 1677 | */ |
1666 | pdev = container_of(dev, struct platform_device, dev); | 1678 | pdev = container_of(dev, struct platform_device, dev); |
1667 | if (pdev->num_resources < 3) | ||
1668 | return -ENODEV; | ||
1669 | |||
1670 | addr = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1671 | data = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
1672 | irq = platform_get_irq(pdev, 0); | 1679 | irq = platform_get_irq(pdev, 0); |
1673 | if (!addr || !data || irq < 0) | 1680 | if (pdev->num_resources < 3 || irq < 0) |
1674 | return -ENODEV; | 1681 | return -ENODEV; |
1675 | 1682 | ||
1676 | /* refuse to confuse usbcore */ | 1683 | /* refuse to confuse usbcore */ |
@@ -1679,24 +1686,31 @@ sl811h_probe(struct device *dev) | |||
1679 | return -EINVAL; | 1686 | return -EINVAL; |
1680 | } | 1687 | } |
1681 | 1688 | ||
1682 | if (!request_mem_region(addr->start, 1, hcd_name)) { | 1689 | /* the chip may be wired for either kind of addressing */ |
1683 | retval = -EBUSY; | 1690 | addr = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1684 | goto err1; | 1691 | data = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
1685 | } | 1692 | retval = -EBUSY; |
1686 | addr_reg = ioremap(addr->start, resource_len(addr)); | 1693 | if (!addr || !data) { |
1687 | if (addr_reg == NULL) { | 1694 | addr = platform_get_resource(pdev, IORESOURCE_IO, 0); |
1688 | retval = -ENOMEM; | 1695 | data = platform_get_resource(pdev, IORESOURCE_IO, 1); |
1689 | goto err2; | 1696 | if (!addr || !data) |
1690 | } | 1697 | return -ENODEV; |
1698 | ioaddr = 1; | ||
1699 | |||
1700 | addr_reg = (void __iomem *) addr->start; | ||
1701 | data_reg = (void __iomem *) data->start; | ||
1702 | } else { | ||
1703 | addr_reg = ioremap(addr->start, 1); | ||
1704 | if (addr_reg == NULL) { | ||
1705 | retval = -ENOMEM; | ||
1706 | goto err2; | ||
1707 | } | ||
1691 | 1708 | ||
1692 | if (!request_mem_region(data->start, 1, hcd_name)) { | 1709 | data_reg = ioremap(data->start, 1); |
1693 | retval = -EBUSY; | 1710 | if (data_reg == NULL) { |
1694 | goto err3; | 1711 | retval = -ENOMEM; |
1695 | } | 1712 | goto err4; |
1696 | data_reg = ioremap(data->start, resource_len(addr)); | 1713 | } |
1697 | if (data_reg == NULL) { | ||
1698 | retval = -ENOMEM; | ||
1699 | goto err4; | ||
1700 | } | 1714 | } |
1701 | 1715 | ||
1702 | /* allocate and initialize hcd */ | 1716 | /* allocate and initialize hcd */ |
@@ -1737,12 +1751,14 @@ sl811h_probe(struct device *dev) | |||
1737 | goto err6; | 1751 | goto err6; |
1738 | } | 1752 | } |
1739 | 1753 | ||
1740 | /* sl811s would need a different handler for this irq */ | 1754 | /* The chip's IRQ is level triggered, active high. A requirement |
1741 | #ifdef CONFIG_ARM | 1755 | * for platform device setup is to cope with things like signal |
1742 | /* Cypress docs say the IRQ is IRQT_HIGH ... */ | 1756 | * inverters (e.g. CF is active low) or working only with edge |
1743 | set_irq_type(irq, IRQT_RISING); | 1757 | * triggers (e.g. most ARM CPUs). Initial driver stress testing |
1744 | #endif | 1758 | * was on a system with single edge triggering, so most sorts of |
1745 | retval = usb_add_hcd(hcd, irq, SA_INTERRUPT); | 1759 | * triggering arrangement should work. |
1760 | */ | ||
1761 | retval = usb_add_hcd(hcd, irq, SA_INTERRUPT | SA_SHIRQ); | ||
1746 | if (retval != 0) | 1762 | if (retval != 0) |
1747 | goto err6; | 1763 | goto err6; |
1748 | 1764 | ||
@@ -1752,14 +1768,12 @@ sl811h_probe(struct device *dev) | |||
1752 | err6: | 1768 | err6: |
1753 | usb_put_hcd(hcd); | 1769 | usb_put_hcd(hcd); |
1754 | err5: | 1770 | err5: |
1755 | iounmap(data_reg); | 1771 | if (!ioaddr) |
1772 | iounmap(data_reg); | ||
1756 | err4: | 1773 | err4: |
1757 | release_mem_region(data->start, 1); | 1774 | if (!ioaddr) |
1758 | err3: | 1775 | iounmap(addr_reg); |
1759 | iounmap(addr_reg); | ||
1760 | err2: | 1776 | err2: |
1761 | release_mem_region(addr->start, 1); | ||
1762 | err1: | ||
1763 | DBG("init error, %d\n", retval); | 1777 | DBG("init error, %d\n", retval); |
1764 | return retval; | 1778 | return retval; |
1765 | } | 1779 | } |
@@ -1767,7 +1781,7 @@ sl811h_probe(struct device *dev) | |||
1767 | #ifdef CONFIG_PM | 1781 | #ifdef CONFIG_PM |
1768 | 1782 | ||
1769 | /* for this device there's no useful distinction between the controller | 1783 | /* for this device there's no useful distinction between the controller |
1770 | * and its root hub, except that the root hub only gets direct PM calls | 1784 | * and its root hub, except that the root hub only gets direct PM calls |
1771 | * when CONFIG_USB_SUSPEND is enabled. | 1785 | * when CONFIG_USB_SUSPEND is enabled. |
1772 | */ | 1786 | */ |
1773 | 1787 | ||
@@ -1821,20 +1835,22 @@ sl811h_resume(struct device *dev, u32 phase) | |||
1821 | #endif | 1835 | #endif |
1822 | 1836 | ||
1823 | 1837 | ||
1824 | static struct device_driver sl811h_driver = { | 1838 | /* this driver is exported so sl811_cs can depend on it */ |
1839 | struct device_driver sl811h_driver = { | ||
1825 | .name = (char *) hcd_name, | 1840 | .name = (char *) hcd_name, |
1826 | .bus = &platform_bus_type, | 1841 | .bus = &platform_bus_type, |
1827 | 1842 | ||
1828 | .probe = sl811h_probe, | 1843 | .probe = sl811h_probe, |
1829 | .remove = sl811h_remove, | 1844 | .remove = __devexit_p(sl811h_remove), |
1830 | 1845 | ||
1831 | .suspend = sl811h_suspend, | 1846 | .suspend = sl811h_suspend, |
1832 | .resume = sl811h_resume, | 1847 | .resume = sl811h_resume, |
1833 | }; | 1848 | }; |
1849 | EXPORT_SYMBOL(sl811h_driver); | ||
1834 | 1850 | ||
1835 | /*-------------------------------------------------------------------------*/ | 1851 | /*-------------------------------------------------------------------------*/ |
1836 | 1852 | ||
1837 | static int __init sl811h_init(void) | 1853 | static int __init sl811h_init(void) |
1838 | { | 1854 | { |
1839 | if (usb_disabled()) | 1855 | if (usb_disabled()) |
1840 | return -ENODEV; | 1856 | return -ENODEV; |
@@ -1844,8 +1860,8 @@ static int __init sl811h_init(void) | |||
1844 | } | 1860 | } |
1845 | module_init(sl811h_init); | 1861 | module_init(sl811h_init); |
1846 | 1862 | ||
1847 | static void __exit sl811h_cleanup(void) | 1863 | static void __exit sl811h_cleanup(void) |
1848 | { | 1864 | { |
1849 | driver_unregister(&sl811h_driver); | 1865 | driver_unregister(&sl811h_driver); |
1850 | } | 1866 | } |
1851 | module_exit(sl811h_cleanup); | 1867 | module_exit(sl811h_cleanup); |
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c new file mode 100644 index 000000000000..6e173265095c --- /dev/null +++ b/drivers/usb/host/sl811_cs.c | |||
@@ -0,0 +1,442 @@ | |||
1 | /* | ||
2 | * PCMCIA driver for SL811HS (as found in REX-CFU1U) | ||
3 | * Filename: sl811_cs.c | ||
4 | * Author: Yukio Yamamoto | ||
5 | * | ||
6 | * Port to sl811-hcd and 2.6.x by | ||
7 | * Botond Botyanszki <boti@rocketmail.com> | ||
8 | * Simon Pickering | ||
9 | * | ||
10 | * Last update: 2005-05-12 | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/sched.h> | ||
17 | #include <linux/ptrace.h> | ||
18 | #include <linux/slab.h> | ||
19 | #include <linux/string.h> | ||
20 | #include <linux/timer.h> | ||
21 | #include <linux/ioport.h> | ||
22 | |||
23 | #include <pcmcia/version.h> | ||
24 | #include <pcmcia/cs_types.h> | ||
25 | #include <pcmcia/cs.h> | ||
26 | #include <pcmcia/cistpl.h> | ||
27 | #include <pcmcia/cisreg.h> | ||
28 | #include <pcmcia/ds.h> | ||
29 | |||
30 | #include <linux/usb_sl811.h> | ||
31 | |||
32 | MODULE_AUTHOR("Botond Botyanszki"); | ||
33 | MODULE_DESCRIPTION("REX-CFU1U PCMCIA driver for 2.6"); | ||
34 | MODULE_LICENSE("GPL"); | ||
35 | |||
36 | |||
37 | /*====================================================================*/ | ||
38 | /* MACROS */ | ||
39 | /*====================================================================*/ | ||
40 | |||
41 | #if defined(DEBUG) || defined(CONFIG_USB_DEBUG) || defined(PCMCIA_DEBUG) | ||
42 | |||
43 | static int pc_debug = 0; | ||
44 | module_param(pc_debug, int, 0644); | ||
45 | |||
46 | #define DBG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG "sl811_cs: " args) | ||
47 | |||
48 | #else | ||
49 | #define DBG(n, args...) do{}while(0) | ||
50 | #endif /* no debugging */ | ||
51 | |||
52 | #define INFO(args...) printk(KERN_INFO "sl811_cs: " args) | ||
53 | |||
54 | #define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444) | ||
55 | |||
56 | #define CS_CHECK(fn, ret) \ | ||
57 | do { \ | ||
58 | last_fn = (fn); \ | ||
59 | if ((last_ret = (ret)) != 0) \ | ||
60 | goto cs_failed; \ | ||
61 | } while (0) | ||
62 | |||
63 | /*====================================================================*/ | ||
64 | /* VARIABLES */ | ||
65 | /*====================================================================*/ | ||
66 | |||
67 | static const char driver_name[DEV_NAME_LEN] = "sl811_cs"; | ||
68 | |||
69 | static dev_link_t *dev_list = NULL; | ||
70 | |||
71 | static int irq_list[4] = { -1 }; | ||
72 | static int irq_list_count; | ||
73 | |||
74 | module_param_array(irq_list, int, &irq_list_count, 0444); | ||
75 | |||
76 | INT_MODULE_PARM(irq_mask, 0xdeb8); | ||
77 | |||
78 | typedef struct local_info_t { | ||
79 | dev_link_t link; | ||
80 | dev_node_t node; | ||
81 | } local_info_t; | ||
82 | |||
83 | /*====================================================================*/ | ||
84 | |||
85 | static void release_platform_dev(struct device * dev) | ||
86 | { | ||
87 | DBG(0, "sl811_cs platform_dev release\n"); | ||
88 | dev->parent = NULL; | ||
89 | } | ||
90 | |||
91 | static struct sl811_platform_data platform_data = { | ||
92 | .potpg = 100, | ||
93 | .power = 50, /* == 100mA */ | ||
94 | // .reset = ... FIXME: invoke CF reset on the card | ||
95 | }; | ||
96 | |||
97 | static struct resource resources[] = { | ||
98 | [0] = { | ||
99 | .flags = IORESOURCE_IRQ, | ||
100 | }, | ||
101 | [1] = { | ||
102 | // .name = "address", | ||
103 | .flags = IORESOURCE_IO, | ||
104 | }, | ||
105 | [2] = { | ||
106 | // .name = "data", | ||
107 | .flags = IORESOURCE_IO, | ||
108 | }, | ||
109 | }; | ||
110 | |||
111 | extern struct device_driver sl811h_driver; | ||
112 | |||
113 | static struct platform_device platform_dev = { | ||
114 | .id = -1, | ||
115 | .dev = { | ||
116 | .platform_data = &platform_data, | ||
117 | .release = release_platform_dev, | ||
118 | }, | ||
119 | .resource = resources, | ||
120 | .num_resources = ARRAY_SIZE(resources), | ||
121 | }; | ||
122 | |||
123 | static int sl811_hc_init(struct device *parent, ioaddr_t base_addr, int irq) | ||
124 | { | ||
125 | if (platform_dev.dev.parent) | ||
126 | return -EBUSY; | ||
127 | platform_dev.dev.parent = parent; | ||
128 | |||
129 | /* finish seting up the platform device */ | ||
130 | resources[0].start = irq; | ||
131 | |||
132 | resources[1].start = base_addr; | ||
133 | resources[1].end = base_addr; | ||
134 | |||
135 | resources[2].start = base_addr + 1; | ||
136 | resources[2].end = base_addr + 1; | ||
137 | |||
138 | /* The driver core will probe for us. We know sl811-hcd has been | ||
139 | * initialized already because of the link order dependency. | ||
140 | */ | ||
141 | platform_dev.name = sl811h_driver.name; | ||
142 | return platform_device_register(&platform_dev); | ||
143 | } | ||
144 | |||
145 | /*====================================================================*/ | ||
146 | |||
147 | static void sl811_cs_detach(dev_link_t *link) | ||
148 | { | ||
149 | dev_link_t **linkp; | ||
150 | |||
151 | DBG(0, "sl811_cs_detach(0x%p)\n", link); | ||
152 | |||
153 | /* Locate device structure */ | ||
154 | for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) { | ||
155 | if (*linkp == link) | ||
156 | break; | ||
157 | } | ||
158 | if (*linkp == NULL) | ||
159 | return; | ||
160 | |||
161 | /* Break the link with Card Services */ | ||
162 | if (link->handle) | ||
163 | pcmcia_deregister_client(link->handle); | ||
164 | |||
165 | /* Unlink device structure, and free it */ | ||
166 | *linkp = link->next; | ||
167 | /* This points to the parent local_info_t struct */ | ||
168 | kfree(link->priv); | ||
169 | } | ||
170 | |||
171 | static void sl811_cs_release(dev_link_t * link) | ||
172 | { | ||
173 | |||
174 | DBG(0, "sl811_cs_release(0x%p)\n", link); | ||
175 | |||
176 | if (link->open) { | ||
177 | DBG(1, "sl811_cs: release postponed, '%s' still open\n", | ||
178 | link->dev->dev_name); | ||
179 | link->state |= DEV_STALE_CONFIG; | ||
180 | return; | ||
181 | } | ||
182 | |||
183 | /* Unlink the device chain */ | ||
184 | link->dev = NULL; | ||
185 | |||
186 | platform_device_unregister(&platform_dev); | ||
187 | pcmcia_release_configuration(link->handle); | ||
188 | if (link->io.NumPorts1) | ||
189 | pcmcia_release_io(link->handle, &link->io); | ||
190 | if (link->irq.AssignedIRQ) | ||
191 | pcmcia_release_irq(link->handle, &link->irq); | ||
192 | link->state &= ~DEV_CONFIG; | ||
193 | |||
194 | if (link->state & DEV_STALE_LINK) | ||
195 | sl811_cs_detach(link); | ||
196 | } | ||
197 | |||
198 | static void sl811_cs_config(dev_link_t *link) | ||
199 | { | ||
200 | client_handle_t handle = link->handle; | ||
201 | struct device *parent = &handle_to_dev(handle); | ||
202 | local_info_t *dev = link->priv; | ||
203 | tuple_t tuple; | ||
204 | cisparse_t parse; | ||
205 | int last_fn, last_ret; | ||
206 | u_char buf[64]; | ||
207 | config_info_t conf; | ||
208 | cistpl_cftable_entry_t dflt = { 0 }; | ||
209 | |||
210 | DBG(0, "sl811_cs_config(0x%p)\n", link); | ||
211 | |||
212 | tuple.DesiredTuple = CISTPL_CONFIG; | ||
213 | tuple.Attributes = 0; | ||
214 | tuple.TupleData = buf; | ||
215 | tuple.TupleDataMax = sizeof(buf); | ||
216 | tuple.TupleOffset = 0; | ||
217 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | ||
218 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); | ||
219 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); | ||
220 | link->conf.ConfigBase = parse.config.base; | ||
221 | link->conf.Present = parse.config.rmask[0]; | ||
222 | |||
223 | /* Configure card */ | ||
224 | link->state |= DEV_CONFIG; | ||
225 | |||
226 | /* Look up the current Vcc */ | ||
227 | CS_CHECK(GetConfigurationInfo, | ||
228 | pcmcia_get_configuration_info(handle, &conf)); | ||
229 | link->conf.Vcc = conf.Vcc; | ||
230 | |||
231 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
232 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | ||
233 | while (1) { | ||
234 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | ||
235 | |||
236 | if (pcmcia_get_tuple_data(handle, &tuple) != 0 | ||
237 | || pcmcia_parse_tuple(handle, &tuple, &parse) | ||
238 | != 0) | ||
239 | goto next_entry; | ||
240 | |||
241 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) { | ||
242 | dflt = *cfg; | ||
243 | } | ||
244 | |||
245 | if (cfg->index == 0) | ||
246 | goto next_entry; | ||
247 | |||
248 | link->conf.ConfigIndex = cfg->index; | ||
249 | |||
250 | /* Use power settings for Vcc and Vpp if present */ | ||
251 | /* Note that the CIS values need to be rescaled */ | ||
252 | if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { | ||
253 | if (cfg->vcc.param[CISTPL_POWER_VNOM]/10000 | ||
254 | != conf.Vcc) | ||
255 | goto next_entry; | ||
256 | } else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) { | ||
257 | if (dflt.vcc.param[CISTPL_POWER_VNOM]/10000 | ||
258 | != conf.Vcc) | ||
259 | goto next_entry; | ||
260 | } | ||
261 | |||
262 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
263 | link->conf.Vpp1 = link->conf.Vpp2 = | ||
264 | cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
265 | else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
266 | link->conf.Vpp1 = link->conf.Vpp2 = | ||
267 | dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
268 | |||
269 | /* we need an interrupt */ | ||
270 | if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) | ||
271 | link->conf.Attributes |= CONF_ENABLE_IRQ; | ||
272 | |||
273 | /* IO window settings */ | ||
274 | link->io.NumPorts1 = link->io.NumPorts2 = 0; | ||
275 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | ||
276 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; | ||
277 | |||
278 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
279 | link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
280 | link->io.BasePort1 = io->win[0].base; | ||
281 | link->io.NumPorts1 = io->win[0].len; | ||
282 | |||
283 | if (pcmcia_request_io(link->handle, &link->io) != 0) | ||
284 | goto next_entry; | ||
285 | } | ||
286 | break; | ||
287 | |||
288 | next_entry: | ||
289 | if (link->io.NumPorts1) | ||
290 | pcmcia_release_io(link->handle, &link->io); | ||
291 | last_ret = pcmcia_get_next_tuple(handle, &tuple); | ||
292 | } | ||
293 | |||
294 | /* require an IRQ and two registers */ | ||
295 | if (!link->io.NumPorts1 || link->io.NumPorts1 < 2) | ||
296 | goto cs_failed; | ||
297 | if (link->conf.Attributes & CONF_ENABLE_IRQ) | ||
298 | CS_CHECK(RequestIRQ, | ||
299 | pcmcia_request_irq(link->handle, &link->irq)); | ||
300 | else | ||
301 | goto cs_failed; | ||
302 | |||
303 | CS_CHECK(RequestConfiguration, | ||
304 | pcmcia_request_configuration(link->handle, &link->conf)); | ||
305 | |||
306 | sprintf(dev->node.dev_name, driver_name); | ||
307 | dev->node.major = dev->node.minor = 0; | ||
308 | link->dev = &dev->node; | ||
309 | |||
310 | printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d", | ||
311 | dev->node.dev_name, link->conf.ConfigIndex, | ||
312 | link->conf.Vcc/10, link->conf.Vcc%10); | ||
313 | if (link->conf.Vpp1) | ||
314 | printk(", Vpp %d.%d", link->conf.Vpp1/10, link->conf.Vpp1%10); | ||
315 | printk(", irq %d", link->irq.AssignedIRQ); | ||
316 | printk(", io 0x%04x-0x%04x", link->io.BasePort1, | ||
317 | link->io.BasePort1+link->io.NumPorts1-1); | ||
318 | printk("\n"); | ||
319 | |||
320 | link->state &= ~DEV_CONFIG_PENDING; | ||
321 | |||
322 | if (sl811_hc_init(parent, link->io.BasePort1, link->irq.AssignedIRQ) | ||
323 | < 0) { | ||
324 | cs_failed: | ||
325 | printk("sl811_cs_config failed\n"); | ||
326 | cs_error(link->handle, last_fn, last_ret); | ||
327 | sl811_cs_release(link); | ||
328 | link->state &= ~DEV_CONFIG_PENDING; | ||
329 | } | ||
330 | } | ||
331 | |||
332 | static int | ||
333 | sl811_cs_event(event_t event, int priority, event_callback_args_t *args) | ||
334 | { | ||
335 | dev_link_t *link = args->client_data; | ||
336 | |||
337 | DBG(1, "sl811_cs_event(0x%06x)\n", event); | ||
338 | |||
339 | switch (event) { | ||
340 | case CS_EVENT_CARD_REMOVAL: | ||
341 | link->state &= ~DEV_PRESENT; | ||
342 | if (link->state & DEV_CONFIG) | ||
343 | sl811_cs_release(link); | ||
344 | break; | ||
345 | |||
346 | case CS_EVENT_CARD_INSERTION: | ||
347 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
348 | sl811_cs_config(link); | ||
349 | break; | ||
350 | |||
351 | case CS_EVENT_PM_SUSPEND: | ||
352 | link->state |= DEV_SUSPEND; | ||
353 | /* Fall through... */ | ||
354 | case CS_EVENT_RESET_PHYSICAL: | ||
355 | if (link->state & DEV_CONFIG) | ||
356 | pcmcia_release_configuration(link->handle); | ||
357 | break; | ||
358 | |||
359 | case CS_EVENT_PM_RESUME: | ||
360 | link->state &= ~DEV_SUSPEND; | ||
361 | /* Fall through... */ | ||
362 | case CS_EVENT_CARD_RESET: | ||
363 | if (link->state & DEV_CONFIG) | ||
364 | pcmcia_request_configuration(link->handle, &link->conf); | ||
365 | DBG(0, "reset sl811-hcd here?\n"); | ||
366 | break; | ||
367 | } | ||
368 | return 0; | ||
369 | } | ||
370 | |||
371 | static dev_link_t *sl811_cs_attach(void) | ||
372 | { | ||
373 | local_info_t *local; | ||
374 | dev_link_t *link; | ||
375 | client_reg_t client_reg; | ||
376 | int ret, i; | ||
377 | |||
378 | local = kmalloc(sizeof(local_info_t), GFP_KERNEL); | ||
379 | if (!local) | ||
380 | return NULL; | ||
381 | memset(local, 0, sizeof(local_info_t)); | ||
382 | link = &local->link; | ||
383 | link->priv = local; | ||
384 | |||
385 | /* Initialize */ | ||
386 | link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; | ||
387 | link->irq.IRQInfo1 = IRQ_INFO2_VALID|IRQ_LEVEL_ID; | ||
388 | if (irq_list[0] == -1) | ||
389 | link->irq.IRQInfo2 = irq_mask; | ||
390 | else | ||
391 | for (i = 0; i < irq_list_count; i++) | ||
392 | link->irq.IRQInfo2 |= 1 << irq_list[i]; | ||
393 | link->irq.Handler = NULL; | ||
394 | |||
395 | link->conf.Attributes = 0; | ||
396 | link->conf.Vcc = 33; | ||
397 | link->conf.IntType = INT_MEMORY_AND_IO; | ||
398 | |||
399 | /* Register with Card Services */ | ||
400 | link->next = dev_list; | ||
401 | dev_list = link; | ||
402 | client_reg.dev_info = (dev_info_t *) &driver_name; | ||
403 | client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE; | ||
404 | client_reg.EventMask = | ||
405 | CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL | | ||
406 | CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET | | ||
407 | CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME; | ||
408 | client_reg.event_handler = &sl811_cs_event; | ||
409 | client_reg.Version = 0x0210; | ||
410 | client_reg.event_callback_args.client_data = link; | ||
411 | ret = pcmcia_register_client(&link->handle, &client_reg); | ||
412 | if (ret != CS_SUCCESS) { | ||
413 | cs_error(link->handle, RegisterClient, ret); | ||
414 | sl811_cs_detach(link); | ||
415 | return NULL; | ||
416 | } | ||
417 | |||
418 | return link; | ||
419 | } | ||
420 | |||
421 | static struct pcmcia_driver sl811_cs_driver = { | ||
422 | .owner = THIS_MODULE, | ||
423 | .drv = { | ||
424 | .name = (char *)driver_name, | ||
425 | }, | ||
426 | .attach = sl811_cs_attach, | ||
427 | .detach = sl811_cs_detach, | ||
428 | }; | ||
429 | |||
430 | /*====================================================================*/ | ||
431 | |||
432 | static int __init init_sl811_cs(void) | ||
433 | { | ||
434 | return pcmcia_register_driver(&sl811_cs_driver); | ||
435 | } | ||
436 | module_init(init_sl811_cs); | ||
437 | |||
438 | static void __exit exit_sl811_cs(void) | ||
439 | { | ||
440 | pcmcia_unregister_driver(&sl811_cs_driver); | ||
441 | } | ||
442 | module_exit(exit_sl811_cs); | ||
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 869ff73690ac..2d8bd9dcc6ed 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c | |||
@@ -1315,6 +1315,8 @@ void hid_init_reports(struct hid_device *hid) | |||
1315 | #define USB_DEVICE_ID_WACOM_INTUOS2 0x0040 | 1315 | #define USB_DEVICE_ID_WACOM_INTUOS2 0x0040 |
1316 | #define USB_DEVICE_ID_WACOM_VOLITO 0x0060 | 1316 | #define USB_DEVICE_ID_WACOM_VOLITO 0x0060 |
1317 | #define USB_DEVICE_ID_WACOM_PTU 0x0003 | 1317 | #define USB_DEVICE_ID_WACOM_PTU 0x0003 |
1318 | #define USB_DEVICE_ID_WACOM_INTUOS3 0x00B0 | ||
1319 | #define USB_DEVICE_ID_WACOM_CINTIQ 0x003F | ||
1318 | 1320 | ||
1319 | #define USB_VENDOR_ID_KBGEAR 0x084e | 1321 | #define USB_VENDOR_ID_KBGEAR 0x084e |
1320 | #define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001 | 1322 | #define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001 |
@@ -1401,6 +1403,7 @@ void hid_init_reports(struct hid_device *hid) | |||
1401 | 1403 | ||
1402 | #define USB_VENDOR_ID_DELORME 0x1163 | 1404 | #define USB_VENDOR_ID_DELORME 0x1163 |
1403 | #define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100 | 1405 | #define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100 |
1406 | #define USB_DEVICE_ID_DELORME_EM_LT20 0x0200 | ||
1404 | 1407 | ||
1405 | #define USB_VENDOR_ID_MCC 0x09db | 1408 | #define USB_VENDOR_ID_MCC 0x09db |
1406 | #define USB_DEVICE_ID_MCC_PMD1024LS 0x0076 | 1409 | #define USB_DEVICE_ID_MCC_PMD1024LS 0x0076 |
@@ -1412,6 +1415,12 @@ void hid_init_reports(struct hid_device *hid) | |||
1412 | #define USB_VENDOR_ID_BTC 0x046e | 1415 | #define USB_VENDOR_ID_BTC 0x046e |
1413 | #define USB_DEVICE_ID_BTC_KEYBOARD 0x5303 | 1416 | #define USB_DEVICE_ID_BTC_KEYBOARD 0x5303 |
1414 | 1417 | ||
1418 | #define USB_VENDOR_ID_VERNIER 0x08f7 | ||
1419 | #define USB_DEVICE_ID_VERNIER_LABPRO 0x0001 | ||
1420 | #define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002 | ||
1421 | #define USB_DEVICE_ID_VERNIER_SKIP 0x0003 | ||
1422 | #define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 | ||
1423 | |||
1415 | 1424 | ||
1416 | /* | 1425 | /* |
1417 | * Alphabetically sorted blacklist by quirk type. | 1426 | * Alphabetically sorted blacklist by quirk type. |
@@ -1437,6 +1446,7 @@ static struct hid_blacklist { | |||
1437 | { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW28, HID_QUIRK_IGNORE }, | 1446 | { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW28, HID_QUIRK_IGNORE }, |
1438 | { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM, HID_QUIRK_IGNORE }, | 1447 | { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM, HID_QUIRK_IGNORE }, |
1439 | { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE, HID_QUIRK_IGNORE }, | 1448 | { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE, HID_QUIRK_IGNORE }, |
1449 | { USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20, HID_QUIRK_IGNORE }, | ||
1440 | { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE }, | 1450 | { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE }, |
1441 | { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30, HID_QUIRK_IGNORE }, | 1451 | { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30, HID_QUIRK_IGNORE }, |
1442 | { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30, HID_QUIRK_IGNORE }, | 1452 | { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30, HID_QUIRK_IGNORE }, |
@@ -1456,6 +1466,10 @@ static struct hid_blacklist { | |||
1456 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300, HID_QUIRK_IGNORE }, | 1466 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300, HID_QUIRK_IGNORE }, |
1457 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400, HID_QUIRK_IGNORE }, | 1467 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400, HID_QUIRK_IGNORE }, |
1458 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500, HID_QUIRK_IGNORE }, | 1468 | { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500, HID_QUIRK_IGNORE }, |
1469 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO, HID_QUIRK_IGNORE }, | ||
1470 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP, HID_QUIRK_IGNORE }, | ||
1471 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP, HID_QUIRK_IGNORE }, | ||
1472 | { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS, HID_QUIRK_IGNORE }, | ||
1459 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PENPARTNER, HID_QUIRK_IGNORE }, | 1473 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PENPARTNER, HID_QUIRK_IGNORE }, |
1460 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE, HID_QUIRK_IGNORE }, | 1474 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE, HID_QUIRK_IGNORE }, |
1461 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE + 1, HID_QUIRK_IGNORE }, | 1475 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE + 1, HID_QUIRK_IGNORE }, |
@@ -1481,6 +1495,10 @@ static struct hid_blacklist { | |||
1481 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 7, HID_QUIRK_IGNORE }, | 1495 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 7, HID_QUIRK_IGNORE }, |
1482 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO, HID_QUIRK_IGNORE }, | 1496 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO, HID_QUIRK_IGNORE }, |
1483 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PTU, HID_QUIRK_IGNORE }, | 1497 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PTU, HID_QUIRK_IGNORE }, |
1498 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3, HID_QUIRK_IGNORE }, | ||
1499 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3 + 1, HID_QUIRK_IGNORE }, | ||
1500 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3 + 2, HID_QUIRK_IGNORE }, | ||
1501 | { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_CINTIQ, HID_QUIRK_IGNORE }, | ||
1484 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, | 1502 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, |
1485 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, | 1503 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, |
1486 | 1504 | ||
diff --git a/drivers/usb/media/pwc/ChangeLog b/drivers/usb/media/pwc/ChangeLog deleted file mode 100644 index b2eb71a9afb5..000000000000 --- a/drivers/usb/media/pwc/ChangeLog +++ /dev/null | |||
@@ -1,143 +0,0 @@ | |||
1 | 9.0.2 | ||
2 | |||
3 | * Adding #ifdef to compile PWC before and after 2.6.5 | ||
4 | |||
5 | 9.0.1 | ||
6 | |||
7 | 9.0 | ||
8 | |||
9 | |||
10 | 8.12 | ||
11 | |||
12 | * Implement motorized pan/tilt feature for Logitech QuickCam Orbit/Spere. | ||
13 | |||
14 | 8.11.1 | ||
15 | |||
16 | * Fix for PCVC720/40, would not be able to set videomode | ||
17 | * Fix for Samsung MPC models, appearantly they are based on a newer chipset | ||
18 | |||
19 | 8.11 | ||
20 | |||
21 | * 20 dev_hints (per request) | ||
22 | * Hot unplugging should be better, no more dangling pointers or memory leaks | ||
23 | * Added reserved Logitech webcam IDs | ||
24 | * Device now remembers size & fps between close()/open() | ||
25 | * Removed palette stuff altogether | ||
26 | |||
27 | 8.10.1 | ||
28 | |||
29 | * Added IDs for PCVC720K/40 and Creative Labs Webcam Pro | ||
30 | |||
31 | 8.10 | ||
32 | |||
33 | * Fixed ID for QuickCam Notebook pro | ||
34 | * Added GREALSIZE ioctl() call | ||
35 | * Fixed bug in case PWCX was not loaded and invalid size was set | ||
36 | |||
37 | 8.9 | ||
38 | |||
39 | * Merging with kernel 2.5.49 | ||
40 | * Adding IDs for QuickCam Zoom & QuickCam Notebook | ||
41 | |||
42 | 8.8 | ||
43 | |||
44 | * Fixing 'leds' parameter | ||
45 | * Adding IDs for Logitech QuickCam Pro 4000 | ||
46 | * Making URB init/cleanup a little nicer | ||
47 | |||
48 | 8.7 | ||
49 | |||
50 | * Incorporating changes in ioctl() parameter passing | ||
51 | * Also changes to URB mechanism | ||
52 | |||
53 | 8.6 | ||
54 | |||
55 | * Added ID's for Visionite VCS UM100 and UC300 | ||
56 | * Removed YUV420-interlaced palette altogether (was confusing) | ||
57 | * Removed MIRROR stuff as it didn't work anyway | ||
58 | * Fixed a problem with the 'leds' parameter (wouldn't blink) | ||
59 | * Added ioctl()s for advanced features: 'extended' whitebalance ioctl()s, | ||
60 | CONTOUR, BACKLIGHT, FLICKER, DYNNOISE. | ||
61 | * VIDIOCGCAP.name now contains real camera model name instead of | ||
62 | 'Philips xxx webcam' | ||
63 | * Added PROBE ioctl (see previous point & API doc) | ||
64 | |||
65 | 8.5 | ||
66 | |||
67 | * Adding IDs for Creative Labs Webcam 5 | ||
68 | * Adding IDs for SOTEC CMS-001 webcam | ||
69 | * Solving possible hang in VIDIOCSYNC when unplugging the cam | ||
70 | * Forgot to return structure in VIDIOCPWCGAWB, oops | ||
71 | * Time interval for the LEDs are now in milliseconds | ||
72 | |||
73 | 8.4 | ||
74 | |||
75 | * Fixing power_save option for Vesta range | ||
76 | * Handling new error codes in ISOC callback | ||
77 | * Adding dev_hint module parameter, to specify /dev/videoX device nodes | ||
78 | |||
79 | 8.3 | ||
80 | |||
81 | * Adding Samsung C10 and C30 cameras | ||
82 | * Removing palette module parameter | ||
83 | * Fixed typo in ID of QuickCam 3000 Pro | ||
84 | * Adding LED settings (blinking while in use) for ToUCam cameras. | ||
85 | * Turns LED off when camera is not in use. | ||
86 | |||
87 | 8.2 | ||
88 | |||
89 | * Making module more silent when trace = 0 | ||
90 | * Adding QuickCam 3000 Pro IDs | ||
91 | * Chrominance control for the Vesta cameras | ||
92 | * Hopefully fixed problems on machines with BIGMEM and > 1GB of RAM | ||
93 | * Included Oliver Neukem's lock_kernel() patch | ||
94 | * Allocates less memory for image buffers | ||
95 | * Adds ioctl()s for the whitebalancing | ||
96 | |||
97 | 8.1 | ||
98 | |||
99 | * Adding support for 750 | ||
100 | * Adding V4L GAUDIO/SAUDIO/UNIT ioctl() calls | ||
101 | |||
102 | 8.0 | ||
103 | * 'damage control' after inclusion in 2.4.5. | ||
104 | * Changed wait-queue mechanism in read/mmap/poll according to the book. | ||
105 | * Included YUV420P palette. | ||
106 | * Changed interface to decompressor module. | ||
107 | * Cleaned up pwc structure a bit. | ||
108 | |||
109 | 7.0 | ||
110 | |||
111 | * Fixed bug in vcvt_420i_yuyv; extra variables on stack were misaligned. | ||
112 | * There is now a clear error message when an image size is selected that | ||
113 | is only supported using the decompressor, and the decompressor isn't | ||
114 | loaded. | ||
115 | * When the decompressor wasn't loaded, selecting large image size | ||
116 | would create skewed or double images. | ||
117 | |||
118 | 6.3 | ||
119 | |||
120 | * Introduced spinlocks for the buffer pointer manipulation; a number of | ||
121 | reports seem to suggest the down()/up() semaphores were the cause of | ||
122 | lockups, since they are not suitable for interrupt/user locking. | ||
123 | * Separated decompressor and core code into 2 modules. | ||
124 | |||
125 | 6.2 | ||
126 | |||
127 | * Non-integral image sizes are now padded with gray or black. | ||
128 | * Added SHUTTERSPEED ioctl(). | ||
129 | * Fixed buglet in VIDIOCPWCSAGC; the function would always return an error, | ||
130 | even though the call succeeded. | ||
131 | * Added hotplug support for 2.4.*. | ||
132 | * Memory: the 645/646 uses less memory now. | ||
133 | |||
134 | 6.1 | ||
135 | |||
136 | * VIDIOCSPICT returns -EINVAL with invalid palettes. | ||
137 | * Added saturation control. | ||
138 | * Split decompressors from rest. | ||
139 | * Fixed bug that would reset the framerate to the default framerate if | ||
140 | the rate field was set to 0 (which is not what I intended, nl. do not | ||
141 | change the framerate!). | ||
142 | * VIDIOCPWCSCQUAL (setting compression quality) now takes effect immediately. | ||
143 | * Workaround for a bug in the 730 sensor. | ||
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 85476e76b244..4cbb408af727 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c | |||
@@ -2765,7 +2765,7 @@ static int blan_mdlm_bind (struct usbnet *dev, struct usb_interface *intf) | |||
2765 | } | 2765 | } |
2766 | /* expect bcdVersion 1.0, ignore */ | 2766 | /* expect bcdVersion 1.0, ignore */ |
2767 | if (memcmp(&desc->bGUID, blan_guid, 16) | 2767 | if (memcmp(&desc->bGUID, blan_guid, 16) |
2768 | && memcmp(&desc->bGUID, blan_guid, 16) ) { | 2768 | && memcmp(&desc->bGUID, safe_guid, 16) ) { |
2769 | /* hey, this one might _really_ be MDLM! */ | 2769 | /* hey, this one might _really_ be MDLM! */ |
2770 | dev_dbg (&intf->dev, "MDLM guid\n"); | 2770 | dev_dbg (&intf->dev, "MDLM guid\n"); |
2771 | goto bad_desc; | 2771 | goto bad_desc; |
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index bc798edf0358..9438909e87a5 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig | |||
@@ -455,6 +455,17 @@ config USB_SERIAL_XIRCOM | |||
455 | To compile this driver as a module, choose M here: the | 455 | To compile this driver as a module, choose M here: the |
456 | module will be called keyspan_pda. | 456 | module will be called keyspan_pda. |
457 | 457 | ||
458 | config USB_SERIAL_OPTION | ||
459 | tristate "USB Option PCMCIA serial driver" | ||
460 | depends on USB_SERIAL && USB_OHCI_HCD && PCCARD | ||
461 | help | ||
462 | Say Y here if you want to use an Option card. This is a | ||
463 | GSM card, controlled by three serial ports which are connected | ||
464 | via an OHCI adapter located on a PC card. | ||
465 | |||
466 | To compile this driver as a module, choose M here: the | ||
467 | module will be called option. | ||
468 | |||
458 | config USB_SERIAL_OMNINET | 469 | config USB_SERIAL_OMNINET |
459 | tristate "USB ZyXEL omni.net LCD Plus Driver (EXPERIMENTAL)" | 470 | tristate "USB ZyXEL omni.net LCD Plus Driver (EXPERIMENTAL)" |
460 | depends on USB_SERIAL && EXPERIMENTAL | 471 | depends on USB_SERIAL && EXPERIMENTAL |
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index d56ff6d86cce..6c7cdcc99a9e 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile | |||
@@ -32,6 +32,7 @@ obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o | |||
32 | obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o | 32 | obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o |
33 | obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o | 33 | obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o |
34 | obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o | 34 | obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o |
35 | obj-$(CONFIG_USB_SERIAL_OPTION) += option.o | ||
35 | obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o | 36 | obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o |
36 | obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o | 37 | obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o |
37 | obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o | 38 | obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o |
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index 7e9bb63eb466..4ace9964fc6b 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c | |||
@@ -7,6 +7,14 @@ | |||
7 | * modify it under the terms of the GNU General Public License version | 7 | * modify it under the terms of the GNU General Public License version |
8 | * 2 as published by the Free Software Foundation. | 8 | * 2 as published by the Free Software Foundation. |
9 | * | 9 | * |
10 | * Support to set flow control line levels using TIOCMGET and TIOCMSET | ||
11 | * thanks to Karl Hiramoto karl@hiramoto.org. RTSCTS hardware flow | ||
12 | * control thanks to Munir Nassar nassarmu@real-time.com | ||
13 | * | ||
14 | * Outstanding Issues: | ||
15 | * Buffers are not flushed when the port is opened. | ||
16 | * Multiple calls to write() may fail with "Resource temporarily unavailable" | ||
17 | * | ||
10 | */ | 18 | */ |
11 | 19 | ||
12 | #include <linux/config.h> | 20 | #include <linux/config.h> |
@@ -24,7 +32,7 @@ | |||
24 | /* | 32 | /* |
25 | * Version Information | 33 | * Version Information |
26 | */ | 34 | */ |
27 | #define DRIVER_VERSION "v0.03" | 35 | #define DRIVER_VERSION "v0.04" |
28 | #define DRIVER_DESC "Silicon Labs CP2101/CP2102 RS232 serial adaptor driver" | 36 | #define DRIVER_DESC "Silicon Labs CP2101/CP2102 RS232 serial adaptor driver" |
29 | 37 | ||
30 | /* | 38 | /* |
@@ -35,6 +43,9 @@ static void cp2101_cleanup(struct usb_serial_port*); | |||
35 | static void cp2101_close(struct usb_serial_port*, struct file*); | 43 | static void cp2101_close(struct usb_serial_port*, struct file*); |
36 | static void cp2101_get_termios(struct usb_serial_port*); | 44 | static void cp2101_get_termios(struct usb_serial_port*); |
37 | static void cp2101_set_termios(struct usb_serial_port*, struct termios*); | 45 | static void cp2101_set_termios(struct usb_serial_port*, struct termios*); |
46 | static int cp2101_tiocmget (struct usb_serial_port *, struct file *); | ||
47 | static int cp2101_tiocmset (struct usb_serial_port *, struct file *, | ||
48 | unsigned int, unsigned int); | ||
38 | static void cp2101_break_ctl(struct usb_serial_port*, int); | 49 | static void cp2101_break_ctl(struct usb_serial_port*, int); |
39 | static int cp2101_startup (struct usb_serial *); | 50 | static int cp2101_startup (struct usb_serial *); |
40 | static void cp2101_shutdown(struct usb_serial*); | 51 | static void cp2101_shutdown(struct usb_serial*); |
@@ -43,9 +54,10 @@ static void cp2101_shutdown(struct usb_serial*); | |||
43 | static int debug; | 54 | static int debug; |
44 | 55 | ||
45 | static struct usb_device_id id_table [] = { | 56 | static struct usb_device_id id_table [] = { |
46 | {USB_DEVICE(0x10c4, 0xea60) }, /*Silicon labs factory default*/ | 57 | { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ |
47 | {USB_DEVICE(0x10ab, 0x10c5) }, /*Siemens MC60 Cable*/ | 58 | { USB_DEVICE(0x10C4, 0x80CA) }, /* Degree Controls Inc */ |
48 | { } /* Terminating Entry*/ | 59 | { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */ |
60 | { } /* Terminating Entry */ | ||
49 | }; | 61 | }; |
50 | 62 | ||
51 | MODULE_DEVICE_TABLE (usb, id_table); | 63 | MODULE_DEVICE_TABLE (usb, id_table); |
@@ -70,32 +82,35 @@ static struct usb_serial_device_type cp2101_device = { | |||
70 | .close = cp2101_close, | 82 | .close = cp2101_close, |
71 | .break_ctl = cp2101_break_ctl, | 83 | .break_ctl = cp2101_break_ctl, |
72 | .set_termios = cp2101_set_termios, | 84 | .set_termios = cp2101_set_termios, |
85 | .tiocmget = cp2101_tiocmget, | ||
86 | .tiocmset = cp2101_tiocmset, | ||
73 | .attach = cp2101_startup, | 87 | .attach = cp2101_startup, |
74 | .shutdown = cp2101_shutdown, | 88 | .shutdown = cp2101_shutdown, |
75 | }; | 89 | }; |
76 | 90 | ||
77 | /*Config request types*/ | 91 | /* Config request types */ |
78 | #define REQTYPE_HOST_TO_DEVICE 0x41 | 92 | #define REQTYPE_HOST_TO_DEVICE 0x41 |
79 | #define REQTYPE_DEVICE_TO_HOST 0xc1 | 93 | #define REQTYPE_DEVICE_TO_HOST 0xc1 |
80 | 94 | ||
81 | /*Config SET requests. To GET, add 1 to the request number*/ | 95 | /* Config SET requests. To GET, add 1 to the request number */ |
82 | #define CP2101_UART 0x00 /*Enable / Disable*/ | 96 | #define CP2101_UART 0x00 /* Enable / Disable */ |
83 | #define CP2101_BAUDRATE 0x01 /*(BAUD_RATE_GEN_FREQ / baudrate)*/ | 97 | #define CP2101_BAUDRATE 0x01 /* (BAUD_RATE_GEN_FREQ / baudrate) */ |
84 | #define CP2101_BITS 0x03 /*0x(0)(data bits)(parity)(stop bits)*/ | 98 | #define CP2101_BITS 0x03 /* 0x(0)(databits)(parity)(stopbits) */ |
85 | #define CP2101_BREAK 0x05 /*On / Off*/ | 99 | #define CP2101_BREAK 0x05 /* On / Off */ |
86 | #define CP2101_DTRRTS 0x07 /*101 / 202 ???*/ | 100 | #define CP2101_CONTROL 0x07 /* Flow control line states */ |
87 | #define CP2101_CONFIG_16 0x13 /*16 bytes of config data ???*/ | 101 | #define CP2101_MODEMCTL 0x13 /* Modem controls */ |
88 | #define CP2101_CONFIG_6 0x19 /*6 bytes of config data ???*/ | 102 | #define CP2101_CONFIG_6 0x19 /* 6 bytes of config data ??? */ |
89 | 103 | ||
90 | /*CP2101_UART*/ | 104 | /* CP2101_UART */ |
91 | #define UART_ENABLE 0x0001 | 105 | #define UART_ENABLE 0x0001 |
92 | #define UART_DISABLE 0x0000 | 106 | #define UART_DISABLE 0x0000 |
93 | 107 | ||
94 | /*CP2101_BAUDRATE*/ | 108 | /* CP2101_BAUDRATE */ |
95 | #define BAUD_RATE_GEN_FREQ 0x384000 | 109 | #define BAUD_RATE_GEN_FREQ 0x384000 |
96 | 110 | ||
97 | /*CP2101_BITS*/ | 111 | /* CP2101_BITS */ |
98 | #define BITS_DATA_MASK 0X0f00 | 112 | #define BITS_DATA_MASK 0X0f00 |
113 | #define BITS_DATA_5 0X0500 | ||
99 | #define BITS_DATA_6 0X0600 | 114 | #define BITS_DATA_6 0X0600 |
100 | #define BITS_DATA_7 0X0700 | 115 | #define BITS_DATA_7 0X0700 |
101 | #define BITS_DATA_8 0X0800 | 116 | #define BITS_DATA_8 0X0800 |
@@ -112,64 +127,137 @@ static struct usb_serial_device_type cp2101_device = { | |||
112 | #define BITS_STOP_1 0x0000 | 127 | #define BITS_STOP_1 0x0000 |
113 | #define BITS_STOP_1_5 0x0001 | 128 | #define BITS_STOP_1_5 0x0001 |
114 | #define BITS_STOP_2 0x0002 | 129 | #define BITS_STOP_2 0x0002 |
130 | |||
131 | /* CP2101_BREAK */ | ||
115 | #define BREAK_ON 0x0000 | 132 | #define BREAK_ON 0x0000 |
116 | #define BREAK_OFF 0x0001 | 133 | #define BREAK_OFF 0x0001 |
117 | 134 | ||
135 | /* CP2101_CONTROL */ | ||
136 | #define CONTROL_DTR 0x0001 | ||
137 | #define CONTROL_RTS 0x0002 | ||
138 | #define CONTROL_CTS 0x0010 | ||
139 | #define CONTROL_DSR 0x0020 | ||
140 | #define CONTROL_RING 0x0040 | ||
141 | #define CONTROL_DCD 0x0080 | ||
142 | #define CONTROL_WRITE_DTR 0x0100 | ||
143 | #define CONTROL_WRITE_RTS 0x0200 | ||
118 | 144 | ||
119 | static int cp2101_get_config(struct usb_serial_port* port, u8 request) | 145 | /* |
146 | * cp2101_get_config | ||
147 | * Reads from the CP2101 configuration registers | ||
148 | * 'size' is specified in bytes. | ||
149 | * 'data' is a pointer to a pre-allocated array of integers large | ||
150 | * enough to hold 'size' bytes (with 4 bytes to each integer) | ||
151 | */ | ||
152 | static int cp2101_get_config(struct usb_serial_port* port, u8 request, | ||
153 | unsigned int *data, int size) | ||
120 | { | 154 | { |
121 | struct usb_serial *serial = port->serial; | 155 | struct usb_serial *serial = port->serial; |
122 | unsigned char buf[4]; | 156 | u32 *buf; |
123 | unsigned int value; | 157 | int result, i, length; |
124 | int result, i; | 158 | |
159 | /* Number of integers required to contain the array */ | ||
160 | length = (((size - 1) | 3) + 1)/4; | ||
161 | |||
162 | buf = kmalloc (length * sizeof(u32), GFP_KERNEL); | ||
163 | memset(buf, 0, length * sizeof(u32)); | ||
164 | |||
165 | if (!buf) { | ||
166 | dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__); | ||
167 | return -ENOMEM; | ||
168 | } | ||
125 | 169 | ||
126 | /*For get requests, the request number must be incremented*/ | 170 | /* For get requests, the request number must be incremented */ |
127 | request++; | 171 | request++; |
128 | 172 | ||
129 | /*Issue the request, attempting to read 4 bytes*/ | 173 | /* Issue the request, attempting to read 'size' bytes */ |
130 | result = usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev, 0), | 174 | result = usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev, 0), |
131 | request, REQTYPE_DEVICE_TO_HOST, 0x0000, | 175 | request, REQTYPE_DEVICE_TO_HOST, 0x0000, |
132 | 0, buf, 4, 300); | 176 | 0, buf, size, 300); |
133 | 177 | ||
134 | if (result < 0) { | 178 | /* Convert data into an array of integers */ |
135 | dev_err(&port->dev, "%s - Unable to send config request, " | 179 | for (i=0; i<length; i++) |
136 | "request=0x%x result=%d\n", | 180 | data[i] = le32_to_cpu(buf[i]); |
137 | __FUNCTION__, request, result); | ||
138 | return result; | ||
139 | } | ||
140 | 181 | ||
141 | /*Assemble each byte read into an integer value*/ | 182 | kfree(buf); |
142 | value = 0; | ||
143 | for (i=0; i<4 && i<result; i++) | ||
144 | value |= (buf[i] << (i * 8)); | ||
145 | 183 | ||
146 | dbg( " %s - request=0x%x result=%d value=0x%x", | 184 | if (result != size) { |
147 | __FUNCTION__, request, result, value); | 185 | dev_err(&port->dev, "%s - Unable to send config request, " |
186 | "request=0x%x size=%d result=%d\n", | ||
187 | __FUNCTION__, request, size, result); | ||
188 | return -EPROTO; | ||
189 | } | ||
148 | 190 | ||
149 | return value; | 191 | return 0; |
150 | } | 192 | } |
151 | 193 | ||
152 | static int cp2101_set_config(struct usb_serial_port* port, u8 request, u16 value) | 194 | /* |
195 | * cp2101_set_config | ||
196 | * Writes to the CP2101 configuration registers | ||
197 | * Values less than 16 bits wide are sent directly | ||
198 | * 'size' is specified in bytes. | ||
199 | */ | ||
200 | static int cp2101_set_config(struct usb_serial_port* port, u8 request, | ||
201 | unsigned int *data, int size) | ||
153 | { | 202 | { |
154 | struct usb_serial *serial = port->serial; | 203 | struct usb_serial *serial = port->serial; |
155 | int result; | 204 | u32 *buf; |
156 | result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), | 205 | int result, i, length; |
157 | request, REQTYPE_HOST_TO_DEVICE, value, | ||
158 | 0, NULL, 0, 300); | ||
159 | 206 | ||
160 | if (result <0) { | 207 | /* Number of integers required to contain the array */ |
161 | dev_err(&port->dev, "%s - Unable to send config request, " | 208 | length = (((size - 1) | 3) + 1)/4; |
162 | "request=0x%x value=0x%x result=%d\n", | 209 | |
163 | __FUNCTION__, request, value, result); | 210 | buf = kmalloc(length * sizeof(u32), GFP_KERNEL); |
164 | return result; | 211 | if (!buf) { |
212 | dev_err(&port->dev, "%s - out of memory.\n", | ||
213 | __FUNCTION__); | ||
214 | return -ENOMEM; | ||
215 | } | ||
216 | |||
217 | /* Array of integers into bytes */ | ||
218 | for (i = 0; i < length; i++) | ||
219 | buf[i] = cpu_to_le32(data[i]); | ||
220 | |||
221 | if (size > 2) { | ||
222 | result = usb_control_msg (serial->dev, | ||
223 | usb_sndctrlpipe(serial->dev, 0), | ||
224 | request, REQTYPE_HOST_TO_DEVICE, 0x0000, | ||
225 | 0, buf, size, 300); | ||
226 | } else { | ||
227 | result = usb_control_msg (serial->dev, | ||
228 | usb_sndctrlpipe(serial->dev, 0), | ||
229 | request, REQTYPE_HOST_TO_DEVICE, data[0], | ||
230 | 0, NULL, 0, 300); | ||
165 | } | 231 | } |
166 | 232 | ||
167 | dbg(" %s - request=0x%x value=0x%x result=%d", | 233 | kfree(buf); |
168 | __FUNCTION__, request, value, result); | 234 | |
235 | if ((size > 2 && result != size) || result < 0) { | ||
236 | dev_err(&port->dev, "%s - Unable to send request, " | ||
237 | "request=0x%x size=%d result=%d\n", | ||
238 | __FUNCTION__, request, size, result); | ||
239 | return -EPROTO; | ||
240 | } | ||
169 | 241 | ||
242 | /* Single data value */ | ||
243 | result = usb_control_msg (serial->dev, | ||
244 | usb_sndctrlpipe(serial->dev, 0), | ||
245 | request, REQTYPE_HOST_TO_DEVICE, data[0], | ||
246 | 0, NULL, 0, 300); | ||
170 | return 0; | 247 | return 0; |
171 | } | 248 | } |
172 | 249 | ||
250 | /* | ||
251 | * cp2101_set_config_single | ||
252 | * Convenience function for calling cp2101_set_config on single data values | ||
253 | * without requiring an integer pointer | ||
254 | */ | ||
255 | static inline int cp2101_set_config_single(struct usb_serial_port* port, | ||
256 | u8 request, unsigned int data) | ||
257 | { | ||
258 | return cp2101_set_config(port, request, &data, 2); | ||
259 | } | ||
260 | |||
173 | static int cp2101_open (struct usb_serial_port *port, struct file *filp) | 261 | static int cp2101_open (struct usb_serial_port *port, struct file *filp) |
174 | { | 262 | { |
175 | struct usb_serial *serial = port->serial; | 263 | struct usb_serial *serial = port->serial; |
@@ -177,7 +265,7 @@ static int cp2101_open (struct usb_serial_port *port, struct file *filp) | |||
177 | 265 | ||
178 | dbg("%s - port %d", __FUNCTION__, port->number); | 266 | dbg("%s - port %d", __FUNCTION__, port->number); |
179 | 267 | ||
180 | if (cp2101_set_config(port, CP2101_UART, UART_ENABLE)) { | 268 | if (cp2101_set_config_single(port, CP2101_UART, UART_ENABLE)) { |
181 | dev_err(&port->dev, "%s - Unable to enable UART\n", | 269 | dev_err(&port->dev, "%s - Unable to enable UART\n", |
182 | __FUNCTION__); | 270 | __FUNCTION__); |
183 | return -EPROTO; | 271 | return -EPROTO; |
@@ -198,9 +286,12 @@ static int cp2101_open (struct usb_serial_port *port, struct file *filp) | |||
198 | return result; | 286 | return result; |
199 | } | 287 | } |
200 | 288 | ||
201 | /*Configure the termios structure*/ | 289 | /* Configure the termios structure */ |
202 | cp2101_get_termios(port); | 290 | cp2101_get_termios(port); |
203 | 291 | ||
292 | /* Set the DTR and RTS pins low */ | ||
293 | cp2101_tiocmset(port, NULL, TIOCM_DTR | TIOCM_RTS, 0); | ||
294 | |||
204 | return 0; | 295 | return 0; |
205 | } | 296 | } |
206 | 297 | ||
@@ -228,16 +319,18 @@ static void cp2101_close (struct usb_serial_port *port, struct file * filp) | |||
228 | usb_kill_urb(port->write_urb); | 319 | usb_kill_urb(port->write_urb); |
229 | usb_kill_urb(port->read_urb); | 320 | usb_kill_urb(port->read_urb); |
230 | 321 | ||
231 | cp2101_set_config(port, CP2101_UART, UART_DISABLE); | 322 | cp2101_set_config_single(port, CP2101_UART, UART_DISABLE); |
232 | } | 323 | } |
233 | 324 | ||
234 | /* cp2101_get_termios*/ | 325 | /* |
235 | /* Reads the baud rate, data bits, parity and stop bits from the device*/ | 326 | * cp2101_get_termios |
236 | /* Corrects any unsupported values*/ | 327 | * Reads the baud rate, data bits, parity, stop bits and flow control mode |
237 | /* Configures the termios structure to reflect the state of the device*/ | 328 | * from the device, corrects any unsupported values, and configures the |
329 | * termios structure to reflect the state of the device | ||
330 | */ | ||
238 | static void cp2101_get_termios (struct usb_serial_port *port) | 331 | static void cp2101_get_termios (struct usb_serial_port *port) |
239 | { | 332 | { |
240 | unsigned int cflag; | 333 | unsigned int cflag, modem_ctl[4]; |
241 | int baud; | 334 | int baud; |
242 | int bits; | 335 | int bits; |
243 | 336 | ||
@@ -249,15 +342,16 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
249 | } | 342 | } |
250 | cflag = port->tty->termios->c_cflag; | 343 | cflag = port->tty->termios->c_cflag; |
251 | 344 | ||
252 | baud = cp2101_get_config(port, CP2101_BAUDRATE); | 345 | cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2); |
253 | /*Convert to baudrate*/ | 346 | /* Convert to baudrate */ |
254 | if (baud) | 347 | if (baud) |
255 | baud = BAUD_RATE_GEN_FREQ / baud; | 348 | baud = BAUD_RATE_GEN_FREQ / baud; |
256 | 349 | ||
257 | dbg("%s - baud rate = %d", __FUNCTION__, baud); | 350 | dbg("%s - baud rate = %d", __FUNCTION__, baud); |
258 | cflag &= ~CBAUD; | 351 | cflag &= ~CBAUD; |
259 | switch (baud) { | 352 | switch (baud) { |
260 | /* The baud rates which are commented out below | 353 | /* |
354 | * The baud rates which are commented out below | ||
261 | * appear to be supported by the device | 355 | * appear to be supported by the device |
262 | * but are non-standard | 356 | * but are non-standard |
263 | */ | 357 | */ |
@@ -284,14 +378,18 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
284 | dbg("%s - Baud rate is not supported, " | 378 | dbg("%s - Baud rate is not supported, " |
285 | "using 9600 baud", __FUNCTION__); | 379 | "using 9600 baud", __FUNCTION__); |
286 | cflag |= B9600; | 380 | cflag |= B9600; |
287 | cp2101_set_config(port, CP2101_BAUDRATE, | 381 | cp2101_set_config_single(port, CP2101_BAUDRATE, |
288 | (BAUD_RATE_GEN_FREQ/9600)); | 382 | (BAUD_RATE_GEN_FREQ/9600)); |
289 | break; | 383 | break; |
290 | } | 384 | } |
291 | 385 | ||
292 | bits = cp2101_get_config(port, CP2101_BITS); | 386 | cp2101_get_config(port, CP2101_BITS, &bits, 2); |
293 | cflag &= ~CSIZE; | 387 | cflag &= ~CSIZE; |
294 | switch(bits & BITS_DATA_MASK) { | 388 | switch(bits & BITS_DATA_MASK) { |
389 | case BITS_DATA_5: | ||
390 | dbg("%s - data bits = 5", __FUNCTION__); | ||
391 | cflag |= CS5; | ||
392 | break; | ||
295 | case BITS_DATA_6: | 393 | case BITS_DATA_6: |
296 | dbg("%s - data bits = 6", __FUNCTION__); | 394 | dbg("%s - data bits = 6", __FUNCTION__); |
297 | cflag |= CS6; | 395 | cflag |= CS6; |
@@ -310,7 +408,7 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
310 | cflag |= CS8; | 408 | cflag |= CS8; |
311 | bits &= ~BITS_DATA_MASK; | 409 | bits &= ~BITS_DATA_MASK; |
312 | bits |= BITS_DATA_8; | 410 | bits |= BITS_DATA_8; |
313 | cp2101_set_config(port, CP2101_BITS, bits); | 411 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
314 | break; | 412 | break; |
315 | default: | 413 | default: |
316 | dbg("%s - Unknown number of data bits, " | 414 | dbg("%s - Unknown number of data bits, " |
@@ -318,7 +416,7 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
318 | cflag |= CS8; | 416 | cflag |= CS8; |
319 | bits &= ~BITS_DATA_MASK; | 417 | bits &= ~BITS_DATA_MASK; |
320 | bits |= BITS_DATA_8; | 418 | bits |= BITS_DATA_8; |
321 | cp2101_set_config(port, CP2101_BITS, bits); | 419 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
322 | break; | 420 | break; |
323 | } | 421 | } |
324 | 422 | ||
@@ -341,21 +439,21 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
341 | "disabling parity)", __FUNCTION__); | 439 | "disabling parity)", __FUNCTION__); |
342 | cflag &= ~PARENB; | 440 | cflag &= ~PARENB; |
343 | bits &= ~BITS_PARITY_MASK; | 441 | bits &= ~BITS_PARITY_MASK; |
344 | cp2101_set_config(port, CP2101_BITS, bits); | 442 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
345 | break; | 443 | break; |
346 | case BITS_PARITY_SPACE: | 444 | case BITS_PARITY_SPACE: |
347 | dbg("%s - parity = SPACE (not supported, " | 445 | dbg("%s - parity = SPACE (not supported, " |
348 | "disabling parity)", __FUNCTION__); | 446 | "disabling parity)", __FUNCTION__); |
349 | cflag &= ~PARENB; | 447 | cflag &= ~PARENB; |
350 | bits &= ~BITS_PARITY_MASK; | 448 | bits &= ~BITS_PARITY_MASK; |
351 | cp2101_set_config(port, CP2101_BITS, bits); | 449 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
352 | break; | 450 | break; |
353 | default: | 451 | default: |
354 | dbg("%s - Unknown parity mode, " | 452 | dbg("%s - Unknown parity mode, " |
355 | "disabling parity", __FUNCTION__); | 453 | "disabling parity", __FUNCTION__); |
356 | cflag &= ~PARENB; | 454 | cflag &= ~PARENB; |
357 | bits &= ~BITS_PARITY_MASK; | 455 | bits &= ~BITS_PARITY_MASK; |
358 | cp2101_set_config(port, CP2101_BITS, bits); | 456 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
359 | break; | 457 | break; |
360 | } | 458 | } |
361 | 459 | ||
@@ -366,9 +464,9 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
366 | break; | 464 | break; |
367 | case BITS_STOP_1_5: | 465 | case BITS_STOP_1_5: |
368 | dbg("%s - stop bits = 1.5 (not supported, " | 466 | dbg("%s - stop bits = 1.5 (not supported, " |
369 | "using 1 stop bit", __FUNCTION__); | 467 | "using 1 stop bit)", __FUNCTION__); |
370 | bits &= ~BITS_STOP_MASK; | 468 | bits &= ~BITS_STOP_MASK; |
371 | cp2101_set_config(port, CP2101_BITS, bits); | 469 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
372 | break; | 470 | break; |
373 | case BITS_STOP_2: | 471 | case BITS_STOP_2: |
374 | dbg("%s - stop bits = 2", __FUNCTION__); | 472 | dbg("%s - stop bits = 2", __FUNCTION__); |
@@ -378,10 +476,19 @@ static void cp2101_get_termios (struct usb_serial_port *port) | |||
378 | dbg("%s - Unknown number of stop bits, " | 476 | dbg("%s - Unknown number of stop bits, " |
379 | "using 1 stop bit", __FUNCTION__); | 477 | "using 1 stop bit", __FUNCTION__); |
380 | bits &= ~BITS_STOP_MASK; | 478 | bits &= ~BITS_STOP_MASK; |
381 | cp2101_set_config(port, CP2101_BITS, bits); | 479 | cp2101_set_config(port, CP2101_BITS, &bits, 2); |
382 | break; | 480 | break; |
383 | } | 481 | } |
384 | 482 | ||
483 | cp2101_get_config(port, CP2101_MODEMCTL, modem_ctl, 16); | ||
484 | if (modem_ctl[0] & 0x0008) { | ||
485 | dbg("%s - flow control = CRTSCTS", __FUNCTION__); | ||
486 | cflag |= CRTSCTS; | ||
487 | } else { | ||
488 | dbg("%s - flow control = NONE", __FUNCTION__); | ||
489 | cflag &= ~CRTSCTS; | ||
490 | } | ||
491 | |||
385 | port->tty->termios->c_cflag = cflag; | 492 | port->tty->termios->c_cflag = cflag; |
386 | } | 493 | } |
387 | 494 | ||
@@ -389,8 +496,8 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
389 | struct termios *old_termios) | 496 | struct termios *old_termios) |
390 | { | 497 | { |
391 | unsigned int cflag, old_cflag=0; | 498 | unsigned int cflag, old_cflag=0; |
392 | int baud=0; | 499 | int baud=0, bits; |
393 | int bits; | 500 | unsigned int modem_ctl[4]; |
394 | 501 | ||
395 | dbg("%s - port %d", __FUNCTION__, port->number); | 502 | dbg("%s - port %d", __FUNCTION__, port->number); |
396 | 503 | ||
@@ -400,7 +507,7 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
400 | } | 507 | } |
401 | cflag = port->tty->termios->c_cflag; | 508 | cflag = port->tty->termios->c_cflag; |
402 | 509 | ||
403 | /* check that they really want us to change something */ | 510 | /* Check that they really want us to change something */ |
404 | if (old_termios) { | 511 | if (old_termios) { |
405 | if ((cflag == old_termios->c_cflag) && | 512 | if ((cflag == old_termios->c_cflag) && |
406 | (RELEVANT_IFLAG(port->tty->termios->c_iflag) | 513 | (RELEVANT_IFLAG(port->tty->termios->c_iflag) |
@@ -415,7 +522,8 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
415 | /* If the baud rate is to be updated*/ | 522 | /* If the baud rate is to be updated*/ |
416 | if ((cflag & CBAUD) != (old_cflag & CBAUD)) { | 523 | if ((cflag & CBAUD) != (old_cflag & CBAUD)) { |
417 | switch (cflag & CBAUD) { | 524 | switch (cflag & CBAUD) { |
418 | /* The baud rates which are commented out below | 525 | /* |
526 | * The baud rates which are commented out below | ||
419 | * appear to be supported by the device | 527 | * appear to be supported by the device |
420 | * but are non-standard | 528 | * but are non-standard |
421 | */ | 529 | */ |
@@ -448,18 +556,22 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
448 | if (baud) { | 556 | if (baud) { |
449 | dbg("%s - Setting baud rate to %d baud", __FUNCTION__, | 557 | dbg("%s - Setting baud rate to %d baud", __FUNCTION__, |
450 | baud); | 558 | baud); |
451 | if (cp2101_set_config(port, CP2101_BAUDRATE, | 559 | if (cp2101_set_config_single(port, CP2101_BAUDRATE, |
452 | (BAUD_RATE_GEN_FREQ / baud))) | 560 | (BAUD_RATE_GEN_FREQ / baud))) |
453 | dev_err(&port->dev, "Baud rate requested not " | 561 | dev_err(&port->dev, "Baud rate requested not " |
454 | "supported by device\n"); | 562 | "supported by device\n"); |
455 | } | 563 | } |
456 | } | 564 | } |
457 | 565 | ||
458 | /*If the number of data bits is to be updated*/ | 566 | /* If the number of data bits is to be updated */ |
459 | if ((cflag & CSIZE) != (old_cflag & CSIZE)) { | 567 | if ((cflag & CSIZE) != (old_cflag & CSIZE)) { |
460 | bits = cp2101_get_config(port, CP2101_BITS); | 568 | cp2101_get_config(port, CP2101_BITS, &bits, 2); |
461 | bits &= ~BITS_DATA_MASK; | 569 | bits &= ~BITS_DATA_MASK; |
462 | switch (cflag & CSIZE) { | 570 | switch (cflag & CSIZE) { |
571 | case CS5: | ||
572 | bits |= BITS_DATA_5; | ||
573 | dbg("%s - data bits = 5", __FUNCTION__); | ||
574 | break; | ||
463 | case CS6: | 575 | case CS6: |
464 | bits |= BITS_DATA_6; | 576 | bits |= BITS_DATA_6; |
465 | dbg("%s - data bits = 6", __FUNCTION__); | 577 | dbg("%s - data bits = 6", __FUNCTION__); |
@@ -483,13 +595,13 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
483 | bits |= BITS_DATA_8; | 595 | bits |= BITS_DATA_8; |
484 | break; | 596 | break; |
485 | } | 597 | } |
486 | if (cp2101_set_config(port, CP2101_BITS, bits)) | 598 | if (cp2101_set_config(port, CP2101_BITS, &bits, 2)) |
487 | dev_err(&port->dev, "Number of data bits requested " | 599 | dev_err(&port->dev, "Number of data bits requested " |
488 | "not supported by device\n"); | 600 | "not supported by device\n"); |
489 | } | 601 | } |
490 | 602 | ||
491 | if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD))) { | 603 | if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD))) { |
492 | bits = cp2101_get_config(port, CP2101_BITS); | 604 | cp2101_get_config(port, CP2101_BITS, &bits, 2); |
493 | bits &= ~BITS_PARITY_MASK; | 605 | bits &= ~BITS_PARITY_MASK; |
494 | if (cflag & PARENB) { | 606 | if (cflag & PARENB) { |
495 | if (cflag & PARODD) { | 607 | if (cflag & PARODD) { |
@@ -500,13 +612,13 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
500 | dbg("%s - parity = EVEN", __FUNCTION__); | 612 | dbg("%s - parity = EVEN", __FUNCTION__); |
501 | } | 613 | } |
502 | } | 614 | } |
503 | if (cp2101_set_config(port, CP2101_BITS, bits)) | 615 | if (cp2101_set_config(port, CP2101_BITS, &bits, 2)) |
504 | dev_err(&port->dev, "Parity mode not supported " | 616 | dev_err(&port->dev, "Parity mode not supported " |
505 | "by device\n"); | 617 | "by device\n"); |
506 | } | 618 | } |
507 | 619 | ||
508 | if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) { | 620 | if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) { |
509 | bits = cp2101_get_config(port, CP2101_BITS); | 621 | cp2101_get_config(port, CP2101_BITS, &bits, 2); |
510 | bits &= ~BITS_STOP_MASK; | 622 | bits &= ~BITS_STOP_MASK; |
511 | if (cflag & CSTOPB) { | 623 | if (cflag & CSTOPB) { |
512 | bits |= BITS_STOP_2; | 624 | bits |= BITS_STOP_2; |
@@ -515,15 +627,90 @@ static void cp2101_set_termios (struct usb_serial_port *port, | |||
515 | bits |= BITS_STOP_1; | 627 | bits |= BITS_STOP_1; |
516 | dbg("%s - stop bits = 1", __FUNCTION__); | 628 | dbg("%s - stop bits = 1", __FUNCTION__); |
517 | } | 629 | } |
518 | if (cp2101_set_config(port, CP2101_BITS, bits)) | 630 | if (cp2101_set_config(port, CP2101_BITS, &bits, 2)) |
519 | dev_err(&port->dev, "Number of stop bits requested " | 631 | dev_err(&port->dev, "Number of stop bits requested " |
520 | "not supported by device\n"); | 632 | "not supported by device\n"); |
521 | } | 633 | } |
634 | |||
635 | if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { | ||
636 | cp2101_get_config(port, CP2101_MODEMCTL, modem_ctl, 16); | ||
637 | dbg("%s - read modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x", | ||
638 | __FUNCTION__, modem_ctl[0], modem_ctl[1], | ||
639 | modem_ctl[2], modem_ctl[3]); | ||
640 | |||
641 | if (cflag & CRTSCTS) { | ||
642 | modem_ctl[0] &= ~0x7B; | ||
643 | modem_ctl[0] |= 0x09; | ||
644 | modem_ctl[1] = 0x80; | ||
645 | dbg("%s - flow control = CRTSCTS", __FUNCTION__); | ||
646 | } else { | ||
647 | modem_ctl[0] &= ~0x7B; | ||
648 | modem_ctl[0] |= 0x01; | ||
649 | modem_ctl[1] |= 0x40; | ||
650 | dbg("%s - flow control = NONE", __FUNCTION__); | ||
651 | } | ||
652 | |||
653 | dbg("%s - write modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x", | ||
654 | __FUNCTION__, modem_ctl[0], modem_ctl[1], | ||
655 | modem_ctl[2], modem_ctl[3]); | ||
656 | cp2101_set_config(port, CP2101_MODEMCTL, modem_ctl, 16); | ||
657 | } | ||
658 | |||
659 | } | ||
660 | |||
661 | static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file, | ||
662 | unsigned int set, unsigned int clear) | ||
663 | { | ||
664 | int control = 0; | ||
665 | |||
666 | dbg("%s - port %d", __FUNCTION__, port->number); | ||
667 | |||
668 | if (set & TIOCM_RTS) { | ||
669 | control |= CONTROL_RTS; | ||
670 | control |= CONTROL_WRITE_RTS; | ||
671 | } | ||
672 | if (set & TIOCM_DTR) { | ||
673 | control |= CONTROL_DTR; | ||
674 | control |= CONTROL_WRITE_DTR; | ||
675 | } | ||
676 | if (clear & TIOCM_RTS) { | ||
677 | control &= ~CONTROL_RTS; | ||
678 | control |= CONTROL_WRITE_RTS; | ||
679 | } | ||
680 | if (clear & TIOCM_DTR) { | ||
681 | control &= ~CONTROL_DTR; | ||
682 | control |= CONTROL_WRITE_DTR; | ||
683 | } | ||
684 | |||
685 | dbg("%s - control = 0x%.4x", __FUNCTION__, control); | ||
686 | |||
687 | return cp2101_set_config(port, CP2101_CONTROL, &control, 2); | ||
688 | |||
689 | } | ||
690 | |||
691 | static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file) | ||
692 | { | ||
693 | int control, result; | ||
694 | |||
695 | dbg("%s - port %d", __FUNCTION__, port->number); | ||
696 | |||
697 | cp2101_get_config(port, CP2101_CONTROL, &control, 1); | ||
698 | |||
699 | result = ((control & CONTROL_DTR) ? TIOCM_DTR : 0) | ||
700 | |((control & CONTROL_RTS) ? TIOCM_RTS : 0) | ||
701 | |((control & CONTROL_CTS) ? TIOCM_CTS : 0) | ||
702 | |((control & CONTROL_DSR) ? TIOCM_DSR : 0) | ||
703 | |((control & CONTROL_RING)? TIOCM_RI : 0) | ||
704 | |((control & CONTROL_DCD) ? TIOCM_CD : 0); | ||
705 | |||
706 | dbg("%s - control = 0x%.2x", __FUNCTION__, control); | ||
707 | |||
708 | return result; | ||
522 | } | 709 | } |
523 | 710 | ||
524 | static void cp2101_break_ctl (struct usb_serial_port *port, int break_state) | 711 | static void cp2101_break_ctl (struct usb_serial_port *port, int break_state) |
525 | { | 712 | { |
526 | u16 state; | 713 | int state; |
527 | 714 | ||
528 | dbg("%s - port %d", __FUNCTION__, port->number); | 715 | dbg("%s - port %d", __FUNCTION__, port->number); |
529 | if (break_state == 0) | 716 | if (break_state == 0) |
@@ -532,12 +719,12 @@ static void cp2101_break_ctl (struct usb_serial_port *port, int break_state) | |||
532 | state = BREAK_ON; | 719 | state = BREAK_ON; |
533 | dbg("%s - turning break %s", __FUNCTION__, | 720 | dbg("%s - turning break %s", __FUNCTION__, |
534 | state==BREAK_OFF ? "off" : "on"); | 721 | state==BREAK_OFF ? "off" : "on"); |
535 | cp2101_set_config(port, CP2101_BREAK, state); | 722 | cp2101_set_config(port, CP2101_BREAK, &state, 2); |
536 | } | 723 | } |
537 | 724 | ||
538 | static int cp2101_startup (struct usb_serial *serial) | 725 | static int cp2101_startup (struct usb_serial *serial) |
539 | { | 726 | { |
540 | /*CP2101 buffers behave strangely unless device is reset*/ | 727 | /* CP2101 buffers behave strangely unless device is reset */ |
541 | usb_reset_device(serial->dev); | 728 | usb_reset_device(serial->dev); |
542 | return 0; | 729 | return 0; |
543 | } | 730 | } |
@@ -548,7 +735,7 @@ static void cp2101_shutdown (struct usb_serial *serial) | |||
548 | 735 | ||
549 | dbg("%s", __FUNCTION__); | 736 | dbg("%s", __FUNCTION__); |
550 | 737 | ||
551 | /* stop reads and writes on all ports */ | 738 | /* Stop reads and writes on all ports */ |
552 | for (i=0; i < serial->num_ports; ++i) { | 739 | for (i=0; i < serial->num_ports; ++i) { |
553 | cp2101_cleanup(serial->port[i]); | 740 | cp2101_cleanup(serial->port[i]); |
554 | } | 741 | } |
@@ -560,16 +747,16 @@ static int __init cp2101_init (void) | |||
560 | 747 | ||
561 | retval = usb_serial_register(&cp2101_device); | 748 | retval = usb_serial_register(&cp2101_device); |
562 | if (retval) | 749 | if (retval) |
563 | return retval; /*Failed to register*/ | 750 | return retval; /* Failed to register */ |
564 | 751 | ||
565 | retval = usb_register(&cp2101_driver); | 752 | retval = usb_register(&cp2101_driver); |
566 | if (retval) { | 753 | if (retval) { |
567 | /*Failed to register*/ | 754 | /* Failed to register */ |
568 | usb_serial_deregister(&cp2101_device); | 755 | usb_serial_deregister(&cp2101_device); |
569 | return retval; | 756 | return retval; |
570 | } | 757 | } |
571 | 758 | ||
572 | /*Success*/ | 759 | /* Success */ |
573 | info(DRIVER_DESC " " DRIVER_VERSION); | 760 | info(DRIVER_DESC " " DRIVER_VERSION); |
574 | return 0; | 761 | return 0; |
575 | } | 762 | } |
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 52394f08a947..051c3a77b41b 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -364,6 +364,7 @@ static struct usb_device_id id_table_8U232AM [] = { | |||
364 | { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_3, 0, 0x3ff) }, | 364 | { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_3, 0, 0x3ff) }, |
365 | { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_4, 0, 0x3ff) }, | 365 | { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_4, 0, 0x3ff) }, |
366 | { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UO100_PID, 0, 0x3ff) }, | 366 | { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UO100_PID, 0, 0x3ff) }, |
367 | { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UM100_PID, 0, 0x3ff) }, | ||
367 | { USB_DEVICE_VER(FTDI_VID, INSIDE_ACCESSO, 0, 0x3ff) }, | 368 | { USB_DEVICE_VER(FTDI_VID, INSIDE_ACCESSO, 0, 0x3ff) }, |
368 | { USB_DEVICE_VER(INTREPID_VID, INTREPID_VALUECAN_PID, 0, 0x3ff) }, | 369 | { USB_DEVICE_VER(INTREPID_VID, INTREPID_VALUECAN_PID, 0, 0x3ff) }, |
369 | { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0, 0x3ff) }, | 370 | { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0, 0x3ff) }, |
@@ -475,6 +476,7 @@ static struct usb_device_id id_table_FT232BM [] = { | |||
475 | { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88E_PID, 0x400, 0xffff) }, | 476 | { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88E_PID, 0x400, 0xffff) }, |
476 | { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88F_PID, 0x400, 0xffff) }, | 477 | { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88F_PID, 0x400, 0xffff) }, |
477 | { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UO100_PID, 0x400, 0xffff) }, | 478 | { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UO100_PID, 0x400, 0xffff) }, |
479 | { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UM100_PID, 0x400, 0xffff) }, | ||
478 | { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) }, | 480 | { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) }, |
479 | { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) }, | 481 | { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) }, |
480 | { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_0_PID, 0x400, 0xffff) }, | 482 | { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_0_PID, 0x400, 0xffff) }, |
@@ -618,6 +620,7 @@ static struct usb_device_id id_table_combined [] = { | |||
618 | { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88E_PID, 0x400, 0xffff) }, | 620 | { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88E_PID, 0x400, 0xffff) }, |
619 | { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88F_PID, 0x400, 0xffff) }, | 621 | { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88F_PID, 0x400, 0xffff) }, |
620 | { USB_DEVICE(FTDI_VID, FTDI_ELV_UO100_PID) }, | 622 | { USB_DEVICE(FTDI_VID, FTDI_ELV_UO100_PID) }, |
623 | { USB_DEVICE(FTDI_VID, FTDI_ELV_UM100_PID) }, | ||
621 | { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) }, | 624 | { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) }, |
622 | { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) }, | 625 | { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) }, |
623 | { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_0_PID, 0x400, 0xffff) }, | 626 | { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_0_PID, 0x400, 0xffff) }, |
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index a52bb13a9ce4..8866376823a5 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h | |||
@@ -144,6 +144,8 @@ | |||
144 | 144 | ||
145 | /* ELV USB Module UO100 (PID sent by Stefan Frings) */ | 145 | /* ELV USB Module UO100 (PID sent by Stefan Frings) */ |
146 | #define FTDI_ELV_UO100_PID 0xFB58 /* Product Id */ | 146 | #define FTDI_ELV_UO100_PID 0xFB58 /* Product Id */ |
147 | /* ELV USB Module UM100 (PID sent by Arnim Laeuger) */ | ||
148 | #define FTDI_ELV_UM100_PID 0xFB5A /* Product Id */ | ||
147 | 149 | ||
148 | /* | 150 | /* |
149 | * Definitions for ID TECH (www.idt-net.com) devices | 151 | * Definitions for ID TECH (www.idt-net.com) devices |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c new file mode 100644 index 000000000000..b722175f108f --- /dev/null +++ b/drivers/usb/serial/option.c | |||
@@ -0,0 +1,729 @@ | |||
1 | /* | ||
2 | Option Card (PCMCIA to) USB to Serial Driver | ||
3 | |||
4 | Copyright (C) 2005 Matthias Urlichs <smurf@smurf.noris.de> | ||
5 | |||
6 | This driver is free software; you can redistribute it and/or modify | ||
7 | it under the terms of Version 2 of the GNU General Public License as | ||
8 | published by the Free Software Foundation. | ||
9 | |||
10 | Portions copied from the Keyspan driver by Hugh Blemings <hugh@blemings.org> | ||
11 | |||
12 | History: | ||
13 | |||
14 | 2005-05-19 v0.1 Initial version, based on incomplete docs | ||
15 | and analysis of misbehavior of the standard driver | ||
16 | 2005-05-20 v0.2 Extended the input buffer to avoid losing | ||
17 | random 64-byte chunks of data | ||
18 | 2005-05-21 v0.3 implemented chars_in_buffer() | ||
19 | turned on low_latency | ||
20 | simplified the code somewhat | ||
21 | */ | ||
22 | #define DRIVER_VERSION "v0.3" | ||
23 | #define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>" | ||
24 | #define DRIVER_DESC "Option Card (PC-Card to) USB to Serial Driver" | ||
25 | |||
26 | #include <linux/config.h> | ||
27 | #include <linux/kernel.h> | ||
28 | #include <linux/jiffies.h> | ||
29 | #include <linux/errno.h> | ||
30 | #include <linux/tty.h> | ||
31 | #include <linux/tty_flip.h> | ||
32 | #include <linux/module.h> | ||
33 | #include <linux/usb.h> | ||
34 | #include "usb-serial.h" | ||
35 | |||
36 | /* Function prototypes */ | ||
37 | static int option_open (struct usb_serial_port *port, struct file *filp); | ||
38 | static void option_close (struct usb_serial_port *port, struct file *filp); | ||
39 | static int option_startup (struct usb_serial *serial); | ||
40 | static void option_shutdown (struct usb_serial *serial); | ||
41 | static void option_rx_throttle (struct usb_serial_port *port); | ||
42 | static void option_rx_unthrottle (struct usb_serial_port *port); | ||
43 | static int option_write_room (struct usb_serial_port *port); | ||
44 | |||
45 | static void option_instat_callback(struct urb *urb, struct pt_regs *regs); | ||
46 | |||
47 | |||
48 | static int option_write (struct usb_serial_port *port, | ||
49 | const unsigned char *buf, int count); | ||
50 | |||
51 | static int option_chars_in_buffer (struct usb_serial_port *port); | ||
52 | static int option_ioctl (struct usb_serial_port *port, struct file *file, | ||
53 | unsigned int cmd, unsigned long arg); | ||
54 | static void option_set_termios (struct usb_serial_port *port, | ||
55 | struct termios *old); | ||
56 | static void option_break_ctl (struct usb_serial_port *port, int break_state); | ||
57 | static int option_tiocmget (struct usb_serial_port *port, struct file *file); | ||
58 | static int option_tiocmset (struct usb_serial_port *port, struct file *file, | ||
59 | unsigned int set, unsigned int clear); | ||
60 | static int option_send_setup (struct usb_serial_port *port); | ||
61 | |||
62 | /* Vendor and product IDs */ | ||
63 | #define OPTION_VENDOR_ID 0x0AF0 | ||
64 | |||
65 | #define OPTION_PRODUCT_OLD 0x5000 | ||
66 | #define OPTION_PRODUCT_WLAN 0x6000 | ||
67 | |||
68 | static struct usb_device_id option_ids[] = { | ||
69 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_OLD) }, | ||
70 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_WLAN) }, | ||
71 | { } /* Terminating entry */ | ||
72 | }; | ||
73 | |||
74 | MODULE_DEVICE_TABLE(usb, option_ids); | ||
75 | |||
76 | static struct usb_driver option_driver = { | ||
77 | .owner = THIS_MODULE, | ||
78 | .name = "option", | ||
79 | .probe = usb_serial_probe, | ||
80 | .disconnect = usb_serial_disconnect, | ||
81 | .id_table = option_ids, | ||
82 | }; | ||
83 | |||
84 | /* The card has three separate interfaces, wich the serial driver | ||
85 | * recognizes separately, thus num_port=1. | ||
86 | */ | ||
87 | static struct usb_serial_device_type option_3port_device = { | ||
88 | .owner = THIS_MODULE, | ||
89 | .name = "Option 3-port card", | ||
90 | .short_name = "option", | ||
91 | .id_table = option_ids, | ||
92 | .num_interrupt_in = NUM_DONT_CARE, | ||
93 | .num_bulk_in = NUM_DONT_CARE, | ||
94 | .num_bulk_out = NUM_DONT_CARE, | ||
95 | .num_ports = 1, /* 3 */ | ||
96 | .open = option_open, | ||
97 | .close = option_close, | ||
98 | .write = option_write, | ||
99 | .write_room = option_write_room, | ||
100 | .chars_in_buffer = option_chars_in_buffer, | ||
101 | .throttle = option_rx_throttle, | ||
102 | .unthrottle = option_rx_unthrottle, | ||
103 | .ioctl = option_ioctl, | ||
104 | .set_termios = option_set_termios, | ||
105 | .break_ctl = option_break_ctl, | ||
106 | .tiocmget = option_tiocmget, | ||
107 | .tiocmset = option_tiocmset, | ||
108 | .attach = option_startup, | ||
109 | .shutdown = option_shutdown, | ||
110 | .read_int_callback = option_instat_callback, | ||
111 | }; | ||
112 | |||
113 | static int debug; | ||
114 | |||
115 | /* per port private data */ | ||
116 | |||
117 | #define N_IN_URB 4 | ||
118 | #define N_OUT_URB 1 | ||
119 | #define IN_BUFLEN 1024 | ||
120 | #define OUT_BUFLEN 1024 | ||
121 | |||
122 | struct option_port_private { | ||
123 | /* Input endpoints and buffer for this port */ | ||
124 | struct urb *in_urbs[N_IN_URB]; | ||
125 | char in_buffer[N_IN_URB][IN_BUFLEN]; | ||
126 | /* Output endpoints and buffer for this port */ | ||
127 | struct urb *out_urbs[N_OUT_URB]; | ||
128 | char out_buffer[N_OUT_URB][OUT_BUFLEN]; | ||
129 | |||
130 | /* Settings for the port */ | ||
131 | int rts_state; /* Handshaking pins (outputs) */ | ||
132 | int dtr_state; | ||
133 | int cts_state; /* Handshaking pins (inputs) */ | ||
134 | int dsr_state; | ||
135 | int dcd_state; | ||
136 | int ri_state; | ||
137 | // int break_on; | ||
138 | |||
139 | unsigned long tx_start_time[N_OUT_URB]; | ||
140 | }; | ||
141 | |||
142 | |||
143 | /* Functions used by new usb-serial code. */ | ||
144 | static int __init | ||
145 | option_init (void) | ||
146 | { | ||
147 | int retval; | ||
148 | retval = usb_serial_register(&option_3port_device); | ||
149 | if (retval) | ||
150 | goto failed_3port_device_register; | ||
151 | retval = usb_register(&option_driver); | ||
152 | if (retval) | ||
153 | goto failed_driver_register; | ||
154 | |||
155 | info(DRIVER_DESC ": " DRIVER_VERSION); | ||
156 | |||
157 | return 0; | ||
158 | |||
159 | failed_driver_register: | ||
160 | usb_serial_deregister (&option_3port_device); | ||
161 | failed_3port_device_register: | ||
162 | return retval; | ||
163 | } | ||
164 | |||
165 | static void __exit | ||
166 | option_exit (void) | ||
167 | { | ||
168 | usb_deregister (&option_driver); | ||
169 | usb_serial_deregister (&option_3port_device); | ||
170 | } | ||
171 | |||
172 | module_init(option_init); | ||
173 | module_exit(option_exit); | ||
174 | |||
175 | static void | ||
176 | option_rx_throttle (struct usb_serial_port *port) | ||
177 | { | ||
178 | dbg("%s", __FUNCTION__); | ||
179 | } | ||
180 | |||
181 | |||
182 | static void | ||
183 | option_rx_unthrottle (struct usb_serial_port *port) | ||
184 | { | ||
185 | dbg("%s", __FUNCTION__); | ||
186 | } | ||
187 | |||
188 | |||
189 | static void | ||
190 | option_break_ctl (struct usb_serial_port *port, int break_state) | ||
191 | { | ||
192 | /* Unfortunately, I don't know how to send a break */ | ||
193 | dbg("%s", __FUNCTION__); | ||
194 | } | ||
195 | |||
196 | |||
197 | static void | ||
198 | option_set_termios (struct usb_serial_port *port, | ||
199 | struct termios *old_termios) | ||
200 | { | ||
201 | dbg("%s", __FUNCTION__); | ||
202 | |||
203 | option_send_setup(port); | ||
204 | } | ||
205 | |||
206 | static int | ||
207 | option_tiocmget(struct usb_serial_port *port, struct file *file) | ||
208 | { | ||
209 | unsigned int value; | ||
210 | struct option_port_private *portdata; | ||
211 | |||
212 | portdata = usb_get_serial_port_data(port); | ||
213 | |||
214 | value = ((portdata->rts_state) ? TIOCM_RTS : 0) | | ||
215 | ((portdata->dtr_state) ? TIOCM_DTR : 0) | | ||
216 | ((portdata->cts_state) ? TIOCM_CTS : 0) | | ||
217 | ((portdata->dsr_state) ? TIOCM_DSR : 0) | | ||
218 | ((portdata->dcd_state) ? TIOCM_CAR : 0) | | ||
219 | ((portdata->ri_state) ? TIOCM_RNG : 0); | ||
220 | |||
221 | return value; | ||
222 | } | ||
223 | |||
224 | static int | ||
225 | option_tiocmset (struct usb_serial_port *port, struct file *file, | ||
226 | unsigned int set, unsigned int clear) | ||
227 | { | ||
228 | struct option_port_private *portdata; | ||
229 | |||
230 | portdata = usb_get_serial_port_data(port); | ||
231 | |||
232 | if (set & TIOCM_RTS) | ||
233 | portdata->rts_state = 1; | ||
234 | if (set & TIOCM_DTR) | ||
235 | portdata->dtr_state = 1; | ||
236 | |||
237 | if (clear & TIOCM_RTS) | ||
238 | portdata->rts_state = 0; | ||
239 | if (clear & TIOCM_DTR) | ||
240 | portdata->dtr_state = 0; | ||
241 | return option_send_setup(port); | ||
242 | } | ||
243 | |||
244 | static int | ||
245 | option_ioctl (struct usb_serial_port *port, struct file *file, | ||
246 | unsigned int cmd, unsigned long arg) | ||
247 | { | ||
248 | return -ENOIOCTLCMD; | ||
249 | } | ||
250 | |||
251 | /* Write */ | ||
252 | static int | ||
253 | option_write(struct usb_serial_port *port, | ||
254 | const unsigned char *buf, int count) | ||
255 | { | ||
256 | struct option_port_private *portdata; | ||
257 | int i; | ||
258 | int left, todo; | ||
259 | struct urb *this_urb = NULL; /* spurious */ | ||
260 | int err; | ||
261 | |||
262 | portdata = usb_get_serial_port_data(port); | ||
263 | |||
264 | dbg("%s: write (%d chars)", __FUNCTION__, count); | ||
265 | |||
266 | #if 0 | ||
267 | spin_lock(&port->lock); | ||
268 | if (port->write_urb_busy) { | ||
269 | spin_unlock(&port->lock); | ||
270 | dbg("%s: already writing", __FUNCTION__); | ||
271 | return 0; | ||
272 | } | ||
273 | port->write_urb_busy = 1; | ||
274 | spin_unlock(&port->lock); | ||
275 | #endif | ||
276 | |||
277 | i = 0; | ||
278 | left = count; | ||
279 | while (left>0) { | ||
280 | todo = left; | ||
281 | if (todo > OUT_BUFLEN) | ||
282 | todo = OUT_BUFLEN; | ||
283 | |||
284 | for (;i < N_OUT_URB; i++) { | ||
285 | /* Check we have a valid urb/endpoint before we use it... */ | ||
286 | this_urb = portdata->out_urbs[i]; | ||
287 | if (this_urb->status != -EINPROGRESS) | ||
288 | break; | ||
289 | if (this_urb->transfer_flags & URB_ASYNC_UNLINK) | ||
290 | continue; | ||
291 | if (time_before(jiffies, portdata->tx_start_time[i] + 10 * HZ)) | ||
292 | continue; | ||
293 | this_urb->transfer_flags |= URB_ASYNC_UNLINK; | ||
294 | usb_unlink_urb(this_urb); | ||
295 | } | ||
296 | |||
297 | if (i == N_OUT_URB) { | ||
298 | /* no bulk out free! */ | ||
299 | dbg("%s: no output urb -- left %d", __FUNCTION__,count-left); | ||
300 | #if 0 | ||
301 | port->write_urb_busy = 0; | ||
302 | #endif | ||
303 | return count-left; | ||
304 | } | ||
305 | |||
306 | dbg("%s: endpoint %d buf %d", __FUNCTION__, usb_pipeendpoint(this_urb->pipe), i); | ||
307 | |||
308 | memcpy (this_urb->transfer_buffer, buf, todo); | ||
309 | |||
310 | /* send the data out the bulk port */ | ||
311 | this_urb->transfer_buffer_length = todo; | ||
312 | |||
313 | this_urb->transfer_flags &= ~URB_ASYNC_UNLINK; | ||
314 | this_urb->dev = port->serial->dev; | ||
315 | err = usb_submit_urb(this_urb, GFP_ATOMIC); | ||
316 | if (err) { | ||
317 | dbg("usb_submit_urb %p (write bulk) failed (%d,, has %d)", this_urb, err, this_urb->status); | ||
318 | continue; | ||
319 | } | ||
320 | portdata->tx_start_time[i] = jiffies; | ||
321 | buf += todo; | ||
322 | left -= todo; | ||
323 | } | ||
324 | |||
325 | count -= left; | ||
326 | #if 0 | ||
327 | port->write_urb_busy = 0; | ||
328 | #endif | ||
329 | dbg("%s: wrote (did %d)", __FUNCTION__, count); | ||
330 | return count; | ||
331 | } | ||
332 | |||
333 | static void | ||
334 | option_indat_callback (struct urb *urb, struct pt_regs *regs) | ||
335 | { | ||
336 | int i, err; | ||
337 | int endpoint; | ||
338 | struct usb_serial_port *port; | ||
339 | struct tty_struct *tty; | ||
340 | unsigned char *data = urb->transfer_buffer; | ||
341 | |||
342 | dbg("%s: %p", __FUNCTION__, urb); | ||
343 | |||
344 | endpoint = usb_pipeendpoint(urb->pipe); | ||
345 | port = (struct usb_serial_port *) urb->context; | ||
346 | |||
347 | if (urb->status) { | ||
348 | dbg("%s: nonzero status: %d on endpoint %02x.", | ||
349 | __FUNCTION__, urb->status, endpoint); | ||
350 | } else { | ||
351 | tty = port->tty; | ||
352 | if (urb->actual_length) { | ||
353 | for (i = 0; i < urb->actual_length ; ++i) { | ||
354 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) | ||
355 | tty_flip_buffer_push(tty); | ||
356 | tty_insert_flip_char(tty, data[i], 0); | ||
357 | } | ||
358 | tty_flip_buffer_push(tty); | ||
359 | } else { | ||
360 | dbg("%s: empty read urb received", __FUNCTION__); | ||
361 | } | ||
362 | |||
363 | /* Resubmit urb so we continue receiving */ | ||
364 | if (port->open_count && urb->status != -ESHUTDOWN) { | ||
365 | err = usb_submit_urb(urb, GFP_ATOMIC); | ||
366 | if (err) | ||
367 | printk(KERN_ERR "%s: resubmit read urb failed. (%d)", __FUNCTION__, err); | ||
368 | } | ||
369 | } | ||
370 | return; | ||
371 | } | ||
372 | |||
373 | static void | ||
374 | option_outdat_callback (struct urb *urb, struct pt_regs *regs) | ||
375 | { | ||
376 | struct usb_serial_port *port; | ||
377 | |||
378 | dbg("%s", __FUNCTION__); | ||
379 | |||
380 | port = (struct usb_serial_port *) urb->context; | ||
381 | |||
382 | if (port->open_count) | ||
383 | schedule_work(&port->work); | ||
384 | } | ||
385 | |||
386 | static void | ||
387 | option_instat_callback (struct urb *urb, struct pt_regs *regs) | ||
388 | { | ||
389 | int err; | ||
390 | struct usb_serial_port *port = (struct usb_serial_port *) urb->context; | ||
391 | struct option_port_private *portdata = usb_get_serial_port_data(port); | ||
392 | struct usb_serial *serial = port->serial; | ||
393 | |||
394 | dbg("%s", __FUNCTION__); | ||
395 | dbg("%s: urb %p port %p has data %p", __FUNCTION__,urb,port,portdata); | ||
396 | |||
397 | if (urb->status == 0) { | ||
398 | struct usb_ctrlrequest *req_pkt = | ||
399 | (struct usb_ctrlrequest *)urb->transfer_buffer; | ||
400 | |||
401 | if (!req_pkt) { | ||
402 | dbg("%s: NULL req_pkt\n", __FUNCTION__); | ||
403 | return; | ||
404 | } | ||
405 | if ((req_pkt->bRequestType == 0xA1) && (req_pkt->bRequest == 0x20)) { | ||
406 | int old_dcd_state; | ||
407 | unsigned char signals = *((unsigned char *) | ||
408 | urb->transfer_buffer + sizeof(struct usb_ctrlrequest)); | ||
409 | |||
410 | dbg("%s: signal x%x", __FUNCTION__, signals); | ||
411 | |||
412 | old_dcd_state = portdata->dcd_state; | ||
413 | portdata->cts_state = 1; | ||
414 | portdata->dcd_state = ((signals & 0x01) ? 1 : 0); | ||
415 | portdata->dsr_state = ((signals & 0x02) ? 1 : 0); | ||
416 | portdata->ri_state = ((signals & 0x08) ? 1 : 0); | ||
417 | |||
418 | if (port->tty && !C_CLOCAL(port->tty) | ||
419 | && old_dcd_state && !portdata->dcd_state) { | ||
420 | tty_hangup(port->tty); | ||
421 | } | ||
422 | } else | ||
423 | dbg("%s: type %x req %x", __FUNCTION__, req_pkt->bRequestType,req_pkt->bRequest); | ||
424 | } else | ||
425 | dbg("%s: error %d", __FUNCTION__, urb->status); | ||
426 | |||
427 | /* Resubmit urb so we continue receiving IRQ data */ | ||
428 | if (urb->status != -ESHUTDOWN) { | ||
429 | urb->dev = serial->dev; | ||
430 | err = usb_submit_urb(urb, GFP_ATOMIC); | ||
431 | if (err) | ||
432 | dbg("%s: resubmit intr urb failed. (%d)", __FUNCTION__, err); | ||
433 | } | ||
434 | } | ||
435 | |||
436 | |||
437 | static int | ||
438 | option_write_room (struct usb_serial_port *port) | ||
439 | { | ||
440 | struct option_port_private *portdata; | ||
441 | int i; | ||
442 | int data_len = 0; | ||
443 | struct urb *this_urb; | ||
444 | |||
445 | portdata = usb_get_serial_port_data(port); | ||
446 | |||
447 | for (i=0; i < N_OUT_URB; i++) | ||
448 | this_urb = portdata->out_urbs[i]; | ||
449 | if (this_urb && this_urb->status != -EINPROGRESS) | ||
450 | data_len += OUT_BUFLEN; | ||
451 | |||
452 | dbg("%s: %d", __FUNCTION__, data_len); | ||
453 | return data_len; | ||
454 | } | ||
455 | |||
456 | |||
457 | static int | ||
458 | option_chars_in_buffer (struct usb_serial_port *port) | ||
459 | { | ||
460 | struct option_port_private *portdata; | ||
461 | int i; | ||
462 | int data_len = 0; | ||
463 | struct urb *this_urb; | ||
464 | |||
465 | portdata = usb_get_serial_port_data(port); | ||
466 | |||
467 | for (i=0; i < N_OUT_URB; i++) | ||
468 | this_urb = portdata->out_urbs[i]; | ||
469 | if (this_urb && this_urb->status == -EINPROGRESS) | ||
470 | data_len += this_urb->transfer_buffer_length; | ||
471 | |||
472 | dbg("%s: %d", __FUNCTION__, data_len); | ||
473 | return data_len; | ||
474 | } | ||
475 | |||
476 | |||
477 | static int | ||
478 | option_open (struct usb_serial_port *port, struct file *filp) | ||
479 | { | ||
480 | struct option_port_private *portdata; | ||
481 | struct usb_serial *serial = port->serial; | ||
482 | int i, err; | ||
483 | struct urb *urb; | ||
484 | |||
485 | portdata = usb_get_serial_port_data(port); | ||
486 | |||
487 | dbg("%s", __FUNCTION__); | ||
488 | |||
489 | /* Set some sane defaults */ | ||
490 | portdata->rts_state = 1; | ||
491 | portdata->dtr_state = 1; | ||
492 | |||
493 | /* Reset low level data toggle and start reading from endpoints */ | ||
494 | for (i = 0; i < N_IN_URB; i++) { | ||
495 | urb = portdata->in_urbs[i]; | ||
496 | if (! urb) | ||
497 | continue; | ||
498 | if (urb->dev != serial->dev) { | ||
499 | dbg("%s: dev %p != %p", __FUNCTION__, urb->dev, serial->dev); | ||
500 | continue; | ||
501 | } | ||
502 | |||
503 | /* make sure endpoint data toggle is synchronized with the device */ | ||
504 | |||
505 | usb_clear_halt(urb->dev, urb->pipe); | ||
506 | |||
507 | err = usb_submit_urb(urb, GFP_KERNEL); | ||
508 | if (err) { | ||
509 | dbg("%s: submit urb %d failed (%d) %d", __FUNCTION__, i, err, | ||
510 | urb->transfer_buffer_length); | ||
511 | } | ||
512 | } | ||
513 | |||
514 | /* Reset low level data toggle on out endpoints */ | ||
515 | for (i = 0; i < N_OUT_URB; i++) { | ||
516 | urb = portdata->out_urbs[i]; | ||
517 | if (! urb) | ||
518 | continue; | ||
519 | urb->dev = serial->dev; | ||
520 | /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe), 0); */ | ||
521 | } | ||
522 | |||
523 | port->tty->low_latency = 1; | ||
524 | |||
525 | option_send_setup(port); | ||
526 | |||
527 | return (0); | ||
528 | } | ||
529 | |||
530 | static inline void | ||
531 | stop_urb(struct urb *urb) | ||
532 | { | ||
533 | if (urb && urb->status == -EINPROGRESS) { | ||
534 | urb->transfer_flags &= ~URB_ASYNC_UNLINK; | ||
535 | usb_kill_urb(urb); | ||
536 | } | ||
537 | } | ||
538 | |||
539 | static void | ||
540 | option_close(struct usb_serial_port *port, struct file *filp) | ||
541 | { | ||
542 | int i; | ||
543 | struct usb_serial *serial = port->serial; | ||
544 | struct option_port_private *portdata; | ||
545 | |||
546 | dbg("%s", __FUNCTION__); | ||
547 | portdata = usb_get_serial_port_data(port); | ||
548 | |||
549 | portdata->rts_state = 0; | ||
550 | portdata->dtr_state = 0; | ||
551 | |||
552 | if (serial->dev) { | ||
553 | option_send_setup(port); | ||
554 | |||
555 | /* Stop reading/writing urbs */ | ||
556 | for (i = 0; i < N_IN_URB; i++) | ||
557 | stop_urb(portdata->in_urbs[i]); | ||
558 | for (i = 0; i < N_OUT_URB; i++) | ||
559 | stop_urb(portdata->out_urbs[i]); | ||
560 | } | ||
561 | port->tty = NULL; | ||
562 | } | ||
563 | |||
564 | |||
565 | /* Helper functions used by option_setup_urbs */ | ||
566 | static struct urb * | ||
567 | option_setup_urb (struct usb_serial *serial, int endpoint, | ||
568 | int dir, void *ctx, char *buf, int len, | ||
569 | void (*callback)(struct urb *, struct pt_regs *regs)) | ||
570 | { | ||
571 | struct urb *urb; | ||
572 | |||
573 | if (endpoint == -1) | ||
574 | return NULL; /* endpoint not needed */ | ||
575 | |||
576 | urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ | ||
577 | if (urb == NULL) { | ||
578 | dbg("%s: alloc for endpoint %d failed.", __FUNCTION__, endpoint); | ||
579 | return NULL; | ||
580 | } | ||
581 | |||
582 | /* Fill URB using supplied data. */ | ||
583 | usb_fill_bulk_urb(urb, serial->dev, | ||
584 | usb_sndbulkpipe(serial->dev, endpoint) | dir, | ||
585 | buf, len, callback, ctx); | ||
586 | |||
587 | return urb; | ||
588 | } | ||
589 | |||
590 | /* Setup urbs */ | ||
591 | static void | ||
592 | option_setup_urbs(struct usb_serial *serial) | ||
593 | { | ||
594 | int j; | ||
595 | struct usb_serial_port *port; | ||
596 | struct option_port_private *portdata; | ||
597 | |||
598 | dbg("%s", __FUNCTION__); | ||
599 | |||
600 | port = serial->port[0]; | ||
601 | portdata = usb_get_serial_port_data(port); | ||
602 | |||
603 | /* Do indat endpoints first */ | ||
604 | for (j = 0; j <= N_IN_URB; ++j) { | ||
605 | portdata->in_urbs[j] = option_setup_urb (serial, | ||
606 | port->bulk_in_endpointAddress, USB_DIR_IN, port, | ||
607 | portdata->in_buffer[j], IN_BUFLEN, option_indat_callback); | ||
608 | } | ||
609 | |||
610 | /* outdat endpoints */ | ||
611 | for (j = 0; j <= N_OUT_URB; ++j) { | ||
612 | portdata->out_urbs[j] = option_setup_urb (serial, | ||
613 | port->bulk_out_endpointAddress, USB_DIR_OUT, port, | ||
614 | portdata->out_buffer[j], OUT_BUFLEN, option_outdat_callback); | ||
615 | } | ||
616 | } | ||
617 | |||
618 | |||
619 | static int | ||
620 | option_send_setup(struct usb_serial_port *port) | ||
621 | { | ||
622 | struct usb_serial *serial = port->serial; | ||
623 | struct option_port_private *portdata; | ||
624 | |||
625 | dbg("%s", __FUNCTION__); | ||
626 | |||
627 | portdata = usb_get_serial_port_data(port); | ||
628 | |||
629 | if (port->tty) { | ||
630 | int val = 0; | ||
631 | if (portdata->dtr_state) | ||
632 | val |= 0x01; | ||
633 | if (portdata->rts_state) | ||
634 | val |= 0x02; | ||
635 | |||
636 | return usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | ||
637 | 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT); | ||
638 | } | ||
639 | |||
640 | return 0; | ||
641 | } | ||
642 | |||
643 | |||
644 | static int | ||
645 | option_startup (struct usb_serial *serial) | ||
646 | { | ||
647 | int i, err; | ||
648 | struct usb_serial_port *port; | ||
649 | struct option_port_private *portdata; | ||
650 | |||
651 | dbg("%s", __FUNCTION__); | ||
652 | |||
653 | /* Now setup per port private data */ | ||
654 | for (i = 0; i < serial->num_ports; i++) { | ||
655 | port = serial->port[i]; | ||
656 | portdata = kmalloc(sizeof(struct option_port_private), GFP_KERNEL); | ||
657 | if (!portdata) { | ||
658 | dbg("%s: kmalloc for option_port_private (%d) failed!.", __FUNCTION__, i); | ||
659 | return (1); | ||
660 | } | ||
661 | memset(portdata, 0, sizeof(struct option_port_private)); | ||
662 | |||
663 | usb_set_serial_port_data(port, portdata); | ||
664 | |||
665 | if (! port->interrupt_in_urb) | ||
666 | continue; | ||
667 | err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | ||
668 | if (err) | ||
669 | dbg("%s: submit irq_in urb failed %d", __FUNCTION__, err); | ||
670 | } | ||
671 | |||
672 | option_setup_urbs(serial); | ||
673 | |||
674 | return (0); | ||
675 | } | ||
676 | |||
677 | static void | ||
678 | option_shutdown (struct usb_serial *serial) | ||
679 | { | ||
680 | int i, j; | ||
681 | struct usb_serial_port *port; | ||
682 | struct option_port_private *portdata; | ||
683 | |||
684 | dbg("%s", __FUNCTION__); | ||
685 | |||
686 | /* Stop reading/writing urbs */ | ||
687 | for (i = 0; i < serial->num_ports; ++i) { | ||
688 | port = serial->port[i]; | ||
689 | portdata = usb_get_serial_port_data(port); | ||
690 | for (j = 0; j < N_IN_URB; j++) | ||
691 | stop_urb(portdata->in_urbs[j]); | ||
692 | for (j = 0; j < N_OUT_URB; j++) | ||
693 | stop_urb(portdata->out_urbs[j]); | ||
694 | } | ||
695 | |||
696 | /* Now free them */ | ||
697 | for (i = 0; i < serial->num_ports; ++i) { | ||
698 | port = serial->port[i]; | ||
699 | portdata = usb_get_serial_port_data(port); | ||
700 | |||
701 | for (j = 0; j < N_IN_URB; j++) { | ||
702 | if (portdata->in_urbs[j]) { | ||
703 | usb_free_urb(portdata->in_urbs[j]); | ||
704 | portdata->in_urbs[j] = NULL; | ||
705 | } | ||
706 | } | ||
707 | for (j = 0; j < N_OUT_URB; j++) { | ||
708 | if (portdata->out_urbs[j]) { | ||
709 | usb_free_urb(portdata->out_urbs[j]); | ||
710 | portdata->out_urbs[j] = NULL; | ||
711 | } | ||
712 | } | ||
713 | } | ||
714 | |||
715 | /* Now free per port private data */ | ||
716 | for (i = 0; i < serial->num_ports; i++) { | ||
717 | port = serial->port[i]; | ||
718 | kfree(usb_get_serial_port_data(port)); | ||
719 | } | ||
720 | } | ||
721 | |||
722 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
723 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
724 | MODULE_VERSION(DRIVER_VERSION); | ||
725 | MODULE_LICENSE("GPL"); | ||
726 | |||
727 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
728 | MODULE_PARM_DESC(debug, "Debug messages"); | ||
729 | |||
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 4536f63faaea..5da76dd8fb28 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -1297,13 +1297,6 @@ static int __init usb_serial_init(void) | |||
1297 | goto exit_bus; | 1297 | goto exit_bus; |
1298 | } | 1298 | } |
1299 | 1299 | ||
1300 | /* register the generic driver, if we should */ | ||
1301 | result = usb_serial_generic_register(debug); | ||
1302 | if (result < 0) { | ||
1303 | err("%s - registering generic driver failed", __FUNCTION__); | ||
1304 | goto exit_generic; | ||
1305 | } | ||
1306 | |||
1307 | usb_serial_tty_driver->owner = THIS_MODULE; | 1300 | usb_serial_tty_driver->owner = THIS_MODULE; |
1308 | usb_serial_tty_driver->driver_name = "usbserial"; | 1301 | usb_serial_tty_driver->driver_name = "usbserial"; |
1309 | usb_serial_tty_driver->devfs_name = "usb/tts/"; | 1302 | usb_serial_tty_driver->devfs_name = "usb/tts/"; |
@@ -1329,17 +1322,24 @@ static int __init usb_serial_init(void) | |||
1329 | goto exit_tty; | 1322 | goto exit_tty; |
1330 | } | 1323 | } |
1331 | 1324 | ||
1325 | /* register the generic driver, if we should */ | ||
1326 | result = usb_serial_generic_register(debug); | ||
1327 | if (result < 0) { | ||
1328 | err("%s - registering generic driver failed", __FUNCTION__); | ||
1329 | goto exit_generic; | ||
1330 | } | ||
1331 | |||
1332 | info(DRIVER_DESC " " DRIVER_VERSION); | 1332 | info(DRIVER_DESC " " DRIVER_VERSION); |
1333 | 1333 | ||
1334 | return result; | 1334 | return result; |
1335 | 1335 | ||
1336 | exit_generic: | ||
1337 | usb_deregister(&usb_serial_driver); | ||
1338 | |||
1336 | exit_tty: | 1339 | exit_tty: |
1337 | tty_unregister_driver(usb_serial_tty_driver); | 1340 | tty_unregister_driver(usb_serial_tty_driver); |
1338 | 1341 | ||
1339 | exit_reg_driver: | 1342 | exit_reg_driver: |
1340 | usb_serial_generic_deregister(); | ||
1341 | |||
1342 | exit_generic: | ||
1343 | bus_unregister(&usb_serial_bus_type); | 1343 | bus_unregister(&usb_serial_bus_type); |
1344 | 1344 | ||
1345 | exit_bus: | 1345 | exit_bus: |
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index d2891f475793..9fcc7bd1fbe4 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
@@ -862,6 +862,15 @@ UNUSUAL_DEV( 0x090a, 0x1001, 0x0100, 0x0100, | |||
862 | US_SC_DEVICE, US_PR_BULK, NULL, | 862 | US_SC_DEVICE, US_PR_BULK, NULL, |
863 | US_FL_NEED_OVERRIDE ), | 863 | US_FL_NEED_OVERRIDE ), |
864 | 864 | ||
865 | /* Reported by Filippo Bardelli <filibard@libero.it> | ||
866 | * The device reports a subclass of RBC, which is wrong. | ||
867 | */ | ||
868 | UNUSUAL_DEV( 0x090a, 0x1050, 0x0100, 0x0100, | ||
869 | "Trumpion Microelectronics, Inc.", | ||
870 | "33520 USB Digital Voice Recorder", | ||
871 | US_SC_UFI, US_PR_DEVICE, NULL, | ||
872 | 0), | ||
873 | |||
865 | /* Trumpion Microelectronics MP3 player (felipe_alfaro@linuxmail.org) */ | 874 | /* Trumpion Microelectronics MP3 player (felipe_alfaro@linuxmail.org) */ |
866 | UNUSUAL_DEV( 0x090a, 0x1200, 0x0000, 0x9999, | 875 | UNUSUAL_DEV( 0x090a, 0x1200, 0x0000, 0x9999, |
867 | "Trumpion", | 876 | "Trumpion", |
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index f0cd67d9d31b..c8998dc66882 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c | |||
@@ -520,7 +520,7 @@ static int load_flat_file(struct linux_binprm * bprm, | |||
520 | DBG_FLT("BINFMT_FLAT: ROM mapping of file (we hope)\n"); | 520 | DBG_FLT("BINFMT_FLAT: ROM mapping of file (we hope)\n"); |
521 | 521 | ||
522 | down_write(¤t->mm->mmap_sem); | 522 | down_write(¤t->mm->mmap_sem); |
523 | textpos = do_mmap(bprm->file, 0, text_len, PROT_READ|PROT_EXEC, 0, 0); | 523 | textpos = do_mmap(bprm->file, 0, text_len, PROT_READ|PROT_EXEC, MAP_SHARED, 0); |
524 | up_write(¤t->mm->mmap_sem); | 524 | up_write(¤t->mm->mmap_sem); |
525 | if (!textpos || textpos >= (unsigned long) -4096) { | 525 | if (!textpos || textpos >= (unsigned long) -4096) { |
526 | if (!textpos) | 526 | if (!textpos) |
@@ -532,7 +532,7 @@ static int load_flat_file(struct linux_binprm * bprm, | |||
532 | down_write(¤t->mm->mmap_sem); | 532 | down_write(¤t->mm->mmap_sem); |
533 | realdatastart = do_mmap(0, 0, data_len + extra + | 533 | realdatastart = do_mmap(0, 0, data_len + extra + |
534 | MAX_SHARED_LIBS * sizeof(unsigned long), | 534 | MAX_SHARED_LIBS * sizeof(unsigned long), |
535 | PROT_READ|PROT_WRITE|PROT_EXEC, 0, 0); | 535 | PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 0); |
536 | up_write(¤t->mm->mmap_sem); | 536 | up_write(¤t->mm->mmap_sem); |
537 | 537 | ||
538 | if (realdatastart == 0 || realdatastart >= (unsigned long)-4096) { | 538 | if (realdatastart == 0 || realdatastart >= (unsigned long)-4096) { |
@@ -574,7 +574,7 @@ static int load_flat_file(struct linux_binprm * bprm, | |||
574 | down_write(¤t->mm->mmap_sem); | 574 | down_write(¤t->mm->mmap_sem); |
575 | textpos = do_mmap(0, 0, text_len + data_len + extra + | 575 | textpos = do_mmap(0, 0, text_len + data_len + extra + |
576 | MAX_SHARED_LIBS * sizeof(unsigned long), | 576 | MAX_SHARED_LIBS * sizeof(unsigned long), |
577 | PROT_READ | PROT_EXEC | PROT_WRITE, 0, 0); | 577 | PROT_READ | PROT_EXEC | PROT_WRITE, MAP_PRIVATE, 0); |
578 | up_write(¤t->mm->mmap_sem); | 578 | up_write(¤t->mm->mmap_sem); |
579 | if (!textpos || textpos >= (unsigned long) -4096) { | 579 | if (!textpos || textpos >= (unsigned long) -4096) { |
580 | if (!textpos) | 580 | if (!textpos) |
diff --git a/fs/cifs/README b/fs/cifs/README index e74df0c73256..34b0cf7111f3 100644 --- a/fs/cifs/README +++ b/fs/cifs/README | |||
@@ -371,7 +371,7 @@ A partial list of the supported mount options follows: | |||
371 | on newly created files, directories, and devices (create, | 371 | on newly created files, directories, and devices (create, |
372 | mkdir, mknod) which will result in the server setting the | 372 | mkdir, mknod) which will result in the server setting the |
373 | uid and gid to the default (usually the server uid of the | 373 | uid and gid to the default (usually the server uid of the |
374 | usern who mounted the share). Letting the server (rather than | 374 | user who mounted the share). Letting the server (rather than |
375 | the client) set the uid and gid is the default. This | 375 | the client) set the uid and gid is the default. This |
376 | parameter has no effect if the CIFS Unix Extensions are not | 376 | parameter has no effect if the CIFS Unix Extensions are not |
377 | negotiated. | 377 | negotiated. |
@@ -384,7 +384,7 @@ A partial list of the supported mount options follows: | |||
384 | client (e.g. when the application is doing large sequential | 384 | client (e.g. when the application is doing large sequential |
385 | reads bigger than page size without rereading the same data) | 385 | reads bigger than page size without rereading the same data) |
386 | this can provide better performance than the default | 386 | this can provide better performance than the default |
387 | behavior which caches reads (reaadahead) and writes | 387 | behavior which caches reads (readahead) and writes |
388 | (writebehind) through the local Linux client pagecache | 388 | (writebehind) through the local Linux client pagecache |
389 | if oplock (caching token) is granted and held. Note that | 389 | if oplock (caching token) is granted and held. Note that |
390 | direct allows write operations larger than page size | 390 | direct allows write operations larger than page size |
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 0010511083fc..ea239dea571e 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h | |||
@@ -228,7 +228,7 @@ extern int CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon, | |||
228 | const struct nls_table *nls_codepage, | 228 | const struct nls_table *nls_codepage, |
229 | int remap_special_chars); | 229 | int remap_special_chars); |
230 | #endif /* CONFIG_CIFS_EXPERIMENTAL */ | 230 | #endif /* CONFIG_CIFS_EXPERIMENTAL */ |
231 | extern int cifs_convertUCSpath(char *target, const __u16 *source, int maxlen, | 231 | extern int cifs_convertUCSpath(char *target, const __le16 *source, int maxlen, |
232 | const struct nls_table * codepage); | 232 | const struct nls_table * codepage); |
233 | extern int cifsConvertToUCS(__le16 * target, const char *source, int maxlen, | 233 | extern int cifsConvertToUCS(__le16 * target, const char *source, int maxlen, |
234 | const struct nls_table * cp, int mapChars); | 234 | const struct nls_table * cp, int mapChars); |
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 741ff0c69f37..3c628bf667a5 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -567,7 +567,7 @@ DelFileRetry: | |||
567 | 567 | ||
568 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 568 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
569 | name_len = | 569 | name_len = |
570 | cifsConvertToUCS((__u16 *) pSMB->fileName, fileName, | 570 | cifsConvertToUCS((__le16 *) pSMB->fileName, fileName, |
571 | PATH_MAX, nls_codepage, remap); | 571 | PATH_MAX, nls_codepage, remap); |
572 | name_len++; /* trailing null */ | 572 | name_len++; /* trailing null */ |
573 | name_len *= 2; | 573 | name_len *= 2; |
@@ -665,7 +665,7 @@ MkDirRetry: | |||
665 | return rc; | 665 | return rc; |
666 | 666 | ||
667 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 667 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
668 | name_len = cifsConvertToUCS((__u16 *) pSMB->DirName, name, | 668 | name_len = cifsConvertToUCS((__le16 *) pSMB->DirName, name, |
669 | PATH_MAX, nls_codepage, remap); | 669 | PATH_MAX, nls_codepage, remap); |
670 | name_len++; /* trailing null */ | 670 | name_len++; /* trailing null */ |
671 | name_len *= 2; | 671 | name_len *= 2; |
@@ -719,7 +719,7 @@ openRetry: | |||
719 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 719 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
720 | count = 1; /* account for one byte pad to word boundary */ | 720 | count = 1; /* account for one byte pad to word boundary */ |
721 | name_len = | 721 | name_len = |
722 | cifsConvertToUCS((__u16 *) (pSMB->fileName + 1), | 722 | cifsConvertToUCS((__le16 *) (pSMB->fileName + 1), |
723 | fileName, PATH_MAX, nls_codepage, remap); | 723 | fileName, PATH_MAX, nls_codepage, remap); |
724 | name_len++; /* trailing null */ | 724 | name_len++; /* trailing null */ |
725 | name_len *= 2; | 725 | name_len *= 2; |
@@ -1141,7 +1141,7 @@ renameRetry: | |||
1141 | 1141 | ||
1142 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 1142 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
1143 | name_len = | 1143 | name_len = |
1144 | cifsConvertToUCS((__u16 *) pSMB->OldFileName, fromName, | 1144 | cifsConvertToUCS((__le16 *) pSMB->OldFileName, fromName, |
1145 | PATH_MAX, nls_codepage, remap); | 1145 | PATH_MAX, nls_codepage, remap); |
1146 | name_len++; /* trailing null */ | 1146 | name_len++; /* trailing null */ |
1147 | name_len *= 2; | 1147 | name_len *= 2; |
@@ -1149,7 +1149,7 @@ renameRetry: | |||
1149 | /* protocol requires ASCII signature byte on Unicode string */ | 1149 | /* protocol requires ASCII signature byte on Unicode string */ |
1150 | pSMB->OldFileName[name_len + 1] = 0x00; | 1150 | pSMB->OldFileName[name_len + 1] = 0x00; |
1151 | name_len2 = | 1151 | name_len2 = |
1152 | cifsConvertToUCS((__u16 *) &pSMB->OldFileName[name_len + 2], | 1152 | cifsConvertToUCS((__le16 *) &pSMB->OldFileName[name_len + 2], |
1153 | toName, PATH_MAX, nls_codepage, remap); | 1153 | toName, PATH_MAX, nls_codepage, remap); |
1154 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; | 1154 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; |
1155 | name_len2 *= 2; /* convert to bytes */ | 1155 | name_len2 *= 2; /* convert to bytes */ |
@@ -1236,10 +1236,10 @@ int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon, | |||
1236 | /* unicode only call */ | 1236 | /* unicode only call */ |
1237 | if(target_name == NULL) { | 1237 | if(target_name == NULL) { |
1238 | sprintf(dummy_string,"cifs%x",pSMB->hdr.Mid); | 1238 | sprintf(dummy_string,"cifs%x",pSMB->hdr.Mid); |
1239 | len_of_str = cifsConvertToUCS((__u16 *)rename_info->target_name, | 1239 | len_of_str = cifsConvertToUCS((__le16 *)rename_info->target_name, |
1240 | dummy_string, 24, nls_codepage, remap); | 1240 | dummy_string, 24, nls_codepage, remap); |
1241 | } else { | 1241 | } else { |
1242 | len_of_str = cifsConvertToUCS((__u16 *)rename_info->target_name, | 1242 | len_of_str = cifsConvertToUCS((__le16 *)rename_info->target_name, |
1243 | target_name, PATH_MAX, nls_codepage, remap); | 1243 | target_name, PATH_MAX, nls_codepage, remap); |
1244 | } | 1244 | } |
1245 | rename_info->target_name_len = cpu_to_le32(2 * len_of_str); | 1245 | rename_info->target_name_len = cpu_to_le32(2 * len_of_str); |
@@ -1296,7 +1296,7 @@ copyRetry: | |||
1296 | pSMB->Flags = cpu_to_le16(flags & COPY_TREE); | 1296 | pSMB->Flags = cpu_to_le16(flags & COPY_TREE); |
1297 | 1297 | ||
1298 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 1298 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
1299 | name_len = cifsConvertToUCS((__u16 *) pSMB->OldFileName, | 1299 | name_len = cifsConvertToUCS((__le16 *) pSMB->OldFileName, |
1300 | fromName, PATH_MAX, nls_codepage, | 1300 | fromName, PATH_MAX, nls_codepage, |
1301 | remap); | 1301 | remap); |
1302 | name_len++; /* trailing null */ | 1302 | name_len++; /* trailing null */ |
@@ -1304,7 +1304,7 @@ copyRetry: | |||
1304 | pSMB->OldFileName[name_len] = 0x04; /* pad */ | 1304 | pSMB->OldFileName[name_len] = 0x04; /* pad */ |
1305 | /* protocol requires ASCII signature byte on Unicode string */ | 1305 | /* protocol requires ASCII signature byte on Unicode string */ |
1306 | pSMB->OldFileName[name_len + 1] = 0x00; | 1306 | pSMB->OldFileName[name_len + 1] = 0x00; |
1307 | name_len2 = cifsConvertToUCS((__u16 *)&pSMB->OldFileName[name_len + 2], | 1307 | name_len2 = cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2], |
1308 | toName, PATH_MAX, nls_codepage, remap); | 1308 | toName, PATH_MAX, nls_codepage, remap); |
1309 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; | 1309 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; |
1310 | name_len2 *= 2; /* convert to bytes */ | 1310 | name_len2 *= 2; /* convert to bytes */ |
@@ -1453,7 +1453,7 @@ createHardLinkRetry: | |||
1453 | return rc; | 1453 | return rc; |
1454 | 1454 | ||
1455 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 1455 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
1456 | name_len = cifsConvertToUCS((__u16 *) pSMB->FileName, toName, | 1456 | name_len = cifsConvertToUCS((__le16 *) pSMB->FileName, toName, |
1457 | PATH_MAX, nls_codepage, remap); | 1457 | PATH_MAX, nls_codepage, remap); |
1458 | name_len++; /* trailing null */ | 1458 | name_len++; /* trailing null */ |
1459 | name_len *= 2; | 1459 | name_len *= 2; |
@@ -1476,7 +1476,7 @@ createHardLinkRetry: | |||
1476 | data_offset = (char *) (&pSMB->hdr.Protocol) + offset; | 1476 | data_offset = (char *) (&pSMB->hdr.Protocol) + offset; |
1477 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 1477 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
1478 | name_len_target = | 1478 | name_len_target = |
1479 | cifsConvertToUCS((__u16 *) data_offset, fromName, PATH_MAX, | 1479 | cifsConvertToUCS((__le16 *) data_offset, fromName, PATH_MAX, |
1480 | nls_codepage, remap); | 1480 | nls_codepage, remap); |
1481 | name_len_target++; /* trailing null */ | 1481 | name_len_target++; /* trailing null */ |
1482 | name_len_target *= 2; | 1482 | name_len_target *= 2; |
@@ -1546,14 +1546,14 @@ winCreateHardLinkRetry: | |||
1546 | 1546 | ||
1547 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 1547 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
1548 | name_len = | 1548 | name_len = |
1549 | cifsConvertToUCS((__u16 *) pSMB->OldFileName, fromName, | 1549 | cifsConvertToUCS((__le16 *) pSMB->OldFileName, fromName, |
1550 | PATH_MAX, nls_codepage, remap); | 1550 | PATH_MAX, nls_codepage, remap); |
1551 | name_len++; /* trailing null */ | 1551 | name_len++; /* trailing null */ |
1552 | name_len *= 2; | 1552 | name_len *= 2; |
1553 | pSMB->OldFileName[name_len] = 0; /* pad */ | 1553 | pSMB->OldFileName[name_len] = 0; /* pad */ |
1554 | pSMB->OldFileName[name_len + 1] = 0x04; | 1554 | pSMB->OldFileName[name_len + 1] = 0x04; |
1555 | name_len2 = | 1555 | name_len2 = |
1556 | cifsConvertToUCS((__u16 *)&pSMB->OldFileName[name_len + 2], | 1556 | cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2], |
1557 | toName, PATH_MAX, nls_codepage, remap); | 1557 | toName, PATH_MAX, nls_codepage, remap); |
1558 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; | 1558 | name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ; |
1559 | name_len2 *= 2; /* convert to bytes */ | 1559 | name_len2 *= 2; /* convert to bytes */ |
@@ -1939,7 +1939,7 @@ queryAclRetry: | |||
1939 | 1939 | ||
1940 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 1940 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
1941 | name_len = | 1941 | name_len = |
1942 | cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, | 1942 | cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, |
1943 | PATH_MAX, nls_codepage, remap); | 1943 | PATH_MAX, nls_codepage, remap); |
1944 | name_len++; /* trailing null */ | 1944 | name_len++; /* trailing null */ |
1945 | name_len *= 2; | 1945 | name_len *= 2; |
@@ -2024,7 +2024,7 @@ setAclRetry: | |||
2024 | return rc; | 2024 | return rc; |
2025 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2025 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2026 | name_len = | 2026 | name_len = |
2027 | cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, | 2027 | cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, |
2028 | PATH_MAX, nls_codepage, remap); | 2028 | PATH_MAX, nls_codepage, remap); |
2029 | name_len++; /* trailing null */ | 2029 | name_len++; /* trailing null */ |
2030 | name_len *= 2; | 2030 | name_len *= 2; |
@@ -2188,7 +2188,7 @@ QPathInfoRetry: | |||
2188 | 2188 | ||
2189 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2189 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2190 | name_len = | 2190 | name_len = |
2191 | cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, | 2191 | cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, |
2192 | PATH_MAX, nls_codepage, remap); | 2192 | PATH_MAX, nls_codepage, remap); |
2193 | name_len++; /* trailing null */ | 2193 | name_len++; /* trailing null */ |
2194 | name_len *= 2; | 2194 | name_len *= 2; |
@@ -2269,7 +2269,7 @@ UnixQPathInfoRetry: | |||
2269 | 2269 | ||
2270 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2270 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2271 | name_len = | 2271 | name_len = |
2272 | cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, | 2272 | cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, |
2273 | PATH_MAX, nls_codepage, remap); | 2273 | PATH_MAX, nls_codepage, remap); |
2274 | name_len++; /* trailing null */ | 2274 | name_len++; /* trailing null */ |
2275 | name_len *= 2; | 2275 | name_len *= 2; |
@@ -2350,7 +2350,7 @@ findUniqueRetry: | |||
2350 | 2350 | ||
2351 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2351 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2352 | name_len = | 2352 | name_len = |
2353 | cifsConvertToUCS((wchar_t *) pSMB->FileName, searchName, PATH_MAX | 2353 | cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, PATH_MAX |
2354 | /* find define for this maxpathcomponent */ | 2354 | /* find define for this maxpathcomponent */ |
2355 | , nls_codepage); | 2355 | , nls_codepage); |
2356 | name_len++; /* trailing null */ | 2356 | name_len++; /* trailing null */ |
@@ -2435,7 +2435,7 @@ findFirstRetry: | |||
2435 | 2435 | ||
2436 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2436 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2437 | name_len = | 2437 | name_len = |
2438 | cifsConvertToUCS((__u16 *) pSMB->FileName,searchName, | 2438 | cifsConvertToUCS((__le16 *) pSMB->FileName,searchName, |
2439 | PATH_MAX, nls_codepage, remap); | 2439 | PATH_MAX, nls_codepage, remap); |
2440 | /* We can not add the asterik earlier in case | 2440 | /* We can not add the asterik earlier in case |
2441 | it got remapped to 0xF03A as if it were part of the | 2441 | it got remapped to 0xF03A as if it were part of the |
@@ -2726,7 +2726,7 @@ GetInodeNumberRetry: | |||
2726 | 2726 | ||
2727 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 2727 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
2728 | name_len = | 2728 | name_len = |
2729 | cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, | 2729 | cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, |
2730 | PATH_MAX,nls_codepage, remap); | 2730 | PATH_MAX,nls_codepage, remap); |
2731 | name_len++; /* trailing null */ | 2731 | name_len++; /* trailing null */ |
2732 | name_len *= 2; | 2732 | name_len *= 2; |
@@ -2837,7 +2837,7 @@ getDFSRetry: | |||
2837 | if (ses->capabilities & CAP_UNICODE) { | 2837 | if (ses->capabilities & CAP_UNICODE) { |
2838 | pSMB->hdr.Flags2 |= SMBFLG2_UNICODE; | 2838 | pSMB->hdr.Flags2 |= SMBFLG2_UNICODE; |
2839 | name_len = | 2839 | name_len = |
2840 | cifsConvertToUCS((__u16 *) pSMB->RequestFileName, | 2840 | cifsConvertToUCS((__le16 *) pSMB->RequestFileName, |
2841 | searchName, PATH_MAX, nls_codepage, remap); | 2841 | searchName, PATH_MAX, nls_codepage, remap); |
2842 | name_len++; /* trailing null */ | 2842 | name_len++; /* trailing null */ |
2843 | name_len *= 2; | 2843 | name_len *= 2; |
@@ -3369,7 +3369,7 @@ SetEOFRetry: | |||
3369 | 3369 | ||
3370 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 3370 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
3371 | name_len = | 3371 | name_len = |
3372 | cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, | 3372 | cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, |
3373 | PATH_MAX, nls_codepage, remap); | 3373 | PATH_MAX, nls_codepage, remap); |
3374 | name_len++; /* trailing null */ | 3374 | name_len++; /* trailing null */ |
3375 | name_len *= 2; | 3375 | name_len *= 2; |
@@ -3627,7 +3627,7 @@ SetTimesRetry: | |||
3627 | 3627 | ||
3628 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 3628 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
3629 | name_len = | 3629 | name_len = |
3630 | cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, | 3630 | cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, |
3631 | PATH_MAX, nls_codepage, remap); | 3631 | PATH_MAX, nls_codepage, remap); |
3632 | name_len++; /* trailing null */ | 3632 | name_len++; /* trailing null */ |
3633 | name_len *= 2; | 3633 | name_len *= 2; |
@@ -3708,7 +3708,7 @@ SetAttrLgcyRetry: | |||
3708 | 3708 | ||
3709 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 3709 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
3710 | name_len = | 3710 | name_len = |
3711 | ConvertToUCS((wchar_t *) pSMB->fileName, fileName, | 3711 | ConvertToUCS((__le16 *) pSMB->fileName, fileName, |
3712 | PATH_MAX, nls_codepage); | 3712 | PATH_MAX, nls_codepage); |
3713 | name_len++; /* trailing null */ | 3713 | name_len++; /* trailing null */ |
3714 | name_len *= 2; | 3714 | name_len *= 2; |
@@ -3759,7 +3759,7 @@ setPermsRetry: | |||
3759 | 3759 | ||
3760 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 3760 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
3761 | name_len = | 3761 | name_len = |
3762 | cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, | 3762 | cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, |
3763 | PATH_MAX, nls_codepage, remap); | 3763 | PATH_MAX, nls_codepage, remap); |
3764 | name_len++; /* trailing null */ | 3764 | name_len++; /* trailing null */ |
3765 | name_len *= 2; | 3765 | name_len *= 2; |
@@ -3904,7 +3904,7 @@ QAllEAsRetry: | |||
3904 | 3904 | ||
3905 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 3905 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
3906 | name_len = | 3906 | name_len = |
3907 | cifsConvertToUCS((wchar_t *) pSMB->FileName, searchName, | 3907 | cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, |
3908 | PATH_MAX, nls_codepage, remap); | 3908 | PATH_MAX, nls_codepage, remap); |
3909 | name_len++; /* trailing null */ | 3909 | name_len++; /* trailing null */ |
3910 | name_len *= 2; | 3910 | name_len *= 2; |
@@ -4047,7 +4047,7 @@ QEARetry: | |||
4047 | 4047 | ||
4048 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 4048 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
4049 | name_len = | 4049 | name_len = |
4050 | cifsConvertToUCS((__u16 *) pSMB->FileName, searchName, | 4050 | cifsConvertToUCS((__le16 *) pSMB->FileName, searchName, |
4051 | PATH_MAX, nls_codepage, remap); | 4051 | PATH_MAX, nls_codepage, remap); |
4052 | name_len++; /* trailing null */ | 4052 | name_len++; /* trailing null */ |
4053 | name_len *= 2; | 4053 | name_len *= 2; |
@@ -4194,7 +4194,7 @@ SetEARetry: | |||
4194 | 4194 | ||
4195 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { | 4195 | if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) { |
4196 | name_len = | 4196 | name_len = |
4197 | cifsConvertToUCS((__u16 *) pSMB->FileName, fileName, | 4197 | cifsConvertToUCS((__le16 *) pSMB->FileName, fileName, |
4198 | PATH_MAX, nls_codepage, remap); | 4198 | PATH_MAX, nls_codepage, remap); |
4199 | name_len++; /* trailing null */ | 4199 | name_len++; /* trailing null */ |
4200 | name_len *= 2; | 4200 | name_len *= 2; |
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index e3137aa48cdd..3f3538d4a1fa 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c | |||
@@ -392,7 +392,8 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct name | |||
392 | rc = 0; | 392 | rc = 0; |
393 | d_add(direntry, NULL); | 393 | d_add(direntry, NULL); |
394 | } else { | 394 | } else { |
395 | cERROR(1,("Error 0x%x or on cifs_get_inode_info in lookup",rc)); | 395 | cERROR(1,("Error 0x%x on cifs_get_inode_info in lookup of %s", |
396 | rc,full_path)); | ||
396 | /* BB special case check for Access Denied - watch security | 397 | /* BB special case check for Access Denied - watch security |
397 | exposure of returning dir info implicitly via different rc | 398 | exposure of returning dir info implicitly via different rc |
398 | if file exists or not but no access BB */ | 399 | if file exists or not but no access BB */ |
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 670947288262..b8b78cbb34c9 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -422,7 +422,8 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
422 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 422 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); |
423 | 423 | ||
424 | if (!rc) { | 424 | if (!rc) { |
425 | direntry->d_inode->i_nlink--; | 425 | if(direntry->d_inode) |
426 | direntry->d_inode->i_nlink--; | ||
426 | } else if (rc == -ENOENT) { | 427 | } else if (rc == -ENOENT) { |
427 | d_drop(direntry); | 428 | d_drop(direntry); |
428 | } else if (rc == -ETXTBSY) { | 429 | } else if (rc == -ETXTBSY) { |
@@ -440,7 +441,8 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
440 | cifs_sb->mnt_cifs_flags & | 441 | cifs_sb->mnt_cifs_flags & |
441 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 442 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
442 | CIFSSMBClose(xid, pTcon, netfid); | 443 | CIFSSMBClose(xid, pTcon, netfid); |
443 | direntry->d_inode->i_nlink--; | 444 | if(direntry->d_inode) |
445 | direntry->d_inode->i_nlink--; | ||
444 | } | 446 | } |
445 | } else if (rc == -EACCES) { | 447 | } else if (rc == -EACCES) { |
446 | /* try only if r/o attribute set in local lookup data? */ | 448 | /* try only if r/o attribute set in local lookup data? */ |
@@ -494,7 +496,8 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
494 | cifs_sb->mnt_cifs_flags & | 496 | cifs_sb->mnt_cifs_flags & |
495 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 497 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
496 | if (!rc) { | 498 | if (!rc) { |
497 | direntry->d_inode->i_nlink--; | 499 | if(direntry->d_inode) |
500 | direntry->d_inode->i_nlink--; | ||
498 | } else if (rc == -ETXTBSY) { | 501 | } else if (rc == -ETXTBSY) { |
499 | int oplock = FALSE; | 502 | int oplock = FALSE; |
500 | __u16 netfid; | 503 | __u16 netfid; |
@@ -514,17 +517,20 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
514 | cifs_sb->mnt_cifs_flags & | 517 | cifs_sb->mnt_cifs_flags & |
515 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 518 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
516 | CIFSSMBClose(xid, pTcon, netfid); | 519 | CIFSSMBClose(xid, pTcon, netfid); |
517 | direntry->d_inode->i_nlink--; | 520 | if(direntry->d_inode) |
521 | direntry->d_inode->i_nlink--; | ||
518 | } | 522 | } |
519 | /* BB if rc = -ETXTBUSY goto the rename logic BB */ | 523 | /* BB if rc = -ETXTBUSY goto the rename logic BB */ |
520 | } | 524 | } |
521 | } | 525 | } |
522 | } | 526 | } |
523 | cifsInode = CIFS_I(direntry->d_inode); | 527 | if(direntry->d_inode) { |
524 | cifsInode->time = 0; /* will force revalidate to get info when | 528 | cifsInode = CIFS_I(direntry->d_inode); |
525 | needed */ | 529 | cifsInode->time = 0; /* will force revalidate to get info |
526 | direntry->d_inode->i_ctime = inode->i_ctime = inode->i_mtime = | 530 | when needed */ |
527 | current_fs_time(inode->i_sb); | 531 | direntry->d_inode->i_ctime = current_fs_time(inode->i_sb); |
532 | } | ||
533 | inode->i_ctime = inode->i_mtime = current_fs_time(inode->i_sb); | ||
528 | cifsInode = CIFS_I(inode); | 534 | cifsInode = CIFS_I(inode); |
529 | cifsInode->time = 0; /* force revalidate of dir as well */ | 535 | cifsInode->time = 0; /* force revalidate of dir as well */ |
530 | 536 | ||
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index db14b503d89e..072b4ee8c53e 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c | |||
@@ -571,6 +571,7 @@ cifs_convertUCSpath(char *target, const __le16 * source, int maxlen, | |||
571 | break; | 571 | break; |
572 | case UNI_LESSTHAN: | 572 | case UNI_LESSTHAN: |
573 | target[j] = '<'; | 573 | target[j] = '<'; |
574 | break; | ||
574 | default: | 575 | default: |
575 | len = cp->uni2char(src_char, &target[j], | 576 | len = cp->uni2char(src_char, &target[j], |
576 | NLS_MAX_CHARSET_SIZE); | 577 | NLS_MAX_CHARSET_SIZE); |
diff --git a/fs/jbd/checkpoint.c b/fs/jbd/checkpoint.c index 98d830401c56..5a97e346bd95 100644 --- a/fs/jbd/checkpoint.c +++ b/fs/jbd/checkpoint.c | |||
@@ -188,7 +188,6 @@ static int __cleanup_transaction(journal_t *journal, transaction_t *transaction) | |||
188 | } else { | 188 | } else { |
189 | jbd_unlock_bh_state(bh); | 189 | jbd_unlock_bh_state(bh); |
190 | } | 190 | } |
191 | jh = next_jh; | ||
192 | } while (jh != last_jh); | 191 | } while (jh != last_jh); |
193 | 192 | ||
194 | return ret; | 193 | return ret; |
@@ -339,8 +338,10 @@ int log_do_checkpoint(journal_t *journal) | |||
339 | } | 338 | } |
340 | } while (jh != last_jh && !retry); | 339 | } while (jh != last_jh && !retry); |
341 | 340 | ||
342 | if (batch_count) | 341 | if (batch_count) { |
343 | __flush_batch(journal, bhs, &batch_count); | 342 | __flush_batch(journal, bhs, &batch_count); |
343 | retry = 1; | ||
344 | } | ||
344 | 345 | ||
345 | /* | 346 | /* |
346 | * If someone cleaned up this transaction while we slept, we're | 347 | * If someone cleaned up this transaction while we slept, we're |
diff --git a/fs/mpage.c b/fs/mpage.c index b92c0e64aefa..bb9aebe93862 100644 --- a/fs/mpage.c +++ b/fs/mpage.c | |||
@@ -79,8 +79,11 @@ static int mpage_end_io_write(struct bio *bio, unsigned int bytes_done, int err) | |||
79 | if (--bvec >= bio->bi_io_vec) | 79 | if (--bvec >= bio->bi_io_vec) |
80 | prefetchw(&bvec->bv_page->flags); | 80 | prefetchw(&bvec->bv_page->flags); |
81 | 81 | ||
82 | if (!uptodate) | 82 | if (!uptodate){ |
83 | SetPageError(page); | 83 | SetPageError(page); |
84 | if (page->mapping) | ||
85 | set_bit(AS_EIO, &page->mapping->flags); | ||
86 | } | ||
84 | end_page_writeback(page); | 87 | end_page_writeback(page); |
85 | } while (bvec >= bio->bi_io_vec); | 88 | } while (bvec >= bio->bi_io_vec); |
86 | bio_put(bio); | 89 | bio_put(bio); |
diff --git a/fs/namei.c b/fs/namei.c index dd78f01b6de8..a7f7f44119b3 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -493,12 +493,21 @@ fail: | |||
493 | return PTR_ERR(link); | 493 | return PTR_ERR(link); |
494 | } | 494 | } |
495 | 495 | ||
496 | static inline int __do_follow_link(struct dentry *dentry, struct nameidata *nd) | 496 | struct path { |
497 | struct vfsmount *mnt; | ||
498 | struct dentry *dentry; | ||
499 | }; | ||
500 | |||
501 | static inline int __do_follow_link(struct path *path, struct nameidata *nd) | ||
497 | { | 502 | { |
498 | int error; | 503 | int error; |
504 | struct dentry *dentry = path->dentry; | ||
499 | 505 | ||
500 | touch_atime(nd->mnt, dentry); | 506 | touch_atime(path->mnt, dentry); |
501 | nd_set_link(nd, NULL); | 507 | nd_set_link(nd, NULL); |
508 | |||
509 | if (path->mnt == nd->mnt) | ||
510 | mntget(path->mnt); | ||
502 | error = dentry->d_inode->i_op->follow_link(dentry, nd); | 511 | error = dentry->d_inode->i_op->follow_link(dentry, nd); |
503 | if (!error) { | 512 | if (!error) { |
504 | char *s = nd_get_link(nd); | 513 | char *s = nd_get_link(nd); |
@@ -507,6 +516,8 @@ static inline int __do_follow_link(struct dentry *dentry, struct nameidata *nd) | |||
507 | if (dentry->d_inode->i_op->put_link) | 516 | if (dentry->d_inode->i_op->put_link) |
508 | dentry->d_inode->i_op->put_link(dentry, nd); | 517 | dentry->d_inode->i_op->put_link(dentry, nd); |
509 | } | 518 | } |
519 | dput(dentry); | ||
520 | mntput(path->mnt); | ||
510 | 521 | ||
511 | return error; | 522 | return error; |
512 | } | 523 | } |
@@ -518,7 +529,7 @@ static inline int __do_follow_link(struct dentry *dentry, struct nameidata *nd) | |||
518 | * Without that kind of total limit, nasty chains of consecutive | 529 | * Without that kind of total limit, nasty chains of consecutive |
519 | * symlinks can cause almost arbitrarily long lookups. | 530 | * symlinks can cause almost arbitrarily long lookups. |
520 | */ | 531 | */ |
521 | static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd) | 532 | static inline int do_follow_link(struct path *path, struct nameidata *nd) |
522 | { | 533 | { |
523 | int err = -ELOOP; | 534 | int err = -ELOOP; |
524 | if (current->link_count >= MAX_NESTED_LINKS) | 535 | if (current->link_count >= MAX_NESTED_LINKS) |
@@ -527,17 +538,20 @@ static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd) | |||
527 | goto loop; | 538 | goto loop; |
528 | BUG_ON(nd->depth >= MAX_NESTED_LINKS); | 539 | BUG_ON(nd->depth >= MAX_NESTED_LINKS); |
529 | cond_resched(); | 540 | cond_resched(); |
530 | err = security_inode_follow_link(dentry, nd); | 541 | err = security_inode_follow_link(path->dentry, nd); |
531 | if (err) | 542 | if (err) |
532 | goto loop; | 543 | goto loop; |
533 | current->link_count++; | 544 | current->link_count++; |
534 | current->total_link_count++; | 545 | current->total_link_count++; |
535 | nd->depth++; | 546 | nd->depth++; |
536 | err = __do_follow_link(dentry, nd); | 547 | err = __do_follow_link(path, nd); |
537 | current->link_count--; | 548 | current->link_count--; |
538 | nd->depth--; | 549 | nd->depth--; |
539 | return err; | 550 | return err; |
540 | loop: | 551 | loop: |
552 | dput(path->dentry); | ||
553 | if (path->mnt != nd->mnt) | ||
554 | mntput(path->mnt); | ||
541 | path_release(nd); | 555 | path_release(nd); |
542 | return err; | 556 | return err; |
543 | } | 557 | } |
@@ -565,87 +579,91 @@ int follow_up(struct vfsmount **mnt, struct dentry **dentry) | |||
565 | /* no need for dcache_lock, as serialization is taken care in | 579 | /* no need for dcache_lock, as serialization is taken care in |
566 | * namespace.c | 580 | * namespace.c |
567 | */ | 581 | */ |
568 | static int follow_mount(struct vfsmount **mnt, struct dentry **dentry) | 582 | static int __follow_mount(struct path *path) |
569 | { | 583 | { |
570 | int res = 0; | 584 | int res = 0; |
585 | while (d_mountpoint(path->dentry)) { | ||
586 | struct vfsmount *mounted = lookup_mnt(path->mnt, path->dentry); | ||
587 | if (!mounted) | ||
588 | break; | ||
589 | dput(path->dentry); | ||
590 | if (res) | ||
591 | mntput(path->mnt); | ||
592 | path->mnt = mounted; | ||
593 | path->dentry = dget(mounted->mnt_root); | ||
594 | res = 1; | ||
595 | } | ||
596 | return res; | ||
597 | } | ||
598 | |||
599 | static void follow_mount(struct vfsmount **mnt, struct dentry **dentry) | ||
600 | { | ||
571 | while (d_mountpoint(*dentry)) { | 601 | while (d_mountpoint(*dentry)) { |
572 | struct vfsmount *mounted = lookup_mnt(*mnt, *dentry); | 602 | struct vfsmount *mounted = lookup_mnt(*mnt, *dentry); |
573 | if (!mounted) | 603 | if (!mounted) |
574 | break; | 604 | break; |
605 | dput(*dentry); | ||
575 | mntput(*mnt); | 606 | mntput(*mnt); |
576 | *mnt = mounted; | 607 | *mnt = mounted; |
577 | dput(*dentry); | ||
578 | *dentry = dget(mounted->mnt_root); | 608 | *dentry = dget(mounted->mnt_root); |
579 | res = 1; | ||
580 | } | 609 | } |
581 | return res; | ||
582 | } | 610 | } |
583 | 611 | ||
584 | /* no need for dcache_lock, as serialization is taken care in | 612 | /* no need for dcache_lock, as serialization is taken care in |
585 | * namespace.c | 613 | * namespace.c |
586 | */ | 614 | */ |
587 | static inline int __follow_down(struct vfsmount **mnt, struct dentry **dentry) | 615 | int follow_down(struct vfsmount **mnt, struct dentry **dentry) |
588 | { | 616 | { |
589 | struct vfsmount *mounted; | 617 | struct vfsmount *mounted; |
590 | 618 | ||
591 | mounted = lookup_mnt(*mnt, *dentry); | 619 | mounted = lookup_mnt(*mnt, *dentry); |
592 | if (mounted) { | 620 | if (mounted) { |
621 | dput(*dentry); | ||
593 | mntput(*mnt); | 622 | mntput(*mnt); |
594 | *mnt = mounted; | 623 | *mnt = mounted; |
595 | dput(*dentry); | ||
596 | *dentry = dget(mounted->mnt_root); | 624 | *dentry = dget(mounted->mnt_root); |
597 | return 1; | 625 | return 1; |
598 | } | 626 | } |
599 | return 0; | 627 | return 0; |
600 | } | 628 | } |
601 | 629 | ||
602 | int follow_down(struct vfsmount **mnt, struct dentry **dentry) | 630 | static inline void follow_dotdot(struct nameidata *nd) |
603 | { | ||
604 | return __follow_down(mnt,dentry); | ||
605 | } | ||
606 | |||
607 | static inline void follow_dotdot(struct vfsmount **mnt, struct dentry **dentry) | ||
608 | { | 631 | { |
609 | while(1) { | 632 | while(1) { |
610 | struct vfsmount *parent; | 633 | struct vfsmount *parent; |
611 | struct dentry *old = *dentry; | 634 | struct dentry *old = nd->dentry; |
612 | 635 | ||
613 | read_lock(¤t->fs->lock); | 636 | read_lock(¤t->fs->lock); |
614 | if (*dentry == current->fs->root && | 637 | if (nd->dentry == current->fs->root && |
615 | *mnt == current->fs->rootmnt) { | 638 | nd->mnt == current->fs->rootmnt) { |
616 | read_unlock(¤t->fs->lock); | 639 | read_unlock(¤t->fs->lock); |
617 | break; | 640 | break; |
618 | } | 641 | } |
619 | read_unlock(¤t->fs->lock); | 642 | read_unlock(¤t->fs->lock); |
620 | spin_lock(&dcache_lock); | 643 | spin_lock(&dcache_lock); |
621 | if (*dentry != (*mnt)->mnt_root) { | 644 | if (nd->dentry != nd->mnt->mnt_root) { |
622 | *dentry = dget((*dentry)->d_parent); | 645 | nd->dentry = dget(nd->dentry->d_parent); |
623 | spin_unlock(&dcache_lock); | 646 | spin_unlock(&dcache_lock); |
624 | dput(old); | 647 | dput(old); |
625 | break; | 648 | break; |
626 | } | 649 | } |
627 | spin_unlock(&dcache_lock); | 650 | spin_unlock(&dcache_lock); |
628 | spin_lock(&vfsmount_lock); | 651 | spin_lock(&vfsmount_lock); |
629 | parent = (*mnt)->mnt_parent; | 652 | parent = nd->mnt->mnt_parent; |
630 | if (parent == *mnt) { | 653 | if (parent == nd->mnt) { |
631 | spin_unlock(&vfsmount_lock); | 654 | spin_unlock(&vfsmount_lock); |
632 | break; | 655 | break; |
633 | } | 656 | } |
634 | mntget(parent); | 657 | mntget(parent); |
635 | *dentry = dget((*mnt)->mnt_mountpoint); | 658 | nd->dentry = dget(nd->mnt->mnt_mountpoint); |
636 | spin_unlock(&vfsmount_lock); | 659 | spin_unlock(&vfsmount_lock); |
637 | dput(old); | 660 | dput(old); |
638 | mntput(*mnt); | 661 | mntput(nd->mnt); |
639 | *mnt = parent; | 662 | nd->mnt = parent; |
640 | } | 663 | } |
641 | follow_mount(mnt, dentry); | 664 | follow_mount(&nd->mnt, &nd->dentry); |
642 | } | 665 | } |
643 | 666 | ||
644 | struct path { | ||
645 | struct vfsmount *mnt; | ||
646 | struct dentry *dentry; | ||
647 | }; | ||
648 | |||
649 | /* | 667 | /* |
650 | * It's more convoluted than I'd like it to be, but... it's still fairly | 668 | * It's more convoluted than I'd like it to be, but... it's still fairly |
651 | * small and for now I'd prefer to have fast path as straight as possible. | 669 | * small and for now I'd prefer to have fast path as straight as possible. |
@@ -664,6 +682,7 @@ static int do_lookup(struct nameidata *nd, struct qstr *name, | |||
664 | done: | 682 | done: |
665 | path->mnt = mnt; | 683 | path->mnt = mnt; |
666 | path->dentry = dentry; | 684 | path->dentry = dentry; |
685 | __follow_mount(path); | ||
667 | return 0; | 686 | return 0; |
668 | 687 | ||
669 | need_lookup: | 688 | need_lookup: |
@@ -751,7 +770,7 @@ static fastcall int __link_path_walk(const char * name, struct nameidata *nd) | |||
751 | case 2: | 770 | case 2: |
752 | if (this.name[1] != '.') | 771 | if (this.name[1] != '.') |
753 | break; | 772 | break; |
754 | follow_dotdot(&nd->mnt, &nd->dentry); | 773 | follow_dotdot(nd); |
755 | inode = nd->dentry->d_inode; | 774 | inode = nd->dentry->d_inode; |
756 | /* fallthrough */ | 775 | /* fallthrough */ |
757 | case 1: | 776 | case 1: |
@@ -771,8 +790,6 @@ static fastcall int __link_path_walk(const char * name, struct nameidata *nd) | |||
771 | err = do_lookup(nd, &this, &next); | 790 | err = do_lookup(nd, &this, &next); |
772 | if (err) | 791 | if (err) |
773 | break; | 792 | break; |
774 | /* Check mountpoints.. */ | ||
775 | follow_mount(&next.mnt, &next.dentry); | ||
776 | 793 | ||
777 | err = -ENOENT; | 794 | err = -ENOENT; |
778 | inode = next.dentry->d_inode; | 795 | inode = next.dentry->d_inode; |
@@ -783,10 +800,7 @@ static fastcall int __link_path_walk(const char * name, struct nameidata *nd) | |||
783 | goto out_dput; | 800 | goto out_dput; |
784 | 801 | ||
785 | if (inode->i_op->follow_link) { | 802 | if (inode->i_op->follow_link) { |
786 | mntget(next.mnt); | 803 | err = do_follow_link(&next, nd); |
787 | err = do_follow_link(next.dentry, nd); | ||
788 | dput(next.dentry); | ||
789 | mntput(next.mnt); | ||
790 | if (err) | 804 | if (err) |
791 | goto return_err; | 805 | goto return_err; |
792 | err = -ENOENT; | 806 | err = -ENOENT; |
@@ -798,6 +812,8 @@ static fastcall int __link_path_walk(const char * name, struct nameidata *nd) | |||
798 | break; | 812 | break; |
799 | } else { | 813 | } else { |
800 | dput(nd->dentry); | 814 | dput(nd->dentry); |
815 | if (nd->mnt != next.mnt) | ||
816 | mntput(nd->mnt); | ||
801 | nd->mnt = next.mnt; | 817 | nd->mnt = next.mnt; |
802 | nd->dentry = next.dentry; | 818 | nd->dentry = next.dentry; |
803 | } | 819 | } |
@@ -819,7 +835,7 @@ last_component: | |||
819 | case 2: | 835 | case 2: |
820 | if (this.name[1] != '.') | 836 | if (this.name[1] != '.') |
821 | break; | 837 | break; |
822 | follow_dotdot(&nd->mnt, &nd->dentry); | 838 | follow_dotdot(nd); |
823 | inode = nd->dentry->d_inode; | 839 | inode = nd->dentry->d_inode; |
824 | /* fallthrough */ | 840 | /* fallthrough */ |
825 | case 1: | 841 | case 1: |
@@ -833,19 +849,17 @@ last_component: | |||
833 | err = do_lookup(nd, &this, &next); | 849 | err = do_lookup(nd, &this, &next); |
834 | if (err) | 850 | if (err) |
835 | break; | 851 | break; |
836 | follow_mount(&next.mnt, &next.dentry); | ||
837 | inode = next.dentry->d_inode; | 852 | inode = next.dentry->d_inode; |
838 | if ((lookup_flags & LOOKUP_FOLLOW) | 853 | if ((lookup_flags & LOOKUP_FOLLOW) |
839 | && inode && inode->i_op && inode->i_op->follow_link) { | 854 | && inode && inode->i_op && inode->i_op->follow_link) { |
840 | mntget(next.mnt); | 855 | err = do_follow_link(&next, nd); |
841 | err = do_follow_link(next.dentry, nd); | ||
842 | dput(next.dentry); | ||
843 | mntput(next.mnt); | ||
844 | if (err) | 856 | if (err) |
845 | goto return_err; | 857 | goto return_err; |
846 | inode = nd->dentry->d_inode; | 858 | inode = nd->dentry->d_inode; |
847 | } else { | 859 | } else { |
848 | dput(nd->dentry); | 860 | dput(nd->dentry); |
861 | if (nd->mnt != next.mnt) | ||
862 | mntput(nd->mnt); | ||
849 | nd->mnt = next.mnt; | 863 | nd->mnt = next.mnt; |
850 | nd->dentry = next.dentry; | 864 | nd->dentry = next.dentry; |
851 | } | 865 | } |
@@ -885,6 +899,8 @@ return_base: | |||
885 | return 0; | 899 | return 0; |
886 | out_dput: | 900 | out_dput: |
887 | dput(next.dentry); | 901 | dput(next.dentry); |
902 | if (nd->mnt != next.mnt) | ||
903 | mntput(next.mnt); | ||
888 | break; | 904 | break; |
889 | } | 905 | } |
890 | path_release(nd); | 906 | path_release(nd); |
@@ -1398,7 +1414,7 @@ int may_open(struct nameidata *nd, int acc_mode, int flag) | |||
1398 | int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd) | 1414 | int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd) |
1399 | { | 1415 | { |
1400 | int acc_mode, error = 0; | 1416 | int acc_mode, error = 0; |
1401 | struct dentry *dentry; | 1417 | struct path path; |
1402 | struct dentry *dir; | 1418 | struct dentry *dir; |
1403 | int count = 0; | 1419 | int count = 0; |
1404 | 1420 | ||
@@ -1442,23 +1458,24 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd) | |||
1442 | dir = nd->dentry; | 1458 | dir = nd->dentry; |
1443 | nd->flags &= ~LOOKUP_PARENT; | 1459 | nd->flags &= ~LOOKUP_PARENT; |
1444 | down(&dir->d_inode->i_sem); | 1460 | down(&dir->d_inode->i_sem); |
1445 | dentry = __lookup_hash(&nd->last, nd->dentry, nd); | 1461 | path.dentry = __lookup_hash(&nd->last, nd->dentry, nd); |
1462 | path.mnt = nd->mnt; | ||
1446 | 1463 | ||
1447 | do_last: | 1464 | do_last: |
1448 | error = PTR_ERR(dentry); | 1465 | error = PTR_ERR(path.dentry); |
1449 | if (IS_ERR(dentry)) { | 1466 | if (IS_ERR(path.dentry)) { |
1450 | up(&dir->d_inode->i_sem); | 1467 | up(&dir->d_inode->i_sem); |
1451 | goto exit; | 1468 | goto exit; |
1452 | } | 1469 | } |
1453 | 1470 | ||
1454 | /* Negative dentry, just create the file */ | 1471 | /* Negative dentry, just create the file */ |
1455 | if (!dentry->d_inode) { | 1472 | if (!path.dentry->d_inode) { |
1456 | if (!IS_POSIXACL(dir->d_inode)) | 1473 | if (!IS_POSIXACL(dir->d_inode)) |
1457 | mode &= ~current->fs->umask; | 1474 | mode &= ~current->fs->umask; |
1458 | error = vfs_create(dir->d_inode, dentry, mode, nd); | 1475 | error = vfs_create(dir->d_inode, path.dentry, mode, nd); |
1459 | up(&dir->d_inode->i_sem); | 1476 | up(&dir->d_inode->i_sem); |
1460 | dput(nd->dentry); | 1477 | dput(nd->dentry); |
1461 | nd->dentry = dentry; | 1478 | nd->dentry = path.dentry; |
1462 | if (error) | 1479 | if (error) |
1463 | goto exit; | 1480 | goto exit; |
1464 | /* Don't check for write permission, don't truncate */ | 1481 | /* Don't check for write permission, don't truncate */ |
@@ -1476,22 +1493,24 @@ do_last: | |||
1476 | if (flag & O_EXCL) | 1493 | if (flag & O_EXCL) |
1477 | goto exit_dput; | 1494 | goto exit_dput; |
1478 | 1495 | ||
1479 | if (d_mountpoint(dentry)) { | 1496 | if (__follow_mount(&path)) { |
1480 | error = -ELOOP; | 1497 | error = -ELOOP; |
1481 | if (flag & O_NOFOLLOW) | 1498 | if (flag & O_NOFOLLOW) |
1482 | goto exit_dput; | 1499 | goto exit_dput; |
1483 | while (__follow_down(&nd->mnt,&dentry) && d_mountpoint(dentry)); | ||
1484 | } | 1500 | } |
1485 | error = -ENOENT; | 1501 | error = -ENOENT; |
1486 | if (!dentry->d_inode) | 1502 | if (!path.dentry->d_inode) |
1487 | goto exit_dput; | 1503 | goto exit_dput; |
1488 | if (dentry->d_inode->i_op && dentry->d_inode->i_op->follow_link) | 1504 | if (path.dentry->d_inode->i_op && path.dentry->d_inode->i_op->follow_link) |
1489 | goto do_link; | 1505 | goto do_link; |
1490 | 1506 | ||
1491 | dput(nd->dentry); | 1507 | dput(nd->dentry); |
1492 | nd->dentry = dentry; | 1508 | nd->dentry = path.dentry; |
1509 | if (nd->mnt != path.mnt) | ||
1510 | mntput(nd->mnt); | ||
1511 | nd->mnt = path.mnt; | ||
1493 | error = -EISDIR; | 1512 | error = -EISDIR; |
1494 | if (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode)) | 1513 | if (path.dentry->d_inode && S_ISDIR(path.dentry->d_inode->i_mode)) |
1495 | goto exit; | 1514 | goto exit; |
1496 | ok: | 1515 | ok: |
1497 | error = may_open(nd, acc_mode, flag); | 1516 | error = may_open(nd, acc_mode, flag); |
@@ -1500,7 +1519,9 @@ ok: | |||
1500 | return 0; | 1519 | return 0; |
1501 | 1520 | ||
1502 | exit_dput: | 1521 | exit_dput: |
1503 | dput(dentry); | 1522 | dput(path.dentry); |
1523 | if (nd->mnt != path.mnt) | ||
1524 | mntput(path.mnt); | ||
1504 | exit: | 1525 | exit: |
1505 | path_release(nd); | 1526 | path_release(nd); |
1506 | return error; | 1527 | return error; |
@@ -1520,18 +1541,15 @@ do_link: | |||
1520 | * are done. Procfs-like symlinks just set LAST_BIND. | 1541 | * are done. Procfs-like symlinks just set LAST_BIND. |
1521 | */ | 1542 | */ |
1522 | nd->flags |= LOOKUP_PARENT; | 1543 | nd->flags |= LOOKUP_PARENT; |
1523 | error = security_inode_follow_link(dentry, nd); | 1544 | error = security_inode_follow_link(path.dentry, nd); |
1524 | if (error) | 1545 | if (error) |
1525 | goto exit_dput; | 1546 | goto exit_dput; |
1526 | error = __do_follow_link(dentry, nd); | 1547 | error = __do_follow_link(&path, nd); |
1527 | dput(dentry); | ||
1528 | if (error) | 1548 | if (error) |
1529 | return error; | 1549 | return error; |
1530 | nd->flags &= ~LOOKUP_PARENT; | 1550 | nd->flags &= ~LOOKUP_PARENT; |
1531 | if (nd->last_type == LAST_BIND) { | 1551 | if (nd->last_type == LAST_BIND) |
1532 | dentry = nd->dentry; | ||
1533 | goto ok; | 1552 | goto ok; |
1534 | } | ||
1535 | error = -EISDIR; | 1553 | error = -EISDIR; |
1536 | if (nd->last_type != LAST_NORM) | 1554 | if (nd->last_type != LAST_NORM) |
1537 | goto exit; | 1555 | goto exit; |
@@ -1546,7 +1564,8 @@ do_link: | |||
1546 | } | 1564 | } |
1547 | dir = nd->dentry; | 1565 | dir = nd->dentry; |
1548 | down(&dir->d_inode->i_sem); | 1566 | down(&dir->d_inode->i_sem); |
1549 | dentry = __lookup_hash(&nd->last, nd->dentry, nd); | 1567 | path.dentry = __lookup_hash(&nd->last, nd->dentry, nd); |
1568 | path.mnt = nd->mnt; | ||
1550 | putname(nd->last.name); | 1569 | putname(nd->last.name); |
1551 | goto do_last; | 1570 | goto do_last; |
1552 | } | 1571 | } |
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 73f96acd5d37..ff6155f5e8d9 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -528,19 +528,39 @@ static inline void nfs_renew_times(struct dentry * dentry) | |||
528 | dentry->d_time = jiffies; | 528 | dentry->d_time = jiffies; |
529 | } | 529 | } |
530 | 530 | ||
531 | /* | ||
532 | * Return the intent data that applies to this particular path component | ||
533 | * | ||
534 | * Note that the current set of intents only apply to the very last | ||
535 | * component of the path. | ||
536 | * We check for this using LOOKUP_CONTINUE and LOOKUP_PARENT. | ||
537 | */ | ||
538 | static inline unsigned int nfs_lookup_check_intent(struct nameidata *nd, unsigned int mask) | ||
539 | { | ||
540 | if (nd->flags & (LOOKUP_CONTINUE|LOOKUP_PARENT)) | ||
541 | return 0; | ||
542 | return nd->flags & mask; | ||
543 | } | ||
544 | |||
545 | /* | ||
546 | * Inode and filehandle revalidation for lookups. | ||
547 | * | ||
548 | * We force revalidation in the cases where the VFS sets LOOKUP_REVAL, | ||
549 | * or if the intent information indicates that we're about to open this | ||
550 | * particular file and the "nocto" mount flag is not set. | ||
551 | * | ||
552 | */ | ||
531 | static inline | 553 | static inline |
532 | int nfs_lookup_verify_inode(struct inode *inode, struct nameidata *nd) | 554 | int nfs_lookup_verify_inode(struct inode *inode, struct nameidata *nd) |
533 | { | 555 | { |
534 | struct nfs_server *server = NFS_SERVER(inode); | 556 | struct nfs_server *server = NFS_SERVER(inode); |
535 | 557 | ||
536 | if (nd != NULL) { | 558 | if (nd != NULL) { |
537 | int ndflags = nd->flags; | ||
538 | /* VFS wants an on-the-wire revalidation */ | 559 | /* VFS wants an on-the-wire revalidation */ |
539 | if (ndflags & LOOKUP_REVAL) | 560 | if (nd->flags & LOOKUP_REVAL) |
540 | goto out_force; | 561 | goto out_force; |
541 | /* This is an open(2) */ | 562 | /* This is an open(2) */ |
542 | if ((ndflags & LOOKUP_OPEN) && | 563 | if (nfs_lookup_check_intent(nd, LOOKUP_OPEN) != 0 && |
543 | !(ndflags & LOOKUP_CONTINUE) && | ||
544 | !(server->flags & NFS_MOUNT_NOCTO)) | 564 | !(server->flags & NFS_MOUNT_NOCTO)) |
545 | goto out_force; | 565 | goto out_force; |
546 | } | 566 | } |
@@ -560,12 +580,8 @@ static inline | |||
560 | int nfs_neg_need_reval(struct inode *dir, struct dentry *dentry, | 580 | int nfs_neg_need_reval(struct inode *dir, struct dentry *dentry, |
561 | struct nameidata *nd) | 581 | struct nameidata *nd) |
562 | { | 582 | { |
563 | int ndflags = 0; | ||
564 | |||
565 | if (nd) | ||
566 | ndflags = nd->flags; | ||
567 | /* Don't revalidate a negative dentry if we're creating a new file */ | 583 | /* Don't revalidate a negative dentry if we're creating a new file */ |
568 | if ((ndflags & LOOKUP_CREATE) && !(ndflags & LOOKUP_CONTINUE)) | 584 | if (nd != NULL && nfs_lookup_check_intent(nd, LOOKUP_CREATE) != 0) |
569 | return 0; | 585 | return 0; |
570 | return !nfs_check_verifier(dir, dentry); | 586 | return !nfs_check_verifier(dir, dentry); |
571 | } | 587 | } |
@@ -700,12 +716,16 @@ struct dentry_operations nfs_dentry_operations = { | |||
700 | .d_iput = nfs_dentry_iput, | 716 | .d_iput = nfs_dentry_iput, |
701 | }; | 717 | }; |
702 | 718 | ||
719 | /* | ||
720 | * Use intent information to check whether or not we're going to do | ||
721 | * an O_EXCL create using this path component. | ||
722 | */ | ||
703 | static inline | 723 | static inline |
704 | int nfs_is_exclusive_create(struct inode *dir, struct nameidata *nd) | 724 | int nfs_is_exclusive_create(struct inode *dir, struct nameidata *nd) |
705 | { | 725 | { |
706 | if (NFS_PROTO(dir)->version == 2) | 726 | if (NFS_PROTO(dir)->version == 2) |
707 | return 0; | 727 | return 0; |
708 | if (!nd || (nd->flags & LOOKUP_CONTINUE) || !(nd->flags & LOOKUP_CREATE)) | 728 | if (nd == NULL || nfs_lookup_check_intent(nd, LOOKUP_CREATE) == 0) |
709 | return 0; | 729 | return 0; |
710 | return (nd->intent.open.flags & O_EXCL) != 0; | 730 | return (nd->intent.open.flags & O_EXCL) != 0; |
711 | } | 731 | } |
@@ -772,12 +792,13 @@ struct dentry_operations nfs4_dentry_operations = { | |||
772 | .d_iput = nfs_dentry_iput, | 792 | .d_iput = nfs_dentry_iput, |
773 | }; | 793 | }; |
774 | 794 | ||
795 | /* | ||
796 | * Use intent information to determine whether we need to substitute | ||
797 | * the NFSv4-style stateful OPEN for the LOOKUP call | ||
798 | */ | ||
775 | static int is_atomic_open(struct inode *dir, struct nameidata *nd) | 799 | static int is_atomic_open(struct inode *dir, struct nameidata *nd) |
776 | { | 800 | { |
777 | if (!nd) | 801 | if (nd == NULL || nfs_lookup_check_intent(nd, LOOKUP_OPEN) == 0) |
778 | return 0; | ||
779 | /* Check that we are indeed trying to open this file */ | ||
780 | if ((nd->flags & LOOKUP_CONTINUE) || !(nd->flags & LOOKUP_OPEN)) | ||
781 | return 0; | 802 | return 0; |
782 | /* NFS does not (yet) have a stateful open for directories */ | 803 | /* NFS does not (yet) have a stateful open for directories */ |
783 | if (nd->flags & LOOKUP_DIRECTORY) | 804 | if (nd->flags & LOOKUP_DIRECTORY) |
diff --git a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c index 67423c696c0a..6fd57f154197 100644 --- a/fs/proc/proc_devtree.c +++ b/fs/proc/proc_devtree.c | |||
@@ -12,15 +12,8 @@ | |||
12 | #include <asm/uaccess.h> | 12 | #include <asm/uaccess.h> |
13 | 13 | ||
14 | #ifndef HAVE_ARCH_DEVTREE_FIXUPS | 14 | #ifndef HAVE_ARCH_DEVTREE_FIXUPS |
15 | static inline void set_node_proc_entry(struct device_node *np, struct proc_dir_entry *de) | 15 | static inline void set_node_proc_entry(struct device_node *np, |
16 | { | 16 | struct proc_dir_entry *de) |
17 | } | ||
18 | |||
19 | static void inline set_node_name_link(struct device_node *np, struct proc_dir_entry *de) | ||
20 | { | ||
21 | } | ||
22 | |||
23 | static void inline set_node_addr_link(struct device_node *np, struct proc_dir_entry *de) | ||
24 | { | 17 | { |
25 | } | 18 | } |
26 | #endif | 19 | #endif |
@@ -58,89 +51,67 @@ static int property_read_proc(char *page, char **start, off_t off, | |||
58 | /* | 51 | /* |
59 | * Process a node, adding entries for its children and its properties. | 52 | * Process a node, adding entries for its children and its properties. |
60 | */ | 53 | */ |
61 | void proc_device_tree_add_node(struct device_node *np, struct proc_dir_entry *de) | 54 | void proc_device_tree_add_node(struct device_node *np, |
55 | struct proc_dir_entry *de) | ||
62 | { | 56 | { |
63 | struct property *pp; | 57 | struct property *pp; |
64 | struct proc_dir_entry *ent; | 58 | struct proc_dir_entry *ent; |
65 | struct device_node *child, *sib; | 59 | struct device_node *child; |
66 | const char *p, *at; | 60 | struct proc_dir_entry *list = NULL, **lastp; |
67 | int l; | 61 | const char *p; |
68 | struct proc_dir_entry *list, **lastp, *al; | ||
69 | 62 | ||
70 | set_node_proc_entry(np, de); | 63 | set_node_proc_entry(np, de); |
71 | lastp = &list; | 64 | lastp = &list; |
72 | for (pp = np->properties; pp != 0; pp = pp->next) { | 65 | for (child = NULL; (child = of_get_next_child(np, child));) { |
73 | /* | ||
74 | * Unfortunately proc_register puts each new entry | ||
75 | * at the beginning of the list. So we rearrange them. | ||
76 | */ | ||
77 | ent = create_proc_read_entry(pp->name, strncmp(pp->name, "security-", 9) ? | ||
78 | S_IRUGO : S_IRUSR, de, property_read_proc, pp); | ||
79 | if (ent == 0) | ||
80 | break; | ||
81 | if (!strncmp(pp->name, "security-", 9)) | ||
82 | ent->size = 0; /* don't leak number of password chars */ | ||
83 | else | ||
84 | ent->size = pp->length; | ||
85 | *lastp = ent; | ||
86 | lastp = &ent->next; | ||
87 | } | ||
88 | child = NULL; | ||
89 | while ((child = of_get_next_child(np, child))) { | ||
90 | p = strrchr(child->full_name, '/'); | 66 | p = strrchr(child->full_name, '/'); |
91 | if (!p) | 67 | if (!p) |
92 | p = child->full_name; | 68 | p = child->full_name; |
93 | else | 69 | else |
94 | ++p; | 70 | ++p; |
95 | /* chop off '@0' if the name ends with that */ | ||
96 | l = strlen(p); | ||
97 | if (l > 2 && p[l-2] == '@' && p[l-1] == '0') | ||
98 | l -= 2; | ||
99 | ent = proc_mkdir(p, de); | 71 | ent = proc_mkdir(p, de); |
100 | if (ent == 0) | 72 | if (ent == 0) |
101 | break; | 73 | break; |
102 | *lastp = ent; | 74 | *lastp = ent; |
75 | ent->next = NULL; | ||
103 | lastp = &ent->next; | 76 | lastp = &ent->next; |
104 | proc_device_tree_add_node(child, ent); | 77 | proc_device_tree_add_node(child, ent); |
105 | 78 | } | |
106 | /* | 79 | of_node_put(child); |
107 | * If we left the address part on the name, consider | 80 | for (pp = np->properties; pp != 0; pp = pp->next) { |
108 | * adding symlinks from the name and address parts. | ||
109 | */ | ||
110 | if (p[l] != 0 || (at = strchr(p, '@')) == 0) | ||
111 | continue; | ||
112 | |||
113 | /* | 81 | /* |
114 | * If this is the first node with a given name property, | 82 | * Yet another Apple device-tree bogosity: on some machines, |
115 | * add a symlink with the name property as its name. | 83 | * they have properties & nodes with the same name. Those |
84 | * properties are quite unimportant for us though, thus we | ||
85 | * simply "skip" them here, but we do have to check. | ||
116 | */ | 86 | */ |
117 | sib = NULL; | 87 | for (ent = list; ent != NULL; ent = ent->next) |
118 | while ((sib = of_get_next_child(np, sib)) && sib != child) | 88 | if (!strcmp(ent->name, pp->name)) |
119 | if (sib->name && strcmp(sib->name, child->name) == 0) | ||
120 | break; | ||
121 | if (sib == child && strncmp(p, child->name, l) != 0) { | ||
122 | al = proc_symlink(child->name, de, ent->name); | ||
123 | if (al == 0) { | ||
124 | of_node_put(sib); | ||
125 | break; | 89 | break; |
126 | } | 90 | if (ent != NULL) { |
127 | set_node_name_link(child, al); | 91 | printk(KERN_WARNING "device-tree: property \"%s\" name" |
128 | *lastp = al; | 92 | " conflicts with node in %s\n", pp->name, |
129 | lastp = &al->next; | 93 | np->full_name); |
94 | continue; | ||
130 | } | 95 | } |
131 | of_node_put(sib); | 96 | |
132 | /* | 97 | /* |
133 | * Add another directory with the @address part as its name. | 98 | * Unfortunately proc_register puts each new entry |
99 | * at the beginning of the list. So we rearrange them. | ||
134 | */ | 100 | */ |
135 | al = proc_symlink(at, de, ent->name); | 101 | ent = create_proc_read_entry(pp->name, |
136 | if (al == 0) | 102 | strncmp(pp->name, "security-", 9) |
103 | ? S_IRUGO : S_IRUSR, de, | ||
104 | property_read_proc, pp); | ||
105 | if (ent == 0) | ||
137 | break; | 106 | break; |
138 | set_node_addr_link(child, al); | 107 | if (!strncmp(pp->name, "security-", 9)) |
139 | *lastp = al; | 108 | ent->size = 0; /* don't leak number of password chars */ |
140 | lastp = &al->next; | 109 | else |
110 | ent->size = pp->length; | ||
111 | ent->next = NULL; | ||
112 | *lastp = ent; | ||
113 | lastp = &ent->next; | ||
141 | } | 114 | } |
142 | of_node_put(child); | ||
143 | *lastp = NULL; | ||
144 | de->subdir = list; | 115 | de->subdir = list; |
145 | } | 116 | } |
146 | 117 | ||
diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c index 457a8fe28575..85d8dbe843f1 100644 --- a/fs/udf/udftime.c +++ b/fs/udf/udftime.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | /* How many days come before each month (0-12). */ | 48 | /* How many days come before each month (0-12). */ |
49 | const unsigned short int __mon_yday[2][13] = | 49 | static const unsigned short int __mon_yday[2][13] = |
50 | { | 50 | { |
51 | /* Normal years. */ | 51 | /* Normal years. */ |
52 | { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, | 52 | { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, |
diff --git a/include/asm-alpha/agp.h b/include/asm-alpha/agp.h index c99dbbb5bcb5..ef855a3bc0f5 100644 --- a/include/asm-alpha/agp.h +++ b/include/asm-alpha/agp.h | |||
@@ -10,4 +10,14 @@ | |||
10 | #define flush_agp_mappings() | 10 | #define flush_agp_mappings() |
11 | #define flush_agp_cache() mb() | 11 | #define flush_agp_cache() mb() |
12 | 12 | ||
13 | /* Convert a physical address to an address suitable for the GART. */ | ||
14 | #define phys_to_gart(x) (x) | ||
15 | #define gart_to_phys(x) (x) | ||
16 | |||
17 | /* GATT allocation. Returns/accepts GATT kernel virtual address. */ | ||
18 | #define alloc_gatt_pages(order) \ | ||
19 | ((char *)__get_free_pages(GFP_KERNEL, (order))) | ||
20 | #define free_gatt_pages(table, order) \ | ||
21 | free_pages((unsigned long)(table), (order)) | ||
22 | |||
13 | #endif | 23 | #endif |
diff --git a/include/asm-h8300/kmap_types.h b/include/asm-h8300/kmap_types.h index 82431edeb2a1..1ec8a3427120 100644 --- a/include/asm-h8300/kmap_types.h +++ b/include/asm-h8300/kmap_types.h | |||
@@ -1,5 +1,5 @@ | |||
1 | #ifndef _ASM_KMAP_TYPES_H | 1 | #ifndef _ASM_H8300_KMAP_TYPES_H |
2 | #define _ASM_KMAP_TYPES_H | 2 | #define _ASM_H8300_KMAP_TYPES_H |
3 | 3 | ||
4 | enum km_type { | 4 | enum km_type { |
5 | KM_BOUNCE_READ, | 5 | KM_BOUNCE_READ, |
@@ -13,6 +13,8 @@ enum km_type { | |||
13 | KM_PTE1, | 13 | KM_PTE1, |
14 | KM_IRQ0, | 14 | KM_IRQ0, |
15 | KM_IRQ1, | 15 | KM_IRQ1, |
16 | KM_SOFTIRQ0, | ||
17 | KM_SOFTIRQ1, | ||
16 | KM_TYPE_NR | 18 | KM_TYPE_NR |
17 | }; | 19 | }; |
18 | 20 | ||
diff --git a/include/asm-h8300/mman.h b/include/asm-h8300/mman.h index abe08856c84f..63f727a59850 100644 --- a/include/asm-h8300/mman.h +++ b/include/asm-h8300/mman.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #define PROT_READ 0x1 /* page can be read */ | 4 | #define PROT_READ 0x1 /* page can be read */ |
5 | #define PROT_WRITE 0x2 /* page can be written */ | 5 | #define PROT_WRITE 0x2 /* page can be written */ |
6 | #define PROT_EXEC 0x4 /* page can be executed */ | 6 | #define PROT_EXEC 0x4 /* page can be executed */ |
7 | #define PROT_SEM 0x8 /* page may be used for atomic ops */ | ||
7 | #define PROT_NONE 0x0 /* page can not be accessed */ | 8 | #define PROT_NONE 0x0 /* page can not be accessed */ |
8 | #define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */ | 9 | #define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */ |
9 | #define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */ | 10 | #define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */ |
@@ -19,6 +20,8 @@ | |||
19 | #define MAP_EXECUTABLE 0x1000 /* mark it as an executable */ | 20 | #define MAP_EXECUTABLE 0x1000 /* mark it as an executable */ |
20 | #define MAP_LOCKED 0x2000 /* pages are locked */ | 21 | #define MAP_LOCKED 0x2000 /* pages are locked */ |
21 | #define MAP_NORESERVE 0x4000 /* don't check for reservations */ | 22 | #define MAP_NORESERVE 0x4000 /* don't check for reservations */ |
23 | #define MAP_POPULATE 0x8000 /* populate (prefault) pagetables */ | ||
24 | #define MAP_NONBLOCK 0x10000 /* do not block on IO */ | ||
22 | 25 | ||
23 | #define MS_ASYNC 1 /* sync memory asynchronously */ | 26 | #define MS_ASYNC 1 /* sync memory asynchronously */ |
24 | #define MS_INVALIDATE 2 /* invalidate the caches */ | 27 | #define MS_INVALIDATE 2 /* invalidate the caches */ |
diff --git a/include/asm-i386/agp.h b/include/asm-i386/agp.h index a917ff50354f..b82f5f3ab887 100644 --- a/include/asm-i386/agp.h +++ b/include/asm-i386/agp.h | |||
@@ -21,4 +21,14 @@ int unmap_page_from_agp(struct page *page); | |||
21 | worth it. Would need a page for it. */ | 21 | worth it. Would need a page for it. */ |
22 | #define flush_agp_cache() asm volatile("wbinvd":::"memory") | 22 | #define flush_agp_cache() asm volatile("wbinvd":::"memory") |
23 | 23 | ||
24 | /* Convert a physical address to an address suitable for the GART. */ | ||
25 | #define phys_to_gart(x) (x) | ||
26 | #define gart_to_phys(x) (x) | ||
27 | |||
28 | /* GATT allocation. Returns/accepts GATT kernel virtual address. */ | ||
29 | #define alloc_gatt_pages(order) \ | ||
30 | ((char *)__get_free_pages(GFP_KERNEL, (order))) | ||
31 | #define free_gatt_pages(table, order) \ | ||
32 | free_pages((unsigned long)(table), (order)) | ||
33 | |||
24 | #endif | 34 | #endif |
diff --git a/include/asm-i386/mach-numaq/mach_ipi.h b/include/asm-i386/mach-numaq/mach_ipi.h index 1b46fd3f2ae3..c6044488e9e6 100644 --- a/include/asm-i386/mach-numaq/mach_ipi.h +++ b/include/asm-i386/mach-numaq/mach_ipi.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef __ASM_MACH_IPI_H | 1 | #ifndef __ASM_MACH_IPI_H |
2 | #define __ASM_MACH_IPI_H | 2 | #define __ASM_MACH_IPI_H |
3 | 3 | ||
4 | inline void send_IPI_mask_sequence(cpumask_t, int vector); | 4 | void send_IPI_mask_sequence(cpumask_t, int vector); |
5 | 5 | ||
6 | static inline void send_IPI_mask(cpumask_t mask, int vector) | 6 | static inline void send_IPI_mask(cpumask_t mask, int vector) |
7 | { | 7 | { |
diff --git a/include/asm-i386/timer.h b/include/asm-i386/timer.h index 40c54f69780e..c34709849839 100644 --- a/include/asm-i386/timer.h +++ b/include/asm-i386/timer.h | |||
@@ -53,6 +53,7 @@ extern struct init_timer_opts timer_cyclone_init; | |||
53 | 53 | ||
54 | extern unsigned long calibrate_tsc(void); | 54 | extern unsigned long calibrate_tsc(void); |
55 | extern void init_cpu_khz(void); | 55 | extern void init_cpu_khz(void); |
56 | extern int recalibrate_cpu_khz(void); | ||
56 | #ifdef CONFIG_HPET_TIMER | 57 | #ifdef CONFIG_HPET_TIMER |
57 | extern struct init_timer_opts timer_hpet_init; | 58 | extern struct init_timer_opts timer_hpet_init; |
58 | extern unsigned long calibrate_tsc_hpet(unsigned long *tsc_hpet_quotient_ptr); | 59 | extern unsigned long calibrate_tsc_hpet(unsigned long *tsc_hpet_quotient_ptr); |
diff --git a/include/asm-ia64/agp.h b/include/asm-ia64/agp.h index d1316f1e6ee1..4e517f0e6afa 100644 --- a/include/asm-ia64/agp.h +++ b/include/asm-ia64/agp.h | |||
@@ -18,4 +18,14 @@ | |||
18 | #define flush_agp_mappings() /* nothing */ | 18 | #define flush_agp_mappings() /* nothing */ |
19 | #define flush_agp_cache() mb() | 19 | #define flush_agp_cache() mb() |
20 | 20 | ||
21 | /* Convert a physical address to an address suitable for the GART. */ | ||
22 | #define phys_to_gart(x) (x) | ||
23 | #define gart_to_phys(x) (x) | ||
24 | |||
25 | /* GATT allocation. Returns/accepts GATT kernel virtual address. */ | ||
26 | #define alloc_gatt_pages(order) \ | ||
27 | ((char *)__get_free_pages(GFP_KERNEL, (order))) | ||
28 | #define free_gatt_pages(table, order) \ | ||
29 | free_pages((unsigned long)(table), (order)) | ||
30 | |||
21 | #endif /* _ASM_IA64_AGP_H */ | 31 | #endif /* _ASM_IA64_AGP_H */ |
diff --git a/include/asm-ia64/perfmon.h b/include/asm-ia64/perfmon.h index ed5416c5b1ac..7f3333dd00e4 100644 --- a/include/asm-ia64/perfmon.h +++ b/include/asm-ia64/perfmon.h | |||
@@ -177,6 +177,10 @@ typedef union { | |||
177 | 177 | ||
178 | extern long perfmonctl(int fd, int cmd, void *arg, int narg); | 178 | extern long perfmonctl(int fd, int cmd, void *arg, int narg); |
179 | 179 | ||
180 | typedef struct { | ||
181 | void (*handler)(int irq, void *arg, struct pt_regs *regs); | ||
182 | } pfm_intr_handler_desc_t; | ||
183 | |||
180 | extern void pfm_save_regs (struct task_struct *); | 184 | extern void pfm_save_regs (struct task_struct *); |
181 | extern void pfm_load_regs (struct task_struct *); | 185 | extern void pfm_load_regs (struct task_struct *); |
182 | 186 | ||
@@ -187,6 +191,10 @@ extern void pfm_syst_wide_update_task(struct task_struct *, unsigned long info, | |||
187 | extern void pfm_inherit(struct task_struct *task, struct pt_regs *regs); | 191 | extern void pfm_inherit(struct task_struct *task, struct pt_regs *regs); |
188 | extern void pfm_init_percpu(void); | 192 | extern void pfm_init_percpu(void); |
189 | extern void pfm_handle_work(void); | 193 | extern void pfm_handle_work(void); |
194 | extern int pfm_install_alt_pmu_interrupt(pfm_intr_handler_desc_t *h); | ||
195 | extern int pfm_remove_alt_pmu_interrupt(pfm_intr_handler_desc_t *h); | ||
196 | |||
197 | |||
190 | 198 | ||
191 | /* | 199 | /* |
192 | * Reset PMD register flags | 200 | * Reset PMD register flags |
diff --git a/include/asm-ia64/sn/sn_sal.h b/include/asm-ia64/sn/sn_sal.h index 56d74ca76b5d..eb0395ad0d6a 100644 --- a/include/asm-ia64/sn/sn_sal.h +++ b/include/asm-ia64/sn/sn_sal.h | |||
@@ -115,6 +115,13 @@ | |||
115 | #define SAL_IROUTER_INTR_XMIT SAL_CONSOLE_INTR_XMIT | 115 | #define SAL_IROUTER_INTR_XMIT SAL_CONSOLE_INTR_XMIT |
116 | #define SAL_IROUTER_INTR_RECV SAL_CONSOLE_INTR_RECV | 116 | #define SAL_IROUTER_INTR_RECV SAL_CONSOLE_INTR_RECV |
117 | 117 | ||
118 | /* | ||
119 | * Error Handling Features | ||
120 | */ | ||
121 | #define SAL_ERR_FEAT_MCA_SLV_TO_OS_INIT_SLV 0x1 | ||
122 | #define SAL_ERR_FEAT_LOG_SBES 0x2 | ||
123 | #define SAL_ERR_FEAT_MFR_OVERRIDE 0x4 | ||
124 | #define SAL_ERR_FEAT_SBE_THRESHOLD 0xffff0000 | ||
118 | 125 | ||
119 | /* | 126 | /* |
120 | * SAL Error Codes | 127 | * SAL Error Codes |
@@ -342,6 +349,25 @@ ia64_sn_plat_cpei_handler(void) | |||
342 | } | 349 | } |
343 | 350 | ||
344 | /* | 351 | /* |
352 | * Set Error Handling Features | ||
353 | */ | ||
354 | static inline u64 | ||
355 | ia64_sn_plat_set_error_handling_features(void) | ||
356 | { | ||
357 | struct ia64_sal_retval ret_stuff; | ||
358 | |||
359 | ret_stuff.status = 0; | ||
360 | ret_stuff.v0 = 0; | ||
361 | ret_stuff.v1 = 0; | ||
362 | ret_stuff.v2 = 0; | ||
363 | SAL_CALL_REENTRANT(ret_stuff, SN_SAL_SET_ERROR_HANDLING_FEATURES, | ||
364 | (SAL_ERR_FEAT_MCA_SLV_TO_OS_INIT_SLV | SAL_ERR_FEAT_LOG_SBES), | ||
365 | 0, 0, 0, 0, 0, 0); | ||
366 | |||
367 | return ret_stuff.status; | ||
368 | } | ||
369 | |||
370 | /* | ||
345 | * Checks for console input. | 371 | * Checks for console input. |
346 | */ | 372 | */ |
347 | static inline u64 | 373 | static inline u64 |
@@ -472,7 +498,7 @@ static inline u64 | |||
472 | ia64_sn_pod_mode(void) | 498 | ia64_sn_pod_mode(void) |
473 | { | 499 | { |
474 | struct ia64_sal_retval isrv; | 500 | struct ia64_sal_retval isrv; |
475 | SAL_CALL(isrv, SN_SAL_POD_MODE, 0, 0, 0, 0, 0, 0, 0); | 501 | SAL_CALL_REENTRANT(isrv, SN_SAL_POD_MODE, 0, 0, 0, 0, 0, 0, 0); |
476 | if (isrv.status) | 502 | if (isrv.status) |
477 | return 0; | 503 | return 0; |
478 | return isrv.v0; | 504 | return isrv.v0; |
diff --git a/include/asm-ppc/agp.h b/include/asm-ppc/agp.h index be27cfa8c5b0..ca9e423307f4 100644 --- a/include/asm-ppc/agp.h +++ b/include/asm-ppc/agp.h | |||
@@ -10,4 +10,14 @@ | |||
10 | #define flush_agp_mappings() | 10 | #define flush_agp_mappings() |
11 | #define flush_agp_cache() mb() | 11 | #define flush_agp_cache() mb() |
12 | 12 | ||
13 | /* Convert a physical address to an address suitable for the GART. */ | ||
14 | #define phys_to_gart(x) (x) | ||
15 | #define gart_to_phys(x) (x) | ||
16 | |||
17 | /* GATT allocation. Returns/accepts GATT kernel virtual address. */ | ||
18 | #define alloc_gatt_pages(order) \ | ||
19 | ((char *)__get_free_pages(GFP_KERNEL, (order))) | ||
20 | #define free_gatt_pages(table, order) \ | ||
21 | free_pages((unsigned long)(table), (order)) | ||
22 | |||
13 | #endif | 23 | #endif |
diff --git a/include/asm-ppc/sigcontext.h b/include/asm-ppc/sigcontext.h index f82dcccdee1e..b7a417e0a921 100644 --- a/include/asm-ppc/sigcontext.h +++ b/include/asm-ppc/sigcontext.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #define _ASM_PPC_SIGCONTEXT_H | 2 | #define _ASM_PPC_SIGCONTEXT_H |
3 | 3 | ||
4 | #include <asm/ptrace.h> | 4 | #include <asm/ptrace.h> |
5 | 5 | #include <linux/compiler.h> | |
6 | 6 | ||
7 | struct sigcontext { | 7 | struct sigcontext { |
8 | unsigned long _unused[4]; | 8 | unsigned long _unused[4]; |
diff --git a/include/asm-ppc64/agp.h b/include/asm-ppc64/agp.h index be27cfa8c5b0..ca9e423307f4 100644 --- a/include/asm-ppc64/agp.h +++ b/include/asm-ppc64/agp.h | |||
@@ -10,4 +10,14 @@ | |||
10 | #define flush_agp_mappings() | 10 | #define flush_agp_mappings() |
11 | #define flush_agp_cache() mb() | 11 | #define flush_agp_cache() mb() |
12 | 12 | ||
13 | /* Convert a physical address to an address suitable for the GART. */ | ||
14 | #define phys_to_gart(x) (x) | ||
15 | #define gart_to_phys(x) (x) | ||
16 | |||
17 | /* GATT allocation. Returns/accepts GATT kernel virtual address. */ | ||
18 | #define alloc_gatt_pages(order) \ | ||
19 | ((char *)__get_free_pages(GFP_KERNEL, (order))) | ||
20 | #define free_gatt_pages(table, order) \ | ||
21 | free_pages((unsigned long)(table), (order)) | ||
22 | |||
13 | #endif | 23 | #endif |
diff --git a/include/asm-ppc64/processor.h b/include/asm-ppc64/processor.h index 0035efe2db2b..809c634ba1df 100644 --- a/include/asm-ppc64/processor.h +++ b/include/asm-ppc64/processor.h | |||
@@ -120,103 +120,18 @@ | |||
120 | 120 | ||
121 | /* Special Purpose Registers (SPRNs)*/ | 121 | /* Special Purpose Registers (SPRNs)*/ |
122 | 122 | ||
123 | #define SPRN_CDBCR 0x3D7 /* Cache Debug Control Register */ | ||
124 | #define SPRN_CTR 0x009 /* Count Register */ | 123 | #define SPRN_CTR 0x009 /* Count Register */ |
125 | #define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */ | 124 | #define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */ |
126 | #define SPRN_DAC1 0x3F6 /* Data Address Compare 1 */ | 125 | #define DABR_TRANSLATION (1UL << 2) |
127 | #define SPRN_DAC2 0x3F7 /* Data Address Compare 2 */ | ||
128 | #define SPRN_DAR 0x013 /* Data Address Register */ | 126 | #define SPRN_DAR 0x013 /* Data Address Register */ |
129 | #define SPRN_DBCR 0x3F2 /* Debug Control Regsiter */ | ||
130 | #define DBCR_EDM 0x80000000 | ||
131 | #define DBCR_IDM 0x40000000 | ||
132 | #define DBCR_RST(x) (((x) & 0x3) << 28) | ||
133 | #define DBCR_RST_NONE 0 | ||
134 | #define DBCR_RST_CORE 1 | ||
135 | #define DBCR_RST_CHIP 2 | ||
136 | #define DBCR_RST_SYSTEM 3 | ||
137 | #define DBCR_IC 0x08000000 /* Instruction Completion Debug Evnt */ | ||
138 | #define DBCR_BT 0x04000000 /* Branch Taken Debug Event */ | ||
139 | #define DBCR_EDE 0x02000000 /* Exception Debug Event */ | ||
140 | #define DBCR_TDE 0x01000000 /* TRAP Debug Event */ | ||
141 | #define DBCR_FER 0x00F80000 /* First Events Remaining Mask */ | ||
142 | #define DBCR_FT 0x00040000 /* Freeze Timers on Debug Event */ | ||
143 | #define DBCR_IA1 0x00020000 /* Instr. Addr. Compare 1 Enable */ | ||
144 | #define DBCR_IA2 0x00010000 /* Instr. Addr. Compare 2 Enable */ | ||
145 | #define DBCR_D1R 0x00008000 /* Data Addr. Compare 1 Read Enable */ | ||
146 | #define DBCR_D1W 0x00004000 /* Data Addr. Compare 1 Write Enable */ | ||
147 | #define DBCR_D1S(x) (((x) & 0x3) << 12) /* Data Adrr. Compare 1 Size */ | ||
148 | #define DAC_BYTE 0 | ||
149 | #define DAC_HALF 1 | ||
150 | #define DAC_WORD 2 | ||
151 | #define DAC_QUAD 3 | ||
152 | #define DBCR_D2R 0x00000800 /* Data Addr. Compare 2 Read Enable */ | ||
153 | #define DBCR_D2W 0x00000400 /* Data Addr. Compare 2 Write Enable */ | ||
154 | #define DBCR_D2S(x) (((x) & 0x3) << 8) /* Data Addr. Compare 2 Size */ | ||
155 | #define DBCR_SBT 0x00000040 /* Second Branch Taken Debug Event */ | ||
156 | #define DBCR_SED 0x00000020 /* Second Exception Debug Event */ | ||
157 | #define DBCR_STD 0x00000010 /* Second Trap Debug Event */ | ||
158 | #define DBCR_SIA 0x00000008 /* Second IAC Enable */ | ||
159 | #define DBCR_SDA 0x00000004 /* Second DAC Enable */ | ||
160 | #define DBCR_JOI 0x00000002 /* JTAG Serial Outbound Int. Enable */ | ||
161 | #define DBCR_JII 0x00000001 /* JTAG Serial Inbound Int. Enable */ | ||
162 | #define SPRN_DBCR0 0x3F2 /* Debug Control Register 0 */ | ||
163 | #define SPRN_DBCR1 0x3BD /* Debug Control Register 1 */ | ||
164 | #define SPRN_DBSR 0x3F0 /* Debug Status Register */ | ||
165 | #define SPRN_DCCR 0x3FA /* Data Cache Cacheability Register */ | ||
166 | #define DCCR_NOCACHE 0 /* Noncacheable */ | ||
167 | #define DCCR_CACHE 1 /* Cacheable */ | ||
168 | #define SPRN_DCMP 0x3D1 /* Data TLB Compare Register */ | ||
169 | #define SPRN_DCWR 0x3BA /* Data Cache Write-thru Register */ | ||
170 | #define DCWR_COPY 0 /* Copy-back */ | ||
171 | #define DCWR_WRITE 1 /* Write-through */ | ||
172 | #define SPRN_DEAR 0x3D5 /* Data Error Address Register */ | ||
173 | #define SPRN_DEC 0x016 /* Decrement Register */ | 127 | #define SPRN_DEC 0x016 /* Decrement Register */ |
174 | #define SPRN_DMISS 0x3D0 /* Data TLB Miss Register */ | ||
175 | #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */ | 128 | #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */ |
176 | #define DSISR_NOHPTE 0x40000000 /* no translation found */ | 129 | #define DSISR_NOHPTE 0x40000000 /* no translation found */ |
177 | #define DSISR_PROTFAULT 0x08000000 /* protection fault */ | 130 | #define DSISR_PROTFAULT 0x08000000 /* protection fault */ |
178 | #define DSISR_ISSTORE 0x02000000 /* access was a store */ | 131 | #define DSISR_ISSTORE 0x02000000 /* access was a store */ |
179 | #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */ | 132 | #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */ |
180 | #define DSISR_NOSEGMENT 0x00200000 /* STAB/SLB miss */ | 133 | #define DSISR_NOSEGMENT 0x00200000 /* STAB/SLB miss */ |
181 | #define SPRN_EAR 0x11A /* External Address Register */ | ||
182 | #define SPRN_ESR 0x3D4 /* Exception Syndrome Register */ | ||
183 | #define ESR_IMCP 0x80000000 /* Instr. Machine Check - Protection */ | ||
184 | #define ESR_IMCN 0x40000000 /* Instr. Machine Check - Non-config */ | ||
185 | #define ESR_IMCB 0x20000000 /* Instr. Machine Check - Bus error */ | ||
186 | #define ESR_IMCT 0x10000000 /* Instr. Machine Check - Timeout */ | ||
187 | #define ESR_PIL 0x08000000 /* Program Exception - Illegal */ | ||
188 | #define ESR_PPR 0x04000000 /* Program Exception - Priveleged */ | ||
189 | #define ESR_PTR 0x02000000 /* Program Exception - Trap */ | ||
190 | #define ESR_DST 0x00800000 /* Storage Exception - Data miss */ | ||
191 | #define ESR_DIZ 0x00400000 /* Storage Exception - Zone fault */ | ||
192 | #define SPRN_EVPR 0x3D6 /* Exception Vector Prefix Register */ | ||
193 | #define SPRN_HASH1 0x3D2 /* Primary Hash Address Register */ | ||
194 | #define SPRN_HASH2 0x3D3 /* Secondary Hash Address Resgister */ | ||
195 | #define SPRN_HID0 0x3F0 /* Hardware Implementation Register 0 */ | 134 | #define SPRN_HID0 0x3F0 /* Hardware Implementation Register 0 */ |
196 | #define HID0_EMCP (1<<31) /* Enable Machine Check pin */ | ||
197 | #define HID0_EBA (1<<29) /* Enable Bus Address Parity */ | ||
198 | #define HID0_EBD (1<<28) /* Enable Bus Data Parity */ | ||
199 | #define HID0_SBCLK (1<<27) | ||
200 | #define HID0_EICE (1<<26) | ||
201 | #define HID0_ECLK (1<<25) | ||
202 | #define HID0_PAR (1<<24) | ||
203 | #define HID0_DOZE (1<<23) | ||
204 | #define HID0_NAP (1<<22) | ||
205 | #define HID0_SLEEP (1<<21) | ||
206 | #define HID0_DPM (1<<20) | ||
207 | #define HID0_ICE (1<<15) /* Instruction Cache Enable */ | ||
208 | #define HID0_DCE (1<<14) /* Data Cache Enable */ | ||
209 | #define HID0_ILOCK (1<<13) /* Instruction Cache Lock */ | ||
210 | #define HID0_DLOCK (1<<12) /* Data Cache Lock */ | ||
211 | #define HID0_ICFI (1<<11) /* Instr. Cache Flash Invalidate */ | ||
212 | #define HID0_DCI (1<<10) /* Data Cache Invalidate */ | ||
213 | #define HID0_SPD (1<<9) /* Speculative disable */ | ||
214 | #define HID0_SGE (1<<7) /* Store Gathering Enable */ | ||
215 | #define HID0_SIED (1<<7) /* Serial Instr. Execution [Disable] */ | ||
216 | #define HID0_BTIC (1<<5) /* Branch Target Instruction Cache Enable */ | ||
217 | #define HID0_ABE (1<<3) /* Address Broadcast Enable */ | ||
218 | #define HID0_BHTE (1<<2) /* Branch History Table Enable */ | ||
219 | #define HID0_BTCD (1<<1) /* Branch target cache disable */ | ||
220 | #define SPRN_MSRDORM 0x3F1 /* Hardware Implementation Register 1 */ | 135 | #define SPRN_MSRDORM 0x3F1 /* Hardware Implementation Register 1 */ |
221 | #define SPRN_HID1 0x3F1 /* Hardware Implementation Register 1 */ | 136 | #define SPRN_HID1 0x3F1 /* Hardware Implementation Register 1 */ |
222 | #define SPRN_IABR 0x3F2 /* Instruction Address Breakpoint Register */ | 137 | #define SPRN_IABR 0x3F2 /* Instruction Address Breakpoint Register */ |
@@ -225,23 +140,8 @@ | |||
225 | #define SPRN_HID5 0x3F6 /* 970 HID5 */ | 140 | #define SPRN_HID5 0x3F6 /* 970 HID5 */ |
226 | #define SPRN_TSC 0x3FD /* Thread switch control */ | 141 | #define SPRN_TSC 0x3FD /* Thread switch control */ |
227 | #define SPRN_TST 0x3FC /* Thread switch timeout */ | 142 | #define SPRN_TST 0x3FC /* Thread switch timeout */ |
228 | #define SPRN_IAC1 0x3F4 /* Instruction Address Compare 1 */ | ||
229 | #define SPRN_IAC2 0x3F5 /* Instruction Address Compare 2 */ | ||
230 | #define SPRN_ICCR 0x3FB /* Instruction Cache Cacheability Register */ | ||
231 | #define ICCR_NOCACHE 0 /* Noncacheable */ | ||
232 | #define ICCR_CACHE 1 /* Cacheable */ | ||
233 | #define SPRN_ICDBDR 0x3D3 /* Instruction Cache Debug Data Register */ | ||
234 | #define SPRN_ICMP 0x3D5 /* Instruction TLB Compare Register */ | ||
235 | #define SPRN_ICTC 0x3FB /* Instruction Cache Throttling Control Reg */ | ||
236 | #define SPRN_IMISS 0x3D4 /* Instruction TLB Miss Register */ | ||
237 | #define SPRN_IMMR 0x27E /* Internal Memory Map Register */ | ||
238 | #define SPRN_L2CR 0x3F9 /* Level 2 Cache Control Regsiter */ | 143 | #define SPRN_L2CR 0x3F9 /* Level 2 Cache Control Regsiter */ |
239 | #define SPRN_LR 0x008 /* Link Register */ | 144 | #define SPRN_LR 0x008 /* Link Register */ |
240 | #define SPRN_PBL1 0x3FC /* Protection Bound Lower 1 */ | ||
241 | #define SPRN_PBL2 0x3FE /* Protection Bound Lower 2 */ | ||
242 | #define SPRN_PBU1 0x3FD /* Protection Bound Upper 1 */ | ||
243 | #define SPRN_PBU2 0x3FF /* Protection Bound Upper 2 */ | ||
244 | #define SPRN_PID 0x3B1 /* Process ID */ | ||
245 | #define SPRN_PIR 0x3FF /* Processor Identification Register */ | 145 | #define SPRN_PIR 0x3FF /* Processor Identification Register */ |
246 | #define SPRN_PIT 0x3DB /* Programmable Interval Timer */ | 146 | #define SPRN_PIT 0x3DB /* Programmable Interval Timer */ |
247 | #define SPRN_PURR 0x135 /* Processor Utilization of Resources Register */ | 147 | #define SPRN_PURR 0x135 /* Processor Utilization of Resources Register */ |
@@ -249,9 +149,6 @@ | |||
249 | #define SPRN_RPA 0x3D6 /* Required Physical Address Register */ | 149 | #define SPRN_RPA 0x3D6 /* Required Physical Address Register */ |
250 | #define SPRN_SDA 0x3BF /* Sampled Data Address Register */ | 150 | #define SPRN_SDA 0x3BF /* Sampled Data Address Register */ |
251 | #define SPRN_SDR1 0x019 /* MMU Hash Base Register */ | 151 | #define SPRN_SDR1 0x019 /* MMU Hash Base Register */ |
252 | #define SPRN_SGR 0x3B9 /* Storage Guarded Register */ | ||
253 | #define SGR_NORMAL 0 | ||
254 | #define SGR_GUARDED 1 | ||
255 | #define SPRN_SIA 0x3BB /* Sampled Instruction Address Register */ | 152 | #define SPRN_SIA 0x3BB /* Sampled Instruction Address Register */ |
256 | #define SPRN_SPRG0 0x110 /* Special Purpose Register General 0 */ | 153 | #define SPRN_SPRG0 0x110 /* Special Purpose Register General 0 */ |
257 | #define SPRN_SPRG1 0x111 /* Special Purpose Register General 1 */ | 154 | #define SPRN_SPRG1 0x111 /* Special Purpose Register General 1 */ |
@@ -264,50 +161,12 @@ | |||
264 | #define SPRN_TBWL 0x11C /* Time Base Lower Register (super, W/O) */ | 161 | #define SPRN_TBWL 0x11C /* Time Base Lower Register (super, W/O) */ |
265 | #define SPRN_TBWU 0x11D /* Time Base Write Upper Register (super, W/O) */ | 162 | #define SPRN_TBWU 0x11D /* Time Base Write Upper Register (super, W/O) */ |
266 | #define SPRN_HIOR 0x137 /* 970 Hypervisor interrupt offset */ | 163 | #define SPRN_HIOR 0x137 /* 970 Hypervisor interrupt offset */ |
267 | #define SPRN_TCR 0x3DA /* Timer Control Register */ | ||
268 | #define TCR_WP(x) (((x)&0x3)<<30) /* WDT Period */ | ||
269 | #define WP_2_17 0 /* 2^17 clocks */ | ||
270 | #define WP_2_21 1 /* 2^21 clocks */ | ||
271 | #define WP_2_25 2 /* 2^25 clocks */ | ||
272 | #define WP_2_29 3 /* 2^29 clocks */ | ||
273 | #define TCR_WRC(x) (((x)&0x3)<<28) /* WDT Reset Control */ | ||
274 | #define WRC_NONE 0 /* No reset will occur */ | ||
275 | #define WRC_CORE 1 /* Core reset will occur */ | ||
276 | #define WRC_CHIP 2 /* Chip reset will occur */ | ||
277 | #define WRC_SYSTEM 3 /* System reset will occur */ | ||
278 | #define TCR_WIE 0x08000000 /* WDT Interrupt Enable */ | ||
279 | #define TCR_PIE 0x04000000 /* PIT Interrupt Enable */ | ||
280 | #define TCR_FP(x) (((x)&0x3)<<24) /* FIT Period */ | ||
281 | #define FP_2_9 0 /* 2^9 clocks */ | ||
282 | #define FP_2_13 1 /* 2^13 clocks */ | ||
283 | #define FP_2_17 2 /* 2^17 clocks */ | ||
284 | #define FP_2_21 3 /* 2^21 clocks */ | ||
285 | #define TCR_FIE 0x00800000 /* FIT Interrupt Enable */ | ||
286 | #define TCR_ARE 0x00400000 /* Auto Reload Enable */ | ||
287 | #define SPRN_THRM1 0x3FC /* Thermal Management Register 1 */ | ||
288 | #define THRM1_TIN (1<<0) | ||
289 | #define THRM1_TIV (1<<1) | ||
290 | #define THRM1_THRES (0x7f<<2) | ||
291 | #define THRM1_TID (1<<29) | ||
292 | #define THRM1_TIE (1<<30) | ||
293 | #define THRM1_V (1<<31) | ||
294 | #define SPRN_THRM2 0x3FD /* Thermal Management Register 2 */ | ||
295 | #define SPRN_THRM3 0x3FE /* Thermal Management Register 3 */ | ||
296 | #define THRM3_E (1<<31) | ||
297 | #define SPRN_TSR 0x3D8 /* Timer Status Register */ | ||
298 | #define TSR_ENW 0x80000000 /* Enable Next Watchdog */ | ||
299 | #define TSR_WIS 0x40000000 /* WDT Interrupt Status */ | ||
300 | #define TSR_WRS(x) (((x)&0x3)<<28) /* WDT Reset Status */ | ||
301 | #define WRS_NONE 0 /* No WDT reset occurred */ | ||
302 | #define WRS_CORE 1 /* WDT forced core reset */ | ||
303 | #define WRS_CHIP 2 /* WDT forced chip reset */ | ||
304 | #define WRS_SYSTEM 3 /* WDT forced system reset */ | ||
305 | #define TSR_PIS 0x08000000 /* PIT Interrupt Status */ | ||
306 | #define TSR_FIS 0x04000000 /* FIT Interrupt Status */ | ||
307 | #define SPRN_USIA 0x3AB /* User Sampled Instruction Address Register */ | 164 | #define SPRN_USIA 0x3AB /* User Sampled Instruction Address Register */ |
308 | #define SPRN_XER 0x001 /* Fixed Point Exception Register */ | 165 | #define SPRN_XER 0x001 /* Fixed Point Exception Register */ |
309 | #define SPRN_ZPR 0x3B0 /* Zone Protection Register */ | ||
310 | #define SPRN_VRSAVE 0x100 /* Vector save */ | 166 | #define SPRN_VRSAVE 0x100 /* Vector save */ |
167 | #define SPRN_CTRLF 0x088 | ||
168 | #define SPRN_CTRLT 0x098 | ||
169 | #define CTRL_RUNLATCH 0x1 | ||
311 | 170 | ||
312 | /* Performance monitor SPRs */ | 171 | /* Performance monitor SPRs */ |
313 | #define SPRN_SIAR 780 | 172 | #define SPRN_SIAR 780 |
@@ -352,28 +211,19 @@ | |||
352 | #define CTR SPRN_CTR /* Counter Register */ | 211 | #define CTR SPRN_CTR /* Counter Register */ |
353 | #define DAR SPRN_DAR /* Data Address Register */ | 212 | #define DAR SPRN_DAR /* Data Address Register */ |
354 | #define DABR SPRN_DABR /* Data Address Breakpoint Register */ | 213 | #define DABR SPRN_DABR /* Data Address Breakpoint Register */ |
355 | #define DCMP SPRN_DCMP /* Data TLB Compare Register */ | ||
356 | #define DEC SPRN_DEC /* Decrement Register */ | 214 | #define DEC SPRN_DEC /* Decrement Register */ |
357 | #define DMISS SPRN_DMISS /* Data TLB Miss Register */ | ||
358 | #define DSISR SPRN_DSISR /* Data Storage Interrupt Status Register */ | 215 | #define DSISR SPRN_DSISR /* Data Storage Interrupt Status Register */ |
359 | #define EAR SPRN_EAR /* External Address Register */ | ||
360 | #define HASH1 SPRN_HASH1 /* Primary Hash Address Register */ | ||
361 | #define HASH2 SPRN_HASH2 /* Secondary Hash Address Register */ | ||
362 | #define HID0 SPRN_HID0 /* Hardware Implementation Register 0 */ | 216 | #define HID0 SPRN_HID0 /* Hardware Implementation Register 0 */ |
363 | #define MSRDORM SPRN_MSRDORM /* MSR Dormant Register */ | 217 | #define MSRDORM SPRN_MSRDORM /* MSR Dormant Register */ |
364 | #define NIADORM SPRN_NIADORM /* NIA Dormant Register */ | 218 | #define NIADORM SPRN_NIADORM /* NIA Dormant Register */ |
365 | #define TSC SPRN_TSC /* Thread switch control */ | 219 | #define TSC SPRN_TSC /* Thread switch control */ |
366 | #define TST SPRN_TST /* Thread switch timeout */ | 220 | #define TST SPRN_TST /* Thread switch timeout */ |
367 | #define IABR SPRN_IABR /* Instruction Address Breakpoint Register */ | 221 | #define IABR SPRN_IABR /* Instruction Address Breakpoint Register */ |
368 | #define ICMP SPRN_ICMP /* Instruction TLB Compare Register */ | ||
369 | #define IMISS SPRN_IMISS /* Instruction TLB Miss Register */ | ||
370 | #define IMMR SPRN_IMMR /* PPC 860/821 Internal Memory Map Register */ | ||
371 | #define L2CR SPRN_L2CR /* PPC 750 L2 control register */ | 222 | #define L2CR SPRN_L2CR /* PPC 750 L2 control register */ |
372 | #define __LR SPRN_LR | 223 | #define __LR SPRN_LR |
373 | #define PVR SPRN_PVR /* Processor Version */ | 224 | #define PVR SPRN_PVR /* Processor Version */ |
374 | #define PIR SPRN_PIR /* Processor ID */ | 225 | #define PIR SPRN_PIR /* Processor ID */ |
375 | #define PURR SPRN_PURR /* Processor Utilization of Resource Register */ | 226 | #define PURR SPRN_PURR /* Processor Utilization of Resource Register */ |
376 | //#define RPA SPRN_RPA /* Required Physical Address Register */ | ||
377 | #define SDR1 SPRN_SDR1 /* MMU hash base register */ | 227 | #define SDR1 SPRN_SDR1 /* MMU hash base register */ |
378 | #define SPR0 SPRN_SPRG0 /* Supervisor Private Registers */ | 228 | #define SPR0 SPRN_SPRG0 /* Supervisor Private Registers */ |
379 | #define SPR1 SPRN_SPRG1 | 229 | #define SPR1 SPRN_SPRG1 |
@@ -389,10 +239,6 @@ | |||
389 | #define TBRU SPRN_TBRU /* Time Base Read Upper Register */ | 239 | #define TBRU SPRN_TBRU /* Time Base Read Upper Register */ |
390 | #define TBWL SPRN_TBWL /* Time Base Write Lower Register */ | 240 | #define TBWL SPRN_TBWL /* Time Base Write Lower Register */ |
391 | #define TBWU SPRN_TBWU /* Time Base Write Upper Register */ | 241 | #define TBWU SPRN_TBWU /* Time Base Write Upper Register */ |
392 | #define ICTC 1019 | ||
393 | #define THRM1 SPRN_THRM1 /* Thermal Management Register 1 */ | ||
394 | #define THRM2 SPRN_THRM2 /* Thermal Management Register 2 */ | ||
395 | #define THRM3 SPRN_THRM3 /* Thermal Management Register 3 */ | ||
396 | #define XER SPRN_XER | 242 | #define XER SPRN_XER |
397 | 243 | ||
398 | /* Processor Version Register (PVR) field extraction */ | 244 | /* Processor Version Register (PVR) field extraction */ |
@@ -436,12 +282,6 @@ | |||
436 | #define XGLUE(a,b) a##b | 282 | #define XGLUE(a,b) a##b |
437 | #define GLUE(a,b) XGLUE(a,b) | 283 | #define GLUE(a,b) XGLUE(a,b) |
438 | 284 | ||
439 | /* iSeries CTRL register (for runlatch) */ | ||
440 | |||
441 | #define CTRLT 0x098 | ||
442 | #define CTRLF 0x088 | ||
443 | #define RUNLATCH 0x0001 | ||
444 | |||
445 | #ifdef __ASSEMBLY__ | 285 | #ifdef __ASSEMBLY__ |
446 | 286 | ||
447 | #define _GLOBAL(name) \ | 287 | #define _GLOBAL(name) \ |
@@ -656,6 +496,24 @@ static inline void prefetchw(const void *x) | |||
656 | 496 | ||
657 | #define HAVE_ARCH_PICK_MMAP_LAYOUT | 497 | #define HAVE_ARCH_PICK_MMAP_LAYOUT |
658 | 498 | ||
499 | static inline void ppc64_runlatch_on(void) | ||
500 | { | ||
501 | unsigned long ctrl; | ||
502 | |||
503 | ctrl = mfspr(SPRN_CTRLF); | ||
504 | ctrl |= CTRL_RUNLATCH; | ||
505 | mtspr(SPRN_CTRLT, ctrl); | ||
506 | } | ||
507 | |||
508 | static inline void ppc64_runlatch_off(void) | ||
509 | { | ||
510 | unsigned long ctrl; | ||
511 | |||
512 | ctrl = mfspr(SPRN_CTRLF); | ||
513 | ctrl &= ~CTRL_RUNLATCH; | ||
514 | mtspr(SPRN_CTRLT, ctrl); | ||
515 | } | ||
516 | |||
659 | #endif /* __KERNEL__ */ | 517 | #endif /* __KERNEL__ */ |
660 | 518 | ||
661 | #endif /* __ASSEMBLY__ */ | 519 | #endif /* __ASSEMBLY__ */ |
diff --git a/include/asm-ppc64/prom.h b/include/asm-ppc64/prom.h index 2440a2c90ae9..04b1a84f7ca3 100644 --- a/include/asm-ppc64/prom.h +++ b/include/asm-ppc64/prom.h | |||
@@ -147,9 +147,7 @@ struct device_node { | |||
147 | struct device_node *sibling; | 147 | struct device_node *sibling; |
148 | struct device_node *next; /* next device of same type */ | 148 | struct device_node *next; /* next device of same type */ |
149 | struct device_node *allnext; /* next in list of all nodes */ | 149 | struct device_node *allnext; /* next in list of all nodes */ |
150 | struct proc_dir_entry *pde; /* this node's proc directory */ | 150 | struct proc_dir_entry *pde; /* this node's proc directory */ |
151 | struct proc_dir_entry *name_link; /* name symlink */ | ||
152 | struct proc_dir_entry *addr_link; /* addr symlink */ | ||
153 | struct kref kref; | 151 | struct kref kref; |
154 | unsigned long _flags; | 152 | unsigned long _flags; |
155 | }; | 153 | }; |
@@ -174,15 +172,6 @@ static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_e | |||
174 | dn->pde = de; | 172 | dn->pde = de; |
175 | } | 173 | } |
176 | 174 | ||
177 | static void inline set_node_name_link(struct device_node *dn, struct proc_dir_entry *de) | ||
178 | { | ||
179 | dn->name_link = de; | ||
180 | } | ||
181 | |||
182 | static void inline set_node_addr_link(struct device_node *dn, struct proc_dir_entry *de) | ||
183 | { | ||
184 | dn->addr_link = de; | ||
185 | } | ||
186 | 175 | ||
187 | /* OBSOLETE: Old stlye node lookup */ | 176 | /* OBSOLETE: Old stlye node lookup */ |
188 | extern struct device_node *find_devices(const char *name); | 177 | extern struct device_node *find_devices(const char *name); |
diff --git a/include/asm-ppc64/thread_info.h b/include/asm-ppc64/thread_info.h index 037b5e06083c..48b7900e90ec 100644 --- a/include/asm-ppc64/thread_info.h +++ b/include/asm-ppc64/thread_info.h | |||
@@ -96,7 +96,7 @@ static inline struct thread_info *current_thread_info(void) | |||
96 | #define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling | 96 | #define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling |
97 | TIF_NEED_RESCHED */ | 97 | TIF_NEED_RESCHED */ |
98 | #define TIF_32BIT 5 /* 32 bit binary */ | 98 | #define TIF_32BIT 5 /* 32 bit binary */ |
99 | #define TIF_RUN_LIGHT 6 /* iSeries run light */ | 99 | /* #define SPARE 6 */ |
100 | #define TIF_ABI_PENDING 7 /* 32/64 bit switch needed */ | 100 | #define TIF_ABI_PENDING 7 /* 32/64 bit switch needed */ |
101 | #define TIF_SYSCALL_AUDIT 8 /* syscall auditing active */ | 101 | #define TIF_SYSCALL_AUDIT 8 /* syscall auditing active */ |
102 | #define TIF_SINGLESTEP 9 /* singlestepping active */ | 102 | #define TIF_SINGLESTEP 9 /* singlestepping active */ |
@@ -110,7 +110,7 @@ static inline struct thread_info *current_thread_info(void) | |||
110 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) | 110 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) |
111 | #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) | 111 | #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) |
112 | #define _TIF_32BIT (1<<TIF_32BIT) | 112 | #define _TIF_32BIT (1<<TIF_32BIT) |
113 | #define _TIF_RUN_LIGHT (1<<TIF_RUN_LIGHT) | 113 | /* #define _SPARE (1<<SPARE) */ |
114 | #define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) | 114 | #define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) |
115 | #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) | 115 | #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) |
116 | #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) | 116 | #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) |
diff --git a/include/asm-s390/user.h b/include/asm-s390/user.h index c64f8c181df3..1dc74baf03c4 100644 --- a/include/asm-s390/user.h +++ b/include/asm-s390/user.h | |||
@@ -10,7 +10,7 @@ | |||
10 | #define _S390_USER_H | 10 | #define _S390_USER_H |
11 | 11 | ||
12 | #include <asm/page.h> | 12 | #include <asm/page.h> |
13 | #include <linux/ptrace.h> | 13 | #include <asm/ptrace.h> |
14 | /* Core file format: The core file is written in such a way that gdb | 14 | /* Core file format: The core file is written in such a way that gdb |
15 | can understand it and provide useful information to the user (under | 15 | can understand it and provide useful information to the user (under |
16 | linux we use the 'trad-core' bfd). There are quite a number of | 16 | linux we use the 'trad-core' bfd). There are quite a number of |
diff --git a/include/asm-sparc64/agp.h b/include/asm-sparc64/agp.h index ba05bdf9a211..58f8cb6ae767 100644 --- a/include/asm-sparc64/agp.h +++ b/include/asm-sparc64/agp.h | |||
@@ -8,4 +8,14 @@ | |||
8 | #define flush_agp_mappings() | 8 | #define flush_agp_mappings() |
9 | #define flush_agp_cache() mb() | 9 | #define flush_agp_cache() mb() |
10 | 10 | ||
11 | /* Convert a physical address to an address suitable for the GART. */ | ||
12 | #define phys_to_gart(x) (x) | ||
13 | #define gart_to_phys(x) (x) | ||
14 | |||
15 | /* GATT allocation. Returns/accepts GATT kernel virtual address. */ | ||
16 | #define alloc_gatt_pages(order) \ | ||
17 | ((char *)__get_free_pages(GFP_KERNEL, (order))) | ||
18 | #define free_gatt_pages(table, order) \ | ||
19 | free_pages((unsigned long)(table), (order)) | ||
20 | |||
11 | #endif | 21 | #endif |
diff --git a/include/asm-sparc64/iommu.h b/include/asm-sparc64/iommu.h index 5fd16e42a045..0de7a3da79cd 100644 --- a/include/asm-sparc64/iommu.h +++ b/include/asm-sparc64/iommu.h | |||
@@ -16,4 +16,6 @@ | |||
16 | #define IOPTE_CACHE 0x0000000000000010UL /* Cached (in UPA E-cache) */ | 16 | #define IOPTE_CACHE 0x0000000000000010UL /* Cached (in UPA E-cache) */ |
17 | #define IOPTE_WRITE 0x0000000000000002UL /* Writeable */ | 17 | #define IOPTE_WRITE 0x0000000000000002UL /* Writeable */ |
18 | 18 | ||
19 | #define IOMMU_NUM_CTXS 4096 | ||
20 | |||
19 | #endif /* !(_SPARC_IOMMU_H) */ | 21 | #endif /* !(_SPARC_IOMMU_H) */ |
diff --git a/include/asm-sparc64/pbm.h b/include/asm-sparc64/pbm.h index 92999631c819..4c15610a2bac 100644 --- a/include/asm-sparc64/pbm.h +++ b/include/asm-sparc64/pbm.h | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <asm/io.h> | 15 | #include <asm/io.h> |
16 | #include <asm/page.h> | 16 | #include <asm/page.h> |
17 | #include <asm/oplib.h> | 17 | #include <asm/oplib.h> |
18 | #include <asm/iommu.h> | ||
18 | 19 | ||
19 | /* The abstraction used here is that there are PCI controllers, | 20 | /* The abstraction used here is that there are PCI controllers, |
20 | * each with one (Sabre) or two (PSYCHO/SCHIZO) PCI bus modules | 21 | * each with one (Sabre) or two (PSYCHO/SCHIZO) PCI bus modules |
@@ -40,9 +41,6 @@ struct pci_iommu { | |||
40 | */ | 41 | */ |
41 | spinlock_t lock; | 42 | spinlock_t lock; |
42 | 43 | ||
43 | /* Context allocator. */ | ||
44 | unsigned int iommu_cur_ctx; | ||
45 | |||
46 | /* IOMMU page table, a linear array of ioptes. */ | 44 | /* IOMMU page table, a linear array of ioptes. */ |
47 | iopte_t *page_table; /* The page table itself. */ | 45 | iopte_t *page_table; /* The page table itself. */ |
48 | int page_table_sz_bits; /* log2 of ow many pages does it map? */ | 46 | int page_table_sz_bits; /* log2 of ow many pages does it map? */ |
@@ -87,6 +85,10 @@ struct pci_iommu { | |||
87 | u16 flush; | 85 | u16 flush; |
88 | } alloc_info[PBM_NCLUSTERS]; | 86 | } alloc_info[PBM_NCLUSTERS]; |
89 | 87 | ||
88 | /* CTX allocation. */ | ||
89 | unsigned long ctx_lowest_free; | ||
90 | unsigned long ctx_bitmap[IOMMU_NUM_CTXS / (sizeof(unsigned long) * 8)]; | ||
91 | |||
90 | /* Here a PCI controller driver describes the areas of | 92 | /* Here a PCI controller driver describes the areas of |
91 | * PCI memory space where DMA to/from physical memory | 93 | * PCI memory space where DMA to/from physical memory |
92 | * are addressed. Drivers interrogate the PCI layer | 94 | * are addressed. Drivers interrogate the PCI layer |
diff --git a/include/asm-x86_64/agp.h b/include/asm-x86_64/agp.h index 0bb9019d58aa..06c52ee9c06b 100644 --- a/include/asm-x86_64/agp.h +++ b/include/asm-x86_64/agp.h | |||
@@ -19,4 +19,14 @@ int unmap_page_from_agp(struct page *page); | |||
19 | worth it. Would need a page for it. */ | 19 | worth it. Would need a page for it. */ |
20 | #define flush_agp_cache() asm volatile("wbinvd":::"memory") | 20 | #define flush_agp_cache() asm volatile("wbinvd":::"memory") |
21 | 21 | ||
22 | /* Convert a physical address to an address suitable for the GART. */ | ||
23 | #define phys_to_gart(x) (x) | ||
24 | #define gart_to_phys(x) (x) | ||
25 | |||
26 | /* GATT allocation. Returns/accepts GATT kernel virtual address. */ | ||
27 | #define alloc_gatt_pages(order) \ | ||
28 | ((char *)__get_free_pages(GFP_KERNEL, (order))) | ||
29 | #define free_gatt_pages(table, order) \ | ||
30 | free_pages((unsigned long)(table), (order)) | ||
31 | |||
22 | #endif | 32 | #endif |
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index d5a55bdb9c3c..b123cc08773d 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
@@ -25,6 +25,8 @@ | |||
25 | #ifndef _LINUX_ACPI_H | 25 | #ifndef _LINUX_ACPI_H |
26 | #define _LINUX_ACPI_H | 26 | #define _LINUX_ACPI_H |
27 | 27 | ||
28 | #include <linux/config.h> | ||
29 | |||
28 | #ifdef CONFIG_ACPI | 30 | #ifdef CONFIG_ACPI |
29 | 31 | ||
30 | #ifndef _LINUX | 32 | #ifndef _LINUX |
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index f21af067d015..927daa86c9b3 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h | |||
@@ -49,7 +49,7 @@ int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list); | |||
49 | /* Frequency values here are CPU kHz so that hardware which doesn't run | 49 | /* Frequency values here are CPU kHz so that hardware which doesn't run |
50 | * with some frequencies can complain without having to guess what per | 50 | * with some frequencies can complain without having to guess what per |
51 | * cent / per mille means. | 51 | * cent / per mille means. |
52 | * Maximum transition latency is in microseconds - if it's unknown, | 52 | * Maximum transition latency is in nanoseconds - if it's unknown, |
53 | * CPUFREQ_ETERNAL shall be used. | 53 | * CPUFREQ_ETERNAL shall be used. |
54 | */ | 54 | */ |
55 | 55 | ||
diff --git a/include/linux/if_shaper.h b/include/linux/if_shaper.h index 0485b256d043..004e6f09a6e2 100644 --- a/include/linux/if_shaper.h +++ b/include/linux/if_shaper.h | |||
@@ -23,7 +23,7 @@ struct shaper | |||
23 | __u32 shapeclock; | 23 | __u32 shapeclock; |
24 | unsigned long recovery; /* Time we can next clock a packet out on | 24 | unsigned long recovery; /* Time we can next clock a packet out on |
25 | an empty queue */ | 25 | an empty queue */ |
26 | unsigned long locked; | 26 | struct semaphore sem; |
27 | struct net_device_stats stats; | 27 | struct net_device_stats stats; |
28 | struct net_device *dev; | 28 | struct net_device *dev; |
29 | int (*hard_start_xmit) (struct sk_buff *skb, | 29 | int (*hard_start_xmit) (struct sk_buff *skb, |
@@ -38,7 +38,6 @@ struct shaper | |||
38 | int (*hard_header_cache)(struct neighbour *neigh, struct hh_cache *hh); | 38 | int (*hard_header_cache)(struct neighbour *neigh, struct hh_cache *hh); |
39 | void (*header_cache_update)(struct hh_cache *hh, struct net_device *dev, unsigned char * haddr); | 39 | void (*header_cache_update)(struct hh_cache *hh, struct net_device *dev, unsigned char * haddr); |
40 | struct net_device_stats* (*get_stats)(struct net_device *dev); | 40 | struct net_device_stats* (*get_stats)(struct net_device *dev); |
41 | wait_queue_head_t wait_queue; | ||
42 | struct timer_list timer; | 41 | struct timer_list timer; |
43 | }; | 42 | }; |
44 | 43 | ||
diff --git a/include/linux/libata.h b/include/linux/libata.h index e74f301e9bae..b009f801e7c5 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -467,12 +467,34 @@ static inline u8 ata_chk_status(struct ata_port *ap) | |||
467 | return ap->ops->check_status(ap); | 467 | return ap->ops->check_status(ap); |
468 | } | 468 | } |
469 | 469 | ||
470 | |||
471 | /** | ||
472 | * ata_pause - Flush writes and pause 400 nanoseconds. | ||
473 | * @ap: Port to wait for. | ||
474 | * | ||
475 | * LOCKING: | ||
476 | * Inherited from caller. | ||
477 | */ | ||
478 | |||
470 | static inline void ata_pause(struct ata_port *ap) | 479 | static inline void ata_pause(struct ata_port *ap) |
471 | { | 480 | { |
472 | ata_altstatus(ap); | 481 | ata_altstatus(ap); |
473 | ndelay(400); | 482 | ndelay(400); |
474 | } | 483 | } |
475 | 484 | ||
485 | |||
486 | /** | ||
487 | * ata_busy_wait - Wait for a port status register | ||
488 | * @ap: Port to wait for. | ||
489 | * | ||
490 | * Waits up to max*10 microseconds for the selected bits in the port's | ||
491 | * status register to be cleared. | ||
492 | * Returns final value of status register. | ||
493 | * | ||
494 | * LOCKING: | ||
495 | * Inherited from caller. | ||
496 | */ | ||
497 | |||
476 | static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits, | 498 | static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits, |
477 | unsigned int max) | 499 | unsigned int max) |
478 | { | 500 | { |
@@ -487,6 +509,18 @@ static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits, | |||
487 | return status; | 509 | return status; |
488 | } | 510 | } |
489 | 511 | ||
512 | |||
513 | /** | ||
514 | * ata_wait_idle - Wait for a port to be idle. | ||
515 | * @ap: Port to wait for. | ||
516 | * | ||
517 | * Waits up to 10ms for port's BUSY and DRQ signals to clear. | ||
518 | * Returns final value of status register. | ||
519 | * | ||
520 | * LOCKING: | ||
521 | * Inherited from caller. | ||
522 | */ | ||
523 | |||
490 | static inline u8 ata_wait_idle(struct ata_port *ap) | 524 | static inline u8 ata_wait_idle(struct ata_port *ap) |
491 | { | 525 | { |
492 | u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); | 526 | u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); |
@@ -525,6 +559,18 @@ static inline void ata_tf_init(struct ata_port *ap, struct ata_taskfile *tf, uns | |||
525 | tf->device = ATA_DEVICE_OBS | ATA_DEV1; | 559 | tf->device = ATA_DEVICE_OBS | ATA_DEV1; |
526 | } | 560 | } |
527 | 561 | ||
562 | |||
563 | /** | ||
564 | * ata_irq_on - Enable interrupts on a port. | ||
565 | * @ap: Port on which interrupts are enabled. | ||
566 | * | ||
567 | * Enable interrupts on a legacy IDE device using MMIO or PIO, | ||
568 | * wait for idle, clear any pending interrupts. | ||
569 | * | ||
570 | * LOCKING: | ||
571 | * Inherited from caller. | ||
572 | */ | ||
573 | |||
528 | static inline u8 ata_irq_on(struct ata_port *ap) | 574 | static inline u8 ata_irq_on(struct ata_port *ap) |
529 | { | 575 | { |
530 | struct ata_ioports *ioaddr = &ap->ioaddr; | 576 | struct ata_ioports *ioaddr = &ap->ioaddr; |
@@ -544,6 +590,18 @@ static inline u8 ata_irq_on(struct ata_port *ap) | |||
544 | return tmp; | 590 | return tmp; |
545 | } | 591 | } |
546 | 592 | ||
593 | |||
594 | /** | ||
595 | * ata_irq_ack - Acknowledge a device interrupt. | ||
596 | * @ap: Port on which interrupts are enabled. | ||
597 | * | ||
598 | * Wait up to 10 ms for legacy IDE device to become idle (BUSY | ||
599 | * or BUSY+DRQ clear). Obtain dma status and port status from | ||
600 | * device. Clear the interrupt. Return port status. | ||
601 | * | ||
602 | * LOCKING: | ||
603 | */ | ||
604 | |||
547 | static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) | 605 | static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) |
548 | { | 606 | { |
549 | unsigned int bits = chk_drq ? ATA_BUSY | ATA_DRQ : ATA_BUSY; | 607 | unsigned int bits = chk_drq ? ATA_BUSY | ATA_DRQ : ATA_BUSY; |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 470af8c1a4a0..ba5d1236aa17 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -204,7 +204,7 @@ struct hh_cache | |||
204 | /* cached hardware header; allow for machine alignment needs. */ | 204 | /* cached hardware header; allow for machine alignment needs. */ |
205 | #define HH_DATA_MOD 16 | 205 | #define HH_DATA_MOD 16 |
206 | #define HH_DATA_OFF(__len) \ | 206 | #define HH_DATA_OFF(__len) \ |
207 | (HH_DATA_MOD - ((__len) & (HH_DATA_MOD - 1))) | 207 | (HH_DATA_MOD - (((__len - 1) & (HH_DATA_MOD - 1)) + 1)) |
208 | #define HH_DATA_ALIGN(__len) \ | 208 | #define HH_DATA_ALIGN(__len) \ |
209 | (((__len)+(HH_DATA_MOD-1))&~(HH_DATA_MOD - 1)) | 209 | (((__len)+(HH_DATA_MOD-1))&~(HH_DATA_MOD - 1)) |
210 | unsigned long hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)]; | 210 | unsigned long hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)]; |
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 7ccbc2e4272c..18f734ec9181 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h | |||
@@ -1230,6 +1230,12 @@ | |||
1230 | #define PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL 0x0258 | 1230 | #define PCI_DEVICE_ID_NVIDIA_QUADRO4_900XGL 0x0258 |
1231 | #define PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL 0x0259 | 1231 | #define PCI_DEVICE_ID_NVIDIA_QUADRO4_750XGL 0x0259 |
1232 | #define PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL 0x025B | 1232 | #define PCI_DEVICE_ID_NVIDIA_QUADRO4_700XGL 0x025B |
1233 | #define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE 0x0265 | ||
1234 | #define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA 0x0266 | ||
1235 | #define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA2 0x0267 | ||
1236 | #define PCI_DEVICE_ID_NVIDIA_NVENET_12 0x0268 | ||
1237 | #define PCI_DEVICE_ID_NVIDIA_NVENET_13 0x0269 | ||
1238 | #define PCI_DEVICE_ID_NVIDIA_MCP51_AUDIO 0x026B | ||
1233 | #define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800 0x0280 | 1239 | #define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800 0x0280 |
1234 | #define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800_8X 0x0281 | 1240 | #define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800_8X 0x0281 |
1235 | #define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800SE 0x0282 | 1241 | #define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800SE 0x0282 |
@@ -2376,6 +2382,8 @@ | |||
2376 | #define PCI_DEVICE_ID_INTEL_82915G_IG 0x2582 | 2382 | #define PCI_DEVICE_ID_INTEL_82915G_IG 0x2582 |
2377 | #define PCI_DEVICE_ID_INTEL_82915GM_HB 0x2590 | 2383 | #define PCI_DEVICE_ID_INTEL_82915GM_HB 0x2590 |
2378 | #define PCI_DEVICE_ID_INTEL_82915GM_IG 0x2592 | 2384 | #define PCI_DEVICE_ID_INTEL_82915GM_IG 0x2592 |
2385 | #define PCI_DEVICE_ID_INTEL_82945G_HB 0x2770 | ||
2386 | #define PCI_DEVICE_ID_INTEL_82945G_IG 0x2772 | ||
2379 | #define PCI_DEVICE_ID_INTEL_ICH6_0 0x2640 | 2387 | #define PCI_DEVICE_ID_INTEL_ICH6_0 0x2640 |
2380 | #define PCI_DEVICE_ID_INTEL_ICH6_1 0x2641 | 2388 | #define PCI_DEVICE_ID_INTEL_ICH6_1 0x2641 |
2381 | #define PCI_DEVICE_ID_INTEL_ICH6_2 0x2642 | 2389 | #define PCI_DEVICE_ID_INTEL_ICH6_2 0x2642 |
diff --git a/include/linux/usb.h b/include/linux/usb.h index 41d1a644c9d4..2d1ac5058534 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
@@ -796,6 +796,10 @@ typedef void (*usb_complete_t)(struct urb *, struct pt_regs *); | |||
796 | * of the iso_frame_desc array, and the number of errors is reported in | 796 | * of the iso_frame_desc array, and the number of errors is reported in |
797 | * error_count. Completion callbacks for ISO transfers will normally | 797 | * error_count. Completion callbacks for ISO transfers will normally |
798 | * (re)submit URBs to ensure a constant transfer rate. | 798 | * (re)submit URBs to ensure a constant transfer rate. |
799 | * | ||
800 | * Note that even fields marked "public" should not be touched by the driver | ||
801 | * when the urb is owned by the hcd, that is, since the call to | ||
802 | * usb_submit_urb() till the entry into the completion routine. | ||
799 | */ | 803 | */ |
800 | struct urb | 804 | struct urb |
801 | { | 805 | { |
@@ -803,12 +807,12 @@ struct urb | |||
803 | struct kref kref; /* reference count of the URB */ | 807 | struct kref kref; /* reference count of the URB */ |
804 | spinlock_t lock; /* lock for the URB */ | 808 | spinlock_t lock; /* lock for the URB */ |
805 | void *hcpriv; /* private data for host controller */ | 809 | void *hcpriv; /* private data for host controller */ |
806 | struct list_head urb_list; /* list pointer to all active urbs */ | ||
807 | int bandwidth; /* bandwidth for INT/ISO request */ | 810 | int bandwidth; /* bandwidth for INT/ISO request */ |
808 | atomic_t use_count; /* concurrent submissions counter */ | 811 | atomic_t use_count; /* concurrent submissions counter */ |
809 | u8 reject; /* submissions will fail */ | 812 | u8 reject; /* submissions will fail */ |
810 | 813 | ||
811 | /* public, documented fields in the urb that can be used by drivers */ | 814 | /* public, documented fields in the urb that can be used by drivers */ |
815 | struct list_head urb_list; /* list head for use by the urb owner */ | ||
812 | struct usb_device *dev; /* (in) pointer to associated device */ | 816 | struct usb_device *dev; /* (in) pointer to associated device */ |
813 | unsigned int pipe; /* (in) pipe information */ | 817 | unsigned int pipe; /* (in) pipe information */ |
814 | int status; /* (return) non-ISO status */ | 818 | int status; /* (return) non-ISO status */ |
diff --git a/kernel/module.c b/kernel/module.c index 5734ab09d3f9..83b3d376708c 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -1758,6 +1758,7 @@ sys_init_module(void __user *umod, | |||
1758 | const char __user *uargs) | 1758 | const char __user *uargs) |
1759 | { | 1759 | { |
1760 | struct module *mod; | 1760 | struct module *mod; |
1761 | mm_segment_t old_fs = get_fs(); | ||
1761 | int ret = 0; | 1762 | int ret = 0; |
1762 | 1763 | ||
1763 | /* Must have permission */ | 1764 | /* Must have permission */ |
@@ -1775,6 +1776,9 @@ sys_init_module(void __user *umod, | |||
1775 | return PTR_ERR(mod); | 1776 | return PTR_ERR(mod); |
1776 | } | 1777 | } |
1777 | 1778 | ||
1779 | /* flush the icache in correct context */ | ||
1780 | set_fs(KERNEL_DS); | ||
1781 | |||
1778 | /* Flush the instruction cache, since we've played with text */ | 1782 | /* Flush the instruction cache, since we've played with text */ |
1779 | if (mod->module_init) | 1783 | if (mod->module_init) |
1780 | flush_icache_range((unsigned long)mod->module_init, | 1784 | flush_icache_range((unsigned long)mod->module_init, |
@@ -1783,6 +1787,8 @@ sys_init_module(void __user *umod, | |||
1783 | flush_icache_range((unsigned long)mod->module_core, | 1787 | flush_icache_range((unsigned long)mod->module_core, |
1784 | (unsigned long)mod->module_core + mod->core_size); | 1788 | (unsigned long)mod->module_core + mod->core_size); |
1785 | 1789 | ||
1790 | set_fs(old_fs); | ||
1791 | |||
1786 | /* Now sew it into the lists. They won't access us, since | 1792 | /* Now sew it into the lists. They won't access us, since |
1787 | strong_try_module_get() will fail. */ | 1793 | strong_try_module_get() will fail. */ |
1788 | stop_machine_run(__link_module, mod, NR_CPUS); | 1794 | stop_machine_run(__link_module, mod, NR_CPUS); |
diff --git a/mm/filemap.c b/mm/filemap.c index 1d33fec7bac6..4a2fee2cb62b 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -1968,6 +1968,7 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, | |||
1968 | do { | 1968 | do { |
1969 | unsigned long index; | 1969 | unsigned long index; |
1970 | unsigned long offset; | 1970 | unsigned long offset; |
1971 | unsigned long maxlen; | ||
1971 | size_t copied; | 1972 | size_t copied; |
1972 | 1973 | ||
1973 | offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */ | 1974 | offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */ |
@@ -1982,7 +1983,10 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, | |||
1982 | * same page as we're writing to, without it being marked | 1983 | * same page as we're writing to, without it being marked |
1983 | * up-to-date. | 1984 | * up-to-date. |
1984 | */ | 1985 | */ |
1985 | fault_in_pages_readable(buf, bytes); | 1986 | maxlen = cur_iov->iov_len - iov_base; |
1987 | if (maxlen > bytes) | ||
1988 | maxlen = bytes; | ||
1989 | fault_in_pages_readable(buf, maxlen); | ||
1986 | 1990 | ||
1987 | page = __grab_cache_page(mapping,index,&cached_page,&lru_pvec); | 1991 | page = __grab_cache_page(mapping,index,&cached_page,&lru_pvec); |
1988 | if (!page) { | 1992 | if (!page) { |
@@ -2024,6 +2028,8 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, | |||
2024 | filemap_set_next_iovec(&cur_iov, | 2028 | filemap_set_next_iovec(&cur_iov, |
2025 | &iov_base, status); | 2029 | &iov_base, status); |
2026 | buf = cur_iov->iov_base + iov_base; | 2030 | buf = cur_iov->iov_base + iov_base; |
2031 | } else { | ||
2032 | iov_base += status; | ||
2027 | } | 2033 | } |
2028 | } | 2034 | } |
2029 | } | 2035 | } |
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 8ec484894d68..a3eeb88e1c81 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
@@ -356,7 +356,7 @@ static int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr) | |||
356 | { | 356 | { |
357 | struct ethtool_coalesce coalesce; | 357 | struct ethtool_coalesce coalesce; |
358 | 358 | ||
359 | if (!dev->ethtool_ops->get_coalesce) | 359 | if (!dev->ethtool_ops->set_coalesce) |
360 | return -EOPNOTSUPP; | 360 | return -EOPNOTSUPP; |
361 | 361 | ||
362 | if (copy_from_user(&coalesce, useraddr, sizeof(coalesce))) | 362 | if (copy_from_user(&coalesce, useraddr, sizeof(coalesce))) |
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c index 053a883247ba..eae84cc39d3f 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c | |||
@@ -478,7 +478,7 @@ static int __init esp4_init(void) | |||
478 | { | 478 | { |
479 | struct xfrm_decap_state decap; | 479 | struct xfrm_decap_state decap; |
480 | 480 | ||
481 | if (sizeof(struct esp_decap_data) < | 481 | if (sizeof(struct esp_decap_data) > |
482 | sizeof(decap.decap_data)) { | 482 | sizeof(decap.decap_data)) { |
483 | extern void decap_data_too_small(void); | 483 | extern void decap_data_too_small(void); |
484 | 484 | ||
diff --git a/net/ipv4/ipvs/Makefile b/net/ipv4/ipvs/Makefile index a788461a40c9..30e85de9ffff 100644 --- a/net/ipv4/ipvs/Makefile +++ b/net/ipv4/ipvs/Makefile | |||
@@ -11,7 +11,7 @@ ip_vs_proto-objs-$(CONFIG_IP_VS_PROTO_AH) += ip_vs_proto_ah.o | |||
11 | 11 | ||
12 | ip_vs-objs := ip_vs_conn.o ip_vs_core.o ip_vs_ctl.o ip_vs_sched.o \ | 12 | ip_vs-objs := ip_vs_conn.o ip_vs_core.o ip_vs_ctl.o ip_vs_sched.o \ |
13 | ip_vs_xmit.o ip_vs_app.o ip_vs_sync.o \ | 13 | ip_vs_xmit.o ip_vs_app.o ip_vs_sync.o \ |
14 | ip_vs_est.o ip_vs_proto.o ip_vs_proto_icmp.o \ | 14 | ip_vs_est.o ip_vs_proto.o \ |
15 | $(ip_vs_proto-objs-y) | 15 | $(ip_vs_proto-objs-y) |
16 | 16 | ||
17 | 17 | ||
diff --git a/net/ipv4/ipvs/ip_vs_proto.c b/net/ipv4/ipvs/ip_vs_proto.c index 253c46252bd5..867d4e9c6594 100644 --- a/net/ipv4/ipvs/ip_vs_proto.c +++ b/net/ipv4/ipvs/ip_vs_proto.c | |||
@@ -216,9 +216,6 @@ int ip_vs_protocol_init(void) | |||
216 | #ifdef CONFIG_IP_VS_PROTO_UDP | 216 | #ifdef CONFIG_IP_VS_PROTO_UDP |
217 | REGISTER_PROTOCOL(&ip_vs_protocol_udp); | 217 | REGISTER_PROTOCOL(&ip_vs_protocol_udp); |
218 | #endif | 218 | #endif |
219 | #ifdef CONFIG_IP_VS_PROTO_ICMP | ||
220 | REGISTER_PROTOCOL(&ip_vs_protocol_icmp); | ||
221 | #endif | ||
222 | #ifdef CONFIG_IP_VS_PROTO_AH | 219 | #ifdef CONFIG_IP_VS_PROTO_AH |
223 | REGISTER_PROTOCOL(&ip_vs_protocol_ah); | 220 | REGISTER_PROTOCOL(&ip_vs_protocol_ah); |
224 | #endif | 221 | #endif |
diff --git a/net/ipv4/ipvs/ip_vs_proto_icmp.c b/net/ipv4/ipvs/ip_vs_proto_icmp.c deleted file mode 100644 index 191e94aa1c1f..000000000000 --- a/net/ipv4/ipvs/ip_vs_proto_icmp.c +++ /dev/null | |||
@@ -1,182 +0,0 @@ | |||
1 | /* | ||
2 | * ip_vs_proto_icmp.c: ICMP load balancing support for IP Virtual Server | ||
3 | * | ||
4 | * Authors: Julian Anastasov <ja@ssi.bg>, March 2002 | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation; | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/icmp.h> | ||
15 | #include <linux/netfilter.h> | ||
16 | #include <linux/netfilter_ipv4.h> | ||
17 | |||
18 | #include <net/ip_vs.h> | ||
19 | |||
20 | |||
21 | static int icmp_timeouts[1] = { 1*60*HZ }; | ||
22 | |||
23 | static char * icmp_state_name_table[1] = { "ICMP" }; | ||
24 | |||
25 | static struct ip_vs_conn * | ||
26 | icmp_conn_in_get(const struct sk_buff *skb, | ||
27 | struct ip_vs_protocol *pp, | ||
28 | const struct iphdr *iph, | ||
29 | unsigned int proto_off, | ||
30 | int inverse) | ||
31 | { | ||
32 | #if 0 | ||
33 | struct ip_vs_conn *cp; | ||
34 | |||
35 | if (likely(!inverse)) { | ||
36 | cp = ip_vs_conn_in_get(iph->protocol, | ||
37 | iph->saddr, 0, | ||
38 | iph->daddr, 0); | ||
39 | } else { | ||
40 | cp = ip_vs_conn_in_get(iph->protocol, | ||
41 | iph->daddr, 0, | ||
42 | iph->saddr, 0); | ||
43 | } | ||
44 | |||
45 | return cp; | ||
46 | |||
47 | #else | ||
48 | return NULL; | ||
49 | #endif | ||
50 | } | ||
51 | |||
52 | static struct ip_vs_conn * | ||
53 | icmp_conn_out_get(const struct sk_buff *skb, | ||
54 | struct ip_vs_protocol *pp, | ||
55 | const struct iphdr *iph, | ||
56 | unsigned int proto_off, | ||
57 | int inverse) | ||
58 | { | ||
59 | #if 0 | ||
60 | struct ip_vs_conn *cp; | ||
61 | |||
62 | if (likely(!inverse)) { | ||
63 | cp = ip_vs_conn_out_get(iph->protocol, | ||
64 | iph->saddr, 0, | ||
65 | iph->daddr, 0); | ||
66 | } else { | ||
67 | cp = ip_vs_conn_out_get(IPPROTO_UDP, | ||
68 | iph->daddr, 0, | ||
69 | iph->saddr, 0); | ||
70 | } | ||
71 | |||
72 | return cp; | ||
73 | #else | ||
74 | return NULL; | ||
75 | #endif | ||
76 | } | ||
77 | |||
78 | static int | ||
79 | icmp_conn_schedule(struct sk_buff *skb, struct ip_vs_protocol *pp, | ||
80 | int *verdict, struct ip_vs_conn **cpp) | ||
81 | { | ||
82 | *verdict = NF_ACCEPT; | ||
83 | return 0; | ||
84 | } | ||
85 | |||
86 | static int | ||
87 | icmp_csum_check(struct sk_buff *skb, struct ip_vs_protocol *pp) | ||
88 | { | ||
89 | if (!(skb->nh.iph->frag_off & __constant_htons(IP_OFFSET))) { | ||
90 | if (skb->ip_summed != CHECKSUM_UNNECESSARY) { | ||
91 | if (ip_vs_checksum_complete(skb, skb->nh.iph->ihl * 4)) { | ||
92 | IP_VS_DBG_RL_PKT(0, pp, skb, 0, "Failed checksum for"); | ||
93 | return 0; | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | return 1; | ||
98 | } | ||
99 | |||
100 | static void | ||
101 | icmp_debug_packet(struct ip_vs_protocol *pp, | ||
102 | const struct sk_buff *skb, | ||
103 | int offset, | ||
104 | const char *msg) | ||
105 | { | ||
106 | char buf[256]; | ||
107 | struct iphdr _iph, *ih; | ||
108 | |||
109 | ih = skb_header_pointer(skb, offset, sizeof(_iph), &_iph); | ||
110 | if (ih == NULL) | ||
111 | sprintf(buf, "%s TRUNCATED", pp->name); | ||
112 | else if (ih->frag_off & __constant_htons(IP_OFFSET)) | ||
113 | sprintf(buf, "%s %u.%u.%u.%u->%u.%u.%u.%u frag", | ||
114 | pp->name, NIPQUAD(ih->saddr), | ||
115 | NIPQUAD(ih->daddr)); | ||
116 | else { | ||
117 | struct icmphdr _icmph, *ic; | ||
118 | |||
119 | ic = skb_header_pointer(skb, offset + ih->ihl*4, | ||
120 | sizeof(_icmph), &_icmph); | ||
121 | if (ic == NULL) | ||
122 | sprintf(buf, "%s TRUNCATED to %u bytes\n", | ||
123 | pp->name, skb->len - offset); | ||
124 | else | ||
125 | sprintf(buf, "%s %u.%u.%u.%u->%u.%u.%u.%u T:%d C:%d", | ||
126 | pp->name, NIPQUAD(ih->saddr), | ||
127 | NIPQUAD(ih->daddr), | ||
128 | ic->type, ic->code); | ||
129 | } | ||
130 | printk(KERN_DEBUG "IPVS: %s: %s\n", msg, buf); | ||
131 | } | ||
132 | |||
133 | static int | ||
134 | icmp_state_transition(struct ip_vs_conn *cp, int direction, | ||
135 | const struct sk_buff *skb, | ||
136 | struct ip_vs_protocol *pp) | ||
137 | { | ||
138 | cp->timeout = pp->timeout_table[IP_VS_ICMP_S_NORMAL]; | ||
139 | return 1; | ||
140 | } | ||
141 | |||
142 | static int | ||
143 | icmp_set_state_timeout(struct ip_vs_protocol *pp, char *sname, int to) | ||
144 | { | ||
145 | int num; | ||
146 | char **names; | ||
147 | |||
148 | num = IP_VS_ICMP_S_LAST; | ||
149 | names = icmp_state_name_table; | ||
150 | return ip_vs_set_state_timeout(pp->timeout_table, num, names, sname, to); | ||
151 | } | ||
152 | |||
153 | |||
154 | static void icmp_init(struct ip_vs_protocol *pp) | ||
155 | { | ||
156 | pp->timeout_table = icmp_timeouts; | ||
157 | } | ||
158 | |||
159 | static void icmp_exit(struct ip_vs_protocol *pp) | ||
160 | { | ||
161 | } | ||
162 | |||
163 | struct ip_vs_protocol ip_vs_protocol_icmp = { | ||
164 | .name = "ICMP", | ||
165 | .protocol = IPPROTO_ICMP, | ||
166 | .dont_defrag = 0, | ||
167 | .init = icmp_init, | ||
168 | .exit = icmp_exit, | ||
169 | .conn_schedule = icmp_conn_schedule, | ||
170 | .conn_in_get = icmp_conn_in_get, | ||
171 | .conn_out_get = icmp_conn_out_get, | ||
172 | .snat_handler = NULL, | ||
173 | .dnat_handler = NULL, | ||
174 | .csum_check = icmp_csum_check, | ||
175 | .state_transition = icmp_state_transition, | ||
176 | .register_app = NULL, | ||
177 | .unregister_app = NULL, | ||
178 | .app_conn_bind = NULL, | ||
179 | .debug_packet = icmp_debug_packet, | ||
180 | .timeout_change = NULL, | ||
181 | .set_state_timeout = icmp_set_state_timeout, | ||
182 | }; | ||
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c index e5746b674413..eda1fba431a4 100644 --- a/net/ipv4/netfilter/ip_queue.c +++ b/net/ipv4/netfilter/ip_queue.c | |||
@@ -3,6 +3,7 @@ | |||
3 | * communicating with userspace via netlink. | 3 | * communicating with userspace via netlink. |
4 | * | 4 | * |
5 | * (C) 2000-2002 James Morris <jmorris@intercode.com.au> | 5 | * (C) 2000-2002 James Morris <jmorris@intercode.com.au> |
6 | * (C) 2003-2005 Netfilter Core Team <coreteam@netfilter.org> | ||
6 | * | 7 | * |
7 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License version 2 as | 9 | * it under the terms of the GNU General Public License version 2 as |
@@ -17,6 +18,7 @@ | |||
17 | * 2005-01-10: Added /proc counter for dropped packets; fixed so | 18 | * 2005-01-10: Added /proc counter for dropped packets; fixed so |
18 | * packets aren't delivered to user space if they're going | 19 | * packets aren't delivered to user space if they're going |
19 | * to be dropped. | 20 | * to be dropped. |
21 | * 2005-05-26: local_bh_{disable,enable} around nf_reinject (Harald Welte) | ||
20 | * | 22 | * |
21 | */ | 23 | */ |
22 | #include <linux/module.h> | 24 | #include <linux/module.h> |
@@ -71,7 +73,15 @@ static DECLARE_MUTEX(ipqnl_sem); | |||
71 | static void | 73 | static void |
72 | ipq_issue_verdict(struct ipq_queue_entry *entry, int verdict) | 74 | ipq_issue_verdict(struct ipq_queue_entry *entry, int verdict) |
73 | { | 75 | { |
76 | /* TCP input path (and probably other bits) assume to be called | ||
77 | * from softirq context, not from syscall, like ipq_issue_verdict is | ||
78 | * called. TCP input path deadlocks with locks taken from timer | ||
79 | * softirq, e.g. We therefore emulate this by local_bh_disable() */ | ||
80 | |||
81 | local_bh_disable(); | ||
74 | nf_reinject(entry->skb, entry->info, verdict); | 82 | nf_reinject(entry->skb, entry->info, verdict); |
83 | local_bh_enable(); | ||
84 | |||
75 | kfree(entry); | 85 | kfree(entry); |
76 | } | 86 | } |
77 | 87 | ||
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 4a6952e3fee9..7c24e64b443f 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -738,7 +738,7 @@ int udp_ioctl(struct sock *sk, int cmd, unsigned long arg) | |||
738 | unsigned long amount; | 738 | unsigned long amount; |
739 | 739 | ||
740 | amount = 0; | 740 | amount = 0; |
741 | spin_lock_irq(&sk->sk_receive_queue.lock); | 741 | spin_lock_bh(&sk->sk_receive_queue.lock); |
742 | skb = skb_peek(&sk->sk_receive_queue); | 742 | skb = skb_peek(&sk->sk_receive_queue); |
743 | if (skb != NULL) { | 743 | if (skb != NULL) { |
744 | /* | 744 | /* |
@@ -748,7 +748,7 @@ int udp_ioctl(struct sock *sk, int cmd, unsigned long arg) | |||
748 | */ | 748 | */ |
749 | amount = skb->len - sizeof(struct udphdr); | 749 | amount = skb->len - sizeof(struct udphdr); |
750 | } | 750 | } |
751 | spin_unlock_irq(&sk->sk_receive_queue.lock); | 751 | spin_unlock_bh(&sk->sk_receive_queue.lock); |
752 | return put_user(amount, (int __user *)arg); | 752 | return put_user(amount, (int __user *)arg); |
753 | } | 753 | } |
754 | 754 | ||
@@ -848,12 +848,12 @@ csum_copy_err: | |||
848 | /* Clear queue. */ | 848 | /* Clear queue. */ |
849 | if (flags&MSG_PEEK) { | 849 | if (flags&MSG_PEEK) { |
850 | int clear = 0; | 850 | int clear = 0; |
851 | spin_lock_irq(&sk->sk_receive_queue.lock); | 851 | spin_lock_bh(&sk->sk_receive_queue.lock); |
852 | if (skb == skb_peek(&sk->sk_receive_queue)) { | 852 | if (skb == skb_peek(&sk->sk_receive_queue)) { |
853 | __skb_unlink(skb, &sk->sk_receive_queue); | 853 | __skb_unlink(skb, &sk->sk_receive_queue); |
854 | clear = 1; | 854 | clear = 1; |
855 | } | 855 | } |
856 | spin_unlock_irq(&sk->sk_receive_queue.lock); | 856 | spin_unlock_bh(&sk->sk_receive_queue.lock); |
857 | if (clear) | 857 | if (clear) |
858 | kfree_skb(skb); | 858 | kfree_skb(skb); |
859 | } | 859 | } |
@@ -1334,7 +1334,7 @@ unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait) | |||
1334 | struct sk_buff_head *rcvq = &sk->sk_receive_queue; | 1334 | struct sk_buff_head *rcvq = &sk->sk_receive_queue; |
1335 | struct sk_buff *skb; | 1335 | struct sk_buff *skb; |
1336 | 1336 | ||
1337 | spin_lock_irq(&rcvq->lock); | 1337 | spin_lock_bh(&rcvq->lock); |
1338 | while ((skb = skb_peek(rcvq)) != NULL) { | 1338 | while ((skb = skb_peek(rcvq)) != NULL) { |
1339 | if (udp_checksum_complete(skb)) { | 1339 | if (udp_checksum_complete(skb)) { |
1340 | UDP_INC_STATS_BH(UDP_MIB_INERRORS); | 1340 | UDP_INC_STATS_BH(UDP_MIB_INERRORS); |
@@ -1345,7 +1345,7 @@ unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait) | |||
1345 | break; | 1345 | break; |
1346 | } | 1346 | } |
1347 | } | 1347 | } |
1348 | spin_unlock_irq(&rcvq->lock); | 1348 | spin_unlock_bh(&rcvq->lock); |
1349 | 1349 | ||
1350 | /* nothing to see, move along */ | 1350 | /* nothing to see, move along */ |
1351 | if (skb == NULL) | 1351 | if (skb == NULL) |
diff --git a/net/ipv6/ipv6_syms.c b/net/ipv6/ipv6_syms.c index 2f4c91ddc9a3..5ade5a5d1990 100644 --- a/net/ipv6/ipv6_syms.c +++ b/net/ipv6/ipv6_syms.c | |||
@@ -37,5 +37,4 @@ EXPORT_SYMBOL(in6_dev_finish_destroy); | |||
37 | EXPORT_SYMBOL(xfrm6_rcv); | 37 | EXPORT_SYMBOL(xfrm6_rcv); |
38 | #endif | 38 | #endif |
39 | EXPORT_SYMBOL(rt6_lookup); | 39 | EXPORT_SYMBOL(rt6_lookup); |
40 | EXPORT_SYMBOL(fl6_sock_lookup); | ||
41 | EXPORT_SYMBOL(ipv6_push_nfrag_opts); | 40 | EXPORT_SYMBOL(ipv6_push_nfrag_opts); |
diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c index 8a3db9d95bab..d8bd2a569c7c 100644 --- a/net/sched/sch_dsmark.c +++ b/net/sched/sch_dsmark.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <asm/byteorder.h> | 18 | #include <asm/byteorder.h> |
19 | 19 | ||
20 | 20 | ||
21 | #if 1 /* control */ | 21 | #if 0 /* control */ |
22 | #define DPRINTK(format,args...) printk(KERN_DEBUG format,##args) | 22 | #define DPRINTK(format,args...) printk(KERN_DEBUG format,##args) |
23 | #else | 23 | #else |
24 | #define DPRINTK(format,args...) | 24 | #define DPRINTK(format,args...) |
@@ -73,8 +73,13 @@ static int dsmark_graft(struct Qdisc *sch,unsigned long arg, | |||
73 | 73 | ||
74 | DPRINTK("dsmark_graft(sch %p,[qdisc %p],new %p,old %p)\n",sch,p,new, | 74 | DPRINTK("dsmark_graft(sch %p,[qdisc %p],new %p,old %p)\n",sch,p,new, |
75 | old); | 75 | old); |
76 | if (!new) | 76 | |
77 | new = &noop_qdisc; | 77 | if (new == NULL) { |
78 | new = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops); | ||
79 | if (new == NULL) | ||
80 | new = &noop_qdisc; | ||
81 | } | ||
82 | |||
78 | sch_tree_lock(sch); | 83 | sch_tree_lock(sch); |
79 | *old = xchg(&p->q,new); | 84 | *old = xchg(&p->q,new); |
80 | if (*old) | 85 | if (*old) |
@@ -163,14 +168,15 @@ static void dsmark_walk(struct Qdisc *sch,struct qdisc_walker *walker) | |||
163 | return; | 168 | return; |
164 | for (i = 0; i < p->indices; i++) { | 169 | for (i = 0; i < p->indices; i++) { |
165 | if (p->mask[i] == 0xff && !p->value[i]) | 170 | if (p->mask[i] == 0xff && !p->value[i]) |
166 | continue; | 171 | goto ignore; |
167 | if (walker->count >= walker->skip) { | 172 | if (walker->count >= walker->skip) { |
168 | if (walker->fn(sch, i+1, walker) < 0) { | 173 | if (walker->fn(sch, i+1, walker) < 0) { |
169 | walker->stop = 1; | 174 | walker->stop = 1; |
170 | break; | 175 | break; |
171 | } | 176 | } |
172 | } | 177 | } |
173 | walker->count++; | 178 | ignore: |
179 | walker->count++; | ||
174 | } | 180 | } |
175 | } | 181 | } |
176 | 182 | ||