* Re: [PATCH v2 1/2] tty/serial: atmel: Add is_half_duplex helper
From: Richard Genoud @ 2019-03-26 15:10 UTC (permalink / raw)
To: Razvan Stefanescu, Greg Kroah-Hartman, Jiri Slaby
Cc: Gil Weber, Nicolas Ferre, Alexandre Belloni, Ludovic Desroches,
linux-serial, linux-arm-kernel, linux-kernel
In-Reply-To: <20190319132035.18481-2-razvan.stefanescu@microchip.com>
Le 19/03/2019 à 14:20, Razvan Stefanescu a écrit :
> Use a helper function to check that a port needs to use half duplex
> communication, replacing several occurrences of multi-line bit checking.
>
> Fixes: b389f173aaa1 ("tty/serial: atmel: RS485 half duplex w/DMA: enable
> RX after TX is done")
> Signed-off-by: Razvan Stefanescu <razvan.stefanescu@microchip.com>
Acked-by: Richard Genoud <richard.genoud@gmail.com>
NB: backport on kernel older than 4.20 will fail because of the
SER_ISO7816_ENABLED flag.
> ---
> Changelog:
> v2:
> - remove extra check
> - add fix info
>
> drivers/tty/serial/atmel_serial.c | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index 05147fe24343..b4b89a16a41b 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -231,6 +231,13 @@ static inline void atmel_uart_write_char(struct uart_port *port, u8 value)
> __raw_writeb(value, port->membase + ATMEL_US_THR);
> }
>
> +static inline int atmel_uart_is_half_duplex(struct uart_port *port)
> +{
> + return ((port->rs485.flags & SER_RS485_ENABLED) &&
> + !(port->rs485.flags & SER_RS485_RX_DURING_TX)) ||
> + (port->iso7816.flags & SER_ISO7816_ENABLED);
> +}
> +
> #ifdef CONFIG_SERIAL_ATMEL_PDC
> static bool atmel_use_pdc_rx(struct uart_port *port)
> {
> @@ -608,10 +615,9 @@ static void atmel_stop_tx(struct uart_port *port)
> /* Disable interrupts */
> atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask);
>
> - if (((port->rs485.flags & SER_RS485_ENABLED) &&
> - !(port->rs485.flags & SER_RS485_RX_DURING_TX)) ||
> - port->iso7816.flags & SER_ISO7816_ENABLED)
> + if (atmel_uart_is_half_duplex(port))
> atmel_start_rx(port);
> +
> }
>
> /*
> @@ -628,9 +634,7 @@ static void atmel_start_tx(struct uart_port *port)
> return;
>
> if (atmel_use_pdc_tx(port) || atmel_use_dma_tx(port))
> - if (((port->rs485.flags & SER_RS485_ENABLED) &&
> - !(port->rs485.flags & SER_RS485_RX_DURING_TX)) ||
> - port->iso7816.flags & SER_ISO7816_ENABLED)
> + if (atmel_uart_is_half_duplex(port))
> atmel_stop_rx(port);
>
> if (atmel_use_pdc_tx(port))
> @@ -928,9 +932,7 @@ static void atmel_complete_tx_dma(void *arg)
> */
> if (!uart_circ_empty(xmit))
> atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx);
> - else if (((port->rs485.flags & SER_RS485_ENABLED) &&
> - !(port->rs485.flags & SER_RS485_RX_DURING_TX)) ||
> - port->iso7816.flags & SER_ISO7816_ENABLED) {
> + else if (atmel_uart_is_half_duplex(port)) {
> /* DMA done, stop TX, start RX for RS485 */
> atmel_start_rx(port);
> }
> @@ -1508,9 +1510,7 @@ static void atmel_tx_pdc(struct uart_port *port)
> atmel_uart_writel(port, ATMEL_US_IER,
> atmel_port->tx_done_mask);
> } else {
> - if (((port->rs485.flags & SER_RS485_ENABLED) &&
> - !(port->rs485.flags & SER_RS485_RX_DURING_TX)) ||
> - port->iso7816.flags & SER_ISO7816_ENABLED) {
> + if (atmel_uart_is_half_duplex(port)) {
> /* DMA done, stop TX, start RX for RS485 */
> atmel_start_rx(port);
> }
>
^ permalink raw reply
* tty: uart: loopback test
From: Subhashini Rao Beerisetty @ 2019-03-26 11:52 UTC (permalink / raw)
To: kernelnewbies; +Cc: linux-serial
Hi All,
I’m looking for an userspace ‘C’ test code to transfer a file on UART
Tx line and receive the file on UART Rx line to test loopback
supported serial port.
Can anybody give example of such application?
Thanks
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply
* Re: [PATCH v2 0/4] Add new features for the Spreadtrum serial controller
From: Baolin Wang @ 2019-03-26 10:41 UTC (permalink / raw)
To: Greg KH, jslaby, Rob Herring, Mark Rutland, Orson Zhai,
Chunyan Zhang
Cc: Mark Brown, lanqing.liu, linux-serial, LKML, DTML
In-Reply-To: <cover.1551689518.git.baolin.wang@linaro.org>
Hi Greg,
On Mon, 4 Mar 2019 at 16:59, Baolin Wang <baolin.wang@linaro.org> wrote:
>
> This patch set fixes the baud rate calculation formula issue, as well as
> adding power management support and DMA mode support for the Spreadtrum
> serial controller.
>
> Changes from v1:
> - The patch 1 of V1 was applied, so remove the baud rate fix from this patch set.
> - Add reviewed tag from Rob for patch 1.
> - Fix the incorrect names' order in patch 3.
Could you apply this patch set if no objection from you? Thanks.
--
Baolin Wang
Best Regards
^ permalink raw reply
* Re: [PATCH v6] tty: 8250: fix a missing check for pci_ioremap_bar
From: Jiri Slaby @ 2019-03-26 10:28 UTC (permalink / raw)
To: Andy Shevchenko, Aditya Pakki
Cc: Vinod Koul, Greg Kroah-Hartman, kjlu, linux-kernel, linux-serial
In-Reply-To: <20190326101758.GV9224@smile.fi.intel.com>
On 26. 03. 19, 11:17, Andy Shevchenko wrote:
>> @@ -199,7 +203,10 @@ static void qrk_serial_exit_dma(struct lpss8250 *lpss)
>>
>> if (!param->dma_dev)
>> return;
>> +
>> dw_dma_remove(&lpss->dma_chip);
>> +
>> + iounmap(&lpss->dma_chip->regs);
>
> This is a bit fragile form of writing. Perhaps
It actually won't even compile, will it (it must have been
"(&lpss->dma_chip)->regs")? Do you at least compile-test your patches
before sending?
thanks,
--
js
suse labs
^ permalink raw reply
* Re: [PATCH v6] tty: 8250: fix a missing check for pci_ioremap_bar
From: Andy Shevchenko @ 2019-03-26 10:17 UTC (permalink / raw)
To: Aditya Pakki
Cc: kjlu, Greg Kroah-Hartman, Jiri Slaby, Vinod Koul, linux-serial,
linux-kernel
In-Reply-To: <20190325222147.13342-1-pakki001@umn.edu>
On Mon, Mar 25, 2019 at 05:21:46PM -0500, Aditya Pakki wrote:
> pci_ioremap_bar could fail. The patch returns in case of failure to
> acquire IOMEM. It also releases the acquired resource in the exit path.
Thanks for an update.
One comment below.
After addressing it, take mine
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
>
> ---
> v5: change pci_iounmap to iounmap to pass kbuild errors in other arch
> v4: Missed resource release in dma_probe failure.
> v3: Change the order of pci_iounmap and dw_dma_remove
> v2: Failed to release resource in exit path and incorrect code in non
> DMA case, suggested by Andy Shevchenko
> v1: Missed return by default in CONFIG_SERIAL_8250_DMA, suggested by
> Jiri Slaby
> ---
> drivers/tty/serial/8250/8250_lpss.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/8250_lpss.c
> index 53ca9ba6ab4b..c7c7bf5d7e5e 100644
> --- a/drivers/tty/serial/8250/8250_lpss.c
> +++ b/drivers/tty/serial/8250/8250_lpss.c
> @@ -170,14 +170,18 @@ static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port)
> int ret;
>
> chip->dev = &pdev->dev;
> + chip->pdata = &qrk_serial_dma_pdata;
> chip->irq = pci_irq_vector(pdev, 0);
> chip->regs = pci_ioremap_bar(pdev, 1);
> - chip->pdata = &qrk_serial_dma_pdata;
> + if (!chip->regs)
> + return;
>
> /* Falling back to PIO mode if DMA probing fails */
> ret = dw_dma_probe(chip);
> - if (ret)
> + if (ret) {
> + iounmap(chip->regs);
> return;
> + }
>
> pci_try_set_mwi(pdev);
>
> @@ -199,7 +203,10 @@ static void qrk_serial_exit_dma(struct lpss8250 *lpss)
>
> if (!param->dma_dev)
> return;
> +
> dw_dma_remove(&lpss->dma_chip);
> +
> + iounmap(&lpss->dma_chip->regs);
This is a bit fragile form of writing. Perhaps
struct dw_dma_chip *chip = &lpss->dma_chip;
...
dw_dma_remove(chip);
iounmap(chip->regs);
> }
> #else /* CONFIG_SERIAL_8250_DMA */
> static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port) {}
> --
> 2.17.1
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH] serial: Add Milbeaut serial control
From: Arnd Bergmann @ 2019-03-26 9:57 UTC (permalink / raw)
To: Sugaya Taichi
Cc: Greg Kroah-Hartman, Jiri Slaby, Takao Orito, Kazuhiro Kasai,
Shinji Kanematsu, Jassi Brar, Masami Hiramatsu,
Linux Kernel Mailing List, linux-serial
In-Reply-To: <1553591536-3760-1-git-send-email-sugaya.taichi@socionext.com>
On Tue, Mar 26, 2019 at 10:13 AM Sugaya Taichi
<sugaya.taichi@socionext.com> wrote:
>
> diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
> index 72966bc..961519b 100644
> --- a/drivers/tty/serial/Kconfig
> +++ b/drivers/tty/serial/Kconfig
> @@ -1582,6 +1582,32 @@ config SERIAL_RDA_CONSOLE
> Say 'Y' here if you wish to use the RDA8810PL UART as the system
> console. Only earlycon is implemented currently.
>
> +config SERIAL_MILBEAUT_USIO
> + tristate "Milbeaut USIO/UART serial port support"
> + depends on ARCH_MILBEAUT
> + default y
> + select SERIAL_CORE
> + help
> + This selects the USIO/UART IP found in Socionext Milbeaut SoCs.
In general, it would be good to make it possible to build this on
other architectures for better compile test coverage, e.g. like
config SERIAL_MILBEAUT_USIO
tristate "Milbeaut USIO/UART serial port support"
depends on ARCH_MILBEAUT || COMPILE_TEST
default ARCH_MILBEAUT
You might need additional dependencies like 'depends on OF'
to make this work reliably.
Arnd
^ permalink raw reply
* [PATCH] serial: Add Milbeaut serial control
From: Sugaya Taichi @ 2019-03-26 9:12 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: Takao Orito, Kazuhiro Kasai, Shinji Kanematsu, Jassi Brar,
Masami Hiramatsu, linux-kernel, linux-serial, Sugaya Taichi
Add Milbeaut serial control including earlycon and console.
Signed-off-by: Sugaya Taichi <sugaya.taichi@socionext.com>
---
drivers/tty/serial/Kconfig | 26 ++
drivers/tty/serial/Makefile | 1 +
drivers/tty/serial/milbeaut_usio.c | 621 +++++++++++++++++++++++++++++++++++++
include/uapi/linux/serial_core.h | 3 +
4 files changed, 651 insertions(+)
create mode 100644 drivers/tty/serial/milbeaut_usio.c
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 72966bc..961519b 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -1582,6 +1582,32 @@ config SERIAL_RDA_CONSOLE
Say 'Y' here if you wish to use the RDA8810PL UART as the system
console. Only earlycon is implemented currently.
+config SERIAL_MILBEAUT_USIO
+ tristate "Milbeaut USIO/UART serial port support"
+ depends on ARCH_MILBEAUT
+ default y
+ select SERIAL_CORE
+ help
+ This selects the USIO/UART IP found in Socionext Milbeaut SoCs.
+
+config SERIAL_MILBEAUT_USIO_PORTS
+ int "Maximum number of CSIO/UART ports (1-8)"
+ range 1 8
+ depends on SERIAL_MILBEAUT_USIO
+ default "4"
+
+config SERIAL_MILBEAUT_USIO_CONSOLE
+ bool "Support for console on MILBEAUT USIO/UART serial port"
+ depends on SERIAL_MILBEAUT_USIO=y
+ default y
+ select SERIAL_CORE_CONSOLE
+ select SERIAL_EARLYCON
+ help
+ Say 'Y' here if you wish to use a USIO/UART of Socionext Milbeaut
+ SoCs as the system console (the system console is the device which
+ receives all kernel messages and warnings and which allows logins in
+ single user mode).
+
endmenu
config SERIAL_MCTRL_GPIO
diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index 40b702a..43ca2d0 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -92,6 +92,7 @@ obj-$(CONFIG_SERIAL_PIC32) += pic32_uart.o
obj-$(CONFIG_SERIAL_MPS2_UART) += mps2-uart.o
obj-$(CONFIG_SERIAL_OWL) += owl-uart.o
obj-$(CONFIG_SERIAL_RDA) += rda-uart.o
+obj-$(CONFIG_SERIAL_MILBEAUT_USIO) += milbeaut_usio.o
# GPIOLIB helpers for modem control lines
obj-$(CONFIG_SERIAL_MCTRL_GPIO) += serial_mctrl_gpio.o
diff --git a/drivers/tty/serial/milbeaut_usio.c b/drivers/tty/serial/milbeaut_usio.c
new file mode 100644
index 0000000..d303b7d
--- /dev/null
+++ b/drivers/tty/serial/milbeaut_usio.c
@@ -0,0 +1,621 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018 Socionext Inc.
+ */
+
+#if defined(CONFIG_SERIAL_MILBEAUT_USIO_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#include <linux/clk.h>
+#include <linux/console.h>
+#include <linux/module.h>
+#include <linux/of_irq.h>
+#include <linux/platform_device.h>
+#include <linux/serial_core.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+
+#define USIO_NAME "mlb-usio-uart"
+#define USIO_UART_DEV_NAME "ttyUSI"
+
+static struct uart_port mlb_usio_ports[CONFIG_SERIAL_MILBEAUT_USIO_PORTS];
+
+#define RX 0
+#define TX 1
+static int mlb_usio_irq[CONFIG_SERIAL_MILBEAUT_USIO_PORTS][2];
+
+#define MLB_USIO_REG_SMR 0
+#define MLB_USIO_REG_SCR 1
+#define MLB_USIO_REG_ESCR 2
+#define MLB_USIO_REG_SSR 3
+#define MLB_USIO_REG_DR 4
+#define MLB_USIO_REG_BGR 6
+#define MLB_USIO_REG_FCR 12
+#define MLB_USIO_REG_FBYTE 14
+
+#define MLB_USIO_SMR_SOE BIT(0)
+#define MLB_USIO_SMR_SBL BIT(3)
+#define MLB_USIO_SCR_TXE BIT(0)
+#define MLB_USIO_SCR_RXE BIT(1)
+#define MLB_USIO_SCR_TBIE BIT(2)
+#define MLB_USIO_SCR_TIE BIT(3)
+#define MLB_USIO_SCR_RIE BIT(4)
+#define MLB_USIO_SCR_UPCL BIT(7)
+#define MLB_USIO_ESCR_L_8BIT 0
+#define MLB_USIO_ESCR_L_5BIT 1
+#define MLB_USIO_ESCR_L_6BIT 2
+#define MLB_USIO_ESCR_L_7BIT 3
+#define MLB_USIO_ESCR_P BIT(3)
+#define MLB_USIO_ESCR_PEN BIT(4)
+#define MLB_USIO_ESCR_FLWEN BIT(7)
+#define MLB_USIO_SSR_TBI BIT(0)
+#define MLB_USIO_SSR_TDRE BIT(1)
+#define MLB_USIO_SSR_RDRF BIT(2)
+#define MLB_USIO_SSR_ORE BIT(3)
+#define MLB_USIO_SSR_FRE BIT(4)
+#define MLB_USIO_SSR_PE BIT(5)
+#define MLB_USIO_SSR_REC BIT(7)
+#define MLB_USIO_SSR_BRK BIT(8)
+#define MLB_USIO_FCR_FE1 BIT(0)
+#define MLB_USIO_FCR_FE2 BIT(1)
+#define MLB_USIO_FCR_FCL1 BIT(2)
+#define MLB_USIO_FCR_FCL2 BIT(3)
+#define MLB_USIO_FCR_FSET BIT(4)
+#define MLB_USIO_FCR_FTIE BIT(9)
+#define MLB_USIO_FCR_FDRQ BIT(10)
+#define MLB_USIO_FCR_FRIIE BIT(11)
+
+static void mlb_usio_stop_tx(struct uart_port *port)
+{
+ writew(readw(port->membase + MLB_USIO_REG_FCR) & ~MLB_USIO_FCR_FTIE,
+ port->membase + MLB_USIO_REG_FCR);
+ writeb(readb(port->membase + MLB_USIO_REG_SCR) & ~MLB_USIO_SCR_TBIE,
+ port->membase + MLB_USIO_REG_SCR);
+}
+
+static void mlb_usio_tx_chars(struct uart_port *port)
+{
+ struct circ_buf *xmit = &port->state->xmit;
+ int count;
+
+ writew(readw(port->membase + MLB_USIO_REG_FCR) & ~MLB_USIO_FCR_FTIE,
+ port->membase + MLB_USIO_REG_FCR);
+ writeb(readb(port->membase + MLB_USIO_REG_SCR) &
+ ~(MLB_USIO_SCR_TIE | MLB_USIO_SCR_TBIE),
+ port->membase + MLB_USIO_REG_SCR);
+
+ if (port->x_char) {
+ writew(port->x_char, port->membase + MLB_USIO_REG_DR);
+ port->icount.tx++;
+ port->x_char = 0;
+ return;
+ }
+ if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
+ mlb_usio_stop_tx(port);
+ return;
+ }
+
+ count = port->fifosize -
+ (readw(port->membase + MLB_USIO_REG_FBYTE) & 0xff);
+
+ do {
+ writew(xmit->buf[xmit->tail], port->membase + MLB_USIO_REG_DR);
+
+ xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
+ port->icount.tx++;
+ if (uart_circ_empty(xmit))
+ break;
+
+ } while (--count > 0);
+
+ writew(readw(port->membase + MLB_USIO_REG_FCR) & ~MLB_USIO_FCR_FDRQ,
+ port->membase + MLB_USIO_REG_FCR);
+
+ writeb(readb(port->membase + MLB_USIO_REG_SCR) | MLB_USIO_SCR_TBIE,
+ port->membase + MLB_USIO_REG_SCR);
+
+ if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
+ uart_write_wakeup(port);
+
+ if (uart_circ_empty(xmit))
+ mlb_usio_stop_tx(port);
+}
+
+static void mlb_usio_start_tx(struct uart_port *port)
+{
+ u16 fcr = readw(port->membase + MLB_USIO_REG_FCR);
+
+ writew(fcr | MLB_USIO_FCR_FTIE, port->membase + MLB_USIO_REG_FCR);
+ if (!(fcr & MLB_USIO_FCR_FDRQ))
+ return;
+
+ writeb(readb(port->membase + MLB_USIO_REG_SCR) | MLB_USIO_SCR_TBIE,
+ port->membase + MLB_USIO_REG_SCR);
+
+ if (readb(port->membase + MLB_USIO_REG_SSR) & MLB_USIO_SSR_TBI)
+ mlb_usio_tx_chars(port);
+}
+
+static void mlb_usio_stop_rx(struct uart_port *port)
+{
+ writeb(readb(port->membase + MLB_USIO_REG_SCR) & ~MLB_USIO_SCR_RIE,
+ port->membase + MLB_USIO_REG_SCR);
+}
+
+static void mlb_usio_enable_ms(struct uart_port *port)
+{
+ writeb(readb(port->membase + MLB_USIO_REG_SCR) |
+ MLB_USIO_SCR_RIE | MLB_USIO_SCR_RXE,
+ port->membase + MLB_USIO_REG_SCR);
+}
+
+static void mlb_usio_rx_chars(struct uart_port *port)
+{
+ struct tty_port *ttyport = &port->state->port;
+ unsigned long flag = 0;
+ char ch = 0;
+ u8 status;
+ int max_count = 2;
+
+ while (max_count--) {
+ status = readb(port->membase + MLB_USIO_REG_SSR);
+
+ if (!(status & MLB_USIO_SSR_RDRF))
+ break;
+
+ if (!(status & (MLB_USIO_SSR_ORE | MLB_USIO_SSR_FRE |
+ MLB_USIO_SSR_PE))) {
+ ch = readw(port->membase + MLB_USIO_REG_DR);
+ flag = TTY_NORMAL;
+ port->icount.rx++;
+ if (uart_handle_sysrq_char(port, ch))
+ continue;
+ uart_insert_char(port, status, MLB_USIO_SSR_ORE,
+ ch, flag);
+ continue;
+ }
+ if (status & MLB_USIO_SSR_PE)
+ port->icount.parity++;
+ if (status & MLB_USIO_SSR_ORE)
+ port->icount.overrun++;
+ status &= port->read_status_mask;
+ if (status & MLB_USIO_SSR_BRK) {
+ flag = TTY_BREAK;
+ ch = 0;
+ } else
+ if (status & MLB_USIO_SSR_PE) {
+ flag = TTY_PARITY;
+ ch = 0;
+ } else
+ if (status & MLB_USIO_SSR_FRE) {
+ flag = TTY_FRAME;
+ ch = 0;
+ }
+ if (flag)
+ uart_insert_char(port, status, MLB_USIO_SSR_ORE,
+ ch, flag);
+
+ writeb(readb(port->membase + MLB_USIO_REG_SSR) |
+ MLB_USIO_SSR_REC,
+ port->membase + MLB_USIO_REG_SSR);
+
+ max_count = readw(port->membase + MLB_USIO_REG_FBYTE) >> 8;
+ writew(readw(port->membase + MLB_USIO_REG_FCR) |
+ MLB_USIO_FCR_FE2 | MLB_USIO_FCR_FRIIE,
+ port->membase + MLB_USIO_REG_FCR);
+ }
+
+ tty_flip_buffer_push(ttyport);
+}
+
+static irqreturn_t mlb_usio_rx_irq(int irq, void *dev_id)
+{
+ struct uart_port *port = dev_id;
+
+ spin_lock(&port->lock);
+ mlb_usio_rx_chars(port);
+ spin_unlock(&port->lock);
+
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t mlb_usio_tx_irq(int irq, void *dev_id)
+{
+ struct uart_port *port = dev_id;
+
+ spin_lock(&port->lock);
+ if (readb(port->membase + MLB_USIO_REG_SSR) & MLB_USIO_SSR_TBI)
+ mlb_usio_tx_chars(port);
+ spin_unlock(&port->lock);
+
+ return IRQ_HANDLED;
+}
+
+static unsigned int mlb_usio_tx_empty(struct uart_port *port)
+{
+ return (readb(port->membase + MLB_USIO_REG_SSR) & MLB_USIO_SSR_TBI) ?
+ TIOCSER_TEMT : 0;
+}
+
+static void mlb_usio_set_mctrl(struct uart_port *port, unsigned int mctrl)
+{
+}
+
+static unsigned int mlb_usio_get_mctrl(struct uart_port *port)
+{
+ return TIOCM_CAR | TIOCM_DSR | TIOCM_CTS;
+
+}
+
+static void mlb_usio_break_ctl(struct uart_port *port, int break_state)
+{
+}
+
+static int mlb_usio_startup(struct uart_port *port)
+{
+ const char *portname = to_platform_device(port->dev)->name;
+ unsigned long flags;
+ int ret, index = port->line;
+ unsigned char escr;
+
+ ret = request_irq(mlb_usio_irq[index][RX], mlb_usio_rx_irq,
+ 0, portname, port);
+ if (ret)
+ return ret;
+ ret = request_irq(mlb_usio_irq[index][TX], mlb_usio_tx_irq,
+ 0, portname, port);
+ if (ret) {
+ free_irq(mlb_usio_irq[index][RX], port);
+ return ret;
+ }
+
+ escr = readb(port->membase + MLB_USIO_REG_ESCR);
+ if (of_property_read_bool(port->dev->of_node, "auto-flow-control"))
+ escr |= MLB_USIO_ESCR_FLWEN;
+ spin_lock_irqsave(&port->lock, flags);
+ writeb(0, port->membase + MLB_USIO_REG_SCR);
+ writeb(escr, port->membase + MLB_USIO_REG_ESCR);
+ writeb(MLB_USIO_SCR_UPCL, port->membase + MLB_USIO_REG_SCR);
+ writeb(MLB_USIO_SSR_REC, port->membase + MLB_USIO_REG_SSR);
+ writew(0, port->membase + MLB_USIO_REG_FCR);
+ writew(MLB_USIO_FCR_FCL1 | MLB_USIO_FCR_FCL2,
+ port->membase + MLB_USIO_REG_FCR);
+ writew(MLB_USIO_FCR_FE1 | MLB_USIO_FCR_FE2 | MLB_USIO_FCR_FRIIE,
+ port->membase + MLB_USIO_REG_FCR);
+ writew(0, port->membase + MLB_USIO_REG_FBYTE);
+ writew(BIT(12), port->membase + MLB_USIO_REG_FBYTE);
+
+ writeb(MLB_USIO_SCR_TXE | MLB_USIO_SCR_RIE | MLB_USIO_SCR_TBIE |
+ MLB_USIO_SCR_RXE, port->membase + MLB_USIO_REG_SCR);
+ spin_unlock_irqrestore(&port->lock, flags);
+
+ return 0;
+}
+
+static void mlb_usio_shutdown(struct uart_port *port)
+{
+ int index = port->line;
+
+ free_irq(mlb_usio_irq[index][RX], port);
+ free_irq(mlb_usio_irq[index][TX], port);
+}
+
+static void mlb_usio_set_termios(struct uart_port *port,
+ struct ktermios *termios, struct ktermios *old)
+{
+ unsigned int escr, smr = MLB_USIO_SMR_SOE;
+ unsigned long flags, baud, quot;
+
+ switch (termios->c_cflag & CSIZE) {
+ case CS5:
+ escr = MLB_USIO_ESCR_L_5BIT;
+ break;
+ case CS6:
+ escr = MLB_USIO_ESCR_L_6BIT;
+ break;
+ case CS7:
+ escr = MLB_USIO_ESCR_L_7BIT;
+ break;
+ case CS8:
+ default:
+ escr = MLB_USIO_ESCR_L_8BIT;
+ break;
+ }
+
+ if (termios->c_cflag & CSTOPB)
+ smr |= MLB_USIO_SMR_SBL;
+
+ if (termios->c_cflag & PARENB) {
+ escr |= MLB_USIO_ESCR_PEN;
+ if (termios->c_cflag & PARODD)
+ escr |= MLB_USIO_ESCR_P;
+ }
+ /* Set hard flow control */
+ if (of_property_read_bool(port->dev->of_node, "auto-flow-control") ||
+ (termios->c_cflag & CRTSCTS))
+ escr |= MLB_USIO_ESCR_FLWEN;
+
+ baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk);
+ if (baud > 1)
+ quot = port->uartclk / baud - 1;
+ else
+ quot = 0;
+
+ spin_lock_irqsave(&port->lock, flags);
+ uart_update_timeout(port, termios->c_cflag, baud);
+ port->read_status_mask = MLB_USIO_SSR_ORE | MLB_USIO_SSR_RDRF |
+ MLB_USIO_SSR_TDRE;
+ if (termios->c_iflag & INPCK)
+ port->read_status_mask |= MLB_USIO_SSR_FRE | MLB_USIO_SSR_PE;
+
+ port->ignore_status_mask = 0;
+ if (termios->c_iflag & IGNPAR)
+ port->ignore_status_mask |= MLB_USIO_SSR_FRE | MLB_USIO_SSR_PE;
+ if ((termios->c_iflag & IGNBRK) && (termios->c_iflag & IGNPAR))
+ port->ignore_status_mask |= MLB_USIO_SSR_ORE;
+ if ((termios->c_cflag & CREAD) == 0)
+ port->ignore_status_mask |= MLB_USIO_SSR_RDRF;
+
+ writeb(0, port->membase + MLB_USIO_REG_SCR);
+ writeb(MLB_USIO_SCR_UPCL, port->membase + MLB_USIO_REG_SCR);
+ writeb(MLB_USIO_SSR_REC, port->membase + MLB_USIO_REG_SSR);
+ writew(0, port->membase + MLB_USIO_REG_FCR);
+ writeb(smr, port->membase + MLB_USIO_REG_SMR);
+ writeb(escr, port->membase + MLB_USIO_REG_ESCR);
+ writew(quot, port->membase + MLB_USIO_REG_BGR);
+ writew(0, port->membase + MLB_USIO_REG_FCR);
+ writew(MLB_USIO_FCR_FCL1 | MLB_USIO_FCR_FCL2 | MLB_USIO_FCR_FE1 |
+ MLB_USIO_FCR_FE2 | MLB_USIO_FCR_FRIIE,
+ port->membase + MLB_USIO_REG_FCR);
+ writew(0, port->membase + MLB_USIO_REG_FBYTE);
+ writew(BIT(12), port->membase + MLB_USIO_REG_FBYTE);
+ writeb(MLB_USIO_SCR_RIE | MLB_USIO_SCR_RXE | MLB_USIO_SCR_TBIE |
+ MLB_USIO_SCR_TXE, port->membase + MLB_USIO_REG_SCR);
+ spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static const char *mlb_usio_type(struct uart_port *port)
+{
+ return ((port->type == PORT_MLB_USIO) ? USIO_NAME : NULL);
+}
+
+static void mlb_usio_config_port(struct uart_port *port, int flags)
+{
+ if (flags & UART_CONFIG_TYPE)
+ port->type = PORT_MLB_USIO;
+}
+
+static const struct uart_ops mlb_usio_ops = {
+ .tx_empty = mlb_usio_tx_empty,
+ .set_mctrl = mlb_usio_set_mctrl,
+ .get_mctrl = mlb_usio_get_mctrl,
+ .stop_tx = mlb_usio_stop_tx,
+ .start_tx = mlb_usio_start_tx,
+ .stop_rx = mlb_usio_stop_rx,
+ .enable_ms = mlb_usio_enable_ms,
+ .break_ctl = mlb_usio_break_ctl,
+ .startup = mlb_usio_startup,
+ .shutdown = mlb_usio_shutdown,
+ .set_termios = mlb_usio_set_termios,
+ .type = mlb_usio_type,
+ .config_port = mlb_usio_config_port,
+};
+
+#ifdef CONFIG_SERIAL_MILBEAUT_USIO_CONSOLE
+
+static void mlb_usio_console_putchar(struct uart_port *port, int c)
+{
+ while (!(readb(port->membase + MLB_USIO_REG_SSR) & MLB_USIO_SSR_TDRE))
+ cpu_relax();
+
+ writew(c, port->membase + MLB_USIO_REG_DR);
+}
+
+static void mlb_usio_console_write(struct console *co, const char *s,
+ unsigned int count)
+{
+ struct uart_port *port = &mlb_usio_ports[co->index];
+
+ uart_console_write(port, s, count, mlb_usio_console_putchar);
+}
+
+static int __init mlb_usio_console_setup(struct console *co, char *options)
+{
+ struct uart_port *port;
+ int baud = 115200;
+ int parity = 'n';
+ int flow = 'n';
+ int bits = 8;
+
+ if (co->index >= CONFIG_SERIAL_MILBEAUT_USIO_PORTS)
+ return -ENODEV;
+
+ port = &mlb_usio_ports[co->index];
+ if (!port->membase)
+ return -ENODEV;
+
+
+ if (options)
+ uart_parse_options(options, &baud, &parity, &bits, &flow);
+
+ if (of_property_read_bool(port->dev->of_node, "auto-flow-control"))
+ flow = 'r';
+
+ return uart_set_options(port, co, baud, parity, bits, flow);
+}
+
+
+static struct uart_driver mlb_usio_uart_driver;
+static struct console mlb_usio_console = {
+ .name = USIO_UART_DEV_NAME,
+ .write = mlb_usio_console_write,
+ .device = uart_console_device,
+ .setup = mlb_usio_console_setup,
+ .flags = CON_PRINTBUFFER,
+ .index = -1,
+ .data = &mlb_usio_uart_driver,
+};
+
+static int __init mlb_usio_console_init(void)
+{
+ register_console(&mlb_usio_console);
+ return 0;
+}
+console_initcall(mlb_usio_console_init);
+
+
+static void mlb_usio_early_console_write(struct console *co, const char *s,
+ u_int count)
+{
+ struct earlycon_device *dev = co->data;
+
+ uart_console_write(&dev->port, s, count, mlb_usio_console_putchar);
+}
+
+static int __init mlb_usio_early_console_setup(struct earlycon_device *device,
+ const char *opt)
+{
+ if (!device->port.membase)
+ return -ENODEV;
+ device->con->write = mlb_usio_early_console_write;
+ return 0;
+}
+
+OF_EARLYCON_DECLARE(mlb_usio, "socionext,milbeaut-usio-uart",
+ mlb_usio_early_console_setup);
+
+#define USIO_CONSOLE (&mlb_usio_console)
+#else
+#define USIO_CONSOLE NULL
+#endif
+
+static struct uart_driver mlb_usio_uart_driver = {
+ .owner = THIS_MODULE,
+ .driver_name = USIO_NAME,
+ .dev_name = USIO_UART_DEV_NAME,
+ .cons = USIO_CONSOLE,
+ .nr = CONFIG_SERIAL_MILBEAUT_USIO_PORTS,
+};
+
+static int mlb_usio_probe(struct platform_device *pdev)
+{
+ struct clk *clk = devm_clk_get(&pdev->dev, 0);
+ struct uart_port *port;
+ struct resource *res;
+ int index = 0;
+ int ret;
+
+ if (IS_ERR(clk)) {
+ dev_err(&pdev->dev, "Missing clock\n");
+ return PTR_ERR(clk);
+ }
+ ret = clk_prepare_enable(clk);
+ if (ret) {
+ dev_err(&pdev->dev, "Clock enable failed: %d\n", ret);
+ return ret;
+ }
+ of_property_read_u32(pdev->dev.of_node, "index", &index);
+ port = &mlb_usio_ports[index];
+
+ port->private_data = (void *)clk;
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (res == NULL) {
+ dev_err(&pdev->dev, "Missing regs\n");
+ ret = -ENODEV;
+ goto failed;
+ }
+ port->mapbase = res->start;
+ port->membase = ioremap(res->start, (res->end - res->start + 1));
+ port->membase = devm_ioremap(&pdev->dev, res->start,
+ resource_size(res));
+
+ ret = platform_get_irq_byname(pdev, "rx");
+ mlb_usio_irq[index][RX] = ret;
+
+ ret = platform_get_irq_byname(pdev, "tx");
+ mlb_usio_irq[index][TX] = ret;
+
+ port->irq = mlb_usio_irq[index][RX];
+ port->uartclk = clk_get_rate(clk);
+ port->fifosize = 128;
+ port->iotype = UPIO_MEM32;
+ port->flags = UPF_BOOT_AUTOCONF | UPF_SPD_VHI;
+ port->line = index;
+ port->ops = &mlb_usio_ops;
+ port->dev = &pdev->dev;
+
+ ret = uart_add_one_port(&mlb_usio_uart_driver, port);
+ if (ret) {
+ dev_err(&pdev->dev, "Adding port failed: %d\n", ret);
+ goto failed1;
+ }
+ return 0;
+
+failed1:
+ iounmap(port->membase);
+
+failed:
+ clk_disable_unprepare(clk);
+ clk_put(clk);
+
+ return ret;
+}
+
+static int mlb_usio_remove(struct platform_device *pdev)
+{
+ struct uart_port *port = &mlb_usio_ports[pdev->id];
+ struct clk *clk = port->private_data;
+
+ uart_remove_one_port(&mlb_usio_uart_driver, port);
+ clk_disable_unprepare(clk);
+ clk_put(clk);
+
+ return 0;
+}
+
+static const struct of_device_id mlb_usio_dt_ids[] = {
+ { .compatible = "socionext,milbeaut-usio-uart" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, mlb_usio_dt_ids);
+
+static struct platform_driver mlb_usio_driver = {
+ .probe = mlb_usio_probe,
+ .remove = mlb_usio_remove,
+ .driver = {
+ .name = USIO_NAME,
+ .of_match_table = mlb_usio_dt_ids,
+ },
+};
+
+static int __init mlb_usio_init(void)
+{
+ int ret = uart_register_driver(&mlb_usio_uart_driver);
+
+ if (ret) {
+ pr_err("%s: uart registration failed: %d\n", __func__, ret);
+ return ret;
+ }
+ ret = platform_driver_register(&mlb_usio_driver);
+ if (ret) {
+ uart_unregister_driver(&mlb_usio_uart_driver);
+ pr_err("%s: drv registration failed: %d\n", __func__, ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+static void __exit mlb_usio_exit(void)
+{
+ platform_driver_unregister(&mlb_usio_driver);
+ uart_unregister_driver(&mlb_usio_uart_driver);
+}
+
+module_init(mlb_usio_init);
+module_exit(mlb_usio_exit);
+
+MODULE_AUTHOR("SOCIONEXT");
+MODULE_DESCRIPTION("MILBEAUT_USIO/UART Driver");
+MODULE_LICENSE("GPL");
diff --git a/include/uapi/linux/serial_core.h b/include/uapi/linux/serial_core.h
index 6009ee2..a51c747 100644
--- a/include/uapi/linux/serial_core.h
+++ b/include/uapi/linux/serial_core.h
@@ -287,4 +287,7 @@
/* RDA UART */
#define PORT_RDA 118
+/* Socionext Milbeaut UART */
+#define PORT_MLB_USIO 119
+
#endif /* _UAPILINUX_SERIAL_CORE_H */
--
1.9.1
^ permalink raw reply related
* Re: [BACKPORT 4.4.y 00/25] candidates from spreadtrum 4.4 product kernel
From: Greg KH @ 2019-03-26 2:18 UTC (permalink / raw)
To: Arnd Bergmann
Cc: stable, linux-arm-kernel, linux-kernel, linux-mmc, linux-serial,
linux-usb, linux-fsdevel, netdev, linux-mm, dccp, alsa-devel
In-Reply-To: <20190322154425.3852517-1-arnd@arndb.de>
On Fri, Mar 22, 2019 at 04:43:51PM +0100, Arnd Bergmann wrote:
> I took a scripted approach to look at some product kernels for patches
> backported into vendor kernels. This is a set of (mostly) bugfixes I found
> in Spreadtrum's linux-4.4 kernel that are missing in 4.4.176:
>
> ffedbd2210f2 mmc: pwrseq: constify mmc_pwrseq_ops structures
> c10368897e10 ALSA: compress: add support for 32bit calls in a 64bit kernel
> 64a67d4762ce mmc: pwrseq_simple: Make reset-gpios optional to match doc
> 4ec0ef3a8212 USB: iowarrior: fix oops with malicious USB descriptors
> e5905ff1281f mmc: debugfs: Add a restriction to mmc debugfs clock setting
> 4ec96b4cbde8 mmc: make MAN_BKOPS_EN message a debug
> ed9feec72fc1 mmc: sanitize 'bus width' in debug output
> 10a16a01d8f7 mmc: core: shut up "voltage-ranges unspecified" pr_info()
> 9772b47a4c29 usb: dwc3: gadget: Fix suspend/resume during device mode
> 6afedcd23cfd arm64: mm: Add trace_irqflags annotations to do_debug_exception()
> 437db4c6e798 mmc: mmc: Attempt to flush cache before reset
> e51534c80660 mmc: core: fix using wrong io voltage if mmc_select_hs200 fails
> e4c5800a3991 mm/rmap: replace BUG_ON(anon_vma->degree) with VM_WARN_ON
> 04c080080855 extcon: usb-gpio: Don't miss event during suspend/resume
> 78283edf2c01 kbuild: setlocalversion: print error to STDERR
> c526c62d565e usb: gadget: composite: fix dereference after null check coverify warning
> 511a36d2f357 usb: gadget: Add the gserial port checking in gs_start_tx()
> 1712c9373f98 mmc: core: don't try to switch block size for dual rate mode
> 5ea8ea2cb7f1 tcp/dccp: drop SYN packets if accept queue is full
> e1dc9b08051a serial: sprd: adjust TIMEOUT to a big value
> 81be24d263db Hang/soft lockup in d_invalidate with simultaneous calls
> 6f44a0bacb79 arm64: traps: disable irq in die()
> b7d44c36a6f6 usb: renesas_usbhs: gadget: fix unused-but-set-variable warning
> 4350782570b9 serial: sprd: clear timeout interrupt only rather than all interrupts
> 3f3295709ede lib/int_sqrt: optimize small argument
> 32fd87b3bbf5 USB: core: only clean up what we allocated
All now queued up, except for the exceptions I have responded to.
thanks,
greg k-h
^ permalink raw reply
* Re: [BACKPORT 4.4.y 23/25] serial: sprd: clear timeout interrupt only rather than all interrupts
From: Greg KH @ 2019-03-26 1:34 UTC (permalink / raw)
To: Arnd Bergmann
Cc: stable, Jiri Slaby, Orson Zhai, Baolin Wang, Chunyan Zhang,
Lanqing Liu, Chunyan Zhang, Lanqing Liu, linux-serial,
linux-kernel
In-Reply-To: <20190322154425.3852517-24-arnd@arndb.de>
On Fri, Mar 22, 2019 at 04:44:14PM +0100, Arnd Bergmann wrote:
> From: Lanqing Liu <lanqing.liu@spreadtrum.com>
>
> On Spreadtrum's serial device, nearly all of interrupts would be cleared
> by hardware except timeout interrupt. This patch removed the operation
> of clearing all interrupt in irq handler, instead added an if statement
> to check if the timeout interrupt is supposed to be cleared.
>
> Wrongly clearing timeout interrupt would lead to uart data stay in rx
> fifo, that means the driver cannot read them out anymore.
>
> Signed-off-by: Lanqing Liu <lanqing.liu@spreadtrum.com>
> Signed-off-by: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> (cherry picked from commit 4350782570b919f254c1e083261a21c19fcaee90)
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/tty/serial/sprd_serial.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Also added to 4.9.y
^ permalink raw reply
* Re: [BACKPORT 4.4.y 19/25] serial: sprd: adjust TIMEOUT to a big value
From: Greg KH @ 2019-03-26 1:21 UTC (permalink / raw)
To: Arnd Bergmann
Cc: stable, Jiri Slaby, Orson Zhai, Baolin Wang, Chunyan Zhang,
Wei Qiao, Chunyan Zhang, Lanqing Liu, linux-serial, linux-kernel
In-Reply-To: <20190322154425.3852517-20-arnd@arndb.de>
On Fri, Mar 22, 2019 at 04:44:10PM +0100, Arnd Bergmann wrote:
> From: Wei Qiao <wei.qiao@spreadtrum.com>
>
> SPRD_TIMEOUT was 256, which is too small to wait until the status
> switched to workable in a while loop, so that the earlycon could
> not work correctly.
>
> Signed-off-by: Wei Qiao <wei.qiao@spreadtrum.com>
> Signed-off-by: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> (cherry picked from commit e1dc9b08051a2c2e694edf48d1e704f07c7c143c)
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/tty/serial/sprd_serial.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Also applied to 4.9.y
^ permalink raw reply
* [PATCH v6] tty: 8250: fix a missing check for pci_ioremap_bar
From: Aditya Pakki @ 2019-03-25 22:21 UTC (permalink / raw)
To: pakki001
Cc: kjlu, Greg Kroah-Hartman, Jiri Slaby, Vinod Koul, Andy Shevchenko,
linux-serial, linux-kernel
pci_ioremap_bar could fail. The patch returns in case of failure to
acquire IOMEM. It also releases the acquired resource in the exit path.
Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
v5: change pci_iounmap to iounmap to pass kbuild errors in other arch
v4: Missed resource release in dma_probe failure.
v3: Change the order of pci_iounmap and dw_dma_remove
v2: Failed to release resource in exit path and incorrect code in non
DMA case, suggested by Andy Shevchenko
v1: Missed return by default in CONFIG_SERIAL_8250_DMA, suggested by
Jiri Slaby
---
drivers/tty/serial/8250/8250_lpss.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/8250_lpss.c
index 53ca9ba6ab4b..c7c7bf5d7e5e 100644
--- a/drivers/tty/serial/8250/8250_lpss.c
+++ b/drivers/tty/serial/8250/8250_lpss.c
@@ -170,14 +170,18 @@ static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port)
int ret;
chip->dev = &pdev->dev;
+ chip->pdata = &qrk_serial_dma_pdata;
chip->irq = pci_irq_vector(pdev, 0);
chip->regs = pci_ioremap_bar(pdev, 1);
- chip->pdata = &qrk_serial_dma_pdata;
+ if (!chip->regs)
+ return;
/* Falling back to PIO mode if DMA probing fails */
ret = dw_dma_probe(chip);
- if (ret)
+ if (ret) {
+ iounmap(chip->regs);
return;
+ }
pci_try_set_mwi(pdev);
@@ -199,7 +203,10 @@ static void qrk_serial_exit_dma(struct lpss8250 *lpss)
if (!param->dma_dev)
return;
+
dw_dma_remove(&lpss->dma_chip);
+
+ iounmap(&lpss->dma_chip->regs);
}
#else /* CONFIG_SERIAL_8250_DMA */
static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port) {}
--
2.17.1
^ permalink raw reply related
* [PATCH 18/27] Lock down TIOCSSERIAL
From: Matthew Garrett @ 2019-03-25 22:09 UTC (permalink / raw)
To: jmorris
Cc: linux-security-module, linux-kernel, dhowells, Greg Kroah-Hartman,
Jiri Slaby, linux-serial, Matthew Garrett
In-Reply-To: <20190325220954.29054-1-matthewgarrett@google.com>
From: David Howells <dhowells@redhat.com>
Lock down TIOCSSERIAL as that can be used to change the ioport and irq
settings on a serial port. This only appears to be an issue for the serial
drivers that use the core serial code. All other drivers seem to either
ignore attempts to change port/irq or give an error.
Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Jiri Slaby <jslaby@suse.com>
Cc: linux-serial@vger.kernel.org
Signed-off-by: Matthew Garrett <matthewgarrett@google.com>
---
drivers/tty/serial/serial_core.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index d4cca5bdaf1c..04534877b575 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -842,6 +842,12 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
new_flags = (__force upf_t)new_info->flags;
old_custom_divisor = uport->custom_divisor;
+ if ((change_port || change_irq) &&
+ kernel_is_locked_down("Using TIOCSSERIAL to change device addresses, irqs and dma channels")) {
+ retval = -EPERM;
+ goto exit;
+ }
+
if (!capable(CAP_SYS_ADMIN)) {
retval = -EPERM;
if (change_irq || change_port ||
--
2.21.0.392.gf8f6787159e-goog
^ permalink raw reply related
* Re: [PATCH 0/3] RISC-V SBI earlycon
From: Andreas Schwab @ 2019-03-25 16:23 UTC (permalink / raw)
To: Anup Patel
Cc: Greg Kroah-Hartman, Jiri Slaby, Palmer Dabbelt, Albert Ou,
Atish Patra, Christoph Hellwig, Rob Herring, linux-riscv,
linux-kernel, linux-serial
In-Reply-To: <20181204135507.3706-1-anup@brainfault.org>
On Dez 04 2018, Anup Patel <anup@brainfault.org> wrote:
> This patchset adds RISC-V SBI earlycon and removes RISC-V EARLY_PRINTK.
>
> We should use earlycon over existing EARLY_PRINTK for SBI console because:
> 1. It's a more generic way of implementing early console for debugging
> 2. Current RISC-V EARLY_PRINTK is a compile-time option whereas earlycon
> is enabled at run-time via kernel parameters.
> 3. To use earlycon with SBI, we have to pass "earlycon=sbi" in kernel
> parameters. If earlycon kernel parameter is not provided then kernel
> boots much faster which is very useful in real-world RISC-V deployments.
Why doesn't this earlycon disable itself when the real console kicks in?
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply
* Re: [PATCH v4] tty: 8250: fix a missing check for pci_ioremap_bar
From: kbuild test robot @ 2019-03-25 9:13 UTC (permalink / raw)
Cc: kbuild-all, pakki001, kjlu, Greg Kroah-Hartman, Jiri Slaby,
Andy Shevchenko, Vinod Koul, linux-serial, linux-kernel
In-Reply-To: <20190324164139.23899-1-pakki001@umn.edu>
[-- Attachment #1: Type: text/plain, Size: 2895 bytes --]
Hi Aditya,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on tty/tty-testing]
[also build test WARNING on v5.1-rc2 next-20190325]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Aditya-Pakki/tty-8250-fix-a-missing-check-for-pci_ioremap_bar/20190325-151723
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
config: i386-randconfig-a2-201912 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All warnings (new ones prefixed by >>):
drivers/tty/serial/8250/8250_lpss.c: In function 'qrk_serial_exit_dma':
drivers/tty/serial/8250/8250_lpss.c:207:45: error: invalid type argument of '->' (have 'struct dw_dma_chip')
pci_iounmap(param->dma_dev, &lpss->dma_chip->regs);
^
>> drivers/tty/serial/8250/8250_lpss.c:207:14: warning: passing argument 1 of 'pci_iounmap' from incompatible pointer type
pci_iounmap(param->dma_dev, &lpss->dma_chip->regs);
^
In file included from arch/x86/include/asm/io.h:232:0,
from arch/x86/include/asm/realmode.h:15,
from arch/x86/include/asm/acpi.h:33,
from arch/x86/include/asm/fixmap.h:29,
from arch/x86/include/asm/apic.h:10,
from arch/x86/include/asm/smp.h:13,
from include/linux/smp.h:68,
from include/linux/topology.h:33,
from include/linux/gfp.h:9,
from include/linux/umh.h:4,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from drivers/tty/serial/8250/8250_lpss.c:10:
include/asm-generic/iomap.h:107:13: note: expected 'struct pci_dev *' but argument is of type 'struct device *'
extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
^
vim +/pci_iounmap +207 drivers/tty/serial/8250/8250_lpss.c
197
198 static void qrk_serial_exit_dma(struct lpss8250 *lpss)
199 {
200 struct dw_dma_slave *param = &lpss->dma_param;
201
202 if (!param->dma_dev)
203 return;
204
205 dw_dma_remove(&lpss->dma_chip);
206
> 207 pci_iounmap(param->dma_dev, &lpss->dma_chip->regs);
208 }
209 #else /* CONFIG_SERIAL_8250_DMA */
210 static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port) {}
211 static void qrk_serial_exit_dma(struct lpss8250 *lpss) {}
212 #endif /* !CONFIG_SERIAL_8250_DMA */
213
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29486 bytes --]
^ permalink raw reply
* Re: [PATCH v4] tty: 8250: fix a missing check for pci_ioremap_bar
From: kbuild test robot @ 2019-03-25 8:42 UTC (permalink / raw)
Cc: kbuild-all, pakki001, kjlu, Greg Kroah-Hartman, Jiri Slaby,
Andy Shevchenko, Vinod Koul, linux-serial, linux-kernel
In-Reply-To: <20190324164139.23899-1-pakki001@umn.edu>
Hi Aditya,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on tty/tty-testing]
[also build test WARNING on v5.1-rc2 next-20190325]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Aditya-Pakki/tty-8250-fix-a-missing-check-for-pci_ioremap_bar/20190325-151723
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
sparse warnings: (new ones prefixed by >>)
>> drivers/tty/serial/8250/8250_lpss.c:207:26: sparse: incorrect type in argument 1 (different base types) @@ expected struct pci_dev *dev @@ got truct pci_dev *dev @@
drivers/tty/serial/8250/8250_lpss.c:207:26: expected struct pci_dev *dev
drivers/tty/serial/8250/8250_lpss.c:207:26: got struct device *dma_dev
>> drivers/tty/serial/8250/8250_lpss.c:207:52: sparse: cannot dereference this type
>> drivers/tty/serial/8250/8250_lpss.c:207:20: sparse: call with no type!
vim +207 drivers/tty/serial/8250/8250_lpss.c
197
198 static void qrk_serial_exit_dma(struct lpss8250 *lpss)
199 {
200 struct dw_dma_slave *param = &lpss->dma_param;
201
202 if (!param->dma_dev)
203 return;
204
205 dw_dma_remove(&lpss->dma_chip);
206
> 207 pci_iounmap(param->dma_dev, &lpss->dma_chip->regs);
208 }
209 #else /* CONFIG_SERIAL_8250_DMA */
210 static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port) {}
211 static void qrk_serial_exit_dma(struct lpss8250 *lpss) {}
212 #endif /* !CONFIG_SERIAL_8250_DMA */
213
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
^ permalink raw reply
* Re: [PATCH v4] tty: 8250: fix a missing check for pci_ioremap_bar
From: kbuild test robot @ 2019-03-25 7:50 UTC (permalink / raw)
Cc: kbuild-all, pakki001, kjlu, Greg Kroah-Hartman, Jiri Slaby,
Andy Shevchenko, Vinod Koul, linux-serial, linux-kernel
In-Reply-To: <20190324164139.23899-1-pakki001@umn.edu>
[-- Attachment #1: Type: text/plain, Size: 2967 bytes --]
Hi Aditya,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on tty/tty-testing]
[also build test ERROR on v5.1-rc2 next-20190325]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Aditya-Pakki/tty-8250-fix-a-missing-check-for-pci_ioremap_bar/20190325-151723
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
config: i386-randconfig-x013-201912 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
drivers/tty/serial/8250/8250_lpss.c: In function 'qrk_serial_exit_dma':
>> drivers/tty/serial/8250/8250_lpss.c:207:45: error: invalid type argument of '->' (have 'struct dw_dma_chip')
pci_iounmap(param->dma_dev, &lpss->dma_chip->regs);
^~
>> drivers/tty/serial/8250/8250_lpss.c:207:14: error: passing argument 1 of 'pci_iounmap' from incompatible pointer type [-Werror=incompatible-pointer-types]
pci_iounmap(param->dma_dev, &lpss->dma_chip->regs);
^~~~~
In file included from arch/x86/include/asm/io.h:232:0,
from arch/x86/include/asm/realmode.h:15,
from arch/x86/include/asm/acpi.h:33,
from arch/x86/include/asm/fixmap.h:29,
from arch/x86/include/asm/apic.h:10,
from arch/x86/include/asm/smp.h:13,
from include/linux/smp.h:68,
from include/linux/topology.h:33,
from include/linux/gfp.h:9,
from include/linux/umh.h:4,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from drivers/tty/serial/8250/8250_lpss.c:10:
include/asm-generic/iomap.h:107:13: note: expected 'struct pci_dev *' but argument is of type 'struct device *'
extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
^~~~~~~~~~~
cc1: some warnings being treated as errors
vim +207 drivers/tty/serial/8250/8250_lpss.c
197
198 static void qrk_serial_exit_dma(struct lpss8250 *lpss)
199 {
200 struct dw_dma_slave *param = &lpss->dma_param;
201
202 if (!param->dma_dev)
203 return;
204
205 dw_dma_remove(&lpss->dma_chip);
206
> 207 pci_iounmap(param->dma_dev, &lpss->dma_chip->regs);
208 }
209 #else /* CONFIG_SERIAL_8250_DMA */
210 static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port) {}
211 static void qrk_serial_exit_dma(struct lpss8250 *lpss) {}
212 #endif /* !CONFIG_SERIAL_8250_DMA */
213
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30377 bytes --]
^ permalink raw reply
* Re: [PATCH v5] tty: 8250: fix a missing check for pci_ioremap_bar
From: Jiri Slaby @ 2019-03-25 6:25 UTC (permalink / raw)
To: Aditya Pakki
Cc: Vinod Koul, Andy Shevchenko, Greg Kroah-Hartman, kjlu,
linux-kernel, linux-serial
In-Reply-To: <20190324192209.27202-1-pakki001@umn.edu>
On 24. 03. 19, 20:22, Aditya Pakki wrote:
> pci_ioremap_bar could fail. The patch returns in case of failure to
> acquire IOMEM. It also releases the acquired resource in the exit path.
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
>
> ---
> v4: Missed resource release in dma_probe failure.
> v3: Change the order of pci_iounmap and dw_dma_remove
> v2: Failed to release resource in exit path and incorrect code in non
> DMA case, suggested by Andy Shevchenko
> v1: Missed return by default in CONFIG_SERIAL_8250_DMA, suggested by
> Jiri Slaby
> ---
> drivers/tty/serial/8250/8250_lpss.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/8250_lpss.c
> index 53ca9ba6ab4b..a098902221df 100644
> --- a/drivers/tty/serial/8250/8250_lpss.c
> +++ b/drivers/tty/serial/8250/8250_lpss.c
> @@ -170,14 +170,18 @@ static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port)
> int ret;
>
> chip->dev = &pdev->dev;
> + chip->pdata = &qrk_serial_dma_pdata;
> chip->irq = pci_irq_vector(pdev, 0);
> chip->regs = pci_ioremap_bar(pdev, 1);
> - chip->pdata = &qrk_serial_dma_pdata;
> + if (!chip->regs)
> + return;
>
> /* Falling back to PIO mode if DMA probing fails */
> ret = dw_dma_probe(chip);
> - if (ret)
> + if (ret) {
> + pci_iounmap(pdev, chip->regs);
> return;
> + }
>
> pci_try_set_mwi(pdev);
>
> @@ -199,7 +203,10 @@ static void qrk_serial_exit_dma(struct lpss8250 *lpss)
>
> if (!param->dma_dev)
> return;
> +
> dw_dma_remove(&lpss->dma_chip);
> +
> + pci_iounmap(param->dma_dev, &lpss->dma_chip->regs);
pci_iounmap is a counterpart of pci_iomap, not pci_ioremap_bar.
You should use plain iounmap. pci_iounmap should do the right job on x86
at least too. But I am not so sure about the other archs -- I suspect
s390 to emit a WARNING.
> }
> #else /* CONFIG_SERIAL_8250_DMA */
> static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port) {}
>
thanks,
--
js
suse labs
^ permalink raw reply
* [PATCH v5] tty: 8250: fix a missing check for pci_ioremap_bar
From: Aditya Pakki @ 2019-03-24 19:22 UTC (permalink / raw)
To: pakki001
Cc: kjlu, Greg Kroah-Hartman, Jiri Slaby, Vinod Koul, Andy Shevchenko,
linux-serial, linux-kernel
pci_ioremap_bar could fail. The patch returns in case of failure to
acquire IOMEM. It also releases the acquired resource in the exit path.
Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
v4: Missed resource release in dma_probe failure.
v3: Change the order of pci_iounmap and dw_dma_remove
v2: Failed to release resource in exit path and incorrect code in non
DMA case, suggested by Andy Shevchenko
v1: Missed return by default in CONFIG_SERIAL_8250_DMA, suggested by
Jiri Slaby
---
drivers/tty/serial/8250/8250_lpss.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/8250_lpss.c
index 53ca9ba6ab4b..a098902221df 100644
--- a/drivers/tty/serial/8250/8250_lpss.c
+++ b/drivers/tty/serial/8250/8250_lpss.c
@@ -170,14 +170,18 @@ static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port)
int ret;
chip->dev = &pdev->dev;
+ chip->pdata = &qrk_serial_dma_pdata;
chip->irq = pci_irq_vector(pdev, 0);
chip->regs = pci_ioremap_bar(pdev, 1);
- chip->pdata = &qrk_serial_dma_pdata;
+ if (!chip->regs)
+ return;
/* Falling back to PIO mode if DMA probing fails */
ret = dw_dma_probe(chip);
- if (ret)
+ if (ret) {
+ pci_iounmap(pdev, chip->regs);
return;
+ }
pci_try_set_mwi(pdev);
@@ -199,7 +203,10 @@ static void qrk_serial_exit_dma(struct lpss8250 *lpss)
if (!param->dma_dev)
return;
+
dw_dma_remove(&lpss->dma_chip);
+
+ pci_iounmap(param->dma_dev, &lpss->dma_chip->regs);
}
#else /* CONFIG_SERIAL_8250_DMA */
static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port) {}
--
2.17.1
^ permalink raw reply related
* Re: [PATCH v4] tty: 8250: fix a missing check for pci_ioremap_bar
From: Andy Shevchenko @ 2019-03-24 18:47 UTC (permalink / raw)
To: Aditya Pakki
Cc: Kangjie Lu, Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko,
Vinod Koul, open list:SERIAL DRIVERS, Linux Kernel Mailing List
In-Reply-To: <20190324164139.23899-1-pakki001@umn.edu>
On Sun, Mar 24, 2019 at 6:43 PM Aditya Pakki <pakki001@umn.edu> wrote:
>
> pci_ioremap_bar could fail. The patch returns in case of failure to
> acquire IOMEM. It also releases the acquired resource in the exit path.
This is good per se, but I'm so sorry I found another missed place.
When DMA ->probe() fails, we have to unmap as well.
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
>
> ---
> v3: Change the order of pci_iounmap and dw_dma_remove
> v2: Failed to release resource in exit path and incorrect code in non
> DMA case, suggested by Andy Shevchenko
> v1: Missed return by default in CONFIG_SERIAL_8250_DMA, suggested by
> Jiri Slaby
> ---
> drivers/tty/serial/8250/8250_lpss.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/8250_lpss.c
> index 53ca9ba6ab4b..69d6e32da713 100644
> --- a/drivers/tty/serial/8250/8250_lpss.c
> +++ b/drivers/tty/serial/8250/8250_lpss.c
> @@ -170,9 +170,11 @@ static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port)
> int ret;
>
> chip->dev = &pdev->dev;
> + chip->pdata = &qrk_serial_dma_pdata;
> chip->irq = pci_irq_vector(pdev, 0);
> chip->regs = pci_ioremap_bar(pdev, 1);
> - chip->pdata = &qrk_serial_dma_pdata;
> + if (!chip->regs)
> + return;
>
> /* Falling back to PIO mode if DMA probing fails */
> ret = dw_dma_probe(chip);
> @@ -199,7 +201,10 @@ static void qrk_serial_exit_dma(struct lpss8250 *lpss)
>
> if (!param->dma_dev)
> return;
> +
> dw_dma_remove(&lpss->dma_chip);
> +
> + pci_iounmap(param->dma_dev, &lpss->dma_chip->regs);
> }
> #else /* CONFIG_SERIAL_8250_DMA */
> static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port) {}
> --
> 2.17.1
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* [PATCH v4] tty: 8250: fix a missing check for pci_ioremap_bar
From: Aditya Pakki @ 2019-03-24 16:41 UTC (permalink / raw)
To: pakki001
Cc: kjlu, Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Vinod Koul,
linux-serial, linux-kernel
pci_ioremap_bar could fail. The patch returns in case of failure to
acquire IOMEM. It also releases the acquired resource in the exit path.
Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
v3: Change the order of pci_iounmap and dw_dma_remove
v2: Failed to release resource in exit path and incorrect code in non
DMA case, suggested by Andy Shevchenko
v1: Missed return by default in CONFIG_SERIAL_8250_DMA, suggested by
Jiri Slaby
---
drivers/tty/serial/8250/8250_lpss.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/8250_lpss.c
index 53ca9ba6ab4b..69d6e32da713 100644
--- a/drivers/tty/serial/8250/8250_lpss.c
+++ b/drivers/tty/serial/8250/8250_lpss.c
@@ -170,9 +170,11 @@ static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port)
int ret;
chip->dev = &pdev->dev;
+ chip->pdata = &qrk_serial_dma_pdata;
chip->irq = pci_irq_vector(pdev, 0);
chip->regs = pci_ioremap_bar(pdev, 1);
- chip->pdata = &qrk_serial_dma_pdata;
+ if (!chip->regs)
+ return;
/* Falling back to PIO mode if DMA probing fails */
ret = dw_dma_probe(chip);
@@ -199,7 +201,10 @@ static void qrk_serial_exit_dma(struct lpss8250 *lpss)
if (!param->dma_dev)
return;
+
dw_dma_remove(&lpss->dma_chip);
+
+ pci_iounmap(param->dma_dev, &lpss->dma_chip->regs);
}
#else /* CONFIG_SERIAL_8250_DMA */
static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port) {}
--
2.17.1
^ permalink raw reply related
* Re: [PATCH v3] tty: 8250: fix a missing check for pci_ioremap_bar
From: Andy Shevchenko @ 2019-03-24 16:29 UTC (permalink / raw)
To: Aditya Pakki
Cc: kjlu, Greg Kroah-Hartman, Jiri Slaby, Vinod Koul, linux-serial,
linux-kernel
In-Reply-To: <20190324160901.23001-1-pakki001@umn.edu>
On Sun, Mar 24, 2019 at 11:09:00AM -0500, Aditya Pakki wrote:
> pci_ioremap_bar could fail. The patch returns in case of failure to
> acquire IOMEM. It also releases the acquired resource in the exit path.
Thanks for an update.
Almost, but one think below.
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
>
> ---
> v2: Failed to release resource in exit path and incorrect code in non
> DMA case, suggested by Andy Shevchenko
> v1: Missed return by default in CONFIG_SERIAL_8250_DMA, suggested by
> Jiri Slaby
> ---
> drivers/tty/serial/8250/8250_lpss.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/8250_lpss.c
> index 53ca9ba6ab4b..7889b2552013 100644
> --- a/drivers/tty/serial/8250/8250_lpss.c
> +++ b/drivers/tty/serial/8250/8250_lpss.c
> @@ -170,9 +170,11 @@ static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port)
> int ret;
>
> chip->dev = &pdev->dev;
> + chip->pdata = &qrk_serial_dma_pdata;
> chip->irq = pci_irq_vector(pdev, 0);
> chip->regs = pci_ioremap_bar(pdev, 1);
> - chip->pdata = &qrk_serial_dma_pdata;
> + if (!chip->regs)
> + return;
>
> /* Falling back to PIO mode if DMA probing fails */
> ret = dw_dma_probe(chip);
> @@ -199,6 +201,7 @@ static void qrk_serial_exit_dma(struct lpss8250 *lpss)
>
> if (!param->dma_dev)
> return;
> + pci_iounmap(param->dma_dev, &lpss->dma_chip->regs);
This will fail the DMA driver ->remove() badly.
You need to do this after removal of DMA itself.
See the symmetry with setup above?
> dw_dma_remove(&lpss->dma_chip);
...put it here.
Don't forget to separate from above with blank line.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* [PATCH v3] tty: 8250: fix a missing check for pci_ioremap_bar
From: Aditya Pakki @ 2019-03-24 16:09 UTC (permalink / raw)
To: pakki001
Cc: kjlu, Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Vinod Koul,
linux-serial, linux-kernel
pci_ioremap_bar could fail. The patch returns in case of failure to
acquire IOMEM. It also releases the acquired resource in the exit path.
Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
v2: Failed to release resource in exit path and incorrect code in non
DMA case, suggested by Andy Shevchenko
v1: Missed return by default in CONFIG_SERIAL_8250_DMA, suggested by
Jiri Slaby
---
drivers/tty/serial/8250/8250_lpss.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/8250_lpss.c
index 53ca9ba6ab4b..7889b2552013 100644
--- a/drivers/tty/serial/8250/8250_lpss.c
+++ b/drivers/tty/serial/8250/8250_lpss.c
@@ -170,9 +170,11 @@ static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port)
int ret;
chip->dev = &pdev->dev;
+ chip->pdata = &qrk_serial_dma_pdata;
chip->irq = pci_irq_vector(pdev, 0);
chip->regs = pci_ioremap_bar(pdev, 1);
- chip->pdata = &qrk_serial_dma_pdata;
+ if (!chip->regs)
+ return;
/* Falling back to PIO mode if DMA probing fails */
ret = dw_dma_probe(chip);
@@ -199,6 +201,7 @@ static void qrk_serial_exit_dma(struct lpss8250 *lpss)
if (!param->dma_dev)
return;
+ pci_iounmap(param->dma_dev, &lpss->dma_chip->regs);
dw_dma_remove(&lpss->dma_chip);
}
#else /* CONFIG_SERIAL_8250_DMA */
--
2.17.1
^ permalink raw reply related
* Re: [PATCH 09/24] mmc: mtk-sd: check for valid optional memory resource
From: Fabien Parent @ 2019-03-24 15:18 UTC (permalink / raw)
To: Yingjoe Chen
Cc: Matthias Brugger, robh+dt, mark.rutland, linux-arm-kernel,
devicetree, ryder.lee, linux-watchdog, jjian.zhou, wenzhen.yu,
Stephane Le Provost, sean.wang, linux-mmc, linux-kernel, yong.mao,
linux-spi, linux-gpio, linux-mediatek, hsin-hsiung.wang,
linux-serial, linux-clk, Chaotian Jing, linux-i2c
In-Reply-To: <1553398466.26628.0.camel@mtksdaap41>
On Sun, Mar 24, 2019 at 4:34 AM Yingjoe Chen <yingjoe.chen@mediatek.com> wrote:
>
> On Sat, 2019-03-23 at 22:15 +0100, Fabien Parent wrote:
> > 'top_base' memory region is optional. Check that the resource is valid
> > before using it. This avoid getting a "invalid resource" error message
> > printed by the kernel.
> >
> > Signed-off-by: Fabien Parent <fparent@baylibre.com>
> > ---
> > drivers/mmc/host/mtk-sd.c | 8 +++++---
> > 1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
> > index 833ef0590af8..573aa127d00b 100644
> > --- a/drivers/mmc/host/mtk-sd.c
> > +++ b/drivers/mmc/host/mtk-sd.c
> > @@ -2123,9 +2123,11 @@ static int msdc_drv_probe(struct platform_device *pdev)
> > }
> >
> > res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> > - host->top_base = devm_ioremap_resource(&pdev->dev, res);
> > - if (IS_ERR(host->top_base))
> > - host->top_base = NULL;
> > + if (ret) {
>
> This should be res?
Indeed. Thanks, I will fix it in v2.
> > + host->top_base = devm_ioremap_resource(&pdev->dev, res);
> > + if (IS_ERR(host->top_base))
> > + host->top_base = NULL;
> > + }
> >
> > ret = mmc_regulator_get_supply(mmc);
> > if (ret)
>
>
^ permalink raw reply
* Re: [PATCH 17/24] dt-bindings: wdog: mtk-wdt: add support for MT851
From: Guenter Roeck @ 2019-03-24 15:13 UTC (permalink / raw)
To: Fabien Parent, matthias.bgg, robh+dt, mark.rutland
Cc: sean.wang, ryder.lee, hsin-hsiung.wang, wenzhen.yu, chaotian.jing,
yong.mao, jjian.zhou, devicetree, linux-kernel, linux-i2c,
linux-arm-kernel, linux-mediatek, linux-mmc, linux-gpio,
linux-serial, linux-spi, linux-watchdog, linux-clk,
stephane.leprovost
In-Reply-To: <20190323211612.860-18-fparent@baylibre.com>
On 3/23/19 2:16 PM, Fabien Parent wrote:
> Add binding documentation of mtk-wdt for MT8516 SoC.
>
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
> ---
> Documentation/devicetree/bindings/watchdog/mtk-wdt.txt | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/watchdog/mtk-wdt.txt b/Documentation/devicetree/bindings/watchdog/mtk-wdt.txt
> index 8682d6a93e5b..fd380eb28df5 100644
> --- a/Documentation/devicetree/bindings/watchdog/mtk-wdt.txt
> +++ b/Documentation/devicetree/bindings/watchdog/mtk-wdt.txt
> @@ -9,6 +9,7 @@ Required properties:
> "mediatek,mt7622-wdt", "mediatek,mt6589-wdt": for MT7622
> "mediatek,mt7623-wdt", "mediatek,mt6589-wdt": for MT7623
> "mediatek,mt7629-wdt", "mediatek,mt6589-wdt": for MT7629
> + "mediatek,mt8516-wdt", "mediatek,mt6589-wdt": for MT8516
>
> - reg : Specifies base physical address and size of the registers.
>
>
^ permalink raw reply
* Re: [PATCH v2] tty: 8250: fix a missing check for pci_ioremap_bar
From: Andy Shevchenko @ 2019-03-24 12:31 UTC (permalink / raw)
To: Aditya Pakki
Cc: Kangjie Lu, Greg Kroah-Hartman, Jiri Slaby, Vinod Koul,
Andy Shevchenko, open list:SERIAL DRIVERS,
Linux Kernel Mailing List
In-Reply-To: <CAHp75VfbPue803w06GdJwU_JYcFKEcShLpyGRMhOg9xi4ZwpAA@mail.gmail.com>
On Sun, Mar 24, 2019 at 2:26 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Sun, Mar 24, 2019 at 2:05 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Sun, Mar 24, 2019 at 12:55 AM Aditya Pakki <pakki001@umn.edu> wrote:
> > >
> > > pci_ioremap_bar could fail. The fix captures the failure and
> > > pass an error code upstream. This can avoid potential NULL
> > > pointer dereferences in the future.
> > >
> >
> > NAK.
> > This will break non-DMA case.
>
> > > @@ -172,12 +172,14 @@ static void qrk_serial_setup_dma(struct lpss8250 *lpss, struct uart_port *port)
>
> Just to clarify, what you need is simple
>
> void __iomem *regs;
Sorry for leftover.
> chip->pdata = ... //move it here for better looking code
> chip->irq = ...
> chip->regs = pci_ioremap_bar(...);
And looking into the code it needs pci_iounmap() on exit one.
> if (!chip->regs)
> return;
>
> and thank you for pointing to this.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox