From patchwork Mon Dec 25 11:35:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 758577 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2070.outbound.protection.outlook.com [40.107.22.70]) (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 C9AF75102A; Mon, 25 Dec 2023 11:36:00 +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="QNvQ8c4g" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jpWz0EEmYtlUsz1NWSJoBt8BOBF5lH7rrpIH/2nFCdWLPnXjeW71uBixkaDNCxwCCwaw7vlcdhGeDRIGYhaxpdLTNidYWBkjyQK6PkMMHpFoTTRiQeHH6EHVTRCZVc3tHXBOzc1KH+fMSD9W9MEodBuKERYMwFWpMYlK0G85t745HJmJwlB0+QSbnk4ohve5FLVq5kbsPNd0k6WJaCdCVZT5wh/asaKLnl9JTrnJL3/0O6NhLyOokyROyKFXt9Yr4UQzizuj8xKBMBdSTXzENDjr12r82VbubY29gK4M7/SXr8G7XTJdbwNnRvpvWRdVOjqDn9DXF6LP3MXQ0lm0Bg== 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=1TC+21YnKQMHFgAz2YduVy8ekn/I7Y9I8WDYbieztEk=; b=JItsaISwsdVODEf6M872IlrjPcyFwS0dJUvnG6GgiGJUAVfSbvfelxkFCpinBaHdRAVOYo+p6M80jpqAWbvqF+BDn7n2IsNfW8mvrf95WiZ8nkaIcmr4zpnWS60HNGYxcBhzwpdwQkU98XDBAYfAtTklmbJOw7ODia7+poy7ot1S2AclunN/0q02jQcFkoXOR+BNUHCEToNBQ3M4jdit2/YegmcXexJbrVVQab/bpQlmXfxufTIaSvgTx05jBt62meKwlepQ8oxRPuPoC+BYZCg84eds5uHJO7778PhWA20GXedBifieF5ZOtN1XW1E9oRUH2s68A1gCpbxNSV3F3w== 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=1TC+21YnKQMHFgAz2YduVy8ekn/I7Y9I8WDYbieztEk=; b=QNvQ8c4gl8aCvMgaXIkLggINom/yZ0ohE72J1J0wcuFQqjf33T3rdZy8IAILZOBIAJYJMjyblrBOobEjWHr6T1hqEhRJCU9+G/H7fHlSlDiK8sgU2eHyr2H21KjOqHoAGzQEfpl6FbwSNvqGh7oUNZTQyT6KQxqGSXIDUjjKuwk= 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 GV1P193MB2070.EURP193.PROD.OUTLOOK.COM (2603:10a6:150:21::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Mon, 25 Dec 2023 11:35:54 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06%5]) with mapi id 15.20.7113.026; Mon, 25 Dec 2023 11:35:54 +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, 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, Hugo Villeneuve Subject: [PATCH v6 1/7] serial: Do not hold the port lock when setting rx-during-tx GPIO Date: Mon, 25 Dec 2023 12:35:17 +0100 Message-ID: <20231225113524.8800-2-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231225113524.8800-1-l.sanfilippo@kunbus.com> References: <20231225113524.8800-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR5P281CA0055.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f0::17) 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_|GV1P193MB2070:EE_ X-MS-Office365-Filtering-Correlation-Id: 44124829-273c-4d47-2c69-08dc053da643 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6jJfUYkdSoDse7HWl5mRa96dswVKDFkIfRdGILJs+YD1orEe5kETVepAbbwEBgwoWZUy4pmPbBy+ijgPWAECHzWeaEmYMP0wB+CdtYoOHereDyBb0QGzV6ZgXrAshtWRKCbAXlmcvsAonKc7AREfQ9mzAYZIZXVpdTYSBQhf0p9zNn9U0kbXmUHD7qVDHe6On77OsWMKAQ4WtVv97vFKxeZJNBA3lnEN0J8MSo0cSPqaFhVfAHN6LPMmV9jtEkUa7SWzQ/MxRPgqoEAhdAcIQoSzPGc3kn2jqjw04LsGlZbR6h7oj1I730NEw1F5GLY9SWacPtPm2ZcfYPxBrN06xIGRluxrl1codMqB3voAYYnEhlGSk6h6Jc5I8ydguwtHtA9GBdLOxAAvp4TuMTSeGFRWisrK3rbGiUx0572VkSL+ZLKPmH7GuuPS4wDC+iqPDRcfq+QkPx+1gsM4VyJtNNnjdSa5mrcLeXHirbvQ7FxfcFlCEI0CyhueEwy8tSy1ncE0KZqMfwaO4SYEz1IS/uZ2JQueEArelpA49QgEJRT3JvScES0XhuuuqtSNQhHm 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)(376002)(136003)(346002)(366004)(39830400003)(396003)(230922051799003)(1800799012)(64100799003)(186009)(451199024)(86362001)(1076003)(2616005)(83380400001)(66574015)(38100700002)(41300700001)(36756003)(7416002)(5660300002)(478600001)(6486002)(2906002)(6666004)(8676002)(8936002)(66946007)(66476007)(66556008)(316002)(54906003)(4326008)(6506007)(6512007)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?SJ9zAljz42Q5pDFZKi73b74JFr7x?= =?utf-8?q?sCPhOV8t7yq2FoC9orT8BOfwFwi51JKeXNzBYACYGZIElGbE+ejopxmdNcaGut/+8?= =?utf-8?q?F4vXgakpI3Qy+h5ykG4v167IQHi7agZG4uQAaMu94mS9W76TF1/HDsxIVo6PMI37d?= =?utf-8?q?Brnu0dARU/P7QmpXKGqS/DCOuFMaXhxJ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UqCgQyQZhI1DuE/JBEFbEtNQipq?= =?utf-8?q?dlbn3s7D1y6BM61MoDuhRFINpgbSR30x6LlN8KI3iuKMLBLX7efYPA5C9Lug0NVw7?= =?utf-8?q?exhJzetUpKYyuJTH5+p0PJB0jGD/hny4U5I1iuuGjhJ0yZFe898WmIv3RL+k0zBAP?= =?utf-8?q?+3/r5rZb29RaovMIr4hR79bJ8jBav3cbTDZA9+nJf2gyTiOQ4tPD0HHOVax3BEaY9?= =?utf-8?q?mvzLmV5GjEdOUhjS0SEW1f7ZcHK/ShyBme1eCP65KB1oR3JH7YDyFtc8mDvpQQmYW?= =?utf-8?q?YkV3uvuUtQN/isoIPeFBbYVePanQnEpmyHHOdZrieIYnN3SOzJhcZGI2Atz5u60ZI?= =?utf-8?q?qjYZB4gErbXcFBhW9/CaVJcV2Dip0jY0WismHUCYmk/lex7s9fN7E+QmmeSFRBY8I?= =?utf-8?q?OqO0YkmEdOuOCIFhdjhsQXfU7EIIqmMVbHZi06ihqLm4ROTDnvBZrkCS0GMQUhEEj?= =?utf-8?q?rm3/Lqes48dKvWUjxLM/C2uFOwODv8xJUS9hXy40hmH8MDZRc3mVVnwgTAmuSp7tt?= =?utf-8?q?7KxbMvwKRaD?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44124829-273c-4d47-2c69-08dc053da643 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2023 11:35:52.2121 (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: Wk5hTa9PCnqEfH4FDfetHkjhmJyFeeuN39dA3C2Zz5599yjxvsALmC8bsgofMEX5qYo2wmNWjqURSiujMxEdHQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P193MB2070 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 an 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 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 Reviewed-by: Hugo Villeneuve Reviewed-by: Ilpo Järvinen Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/imx.c | 4 ---- drivers/tty/serial/serial_core.c | 26 ++++++++++++++++++++++++-- drivers/tty/serial/stm32-usart.c | 5 +---- 3 files changed, 25 insertions(+), 10 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..ec9a72a5bea9 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -226,10 +226,7 @@ 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 + if (!port->rs485_rx_during_tx_gpio) rs485conf->flags |= SER_RS485_RX_DURING_TX; if (rs485conf->flags & SER_RS485_ENABLED) { From patchwork Mon Dec 25 11:35:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 758578 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2070.outbound.protection.outlook.com [40.107.22.70]) (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 A03DB51018; Mon, 25 Dec 2023 11:35:58 +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="GlbbuC2R" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vu5VxcvhoEY6ZxdPtfc6pAZ4zs71q+Eh7kAkaTrw1fUOyqOZd42FnUNGyaOW/LcOAFpJ3aTyXKDGMeBaTGWJpEc0MCJaN24cvhdSw7U4CiMzezLTEPaYgKsjTbUPu9gYTbrNIgp2lcNNDClY2WUatGWOpWQmWj+1dY12Jl5jGc0Ihqhnej9H4zSSIh4ZEQ//DZ7z8mIIL/5NB7NsyL5ExFsWmkJQ60vSRNhRbKIrhJtLS1RWvF5BI649YpELZkmwthTD+7b3VPX8d5EbeNDmQ+mD+AO9lNkzN6F4/BDBuJbAtbGSAuDIDnmiVAXjLBVzoYPukVSVJFzyvLnqni+fPA== 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=OncriHkcvWJWNFlfsrQo1DKSpaTIWLwBKZU4AvicFoI=; b=l3j2QJvBf5xV+7Zd9ePH8FR9Pb6CMisZRrnYiZBGMHKKzru1UuzApVBgv2i5nDpfkmVlPh+l7p3Mr1RCrYjGjA6z8Q+YU/U8behh11oYxLJPkijjRALQ/0GjEdp8h03+NXJPcrujfAlZurf/PMIxQ7GnEDnWOTO75cRyvGdcSixaTWitbTHjVf+esvfrq5QE8eV57PGakikO8skE53ykxXjO8k5bGJBpjXxkBoRuZYnw2M2y/5/96/U29DPy88/sgV9rRRdohUxz60LHDphfunRZO4epfqNuNFNjLM849Auh8plD1Y+F4Ow67MANPLQF1h25meqE8MzymCWD1mcwQQ== 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=OncriHkcvWJWNFlfsrQo1DKSpaTIWLwBKZU4AvicFoI=; b=GlbbuC2RWwAfvzJJUMSKb8FR/3AQ+i/P2s8Fxg+FgK2hVX0YTBhy1Q+53IO1OlDOhSJNkA/NuX2nO4UIfyb0P/7t/IO50RWcU/e1jdOyQikaiE8VEDvTYLZWKzCDDAO+56oKw/sfx4ivBvTTXt8brU6hQzGqrgORBJ4EvcXTqso= 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 GV1P193MB2070.EURP193.PROD.OUTLOOK.COM (2603:10a6:150:21::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Mon, 25 Dec 2023 11:35:54 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06%5]) with mapi id 15.20.7113.026; Mon, 25 Dec 2023 11:35:54 +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, 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 v6 2/7] serial: core: set missing supported flag for RX during TX GPIO Date: Mon, 25 Dec 2023 12:35:18 +0100 Message-ID: <20231225113524.8800-3-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231225113524.8800-1-l.sanfilippo@kunbus.com> References: <20231225113524.8800-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR5P281CA0055.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f0::17) 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_|GV1P193MB2070:EE_ X-MS-Office365-Filtering-Correlation-Id: 614d6e6d-0513-43d4-4efe-08dc053da6a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2mn52qyVxPD4EH/agxW3kt0BqkZR0pCag8np5JcIBalCic51J1bXkQUUlKZ10tz8csAo6qUzhqVPs6DGeOJLz6+3jJmVkbvsnjSfdYUmp4Pi8YargQBzDe2KFMcD3eKI7VRYX/0YqgTqWmrrfBtI8RHsBFZ2ocaQcmUp4NmkVpXcxmOUN3n8fwvtSSkQ1Xgji8E8wkd7YKb1wuKTDACAnXhq+cHMKzuQ9Fnqn55xXv+S6qRllAXWegzR5nfd7ymPGpc8zZNoz1QGIBzQrUy8k8IQrEOCZKKm/zlFR4iJ9vdXJRik1hhSfoh1VL1mRPn7I9nzyco/6HYKym/pRv7K3D/gaac7ZQVNs6R7aLnhEeMCbcB0pQ3Y1Ba4wyfnjkWhwN6advODx065miXGmjdNtdBLy741u9RMO7jxbZeo9aUgXXDkXfFOhQrRkf7HKHd38UH6HaRMCfzW6aaISphbEusd+ag+dVP09thILQjACG0eLaxMArMbCfzhUYlhDY7qNCy0mgAUJzuzWtCEpVoTcSJ+Hmm0uTM2Ux4Yic4LPKR0jS+lPTKnxO3aYsNjgyQj 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)(376002)(136003)(346002)(366004)(39830400003)(396003)(230922051799003)(1800799012)(64100799003)(186009)(451199024)(86362001)(1076003)(2616005)(38100700002)(41300700001)(36756003)(7416002)(5660300002)(478600001)(6486002)(2906002)(6666004)(8676002)(8936002)(66946007)(66476007)(66556008)(316002)(4326008)(6506007)(6512007)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?UADp/RCCx64wLrK9RwNSUkIOnY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7?= =?utf-8?q?MKfqI6RCfVFiXsFMOvQ7ZD8/ylJaKWhv587gROK3xTiBfdZUDM/RQOkEydK3ECVe9?= =?utf-8?q?VmB9qrH8hi68i/Z+YRwqocN9206dpC7dU5Nmqe6ujAGuKCwVuxfUNBM6Y2oQJYLcY?= =?utf-8?q?VLF0w2v5ixRALB3l81tzB27HE32I+JpN28ZYXBXro8o6eGewyXA4Qn97VnNUjXdMj?= =?utf-8?q?UkpYpGz9wrPgAXGFTJ2oJzTAAnfF1BgBvK7XbhaEVIlvHMHTN3wd33MPeo1YeVTtc?= =?utf-8?q?Sp4ELpNsNJXhAOFVI/vlsCm7LBOEV7B52prB172oFH+KSEVtfdl9kSlxSm4Al/WJ1?= =?utf-8?q?+sTApqC1bruM4KnLts3dBjJfiNIZbturGSuqei1GLZuXmmZU3orkuGGoZnfeFax7t?= =?utf-8?q?Na7OWPFV7Vwd9F4dKlqnoxeg0tHR0wsHq5Lmq9hj7RrzfUz+Z4Mx0rhL4vNesZwdm?= =?utf-8?q?I0DYb76msZWMxF5Fm77OhfyTrB+wppq7No4IAdd0o8PSMmSmWqqZezJEBSnGEMu+4?= =?utf-8?q?IxAH4PPghbKs7fMGoGY7eaJdakudvge9pSLNgq7bxj2vGRO2HQvqkAza/LCGFSA1i?= =?utf-8?q?X9zgleYfAPb4ggu9n1dtfUcKSDgQs1fSTcnXaaGoyq/LszpF4vTSTk/IfQyYB0w+a?= =?utf-8?q?BMOjs8F5DB/iLaTeIGXk3eqlnhVm9FKNznpgq/xaFmJoxF2ASHRmesHCIjaDGbiIx?= =?utf-8?q?sR5519oIII7?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 614d6e6d-0513-43d4-4efe-08dc053da6a7 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2023 11:35:52.8185 (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: gitdj3McloKMuX9Y3machw/f5FmTRZxVhle8mk6UnCosx3MhN4ziB6YJp54uaePWHtIjrqIK5G0rLG9OLniYNw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P193MB2070 If the RS485 feature RX-during-TX is supported by means of a GPIO set the according supported flag. Otherwise setting this feature from userspace may not be possible, since in uart_sanitize_serial_rs485() the passed RS485 configuration is matched against the supported features and unsupported settings are thereby removed and thus take no effect. Cc: stable@vger.kernel.org Fixes: 163f080eb717 ("serial: core: Add option to output RS485 RX_DURING_TX state via GPIO") Reviewed-by: Ilpo Järvinen Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/serial_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index d155131f221d..1204102d7162 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3642,6 +3642,8 @@ int uart_get_rs485_mode(struct uart_port *port) if (IS_ERR(desc)) return dev_err_probe(dev, PTR_ERR(desc), "Cannot get rs485-rx-during-tx-gpios\n"); port->rs485_rx_during_tx_gpio = desc; + if (port->rs485_rx_during_tx_gpio) + port->rs485_supported.flags |= SER_RS485_RX_DURING_TX; return 0; } From patchwork Mon Dec 25 11:35:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 758366 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2052.outbound.protection.outlook.com [40.107.7.52]) (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 5941C5101A; Mon, 25 Dec 2023 11:35:59 +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="q3qNevDO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LpC5wcYTiAAzADkbjRVWnNVIHJ3oc0NjNXAxyD+DQhs2kPHX7YKYBbMbWsca034lTmVRqTUVR4vdlbH03vgjlMVqk7U/AJcnmzXDpxUXR1j3Qzb2iOlELyY9eEQRCz05cvJtOgA5a/VPn8Xct74ltvtTGEPGRD/lMMw29MZVs39metjd6MQt0pLD+nfvz25TN8TKEXMBY85pBis/mh95+LxDwr0tKq5ugh0S/0OnWz2D6pT09H6AfkETrdYFOfa4+bzn324cHB3FkdznJkl0ZKj69Enrvww6HH56fN3XVWjImRsHMx01Z+SdfV4du/Iot6SshQfM4k8lbi5ak8Eylg== 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=zrTCdaXp4RpigukbEw/E4R9h20jHnCpK5qa1aIze2JA=; b=RX0VOlqsxwAelafUxxyEz52H7AQErRF+3uMufOn3TtuSLIn+XzX0wSLkByfP5cC1yFg9qdXYBbrPTGcd5JLZ3tKgGJaKV/hTmfZjBfTt/oblDmMXbSIRiqXgIXjWyuqbTuChryJHanpXiLMJjcmq6vJoVuqLqsjhaGiQg4Hx/6zjmJa6zu8tNlfNvvwrxzolGzB5INkyt/aibGRK46KlDDKON/o/Dem4fA8Is0qTsiwsRBjv9LuHT7vG41wvJa7/IAMpL4s8ZHYNH0tdRbITA5gYSv35M/6yJnXZXsmW9+0M0n3jZAR6ksZLEW9Pl/7VO1oZcWZ0P4vYiiNDVwaaTA== 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=zrTCdaXp4RpigukbEw/E4R9h20jHnCpK5qa1aIze2JA=; b=q3qNevDOoMSWtTdU9thGwvjR74myYQvod685CZebiuKxMBGj64UkeTLW+dBdZhI2pAYoN4F/bRXBY6oghXRxNbxDLYQgnm0Ft8QzeLqElzymoCTsWIRU2m7TpKlu3mRTTGugscoEYc1DCKQl7Z20NDueTo0EuGI6nMzc9l1+2Uk= 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 AS8P193MB2061.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:44d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Mon, 25 Dec 2023 11:35:55 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06%5]) with mapi id 15.20.7113.026; Mon, 25 Dec 2023 11:35:55 +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, 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 v6 3/7] serial: core: fix sanitizing check for RTS settings Date: Mon, 25 Dec 2023 12:35:19 +0100 Message-ID: <20231225113524.8800-4-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231225113524.8800-1-l.sanfilippo@kunbus.com> References: <20231225113524.8800-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR5P281CA0055.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f0::17) 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_|AS8P193MB2061:EE_ X-MS-Office365-Filtering-Correlation-Id: 56ccb621-1b1a-4440-85ea-08dc053da6ff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tKYCaaPah3qoqQ7coyRN2F484bUDQK7mx30jI9/oUyi7kFetL17EqK5Pqwq7/Yw3x2+/lyT8XX3n9UM/P2h/rjscdBLX/sFBy1Qubs7JmZACkLs/gQFiorIoqBWSJ9NrIwEb112JJqpdg/Ot1eYKwtoLEs8ap8nKaykPZ6URcrZuDtR/AsGIY6/cCiovED8fAhfUIHSTgr/bZcg4tgwIGso84qFR3vUf+0jnohmxazrYRBAkMNTkceNWubpe9nb09WsoKrpTlYP/ljEjN0HkkYyurYjgYfLCHlkAHycR5iUI2y0odaPwwjxPCQR6SRh6dXp5yUX+Z3wqNbcCm3RHow+arR5ghwp33clpOWmFfM22Tdrt65SoyBJX1cQGbJKXKNIEFCovr3lUG0ztDiEHf45HsxqbxkJcv1YtkuBoS/zQmgl7GEfN1REspYDcllweM8PZgMMYwC7RtIhh1NgP9WpQwxebBMVq3YquN5VMLCAwCKdkkUuCsOZvXy0YY98Vfl8YP7Ega2P9hxbrQ1jvdqVn0Duk7ITXuLen9WAYZtMgSzXg6ja6xvCbVLQWcPTi 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)(396003)(39830400003)(366004)(346002)(136003)(376002)(230922051799003)(186009)(451199024)(1800799012)(64100799003)(2616005)(6666004)(6486002)(478600001)(2906002)(8676002)(8936002)(5660300002)(36756003)(7416002)(52116002)(6512007)(6506007)(66556008)(66476007)(4326008)(66946007)(316002)(66574015)(83380400001)(86362001)(1076003)(41300700001)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?AAkkXEHU+G0A4C8Ju1eb9q6FtxVa?= =?utf-8?q?mhX4Vda++W1O3mwI8ed64zFfLnRKFeiQVrIf8SUb9gNdGLZkwjN62qwXO3we0WoRJ?= =?utf-8?q?bDhD7lh28lxP2spwFYKFWpUtnnA5RxgnHXLGUV/38gVa/JgwA80DpX4ooNjCXVpIE?= =?utf-8?q?FF6xEj5vEH9v5XZV9Z4XkoGFZLyv4Fs83Y3NX+bWeF5ayg3JZR7G3TrW+ca+BIr2E?= =?utf-8?q?Z3qaAlHzKJHqARagTgZ/OkvFDzLVahNrA687ePF5OR93o8gKYLSKsYoWIQtVPX1Qf?= =?utf-8?q?EN/i6MU8QVvanp7e7PoMo61322Hor/GQWMn7xQkn41aJdKkWLz9yxpr8ukDwGkR/u?= =?utf-8?q?cW55X42YYyC5ZKE468znvMR0Ej+kYq/ttI1IqPpy676o0ElRjq8IGtac0tOJL55GV?= =?utf-8?q?mgG3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Qg22acAJwF2FXzhNyNpYUIUPbaMBq9L0fzaKrL2zQ8/PBiSTPGnL+OiEx1zds?= =?utf-8?q?EMIfwlNvTJFlhH0T6lZ/N4p/MQmirSAkrkDRxrokUmQ/QnO1zMjAiCPjY+EXThh8Y?= =?utf-8?q?2wfdlVUQl7B1XbWNFhBqSMM0YrqhTid2jxpcaFkJ+APXCaP4kyXV/vKsX/Sosd732?= =?utf-8?q?JBYxSjkk4sdSwKM9SW+a56K6SyyUGQORoJNbugRV0JRMdfsAWtMr3hTHa50u+drhU?= =?utf-8?q?oIo4sSxuc7h0y8Uyjsa+kI3PsZklZGAEPHepLd/iv378N+u977+IOib+dj43QJGL+?= =?utf-8?q?Z+vJF1LDhTU?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56ccb621-1b1a-4440-85ea-08dc053da6ff X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2023 11:35:53.3842 (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: lrewWoKd3gv5sQ5zK3ViorQwpYJy753VNrJaXDkRlCld3NkOkIUt0QtNLVcF7tuJhF7ih/twgZOJgZjMVpgBwg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB2061 Among other things uart_sanitize_serial_rs485() tests the sanity of the RTS settings in a RS485 configuration that has been passed by userspace. If RTS-on-send and RTS-after-send are both set or unset the configuration is adjusted and RTS-after-send is disabled and RTS-on-send enabled. This however makes only sense if both RTS modes are actually supported by the driver. With commit be2e2cb1d281 ("serial: Sanitize rs485_struct") the code does take the driver support into account but only checks if one of both RTS modes are supported. This may lead to the errorneous result of RTS-on-send being set even if only RTS-after-send is supported. Fix this by changing the implemented logic: First clear all unsupported flags in the RS485 configuration, then adjust an invalid RTS setting by taking into account which RTS mode is supported. Cc: stable@vger.kernel.org Fixes: be2e2cb1d281 ("serial: Sanitize rs485_struct") Reviewed-by: Ilpo Järvinen Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/serial_core.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 1204102d7162..f67fb6a04983 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1371,19 +1371,27 @@ static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs4 return; } + rs485->flags &= supported_flags; + /* Pick sane settings if the user hasn't */ - if ((supported_flags & (SER_RS485_RTS_ON_SEND|SER_RS485_RTS_AFTER_SEND)) && - !(rs485->flags & SER_RS485_RTS_ON_SEND) == + if (!(rs485->flags & SER_RS485_RTS_ON_SEND) == !(rs485->flags & SER_RS485_RTS_AFTER_SEND)) { - dev_warn_ratelimited(port->dev, - "%s (%d): invalid RTS setting, using RTS_ON_SEND instead\n", - port->name, port->line); - rs485->flags |= SER_RS485_RTS_ON_SEND; - rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; - supported_flags |= SER_RS485_RTS_ON_SEND|SER_RS485_RTS_AFTER_SEND; - } + if (supported_flags & SER_RS485_RTS_ON_SEND) { + rs485->flags |= SER_RS485_RTS_ON_SEND; + rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; - rs485->flags &= supported_flags; + dev_warn_ratelimited(port->dev, + "%s (%d): invalid RTS setting, using RTS_ON_SEND instead\n", + port->name, port->line); + } else { + rs485->flags |= SER_RS485_RTS_AFTER_SEND; + rs485->flags &= ~SER_RS485_RTS_ON_SEND; + + dev_warn_ratelimited(port->dev, + "%s (%d): invalid RTS setting, using RTS_AFTER_SEND instead\n", + port->name, port->line); + } + } uart_sanitize_serial_rs485_delays(port, rs485); From patchwork Mon Dec 25 11:35:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 758365 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2052.outbound.protection.outlook.com [40.107.7.52]) (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 DED1F51C27; Mon, 25 Dec 2023 11:36:01 +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="w1ji+nWt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uhgamo/qxh7U4Z+LczJ/SqVEWiWKp9PVxnvh7Bc8QErvHM/KD8X3PvpisX5PMntWfhiP1sG9yrEDnC3IHPc5Q7HgxywAeiY5Wwd3LFv6uuSf9ATLeVkKEg2cAawW6GasbB/ibJlOrHUJLwaUZE8NqxW+XCYFg6XiXwPqgvg7aAlE/9tNS5m5uhkLj/RZqOY++WSTlfV01DNTYjt/sA5IHzJj4d4iEk/1yDN1XMuRTwparwXmzQG37Hb1qv5juE1gnRSAskXvjxK37zWcjhRT6Zyvk5x+M9cmiGuaEaiFRjQ/D9s/KiHUsFUUhBZPp+hzxs1q8f3GOlQT0KEXtcpNVg== 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=ctoSUvaSE63QhX1RJ/Y+ZsAabtaxgzq3AnK1Gc9jmAU=; b=YEMr8QeaKZGTm8HbQlXVpdmzDBiXpH17KgOg5cBBGk0rBC6pEoBo0kSY8d8Gt0id4+MQvWMQiAE9qTK3Zq7EDB3MijfRSEfXIByCxZUfXwvy/ti4cK382w4iFdv2hPkHRa6FNtF/jcdhIBZQi7u9l7BkTcdofTI388g6HSktP3R3+xHUBEU/ym1JB2Iz/dKMl2ksupEFHTK4BzqQSvpqhSmO9bPIoPcadjUBWN90bZn4kwkjvXOiZLLbZmbjZtz7Y70D4k8QX6V38pjfAQKerPVgL4bsA/75302NW6KlQ/55oxsL7283ozp4+fdIjPV2BF3K8xiITm/+o5BOWLBcsA== 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=ctoSUvaSE63QhX1RJ/Y+ZsAabtaxgzq3AnK1Gc9jmAU=; b=w1ji+nWtf5OJqGPjcOFRHCeTrVoPQ3mBx+y4OXM7oA0O5Ufk82I4g3cXqBuRACBN7DVPcUqjsRZ6pZrfDIobGGhksKh95DMDw7x3q1BXmRmK+3mKTS0MBxem6ULkoZ5dn9lct5YIXXDeb5ucQpIOx8SB04yKqgaQRvy0Qy3P5CM= 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 AS8P193MB2061.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:44d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Mon, 25 Dec 2023 11:35:55 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06%5]) with mapi id 15.20.7113.026; Mon, 25 Dec 2023 11:35:55 +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, 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 v6 4/7] serial: core: make sure RS485 cannot be enabled when it is not supported Date: Mon, 25 Dec 2023 12:35:20 +0100 Message-ID: <20231225113524.8800-5-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231225113524.8800-1-l.sanfilippo@kunbus.com> References: <20231225113524.8800-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR5P281CA0055.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f0::17) 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_|AS8P193MB2061:EE_ X-MS-Office365-Filtering-Correlation-Id: 25892f0c-64d6-4563-bcbf-08dc053da757 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dYRxqpEKapPguGhfz1jXmu2nZjVbz12ASsRhsva6mrhAblV5eZuvhRaB2wZ2B5sipOUJh0czw0Do8NVfAKDpJu71fB2qrJkjb7ypxUtcyMARfL2Vo7q0NFFifIhMmFEcTKqM+3uva2x8mDJjQNJuhh43zch4mj25s9VYZRYfUBIm5Kyb3wnJ6tuU31xXg89gaFX8K0/E8LUatxU/U6QfUMvew6is7hSw9SQH15coGbdpiAPKmsms+p5fxq3Vd8x3A3OIcfZpKLOok45NrNGmMdSNvjwAHJNAektupX9sx7l6B7yUfTG9DApfUEwUhVnkCtYC67DDTDfb3z+SwAjFwY2i4gvWGu4SoOhD1Z7Q8G2tkOMBgQMidrK/RFLnUBH0qUozGmRTvdsBS8M5CpHbzP5GrxtzInQW5fp8W80hgqd16uGew4i3R2EDdhKNinvG5U5MZTHzdmV+zBdz6yn9X5t7kCcWucpF5CVpHqySDF1s3ptQ7FfhsYU2RKsbwEFSnvhP+gvEqm1TD7bAHGV6/Qsg55k/btrfuZJ6ksr4NEeShvbCMjEyFYNlWSPR1WCv 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)(396003)(39830400003)(366004)(346002)(136003)(376002)(230922051799003)(186009)(451199024)(1800799012)(64100799003)(2616005)(6666004)(6486002)(478600001)(2906002)(8676002)(8936002)(5660300002)(36756003)(7416002)(52116002)(6512007)(6506007)(66556008)(66476007)(4326008)(66946007)(316002)(66574015)(83380400001)(86362001)(1076003)(41300700001)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Nq+lTjuMrl/0ERPmSiQXDa+o6JjX?= =?utf-8?q?Z63EQswZkM8YtWJBmu/wSxw+Te4C0pHHyFbyqHYcPtIQrEOi73fvWHdAWsVNTtrAF?= =?utf-8?q?1P2eSkqBiYFf5+qv3V+m53AVdCM4Kvv0GLBKy8xfpwPvciC/8oJ8KUos0567P+m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CPz?= =?utf-8?q?Y0jnD0isXXQYrM+Glxk0XVKpBOrboD+hG+0k4BQ2OwAQgT3x+9dztj00lxdnUd3YD?= =?utf-8?q?f46ghQPNFrv1LK6xn69U81dIKVtZ8Rv2y2L985CO4lJa7tDXvV6+DbxpsdJeitBmH?= =?utf-8?q?XY2Y6KW/VXIMe8GL4V4csE7+OAiwi21Tn4HFzrcTFik01vV2DZlRd+6qVP3n/f1NG?= =?utf-8?q?eVpITPEaoet45nmCYCw8TVd8nmIelfJk4QIttJVVZoO+BBqd3FMXSGdZDvEuf2YUZ?= =?utf-8?q?1GaWWAUXyWrTJqpGKNIz+7h5HJaNIXHD3aGQ2HKjZ7vwZvdrxlvF6GjgLw5QfYWTb?= =?utf-8?q?nAOEMEUfAwV40zzoqr5X1Q8qZwT7xE+WCGHGYMSxCgBORH3grh0QDuEveIgSOr4c9?= =?utf-8?q?Wl7xoKFldxaSfGwBhYm38FWVf6rhjpvoE/grE9zEwdlnnqV/aQkqtffTUAmjaqT3o?= =?utf-8?q?RPTOR7xcGvr2wOvLVZ3mvrLQ+JEGVrRJl1ukxnyHw58J0WsGPVkDI4hLD3b9fdfUt?= =?utf-8?q?s3KBAPK5rj46I5J6NiU+0KcSuFHk7QKKE4kI03OvZtKj+vKJV/rLGJo0U2ipXlg+/?= =?utf-8?q?7RWbr7ZU2Fr?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25892f0c-64d6-4563-bcbf-08dc053da757 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2023 11:35:53.9842 (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: 1QLWCILvtFq2cYHxzCXWSN4NIZeG86c6fn5TluajrhQJs1/vGnmwQoKr3rcknazHD830QXfUkLxApUYuw2KwlQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB2061 Some uart drivers specify a rs485_config() function and then decide later to disable RS485 support for some reason (e.g. imx and ar933). In these cases userspace may be able to activate RS485 via TIOCSRS485 nevertheless, since in uart_set_rs485_config() an existing rs485_config() function indicates that RS485 is supported. Make sure that this is not longer possible by checking the uarts rs485_supported.flags instead and bailing out if SER_RS485_ENABLED is not set. Furthermore instead of returning an empty structure return -ENOTTY if the RS485 configuration is requested via TIOCGRS485 but RS485 is not supported. This has a small impact on userspace visibility but it is consistent with the -ENOTTY error for TIOCGRS485. Fixes: e849145e1fdd ("serial: ar933x: Fill in rs485_supported") Fixes: 55e18c6b6d42 ("serial: imx: Remove serial_rs485 sanitization") Cc: Shawn Guo Cc: Sascha Hauer Cc: stable@vger.kernel.org Reviewed-by: Ilpo Järvinen Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/serial_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f67fb6a04983..28bcbc686c67 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1469,7 +1469,7 @@ static int uart_set_rs485_config(struct tty_struct *tty, struct uart_port *port, int ret; unsigned long flags; - if (!port->rs485_config) + if (!(port->rs485_supported.flags & SER_RS485_ENABLED)) return -ENOTTY; if (copy_from_user(&rs485, rs485_user, sizeof(*rs485_user))) From patchwork Mon Dec 25 11:35:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 758364 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2052.outbound.protection.outlook.com [40.107.7.52]) (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 0740E524BD; Mon, 25 Dec 2023 11:36:04 +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="k4bJpEMs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aYx4NuAc7XhQ97gBxeJHkX471JybGGJfV9KCCux9Psqql6FXxXdnTQmP61v0MhsVLoFx2QjqUDOijHrTQeF621s1uXGFfczCwNlrU5JRKChOK7TWxoY/o0KrEEqNmn1oAGTTeiyRVj5JrawryUviUPl2ugpRd5jrBVhmIxTjy8gOFdL5OkmLzlILpnW3be18Ji/DIP1VNE/6Y9deHNxfHnPX21fBFeWeWpXwzheuWJwz0bkiFr5rWViRKWGo/wDaV84FZ74iBgLssgKj9DLK4WvISrUk3UHdYcQimVxrnnj8N6BDJvCd0keu13qijj0biP+j/mTd3RyUvQcBwnpTCQ== 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=C38aQgxrguska+PIS31RCMq8xo/e6B4gcD7K2L61VXDreLMpI7oq7t/woB9m0Y6PKY0zhL7c1Y8W8GQwdA/YhU4AeBFNIBGh/gt2fvLX8RKNsRvQ1voh/XT13qzfQFe8+27aIQn82rU7tONfy9WCP3HLTJn6SWxzu2lZDMyD+XACvAoDyJS6gaCu2hl4vRBj7HZzjVS3gWeIUwq+MVlpKqA0uEfCsMqw122Z0moUvx6Kr+FDMPKogHvKEPaB46kufcWxHHNnDrnilfWBuFcjdPsz5xumPRxt8Bcdui7Mi46Jz8P6XNqMAyQSEuf5xKm3AtmkFunwRC9XHiwxmHWXkQ== 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=k4bJpEMsad4dfxfCn2W6zYW1XUkw39AWvj2SzUvgJe4U5cyRbXaC6er9EuMsg2FmuJ072bqF1/1SAE6KM3ljI5ZAtffuESWe6Ibh4F9Xzl1+4vktxkTgbzg9/mVlEk5+KNSUZ521bQmg4AmUvCL4tEBFnItdy00h2mAyxtpqMKk= 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 AS8P193MB2061.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:44d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Mon, 25 Dec 2023 11:35:55 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06%5]) with mapi id 15.20.7113.026; Mon, 25 Dec 2023 11:35:55 +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, 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 v6 5/7] serial: core, imx: do not set RS485 enabled if it is not supported Date: Mon, 25 Dec 2023 12:35:21 +0100 Message-ID: <20231225113524.8800-6-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231225113524.8800-1-l.sanfilippo@kunbus.com> References: <20231225113524.8800-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR5P281CA0055.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f0::17) 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_|AS8P193MB2061:EE_ X-MS-Office365-Filtering-Correlation-Id: 365e86ba-c222-4353-5610-08dc053da7b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PlB/dzJlVsp6kOYONNs5G8rQy3E0bfSyqbZZ/KLqsUHyxFFufMIf2ge/bOVIp6BjLChBPnWI6E/0ipd9eGbvimehEi8a25QbhV75UcA9URQL0JjS+MplZcNkaAVlFiStyArm8n0ZulPL4z/dBvl4VWikTAVKFoIVMbp4libo/c3QOhqZAM8RqO+cnyBjeqZUdAM0jcpSR+UrB8C3TjH/tvvzyfvgONTekMitEx+iOIW/UuHfE1NGIu5kGrFkfvudeNtfU09Reii5G0sXfW70FkXqpLrja9XIOI0qVSevT+FZjJndw1u8UMph7TLweysN0cAm/CKZwom3246U4TQp2NEkNA+p/hZNu9kqzJIT0gaOE8ulzK8nZCxdizE1hy0cjLMf3dEKtsIlbUO2RVXLSlvLHPDBRCOxU2ZxXcmYm7XusOlAZBVS+fYDHYY7XPupadB2DA6HWx2plTjnBcbsofRGBGduIsbedJgY/O632lGHAXHl7o+ERCGw6HYwdok/ZqwR7zBlB/LBydj5BTpF7ANj0IIQ+unxi/UBaTdDA1VFpoNP+n0oaEkCqOi6k5fz 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)(396003)(39830400003)(366004)(346002)(136003)(376002)(230922051799003)(186009)(451199024)(1800799012)(64100799003)(2616005)(6666004)(6486002)(478600001)(2906002)(8676002)(8936002)(5660300002)(36756003)(7416002)(52116002)(6512007)(6506007)(66556008)(66476007)(4326008)(66946007)(316002)(83380400001)(86362001)(1076003)(41300700001)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?yy7Q/fVAPliT8+RcWQ9fsnClNKAf?= =?utf-8?q?+F6oP9DO1j3wgotJUpEJ60elIBrXj+n0SfDfNDlMS78ej8iSJ4mGC3HSzDwlIRUrb?= =?utf-8?q?vUGB4/kX0thGfCZ5EuTuGPks7GVnBpMOBJ9cAHrvy9199ZYCShHxP2nuQMyGadfBY?= =?utf-8?q?kK7ojy9CzadS/3V4wbkL8SYwHq09+g2cArPySGmOPbkKH9h2y2R9yv1IdTNd+Y6zg?= =?utf-8?q?dmKyAgSNROBdPy9IgJmlFN7Ck5zn1l2sE14O6QDdBJdAmJOkjXgWX1FDpZJ+jQ3Hn?= =?utf-8?q?48kdcHnqEskPaVf233j/kWA9g52Yh8n8johjVlN5ha+FtYvxMTgD+bzdlHniKcrpo?= =?utf-8?q?nU+CgrGudfOEdjywybiBKpUS8yNOS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pJfo2qZh8e3Vy8oPbMyTG6zFaW7LC?= =?utf-8?q?lZDNOu9EzOIE5bwlZQ71tvYdPDyGksM6DVJ7K2ZD7yY7bHpr8cEbl25l1VotmNxxY?= =?utf-8?q?6mtTqRB6tk4T6uVvFRI4mvbgbXrBZEXN+e1m611sp6/MrCPMdcR/xgkKqWFixI9kd?= =?utf-8?q?JTbUdUhqfgA7MBrOUnCSF+E91BQ9elHny/lAv22rs1VohpLZVvRY87e4M2/obThwb?= =?utf-8?q?WDdflU4PoKfDsA3x/K1pQ7mC1vHL+EEsO+rkVwzJbHtS4JtUmDvjKtF3yZwc7ncf0?= =?utf-8?q?VeBx0ZeA8F+yOHirhl82a2GBHt9tiojK/96GvFTppJQ0qABUwN8AC75RZfNaaOfej?= =?utf-8?q?gOh28yRZcvZ?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 365e86ba-c222-4353-5610-08dc053da7b2 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2023 11:35:54.5452 (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: MhmUu6DHwmQHVNngcV4n3xhznAqp1Q5Bk9kRjuwGv5btj9ceEsJJW/mOvbKp1PFuFDHAMEXzcWum694+s627Eg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB2061 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 Mon Dec 25 11:35:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 758575 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2052.outbound.protection.outlook.com [40.107.7.52]) (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 149EF52F8F; Mon, 25 Dec 2023 11:36:06 +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="no0UPUwQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DFMvX2cqB4MV0caLkGCbYe38JMLpp3gOkodkG7o8LkCohpkAZ4hKT0hJKCbIQ5N3omFJcctyCguqgc8zR+od2KKs2fIeEk5pwAOJhtJ7bXRg6Wj0qwxdIXM+rI7MTd+zkd1yacd9PbVS4tzqwGiAhiIBKTYWkG9iure+addGErnt1TGdP4qE7J3guOXd0AicI2kqkQB8dkbB9b2RbwmyVpBhMy5qSvD/3BbfkQ1F8if86E5yPWD05k6JnlaQhOCczdOp0qmdp6+2RoWGgKHi0IKPF8hXVA7q6yVbCvR8A3v0dz/3PE3QVj4j8RjkH+huZXu1XOidXcMUb+7IhbDpfA== 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=/ROGmuOC2TLqjECCgazHB9VmmEt4XgeMwjvGKQa0cQI=; b=DS2AiYxJCcigOl9SWHlQJbSjNDZHdkZY8AIkRK8DkfS0vdcNblNRQamMApihyA4s5TQUBT8lq+xB8SWumnhSEXTfVIXYFxyhmMP+v2co+Cwq6S3gliDLz6BBMWfJ2jZQhiJ2PhDC8KYlH/gB3ys/sapzwFG6sUqYNLsd3R3kO+l6Z6jbJbzRnUyFqJxTVhea6UTZHeD7QtiP1UZmcVjNOEWlWoYhsAbIPH05K5surnjoogHE9wbOyMKJ24zHL00cbcUqAZmnJCzwCNTmjMXxJamcM+zSlkoxxXXlgOKzvDhF2dBNjFSBL8PNZ9WWGkt6TOVf3gbWED8FJt315M4BWg== 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=/ROGmuOC2TLqjECCgazHB9VmmEt4XgeMwjvGKQa0cQI=; b=no0UPUwQ6FA6scLTzxETjAPz8yXSmAp//CSh2wr+8G8g/7dqcTvVB5NdIXe601as15kztalLT7PptROvgsZMjhZTjFqDjQGSC3+78pcMtudcNH1wdQn5v7YowiSRV9qNDA8s64rTlh/j940j4tHdgZXoEWreyd6Ll8W8b0s9nRw= 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 AS8P193MB2061.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:44d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Mon, 25 Dec 2023 11:35:56 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06%5]) with mapi id 15.20.7113.026; Mon, 25 Dec 2023 11:35:56 +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, 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 v6 6/7] serial: omap: do not override settings for RS485 support Date: Mon, 25 Dec 2023 12:35:22 +0100 Message-ID: <20231225113524.8800-7-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231225113524.8800-1-l.sanfilippo@kunbus.com> References: <20231225113524.8800-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR5P281CA0055.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f0::17) 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_|AS8P193MB2061:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e8ec249-c1a4-450b-2ab8-08dc053da808 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vx2UV8R5h3VLPB4KJlIRch5nVKThQ9aHSrs32vQcxB09mHjEddEiFH5N4EHIhbp9g+SMf4HJbatuj9jrgKP866ljcmRf2rbU7jXamIHO7t59FEktR09Z0qQhgWqqlSj2Km4m3g3mK9XdNGNrTTVuPnh9+lE1elfPAseBiUCBrOG6ZhY7Q1f63odIBKZilF+VtG+SdgjKaiqalAxdFCom5Nvotx4WUopsagJJZHiUYqhgDtbgwUnbHowNO5HvStKezAs9Ajb8JsHF3XsrER+VvJ3xk7MMj291b3AdV7WY1ThyI+xgPSzhpSJcK0vbhhY4PgOPFGXFX2oRANcw/B15yqnJtUUzr3AaAET863QFe+bGrzFLdbEc/zxOre91EZfLGI267eDP9bnmqU/aANWbSloFwmpuyqrQdg0y8yQrVk4XOqa5Vc7VrbxqfTRAvlRvQ1FuuQPzoGjv2eXMhbf+NpJZ49Kj0qHNbM64fh6NOKRyGa6xD2UDRlAumilMk9pmZ7SmBMkOjTkrzgHPN/AzCu5yxvAQvT6bxNzyMBqmwlFTn5EsRmtIo2cbYa0hw3RX 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)(396003)(39830400003)(366004)(346002)(136003)(376002)(230922051799003)(186009)(451199024)(1800799012)(64100799003)(2616005)(6666004)(6486002)(478600001)(2906002)(8676002)(8936002)(5660300002)(36756003)(7416002)(52116002)(6512007)(6506007)(66556008)(66476007)(4326008)(66946007)(316002)(83380400001)(86362001)(1076003)(41300700001)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2TlGRWmsH/EkwMNsS1FPAce1CRSDyYmZ98XMFI76VFzms6H9xBeL+12GfPaFMsauB16mJ661Lko2tcSDNPfXwdfFwS5w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UY/fmX06e3PPqmtXlkGQ0RtPuAsgGe4iaY79GSl7GW5YNarZgzTwh283nU08QYRbQ05/OWkUL4gte/pxWAbqA4hwVwILqQ2BiEiKahMdMekUDm250ba/rt/E0nRdQpvXfoAABDGRw1b5pz2C7mvdQonxUdlXkS3PHAuZCPDCvHeCmNN/2vbFJCMGthEjGdT5VYmibc3ngoI3yE/IUjEl87ZgjxkbMGXMT7MpoGkiJ9g3ZYk0nfr19gfJN6Abl6sxhzW1FYR+Fu6RGK+5eHT0qJg+s3aN2iS1XYP7/yAUt9YA5LkDeKbe/rBUmeibEFdLPXcickuINjfgRIOPnQRqgDzPOZZtVFuN3Btbp97spltTQ5087enkAqL7zdWzt96dnMehDKmRBMieJB7CnN9CSsOyI+yqh5XcecGhBTATF9pYMbfgPr8LWiCpcI+mas2Y9ccbqH14mhwEHYTgihnJpK+9oxEVjzJ0vQ3TWqwV X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e8ec249-c1a4-450b-2ab8-08dc053da808 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2023 11:35:55.1328 (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: jivhMEjxjQ7hctgKLt4/1a0f4GQMAzY2ydnYFwLA5+VZKIs/M78JN9XKJsq9iwnyTvzYXb2zQ7bvdhKaBWOcIg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB2061 The drivers RS485 support is deactivated if there is no RTS GPIO available. This is done by nullifying the ports rs485_supported struct. After that however the settings in serial_omap_rs485_supported are assigned to the same structure unconditionally, which results in an unintended reactivation of RS485 support. Fix this by moving the assignment to the beginning of serial_omap_probe_rs485() and thus before uart_get_rs485_mode() gets called. Also replace the assignment of rs485_config() to have the complete RS485 setup in one function. Fixes: e2752ae3cfc9 ("serial: omap: Disallow RS-485 if rts-gpio is not specified") Cc: stable@vger.kernel.org Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/omap-serial.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index ad4c1c5d0a7f..b563c109caa9 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -1497,6 +1497,9 @@ static int serial_omap_probe_rs485(struct uart_omap_port *up, if (!np) return 0; + up->port.rs485_config = serial_omap_config_rs485; + up->port.rs485_supported = serial_omap_rs485_supported; + ret = uart_get_rs485_mode(&up->port); if (ret) return ret; @@ -1604,17 +1607,11 @@ static int serial_omap_probe(struct platform_device *pdev) dev_info(up->port.dev, "no wakeirq for uart%d\n", up->port.line); - ret = serial_omap_probe_rs485(up, &pdev->dev); - if (ret < 0) - goto err_rs485; - sprintf(up->name, "OMAP UART%d", up->port.line); up->port.mapbase = mem->start; up->port.membase = base; up->port.flags = omap_up_info->flags; up->port.uartclk = omap_up_info->uartclk; - up->port.rs485_config = serial_omap_config_rs485; - up->port.rs485_supported = serial_omap_rs485_supported; if (!up->port.uartclk) { up->port.uartclk = DEFAULT_CLK_SPEED; dev_warn(&pdev->dev, @@ -1622,6 +1619,10 @@ static int serial_omap_probe(struct platform_device *pdev) DEFAULT_CLK_SPEED); } + ret = serial_omap_probe_rs485(up, &pdev->dev); + if (ret < 0) + goto err_rs485; + up->latency = PM_QOS_CPU_LATENCY_DEFAULT_VALUE; up->calc_latency = PM_QOS_CPU_LATENCY_DEFAULT_VALUE; cpu_latency_qos_add_request(&up->pm_qos_request, up->latency); From patchwork Mon Dec 25 11:35:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 758363 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2052.outbound.protection.outlook.com [40.107.7.52]) (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 24DD7537FE; Mon, 25 Dec 2023 11:36:08 +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="ymtlYky5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aNJRRw5ymkA3Uy05q0jMMQa5CX78MCbwxqk9nm442VexDQuxS4R9IjoBcoxrHx9LkDLlDXlOYFgylXFXj3AaFG+aWQzs0FAqGjMV37QhIcHJJbyQDyFFhZXF635LyOo3jZGQ6buqT1MnkKIXI1736tZAgAOnwNl+qj9uThDO5DvO5alPpG5jZaZFy5PJ5jfoWVjkMVKYDGwXsKhAtC4WV4bYbRuO9A+R5NA5x7vp3W+3ck/EFmYZki+er8xOo8jzy7FmSh8jkcWY1LB/uN38VBeyzHS7qUKgtUR6OYc5C9hnga2WV926RW41k/tgPscsuWrzq3TufqFbzEYX6aG/2w== 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=QiOByNnSXuhOU2V7uzwkcQkLBUYUrviqa79k+nrvaZaH0jJUvAcAB4PTEkouJHxYOvo6wU1MZCWsn1rJYBgBtN2jktlVYmi/G0k9bsCfwTVBtoxf/sLkLxBLqYDmAwe6RXmUqjbInKnv6B64XhYbwTCJ2I2j8oJqn2SXqtqgYW58FZvxAW6U3p+8gvjj+OyF+iQv0hFSQBCKlxHQN7AsFtSXvE7tVKB29iWV1VruOOO3CL1VT1SbmXyabuPGQODumjPRBum3vRT3Nnxc+5EwLHtgo6YzYfks3ZlXkNtVdTWgoXGYlmGN+WvKtZwKgTEmRBLHiGZwWeOyvAO11GlfIw== 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=ymtlYky5Jx7ECUkTPyeLk5uXWVw33reXsylPatPOT9sq3qdhnozvCEUcMkfjdJUTsBKJHcACzEazKwz32GsQhlNewkOuWfaxCAbGl8zOe62tuNhvLE3nXi+C1PnHDOfOLx2Ai9xLec8sKorGhQfvGrgOG01qcbzkNXnUVK91TgA= 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 AS8P193MB2061.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:44d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Mon, 25 Dec 2023 11:35:56 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06%5]) with mapi id 15.20.7113.026; Mon, 25 Dec 2023 11:35:56 +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, 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 v6 7/7] serial: 8250_exar: Set missing rs485_supported flag Date: Mon, 25 Dec 2023 12:35:23 +0100 Message-ID: <20231225113524.8800-8-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231225113524.8800-1-l.sanfilippo@kunbus.com> References: <20231225113524.8800-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR5P281CA0055.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f0::17) 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_|AS8P193MB2061:EE_ X-MS-Office365-Filtering-Correlation-Id: 81315aaf-8be6-4414-619a-08dc053da860 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v5bPqL66AomTiIOdGfSSBg5v7G/XFizRuF1lz8EvnjVkNkUMD1mFowQaWYTTHpzMF6ZKO2OVB1R4+oV2c56CQGA9Pq1ZbxIgr2N0WenDpAth6N8xhCCTGDywZDQSRc641mklS39T/ErKvpEv17HRdQdXL6QCrn81dKFVUhW3IPk4CeeCeFnPcOOq//vCfbiApxzGITVgus4hci1KJsEjtMSs1HJLfx7EB3kUYikWKYgufnqvDFCY4k8xZHrz4yawVGWEQa4dSDKW+aSgsq+mqUCD73s7yuAj6BiujFoxTxlsFUeuBxuATWx2AanFjyskv2qUy21wfiabdWlBmagOSfoqeesx/biYscINCyEKHC25TTd3oya1qzMNuPALt+PqNbtkMYUI00unaHQFCxpbdJeQg6hBlIzCpreb2aaQ5a6cSnblX9ZOkB1HmCeJdhaqgI075M0ousPzGc+tEzqMsW86q0aBZyBbP/bA101NtzXoC4eACix0NP4NSDlDiutYrxh7rAjjstRsfQkZuDQrHHssaztRr3kkpCTvztth5jBXvGRsa+yw+k/zkTlRo6SWQpk+gAZDTZD3/13iz13JvuwrZtsrAiQdWR19zGRX0ayD48lqzDIQH0XQYHt6bCu3 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)(396003)(39830400003)(366004)(346002)(136003)(376002)(230922051799003)(230273577357003)(230173577357003)(186009)(451199024)(1800799012)(64100799003)(2616005)(6666004)(6486002)(478600001)(2906002)(8676002)(8936002)(5660300002)(36756003)(7416002)(52116002)(6512007)(6506007)(66556008)(66476007)(4326008)(66946007)(316002)(66574015)(83380400001)(86362001)(1076003)(41300700001)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?gPR9yNmrUcPV1Yo4TCJ1pN618826?= =?utf-8?q?YN2o/0BxTGvB3UjfymdQW6rLXnTbLxJHr5BH86gZTztAJ0V4ub8Lz+xpXcBBcCXRl?= =?utf-8?q?1rZoM+ACj+/N24HVJ++ZUQ87IL3LR2QCjR0H60+ffrC5pqVlLEX0mtnOFlR3Zvqeb?= =?utf-8?q?n+0XIU7a9oWNU6H0GNCxIlQycndBICUq/yZoiMwWf3i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zKPd8VcLR?= =?utf-8?q?rrxWurASdnlTmln6gpUTIgUqyl2c8LfqJZgp/9nrmrNK7xng2nfgsT0i1VPceplf/?= =?utf-8?q?fmLAwB7Mf7dWRq+VQ1A5WKyaThE6cDqki67xvr3NIglvEo4ppHmbYQd8bl7+02gCi?= =?utf-8?q?FXzn6xmAuypaLrY98x1asdL1QYYGkfgMD17LAiWufSDPZY+T3uPYFr+FdZFgFptI/?= =?utf-8?q?YsiJ7EHcwIv8a+O/upQX3XxoqOfWQ+wwaBBbL4Vn3XxnT7m5BfSx9SEk3Zpk9zqi0?= =?utf-8?q?ymSv16wsrk1BlAWdqBt1NGkvF5hKncHwoX7gQaVI56jTRVIUTidAEo55STOSwYovS?= =?utf-8?q?XFy10w91t0eytJ2LScAaaqtItuM1Ho1q04LvhFYWle7BYl78Mj8TB0aRGFcqV4gQf?= =?utf-8?q?BkxSoIZnhTxCKN7siWtRsmDSSFM35a36AFLH/FHt5GcaAKzU1/232waSR5pMFuJPa?= =?utf-8?q?F2K3ILFaWSPFky5Tk8sx7Fp5IdUcVENmeP3rcRXhxzrlTLoKUBcwhQTj/prB8OVAx?= =?utf-8?q?OAH8B5wwTa8?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81315aaf-8be6-4414-619a-08dc053da860 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2023 11:35:55.7011 (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: S9PtAv4d1Mr5FjJOCaUd6BWAdu/RCgZDRXN0ZF3JMMESeExq84rhkPQMSsUJzTTn7Muibbgy6ARAcunKNtM8vA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB2061 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[] = {