From: Sasha Levin Date: Sun, 10 Sep 2023 14:39:26 +0000 (-0400) Subject: Fixes for 5.4 X-Git-Tag: v6.1.53~37 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dc7ac18305891960f3c8d632c42afcaeb4c2f55d;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.4 Signed-off-by: Sasha Levin --- diff --git a/queue-5.4/sc16is7xx-set-iobase-to-device-index.patch b/queue-5.4/sc16is7xx-set-iobase-to-device-index.patch new file mode 100644 index 00000000000..70a66ccda40 --- /dev/null +++ b/queue-5.4/sc16is7xx-set-iobase-to-device-index.patch @@ -0,0 +1,41 @@ +From 8e9e9d1d4312535db5edbe30a0d6ab4a1455026c 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 d8b015335009b..9b68725d4e9ba 100644 +--- a/drivers/tty/serial/sc16is7xx.c ++++ b/drivers/tty/serial/sc16is7xx.c +@@ -1270,6 +1270,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-5.4/serial-sc16is7xx-fix-broken-port-0-uart-init.patch b/queue-5.4/serial-sc16is7xx-fix-broken-port-0-uart-init.patch new file mode 100644 index 00000000000..66096f57cd6 --- /dev/null +++ b/queue-5.4/serial-sc16is7xx-fix-broken-port-0-uart-init.patch @@ -0,0 +1,73 @@ +From cd7d91af8b9cd8bc0567238d254997ff56af2634 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 9b68725d4e9ba..091cf5fe90304 100644 +--- a/drivers/tty/serial/sc16is7xx.c ++++ b/drivers/tty/serial/sc16is7xx.c +@@ -1271,6 +1271,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-5.4/series b/queue-5.4/series index fcb9c5d38e3..538609414ca 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -234,3 +234,6 @@ pstore-ram-check-start-of-empty-przs-during-init.patch s390-ipl-add-missing-secure-has_secure-file-to-ipl-type-unknown.patch crypto-stm32-fix-loop-iterating-through-scatterlist-for-dma.patch cpufreq-brcmstb-avs-cpufreq-fix-warray-bounds-bug.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-5.4/usb-typec-tcpci-clear-the-fault-status-bit.patch b/queue-5.4/usb-typec-tcpci-clear-the-fault-status-bit.patch new file mode 100644 index 00000000000..fd822f30744 --- /dev/null +++ b/queue-5.4/usb-typec-tcpci-clear-the-fault-status-bit.patch @@ -0,0 +1,65 @@ +From 15fc14055086233675e026fdfa5fa855e978c163 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/tcpm/tcpci.c | 4 ++++ + drivers/usb/typec/tcpm/tcpci.h | 1 + + 2 files changed, 5 insertions(+) + +diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c +index 84b23ae48aeec..ccb72875c8ee5 100644 +--- a/drivers/usb/typec/tcpm/tcpci.c ++++ b/drivers/usb/typec/tcpm/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/tcpm/tcpci.h b/drivers/usb/typec/tcpm/tcpci.h +index 303ebde265465..dcf60399f161f 100644 +--- a/drivers/usb/typec/tcpm/tcpci.h ++++ b/drivers/usb/typec/tcpm/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 +