Isaac True
c8f71b49ee
serial: sc16is7xx: setup GPIO controller later in probe
...
The GPIO controller component of the sc16is7xx driver is setup too
early, which can result in a race condition where another device tries
to utilise the GPIO lines before the sc16is7xx device has finished
initialising.
This issue manifests itself as an Oops when the GPIO lines are configured:
Unable to handle kernel read from unreadable memory at virtual address
...
pc : sc16is7xx_gpio_direction_output+0x68/0x108 [sc16is7xx]
lr : sc16is7xx_gpio_direction_output+0x4c/0x108 [sc16is7xx]
...
Call trace:
sc16is7xx_gpio_direction_output+0x68/0x108 [sc16is7xx]
gpiod_direction_output_raw_commit+0x64/0x318
gpiod_direction_output+0xb0/0x170
create_gpio_led+0xec/0x198
gpio_led_probe+0x16c/0x4f0
platform_drv_probe+0x5c/0xb0
really_probe+0xe8/0x448
driver_probe_device+0xe8/0x138
__device_attach_driver+0x94/0x118
bus_for_each_drv+0x8c/0xe0
__device_attach+0x100/0x1b8
device_initial_probe+0x28/0x38
bus_probe_device+0xa4/0xb0
deferred_probe_work_func+0x90/0xe0
process_one_work+0x1c4/0x480
worker_thread+0x54/0x430
kthread+0x138/0x150
ret_from_fork+0x10/0x1c
This patch moves the setup of the GPIO controller functions to later in the
probe function, ensuring the sc16is7xx device has already finished
initialising by the time other devices try to make use of the GPIO lines.
The error handling has also been reordered to reflect the new
initialisation order.
Co-developed-by: Wen-chien Jesse Sung <jesse.sung@canonical.com >
Signed-off-by: Wen-chien Jesse Sung <jesse.sung@canonical.com >
Signed-off-by: Isaac True <isaac.true@canonical.com >
Link: https://lore.kernel.org/r/20221130105529.698385-1-isaac.true@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:53:41 +01:00
Krzysztof Kozlowski
7aa34bb3ae
serial: msm: add lock annotation to msm_set_baud_rate()
...
msm_set_baud_rate() releases and re-acquires the port->lock, thus add
lock annotation for Sparse static code checks.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org >
Link: https://lore.kernel.org/r/20230109152212.343476-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:53:09 +01:00
Christophe JAILLET
03e30f06e5
serial: sccnxp: Use devm_clk_get_enabled() helper
...
The devm_clk_get_enabled() helper:
- calls devm_clk_get()
- calls clk_prepare_enable() and registers what is needed in order to
call clk_disable_unprepare() when needed, as a managed resource.
This simplifies the code.
This also avoids some other warnings/issues. (see [1])
[1]: https://lore.kernel.org/all/20221118233101.never.215-kees@kernel.org/
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr >
Link: https://lore.kernel.org/r/735a807c2df835aa436dcbc76b374f983f89a9af.1672419577.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:51:28 +01:00
Liang He
6e054678ff
serial: ucc_uart: Add of_node_put() in ucc_uart_remove()
...
In ucc_uart_probe(), we have added proper of_node_put() in the failure
paths. However, we miss it before we free *qe_port* in the remove() function.
Signed-off-by: Liang He <windhl@126.com >
Link: https://lore.kernel.org/r/20221205085437.1163682-1-windhl@126.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:51:09 +01:00
Bartosz Golaszewski
2aaa43c707
tty: serial: qcom-geni-serial: add support for serial engine DMA
...
The qcom-geni-serial driver currently only works in SE FIFO mode. This
limits the UART speed to around 180 kB/s. In order to achieve higher
speeds we need to use SE DMA mode.
Keep the console port working in FIFO mode but extend the code to use DMA
for the high-speed port.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
Link: https://lore.kernel.org/r/20221229155030.418800-15-brgl@bgdev.pl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:08:26 +01:00
Bartosz Golaszewski
40ec6d41c8
tty: serial: qcom-geni-serial: use of_device_id data
...
Instead of checking the device compatible in probe(), assign the
device-specific data to struct of_device_id. We'll use it later when
providing SE DMA support.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org >
Link: https://lore.kernel.org/r/20221229155030.418800-13-brgl@bgdev.pl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:08:25 +01:00
Bartosz Golaszewski
0626afe57b
tty: serial: qcom-geni-serial: drop the return value from handle_rx
...
The return value of the handle_rx() callback is never checked. Drop it.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org >
Link: https://lore.kernel.org/r/20221229155030.418800-12-brgl@bgdev.pl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:08:25 +01:00
Bartosz Golaszewski
bd7955840c
tty: serial: qcom-geni-serial: refactor qcom_geni_serial_send_chunk_fifo()
...
Shuffle the code a bit, drop unneeded variables, make types of others
more consistent and use uart_xmit_advance() instead of handling
tail->xmit manually.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
Link: https://lore.kernel.org/r/20221229155030.418800-11-brgl@bgdev.pl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:08:25 +01:00
Bartosz Golaszewski
d420fb491c
tty: serial: qcom-geni-serial: split out the FIFO tx code
...
qcom_geni_serial_handle_tx() is pretty big, let's move the code that
handles the actual writing of data to a separate function which makes
sense in preparation for introducing a dma variant of handle_tx().
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
Link: https://lore.kernel.org/r/20221229155030.418800-10-brgl@bgdev.pl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:08:25 +01:00
Bartosz Golaszewski
3931b8fdec
tty: serial: qcom-geni-serial: remove unneeded tabs
...
Remove redundant indentation in struct member assignment.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org >
Link: https://lore.kernel.org/r/20221229155030.418800-9-brgl@bgdev.pl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:08:25 +01:00
Bartosz Golaszewski
fe6a00e8fc
tty: serial: qcom-geni-serial: refactor qcom_geni_serial_isr()
...
Simplify the conditions in qcom_geni_serial_isr() and fix indentation.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20221229155030.418800-8-brgl@bgdev.pl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:08:25 +01:00
Bartosz Golaszewski
2f853f83f4
tty: serial: qcom-geni-serial: remove stray newlines
...
Remove stray newlines around #ifdefs for consistency with the rest
of the driver code.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org >
Link: https://lore.kernel.org/r/20221229155030.418800-7-brgl@bgdev.pl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:08:25 +01:00
Bartosz Golaszewski
00ce7c6e86
tty: serial: qcom-geni-serial: improve the to_dev_port() macro
...
The member we want to resolve in struct qcom_geni_serial_port is called
uport so we don't need an additional redundant parameter in this macro.
While at it: turn the macro into a static inline function.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org >
Link: https://lore.kernel.org/r/20221229155030.418800-6-brgl@bgdev.pl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:08:25 +01:00
Bartosz Golaszewski
6cde11dbf4
tty: serial: qcom-geni-serial: align #define values
...
Keep the #define symbols aligned for better readability.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org >
Link: https://lore.kernel.org/r/20221229155030.418800-5-brgl@bgdev.pl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:08:25 +01:00
Bartosz Golaszewski
68c6bd92c8
tty: serial: qcom-geni-serial: remove unused symbols
...
Drop all unused symbols from the driver.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org >
Link: https://lore.kernel.org/r/20221229155030.418800-4-brgl@bgdev.pl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:08:25 +01:00
Bartosz Golaszewski
d0fabb0dc1
tty: serial: qcom-geni-serial: drop unneeded forward definitions
...
If we shuffle the code a bit, we can drop all forward definitions of
various static functions.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org >
Link: https://lore.kernel.org/r/20221229155030.418800-3-brgl@bgdev.pl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:08:25 +01:00
Bartosz Golaszewski
d8aca2f968
tty: serial: qcom-geni-serial: stop operations in progress at shutdown
...
We don't stop transmissions in progress at shutdown. This is fine with
FIFO SE mode but with DMA (support for which we'll introduce later) it
causes trouble so fix it now.
Fixes: e83766334f ("tty: serial: qcom_geni_serial: No need to stop tx/rx on UART shutdown")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org >
Link: https://lore.kernel.org/r/20221229155030.418800-2-brgl@bgdev.pl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:08:24 +01:00
Jiri Slaby (SUSE)
bf8baa0066
tty: vt: cache row count in con_scroll()
...
It's used on few places, so make the code easier to follow by caching
the subtraction result.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20230112080136.4929-11-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:06:42 +01:00
Jiri Slaby (SUSE)
424c82af26
tty: vt: saner names for more scroll variables
...
Rename more variables (t, b, s, d) -> (top, bottom, src, dst) to make
them more obvious.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20230112080136.4929-10-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:06:42 +01:00
Jiri Slaby (SUSE)
8aad24ad9d
tty: vt: separate array juggling to juggle_array()
...
The algorithm used for scrolling is the array juggling. It has
complexity O(N) and space complexity O(1). I.e. quite fast w/o
requirements for temporary storage.
Move the algorithm to a separate function so it is obvious what it is.
It is almost generic (except the array type), so if anyone else wants
array rotation, feel free to make it generic and move it to include/.
And rename all the variables from i, j, k, sz, d, and so on to something
saner.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org >
Link: https://lore.kernel.org/r/20230112080136.4929-9-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:06:42 +01:00
Jiri Slaby (SUSE)
287696d5b4
tty: vt: simplify some unicode conditions
...
After previous patches, we can simply test vc->vc_uni_lines, so do so in
many unicode functions. This makes the code more compact. And even use
if (!)
return;
in vc_uniscr_scroll(), so that the whole code is indented on the left.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20230112080136.4929-8-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:06:42 +01:00
Jiri Slaby (SUSE)
441c938168
tty: vt: replace BUG_ON() by WARN_ON_ONCE()
...
No need to panic in vc_uniscr_copy_line(), just warn. This should never
happen though, as vc_uniscr_check() is supposed to be called before
vc_uniscr_copy_line(). And the former checks vc->vc_uni_lines already.
In any case, use _ONCE as vc_uniscr_copy_line() is called repeatedly for
each line. So don't flood the logs, just in case.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20230112080136.4929-7-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:06:42 +01:00
Jiri Slaby (SUSE)
feb36abbed
tty: vt: remove struct uni_screen
...
It contains only lines with pointers to characters (u32s). So use
simple clear 'u32 **lines' all over the code.
This avoids zero-length arrays. It also makes the allocation less
error-prone (size of the struct wasn't taken into account at all).
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20230112080136.4929-6-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:06:42 +01:00
Jiri Slaby (SUSE)
0c8414a682
tty: vt: remove char32_t typedef
...
It boils down to uint32_t, so use u32 directly, instead. This makes the
code more obvious.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20230112080136.4929-5-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:06:42 +01:00
Jiri Slaby (SUSE)
4ba77bfbad
tty: vt: use sizeof(*variable) where possible
...
Instead of sizeof(type), use sizeof(*variable) which is preferred. We
are going to remove the unicode's char32_t typedef, so this makes the
switch easier.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org >
Link: https://lore.kernel.org/r/20230112080136.4929-4-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:06:42 +01:00
Jiri Slaby (SUSE)
70caeac76d
tty: vt: remove reference to undefined NO_VC_UNI_SCREEN
...
NO_VC_UNI_SCREEN is defined nowhere. Remove the last reference to it.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20230112080136.4929-3-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:06:41 +01:00
Jiri Slaby (SUSE)
3b140fbbbb
tty: vt: drop get_vc_uniscr()
...
Its definition depends on the NO_VC_UNI_SCREEN macro. But that is never
defined, so remove all this completely. I.e. expand the macro to
vc->vc_uni_screen everywhere.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20230112080136.4929-2-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:06:41 +01:00
Jiri Slaby (SUSE)
3831c2a454
tty: vt: remove vc_uniscr_debug_check()
...
VC_UNI_SCREEN_DEBUG is always defined as 0, so this code is never
executed. Drop it along with VC_UNI_SCREEN_DEBUG.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20230112080136.4929-1-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:06:41 +01:00
Nate Drude
885692ae3c
tty: serial: fsl_lpuart: increase maximum uart_nr to eight
...
Some SoCs like the i.MX93 have aliases for up to eight UARTs, see:
https://github.com/torvalds/linux/blob/v6.1/arch/arm64/boot/dts/freescale/imx93.dtsi#L31-L38
Increase UART_NR from 6 to 8 to support lpuart7 and lpuart8 and avoid
initialization failures like the following:
[ 0.837146] fsl-lpuart 42690000.serial: serial6 out of range
[ 0.842814] fsl-lpuart: probe of 42690000.serial failed with error -22
Signed-off-by: Nate Drude <nate.d@variscite.com >
Reviewed-by: Sherry Sun <sherry.sun@nxp.com >
Link: https://lore.kernel.org/r/20221222145634.2217793-1-nate.d@variscite.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:05:41 +01:00
Sherry Sun
509597ebca
tty: serial: imx: disable the break condition when shutdown the uart port
...
The comment in imx_uart_shutdown() says to disable the break condition,
but it doesn't actually do that, here fix this by disabling UCR1_SNDBRK
when closing the uart port like other uart drivers do.
Signed-off-by: Sherry Sun <sherry.sun@nxp.com >
Link: https://lore.kernel.org/r/20221214031137.28815-4-sherry.sun@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:05:37 +01:00
Sherry Sun
10929eac41
tty: serial: fsl_lpuart: disable the break condition when shutdown the uart port
...
Need to disable the break condition for lpuart driver when closing
the uart port like other uart drivers do.
Signed-off-by: Sherry Sun <sherry.sun@nxp.com >
Link: https://lore.kernel.org/r/20221214031137.28815-3-sherry.sun@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:05:36 +01:00
Sherry Sun
c4c81db5cf
tty: serial: fsl_lpuart: disable the CTS when send break signal
...
LPUART IP has a bug that it treats the CTS as higher priority than the
break signal, which cause the break signal sending through UARTCTRL_SBK
may impacted by the CTS input if the HW flow control is enabled.
Add this workaround patch to fix the IP bug, we can disable CTS before
asserting SBK to avoid any interference from CTS, and re-enable it when
break off.
Such as for the bluetooth chip power save feature, host can let the BT
chip get into sleep state by sending a UART break signal, and wake it up
by turning off the UART break. If the BT chip enters the sleep mode
successfully, it will pull up the CTS line, if the BT chip is woken up,
it will pull down the CTS line. If without this workaround patch, the
UART TX pin cannot send the break signal successfully as it affected by
the BT CTS pin. After adding this patch, the BT power save feature can
work well.
Signed-off-by: Sherry Sun <sherry.sun@nxp.com >
Link: https://lore.kernel.org/r/20221214031137.28815-2-sherry.sun@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:05:36 +01:00
Sherry Sun
4029dfc034
tty: serial: fsl_lpuart: clear LPUART Status Register in lpuart32_shutdown()
...
The LPUART Status Register needs to be cleared when closing the uart
port to get a clean environment when reopening the uart.
Fixes: 380c966c09 ("tty: serial: fsl_lpuart: add 32-bit register interface support")
Signed-off-by: Sherry Sun <sherry.sun@nxp.com >
Link: https://lore.kernel.org/r/20221125101953.18753-4-sherry.sun@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:05:33 +01:00
Sherry Sun
1d4bd0e4ae
tty: serial: fsl_lpuart: disable Rx/Tx DMA in lpuart32_shutdown()
...
UARTBAUD_RDMAE and UARTBAUD_TDMAE are enabled in lpuart32_startup(), but
lpuart32_shutdown() not disable them, only free the dma ring buffer and
release the dma channels, so here disable the Rx/Tx DMA first in
lpuart32_shutdown().
Fixes: 42b68768e5 ("serial: fsl_lpuart: DMA support for 32-bit variant")
Signed-off-by: Sherry Sun <sherry.sun@nxp.com >
Link: https://lore.kernel.org/r/20221125101953.18753-3-sherry.sun@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:05:33 +01:00
Sherry Sun
e1d91dda0b
tty: serial: fsl_lpuart: only enable Idle Line Interrupt for non-dma case
...
For the lpuart driver, the Idle Line Interrupt Enable now is only needed
for the CPU mode, so enable the UARTCTRL_ILIE at the correct place, and
clear it when shutdown.
Also need to configure the suitable UARTCTRL_IDLECFG, now the value is
0x7, represent 128 idle characters will trigger the Idle Line Interrupt.
Signed-off-by: Sherry Sun <sherry.sun@nxp.com >
Link: https://lore.kernel.org/r/20221125101953.18753-2-sherry.sun@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:05:33 +01:00
Sven Schnelle
7370a25f93
tty/vt: prevent registration of console with invalid number
...
If a user specifies an invalid console like 'console=tty3000',
the vt driver should prevent setting up a vt entry for that.
Suggested-by: Jiri Slaby <jirislaby@kernel.org >
Signed-off-by: Sven Schnelle <svens@linux.ibm.com >
Link: https://lore.kernel.org/r/20221209112737.3222509-3-svens@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:04:56 +01:00
Sven Schnelle
db4df8e9d7
tty: fix out-of-bounds access in tty_driver_lookup_tty()
...
When specifying an invalid console= device like console=tty3270,
tty_driver_lookup_tty() returns the tty struct without checking
whether index is a valid number.
To reproduce:
qemu-system-x86_64 -enable-kvm -nographic -serial mon:stdio \
-kernel ../linux-build-x86/arch/x86/boot/bzImage \
-append "console=ttyS0 console=tty3270"
This crashes with:
[ 0.770599] BUG: kernel NULL pointer dereference, address: 00000000000000ef
[ 0.771265] #PF: supervisor read access in kernel mode
[ 0.771773] #PF: error_code(0x0000) - not-present page
[ 0.772609] Oops: 0000 [#1 ] PREEMPT SMP PTI
[ 0.774878] RIP: 0010:tty_open+0x268/0x6f0
[ 0.784013] chrdev_open+0xbd/0x230
[ 0.784444] ? cdev_device_add+0x80/0x80
[ 0.784920] do_dentry_open+0x1e0/0x410
[ 0.785389] path_openat+0xca9/0x1050
[ 0.785813] do_filp_open+0xaa/0x150
[ 0.786240] file_open_name+0x133/0x1b0
[ 0.786746] filp_open+0x27/0x50
[ 0.787244] console_on_rootfs+0x14/0x4d
[ 0.787800] kernel_init_freeable+0x1e4/0x20d
[ 0.788383] ? rest_init+0xc0/0xc0
[ 0.788881] kernel_init+0x11/0x120
[ 0.789356] ret_from_fork+0x22/0x30
Signed-off-by: Sven Schnelle <svens@linux.ibm.com >
Reviewed-by: Jiri Slaby <jirislaby@kernel.org >
Link: https://lore.kernel.org/r/20221209112737.3222509-2-svens@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:04:56 +01:00
Ilpo Järvinen
8573b2ebce
serial: 8250_early: Convert literals to use defines
...
Use existing defines for the serial register values in 8250_early.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20221125130509.8482-7-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:01:20 +01:00
Ilpo Järvinen
afd216ca17
serial: 8250: Define IIR 64 byte bit & cleanup related code
...
16750 indicates 64 bytes FIFO with a IIR bit. Add define for it and
make related code more obvious.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20221125130509.8482-6-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:01:20 +01:00
Ilpo Järvinen
3398cc4f2b
serial: 8250: Add IIR FIFOs enabled field properly
...
Don't use magic literals & comments but define a real field instead
for UART_IIR_FIFO_ENABLED and name also the values.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20221125130509.8482-5-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:01:20 +01:00
Ilpo Järvinen
67a9aee781
serial: 8250: Cleanup MCR literals
...
Use proper names from MCR bits.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20221125130509.8482-4-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:01:20 +01:00
Ilpo Järvinen
d9c1d3cbde
serial: 8250: Name MSR literals
...
Add UART_MSR_STATUS_BITS for CD, RI, DSR & CTS. Use names for the
literal.
Don't make the define for combined flags part of UAPI.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20221125130509.8482-3-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:01:19 +01:00
Ilpo Järvinen
ef460db2a7
serial: 8250: Use defined IER bits
...
Instead of literal 0x0f, add a define for enabling all IER bits the
8250 driver is interested in.
Don't make the define for combined flags part of UAPI.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20221125130509.8482-2-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 15:01:19 +01:00
Jean Delvare
98a59cd26e
serial: liteuart: drop obsolete dependency on COMPILE_TEST
...
Since commit 0166dc11be ("of: make CONFIG_OF user selectable"), it
is possible to test-build any driver which depends on OF on any
architecture by explicitly selecting OF. Therefore depending on
COMPILE_TEST as an alternative is no longer needed.
It is actually better to always build such drivers with OF enabled,
so that the test builds are closer to how each driver will actually be
built on its intended target. Building them without OF may not test
much as the compiler will optimize out potentially large parts of the
code. In the worst case, this could even pop false positive warnings.
Dropping COMPILE_TEST here improves the quality of our testing and
avoids wasting time on non-existent issues.
Signed-off-by: Jean Delvare <jdelvare@suse.de >
Cc: Karol Gugala <kgugala@antmicro.com >
Cc: Mateusz Holenko <mholenko@antmicro.com >
Cc: Gabriel Somlo <gsomlo@gmail.com >
Cc: Joel Stanley <joel@jms.id.au >
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
Acked-by: Gabriel Somlo <gsomlo@gmail.com >
Link: https://lore.kernel.org/r/20221125142756.3e51a28d@endymion.delvare
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 14:59:55 +01:00
Gabriel Somlo
f1c6c8b1b4
serial: liteuart: move polling putchar() function
...
The polling liteuart_putchar() function is only called from methods
conditionally enabled by CONFIG_SERIAL_LITEUART_CONSOLE. Move its
definition closer to the console code where it is dependent on the
same config option.
Signed-off-by: Gabriel Somlo <gsomlo@gmail.com >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Reviewed-by: Jiri Slaby <jirislaby@kernel.org >
Link: https://lore.kernel.org/r/20221123130500.1030189-15-gsomlo@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 14:59:41 +01:00
Gabriel Somlo
01a305a366
serial: liteuart: add IRQ support for the TX path
...
Switch the TX path to IRQ-driven operation, while maintaining support
for polling mode via the poll timer.
Signed-off-by: Gabriel Somlo <gsomlo@gmail.com >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Reviewed-by: Jiri Slaby <jirislaby@kernel.org >
Link: https://lore.kernel.org/r/20221123130500.1030189-14-gsomlo@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 14:59:41 +01:00
Gabriel Somlo
5602cf99dc
serial: liteuart: add IRQ support for the RX path
...
Add support for IRQ-driven RX. Support for the TX path will be added
in a separate commit.
Signed-off-by: Gabriel Somlo <gsomlo@gmail.com >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Reviewed-by: Jiri Slaby <jirislaby@kernel.org >
Link: https://lore.kernel.org/r/20221123130500.1030189-13-gsomlo@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 14:59:40 +01:00
Gabriel Somlo
7121d86eff
serial: liteuart: move function definitions
...
Move definitions for liteuart_[stop|start]_tx(), liteuart_stop_rx(),
and liteuart_putchar() to a more convenient location in preparation
for adding IRQ support. This patch contains no functional changes.
Signed-off-by: Gabriel Somlo <gsomlo@gmail.com >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org >
Reviewed-by: Jiri Slaby <jirislaby@kernel.org >
Link: https://lore.kernel.org/r/20221123130500.1030189-12-gsomlo@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 14:59:40 +01:00
Gabriel Somlo
5dcceabe8e
serial: liteuart: separate rx loop from poll timer
...
Convert the rx loop into its own dedicated function, and (for now)
call it from the poll timer. This is in preparation for adding irq
support to the receive path.
Signed-off-by: Gabriel Somlo <gsomlo@gmail.com >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Reviewed-by: Jiri Slaby <jirislaby@kernel.org >
Link: https://lore.kernel.org/r/20221123130500.1030189-11-gsomlo@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 14:59:40 +01:00
Gabriel Somlo
a774aa4580
serial: liteuart: clean up rx loop variables
...
The `status` variable will always be `1` when passed into the call
to `uart_insert_char()`, so it can be eliminated altogether.
Use `u8` as the type for `ch`, as it matches the return type of
the `litex_read8()` call which produces its value.
Signed-off-by: Gabriel Somlo <gsomlo@gmail.com >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Reviewed-by: Jiri Slaby <jirislaby@kernel.org >
Link: https://lore.kernel.org/r/20221123130500.1030189-10-gsomlo@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-01-19 14:59:40 +01:00