1. 28 2月, 2018 11 次提交
  2. 07 2月, 2018 1 次提交
  3. 25 1月, 2018 1 次提交
    • A
      tty: serial: exar: Relocate sleep wake-up handling · c7e1b405
      Aaron Sierra 提交于
      Exar sleep wake-up handling has been done on a per-channel basis by
      virtue of INT0 being accessible from each channel's address space. I
      believe this was initially done out of necessity, but now that Exar
      devices have their own driver, we can do things more efficiently by
      registering a dedicated INT0 handler at the PCI device level.
      
      I see this change providing the following benefits:
      
          1. If more than one port is active, eliminates the redundant bus
             cycles for reading INT0 on every interrupt.
          2. This note associated with hooking in the per-channel handler in
             8250_port.c is resolved:
              /* Fixme: probably not the best place for this */
      
      Cc: Matt Schulte <matts@commtech-fastcom.com>
      Signed-off-by: NAaron Sierra <asierra@xes-inc.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c7e1b405
  4. 22 1月, 2018 4 次提交
    • M
      serial: imx: fix endless loop during suspend · 09df0b34
      Martin Kaiser 提交于
      Before we go into suspend mode, we enable the imx uart's interrupt for
      the awake bit in the UART Status Register 1. If, for some reason, the
      awake bit is already set before we enter suspend mode, we get an
      interrupt immediately when we enable interrupts for awake. The uart's
      clk_ipg is disabled at this point (unless there's an ongoing transfer).
      We end up in the interrupt handler, which usually tries to clear the
      awake bit. This doesn't work with the clock disabled. Therefore, we
      keep getting interrupts forever, resulting in an endless loop.
      
      Clear the awake bit before setting the awaken bit to signal that we want
      an imx interrupt when the awake bit will be set. This ensures that we're
      not woken up by events that happened before we started going into
      suspend mode.
      
      Change the clock handling so that suspend prepares and enables the clock
      and suspend_noirq disables it. Revert these operations in resume_noirq and
      resume.
      
      With these preparations in place, we can now modify awake and awaken in
      the suspend function when the actual imx interrupt is disabled and the
      required clk_ipg is active.
      
      Update the thaw and freeze functions to use the new clock handling since
      we share the suspend_noirq function between suspend and hibernate.
      Signed-off-by: NMartin Kaiser <martin@kaiser.cx>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      09df0b34
    • S
      serial: core: mark port as initialized after successful IRQ change · 44117a1d
      Sebastian Andrzej Siewior 提交于
      setserial changes the IRQ via uart_set_info(). It invokes
      uart_shutdown() which free the current used IRQ and clear
      TTY_PORT_INITIALIZED. It will then update the IRQ number and invoke
      uart_startup() before returning to the caller leaving
      TTY_PORT_INITIALIZED cleared.
      
      The next open will crash with
      |  list_add double add: new=ffffffff839fcc98, prev=ffffffff839fcc98, next=ffffffff839fcc98.
      since the close from the IOCTL won't free the IRQ (and clean the list)
      due to the TTY_PORT_INITIALIZED check in uart_shutdown().
      
      There is same pattern in uart_do_autoconfig() and I *think* it also
      needs to set TTY_PORT_INITIALIZED there.
      Is there a reason why uart_startup() does not set the flag by itself
      after the IRQ has been acquired (since it is cleared in uart_shutdown)?
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      44117a1d
    • W
      serial: mxs-auart: don't use GPIOF_* with gpiod_get_direction · f8bdfe9d
      Wolfram Sang 提交于
      The documentation was wrong, gpiod_get_direction() returns 0/1 instead
      of the GPIOF_* flags. The docs were fixed with commit 94fc7309
      ("gpio: correct docs about return value of gpiod_get_direction"). Now,
      fix this user (until a better, system-wide solution is in place). This
      also means we can drop the deprecated use of 'linux/gpio.h'. Yay!
      Signed-off-by: NWolfram Sang <wsa+renesas@sang-engineering.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f8bdfe9d
    • A
      serial: 8250_dw: Revert "Improve clock rate setting" · c14b65fe
      Andy Shevchenko 提交于
      The commit
      
        de9e33bd ("serial: 8250_dw: Improve clock rate setting")
      
      obviously tries to cure symptoms, and not a root cause.
      
      The root cause is the non-flexible rate calculation inside the
      corresponding clock driver. What we need is to provide maximum UART
      divisor value to the clock driver to allow it do the job transparently
      to the caller.
      
      Since from the initial commit message I have got no clue which clock
      driver actually needs to be amended, I leave this exercise to the people
      who know better the case.
      
      Moreover, it seems [1] the fix introduced a regression. And possible
      even one more [2].
      
      Taking above, revert the commit de9e33bd for now.
      
      [1]: https://www.spinics.net/lists/linux-serial/msg28872.html
      [2]: https://github.com/Dunedan/mbp-2016-linux/issues/29#issuecomment-357583782
      
      Fixes: de9e33bd ("serial: 8250_dw: Improve clock rate setting")
      Cc: stable <stable@vger.kernel.org> # 4.15
      Cc: Ed Blake <ed.blake@sondrel.com>
      Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
      Cc: Lukas Wunner <lukas@wunner.de>
      Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c14b65fe
  5. 10 1月, 2018 1 次提交
  6. 09 1月, 2018 10 次提交
  7. 19 12月, 2017 5 次提交
    • J
      serial: max310x: Reduce RX work starvation · 22587612
      Jan Kundrát 提交于
      Prior to this patch, the code would happily trigger TX on some ports
      before having a chance of reading the RX buffer from the rest of them.
      When no flow control was used, this led to RX buffer overruns and
      therefore lost data under certain circumstances.
      
      I was able to reproduce this with MAX14830 (that's a quad channel one)
      and a simple daisy-chain of RX and TX ports on the eval board:
      
      - TX0 -> RX1
      - TX1 -> RX2
      - TX2 -> RX3
      - TX3 -> RX0
      
      I was testing this by transferring 2MB of data at 115200 baud via each
      port. I used a Solidrun Clearfog Base (Armada 388) which was talking to
      the UART over an SPI bus clocked at 26MHz (the chip's maximum). Without
      this patch, I would always get a "Possible RX FIFO overrun" in dmesg,
      and fewer-than-expected amount of bytes received over ttyMAX0. Results
      on ttyMAX{1,2,3} tended to be correct all the time, even without the
      previous patches in this series and with PIO SPI transfers ("indirect
      mode" as the Marvell datasheet calls it), so I assume that heavy
      congestion is needed in order to reproduce this.
      
      A drawback of this patch is that the throughput gets reduced "a bit".
      Previously, a 115200 baud resulted in about 11.2kBps throughput as
      reported by a simple `pv`. With this patch, the throughput of four
      parallel streams is roughly 7kBps each, and 9kBps for three streams.
      There is no slowdown for one or two parallel streams.
      
      Situation is worse if bytes are being read one-by-one (such as if the
      userspace wants to perform parity/framing/break checking) and therefore
      without the batched reads.
      
      With just this patch and no other modifications on top of 4.14, I was
      only getting roughly 3.6kBps with four parallel streams. The
      single-stream performance was the same, and I was seeing about 7.2kBps
      with two parallel streams. `perf top` said that a substantial amount of
      time was spent in `finish_task_switch`, `_raw_spin_unlock_irqrestore`
      and `__timer_delay`.
      Signed-off-by: NJan Kundrát <jan.kundrat@cesnet.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      22587612
    • J
      serial: max310x: Use batched reads when reasonably safe · 2b4bac48
      Jan Kundrát 提交于
      The hardware has a 128 byte RX FIFO buffer for each independent UART.
      Previously, the code was always reading that byte-by-byte via
      independent SPI transactions and the associated overhead. In practice,
      this led to up to eight bytes over SPI for just one byte in the UART's
      RX FIFO:
      
      - reading the global IRQ register (two bytes, one for command, the other
      for data)
      - reading one UART's ISR (again two bytes)
      - reading the byte count (two bytes yet again)
      - finally, reading one byte of the FIFO via another two-byte transaction
      
      We cannot always use a batched read. If the TTY is set to intercept
      break conditions or report framing or parity errors, then it is required
      to check the Line Status Register (LSR) for each byte which is read from
      the RX FIFO. The documentation does not show a way of doing that in a
      single SPI transaction; registers 0x00 and 0x04 are separate.
      
      In my testing, this is no silver bullet. I was feeding 2MB of random
      data over four daisy-chaned UARTs of MAX14830, and this is the
      distribution that I was getting:
      
      - R <= 1: 7437322
      - R <= 2: 162093
      - R <= 4: 4093
      - R <= 8: 4196
      - R <= 16: 645
      - R <= 32: 165
      - R <= 64: 58
      - R <= 128: 0
      
      For a reference, batching the write operations works much better:
      
      - W <= 1: 2664
      - W <= 2: 1305
      - W <= 4: 627
      - W <= 8: 371
      - W <= 16: 121
      - W <= 32: 68
      - W <= 64: 33
      - W <= 128: 63139
      
      That's probably because this HW/SW combination (Clearfog Base, Armada
      388) is probably "good enough" to react to the chip's IRQ "fast enough"
      most of the time. Still, I was getting RX overruns every now and then.
      In future, I plan to improve this by letting the RX FIFO be filled a
      little more (the chip has support for that and also for a "stale
      timeout" to prevent additional starvation).
      Signed-off-by: NJan Kundrát <jan.kundrat@cesnet.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2b4bac48
    • J
      serial: max310x: use a batch write op for UART transmit · d584b65c
      Jan Kundrát 提交于
      The transmit register supports batched writes. The key is simply to keep
      sending additional bytes up to the FIFO size in the same SPI
      transaction with the CS pin still being held low.
      
      This duplicates the regmap infrastructure to a certain extent. There are
      some provisions for multiple writes in there, but there does not appear
      to be any support for those writes which are destined to the *same*
      register (and also no standard for SPI bus transfers of these, anyway).
      
      This patch does not solve every case (if the UART xmit circular buffer
      wraps around, we're still doing two SPI transactions), but at least
      it's not one-byte-per-transaction anymore.
      
      This change does not touch the receive path at this time. Doing that in
      the generic case appears to be impossible in the general case, because
      the chips' status register contains data about the *current* byte in the
      HW's Rx FIFO. We cannot read these two registers in one go,
      unfortunately.
      Signed-off-by: NJan Kundrát <jan.kundrat@cesnet.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d584b65c
    • J
      serial: max310x: Support IRQ sharing with other devices · 78be70c8
      Jan Kundrát 提交于
      According to my chip's datasheet [1], the IRQ output is an open
      collector pin which is suitable for sharing with other chips. The chip
      also has a register which indicates which UART performed a change and
      the driver checks that register already, so we have everything what is
      needed to effectively share the IRQ GPIO.
      
      [1] https://datasheets.maximintegrated.com/en/ds/MAX14830.pdfSigned-off-by: NJan Kundrát <jan.kundrat@cesnet.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      78be70c8
    • J
      serial: max310x: Do not hard-code the IRQ type · bceb4839
      Jan Kundrát 提交于
      As suggested by Russell King, a driver should not really care about bits
      such as the interrupt polarity or whether it is edge- or level-
      triggered. The reasons for that include:
      
      - an upstream IRQ controller which cannot support edge- or
      level-triggered interrupts,
      - board design with a built-in inverter
      
      The interrupt type is being already specified by the Device Tree,
      anyway. Other drivers (gpio/gpio-tc3589x.c for example) already work in
      this way, delegating the proper IRQ line setup to the DT and not
      specifying anything by hand.
      
      Also, there's no reason to have the IRQ flags split between two places.
      The SPI probing is the only entry point anyway.
      Signed-off-by: NJan Kundrát <jan.kundrat@cesnet.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bceb4839
  8. 18 12月, 2017 1 次提交
  9. 16 12月, 2017 6 次提交
    • J
      serial: max310x: Fix invalid memory access during GPIO init · 38d5583f
      Jan Kundrát 提交于
      The `max310x_spi_probe` function attempted to setup the GPIO bits before
      the corresponding structs for each serial port were initialized. If the
      DTS file specified a GPIO hog, this led to a crash because the GPIO
      stack ended up calling `max310x_gpio_direction_output` which referenced
      uninitialized memory:
      
       [<c04598c0>] (max310x_gpio_direction_output) from [<c03f5a2c>] (_gpiod_direction_output_raw+0x94/0x2d4)
       [<c03f5a2c>] (_gpiod_direction_output_raw) from [<c03f991c>] (gpiod_hog+0x6c/0x154)
       [<c03f991c>] (gpiod_hog) from [<c03fa2d8>] (of_gpiochip_add+0x28c/0x444)
       [<c03fa2d8>] (of_gpiochip_add) from [<c03f6b2c>] (gpiochip_add_data+0x4f8/0x760)
       [<c03f6b2c>] (gpiochip_add_data) from [<c03f6dd4>] (devm_gpiochip_add_data+0x40/0x7c)
       [<c03f6dd4>] (devm_gpiochip_add_data) from [<c0459fec>] (max310x_spi_probe+0x530/0x894)
       [<c0459fec>] (max310x_spi_probe) from [<c0503294>] (spi_drv_probe+0x7c/0xac)
       [<c0503294>] (spi_drv_probe) from [<c046628c>] (driver_probe_device+0x234/0x2e8)
       [<c046628c>] (driver_probe_device) from [<c0464890>] (bus_for_each_drv+0x60/0x94)
       [<c0464890>] (bus_for_each_drv) from [<c0465f78>] (__device_attach+0xb0/0x114)
       [<c0465f78>] (__device_attach) from [<c0465548>] (bus_probe_device+0x84/0x8c)
       [<c0465548>] (bus_probe_device) from [<c0463a00>] (device_add+0x3f4/0x580)
       [<c0463a00>] (device_add) from [<c0504164>] (spi_add_device+0x9c/0x134)
       [<c0504164>] (spi_add_device) from [<c0504c18>] (spi_register_controller+0x484/0x910)
       [<c0504c18>] (spi_register_controller) from [<c0506ee0>] (orion_spi_probe+0x2f4/0x3b4)
       [<c0506ee0>] (orion_spi_probe) from [<c0467dac>] (platform_drv_probe+0x50/0xb0)
       [<c0467dac>] (platform_drv_probe) from [<c046628c>] (driver_probe_device+0x234/0x2e8)
       [<c046628c>] (driver_probe_device) from [<c04663f8>] (__driver_attach+0xb8/0xbc)
       [<c04663f8>] (__driver_attach) from [<c04647e8>] (bus_for_each_dev+0x68/0x9c)
       [<c04647e8>] (bus_for_each_dev) from [<c046574c>] (bus_add_driver+0x104/0x210)
       [<c046574c>] (bus_add_driver) from [<c0466f14>] (driver_register+0x78/0xf4)
       [<c0466f14>] (driver_register) from [<c0101bdc>] (do_one_initcall+0x44/0x168)
       [<c0101bdc>] (do_one_initcall) from [<c0a00dc0>] (kernel_init_freeable+0x140/0x1cc)
       [<c0a00dc0>] (kernel_init_freeable) from [<c078c590>] (kernel_init+0x8/0x108)
       [<c078c590>] (kernel_init) from [<c0107a50>] (ret_from_fork+0x14/0x24)
      
      This can be easily fixed by moving the corresponding code below. And
      because the UARTs are already there by the time we reach this point, the
      `goto` needs changing so that more stuff is freed. (I have not tested
      this error path.)
      Signed-off-by: NJan Kundrát <jan.kundrat@cesnet.cz>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      38d5583f
    • B
      tty: serial: mxs-auart: fix error handling in mxs_auart_probe · 5c305539
      Branislav Radocaj 提交于
      If uart_add_one_port() fails in mxs_auart_probe, the clks has
      to be disabled.Two clks are previously enabled in mxs_get_clks().
      Found by Linux Driver Verification project (linuxtesting.org).
      Signed-off-by: NBranislav Radocaj <branislav@radocaj.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5c305539
    • R
      serial: 8250: 8250_omap: Fix spelling error. · 93ad8673
      Rolf Evers-Fischer 提交于
      Fixed a spelling error in a comment.
      Signed-off-by: NRolf Evers-Fischer <rolf.evers.fischer@aptiv.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93ad8673
    • S
      serial: 8250_dw: Disable clock on error · 8af016aa
      Stefan Potyra 提交于
      If there is no clock rate for uartclk defined, disable the previously
      enabled clock again.
      
      Found by Linux Driver Verification project (linuxtesting.org).
      
      Fixes: 23f5b3fd serial: 8250_dw: only get the clock rate in one place
      Signed-off-by: NStefan Potyra <Stefan.Potyra@elektrobit.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8af016aa
    • L
      serial: stm32: fix name conflict with 8250 · 0858fe3c
      Ludovic Barre 提交于
      This patch replaces stm32 tty name ttyS by ttySTM
      to avoid a name conflict when Serial: 8250/16550 driver
      is activated.
      
      sysfs: cannot create duplicate filename '/class/tty/ttyS3'
      Modules linked in:
      CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.14.0-12903-gb392521-dirty #1
      [<c03118dc>] (unwind_backtrace) from [<c030c950>] (show_stack+0x10/0x14)
      [<c030c950>] (show_stack) from [<c0d31e18>] (dump_stack+0x90/0xa4)
      [<c0d31e18>] (dump_stack) from [<c03430a0>] (__warn+0xf8/0x110)
      [<c03430a0>] (__warn) from [<c03430f0>] (warn_slowpath_fmt+0x38/0x48)
      [<c03430f0>] (warn_slowpath_fmt) from [<c04ce574>] (sysfs_warn_dup+0x68/0x78)
      [<c04ce574>] (sysfs_warn_dup) from [<c04ce824>] (sysfs_do_create_link_sd+0xb4/0xc4)
      [<c04ce824>] (sysfs_do_create_link_sd) from [<c08c60ec>] (device_add+0x204/0x574)
      [<c08c60ec>] (device_add) from [<c07a7ddc>] (tty_register_device_attr+0xc8/0x1bc)
      [<c07a7ddc>] (tty_register_device_attr) from [<c07c6530>] (uart_add_one_port+0x22c/0x4f4)
      Signed-off-by: NLudovic Barre <ludovic.barre@st.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0858fe3c
    • G
      tty: serial: sh-sci: Hide DMA config question · be7e251d
      Geert Uytterhoeven 提交于
      On most Renesas ARM platforms, the SCIF serial ports can be used with
      DMA, so most users will want DMA support to be enabled.
      
      On SuperH platforms, SCI(F) serial ports cannot be used with DMA yet
      (see also commit 219fb0c1 ("serial: sh-sci: Remove the platform
      data dma slave rx/tx channel IDs")), so users will want it disabled to
      reduce kernel size.
      
      Hence follow the above rationale to configure the default, unless
      CONFIG_EXPERT is enabled.
      Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      be7e251d