1. 29 4月, 2014 22 次提交
  2. 26 4月, 2014 11 次提交
  3. 25 4月, 2014 7 次提交
    • T
      serial_core: fix uart PORT_UNKNOWN handling · 7deb39ed
      Thomas Pfaff 提交于
      While porting a RS485 driver from 2.6.29 to 3.14, i noticed that the serial tty
      driver could break it by using uart ports that it does not own :
      
      1. uart_change_pm ist called during uart_open and calls the uart pm function
         without checking for PORT_UNKNOWN.
         The fix is to move uart_change_pm from uart_open to uart_port_startup.
      2. The return code from the uart request_port call in uart_set_info is not
         handled properly, leading to the situation that the serial driver also
         thinks it owns the uart ports.
         This can triggered by doing following actions :
      
         setserial /dev/ttyS0 uart none    # release the uart ports
         modprobe lirc-serial              # or any other device that uses the uart
         setserial /dev/ttyS0 uart 16550   # gives no error and the uart tty driver
                                           # can use the ports as well
      Signed-off-by: NThomas Pfaff <tpfaff@pcs.com>
      Reviewed-by: NAlan Cox <alan@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7deb39ed
    • D
      serial: samsung: Change barrier() to cpu_relax() in console output · f94b0572
      Doug Anderson 提交于
      The two functions to write out to the console (one used in normal
      console mode and one in polling console mode) were slightly different.
      One used a barrier() in its loop and the other a cpu_relax().  The
      barrier() really doesn't do anything since we're using rd_regl() to
      read the port anyway.  Switch it to cpu_relax() to make things
      consistent.
      
      No known bugs / issues are fixed by this change--it just makes things
      more consistent.
      Signed-off-by: NDoug Anderson <dianders@chromium.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f94b0572
    • D
      serial: samsung: don't check config for every character · ab88c8dc
      Doug Anderson 提交于
      The s3c24xx_serial_console_putchar() is _only_ ever used by
      s3c24xx_serial_console_write() and is called in a loop (indirectly
      through uart_console_write()).  There's no reason to call
      s3c24xx_port_configured() for every iteration through the loop.  Move
      it outside the loop.
      Signed-off-by: NDoug Anderson <dianders@chromium.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ab88c8dc
    • D
      serial: samsung: Use the passed in "port", fixing kgdb w/ no console · bb7f09ba
      Doug Anderson 提交于
      The two functions in the samsung serial driver used for writing
      characters out to the port were inconsistent about whether they used
      the passed in "port" or the global "cons_uart".  There was no reason
      to use the global and the use of the global in
      s3c24xx_serial_put_poll_char() caused a crash in the case where you
      used the serial port for kgdboc but not for console.
      
      Fix it so we used the passed in variable.
      
      Note that this doesn't fix all problems with the samsung serial
      driver.  Specifically:
      * s3c24xx_serial_console_putchar() is still 99% identical to
        s3c24xx_serial_put_poll_char() (the function signature is different,
        but that's about it).  A future patch will make them slightly less
        identical and judging by other serial drivers we may need yet more
        differences eventually.
      * The samsung serial driver still doesn't allow you to have more than
        one console port since it still uses the global cons_uart in
        s3c24xx_serial_console_write().
      Signed-off-by: NDoug Anderson <dianders@chromium.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb7f09ba
    • L
      serial: 8250: Fix thread unsafe __dma_tx_complete function · f8fd1b03
      Loic Poulain 提交于
      __dma_tx_complete is not protected against concurrent
      call of serial8250_tx_dma. it can lead to circular tail
      index corruption or parallel call of serial_tx_dma on the
      same data portion.
      
      This patch fixes this issue by holding the port lock.
      Signed-off-by: NLoic Poulain <loic.poulain@intel.com>
      Reviewed-by: NHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f8fd1b03
    • L
      8250_core: Fix unwanted TX chars write · b08c9c31
      Loic Poulain 提交于
      On transmit-hold-register empty, serial8250_tx_chars
      should be called only if we don't use DMA.
      DMA has its own tx cycle.
      Signed-off-by: NLoic Poulain <loic.poulain@intel.com>
      Reviewed-by: NHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b08c9c31
    • M
      tty: Fix race condition between __tty_buffer_request_room and flush_to_ldisc · 6a20dbd6
      Manfred Schlaegl 提交于
      The race was introduced while development of linux-3.11 by
      e8437d7e and
      e9975fde.
      Originally it was found and reproduced on linux-3.12.15 and
      linux-3.12.15-rt25, by sending 500 byte blocks with 115kbaud to the
      target uart in a loop with 100 milliseconds delay.
      
      In short:
       1. The consumer flush_to_ldisc is on to remove the head tty_buffer.
       2. The producer adds a number of bytes, so that a new tty_buffer must
      	be allocated and added by __tty_buffer_request_room.
       3. The consumer removes the head tty_buffer element, without handling
      	newly committed data.
      
      Detailed example:
       * Initial buffer:
         * Head, Tail -> 0: used=250; commit=250; read=240; next=NULL
       * Consumer: ''flush_to_ldisc''
         * consumed 10 Byte
         * buffer:
           * Head, Tail -> 0: used=250; commit=250; read=250; next=NULL
      {{{
      		count = head->commit - head->read;	// count = 0
      		if (!count) {				// enter
      			// INTERRUPTED BY PRODUCER ->
      			if (head->next == NULL)
      				break;
      			buf->head = head->next;
      			tty_buffer_free(port, head);
      			continue;
      		}
      }}}
       * Producer: tty_insert_flip_... 10 bytes + tty_flip_buffer_push
         * buffer:
           * Head, Tail -> 0: used=250; commit=250; read=250; next=NULL
         * added 6 bytes: head-element filled to maximum.
           * buffer:
             * Head, Tail -> 0: used=256; commit=250; read=250; next=NULL
         * added 4 bytes: __tty_buffer_request_room is called
           * buffer:
             * Head -> 0: used=256; commit=256; read=250; next=1
             * Tail -> 1: used=4; commit=0; read=250 next=NULL
         * push (tty_flip_buffer_push)
           * buffer:
             * Head -> 0: used=256; commit=256; read=250; next=1
             * Tail -> 1: used=4; commit=4; read=250 next=NULL
       * Consumer
      {{{
      		count = head->commit - head->read;
      		if (!count) {
      			// INTERRUPTED BY PRODUCER <-
      			if (head->next == NULL)		// -> no break
      				break;
      			buf->head = head->next;
      			tty_buffer_free(port, head);
      			// ERROR: tty_buffer head freed -> 6 bytes lost
      			continue;
      		}
      }}}
      
      This patch reintroduces a spin_lock to protect this case. Perhaps later
      a lock-less solution could be found.
      Signed-off-by: NManfred Schlaegl <manfred.schlaegl@gmx.at>
      Cc: stable <stable@vger.kernel.org> # 3.11
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6a20dbd6