From: Sasha Levin Date: Sun, 10 Sep 2023 14:39:27 +0000 (-0400) Subject: Fixes for 4.19 X-Git-Tag: v6.1.53~36 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2ff88fc0157820451ebdc958a5ac4cca1d769b63;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.19 Signed-off-by: Sasha Levin --- diff --git a/queue-4.19/sc16is7xx-set-iobase-to-device-index.patch b/queue-4.19/sc16is7xx-set-iobase-to-device-index.patch new file mode 100644 index 00000000000..57906c2cd81 --- /dev/null +++ b/queue-4.19/sc16is7xx-set-iobase-to-device-index.patch @@ -0,0 +1,41 @@ +From c6d4f20ff6d4772957103caef35369968a484216 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 1 Sep 2020 14:03:29 +0200 +Subject: sc16is7xx: Set iobase to device index + +From: Daniel Mack + +[ Upstream commit 5da6b1c079e6804a81e63ab8337224cbd2148c91 ] + +Some derivates of sc16is7xx devices expose more than one tty device to +userspace. If multiple such devices exist in a system, userspace +currently has no clean way to infer which tty maps to which physical +line. + +Set the .iobase value to the relative index within the device to allow +infering the order through sysfs. + +Signed-off-by: Daniel Mack +Link: https://lore.kernel.org/r/20200901120329.4176302-1-daniel@zonque.org +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: 2861ed4d6e6d ("serial: sc16is7xx: fix broken port 0 uart init") +Signed-off-by: Sasha Levin +--- + drivers/tty/serial/sc16is7xx.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c +index 453cdcc9f3223..1ff48f827b2c3 100644 +--- a/drivers/tty/serial/sc16is7xx.c ++++ b/drivers/tty/serial/sc16is7xx.c +@@ -1264,6 +1264,7 @@ static int sc16is7xx_probe(struct device *dev, + s->p[i].port.type = PORT_SC16IS7XX; + s->p[i].port.fifosize = SC16IS7XX_FIFO_SIZE; + s->p[i].port.flags = UPF_FIXED_TYPE | UPF_LOW_LATENCY; ++ s->p[i].port.iobase = i; + s->p[i].port.iotype = UPIO_PORT; + s->p[i].port.uartclk = freq; + s->p[i].port.rs485_config = sc16is7xx_config_rs485; +-- +2.40.1 + diff --git a/queue-4.19/serial-sc16is7xx-fix-broken-port-0-uart-init.patch b/queue-4.19/serial-sc16is7xx-fix-broken-port-0-uart-init.patch new file mode 100644 index 00000000000..cf5e8b7da73 --- /dev/null +++ b/queue-4.19/serial-sc16is7xx-fix-broken-port-0-uart-init.patch @@ -0,0 +1,73 @@ +From 1fa9668e91e0a65049ae20ecc9f93ed03327e9e3 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 7 Aug 2023 17:45:51 -0400 +Subject: serial: sc16is7xx: fix broken port 0 uart init +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Hugo Villeneuve + +[ Upstream commit 2861ed4d6e6d1a2c9de9bf5b0abd996c2dc673d0 ] + +The sc16is7xx_config_rs485() function is called only for the second +port (index 1, channel B), causing initialization problems for the +first port. + +For the sc16is7xx driver, port->membase and port->mapbase are not set, +and their default values are 0. And we set port->iobase to the device +index. This means that when the first device is registered using the +uart_add_one_port() function, the following values will be in the port +structure: + port->membase = 0 + port->mapbase = 0 + port->iobase = 0 + +Therefore, the function uart_configure_port() in serial_core.c will +exit early because of the following check: + /* + * If there isn't a port here, don't do anything further. + */ + if (!port->iobase && !port->mapbase && !port->membase) + return; + +Typically, I2C and SPI drivers do not set port->membase and +port->mapbase. + +The max310x driver sets port->membase to ~0 (all ones). By +implementing the same change in this driver, uart_configure_port() is +now correctly executed for all ports. + +Fixes: dfeae619d781 ("serial: sc16is7xx") +Cc: stable@vger.kernel.org +Signed-off-by: Hugo Villeneuve +Reviewed-by: Ilpo Järvinen +Reviewed-by: Lech Perczak +Tested-by: Lech Perczak +Link: https://lore.kernel.org/r/20230807214556.540627-2-hugo@hugovil.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/tty/serial/sc16is7xx.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c +index 1ff48f827b2c3..d4496a44abdfe 100644 +--- a/drivers/tty/serial/sc16is7xx.c ++++ b/drivers/tty/serial/sc16is7xx.c +@@ -1265,6 +1265,12 @@ static int sc16is7xx_probe(struct device *dev, + s->p[i].port.fifosize = SC16IS7XX_FIFO_SIZE; + s->p[i].port.flags = UPF_FIXED_TYPE | UPF_LOW_LATENCY; + s->p[i].port.iobase = i; ++ /* ++ * Use all ones as membase to make sure uart_configure_port() in ++ * serial_core.c does not abort for SPI/I2C devices where the ++ * membase address is not applicable. ++ */ ++ s->p[i].port.membase = (void __iomem *)~0; + s->p[i].port.iotype = UPIO_PORT; + s->p[i].port.uartclk = freq; + s->p[i].port.rs485_config = sc16is7xx_config_rs485; +-- +2.40.1 + diff --git a/queue-4.19/series b/queue-4.19/series index 4308ec7e4b4..b02207589bc 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -189,3 +189,6 @@ cpufreq-brcmstb-avs-cpufreq-fix-warray-bounds-bug.patch x.509-if-signature-is-unsupported-skip-validation.patch net-handle-arphrd_ppp-in-dev_is_mac_header_xmit.patch pstore-ram-check-start-of-empty-przs-during-init.patch +sc16is7xx-set-iobase-to-device-index.patch +serial-sc16is7xx-fix-broken-port-0-uart-init.patch +usb-typec-tcpci-clear-the-fault-status-bit.patch diff --git a/queue-4.19/usb-typec-tcpci-clear-the-fault-status-bit.patch b/queue-4.19/usb-typec-tcpci-clear-the-fault-status-bit.patch new file mode 100644 index 00000000000..1418f6e3633 --- /dev/null +++ b/queue-4.19/usb-typec-tcpci-clear-the-fault-status-bit.patch @@ -0,0 +1,65 @@ +From b956e4360b54dcb008e6e4067f181ebb2e7b5f68 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 16 Aug 2023 14:25:02 -0300 +Subject: usb: typec: tcpci: clear the fault status bit + +From: Marco Felsch + +[ Upstream commit 23e60c8daf5ec2ab1b731310761b668745fcf6ed ] + +According the "USB Type-C Port Controller Interface Specification v2.0" +the TCPC sets the fault status register bit-7 +(AllRegistersResetToDefault) once the registers have been reset to +their default values. + +This triggers an alert(-irq) on PTN5110 devices albeit we do mask the +fault-irq, which may cause a kernel hang. Fix this generically by writing +a one to the corresponding bit-7. + +Cc: stable@vger.kernel.org +Fixes: 74e656d6b055 ("staging: typec: Type-C Port Controller Interface driver (tcpci)") +Reported-by: "Angus Ainslie (Purism)" +Closes: https://lore.kernel.org/all/20190508002749.14816-2-angus@akkea.ca/ +Reported-by: Christian Bach +Closes: https://lore.kernel.org/regressions/ZR0P278MB07737E5F1D48632897D51AC3EB329@ZR0P278MB0773.CHEP278.PROD.OUTLOOK.COM/t/ +Signed-off-by: Marco Felsch +Signed-off-by: Fabio Estevam +Reviewed-by: Guenter Roeck +Link: https://lore.kernel.org/r/20230816172502.1155079-1-festevam@gmail.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/usb/typec/tcpci.c | 4 ++++ + drivers/usb/typec/tcpci.h | 1 + + 2 files changed, 5 insertions(+) + +diff --git a/drivers/usb/typec/tcpci.c b/drivers/usb/typec/tcpci.c +index 9f98376d9bef4..d1393371b6b0a 100644 +--- a/drivers/usb/typec/tcpci.c ++++ b/drivers/usb/typec/tcpci.c +@@ -379,6 +379,10 @@ static int tcpci_init(struct tcpc_dev *tcpc) + if (time_after(jiffies, timeout)) + return -ETIMEDOUT; + ++ ret = tcpci_write16(tcpci, TCPC_FAULT_STATUS, TCPC_FAULT_STATUS_ALL_REG_RST_TO_DEFAULT); ++ if (ret < 0) ++ return ret; ++ + /* Handle vendor init */ + if (tcpci->data->init) { + ret = tcpci->data->init(tcpci, tcpci->data); +diff --git a/drivers/usb/typec/tcpci.h b/drivers/usb/typec/tcpci.h +index 303ebde265465..dcf60399f161f 100644 +--- a/drivers/usb/typec/tcpci.h ++++ b/drivers/usb/typec/tcpci.h +@@ -72,6 +72,7 @@ + #define TCPC_POWER_STATUS_VBUS_PRES BIT(2) + + #define TCPC_FAULT_STATUS 0x1f ++#define TCPC_FAULT_STATUS_ALL_REG_RST_TO_DEFAULT BIT(7) + + #define TCPC_COMMAND 0x23 + #define TCPC_CMD_WAKE_I2C 0x11 +-- +2.40.1 +