From patchwork Wed Jan 3 06:18:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 760417 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2081.outbound.protection.outlook.com [40.107.13.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B0041804E; Wed, 3 Jan 2024 06:19:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=kunbus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kunbus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kunbus.com header.i=@kunbus.com header.b="y/yFatKQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AlDcfOGDMVo821yNuIXqhducL8kfwwAmpUoS4l9TdcRZvedWpZ9/KuroUQ6sASKspxEOMSgmPY+U6kxLMZB4iwJ5D5Pg6N8fZodM3Swm5Be7CJnVixSrboepHUmqcsJA4gBefKDHmH2+97Rw/tEoimpm0JNNTzYTkIkKSBxsTMLHtF2Fdrh2I1Fjlz7Uno/zz4Kp0xuDGh/4857pOqSEyxmLNZghg2VryNuTgj9r7cF9hsXyet0ak6kRuYeM2G0K9AX9TUUw6UsT8oX4kF1O1V6eKR5yjjyDcbVi842CR+mzqNeXlRZFVb6JQnXHUVBUzJeNehkujyCSnJVwBUQmkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=A7XY6q1hHzURDCSJAsn272m2uNlivDy635/jnq949R4=; b=jjXsD5k4PVdJRbJTeyZ13Jtb/Tr1XMhbGz6C+F6JamOvKH6QHnWNpMmtiJVyR3i2rvC2/Uarop8SU6SteEqqc86Jcz3lIXC8J7xLhfDrOHB/LPhVlQvlPU6lL3tPLGHwnR2cpuDVULZHhi2+sk8A5Nlin239Lao5sh1xm1NTlNSWo8G1mjApe5eW+W/Fcr6fgR7L10EI8WMwHW3a6U7oM4aZuQqBcBEsZ+aKsewrg23R1xf4tYMjYGp/MU3qmIg5Mc8zFO0PhA63DpLUeeYK6Gb1YIGvZOvb4hyw0fk5O1U7JDK/0LmM6SsfaCOQ2tclXJKgbZNqW1RSi4oU8eEMuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kunbus.com; dmarc=pass action=none header.from=kunbus.com; dkim=pass header.d=kunbus.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kunbus.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=A7XY6q1hHzURDCSJAsn272m2uNlivDy635/jnq949R4=; b=y/yFatKQEjRUiKUCfMpJ32w6fKMxdCTivrLppKwZx7X2LJcKTWp+ZVYaJbCZcVTouVeaDC74rCKXDF/hKVcoHUwDSNCqZX0vsWqp18sbLRWYT8NVcW0W6QMOw7NSgMyD/417BVEpaY2O/aqSVx80ZjAz5ubQ/j2tobB+SB5ppcI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kunbus.com; Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) by GV1P193MB2245.EURP193.PROD.OUTLOOK.COM (2603:10a6:150:2c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.25; Wed, 3 Jan 2024 06:19:10 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::67b0:68bf:2582:19cb]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::67b0:68bf:2582:19cb%6]) with mapi id 15.20.7159.013; Wed, 3 Jan 2024 06:19:10 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: u.kleine-koenig@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, hugo@hugovil.com, m.brock@vanmierlo.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org Subject: [PATCH v7 1/7] serial: Do not hold the port lock when setting rx-during-tx GPIO Date: Wed, 3 Jan 2024 07:18:12 +0100 Message-ID: <20240103061818.564-2-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103061818.564-1-l.sanfilippo@kunbus.com> References: <20240103061818.564-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR0P281CA0267.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b5::13) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|GV1P193MB2245:EE_ X-MS-Office365-Filtering-Correlation-Id: 01f1d246-a59f-4310-bb13-08dc0c23e5c1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Xw+9grU9SzQgsPiQCZgwHiWqVAFooyPGuxUUUYRZ3tPBnr3O6kGiAJVl5hssSf+/CYB+yYg/02O0buQqYcHOSZNZJMEUP7LgHkh4FamFvKc34I16mS68RyxkF2j4dh6ORLrgR5tS4CaDJ2cK8lZ63/of1CN69zZi2tJ/0I1Y7bg1kWtNcegW+6OsQKjoDjcCblD6NZBZiMa2FDBszZzDiRMEx/9nqjX2ca2IwW2cKH7tVwfGhogID4favPnlkkUvKQudsUGz4c0m01P0+e+x0LF4p1SBYh+yZk6R/wj9SR7nlbXMforwgl2qIfr/t3oysxV3f22lVbCkK4bkVOhhKI4UlR0KFL/2e7Adw0juaH2p81NRjDdvtt110FaBH3cjc/2et9ULdjuATWKRFw55BTQ9D276SLm5lNbh+JpId2l9JKnH6Lc/Bg48qfHBI3Uy5TkfxB9edW886K2eBWjZM7GhYRl4ZqIYO9AbuU07MDe8lNPgnvMNsXtd7dusyAffI7ejSZp19sNSspS643zrquzt5JV4J6TGYfpBAkAqiX6okIEWpAXAdfx4rBIH/1uC X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(346002)(396003)(376002)(136003)(39830400003)(366004)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(66556008)(66946007)(66476007)(4326008)(478600001)(316002)(8936002)(8676002)(6486002)(83380400001)(6512007)(6506007)(52116002)(1076003)(2616005)(7416002)(5660300002)(41300700001)(2906002)(36756003)(38100700002)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z6rc2GsGjLTaB7jGhYfVQ6E0snFJMaQ826RF8RURvqyBqs5EYXtaYmBPYMzB7sn9veT6HgNhdoe7CuWl/nzFvKvzY3wWKqE6l14q//MaiDHHAY7cXrgiMJvNjoFuicbTSAljXLFGZzsrjhrEYMatmwgJ+qpLjas9IbcRWAISodn7jeJt6EFHdX4L4c9Bw66fkHM8gSiRDD8D96Hdsf2kqzGgv0crdKJonLpwlVrB3k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/PnYfnL7yzIdfcKSsxZK1PvN+U70sNEbs63/vue9H/xkb80w4+psnISBFfL8J9D7nkSzZrBNm1UUhz3CVs/hYyXba7cqM7rIMsaJKnLj/xVvMgzRagvl2Q0nzDYHdgmoA320KeyDfb3lYbgMUemT+RdW3yCX7ax8EQaiE4IzMV9TBOthSofkHKeAszi4radlRVpfCiHsPVVl92o5Mm4b2TokRXXZ5h+WD9HwoppSXmD0+U0ihxkccBC99kcHaORJ1xLNMPaU5bHsJWR/7TCXDMmsuGngqDx6qmqpAJ99x0V44UJTucL5tXKD/bOH4TQBHbfsKqz/vzmhxgN7WyJYEVRRuVsNccp0kM4IHYRetrb7SXjJP6zyDAQmflgJUgw== X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01f1d246-a59f-4310-bb13-08dc0c23e5c1 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2024 06:19:09.9931 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: aaa4d814-e659-4b0a-9698-1c671f11520b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IpaUicFCG89A6B5Lp6oNH/8QjyZPJ67MA1FIUihfr+VLDtshDyEKLjmbCARQUv5PrqQ0b9wbWtJbGuL5eUuwAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P193MB2245 Both the imx and stm32 driver set the rx-during-tx GPIO in rs485_config(). Since this function is called with the port lock held, this can be a problem in case that setting the GPIO line can sleep (e.g. if a GPIO expander is used which is connected via SPI or I2C). Avoid this issue by moving the GPIO setting outside of the port lock into the serial core and thus making it a generic feature. Also with commit c54d48543689 ("serial: stm32: Add support for rs485 RX_DURING_TX output GPIO") the SER_RS485_RX_DURING_TX flag is only set if a rx-during-tx GPIO is _not_ available, which is wrong. Fix this, too. Furthermore reset old GPIO settings in case that changing the RS485 configuration failed. Fixes: c54d48543689 ("serial: stm32: Add support for rs485 RX_DURING_TX output GPIO") Fixes: ca530cfa968c ("serial: imx: Add support for RS485 RX_DURING_TX output GPIO") Cc: Shawn Guo Cc: Sascha Hauer Cc: stable@vger.kernel.org Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/imx.c | 4 ---- drivers/tty/serial/serial_core.c | 26 ++++++++++++++++++++++++-- drivers/tty/serial/stm32-usart.c | 8 ++------ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 708b9852a575..9cffeb23112b 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1943,10 +1943,6 @@ static int imx_uart_rs485_config(struct uart_port *port, struct ktermios *termio rs485conf->flags & SER_RS485_RX_DURING_TX) imx_uart_start_rx(port); - if (port->rs485_rx_during_tx_gpio) - gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, - !!(rs485conf->flags & SER_RS485_RX_DURING_TX)); - return 0; } diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f1348a509552..d155131f221d 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1402,6 +1402,16 @@ static void uart_set_rs485_termination(struct uart_port *port, !!(rs485->flags & SER_RS485_TERMINATE_BUS)); } +static void uart_set_rs485_rx_during_tx(struct uart_port *port, + const struct serial_rs485 *rs485) +{ + if (!(rs485->flags & SER_RS485_ENABLED)) + return; + + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, + !!(rs485->flags & SER_RS485_RX_DURING_TX)); +} + static int uart_rs485_config(struct uart_port *port) { struct serial_rs485 *rs485 = &port->rs485; @@ -1413,12 +1423,17 @@ static int uart_rs485_config(struct uart_port *port) uart_sanitize_serial_rs485(port, rs485); uart_set_rs485_termination(port, rs485); + uart_set_rs485_rx_during_tx(port, rs485); uart_port_lock_irqsave(port, &flags); ret = port->rs485_config(port, NULL, rs485); uart_port_unlock_irqrestore(port, flags); - if (ret) + if (ret) { memset(rs485, 0, sizeof(*rs485)); + /* unset GPIOs */ + gpiod_set_value_cansleep(port->rs485_term_gpio, 0); + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, 0); + } return ret; } @@ -1457,6 +1472,7 @@ static int uart_set_rs485_config(struct tty_struct *tty, struct uart_port *port, return ret; uart_sanitize_serial_rs485(port, &rs485); uart_set_rs485_termination(port, &rs485); + uart_set_rs485_rx_during_tx(port, &rs485); uart_port_lock_irqsave(port, &flags); ret = port->rs485_config(port, &tty->termios, &rs485); @@ -1468,8 +1484,14 @@ static int uart_set_rs485_config(struct tty_struct *tty, struct uart_port *port, port->ops->set_mctrl(port, port->mctrl); } uart_port_unlock_irqrestore(port, flags); - if (ret) + if (ret) { + /* restore old GPIO settings */ + gpiod_set_value_cansleep(port->rs485_term_gpio, + !!(port->rs485.flags & SER_RS485_TERMINATE_BUS)); + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, + !!(port->rs485.flags & SER_RS485_RX_DURING_TX)); return ret; + } if (copy_to_user(rs485_user, &port->rs485, sizeof(port->rs485))) return -EFAULT; diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 3048620315d6..fc7fd40bca98 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -226,12 +226,6 @@ static int stm32_usart_config_rs485(struct uart_port *port, struct ktermios *ter stm32_usart_clr_bits(port, ofs->cr1, BIT(cfg->uart_enable_bit)); - if (port->rs485_rx_during_tx_gpio) - gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, - !!(rs485conf->flags & SER_RS485_RX_DURING_TX)); - else - rs485conf->flags |= SER_RS485_RX_DURING_TX; - if (rs485conf->flags & SER_RS485_ENABLED) { cr1 = readl_relaxed(port->membase + ofs->cr1); cr3 = readl_relaxed(port->membase + ofs->cr3); @@ -256,6 +250,8 @@ static int stm32_usart_config_rs485(struct uart_port *port, struct ktermios *ter writel_relaxed(cr3, port->membase + ofs->cr3); writel_relaxed(cr1, port->membase + ofs->cr1); + + rs485conf->flags |= SER_RS485_RX_DURING_TX; } else { stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DEM | USART_CR3_DEP); From patchwork Wed Jan 3 06:18:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 760416 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2081.outbound.protection.outlook.com [40.107.13.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9656D182CA; Wed, 3 Jan 2024 06:19:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=kunbus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kunbus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kunbus.com header.i=@kunbus.com header.b="DdkWwkVO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZujBbf01IcdCM1f3Jwg5ek1O0b3+3vg2wSG1XCxC23RBNl9lVMp2xWC8zSEe2xnHQqf7CQHu8eGN3Kc3Qo66LZv8TDQhaTzb4KaARchySEPOphTroDS2cra5IN55TDXFgFc7cg09CCgsLUgrwFvmJm75LrHy33YIrZabLZbi2hA7xCeUzIePCX69quOmjLJPWL6nFeChZ9/xdyha1WgxbQdmfU9lDVGjX9khmDmez/7DQaDDyjhT2J0XtNMdFy2qpCnOyALxewRTLXZUZzfaeea02v1ym3iAhNxTDFFfS2CGgA3bBAptx1Xe87Qil1uOn8E9kEBVaZaLyCQnn3PbLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yPnBAB65jmBQDLunpS8k5O/cIgfIkQi5kIiRI2Szkg4=; b=VLpap3fysCN1L0A+G61Ig5vjNHDwq5LMYvqjA8EDBHAOdm/cyAqBhjTudQG73p1lJU/EItYdn/DAedi4JKEJlN17r8GLmat8GudK3o+0rvQB6wBGgQXcTvs8gvw9CJg14XhnvvcMmqJAEQKiHAATWEgau0fTnk1zxpMmizNeK6cQ5wnxatuEayTn2D5MrA5t7+pOa4TaN4pl34pQ4bQsEfZ7lEAA/2EdxoiIscMsILQjoIzqDciChFyGSt3QlXAlI+nGCsvdzyj+wJB8kQ9PMq4th2vR29ceDdeDOa4wnWbUVFUV9zePrzUAraTZfJM7a0K0k6D4XDBVFnbxhI2RkQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kunbus.com; dmarc=pass action=none header.from=kunbus.com; dkim=pass header.d=kunbus.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kunbus.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yPnBAB65jmBQDLunpS8k5O/cIgfIkQi5kIiRI2Szkg4=; b=DdkWwkVO1EUqR1dPhDi2gD3XFmzCHU9GJW3Z2m4ZHY7y2nLbZvfivXT60ONHOVfqkSCyXLytdOREhF2mpLFu5wBuOSFSOVqEKBQLNcv0QpnhgUbNb8p5/ocn5TBDHeGFCk5DrMEk2XNzUaJWrF4mKDuBJi99kO6RUk6laQsk5GU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kunbus.com; Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) by GV1P193MB2245.EURP193.PROD.OUTLOOK.COM (2603:10a6:150:2c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.25; Wed, 3 Jan 2024 06:19:12 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::67b0:68bf:2582:19cb]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::67b0:68bf:2582:19cb%6]) with mapi id 15.20.7159.013; Wed, 3 Jan 2024 06:19:12 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: u.kleine-koenig@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, hugo@hugovil.com, m.brock@vanmierlo.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org Subject: [PATCH v7 5/7] serial: core, imx: do not set RS485 enabled if it is not supported Date: Wed, 3 Jan 2024 07:18:16 +0100 Message-ID: <20240103061818.564-6-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103061818.564-1-l.sanfilippo@kunbus.com> References: <20240103061818.564-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR0P281CA0267.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b5::13) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|GV1P193MB2245:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f77156c-8206-4263-c196-08dc0c23e767 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nGEyZu1xfvJUAaMFj3Wd25DC2K3Rxxu9UMussr0XYAx36glD5pvZclkOxHQNvIETGcl0nBFj8rCsTD4rp75VS4dlFeZct+afsWTEjSkuxRvtzEitS9ZOpaiXvBPPkqrhE8wqaDHlKwr+UhHtM8BKIcSaXMuGsggVzFl2mQF1VqMt60mBBe8XcjEhheTZ7BZrL1kvUTvmnd7def+d2HIvrxJzJBJ2rCl5B6T/rz6u2Y/Z02shkhKLjQPRIPFDENASnkfvwfJbH0u4CHDWDIQ9bB6QvjySclI7RSfKfDtGhfOV0WmuzlaiVOB21e5+YdzMdFpp1lTdIn3VJlSCp20ZFnUnIK3rVa/dKQw/IVUQWQmxhzYOHeCLy9/Ll6AO5mXLPKXqw2vl9WB/GvtxWRszuo0EQcnklo5g9q4gGqS+RtwNkIscK5l5LBsblbhlwryBssZZZ13CZuwj+p1txfmCrTpm7G4KPrgJwePIxtRLNH9zx9iziVWdk0Y2Dfqj+4aOxi0zSqgirQfyXiISXOw2LBtq85UzgIr3KDwXAjivQhuwYFmFGYrn+QagHd3SLX0C X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(346002)(396003)(376002)(136003)(39830400003)(366004)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(66556008)(66946007)(66476007)(4326008)(478600001)(316002)(8936002)(8676002)(6486002)(83380400001)(6512007)(6506007)(52116002)(1076003)(2616005)(7416002)(5660300002)(41300700001)(2906002)(36756003)(38100700002)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?5rSgsxANlDeer1lwBlQLWlri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VygPuB4hgxzSC?= =?utf-8?q?3LQxKWBfuwKz8kBZ3gKnFfoKpgyN5jyv7X9V1oS55SP0lq8yOc5kW335Lnm9gvUGm?= =?utf-8?q?xrXlj4M/1rJAz3ROgbXXC0ATVepfpb8DJxlijaX+f0MmBShZz0O0lRaOpRCGSnqD9?= =?utf-8?q?gVeeHKvoZVWgop66Jb8H3+Ph2HMTV04N/r70DXb1qjxal066Dz4NR7bYup1pcyCaL?= =?utf-8?q?snqOnAiRsx1kGmGP4Mp+eXbMeJ5DGI+4/fwhLydQYKPmfHmNPzfoWuVpdpDztyup9?= =?utf-8?q?3B0BLpp3AUf1CsqdGdli9GD32rH29TZKOPGiUMjyRw9/F+BnJKBjbh7EPfJ50qNpT?= =?utf-8?q?SS0dl/pV+YemEvvxt+N7mNKsI2pw36ZyvbO68huef3g7XxwKCEKDa4USD4m9jimEw?= =?utf-8?q?GiHe/3RplswZIEfR8CKdAF6smlNOw1QpJHcO3txSPZpzjxzzCGzBjkdf8dXCKlz5W?= =?utf-8?q?+oLVu+owiXZftJd70WVdGWXSuZeR9ZE/muGnqdqP3JVlaZLv62Kqd9vMrp8eH6pgk?= =?utf-8?q?/lPpWRq18VANxXcTa/JQB97TJ2sP6ss3h3a7QTvv768s8gSpWMDLVzKMyAYTkKvOc?= =?utf-8?q?y5EKN6WOiDhVykLJIKYl4JZwxjAveoYptaZCE9LIkOQhf6eqfoh+0uJczqZpZDdFX?= =?utf-8?q?fmtokgs8oUsipYZb+WOrrUeyp9mvWKL7DuJg/KLtF5fF3g8kcEUbU/9EyE1iTeAcb?= =?utf-8?q?5+qexItzKaXEpIY0q9i+7cHD2V26YgfrQ=3D=3D?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f77156c-8206-4263-c196-08dc0c23e767 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2024 06:19:12.7168 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: aaa4d814-e659-4b0a-9698-1c671f11520b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HZhpjmiY5i1KRCeGKK2uOixqTpu5Pw1Xub0Dd+vXMU8gSay4CMDqgQoQDB56Zq4y5TjlEYkFxrWe2STNIxU+gQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P193MB2245 If the imx driver cannot support RS485 it nullifies the ports rs485_supported structure. But it still calls uart_get_rs485_mode() which may set the RS485_ENABLED flag nevertheless. This may lead to an attempt to configure RS485 even if it is not supported when the flag is evaluated in uart_configure_port() at port startup. Avoid this by bailing out of uart_get_rs485_mode() if the RS485_ENABLED flag is not supported by the caller. With this fix a check for RTS availability is now obsolete in the imx driver, since it can not evaluate to true any more. So remove this check. Furthermore the explicit nullifcation of rs485_supported is not needed, since the memory has already been set to zeros at allocation. So remove this, too. Fixes: 00d7a00e2a6f ("serial: imx: Fill in rs485_supported") Cc: Shawn Guo Cc: Sascha Hauer Cc: stable@vger.kernel.org Suggested-by: Uwe Kleine-König Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/imx.c | 7 ------- drivers/tty/serial/serial_core.c | 3 +++ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 9cffeb23112b..198ce7e7bc8b 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -2206,7 +2206,6 @@ static enum hrtimer_restart imx_trigger_stop_tx(struct hrtimer *t) return HRTIMER_NORESTART; } -static const struct serial_rs485 imx_no_rs485 = {}; /* No RS485 if no RTS */ static const struct serial_rs485 imx_rs485_supported = { .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND | SER_RS485_RX_DURING_TX, @@ -2290,8 +2289,6 @@ static int imx_uart_probe(struct platform_device *pdev) /* RTS is required to control the RS485 transmitter */ if (sport->have_rtscts || sport->have_rtsgpio) sport->port.rs485_supported = imx_rs485_supported; - else - sport->port.rs485_supported = imx_no_rs485; sport->port.flags = UPF_BOOT_AUTOCONF; timer_setup(&sport->timer, imx_uart_timeout, 0); @@ -2328,10 +2325,6 @@ static int imx_uart_probe(struct platform_device *pdev) return ret; } - if (sport->port.rs485.flags & SER_RS485_ENABLED && - (!sport->have_rtscts && !sport->have_rtsgpio)) - dev_err(&pdev->dev, "no RTS control, disabling rs485\n"); - /* * If using the i.MX UART RTS/CTS control then the RTS (CTS_B) * signal cannot be set low during transmission in case the diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 28bcbc686c67..93e4e1693601 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3600,6 +3600,9 @@ int uart_get_rs485_mode(struct uart_port *port) u32 rs485_delay[2]; int ret; + if (!(port->rs485_supported.flags & SER_RS485_ENABLED)) + return 0; + ret = device_property_read_u32_array(dev, "rs485-rts-delay", rs485_delay, 2); if (!ret) { From patchwork Wed Jan 3 06:18:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 760415 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2081.outbound.protection.outlook.com [40.107.13.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9433F18AEF; Wed, 3 Jan 2024 06:19:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=kunbus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kunbus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kunbus.com header.i=@kunbus.com header.b="hlRPHxUT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j/BoAtEo4+jettHSX3QXWeO2bVAO1urqJw+CpulYdsDwZedK5ybV+SM0QvqeHYSsosyo8rgkxMP4kgOYYfBiUkJ4b/abILDGPeZjDL9rOFZdSa1g4H9OHtBne0UrQ+QNVeMQ9eKguJRz9pvYZqeWfpMck5bKcwIyNGKESYBTnSFtrpVa5Ka7c0/svjrbjdbNGW7Flna7tFyIEdphREmJ+5Gkmzrep/5uMXn48xoGNXuLJrDm0iW2vWEsT1vYRpaga0S6ak8Bptw1s9tCLk6CzuVbaXne07nlNMC+7f9rsyDbtvyS8n5kt3L6Ikxb68YH2MYN6MZ/reHTuvqnEs8vEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6BcGoe+ESDzoCivkDyl+SvQ6vxiyAUtVpHN4Fyf7TKI=; b=Q11JJE0u/SbCoilMzsMC279WfaNtlEqNoVFNNpeyLJ/8ldhz0Sfq2PEdt1l42cdCCEHIIlKFtt6fTaK29ocIn6yi+5WBNiswZQqH0EAQE6vLh7f2wez/mf4JFtxt8Oblf2JZ3ph/UvC6SJfQBQZlGpGhwDeLkCzXnUkQ3gFhbLEjtnrfQmNMwIEH0sO4i9v3K1Bx4erAzi4oZabjkvNQAjYgzy2q896lmP/85QUhGv05pr2NxYlyhwNtIhJZVqaYt4VDpm8WYwieErT9c0U2T57BgYm5EAxZRslQAl4Ny/2Nj6/ZR+/ZjxnDlutXIlJLS6OTezRsos8cmpHMz7D5/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kunbus.com; dmarc=pass action=none header.from=kunbus.com; dkim=pass header.d=kunbus.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kunbus.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6BcGoe+ESDzoCivkDyl+SvQ6vxiyAUtVpHN4Fyf7TKI=; b=hlRPHxUTZXM1jLsUtxbGH6StlAXqbRYeDqgOmCTCGw6Kvy3BSB/KAuOiGyFvNjSA1tFRAoJzJu43Z/OozJ/5VCqF/8qCe87kJVAYcXwpK6fflQsw1dPPHHFI+WREp02C1XKxnF87Mv81F9C4VPa8u9vCdxGAPvZQWMzyR2KnuUA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kunbus.com; Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) by GV1P193MB2245.EURP193.PROD.OUTLOOK.COM (2603:10a6:150:2c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.25; Wed, 3 Jan 2024 06:19:14 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::67b0:68bf:2582:19cb]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::67b0:68bf:2582:19cb%6]) with mapi id 15.20.7159.013; Wed, 3 Jan 2024 06:19:14 +0000 From: Lino Sanfilippo To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: u.kleine-koenig@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, hugo@hugovil.com, m.brock@vanmierlo.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo , stable@vger.kernel.org Subject: [PATCH v7 7/7] serial: 8250_exar: Set missing rs485_supported flag Date: Wed, 3 Jan 2024 07:18:18 +0100 Message-ID: <20240103061818.564-8-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103061818.564-1-l.sanfilippo@kunbus.com> References: <20240103061818.564-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR0P281CA0267.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b5::13) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|GV1P193MB2245:EE_ X-MS-Office365-Filtering-Correlation-Id: 5442ca88-43cd-41ab-1b81-08dc0c23e881 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i0i10wbcsseClDcPxXTkxp/eOzY6dlwiOAs0k+BQIj8AUmIg2obd0kyrGUMwwjsG31dn5ymS7u68aaoRjGIVb0+MRI9Nk7cbdyLf3wDbxVCxj90w9tmj4GPGToPeYvLFqsYtU6XRw31oC2ShLehceFSe0f3XZiN7t4ywP2qJYVx7u7ubvmVWpDsHpQ90t3AjNPrUDelzColVcHhB6LPKmEdviHa05n+UdKKybHOHW8gZ4JEXoq+JyQXa8Ucba1tTRaxLUKp+0sZfIIhelh2B2790beSH7x5r7Xud7LuaqQefcG+JJp+7UmQ5z5naFBrMQ1VHtNjZFSB2SD3MZU9p9Z+EwVUTMUqlbxiLb2I6Nzx9dG5Y3FALs1tq7hrc04h73uRjQ5ymzg81oLogmX9sJmmTmHjahIzhhygC2QTDOQIZoawdsFi+YPSzHuLNZwY+cxKKXqCTS0jj+eEldBYQNE2tm8IFp77EkfKz3ZKAehUM/ePoUduO2GjAcAaK7kvFfzV2GU78Boy8j1zJL2vieDnaEdLylpY9VXYV3zHh7UzRVo8VAFGmwxZi0ZDWLFd9H6efcW7ZLQOsExQd9hhvB0x4i0eiIg8n6LFw94BHlBC+d8zQveLHctLgqEScwtnx X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(346002)(396003)(376002)(136003)(39830400003)(366004)(230173577357003)(230273577357003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(66556008)(66946007)(66476007)(4326008)(478600001)(316002)(8936002)(8676002)(6486002)(83380400001)(6512007)(6506007)(52116002)(1076003)(2616005)(66574015)(7416002)(5660300002)(41300700001)(2906002)(36756003)(38100700002)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?qEBvHWspHtLO2/+rbBN2hO3z+N16?= =?utf-8?q?/vWZJsBwhN1fP1kt5NGschUYMTRslnlXZWypgHkVtAMoW3tklXltMSYOexSBV+HNR?= =?utf-8?q?vDQ4TAiRNGn5xCUL3hhd1kZX85uLuRC9O9JM2c2nj/oWgKcenJ3BD54vUQEh9HDLt?= =?utf-8?q?/MOqbE1WAaNg/36tvk2OesfZ4meOnHYo1Ur3V+FF5aRU1rRfrdnhonzbUealioP+y?= =?utf-8?q?vGE53jIzNXUYTSGqeEGYQ0sHmgoW3ZNV/Ck5UIydYlCcviIsglycfWWfcJ+sJQUXz?= =?utf-8?q?xHkis+jXMvjKmcBXfRhiDGXAtACNRPdymgfs8zS8OK+Ex/1vPScXcbuUARG2rXlsd?= =?utf-8?q?I/9pzNvcNudhpW699zSB6JsdaPRytBl5X2aRuPyDPWoaqJC+J3D3idf6o0mN5SYvE?= =?utf-8?q?Uihp94OizMNjxN/z1eWy5q0QMc2zVjTahcSGaJJqKXXbJSV8ce+aQQbe3/Ru1Xnif?= =?utf-8?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=?utf-8?q?1elsoGDpMUKS8fHS+Ic8s9v+Q/omkKqp1WE3pCR5aqxWPYqGWoNnnFIqmJ+m7vIbW?= =?utf-8?q?Qi2XeUrMxjahiMPfw/Gr/75ZL3wlO5Nio1SR2N1XGknd8CzA09/qPddebYh46HWlQ?= =?utf-8?q?sHZRoB0lqY7F2fzR27hkASn15r+Fzr7dD3NX4c+2hKSGxa5hYltKMjleyzk1DUoTt?= =?utf-8?q?5AFE/29NM+VfxFJMgwKBSHeh4ixuP+sVFw+WjjWx9MlFdmWUKPTW3paE7P5krmqkL?= =?utf-8?q?Ly7jR8C8mxuxBkiQ3Bp6jdcrTqGFxHICw=3D=3D?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5442ca88-43cd-41ab-1b81-08dc0c23e881 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2024 06:19:14.5241 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: aaa4d814-e659-4b0a-9698-1c671f11520b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ThHwi2955tpYL1VnFuPrqJoY5gVfMa7LI713tMIqHSqQjRm0h1Up4J6qzYhdDE5guumhg+khpNMKXf4g48I5Kg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P193MB2245 The UART supports an auto-RTS mode in which the RTS pin is automatically activated during transmission. So mark this mode as being supported even if RTS is not controlled by the driver but the UART. Also the serial core expects now at least one of both modes rts-on-send or rts-after-send to be supported. This is since during sanitization unsupported flags are deleted from a RS485 configuration set by userspace. However if the configuration ends up with both flags unset, the core prints a warning since it considers such a configuration invalid (see uart_sanitize_serial_rs485()). Cc: stable@vger.kernel.org Reviewed-by: Ilpo Järvinen Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/8250/8250_exar.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c index 6085d356ad86..23366f868ae3 100644 --- a/drivers/tty/serial/8250/8250_exar.c +++ b/drivers/tty/serial/8250/8250_exar.c @@ -480,7 +480,7 @@ static int sealevel_rs485_config(struct uart_port *port, struct ktermios *termio } static const struct serial_rs485 generic_rs485_supported = { - .flags = SER_RS485_ENABLED, + .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND, }; static const struct exar8250_platform exar8250_default_platform = { @@ -524,7 +524,8 @@ static int iot2040_rs485_config(struct uart_port *port, struct ktermios *termios } static const struct serial_rs485 iot2040_rs485_supported = { - .flags = SER_RS485_ENABLED | SER_RS485_RX_DURING_TX | SER_RS485_TERMINATE_BUS, + .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | + SER_RS485_RX_DURING_TX | SER_RS485_TERMINATE_BUS, }; static const struct property_entry iot2040_gpio_properties[] = {