1. 04 Jan, 2024 10 commits
    • Vamshi Gajjela's avatar
      serial: 8250_dw: Do not bailout on UCV read returning zero · d8a02844
      Vamshi Gajjela authored
      Designware UART has optional feature FIFO_MODE to implement FIFO.
      Encoding FIFO capabilities through Component Parameter Register CPR is
      optional and it can be enabled using parameter UART_ADD_ENCODED_PARAMS.
      
      Driver can exercise fifo capabilities by decoding CPR if implemented
      or from cpr_val provided from the dw8250_platform_data otherwise.
      
      dw8250_setup_port() checks for CPR or cpr_val to determine FIFO size
      only when Component Version (UCV) is non-zero. Bailing out early on UCV
      read returning zero will leave fifosize as zero and !UART_CAP_FIFO,
      hence prevent early return and continue to process CPR or cpr_val for
      the driver to utilize FIFO.
      
      Non-zero UCV implies ADDITIONAL_FEATURES=1, preventing early return
      will not be an overhead here.
      Signed-off-by: default avatarVamshi Gajjela <vamshigajjela@google.com>
      Link: https://lore.kernel.org/r/20231231182951.877805-1-vamshigajjela@google.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d8a02844
    • Christoph Niedermaier's avatar
      serial: imx: Ensure that imx_uart_rs485_config() is called with enabled clock · 7c45eaa8
      Christoph Niedermaier authored
      There are register accesses in the function imx_uart_rs485_config(). The
      clock must be enabled for these accesses. This was ensured by calling it
      via the function uart_rs485_config() in the probe() function within the
      range where the clock is enabled. With the commit 7c7f9bc9 ("serial:
      Deassert Transmit Enable on probe in driver-specific way") it was removed
      from the probe() function and is now only called through the function
      uart_add_one_port() which is located at the end of the probe() function.
      But the clock is already switched off in this area. To ensure that the
      clock is enabled during register access, move the disabling of the clock
      to the very end of the probe() function. To avoid leaking enabled clocks
      on error also add an error path for exiting with disabling the clock.
      
      Fixes: 7c7f9bc9 ("serial: Deassert Transmit Enable on probe in driver-specific way")
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarChristoph Niedermaier <cniedermaier@dh-electronics.com>
      Reviewed-by: default avatarLukas Wunner <lukas@wunner.de>
      Link: https://lore.kernel.org/r/20231226113647.39376-1-cniedermaier@dh-electronics.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7c45eaa8
    • Sam Ravnborg's avatar
      serial: apbuart: fix console prompt on qemu · c6dcd805
      Sam Ravnborg authored
      When using a leon kernel with qemu there where no console prompt.
      The root cause is the handling of the fifo size in the tx part of the
      apbuart driver.
      
      The qemu uart driver only have a very rudimentary status handling and do
      not report the number of chars queued in the tx fifo in the status register.
      So the driver ends up with a fifo size of 1.
      
      In the tx path the fifo size is divided by 2 - resulting in a fifo
      size of zero.
      
      The original implementation would always try to send one char, but
      after the introduction of uart_port_tx_limited() the fifo size is
      respected even for the first char.
      
      There seems to be no good reason to divide the fifo size with two - so
      remove this. It looks like something copied from the original amba driver.
      
      With qemu we now have a minimum fifo size of one char, so we show
      the prompt.
      Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Fixes: d11cc8c3 ("tty: serial: use uart_port_tx_limited()")
      Cc: Andreas Larsson <andreas@gaisler.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jiri Slaby <jirislaby@kernel.org>
      Cc:  <linux-serial@vger.kernel.org>
      Cc:  <sparclinux@vger.kernel.org>
      Link: https://lore.kernel.org/r/20231226121607.GA2622970@ravnborg.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c6dcd805
    • Michael Trimarchi's avatar
      tty: serial: kgdboc: Fix 8250_* kgdb over serial · 788aeef3
      Michael Trimarchi authored
      Check if port type is not PORT_UNKNOWN during poll_init.
      The kgdboc calls the tty_find_polling_driver that check
      if the serial is able to use poll_init. The poll_init calls
      the uart uart_poll_init that try to configure the uart with the
      selected boot parameters. The uart must be ready before setting
      parameters. Seems that PORT_UNKNOWN is already used by other
      functions in serial_core to detect uart status, so use the same
      to avoid to use it in invalid state.
      
      The crash happen for instance in am62x architecture where the 8250
      register the platform driver after the 8250 core is initialized.
      
      Follow the report crash coming from KGDB
      
      Thread 2 received signal SIGSEGV, Segmentation fault.
      [Switching to Thread 1]
      _outb (addr=<optimized out>, value=<optimized out>) at ./include/asm-generic/io.h:584
      584		__raw_writeb(value, PCI_IOBASE + addr);
      (gdb) bt
      
      This section of the code is too early because in this case
      the omap serial is not probed
      
      Thread 2 received signal SIGSEGV, Segmentation fault.
      [Switching to Thread 1]
      _outb (addr=<optimized out>, value=<optimized out>) at ./include/asm-generic/io.h:584
      584		__raw_writeb(value, PCI_IOBASE + addr);
      (gdb) bt
      
      Thread 2 received signal SIGSEGV, Segmentation fault.
      [Switching to Thread 1]
      _outb (addr=<optimized out>, value=<optimized out>) at ./include/asm-generic/io.h:584
      584		__raw_writeb(value, PCI_IOBASE + addr);
      (gdb) bt
      0  _outb (addr=<optimized out>, value=<optimized out>) at ./include/asm-generic/io.h:584
      1  logic_outb (value=0 '\000', addr=18446739675637874689) at lib/logic_pio.c:299
      2  0xffff80008082dfcc in io_serial_out (p=0x0, offset=16760830, value=0) at drivers/tty/serial/8250/8250_port.c:416
      3  0xffff80008082fe34 in serial_port_out (value=<optimized out>, offset=<optimized out>, up=<optimized out>)
          at ./include/linux/serial_core.h:677
      4  serial8250_do_set_termios (port=0xffff8000828ee940 <serial8250_ports+1568>, termios=0xffff80008292b93c, old=0x0)
          at drivers/tty/serial/8250/8250_port.c:2860
      5  0xffff800080830064 in serial8250_set_termios (port=0xfffffbfffe800000, termios=0xffbffe, old=0x0)
          at drivers/tty/serial/8250/8250_port.c:2912
      6  0xffff80008082571c in uart_set_options (port=0xffff8000828ee940 <serial8250_ports+1568>, co=0x0, baud=115200, parity=110, bits=8, flow=110)
          at drivers/tty/serial/serial_core.c:2285
      7  0xffff800080828434 in uart_poll_init (driver=0xfffffbfffe800000, line=16760830, options=0xffff8000828f7506 <config+6> "115200n8")
          at drivers/tty/serial/serial_core.c:2656
      8  0xffff800080801690 in tty_find_polling_driver (name=0xffff8000828f7500 <config> "ttyS2,115200n8", line=0xffff80008292ba90)
          at drivers/tty/tty_io.c:410
      9  0xffff80008086c0b0 in configure_kgdboc () at drivers/tty/serial/kgdboc.c:194
      10 0xffff80008086c1ec in kgdboc_probe (pdev=0xfffffbfffe800000) at drivers/tty/serial/kgdboc.c:249
      11 0xffff8000808b399c in platform_probe (_dev=0xffff000000ebb810) at drivers/base/platform.c:1404
      12 0xffff8000808b0b44 in call_driver_probe (drv=<optimized out>, dev=<optimized out>) at drivers/base/dd.c:579
      13 really_probe (dev=0xffff000000ebb810, drv=0xffff80008277f138 <kgdboc_platform_driver+48>) at drivers/base/dd.c:658
      14 0xffff8000808b0d2c in __driver_probe_device (drv=0xffff80008277f138 <kgdboc_platform_driver+48>, dev=0xffff000000ebb810)
          at drivers/base/dd.c:800
      15 0xffff8000808b0eb8 in driver_probe_device (drv=0xfffffbfffe800000, dev=0xffff000000ebb810) at drivers/base/dd.c:830
      16 0xffff8000808b0ff4 in __device_attach_driver (drv=0xffff80008277f138 <kgdboc_platform_driver+48>, _data=0xffff80008292bc48)
          at drivers/base/dd.c:958
      17 0xffff8000808ae970 in bus_for_each_drv (bus=0xfffffbfffe800000, start=0x0, data=0xffff80008292bc48,
          fn=0xffff8000808b0f3c <__device_attach_driver>) at drivers/base/bus.c:457
      18 0xffff8000808b1408 in __device_attach (dev=0xffff000000ebb810, allow_async=true) at drivers/base/dd.c:1030
      19 0xffff8000808b16d8 in device_initial_probe (dev=0xfffffbfffe800000) at drivers/base/dd.c:1079
      20 0xffff8000808af9f4 in bus_probe_device (dev=0xffff000000ebb810) at drivers/base/bus.c:532
      21 0xffff8000808ac77c in device_add (dev=0xfffffbfffe800000) at drivers/base/core.c:3625
      22 0xffff8000808b3428 in platform_device_add (pdev=0xffff000000ebb800) at drivers/base/platform.c:716
      23 0xffff800081b5dc0c in init_kgdboc () at drivers/tty/serial/kgdboc.c:292
      24 0xffff800080014db0 in do_one_initcall (fn=0xffff800081b5dba4 <init_kgdboc>) at init/main.c:1236
      25 0xffff800081b0114c in do_initcall_level (command_line=<optimized out>, level=<optimized out>) at init/main.c:1298
      26 do_initcalls () at init/main.c:1314
      27 do_basic_setup () at init/main.c:1333
      28 kernel_init_freeable () at init/main.c:1551
      29 0xffff8000810271ec in kernel_init (unused=0xfffffbfffe800000) at init/main.c:1441
      30 0xffff800080015e80 in ret_from_fork () at arch/arm64/kernel/entry.S:857
      Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
      Signed-off-by: default avatarMichael Trimarchi <michael@amarulasolutions.com>
      Link: https://lore.kernel.org/r/20231224131200.266224-1-michael@amarulasolutions.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      788aeef3
    • Christoph Niedermaier's avatar
      serial: imx: Correct clock error message in function probe() · 3e189470
      Christoph Niedermaier authored
      Correct the clock error message by changing the clock name.
      
      Fixes: 1e512d45 ("serial: imx: add error messages when .probe fails")
      Signed-off-by: default avatarChristoph Niedermaier <cniedermaier@dh-electronics.com>
      Reviewed-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Link: https://lore.kernel.org/r/20231224093209.2612-1-cniedermaier@dh-electronics.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e189470
    • Antony Pavlov's avatar
      tty/serial: altera_uart: use more informative labels in /proc/interrupts · f0635480
      Antony Pavlov authored
      Prior to this patch:
      
      ~# cat /proc/interrupts
      ...
       40:        123          0     GIC-0  72 Level     altera_uart
       41:          9          0     GIC-0  73 Level     altera_uart
      
      After this patch:
      
      ~# cat /proc/interrupts
      ...
       40:          6          0     GIC-0  72 Level     ff200100.fpga-uart0
       41:         28          0     GIC-0  73 Level     ff200200.fpga-uart1
      Signed-off-by: default avatarAntony Pavlov <antonynpavlov@gmail.com>
      Acked-by: default avatarTobias Klauser <tklauser@distanz.ch>
      Link: https://lore.kernel.org/r/20231217195601.236002-1-antonynpavlov@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f0635480
    • Crescent CY Hsieh's avatar
      tty: serial: Add RS422 flag to struct serial_rs485 · 6056f20f
      Crescent CY Hsieh authored
      Add "SER_RS485_MODE_RS422" flag to struct serial_rs485, so that serial
      port can switch interface into RS422 if supported by using ioctl command
      "TIOCSRS485".
      
      By treating RS422 as a mode of RS485, which means while enabling RS422
      there are two flags need to be set (SER_RS485_ENABLED and
      SER_RS485_MODE_RS422), it would make things much easier. For example
      some places that checks for "SER_RS485_ENABLED" won't need to be rewritten.
      Signed-off-by: default avatarCrescent CY Hsieh <crescentcy.hsieh@moxa.com>
      Link: https://lore.kernel.org/r/20231201071554.258607-3-crescentcy.hsieh@moxa.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6056f20f
    • Crescent CY Hsieh's avatar
      tty: serial: Cleanup the bit shift with macro · 76ac8e29
      Crescent CY Hsieh authored
      This patch replaces the bit shift code with "_BITUL()" macro inside
      "serial_rs485" struct.
      Signed-off-by: default avatarCrescent CY Hsieh <crescentcy.hsieh@moxa.com>
      Link: https://lore.kernel.org/r/20231201071554.258607-2-crescentcy.hsieh@moxa.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      76ac8e29
    • Vamshi Gajjela's avatar
      serial: core: Clean up uart_update_timeout() function · d4303e0b
      Vamshi Gajjela authored
      Rename the variable size to temp and change its data type from
      unsigned int to u64 to avoid type casting in multiplication. Remove the
      intermediate variable frame_time and use temp instead to accommodate
      the nanoseconds(ns). port->frame_time is an unsigned int, therefore an
      explicit cast is used to improve readability. Having said this unsigned
      int is sufficinet to hold frame time duration in nanoseconds for all
      the standard baudrates.
      
      Consider 9600 baud, it takes 1/9600 seconds for one bit, for a total of
      10 bits (start, 8-bit data, stop) 10/9600=1.04 ms for 1 byte transfer,
      frame_time here is 1041667ns. As baudrate increases frame_time
      decreases, say for 115200 baud it is 86806ns.
      
      To avoid costly 64-bit arithmetic we do not upconvert the type for
      variable frame_time as overflow happens for extremely low baudrates
      which are impractical and are not used in real-world applications.
      Signed-off-by: default avatarVamshi Gajjela <vamshigajjela@google.com>
      Link: https://lore.kernel.org/r/20231109063417.3971005-3-vamshigajjela@google.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d4303e0b
    • Vamshi Gajjela's avatar
      serial: core: Update uart_poll_timeout() function to return unsigned long · cb86a338
      Vamshi Gajjela authored
      The function uart_fifo_timeout() returns an unsigned long value, which
      is the number of jiffies. Therefore, change the variable timeout in the
      function uart_poll_timeout() from int to unsigned long.
      Change the return type of the function uart_poll_timeout() from int to
      unsigned long to be consistent with the type of timeout values.
      Signed-off-by: default avatarVamshi Gajjela <vamshigajjela@google.com>
      Link: https://lore.kernel.org/r/20231109063417.3971005-2-vamshigajjela@google.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cb86a338
  2. 15 Dec, 2023 23 commits
  3. 11 Dec, 2023 1 commit
  4. 10 Dec, 2023 6 commits