From: Sasha Levin Date: Fri, 24 Nov 2023 04:28:44 +0000 (-0500) Subject: Fixes for 4.19 X-Git-Tag: v4.14.331~79^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=af2d4dc237e657b77241f19aaeea6ee3278ed98e;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.19 Signed-off-by: Sasha Levin --- diff --git a/queue-4.19/serial-meson-remove-redundant-initialization-of-vari.patch b/queue-4.19/serial-meson-remove-redundant-initialization-of-vari.patch new file mode 100644 index 00000000000..3faf7721ee8 --- /dev/null +++ b/queue-4.19/serial-meson-remove-redundant-initialization-of-vari.patch @@ -0,0 +1,48 @@ +From b8f7387fc8b346567d6e3b871e298c81de6f712e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 26 Apr 2021 11:11:06 +0100 +Subject: serial: meson: remove redundant initialization of variable id + +From: Colin Ian King + +[ Upstream commit 021212f5335229ed12e3d31f9b7d30bd3bb66f7d ] + +The variable id being initialized with a value that is never read +and it is being updated later with a new value. The initialization is +redundant and can be removed. Since id is just being used in a for-loop +inside a local scope, move the declaration of id to that scope. + +Reviewed-by: Kevin Hilman +Reviewed-by: Martin Blumenstingl +Signed-off-by: Colin Ian King +Addresses-Coverity: ("Unused value") +Link: https://lore.kernel.org/r/20210426101106.9122-1-colin.king@canonical.com +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: 2a1d728f20ed ("tty: serial: meson: fix hard LOCKUP on crtscts mode") +Signed-off-by: Sasha Levin +--- + drivers/tty/serial/meson_uart.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c +index 4c3616cc00833..6a74a31231ebf 100644 +--- a/drivers/tty/serial/meson_uart.c ++++ b/drivers/tty/serial/meson_uart.c +@@ -664,12 +664,13 @@ static int meson_uart_probe(struct platform_device *pdev) + struct resource *res_mem, *res_irq; + struct uart_port *port; + int ret = 0; +- int id = -1; + + if (pdev->dev.of_node) + pdev->id = of_alias_get_id(pdev->dev.of_node, "serial"); + + if (pdev->id < 0) { ++ int id; ++ + for (id = AML_UART_PORT_OFFSET; id < AML_UART_PORT_NUM; id++) { + if (!meson_ports[id]) { + pdev->id = id; +-- +2.42.0 + diff --git a/queue-4.19/serial-meson-use-platform_get_irq-to-get-the-interru.patch b/queue-4.19/serial-meson-use-platform_get_irq-to-get-the-interru.patch new file mode 100644 index 00000000000..e1b5974d623 --- /dev/null +++ b/queue-4.19/serial-meson-use-platform_get_irq-to-get-the-interru.patch @@ -0,0 +1,69 @@ +From 8c74e96d3137e55f16598271370a3ec8dda10125 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 24 Dec 2021 14:29:10 +0000 +Subject: serial: meson: Use platform_get_irq() to get the interrupt + +From: Lad Prabhakar + +[ Upstream commit 5b68061983471470d4109bac776145245f06bc09 ] + +platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static +allocation of IRQ resources in DT core code, this causes an issue +when using hierarchical interrupt domains using "interrupts" property +in the node as this bypasses the hierarchical setup and messes up the +irq chaining. + +In preparation for removal of static setup of IRQ resource from DT core +code use platform_get_irq(). + +Signed-off-by: Lad Prabhakar +Link: https://lore.kernel.org/r/20211224142917.6966-5-prabhakar.mahadev-lad.rj@bp.renesas.com +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: 2a1d728f20ed ("tty: serial: meson: fix hard LOCKUP on crtscts mode") +Signed-off-by: Sasha Levin +--- + drivers/tty/serial/meson_uart.c | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c +index 7563fd215d816..a193cbc78ebc0 100644 +--- a/drivers/tty/serial/meson_uart.c ++++ b/drivers/tty/serial/meson_uart.c +@@ -661,10 +661,11 @@ static int meson_uart_probe_clocks(struct platform_device *pdev, + + static int meson_uart_probe(struct platform_device *pdev) + { +- struct resource *res_mem, *res_irq; ++ struct resource *res_mem; + struct uart_port *port; + u32 fifosize = 64; /* Default is 64, 128 for EE UART_0 */ + int ret = 0; ++ int irq; + + if (pdev->dev.of_node) + pdev->id = of_alias_get_id(pdev->dev.of_node, "serial"); +@@ -687,9 +688,9 @@ static int meson_uart_probe(struct platform_device *pdev) + if (!res_mem) + return -ENODEV; + +- res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); +- if (!res_irq) +- return -ENODEV; ++ irq = platform_get_irq(pdev, 0); ++ if (irq < 0) ++ return irq; + + of_property_read_u32(pdev->dev.of_node, "fifo-size", &fifosize); + +@@ -714,7 +715,7 @@ static int meson_uart_probe(struct platform_device *pdev) + port->iotype = UPIO_MEM; + port->mapbase = res_mem->start; + port->mapsize = resource_size(res_mem); +- port->irq = res_irq->start; ++ port->irq = irq; + port->flags = UPF_BOOT_AUTOCONF | UPF_LOW_LATENCY; + port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MESON_CONSOLE); + port->dev = &pdev->dev; +-- +2.42.0 + diff --git a/queue-4.19/series b/queue-4.19/series index ccb0bc8cbaf..0f81f0c2c20 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -68,3 +68,9 @@ mcb-fix-error-handling-for-different-scenarios-when-parsing.patch dmaengine-stm32-mdma-correct-desc-prep-when-channel-running.patch s390-cmma-fix-initial-kernel-address-space-page-table-walk.patch s390-cmma-fix-handling-of-swapper_pg_dir-and-invalid_pg_dir.patch +tty-serial-meson-if-no-alias-specified-use-an-availa.patch +tty-serial-migrate-meson_uart-to-use-has_sysrq.patch +serial-meson-remove-redundant-initialization-of-vari.patch +tty-serial-meson-retrieve-port-fifo-size-from-dt.patch +serial-meson-use-platform_get_irq-to-get-the-interru.patch +tty-serial-meson-fix-hard-lockup-on-crtscts-mode.patch diff --git a/queue-4.19/tty-serial-meson-fix-hard-lockup-on-crtscts-mode.patch b/queue-4.19/tty-serial-meson-fix-hard-lockup-on-crtscts-mode.patch new file mode 100644 index 00000000000..7527c2e6c59 --- /dev/null +++ b/queue-4.19/tty-serial-meson-fix-hard-lockup-on-crtscts-mode.patch @@ -0,0 +1,101 @@ +From 75e0269ca4d98027ebc852499da87ee4c5970c8c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 14 Oct 2023 11:39:26 +0000 +Subject: tty: serial: meson: fix hard LOCKUP on crtscts mode + +From: Pavel Krasavin + +[ Upstream commit 2a1d728f20edeee7f26dc307ed9df4e0d23947ab ] + +There might be hard lockup if we set crtscts mode on port without RTS/CTS configured: + +# stty -F /dev/ttyAML6 crtscts; echo 1 > /dev/ttyAML6; echo 2 > /dev/ttyAML6 +[ 95.890386] rcu: INFO: rcu_preempt detected stalls on CPUs/tasks: +[ 95.890857] rcu: 3-...0: (201 ticks this GP) idle=e33c/1/0x4000000000000000 softirq=5844/5846 fqs=4984 +[ 95.900212] rcu: (detected by 2, t=21016 jiffies, g=7753, q=296 ncpus=4) +[ 95.906972] Task dump for CPU 3: +[ 95.910178] task:bash state:R running task stack:0 pid:205 ppid:1 flags:0x00000202 +[ 95.920059] Call trace: +[ 95.922485] __switch_to+0xe4/0x168 +[ 95.925951] 0xffffff8003477508 +[ 95.974379] watchdog: Watchdog detected hard LOCKUP on cpu 3 +[ 95.974424] Modules linked in: 88x2cs(O) rtc_meson_vrtc + +Possible solution would be to not allow to setup crtscts on such port. + +Tested on S905X3 based board. + +Fixes: ff7693d079e5 ("ARM: meson: serial: add MesonX SoC on-chip uart driver") +Cc: stable@vger.kernel.org +Signed-off-by: Pavel Krasavin +Reviewed-by: Neil Armstrong +Reviewed-by: Dmitry Rokosov + +v6: stable tag added +v5: https://lore.kernel.org/lkml/OF43DA36FF.2BD3BB21-ON00258A47.005A8125-00258A47.005A9513@gdc.ru/ +added missed Reviewed-by tags, Fixes tag added according to Dmitry and Neil notes +v4: https://lore.kernel.org/lkml/OF55521400.7512350F-ON00258A47.003F7254-00258A47.0040E15C@gdc.ru/ +More correct patch subject according to Jiri's note +v3: https://lore.kernel.org/lkml/OF6CF5FFA0.CCFD0E8E-ON00258A46.00549EDF-00258A46.0054BB62@gdc.ru/ +"From:" line added to the mail +v2: https://lore.kernel.org/lkml/OF950BEF72.7F425944-ON00258A46.00488A76-00258A46.00497D44@gdc.ru/ +braces for single statement removed according to Dmitry's note +v1: https://lore.kernel.org/lkml/OF28B2B8C9.5BC0CD28-ON00258A46.0037688F-00258A46.0039155B@gdc.ru/ +Link: https://lore.kernel.org/r/OF66360032.51C36182-ON00258A48.003F656B-00258A48.0040092C@gdc.ru + +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/tty/serial/meson_uart.c | 14 +++++++++++--- + 1 file changed, 11 insertions(+), 3 deletions(-) + +diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c +index a193cbc78ebc0..60c0a4079e093 100644 +--- a/drivers/tty/serial/meson_uart.c ++++ b/drivers/tty/serial/meson_uart.c +@@ -367,10 +367,14 @@ static void meson_uart_set_termios(struct uart_port *port, + else + val |= AML_UART_STOP_BIT_1SB; + +- if (cflags & CRTSCTS) +- val &= ~AML_UART_TWO_WIRE_EN; +- else ++ if (cflags & CRTSCTS) { ++ if (port->flags & UPF_HARD_FLOW) ++ val &= ~AML_UART_TWO_WIRE_EN; ++ else ++ termios->c_cflag &= ~CRTSCTS; ++ } else { + val |= AML_UART_TWO_WIRE_EN; ++ } + + writel(val, port->membase + AML_UART_CONTROL); + +@@ -666,6 +670,7 @@ static int meson_uart_probe(struct platform_device *pdev) + u32 fifosize = 64; /* Default is 64, 128 for EE UART_0 */ + int ret = 0; + int irq; ++ bool has_rtscts; + + if (pdev->dev.of_node) + pdev->id = of_alias_get_id(pdev->dev.of_node, "serial"); +@@ -693,6 +698,7 @@ static int meson_uart_probe(struct platform_device *pdev) + return irq; + + of_property_read_u32(pdev->dev.of_node, "fifo-size", &fifosize); ++ has_rtscts = of_property_read_bool(pdev->dev.of_node, "uart-has-rtscts"); + + if (meson_ports[pdev->id]) { + dev_err(&pdev->dev, "port %d already allocated\n", pdev->id); +@@ -717,6 +723,8 @@ static int meson_uart_probe(struct platform_device *pdev) + port->mapsize = resource_size(res_mem); + port->irq = irq; + port->flags = UPF_BOOT_AUTOCONF | UPF_LOW_LATENCY; ++ if (has_rtscts) ++ port->flags |= UPF_HARD_FLOW; + port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MESON_CONSOLE); + port->dev = &pdev->dev; + port->line = pdev->id; +-- +2.42.0 + diff --git a/queue-4.19/tty-serial-meson-if-no-alias-specified-use-an-availa.patch b/queue-4.19/tty-serial-meson-if-no-alias-specified-use-an-availa.patch new file mode 100644 index 00000000000..483c75a5356 --- /dev/null +++ b/queue-4.19/tty-serial-meson-if-no-alias-specified-use-an-availa.patch @@ -0,0 +1,65 @@ +From e7e14b757462fb9ba63ff16201863d50f76b7041 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 14 Jan 2019 17:54:26 +0100 +Subject: tty: serial: meson: if no alias specified use an available id + +From: Loys Ollivier + +[ Upstream commit a26988e8fef4b258d1b771e0f4b2e3b67cb2e044 ] + +At probe, the uart driver tries to get an id from a device tree alias. +When no alias was specified, the driver would return an error and probing +would fail. + +Providing an alias for registering a serial device should not be mandatory. +If the device tree does not specify an alias, provide an id from a reserved +range so that the probing can continue. + +Suggested-by: Rob Herring +Signed-off-by: Loys Ollivier +Reviewed-by: Neil Armstrong +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: 2a1d728f20ed ("tty: serial: meson: fix hard LOCKUP on crtscts mode") +Signed-off-by: Sasha Levin +--- + drivers/tty/serial/meson_uart.c | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c +index 1838d0be37044..849ce8c1ef392 100644 +--- a/drivers/tty/serial/meson_uart.c ++++ b/drivers/tty/serial/meson_uart.c +@@ -72,7 +72,8 @@ + #define AML_UART_BAUD_USE BIT(23) + #define AML_UART_BAUD_XTAL BIT(24) + +-#define AML_UART_PORT_NUM 6 ++#define AML_UART_PORT_NUM 12 ++#define AML_UART_PORT_OFFSET 6 + #define AML_UART_DEV_NAME "ttyAML" + + +@@ -667,10 +668,20 @@ static int meson_uart_probe(struct platform_device *pdev) + struct resource *res_mem, *res_irq; + struct uart_port *port; + int ret = 0; ++ int id = -1; + + if (pdev->dev.of_node) + pdev->id = of_alias_get_id(pdev->dev.of_node, "serial"); + ++ if (pdev->id < 0) { ++ for (id = AML_UART_PORT_OFFSET; id < AML_UART_PORT_NUM; id++) { ++ if (!meson_ports[id]) { ++ pdev->id = id; ++ break; ++ } ++ } ++ } ++ + if (pdev->id < 0 || pdev->id >= AML_UART_PORT_NUM) + return -EINVAL; + +-- +2.42.0 + diff --git a/queue-4.19/tty-serial-meson-retrieve-port-fifo-size-from-dt.patch b/queue-4.19/tty-serial-meson-retrieve-port-fifo-size-from-dt.patch new file mode 100644 index 00000000000..fbd781699bc --- /dev/null +++ b/queue-4.19/tty-serial-meson-retrieve-port-fifo-size-from-dt.patch @@ -0,0 +1,55 @@ +From 98fe54a3f03900c74d48832b0ff75eb350a11ef3 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 18 May 2021 09:58:32 +0200 +Subject: tty: serial: meson: retrieve port FIFO size from DT + +From: Neil Armstrong + +[ Upstream commit 27d44e05d7b85d9d4cfe0a3c0663ea49752ece93 ] + +Now the DT bindings has a property to get the FIFO size for a particular port, +retrieve it and use to setup the FIFO interrupts threshold. + +Reviewed-by: Kevin Hilman +Signed-off-by: Neil Armstrong +Link: https://lore.kernel.org/r/20210518075833.3736038-3-narmstrong@baylibre.com +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: 2a1d728f20ed ("tty: serial: meson: fix hard LOCKUP on crtscts mode") +Signed-off-by: Sasha Levin +--- + drivers/tty/serial/meson_uart.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c +index 6a74a31231ebf..7563fd215d816 100644 +--- a/drivers/tty/serial/meson_uart.c ++++ b/drivers/tty/serial/meson_uart.c +@@ -663,6 +663,7 @@ static int meson_uart_probe(struct platform_device *pdev) + { + struct resource *res_mem, *res_irq; + struct uart_port *port; ++ u32 fifosize = 64; /* Default is 64, 128 for EE UART_0 */ + int ret = 0; + + if (pdev->dev.of_node) +@@ -690,6 +691,8 @@ static int meson_uart_probe(struct platform_device *pdev) + if (!res_irq) + return -ENODEV; + ++ of_property_read_u32(pdev->dev.of_node, "fifo-size", &fifosize); ++ + if (meson_ports[pdev->id]) { + dev_err(&pdev->dev, "port %d already allocated\n", pdev->id); + return -EBUSY; +@@ -719,7 +722,7 @@ static int meson_uart_probe(struct platform_device *pdev) + port->type = PORT_MESON; + port->x_char = 0; + port->ops = &meson_uart_ops; +- port->fifosize = 64; ++ port->fifosize = fifosize; + + meson_ports[pdev->id] = port; + platform_set_drvdata(pdev, port); +-- +2.42.0 + diff --git a/queue-4.19/tty-serial-migrate-meson_uart-to-use-has_sysrq.patch b/queue-4.19/tty-serial-migrate-meson_uart-to-use-has_sysrq.patch new file mode 100644 index 00000000000..65f25294157 --- /dev/null +++ b/queue-4.19/tty-serial-migrate-meson_uart-to-use-has_sysrq.patch @@ -0,0 +1,56 @@ +From f10405e5e2a157f4b387de97d81986d5415cfa61 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 13 Dec 2019 00:06:20 +0000 +Subject: tty/serial: Migrate meson_uart to use has_sysrq + +From: Dmitry Safonov + +[ Upstream commit dca3ac8d3bc9436eb5fd35b80cdcad762fbfa518 ] + +The SUPPORT_SYSRQ ifdeffery is not nice as: +- May create misunderstanding about sizeof(struct uart_port) between + different objects +- Prevents moving functions from serial_core.h +- Reduces readability (well, it's ifdeffery - it's hard to follow) + +In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. +Initialise it in driver's probe and remove ifdeffery. + +Cc: Kevin Hilman +Cc: linux-arm-kernel@lists.infradead.org +Cc: linux-amlogic@lists.infradead.org +Signed-off-by: Dmitry Safonov +Link: https://lore.kernel.org/r/20191213000657.931618-22-dima@arista.com +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: 2a1d728f20ed ("tty: serial: meson: fix hard LOCKUP on crtscts mode") +Signed-off-by: Sasha Levin +--- + drivers/tty/serial/meson_uart.c | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c +index 849ce8c1ef392..4c3616cc00833 100644 +--- a/drivers/tty/serial/meson_uart.c ++++ b/drivers/tty/serial/meson_uart.c +@@ -5,10 +5,6 @@ + * Copyright (C) 2014 Carlo Caione + */ + +-#if defined(CONFIG_SERIAL_MESON_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) +-#define SUPPORT_SYSRQ +-#endif +- + #include + #include + #include +@@ -716,6 +712,7 @@ static int meson_uart_probe(struct platform_device *pdev) + port->mapsize = resource_size(res_mem); + port->irq = res_irq->start; + port->flags = UPF_BOOT_AUTOCONF | UPF_LOW_LATENCY; ++ port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MESON_CONSOLE); + port->dev = &pdev->dev; + port->line = pdev->id; + port->type = PORT_MESON; +-- +2.42.0 +