diff options
Diffstat (limited to 'drivers/char')
46 files changed, 2310 insertions, 1398 deletions
diff --git a/drivers/char/ChangeLog b/drivers/char/ChangeLog deleted file mode 100644 index 56b8a2e76ab1..000000000000 --- a/drivers/char/ChangeLog +++ /dev/null | |||
@@ -1,775 +0,0 @@ | |||
1 | 2001-08-11 Tim Waugh <twaugh@redhat.com> | ||
2 | |||
3 | * serial.c (get_pci_port): Deal with awkward Titan cards. | ||
4 | |||
5 | 1998-08-26 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
6 | |||
7 | * serial.c (rs_open): Correctly decrement the module in-use count | ||
8 | on errors. | ||
9 | |||
10 | Thu Feb 19 14:24:08 1998 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
11 | |||
12 | * tty_io.c (tty_name): Remove the non-reentrant (and non-SMP safe) | ||
13 | version of tty_name, and rename the reentrant _tty_name | ||
14 | function to be tty_name. | ||
15 | (tty_open): Add a warning message stating callout devices | ||
16 | are deprecated. | ||
17 | |||
18 | Mon Dec 1 08:24:15 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
19 | |||
20 | * tty_io.c (tty_get_baud_rate): Print a warning syslog if the | ||
21 | tty->alt_speed kludge is used; this means the system is | ||
22 | using the deprecated SPD_HI ioctls. | ||
23 | |||
24 | Mon Nov 24 10:37:49 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
25 | |||
26 | * serial.c, esp.c, rocket.c: Change drivers to take advantage of | ||
27 | tty_get_baud_rate(). | ||
28 | |||
29 | * tty_io.c (tty_get_baud_rate): New function which computes the | ||
30 | correct baud rate for the tty. More factoring out of | ||
31 | common code out of the serial driver to the high-level tty | ||
32 | functions.... | ||
33 | |||
34 | Sat Nov 22 07:53:36 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
35 | |||
36 | * serial.c, esp.c, rocket.c: Add tty->driver.break() routine, and | ||
37 | allow high-level tty code to handle the break and soft | ||
38 | carrier ioctls. | ||
39 | |||
40 | * tty_ioctl.c (n_tty_ioctl): Support TIOCGSOFTCAR and | ||
41 | TIOCSSOFTCAR, so that device drivers don't have to support | ||
42 | it. | ||
43 | |||
44 | * serial.c (autoconfig): Change 16750 test to hopefully eliminate | ||
45 | false results by people with strange 16550As being | ||
46 | detected as 16750s. Hopefully 16750s will still be | ||
47 | detected as 16750, and other weird UARTs won't get poorly | ||
48 | autodetected. If this doesn't work, I'll have to disable | ||
49 | the auto identification for the 16750. | ||
50 | |||
51 | * tty_io.c (tty_hangup): Now actually do the tty hangup | ||
52 | processing during the timer processing, and disable | ||
53 | interrupts while doing the hangup processing. This avoids | ||
54 | several nasty race conditions which happened when the | ||
55 | hangup processing was done asynchronously. | ||
56 | (tty_ioctl): Do break handling in the tty driver if | ||
57 | driver's break function is supported. | ||
58 | (tty_flip_buffer_push): New exported function which should | ||
59 | be used by drivers to push characters in the flip buffer | ||
60 | to the tty handler. This may either be done using a task | ||
61 | queue function for better CPU efficiency, or directly for | ||
62 | low latency operation. | ||
63 | |||
64 | * serial.c (rs_set_termios): Fix bug rs_set_termios when | ||
65 | transitioning away from B0, submitted by Stanislav | ||
66 | Voronyi. | ||
67 | |||
68 | Thu Jun 19 20:05:58 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
69 | |||
70 | * serial.c (begin_break, end_break, rs_ioctl): Applied patch | ||
71 | to support BSD ioctls to set and clear the break | ||
72 | condition explicitly. | ||
73 | |||
74 | * console.c (scrup, scrdown, insert_line, delete_line): Applied | ||
75 | fix suggested by Aaron Tiensivu to speed up block scrolls | ||
76 | up and down. | ||
77 | |||
78 | * n_tty.c (opost_block, write_chan): Added a modified "fast | ||
79 | console" patch which processes a block of text via | ||
80 | "cooking" efficiently. | ||
81 | |||
82 | Wed Jun 18 15:25:50 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
83 | |||
84 | * tty_io.c (init_dev, release_dev): Applied fix suggested by Bill | ||
85 | Hawes to prevent race conditions in the tty code. | ||
86 | |||
87 | * n_tty.c (n_tty_chars_in_buffer): Applied fix suggested by Bill | ||
88 | Hawes so that n_tty_chars_in_buffer returns the correct | ||
89 | value in the case when the tty is in cannonical mode. (To | ||
90 | avoid a pty deadlock with telnetd.) | ||
91 | |||
92 | Thu Feb 27 01:53:08 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
93 | |||
94 | * serial.c (change_speed): Add support for the termios flag | ||
95 | CMSPAR, which allows the user to select stick parity. | ||
96 | (i.e, if PARODD is set, the parity bit is always 1; if | ||
97 | PARRODD is not set, then the parity bit is always 0). | ||
98 | |||
99 | Wed Feb 26 19:03:10 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
100 | |||
101 | * serial.c (cleanup_module): Fix memory leak when using the serial | ||
102 | driver as a module; make sure tmp_buf gets freed! | ||
103 | |||
104 | Tue Feb 25 11:01:59 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
105 | |||
106 | * serial.c (set_modem_info): Add support for setting and clearing | ||
107 | the OUT1 and OUT2 bits. (For special case UART's, usually | ||
108 | for half-duplex.) | ||
109 | (autoconfig, change_speed): Fix TI 16750 support. | ||
110 | |||
111 | Sun Feb 16 00:14:43 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
112 | |||
113 | * tty_io.c (release_dev): Add sanity check to make sure there are | ||
114 | no waiters on tty->read_wait or tty->write_wait. | ||
115 | |||
116 | * serial.c (rs_init): Don't autoconfig a device if the I/O region | ||
117 | is already reserved. | ||
118 | |||
119 | * serial.c (serial_proc_info): Add support for /proc/serial. | ||
120 | |||
121 | Thu Feb 13 00:49:10 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
122 | |||
123 | * serial.c (receive_chars): When the UART repotrs an overrun | ||
124 | condition, it does so with a valid character. Changed to | ||
125 | not throw away the valid character, but instead report the | ||
126 | overrun after the valid character. | ||
127 | |||
128 | * serial.c: Added new #ifdef's for some of the advanced serial | ||
129 | driver features. A minimal driver that only supports COM | ||
130 | 1/2/3/4 without sharing serial interrupts only takes 17k; | ||
131 | the full driver takes 32k. | ||
132 | |||
133 | Wed Feb 12 14:50:44 1997 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
134 | |||
135 | * vt.c: | ||
136 | * pty.c: | ||
137 | * tty_ioctl.c: | ||
138 | * serial.c: Update routines to use the new 2.1 memory access | ||
139 | routines. | ||
140 | |||
141 | Wed Dec 4 07:51:52 1996 Theodore Ts'o <tytso@localhost.mit.edu> | ||
142 | |||
143 | * serial.c (change_speed): Use save_flags(); cli() and | ||
144 | restore_flags() in order to ensure we don't accidentally | ||
145 | turn on interrupts when starting up the port. | ||
146 | (startup): Move the insertion of serial structure into the | ||
147 | IRQ chain earlier into the startup processing. Interrupts | ||
148 | should be off this whole time, but we eventually will want | ||
149 | to reduce this window. | ||
150 | |||
151 | Thu Nov 21 10:05:22 1996 Theodore Ts'o <tytso@localhost.mit.edu> | ||
152 | |||
153 | * tty_ioctl.c (tty_wait_until_sent): Always check the driver | ||
154 | wait_until_ready routine, even if there are no characters | ||
155 | in the xmit buffer. (There may be charactes in the device | ||
156 | FIFO.) | ||
157 | (n_tty_ioctl): Add new flag tty->flow_stopped which | ||
158 | indicates whether the tty is stopped due to a request by | ||
159 | the TCXONC ioctl (used by tcflow). If so, don't let an | ||
160 | incoming XOFF character restart the tty. The tty can only | ||
161 | be restarted by another TCXONC request. | ||
162 | |||
163 | * tty_io.c (start_tty): Don't allow the tty to be restarted if | ||
164 | tty->flow_stopped is true. | ||
165 | |||
166 | * n_tty.c (n_tty_receive_char): If tty->flow_stopped is true, and | ||
167 | IXANY is set, don't eat a character trying to restart the | ||
168 | tty. | ||
169 | |||
170 | * serial.c (startup): Remove need for MCR_noint from the | ||
171 | async_struct structure. Only turn on DTR and RTS if the | ||
172 | baud rate is not zero. | ||
173 | (change_speed): More accurately calculate the timeout | ||
174 | value based on the word size. Move responsibility of | ||
175 | hangup when speed becomes B0 to rs_set_termios() | ||
176 | (set_serial_info): When changing the UART type set the | ||
177 | current xmit_fifo_size as well as the permanent | ||
178 | xmit_fifo_size. | ||
179 | (rs_ioctl): Fix TCSBRK (used by tcdrain) and TCSBRKP | ||
180 | ioctls to return EINTR if interrupted by a signal. | ||
181 | (rs_set_termios): If the baud rate changes to or from B0, | ||
182 | this function is now responsible for setting or clearing | ||
183 | DTR and RTS. DTR and RTS are only be changed on the | ||
184 | transition to or from the B0 state. | ||
185 | (rs_close): Wait for the characters to drain based on | ||
186 | info->timeout. At low baud rates (50 bps), it may take a | ||
187 | long time for the FIFO to completely drain out! | ||
188 | (rs_wait_until_sent): Fixed timeout handling. Now | ||
189 | releases control to the scheduler, but checks frequently | ||
190 | enough so that the function is sensitive enough to pass | ||
191 | the timing requirements of the NIST-PCTS. | ||
192 | (block_til_ready): When opening the device, don't turn on | ||
193 | DTR and RTS if the baud rate is B0. | ||
194 | |||
195 | Thu Nov 14 00:06:09 1996 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
196 | |||
197 | * serial.c (autoconfig): Fix autoconfiguration problems; | ||
198 | info->flags wasn't getting initialized from the state | ||
199 | structure. Put in more paranoid test for the 16750. | ||
200 | |||
201 | Fri Nov 8 20:19:50 1996 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
202 | |||
203 | * n_tty.c (n_tty_flush_buffer): Only call driver->unthrottle() if | ||
204 | the tty was previous throttled. | ||
205 | (n_tty_set_termios, write_chan): Add changes suggested by | ||
206 | Simon P. Allen to allow hardware cooking. | ||
207 | |||
208 | * tty_ioctl.c (set_termios): If we get a signal while waiting for | ||
209 | the tty to drain, return -EINTR. | ||
210 | |||
211 | * serial.c (change_speed): Add support for CREAD, as required by | ||
212 | POSIX. | ||
213 | |||
214 | Sat Nov 2 20:43:10 1996 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
215 | |||
216 | * serial.c: Wholesale changes. Added support for the Startech | ||
217 | 16650 and 16650V2 chips. (WARNING: the new startech | ||
218 | 16650A may or may not work!) Added support for the | ||
219 | TI16750 (not yet tested). Split async_struct into a | ||
220 | transient part (async_struct) and a permanent part | ||
221 | (serial_state) which contains the configuration | ||
222 | information for the ports. Added new driver routines | ||
223 | wait_until_sent() and send_xchar() to help with POSIX | ||
224 | compliance. Added support for radio clocks which waggle | ||
225 | the carrier detect line (CONFIG_HARD_PPS). | ||
226 | |||
227 | * tty_ioctl.c (tty_wait_until_sent): Added call to new driver | ||
228 | function tty->driver.wait_until_sent(), which returns when | ||
229 | the tty's device xmit buffers are drained. Needed for | ||
230 | full POSIX compliance. | ||
231 | |||
232 | (send_prio_char): New function, called by the ioctl's | ||
233 | TCIOFF and TCION; uses the new driver call send_xchar(), | ||
234 | which will send the XON or XOFF character at high priority | ||
235 | (and even if tty output is stopped). | ||
236 | |||
237 | Wed Jun 5 18:52:04 1996 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
238 | |||
239 | * pty.c (pty_close): When closing a pty, make sure packet mode is | ||
240 | cleared. | ||
241 | |||
242 | Sun May 26 09:33:52 1996 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
243 | |||
244 | * vesa_blank.c (set_vesa_blanking): Add missing verify_area() call. | ||
245 | |||
246 | * selection.c (set_selection): Add missing verify_area() call. | ||
247 | |||
248 | * tty_io.c (tty_ioctl): Add missing verify_area() calls. | ||
249 | |||
250 | * serial.c (rs_ioctl): Add missing verify_area() calls. | ||
251 | (rs_init): Allow initialization of serial driver | ||
252 | configuration from a module. | ||
253 | |||
254 | * random.c (extract_entropy): Add missing verify_area call. | ||
255 | Don't limit number of characters returned to | ||
256 | 32,768. Extract entropy is now no longer a inlined | ||
257 | function. | ||
258 | |||
259 | (random_read): Check return value in case extract_entropy | ||
260 | returns an error. | ||
261 | |||
262 | (secure_tcp_sequence_number): New function which returns a | ||
263 | secure TCP sequence number. This is needed to prevent some | ||
264 | nasty TCP hijacking attacks. | ||
265 | |||
266 | (init_std_data): Initialize using gettimeofday() instead of | ||
267 | struct timeval xtime. | ||
268 | |||
269 | (fast_add_entropy_word, add_entropy_word): Rename the | ||
270 | inline function add_entropy_word() to | ||
271 | fast_add_entropy_word(). Make add_entropy_word() be the | ||
272 | non-inlined function which is used in non-timing critical | ||
273 | places, in order to save space. | ||
274 | |||
275 | (initialize_benchmark, begin_benchmark, end_benchmark): New | ||
276 | functions defined when RANDOM_BENCHMARK is defined. They | ||
277 | allow us to benchmark the speed of the | ||
278 | add_timer_randomness() call. | ||
279 | |||
280 | (int_ln, rotate_left): Add two new inline functions with | ||
281 | i386 optimized asm instructions. This speeds up the | ||
282 | critical add_entropy_word() and add_timer_randomness() | ||
283 | functions, which are called from interrupt handlers. | ||
284 | |||
285 | Tue May 7 22:51:11 1996 <tytso@rsts-11.mit.edu> | ||
286 | |||
287 | * random.c (add_timer_randomness): Limit the amount randomness | ||
288 | that we estimate to 12 bits. (An arbitrary amount). | ||
289 | |||
290 | (extract_entropy): To make it harder to analyze the hash | ||
291 | function, fold the hash function in half using XOR, and | ||
292 | use the folded result as the value to emit to the user. | ||
293 | Also, add timer randomness each pass through the | ||
294 | exact_entropy call, to increase the amount of unknown | ||
295 | values during the extraction process. | ||
296 | |||
297 | (random_ioctl): Use IOR/IOW definitions to define the | ||
298 | ioctl values used by the /dev/random driver. Allow the | ||
299 | old ioctl values to be used for backwards compatibility | ||
300 | (for a limited amount of time). | ||
301 | |||
302 | Wed Apr 24 14:02:04 1996 Theodore Ts'o <tytso@rsts-11.mit.edu> | ||
303 | |||
304 | * random.c (add_timer_randomness): Use 2nd derivative as well to | ||
305 | better estimate entropy. | ||
306 | |||
307 | (rand_initialize): Explicitly initialize all the pointers | ||
308 | to NULL. (Clearing pointers using memset isn't portable.) | ||
309 | Initialize the random pool with OS-dependent data. | ||
310 | |||
311 | (random_write): Add sanity checking to the arguments to | ||
312 | random_write(), so that bad arguments won't cause a kernel | ||
313 | SEGV. | ||
314 | |||
315 | (random_read): Update the access time of the device inode | ||
316 | when you return data to the user. | ||
317 | |||
318 | (random_ioctl): Wake up the random_wait channel when there | ||
319 | are only WAIT_INPUT_BITS available. Add more paranoia | ||
320 | checks to make sure entropy_count doesn't go beyond the | ||
321 | bounds of (0, POOLSIZE). Add a few missing verify_area | ||
322 | checks. Add support for the RNDCLEARPOOL ioctl, which | ||
323 | zaps the random pool. | ||
324 | |||
325 | (add_timer_randomness): Wake up the random_wait | ||
326 | channel only when there are WAIT_INPUT_BITS available. | ||
327 | |||
328 | (random_select): Allow a random refresh daemon process to | ||
329 | select on /dev/random for writing; wake up the daemon when | ||
330 | there are less than WAIT_OUTPUT_BITS bits of randomness | ||
331 | available. | ||
332 | |||
333 | Tue Apr 23 22:56:07 1996 <tytso@rsts-11.mit.edu> | ||
334 | |||
335 | * tty_io.c (init_dev): Change return code when user attempts to | ||
336 | open master pty which is already open from EAGAIN to EIO, | ||
337 | to match with BSD expectations. EIO is more correct | ||
338 | anyway, since EAGAIN implies that retrying will be | ||
339 | successful --- which it might be.... Eventually!! | ||
340 | |||
341 | * pty.c (pty_open, pty_close): Fix wait loop so that we don't | ||
342 | busy loop while waiting for the master side to open. | ||
343 | Fix tty opening/closing logic. TTY_SLAVE_CLOSED was | ||
344 | renamed to TTY_OTHER_CLOSED, so that the name is more | ||
345 | descriptive. Also fixed code so that the tty flag | ||
346 | actually works correctly now.... | ||
347 | |||
348 | Mon Apr 1 10:22:01 1996 <tytso@rsts-11.mit.edu> | ||
349 | |||
350 | * serial.c (rs_close): Cleaned up modularization changes. | ||
351 | Remove code which forced line discipline back to N_TTY | ||
352 | this is done in the tty upper layers, and there's no | ||
353 | reason to do it here. (Making this change also | ||
354 | removed the requirement that the serial module access | ||
355 | the internal kernel symbol "ldiscs".) | ||
356 | |||
357 | * tty_io.c (tty_init): Formally register a tty_driver entry for | ||
358 | /dev/tty (device 4, 0) and /dev/console (device 5, 0). | ||
359 | This guarantees that major device numbers 4 and 5 will be | ||
360 | reserved for the tty subsystem (as they have to be because | ||
361 | of /dev/tty and /dev/console). Removed tty_regdev, as | ||
362 | this interface is no longer necessary. | ||
363 | |||
364 | Sun Mar 17 20:42:47 GMT 1996 <ah@doc.ic.ac.uk> | ||
365 | |||
366 | * serial.c : modularisation (changes in linux/fs/device.c allow | ||
367 | kerneld to automatically load the serial module). | ||
368 | |||
369 | * Makefile, Config.in : serial modularisation adds. | ||
370 | |||
371 | * tty_io.c : tty_init_ctty used by to register "cua" driver just | ||
372 | for the /dev/tty device (5,0). Added tty_regdev. | ||
373 | |||
374 | * serial.c (shutdown, rs_ioctl) : when port shuts down wakeup processes | ||
375 | waiting on delta_msr_wait. The TIOCMIWAIT ioctl returns EIO | ||
376 | if no change was done since the time of call. | ||
377 | |||
378 | Sat Mar 16 14:33:13 1996 <aeb@cwi.nl> | ||
379 | |||
380 | * tty_io.c (disassociate_ctty): If disassociate_ctty is called by | ||
381 | exit, do not perform an implicit vhangup on a pty. | ||
382 | |||
383 | Fri Feb 9 14:15:47 1996 <tytso@rsts-11.mit.edu> | ||
384 | |||
385 | * serial.c (block_til_ready): Fixed another race condition which | ||
386 | happens if a hangup happens during the open. | ||
387 | |||
388 | Wed Jan 10 10:08:00 1996 <tytso@rsts-11.mit.edu> | ||
389 | |||
390 | * serial.c (block_til_ready): Remove race condition which happened | ||
391 | if a hangup condition happened during the setup of the | ||
392 | UART, before rs_open() called block_til_ready(). This | ||
393 | caused the info->count counter to be erroneously | ||
394 | decremented. | ||
395 | |||
396 | * serial.c (startup, rs_open): Remove race condition that could | ||
397 | cause a memory leak of one page. (Fortunately, both race | ||
398 | conditions were relatively rare in practice.) | ||
399 | |||
400 | Tue Dec 5 13:21:27 1995 <tytso@rsts-11.mit.edu> | ||
401 | |||
402 | * serial.c (check_modem_status, rs_ioctl): Support the new | ||
403 | ioctl()'s TIOCGICOUNT, TIOCMIWAIT. These allow an | ||
404 | application program to wait on a modem serial register | ||
405 | status bit change, and to find out how many changes have | ||
406 | taken place for the MSR bits. | ||
407 | |||
408 | (rs_write): Eliminate a race condition which is introduced | ||
409 | if it is necessary to wait for the semaphore. | ||
410 | |||
411 | Sat Nov 4 17:14:45 1995 <tytso@rsts-11.mit.edu> | ||
412 | |||
413 | * tty_io.c (tty_init): Move registration of TTY_MAJOR and | ||
414 | TTY_AUX_MAJOR to the end, so that /proc/devices looks | ||
415 | prettier. | ||
416 | |||
417 | * pty.c (pty_init): Use new major numbers for PTY master and slave | ||
418 | devices. This allow us to have more than 64 pty's. We | ||
419 | register the old pty devices for backwards compatibility. | ||
420 | Note that a system should either be using the old pty | ||
421 | devices or the new pty devices --- in general, it should | ||
422 | try to use both, since they map into the same pty table. | ||
423 | The old pty devices are strictly for backwards compatibility. | ||
424 | |||
425 | Wed Oct 11 12:45:24 1995 <tytso@rsts-11.mit.edu> | ||
426 | |||
427 | * tty_io.c (disassociate_ctty): If disassociate_ctty is called by | ||
428 | exit, perform an implicit vhangup on the tty. | ||
429 | |||
430 | * pty.c (pty_close): When the master pty is closed, send a hangup | ||
431 | to the slave pty. | ||
432 | (pty_open): Use the flag TTY_SLAVE_CLOSED to test to see | ||
433 | if there are any open slave ptys, instead of using | ||
434 | tty->link->count. The old method got confused if there | ||
435 | were processes that had hung-up file descriptors on the | ||
436 | slave tty. | ||
437 | |||
438 | Tue May 2 00:53:25 1995 <tytso@rsx-11.mit.edu> | ||
439 | |||
440 | * tty_io.c (tty_set_ldisc): Wait until the output buffer is | ||
441 | drained before closing the old line discipline --- needed | ||
442 | in only one case: XON/XOFF processing. | ||
443 | |||
444 | * n_tty.c (n_tty_close): Don't bother waiting until the output | ||
445 | driver is closed; in general, the line discipline | ||
446 | shouldn't care if the hardware is finished | ||
447 | transmitting before the line discipline terminates. | ||
448 | |||
449 | * tty_io.c (release_dev): Shutdown the line discipline after | ||
450 | decrementing the tty count variable; but set the | ||
451 | TTY_CLOSING flag so that we know that this tty structure | ||
452 | isn't long for this world. | ||
453 | |||
454 | * tty_io.c (init_dev): Add sanity code to check to see if | ||
455 | TTY_CLOSING is set on a tty structure; if so, something | ||
456 | bad has happened (probably a line discipline close blocked | ||
457 | when it shouldn't have; so do a kernel printk and then | ||
458 | return an error). | ||
459 | |||
460 | Wed Apr 26 10:23:44 1995 Theodore Y. Ts'o <tytso@localhost> | ||
461 | |||
462 | * tty_io.c (release_dev): Try to shutdown the line discipline | ||
463 | *before* decrementing the tty count variable; this removes | ||
464 | a potential race condition which occurs when the line | ||
465 | discipline close blocks, and another process then tries | ||
466 | open the same serial port. | ||
467 | |||
468 | * serial.c (rs_hangup): When hanging up, flush the output buffer | ||
469 | before shutting down the UART. Otherwise the line | ||
470 | discipline close blocks waiting for the characters to get | ||
471 | flushed, which never happens until the serial port gets reused. | ||
472 | |||
473 | Wed Apr 12 08:06:16 1995 Theodore Y. Ts'o <tytso@localhost> | ||
474 | |||
475 | * serial.c (do_serial_hangup, do_softint, check_modem_status, | ||
476 | rs_init): Hangups are now scheduled via a separate tqueue | ||
477 | structure in the async_struct structure, tqueue_hangup. | ||
478 | This task is pushed on to the tq_schedule queue, so that | ||
479 | it is processed synchronously by the scheduler. | ||
480 | |||
481 | Sat Feb 18 12:13:51 1995 Theodore Y. Ts'o (tytso@rt-11) | ||
482 | |||
483 | * tty_io.c (disassociate_ctty, tty_open, tty_ioctl): Clear | ||
484 | current->tty_old_pgrp field when a session leader | ||
485 | acquires a controlling tty, and after a session leader | ||
486 | has disassociated from a controlling tty. | ||
487 | |||
488 | Fri Feb 17 09:34:09 1995 Theodore Y. Ts'o (tytso@rt-11) | ||
489 | |||
490 | * serial.c (rs_interrupt_single, rs_interrupt, rs_interrupt_multi): | ||
491 | Change the number of passes made from 64 to be 256, | ||
492 | configurable with the #define RS_ISR_PASS_LIMIT. | ||
493 | |||
494 | * serial.c (rs_init, set_serial_info, get_serial_info, rs_close): | ||
495 | Remove support for closing_wait2. Instead, set | ||
496 | tty->closing and rely on the line discipline to prevent | ||
497 | echo wars. | ||
498 | |||
499 | * n_tty.c (n_tty_receive_char): IEXTEN does not need to be | ||
500 | enabled in order for IXANY to be active. | ||
501 | |||
502 | If tty->closing is set, then only process XON and XOFF | ||
503 | characters. | ||
504 | |||
505 | Sun Feb 12 23:57:48 1995 Theodore Y. Ts'o (tytso@rt-11) | ||
506 | |||
507 | * serial.c (rs_timer): Change the interrupt poll time from 60 | ||
508 | seconds to 10 seconds, configurable with the #define | ||
509 | RS_STROBE_TIME. | ||
510 | |||
511 | * serial.c (rs_interrupt_multi, startup, shutdown, rs_ioctl, | ||
512 | set_multiport_struct, get_multiport_struct): Add | ||
513 | provisions for a new type of interrupt service routine, | ||
514 | which better supports multiple serial ports on a single | ||
515 | IRQ. | ||
516 | |||
517 | Sun Feb 5 19:35:11 1995 Theodore Y. Ts'o (tytso@rt-11) | ||
518 | |||
519 | * tty_ioctl.c (n_tty_ioctl, set_termios, tty_wait_until_sent): | ||
520 | * serial.c (rs_ioctl, rs_close): | ||
521 | * cyclades.c (cy_ioctl, cy_close): | ||
522 | * n_tty.c (n_tty_close): Rename wait_until_sent to | ||
523 | tty_wait_until_sent, so that it's a better name to export | ||
524 | in ksyms.c. | ||
525 | |||
526 | Sat Feb 4 23:36:20 1995 Theodore Y. Ts'o (tytso@rt-11) | ||
527 | |||
528 | * serial.c (rs_close): Added missing check for closing_wait2 being | ||
529 | ASYNC_CLOSING_WAIT_NONE. | ||
530 | |||
531 | Thu Jan 26 09:02:49 1995 Theodore Y. Ts'o (tytso@rt-11) | ||
532 | |||
533 | * serial.c (rs_init, set_serial_info, get_serial_info, | ||
534 | rs_close): Support close_wait in the serial driver. | ||
535 | This is helpful for slow devices (like serial | ||
536 | plotters) so that their outputs don't get flushed upon | ||
537 | device close. This has to be configurable because | ||
538 | normally we don't want ports to be hung up for long | ||
539 | periods of time during a close when they are not | ||
540 | connected to a device, or the device is powered off. | ||
541 | |||
542 | The default is to wait 30 seconds; in the case of a | ||
543 | very slow device, the close_wait timeout should be | ||
544 | lengthened. If it is set to 0, the kernel will wait | ||
545 | forever for all of the data to be transmitted. | ||
546 | |||
547 | Thu Jan 17 01:17:20 1995 Theodore Y. Ts'o (tytso@rt-11) | ||
548 | |||
549 | * serial.c (startup, change_speed, rs_init): Add support to detect | ||
550 | the StarTech 16650 chip. Treat it as a 16450 for now, | ||
551 | because of its FIFO bugs. | ||
552 | |||
553 | Thu Jan 5 21:21:57 1995 <dahinds@users.sourceforge.net> | ||
554 | |||
555 | * serial.c: (receive_char): Added counter to prevent infinite loop | ||
556 | when a PCMCIA serial device is ejected. | ||
557 | |||
558 | Thu Dec 29 17:53:48 1994 <tytso@rsx-11.mit.edu> | ||
559 | |||
560 | * tty_io.c (check_tty_count): New procedure which checks | ||
561 | tty->count to make sure that it matches with the number of | ||
562 | open file descriptors which point at the structure. If | ||
563 | the number doesn't match, it prints a warning message. | ||
564 | |||
565 | Wed Dec 28 15:41:51 1994 <tytso@rsx-11.mit.edu> | ||
566 | |||
567 | * tty_io.c (do_tty_hangup, disassociate_ctty): At hangup time, | ||
568 | save the tty's current foreground process group in the | ||
569 | session leader's task structure. When the session leader | ||
570 | terminates, send a SIGHUP, SIGCONT to that process group. | ||
571 | This is not required by POSIX, but it's not prohibited | ||
572 | either, and it appears to be the least intrusive way | ||
573 | to fix a problem that dialup servers have with | ||
574 | orphaned process groups caused by modem hangups. | ||
575 | |||
576 | Thu Dec 8 14:52:11 1994 <tytso@rsx-11.mit.edu> | ||
577 | |||
578 | * serial.c (rs_ioctl): Don't allow most ioctl's if the serial port | ||
579 | isn't initialized. | ||
580 | |||
581 | * serial.c (rs_close): Don't clear the IER if the serial port | ||
582 | isn't initialized. | ||
583 | |||
584 | * serial.c (block_til_ready): Don't try to block on the dialin | ||
585 | port if the serial port isn't initialized. | ||
586 | |||
587 | Wed Dec 7 10:48:30 1994 Si Park (si@wimpol.demon.co.uk) | ||
588 | * tty_io.c (tty_register_driver): Fix bug when linking onto | ||
589 | the tty_drivers list. We now test that there are elements | ||
590 | already on the list before setting the back link from the | ||
591 | first element to the new driver. | ||
592 | |||
593 | * tty_io.c (tty_unregister_driver): Fix bug in unlinking the | ||
594 | specified driver from the tty_drivers list. We were not | ||
595 | setting the back link correctly. This used to result in | ||
596 | a dangling back link pointer and cause panics on the next | ||
597 | call to get_tty_driver(). | ||
598 | |||
599 | Tue Nov 29 10:21:09 1994 Theodore Y. Ts'o (tytso@rt-11) | ||
600 | |||
601 | * tty_io.c (tty_unregister_driver): Fix bug in | ||
602 | tty_unregister_driver where the pointer to the refcount is | ||
603 | tested, instead of the refcount itself. This caused | ||
604 | tty_unregister_driver to always return EBUSY. | ||
605 | |||
606 | Sat Nov 26 11:59:24 1994 Theodore Y. Ts'o (tytso@rt-11) | ||
607 | |||
608 | * tty_io.c (tty_ioctl): Add support for the new ioctl | ||
609 | TIOCTTYGSTRUCT, which allow a kernel debugging program | ||
610 | direct read access to the tty and tty_driver structures. | ||
611 | |||
612 | Fri Nov 25 17:26:22 1994 Theodore Y. Ts'o (tytso@rt-11) | ||
613 | |||
614 | * serial.c (rs_set_termios): Don't wake up processes blocked in | ||
615 | open when the CLOCAL flag changes, since a blocking | ||
616 | open only samples the CLOCAL flag once when it blocks, | ||
617 | and doesn't check it again. (n.b. FreeBSD has a | ||
618 | different behavior for blocking opens; it's not clear | ||
619 | whether Linux or FreeBSD's interpretation is correct. | ||
620 | POSIX doesn't give clear guidance on this issue, so | ||
621 | this may change in the future....) | ||
622 | |||
623 | * serial.c (block_til_ready): Use the correct termios structure to | ||
624 | check the CLOCAL flag. If the cuaXX device is active, | ||
625 | then check the saved termios for the ttySXX device. | ||
626 | Otherwise, use the currently active termios structure. | ||
627 | |||
628 | Sun Nov 6 21:05:44 1994 Theodore Y. Ts'o (tytso@rt-11) | ||
629 | |||
630 | * serial.c (change_speed): Add support for direct access of | ||
631 | 57,600 and 115,200 bps. | ||
632 | |||
633 | Wed Nov 2 10:32:36 1994 Theodore Y. Ts'o (tytso@rt-11) | ||
634 | |||
635 | * n_tty.c (n_tty_receive_room): Only allow excess characters | ||
636 | through if we are in ICANON mode *and* there are other no | ||
637 | pending lines in the buffer. Otherwise cut and paste over | ||
638 | 4k breaks. | ||
639 | |||
640 | Sat Oct 29 18:17:34 1994 Theodore Y. Ts'o (tytso@rt-11) | ||
641 | |||
642 | * serial.c (rs_ioctl, get_lsr_info): Added patch suggested by Arne | ||
643 | Riiber so that user mode programs can tell when the | ||
644 | transmitter shift register is empty. | ||
645 | |||
646 | Thu Oct 27 23:14:29 1994 Theodore Y. Ts'o (tytso@rt-11) | ||
647 | |||
648 | * tty_ioctl.c (wait_until_sent): Added debugging printk statements | ||
649 | (under the #ifdef TTY_DEBUG_WAIT_UNTIL_SENT) | ||
650 | |||
651 | * serial.c (rs_interrupt, rs_interrupt_single, receive_chars, | ||
652 | change_speed, rs_close): rs_close now disables receiver | ||
653 | interrupts when closing the serial port. This allows the | ||
654 | serial port to close quickly when Linux and a modem (or a | ||
655 | mouse) are engaged in an echo war; when closing the serial | ||
656 | port, we now first stop listening to incoming characters, | ||
657 | and *then* wait for the transmit buffer to drain. | ||
658 | |||
659 | In order to make this change, the info->read_status_mask | ||
660 | is now used to control what bits of the line status | ||
661 | register are looked at in the interrupt routine in all | ||
662 | cases; previously it was only used in receive_chars to | ||
663 | select a few of the status bits. | ||
664 | |||
665 | Mon Oct 24 23:36:21 1994 Theodore Y. Ts'o (tytso@rt-11) | ||
666 | |||
667 | * serial.c (rs_close): Add a timeout to the transmitter flush | ||
668 | loop; this is just a sanity check in case we have flaky | ||
669 | (or non-existent-but-configured-by-the-user) hardware. | ||
670 | |||
671 | Fri Oct 21 09:37:23 1994 Theodore Y. Ts'o (tytso@rt-11) | ||
672 | |||
673 | * tty_io.c (tty_fasync): When asynchronous I/O is enabled, if the | ||
674 | process or process group has not be specified yet, set it | ||
675 | to be the tty's process group, or if that is not yet set, | ||
676 | to the current process's pid. | ||
677 | |||
678 | Thu Oct 20 23:17:28 1994 Theodore Y. Ts'o (tytso@rt-11) | ||
679 | |||
680 | * n_tty.c (n_tty_receive_room): If we are doing input | ||
681 | canonicalization, let as many characters through as | ||
682 | possible, so that the excess characters can be "beeped". | ||
683 | |||
684 | Tue Oct 18 10:02:43 1994 Theodore Y. Ts'o (tytso@rt-11) | ||
685 | |||
686 | * serial.c (rs_start): Removed an incorrect '!' that was | ||
687 | preventing transmit interrupts from being re-enabled in | ||
688 | rs_start(). Fortunately in most cases it would be | ||
689 | re-enabled elsewhere, but this still should be fixed | ||
690 | correctly. | ||
691 | |||
692 | Sun Oct 9 23:46:03 1994 Theodore Y. Ts'o (tytso@rt-11) | ||
693 | |||
694 | * tty_io.c (do_tty_hangup): If the tty driver flags | ||
695 | TTY_DRIVER_RESET_TERMIOS is set, then reset the termios | ||
696 | settings back to the driver's initial configuration. This | ||
697 | allows the termios settings to be reset even if a process | ||
698 | has hung up file descriptors keeping a pty's termios from | ||
699 | being freed and reset. | ||
700 | |||
701 | * tty_io.c (release_dev): Fix memory leak. The pty's other | ||
702 | termios structure should also be freed. | ||
703 | |||
704 | * serial.c (rs_close, shutdown): Change how we wait for the | ||
705 | transmitter to completely drain before shutting down the | ||
706 | serial port. We now do it by scheduling in another | ||
707 | process instead of busy looping with the interrupts turned | ||
708 | on. This may eliminate some race condition problems that | ||
709 | some people seem to be reporting. | ||
710 | |||
711 | Sun Sep 25 14:18:14 1994 Theodore Y. Ts'o (tytso@rt-11) | ||
712 | |||
713 | * tty_io.c (release_dev): When freeing a tty make sure that both | ||
714 | the tty and the o_tty (if present) aren't a process's | ||
715 | controlling tty. (Previously, we only checked the tty.) | ||
716 | |||
717 | * serial.c (change_speed): Only enable the Modem Status | ||
718 | Interrupt for a port if CLOCAL is not set or CRTSCTS | ||
719 | is set. If we're not checking the carrier detect and | ||
720 | CTS line, there's no point in enabling the modem | ||
721 | status interrupt. This will save spurious interrupts | ||
722 | from slowing down systems who have terminals that | ||
723 | don't support either line. (Of course, if you want | ||
724 | only one of CD and CTS support, you will need a | ||
725 | properly wired serial cable.) | ||
726 | |||
727 | Thu Sep 22 08:32:48 1994 Theodore Y. Ts'o (tytso@rt-11) | ||
728 | |||
729 | * tty_io.c (do_SAK): Return if tty is null. | ||
730 | |||
731 | * tty_io.c (_tty_name): Return "NULL tty" if the passed in tty is | ||
732 | NULL. | ||
733 | |||
734 | Sat Sep 17 13:19:25 1994 Theodore Y. Ts'o (tytso@rt-11) | ||
735 | |||
736 | * tty_ioctl.c (n_tty_ioctl): Fix TIOCGLCKTRMIOS and | ||
737 | TIOCSLCKTRMIOS, which were totally broken. Remove | ||
738 | extra indirection from argument; it should be a struct | ||
739 | termios *, not a struct termios **. | ||
740 | &real_tty->termios_locked should have been | ||
741 | real_tty->termios_locked. This caused us to be | ||
742 | reading and writing the termios_locked structure to | ||
743 | random places in kernel memory. | ||
744 | |||
745 | * tty_io.c (release_dev): Oops! Forgot to delete a critical kfree | ||
746 | of the locked_termios. This leaves the locked_termios | ||
747 | structure pointed at a freed object. | ||
748 | |||
749 | Fri Sep 16 08:13:25 1994 Theodore Y. Ts'o (tytso@rt-11) | ||
750 | |||
751 | * tty_io.c (tty_open): Don't check for an exclusive open until | ||
752 | after the device specific open routine has been called. | ||
753 | Otherwise, the serial device ref counting will be screwed | ||
754 | up. | ||
755 | |||
756 | * serial.c (rs_open, block_til_ready): Don't set termios structure | ||
757 | until after block_til_ready has returned successfully. | ||
758 | Modify block_til_ready to check the normal_termios | ||
759 | structure directly, so it doesn't rely on termios being | ||
760 | set before it's called. | ||
761 | |||
762 | Thu Sep 15 23:34:01 1994 Theodore Y. Ts'o (tytso@rt-11) | ||
763 | |||
764 | * serial.c (rs_close): Turn off interrupts during rs_close() to | ||
765 | prevent a race condition with the hangup code (which | ||
766 | runs during a software interrupt). | ||
767 | |||
768 | * tty_io.c (release_dev): Don't free the locked_termios structure; | ||
769 | its state must be retained across device opens. | ||
770 | |||
771 | |||
772 | * tty_io.c (tty_unregister_driver): Added function to unregister a | ||
773 | tty driver. (For loadable device drivers.) | ||
774 | |||
775 | |||
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index e023682be2c4..3141dd3b6e53 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
@@ -666,6 +666,14 @@ config VIRTIO_CONSOLE | |||
666 | help | 666 | help |
667 | Virtio console for use with lguest and other hypervisors. | 667 | Virtio console for use with lguest and other hypervisors. |
668 | 668 | ||
669 | Also serves as a general-purpose serial device for data | ||
670 | transfer between the guest and host. Character devices at | ||
671 | /dev/vportNpn will be created when corresponding ports are | ||
672 | found, where N is the device number and n is the port number | ||
673 | within that device. If specified by the host, a sysfs | ||
674 | attribute called 'name' will be populated with a name for | ||
675 | the port which can be used by udev scripts to create a | ||
676 | symlink to the device. | ||
669 | 677 | ||
670 | config HVCS | 678 | config HVCS |
671 | tristate "IBM Hypervisor Virtual Console Server support" | 679 | tristate "IBM Hypervisor Virtual Console Server support" |
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c index 3999a5f25f38..a3e10dc7cc25 100644 --- a/drivers/char/agp/intel-agp.c +++ b/drivers/char/agp/intel-agp.c | |||
@@ -8,8 +8,12 @@ | |||
8 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
9 | #include <linux/pagemap.h> | 9 | #include <linux/pagemap.h> |
10 | #include <linux/agp_backend.h> | 10 | #include <linux/agp_backend.h> |
11 | #include <asm/smp.h> | ||
11 | #include "agp.h" | 12 | #include "agp.h" |
12 | 13 | ||
14 | int intel_agp_enabled; | ||
15 | EXPORT_SYMBOL(intel_agp_enabled); | ||
16 | |||
13 | /* | 17 | /* |
14 | * If we have Intel graphics, we're not going to have anything other than | 18 | * If we have Intel graphics, we're not going to have anything other than |
15 | * an Intel IOMMU. So make the correct use of the PCI DMA API contingent | 19 | * an Intel IOMMU. So make the correct use of the PCI DMA API contingent |
@@ -64,6 +68,10 @@ | |||
64 | #define PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB 0x0062 | 68 | #define PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB 0x0062 |
65 | #define PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB 0x006a | 69 | #define PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB 0x006a |
66 | #define PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG 0x0046 | 70 | #define PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG 0x0046 |
71 | #define PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB 0x0100 | ||
72 | #define PCI_DEVICE_ID_INTEL_SANDYBRIDGE_IG 0x0102 | ||
73 | #define PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB 0x0104 | ||
74 | #define PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_IG 0x0106 | ||
67 | 75 | ||
68 | /* cover 915 and 945 variants */ | 76 | /* cover 915 and 945 variants */ |
69 | #define IS_I915 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_E7221_HB || \ | 77 | #define IS_I915 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_E7221_HB || \ |
@@ -98,7 +106,9 @@ | |||
98 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_D_HB || \ | 106 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_D_HB || \ |
99 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB || \ | 107 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB || \ |
100 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB || \ | 108 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB || \ |
101 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB) | 109 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB || \ |
110 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB || \ | ||
111 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB) | ||
102 | 112 | ||
103 | extern int agp_memory_reserved; | 113 | extern int agp_memory_reserved; |
104 | 114 | ||
@@ -147,6 +157,25 @@ extern int agp_memory_reserved; | |||
147 | #define INTEL_I7505_AGPCTRL 0x70 | 157 | #define INTEL_I7505_AGPCTRL 0x70 |
148 | #define INTEL_I7505_MCHCFG 0x50 | 158 | #define INTEL_I7505_MCHCFG 0x50 |
149 | 159 | ||
160 | #define SNB_GMCH_CTRL 0x50 | ||
161 | #define SNB_GMCH_GMS_STOLEN_MASK 0xF8 | ||
162 | #define SNB_GMCH_GMS_STOLEN_32M (1 << 3) | ||
163 | #define SNB_GMCH_GMS_STOLEN_64M (2 << 3) | ||
164 | #define SNB_GMCH_GMS_STOLEN_96M (3 << 3) | ||
165 | #define SNB_GMCH_GMS_STOLEN_128M (4 << 3) | ||
166 | #define SNB_GMCH_GMS_STOLEN_160M (5 << 3) | ||
167 | #define SNB_GMCH_GMS_STOLEN_192M (6 << 3) | ||
168 | #define SNB_GMCH_GMS_STOLEN_224M (7 << 3) | ||
169 | #define SNB_GMCH_GMS_STOLEN_256M (8 << 3) | ||
170 | #define SNB_GMCH_GMS_STOLEN_288M (9 << 3) | ||
171 | #define SNB_GMCH_GMS_STOLEN_320M (0xa << 3) | ||
172 | #define SNB_GMCH_GMS_STOLEN_352M (0xb << 3) | ||
173 | #define SNB_GMCH_GMS_STOLEN_384M (0xc << 3) | ||
174 | #define SNB_GMCH_GMS_STOLEN_416M (0xd << 3) | ||
175 | #define SNB_GMCH_GMS_STOLEN_448M (0xe << 3) | ||
176 | #define SNB_GMCH_GMS_STOLEN_480M (0xf << 3) | ||
177 | #define SNB_GMCH_GMS_STOLEN_512M (0x10 << 3) | ||
178 | |||
150 | static const struct aper_size_info_fixed intel_i810_sizes[] = | 179 | static const struct aper_size_info_fixed intel_i810_sizes[] = |
151 | { | 180 | { |
152 | {64, 16384, 4}, | 181 | {64, 16384, 4}, |
@@ -269,7 +298,7 @@ static void intel_agp_insert_sg_entries(struct agp_memory *mem, | |||
269 | j++; | 298 | j++; |
270 | } | 299 | } |
271 | } else { | 300 | } else { |
272 | /* sg may merge pages, but we have to seperate | 301 | /* sg may merge pages, but we have to separate |
273 | * per-page addr for GTT */ | 302 | * per-page addr for GTT */ |
274 | unsigned int len, m; | 303 | unsigned int len, m; |
275 | 304 | ||
@@ -293,6 +322,13 @@ static void intel_agp_insert_sg_entries(struct agp_memory *mem, | |||
293 | off_t pg_start, int mask_type) | 322 | off_t pg_start, int mask_type) |
294 | { | 323 | { |
295 | int i, j; | 324 | int i, j; |
325 | u32 cache_bits = 0; | ||
326 | |||
327 | if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB || | ||
328 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB) | ||
329 | { | ||
330 | cache_bits = I830_PTE_SYSTEM_CACHED; | ||
331 | } | ||
296 | 332 | ||
297 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | 333 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { |
298 | writel(agp_bridge->driver->mask_memory(agp_bridge, | 334 | writel(agp_bridge->driver->mask_memory(agp_bridge, |
@@ -613,7 +649,7 @@ static struct aper_size_info_fixed intel_i830_sizes[] = | |||
613 | static void intel_i830_init_gtt_entries(void) | 649 | static void intel_i830_init_gtt_entries(void) |
614 | { | 650 | { |
615 | u16 gmch_ctrl; | 651 | u16 gmch_ctrl; |
616 | int gtt_entries; | 652 | int gtt_entries = 0; |
617 | u8 rdct; | 653 | u8 rdct; |
618 | int local = 0; | 654 | int local = 0; |
619 | static const int ddt[4] = { 0, 16, 32, 64 }; | 655 | static const int ddt[4] = { 0, 16, 32, 64 }; |
@@ -705,6 +741,63 @@ static void intel_i830_init_gtt_entries(void) | |||
705 | gtt_entries = 0; | 741 | gtt_entries = 0; |
706 | break; | 742 | break; |
707 | } | 743 | } |
744 | } else if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB || | ||
745 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB) { | ||
746 | /* | ||
747 | * SandyBridge has new memory control reg at 0x50.w | ||
748 | */ | ||
749 | u16 snb_gmch_ctl; | ||
750 | pci_read_config_word(intel_private.pcidev, SNB_GMCH_CTRL, &snb_gmch_ctl); | ||
751 | switch (snb_gmch_ctl & SNB_GMCH_GMS_STOLEN_MASK) { | ||
752 | case SNB_GMCH_GMS_STOLEN_32M: | ||
753 | gtt_entries = MB(32) - KB(size); | ||
754 | break; | ||
755 | case SNB_GMCH_GMS_STOLEN_64M: | ||
756 | gtt_entries = MB(64) - KB(size); | ||
757 | break; | ||
758 | case SNB_GMCH_GMS_STOLEN_96M: | ||
759 | gtt_entries = MB(96) - KB(size); | ||
760 | break; | ||
761 | case SNB_GMCH_GMS_STOLEN_128M: | ||
762 | gtt_entries = MB(128) - KB(size); | ||
763 | break; | ||
764 | case SNB_GMCH_GMS_STOLEN_160M: | ||
765 | gtt_entries = MB(160) - KB(size); | ||
766 | break; | ||
767 | case SNB_GMCH_GMS_STOLEN_192M: | ||
768 | gtt_entries = MB(192) - KB(size); | ||
769 | break; | ||
770 | case SNB_GMCH_GMS_STOLEN_224M: | ||
771 | gtt_entries = MB(224) - KB(size); | ||
772 | break; | ||
773 | case SNB_GMCH_GMS_STOLEN_256M: | ||
774 | gtt_entries = MB(256) - KB(size); | ||
775 | break; | ||
776 | case SNB_GMCH_GMS_STOLEN_288M: | ||
777 | gtt_entries = MB(288) - KB(size); | ||
778 | break; | ||
779 | case SNB_GMCH_GMS_STOLEN_320M: | ||
780 | gtt_entries = MB(320) - KB(size); | ||
781 | break; | ||
782 | case SNB_GMCH_GMS_STOLEN_352M: | ||
783 | gtt_entries = MB(352) - KB(size); | ||
784 | break; | ||
785 | case SNB_GMCH_GMS_STOLEN_384M: | ||
786 | gtt_entries = MB(384) - KB(size); | ||
787 | break; | ||
788 | case SNB_GMCH_GMS_STOLEN_416M: | ||
789 | gtt_entries = MB(416) - KB(size); | ||
790 | break; | ||
791 | case SNB_GMCH_GMS_STOLEN_448M: | ||
792 | gtt_entries = MB(448) - KB(size); | ||
793 | break; | ||
794 | case SNB_GMCH_GMS_STOLEN_480M: | ||
795 | gtt_entries = MB(480) - KB(size); | ||
796 | break; | ||
797 | case SNB_GMCH_GMS_STOLEN_512M: | ||
798 | gtt_entries = MB(512) - KB(size); | ||
799 | break; | ||
800 | } | ||
708 | } else { | 801 | } else { |
709 | switch (gmch_ctrl & I855_GMCH_GMS_MASK) { | 802 | switch (gmch_ctrl & I855_GMCH_GMS_MASK) { |
710 | case I855_GMCH_GMS_STOLEN_1M: | 803 | case I855_GMCH_GMS_STOLEN_1M: |
@@ -815,12 +908,6 @@ static void intel_i830_setup_flush(void) | |||
815 | intel_i830_fini_flush(); | 908 | intel_i830_fini_flush(); |
816 | } | 909 | } |
817 | 910 | ||
818 | static void | ||
819 | do_wbinvd(void *null) | ||
820 | { | ||
821 | wbinvd(); | ||
822 | } | ||
823 | |||
824 | /* The chipset_flush interface needs to get data that has already been | 911 | /* The chipset_flush interface needs to get data that has already been |
825 | * flushed out of the CPU all the way out to main memory, because the GPU | 912 | * flushed out of the CPU all the way out to main memory, because the GPU |
826 | * doesn't snoop those buffers. | 913 | * doesn't snoop those buffers. |
@@ -837,12 +924,10 @@ static void intel_i830_chipset_flush(struct agp_bridge_data *bridge) | |||
837 | 924 | ||
838 | memset(pg, 0, 1024); | 925 | memset(pg, 0, 1024); |
839 | 926 | ||
840 | if (cpu_has_clflush) { | 927 | if (cpu_has_clflush) |
841 | clflush_cache_range(pg, 1024); | 928 | clflush_cache_range(pg, 1024); |
842 | } else { | 929 | else if (wbinvd_on_all_cpus() != 0) |
843 | if (on_each_cpu(do_wbinvd, NULL, 1) != 0) | 930 | printk(KERN_ERR "Timed out waiting for cache flush.\n"); |
844 | printk(KERN_ERR "Timed out waiting for cache flush.\n"); | ||
845 | } | ||
846 | } | 931 | } |
847 | 932 | ||
848 | /* The intel i830 automatically initializes the agp aperture during POST. | 933 | /* The intel i830 automatically initializes the agp aperture during POST. |
@@ -1364,6 +1449,8 @@ static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size) | |||
1364 | case PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB: | 1449 | case PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB: |
1365 | case PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB: | 1450 | case PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB: |
1366 | case PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB: | 1451 | case PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB: |
1452 | case PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB: | ||
1453 | case PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB: | ||
1367 | *gtt_offset = *gtt_size = MB(2); | 1454 | *gtt_offset = *gtt_size = MB(2); |
1368 | break; | 1455 | break; |
1369 | default: | 1456 | default: |
@@ -2345,9 +2432,9 @@ static const struct intel_driver_description { | |||
2345 | NULL, &intel_g33_driver }, | 2432 | NULL, &intel_g33_driver }, |
2346 | { PCI_DEVICE_ID_INTEL_Q33_HB, PCI_DEVICE_ID_INTEL_Q33_IG, 0, "Q33", | 2433 | { PCI_DEVICE_ID_INTEL_Q33_HB, PCI_DEVICE_ID_INTEL_Q33_IG, 0, "Q33", |
2347 | NULL, &intel_g33_driver }, | 2434 | NULL, &intel_g33_driver }, |
2348 | { PCI_DEVICE_ID_INTEL_PINEVIEW_M_HB, PCI_DEVICE_ID_INTEL_PINEVIEW_M_IG, 0, "Pineview", | 2435 | { PCI_DEVICE_ID_INTEL_PINEVIEW_M_HB, PCI_DEVICE_ID_INTEL_PINEVIEW_M_IG, 0, "GMA3150", |
2349 | NULL, &intel_g33_driver }, | 2436 | NULL, &intel_g33_driver }, |
2350 | { PCI_DEVICE_ID_INTEL_PINEVIEW_HB, PCI_DEVICE_ID_INTEL_PINEVIEW_IG, 0, "Pineview", | 2437 | { PCI_DEVICE_ID_INTEL_PINEVIEW_HB, PCI_DEVICE_ID_INTEL_PINEVIEW_IG, 0, "GMA3150", |
2351 | NULL, &intel_g33_driver }, | 2438 | NULL, &intel_g33_driver }, |
2352 | { PCI_DEVICE_ID_INTEL_GM45_HB, PCI_DEVICE_ID_INTEL_GM45_IG, 0, | 2439 | { PCI_DEVICE_ID_INTEL_GM45_HB, PCI_DEVICE_ID_INTEL_GM45_IG, 0, |
2353 | "GM45", NULL, &intel_i965_driver }, | 2440 | "GM45", NULL, &intel_i965_driver }, |
@@ -2362,13 +2449,17 @@ static const struct intel_driver_description { | |||
2362 | { PCI_DEVICE_ID_INTEL_G41_HB, PCI_DEVICE_ID_INTEL_G41_IG, 0, | 2449 | { PCI_DEVICE_ID_INTEL_G41_HB, PCI_DEVICE_ID_INTEL_G41_IG, 0, |
2363 | "G41", NULL, &intel_i965_driver }, | 2450 | "G41", NULL, &intel_i965_driver }, |
2364 | { PCI_DEVICE_ID_INTEL_IRONLAKE_D_HB, PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG, 0, | 2451 | { PCI_DEVICE_ID_INTEL_IRONLAKE_D_HB, PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG, 0, |
2365 | "Ironlake/D", NULL, &intel_i965_driver }, | 2452 | "HD Graphics", NULL, &intel_i965_driver }, |
2366 | { PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB, PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG, 0, | 2453 | { PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB, PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG, 0, |
2367 | "Ironlake/M", NULL, &intel_i965_driver }, | 2454 | "HD Graphics", NULL, &intel_i965_driver }, |
2368 | { PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB, PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG, 0, | 2455 | { PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB, PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG, 0, |
2369 | "Ironlake/MA", NULL, &intel_i965_driver }, | 2456 | "HD Graphics", NULL, &intel_i965_driver }, |
2370 | { PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB, PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG, 0, | 2457 | { PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB, PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG, 0, |
2371 | "Ironlake/MC2", NULL, &intel_i965_driver }, | 2458 | "HD Graphics", NULL, &intel_i965_driver }, |
2459 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB, PCI_DEVICE_ID_INTEL_SANDYBRIDGE_IG, 0, | ||
2460 | "Sandybridge", NULL, &intel_i965_driver }, | ||
2461 | { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB, PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_IG, 0, | ||
2462 | "Sandybridge", NULL, &intel_i965_driver }, | ||
2372 | { 0, 0, 0, NULL, NULL, NULL } | 2463 | { 0, 0, 0, NULL, NULL, NULL } |
2373 | }; | 2464 | }; |
2374 | 2465 | ||
@@ -2378,7 +2469,7 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev, | |||
2378 | struct agp_bridge_data *bridge; | 2469 | struct agp_bridge_data *bridge; |
2379 | u8 cap_ptr = 0; | 2470 | u8 cap_ptr = 0; |
2380 | struct resource *r; | 2471 | struct resource *r; |
2381 | int i; | 2472 | int i, err; |
2382 | 2473 | ||
2383 | cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); | 2474 | cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); |
2384 | 2475 | ||
@@ -2470,7 +2561,10 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev, | |||
2470 | } | 2561 | } |
2471 | 2562 | ||
2472 | pci_set_drvdata(pdev, bridge); | 2563 | pci_set_drvdata(pdev, bridge); |
2473 | return agp_add_bridge(bridge); | 2564 | err = agp_add_bridge(bridge); |
2565 | if (!err) | ||
2566 | intel_agp_enabled = 1; | ||
2567 | return err; | ||
2474 | } | 2568 | } |
2475 | 2569 | ||
2476 | static void __devexit agp_intel_remove(struct pci_dev *pdev) | 2570 | static void __devexit agp_intel_remove(struct pci_dev *pdev) |
@@ -2575,6 +2669,8 @@ static struct pci_device_id agp_intel_pci_table[] = { | |||
2575 | ID(PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB), | 2669 | ID(PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB), |
2576 | ID(PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB), | 2670 | ID(PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB), |
2577 | ID(PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB), | 2671 | ID(PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB), |
2672 | ID(PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB), | ||
2673 | ID(PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB), | ||
2578 | { } | 2674 | { } |
2579 | }; | 2675 | }; |
2580 | 2676 | ||
diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c index fe2cb2f5db17..a7424bf7eacf 100644 --- a/drivers/char/applicom.c +++ b/drivers/char/applicom.c | |||
@@ -14,7 +14,7 @@ | |||
14 | /* et passe en argument a acinit, mais est scrute sur le bus pour s'adapter */ | 14 | /* et passe en argument a acinit, mais est scrute sur le bus pour s'adapter */ |
15 | /* au nombre de cartes presentes sur le bus. IOCL code 6 affichait V2.4.3 */ | 15 | /* au nombre de cartes presentes sur le bus. IOCL code 6 affichait V2.4.3 */ |
16 | /* F.LAFORSE 28/11/95 creation de fichiers acXX.o avec les differentes */ | 16 | /* F.LAFORSE 28/11/95 creation de fichiers acXX.o avec les differentes */ |
17 | /* adresses de base des cartes, IOCTL 6 plus complet */ | 17 | /* addresses de base des cartes, IOCTL 6 plus complet */ |
18 | /* J.PAGET le 19/08/96 copie de la version V2.6 en V2.8.0 sans modification */ | 18 | /* J.PAGET le 19/08/96 copie de la version V2.6 en V2.8.0 sans modification */ |
19 | /* de code autre que le texte V2.6.1 en V2.8.0 */ | 19 | /* de code autre que le texte V2.6.1 en V2.8.0 */ |
20 | /*****************************************************************************/ | 20 | /*****************************************************************************/ |
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index 4254457d3911..b861c08263a4 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c | |||
@@ -158,13 +158,11 @@ static unsigned int cy_isa_addresses[] = { | |||
158 | 158 | ||
159 | #define NR_ISA_ADDRS ARRAY_SIZE(cy_isa_addresses) | 159 | #define NR_ISA_ADDRS ARRAY_SIZE(cy_isa_addresses) |
160 | 160 | ||
161 | #ifdef MODULE | ||
162 | static long maddr[NR_CARDS]; | 161 | static long maddr[NR_CARDS]; |
163 | static int irq[NR_CARDS]; | 162 | static int irq[NR_CARDS]; |
164 | 163 | ||
165 | module_param_array(maddr, long, NULL, 0); | 164 | module_param_array(maddr, long, NULL, 0); |
166 | module_param_array(irq, int, NULL, 0); | 165 | module_param_array(irq, int, NULL, 0); |
167 | #endif | ||
168 | 166 | ||
169 | #endif /* CONFIG_ISA */ | 167 | #endif /* CONFIG_ISA */ |
170 | 168 | ||
@@ -598,12 +596,6 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip, | |||
598 | save_car = readb(base_addr + (CyCAR << index)); | 596 | save_car = readb(base_addr + (CyCAR << index)); |
599 | cy_writeb(base_addr + (CyCAR << index), save_xir); | 597 | cy_writeb(base_addr + (CyCAR << index), save_xir); |
600 | 598 | ||
601 | /* validate the port# (as configured and open) */ | ||
602 | if (channel + chip * 4 >= cinfo->nports) { | ||
603 | cy_writeb(base_addr + (CySRER << index), | ||
604 | readb(base_addr + (CySRER << index)) & ~CyTxRdy); | ||
605 | goto end; | ||
606 | } | ||
607 | info = &cinfo->ports[channel + chip * 4]; | 599 | info = &cinfo->ports[channel + chip * 4]; |
608 | tty = tty_port_tty_get(&info->port); | 600 | tty = tty_port_tty_get(&info->port); |
609 | if (tty == NULL) { | 601 | if (tty == NULL) { |
@@ -3316,13 +3308,10 @@ static int __init cy_detect_isa(void) | |||
3316 | unsigned short cy_isa_irq, nboard; | 3308 | unsigned short cy_isa_irq, nboard; |
3317 | void __iomem *cy_isa_address; | 3309 | void __iomem *cy_isa_address; |
3318 | unsigned short i, j, cy_isa_nchan; | 3310 | unsigned short i, j, cy_isa_nchan; |
3319 | #ifdef MODULE | ||
3320 | int isparam = 0; | 3311 | int isparam = 0; |
3321 | #endif | ||
3322 | 3312 | ||
3323 | nboard = 0; | 3313 | nboard = 0; |
3324 | 3314 | ||
3325 | #ifdef MODULE | ||
3326 | /* Check for module parameters */ | 3315 | /* Check for module parameters */ |
3327 | for (i = 0; i < NR_CARDS; i++) { | 3316 | for (i = 0; i < NR_CARDS; i++) { |
3328 | if (maddr[i] || i) { | 3317 | if (maddr[i] || i) { |
@@ -3332,7 +3321,6 @@ static int __init cy_detect_isa(void) | |||
3332 | if (!maddr[i]) | 3321 | if (!maddr[i]) |
3333 | break; | 3322 | break; |
3334 | } | 3323 | } |
3335 | #endif | ||
3336 | 3324 | ||
3337 | /* scan the address table probing for Cyclom-Y/ISA boards */ | 3325 | /* scan the address table probing for Cyclom-Y/ISA boards */ |
3338 | for (i = 0; i < NR_ISA_ADDRS; i++) { | 3326 | for (i = 0; i < NR_ISA_ADDRS; i++) { |
@@ -3353,11 +3341,10 @@ static int __init cy_detect_isa(void) | |||
3353 | iounmap(cy_isa_address); | 3341 | iounmap(cy_isa_address); |
3354 | continue; | 3342 | continue; |
3355 | } | 3343 | } |
3356 | #ifdef MODULE | 3344 | |
3357 | if (isparam && i < NR_CARDS && irq[i]) | 3345 | if (isparam && i < NR_CARDS && irq[i]) |
3358 | cy_isa_irq = irq[i]; | 3346 | cy_isa_irq = irq[i]; |
3359 | else | 3347 | else |
3360 | #endif | ||
3361 | /* find out the board's irq by probing */ | 3348 | /* find out the board's irq by probing */ |
3362 | cy_isa_irq = detect_isa_irq(cy_isa_address); | 3349 | cy_isa_irq = detect_isa_irq(cy_isa_address); |
3363 | if (cy_isa_irq == 0) { | 3350 | if (cy_isa_irq == 0) { |
@@ -4208,3 +4195,4 @@ module_exit(cy_cleanup_module); | |||
4208 | MODULE_LICENSE("GPL"); | 4195 | MODULE_LICENSE("GPL"); |
4209 | MODULE_VERSION(CY_VERSION); | 4196 | MODULE_VERSION(CY_VERSION); |
4210 | MODULE_ALIAS_CHARDEV_MAJOR(CYCLADES_MAJOR); | 4197 | MODULE_ALIAS_CHARDEV_MAJOR(CYCLADES_MAJOR); |
4198 | MODULE_FIRMWARE("cyzfirm.bin"); | ||
diff --git a/drivers/char/hvc_beat.c b/drivers/char/hvc_beat.c index 0afc8b82212e..5fe4631e2a61 100644 --- a/drivers/char/hvc_beat.c +++ b/drivers/char/hvc_beat.c | |||
@@ -84,7 +84,7 @@ static int hvc_beat_put_chars(uint32_t vtermno, const char *buf, int cnt) | |||
84 | return cnt; | 84 | return cnt; |
85 | } | 85 | } |
86 | 86 | ||
87 | static struct hv_ops hvc_beat_get_put_ops = { | 87 | static const struct hv_ops hvc_beat_get_put_ops = { |
88 | .get_chars = hvc_beat_get_chars, | 88 | .get_chars = hvc_beat_get_chars, |
89 | .put_chars = hvc_beat_put_chars, | 89 | .put_chars = hvc_beat_put_chars, |
90 | }; | 90 | }; |
@@ -99,7 +99,7 @@ static int hvc_beat_config(char *p) | |||
99 | 99 | ||
100 | static int __init hvc_beat_console_init(void) | 100 | static int __init hvc_beat_console_init(void) |
101 | { | 101 | { |
102 | if (hvc_beat_useit && machine_is_compatible("Beat")) { | 102 | if (hvc_beat_useit && of_machine_is_compatible("Beat")) { |
103 | hvc_instantiate(0, 0, &hvc_beat_get_put_ops); | 103 | hvc_instantiate(0, 0, &hvc_beat_get_put_ops); |
104 | } | 104 | } |
105 | return 0; | 105 | return 0; |
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c index 416d3423150d..465185fc0f52 100644 --- a/drivers/char/hvc_console.c +++ b/drivers/char/hvc_console.c | |||
@@ -125,7 +125,7 @@ static struct hvc_struct *hvc_get_by_index(int index) | |||
125 | * console interfaces but can still be used as a tty device. This has to be | 125 | * console interfaces but can still be used as a tty device. This has to be |
126 | * static because kmalloc will not work during early console init. | 126 | * static because kmalloc will not work during early console init. |
127 | */ | 127 | */ |
128 | static struct hv_ops *cons_ops[MAX_NR_HVC_CONSOLES]; | 128 | static const struct hv_ops *cons_ops[MAX_NR_HVC_CONSOLES]; |
129 | static uint32_t vtermnos[MAX_NR_HVC_CONSOLES] = | 129 | static uint32_t vtermnos[MAX_NR_HVC_CONSOLES] = |
130 | {[0 ... MAX_NR_HVC_CONSOLES - 1] = -1}; | 130 | {[0 ... MAX_NR_HVC_CONSOLES - 1] = -1}; |
131 | 131 | ||
@@ -146,7 +146,7 @@ static void hvc_console_print(struct console *co, const char *b, | |||
146 | return; | 146 | return; |
147 | 147 | ||
148 | /* This console adapter was removed so it is not usable. */ | 148 | /* This console adapter was removed so it is not usable. */ |
149 | if (vtermnos[index] < 0) | 149 | if (vtermnos[index] == -1) |
150 | return; | 150 | return; |
151 | 151 | ||
152 | while (count > 0 || i > 0) { | 152 | while (count > 0 || i > 0) { |
@@ -247,7 +247,7 @@ static void destroy_hvc_struct(struct kref *kref) | |||
247 | * vty adapters do NOT get an hvc_instantiate() callback since they | 247 | * vty adapters do NOT get an hvc_instantiate() callback since they |
248 | * appear after early console init. | 248 | * appear after early console init. |
249 | */ | 249 | */ |
250 | int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops) | 250 | int hvc_instantiate(uint32_t vtermno, int index, const struct hv_ops *ops) |
251 | { | 251 | { |
252 | struct hvc_struct *hp; | 252 | struct hvc_struct *hp; |
253 | 253 | ||
@@ -748,8 +748,9 @@ static const struct tty_operations hvc_ops = { | |||
748 | .chars_in_buffer = hvc_chars_in_buffer, | 748 | .chars_in_buffer = hvc_chars_in_buffer, |
749 | }; | 749 | }; |
750 | 750 | ||
751 | struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int data, | 751 | struct hvc_struct *hvc_alloc(uint32_t vtermno, int data, |
752 | struct hv_ops *ops, int outbuf_size) | 752 | const struct hv_ops *ops, |
753 | int outbuf_size) | ||
753 | { | 754 | { |
754 | struct hvc_struct *hp; | 755 | struct hvc_struct *hp; |
755 | int i; | 756 | int i; |
diff --git a/drivers/char/hvc_console.h b/drivers/char/hvc_console.h index 10950ca706d8..54381eba4e4a 100644 --- a/drivers/char/hvc_console.h +++ b/drivers/char/hvc_console.h | |||
@@ -55,7 +55,7 @@ struct hvc_struct { | |||
55 | int outbuf_size; | 55 | int outbuf_size; |
56 | int n_outbuf; | 56 | int n_outbuf; |
57 | uint32_t vtermno; | 57 | uint32_t vtermno; |
58 | struct hv_ops *ops; | 58 | const struct hv_ops *ops; |
59 | int irq_requested; | 59 | int irq_requested; |
60 | int data; | 60 | int data; |
61 | struct winsize ws; | 61 | struct winsize ws; |
@@ -76,11 +76,12 @@ struct hv_ops { | |||
76 | }; | 76 | }; |
77 | 77 | ||
78 | /* Register a vterm and a slot index for use as a console (console_init) */ | 78 | /* Register a vterm and a slot index for use as a console (console_init) */ |
79 | extern int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops); | 79 | extern int hvc_instantiate(uint32_t vtermno, int index, |
80 | const struct hv_ops *ops); | ||
80 | 81 | ||
81 | /* register a vterm for hvc tty operation (module_init or hotplug add) */ | 82 | /* register a vterm for hvc tty operation (module_init or hotplug add) */ |
82 | extern struct hvc_struct * __devinit hvc_alloc(uint32_t vtermno, int data, | 83 | extern struct hvc_struct * hvc_alloc(uint32_t vtermno, int data, |
83 | struct hv_ops *ops, int outbuf_size); | 84 | const struct hv_ops *ops, int outbuf_size); |
84 | /* remove a vterm from hvc tty operation (module_exit or hotplug remove) */ | 85 | /* remove a vterm from hvc tty operation (module_exit or hotplug remove) */ |
85 | extern int hvc_remove(struct hvc_struct *hp); | 86 | extern int hvc_remove(struct hvc_struct *hp); |
86 | 87 | ||
diff --git a/drivers/char/hvc_iseries.c b/drivers/char/hvc_iseries.c index 936d05bf37fa..21c54955084e 100644 --- a/drivers/char/hvc_iseries.c +++ b/drivers/char/hvc_iseries.c | |||
@@ -197,7 +197,7 @@ done: | |||
197 | return sent; | 197 | return sent; |
198 | } | 198 | } |
199 | 199 | ||
200 | static struct hv_ops hvc_get_put_ops = { | 200 | static const struct hv_ops hvc_get_put_ops = { |
201 | .get_chars = get_chars, | 201 | .get_chars = get_chars, |
202 | .put_chars = put_chars, | 202 | .put_chars = put_chars, |
203 | .notifier_add = notifier_add_irq, | 203 | .notifier_add = notifier_add_irq, |
@@ -353,7 +353,7 @@ static void hvc_close_event(struct HvLpEvent *event) | |||
353 | 353 | ||
354 | if (!hvlpevent_is_int(event)) { | 354 | if (!hvlpevent_is_int(event)) { |
355 | printk(KERN_WARNING | 355 | printk(KERN_WARNING |
356 | "hvc: got unexpected close acknowlegement\n"); | 356 | "hvc: got unexpected close acknowledgement\n"); |
357 | return; | 357 | return; |
358 | } | 358 | } |
359 | 359 | ||
diff --git a/drivers/char/hvc_iucv.c b/drivers/char/hvc_iucv.c index fe62bd0e17b7..37b0542a4eeb 100644 --- a/drivers/char/hvc_iucv.c +++ b/drivers/char/hvc_iucv.c | |||
@@ -139,6 +139,8 @@ struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num) | |||
139 | * | 139 | * |
140 | * This function allocates a new struct iucv_tty_buffer element and, optionally, | 140 | * This function allocates a new struct iucv_tty_buffer element and, optionally, |
141 | * allocates an internal data buffer with the specified size @size. | 141 | * allocates an internal data buffer with the specified size @size. |
142 | * The internal data buffer is always allocated with GFP_DMA which is | ||
143 | * required for receiving and sending data with IUCV. | ||
142 | * Note: The total message size arises from the internal buffer size and the | 144 | * Note: The total message size arises from the internal buffer size and the |
143 | * members of the iucv_tty_msg structure. | 145 | * members of the iucv_tty_msg structure. |
144 | * The function returns NULL if memory allocation has failed. | 146 | * The function returns NULL if memory allocation has failed. |
@@ -154,7 +156,7 @@ static struct iucv_tty_buffer *alloc_tty_buffer(size_t size, gfp_t flags) | |||
154 | 156 | ||
155 | if (size > 0) { | 157 | if (size > 0) { |
156 | bufp->msg.length = MSG_SIZE(size); | 158 | bufp->msg.length = MSG_SIZE(size); |
157 | bufp->mbuf = kmalloc(bufp->msg.length, flags); | 159 | bufp->mbuf = kmalloc(bufp->msg.length, flags | GFP_DMA); |
158 | if (!bufp->mbuf) { | 160 | if (!bufp->mbuf) { |
159 | mempool_free(bufp, hvc_iucv_mempool); | 161 | mempool_free(bufp, hvc_iucv_mempool); |
160 | return NULL; | 162 | return NULL; |
@@ -237,7 +239,7 @@ static int hvc_iucv_write(struct hvc_iucv_private *priv, | |||
237 | if (!rb->mbuf) { /* message not yet received ... */ | 239 | if (!rb->mbuf) { /* message not yet received ... */ |
238 | /* allocate mem to store msg data; if no memory is available | 240 | /* allocate mem to store msg data; if no memory is available |
239 | * then leave the buffer on the list and re-try later */ | 241 | * then leave the buffer on the list and re-try later */ |
240 | rb->mbuf = kmalloc(rb->msg.length, GFP_ATOMIC); | 242 | rb->mbuf = kmalloc(rb->msg.length, GFP_ATOMIC | GFP_DMA); |
241 | if (!rb->mbuf) | 243 | if (!rb->mbuf) |
242 | return -ENOMEM; | 244 | return -ENOMEM; |
243 | 245 | ||
@@ -922,7 +924,7 @@ static int hvc_iucv_pm_restore_thaw(struct device *dev) | |||
922 | 924 | ||
923 | 925 | ||
924 | /* HVC operations */ | 926 | /* HVC operations */ |
925 | static struct hv_ops hvc_iucv_ops = { | 927 | static const struct hv_ops hvc_iucv_ops = { |
926 | .get_chars = hvc_iucv_get_chars, | 928 | .get_chars = hvc_iucv_get_chars, |
927 | .put_chars = hvc_iucv_put_chars, | 929 | .put_chars = hvc_iucv_put_chars, |
928 | .notifier_add = hvc_iucv_notifier_add, | 930 | .notifier_add = hvc_iucv_notifier_add, |
diff --git a/drivers/char/hvc_rtas.c b/drivers/char/hvc_rtas.c index 88590d040046..61c4a61558d9 100644 --- a/drivers/char/hvc_rtas.c +++ b/drivers/char/hvc_rtas.c | |||
@@ -71,7 +71,7 @@ static int hvc_rtas_read_console(uint32_t vtermno, char *buf, int count) | |||
71 | return i; | 71 | return i; |
72 | } | 72 | } |
73 | 73 | ||
74 | static struct hv_ops hvc_rtas_get_put_ops = { | 74 | static const struct hv_ops hvc_rtas_get_put_ops = { |
75 | .get_chars = hvc_rtas_read_console, | 75 | .get_chars = hvc_rtas_read_console, |
76 | .put_chars = hvc_rtas_write_console, | 76 | .put_chars = hvc_rtas_write_console, |
77 | }; | 77 | }; |
diff --git a/drivers/char/hvc_udbg.c b/drivers/char/hvc_udbg.c index bd63ba878a56..b0957e61a7be 100644 --- a/drivers/char/hvc_udbg.c +++ b/drivers/char/hvc_udbg.c | |||
@@ -58,7 +58,7 @@ static int hvc_udbg_get(uint32_t vtermno, char *buf, int count) | |||
58 | return i; | 58 | return i; |
59 | } | 59 | } |
60 | 60 | ||
61 | static struct hv_ops hvc_udbg_ops = { | 61 | static const struct hv_ops hvc_udbg_ops = { |
62 | .get_chars = hvc_udbg_get, | 62 | .get_chars = hvc_udbg_get, |
63 | .put_chars = hvc_udbg_put, | 63 | .put_chars = hvc_udbg_put, |
64 | }; | 64 | }; |
diff --git a/drivers/char/hvc_vio.c b/drivers/char/hvc_vio.c index 10be343d6ae7..27370e99c66f 100644 --- a/drivers/char/hvc_vio.c +++ b/drivers/char/hvc_vio.c | |||
@@ -77,7 +77,7 @@ static int filtered_get_chars(uint32_t vtermno, char *buf, int count) | |||
77 | return got; | 77 | return got; |
78 | } | 78 | } |
79 | 79 | ||
80 | static struct hv_ops hvc_get_put_ops = { | 80 | static const struct hv_ops hvc_get_put_ops = { |
81 | .get_chars = filtered_get_chars, | 81 | .get_chars = filtered_get_chars, |
82 | .put_chars = hvc_put_chars, | 82 | .put_chars = hvc_put_chars, |
83 | .notifier_add = notifier_add_irq, | 83 | .notifier_add = notifier_add_irq, |
diff --git a/drivers/char/hvc_xen.c b/drivers/char/hvc_xen.c index b1a71638c772..60446f82a3fc 100644 --- a/drivers/char/hvc_xen.c +++ b/drivers/char/hvc_xen.c | |||
@@ -122,7 +122,7 @@ static int read_console(uint32_t vtermno, char *buf, int len) | |||
122 | return recv; | 122 | return recv; |
123 | } | 123 | } |
124 | 124 | ||
125 | static struct hv_ops hvc_ops = { | 125 | static const struct hv_ops hvc_ops = { |
126 | .get_chars = read_console, | 126 | .get_chars = read_console, |
127 | .put_chars = write_console, | 127 | .put_chars = write_console, |
128 | .notifier_add = notifier_add_irq, | 128 | .notifier_add = notifier_add_irq, |
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index 87060266ef91..d31483c54883 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig | |||
@@ -114,7 +114,7 @@ config HW_RANDOM_IXP4XX | |||
114 | 114 | ||
115 | config HW_RANDOM_OMAP | 115 | config HW_RANDOM_OMAP |
116 | tristate "OMAP Random Number Generator support" | 116 | tristate "OMAP Random Number Generator support" |
117 | depends on HW_RANDOM && (ARCH_OMAP16XX || ARCH_OMAP24XX) | 117 | depends on HW_RANDOM && (ARCH_OMAP16XX || ARCH_OMAP2) |
118 | default HW_RANDOM | 118 | default HW_RANDOM |
119 | ---help--- | 119 | ---help--- |
120 | This driver provides kernel-side support for the Random Number | 120 | This driver provides kernel-side support for the Random Number |
@@ -186,3 +186,15 @@ config HW_RANDOM_MXC_RNGA | |||
186 | module will be called mxc-rnga. | 186 | module will be called mxc-rnga. |
187 | 187 | ||
188 | If unsure, say Y. | 188 | If unsure, say Y. |
189 | |||
190 | config HW_RANDOM_NOMADIK | ||
191 | tristate "ST-Ericsson Nomadik Random Number Generator support" | ||
192 | depends on HW_RANDOM && PLAT_NOMADIK | ||
193 | ---help--- | ||
194 | This driver provides kernel-side support for the Random Number | ||
195 | Generator hardware found on ST-Ericsson SoCs (8815 and 8500). | ||
196 | |||
197 | To compile this driver as a module, choose M here: the | ||
198 | module will be called nomadik-rng. | ||
199 | |||
200 | If unsure, say Y. | ||
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile index 5eeb1303f0d0..4273308aa1e3 100644 --- a/drivers/char/hw_random/Makefile +++ b/drivers/char/hw_random/Makefile | |||
@@ -18,3 +18,4 @@ obj-$(CONFIG_HW_RANDOM_VIRTIO) += virtio-rng.o | |||
18 | obj-$(CONFIG_HW_RANDOM_TX4939) += tx4939-rng.o | 18 | obj-$(CONFIG_HW_RANDOM_TX4939) += tx4939-rng.o |
19 | obj-$(CONFIG_HW_RANDOM_MXC_RNGA) += mxc-rnga.o | 19 | obj-$(CONFIG_HW_RANDOM_MXC_RNGA) += mxc-rnga.o |
20 | obj-$(CONFIG_HW_RANDOM_OCTEON) += octeon-rng.o | 20 | obj-$(CONFIG_HW_RANDOM_OCTEON) += octeon-rng.o |
21 | obj-$(CONFIG_HW_RANDOM_NOMADIK) += nomadik-rng.o | ||
diff --git a/drivers/char/hw_random/n2-drv.c b/drivers/char/hw_random/n2-drv.c index 9b3e09cd41f9..10f868eefaa6 100644 --- a/drivers/char/hw_random/n2-drv.c +++ b/drivers/char/hw_random/n2-drv.c | |||
@@ -71,7 +71,7 @@ MODULE_VERSION(DRV_MODULE_VERSION); | |||
71 | * x22 + x21 + x17 + x15 + x13 + x12 + x11 + x7 + x5 + x + 1 | 71 | * x22 + x21 + x17 + x15 + x13 + x12 + x11 + x7 + x5 + x + 1 |
72 | * | 72 | * |
73 | * The RNG_CTL_VCO value of each noise cell must be programmed | 73 | * The RNG_CTL_VCO value of each noise cell must be programmed |
74 | * seperately. This is why 4 control register values must be provided | 74 | * separately. This is why 4 control register values must be provided |
75 | * to the hypervisor. During a write, the hypervisor writes them all, | 75 | * to the hypervisor. During a write, the hypervisor writes them all, |
76 | * one at a time, to the actual RNG_CTL register. The first three | 76 | * one at a time, to the actual RNG_CTL register. The first three |
77 | * values are used to setup the desired RNG_CTL_VCO for each entropy | 77 | * values are used to setup the desired RNG_CTL_VCO for each entropy |
diff --git a/drivers/char/hw_random/nomadik-rng.c b/drivers/char/hw_random/nomadik-rng.c new file mode 100644 index 000000000000..a8b4c4010144 --- /dev/null +++ b/drivers/char/hw_random/nomadik-rng.c | |||
@@ -0,0 +1,103 @@ | |||
1 | /* | ||
2 | * Nomadik RNG support | ||
3 | * Copyright 2009 Alessandro Rubini | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/device.h> | ||
15 | #include <linux/amba/bus.h> | ||
16 | #include <linux/hw_random.h> | ||
17 | #include <linux/io.h> | ||
18 | |||
19 | static int nmk_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) | ||
20 | { | ||
21 | void __iomem *base = (void __iomem *)rng->priv; | ||
22 | |||
23 | /* | ||
24 | * The register is 32 bits and gives 16 random bits (low half). | ||
25 | * A subsequent read will delay the core for 400ns, so we just read | ||
26 | * once and accept the very unlikely very small delay, even if wait==0. | ||
27 | */ | ||
28 | *(u16 *)data = __raw_readl(base + 8) & 0xffff; | ||
29 | return 2; | ||
30 | } | ||
31 | |||
32 | /* we have at most one RNG per machine, granted */ | ||
33 | static struct hwrng nmk_rng = { | ||
34 | .name = "nomadik", | ||
35 | .read = nmk_rng_read, | ||
36 | }; | ||
37 | |||
38 | static int nmk_rng_probe(struct amba_device *dev, struct amba_id *id) | ||
39 | { | ||
40 | void __iomem *base; | ||
41 | int ret; | ||
42 | |||
43 | ret = amba_request_regions(dev, dev->dev.init_name); | ||
44 | if (ret) | ||
45 | return ret; | ||
46 | ret = -ENOMEM; | ||
47 | base = ioremap(dev->res.start, resource_size(&dev->res)); | ||
48 | if (!base) | ||
49 | goto out_release; | ||
50 | nmk_rng.priv = (unsigned long)base; | ||
51 | ret = hwrng_register(&nmk_rng); | ||
52 | if (ret) | ||
53 | goto out_unmap; | ||
54 | return 0; | ||
55 | |||
56 | out_unmap: | ||
57 | iounmap(base); | ||
58 | out_release: | ||
59 | amba_release_regions(dev); | ||
60 | return ret; | ||
61 | } | ||
62 | |||
63 | static int nmk_rng_remove(struct amba_device *dev) | ||
64 | { | ||
65 | void __iomem *base = (void __iomem *)nmk_rng.priv; | ||
66 | hwrng_unregister(&nmk_rng); | ||
67 | iounmap(base); | ||
68 | amba_release_regions(dev); | ||
69 | return 0; | ||
70 | } | ||
71 | |||
72 | static struct amba_id nmk_rng_ids[] = { | ||
73 | { | ||
74 | .id = 0x000805e1, | ||
75 | .mask = 0x000fffff, /* top bits are rev and cfg: accept all */ | ||
76 | }, | ||
77 | {0, 0}, | ||
78 | }; | ||
79 | |||
80 | static struct amba_driver nmk_rng_driver = { | ||
81 | .drv = { | ||
82 | .owner = THIS_MODULE, | ||
83 | .name = "rng", | ||
84 | }, | ||
85 | .probe = nmk_rng_probe, | ||
86 | .remove = nmk_rng_remove, | ||
87 | .id_table = nmk_rng_ids, | ||
88 | }; | ||
89 | |||
90 | static int __init nmk_rng_init(void) | ||
91 | { | ||
92 | return amba_driver_register(&nmk_rng_driver); | ||
93 | } | ||
94 | |||
95 | static void __devexit nmk_rng_exit(void) | ||
96 | { | ||
97 | amba_driver_unregister(&nmk_rng_driver); | ||
98 | } | ||
99 | |||
100 | module_init(nmk_rng_init); | ||
101 | module_exit(nmk_rng_exit); | ||
102 | |||
103 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/char/ip2/i2hw.h b/drivers/char/ip2/i2hw.h index 8aa6e7ab8d5b..c0ba6c05f0cd 100644 --- a/drivers/char/ip2/i2hw.h +++ b/drivers/char/ip2/i2hw.h | |||
@@ -559,7 +559,7 @@ Loadware may be sent to the board in two ways: | |||
559 | 559 | ||
560 | 2) It may be hard-coded into your source by including a .h file (typically | 560 | 2) It may be hard-coded into your source by including a .h file (typically |
561 | supplied by Computone), which declares a data array and initializes every | 561 | supplied by Computone), which declares a data array and initializes every |
562 | element. This acheives the same result as if an entire loadware file had | 562 | element. This achieves the same result as if an entire loadware file had |
563 | been read into the array. | 563 | been read into the array. |
564 | 564 | ||
565 | This requires more data space in your program, but access to the file system | 565 | This requires more data space in your program, but access to the file system |
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c index 517271c762e6..911e1da6def2 100644 --- a/drivers/char/ip2/ip2main.c +++ b/drivers/char/ip2/ip2main.c | |||
@@ -208,6 +208,7 @@ static int DumpFifoBuffer( char __user *, int); | |||
208 | 208 | ||
209 | static void ip2_init_board(int, const struct firmware *); | 209 | static void ip2_init_board(int, const struct firmware *); |
210 | static unsigned short find_eisa_board(int); | 210 | static unsigned short find_eisa_board(int); |
211 | static int ip2_setup(char *str); | ||
211 | 212 | ||
212 | /***************/ | 213 | /***************/ |
213 | /* Static Data */ | 214 | /* Static Data */ |
@@ -263,7 +264,7 @@ static int tracewrap; | |||
263 | /* Macros */ | 264 | /* Macros */ |
264 | /**********/ | 265 | /**********/ |
265 | 266 | ||
266 | #if defined(MODULE) && defined(IP2DEBUG_OPEN) | 267 | #ifdef IP2DEBUG_OPEN |
267 | #define DBG_CNT(s) printk(KERN_DEBUG "(%s): [%x] ttyc=%d, modc=%x -> %s\n", \ | 268 | #define DBG_CNT(s) printk(KERN_DEBUG "(%s): [%x] ttyc=%d, modc=%x -> %s\n", \ |
268 | tty->name,(pCh->flags), \ | 269 | tty->name,(pCh->flags), \ |
269 | tty->count,/*GET_USE_COUNT(module)*/0,s) | 270 | tty->count,/*GET_USE_COUNT(module)*/0,s) |
@@ -285,7 +286,10 @@ MODULE_AUTHOR("Doug McNash"); | |||
285 | MODULE_DESCRIPTION("Computone IntelliPort Plus Driver"); | 286 | MODULE_DESCRIPTION("Computone IntelliPort Plus Driver"); |
286 | MODULE_LICENSE("GPL"); | 287 | MODULE_LICENSE("GPL"); |
287 | 288 | ||
289 | #define MAX_CMD_STR 50 | ||
290 | |||
288 | static int poll_only; | 291 | static int poll_only; |
292 | static char cmd[MAX_CMD_STR]; | ||
289 | 293 | ||
290 | static int Eisa_irq; | 294 | static int Eisa_irq; |
291 | static int Eisa_slot; | 295 | static int Eisa_slot; |
@@ -309,6 +313,8 @@ module_param_array(io, int, NULL, 0); | |||
309 | MODULE_PARM_DESC(io, "I/O ports for IntelliPort Cards"); | 313 | MODULE_PARM_DESC(io, "I/O ports for IntelliPort Cards"); |
310 | module_param(poll_only, bool, 0); | 314 | module_param(poll_only, bool, 0); |
311 | MODULE_PARM_DESC(poll_only, "Do not use card interrupts"); | 315 | MODULE_PARM_DESC(poll_only, "Do not use card interrupts"); |
316 | module_param_string(ip2, cmd, MAX_CMD_STR, 0); | ||
317 | MODULE_PARM_DESC(ip2, "Contains module parameter passed with 'ip2='"); | ||
312 | 318 | ||
313 | /* for sysfs class support */ | 319 | /* for sysfs class support */ |
314 | static struct class *ip2_class; | 320 | static struct class *ip2_class; |
@@ -487,7 +493,6 @@ static const struct firmware *ip2_request_firmware(void) | |||
487 | return fw; | 493 | return fw; |
488 | } | 494 | } |
489 | 495 | ||
490 | #ifndef MODULE | ||
491 | /****************************************************************************** | 496 | /****************************************************************************** |
492 | * ip2_setup: | 497 | * ip2_setup: |
493 | * str: kernel command line string | 498 | * str: kernel command line string |
@@ -531,7 +536,6 @@ static int __init ip2_setup(char *str) | |||
531 | return 1; | 536 | return 1; |
532 | } | 537 | } |
533 | __setup("ip2=", ip2_setup); | 538 | __setup("ip2=", ip2_setup); |
534 | #endif /* !MODULE */ | ||
535 | 539 | ||
536 | static int __init ip2_loadmain(void) | 540 | static int __init ip2_loadmain(void) |
537 | { | 541 | { |
@@ -539,14 +543,20 @@ static int __init ip2_loadmain(void) | |||
539 | int err = 0; | 543 | int err = 0; |
540 | i2eBordStrPtr pB = NULL; | 544 | i2eBordStrPtr pB = NULL; |
541 | int rc = -1; | 545 | int rc = -1; |
542 | struct pci_dev *pdev = NULL; | ||
543 | const struct firmware *fw = NULL; | 546 | const struct firmware *fw = NULL; |
547 | char *str; | ||
548 | |||
549 | str = cmd; | ||
544 | 550 | ||
545 | if (poll_only) { | 551 | if (poll_only) { |
546 | /* Hard lock the interrupts to zero */ | 552 | /* Hard lock the interrupts to zero */ |
547 | irq[0] = irq[1] = irq[2] = irq[3] = poll_only = 0; | 553 | irq[0] = irq[1] = irq[2] = irq[3] = poll_only = 0; |
548 | } | 554 | } |
549 | 555 | ||
556 | /* Check module parameter with 'ip2=' has been passed or not */ | ||
557 | if (!poll_only && (!strncmp(str, "ip2=", 4))) | ||
558 | ip2_setup(str); | ||
559 | |||
550 | ip2trace(ITRC_NO_PORT, ITRC_INIT, ITRC_ENTER, 0); | 560 | ip2trace(ITRC_NO_PORT, ITRC_INIT, ITRC_ENTER, 0); |
551 | 561 | ||
552 | /* process command line arguments to modprobe or | 562 | /* process command line arguments to modprobe or |
@@ -612,6 +622,7 @@ static int __init ip2_loadmain(void) | |||
612 | case PCI: | 622 | case PCI: |
613 | #ifdef CONFIG_PCI | 623 | #ifdef CONFIG_PCI |
614 | { | 624 | { |
625 | struct pci_dev *pdev = NULL; | ||
615 | u32 addr; | 626 | u32 addr; |
616 | int status; | 627 | int status; |
617 | 628 | ||
@@ -626,7 +637,7 @@ static int __init ip2_loadmain(void) | |||
626 | 637 | ||
627 | if (pci_enable_device(pdev)) { | 638 | if (pci_enable_device(pdev)) { |
628 | dev_err(&pdev->dev, "can't enable device\n"); | 639 | dev_err(&pdev->dev, "can't enable device\n"); |
629 | break; | 640 | goto out; |
630 | } | 641 | } |
631 | ip2config.type[i] = PCI; | 642 | ip2config.type[i] = PCI; |
632 | ip2config.pci_dev[i] = pci_dev_get(pdev); | 643 | ip2config.pci_dev[i] = pci_dev_get(pdev); |
@@ -638,6 +649,8 @@ static int __init ip2_loadmain(void) | |||
638 | dev_err(&pdev->dev, "I/O address error\n"); | 649 | dev_err(&pdev->dev, "I/O address error\n"); |
639 | 650 | ||
640 | ip2config.irq[i] = pdev->irq; | 651 | ip2config.irq[i] = pdev->irq; |
652 | out: | ||
653 | pci_dev_put(pdev); | ||
641 | } | 654 | } |
642 | #else | 655 | #else |
643 | printk(KERN_ERR "IP2: PCI card specified but PCI " | 656 | printk(KERN_ERR "IP2: PCI card specified but PCI " |
@@ -656,7 +669,6 @@ static int __init ip2_loadmain(void) | |||
656 | break; | 669 | break; |
657 | } /* switch */ | 670 | } /* switch */ |
658 | } /* for */ | 671 | } /* for */ |
659 | pci_dev_put(pdev); | ||
660 | 672 | ||
661 | for (i = 0; i < IP2_MAX_BOARDS; ++i) { | 673 | for (i = 0; i < IP2_MAX_BOARDS; ++i) { |
662 | if (ip2config.addr[i]) { | 674 | if (ip2config.addr[i]) { |
@@ -3197,3 +3209,5 @@ static struct pci_device_id ip2main_pci_tbl[] __devinitdata = { | |||
3197 | }; | 3209 | }; |
3198 | 3210 | ||
3199 | MODULE_DEVICE_TABLE(pci, ip2main_pci_tbl); | 3211 | MODULE_DEVICE_TABLE(pci, ip2main_pci_tbl); |
3212 | |||
3213 | MODULE_FIRMWARE("intelliport2.bin"); | ||
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 176f1751237f..4462b113ba3f 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c | |||
@@ -295,6 +295,9 @@ struct smi_info { | |||
295 | static int force_kipmid[SI_MAX_PARMS]; | 295 | static int force_kipmid[SI_MAX_PARMS]; |
296 | static int num_force_kipmid; | 296 | static int num_force_kipmid; |
297 | 297 | ||
298 | static unsigned int kipmid_max_busy_us[SI_MAX_PARMS]; | ||
299 | static int num_max_busy_us; | ||
300 | |||
298 | static int unload_when_empty = 1; | 301 | static int unload_when_empty = 1; |
299 | 302 | ||
300 | static int try_smi_init(struct smi_info *smi); | 303 | static int try_smi_init(struct smi_info *smi); |
@@ -925,23 +928,77 @@ static void set_run_to_completion(void *send_info, int i_run_to_completion) | |||
925 | } | 928 | } |
926 | } | 929 | } |
927 | 930 | ||
931 | /* | ||
932 | * Use -1 in the nsec value of the busy waiting timespec to tell that | ||
933 | * we are spinning in kipmid looking for something and not delaying | ||
934 | * between checks | ||
935 | */ | ||
936 | static inline void ipmi_si_set_not_busy(struct timespec *ts) | ||
937 | { | ||
938 | ts->tv_nsec = -1; | ||
939 | } | ||
940 | static inline int ipmi_si_is_busy(struct timespec *ts) | ||
941 | { | ||
942 | return ts->tv_nsec != -1; | ||
943 | } | ||
944 | |||
945 | static int ipmi_thread_busy_wait(enum si_sm_result smi_result, | ||
946 | const struct smi_info *smi_info, | ||
947 | struct timespec *busy_until) | ||
948 | { | ||
949 | unsigned int max_busy_us = 0; | ||
950 | |||
951 | if (smi_info->intf_num < num_max_busy_us) | ||
952 | max_busy_us = kipmid_max_busy_us[smi_info->intf_num]; | ||
953 | if (max_busy_us == 0 || smi_result != SI_SM_CALL_WITH_DELAY) | ||
954 | ipmi_si_set_not_busy(busy_until); | ||
955 | else if (!ipmi_si_is_busy(busy_until)) { | ||
956 | getnstimeofday(busy_until); | ||
957 | timespec_add_ns(busy_until, max_busy_us*NSEC_PER_USEC); | ||
958 | } else { | ||
959 | struct timespec now; | ||
960 | getnstimeofday(&now); | ||
961 | if (unlikely(timespec_compare(&now, busy_until) > 0)) { | ||
962 | ipmi_si_set_not_busy(busy_until); | ||
963 | return 0; | ||
964 | } | ||
965 | } | ||
966 | return 1; | ||
967 | } | ||
968 | |||
969 | |||
970 | /* | ||
971 | * A busy-waiting loop for speeding up IPMI operation. | ||
972 | * | ||
973 | * Lousy hardware makes this hard. This is only enabled for systems | ||
974 | * that are not BT and do not have interrupts. It starts spinning | ||
975 | * when an operation is complete or until max_busy tells it to stop | ||
976 | * (if that is enabled). See the paragraph on kimid_max_busy_us in | ||
977 | * Documentation/IPMI.txt for details. | ||
978 | */ | ||
928 | static int ipmi_thread(void *data) | 979 | static int ipmi_thread(void *data) |
929 | { | 980 | { |
930 | struct smi_info *smi_info = data; | 981 | struct smi_info *smi_info = data; |
931 | unsigned long flags; | 982 | unsigned long flags; |
932 | enum si_sm_result smi_result; | 983 | enum si_sm_result smi_result; |
984 | struct timespec busy_until; | ||
933 | 985 | ||
986 | ipmi_si_set_not_busy(&busy_until); | ||
934 | set_user_nice(current, 19); | 987 | set_user_nice(current, 19); |
935 | while (!kthread_should_stop()) { | 988 | while (!kthread_should_stop()) { |
989 | int busy_wait; | ||
990 | |||
936 | spin_lock_irqsave(&(smi_info->si_lock), flags); | 991 | spin_lock_irqsave(&(smi_info->si_lock), flags); |
937 | smi_result = smi_event_handler(smi_info, 0); | 992 | smi_result = smi_event_handler(smi_info, 0); |
938 | spin_unlock_irqrestore(&(smi_info->si_lock), flags); | 993 | spin_unlock_irqrestore(&(smi_info->si_lock), flags); |
994 | busy_wait = ipmi_thread_busy_wait(smi_result, smi_info, | ||
995 | &busy_until); | ||
939 | if (smi_result == SI_SM_CALL_WITHOUT_DELAY) | 996 | if (smi_result == SI_SM_CALL_WITHOUT_DELAY) |
940 | ; /* do nothing */ | 997 | ; /* do nothing */ |
941 | else if (smi_result == SI_SM_CALL_WITH_DELAY) | 998 | else if (smi_result == SI_SM_CALL_WITH_DELAY && busy_wait) |
942 | schedule(); | 999 | schedule(); |
943 | else | 1000 | else |
944 | schedule_timeout_interruptible(1); | 1001 | schedule_timeout_interruptible(0); |
945 | } | 1002 | } |
946 | return 0; | 1003 | return 0; |
947 | } | 1004 | } |
@@ -1144,7 +1201,7 @@ static int regsizes[SI_MAX_PARMS]; | |||
1144 | static unsigned int num_regsizes; | 1201 | static unsigned int num_regsizes; |
1145 | static int regshifts[SI_MAX_PARMS]; | 1202 | static int regshifts[SI_MAX_PARMS]; |
1146 | static unsigned int num_regshifts; | 1203 | static unsigned int num_regshifts; |
1147 | static int slave_addrs[SI_MAX_PARMS]; | 1204 | static int slave_addrs[SI_MAX_PARMS]; /* Leaving 0 chooses the default value */ |
1148 | static unsigned int num_slave_addrs; | 1205 | static unsigned int num_slave_addrs; |
1149 | 1206 | ||
1150 | #define IPMI_IO_ADDR_SPACE 0 | 1207 | #define IPMI_IO_ADDR_SPACE 0 |
@@ -1212,6 +1269,11 @@ module_param(unload_when_empty, int, 0); | |||
1212 | MODULE_PARM_DESC(unload_when_empty, "Unload the module if no interfaces are" | 1269 | MODULE_PARM_DESC(unload_when_empty, "Unload the module if no interfaces are" |
1213 | " specified or found, default is 1. Setting to 0" | 1270 | " specified or found, default is 1. Setting to 0" |
1214 | " is useful for hot add of devices using hotmod."); | 1271 | " is useful for hot add of devices using hotmod."); |
1272 | module_param_array(kipmid_max_busy_us, uint, &num_max_busy_us, 0644); | ||
1273 | MODULE_PARM_DESC(kipmid_max_busy_us, | ||
1274 | "Max time (in microseconds) to busy-wait for IPMI data before" | ||
1275 | " sleeping. 0 (default) means to wait forever. Set to 100-500" | ||
1276 | " if kipmid is using up a lot of CPU time."); | ||
1215 | 1277 | ||
1216 | 1278 | ||
1217 | static void std_irq_cleanup(struct smi_info *info) | 1279 | static void std_irq_cleanup(struct smi_info *info) |
@@ -1607,7 +1669,7 @@ static int hotmod_handler(const char *val, struct kernel_param *kp) | |||
1607 | regsize = 1; | 1669 | regsize = 1; |
1608 | regshift = 0; | 1670 | regshift = 0; |
1609 | irq = 0; | 1671 | irq = 0; |
1610 | ipmb = 0x20; | 1672 | ipmb = 0; /* Choose the default if not specified */ |
1611 | 1673 | ||
1612 | next = strchr(curr, ':'); | 1674 | next = strchr(curr, ':'); |
1613 | if (next) { | 1675 | if (next) { |
@@ -1799,6 +1861,7 @@ static __devinit void hardcode_find_bmc(void) | |||
1799 | info->irq = irqs[i]; | 1861 | info->irq = irqs[i]; |
1800 | if (info->irq) | 1862 | if (info->irq) |
1801 | info->irq_setup = std_irq_setup; | 1863 | info->irq_setup = std_irq_setup; |
1864 | info->slave_addr = slave_addrs[i]; | ||
1802 | 1865 | ||
1803 | try_smi_init(info); | 1866 | try_smi_init(info); |
1804 | } | 1867 | } |
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c index 300d5bd6cd06..be2e8f9a27c3 100644 --- a/drivers/char/isicom.c +++ b/drivers/char/isicom.c | |||
@@ -113,6 +113,8 @@ | |||
113 | * 64-bit verification | 113 | * 64-bit verification |
114 | */ | 114 | */ |
115 | 115 | ||
116 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
117 | |||
116 | #include <linux/module.h> | 118 | #include <linux/module.h> |
117 | #include <linux/firmware.h> | 119 | #include <linux/firmware.h> |
118 | #include <linux/kernel.h> | 120 | #include <linux/kernel.h> |
@@ -140,7 +142,6 @@ | |||
140 | #define InterruptTheCard(base) outw(0, (base) + 0xc) | 142 | #define InterruptTheCard(base) outw(0, (base) + 0xc) |
141 | #define ClearInterrupt(base) inw((base) + 0x0a) | 143 | #define ClearInterrupt(base) inw((base) + 0x0a) |
142 | 144 | ||
143 | #define pr_dbg(str...) pr_debug("ISICOM: " str) | ||
144 | #ifdef DEBUG | 145 | #ifdef DEBUG |
145 | #define isicom_paranoia_check(a, b, c) __isicom_paranoia_check((a), (b), (c)) | 146 | #define isicom_paranoia_check(a, b, c) __isicom_paranoia_check((a), (b), (c)) |
146 | #else | 147 | #else |
@@ -249,8 +250,7 @@ static int lock_card(struct isi_board *card) | |||
249 | spin_unlock_irqrestore(&card->card_lock, card->flags); | 250 | spin_unlock_irqrestore(&card->card_lock, card->flags); |
250 | msleep(10); | 251 | msleep(10); |
251 | } | 252 | } |
252 | printk(KERN_WARNING "ISICOM: Failed to lock Card (0x%lx)\n", | 253 | pr_warning("Failed to lock Card (0x%lx)\n", card->base); |
253 | card->base); | ||
254 | 254 | ||
255 | return 0; /* Failed to acquire the card! */ | 255 | return 0; /* Failed to acquire the card! */ |
256 | } | 256 | } |
@@ -379,13 +379,13 @@ static inline int __isicom_paranoia_check(struct isi_port const *port, | |||
379 | char *name, const char *routine) | 379 | char *name, const char *routine) |
380 | { | 380 | { |
381 | if (!port) { | 381 | if (!port) { |
382 | printk(KERN_WARNING "ISICOM: Warning: bad isicom magic for " | 382 | pr_warning("Warning: bad isicom magic for dev %s in %s.\n", |
383 | "dev %s in %s.\n", name, routine); | 383 | name, routine); |
384 | return 1; | 384 | return 1; |
385 | } | 385 | } |
386 | if (port->magic != ISICOM_MAGIC) { | 386 | if (port->magic != ISICOM_MAGIC) { |
387 | printk(KERN_WARNING "ISICOM: Warning: NULL isicom port for " | 387 | pr_warning("Warning: NULL isicom port for dev %s in %s.\n", |
388 | "dev %s in %s.\n", name, routine); | 388 | name, routine); |
389 | return 1; | 389 | return 1; |
390 | } | 390 | } |
391 | 391 | ||
@@ -450,8 +450,8 @@ static void isicom_tx(unsigned long _data) | |||
450 | if (!(inw(base + 0x02) & (1 << port->channel))) | 450 | if (!(inw(base + 0x02) & (1 << port->channel))) |
451 | continue; | 451 | continue; |
452 | 452 | ||
453 | pr_dbg("txing %d bytes, port%d.\n", txcount, | 453 | pr_debug("txing %d bytes, port%d.\n", |
454 | port->channel + 1); | 454 | txcount, port->channel + 1); |
455 | outw((port->channel << isi_card[card].shift_count) | txcount, | 455 | outw((port->channel << isi_card[card].shift_count) | txcount, |
456 | base); | 456 | base); |
457 | residue = NO; | 457 | residue = NO; |
@@ -547,8 +547,8 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) | |||
547 | byte_count = header & 0xff; | 547 | byte_count = header & 0xff; |
548 | 548 | ||
549 | if (channel + 1 > card->port_count) { | 549 | if (channel + 1 > card->port_count) { |
550 | printk(KERN_WARNING "ISICOM: isicom_interrupt(0x%lx): " | 550 | pr_warning("%s(0x%lx): %d(channel) > port_count.\n", |
551 | "%d(channel) > port_count.\n", base, channel+1); | 551 | __func__, base, channel+1); |
552 | outw(0x0000, base+0x04); /* enable interrupts */ | 552 | outw(0x0000, base+0x04); /* enable interrupts */ |
553 | spin_unlock(&card->card_lock); | 553 | spin_unlock(&card->card_lock); |
554 | return IRQ_HANDLED; | 554 | return IRQ_HANDLED; |
@@ -582,14 +582,15 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) | |||
582 | if (port->status & ISI_DCD) { | 582 | if (port->status & ISI_DCD) { |
583 | if (!(header & ISI_DCD)) { | 583 | if (!(header & ISI_DCD)) { |
584 | /* Carrier has been lost */ | 584 | /* Carrier has been lost */ |
585 | pr_dbg("interrupt: DCD->low.\n" | 585 | pr_debug("%s: DCD->low.\n", |
586 | ); | 586 | __func__); |
587 | port->status &= ~ISI_DCD; | 587 | port->status &= ~ISI_DCD; |
588 | tty_hangup(tty); | 588 | tty_hangup(tty); |
589 | } | 589 | } |
590 | } else if (header & ISI_DCD) { | 590 | } else if (header & ISI_DCD) { |
591 | /* Carrier has been detected */ | 591 | /* Carrier has been detected */ |
592 | pr_dbg("interrupt: DCD->high.\n"); | 592 | pr_debug("%s: DCD->high.\n", |
593 | __func__); | ||
593 | port->status |= ISI_DCD; | 594 | port->status |= ISI_DCD; |
594 | wake_up_interruptible(&port->port.open_wait); | 595 | wake_up_interruptible(&port->port.open_wait); |
595 | } | 596 | } |
@@ -641,17 +642,19 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) | |||
641 | break; | 642 | break; |
642 | 643 | ||
643 | case 2: /* Statistics */ | 644 | case 2: /* Statistics */ |
644 | pr_dbg("isicom_interrupt: stats!!!.\n"); | 645 | pr_debug("%s: stats!!!\n", __func__); |
645 | break; | 646 | break; |
646 | 647 | ||
647 | default: | 648 | default: |
648 | pr_dbg("Intr: Unknown code in status packet.\n"); | 649 | pr_debug("%s: Unknown code in status packet.\n", |
650 | __func__); | ||
649 | break; | 651 | break; |
650 | } | 652 | } |
651 | } else { /* Data Packet */ | 653 | } else { /* Data Packet */ |
652 | 654 | ||
653 | count = tty_prepare_flip_string(tty, &rp, byte_count & ~1); | 655 | count = tty_prepare_flip_string(tty, &rp, byte_count & ~1); |
654 | pr_dbg("Intr: Can rx %d of %d bytes.\n", count, byte_count); | 656 | pr_debug("%s: Can rx %d of %d bytes.\n", |
657 | __func__, count, byte_count); | ||
655 | word_count = count >> 1; | 658 | word_count = count >> 1; |
656 | insw(base, rp, word_count); | 659 | insw(base, rp, word_count); |
657 | byte_count -= (word_count << 1); | 660 | byte_count -= (word_count << 1); |
@@ -661,8 +664,8 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) | |||
661 | byte_count -= 2; | 664 | byte_count -= 2; |
662 | } | 665 | } |
663 | if (byte_count > 0) { | 666 | if (byte_count > 0) { |
664 | pr_dbg("Intr(0x%lx:%d): Flip buffer overflow! dropping " | 667 | pr_debug("%s(0x%lx:%d): Flip buffer overflow! dropping bytes...\n", |
665 | "bytes...\n", base, channel + 1); | 668 | __func__, base, channel + 1); |
666 | /* drain out unread xtra data */ | 669 | /* drain out unread xtra data */ |
667 | while (byte_count > 0) { | 670 | while (byte_count > 0) { |
668 | inw(base); | 671 | inw(base); |
@@ -888,8 +891,8 @@ static void isicom_shutdown_port(struct isi_port *port) | |||
888 | struct isi_board *card = port->card; | 891 | struct isi_board *card = port->card; |
889 | 892 | ||
890 | if (--card->count < 0) { | 893 | if (--card->count < 0) { |
891 | pr_dbg("isicom_shutdown_port: bad board(0x%lx) count %d.\n", | 894 | pr_debug("%s: bad board(0x%lx) count %d.\n", |
892 | card->base, card->count); | 895 | __func__, card->base, card->count); |
893 | card->count = 0; | 896 | card->count = 0; |
894 | } | 897 | } |
895 | /* last port was closed, shutdown that board too */ | 898 | /* last port was closed, shutdown that board too */ |
@@ -1681,13 +1684,13 @@ static int __init isicom_init(void) | |||
1681 | 1684 | ||
1682 | retval = tty_register_driver(isicom_normal); | 1685 | retval = tty_register_driver(isicom_normal); |
1683 | if (retval) { | 1686 | if (retval) { |
1684 | pr_dbg("Couldn't register the dialin driver\n"); | 1687 | pr_debug("Couldn't register the dialin driver\n"); |
1685 | goto err_puttty; | 1688 | goto err_puttty; |
1686 | } | 1689 | } |
1687 | 1690 | ||
1688 | retval = pci_register_driver(&isicom_driver); | 1691 | retval = pci_register_driver(&isicom_driver); |
1689 | if (retval < 0) { | 1692 | if (retval < 0) { |
1690 | printk(KERN_ERR "ISICOM: Unable to register pci driver.\n"); | 1693 | pr_err("Unable to register pci driver.\n"); |
1691 | goto err_unrtty; | 1694 | goto err_unrtty; |
1692 | } | 1695 | } |
1693 | 1696 | ||
@@ -1717,3 +1720,8 @@ module_exit(isicom_exit); | |||
1717 | MODULE_AUTHOR("MultiTech"); | 1720 | MODULE_AUTHOR("MultiTech"); |
1718 | MODULE_DESCRIPTION("Driver for the ISI series of cards by MultiTech"); | 1721 | MODULE_DESCRIPTION("Driver for the ISI series of cards by MultiTech"); |
1719 | MODULE_LICENSE("GPL"); | 1722 | MODULE_LICENSE("GPL"); |
1723 | MODULE_FIRMWARE("isi608.bin"); | ||
1724 | MODULE_FIRMWARE("isi608em.bin"); | ||
1725 | MODULE_FIRMWARE("isi616em.bin"); | ||
1726 | MODULE_FIRMWARE("isi4608.bin"); | ||
1727 | MODULE_FIRMWARE("isi4616.bin"); | ||
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index f706b1dffdb3..ada25bb8941e 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c | |||
@@ -1185,11 +1185,6 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw) | |||
1185 | 1185 | ||
1186 | rep = (down == 2); | 1186 | rep = (down == 2); |
1187 | 1187 | ||
1188 | #ifdef CONFIG_MAC_EMUMOUSEBTN | ||
1189 | if (mac_hid_mouse_emulate_buttons(1, keycode, down)) | ||
1190 | return; | ||
1191 | #endif /* CONFIG_MAC_EMUMOUSEBTN */ | ||
1192 | |||
1193 | if ((raw_mode = (kbd->kbdmode == VC_RAW)) && !hw_raw) | 1188 | if ((raw_mode = (kbd->kbdmode == VC_RAW)) && !hw_raw) |
1194 | if (emulate_raw(vc, keycode, !down << 7)) | 1189 | if (emulate_raw(vc, keycode, !down << 7)) |
1195 | if (keycode < BTN_MISC && printk_ratelimit()) | 1190 | if (keycode < BTN_MISC && printk_ratelimit()) |
@@ -1328,6 +1323,21 @@ static void kbd_event(struct input_handle *handle, unsigned int event_type, | |||
1328 | schedule_console_callback(); | 1323 | schedule_console_callback(); |
1329 | } | 1324 | } |
1330 | 1325 | ||
1326 | static bool kbd_match(struct input_handler *handler, struct input_dev *dev) | ||
1327 | { | ||
1328 | int i; | ||
1329 | |||
1330 | if (test_bit(EV_SND, dev->evbit)) | ||
1331 | return true; | ||
1332 | |||
1333 | if (test_bit(EV_KEY, dev->evbit)) | ||
1334 | for (i = KEY_RESERVED; i < BTN_MISC; i++) | ||
1335 | if (test_bit(i, dev->keybit)) | ||
1336 | return true; | ||
1337 | |||
1338 | return false; | ||
1339 | } | ||
1340 | |||
1331 | /* | 1341 | /* |
1332 | * When a keyboard (or other input device) is found, the kbd_connect | 1342 | * When a keyboard (or other input device) is found, the kbd_connect |
1333 | * function is called. The function then looks at the device, and if it | 1343 | * function is called. The function then looks at the device, and if it |
@@ -1339,14 +1349,6 @@ static int kbd_connect(struct input_handler *handler, struct input_dev *dev, | |||
1339 | { | 1349 | { |
1340 | struct input_handle *handle; | 1350 | struct input_handle *handle; |
1341 | int error; | 1351 | int error; |
1342 | int i; | ||
1343 | |||
1344 | for (i = KEY_RESERVED; i < BTN_MISC; i++) | ||
1345 | if (test_bit(i, dev->keybit)) | ||
1346 | break; | ||
1347 | |||
1348 | if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit)) | ||
1349 | return -ENODEV; | ||
1350 | 1352 | ||
1351 | handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL); | 1353 | handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL); |
1352 | if (!handle) | 1354 | if (!handle) |
@@ -1412,6 +1414,7 @@ MODULE_DEVICE_TABLE(input, kbd_ids); | |||
1412 | 1414 | ||
1413 | static struct input_handler kbd_handler = { | 1415 | static struct input_handler kbd_handler = { |
1414 | .event = kbd_event, | 1416 | .event = kbd_event, |
1417 | .match = kbd_match, | ||
1415 | .connect = kbd_connect, | 1418 | .connect = kbd_connect, |
1416 | .disconnect = kbd_disconnect, | 1419 | .disconnect = kbd_disconnect, |
1417 | .start = kbd_start, | 1420 | .start = kbd_start, |
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index be832b6f8279..1f3215ac085b 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 1991, 1992 Linus Torvalds | 4 | * Copyright (C) 1991, 1992 Linus Torvalds |
5 | * | 5 | * |
6 | * Added devfs support. | 6 | * Added devfs support. |
7 | * Jan-11-1998, C. Scott Ananian <cananian@alumni.princeton.edu> | 7 | * Jan-11-1998, C. Scott Ananian <cananian@alumni.princeton.edu> |
8 | * Shared /dev/zero mmapping support, Feb 2000, Kanoj Sarcar <kanoj@sgi.com> | 8 | * Shared /dev/zero mmapping support, Feb 2000, Kanoj Sarcar <kanoj@sgi.com> |
9 | */ | 9 | */ |
@@ -44,36 +44,6 @@ static inline unsigned long size_inside_page(unsigned long start, | |||
44 | return min(sz, size); | 44 | return min(sz, size); |
45 | } | 45 | } |
46 | 46 | ||
47 | /* | ||
48 | * Architectures vary in how they handle caching for addresses | ||
49 | * outside of main memory. | ||
50 | * | ||
51 | */ | ||
52 | static inline int uncached_access(struct file *file, unsigned long addr) | ||
53 | { | ||
54 | #if defined(CONFIG_IA64) | ||
55 | /* | ||
56 | * On ia64, we ignore O_DSYNC because we cannot tolerate memory attribute aliases. | ||
57 | */ | ||
58 | return !(efi_mem_attributes(addr) & EFI_MEMORY_WB); | ||
59 | #elif defined(CONFIG_MIPS) | ||
60 | { | ||
61 | extern int __uncached_access(struct file *file, | ||
62 | unsigned long addr); | ||
63 | |||
64 | return __uncached_access(file, addr); | ||
65 | } | ||
66 | #else | ||
67 | /* | ||
68 | * Accessing memory above the top the kernel knows about or through a file pointer | ||
69 | * that was marked O_DSYNC will be done non-cached. | ||
70 | */ | ||
71 | if (file->f_flags & O_DSYNC) | ||
72 | return 1; | ||
73 | return addr >= __pa(high_memory); | ||
74 | #endif | ||
75 | } | ||
76 | |||
77 | #ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE | 47 | #ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE |
78 | static inline int valid_phys_addr_range(unsigned long addr, size_t count) | 48 | static inline int valid_phys_addr_range(unsigned long addr, size_t count) |
79 | { | 49 | { |
@@ -115,15 +85,15 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size) | |||
115 | } | 85 | } |
116 | #endif | 86 | #endif |
117 | 87 | ||
118 | void __attribute__((weak)) unxlate_dev_mem_ptr(unsigned long phys, void *addr) | 88 | void __weak unxlate_dev_mem_ptr(unsigned long phys, void *addr) |
119 | { | 89 | { |
120 | } | 90 | } |
121 | 91 | ||
122 | /* | 92 | /* |
123 | * This funcion reads the *physical* memory. The f_pos points directly to the | 93 | * This funcion reads the *physical* memory. The f_pos points directly to the |
124 | * memory location. | 94 | * memory location. |
125 | */ | 95 | */ |
126 | static ssize_t read_mem(struct file * file, char __user * buf, | 96 | static ssize_t read_mem(struct file *file, char __user *buf, |
127 | size_t count, loff_t *ppos) | 97 | size_t count, loff_t *ppos) |
128 | { | 98 | { |
129 | unsigned long p = *ppos; | 99 | unsigned long p = *ppos; |
@@ -140,10 +110,10 @@ static ssize_t read_mem(struct file * file, char __user * buf, | |||
140 | if (sz > 0) { | 110 | if (sz > 0) { |
141 | if (clear_user(buf, sz)) | 111 | if (clear_user(buf, sz)) |
142 | return -EFAULT; | 112 | return -EFAULT; |
143 | buf += sz; | 113 | buf += sz; |
144 | p += sz; | 114 | p += sz; |
145 | count -= sz; | 115 | count -= sz; |
146 | read += sz; | 116 | read += sz; |
147 | } | 117 | } |
148 | } | 118 | } |
149 | #endif | 119 | #endif |
@@ -157,9 +127,9 @@ static ssize_t read_mem(struct file * file, char __user * buf, | |||
157 | return -EPERM; | 127 | return -EPERM; |
158 | 128 | ||
159 | /* | 129 | /* |
160 | * On ia64 if a page has been mapped somewhere as | 130 | * On ia64 if a page has been mapped somewhere as uncached, then |
161 | * uncached, then it must also be accessed uncached | 131 | * it must also be accessed uncached by the kernel or data |
162 | * by the kernel or data corruption may occur | 132 | * corruption may occur. |
163 | */ | 133 | */ |
164 | ptr = xlate_dev_mem_ptr(p); | 134 | ptr = xlate_dev_mem_ptr(p); |
165 | if (!ptr) | 135 | if (!ptr) |
@@ -180,7 +150,7 @@ static ssize_t read_mem(struct file * file, char __user * buf, | |||
180 | return read; | 150 | return read; |
181 | } | 151 | } |
182 | 152 | ||
183 | static ssize_t write_mem(struct file * file, const char __user * buf, | 153 | static ssize_t write_mem(struct file *file, const char __user *buf, |
184 | size_t count, loff_t *ppos) | 154 | size_t count, loff_t *ppos) |
185 | { | 155 | { |
186 | unsigned long p = *ppos; | 156 | unsigned long p = *ppos; |
@@ -212,9 +182,9 @@ static ssize_t write_mem(struct file * file, const char __user * buf, | |||
212 | return -EPERM; | 182 | return -EPERM; |
213 | 183 | ||
214 | /* | 184 | /* |
215 | * On ia64 if a page has been mapped somewhere as | 185 | * On ia64 if a page has been mapped somewhere as uncached, then |
216 | * uncached, then it must also be accessed uncached | 186 | * it must also be accessed uncached by the kernel or data |
217 | * by the kernel or data corruption may occur | 187 | * corruption may occur. |
218 | */ | 188 | */ |
219 | ptr = xlate_dev_mem_ptr(p); | 189 | ptr = xlate_dev_mem_ptr(p); |
220 | if (!ptr) { | 190 | if (!ptr) { |
@@ -242,13 +212,46 @@ static ssize_t write_mem(struct file * file, const char __user * buf, | |||
242 | return written; | 212 | return written; |
243 | } | 213 | } |
244 | 214 | ||
245 | int __attribute__((weak)) phys_mem_access_prot_allowed(struct file *file, | 215 | int __weak phys_mem_access_prot_allowed(struct file *file, |
246 | unsigned long pfn, unsigned long size, pgprot_t *vma_prot) | 216 | unsigned long pfn, unsigned long size, pgprot_t *vma_prot) |
247 | { | 217 | { |
248 | return 1; | 218 | return 1; |
249 | } | 219 | } |
250 | 220 | ||
251 | #ifndef __HAVE_PHYS_MEM_ACCESS_PROT | 221 | #ifndef __HAVE_PHYS_MEM_ACCESS_PROT |
222 | |||
223 | /* | ||
224 | * Architectures vary in how they handle caching for addresses | ||
225 | * outside of main memory. | ||
226 | * | ||
227 | */ | ||
228 | static int uncached_access(struct file *file, unsigned long addr) | ||
229 | { | ||
230 | #if defined(CONFIG_IA64) | ||
231 | /* | ||
232 | * On ia64, we ignore O_DSYNC because we cannot tolerate memory | ||
233 | * attribute aliases. | ||
234 | */ | ||
235 | return !(efi_mem_attributes(addr) & EFI_MEMORY_WB); | ||
236 | #elif defined(CONFIG_MIPS) | ||
237 | { | ||
238 | extern int __uncached_access(struct file *file, | ||
239 | unsigned long addr); | ||
240 | |||
241 | return __uncached_access(file, addr); | ||
242 | } | ||
243 | #else | ||
244 | /* | ||
245 | * Accessing memory above the top the kernel knows about or through a | ||
246 | * file pointer | ||
247 | * that was marked O_DSYNC will be done non-cached. | ||
248 | */ | ||
249 | if (file->f_flags & O_DSYNC) | ||
250 | return 1; | ||
251 | return addr >= __pa(high_memory); | ||
252 | #endif | ||
253 | } | ||
254 | |||
252 | static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, | 255 | static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, |
253 | unsigned long size, pgprot_t vma_prot) | 256 | unsigned long size, pgprot_t vma_prot) |
254 | { | 257 | { |
@@ -294,7 +297,7 @@ static const struct vm_operations_struct mmap_mem_ops = { | |||
294 | #endif | 297 | #endif |
295 | }; | 298 | }; |
296 | 299 | ||
297 | static int mmap_mem(struct file * file, struct vm_area_struct * vma) | 300 | static int mmap_mem(struct file *file, struct vm_area_struct *vma) |
298 | { | 301 | { |
299 | size_t size = vma->vm_end - vma->vm_start; | 302 | size_t size = vma->vm_end - vma->vm_start; |
300 | 303 | ||
@@ -329,7 +332,7 @@ static int mmap_mem(struct file * file, struct vm_area_struct * vma) | |||
329 | } | 332 | } |
330 | 333 | ||
331 | #ifdef CONFIG_DEVKMEM | 334 | #ifdef CONFIG_DEVKMEM |
332 | static int mmap_kmem(struct file * file, struct vm_area_struct * vma) | 335 | static int mmap_kmem(struct file *file, struct vm_area_struct *vma) |
333 | { | 336 | { |
334 | unsigned long pfn; | 337 | unsigned long pfn; |
335 | 338 | ||
@@ -337,9 +340,9 @@ static int mmap_kmem(struct file * file, struct vm_area_struct * vma) | |||
337 | pfn = __pa((u64)vma->vm_pgoff << PAGE_SHIFT) >> PAGE_SHIFT; | 340 | pfn = __pa((u64)vma->vm_pgoff << PAGE_SHIFT) >> PAGE_SHIFT; |
338 | 341 | ||
339 | /* | 342 | /* |
340 | * RED-PEN: on some architectures there is more mapped memory | 343 | * RED-PEN: on some architectures there is more mapped memory than |
341 | * than available in mem_map which pfn_valid checks | 344 | * available in mem_map which pfn_valid checks for. Perhaps should add a |
342 | * for. Perhaps should add a new macro here. | 345 | * new macro here. |
343 | * | 346 | * |
344 | * RED-PEN: vmalloc is not supported right now. | 347 | * RED-PEN: vmalloc is not supported right now. |
345 | */ | 348 | */ |
@@ -389,18 +392,19 @@ static ssize_t read_oldmem(struct file *file, char __user *buf, | |||
389 | /* | 392 | /* |
390 | * This function reads the *virtual* memory as seen by the kernel. | 393 | * This function reads the *virtual* memory as seen by the kernel. |
391 | */ | 394 | */ |
392 | static ssize_t read_kmem(struct file *file, char __user *buf, | 395 | static ssize_t read_kmem(struct file *file, char __user *buf, |
393 | size_t count, loff_t *ppos) | 396 | size_t count, loff_t *ppos) |
394 | { | 397 | { |
395 | unsigned long p = *ppos; | 398 | unsigned long p = *ppos; |
396 | ssize_t low_count, read, sz; | 399 | ssize_t low_count, read, sz; |
397 | char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */ | 400 | char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */ |
401 | int err = 0; | ||
398 | 402 | ||
399 | read = 0; | 403 | read = 0; |
400 | if (p < (unsigned long) high_memory) { | 404 | if (p < (unsigned long) high_memory) { |
401 | low_count = count; | 405 | low_count = count; |
402 | if (count > (unsigned long) high_memory - p) | 406 | if (count > (unsigned long)high_memory - p) |
403 | low_count = (unsigned long) high_memory - p; | 407 | low_count = (unsigned long)high_memory - p; |
404 | 408 | ||
405 | #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED | 409 | #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED |
406 | /* we don't have page 0 mapped on sparc and m68k.. */ | 410 | /* we don't have page 0 mapped on sparc and m68k.. */ |
@@ -441,12 +445,16 @@ static ssize_t read_kmem(struct file *file, char __user *buf, | |||
441 | return -ENOMEM; | 445 | return -ENOMEM; |
442 | while (count > 0) { | 446 | while (count > 0) { |
443 | sz = size_inside_page(p, count); | 447 | sz = size_inside_page(p, count); |
448 | if (!is_vmalloc_or_module_addr((void *)p)) { | ||
449 | err = -ENXIO; | ||
450 | break; | ||
451 | } | ||
444 | sz = vread(kbuf, (char *)p, sz); | 452 | sz = vread(kbuf, (char *)p, sz); |
445 | if (!sz) | 453 | if (!sz) |
446 | break; | 454 | break; |
447 | if (copy_to_user(buf, kbuf, sz)) { | 455 | if (copy_to_user(buf, kbuf, sz)) { |
448 | free_page((unsigned long)kbuf); | 456 | err = -EFAULT; |
449 | return -EFAULT; | 457 | break; |
450 | } | 458 | } |
451 | count -= sz; | 459 | count -= sz; |
452 | buf += sz; | 460 | buf += sz; |
@@ -455,14 +463,13 @@ static ssize_t read_kmem(struct file *file, char __user *buf, | |||
455 | } | 463 | } |
456 | free_page((unsigned long)kbuf); | 464 | free_page((unsigned long)kbuf); |
457 | } | 465 | } |
458 | *ppos = p; | 466 | *ppos = p; |
459 | return read; | 467 | return read ? read : err; |
460 | } | 468 | } |
461 | 469 | ||
462 | 470 | ||
463 | static inline ssize_t | 471 | static ssize_t do_write_kmem(unsigned long p, const char __user *buf, |
464 | do_write_kmem(unsigned long p, const char __user *buf, | 472 | size_t count, loff_t *ppos) |
465 | size_t count, loff_t *ppos) | ||
466 | { | 473 | { |
467 | ssize_t written, sz; | 474 | ssize_t written, sz; |
468 | unsigned long copied; | 475 | unsigned long copied; |
@@ -486,9 +493,9 @@ do_write_kmem(unsigned long p, const char __user *buf, | |||
486 | sz = size_inside_page(p, count); | 493 | sz = size_inside_page(p, count); |
487 | 494 | ||
488 | /* | 495 | /* |
489 | * On ia64 if a page has been mapped somewhere as | 496 | * On ia64 if a page has been mapped somewhere as uncached, then |
490 | * uncached, then it must also be accessed uncached | 497 | * it must also be accessed uncached by the kernel or data |
491 | * by the kernel or data corruption may occur | 498 | * corruption may occur. |
492 | */ | 499 | */ |
493 | ptr = xlate_dev_kmem_ptr((char *)p); | 500 | ptr = xlate_dev_kmem_ptr((char *)p); |
494 | 501 | ||
@@ -509,17 +516,17 @@ do_write_kmem(unsigned long p, const char __user *buf, | |||
509 | return written; | 516 | return written; |
510 | } | 517 | } |
511 | 518 | ||
512 | |||
513 | /* | 519 | /* |
514 | * This function writes to the *virtual* memory as seen by the kernel. | 520 | * This function writes to the *virtual* memory as seen by the kernel. |
515 | */ | 521 | */ |
516 | static ssize_t write_kmem(struct file * file, const char __user * buf, | 522 | static ssize_t write_kmem(struct file *file, const char __user *buf, |
517 | size_t count, loff_t *ppos) | 523 | size_t count, loff_t *ppos) |
518 | { | 524 | { |
519 | unsigned long p = *ppos; | 525 | unsigned long p = *ppos; |
520 | ssize_t wrote = 0; | 526 | ssize_t wrote = 0; |
521 | ssize_t virtr = 0; | 527 | ssize_t virtr = 0; |
522 | char * kbuf; /* k-addr because vwrite() takes vmlist_lock rwlock */ | 528 | char * kbuf; /* k-addr because vwrite() takes vmlist_lock rwlock */ |
529 | int err = 0; | ||
523 | 530 | ||
524 | if (p < (unsigned long) high_memory) { | 531 | if (p < (unsigned long) high_memory) { |
525 | unsigned long to_write = min_t(unsigned long, count, | 532 | unsigned long to_write = min_t(unsigned long, count, |
@@ -540,14 +547,16 @@ static ssize_t write_kmem(struct file * file, const char __user * buf, | |||
540 | unsigned long sz = size_inside_page(p, count); | 547 | unsigned long sz = size_inside_page(p, count); |
541 | unsigned long n; | 548 | unsigned long n; |
542 | 549 | ||
550 | if (!is_vmalloc_or_module_addr((void *)p)) { | ||
551 | err = -ENXIO; | ||
552 | break; | ||
553 | } | ||
543 | n = copy_from_user(kbuf, buf, sz); | 554 | n = copy_from_user(kbuf, buf, sz); |
544 | if (n) { | 555 | if (n) { |
545 | if (wrote + virtr) | 556 | err = -EFAULT; |
546 | break; | 557 | break; |
547 | free_page((unsigned long)kbuf); | ||
548 | return -EFAULT; | ||
549 | } | 558 | } |
550 | sz = vwrite(kbuf, (char *)p, sz); | 559 | vwrite(kbuf, (char *)p, sz); |
551 | count -= sz; | 560 | count -= sz; |
552 | buf += sz; | 561 | buf += sz; |
553 | virtr += sz; | 562 | virtr += sz; |
@@ -556,23 +565,23 @@ static ssize_t write_kmem(struct file * file, const char __user * buf, | |||
556 | free_page((unsigned long)kbuf); | 565 | free_page((unsigned long)kbuf); |
557 | } | 566 | } |
558 | 567 | ||
559 | *ppos = p; | 568 | *ppos = p; |
560 | return virtr + wrote; | 569 | return virtr + wrote ? : err; |
561 | } | 570 | } |
562 | #endif | 571 | #endif |
563 | 572 | ||
564 | #ifdef CONFIG_DEVPORT | 573 | #ifdef CONFIG_DEVPORT |
565 | static ssize_t read_port(struct file * file, char __user * buf, | 574 | static ssize_t read_port(struct file *file, char __user *buf, |
566 | size_t count, loff_t *ppos) | 575 | size_t count, loff_t *ppos) |
567 | { | 576 | { |
568 | unsigned long i = *ppos; | 577 | unsigned long i = *ppos; |
569 | char __user *tmp = buf; | 578 | char __user *tmp = buf; |
570 | 579 | ||
571 | if (!access_ok(VERIFY_WRITE, buf, count)) | 580 | if (!access_ok(VERIFY_WRITE, buf, count)) |
572 | return -EFAULT; | 581 | return -EFAULT; |
573 | while (count-- > 0 && i < 65536) { | 582 | while (count-- > 0 && i < 65536) { |
574 | if (__put_user(inb(i),tmp) < 0) | 583 | if (__put_user(inb(i), tmp) < 0) |
575 | return -EFAULT; | 584 | return -EFAULT; |
576 | i++; | 585 | i++; |
577 | tmp++; | 586 | tmp++; |
578 | } | 587 | } |
@@ -580,22 +589,22 @@ static ssize_t read_port(struct file * file, char __user * buf, | |||
580 | return tmp-buf; | 589 | return tmp-buf; |
581 | } | 590 | } |
582 | 591 | ||
583 | static ssize_t write_port(struct file * file, const char __user * buf, | 592 | static ssize_t write_port(struct file *file, const char __user *buf, |
584 | size_t count, loff_t *ppos) | 593 | size_t count, loff_t *ppos) |
585 | { | 594 | { |
586 | unsigned long i = *ppos; | 595 | unsigned long i = *ppos; |
587 | const char __user * tmp = buf; | 596 | const char __user * tmp = buf; |
588 | 597 | ||
589 | if (!access_ok(VERIFY_READ,buf,count)) | 598 | if (!access_ok(VERIFY_READ, buf, count)) |
590 | return -EFAULT; | 599 | return -EFAULT; |
591 | while (count-- > 0 && i < 65536) { | 600 | while (count-- > 0 && i < 65536) { |
592 | char c; | 601 | char c; |
593 | if (__get_user(c, tmp)) { | 602 | if (__get_user(c, tmp)) { |
594 | if (tmp > buf) | 603 | if (tmp > buf) |
595 | break; | 604 | break; |
596 | return -EFAULT; | 605 | return -EFAULT; |
597 | } | 606 | } |
598 | outb(c,i); | 607 | outb(c, i); |
599 | i++; | 608 | i++; |
600 | tmp++; | 609 | tmp++; |
601 | } | 610 | } |
@@ -604,13 +613,13 @@ static ssize_t write_port(struct file * file, const char __user * buf, | |||
604 | } | 613 | } |
605 | #endif | 614 | #endif |
606 | 615 | ||
607 | static ssize_t read_null(struct file * file, char __user * buf, | 616 | static ssize_t read_null(struct file *file, char __user *buf, |
608 | size_t count, loff_t *ppos) | 617 | size_t count, loff_t *ppos) |
609 | { | 618 | { |
610 | return 0; | 619 | return 0; |
611 | } | 620 | } |
612 | 621 | ||
613 | static ssize_t write_null(struct file * file, const char __user * buf, | 622 | static ssize_t write_null(struct file *file, const char __user *buf, |
614 | size_t count, loff_t *ppos) | 623 | size_t count, loff_t *ppos) |
615 | { | 624 | { |
616 | return count; | 625 | return count; |
@@ -622,13 +631,13 @@ static int pipe_to_null(struct pipe_inode_info *info, struct pipe_buffer *buf, | |||
622 | return sd->len; | 631 | return sd->len; |
623 | } | 632 | } |
624 | 633 | ||
625 | static ssize_t splice_write_null(struct pipe_inode_info *pipe,struct file *out, | 634 | static ssize_t splice_write_null(struct pipe_inode_info *pipe, struct file *out, |
626 | loff_t *ppos, size_t len, unsigned int flags) | 635 | loff_t *ppos, size_t len, unsigned int flags) |
627 | { | 636 | { |
628 | return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_null); | 637 | return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_null); |
629 | } | 638 | } |
630 | 639 | ||
631 | static ssize_t read_zero(struct file * file, char __user * buf, | 640 | static ssize_t read_zero(struct file *file, char __user *buf, |
632 | size_t count, loff_t *ppos) | 641 | size_t count, loff_t *ppos) |
633 | { | 642 | { |
634 | size_t written; | 643 | size_t written; |
@@ -659,7 +668,7 @@ static ssize_t read_zero(struct file * file, char __user * buf, | |||
659 | return written ? written : -EFAULT; | 668 | return written ? written : -EFAULT; |
660 | } | 669 | } |
661 | 670 | ||
662 | static int mmap_zero(struct file * file, struct vm_area_struct * vma) | 671 | static int mmap_zero(struct file *file, struct vm_area_struct *vma) |
663 | { | 672 | { |
664 | #ifndef CONFIG_MMU | 673 | #ifndef CONFIG_MMU |
665 | return -ENOSYS; | 674 | return -ENOSYS; |
@@ -669,7 +678,7 @@ static int mmap_zero(struct file * file, struct vm_area_struct * vma) | |||
669 | return 0; | 678 | return 0; |
670 | } | 679 | } |
671 | 680 | ||
672 | static ssize_t write_full(struct file * file, const char __user * buf, | 681 | static ssize_t write_full(struct file *file, const char __user *buf, |
673 | size_t count, loff_t *ppos) | 682 | size_t count, loff_t *ppos) |
674 | { | 683 | { |
675 | return -ENOSPC; | 684 | return -ENOSPC; |
@@ -680,8 +689,7 @@ static ssize_t write_full(struct file * file, const char __user * buf, | |||
680 | * can fopen() both devices with "a" now. This was previously impossible. | 689 | * can fopen() both devices with "a" now. This was previously impossible. |
681 | * -- SRB. | 690 | * -- SRB. |
682 | */ | 691 | */ |
683 | 692 | static loff_t null_lseek(struct file *file, loff_t offset, int orig) | |
684 | static loff_t null_lseek(struct file * file, loff_t offset, int orig) | ||
685 | { | 693 | { |
686 | return file->f_pos = 0; | 694 | return file->f_pos = 0; |
687 | } | 695 | } |
@@ -694,24 +702,31 @@ static loff_t null_lseek(struct file * file, loff_t offset, int orig) | |||
694 | * also note that seeking relative to the "end of file" isn't supported: | 702 | * also note that seeking relative to the "end of file" isn't supported: |
695 | * it has no meaning, so it returns -EINVAL. | 703 | * it has no meaning, so it returns -EINVAL. |
696 | */ | 704 | */ |
697 | static loff_t memory_lseek(struct file * file, loff_t offset, int orig) | 705 | static loff_t memory_lseek(struct file *file, loff_t offset, int orig) |
698 | { | 706 | { |
699 | loff_t ret; | 707 | loff_t ret; |
700 | 708 | ||
701 | mutex_lock(&file->f_path.dentry->d_inode->i_mutex); | 709 | mutex_lock(&file->f_path.dentry->d_inode->i_mutex); |
702 | switch (orig) { | 710 | switch (orig) { |
703 | case 0: | 711 | case SEEK_CUR: |
704 | file->f_pos = offset; | 712 | offset += file->f_pos; |
705 | ret = file->f_pos; | 713 | if ((unsigned long long)offset < |
706 | force_successful_syscall_return(); | 714 | (unsigned long long)file->f_pos) { |
715 | ret = -EOVERFLOW; | ||
707 | break; | 716 | break; |
708 | case 1: | 717 | } |
709 | file->f_pos += offset; | 718 | case SEEK_SET: |
710 | ret = file->f_pos; | 719 | /* to avoid userland mistaking f_pos=-9 as -EBADF=-9 */ |
711 | force_successful_syscall_return(); | 720 | if ((unsigned long long)offset >= ~0xFFFULL) { |
721 | ret = -EOVERFLOW; | ||
712 | break; | 722 | break; |
713 | default: | 723 | } |
714 | ret = -EINVAL; | 724 | file->f_pos = offset; |
725 | ret = file->f_pos; | ||
726 | force_successful_syscall_return(); | ||
727 | break; | ||
728 | default: | ||
729 | ret = -EINVAL; | ||
715 | } | 730 | } |
716 | mutex_unlock(&file->f_path.dentry->d_inode->i_mutex); | 731 | mutex_unlock(&file->f_path.dentry->d_inode->i_mutex); |
717 | return ret; | 732 | return ret; |
@@ -795,7 +810,7 @@ static const struct file_operations oldmem_fops = { | |||
795 | }; | 810 | }; |
796 | #endif | 811 | #endif |
797 | 812 | ||
798 | static ssize_t kmsg_write(struct file * file, const char __user * buf, | 813 | static ssize_t kmsg_write(struct file *file, const char __user *buf, |
799 | size_t count, loff_t *ppos) | 814 | size_t count, loff_t *ppos) |
800 | { | 815 | { |
801 | char *tmp; | 816 | char *tmp; |
@@ -817,7 +832,7 @@ static ssize_t kmsg_write(struct file * file, const char __user * buf, | |||
817 | } | 832 | } |
818 | 833 | ||
819 | static const struct file_operations kmsg_fops = { | 834 | static const struct file_operations kmsg_fops = { |
820 | .write = kmsg_write, | 835 | .write = kmsg_write, |
821 | }; | 836 | }; |
822 | 837 | ||
823 | static const struct memdev { | 838 | static const struct memdev { |
@@ -868,7 +883,7 @@ static int memory_open(struct inode *inode, struct file *filp) | |||
868 | } | 883 | } |
869 | 884 | ||
870 | static const struct file_operations memory_fops = { | 885 | static const struct file_operations memory_fops = { |
871 | .open = memory_open, | 886 | .open = memory_open, |
872 | }; | 887 | }; |
873 | 888 | ||
874 | static char *mem_devnode(struct device *dev, mode_t *mode) | 889 | static char *mem_devnode(struct device *dev, mode_t *mode) |
@@ -889,7 +904,7 @@ static int __init chr_dev_init(void) | |||
889 | if (err) | 904 | if (err) |
890 | return err; | 905 | return err; |
891 | 906 | ||
892 | if (register_chrdev(MEM_MAJOR,"mem",&memory_fops)) | 907 | if (register_chrdev(MEM_MAJOR, "mem", &memory_fops)) |
893 | printk("unable to get major %d for memory devs\n", MEM_MAJOR); | 908 | printk("unable to get major %d for memory devs\n", MEM_MAJOR); |
894 | 909 | ||
895 | mem_class = class_create(THIS_MODULE, "mem"); | 910 | mem_class = class_create(THIS_MODULE, "mem"); |
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c index 918711aa56f3..04fd0d843b3b 100644 --- a/drivers/char/mmtimer.c +++ b/drivers/char/mmtimer.c | |||
@@ -546,7 +546,7 @@ static void mmtimer_tasklet(unsigned long data) | |||
546 | { | 546 | { |
547 | int nodeid = data; | 547 | int nodeid = data; |
548 | struct mmtimer_node *mn = &timers[nodeid]; | 548 | struct mmtimer_node *mn = &timers[nodeid]; |
549 | struct mmtimer *x = rb_entry(mn->next, struct mmtimer, list); | 549 | struct mmtimer *x; |
550 | struct k_itimer *t; | 550 | struct k_itimer *t; |
551 | unsigned long flags; | 551 | unsigned long flags; |
552 | 552 | ||
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index 63ee3bbc1ce4..166495d6a1d7 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c | |||
@@ -164,24 +164,25 @@ static unsigned int moxaFuncTout = HZ / 2; | |||
164 | static unsigned int moxaLowWaterChk; | 164 | static unsigned int moxaLowWaterChk; |
165 | static DEFINE_MUTEX(moxa_openlock); | 165 | static DEFINE_MUTEX(moxa_openlock); |
166 | static DEFINE_SPINLOCK(moxa_lock); | 166 | static DEFINE_SPINLOCK(moxa_lock); |
167 | /* Variables for insmod */ | 167 | |
168 | #ifdef MODULE | ||
169 | static unsigned long baseaddr[MAX_BOARDS]; | 168 | static unsigned long baseaddr[MAX_BOARDS]; |
170 | static unsigned int type[MAX_BOARDS]; | 169 | static unsigned int type[MAX_BOARDS]; |
171 | static unsigned int numports[MAX_BOARDS]; | 170 | static unsigned int numports[MAX_BOARDS]; |
172 | #endif | ||
173 | 171 | ||
174 | MODULE_AUTHOR("William Chen"); | 172 | MODULE_AUTHOR("William Chen"); |
175 | MODULE_DESCRIPTION("MOXA Intellio Family Multiport Board Device Driver"); | 173 | MODULE_DESCRIPTION("MOXA Intellio Family Multiport Board Device Driver"); |
176 | MODULE_LICENSE("GPL"); | 174 | MODULE_LICENSE("GPL"); |
177 | #ifdef MODULE | 175 | MODULE_FIRMWARE("c218tunx.cod"); |
176 | MODULE_FIRMWARE("cp204unx.cod"); | ||
177 | MODULE_FIRMWARE("c320tunx.cod"); | ||
178 | |||
178 | module_param_array(type, uint, NULL, 0); | 179 | module_param_array(type, uint, NULL, 0); |
179 | MODULE_PARM_DESC(type, "card type: C218=2, C320=4"); | 180 | MODULE_PARM_DESC(type, "card type: C218=2, C320=4"); |
180 | module_param_array(baseaddr, ulong, NULL, 0); | 181 | module_param_array(baseaddr, ulong, NULL, 0); |
181 | MODULE_PARM_DESC(baseaddr, "base address"); | 182 | MODULE_PARM_DESC(baseaddr, "base address"); |
182 | module_param_array(numports, uint, NULL, 0); | 183 | module_param_array(numports, uint, NULL, 0); |
183 | MODULE_PARM_DESC(numports, "numports (ignored for C218)"); | 184 | MODULE_PARM_DESC(numports, "numports (ignored for C218)"); |
184 | #endif | 185 | |
185 | module_param(ttymajor, int, 0); | 186 | module_param(ttymajor, int, 0); |
186 | 187 | ||
187 | /* | 188 | /* |
@@ -1024,6 +1025,8 @@ static int __init moxa_init(void) | |||
1024 | { | 1025 | { |
1025 | unsigned int isabrds = 0; | 1026 | unsigned int isabrds = 0; |
1026 | int retval = 0; | 1027 | int retval = 0; |
1028 | struct moxa_board_conf *brd = moxa_boards; | ||
1029 | unsigned int i; | ||
1027 | 1030 | ||
1028 | printk(KERN_INFO "MOXA Intellio family driver version %s\n", | 1031 | printk(KERN_INFO "MOXA Intellio family driver version %s\n", |
1029 | MOXA_VERSION); | 1032 | MOXA_VERSION); |
@@ -1051,10 +1054,7 @@ static int __init moxa_init(void) | |||
1051 | } | 1054 | } |
1052 | 1055 | ||
1053 | /* Find the boards defined from module args. */ | 1056 | /* Find the boards defined from module args. */ |
1054 | #ifdef MODULE | 1057 | |
1055 | { | ||
1056 | struct moxa_board_conf *brd = moxa_boards; | ||
1057 | unsigned int i; | ||
1058 | for (i = 0; i < MAX_BOARDS; i++) { | 1058 | for (i = 0; i < MAX_BOARDS; i++) { |
1059 | if (!baseaddr[i]) | 1059 | if (!baseaddr[i]) |
1060 | break; | 1060 | break; |
@@ -1087,8 +1087,6 @@ static int __init moxa_init(void) | |||
1087 | isabrds++; | 1087 | isabrds++; |
1088 | } | 1088 | } |
1089 | } | 1089 | } |
1090 | } | ||
1091 | #endif | ||
1092 | 1090 | ||
1093 | #ifdef CONFIG_PCI | 1091 | #ifdef CONFIG_PCI |
1094 | retval = pci_register_driver(&moxa_pci_driver); | 1092 | retval = pci_register_driver(&moxa_pci_driver); |
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index 3d923065d9a2..e0c5d2a69046 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c | |||
@@ -895,8 +895,7 @@ static int mxser_activate(struct tty_port *port, struct tty_struct *tty) | |||
895 | if (inb(info->ioaddr + UART_LSR) == 0xff) { | 895 | if (inb(info->ioaddr + UART_LSR) == 0xff) { |
896 | spin_unlock_irqrestore(&info->slock, flags); | 896 | spin_unlock_irqrestore(&info->slock, flags); |
897 | if (capable(CAP_SYS_ADMIN)) { | 897 | if (capable(CAP_SYS_ADMIN)) { |
898 | if (tty) | 898 | set_bit(TTY_IO_ERROR, &tty->flags); |
899 | set_bit(TTY_IO_ERROR, &tty->flags); | ||
900 | return 0; | 899 | return 0; |
901 | } else | 900 | } else |
902 | return -ENODEV; | 901 | return -ENODEV; |
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index 2e50f4dfc79c..bdae8327143c 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <linux/audit.h> | 48 | #include <linux/audit.h> |
49 | #include <linux/file.h> | 49 | #include <linux/file.h> |
50 | #include <linux/uaccess.h> | 50 | #include <linux/uaccess.h> |
51 | #include <linux/module.h> | ||
51 | 52 | ||
52 | #include <asm/system.h> | 53 | #include <asm/system.h> |
53 | 54 | ||
@@ -2091,3 +2092,19 @@ struct tty_ldisc_ops tty_ldisc_N_TTY = { | |||
2091 | .receive_buf = n_tty_receive_buf, | 2092 | .receive_buf = n_tty_receive_buf, |
2092 | .write_wakeup = n_tty_write_wakeup | 2093 | .write_wakeup = n_tty_write_wakeup |
2093 | }; | 2094 | }; |
2095 | |||
2096 | /** | ||
2097 | * n_tty_inherit_ops - inherit N_TTY methods | ||
2098 | * @ops: struct tty_ldisc_ops where to save N_TTY methods | ||
2099 | * | ||
2100 | * Used by a generic struct tty_ldisc_ops to easily inherit N_TTY | ||
2101 | * methods. | ||
2102 | */ | ||
2103 | |||
2104 | void n_tty_inherit_ops(struct tty_ldisc_ops *ops) | ||
2105 | { | ||
2106 | *ops = tty_ldisc_N_TTY; | ||
2107 | ops->owner = NULL; | ||
2108 | ops->refcount = ops->flags = 0; | ||
2109 | } | ||
2110 | EXPORT_SYMBOL_GPL(n_tty_inherit_ops); | ||
diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c index 2ad7d37afbd0..a3f32a15fde4 100644 --- a/drivers/char/nozomi.c +++ b/drivers/char/nozomi.c | |||
@@ -136,10 +136,6 @@ static int debug; | |||
136 | #define RECEIVE_BUF_MAX 4 | 136 | #define RECEIVE_BUF_MAX 4 |
137 | 137 | ||
138 | 138 | ||
139 | /* Define all types of vendors and devices to support */ | ||
140 | #define VENDOR1 0x1931 /* Vendor Option */ | ||
141 | #define DEVICE1 0x000c /* HSDPA card */ | ||
142 | |||
143 | #define R_IIR 0x0000 /* Interrupt Identity Register */ | 139 | #define R_IIR 0x0000 /* Interrupt Identity Register */ |
144 | #define R_FCR 0x0000 /* Flow Control Register */ | 140 | #define R_FCR 0x0000 /* Flow Control Register */ |
145 | #define R_IER 0x0004 /* Interrupt Enable Register */ | 141 | #define R_IER 0x0004 /* Interrupt Enable Register */ |
@@ -371,6 +367,8 @@ struct port { | |||
371 | struct mutex tty_sem; | 367 | struct mutex tty_sem; |
372 | wait_queue_head_t tty_wait; | 368 | wait_queue_head_t tty_wait; |
373 | struct async_icount tty_icount; | 369 | struct async_icount tty_icount; |
370 | |||
371 | struct nozomi *dc; | ||
374 | }; | 372 | }; |
375 | 373 | ||
376 | /* Private data one for each card in the system */ | 374 | /* Private data one for each card in the system */ |
@@ -405,7 +403,7 @@ struct buffer { | |||
405 | 403 | ||
406 | /* Global variables */ | 404 | /* Global variables */ |
407 | static const struct pci_device_id nozomi_pci_tbl[] __devinitconst = { | 405 | static const struct pci_device_id nozomi_pci_tbl[] __devinitconst = { |
408 | {PCI_DEVICE(VENDOR1, DEVICE1)}, | 406 | {PCI_DEVICE(0x1931, 0x000c)}, /* Nozomi HSDPA */ |
409 | {}, | 407 | {}, |
410 | }; | 408 | }; |
411 | 409 | ||
@@ -414,6 +412,8 @@ MODULE_DEVICE_TABLE(pci, nozomi_pci_tbl); | |||
414 | static struct nozomi *ndevs[NOZOMI_MAX_CARDS]; | 412 | static struct nozomi *ndevs[NOZOMI_MAX_CARDS]; |
415 | static struct tty_driver *ntty_driver; | 413 | static struct tty_driver *ntty_driver; |
416 | 414 | ||
415 | static const struct tty_port_operations noz_tty_port_ops; | ||
416 | |||
417 | /* | 417 | /* |
418 | * find card by tty_index | 418 | * find card by tty_index |
419 | */ | 419 | */ |
@@ -853,8 +853,6 @@ static int receive_data(enum port_type index, struct nozomi *dc) | |||
853 | goto put; | 853 | goto put; |
854 | } | 854 | } |
855 | 855 | ||
856 | tty_buffer_request_room(tty, size); | ||
857 | |||
858 | while (size > 0) { | 856 | while (size > 0) { |
859 | read_mem32((u32 *) buf, addr + offset, RECEIVE_BUF_MAX); | 857 | read_mem32((u32 *) buf, addr + offset, RECEIVE_BUF_MAX); |
860 | 858 | ||
@@ -1473,9 +1471,11 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev, | |||
1473 | 1471 | ||
1474 | for (i = 0; i < MAX_PORT; i++) { | 1472 | for (i = 0; i < MAX_PORT; i++) { |
1475 | struct device *tty_dev; | 1473 | struct device *tty_dev; |
1476 | 1474 | struct port *port = &dc->port[i]; | |
1477 | mutex_init(&dc->port[i].tty_sem); | 1475 | port->dc = dc; |
1478 | tty_port_init(&dc->port[i].port); | 1476 | mutex_init(&port->tty_sem); |
1477 | tty_port_init(&port->port); | ||
1478 | port->port.ops = &noz_tty_port_ops; | ||
1479 | tty_dev = tty_register_device(ntty_driver, dc->index_start + i, | 1479 | tty_dev = tty_register_device(ntty_driver, dc->index_start + i, |
1480 | &pdev->dev); | 1480 | &pdev->dev); |
1481 | 1481 | ||
@@ -1600,67 +1600,74 @@ static void set_dtr(const struct tty_struct *tty, int dtr) | |||
1600 | * ---------------------------------------------------------------------------- | 1600 | * ---------------------------------------------------------------------------- |
1601 | */ | 1601 | */ |
1602 | 1602 | ||
1603 | /* Called when the userspace process opens the tty, /dev/noz*. */ | 1603 | static int ntty_install(struct tty_driver *driver, struct tty_struct *tty) |
1604 | static int ntty_open(struct tty_struct *tty, struct file *file) | ||
1605 | { | 1604 | { |
1606 | struct port *port = get_port_by_tty(tty); | 1605 | struct port *port = get_port_by_tty(tty); |
1607 | struct nozomi *dc = get_dc_by_tty(tty); | 1606 | struct nozomi *dc = get_dc_by_tty(tty); |
1608 | unsigned long flags; | 1607 | int ret; |
1609 | |||
1610 | if (!port || !dc || dc->state != NOZOMI_STATE_READY) | 1608 | if (!port || !dc || dc->state != NOZOMI_STATE_READY) |
1611 | return -ENODEV; | 1609 | return -ENODEV; |
1612 | 1610 | ret = tty_init_termios(tty); | |
1613 | if (mutex_lock_interruptible(&port->tty_sem)) | 1611 | if (ret == 0) { |
1614 | return -ERESTARTSYS; | 1612 | tty_driver_kref_get(driver); |
1615 | 1613 | driver->ttys[tty->index] = tty; | |
1616 | port->port.count++; | ||
1617 | dc->open_ttys++; | ||
1618 | |||
1619 | /* Enable interrupt downlink for channel */ | ||
1620 | if (port->port.count == 1) { | ||
1621 | tty->driver_data = port; | ||
1622 | tty_port_tty_set(&port->port, tty); | ||
1623 | DBG1("open: %d", port->token_dl); | ||
1624 | spin_lock_irqsave(&dc->spin_mutex, flags); | ||
1625 | dc->last_ier = dc->last_ier | port->token_dl; | ||
1626 | writew(dc->last_ier, dc->reg_ier); | ||
1627 | spin_unlock_irqrestore(&dc->spin_mutex, flags); | ||
1628 | } | 1614 | } |
1629 | mutex_unlock(&port->tty_sem); | 1615 | return ret; |
1630 | return 0; | ||
1631 | } | 1616 | } |
1632 | 1617 | ||
1633 | /* Called when the userspace process close the tty, /dev/noz*. Also | 1618 | static void ntty_cleanup(struct tty_struct *tty) |
1634 | called immediately if ntty_open fails in which case tty->driver_data | 1619 | { |
1635 | will be NULL an we exit by the first return */ | 1620 | tty->driver_data = NULL; |
1621 | } | ||
1636 | 1622 | ||
1637 | static void ntty_close(struct tty_struct *tty, struct file *file) | 1623 | static int ntty_activate(struct tty_port *tport, struct tty_struct *tty) |
1638 | { | 1624 | { |
1639 | struct nozomi *dc = get_dc_by_tty(tty); | 1625 | struct port *port = container_of(tport, struct port, port); |
1640 | struct port *nport = tty->driver_data; | 1626 | struct nozomi *dc = port->dc; |
1641 | struct tty_port *port = &nport->port; | ||
1642 | unsigned long flags; | 1627 | unsigned long flags; |
1643 | 1628 | ||
1644 | if (!dc || !nport) | 1629 | DBG1("open: %d", port->token_dl); |
1645 | return; | 1630 | spin_lock_irqsave(&dc->spin_mutex, flags); |
1631 | dc->last_ier = dc->last_ier | port->token_dl; | ||
1632 | writew(dc->last_ier, dc->reg_ier); | ||
1633 | dc->open_ttys++; | ||
1634 | spin_unlock_irqrestore(&dc->spin_mutex, flags); | ||
1635 | printk("noz: activated %d: %p\n", tty->index, tport); | ||
1636 | return 0; | ||
1637 | } | ||
1646 | 1638 | ||
1647 | /* Users cannot interrupt a close */ | 1639 | static int ntty_open(struct tty_struct *tty, struct file *filp) |
1648 | mutex_lock(&nport->tty_sem); | 1640 | { |
1641 | struct port *port = get_port_by_tty(tty); | ||
1642 | return tty_port_open(&port->port, tty, filp); | ||
1643 | } | ||
1649 | 1644 | ||
1650 | WARN_ON(!port->count); | 1645 | static void ntty_shutdown(struct tty_port *tport) |
1646 | { | ||
1647 | struct port *port = container_of(tport, struct port, port); | ||
1648 | struct nozomi *dc = port->dc; | ||
1649 | unsigned long flags; | ||
1651 | 1650 | ||
1651 | DBG1("close: %d", port->token_dl); | ||
1652 | spin_lock_irqsave(&dc->spin_mutex, flags); | ||
1653 | dc->last_ier &= ~(port->token_dl); | ||
1654 | writew(dc->last_ier, dc->reg_ier); | ||
1652 | dc->open_ttys--; | 1655 | dc->open_ttys--; |
1653 | port->count--; | 1656 | spin_unlock_irqrestore(&dc->spin_mutex, flags); |
1657 | printk("noz: shutdown %p\n", tport); | ||
1658 | } | ||
1654 | 1659 | ||
1655 | if (port->count == 0) { | 1660 | static void ntty_close(struct tty_struct *tty, struct file *filp) |
1656 | DBG1("close: %d", nport->token_dl); | 1661 | { |
1657 | tty_port_tty_set(port, NULL); | 1662 | struct port *port = tty->driver_data; |
1658 | spin_lock_irqsave(&dc->spin_mutex, flags); | 1663 | if (port) |
1659 | dc->last_ier &= ~(nport->token_dl); | 1664 | tty_port_close(&port->port, tty, filp); |
1660 | writew(dc->last_ier, dc->reg_ier); | 1665 | } |
1661 | spin_unlock_irqrestore(&dc->spin_mutex, flags); | 1666 | |
1662 | } | 1667 | static void ntty_hangup(struct tty_struct *tty) |
1663 | mutex_unlock(&nport->tty_sem); | 1668 | { |
1669 | struct port *port = tty->driver_data; | ||
1670 | tty_port_hangup(&port->port); | ||
1664 | } | 1671 | } |
1665 | 1672 | ||
1666 | /* | 1673 | /* |
@@ -1680,15 +1687,7 @@ static int ntty_write(struct tty_struct *tty, const unsigned char *buffer, | |||
1680 | if (!dc || !port) | 1687 | if (!dc || !port) |
1681 | return -ENODEV; | 1688 | return -ENODEV; |
1682 | 1689 | ||
1683 | if (unlikely(!mutex_trylock(&port->tty_sem))) { | 1690 | mutex_lock(&port->tty_sem); |
1684 | /* | ||
1685 | * must test lock as tty layer wraps calls | ||
1686 | * to this function with BKL | ||
1687 | */ | ||
1688 | dev_err(&dc->pdev->dev, "Would have deadlocked - " | ||
1689 | "return EAGAIN\n"); | ||
1690 | return -EAGAIN; | ||
1691 | } | ||
1692 | 1691 | ||
1693 | if (unlikely(!port->port.count)) { | 1692 | if (unlikely(!port->port.count)) { |
1694 | DBG1(" "); | 1693 | DBG1(" "); |
@@ -1728,25 +1727,23 @@ exit: | |||
1728 | * This method is called by the upper tty layer. | 1727 | * This method is called by the upper tty layer. |
1729 | * #according to sources N_TTY.c it expects a value >= 0 and | 1728 | * #according to sources N_TTY.c it expects a value >= 0 and |
1730 | * does not check for negative values. | 1729 | * does not check for negative values. |
1730 | * | ||
1731 | * If the port is unplugged report lots of room and let the bits | ||
1732 | * dribble away so we don't block anything. | ||
1731 | */ | 1733 | */ |
1732 | static int ntty_write_room(struct tty_struct *tty) | 1734 | static int ntty_write_room(struct tty_struct *tty) |
1733 | { | 1735 | { |
1734 | struct port *port = tty->driver_data; | 1736 | struct port *port = tty->driver_data; |
1735 | int room = 0; | 1737 | int room = 4096; |
1736 | const struct nozomi *dc = get_dc_by_tty(tty); | 1738 | const struct nozomi *dc = get_dc_by_tty(tty); |
1737 | 1739 | ||
1738 | if (!dc || !port) | 1740 | if (dc) { |
1739 | return 0; | 1741 | mutex_lock(&port->tty_sem); |
1740 | if (!mutex_trylock(&port->tty_sem)) | 1742 | if (port->port.count) |
1741 | return 0; | 1743 | room = port->fifo_ul.size - |
1742 | 1744 | kfifo_len(&port->fifo_ul); | |
1743 | if (!port->port.count) | 1745 | mutex_unlock(&port->tty_sem); |
1744 | goto exit; | 1746 | } |
1745 | |||
1746 | room = port->fifo_ul.size - kfifo_len(&port->fifo_ul); | ||
1747 | |||
1748 | exit: | ||
1749 | mutex_unlock(&port->tty_sem); | ||
1750 | return room; | 1747 | return room; |
1751 | } | 1748 | } |
1752 | 1749 | ||
@@ -1906,10 +1903,16 @@ exit_in_buffer: | |||
1906 | return rval; | 1903 | return rval; |
1907 | } | 1904 | } |
1908 | 1905 | ||
1906 | static const struct tty_port_operations noz_tty_port_ops = { | ||
1907 | .activate = ntty_activate, | ||
1908 | .shutdown = ntty_shutdown, | ||
1909 | }; | ||
1910 | |||
1909 | static const struct tty_operations tty_ops = { | 1911 | static const struct tty_operations tty_ops = { |
1910 | .ioctl = ntty_ioctl, | 1912 | .ioctl = ntty_ioctl, |
1911 | .open = ntty_open, | 1913 | .open = ntty_open, |
1912 | .close = ntty_close, | 1914 | .close = ntty_close, |
1915 | .hangup = ntty_hangup, | ||
1913 | .write = ntty_write, | 1916 | .write = ntty_write, |
1914 | .write_room = ntty_write_room, | 1917 | .write_room = ntty_write_room, |
1915 | .unthrottle = ntty_unthrottle, | 1918 | .unthrottle = ntty_unthrottle, |
@@ -1917,6 +1920,8 @@ static const struct tty_operations tty_ops = { | |||
1917 | .chars_in_buffer = ntty_chars_in_buffer, | 1920 | .chars_in_buffer = ntty_chars_in_buffer, |
1918 | .tiocmget = ntty_tiocmget, | 1921 | .tiocmget = ntty_tiocmget, |
1919 | .tiocmset = ntty_tiocmset, | 1922 | .tiocmset = ntty_tiocmset, |
1923 | .install = ntty_install, | ||
1924 | .cleanup = ntty_cleanup, | ||
1920 | }; | 1925 | }; |
1921 | 1926 | ||
1922 | /* Module initialization */ | 1927 | /* Module initialization */ |
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c index fdbcc9fd6d31..5eb83c3ca20d 100644 --- a/drivers/char/nvram.c +++ b/drivers/char/nvram.c | |||
@@ -336,14 +336,12 @@ static int nvram_ioctl(struct inode *inode, struct file *file, | |||
336 | 336 | ||
337 | static int nvram_open(struct inode *inode, struct file *file) | 337 | static int nvram_open(struct inode *inode, struct file *file) |
338 | { | 338 | { |
339 | lock_kernel(); | ||
340 | spin_lock(&nvram_state_lock); | 339 | spin_lock(&nvram_state_lock); |
341 | 340 | ||
342 | if ((nvram_open_cnt && (file->f_flags & O_EXCL)) || | 341 | if ((nvram_open_cnt && (file->f_flags & O_EXCL)) || |
343 | (nvram_open_mode & NVRAM_EXCL) || | 342 | (nvram_open_mode & NVRAM_EXCL) || |
344 | ((file->f_mode & FMODE_WRITE) && (nvram_open_mode & NVRAM_WRITE))) { | 343 | ((file->f_mode & FMODE_WRITE) && (nvram_open_mode & NVRAM_WRITE))) { |
345 | spin_unlock(&nvram_state_lock); | 344 | spin_unlock(&nvram_state_lock); |
346 | unlock_kernel(); | ||
347 | return -EBUSY; | 345 | return -EBUSY; |
348 | } | 346 | } |
349 | 347 | ||
@@ -354,7 +352,6 @@ static int nvram_open(struct inode *inode, struct file *file) | |||
354 | nvram_open_cnt++; | 352 | nvram_open_cnt++; |
355 | 353 | ||
356 | spin_unlock(&nvram_state_lock); | 354 | spin_unlock(&nvram_state_lock); |
357 | unlock_kernel(); | ||
358 | 355 | ||
359 | return 0; | 356 | return 0; |
360 | } | 357 | } |
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index 2db4c0a29b05..c9bc896d68af 100644 --- a/drivers/char/pcmcia/cm4000_cs.c +++ b/drivers/char/pcmcia/cm4000_cs.c | |||
@@ -1047,7 +1047,7 @@ release_io: | |||
1047 | static ssize_t cmm_write(struct file *filp, const char __user *buf, | 1047 | static ssize_t cmm_write(struct file *filp, const char __user *buf, |
1048 | size_t count, loff_t *ppos) | 1048 | size_t count, loff_t *ppos) |
1049 | { | 1049 | { |
1050 | struct cm4000_dev *dev = (struct cm4000_dev *) filp->private_data; | 1050 | struct cm4000_dev *dev = filp->private_data; |
1051 | unsigned int iobase = dev->p_dev->io.BasePort1; | 1051 | unsigned int iobase = dev->p_dev->io.BasePort1; |
1052 | unsigned short s; | 1052 | unsigned short s; |
1053 | unsigned char tmp; | 1053 | unsigned char tmp; |
diff --git a/drivers/char/pty.c b/drivers/char/pty.c index 385c44b3034f..5ee424817263 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c | |||
@@ -220,7 +220,7 @@ static void pty_set_termios(struct tty_struct *tty, | |||
220 | * @tty: tty being resized | 220 | * @tty: tty being resized |
221 | * @ws: window size being set. | 221 | * @ws: window size being set. |
222 | * | 222 | * |
223 | * Update the termios variables and send the neccessary signals to | 223 | * Update the termios variables and send the necessary signals to |
224 | * peform a terminal resize correctly | 224 | * peform a terminal resize correctly |
225 | */ | 225 | */ |
226 | 226 | ||
diff --git a/drivers/char/random.c b/drivers/char/random.c index 2849713d2231..2fd3d39995d5 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -1191,7 +1191,7 @@ const struct file_operations urandom_fops = { | |||
1191 | void generate_random_uuid(unsigned char uuid_out[16]) | 1191 | void generate_random_uuid(unsigned char uuid_out[16]) |
1192 | { | 1192 | { |
1193 | get_random_bytes(uuid_out, 16); | 1193 | get_random_bytes(uuid_out, 16); |
1194 | /* Set UUID version to 4 --- truely random generation */ | 1194 | /* Set UUID version to 4 --- truly random generation */ |
1195 | uuid_out[6] = (uuid_out[6] & 0x0F) | 0x40; | 1195 | uuid_out[6] = (uuid_out[6] & 0x0F) | 0x40; |
1196 | /* Set the UUID variant to DCE */ | 1196 | /* Set the UUID variant to DCE */ |
1197 | uuid_out[8] = (uuid_out[8] & 0x3F) | 0x80; | 1197 | uuid_out[8] = (uuid_out[8] & 0x3F) | 0x80; |
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c index 452370af95de..1ec3d5cd748f 100644 --- a/drivers/char/serial167.c +++ b/drivers/char/serial167.c | |||
@@ -658,8 +658,7 @@ static irqreturn_t cd2401_rx_interrupt(int irq, void *dev_id) | |||
658 | info->mon.char_max = char_count; | 658 | info->mon.char_max = char_count; |
659 | info->mon.char_last = char_count; | 659 | info->mon.char_last = char_count; |
660 | #endif | 660 | #endif |
661 | len = tty_buffer_request_room(tty, char_count); | 661 | while (char_count--) { |
662 | while (len--) { | ||
663 | data = base_addr[CyRDR]; | 662 | data = base_addr[CyRDR]; |
664 | tty_insert_flip_char(tty, data, TTY_NORMAL); | 663 | tty_insert_flip_char(tty, data, TTY_NORMAL); |
665 | #ifdef CYCLOM_16Y_HACK | 664 | #ifdef CYCLOM_16Y_HACK |
@@ -1990,7 +1989,7 @@ void mvme167_serial_console_setup(int cflag) | |||
1990 | /* | 1989 | /* |
1991 | * Attempt to set up all channels to something reasonable, and | 1990 | * Attempt to set up all channels to something reasonable, and |
1992 | * bang out a INIT_CHAN command. We should then be able to limit | 1991 | * bang out a INIT_CHAN command. We should then be able to limit |
1993 | * the ammount of fiddling we have to do in normal running. | 1992 | * the amount of fiddling we have to do in normal running. |
1994 | */ | 1993 | */ |
1995 | 1994 | ||
1996 | for (ch = 3; ch >= 0; ch--) { | 1995 | for (ch = 3; ch >= 0; ch--) { |
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c index 268e17f9ec3f..07ac14d949ce 100644 --- a/drivers/char/specialix.c +++ b/drivers/char/specialix.c | |||
@@ -646,8 +646,6 @@ static void sx_receive(struct specialix_board *bp) | |||
646 | dprintk(SX_DEBUG_RX, "port: %p: count: %d\n", port, count); | 646 | dprintk(SX_DEBUG_RX, "port: %p: count: %d\n", port, count); |
647 | port->hits[count > 8 ? 9 : count]++; | 647 | port->hits[count > 8 ? 9 : count]++; |
648 | 648 | ||
649 | tty_buffer_request_room(tty, count); | ||
650 | |||
651 | while (count--) | 649 | while (count--) |
652 | tty_insert_flip_char(tty, sx_in(bp, CD186x_RDR), TTY_NORMAL); | 650 | tty_insert_flip_char(tty, sx_in(bp, CD186x_RDR), TTY_NORMAL); |
653 | tty_flip_buffer_push(tty); | 651 | tty_flip_buffer_push(tty); |
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 4846b73ef28d..0658fc548222 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c | |||
@@ -2031,7 +2031,7 @@ static int mgsl_put_char(struct tty_struct *tty, unsigned char ch) | |||
2031 | if (mgsl_paranoia_check(info, tty->name, "mgsl_put_char")) | 2031 | if (mgsl_paranoia_check(info, tty->name, "mgsl_put_char")) |
2032 | return 0; | 2032 | return 0; |
2033 | 2033 | ||
2034 | if (!tty || !info->xmit_buf) | 2034 | if (!info->xmit_buf) |
2035 | return 0; | 2035 | return 0; |
2036 | 2036 | ||
2037 | spin_lock_irqsave(&info->irq_spinlock, flags); | 2037 | spin_lock_irqsave(&info->irq_spinlock, flags); |
@@ -2121,7 +2121,7 @@ static int mgsl_write(struct tty_struct * tty, | |||
2121 | if (mgsl_paranoia_check(info, tty->name, "mgsl_write")) | 2121 | if (mgsl_paranoia_check(info, tty->name, "mgsl_write")) |
2122 | goto cleanup; | 2122 | goto cleanup; |
2123 | 2123 | ||
2124 | if (!tty || !info->xmit_buf) | 2124 | if (!info->xmit_buf) |
2125 | goto cleanup; | 2125 | goto cleanup; |
2126 | 2126 | ||
2127 | if ( info->params.mode == MGSL_MODE_HDLC || | 2127 | if ( info->params.mode == MGSL_MODE_HDLC || |
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index 8678f0c8699d..4561ce2fba6d 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c | |||
@@ -468,7 +468,7 @@ static unsigned int free_tbuf_count(struct slgt_info *info); | |||
468 | static unsigned int tbuf_bytes(struct slgt_info *info); | 468 | static unsigned int tbuf_bytes(struct slgt_info *info); |
469 | static void reset_tbufs(struct slgt_info *info); | 469 | static void reset_tbufs(struct slgt_info *info); |
470 | static void tdma_reset(struct slgt_info *info); | 470 | static void tdma_reset(struct slgt_info *info); |
471 | static void tx_load(struct slgt_info *info, const char *buf, unsigned int count); | 471 | static bool tx_load(struct slgt_info *info, const char *buf, unsigned int count); |
472 | 472 | ||
473 | static void get_signals(struct slgt_info *info); | 473 | static void get_signals(struct slgt_info *info); |
474 | static void set_signals(struct slgt_info *info); | 474 | static void set_signals(struct slgt_info *info); |
@@ -813,59 +813,32 @@ static int write(struct tty_struct *tty, | |||
813 | int ret = 0; | 813 | int ret = 0; |
814 | struct slgt_info *info = tty->driver_data; | 814 | struct slgt_info *info = tty->driver_data; |
815 | unsigned long flags; | 815 | unsigned long flags; |
816 | unsigned int bufs_needed; | ||
817 | 816 | ||
818 | if (sanity_check(info, tty->name, "write")) | 817 | if (sanity_check(info, tty->name, "write")) |
819 | goto cleanup; | 818 | return -EIO; |
819 | |||
820 | DBGINFO(("%s write count=%d\n", info->device_name, count)); | 820 | DBGINFO(("%s write count=%d\n", info->device_name, count)); |
821 | 821 | ||
822 | if (!info->tx_buf) | 822 | if (!info->tx_buf || (count > info->max_frame_size)) |
823 | goto cleanup; | 823 | return -EIO; |
824 | 824 | ||
825 | if (count > info->max_frame_size) { | 825 | if (!count || tty->stopped || tty->hw_stopped) |
826 | ret = -EIO; | 826 | return 0; |
827 | goto cleanup; | ||
828 | } | ||
829 | 827 | ||
830 | if (!count) | 828 | spin_lock_irqsave(&info->lock, flags); |
831 | goto cleanup; | ||
832 | 829 | ||
833 | if (!info->tx_active && info->tx_count) { | 830 | if (info->tx_count) { |
834 | /* send accumulated data from send_char() */ | 831 | /* send accumulated data from send_char() */ |
835 | tx_load(info, info->tx_buf, info->tx_count); | 832 | if (!tx_load(info, info->tx_buf, info->tx_count)) |
836 | goto start; | 833 | goto cleanup; |
834 | info->tx_count = 0; | ||
837 | } | 835 | } |
838 | bufs_needed = (count/DMABUFSIZE); | ||
839 | if (count % DMABUFSIZE) | ||
840 | ++bufs_needed; | ||
841 | if (bufs_needed > free_tbuf_count(info)) | ||
842 | goto cleanup; | ||
843 | 836 | ||
844 | ret = info->tx_count = count; | 837 | if (tx_load(info, buf, count)) |
845 | tx_load(info, buf, count); | 838 | ret = count; |
846 | goto start; | ||
847 | |||
848 | start: | ||
849 | if (info->tx_count && !tty->stopped && !tty->hw_stopped) { | ||
850 | spin_lock_irqsave(&info->lock,flags); | ||
851 | if (!info->tx_active) | ||
852 | tx_start(info); | ||
853 | else if (!(rd_reg32(info, TDCSR) & BIT0)) { | ||
854 | /* transmit still active but transmit DMA stopped */ | ||
855 | unsigned int i = info->tbuf_current; | ||
856 | if (!i) | ||
857 | i = info->tbuf_count; | ||
858 | i--; | ||
859 | /* if DMA buf unsent must try later after tx idle */ | ||
860 | if (desc_count(info->tbufs[i])) | ||
861 | ret = 0; | ||
862 | } | ||
863 | if (ret > 0) | ||
864 | update_tx_timer(info); | ||
865 | spin_unlock_irqrestore(&info->lock,flags); | ||
866 | } | ||
867 | 839 | ||
868 | cleanup: | 840 | cleanup: |
841 | spin_unlock_irqrestore(&info->lock, flags); | ||
869 | DBGINFO(("%s write rc=%d\n", info->device_name, ret)); | 842 | DBGINFO(("%s write rc=%d\n", info->device_name, ret)); |
870 | return ret; | 843 | return ret; |
871 | } | 844 | } |
@@ -882,7 +855,7 @@ static int put_char(struct tty_struct *tty, unsigned char ch) | |||
882 | if (!info->tx_buf) | 855 | if (!info->tx_buf) |
883 | return 0; | 856 | return 0; |
884 | spin_lock_irqsave(&info->lock,flags); | 857 | spin_lock_irqsave(&info->lock,flags); |
885 | if (!info->tx_active && (info->tx_count < info->max_frame_size)) { | 858 | if (info->tx_count < info->max_frame_size) { |
886 | info->tx_buf[info->tx_count++] = ch; | 859 | info->tx_buf[info->tx_count++] = ch; |
887 | ret = 1; | 860 | ret = 1; |
888 | } | 861 | } |
@@ -981,10 +954,8 @@ static void flush_chars(struct tty_struct *tty) | |||
981 | DBGINFO(("%s flush_chars start transmit\n", info->device_name)); | 954 | DBGINFO(("%s flush_chars start transmit\n", info->device_name)); |
982 | 955 | ||
983 | spin_lock_irqsave(&info->lock,flags); | 956 | spin_lock_irqsave(&info->lock,flags); |
984 | if (!info->tx_active && info->tx_count) { | 957 | if (info->tx_count && tx_load(info, info->tx_buf, info->tx_count)) |
985 | tx_load(info, info->tx_buf,info->tx_count); | 958 | info->tx_count = 0; |
986 | tx_start(info); | ||
987 | } | ||
988 | spin_unlock_irqrestore(&info->lock,flags); | 959 | spin_unlock_irqrestore(&info->lock,flags); |
989 | } | 960 | } |
990 | 961 | ||
@@ -997,10 +968,9 @@ static void flush_buffer(struct tty_struct *tty) | |||
997 | return; | 968 | return; |
998 | DBGINFO(("%s flush_buffer\n", info->device_name)); | 969 | DBGINFO(("%s flush_buffer\n", info->device_name)); |
999 | 970 | ||
1000 | spin_lock_irqsave(&info->lock,flags); | 971 | spin_lock_irqsave(&info->lock, flags); |
1001 | if (!info->tx_active) | 972 | info->tx_count = 0; |
1002 | info->tx_count = 0; | 973 | spin_unlock_irqrestore(&info->lock, flags); |
1003 | spin_unlock_irqrestore(&info->lock,flags); | ||
1004 | 974 | ||
1005 | tty_wakeup(tty); | 975 | tty_wakeup(tty); |
1006 | } | 976 | } |
@@ -1033,12 +1003,10 @@ static void tx_release(struct tty_struct *tty) | |||
1033 | if (sanity_check(info, tty->name, "tx_release")) | 1003 | if (sanity_check(info, tty->name, "tx_release")) |
1034 | return; | 1004 | return; |
1035 | DBGINFO(("%s tx_release\n", info->device_name)); | 1005 | DBGINFO(("%s tx_release\n", info->device_name)); |
1036 | spin_lock_irqsave(&info->lock,flags); | 1006 | spin_lock_irqsave(&info->lock, flags); |
1037 | if (!info->tx_active && info->tx_count) { | 1007 | if (info->tx_count && tx_load(info, info->tx_buf, info->tx_count)) |
1038 | tx_load(info, info->tx_buf, info->tx_count); | 1008 | info->tx_count = 0; |
1039 | tx_start(info); | 1009 | spin_unlock_irqrestore(&info->lock, flags); |
1040 | } | ||
1041 | spin_unlock_irqrestore(&info->lock,flags); | ||
1042 | } | 1010 | } |
1043 | 1011 | ||
1044 | /* | 1012 | /* |
@@ -1506,27 +1474,25 @@ static netdev_tx_t hdlcdev_xmit(struct sk_buff *skb, | |||
1506 | 1474 | ||
1507 | DBGINFO(("%s hdlc_xmit\n", dev->name)); | 1475 | DBGINFO(("%s hdlc_xmit\n", dev->name)); |
1508 | 1476 | ||
1477 | if (!skb->len) | ||
1478 | return NETDEV_TX_OK; | ||
1479 | |||
1509 | /* stop sending until this frame completes */ | 1480 | /* stop sending until this frame completes */ |
1510 | netif_stop_queue(dev); | 1481 | netif_stop_queue(dev); |
1511 | 1482 | ||
1512 | /* copy data to device buffers */ | ||
1513 | info->tx_count = skb->len; | ||
1514 | tx_load(info, skb->data, skb->len); | ||
1515 | |||
1516 | /* update network statistics */ | 1483 | /* update network statistics */ |
1517 | dev->stats.tx_packets++; | 1484 | dev->stats.tx_packets++; |
1518 | dev->stats.tx_bytes += skb->len; | 1485 | dev->stats.tx_bytes += skb->len; |
1519 | 1486 | ||
1520 | /* done with socket buffer, so free it */ | ||
1521 | dev_kfree_skb(skb); | ||
1522 | |||
1523 | /* save start time for transmit timeout detection */ | 1487 | /* save start time for transmit timeout detection */ |
1524 | dev->trans_start = jiffies; | 1488 | dev->trans_start = jiffies; |
1525 | 1489 | ||
1526 | spin_lock_irqsave(&info->lock,flags); | 1490 | spin_lock_irqsave(&info->lock, flags); |
1527 | tx_start(info); | 1491 | tx_load(info, skb->data, skb->len); |
1528 | update_tx_timer(info); | 1492 | spin_unlock_irqrestore(&info->lock, flags); |
1529 | spin_unlock_irqrestore(&info->lock,flags); | 1493 | |
1494 | /* done with socket buffer, so free it */ | ||
1495 | dev_kfree_skb(skb); | ||
1530 | 1496 | ||
1531 | return NETDEV_TX_OK; | 1497 | return NETDEV_TX_OK; |
1532 | } | 1498 | } |
@@ -2180,7 +2146,7 @@ static void isr_serial(struct slgt_info *info) | |||
2180 | 2146 | ||
2181 | if (info->params.mode == MGSL_MODE_ASYNC) { | 2147 | if (info->params.mode == MGSL_MODE_ASYNC) { |
2182 | if (status & IRQ_TXIDLE) { | 2148 | if (status & IRQ_TXIDLE) { |
2183 | if (info->tx_count) | 2149 | if (info->tx_active) |
2184 | isr_txeom(info, status); | 2150 | isr_txeom(info, status); |
2185 | } | 2151 | } |
2186 | if (info->rx_pio && (status & IRQ_RXDATA)) | 2152 | if (info->rx_pio && (status & IRQ_RXDATA)) |
@@ -2276,13 +2242,42 @@ static void isr_tdma(struct slgt_info *info) | |||
2276 | } | 2242 | } |
2277 | } | 2243 | } |
2278 | 2244 | ||
2245 | /* | ||
2246 | * return true if there are unsent tx DMA buffers, otherwise false | ||
2247 | * | ||
2248 | * if there are unsent buffers then info->tbuf_start | ||
2249 | * is set to index of first unsent buffer | ||
2250 | */ | ||
2251 | static bool unsent_tbufs(struct slgt_info *info) | ||
2252 | { | ||
2253 | unsigned int i = info->tbuf_current; | ||
2254 | bool rc = false; | ||
2255 | |||
2256 | /* | ||
2257 | * search backwards from last loaded buffer (precedes tbuf_current) | ||
2258 | * for first unsent buffer (desc_count > 0) | ||
2259 | */ | ||
2260 | |||
2261 | do { | ||
2262 | if (i) | ||
2263 | i--; | ||
2264 | else | ||
2265 | i = info->tbuf_count - 1; | ||
2266 | if (!desc_count(info->tbufs[i])) | ||
2267 | break; | ||
2268 | info->tbuf_start = i; | ||
2269 | rc = true; | ||
2270 | } while (i != info->tbuf_current); | ||
2271 | |||
2272 | return rc; | ||
2273 | } | ||
2274 | |||
2279 | static void isr_txeom(struct slgt_info *info, unsigned short status) | 2275 | static void isr_txeom(struct slgt_info *info, unsigned short status) |
2280 | { | 2276 | { |
2281 | DBGISR(("%s txeom status=%04x\n", info->device_name, status)); | 2277 | DBGISR(("%s txeom status=%04x\n", info->device_name, status)); |
2282 | 2278 | ||
2283 | slgt_irq_off(info, IRQ_TXDATA + IRQ_TXIDLE + IRQ_TXUNDER); | 2279 | slgt_irq_off(info, IRQ_TXDATA + IRQ_TXIDLE + IRQ_TXUNDER); |
2284 | tdma_reset(info); | 2280 | tdma_reset(info); |
2285 | reset_tbufs(info); | ||
2286 | if (status & IRQ_TXUNDER) { | 2281 | if (status & IRQ_TXUNDER) { |
2287 | unsigned short val = rd_reg16(info, TCR); | 2282 | unsigned short val = rd_reg16(info, TCR); |
2288 | wr_reg16(info, TCR, (unsigned short)(val | BIT2)); /* set reset bit */ | 2283 | wr_reg16(info, TCR, (unsigned short)(val | BIT2)); /* set reset bit */ |
@@ -2297,8 +2292,12 @@ static void isr_txeom(struct slgt_info *info, unsigned short status) | |||
2297 | info->icount.txok++; | 2292 | info->icount.txok++; |
2298 | } | 2293 | } |
2299 | 2294 | ||
2295 | if (unsent_tbufs(info)) { | ||
2296 | tx_start(info); | ||
2297 | update_tx_timer(info); | ||
2298 | return; | ||
2299 | } | ||
2300 | info->tx_active = false; | 2300 | info->tx_active = false; |
2301 | info->tx_count = 0; | ||
2302 | 2301 | ||
2303 | del_timer(&info->tx_timer); | 2302 | del_timer(&info->tx_timer); |
2304 | 2303 | ||
@@ -3949,7 +3948,7 @@ static void tx_start(struct slgt_info *info) | |||
3949 | info->tx_enabled = true; | 3948 | info->tx_enabled = true; |
3950 | } | 3949 | } |
3951 | 3950 | ||
3952 | if (info->tx_count) { | 3951 | if (desc_count(info->tbufs[info->tbuf_start])) { |
3953 | info->drop_rts_on_tx_done = false; | 3952 | info->drop_rts_on_tx_done = false; |
3954 | 3953 | ||
3955 | if (info->params.mode != MGSL_MODE_ASYNC) { | 3954 | if (info->params.mode != MGSL_MODE_ASYNC) { |
@@ -4772,25 +4771,36 @@ static unsigned int tbuf_bytes(struct slgt_info *info) | |||
4772 | } | 4771 | } |
4773 | 4772 | ||
4774 | /* | 4773 | /* |
4775 | * load transmit DMA buffer(s) with data | 4774 | * load data into transmit DMA buffer ring and start transmitter if needed |
4775 | * return true if data accepted, otherwise false (buffers full) | ||
4776 | */ | 4776 | */ |
4777 | static void tx_load(struct slgt_info *info, const char *buf, unsigned int size) | 4777 | static bool tx_load(struct slgt_info *info, const char *buf, unsigned int size) |
4778 | { | 4778 | { |
4779 | unsigned short count; | 4779 | unsigned short count; |
4780 | unsigned int i; | 4780 | unsigned int i; |
4781 | struct slgt_desc *d; | 4781 | struct slgt_desc *d; |
4782 | 4782 | ||
4783 | if (size == 0) | 4783 | /* check required buffer space */ |
4784 | return; | 4784 | if (DIV_ROUND_UP(size, DMABUFSIZE) > free_tbuf_count(info)) |
4785 | return false; | ||
4785 | 4786 | ||
4786 | DBGDATA(info, buf, size, "tx"); | 4787 | DBGDATA(info, buf, size, "tx"); |
4787 | 4788 | ||
4789 | /* | ||
4790 | * copy data to one or more DMA buffers in circular ring | ||
4791 | * tbuf_start = first buffer for this data | ||
4792 | * tbuf_current = next free buffer | ||
4793 | * | ||
4794 | * Copy all data before making data visible to DMA controller by | ||
4795 | * setting descriptor count of the first buffer. | ||
4796 | * This prevents an active DMA controller from reading the first DMA | ||
4797 | * buffers of a frame and stopping before the final buffers are filled. | ||
4798 | */ | ||
4799 | |||
4788 | info->tbuf_start = i = info->tbuf_current; | 4800 | info->tbuf_start = i = info->tbuf_current; |
4789 | 4801 | ||
4790 | while (size) { | 4802 | while (size) { |
4791 | d = &info->tbufs[i]; | 4803 | d = &info->tbufs[i]; |
4792 | if (++i == info->tbuf_count) | ||
4793 | i = 0; | ||
4794 | 4804 | ||
4795 | count = (unsigned short)((size > DMABUFSIZE) ? DMABUFSIZE : size); | 4805 | count = (unsigned short)((size > DMABUFSIZE) ? DMABUFSIZE : size); |
4796 | memcpy(d->buf, buf, count); | 4806 | memcpy(d->buf, buf, count); |
@@ -4808,11 +4818,27 @@ static void tx_load(struct slgt_info *info, const char *buf, unsigned int size) | |||
4808 | else | 4818 | else |
4809 | set_desc_eof(*d, 0); | 4819 | set_desc_eof(*d, 0); |
4810 | 4820 | ||
4811 | set_desc_count(*d, count); | 4821 | /* set descriptor count for all but first buffer */ |
4822 | if (i != info->tbuf_start) | ||
4823 | set_desc_count(*d, count); | ||
4812 | d->buf_count = count; | 4824 | d->buf_count = count; |
4825 | |||
4826 | if (++i == info->tbuf_count) | ||
4827 | i = 0; | ||
4813 | } | 4828 | } |
4814 | 4829 | ||
4815 | info->tbuf_current = i; | 4830 | info->tbuf_current = i; |
4831 | |||
4832 | /* set first buffer count to make new data visible to DMA controller */ | ||
4833 | d = &info->tbufs[info->tbuf_start]; | ||
4834 | set_desc_count(*d, d->buf_count); | ||
4835 | |||
4836 | /* start transmitter if needed and update transmit timeout */ | ||
4837 | if (!info->tx_active) | ||
4838 | tx_start(info); | ||
4839 | update_tx_timer(info); | ||
4840 | |||
4841 | return true; | ||
4816 | } | 4842 | } |
4817 | 4843 | ||
4818 | static int register_test(struct slgt_info *info) | 4844 | static int register_test(struct slgt_info *info) |
@@ -4934,9 +4960,7 @@ static int loopback_test(struct slgt_info *info) | |||
4934 | spin_lock_irqsave(&info->lock,flags); | 4960 | spin_lock_irqsave(&info->lock,flags); |
4935 | async_mode(info); | 4961 | async_mode(info); |
4936 | rx_start(info); | 4962 | rx_start(info); |
4937 | info->tx_count = count; | ||
4938 | tx_load(info, buf, count); | 4963 | tx_load(info, buf, count); |
4939 | tx_start(info); | ||
4940 | spin_unlock_irqrestore(&info->lock, flags); | 4964 | spin_unlock_irqrestore(&info->lock, flags); |
4941 | 4965 | ||
4942 | /* wait for receive complete */ | 4966 | /* wait for receive complete */ |
diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c index ecba4942fc8e..f58440791e65 100644 --- a/drivers/char/tpm/tpm_infineon.c +++ b/drivers/char/tpm/tpm_infineon.c | |||
@@ -39,12 +39,12 @@ | |||
39 | struct tpm_inf_dev { | 39 | struct tpm_inf_dev { |
40 | int iotype; | 40 | int iotype; |
41 | 41 | ||
42 | void __iomem *mem_base; /* MMIO ioremap'd addr */ | 42 | void __iomem *mem_base; /* MMIO ioremap'd addr */ |
43 | unsigned long map_base; /* phys MMIO base */ | 43 | unsigned long map_base; /* phys MMIO base */ |
44 | unsigned long map_size; /* MMIO region size */ | 44 | unsigned long map_size; /* MMIO region size */ |
45 | unsigned int index_off; /* index register offset */ | 45 | unsigned int index_off; /* index register offset */ |
46 | 46 | ||
47 | unsigned int data_regs; /* Data registers */ | 47 | unsigned int data_regs; /* Data registers */ |
48 | unsigned int data_size; | 48 | unsigned int data_size; |
49 | 49 | ||
50 | unsigned int config_port; /* IO Port config index reg */ | 50 | unsigned int config_port; /* IO Port config index reg */ |
@@ -406,14 +406,14 @@ static const struct tpm_vendor_specific tpm_inf = { | |||
406 | .miscdev = {.fops = &inf_ops,}, | 406 | .miscdev = {.fops = &inf_ops,}, |
407 | }; | 407 | }; |
408 | 408 | ||
409 | static const struct pnp_device_id tpm_pnp_tbl[] = { | 409 | static const struct pnp_device_id tpm_inf_pnp_tbl[] = { |
410 | /* Infineon TPMs */ | 410 | /* Infineon TPMs */ |
411 | {"IFX0101", 0}, | 411 | {"IFX0101", 0}, |
412 | {"IFX0102", 0}, | 412 | {"IFX0102", 0}, |
413 | {"", 0} | 413 | {"", 0} |
414 | }; | 414 | }; |
415 | 415 | ||
416 | MODULE_DEVICE_TABLE(pnp, tpm_pnp_tbl); | 416 | MODULE_DEVICE_TABLE(pnp, tpm_inf_pnp_tbl); |
417 | 417 | ||
418 | static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | 418 | static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, |
419 | const struct pnp_device_id *dev_id) | 419 | const struct pnp_device_id *dev_id) |
@@ -430,7 +430,7 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | |||
430 | if (pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && | 430 | if (pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && |
431 | !(pnp_port_flags(dev, 0) & IORESOURCE_DISABLED)) { | 431 | !(pnp_port_flags(dev, 0) & IORESOURCE_DISABLED)) { |
432 | 432 | ||
433 | tpm_dev.iotype = TPM_INF_IO_PORT; | 433 | tpm_dev.iotype = TPM_INF_IO_PORT; |
434 | 434 | ||
435 | tpm_dev.config_port = pnp_port_start(dev, 0); | 435 | tpm_dev.config_port = pnp_port_start(dev, 0); |
436 | tpm_dev.config_size = pnp_port_len(dev, 0); | 436 | tpm_dev.config_size = pnp_port_len(dev, 0); |
@@ -459,9 +459,9 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | |||
459 | goto err_last; | 459 | goto err_last; |
460 | } | 460 | } |
461 | } else if (pnp_mem_valid(dev, 0) && | 461 | } else if (pnp_mem_valid(dev, 0) && |
462 | !(pnp_mem_flags(dev, 0) & IORESOURCE_DISABLED)) { | 462 | !(pnp_mem_flags(dev, 0) & IORESOURCE_DISABLED)) { |
463 | 463 | ||
464 | tpm_dev.iotype = TPM_INF_IO_MEM; | 464 | tpm_dev.iotype = TPM_INF_IO_MEM; |
465 | 465 | ||
466 | tpm_dev.map_base = pnp_mem_start(dev, 0); | 466 | tpm_dev.map_base = pnp_mem_start(dev, 0); |
467 | tpm_dev.map_size = pnp_mem_len(dev, 0); | 467 | tpm_dev.map_size = pnp_mem_len(dev, 0); |
@@ -563,11 +563,11 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | |||
563 | "product id 0x%02x%02x" | 563 | "product id 0x%02x%02x" |
564 | "%s\n", | 564 | "%s\n", |
565 | tpm_dev.iotype == TPM_INF_IO_PORT ? | 565 | tpm_dev.iotype == TPM_INF_IO_PORT ? |
566 | tpm_dev.config_port : | 566 | tpm_dev.config_port : |
567 | tpm_dev.map_base + tpm_dev.index_off, | 567 | tpm_dev.map_base + tpm_dev.index_off, |
568 | tpm_dev.iotype == TPM_INF_IO_PORT ? | 568 | tpm_dev.iotype == TPM_INF_IO_PORT ? |
569 | tpm_dev.data_regs : | 569 | tpm_dev.data_regs : |
570 | tpm_dev.map_base + tpm_dev.data_regs, | 570 | tpm_dev.map_base + tpm_dev.data_regs, |
571 | version[0], version[1], | 571 | version[0], version[1], |
572 | vendorid[0], vendorid[1], | 572 | vendorid[0], vendorid[1], |
573 | productid[0], productid[1], chipname); | 573 | productid[0], productid[1], chipname); |
@@ -607,20 +607,55 @@ static __devexit void tpm_inf_pnp_remove(struct pnp_dev *dev) | |||
607 | iounmap(tpm_dev.mem_base); | 607 | iounmap(tpm_dev.mem_base); |
608 | release_mem_region(tpm_dev.map_base, tpm_dev.map_size); | 608 | release_mem_region(tpm_dev.map_base, tpm_dev.map_size); |
609 | } | 609 | } |
610 | tpm_dev_vendor_release(chip); | ||
610 | tpm_remove_hardware(chip->dev); | 611 | tpm_remove_hardware(chip->dev); |
611 | } | 612 | } |
612 | } | 613 | } |
613 | 614 | ||
615 | static int tpm_inf_pnp_suspend(struct pnp_dev *dev, pm_message_t pm_state) | ||
616 | { | ||
617 | struct tpm_chip *chip = pnp_get_drvdata(dev); | ||
618 | int rc; | ||
619 | if (chip) { | ||
620 | u8 savestate[] = { | ||
621 | 0, 193, /* TPM_TAG_RQU_COMMAND */ | ||
622 | 0, 0, 0, 10, /* blob length (in bytes) */ | ||
623 | 0, 0, 0, 152 /* TPM_ORD_SaveState */ | ||
624 | }; | ||
625 | dev_info(&dev->dev, "saving TPM state\n"); | ||
626 | rc = tpm_inf_send(chip, savestate, sizeof(savestate)); | ||
627 | if (rc < 0) { | ||
628 | dev_err(&dev->dev, "error while saving TPM state\n"); | ||
629 | return rc; | ||
630 | } | ||
631 | } | ||
632 | return 0; | ||
633 | } | ||
634 | |||
635 | static int tpm_inf_pnp_resume(struct pnp_dev *dev) | ||
636 | { | ||
637 | /* Re-configure TPM after suspending */ | ||
638 | tpm_config_out(ENABLE_REGISTER_PAIR, TPM_INF_ADDR); | ||
639 | tpm_config_out(IOLIMH, TPM_INF_ADDR); | ||
640 | tpm_config_out((tpm_dev.data_regs >> 8) & 0xff, TPM_INF_DATA); | ||
641 | tpm_config_out(IOLIML, TPM_INF_ADDR); | ||
642 | tpm_config_out((tpm_dev.data_regs & 0xff), TPM_INF_DATA); | ||
643 | /* activate register */ | ||
644 | tpm_config_out(TPM_DAR, TPM_INF_ADDR); | ||
645 | tpm_config_out(0x01, TPM_INF_DATA); | ||
646 | tpm_config_out(DISABLE_REGISTER_PAIR, TPM_INF_ADDR); | ||
647 | /* disable RESET, LP and IRQC */ | ||
648 | tpm_data_out(RESET_LP_IRQC_DISABLE, CMD); | ||
649 | return tpm_pm_resume(&dev->dev); | ||
650 | } | ||
651 | |||
614 | static struct pnp_driver tpm_inf_pnp_driver = { | 652 | static struct pnp_driver tpm_inf_pnp_driver = { |
615 | .name = "tpm_inf_pnp", | 653 | .name = "tpm_inf_pnp", |
616 | .driver = { | 654 | .id_table = tpm_inf_pnp_tbl, |
617 | .owner = THIS_MODULE, | ||
618 | .suspend = tpm_pm_suspend, | ||
619 | .resume = tpm_pm_resume, | ||
620 | }, | ||
621 | .id_table = tpm_pnp_tbl, | ||
622 | .probe = tpm_inf_pnp_probe, | 655 | .probe = tpm_inf_pnp_probe, |
623 | .remove = __devexit_p(tpm_inf_pnp_remove), | 656 | .suspend = tpm_inf_pnp_suspend, |
657 | .resume = tpm_inf_pnp_resume, | ||
658 | .remove = __devexit_p(tpm_inf_pnp_remove) | ||
624 | }; | 659 | }; |
625 | 660 | ||
626 | static int __init init_inf(void) | 661 | static int __init init_inf(void) |
@@ -638,5 +673,5 @@ module_exit(cleanup_inf); | |||
638 | 673 | ||
639 | MODULE_AUTHOR("Marcel Selhorst <m.selhorst@sirrix.com>"); | 674 | MODULE_AUTHOR("Marcel Selhorst <m.selhorst@sirrix.com>"); |
640 | MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2"); | 675 | MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2"); |
641 | MODULE_VERSION("1.9"); | 676 | MODULE_VERSION("1.9.2"); |
642 | MODULE_LICENSE("GPL"); | 677 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/char/tty_audit.c b/drivers/char/tty_audit.c index ac16fbec72d0..283a15bc84e3 100644 --- a/drivers/char/tty_audit.c +++ b/drivers/char/tty_audit.c | |||
@@ -148,7 +148,6 @@ void tty_audit_fork(struct signal_struct *sig) | |||
148 | spin_lock_irq(¤t->sighand->siglock); | 148 | spin_lock_irq(¤t->sighand->siglock); |
149 | sig->audit_tty = current->signal->audit_tty; | 149 | sig->audit_tty = current->signal->audit_tty; |
150 | spin_unlock_irq(¤t->sighand->siglock); | 150 | spin_unlock_irq(¤t->sighand->siglock); |
151 | sig->tty_audit_buf = NULL; | ||
152 | } | 151 | } |
153 | 152 | ||
154 | /** | 153 | /** |
diff --git a/drivers/char/tty_buffer.c b/drivers/char/tty_buffer.c index 66fa4e10d76b..af8d97715728 100644 --- a/drivers/char/tty_buffer.c +++ b/drivers/char/tty_buffer.c | |||
@@ -231,9 +231,10 @@ int tty_buffer_request_room(struct tty_struct *tty, size_t size) | |||
231 | EXPORT_SYMBOL_GPL(tty_buffer_request_room); | 231 | EXPORT_SYMBOL_GPL(tty_buffer_request_room); |
232 | 232 | ||
233 | /** | 233 | /** |
234 | * tty_insert_flip_string - Add characters to the tty buffer | 234 | * tty_insert_flip_string_fixed_flag - Add characters to the tty buffer |
235 | * @tty: tty structure | 235 | * @tty: tty structure |
236 | * @chars: characters | 236 | * @chars: characters |
237 | * @flag: flag value for each character | ||
237 | * @size: size | 238 | * @size: size |
238 | * | 239 | * |
239 | * Queue a series of bytes to the tty buffering. All the characters | 240 | * Queue a series of bytes to the tty buffering. All the characters |
@@ -242,18 +243,19 @@ EXPORT_SYMBOL_GPL(tty_buffer_request_room); | |||
242 | * Locking: Called functions may take tty->buf.lock | 243 | * Locking: Called functions may take tty->buf.lock |
243 | */ | 244 | */ |
244 | 245 | ||
245 | int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, | 246 | int tty_insert_flip_string_fixed_flag(struct tty_struct *tty, |
246 | size_t size) | 247 | const unsigned char *chars, char flag, size_t size) |
247 | { | 248 | { |
248 | int copied = 0; | 249 | int copied = 0; |
249 | do { | 250 | do { |
250 | int space = tty_buffer_request_room(tty, size - copied); | 251 | int goal = min(size - copied, TTY_BUFFER_PAGE); |
252 | int space = tty_buffer_request_room(tty, goal); | ||
251 | struct tty_buffer *tb = tty->buf.tail; | 253 | struct tty_buffer *tb = tty->buf.tail; |
252 | /* If there is no space then tb may be NULL */ | 254 | /* If there is no space then tb may be NULL */ |
253 | if (unlikely(space == 0)) | 255 | if (unlikely(space == 0)) |
254 | break; | 256 | break; |
255 | memcpy(tb->char_buf_ptr + tb->used, chars, space); | 257 | memcpy(tb->char_buf_ptr + tb->used, chars, space); |
256 | memset(tb->flag_buf_ptr + tb->used, TTY_NORMAL, space); | 258 | memset(tb->flag_buf_ptr + tb->used, flag, space); |
257 | tb->used += space; | 259 | tb->used += space; |
258 | copied += space; | 260 | copied += space; |
259 | chars += space; | 261 | chars += space; |
@@ -262,7 +264,7 @@ int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, | |||
262 | } while (unlikely(size > copied)); | 264 | } while (unlikely(size > copied)); |
263 | return copied; | 265 | return copied; |
264 | } | 266 | } |
265 | EXPORT_SYMBOL(tty_insert_flip_string); | 267 | EXPORT_SYMBOL(tty_insert_flip_string_fixed_flag); |
266 | 268 | ||
267 | /** | 269 | /** |
268 | * tty_insert_flip_string_flags - Add characters to the tty buffer | 270 | * tty_insert_flip_string_flags - Add characters to the tty buffer |
@@ -283,7 +285,8 @@ int tty_insert_flip_string_flags(struct tty_struct *tty, | |||
283 | { | 285 | { |
284 | int copied = 0; | 286 | int copied = 0; |
285 | do { | 287 | do { |
286 | int space = tty_buffer_request_room(tty, size - copied); | 288 | int goal = min(size - copied, TTY_BUFFER_PAGE); |
289 | int space = tty_buffer_request_room(tty, goal); | ||
287 | struct tty_buffer *tb = tty->buf.tail; | 290 | struct tty_buffer *tb = tty->buf.tail; |
288 | /* If there is no space then tb may be NULL */ | 291 | /* If there is no space then tb may be NULL */ |
289 | if (unlikely(space == 0)) | 292 | if (unlikely(space == 0)) |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index c6f3b48be9dd..a42c466f7092 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -1951,8 +1951,10 @@ static int tty_fasync(int fd, struct file *filp, int on) | |||
1951 | pid = task_pid(current); | 1951 | pid = task_pid(current); |
1952 | type = PIDTYPE_PID; | 1952 | type = PIDTYPE_PID; |
1953 | } | 1953 | } |
1954 | retval = __f_setown(filp, pid, type, 0); | 1954 | get_pid(pid); |
1955 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | 1955 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); |
1956 | retval = __f_setown(filp, pid, type, 0); | ||
1957 | put_pid(pid); | ||
1956 | if (retval) | 1958 | if (retval) |
1957 | goto out; | 1959 | goto out; |
1958 | } else { | 1960 | } else { |
@@ -2026,7 +2028,7 @@ static int tiocgwinsz(struct tty_struct *tty, struct winsize __user *arg) | |||
2026 | * @rows: rows (character) | 2028 | * @rows: rows (character) |
2027 | * @cols: cols (character) | 2029 | * @cols: cols (character) |
2028 | * | 2030 | * |
2029 | * Update the termios variables and send the neccessary signals to | 2031 | * Update the termios variables and send the necessary signals to |
2030 | * peform a terminal resize correctly | 2032 | * peform a terminal resize correctly |
2031 | */ | 2033 | */ |
2032 | 2034 | ||
diff --git a/drivers/char/tty_ldisc.c b/drivers/char/tty_ldisc.c index 3f653f7d849f..500e740ec5e4 100644 --- a/drivers/char/tty_ldisc.c +++ b/drivers/char/tty_ldisc.c | |||
@@ -706,12 +706,13 @@ static void tty_reset_termios(struct tty_struct *tty) | |||
706 | /** | 706 | /** |
707 | * tty_ldisc_reinit - reinitialise the tty ldisc | 707 | * tty_ldisc_reinit - reinitialise the tty ldisc |
708 | * @tty: tty to reinit | 708 | * @tty: tty to reinit |
709 | * @ldisc: line discipline to reinitialize | ||
709 | * | 710 | * |
710 | * Switch the tty back to N_TTY line discipline and leave the | 711 | * Switch the tty to a line discipline and leave the ldisc |
711 | * ldisc state closed | 712 | * state closed |
712 | */ | 713 | */ |
713 | 714 | ||
714 | static void tty_ldisc_reinit(struct tty_struct *tty) | 715 | static void tty_ldisc_reinit(struct tty_struct *tty, int ldisc) |
715 | { | 716 | { |
716 | struct tty_ldisc *ld; | 717 | struct tty_ldisc *ld; |
717 | 718 | ||
@@ -721,10 +722,10 @@ static void tty_ldisc_reinit(struct tty_struct *tty) | |||
721 | /* | 722 | /* |
722 | * Switch the line discipline back | 723 | * Switch the line discipline back |
723 | */ | 724 | */ |
724 | ld = tty_ldisc_get(N_TTY); | 725 | ld = tty_ldisc_get(ldisc); |
725 | BUG_ON(IS_ERR(ld)); | 726 | BUG_ON(IS_ERR(ld)); |
726 | tty_ldisc_assign(tty, ld); | 727 | tty_ldisc_assign(tty, ld); |
727 | tty_set_termios_ldisc(tty, N_TTY); | 728 | tty_set_termios_ldisc(tty, ldisc); |
728 | } | 729 | } |
729 | 730 | ||
730 | /** | 731 | /** |
@@ -745,6 +746,8 @@ static void tty_ldisc_reinit(struct tty_struct *tty) | |||
745 | void tty_ldisc_hangup(struct tty_struct *tty) | 746 | void tty_ldisc_hangup(struct tty_struct *tty) |
746 | { | 747 | { |
747 | struct tty_ldisc *ld; | 748 | struct tty_ldisc *ld; |
749 | int reset = tty->driver->flags & TTY_DRIVER_RESET_TERMIOS; | ||
750 | int err = 0; | ||
748 | 751 | ||
749 | /* | 752 | /* |
750 | * FIXME! What are the locking issues here? This may me overdoing | 753 | * FIXME! What are the locking issues here? This may me overdoing |
@@ -772,25 +775,32 @@ void tty_ldisc_hangup(struct tty_struct *tty) | |||
772 | wake_up_interruptible_poll(&tty->read_wait, POLLIN); | 775 | wake_up_interruptible_poll(&tty->read_wait, POLLIN); |
773 | /* | 776 | /* |
774 | * Shutdown the current line discipline, and reset it to | 777 | * Shutdown the current line discipline, and reset it to |
775 | * N_TTY. | 778 | * N_TTY if need be. |
779 | * | ||
780 | * Avoid racing set_ldisc or tty_ldisc_release | ||
776 | */ | 781 | */ |
777 | if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) { | 782 | mutex_lock(&tty->ldisc_mutex); |
778 | /* Avoid racing set_ldisc or tty_ldisc_release */ | 783 | tty_ldisc_halt(tty); |
779 | mutex_lock(&tty->ldisc_mutex); | 784 | /* At this point we have a closed ldisc and we want to |
780 | tty_ldisc_halt(tty); | 785 | reopen it. We could defer this to the next open but |
781 | if (tty->ldisc) { /* Not yet closed */ | 786 | it means auditing a lot of other paths so this is |
782 | /* Switch back to N_TTY */ | 787 | a FIXME */ |
783 | tty_ldisc_reinit(tty); | 788 | if (tty->ldisc) { /* Not yet closed */ |
784 | /* At this point we have a closed ldisc and we want to | 789 | if (reset == 0) { |
785 | reopen it. We could defer this to the next open but | 790 | tty_ldisc_reinit(tty, tty->termios->c_line); |
786 | it means auditing a lot of other paths so this is | 791 | err = tty_ldisc_open(tty, tty->ldisc); |
787 | a FIXME */ | 792 | } |
793 | /* If the re-open fails or we reset then go to N_TTY. The | ||
794 | N_TTY open cannot fail */ | ||
795 | if (reset || err) { | ||
796 | tty_ldisc_reinit(tty, N_TTY); | ||
788 | WARN_ON(tty_ldisc_open(tty, tty->ldisc)); | 797 | WARN_ON(tty_ldisc_open(tty, tty->ldisc)); |
789 | tty_ldisc_enable(tty); | ||
790 | } | 798 | } |
791 | mutex_unlock(&tty->ldisc_mutex); | 799 | tty_ldisc_enable(tty); |
792 | tty_reset_termios(tty); | ||
793 | } | 800 | } |
801 | mutex_unlock(&tty->ldisc_mutex); | ||
802 | if (reset) | ||
803 | tty_reset_termios(tty); | ||
794 | } | 804 | } |
795 | 805 | ||
796 | /** | 806 | /** |
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index a035ae39a359..f404ccfc9c20 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
@@ -1,18 +1,6 @@ | |||
1 | /*D:300 | 1 | /* |
2 | * The Guest console driver | 2 | * Copyright (C) 2006, 2007, 2009 Rusty Russell, IBM Corporation |
3 | * | 3 | * Copyright (C) 2009, 2010 Red Hat, Inc. |
4 | * Writing console drivers is one of the few remaining Dark Arts in Linux. | ||
5 | * Fortunately for us, the path of virtual consoles has been well-trodden by | ||
6 | * the PowerPC folks, who wrote "hvc_console.c" to generically support any | ||
7 | * virtual console. We use that infrastructure which only requires us to write | ||
8 | * the basic put_chars and get_chars functions and call the right register | ||
9 | * functions. | ||
10 | :*/ | ||
11 | |||
12 | /*M:002 The console can be flooded: while the Guest is processing input the | ||
13 | * Host can send more. Buffering in the Host could alleviate this, but it is a | ||
14 | * difficult problem in general. :*/ | ||
15 | /* Copyright (C) 2006, 2007 Rusty Russell, IBM Corporation | ||
16 | * | 4 | * |
17 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
18 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
@@ -28,142 +16,694 @@ | |||
28 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
29 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
30 | */ | 18 | */ |
19 | #include <linux/cdev.h> | ||
20 | #include <linux/debugfs.h> | ||
21 | #include <linux/device.h> | ||
31 | #include <linux/err.h> | 22 | #include <linux/err.h> |
23 | #include <linux/fs.h> | ||
32 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/list.h> | ||
26 | #include <linux/poll.h> | ||
27 | #include <linux/sched.h> | ||
28 | #include <linux/spinlock.h> | ||
33 | #include <linux/virtio.h> | 29 | #include <linux/virtio.h> |
34 | #include <linux/virtio_console.h> | 30 | #include <linux/virtio_console.h> |
31 | #include <linux/wait.h> | ||
32 | #include <linux/workqueue.h> | ||
35 | #include "hvc_console.h" | 33 | #include "hvc_console.h" |
36 | 34 | ||
37 | /*D:340 These represent our input and output console queues, and the virtio | 35 | /* |
38 | * operations for them. */ | 36 | * This is a global struct for storing common data for all the devices |
39 | static struct virtqueue *in_vq, *out_vq; | 37 | * this driver handles. |
40 | static struct virtio_device *vdev; | 38 | * |
39 | * Mainly, it has a linked list for all the consoles in one place so | ||
40 | * that callbacks from hvc for get_chars(), put_chars() work properly | ||
41 | * across multiple devices and multiple ports per device. | ||
42 | */ | ||
43 | struct ports_driver_data { | ||
44 | /* Used for registering chardevs */ | ||
45 | struct class *class; | ||
46 | |||
47 | /* Used for exporting per-port information to debugfs */ | ||
48 | struct dentry *debugfs_dir; | ||
49 | |||
50 | /* Number of devices this driver is handling */ | ||
51 | unsigned int index; | ||
52 | |||
53 | /* | ||
54 | * This is used to keep track of the number of hvc consoles | ||
55 | * spawned by this driver. This number is given as the first | ||
56 | * argument to hvc_alloc(). To correctly map an initial | ||
57 | * console spawned via hvc_instantiate to the console being | ||
58 | * hooked up via hvc_alloc, we need to pass the same vtermno. | ||
59 | * | ||
60 | * We also just assume the first console being initialised was | ||
61 | * the first one that got used as the initial console. | ||
62 | */ | ||
63 | unsigned int next_vtermno; | ||
64 | |||
65 | /* All the console devices handled by this driver */ | ||
66 | struct list_head consoles; | ||
67 | }; | ||
68 | static struct ports_driver_data pdrvdata; | ||
69 | |||
70 | DEFINE_SPINLOCK(pdrvdata_lock); | ||
71 | |||
72 | /* This struct holds information that's relevant only for console ports */ | ||
73 | struct console { | ||
74 | /* We'll place all consoles in a list in the pdrvdata struct */ | ||
75 | struct list_head list; | ||
76 | |||
77 | /* The hvc device associated with this console port */ | ||
78 | struct hvc_struct *hvc; | ||
79 | |||
80 | /* | ||
81 | * This number identifies the number that we used to register | ||
82 | * with hvc in hvc_instantiate() and hvc_alloc(); this is the | ||
83 | * number passed on by the hvc callbacks to us to | ||
84 | * differentiate between the other console ports handled by | ||
85 | * this driver | ||
86 | */ | ||
87 | u32 vtermno; | ||
88 | }; | ||
89 | |||
90 | struct port_buffer { | ||
91 | char *buf; | ||
92 | |||
93 | /* size of the buffer in *buf above */ | ||
94 | size_t size; | ||
95 | |||
96 | /* used length of the buffer */ | ||
97 | size_t len; | ||
98 | /* offset in the buf from which to consume data */ | ||
99 | size_t offset; | ||
100 | }; | ||
101 | |||
102 | /* | ||
103 | * This is a per-device struct that stores data common to all the | ||
104 | * ports for that device (vdev->priv). | ||
105 | */ | ||
106 | struct ports_device { | ||
107 | /* | ||
108 | * Workqueue handlers where we process deferred work after | ||
109 | * notification | ||
110 | */ | ||
111 | struct work_struct control_work; | ||
112 | struct work_struct config_work; | ||
113 | |||
114 | struct list_head ports; | ||
115 | |||
116 | /* To protect the list of ports */ | ||
117 | spinlock_t ports_lock; | ||
118 | |||
119 | /* To protect the vq operations for the control channel */ | ||
120 | spinlock_t cvq_lock; | ||
121 | |||
122 | /* The current config space is stored here */ | ||
123 | struct virtio_console_config config; | ||
124 | |||
125 | /* The virtio device we're associated with */ | ||
126 | struct virtio_device *vdev; | ||
127 | |||
128 | /* | ||
129 | * A couple of virtqueues for the control channel: one for | ||
130 | * guest->host transfers, one for host->guest transfers | ||
131 | */ | ||
132 | struct virtqueue *c_ivq, *c_ovq; | ||
133 | |||
134 | /* Array of per-port IO virtqueues */ | ||
135 | struct virtqueue **in_vqs, **out_vqs; | ||
136 | |||
137 | /* Used for numbering devices for sysfs and debugfs */ | ||
138 | unsigned int drv_index; | ||
139 | |||
140 | /* Major number for this device. Ports will be created as minors. */ | ||
141 | int chr_major; | ||
142 | }; | ||
143 | |||
144 | /* This struct holds the per-port data */ | ||
145 | struct port { | ||
146 | /* Next port in the list, head is in the ports_device */ | ||
147 | struct list_head list; | ||
148 | |||
149 | /* Pointer to the parent virtio_console device */ | ||
150 | struct ports_device *portdev; | ||
151 | |||
152 | /* The current buffer from which data has to be fed to readers */ | ||
153 | struct port_buffer *inbuf; | ||
154 | |||
155 | /* | ||
156 | * To protect the operations on the in_vq associated with this | ||
157 | * port. Has to be a spinlock because it can be called from | ||
158 | * interrupt context (get_char()). | ||
159 | */ | ||
160 | spinlock_t inbuf_lock; | ||
161 | |||
162 | /* The IO vqs for this port */ | ||
163 | struct virtqueue *in_vq, *out_vq; | ||
164 | |||
165 | /* File in the debugfs directory that exposes this port's information */ | ||
166 | struct dentry *debugfs_file; | ||
167 | |||
168 | /* | ||
169 | * The entries in this struct will be valid if this port is | ||
170 | * hooked up to an hvc console | ||
171 | */ | ||
172 | struct console cons; | ||
173 | |||
174 | /* Each port associates with a separate char device */ | ||
175 | struct cdev cdev; | ||
176 | struct device *dev; | ||
177 | |||
178 | /* A waitqueue for poll() or blocking read operations */ | ||
179 | wait_queue_head_t waitqueue; | ||
180 | |||
181 | /* The 'name' of the port that we expose via sysfs properties */ | ||
182 | char *name; | ||
183 | |||
184 | /* The 'id' to identify the port with the Host */ | ||
185 | u32 id; | ||
186 | |||
187 | /* Is the host device open */ | ||
188 | bool host_connected; | ||
189 | |||
190 | /* We should allow only one process to open a port */ | ||
191 | bool guest_connected; | ||
192 | }; | ||
193 | |||
194 | /* This is the very early arch-specified put chars function. */ | ||
195 | static int (*early_put_chars)(u32, const char *, int); | ||
196 | |||
197 | static struct port *find_port_by_vtermno(u32 vtermno) | ||
198 | { | ||
199 | struct port *port; | ||
200 | struct console *cons; | ||
201 | unsigned long flags; | ||
202 | |||
203 | spin_lock_irqsave(&pdrvdata_lock, flags); | ||
204 | list_for_each_entry(cons, &pdrvdata.consoles, list) { | ||
205 | if (cons->vtermno == vtermno) { | ||
206 | port = container_of(cons, struct port, cons); | ||
207 | goto out; | ||
208 | } | ||
209 | } | ||
210 | port = NULL; | ||
211 | out: | ||
212 | spin_unlock_irqrestore(&pdrvdata_lock, flags); | ||
213 | return port; | ||
214 | } | ||
215 | |||
216 | static struct port *find_port_by_id(struct ports_device *portdev, u32 id) | ||
217 | { | ||
218 | struct port *port; | ||
219 | unsigned long flags; | ||
220 | |||
221 | spin_lock_irqsave(&portdev->ports_lock, flags); | ||
222 | list_for_each_entry(port, &portdev->ports, list) | ||
223 | if (port->id == id) | ||
224 | goto out; | ||
225 | port = NULL; | ||
226 | out: | ||
227 | spin_unlock_irqrestore(&portdev->ports_lock, flags); | ||
228 | |||
229 | return port; | ||
230 | } | ||
231 | |||
232 | static struct port *find_port_by_vq(struct ports_device *portdev, | ||
233 | struct virtqueue *vq) | ||
234 | { | ||
235 | struct port *port; | ||
236 | unsigned long flags; | ||
237 | |||
238 | spin_lock_irqsave(&portdev->ports_lock, flags); | ||
239 | list_for_each_entry(port, &portdev->ports, list) | ||
240 | if (port->in_vq == vq || port->out_vq == vq) | ||
241 | goto out; | ||
242 | port = NULL; | ||
243 | out: | ||
244 | spin_unlock_irqrestore(&portdev->ports_lock, flags); | ||
245 | return port; | ||
246 | } | ||
247 | |||
248 | static bool is_console_port(struct port *port) | ||
249 | { | ||
250 | if (port->cons.hvc) | ||
251 | return true; | ||
252 | return false; | ||
253 | } | ||
254 | |||
255 | static inline bool use_multiport(struct ports_device *portdev) | ||
256 | { | ||
257 | /* | ||
258 | * This condition can be true when put_chars is called from | ||
259 | * early_init | ||
260 | */ | ||
261 | if (!portdev->vdev) | ||
262 | return 0; | ||
263 | return portdev->vdev->features[0] & (1 << VIRTIO_CONSOLE_F_MULTIPORT); | ||
264 | } | ||
41 | 265 | ||
42 | /* This is our input buffer, and how much data is left in it. */ | 266 | static void free_buf(struct port_buffer *buf) |
43 | static unsigned int in_len; | 267 | { |
44 | static char *in, *inbuf; | 268 | kfree(buf->buf); |
269 | kfree(buf); | ||
270 | } | ||
271 | |||
272 | static struct port_buffer *alloc_buf(size_t buf_size) | ||
273 | { | ||
274 | struct port_buffer *buf; | ||
45 | 275 | ||
46 | /* The operations for our console. */ | 276 | buf = kmalloc(sizeof(*buf), GFP_KERNEL); |
47 | static struct hv_ops virtio_cons; | 277 | if (!buf) |
278 | goto fail; | ||
279 | buf->buf = kzalloc(buf_size, GFP_KERNEL); | ||
280 | if (!buf->buf) | ||
281 | goto free_buf; | ||
282 | buf->len = 0; | ||
283 | buf->offset = 0; | ||
284 | buf->size = buf_size; | ||
285 | return buf; | ||
286 | |||
287 | free_buf: | ||
288 | kfree(buf); | ||
289 | fail: | ||
290 | return NULL; | ||
291 | } | ||
292 | |||
293 | /* Callers should take appropriate locks */ | ||
294 | static void *get_inbuf(struct port *port) | ||
295 | { | ||
296 | struct port_buffer *buf; | ||
297 | struct virtqueue *vq; | ||
298 | unsigned int len; | ||
48 | 299 | ||
49 | /* The hvc device */ | 300 | vq = port->in_vq; |
50 | static struct hvc_struct *hvc; | 301 | buf = vq->vq_ops->get_buf(vq, &len); |
302 | if (buf) { | ||
303 | buf->len = len; | ||
304 | buf->offset = 0; | ||
305 | } | ||
306 | return buf; | ||
307 | } | ||
51 | 308 | ||
52 | /*D:310 The put_chars() callback is pretty straightforward. | 309 | /* |
310 | * Create a scatter-gather list representing our input buffer and put | ||
311 | * it in the queue. | ||
53 | * | 312 | * |
54 | * We turn the characters into a scatter-gather list, add it to the output | 313 | * Callers should take appropriate locks. |
55 | * queue and then kick the Host. Then we sit here waiting for it to finish: | 314 | */ |
56 | * inefficient in theory, but in practice implementations will do it | 315 | static int add_inbuf(struct virtqueue *vq, struct port_buffer *buf) |
57 | * immediately (lguest's Launcher does). */ | ||
58 | static int put_chars(u32 vtermno, const char *buf, int count) | ||
59 | { | 316 | { |
60 | struct scatterlist sg[1]; | 317 | struct scatterlist sg[1]; |
318 | int ret; | ||
319 | |||
320 | sg_init_one(sg, buf->buf, buf->size); | ||
321 | |||
322 | ret = vq->vq_ops->add_buf(vq, sg, 0, 1, buf); | ||
323 | vq->vq_ops->kick(vq); | ||
324 | return ret; | ||
325 | } | ||
326 | |||
327 | /* Discard any unread data this port has. Callers lockers. */ | ||
328 | static void discard_port_data(struct port *port) | ||
329 | { | ||
330 | struct port_buffer *buf; | ||
331 | struct virtqueue *vq; | ||
61 | unsigned int len; | 332 | unsigned int len; |
333 | int ret; | ||
62 | 334 | ||
63 | /* This is a convenient routine to initialize a single-elem sg list */ | 335 | vq = port->in_vq; |
64 | sg_init_one(sg, buf, count); | 336 | if (port->inbuf) |
337 | buf = port->inbuf; | ||
338 | else | ||
339 | buf = vq->vq_ops->get_buf(vq, &len); | ||
65 | 340 | ||
66 | /* add_buf wants a token to identify this buffer: we hand it any | 341 | ret = 0; |
67 | * non-NULL pointer, since there's only ever one buffer. */ | 342 | while (buf) { |
68 | if (out_vq->vq_ops->add_buf(out_vq, sg, 1, 0, (void *)1) >= 0) { | 343 | if (add_inbuf(vq, buf) < 0) { |
69 | /* Tell Host to go! */ | 344 | ret++; |
70 | out_vq->vq_ops->kick(out_vq); | 345 | free_buf(buf); |
71 | /* Chill out until it's done with the buffer. */ | 346 | } |
72 | while (!out_vq->vq_ops->get_buf(out_vq, &len)) | 347 | buf = vq->vq_ops->get_buf(vq, &len); |
73 | cpu_relax(); | ||
74 | } | 348 | } |
349 | port->inbuf = NULL; | ||
350 | if (ret) | ||
351 | dev_warn(port->dev, "Errors adding %d buffers back to vq\n", | ||
352 | ret); | ||
353 | } | ||
75 | 354 | ||
76 | /* We're expected to return the amount of data we wrote: all of it. */ | 355 | static bool port_has_data(struct port *port) |
77 | return count; | 356 | { |
357 | unsigned long flags; | ||
358 | bool ret; | ||
359 | |||
360 | spin_lock_irqsave(&port->inbuf_lock, flags); | ||
361 | if (port->inbuf) { | ||
362 | ret = true; | ||
363 | goto out; | ||
364 | } | ||
365 | port->inbuf = get_inbuf(port); | ||
366 | if (port->inbuf) { | ||
367 | ret = true; | ||
368 | goto out; | ||
369 | } | ||
370 | ret = false; | ||
371 | out: | ||
372 | spin_unlock_irqrestore(&port->inbuf_lock, flags); | ||
373 | return ret; | ||
78 | } | 374 | } |
79 | 375 | ||
80 | /* Create a scatter-gather list representing our input buffer and put it in the | 376 | static ssize_t send_control_msg(struct port *port, unsigned int event, |
81 | * queue. */ | 377 | unsigned int value) |
82 | static void add_inbuf(void) | ||
83 | { | 378 | { |
84 | struct scatterlist sg[1]; | 379 | struct scatterlist sg[1]; |
85 | sg_init_one(sg, inbuf, PAGE_SIZE); | 380 | struct virtio_console_control cpkt; |
381 | struct virtqueue *vq; | ||
382 | unsigned int len; | ||
383 | |||
384 | if (!use_multiport(port->portdev)) | ||
385 | return 0; | ||
386 | |||
387 | cpkt.id = port->id; | ||
388 | cpkt.event = event; | ||
389 | cpkt.value = value; | ||
86 | 390 | ||
87 | /* We should always be able to add one buffer to an empty queue. */ | 391 | vq = port->portdev->c_ovq; |
88 | if (in_vq->vq_ops->add_buf(in_vq, sg, 0, 1, inbuf) < 0) | 392 | |
89 | BUG(); | 393 | sg_init_one(sg, &cpkt, sizeof(cpkt)); |
90 | in_vq->vq_ops->kick(in_vq); | 394 | if (vq->vq_ops->add_buf(vq, sg, 1, 0, &cpkt) >= 0) { |
395 | vq->vq_ops->kick(vq); | ||
396 | while (!vq->vq_ops->get_buf(vq, &len)) | ||
397 | cpu_relax(); | ||
398 | } | ||
399 | return 0; | ||
91 | } | 400 | } |
92 | 401 | ||
93 | /*D:350 get_chars() is the callback from the hvc_console infrastructure when | 402 | static ssize_t send_buf(struct port *port, void *in_buf, size_t in_count) |
94 | * an interrupt is received. | ||
95 | * | ||
96 | * Most of the code deals with the fact that the hvc_console() infrastructure | ||
97 | * only asks us for 16 bytes at a time. We keep in_offset and in_used fields | ||
98 | * for partially-filled buffers. */ | ||
99 | static int get_chars(u32 vtermno, char *buf, int count) | ||
100 | { | 403 | { |
101 | /* If we don't have an input queue yet, we can't get input. */ | 404 | struct scatterlist sg[1]; |
102 | BUG_ON(!in_vq); | 405 | struct virtqueue *out_vq; |
406 | ssize_t ret; | ||
407 | unsigned int len; | ||
408 | |||
409 | out_vq = port->out_vq; | ||
410 | |||
411 | sg_init_one(sg, in_buf, in_count); | ||
412 | ret = out_vq->vq_ops->add_buf(out_vq, sg, 1, 0, in_buf); | ||
413 | |||
414 | /* Tell Host to go! */ | ||
415 | out_vq->vq_ops->kick(out_vq); | ||
416 | |||
417 | if (ret < 0) { | ||
418 | len = 0; | ||
419 | goto fail; | ||
420 | } | ||
421 | |||
422 | /* | ||
423 | * Wait till the host acknowledges it pushed out the data we | ||
424 | * sent. Also ensure we return to userspace the number of | ||
425 | * bytes that were successfully consumed by the host. | ||
426 | */ | ||
427 | while (!out_vq->vq_ops->get_buf(out_vq, &len)) | ||
428 | cpu_relax(); | ||
429 | fail: | ||
430 | /* We're expected to return the amount of data we wrote */ | ||
431 | return len; | ||
432 | } | ||
433 | |||
434 | /* | ||
435 | * Give out the data that's requested from the buffer that we have | ||
436 | * queued up. | ||
437 | */ | ||
438 | static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count, | ||
439 | bool to_user) | ||
440 | { | ||
441 | struct port_buffer *buf; | ||
442 | unsigned long flags; | ||
443 | |||
444 | if (!out_count || !port_has_data(port)) | ||
445 | return 0; | ||
446 | |||
447 | buf = port->inbuf; | ||
448 | out_count = min(out_count, buf->len - buf->offset); | ||
449 | |||
450 | if (to_user) { | ||
451 | ssize_t ret; | ||
452 | |||
453 | ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count); | ||
454 | if (ret) | ||
455 | return -EFAULT; | ||
456 | } else { | ||
457 | memcpy(out_buf, buf->buf + buf->offset, out_count); | ||
458 | } | ||
459 | |||
460 | buf->offset += out_count; | ||
461 | |||
462 | if (buf->offset == buf->len) { | ||
463 | /* | ||
464 | * We're done using all the data in this buffer. | ||
465 | * Re-queue so that the Host can send us more data. | ||
466 | */ | ||
467 | spin_lock_irqsave(&port->inbuf_lock, flags); | ||
468 | port->inbuf = NULL; | ||
469 | |||
470 | if (add_inbuf(port->in_vq, buf) < 0) | ||
471 | dev_warn(port->dev, "failed add_buf\n"); | ||
472 | |||
473 | spin_unlock_irqrestore(&port->inbuf_lock, flags); | ||
474 | } | ||
475 | /* Return the number of bytes actually copied */ | ||
476 | return out_count; | ||
477 | } | ||
478 | |||
479 | /* The condition that must be true for polling to end */ | ||
480 | static bool wait_is_over(struct port *port) | ||
481 | { | ||
482 | return port_has_data(port) || !port->host_connected; | ||
483 | } | ||
484 | |||
485 | static ssize_t port_fops_read(struct file *filp, char __user *ubuf, | ||
486 | size_t count, loff_t *offp) | ||
487 | { | ||
488 | struct port *port; | ||
489 | ssize_t ret; | ||
490 | |||
491 | port = filp->private_data; | ||
103 | 492 | ||
104 | /* No buffer? Try to get one. */ | 493 | if (!port_has_data(port)) { |
105 | if (!in_len) { | 494 | /* |
106 | in = in_vq->vq_ops->get_buf(in_vq, &in_len); | 495 | * If nothing's connected on the host just return 0 in |
107 | if (!in) | 496 | * case of list_empty; this tells the userspace app |
497 | * that there's no connection | ||
498 | */ | ||
499 | if (!port->host_connected) | ||
108 | return 0; | 500 | return 0; |
501 | if (filp->f_flags & O_NONBLOCK) | ||
502 | return -EAGAIN; | ||
503 | |||
504 | ret = wait_event_interruptible(port->waitqueue, | ||
505 | wait_is_over(port)); | ||
506 | if (ret < 0) | ||
507 | return ret; | ||
508 | } | ||
509 | /* | ||
510 | * We could've received a disconnection message while we were | ||
511 | * waiting for more data. | ||
512 | * | ||
513 | * This check is not clubbed in the if() statement above as we | ||
514 | * might receive some data as well as the host could get | ||
515 | * disconnected after we got woken up from our wait. So we | ||
516 | * really want to give off whatever data we have and only then | ||
517 | * check for host_connected. | ||
518 | */ | ||
519 | if (!port_has_data(port) && !port->host_connected) | ||
520 | return 0; | ||
521 | |||
522 | return fill_readbuf(port, ubuf, count, true); | ||
523 | } | ||
524 | |||
525 | static ssize_t port_fops_write(struct file *filp, const char __user *ubuf, | ||
526 | size_t count, loff_t *offp) | ||
527 | { | ||
528 | struct port *port; | ||
529 | char *buf; | ||
530 | ssize_t ret; | ||
531 | |||
532 | port = filp->private_data; | ||
533 | |||
534 | count = min((size_t)(32 * 1024), count); | ||
535 | |||
536 | buf = kmalloc(count, GFP_KERNEL); | ||
537 | if (!buf) | ||
538 | return -ENOMEM; | ||
539 | |||
540 | ret = copy_from_user(buf, ubuf, count); | ||
541 | if (ret) { | ||
542 | ret = -EFAULT; | ||
543 | goto free_buf; | ||
109 | } | 544 | } |
110 | 545 | ||
111 | /* You want more than we have to give? Well, try wanting less! */ | 546 | ret = send_buf(port, buf, count); |
112 | if (in_len < count) | 547 | free_buf: |
113 | count = in_len; | 548 | kfree(buf); |
549 | return ret; | ||
550 | } | ||
551 | |||
552 | static unsigned int port_fops_poll(struct file *filp, poll_table *wait) | ||
553 | { | ||
554 | struct port *port; | ||
555 | unsigned int ret; | ||
556 | |||
557 | port = filp->private_data; | ||
558 | poll_wait(filp, &port->waitqueue, wait); | ||
559 | |||
560 | ret = 0; | ||
561 | if (port->inbuf) | ||
562 | ret |= POLLIN | POLLRDNORM; | ||
563 | if (port->host_connected) | ||
564 | ret |= POLLOUT; | ||
565 | if (!port->host_connected) | ||
566 | ret |= POLLHUP; | ||
567 | |||
568 | return ret; | ||
569 | } | ||
570 | |||
571 | static int port_fops_release(struct inode *inode, struct file *filp) | ||
572 | { | ||
573 | struct port *port; | ||
574 | |||
575 | port = filp->private_data; | ||
576 | |||
577 | /* Notify host of port being closed */ | ||
578 | send_control_msg(port, VIRTIO_CONSOLE_PORT_OPEN, 0); | ||
579 | |||
580 | spin_lock_irq(&port->inbuf_lock); | ||
581 | port->guest_connected = false; | ||
582 | |||
583 | discard_port_data(port); | ||
584 | |||
585 | spin_unlock_irq(&port->inbuf_lock); | ||
586 | |||
587 | return 0; | ||
588 | } | ||
589 | |||
590 | static int port_fops_open(struct inode *inode, struct file *filp) | ||
591 | { | ||
592 | struct cdev *cdev = inode->i_cdev; | ||
593 | struct port *port; | ||
594 | |||
595 | port = container_of(cdev, struct port, cdev); | ||
596 | filp->private_data = port; | ||
597 | |||
598 | /* | ||
599 | * Don't allow opening of console port devices -- that's done | ||
600 | * via /dev/hvc | ||
601 | */ | ||
602 | if (is_console_port(port)) | ||
603 | return -ENXIO; | ||
114 | 604 | ||
115 | /* Copy across to their buffer and increment offset. */ | 605 | /* Allow only one process to open a particular port at a time */ |
116 | memcpy(buf, in, count); | 606 | spin_lock_irq(&port->inbuf_lock); |
117 | in += count; | 607 | if (port->guest_connected) { |
118 | in_len -= count; | 608 | spin_unlock_irq(&port->inbuf_lock); |
609 | return -EMFILE; | ||
610 | } | ||
611 | |||
612 | port->guest_connected = true; | ||
613 | spin_unlock_irq(&port->inbuf_lock); | ||
119 | 614 | ||
120 | /* Finished? Re-register buffer so Host will use it again. */ | 615 | /* Notify host of port being opened */ |
121 | if (in_len == 0) | 616 | send_control_msg(filp->private_data, VIRTIO_CONSOLE_PORT_OPEN, 1); |
122 | add_inbuf(); | ||
123 | 617 | ||
124 | return count; | 618 | return 0; |
125 | } | 619 | } |
126 | /*:*/ | ||
127 | 620 | ||
128 | /*D:320 Console drivers are initialized very early so boot messages can go out, | 621 | /* |
129 | * so we do things slightly differently from the generic virtio initialization | 622 | * The file operations that we support: programs in the guest can open |
130 | * of the net and block drivers. | 623 | * a console device, read from it, write to it, poll for data and |
624 | * close it. The devices are at | ||
625 | * /dev/vport<device number>p<port number> | ||
626 | */ | ||
627 | static const struct file_operations port_fops = { | ||
628 | .owner = THIS_MODULE, | ||
629 | .open = port_fops_open, | ||
630 | .read = port_fops_read, | ||
631 | .write = port_fops_write, | ||
632 | .poll = port_fops_poll, | ||
633 | .release = port_fops_release, | ||
634 | }; | ||
635 | |||
636 | /* | ||
637 | * The put_chars() callback is pretty straightforward. | ||
131 | * | 638 | * |
132 | * At this stage, the console is output-only. It's too early to set up a | 639 | * We turn the characters into a scatter-gather list, add it to the |
133 | * virtqueue, so we let the drivers do some boutique early-output thing. */ | 640 | * output queue and then kick the Host. Then we sit here waiting for |
134 | int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int)) | 641 | * it to finish: inefficient in theory, but in practice |
642 | * implementations will do it immediately (lguest's Launcher does). | ||
643 | */ | ||
644 | static int put_chars(u32 vtermno, const char *buf, int count) | ||
135 | { | 645 | { |
136 | virtio_cons.put_chars = put_chars; | 646 | struct port *port; |
137 | return hvc_instantiate(0, 0, &virtio_cons); | 647 | |
648 | port = find_port_by_vtermno(vtermno); | ||
649 | if (!port) | ||
650 | return 0; | ||
651 | |||
652 | if (unlikely(early_put_chars)) | ||
653 | return early_put_chars(vtermno, buf, count); | ||
654 | |||
655 | return send_buf(port, (void *)buf, count); | ||
138 | } | 656 | } |
139 | 657 | ||
140 | /* | 658 | /* |
141 | * virtio console configuration. This supports: | 659 | * get_chars() is the callback from the hvc_console infrastructure |
142 | * - console resize | 660 | * when an interrupt is received. |
661 | * | ||
662 | * We call out to fill_readbuf that gets us the required data from the | ||
663 | * buffers that are queued up. | ||
143 | */ | 664 | */ |
144 | static void virtcons_apply_config(struct virtio_device *dev) | 665 | static int get_chars(u32 vtermno, char *buf, int count) |
145 | { | 666 | { |
667 | struct port *port; | ||
668 | |||
669 | port = find_port_by_vtermno(vtermno); | ||
670 | if (!port) | ||
671 | return 0; | ||
672 | |||
673 | /* If we don't have an input queue yet, we can't get input. */ | ||
674 | BUG_ON(!port->in_vq); | ||
675 | |||
676 | return fill_readbuf(port, buf, count, false); | ||
677 | } | ||
678 | |||
679 | static void resize_console(struct port *port) | ||
680 | { | ||
681 | struct virtio_device *vdev; | ||
146 | struct winsize ws; | 682 | struct winsize ws; |
147 | 683 | ||
148 | if (virtio_has_feature(dev, VIRTIO_CONSOLE_F_SIZE)) { | 684 | vdev = port->portdev->vdev; |
149 | dev->config->get(dev, | 685 | if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE)) { |
150 | offsetof(struct virtio_console_config, cols), | 686 | vdev->config->get(vdev, |
151 | &ws.ws_col, sizeof(u16)); | 687 | offsetof(struct virtio_console_config, cols), |
152 | dev->config->get(dev, | 688 | &ws.ws_col, sizeof(u16)); |
153 | offsetof(struct virtio_console_config, rows), | 689 | vdev->config->get(vdev, |
154 | &ws.ws_row, sizeof(u16)); | 690 | offsetof(struct virtio_console_config, rows), |
155 | hvc_resize(hvc, ws); | 691 | &ws.ws_row, sizeof(u16)); |
692 | hvc_resize(port->cons.hvc, ws); | ||
156 | } | 693 | } |
157 | } | 694 | } |
158 | 695 | ||
159 | /* | 696 | /* We set the configuration at this point, since we now have a tty */ |
160 | * we support only one console, the hvc struct is a global var | ||
161 | * We set the configuration at this point, since we now have a tty | ||
162 | */ | ||
163 | static int notifier_add_vio(struct hvc_struct *hp, int data) | 697 | static int notifier_add_vio(struct hvc_struct *hp, int data) |
164 | { | 698 | { |
699 | struct port *port; | ||
700 | |||
701 | port = find_port_by_vtermno(hp->vtermno); | ||
702 | if (!port) | ||
703 | return -EINVAL; | ||
704 | |||
165 | hp->irq_requested = 1; | 705 | hp->irq_requested = 1; |
166 | virtcons_apply_config(vdev); | 706 | resize_console(port); |
167 | 707 | ||
168 | return 0; | 708 | return 0; |
169 | } | 709 | } |
@@ -173,79 +713,800 @@ static void notifier_del_vio(struct hvc_struct *hp, int data) | |||
173 | hp->irq_requested = 0; | 713 | hp->irq_requested = 0; |
174 | } | 714 | } |
175 | 715 | ||
176 | static void hvc_handle_input(struct virtqueue *vq) | 716 | /* The operations for console ports. */ |
717 | static const struct hv_ops hv_ops = { | ||
718 | .get_chars = get_chars, | ||
719 | .put_chars = put_chars, | ||
720 | .notifier_add = notifier_add_vio, | ||
721 | .notifier_del = notifier_del_vio, | ||
722 | .notifier_hangup = notifier_del_vio, | ||
723 | }; | ||
724 | |||
725 | /* | ||
726 | * Console drivers are initialized very early so boot messages can go | ||
727 | * out, so we do things slightly differently from the generic virtio | ||
728 | * initialization of the net and block drivers. | ||
729 | * | ||
730 | * At this stage, the console is output-only. It's too early to set | ||
731 | * up a virtqueue, so we let the drivers do some boutique early-output | ||
732 | * thing. | ||
733 | */ | ||
734 | int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int)) | ||
735 | { | ||
736 | early_put_chars = put_chars; | ||
737 | return hvc_instantiate(0, 0, &hv_ops); | ||
738 | } | ||
739 | |||
740 | int init_port_console(struct port *port) | ||
741 | { | ||
742 | int ret; | ||
743 | |||
744 | /* | ||
745 | * The Host's telling us this port is a console port. Hook it | ||
746 | * up with an hvc console. | ||
747 | * | ||
748 | * To set up and manage our virtual console, we call | ||
749 | * hvc_alloc(). | ||
750 | * | ||
751 | * The first argument of hvc_alloc() is the virtual console | ||
752 | * number. The second argument is the parameter for the | ||
753 | * notification mechanism (like irq number). We currently | ||
754 | * leave this as zero, virtqueues have implicit notifications. | ||
755 | * | ||
756 | * The third argument is a "struct hv_ops" containing the | ||
757 | * put_chars() get_chars(), notifier_add() and notifier_del() | ||
758 | * pointers. The final argument is the output buffer size: we | ||
759 | * can do any size, so we put PAGE_SIZE here. | ||
760 | */ | ||
761 | port->cons.vtermno = pdrvdata.next_vtermno; | ||
762 | |||
763 | port->cons.hvc = hvc_alloc(port->cons.vtermno, 0, &hv_ops, PAGE_SIZE); | ||
764 | if (IS_ERR(port->cons.hvc)) { | ||
765 | ret = PTR_ERR(port->cons.hvc); | ||
766 | dev_err(port->dev, | ||
767 | "error %d allocating hvc for port\n", ret); | ||
768 | port->cons.hvc = NULL; | ||
769 | return ret; | ||
770 | } | ||
771 | spin_lock_irq(&pdrvdata_lock); | ||
772 | pdrvdata.next_vtermno++; | ||
773 | list_add_tail(&port->cons.list, &pdrvdata.consoles); | ||
774 | spin_unlock_irq(&pdrvdata_lock); | ||
775 | port->guest_connected = true; | ||
776 | |||
777 | /* Notify host of port being opened */ | ||
778 | send_control_msg(port, VIRTIO_CONSOLE_PORT_OPEN, 1); | ||
779 | |||
780 | return 0; | ||
781 | } | ||
782 | |||
783 | static ssize_t show_port_name(struct device *dev, | ||
784 | struct device_attribute *attr, char *buffer) | ||
785 | { | ||
786 | struct port *port; | ||
787 | |||
788 | port = dev_get_drvdata(dev); | ||
789 | |||
790 | return sprintf(buffer, "%s\n", port->name); | ||
791 | } | ||
792 | |||
793 | static DEVICE_ATTR(name, S_IRUGO, show_port_name, NULL); | ||
794 | |||
795 | static struct attribute *port_sysfs_entries[] = { | ||
796 | &dev_attr_name.attr, | ||
797 | NULL | ||
798 | }; | ||
799 | |||
800 | static struct attribute_group port_attribute_group = { | ||
801 | .name = NULL, /* put in device directory */ | ||
802 | .attrs = port_sysfs_entries, | ||
803 | }; | ||
804 | |||
805 | static int debugfs_open(struct inode *inode, struct file *filp) | ||
806 | { | ||
807 | filp->private_data = inode->i_private; | ||
808 | return 0; | ||
809 | } | ||
810 | |||
811 | static ssize_t debugfs_read(struct file *filp, char __user *ubuf, | ||
812 | size_t count, loff_t *offp) | ||
813 | { | ||
814 | struct port *port; | ||
815 | char *buf; | ||
816 | ssize_t ret, out_offset, out_count; | ||
817 | |||
818 | out_count = 1024; | ||
819 | buf = kmalloc(out_count, GFP_KERNEL); | ||
820 | if (!buf) | ||
821 | return -ENOMEM; | ||
822 | |||
823 | port = filp->private_data; | ||
824 | out_offset = 0; | ||
825 | out_offset += snprintf(buf + out_offset, out_count, | ||
826 | "name: %s\n", port->name ? port->name : ""); | ||
827 | out_offset += snprintf(buf + out_offset, out_count - out_offset, | ||
828 | "guest_connected: %d\n", port->guest_connected); | ||
829 | out_offset += snprintf(buf + out_offset, out_count - out_offset, | ||
830 | "host_connected: %d\n", port->host_connected); | ||
831 | out_offset += snprintf(buf + out_offset, out_count - out_offset, | ||
832 | "is_console: %s\n", | ||
833 | is_console_port(port) ? "yes" : "no"); | ||
834 | out_offset += snprintf(buf + out_offset, out_count - out_offset, | ||
835 | "console_vtermno: %u\n", port->cons.vtermno); | ||
836 | |||
837 | ret = simple_read_from_buffer(ubuf, count, offp, buf, out_offset); | ||
838 | kfree(buf); | ||
839 | return ret; | ||
840 | } | ||
841 | |||
842 | static const struct file_operations port_debugfs_ops = { | ||
843 | .owner = THIS_MODULE, | ||
844 | .open = debugfs_open, | ||
845 | .read = debugfs_read, | ||
846 | }; | ||
847 | |||
848 | /* Remove all port-specific data. */ | ||
849 | static int remove_port(struct port *port) | ||
850 | { | ||
851 | struct port_buffer *buf; | ||
852 | |||
853 | spin_lock_irq(&port->portdev->ports_lock); | ||
854 | list_del(&port->list); | ||
855 | spin_unlock_irq(&port->portdev->ports_lock); | ||
856 | |||
857 | if (is_console_port(port)) { | ||
858 | spin_lock_irq(&pdrvdata_lock); | ||
859 | list_del(&port->cons.list); | ||
860 | spin_unlock_irq(&pdrvdata_lock); | ||
861 | hvc_remove(port->cons.hvc); | ||
862 | } | ||
863 | if (port->guest_connected) | ||
864 | send_control_msg(port, VIRTIO_CONSOLE_PORT_OPEN, 0); | ||
865 | |||
866 | sysfs_remove_group(&port->dev->kobj, &port_attribute_group); | ||
867 | device_destroy(pdrvdata.class, port->dev->devt); | ||
868 | cdev_del(&port->cdev); | ||
869 | |||
870 | /* Remove unused data this port might have received. */ | ||
871 | discard_port_data(port); | ||
872 | |||
873 | /* Remove buffers we queued up for the Host to send us data in. */ | ||
874 | while ((buf = port->in_vq->vq_ops->detach_unused_buf(port->in_vq))) | ||
875 | free_buf(buf); | ||
876 | |||
877 | kfree(port->name); | ||
878 | |||
879 | debugfs_remove(port->debugfs_file); | ||
880 | |||
881 | kfree(port); | ||
882 | return 0; | ||
883 | } | ||
884 | |||
885 | /* Any private messages that the Host and Guest want to share */ | ||
886 | static void handle_control_message(struct ports_device *portdev, | ||
887 | struct port_buffer *buf) | ||
888 | { | ||
889 | struct virtio_console_control *cpkt; | ||
890 | struct port *port; | ||
891 | size_t name_size; | ||
892 | int err; | ||
893 | |||
894 | cpkt = (struct virtio_console_control *)(buf->buf + buf->offset); | ||
895 | |||
896 | port = find_port_by_id(portdev, cpkt->id); | ||
897 | if (!port) { | ||
898 | /* No valid header at start of buffer. Drop it. */ | ||
899 | dev_dbg(&portdev->vdev->dev, | ||
900 | "Invalid index %u in control packet\n", cpkt->id); | ||
901 | return; | ||
902 | } | ||
903 | |||
904 | switch (cpkt->event) { | ||
905 | case VIRTIO_CONSOLE_CONSOLE_PORT: | ||
906 | if (!cpkt->value) | ||
907 | break; | ||
908 | if (is_console_port(port)) | ||
909 | break; | ||
910 | |||
911 | init_port_console(port); | ||
912 | /* | ||
913 | * Could remove the port here in case init fails - but | ||
914 | * have to notify the host first. | ||
915 | */ | ||
916 | break; | ||
917 | case VIRTIO_CONSOLE_RESIZE: | ||
918 | if (!is_console_port(port)) | ||
919 | break; | ||
920 | port->cons.hvc->irq_requested = 1; | ||
921 | resize_console(port); | ||
922 | break; | ||
923 | case VIRTIO_CONSOLE_PORT_OPEN: | ||
924 | port->host_connected = cpkt->value; | ||
925 | wake_up_interruptible(&port->waitqueue); | ||
926 | break; | ||
927 | case VIRTIO_CONSOLE_PORT_NAME: | ||
928 | /* | ||
929 | * Skip the size of the header and the cpkt to get the size | ||
930 | * of the name that was sent | ||
931 | */ | ||
932 | name_size = buf->len - buf->offset - sizeof(*cpkt) + 1; | ||
933 | |||
934 | port->name = kmalloc(name_size, GFP_KERNEL); | ||
935 | if (!port->name) { | ||
936 | dev_err(port->dev, | ||
937 | "Not enough space to store port name\n"); | ||
938 | break; | ||
939 | } | ||
940 | strncpy(port->name, buf->buf + buf->offset + sizeof(*cpkt), | ||
941 | name_size - 1); | ||
942 | port->name[name_size - 1] = 0; | ||
943 | |||
944 | /* | ||
945 | * Since we only have one sysfs attribute, 'name', | ||
946 | * create it only if we have a name for the port. | ||
947 | */ | ||
948 | err = sysfs_create_group(&port->dev->kobj, | ||
949 | &port_attribute_group); | ||
950 | if (err) | ||
951 | dev_err(port->dev, | ||
952 | "Error %d creating sysfs device attributes\n", | ||
953 | err); | ||
954 | |||
955 | break; | ||
956 | case VIRTIO_CONSOLE_PORT_REMOVE: | ||
957 | /* | ||
958 | * Hot unplug the port. We don't decrement nr_ports | ||
959 | * since we don't want to deal with extra complexities | ||
960 | * of using the lowest-available port id: We can just | ||
961 | * pick up the nr_ports number as the id and not have | ||
962 | * userspace send it to us. This helps us in two | ||
963 | * ways: | ||
964 | * | ||
965 | * - We don't need to have a 'port_id' field in the | ||
966 | * config space when a port is hot-added. This is a | ||
967 | * good thing as we might queue up multiple hotplug | ||
968 | * requests issued in our workqueue. | ||
969 | * | ||
970 | * - Another way to deal with this would have been to | ||
971 | * use a bitmap of the active ports and select the | ||
972 | * lowest non-active port from that map. That | ||
973 | * bloats the already tight config space and we | ||
974 | * would end up artificially limiting the | ||
975 | * max. number of ports to sizeof(bitmap). Right | ||
976 | * now we can support 2^32 ports (as the port id is | ||
977 | * stored in a u32 type). | ||
978 | * | ||
979 | */ | ||
980 | remove_port(port); | ||
981 | break; | ||
982 | } | ||
983 | } | ||
984 | |||
985 | static void control_work_handler(struct work_struct *work) | ||
986 | { | ||
987 | struct ports_device *portdev; | ||
988 | struct virtqueue *vq; | ||
989 | struct port_buffer *buf; | ||
990 | unsigned int len; | ||
991 | |||
992 | portdev = container_of(work, struct ports_device, control_work); | ||
993 | vq = portdev->c_ivq; | ||
994 | |||
995 | spin_lock(&portdev->cvq_lock); | ||
996 | while ((buf = vq->vq_ops->get_buf(vq, &len))) { | ||
997 | spin_unlock(&portdev->cvq_lock); | ||
998 | |||
999 | buf->len = len; | ||
1000 | buf->offset = 0; | ||
1001 | |||
1002 | handle_control_message(portdev, buf); | ||
1003 | |||
1004 | spin_lock(&portdev->cvq_lock); | ||
1005 | if (add_inbuf(portdev->c_ivq, buf) < 0) { | ||
1006 | dev_warn(&portdev->vdev->dev, | ||
1007 | "Error adding buffer to queue\n"); | ||
1008 | free_buf(buf); | ||
1009 | } | ||
1010 | } | ||
1011 | spin_unlock(&portdev->cvq_lock); | ||
1012 | } | ||
1013 | |||
1014 | static void in_intr(struct virtqueue *vq) | ||
177 | { | 1015 | { |
178 | if (hvc_poll(hvc)) | 1016 | struct port *port; |
1017 | unsigned long flags; | ||
1018 | |||
1019 | port = find_port_by_vq(vq->vdev->priv, vq); | ||
1020 | if (!port) | ||
1021 | return; | ||
1022 | |||
1023 | spin_lock_irqsave(&port->inbuf_lock, flags); | ||
1024 | if (!port->inbuf) | ||
1025 | port->inbuf = get_inbuf(port); | ||
1026 | |||
1027 | /* | ||
1028 | * Don't queue up data when port is closed. This condition | ||
1029 | * can be reached when a console port is not yet connected (no | ||
1030 | * tty is spawned) and the host sends out data to console | ||
1031 | * ports. For generic serial ports, the host won't | ||
1032 | * (shouldn't) send data till the guest is connected. | ||
1033 | */ | ||
1034 | if (!port->guest_connected) | ||
1035 | discard_port_data(port); | ||
1036 | |||
1037 | spin_unlock_irqrestore(&port->inbuf_lock, flags); | ||
1038 | |||
1039 | wake_up_interruptible(&port->waitqueue); | ||
1040 | |||
1041 | if (is_console_port(port) && hvc_poll(port->cons.hvc)) | ||
179 | hvc_kick(); | 1042 | hvc_kick(); |
180 | } | 1043 | } |
181 | 1044 | ||
182 | /*D:370 Once we're further in boot, we get probed like any other virtio device. | 1045 | static void control_intr(struct virtqueue *vq) |
183 | * At this stage we set up the output virtqueue. | 1046 | { |
184 | * | 1047 | struct ports_device *portdev; |
185 | * To set up and manage our virtual console, we call hvc_alloc(). Since we | 1048 | |
186 | * never remove the console device we never need this pointer again. | 1049 | portdev = vq->vdev->priv; |
1050 | schedule_work(&portdev->control_work); | ||
1051 | } | ||
1052 | |||
1053 | static void config_intr(struct virtio_device *vdev) | ||
1054 | { | ||
1055 | struct ports_device *portdev; | ||
1056 | |||
1057 | portdev = vdev->priv; | ||
1058 | if (use_multiport(portdev)) { | ||
1059 | /* Handle port hot-add */ | ||
1060 | schedule_work(&portdev->config_work); | ||
1061 | } | ||
1062 | /* | ||
1063 | * We'll use this way of resizing only for legacy support. | ||
1064 | * For newer userspace (VIRTIO_CONSOLE_F_MULTPORT+), use | ||
1065 | * control messages to indicate console size changes so that | ||
1066 | * it can be done per-port | ||
1067 | */ | ||
1068 | resize_console(find_port_by_id(portdev, 0)); | ||
1069 | } | ||
1070 | |||
1071 | static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock) | ||
1072 | { | ||
1073 | struct port_buffer *buf; | ||
1074 | unsigned int nr_added_bufs; | ||
1075 | int ret; | ||
1076 | |||
1077 | nr_added_bufs = 0; | ||
1078 | do { | ||
1079 | buf = alloc_buf(PAGE_SIZE); | ||
1080 | if (!buf) | ||
1081 | break; | ||
1082 | |||
1083 | spin_lock_irq(lock); | ||
1084 | ret = add_inbuf(vq, buf); | ||
1085 | if (ret < 0) { | ||
1086 | spin_unlock_irq(lock); | ||
1087 | free_buf(buf); | ||
1088 | break; | ||
1089 | } | ||
1090 | nr_added_bufs++; | ||
1091 | spin_unlock_irq(lock); | ||
1092 | } while (ret > 0); | ||
1093 | |||
1094 | return nr_added_bufs; | ||
1095 | } | ||
1096 | |||
1097 | static int add_port(struct ports_device *portdev, u32 id) | ||
1098 | { | ||
1099 | char debugfs_name[16]; | ||
1100 | struct port *port; | ||
1101 | struct port_buffer *buf; | ||
1102 | dev_t devt; | ||
1103 | unsigned int nr_added_bufs; | ||
1104 | int err; | ||
1105 | |||
1106 | port = kmalloc(sizeof(*port), GFP_KERNEL); | ||
1107 | if (!port) { | ||
1108 | err = -ENOMEM; | ||
1109 | goto fail; | ||
1110 | } | ||
1111 | |||
1112 | port->portdev = portdev; | ||
1113 | port->id = id; | ||
1114 | |||
1115 | port->name = NULL; | ||
1116 | port->inbuf = NULL; | ||
1117 | port->cons.hvc = NULL; | ||
1118 | |||
1119 | port->host_connected = port->guest_connected = false; | ||
1120 | |||
1121 | port->in_vq = portdev->in_vqs[port->id]; | ||
1122 | port->out_vq = portdev->out_vqs[port->id]; | ||
1123 | |||
1124 | cdev_init(&port->cdev, &port_fops); | ||
1125 | |||
1126 | devt = MKDEV(portdev->chr_major, id); | ||
1127 | err = cdev_add(&port->cdev, devt, 1); | ||
1128 | if (err < 0) { | ||
1129 | dev_err(&port->portdev->vdev->dev, | ||
1130 | "Error %d adding cdev for port %u\n", err, id); | ||
1131 | goto free_port; | ||
1132 | } | ||
1133 | port->dev = device_create(pdrvdata.class, &port->portdev->vdev->dev, | ||
1134 | devt, port, "vport%up%u", | ||
1135 | port->portdev->drv_index, id); | ||
1136 | if (IS_ERR(port->dev)) { | ||
1137 | err = PTR_ERR(port->dev); | ||
1138 | dev_err(&port->portdev->vdev->dev, | ||
1139 | "Error %d creating device for port %u\n", | ||
1140 | err, id); | ||
1141 | goto free_cdev; | ||
1142 | } | ||
1143 | |||
1144 | spin_lock_init(&port->inbuf_lock); | ||
1145 | init_waitqueue_head(&port->waitqueue); | ||
1146 | |||
1147 | /* Fill the in_vq with buffers so the host can send us data. */ | ||
1148 | nr_added_bufs = fill_queue(port->in_vq, &port->inbuf_lock); | ||
1149 | if (!nr_added_bufs) { | ||
1150 | dev_err(port->dev, "Error allocating inbufs\n"); | ||
1151 | err = -ENOMEM; | ||
1152 | goto free_device; | ||
1153 | } | ||
1154 | |||
1155 | /* | ||
1156 | * If we're not using multiport support, this has to be a console port | ||
1157 | */ | ||
1158 | if (!use_multiport(port->portdev)) { | ||
1159 | err = init_port_console(port); | ||
1160 | if (err) | ||
1161 | goto free_inbufs; | ||
1162 | } | ||
1163 | |||
1164 | spin_lock_irq(&portdev->ports_lock); | ||
1165 | list_add_tail(&port->list, &port->portdev->ports); | ||
1166 | spin_unlock_irq(&portdev->ports_lock); | ||
1167 | |||
1168 | /* | ||
1169 | * Tell the Host we're set so that it can send us various | ||
1170 | * configuration parameters for this port (eg, port name, | ||
1171 | * caching, whether this is a console port, etc.) | ||
1172 | */ | ||
1173 | send_control_msg(port, VIRTIO_CONSOLE_PORT_READY, 1); | ||
1174 | |||
1175 | if (pdrvdata.debugfs_dir) { | ||
1176 | /* | ||
1177 | * Finally, create the debugfs file that we can use to | ||
1178 | * inspect a port's state at any time | ||
1179 | */ | ||
1180 | sprintf(debugfs_name, "vport%up%u", | ||
1181 | port->portdev->drv_index, id); | ||
1182 | port->debugfs_file = debugfs_create_file(debugfs_name, 0444, | ||
1183 | pdrvdata.debugfs_dir, | ||
1184 | port, | ||
1185 | &port_debugfs_ops); | ||
1186 | } | ||
1187 | return 0; | ||
1188 | |||
1189 | free_inbufs: | ||
1190 | while ((buf = port->in_vq->vq_ops->detach_unused_buf(port->in_vq))) | ||
1191 | free_buf(buf); | ||
1192 | free_device: | ||
1193 | device_destroy(pdrvdata.class, port->dev->devt); | ||
1194 | free_cdev: | ||
1195 | cdev_del(&port->cdev); | ||
1196 | free_port: | ||
1197 | kfree(port); | ||
1198 | fail: | ||
1199 | return err; | ||
1200 | } | ||
1201 | |||
1202 | /* | ||
1203 | * The workhandler for config-space updates. | ||
187 | * | 1204 | * |
188 | * Finally we put our input buffer in the input queue, ready to receive. */ | 1205 | * This is called when ports are hot-added. |
189 | static int __devinit virtcons_probe(struct virtio_device *dev) | 1206 | */ |
1207 | static void config_work_handler(struct work_struct *work) | ||
1208 | { | ||
1209 | struct virtio_console_config virtconconf; | ||
1210 | struct ports_device *portdev; | ||
1211 | struct virtio_device *vdev; | ||
1212 | int err; | ||
1213 | |||
1214 | portdev = container_of(work, struct ports_device, config_work); | ||
1215 | |||
1216 | vdev = portdev->vdev; | ||
1217 | vdev->config->get(vdev, | ||
1218 | offsetof(struct virtio_console_config, nr_ports), | ||
1219 | &virtconconf.nr_ports, | ||
1220 | sizeof(virtconconf.nr_ports)); | ||
1221 | |||
1222 | if (portdev->config.nr_ports == virtconconf.nr_ports) { | ||
1223 | /* | ||
1224 | * Port 0 got hot-added. Since we already did all the | ||
1225 | * other initialisation for it, just tell the Host | ||
1226 | * that the port is ready if we find the port. In | ||
1227 | * case the port was hot-removed earlier, we call | ||
1228 | * add_port to add the port. | ||
1229 | */ | ||
1230 | struct port *port; | ||
1231 | |||
1232 | port = find_port_by_id(portdev, 0); | ||
1233 | if (!port) | ||
1234 | add_port(portdev, 0); | ||
1235 | else | ||
1236 | send_control_msg(port, VIRTIO_CONSOLE_PORT_READY, 1); | ||
1237 | return; | ||
1238 | } | ||
1239 | if (virtconconf.nr_ports > portdev->config.max_nr_ports) { | ||
1240 | dev_warn(&vdev->dev, | ||
1241 | "More ports specified (%u) than allowed (%u)", | ||
1242 | portdev->config.nr_ports + 1, | ||
1243 | portdev->config.max_nr_ports); | ||
1244 | return; | ||
1245 | } | ||
1246 | if (virtconconf.nr_ports < portdev->config.nr_ports) | ||
1247 | return; | ||
1248 | |||
1249 | /* Hot-add ports */ | ||
1250 | while (virtconconf.nr_ports - portdev->config.nr_ports) { | ||
1251 | err = add_port(portdev, portdev->config.nr_ports); | ||
1252 | if (err) | ||
1253 | break; | ||
1254 | portdev->config.nr_ports++; | ||
1255 | } | ||
1256 | } | ||
1257 | |||
1258 | static int init_vqs(struct ports_device *portdev) | ||
190 | { | 1259 | { |
191 | vq_callback_t *callbacks[] = { hvc_handle_input, NULL}; | 1260 | vq_callback_t **io_callbacks; |
192 | const char *names[] = { "input", "output" }; | 1261 | char **io_names; |
193 | struct virtqueue *vqs[2]; | 1262 | struct virtqueue **vqs; |
1263 | u32 i, j, nr_ports, nr_queues; | ||
194 | int err; | 1264 | int err; |
195 | 1265 | ||
196 | vdev = dev; | 1266 | nr_ports = portdev->config.max_nr_ports; |
1267 | nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2; | ||
197 | 1268 | ||
198 | /* This is the scratch page we use to receive console input */ | 1269 | vqs = kmalloc(nr_queues * sizeof(struct virtqueue *), GFP_KERNEL); |
199 | inbuf = kmalloc(PAGE_SIZE, GFP_KERNEL); | 1270 | if (!vqs) { |
200 | if (!inbuf) { | ||
201 | err = -ENOMEM; | 1271 | err = -ENOMEM; |
202 | goto fail; | 1272 | goto fail; |
203 | } | 1273 | } |
1274 | io_callbacks = kmalloc(nr_queues * sizeof(vq_callback_t *), GFP_KERNEL); | ||
1275 | if (!io_callbacks) { | ||
1276 | err = -ENOMEM; | ||
1277 | goto free_vqs; | ||
1278 | } | ||
1279 | io_names = kmalloc(nr_queues * sizeof(char *), GFP_KERNEL); | ||
1280 | if (!io_names) { | ||
1281 | err = -ENOMEM; | ||
1282 | goto free_callbacks; | ||
1283 | } | ||
1284 | portdev->in_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *), | ||
1285 | GFP_KERNEL); | ||
1286 | if (!portdev->in_vqs) { | ||
1287 | err = -ENOMEM; | ||
1288 | goto free_names; | ||
1289 | } | ||
1290 | portdev->out_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *), | ||
1291 | GFP_KERNEL); | ||
1292 | if (!portdev->out_vqs) { | ||
1293 | err = -ENOMEM; | ||
1294 | goto free_invqs; | ||
1295 | } | ||
1296 | |||
1297 | /* | ||
1298 | * For backward compat (newer host but older guest), the host | ||
1299 | * spawns a console port first and also inits the vqs for port | ||
1300 | * 0 before others. | ||
1301 | */ | ||
1302 | j = 0; | ||
1303 | io_callbacks[j] = in_intr; | ||
1304 | io_callbacks[j + 1] = NULL; | ||
1305 | io_names[j] = "input"; | ||
1306 | io_names[j + 1] = "output"; | ||
1307 | j += 2; | ||
204 | 1308 | ||
1309 | if (use_multiport(portdev)) { | ||
1310 | io_callbacks[j] = control_intr; | ||
1311 | io_callbacks[j + 1] = NULL; | ||
1312 | io_names[j] = "control-i"; | ||
1313 | io_names[j + 1] = "control-o"; | ||
1314 | |||
1315 | for (i = 1; i < nr_ports; i++) { | ||
1316 | j += 2; | ||
1317 | io_callbacks[j] = in_intr; | ||
1318 | io_callbacks[j + 1] = NULL; | ||
1319 | io_names[j] = "input"; | ||
1320 | io_names[j + 1] = "output"; | ||
1321 | } | ||
1322 | } | ||
205 | /* Find the queues. */ | 1323 | /* Find the queues. */ |
206 | /* FIXME: This is why we want to wean off hvc: we do nothing | 1324 | err = portdev->vdev->config->find_vqs(portdev->vdev, nr_queues, vqs, |
207 | * when input comes in. */ | 1325 | io_callbacks, |
208 | err = vdev->config->find_vqs(vdev, 2, vqs, callbacks, names); | 1326 | (const char **)io_names); |
209 | if (err) | 1327 | if (err) |
1328 | goto free_outvqs; | ||
1329 | |||
1330 | j = 0; | ||
1331 | portdev->in_vqs[0] = vqs[0]; | ||
1332 | portdev->out_vqs[0] = vqs[1]; | ||
1333 | j += 2; | ||
1334 | if (use_multiport(portdev)) { | ||
1335 | portdev->c_ivq = vqs[j]; | ||
1336 | portdev->c_ovq = vqs[j + 1]; | ||
1337 | |||
1338 | for (i = 1; i < nr_ports; i++) { | ||
1339 | j += 2; | ||
1340 | portdev->in_vqs[i] = vqs[j]; | ||
1341 | portdev->out_vqs[i] = vqs[j + 1]; | ||
1342 | } | ||
1343 | } | ||
1344 | kfree(io_callbacks); | ||
1345 | kfree(io_names); | ||
1346 | kfree(vqs); | ||
1347 | |||
1348 | return 0; | ||
1349 | |||
1350 | free_names: | ||
1351 | kfree(io_names); | ||
1352 | free_callbacks: | ||
1353 | kfree(io_callbacks); | ||
1354 | free_outvqs: | ||
1355 | kfree(portdev->out_vqs); | ||
1356 | free_invqs: | ||
1357 | kfree(portdev->in_vqs); | ||
1358 | free_vqs: | ||
1359 | kfree(vqs); | ||
1360 | fail: | ||
1361 | return err; | ||
1362 | } | ||
1363 | |||
1364 | static const struct file_operations portdev_fops = { | ||
1365 | .owner = THIS_MODULE, | ||
1366 | }; | ||
1367 | |||
1368 | /* | ||
1369 | * Once we're further in boot, we get probed like any other virtio | ||
1370 | * device. | ||
1371 | * | ||
1372 | * If the host also supports multiple console ports, we check the | ||
1373 | * config space to see how many ports the host has spawned. We | ||
1374 | * initialize each port found. | ||
1375 | */ | ||
1376 | static int __devinit virtcons_probe(struct virtio_device *vdev) | ||
1377 | { | ||
1378 | struct ports_device *portdev; | ||
1379 | u32 i; | ||
1380 | int err; | ||
1381 | bool multiport; | ||
1382 | |||
1383 | portdev = kmalloc(sizeof(*portdev), GFP_KERNEL); | ||
1384 | if (!portdev) { | ||
1385 | err = -ENOMEM; | ||
1386 | goto fail; | ||
1387 | } | ||
1388 | |||
1389 | /* Attach this portdev to this virtio_device, and vice-versa. */ | ||
1390 | portdev->vdev = vdev; | ||
1391 | vdev->priv = portdev; | ||
1392 | |||
1393 | spin_lock_irq(&pdrvdata_lock); | ||
1394 | portdev->drv_index = pdrvdata.index++; | ||
1395 | spin_unlock_irq(&pdrvdata_lock); | ||
1396 | |||
1397 | portdev->chr_major = register_chrdev(0, "virtio-portsdev", | ||
1398 | &portdev_fops); | ||
1399 | if (portdev->chr_major < 0) { | ||
1400 | dev_err(&vdev->dev, | ||
1401 | "Error %d registering chrdev for device %u\n", | ||
1402 | portdev->chr_major, portdev->drv_index); | ||
1403 | err = portdev->chr_major; | ||
210 | goto free; | 1404 | goto free; |
1405 | } | ||
211 | 1406 | ||
212 | in_vq = vqs[0]; | 1407 | multiport = false; |
213 | out_vq = vqs[1]; | 1408 | portdev->config.nr_ports = 1; |
1409 | portdev->config.max_nr_ports = 1; | ||
1410 | if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT)) { | ||
1411 | multiport = true; | ||
1412 | vdev->features[0] |= 1 << VIRTIO_CONSOLE_F_MULTIPORT; | ||
214 | 1413 | ||
215 | /* Start using the new console output. */ | 1414 | vdev->config->get(vdev, offsetof(struct virtio_console_config, |
216 | virtio_cons.get_chars = get_chars; | 1415 | nr_ports), |
217 | virtio_cons.put_chars = put_chars; | 1416 | &portdev->config.nr_ports, |
218 | virtio_cons.notifier_add = notifier_add_vio; | 1417 | sizeof(portdev->config.nr_ports)); |
219 | virtio_cons.notifier_del = notifier_del_vio; | 1418 | vdev->config->get(vdev, offsetof(struct virtio_console_config, |
220 | virtio_cons.notifier_hangup = notifier_del_vio; | 1419 | max_nr_ports), |
221 | 1420 | &portdev->config.max_nr_ports, | |
222 | /* The first argument of hvc_alloc() is the virtual console number, so | 1421 | sizeof(portdev->config.max_nr_ports)); |
223 | * we use zero. The second argument is the parameter for the | 1422 | if (portdev->config.nr_ports > portdev->config.max_nr_ports) { |
224 | * notification mechanism (like irq number). We currently leave this | 1423 | dev_warn(&vdev->dev, |
225 | * as zero, virtqueues have implicit notifications. | 1424 | "More ports (%u) specified than allowed (%u). Will init %u ports.", |
226 | * | 1425 | portdev->config.nr_ports, |
227 | * The third argument is a "struct hv_ops" containing the put_chars() | 1426 | portdev->config.max_nr_ports, |
228 | * get_chars(), notifier_add() and notifier_del() pointers. | 1427 | portdev->config.max_nr_ports); |
229 | * The final argument is the output buffer size: we can do any size, | 1428 | |
230 | * so we put PAGE_SIZE here. */ | 1429 | portdev->config.nr_ports = portdev->config.max_nr_ports; |
231 | hvc = hvc_alloc(0, 0, &virtio_cons, PAGE_SIZE); | 1430 | } |
232 | if (IS_ERR(hvc)) { | 1431 | } |
233 | err = PTR_ERR(hvc); | 1432 | |
234 | goto free_vqs; | 1433 | /* Let the Host know we support multiple ports.*/ |
1434 | vdev->config->finalize_features(vdev); | ||
1435 | |||
1436 | err = init_vqs(portdev); | ||
1437 | if (err < 0) { | ||
1438 | dev_err(&vdev->dev, "Error %d initializing vqs\n", err); | ||
1439 | goto free_chrdev; | ||
1440 | } | ||
1441 | |||
1442 | spin_lock_init(&portdev->ports_lock); | ||
1443 | INIT_LIST_HEAD(&portdev->ports); | ||
1444 | |||
1445 | if (multiport) { | ||
1446 | unsigned int nr_added_bufs; | ||
1447 | |||
1448 | spin_lock_init(&portdev->cvq_lock); | ||
1449 | INIT_WORK(&portdev->control_work, &control_work_handler); | ||
1450 | INIT_WORK(&portdev->config_work, &config_work_handler); | ||
1451 | |||
1452 | nr_added_bufs = fill_queue(portdev->c_ivq, &portdev->cvq_lock); | ||
1453 | if (!nr_added_bufs) { | ||
1454 | dev_err(&vdev->dev, | ||
1455 | "Error allocating buffers for control queue\n"); | ||
1456 | err = -ENOMEM; | ||
1457 | goto free_vqs; | ||
1458 | } | ||
235 | } | 1459 | } |
236 | 1460 | ||
237 | /* Register the input buffer the first time. */ | 1461 | for (i = 0; i < portdev->config.nr_ports; i++) |
238 | add_inbuf(); | 1462 | add_port(portdev, i); |
1463 | |||
1464 | /* Start using the new console output. */ | ||
1465 | early_put_chars = NULL; | ||
239 | return 0; | 1466 | return 0; |
240 | 1467 | ||
241 | free_vqs: | 1468 | free_vqs: |
242 | vdev->config->del_vqs(vdev); | 1469 | vdev->config->del_vqs(vdev); |
1470 | kfree(portdev->in_vqs); | ||
1471 | kfree(portdev->out_vqs); | ||
1472 | free_chrdev: | ||
1473 | unregister_chrdev(portdev->chr_major, "virtio-portsdev"); | ||
243 | free: | 1474 | free: |
244 | kfree(inbuf); | 1475 | kfree(portdev); |
245 | fail: | 1476 | fail: |
246 | return err; | 1477 | return err; |
247 | } | 1478 | } |
248 | 1479 | ||
1480 | static void virtcons_remove(struct virtio_device *vdev) | ||
1481 | { | ||
1482 | struct ports_device *portdev; | ||
1483 | struct port *port, *port2; | ||
1484 | struct port_buffer *buf; | ||
1485 | unsigned int len; | ||
1486 | |||
1487 | portdev = vdev->priv; | ||
1488 | |||
1489 | cancel_work_sync(&portdev->control_work); | ||
1490 | cancel_work_sync(&portdev->config_work); | ||
1491 | |||
1492 | list_for_each_entry_safe(port, port2, &portdev->ports, list) | ||
1493 | remove_port(port); | ||
1494 | |||
1495 | unregister_chrdev(portdev->chr_major, "virtio-portsdev"); | ||
1496 | |||
1497 | while ((buf = portdev->c_ivq->vq_ops->get_buf(portdev->c_ivq, &len))) | ||
1498 | free_buf(buf); | ||
1499 | |||
1500 | while ((buf = portdev->c_ivq->vq_ops->detach_unused_buf(portdev->c_ivq))) | ||
1501 | free_buf(buf); | ||
1502 | |||
1503 | vdev->config->del_vqs(vdev); | ||
1504 | kfree(portdev->in_vqs); | ||
1505 | kfree(portdev->out_vqs); | ||
1506 | |||
1507 | kfree(portdev); | ||
1508 | } | ||
1509 | |||
249 | static struct virtio_device_id id_table[] = { | 1510 | static struct virtio_device_id id_table[] = { |
250 | { VIRTIO_ID_CONSOLE, VIRTIO_DEV_ANY_ID }, | 1511 | { VIRTIO_ID_CONSOLE, VIRTIO_DEV_ANY_ID }, |
251 | { 0 }, | 1512 | { 0 }, |
@@ -253,6 +1514,7 @@ static struct virtio_device_id id_table[] = { | |||
253 | 1514 | ||
254 | static unsigned int features[] = { | 1515 | static unsigned int features[] = { |
255 | VIRTIO_CONSOLE_F_SIZE, | 1516 | VIRTIO_CONSOLE_F_SIZE, |
1517 | VIRTIO_CONSOLE_F_MULTIPORT, | ||
256 | }; | 1518 | }; |
257 | 1519 | ||
258 | static struct virtio_driver virtio_console = { | 1520 | static struct virtio_driver virtio_console = { |
@@ -262,14 +1524,41 @@ static struct virtio_driver virtio_console = { | |||
262 | .driver.owner = THIS_MODULE, | 1524 | .driver.owner = THIS_MODULE, |
263 | .id_table = id_table, | 1525 | .id_table = id_table, |
264 | .probe = virtcons_probe, | 1526 | .probe = virtcons_probe, |
265 | .config_changed = virtcons_apply_config, | 1527 | .remove = virtcons_remove, |
1528 | .config_changed = config_intr, | ||
266 | }; | 1529 | }; |
267 | 1530 | ||
268 | static int __init init(void) | 1531 | static int __init init(void) |
269 | { | 1532 | { |
1533 | int err; | ||
1534 | |||
1535 | pdrvdata.class = class_create(THIS_MODULE, "virtio-ports"); | ||
1536 | if (IS_ERR(pdrvdata.class)) { | ||
1537 | err = PTR_ERR(pdrvdata.class); | ||
1538 | pr_err("Error %d creating virtio-ports class\n", err); | ||
1539 | return err; | ||
1540 | } | ||
1541 | |||
1542 | pdrvdata.debugfs_dir = debugfs_create_dir("virtio-ports", NULL); | ||
1543 | if (!pdrvdata.debugfs_dir) { | ||
1544 | pr_warning("Error %ld creating debugfs dir for virtio-ports\n", | ||
1545 | PTR_ERR(pdrvdata.debugfs_dir)); | ||
1546 | } | ||
1547 | INIT_LIST_HEAD(&pdrvdata.consoles); | ||
1548 | |||
270 | return register_virtio_driver(&virtio_console); | 1549 | return register_virtio_driver(&virtio_console); |
271 | } | 1550 | } |
1551 | |||
1552 | static void __exit fini(void) | ||
1553 | { | ||
1554 | unregister_virtio_driver(&virtio_console); | ||
1555 | |||
1556 | class_destroy(pdrvdata.class); | ||
1557 | if (pdrvdata.debugfs_dir) | ||
1558 | debugfs_remove_recursive(pdrvdata.debugfs_dir); | ||
1559 | } | ||
272 | module_init(init); | 1560 | module_init(init); |
1561 | module_exit(fini); | ||
273 | 1562 | ||
274 | MODULE_DEVICE_TABLE(virtio, id_table); | 1563 | MODULE_DEVICE_TABLE(virtio, id_table); |
275 | MODULE_DESCRIPTION("Virtio console driver"); | 1564 | MODULE_DESCRIPTION("Virtio console driver"); |
diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c index 994e1a58b987..8b24729fec89 100644 --- a/drivers/char/vme_scc.c +++ b/drivers/char/vme_scc.c | |||
@@ -136,7 +136,7 @@ static const struct tty_port_operations scc_port_ops = { | |||
136 | * vme_scc_init() and support functions | 136 | * vme_scc_init() and support functions |
137 | *---------------------------------------------------------------------------*/ | 137 | *---------------------------------------------------------------------------*/ |
138 | 138 | ||
139 | static int scc_init_drivers(void) | 139 | static int __init scc_init_drivers(void) |
140 | { | 140 | { |
141 | int error; | 141 | int error; |
142 | 142 | ||
@@ -172,7 +172,7 @@ static int scc_init_drivers(void) | |||
172 | /* ports[] array is indexed by line no (i.e. [0] for ttyS0, [1] for ttyS1). | 172 | /* ports[] array is indexed by line no (i.e. [0] for ttyS0, [1] for ttyS1). |
173 | */ | 173 | */ |
174 | 174 | ||
175 | static void scc_init_portstructs(void) | 175 | static void __init scc_init_portstructs(void) |
176 | { | 176 | { |
177 | struct scc_port *port; | 177 | struct scc_port *port; |
178 | int i; | 178 | int i; |
@@ -195,7 +195,7 @@ static void scc_init_portstructs(void) | |||
195 | 195 | ||
196 | 196 | ||
197 | #ifdef CONFIG_MVME147_SCC | 197 | #ifdef CONFIG_MVME147_SCC |
198 | static int mvme147_scc_init(void) | 198 | static int __init mvme147_scc_init(void) |
199 | { | 199 | { |
200 | struct scc_port *port; | 200 | struct scc_port *port; |
201 | int error; | 201 | int error; |
@@ -298,7 +298,7 @@ fail: | |||
298 | 298 | ||
299 | 299 | ||
300 | #ifdef CONFIG_MVME162_SCC | 300 | #ifdef CONFIG_MVME162_SCC |
301 | static int mvme162_scc_init(void) | 301 | static int __init mvme162_scc_init(void) |
302 | { | 302 | { |
303 | struct scc_port *port; | 303 | struct scc_port *port; |
304 | int error; | 304 | int error; |
@@ -404,7 +404,7 @@ fail: | |||
404 | 404 | ||
405 | 405 | ||
406 | #ifdef CONFIG_BVME6000_SCC | 406 | #ifdef CONFIG_BVME6000_SCC |
407 | static int bvme6000_scc_init(void) | 407 | static int __init bvme6000_scc_init(void) |
408 | { | 408 | { |
409 | struct scc_port *port; | 409 | struct scc_port *port; |
410 | int error; | 410 | int error; |
@@ -503,7 +503,7 @@ fail_free_b_rx: | |||
503 | #endif | 503 | #endif |
504 | 504 | ||
505 | 505 | ||
506 | static int vme_scc_init(void) | 506 | static int __init vme_scc_init(void) |
507 | { | 507 | { |
508 | int res = -ENODEV; | 508 | int res = -ENODEV; |
509 | 509 | ||
diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 50faa1fb0f06..bd1d1164fec5 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c | |||
@@ -821,7 +821,7 @@ static inline int resize_screen(struct vc_data *vc, int width, int height, | |||
821 | * | 821 | * |
822 | * Resize a virtual console, clipping according to the actual constraints. | 822 | * Resize a virtual console, clipping according to the actual constraints. |
823 | * If the caller passes a tty structure then update the termios winsize | 823 | * If the caller passes a tty structure then update the termios winsize |
824 | * information and perform any neccessary signal handling. | 824 | * information and perform any necessary signal handling. |
825 | * | 825 | * |
826 | * Caller must hold the console semaphore. Takes the termios mutex and | 826 | * Caller must hold the console semaphore. Takes the termios mutex and |
827 | * ctrl_lock of the tty IFF a tty is passed. | 827 | * ctrl_lock of the tty IFF a tty is passed. |
@@ -2119,8 +2119,6 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co | |||
2119 | uint8_t inverse; | 2119 | uint8_t inverse; |
2120 | uint8_t width; | 2120 | uint8_t width; |
2121 | u16 himask, charmask; | 2121 | u16 himask, charmask; |
2122 | const unsigned char *orig_buf = NULL; | ||
2123 | int orig_count; | ||
2124 | 2122 | ||
2125 | if (in_interrupt()) | 2123 | if (in_interrupt()) |
2126 | return count; | 2124 | return count; |
@@ -2142,8 +2140,6 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co | |||
2142 | release_console_sem(); | 2140 | release_console_sem(); |
2143 | return 0; | 2141 | return 0; |
2144 | } | 2142 | } |
2145 | orig_buf = buf; | ||
2146 | orig_count = count; | ||
2147 | 2143 | ||
2148 | himask = vc->vc_hi_font_mask; | 2144 | himask = vc->vc_hi_font_mask; |
2149 | charmask = himask ? 0x1ff : 0xff; | 2145 | charmask = himask ? 0x1ff : 0xff; |
diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c index 6aa10284104a..87778dcf8727 100644 --- a/drivers/char/vt_ioctl.c +++ b/drivers/char/vt_ioctl.c | |||
@@ -888,7 +888,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, | |||
888 | ret = -EFAULT; | 888 | ret = -EFAULT; |
889 | goto out; | 889 | goto out; |
890 | } | 890 | } |
891 | if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS) { | 891 | if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS && tmp.mode != VT_PROCESS_AUTO) { |
892 | ret = -EINVAL; | 892 | ret = -EINVAL; |
893 | goto out; | 893 | goto out; |
894 | } | 894 | } |
@@ -1622,7 +1622,7 @@ static void complete_change_console(struct vc_data *vc) | |||
1622 | * telling it that it has acquired. Also check if it has died and | 1622 | * telling it that it has acquired. Also check if it has died and |
1623 | * clean up (similar to logic employed in change_console()) | 1623 | * clean up (similar to logic employed in change_console()) |
1624 | */ | 1624 | */ |
1625 | if (vc->vt_mode.mode == VT_PROCESS) { | 1625 | if (vc->vt_mode.mode == VT_PROCESS || vc->vt_mode.mode == VT_PROCESS_AUTO) { |
1626 | /* | 1626 | /* |
1627 | * Send the signal as privileged - kill_pid() will | 1627 | * Send the signal as privileged - kill_pid() will |
1628 | * tell us if the process has gone or something else | 1628 | * tell us if the process has gone or something else |
@@ -1682,7 +1682,7 @@ void change_console(struct vc_data *new_vc) | |||
1682 | * vt to auto control. | 1682 | * vt to auto control. |
1683 | */ | 1683 | */ |
1684 | vc = vc_cons[fg_console].d; | 1684 | vc = vc_cons[fg_console].d; |
1685 | if (vc->vt_mode.mode == VT_PROCESS) { | 1685 | if (vc->vt_mode.mode == VT_PROCESS || vc->vt_mode.mode == VT_PROCESS_AUTO) { |
1686 | /* | 1686 | /* |
1687 | * Send the signal as privileged - kill_pid() will | 1687 | * Send the signal as privileged - kill_pid() will |
1688 | * tell us if the process has gone or something else | 1688 | * tell us if the process has gone or something else |
@@ -1693,27 +1693,28 @@ void change_console(struct vc_data *new_vc) | |||
1693 | */ | 1693 | */ |
1694 | vc->vt_newvt = new_vc->vc_num; | 1694 | vc->vt_newvt = new_vc->vc_num; |
1695 | if (kill_pid(vc->vt_pid, vc->vt_mode.relsig, 1) == 0) { | 1695 | if (kill_pid(vc->vt_pid, vc->vt_mode.relsig, 1) == 0) { |
1696 | if(vc->vt_mode.mode == VT_PROCESS) | ||
1697 | /* | ||
1698 | * It worked. Mark the vt to switch to and | ||
1699 | * return. The process needs to send us a | ||
1700 | * VT_RELDISP ioctl to complete the switch. | ||
1701 | */ | ||
1702 | return; | ||
1703 | } else { | ||
1696 | /* | 1704 | /* |
1697 | * It worked. Mark the vt to switch to and | 1705 | * The controlling process has died, so we revert back to |
1698 | * return. The process needs to send us a | 1706 | * normal operation. In this case, we'll also change back |
1699 | * VT_RELDISP ioctl to complete the switch. | 1707 | * to KD_TEXT mode. I'm not sure if this is strictly correct |
1708 | * but it saves the agony when the X server dies and the screen | ||
1709 | * remains blanked due to KD_GRAPHICS! It would be nice to do | ||
1710 | * this outside of VT_PROCESS but there is no single process | ||
1711 | * to account for and tracking tty count may be undesirable. | ||
1700 | */ | 1712 | */ |
1701 | return; | 1713 | reset_vc(vc); |
1702 | } | 1714 | } |
1703 | 1715 | ||
1704 | /* | 1716 | /* |
1705 | * The controlling process has died, so we revert back to | 1717 | * Fall through to normal (VT_AUTO and VT_PROCESS_AUTO) handling of the switch... |
1706 | * normal operation. In this case, we'll also change back | ||
1707 | * to KD_TEXT mode. I'm not sure if this is strictly correct | ||
1708 | * but it saves the agony when the X server dies and the screen | ||
1709 | * remains blanked due to KD_GRAPHICS! It would be nice to do | ||
1710 | * this outside of VT_PROCESS but there is no single process | ||
1711 | * to account for and tracking tty count may be undesirable. | ||
1712 | */ | ||
1713 | reset_vc(vc); | ||
1714 | |||
1715 | /* | ||
1716 | * Fall through to normal (VT_AUTO) handling of the switch... | ||
1717 | */ | 1718 | */ |
1718 | } | 1719 | } |
1719 | 1720 | ||