1. 22 8月, 2016 1 次提交
    • B
      usb: gadget: Add the gserial port checking in gs_start_tx() · 511a36d2
      Baolin Wang 提交于
      When usb gadget is set gadget serial function, it will be crash in below
      situation.
      
      It will clean the 'port->port_usb' pointer in gserial_disconnect() function
      when usb link is inactive, but it will release lock for disabling the endpoints
      in this function. Druing the lock release period, it maybe complete one request
      to issue gs_write_complete()--->gs_start_tx() function, but the 'port->port_usb'
      pointer had been set NULL, thus it will be crash in gs_start_tx() function.
      
      This patch adds the 'port->port_usb' pointer checking in gs_start_tx() function
      to avoid this situation.
      Signed-off-by: NBaolin Wang <baolin.wang@linaro.org>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      511a36d2
  2. 21 6月, 2016 1 次提交
  3. 01 5月, 2016 1 次提交
  4. 23 12月, 2015 1 次提交
  5. 18 10月, 2015 1 次提交
  6. 27 9月, 2015 1 次提交
  7. 28 4月, 2015 1 次提交
    • P
      usb: gadget: serial: fix re-ordering of tx data · 3e9d3d2e
      Philip Oberstaller 提交于
      When a single thread is sending out data over the gadget serial port,
      gs_start_tx() will be called both from the sender context and from the
      write completion. Since the port lock is released before the packet is
      queued, the order in which the URBs are submitted is not guaranteed.
      E.g.
      
        sending thread                      completion (interrupt)
      
        gs_write()
          LOCK
                                            gs_write_complete()
                                              LOCK (wait)
          gs_start_tx()
            req1 = list_entry(pool->next)
            UNLOCK
                                              LOCK (acquired)
                                              gs_start_tx()
                                                req2 = list_entry(pool->next)
                                                UNLOCK
                                                usb_ep_queue(req2)
            usb_ep_queue(req1)
      
      I.e., req2 is submitted before req1 but it contains the data that
      comes after req1.
      
      To reproduce, use SMP with sending thread and completion pinned to
      different CPUs, or use PREEMPT_RT, and add the following delay just
      before the call to usb_ep_queue():
      
      		if (port->write_started > 0 && !list_empty(pool))
      			udelay(1000);
      
      To work around this problem, make sure that only one thread is running
      through the gs_start_tx() loop with an extra flag write_busy. Since
      gs_start_tx() is always called with the port lock held, no further
      synchronisation is needed. The original caller will continue through
      the loop when the request was successfully submitted.
      Signed-off-by: NPhilip Oberstaller <Philip.Oberstaller@septentrio.com>
      Signed-off-by: NArnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      3e9d3d2e
  8. 13 3月, 2015 1 次提交
  9. 28 8月, 2014 1 次提交
    • R
      usb: gadget: serial: remove PREFIX macro · c572a217
      Richard Leitner 提交于
      Remove the ttyGS PREFIX macro from u_serial.c and replace all occurences with
      the hardcoded ttyGS string.
      
      This macro was mostly used in a few debug/warning messages and a lot of
      hardcoded ttyGS existed beneath. It may have been used for renaming the
      tty, but if done so most debug messages would have ignored this.
      
      Due to the fact the usage of this PREFIX in all debug calls would have
      resulted in a hard to read/grep code it is removed completely.
      Signed-off-by: NRichard Leitner <richard.leitner@skidata.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      c572a217
  10. 17 7月, 2014 1 次提交
  11. 01 3月, 2014 1 次提交
    • P
      tty: Fix low_latency BUG · a9c3f68f
      Peter Hurley 提交于
      The user-settable knob, low_latency, has been the source of
      several BUG reports which stem from flush_to_ldisc() running
      in interrupt context. Since 3.12, which added several sleeping
      locks (termios_rwsem and buf->lock) to the input processing path,
      the frequency of these BUG reports has increased.
      
      Note that changes in 3.12 did not introduce this regression;
      sleeping locks were first added to the input processing path
      with the removal of the BKL from N_TTY in commit
      a88a69c9,
      'n_tty: Fix loss of echoed characters and remove bkl from n_tty'
      and later in commit 38db8979,
      'tty: throttling race fix'. Since those changes, executing
      flush_to_ldisc() in interrupt_context (ie, low_latency set), is unsafe.
      
      However, since most devices do not validate if the low_latency
      setting is appropriate for the context (process or interrupt) in
      which they receive data, some reports are due to misconfiguration.
      Further, serial dma devices for which dma fails, resort to
      interrupt receiving as a backup without resetting low_latency.
      
      Historically, low_latency was used to force wake-up the reading
      process rather than wait for the next scheduler tick. The
      effect was to trim multiple milliseconds of latency from
      when the process would receive new data.
      
      Recent tests [1] have shown that the reading process now receives
      data with only 10's of microseconds latency without low_latency set.
      
      Remove the low_latency rx steering from tty_flip_buffer_push();
      however, leave the knob as an optional hint to drivers that can
      tune their rx fifos and such like. Cleanup stale code comments
      regarding low_latency.
      
      [1] https://lkml.org/lkml/2014/2/20/434
      
      "Yay.. thats an annoying historical pain in the butt gone."
      	-- Alan Cox
      Reported-by: NBeat Bolli <bbolli@ewanet.ch>
      Reported-by: NPavel Roskin <proski@gnu.org>
      Acked-by: NDavid Sterba <dsterba@suse.cz>
      Cc: Grant Edwards <grant.b.edwards@gmail.com>
      Cc: Stanislaw Gruszka <sgruszka@redhat.com>
      Cc: Hal Murray <murray+fedora@ip-64-139-1-69.sjc.megapath.net>
      Cc: <stable@vger.kernel.org> # 3.12.x+
      Signed-off-by: NPeter Hurley <peter@hurleysoftware.com>
      Signed-off-by: NAlan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a9c3f68f
  12. 14 3月, 2013 1 次提交
  13. 22 1月, 2013 3 次提交
    • F
      usb: gadget: fix two sparse warnings · 38b3ad56
      Felipe Balbi 提交于
      drivers/usb/gadget/u_serial.c:1291:5: sparse: symbol \
      	'userial_init' was not declared. Should it be static?
      drivers/usb/gadget/zero.c:66:25: sparse: symbol \
      	'gzero_options' was not declared. Should it be static?
      Reported-by: NFengguang Wu <fengguang.wu@intel.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      38b3ad56
    • S
      usb: gadget: allocate & giveback serial ports instead hard code them · 19b10a88
      Sebastian Andrzej Siewior 提交于
      This patch removes gserial_setup() and gserial_cleanup() and adds
      gserial_alloc_line() and gserial_free_line() to replace them.
      
      The initial setup of u_serial happens now on module load time. A
      maximum of four TTY ports can be requested which is the current limit.
      In theory we could extend this limit, the hard limit is the number of
      available endpoints.
      alloc_tty_driver() is now called at module init time with the max
      available ports. The per-line footprint here is on 32bit is 3 * size of
      pointer + 60 bytes (for cdevs).
      The remaining memory (struct gs_port) is allocated once a port is
      requested.
      
      With this change it is possible to load g_multi and g_serial at the same
      time. GS0 receives the module that is loaded first, GS1 is received by
      the next module and so on. With the configfs interface the port number
      can be exported and the device node is more predictable. Nothing changes
      for g_serial and friends as long as one module is used.
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      19b10a88
    • S
      usb: gadget: u_serial: convert into a module · 3249ca22
      Sebastian Andrzej Siewior 提交于
      Every user of u_serial has now to select the U_SERIAL symbol instead of
      including the file.
      There is one limition with this: ports and and gs_tty_driver are global
      variables in u_serial. Since all users share them, there can be only one
      user loaded at a time i.e. either g_serial or g_nokia.
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      3249ca22
  14. 16 1月, 2013 2 次提交
    • J
      TTY: switch tty_flip_buffer_push · 2e124b4a
      Jiri Slaby 提交于
      Now, we start converting tty buffer functions to actually use
      tty_port. This will allow us to get rid of the need of tty in many
      call sites. Only tty_port will needed and hence no more
      tty_port_tty_get in those paths.
      
      Now, the one where most of tty_port_tty_get gets removed:
      tty_flip_buffer_push.
      
      IOW we also closed all the races in drivers not using tty_port_tty_get
      at all yet.
      
      Also we move tty_flip_buffer_push declaration from include/linux/tty.h
      to include/linux/tty_flip.h to all others while we are changing it
      anyway.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2e124b4a
    • J
      TTY: switch tty_insert_flip_string · 05c7cd39
      Jiri Slaby 提交于
      Now, we start converting tty buffer functions to actually use
      tty_port. This will allow us to get rid of the need of tty in many
      call sites. Only tty_port will needed and hence no more
      tty_port_tty_get in those paths.
      
      tty_insert_flip_string this time.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      05c7cd39
  15. 13 12月, 2012 1 次提交
  16. 16 11月, 2012 1 次提交
    • J
      TTY: call tty_port_destroy in the rest of drivers · 191c5f10
      Jiri Slaby 提交于
      After commit "TTY: move tty buffers to tty_port", the tty buffers are
      not freed in some drivers. This is because tty_port_destructor is not
      called whenever a tty_port is freed. This was an assumption I counted
      with but was unfortunately untrue. So fix the drivers to fulfil this
      assumption.
      
      To be sure, the TTY buffers (and later some stuff) are gone along with
      the tty_port, we have to call tty_port_destroy at tear-down places.
      This is mostly where the structure containing a tty_port is freed.
      This patch does exactly that -- put tty_port_destroy at those places.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      191c5f10
  17. 07 9月, 2012 1 次提交
  18. 14 8月, 2012 1 次提交
    • J
      TTY: use tty_port_register_device · 734cc178
      Jiri Slaby 提交于
      Currently we have no way to assign tty->port while performing tty
      installation. There are two ways to provide the link tty_struct =>
      tty_port. Either by calling tty_port_install from tty->ops->install or
      tty_port_register_device called instead of tty_register_device when
      the device is being set up after connected.
      
      In this patch we modify most of the drivers to do the latter. When the
      drivers use tty_register_device and we have tty_port already, we
      switch to tty_port_register_device. So we have the tty_struct =>
      tty_port link for free for those.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Acked-by: NAlan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      734cc178
  19. 11 5月, 2012 1 次提交
  20. 10 4月, 2012 3 次提交
  21. 06 4月, 2012 1 次提交
  22. 09 3月, 2012 2 次提交
  23. 01 11月, 2011 1 次提交
  24. 27 9月, 2011 1 次提交
  25. 29 6月, 2011 1 次提交
  26. 11 11月, 2010 1 次提交
    • J
      usb: subtle increased memory usage in u_serial · 28609d40
      Jim Sung 提交于
      OK, the USB gadget serial driver actually has a couple of problems.  On
      gs_open(), it always allocates and queues an additional QUEUE_SIZE (16)
      worth of requests, so with a loop like this:
      
          i=1 ; while echo $i > /dev/ttyGS0 ; do let i++ ; done
      
      eventually we run into OOM (Out of Memory).
      
      Technically, it is not a leak as everything gets freed up when the USB
      connection is broken, but not on gs_close().
      
      With a USB device/gadget controller driver that has limited resources
      (e.g., Marvell has a this MAX_XDS_FOR_TR_CALLS of 64 for transmit and
      receive), so even after 4
      
          stty -F /dev/ttyGS0
      
      we cannot transmit anymore.  We can still receive (not necessarily
      reliably) as now we have 16 * 4 = 64 descriptors/buffers ready, but the
      device is otherwise not usable.
      Signed-off-by: NJim Sung <jsung@syncadence.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      28609d40
  27. 11 8月, 2010 1 次提交
    • S
      USB: gadget: compilation issue: missing TASK_INTERRUPTIBLE · 1e413943
      stephane duverger 提交于
      Here is the patch for the following issue:
      
      drivers/usb/gadget/u_serial.c: In function ‘gs_start_tx’:
      drivers/usb/gadget/u_serial.c:369: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
      drivers/usb/gadget/u_serial.c:369: error: (Each undeclared identifier is reported only once
      drivers/usb/gadget/u_serial.c:369: error: for each function it appears in.)
      drivers/usb/gadget/u_serial.c: In function ‘gs_rx_push’:
      drivers/usb/gadget/u_serial.c:546: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
      drivers/usb/gadget/u_serial.c: In function ‘gs_close’:
      drivers/usb/gadget/u_serial.c:857: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
      drivers/usb/gadget/u_serial.c:857: error: implicit declaration of function ‘signal_pending’
      drivers/usb/gadget/u_serial.c:857: error: implicit declaration of function ‘schedule_timeout’
      drivers/usb/gadget/u_serial.c: In function ‘gserial_cleanup’:
      drivers/usb/gadget/u_serial.c:1190: error: ‘TASK_UNINTERRUPTIBLE’ undeclared (first use in this function)
      drivers/usb/gadget/u_serial.c:1190: error: implicit declaration of function ‘schedule’
      drivers/usb/gadget/u_serial.c: In function ‘gserial_disconnect’:
      drivers/usb/gadget/u_serial.c:1311: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
      Signed-off-by: NStephane Duverger <stephane.duverger@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      1e413943
  28. 30 6月, 2010 2 次提交
  29. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  30. 23 9月, 2009 1 次提交
  31. 16 6月, 2009 1 次提交
  32. 25 3月, 2009 1 次提交
  33. 14 8月, 2008 1 次提交
    • D
      usb gadget: issue notifications from ACM function · 1f1ba11b
      David Brownell 提交于
      Update the CDC-ACM gadget code to support the peripheral-to-host
      notifications when the tty is opened or closed, or issues a BREAK.
      The serial framework code calls new generic hooks; right now only
      CDC-ACM uses those hooks.  This resolves several REVISIT comments
      in the code.  (Based on a patch from Felipe Balbi.)
      
      Note that this doesn't expose USB_CDC_CAP_BRK to the host, since
      this code still rejects USB_CDC_REQ_SEND_BREAK control requests
      for host-to-peripheral BREAK signaling (received via /dev/ttyGS*).
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Cc: Felipe Balbi <felipe.balbi@nokia.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      1f1ba11b