Skip to content

Commit 5163953

Browse files
committed
Merge tag 'tty-5.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial fixes from Greg KH: "Here are some small TTY and Serial driver fixes for 5.16-rc4 to resolve a number of reported problems. They include: - liteuart serial driver fixes - 8250_pci serial driver fixes for pericom devices - 8250 RTS line control fix while in RS-485 mode - tegra serial driver fix - msm_serial driver fix - pl011 serial driver new id - fsl_lpuart revert of broken change - 8250_bcm7271 serial driver fix - MAINTAINERS file update for rpmsg tty driver that came in 5.16-rc1 - vgacon fix for reported problem All of these, except for the 8250_bcm7271 fix have been in linux-next with no reported problem. The 8250_bcm7271 fix was added to the tree on Friday so no chance to be linux-next yet. But it should be fine as the affected developers submitted it" * tag 'tty-5.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: serial: 8250_bcm7271: UART errors after resuming from S2 serial: 8250_pci: rewrite pericom_do_set_divisor() serial: 8250_pci: Fix ACCES entries in pci_serial_quirks array serial: 8250: Fix RTS modem control while in rs485 mode Revert "tty: serial: fsl_lpuart: drop earlycon entry for i.MX8QXP" serial: tegra: Change lower tolerance baud rate limit for tegra20 and tegra30 serial: liteuart: relax compile-test dependencies serial: liteuart: fix minor-number leak on probe errors serial: liteuart: fix use-after-free and memleak on unbind serial: liteuart: Fix NULL pointer dereference in ->remove() vgacon: Propagate console boot parameters before calling `vc_resize' tty: serial: msm_serial: Deactivate RX DMA for polling support serial: pl011: Add ACPI SBSA UART match id serial: core: fix transmit-buffer reset and memleak MAINTAINERS: Add rpmsg tty driver maintainer
2 parents 7587a4a + 9cabe26 commit 5163953

File tree

12 files changed

+95
-33
lines changed

12 files changed

+95
-33
lines changed

MAINTAINERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16502,6 +16502,12 @@ T: git git://linuxtv.org/media_tree.git
1650216502
F: Documentation/devicetree/bindings/media/allwinner,sun8i-a83t-de2-rotate.yaml
1650316503
F: drivers/media/platform/sunxi/sun8i-rotate/
1650416504

16505+
RPMSG TTY DRIVER
16506+
M: Arnaud Pouliquen <[email protected]>
16507+
16508+
S: Maintained
16509+
F: drivers/tty/rpmsg_tty.c
16510+
1650516511
RTL2830 MEDIA DRIVER
1650616512
M: Antti Palosaari <[email protected]>
1650716513

drivers/tty/serial/8250/8250_bcm7271.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ struct brcmuart_priv {
237237
u32 rx_err;
238238
u32 rx_timeout;
239239
u32 rx_abort;
240+
u32 saved_mctrl;
240241
};
241242

242243
static struct dentry *brcmuart_debugfs_root;
@@ -1133,16 +1134,27 @@ static int brcmuart_remove(struct platform_device *pdev)
11331134
static int __maybe_unused brcmuart_suspend(struct device *dev)
11341135
{
11351136
struct brcmuart_priv *priv = dev_get_drvdata(dev);
1137+
struct uart_8250_port *up = serial8250_get_port(priv->line);
1138+
struct uart_port *port = &up->port;
11361139

11371140
serial8250_suspend_port(priv->line);
11381141
clk_disable_unprepare(priv->baud_mux_clk);
11391142

1143+
/*
1144+
* This will prevent resume from enabling RTS before the
1145+
* baud rate has been resored.
1146+
*/
1147+
priv->saved_mctrl = port->mctrl;
1148+
port->mctrl = 0;
1149+
11401150
return 0;
11411151
}
11421152

11431153
static int __maybe_unused brcmuart_resume(struct device *dev)
11441154
{
11451155
struct brcmuart_priv *priv = dev_get_drvdata(dev);
1156+
struct uart_8250_port *up = serial8250_get_port(priv->line);
1157+
struct uart_port *port = &up->port;
11461158
int ret;
11471159

11481160
ret = clk_prepare_enable(priv->baud_mux_clk);
@@ -1165,6 +1177,7 @@ static int __maybe_unused brcmuart_resume(struct device *dev)
11651177
start_rx_dma(serial8250_get_port(priv->line));
11661178
}
11671179
serial8250_resume_port(priv->line);
1180+
port->mctrl = priv->saved_mctrl;
11681181
return 0;
11691182
}
11701183

drivers/tty/serial/8250/8250_pci.c

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,29 +1324,33 @@ pericom_do_set_divisor(struct uart_port *port, unsigned int baud,
13241324
{
13251325
int scr;
13261326
int lcr;
1327-
int actual_baud;
1328-
int tolerance;
13291327

1330-
for (scr = 5 ; scr <= 15 ; scr++) {
1331-
actual_baud = 921600 * 16 / scr;
1332-
tolerance = actual_baud / 50;
1328+
for (scr = 16; scr > 4; scr--) {
1329+
unsigned int maxrate = port->uartclk / scr;
1330+
unsigned int divisor = max(maxrate / baud, 1U);
1331+
int delta = maxrate / divisor - baud;
13331332

1334-
if ((baud < actual_baud + tolerance) &&
1335-
(baud > actual_baud - tolerance)) {
1333+
if (baud > maxrate + baud / 50)
1334+
continue;
13361335

1336+
if (delta > baud / 50)
1337+
divisor++;
1338+
1339+
if (divisor > 0xffff)
1340+
continue;
1341+
1342+
/* Update delta due to possible divisor change */
1343+
delta = maxrate / divisor - baud;
1344+
if (abs(delta) < baud / 50) {
13371345
lcr = serial_port_in(port, UART_LCR);
13381346
serial_port_out(port, UART_LCR, lcr | 0x80);
1339-
1340-
serial_port_out(port, UART_DLL, 1);
1341-
serial_port_out(port, UART_DLM, 0);
1347+
serial_port_out(port, UART_DLL, divisor & 0xff);
1348+
serial_port_out(port, UART_DLM, divisor >> 8 & 0xff);
13421349
serial_port_out(port, 2, 16 - scr);
13431350
serial_port_out(port, UART_LCR, lcr);
13441351
return;
1345-
} else if (baud > actual_baud) {
1346-
break;
13471352
}
13481353
}
1349-
serial8250_do_set_divisor(port, baud, quot, quot_frac);
13501354
}
13511355
static int pci_pericom_setup(struct serial_private *priv,
13521356
const struct pciserial_board *board,
@@ -2291,12 +2295,19 @@ static struct pci_serial_quirk pci_serial_quirks[] = {
22912295
.setup = pci_pericom_setup_four_at_eight,
22922296
},
22932297
{
2294-
.vendor = PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4S,
2298+
.vendor = PCI_VENDOR_ID_ACCESIO,
22952299
.device = PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_4,
22962300
.subvendor = PCI_ANY_ID,
22972301
.subdevice = PCI_ANY_ID,
22982302
.setup = pci_pericom_setup_four_at_eight,
22992303
},
2304+
{
2305+
.vendor = PCI_VENDOR_ID_ACCESIO,
2306+
.device = PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4S,
2307+
.subvendor = PCI_ANY_ID,
2308+
.subdevice = PCI_ANY_ID,
2309+
.setup = pci_pericom_setup_four_at_eight,
2310+
},
23002311
{
23012312
.vendor = PCI_VENDOR_ID_ACCESIO,
23022313
.device = PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_4,

drivers/tty/serial/8250/8250_port.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,13 +2024,6 @@ void serial8250_do_set_mctrl(struct uart_port *port, unsigned int mctrl)
20242024
struct uart_8250_port *up = up_to_u8250p(port);
20252025
unsigned char mcr;
20262026

2027-
if (port->rs485.flags & SER_RS485_ENABLED) {
2028-
if (serial8250_in_MCR(up) & UART_MCR_RTS)
2029-
mctrl |= TIOCM_RTS;
2030-
else
2031-
mctrl &= ~TIOCM_RTS;
2032-
}
2033-
20342027
mcr = serial8250_TIOCM_to_MCR(mctrl);
20352028

20362029
mcr = (mcr & up->mcr_mask) | up->mcr_force | up->mcr;

drivers/tty/serial/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ config SERIAL_LITEUART
15331533
tristate "LiteUART serial port support"
15341534
depends on HAS_IOMEM
15351535
depends on OF || COMPILE_TEST
1536-
depends on LITEX
1536+
depends on LITEX || COMPILE_TEST
15371537
select SERIAL_CORE
15381538
help
15391539
This driver is for the FPGA-based LiteUART serial controller from LiteX

drivers/tty/serial/amba-pl011.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,6 +2947,7 @@ MODULE_DEVICE_TABLE(of, sbsa_uart_of_match);
29472947

29482948
static const struct acpi_device_id __maybe_unused sbsa_uart_acpi_match[] = {
29492949
{ "ARMH0011", 0 },
2950+
{ "ARMHB000", 0 },
29502951
{},
29512952
};
29522953
MODULE_DEVICE_TABLE(acpi, sbsa_uart_acpi_match);

drivers/tty/serial/fsl_lpuart.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,6 +2625,7 @@ OF_EARLYCON_DECLARE(lpuart, "fsl,vf610-lpuart", lpuart_early_console_setup);
26252625
OF_EARLYCON_DECLARE(lpuart32, "fsl,ls1021a-lpuart", lpuart32_early_console_setup);
26262626
OF_EARLYCON_DECLARE(lpuart32, "fsl,ls1028a-lpuart", ls1028a_early_console_setup);
26272627
OF_EARLYCON_DECLARE(lpuart32, "fsl,imx7ulp-lpuart", lpuart32_imx_early_console_setup);
2628+
OF_EARLYCON_DECLARE(lpuart32, "fsl,imx8qxp-lpuart", lpuart32_imx_early_console_setup);
26282629
EARLYCON_DECLARE(lpuart, lpuart_early_console_setup);
26292630
EARLYCON_DECLARE(lpuart32, lpuart32_early_console_setup);
26302631

drivers/tty/serial/liteuart.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,10 @@ static int liteuart_probe(struct platform_device *pdev)
270270

271271
/* get membase */
272272
port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
273-
if (IS_ERR(port->membase))
274-
return PTR_ERR(port->membase);
273+
if (IS_ERR(port->membase)) {
274+
ret = PTR_ERR(port->membase);
275+
goto err_erase_id;
276+
}
275277

276278
/* values not from device tree */
277279
port->dev = &pdev->dev;
@@ -285,14 +287,26 @@ static int liteuart_probe(struct platform_device *pdev)
285287
port->line = dev_id;
286288
spin_lock_init(&port->lock);
287289

288-
return uart_add_one_port(&liteuart_driver, &uart->port);
290+
platform_set_drvdata(pdev, port);
291+
292+
ret = uart_add_one_port(&liteuart_driver, &uart->port);
293+
if (ret)
294+
goto err_erase_id;
295+
296+
return 0;
297+
298+
err_erase_id:
299+
xa_erase(&liteuart_array, uart->id);
300+
301+
return ret;
289302
}
290303

291304
static int liteuart_remove(struct platform_device *pdev)
292305
{
293306
struct uart_port *port = platform_get_drvdata(pdev);
294307
struct liteuart_port *uart = to_liteuart_port(port);
295308

309+
uart_remove_one_port(&liteuart_driver, port);
296310
xa_erase(&liteuart_array, uart->id);
297311

298312
return 0;

drivers/tty/serial/msm_serial.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,9 @@ static void msm_start_rx_dma(struct msm_port *msm_port)
598598
u32 val;
599599
int ret;
600600

601+
if (IS_ENABLED(CONFIG_CONSOLE_POLL))
602+
return;
603+
601604
if (!dma->chan)
602605
return;
603606

drivers/tty/serial/serial-tegra.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,7 @@ static struct tegra_uart_chip_data tegra20_uart_chip_data = {
15061506
.fifo_mode_enable_status = false,
15071507
.uart_max_port = 5,
15081508
.max_dma_burst_bytes = 4,
1509-
.error_tolerance_low_range = 0,
1509+
.error_tolerance_low_range = -4,
15101510
.error_tolerance_high_range = 4,
15111511
};
15121512

@@ -1517,7 +1517,7 @@ static struct tegra_uart_chip_data tegra30_uart_chip_data = {
15171517
.fifo_mode_enable_status = false,
15181518
.uart_max_port = 5,
15191519
.max_dma_burst_bytes = 4,
1520-
.error_tolerance_low_range = 0,
1520+
.error_tolerance_low_range = -4,
15211521
.error_tolerance_high_range = 4,
15221522
};
15231523

0 commit comments

Comments
 (0)