Skip to content
  1. Jul 17, 2019
  2. Jul 15, 2019
  3. Jul 14, 2019
  4. Jul 13, 2019
  5. Jul 12, 2019
  6. Jul 11, 2019
    • Phil Elwell's avatar
      tty: amba-pl011: Make TX optimisation conditional · 9bf5cd2d
      Phil Elwell authored
      pl011_tx_chars takes a "from_irq" parameter to reduce the number of
      register accesses. When from_irq is true the function assumes that the
      FIFO is half empty and writes up to half a FIFO's worth of bytes
      without polling the FIFO status register, the reasoning being that
      the function is being called as a result of the TX interrupt being
      raised. This logic would work were it not for the fact that
      pl011_rx_chars, called from pl011_int before pl011_tx_chars, releases
      the spinlock before calling tty_flip_buffer_push.
      
      A user thread writing to the UART claims the spinlock and ultimately
      calls pl011_tx_chars with from_irq set to false. This reverts to the
      older logic that polls the FIFO status register before sending every
      byte. If this happen on an SMP system during the section of the IRQ
      handler where the spinlock has been released, then by the time the TX
      interrupt handler is called, the FIFO may already be full, and any
      further writes are likely to be lost.
      
      The fix involves adding a per-port flag that is true iff running from
      within the interrupt handler and the spinlock has not yet been released.
      This flag is then used as the value for the from_irq parameter of
      pl011_tx_chars, causing polling to be used in the unsafe case.
      
      Fixes: 1e84d223
      
       ("serial/amba-pl011: Refactor and simplify TX FIFO handling")
      
      Signed-off-by: default avatarPhil Elwell <phil@raspberrypi.org>
      9bf5cd2d
  7. Jul 10, 2019