aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/generic.c
Commit message (Collapse)AuthorAgeFilesLines
* USB: serial: fix race in generic writeJohan Hovold2014-01-031-8/+1
| | | | | | | | | | | | | | | | | | | | | | commit 6f6485463aada1ec6a0f3db6a03eb8e393d6bb55 upstream. Fix race in generic write implementation, which could lead to temporarily degraded throughput. The current generic write implementation introduced by commit 27c7acf22047 ("USB: serial: reimplement generic fifo-based writes") has always had this bug, although it's fairly hard to trigger and the consequences are not likely to be noticed. Specifically, a write() on one CPU while the completion handler is running on another could result in only one of the two write urbs being utilised to empty the remainder of the write fifo (unless there is a second write() that doesn't race during that time). Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> [bwh: Backported to 3.2: deleted code is a bit different] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
* USB: serial: fix console error reportingJohan Hovold2012-04-021-1/+3
| | | | | | | | | | | | commit 548dd4b6da8a8e428453d55f7fa7b8a46498d147 upstream. Do not report errors in write path if port is used as a console as this may trigger the same error (and error report) resulting in a loop. Reported-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* USB: serial: handle Data Carrier Detect changesLibor Pechacek2011-01-221-0/+20
| | | | | | | | | | | | | | | | | Alan's commit 335f8514f200e63d689113d29cb7253a5c282967 introduced .carrier_raised function in several drivers. That also means tty_port_block_til_ready can now suspend the process trying to open the serial port when Carrier Detect is low and put it into tty_port.open_wait queue. We need to wake up the process when Carrier Detect goes high and trigger TTY hangup when CD goes low. Some of the devices do not report modem status line changes, or at least we don't understand the status message, so for those we remove .carrier_raised again. Signed-off-by: Libor Pechacek <lpechacek@suse.cz> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* Merge branch 'for-linus' of ↵Linus Torvalds2010-08-281-6/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: Input: pxa27x_keypad - remove input_free_device() in pxa27x_keypad_remove() Input: mousedev - fix regression of inverting axes Input: uinput - add devname alias to allow module on-demand load Input: hil_kbd - fix compile error USB: drop tty argument from usb_serial_handle_sysrq_char() Input: sysrq - drop tty argument form handle_sysrq() Input: sysrq - drop tty argument from sysrq ops handlers
| * USB: drop tty argument from usb_serial_handle_sysrq_char()Dmitry Torokhov2010-08-211-5/+3
| | | | | | | | | | | | | | | | | | | | Since handle_sysrq() does not take tty as argument anymore we can drop it from usb_serial_handle_sysrq_char() as well. Acked-by: Alan Cox <alan@lxorguk.ukuu.org.uk> Acked-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
| * Input: sysrq - drop tty argument form handle_sysrq()Dmitry Torokhov2010-08-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sysrq operations do not accept tty argument anymore so no need to pass it to us. [Stephen Rothwell <sfr@canb.auug.org.au>: fix build breakage in drm code caused by sysrq using bool but not including linux/types.h] [Sachin Sant <sachinp@in.ibm.com>: fix build breakage in s390 keyboadr driver] Acked-by: Alan Cox <alan@lxorguk.ukuu.org.uk> Acked-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
* | USB: serial: export symbol usb_serial_generic_disconnectBill Pemberton2010-08-231-0/+1
|/ | | | | | | | This is needed by the ssu100 driver to use this function. Signed-off-by: Bill Pemberton <wfp5p@virginia.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: fix stalled writesJohan Hovold2010-08-101-5/+10
| | | | | | | | | | | | | | | | | | | | As David VomLehn points out, it was possible to receive an interrupt before clearing the free-urb flag which could lead to the urb being incorrectly marked as busy. For the same reason, move tx_bytes accounting so that it will never be negative. Note that the free-flags set and clear operations do not need any additional locking as they are manipulated while USB_SERIAL_WRITE_BUSY is set. Reported-by: David VomLehn <dvomlehn@cisco.com> Tested-by: David VomLehn <dvomlehn@cisco.com> Signed-off-by: Johan Hovold <jhovold@gmail.com> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: add special case for processing of empty read urbsJohan Hovold2010-05-201-0/+3
| | | | | | | | Return immediately from generic process_read_urb if urb is empty. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: remove multi-urb write from generic driverJohan Hovold2010-05-201-128/+22
| | | | | | | | | | | | | | | | | | | Remove multi-urb write from the generic driver and simplify the prepare_write_buffer prototype: int (*prepare_write_buffer)(struct usb_serial_port *port, void *dest, size_t size); The default implementation simply fills dest with data from port write fifo but drivers can override it if they need to process the outgoing data (e.g. add headers). Turn ftdi_sio into a generic fifo-based driver, which lowers CPU usage significantly for small writes while retaining maximum throughput. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: reimplement generic fifo-based writesJohan Hovold2010-05-201-20/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Reimplement fifo-based writes in the generic driver using a multiple pre-allocated urb scheme. In contrast to multi-urb writes, no allocations (of urbs or buffers) are made during run-time and there is less pressure on the host stack queues as currently only two urbs are used (implementation is generic and can handle more than two urbs as well, though). Initial tests using ftdi_sio show that the implementation achieves the same (maximum) throughput at high baudrates as multi-urb writes. The CPU usage is much lower than for multi-urb writes for small write requests and only slightly higher for large (e.g. 2k) requests (due to extra copy via fifo?). Also outperforms multi-urb writes for small write requests on an embedded arm-9 system, where multi-urb writes are CPU-bound at high baudrates (perf reveals that a lot of time is spent in the host stack enqueue function -- could perhaps be a bug as well). Keeping the original write_urb, buffer and flag for now as there are other drivers depending on them. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: generalise write buffer preparationJohan Hovold2010-05-201-13/+34
| | | | | | | | | | | | | | | | | | | | | | | | | Generalise write buffer preparation. This allows for drivers to manipulate (e.g. add headers) to bulk out data before it is sent. This adds a new function pointer to usb_serial_driver: int (*prepare_write_buffer)(struct usb_serial_port *port, void **dest, size_t size, const void *src, size_t count); The function is generic and can be used with either kfifo-based or multi-urb writes: If *dest is NULL the implementation should allocate dest. If src is NULL the implementation should use the port write fifo. If not set, a generic implementation is used which simply uses memcpy or kfifo_out. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: re-implement multi-urb writes in generic driverJohan Hovold2010-05-201-76/+56
| | | | | | | | | | | | | | | | Use dynamic transfer buffer sizes since it is more efficient to let the host controller do the partitioning to fit endpoint size. This way we also do not use more than one urb per write request. Replace max_in_flight_urbs with multi_urb_write flag in struct usb_serial_driver to enable multi-urb writes. Use MAX_TX_URBS=40 and a max buffer size of PAGE_SIZE to prevent DoS attacks. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: allow custom multi-urb write bulk callbacksJohan Hovold2010-05-201-1/+1
| | | | | | | | | Allow drivers to implement their own multi-urb write bulk callbacks as we do for single urb writes. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: clean up generic write start busy testJohan Hovold2010-05-201-11/+4
| | | | | | | | Submit write urb if it is not already in use and we have buffered data. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: clean up some error and debug messages in generic driverJohan Hovold2010-05-201-9/+4
| | | | | | | | | Clean up error messages on usb_submit_urb failure. Remove debug message on zero-length writes. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: export generic throttle and unthrottleJohan Hovold2010-05-201-0/+2
| | | | | | | | | | | | Allow drivers to use the generic throttle and unthrottle implementation. This makes sense for drivers using the generic read functionality. Note that drivers need to set these explicitly in order to enable them (i.e., we do not set them at port probe if not defined). Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: generalise generic read implementationJohan Hovold2010-05-201-2/+3
| | | | | | | | | | | | | | Add process_read_urb to usb_serial_driver so that a driver can rely on the generic read (and throttle) mechanism but still do device specific processing of incoming data (such as adding tty_flags before pushing to line discipline). The default generic implementation handles sysrq for consoles but otherwise simply pushes to tty. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: clean up read processing in generic driverJohan Hovold2010-05-201-16/+11
| | | | | | | | | | | | | | | | | Always process and flush read urb, but only resubmit when not throttled. The new tty-layer supply plenty of slack so there is really no need to cache and delay processing of a single urb while throttled. Note that unthrottle now submits using GFP_KERNEL as we are not in atomic context (so there is no need to save irq state either). Note also that the process_read_urb function could be added to usb_serial_driver should any driver need to do any device specific processing. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: remove unnecessary re-initialisation of generic urbsJohan Hovold2010-05-201-23/+2
| | | | | | | | | | The generic read and write bulk urbs are initialised when allocated in usb_serial_probe. The only field that needs to be updated after that is the transfer_buffer_length of the write urb. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: refactor read urb submission in generic driverJohan Hovold2010-05-201-24/+8
| | | | | | | | | | | | Use the already exported function for submitting the read urb associated with a usb_serial_port. Make sure it returns the result of usb_submit_urb and rename to the more descriptive usb_serial_generic_submit_read_urb. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: refactor generic closeJohan Hovold2010-05-201-0/+1
| | | | | | | | | Export usb_serial_generic_close so that drivers can easily kill the read and write urb and make sure that the write fifo is reset. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: clear fifo on closeJohan Hovold2010-05-201-1/+7
| | | | | | | | Make sure fifo is emptied on close. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: fix missing locking on fifo in write callbackJohan Hovold2010-05-201-2/+5
| | | | | | | | | | | | On errors the fifo was reset without any locking. This could race with write which do kfifo_put and perhaps also chars_in_buffer and write_room. Every other access to the fifo is protected using the port lock so better add it to the error path as well. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: fix generic chars_in_bufferJohan Hovold2010-05-201-4/+11
| | | | | | | | | | | | Make sure chars_in_buffer accounts also for data in host stack queues. This fixes the problem with tty_wait_until_sent returning too soon at close which could cause the final write urb to be cancelled. Reported-by: Pete Zaitcev <zaitcev@redhat.com> Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* usb: fix serial build when SYSRQ is disabledRandy Dunlap2010-05-201-0/+9
| | | | | | | | | | Fix build error when CONFIG_MAGIC_SYSRQ is not enabled: drivers/usb/serial/generic.c:566: error: implicit declaration of function 'handle_sysrq' Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* usb-serial: Use tty_port version console instead of usb_serial_portJason Wessel2010-05-201-2/+2
| | | | | | | | | | | | | | | Replace all instances of using the console variable in struct usb_serial_port with the struct tty_port version. CC: Alan Cox <alan@linux.intel.com> CC: Alan Stern <stern@rowland.harvard.edu> CC: Oliver Neukum <oliver@neukum.org> CC: Andrew Morton <akpm@linux-foundation.org> CC: linux-usb@vger.kernel.org CC: linux-kernel@vger.kernel.org Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: use port endpoint size to determine if ep is availableJohan Hovold2010-03-191-11/+19
| | | | | | | | | | | | | | | | | | It is possible to have a multi-port device with a port lacking an in or out bulk endpoint. Only checking for num_bulk_in or num_bulk_out is thus not sufficient to determine whether a specific port has an in or out bulk endpoint. This fixes potential null pointer dereferences in the generic open and write routines, as well as access to uninitialised fifo in write_room and chars_in_buffer. Also let write fail with ENODEV (instead of 0) on missing out endpoint (also on zero-length writes). Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: fix softint not being called on errorsJohan Hovold2010-03-191-10/+5
| | | | | | | | | Make sure usb_serial_port_softint is called on errors also when using multi urb writes. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: fix error message on close in generic driverJohan Hovold2010-03-191-1/+3
| | | | | | | | | Resubmitting read urb fails with -EPERM if completion handler runs while urb is being killed on close. This should not be reported as an error. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: remove references to port->port.count from the serial driversAlan Stern2010-03-021-1/+2
| | | | | | | | | | | | This patch (as1344) removes references to port->port.count from the USB serial drivers. Now that serial ports are properly reference counted, port.count checking is unnecessary and incorrect. Drivers should assume that the port is in use from the time the open method runs until the close method is called. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: Remove unnecessary \n's from dbg usesJoe Perches2010-03-021-1/+1
| | | | | | | | | #define dbg adds the newline, messages shouldn't. Converted dbg("%s", "some string") to dbg("some string") Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB serial: make USB device id constantNémeth Márton2010-03-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The id_table field of the struct usb_device_id is constant in <linux/usb.h> so it is worth to make the initialization data also constant. The semantic match that finds this kind of pattern is as follows: (http://coccinelle.lip6.fr/) // <smpl> @r@ disable decl_init,const_decl_init; identifier I1, I2, x; @@ struct I1 { ... const struct I2 *x; ... }; @s@ identifier r.I1, y; identifier r.x, E; @@ struct I1 y = { .x = E, }; @c@ identifier r.I2; identifier s.E; @@ const struct I2 E[] = ... ; @depends on !c@ identifier r.I2; identifier s.E; @@ + const struct I2 E[] = ...; // </smpl> Signed-off-by: Németh Márton <nm127@freemail.hu> Cc: Julia Lawall <julia@diku.dk> Cc: cocci@diku.dk Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* usb: serial: fix memory leak in generic driverJohan Hovold2010-01-201-0/+2
| | | | | | | | | | | | | | | | | Fix a regression introduced by commit 715b1dc01fe44537e8fce9566e4bb48d6821d84b ("USB: usb_debug, usb_generic_serial: implement multi urb write"). URB transfer buffer was never freed when using multi-urb writes. Currently the only driver enabling multi-urb writes is usb_debug. Signed-off-by: Johan Hovold <jhovold@gmail.com> Cc: Greg KH <greg@kroah.com> Acked-by: Jason Wessel <jason.wessel@windriver.com> Cc: stable <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: fix USB serial fix kfifo_len lockingStefani Seibold2010-01-201-4/+4
| | | | | | | | | | | This patch fix a possible race bug in drivers/usb/serial/generic with the new kfifo API. Please apply it to the 2.6.33-rc* tree. Signed-off-by: Stefani Seibold <stefani@seibold.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* Fix usb_serial_probe() problem introduced by the recent kfifo changesStefani Seibold2009-12-231-6/+6
| | | | | | | | | | | | | | | The USB serial code was a new user of the kfifo API, and it was missed when porting things to the new kfifo API. Please make the write_fifo in place. Here is my patch to fix the regression and full ported version. Signed-off-by: Stefani Seibold <stefani@seibold.net> Reported-and-tested-by: Rafael J. Wysocki <rjw@sisk.pl> Cc: Greg KH <greg@kroah.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* kfifo: rename kfifo_put... into kfifo_in... and kfifo_get... into kfifo_out...Stefani Seibold2009-12-221-2/+2
| | | | | | | | | | | | | | | | | | | | rename kfifo_put... into kfifo_in... to prevent miss use of old non in kernel-tree drivers ditto for kfifo_get... -> kfifo_out... Improve the prototypes of kfifo_in and kfifo_out to make the kerneldoc annotations more readable. Add mini "howto porting to the new API" in kfifo.h Signed-off-by: Stefani Seibold <stefani@seibold.net> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com> Acked-by: Andi Kleen <ak@linux.intel.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* kfifo: cleanup namespaceStefani Seibold2009-12-221-2/+2
| | | | | | | | | | | | | change name of __kfifo_* functions to kfifo_*, because the prefix __kfifo should be reserved for internal functions only. Signed-off-by: Stefani Seibold <stefani@seibold.net> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com> Acked-by: Andi Kleen <ak@linux.intel.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* kfifo: move out spinlockStefani Seibold2009-12-221-2/+2
| | | | | | | | | | | | | | | Move the pointer to the spinlock out of struct kfifo. Most users in tree do not actually use a spinlock, so the few exceptions now have to call kfifo_{get,put}_locked, which takes an extra argument to a spinlock. Signed-off-by: Stefani Seibold <stefani@seibold.net> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com> Acked-by: Andi Kleen <ak@linux.intel.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* USB: Fix throttling in generic usbserial driverJoris van Rantwijk2009-10-091-1/+1
| | | | | | | | | | | | | | The generic usbserial driver in Linux 2.6.31 halts its receiving channel in response to throttle requests from the line discipline. Unfortunately it drops the contents of the first URB received after throttling takes effect. This patch corrects that problem. Signed-off-by: Joris van Rantwijk <jorispubl@xs4all.nl> Acked-by: Johan Hovold <jhovold@gmail.com> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: use kfifo to buffer usb-generic serial writesDavid VomLehn2009-09-231-81/+125
| | | | | | | | | | | | | | | | | | When do_output_char() attempts to write a carriage return/line feed sequence, it first checks to see how much buffer room is available. If there are at least two characters free, it will write the carriage return/line feed with two calls to tty_put_char(). It calls the tty_operation functions write() for devices that don't support the tty_operations function put_char(). If the USB generic serial device's write URB is not in use, it will return the buffer size when asked how much room is available. The write() of the carriage return will cause it to mark the write URB busy, so the subsequent write() of the line feed will be ignored. This patch uses the kfifo infrastructure to implement a write FIFO that accurately returns the amount of space available in the buffer. Signed-off-by: David VomLehn <dvomlehn@cisco.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* tty: USB does not need the filp argument in the driversAlan Cox2009-09-191-2/+1
| | | | | | | | And indeed none of them use it. Clean this up as it will make moving to a standard open method rather easier. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* tty: Fix USB kref leakAlan Cox2009-07-101-3/+4
| | | | | | | | | The sysrq code acquired a kref leak. Fix it by passing the tty separately from the caller (thus effectively using the callers kref which all the callers hold anyway) Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* tty: Sort out the USB sysrq changes that wrecked performanceAlan Cox2009-07-101-4/+11
| | | | | | | | We can't go around calling all sorts of magic per character functions at full rate 3G data speed. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* USB: usb-serial: replace shutdown with disconnect, releaseAlan Stern2009-06-151-2/+7
| | | | | | | | | | | | | | | | This patch (as1254) splits up the shutdown method of usb_serial_driver into a disconnect and a release method. The problem is that the usb-serial core was calling shutdown during disconnect handling, but drivers didn't expect it to be called until after all the open file references had been closed. The result was an oops when the close method tried to use memory that had been deallocated by shutdown. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: usb_serial: only allow sysrq on a console portJason Wessel2009-06-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The only time a sysrq should get processed is if the attached device is a console. This is intended to protect sysrq execution on a host connected with a terminal program. Here is the problem scenario: host A <-- rs232 link --> host B Host A is using mincom and a usb pl2303 device to connect to host b which is a linux system with a usb pl2303 device acting as the serial console. When host B is rebooted the pl2303 emits random junk characters on reset. These character sequences contain serial break signals most of the time and when translated to a sysrq have caused host A to get random processes killed, reboots or power down. It is true that in this setup with this patch host B might still have the same problem as host A if you reboot host A. In most cases host A is a development host which seldom gets rebooted, and you could turn off sysrq temporarily on host B if you need to reboot host A. Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: serial: usb_debug,usb_generic_serial: implement sysrq and serial breakJason Wessel2009-06-151-12/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | The usb_debug driver was modified to implement serial break handling by using a "magic" data packet comprised of the sequence: 0x00 0xff 0x01 0xfe 0x00 0xfe 0x01 0xff When the tty layer requests a serial break the usb_debug driver sends the magic packet. On the receiving side the magic packet is thrown away or a sysrq is activated depending on what kernel .config options have been set. The generic serial driver was modified as well as the usb serial headers to generically implement sysrq processing in the same way the non usb uart based drivers implement the sysrq handling. This will allow other usb serial devices to implement sysrq handling as desired. The new usb serial functions are named similarly and implemented similarly to the uart functions as follows: usb_serial_handle_break <-> uart_handle_break usb_serial_handle_sysrq_char <-> uart_handle_sysrq_char Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* USB: usb_debug, usb_generic_serial: implement multi urb writeJason Wessel2009-06-151-7/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | The usb_debug driver, when used as the console, will always fail to insert the carriage return and new line sequence as well as randomly drop console output. This is a result of only having the single write_urb and that the tty layer will have a lock that prevents the processing of the back to back urb requests. The solution is to allow more than one urb to be outstanding and have a slightly deeper transmit queue. The idea and some code is borrowed from the ftdi_sio usb driver. The generic usb serial driver was modified so as to allow the classic method of 1 write urb, or a multi write urb scheme with N allowed outstanding urbs where N is controlled by max_in_flight_urbs. When max_in_flight_urbs in a "struct usb_serial_driver" is non zero the multi write urb scheme will be used. The size of 4000 was selected for the usb_debug driver so that the driver lowers possibility of losing the queued console messages during the kernel startup. Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* tty: Bring the usb tty port structure into more useAlan Cox2009-06-111-2/+1
| | | | | | | | | | This allows us to clean stuff up, but is probably also going to cause some app breakage with buggy apps as we now implement proper POSIX behaviour for USB ports matching all the other ports. This does also mean other apps that break on USB will now work properly. Signed-off-by: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* USB: removal of tty->low_latency hack dating back to the old serial codeOliver Neukum2009-04-231-6/+0
| | | | | | | | | | | | This removes tty->low_latency from all USB serial drivers that push data into the tty layer at hard interrupt context. It's no longer needed and actually harmful. Signed-off-by: Oliver Neukum <oliver@neukum.org> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>