From patchwork Fri Jan 5 14:11:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 760405 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2060.outbound.protection.outlook.com [40.107.22.60]) (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 79F2C2DF62; Fri, 5 Jan 2024 14:12:18 +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="xIgIn/g9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ezpO/WuQlYeaPlhfJJGWvXmj1fi/71Xj240Vj9g5DAXhSry5PTIf+w8lQyvqu/z25wdQjQKQw34HGGeMmWjwpPZMlGTxoWdx9F6HHrgGmCXoYyuQXMlrwFxTcwzkFYUCZp2AaQpk5/FBgAA1T80/kByYRt+NqS3N9XOaGgGDK+FjIsq8nzcK612wX50gh5BwtJqDHSLHxOqztqmbsw67aAheN5EVM5Wvn1Rx67/J8zrhNxSjpt0R7An7TEL/l2bO5KMgfkNdNpzvqU1EAZehuIxNzugl84t/Ixbh4QBzyCTII6RL+KcHesiHTf7aoXo+V3vdP7X823LRcv6JQPjfZA== 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=08tY/p64qe3JTx/fl3vp5vN6HV6IIz26ikwTn6Erw4M=; b=WH3tkmAcdTeTQdOxKevgvs/GDLnoD79/B7+gPJb7+mBNo4jXAlwiFDRdFdYyUm410avHTOXBTog28Or7wNOevy2CbmSeaBdOlR7LqNGgmDvQBNyOLqTteoti6vKJ5kdXZrjwoTVDiMxDzV+1xkuituq3g/slVGixMkGs4yXbJEtELefAjT9UwOO5qUjuewijk3AkokMYeK8Wd1bSixCiFfT6ro2aHEzZ+FdmHq7tsy3HZyvLEOKTBF6lJVNas26CdzNoIjiyXTVlpzSnnQ83clVZO1OEAxWxjB9rjUYyvf7EidjbOCK4RD2zrI7jiGqGTO1GrhTmQXTA86OLNrri6g== 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=08tY/p64qe3JTx/fl3vp5vN6HV6IIz26ikwTn6Erw4M=; b=xIgIn/g9e/MvI3R33fVdtTa97/V1sCsD7Wd8RpSIJiwmdGjbvad/eqi6mRSi4Dua3uDA/x2hIBVylxOaHPnkkDRePH1FP56GDwipJhoqD/DBGDs6wwkCrvnzCXc7jZQ60S0IFRA7OzPoOl8yC0w3KPE1g0Zlk6r2NC9ff7+GO3U= 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 AM9P193MB1538.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:30a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.16; Fri, 5 Jan 2024 14:12:13 +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.015; Fri, 5 Jan 2024 14:12:13 +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 v8 1/7] serial: Do not hold the port lock when setting rx-during-tx GPIO Date: Fri, 5 Jan 2024 15:11:47 +0100 Message-ID: <20240105141153.19249-2-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240105141153.19249-1-l.sanfilippo@kunbus.com> References: <20240105141153.19249-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR4P281CA0327.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:eb::11) 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_|AM9P193MB1538:EE_ X-MS-Office365-Filtering-Correlation-Id: 603bc360-aa28-4985-4403-08dc0df84ff8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oxe1DYxMJQTpGEWY3LZdg3W9U/EQwWhuFE26xuSF1aAXemLq4H+mDvgvrRxDtXFo3pQKfpjptFXL/ylhc2UuczZSSI3sofRA1qvdmHB79P3EeXoGkmJJPXVk4yl4HIhFWs9TZvUNKjpRgQa1ul3OKAMyqtB6WahW9Aqv/4bxjiogSSn4GB6mUReJjj8QscE7Air2yiNO7Yt8hra9tohFY9fFRIyVriEBZdVcOxe+5H74p0KWBYSBH8K1YJevr84JFlVe9mBLD+Yg3n3J6LQy+GGB98Bat3EXAveHA4h6B+YeB2BodPZtmSEVqEUuZ0FraaCuGG+QXExEaHcYkqi8CeXj6dVfd/Snk+FZsTLs7M1x98b/nOe+iNJOwDd+uxA81GezDEzKsRhij64ZhFK3lXEeTfXvc9F7Gh4Cj0yGmLJgW6j5yiOisf6l7Sy94tsZHveBv9HQtU/orcDnDik1FTmBbunec19Ghz+9vqdYUm5ai34zoVots7iDWC4KNbYVWvjXMq3phZLLogkXPoxVzpsJBfOZt/u4kuVWNq+aGHxZVLAu5fRQffpATGBvBndE 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)(39830400003)(376002)(136003)(346002)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(36756003)(52116002)(6512007)(478600001)(6506007)(66946007)(66556008)(86362001)(66476007)(6486002)(83380400001)(38100700002)(2906002)(6666004)(2616005)(1076003)(7416002)(4326008)(5660300002)(41300700001)(316002)(8936002)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zmDd+0EkATo54gzNXsg09YLp3vKBbmELhGcI9Y18tra+o6WayCbmpKLOzGixxyFGSTYWJ80xvfYX3r2v3bZbe3wV55Qu2VtcK+PCe0phOzUOoS4ZXU99aPFZUAblGI0i4LageeuW2E/VPzy5ZGbERKgrfuvbXKbqo1SgN7PizDngtjegzTNE1NalOYnfCPClPzSg83Av8EfTyC0ZIuC/+IhI+X3A/lpOvHH2m2GnN3+Go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xJpb5d8/RNWqoz+MoVmDea6nw6NEFelU8zSZg2FE+/ecEujsXt4Q9EYHVAfWZ7mqLxNPWiupZ4PO/Au9/yuspNGfDi8BmZ77hrjA7Dg6j/NGufexr97cGO2ETnHTc5UzE/SGdTmMIQKLoQRHatA7vqwobtiBp6X4iGG+y1aygh8BHY9eeTelQwG68dwAq6aqA8uvlpWzRk23BIO0KTbtlRwCpk2R7m4TLV49+HuOyh36bEEW9u8//JOcbJh3mbXpnUef/A/guYWRCDsYnaIHYUfL/VgieKyMuGuGWUUuIY7KCZG1EHXd8675MQc43H9iDM6mJEwzLE7EAroFt9Ox5olt+Mpyl8jMG3rvne/PqGDUziYfQ== X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 603bc360-aa28-4985-4403-08dc0df84ff8 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2024 14:12:12.6080 (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: pMs1JZs1AOxaf/GiR/+CaHy7kq2nfWvV9YZFS+PYxZSvVC2WtV8jKT2Ll/wZgVjaxZyywL7bcHq6OY9Vbaucfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9P193MB1538 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 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 Fri Jan 5 14:11:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 761740 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2060.outbound.protection.outlook.com [40.107.22.60]) (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 85FEE2E3E4; Fri, 5 Jan 2024 14:12:20 +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="r7DJohUJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ToW98U5UXN+ZU/GJpPLQhGwKINY+tiRHXkol8eSWxEiOqwlj5GWppMsBSEilxRsK56FLS8CviYjmRsXMzIqdyKtZjxRXn4NmQ3c1Jpf/h7qi/lmb6JZP/2yaQxDJXHhiWwdUZuutQlbBR45AGlQldmq7ZDroqdB7NidnvJL6DjDF+VDivaHBJOEC6mQv1cX473qdw/8yPu4l/jh94Lv8vVDAbxIqS6U0YxWpD1aftmVxAe/sF+br6TOmh9nbBArPZU6hMNSHKKWGGUpqdrIcyjWcYUe19Mlg00zptGtCcZIPWWjG4y61lPC4K7Yf/yXke8QnJ1F89nVNsWEc8m0Vrg== 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=oEx3SYztbzWEv2h9I0tmMgmESEASOXDa8hOqqMmcMopJs/s0pwZxsCi9Dhlb3LlLdAGkPJudLdetdLxvJjMs6Kc3ugZfm9M/0Z1uyf8QHAJ37rl1U2bTfXV1hiAWzmdfv+7delwJ+U8nupdCy+rzhq0TX5aueIu2xvI4kh2pb7yXEaMTLUCXOTEdP7XfPbC0tNc3mZcetgieKSKqt6GqN1aShGBXYAnnRXXZxXtQEpzTLgHkAIi9bwXRlKCssaZjbzg7WCrwv0jhsSptc1VmNy8Td2ulrTaf+Vu7nsM6PhN/uvPCHyj3efR1O8RH6JlVRJ+kP/a6hfnQOrpaNlmj2g== 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=r7DJohUJc6gEM0YnUOqxMDtK6sYWRq89XAF9H3Osx3p+qzV7sC1diuULSADMXgmBR7L9AzJ2nl5KfdvcH0mORpNgnlMVspClQww8+t1I4sGqcr3jO0kBs+eTWsEvC71S+je5jUjyllwRw+aV0LU/rYWQTlHsYRbVo2+16KSQPck= 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 AM9P193MB1538.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:30a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.16; Fri, 5 Jan 2024 14:12:13 +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.015; Fri, 5 Jan 2024 14:12:13 +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 v8 2/7] serial: core: set missing supported flag for RX during TX GPIO Date: Fri, 5 Jan 2024 15:11:48 +0100 Message-ID: <20240105141153.19249-3-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240105141153.19249-1-l.sanfilippo@kunbus.com> References: <20240105141153.19249-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR4P281CA0327.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:eb::11) 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_|AM9P193MB1538:EE_ X-MS-Office365-Filtering-Correlation-Id: e7694866-e269-417f-ca95-08dc0df8505e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: osqh4yZfWZ4V17rCDgFzfUeyTa0shGbwc4I2+cxMyBdiiaRn1oew0RKvGyq9mCYf1lFRUylc3IckAF1L7DPbuZWQrpqxLXPowDlijlBWEWSNY56OdXeiMULHLcjjK2e15JdTJ21hE65RtnEp/CDytxiYKdFzDf/W29FNEjtLccRz3JfixEpnJOcczlEaFZG3XdYDAV0AP3UX5jo+DIju/rBTQkh2HBT2GyLB8Cxe1ahn67/8r1CK1MZHP4JCxcpJIHfi5t08v8xZeLCDw3iDOrTloP0HxKVe3AwoAEiyw1GL89QNPPnoiOpT8TQq/oiKnCs9H4jXIv4whhNHT6vOpERaoYLWK0rHOiYA2LpCGp9jDocO0FfXcq+nrAS0jZTkwdhr+DV5pKfpUd40sG6EhruIyvlrMbunHJi31AsDU3JwkoNAad2NhDeVPrhJwCe+4XxPpi2A4Se/HMe38wuuydQ/oxPqI7Ffy9IPM1U2YXkH8wEYtNFQnEyv7W49Au5aUG/ZRUWOeyIS+X+ufO/1lJu8Y/CcO8WN6VWQve+9AE5pGqHneV/+xkZztWw8SDMs 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)(39830400003)(376002)(136003)(346002)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(36756003)(52116002)(6512007)(478600001)(6506007)(66946007)(66556008)(86362001)(66476007)(6486002)(38100700002)(2906002)(6666004)(2616005)(1076003)(7416002)(4326008)(5660300002)(41300700001)(316002)(8936002)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Hd2iiKUuAB5wSO425yBwXa20HWD4?= =?utf-8?q?8S6SuMzK1qBk2jhDIk0nj+xDVA/Bv8LFuF+AMQRESUmxiRXzBQ1stILIsEc97iMBh?= =?utf-8?q?Ve533lB1iakJpvpkimb83SPEn+68du0spXf8LkliDH24oLAeXQ9NY9K5dqSTS7R3v?= =?utf-8?q?AZwTL1+PXu69ksUrLq+Vq8v2l9LBPL2oadGLxKwqMkxVSDraIlbeNJvTl+dN3MDcD?= =?utf-8?q?H3njTRuKfRbpfOUTCuKvjAWYGxA4U1bpD10n8EoQ0mVgdHwMt9+OCrNTqjv4xujdK?= =?utf-8?q?wpLdYpDrCKfA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8W96xdqI9WwtkppZWzkLicJl/4OwPobRnbRMcPwyR7?= =?utf-8?q?U0tpSK1/Zk7Rh8QjiEE12DRFxiO8wiwATmmrbwDs/eRMy9ONR3ZUQs/2w+X+lJCSI?= =?utf-8?q?zmJPyzD/VFBLcaomBaWQZUXhC/xs23hoVq849sOi/LwNBEoK5UCUeryA88WMfHjTH?= =?utf-8?q?ptvNrnd1S9mtUqIexyBwAjyF050BD8QrZlO0LZGpFvOtk1xRkfPYaIhZ+Qwlazq7h?= =?utf-8?q?8faxJ5Kb1ZS0qIovKo+ysnR0IUtCDe5uE2o4Z37Ryy6cyRf9ij4kP6geIGrYvywjL?= =?utf-8?q?Kv2xLjSGQCu3FEnhfFsNHqPJLWzMYzqAH23HsjZHOoeW0fCMXgfhKahSxqISHWivT?= =?utf-8?q?/NtG+BWOpSD4lE/JHqKyhO64kwXtuFXjepQKRnaqRjlc4wgooY+77Ww1m+C10Wt+l?= =?utf-8?q?iBzADHPaRGDGuDqOW33mQEeSSGZ7YtCPg=3D=3D?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7694866-e269-417f-ca95-08dc0df8505e X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2024 14:12:13.2731 (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: QmOBhBnc+nitfPS+ygu8XUuUVnIQslKXJ8uIH5gCDEZbUrFLjUPojocTBlDeeyvA/0kH6FtXRKWTTqKPoVJlvQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9P193MB1538 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 Fri Jan 5 14:11:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 760404 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2060.outbound.protection.outlook.com [40.107.22.60]) (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 4364A2E40B; Fri, 5 Jan 2024 14:12:22 +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="J4oShjNu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HOMA1eUQsjxYQT73u5GF3XbLSTqiO+/28/a7MYwt2EmSlUlD6DausqaaYSykPlCspzAQpTqdvOQnI3luMKNL/ru97xG4g86d4qEf+dKleCobTpYTleJY/EjeqwyLQVqkYZhxygQ2xqVjsnweFKISwKOsjpEjOGvZzqOmR3l1LD5alB72yfzgIBOsfwlhI0R2ORRCnPSX8kSjb3r8Z7CCtKIymq14YeojqqJPu3f7pkba5hRG5JEP6Sry2jFOYDda3/5zHaOeRQfdnmCrEalAFhG5ScJ/KI+gwYwxx/Pm5+qzQlTVRL9gX6By5YA1c1bkJJ5WYsRGJMYkQgXMYqY03g== 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=WCA26vCwF2ZupWSgm09Gh8MejcDVcntyi0U4UJSqGjr3cUpWU1JR5b4By8y8YX3Hnct6oA4T9D3ktshJnZ9pf7EMVUltbetGTLJ0Hv+wI5q8Sr7+N3hi8lz89qvgiWyUqusutTnBPlQgAk8cD2M+nDH85ioKbA8de2A2qv5rd4eRfdsVyqBgkzZNK2Vk2bwB9jRdAu/hOygbREpPphApAufveNVbFm9jtQEMxIQWJM/82Z/aFGU8vAVMJHOv01ElIZ3wbVTzAdudd09v+Q8JIZI7zsD+QkMPpCeoGBH7mZViiHdcA+Hw8VSmSMiuxiz+VWLLFtGW/8ndQtdzLE7XpQ== 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=J4oShjNuAeUBDVNh+HFp0ApML6KsJdZWsCvrZaI0fyjwzQ/Kc4kd5OgV0Eg+uIcBBLpdRH/SHiUOev68/zLJ25dpH9NkFcaQSj9Q4d7Xs7BHMkfQ/B5AmuAkVossf5cQqm5Iu45GpE6EVXDGAeK4SS4JJs5imKEcDXszOzOu1KA= 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 AM9P193MB1538.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:30a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.16; Fri, 5 Jan 2024 14:12: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.015; Fri, 5 Jan 2024 14:12:13 +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 v8 3/7] serial: core: fix sanitizing check for RTS settings Date: Fri, 5 Jan 2024 15:11:49 +0100 Message-ID: <20240105141153.19249-4-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240105141153.19249-1-l.sanfilippo@kunbus.com> References: <20240105141153.19249-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR4P281CA0327.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:eb::11) 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_|AM9P193MB1538:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f9d0a11-92fb-4370-5141-08dc0df850c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Npi7DARQ6mcOFrEijT2MqAzd8f2HH75iT4+1Hi/9x9ukllogheVpq7RjaErlbakdwpq40biLKCp2Sf8PuNodd+0WXyi555r6LH2iYWWyBBe3q35E+7lhlMDoanUBrOmaaZ8SvK6feqQ8EgeGOSghg6GzjZEHb/n/fJ5KRj+gNRrcQflS1kPUl+Wdkx77pizladznaLWgX0kdhBvPAwjng2h7VLAk7JroOfY2TjbqOSR4WyvtwXLJ3C4HBs6B+k0E6HmE5I44mcgA9ONR8vrADUPigj3J8LQYsE9krmnO7dtYPaes4cefwrhsPIt1Bf3EN5FAUojDrmaJUb48KhEIzqoCzSjVok/QK+dNQ8GuX4e40ofuASpv8Jrn44TcsK6prl0RImsKvc8UrhJivGQvSEYZMWINSIdVl2dKBToampFJsgdQgZ1gbcuFAUTwWttwP/iDzUii63rulOiLw+CVMgums1JMCaHeET0QmLqYB/qOGYEv/XNuGHQD6TXI8pJWQOQGcO1VZFvBXbkU47tVe29rMWW5MEGneCYHNw6swoaayBs+p8BVxr2bOZOU6Sbt 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)(39830400003)(376002)(136003)(346002)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(36756003)(52116002)(6512007)(478600001)(6506007)(66946007)(66556008)(86362001)(66476007)(6486002)(83380400001)(38100700002)(66574015)(2906002)(6666004)(2616005)(1076003)(7416002)(4326008)(5660300002)(41300700001)(316002)(8936002)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Sz7Owekoqr4WMELE08KHY5ljcgH1?= =?utf-8?q?n2oO5Vq+qo3w3ocBpXw10DcFsklbefz3wCZfVfv6Lxf8PQ2Y/UCHf1us83LJmrTvm?= =?utf-8?q?3TX/kqMAZSV+1jr1KrT85+peal20s1uUv4ex+/meYwPnO+TLxkKLhcxkzokNCTx9d?= =?utf-8?q?w4ZkaECyQvf3d+trCSnClDau53FB/XUxXcOcUbzjojPWOEFkIrqNghOylWS27+J6z?= =?utf-8?q?SK7DcYoLo7RRGvDS5N1bfX0NFeTAJDoaCEFrPLRhRKs6NLXbIBMa0LgmtD6yiXmso?= =?utf-8?q?ntdT33T+oJjlgbgq1bQHwuFMf3O1ZozrgDAoOJo3wkOWISeVMlyhCKeaieTBrolYP?= =?utf-8?q?ur4MqW2rnoIOn542J29xoZEapJ5VA4shGGVNPyezPC6DO5/Z6ybX/ghWnrHxqbfHH?= =?utf-8?q?tHCPwY3YrTpUgI0XTibzDri/d2iHvn7TFqLPgbYka8qHGP5wPOro9H3v4Rfm8o1oZ?= =?utf-8?q?URJZxnjUXJ2NEMaXKDcV0KKSzcH61VQGuwEnSx2QC/ZYMph7IKFvdNp4epTIFvFKk?= =?utf-8?q?+a3taraS0BlznPzJB20cQkxQNUQHyaLWadDFCF5Q9uUDMWKuteDQPulq+5ldd2vU6?= =?utf-8?q?AaOI+/sZ4lO7Zm44VOBuzKy5bTNtWMtUr8ZsUB3FzyeY5ZB6lNXBvKcFuf1jze1PW?= =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VCfUudGkZFN0kzc5YWkmGPnZ7yFwE7oL2W0W7ZdGeGxU4PqybmhCHKopbdZ8gao?= =?utf-8?q?0ry5kB04/Wc3PVmw0YtIYbeFO+06r2eYA=3D=3D?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f9d0a11-92fb-4370-5141-08dc0df850c5 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2024 14:12:13.9152 (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: iKs109ZPNINBRfKQpAiQtq22vD5U3Gfyv+53ZPp+1rvgkIPbumGcRhoYqRc6tUoODLVO3sB1oxPEGrEmFWRbSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9P193MB1538 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 Fri Jan 5 14:11:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 760403 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2060.outbound.protection.outlook.com [40.107.22.60]) (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 23EC92E418; Fri, 5 Jan 2024 14:12:24 +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="hskFSoS1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oIu4ZLUlgMNtn20eAZqPvn9CUZOQvENTPh1uw5WWnG1SKFO65kubymgB1ukY2u8Yl20W3bL6VSy1dqSj4xlB/Joiy7lgJaZ3Q/kjn18zlCtl9g70IqYpxf9FM3enonPd1e0NfuU0JZibdRJ85H7TEwl+C8YlLvpNwj2bHLtxfPZyu4VqNz/KHgV8wUQQM47xwuiB9ULp5HfKYl0/Q/ZSFGAUEQWsRRq5eEw0nzj85nrAIEy5VdN2rJ4h1BWXAHLsCFNyUOWQEw09ugbMh6NulcF3A5H3EQvhYU8lS2hasiKRZzhy/2lkyaXwTLr2COv42Ptd5wC51fZRq1M5vDaH9w== 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=WY9Utj8zaphMFYCcf9xvn53oVr/J7X9+LgpvPc/jERx+WrT5FXnDGHG174FkGT1/Z3Al2IjfV20Awk0ACpeJOI4xbVabR4EdRF/cPj9vxkEUNsFPhgI80qfLz6fTIBkueumLFZj0FAd6pynVxkUP21O0nF9JgwvBMT4OD+s1FZOhDxKMsEa/KBIeMJrmNwX/c9P6KveyLztLZEl8k3k+fl78+xQwna0tEO3bUQFeS5CILGWfbeiMewPguscQ7ZjpVrQ0g9q2oIJ7BEIemcvYiF9ykf3waiyhAjPMCWF4V/uryatnjTN/b3F4kqJI0eo1FEY+gTPk13d2MzrD3TZkgA== 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=hskFSoS1sKRoH3JrGD/NrtLM8rNenRjt2qXlsaHxJphpNeJNjN+lhToeGCUMK6SEnEO4HRw8VU42l1p54GwlXfmz3k6kd2VdNR/vDhv7GXnjVZ0bhSXbSwwKIv6BO4nvJqT7gDB6y90FPj9lN6VVP1p4BofVlA2u9svbHMp+Gn8= 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 AM9P193MB1538.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:30a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.16; Fri, 5 Jan 2024 14:12: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.015; Fri, 5 Jan 2024 14:12: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 v8 4/7] serial: core: make sure RS485 cannot be enabled when it is not supported Date: Fri, 5 Jan 2024 15:11:50 +0100 Message-ID: <20240105141153.19249-5-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240105141153.19249-1-l.sanfilippo@kunbus.com> References: <20240105141153.19249-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR4P281CA0327.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:eb::11) 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_|AM9P193MB1538:EE_ X-MS-Office365-Filtering-Correlation-Id: 9996ae0f-1580-44d8-c3de-08dc0df85137 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hqOxhL61v9xa51MrUBdeVXgbNudvQcPF0xAoNNw4aeuhMwCLAlryMOJRWkVJcVWmuJZ3PA1EoGfy8Gnln8zFSJbe91K2pf3XQGbhtAlXs5gTaVfJq82Rx85FcxQxRF7KnOtWX5PPI3zGrotYEVdTemcRM7x6yYCHqfpVhwm0sE7NH8u95HDBxpJ73+nZSR2VpZ6YV1dIPZw5VQPepPoD0ITn2WMehD5hTt3EYXTiMQVRTu0ajfFPE5DOn4FBelI7pekQHqTd1GOWVv7iNZFkT7+fRej0mUKsZtbYmDGToY6jGiCck/wKzBBCoz21hvZugxDvp2wP12E9U/DIWldEb9t8TCWYcR9QoCsEcgaiGk2WOyfCHcZoK9CSBq/MRat+TXxiESIPtbWGKDOTCGX546iHWigqyqqrp9h99HjSyDXdvrCRkMAjpyPc7N0TTYab0r0yIQcyqWRLoYwpmlquheBsoUZPxzpxKhlVdn6Hb1xyzmgoJquTOPMikpB4NMJoax3U+QQ6BSVmufNDq1whI+RRWZKzoI3LD4jbpKY0MsCdYBkoGzZ8+KAhAFjmDtIY 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)(39830400003)(376002)(136003)(346002)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(36756003)(52116002)(6512007)(478600001)(6506007)(66946007)(66556008)(86362001)(66476007)(6486002)(83380400001)(38100700002)(66574015)(2906002)(6666004)(2616005)(1076003)(7416002)(4326008)(5660300002)(41300700001)(316002)(8936002)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?JGUhf7tu6Hq56yawSQ5XZl6MfXAe?= =?utf-8?q?fSpamVjVa21QaIeT0Mpk1F3YszvoGnD9SPMWTZP9Eev9tiUULY8Yx0HJgwWBIyebU?= =?utf-8?q?4wvs3URAwRph/fxU32M3UOXsNpqfGzOhoeTuIYs6G/cGPHLi9RTvIAh/qcOpY9NsP?= =?utf-8?q?ummcbQn0+/s5YsQW2Hkq/Tb4SXEAtytcZz9+ZY4ovtifHxgSfs8wz5xudDjyCOqyq?= =?utf-8?q?0G3G8trtOszl+pmIA8bCmKNIFoyjCCk4X4rMq183FqJT4ISQq0pFBWe5lDBlRsldj?= =?utf-8?q?OvZxb7+B3JP5juMgxr19mR0ntPIqW/TU7nIcihlNzP+D80T4SN/puf1FTK7llzCJI?= =?utf-8?q?T9SATufAjPyeKdHjqWfQNig/6lR+98rOj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Uve9ZJ2GorFlkJYFIv?= =?utf-8?q?84i4oAfDD9Fzv3yxnvjSqEcPqCgd+9Gr/XglfukifWinN7ka+UbXtuYARBsYewaxt?= =?utf-8?q?Kh326CDp8uinMZ+n81gOslgnhvxOyWr11SdwLKS1HYdaqn3wMPjQ23kT7HkXp+fca?= =?utf-8?q?pIoYK+973g7RpXuTAFCfM3LpJIIc4mwznJf9K1ZB2Yu2c2O2v/gJNXZ0Hs5Qhg7SQ?= =?utf-8?q?kOyy3XhLbu1coLZJaZzqvLK8StCVSemuIqiQBn+kyWPAJ4C8ExyXGhPTN7ndfXHJd?= =?utf-8?q?YYY8Kl6S3aWn2X6u2tNg3kYTU7wTO11/dyYs+Z0IbPn658gugOzygNbz6IGjkwsQx?= =?utf-8?q?XxrYx6jvB/gbRH3hHwFH7U8Jq4CYICAOw=3D=3D?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9996ae0f-1580-44d8-c3de-08dc0df85137 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2024 14:12:14.7121 (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: 2OMxQ1nk6vEfxu5K6lxlHNDF5KU9o0R2FBKnjca4OFlRdjMIV5qs8LSjgPH4Qt4nhZTlOQymbd18bwiUas3W6g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9P193MB1538 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 Fri Jan 5 14:11:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 760402 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2060.outbound.protection.outlook.com [40.107.22.60]) (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 F29942D7B0; Fri, 5 Jan 2024 14:12:25 +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="S/8SUKsg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F/QPTRoJPsHYzI7Y/eZi8f48OO6K+1YbYVmB6BkSqAIjT7SGQugK54lk/WgNWUJuxPpWi/TqqD7AAJmlJF0ZyR7Dy/Jv4DwJCF1Mm2YgqgI6Vqilld5EIPRUvREtID14QfAHiWTtl6duNX88w5sW7QEp7v8TjUm7P2DndS0dUsp34y2k6QGlXjoH21l3gSOuan0OgOeZ72DIx6647TzhEQxSfwUeGSyyyivU3V2YO7DqxUm6c+H7hHITIMK1QUVIPVRoeINRLzwitwV9EacepO9sP02c2IeAOCZV0mxKsLnAAWF5dS1EJw9+zfT182R8MrgQJYc0tOuxrSi3GYmrJg== 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=MO90q+6gxUPedgZTk9T0oK698FDczikJmPxC4jA222g=; b=R4Zqkxe5ntveX9ULH7nAeWgXtGDbpXaIu3I4KwCo+0Opn/WyVFXdXzUKteDog5sNyjqWVXpKQQdUyHd5YDbQcCwPIBDUPL5puZGM3hvpgwX340hHWZzxXm/6RFY+z6fllmsTjSvKJSKc1G2v2VFrIc4q98nOMnLWb+nXiRuskdjoMsMGzgBuMVbGV3YsjM396HMciOW/mf7z4X4/6UUOAKDkKYvxBfbhtdWx4BdjgPWMtTVLacHOJWQrGE4V3bNhn8zJaoVhkpyiPvWKJvTYKul+N+9d96rZzMPkl31ceAzWpC6pKyeDe/9ca/QpSAeIwiHt2E3TILl5sw7J0+E7Og== 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=MO90q+6gxUPedgZTk9T0oK698FDczikJmPxC4jA222g=; b=S/8SUKsgb6ZvPyKEW3G7bHLLjcnakHCwQk6KbH1eGc8ubt6BTWToeGZZxaGSwSH4/9/4wGWaqiJMm7yCW+R8BhhcCamWFJeBgAeXl6XEyW5rDbfXMM5CTjNLLjgO1jK//pkMARRaXjnnbQgif4q/yTS5l1rN6MEf814owlHzLKI= 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 AM9P193MB1538.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:30a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.16; Fri, 5 Jan 2024 14:12:18 +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.015; Fri, 5 Jan 2024 14:12:16 +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 v8 5/7] serial: core, imx: do not set RS485 enabled if it is not supported Date: Fri, 5 Jan 2024 15:11:51 +0100 Message-ID: <20240105141153.19249-6-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240105141153.19249-1-l.sanfilippo@kunbus.com> References: <20240105141153.19249-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR4P281CA0327.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:eb::11) 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_|AM9P193MB1538:EE_ X-MS-Office365-Filtering-Correlation-Id: b1625078-dbf0-4cdc-83ec-08dc0df851d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zkrSp1WpqhNISZxhdP2n9577Lf+dwFRdRHq5Q8OERXCKHkBRZdFQkNewckBDRs6vFXPGa1wQtxjI+bCdocAkcqyxDELvaoKmqe8WbJcZk6KYenm/MxH9n9kyEFyDdU+mG58NvELBav99A45UrPBIZx/lkAkkbRVnM+0jR7XmQ7wqprGaCTia9n6yZaLnpDhvByu24I78ItL8QDWSLT4MkodysWY2ZOXMfEgFrH4inFEaNl3lY/xLWKnloUdNK4V+GbMncI0PaHktfwQzj+HjX2M0TBvvBnDOiyazJPpS6P8fKmsgXoHyNvxGSFRDDgyOL76m8MY+Jepe3hnN2pWNEh43dRpahgjOF3cQNVfAjGx2l2Ud01kXhktHhJa75rv9bkGb3lL6M10uqK1Yr4P2gsQtEwvaGrgSRBCnanTiT+edAybTpi2EswRkskx1nGxotI4G5qPNH2ms6HJmFEjvD378t3Blhs+f/4ie6FZ9M6AbfSreCC4Gh6P3E2LlVLbNEp43HB/E0r2TIHvvHiQT1qjx1IpRf4yz28DKSoKAd3OTS1Kt22TRv4IiQdX5mbjw 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)(39830400003)(376002)(136003)(346002)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(36756003)(52116002)(6512007)(478600001)(6506007)(66946007)(66556008)(86362001)(66476007)(6486002)(83380400001)(38100700002)(2906002)(6666004)(2616005)(1076003)(7416002)(4326008)(5660300002)(41300700001)(316002)(8936002)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?WCqu8lTli3YFfiLEYUKIUTHidJWE?= =?utf-8?q?0vW5E+zTSCeZpaIqRRDkF4a+S4F3xUSU/MUEVBRAb9LUNkKuncLgFKVVmvSwQ4hz2?= =?utf-8?q?ktnuPHipXC/WV1d/0YKhY1LyNQPhokAzG2CUX3yVppI7jiYkkr/moirzLFIiHoj7F?= =?utf-8?q?nnXKkIXV7gfoE31Wbyy74/3hOWQ7GCKIQOm3ILuktnQ54BoEZyPQ12xh8n0uRVz+y?= =?utf-8?q?kRipWG0ACoE0MPSNcqxw1xLDsGXwWYydi4ad2sgDC5+F2IZh7LoZ1G6fAdiGuh/E+?= =?utf-8?q?EY6sQvfDMYht/LvpX3tmIa/mJydPmhyAqIviDdn6FP6ZqLojc1T6L7M2ThWAdAVqS?= =?utf-8?q?TZHc+G1iTds2JOrvxzdAO//fo9WOK4tkrShsyMmzpjKudVJTHGesPZ7bb6BBjzYZs?= =?utf-8?q?PxiYDK5hx5xAPA5LmkvgRccgnH8t3Vy5MpdVpbpUKMM/aUQjEjRnDQZ1vNSqsHzPX?= =?utf-8?q?ffA/XRIpuL1qlDWxui2UJKHmVFMz0ls1a32mk1E2mN0geovBjk+hhSfzdesl3S96D?= =?utf-8?q?C+zK1tYm+V/gUouyhIhw3jwCoAs4M2Ursvayqv0qnUeQzLzzB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wopT9LgfghSqWBn/sH?= =?utf-8?q?r5cK8EWLQky2X6TB0SBHVlCX24KRYE4x/lFEMJxlnNeCAIHeBUGYlbyepl9dPL9Zb?= =?utf-8?q?0avZdkzB3SqwETcXx6oBbSs/2F14I41NCg+AltlLawhYB/Bnc4/aDFkzXH19B6sXV?= =?utf-8?q?fv1Q7pPFsUuJQbFNdX6pUiqwcXoiYURWQ=3D=3D?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1625078-dbf0-4cdc-83ec-08dc0df851d7 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2024 14:12:16.7359 (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: Ga+VbiUBD5SXtC4BDn1IouYSM/sF6+VEI8cboMWmc//Qqj5m37LAi7aUZa2nzlaGr8fuBKhHBPc7MXEGlUTxVA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9P193MB1538 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 Reviewed-by: Ilpo Järvinen 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 Fri Jan 5 14:11:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 761738 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2080.outbound.protection.outlook.com [40.107.15.80]) (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 364F92E652; Fri, 5 Jan 2024 14:12:24 +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="X4yanZ/f" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VLauKdM8GrYIQkQbUFaKq/DfLSq8tG4C2U0qlHIoFyYttTQjTBoXQIrHxDXeqvVSw9u2/xuU8gRbsEuLEdV19o+9icnRBAA3bPv+/zl4YGdUja1To1aoyIWCPiVDBS4qzPeBs9Z/Rx9/iDx1oRqIi8a/wvcraJBrptJwZz2FVdOy0MRr4P5fmak9bqPNE6zsSVSLW7OzIKEzOiFCZZJfhlyyj31AMvTD2KarF4Va4sgJaJ85qQyZWLhVq4U+HT+jJ6YOv1OtjHHYUgBRKPGeBDmPiCv40p33P8Xu0yo7Ni5TBNrWNM4ch5iwn/4EBhEstK4ZeGjFpcILCVEr5hKTZQ== 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=aG14v1l0mNKMp5n7ZH3UkcOWh/FnIG3dYuQfg/M+qPs=; b=XT/qUy9uO8JAvJBHdTjAsZOMk6Y9Uq7CYz+jIrBm7vYAAmwRZJ3IHgFORrtcwylqAGQfQmpa/bmS2XsfslbIwCNouc8vnnULqFxRNZ94h1jOePu8mam0Gm+s1BpZFfEqYibGpGb9YEu5tCYRur5p9q3AG2DrY4jWP/bYeAvoLaf4EJtDNe9lZUl5kWOFJzaSNiN3yg1UCJq5iX3bjiu+31ol0g8J+8z3G4qdOUEvd0x64m5xhUoe2P8ESvDxU48ilR8AL4kIODfEzpcPfQ+OZcz4QLrnVozQKgCZWUZFlXY7q7PrbYhUb+op+k1rRljAN0mQGbDYkkYzaz/3vXwcWg== 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=aG14v1l0mNKMp5n7ZH3UkcOWh/FnIG3dYuQfg/M+qPs=; b=X4yanZ/f/oZgGQcZz+ma9CBBSUKpKx1uEle5+dCzEZAlPL+6qU1usaimqA1hKJE8rfM8WWRRUnz7m300pnDak7JzYWivXf11hGYbaFrcbmnU0CkV+C95Pq97scXIvV+lkcW2VRjI9DdIsEa4PDwncdaXlF7+HXO3Y2l3PjJMWh8= 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 DB9P193MB1403.EURP193.PROD.OUTLOOK.COM (2603:10a6:10:2ae::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.16; Fri, 5 Jan 2024 14:12:18 +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.015; Fri, 5 Jan 2024 14:12:18 +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 v8 6/7] serial: omap: do not override settings for RS485 support Date: Fri, 5 Jan 2024 15:11:52 +0100 Message-ID: <20240105141153.19249-7-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240105141153.19249-1-l.sanfilippo@kunbus.com> References: <20240105141153.19249-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR4P281CA0327.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:eb::11) 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_|DB9P193MB1403:EE_ X-MS-Office365-Filtering-Correlation-Id: d6ab6fdf-e054-45f1-9e7b-08dc0df85371 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R6/SgkcEoxjAk8kKHxgrt9h24fYdsVaYgu5RaU+dxI6L7uAx2o7JBWwGnJr87+gx7WZKAnOBZWGJ9789A4PC2dfyeR5Vqok1/oGZxZ4bUF9KS0DDup4kpc6I7xvG0i+6uMxzSKOw8EPqMAfjznpX02h7T3/CbFycGqNexWwhQc4YotOPoMdxeZt3CInJIy4s4g5MN0Na13OWX98XA4q+q7S7sxb5hyBlXTw4FQmKTmXzvDsDkcQdhQJTTWeJO8kzm9mvff/c+t46NY1/h577fWi5vqzmCR+XpS8gNDwVYJOTYNdc8onZi5i3Hw8mGqpc8k0ct+0/Asg/od1tzmTppWHxNzYERygulYJR1nFp4NFT9npKjf9ZKplRT+Sm2v0Oe+4Py0OgQK83lWKi0p0HaczbdeEKUmsgkqSZT67g7RZsDj/bumNgOASNI9PB5/wA8NBCnO960eklOCOejf/Ib+6Um4SHah17AC/xVYQ+Sut+H7yE/8+bKmBPyiexmPmJ7ZN7FZKcnNVO77QTY+sMv8hNSYzM2LXWsns7ZY4xSRkclQUZfmtXNOS2PJMDRvS9 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)(136003)(396003)(39840400004)(346002)(366004)(376002)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(6666004)(478600001)(2616005)(83380400001)(5660300002)(1076003)(66574015)(6512007)(6486002)(66556008)(66946007)(66476007)(6506007)(52116002)(316002)(4326008)(41300700001)(86362001)(2906002)(8676002)(8936002)(7416002)(36756003)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?6boWALpuO/N/z5qPZo2rpTJSyQDi?= =?utf-8?q?FcsddDuFq7uyoElVDhhADaQ3cH0qwxxSWiV/s8CJFXQtROU710UXkPWZXjaO2SH38?= =?utf-8?q?+u1QHv0EkzIViGg3yuKBdO2v6d1u6640TlaTDIcGPYcOibwuMM3IZNKsso13Zdsgd?= =?utf-8?q?MSLVTPOvJuxvOghvchB9YDqyZ7906ycxnpTOKg8HOv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H62g5++0tMqhs7?= =?utf-8?q?gMmNE3imv0IGX1ndezHci/sty0eVuFDcT6pdc8hYuOVUGGZo7jAQ+WMpY4sVeq4fR?= =?utf-8?q?8TgN3pK2EclZjWW3lk9znvd1Qj6t9xmGhRke2OPSR5ZuPbok81Tuh+SYM/sZMGSRM?= =?utf-8?q?vDzCcQK1UcR4VWZMZU8owS5IVj2vM0srYIOcPtZCNKRolWtZCdbBmonwB4Lr80ZcW?= =?utf-8?q?5wp7kNfE4rewQ0tvGttoUA79Ul47s23B171xOTaByBelYFxtELecKCF4K3ClXviOw?= =?utf-8?q?x0q7gQVcfUVHeRpiqjVnvmmilzni+chaTfl4DZKG3I5uJ5RoUYV/6oiLOIOosUbQE?= =?utf-8?q?LTwMwdoRtRt+duImfNMSRaeLMPtVq2J0IyWW0TfCt57f9biHRufeJSRArtrASon0d?= =?utf-8?q?aSfcu8wmNHJJAsL+MIajoTbCGTEk+dIpyMS8mUP7Pipda3B+O02q93PbCRnyhqMdK?= =?utf-8?q?o8ZkkIvgd+LbUrpbj4l68EsG0huJcdmrsU5ROnNJC/R+38Za1FsjTB2PniI6HqjVI?= =?utf-8?q?5uO4DZQIf6AWroxXeAezXJzcat6jG0Zug=3D=3D?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6ab6fdf-e054-45f1-9e7b-08dc0df85371 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2024 14:12:18.4206 (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: uVnGjhFn0Z9nWiU+W2V5ebZygC+epw2MsQHz5hmgpUfsXSGv+4YwjdA9kkWsLz8Or4V1k/eto/M6ceg6Muo6Qg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P193MB1403 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 the check for the RTS GPIO. Also relocate the assignment of serial_omap_config_rs485() 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 Reviewed-by: Ilpo Järvinen Signed-off-by: Lino Sanfilippo --- drivers/tty/serial/omap-serial.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index ad4c1c5d0a7f..f4c6ff806465 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -1483,6 +1483,13 @@ static struct omap_uart_port_info *of_get_uart_port_info(struct device *dev) return omap_up_info; } +static const struct serial_rs485 serial_omap_rs485_supported = { + .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND | + SER_RS485_RX_DURING_TX, + .delay_rts_before_send = 1, + .delay_rts_after_send = 1, +}; + static int serial_omap_probe_rs485(struct uart_omap_port *up, struct device *dev) { @@ -1497,6 +1504,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; @@ -1531,13 +1541,6 @@ static int serial_omap_probe_rs485(struct uart_omap_port *up, return 0; } -static const struct serial_rs485 serial_omap_rs485_supported = { - .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND | - SER_RS485_RX_DURING_TX, - .delay_rts_before_send = 1, - .delay_rts_after_send = 1, -}; - static int serial_omap_probe(struct platform_device *pdev) { struct omap_uart_port_info *omap_up_info = dev_get_platdata(&pdev->dev); @@ -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 Fri Jan 5 14:11:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 761739 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2080.outbound.protection.outlook.com [40.107.15.80]) (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 6D83A2E414; Fri, 5 Jan 2024 14:12:22 +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="DPttAp0/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iOnRHYuXkiy0LthVVIyclyZHm6wmLWxYfNc5Y05T8HrngxzTTFqY8KMnarjLGEFduEqsWkOHL3MPm0lLUERPpmnoQPmjiVfw3LQoJqjZs0tYkIOi07ToG0Su9DhQdkCsy9baRcCmcZWHMmACVJb9eRpXnbjlBd6xwSTnuIAiSqXpJlzqbZhz1Om+s0qzlmOjAdWiTGDVV3vHUpMPPJ9Wx2nJJGhxM+BPYXW5WhfCTVsHKPVz5klqpNJMncB40N3K+LNiRnFDOfzLVTdxJ8qAAcUFIKkbdX7PpSBD8IvzOHJJNd0WL3nWVVFPemd3sKI/LV7vamTKNP4x289M/+xvqA== 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=JzfaphI09etIdPQmmCzjbcl3olLF3wrHrzA2QYltA+TulO1cC/9yAZA5q8rke3dbSMjcieyYz54XrLvd6PSfK7sYP7QFKNtxbQyNrwXKX72npGeUUHUCn35AuSftRUS/2TmPnfH2T8Ry7kNqz5OlF2mxfgX64lrWzuYpAye73dt0gJYZo+mX9a4ECVBMsKAkRlCJSDOA316RwH9XKzc2RgQ4v4QweHq6GXpUCIAEakC9mGNfi+34BrmdcZ8i84Cu7BIvJeIXDBSD5XrusjfVgW3UlxABjGVPxKajkGeFgaA6NTFRcWfhclwWQHSIU1FNL9ujinUFVJOnxFzSpfp78w== 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=DPttAp0/XMkIb1FvF/YYqLaAUfs+aAu/RaiQngACPmy/amnhIInGdBsPYZfSOfF2JyNGjb2UVPQGQwO/quXOC5p/jGcbWMRtTPq7TciJAVXcOSutoIYTY+RngNHdx+8GxW5aFNVLCWjBWFE6MolfDUEYcqf2dPwmYbwtmiWc4nI= 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 DB9P193MB1403.EURP193.PROD.OUTLOOK.COM (2603:10a6:10:2ae::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.16; Fri, 5 Jan 2024 14:12:19 +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.015; Fri, 5 Jan 2024 14:12:19 +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 v8 7/7] serial: 8250_exar: Set missing rs485_supported flag Date: Fri, 5 Jan 2024 15:11:53 +0100 Message-ID: <20240105141153.19249-8-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240105141153.19249-1-l.sanfilippo@kunbus.com> References: <20240105141153.19249-1-l.sanfilippo@kunbus.com> X-ClientProxiedBy: FR4P281CA0327.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:eb::11) 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_|DB9P193MB1403:EE_ X-MS-Office365-Filtering-Correlation-Id: eae7664a-64e5-4ed2-c0cd-08dc0df85413 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pclExZA+wfAIN9iDmg6KFEMi71SNqIxCeM23GcC7SOzz6kdmZNeaFfO93dXZuYFJV5NVAej1cB0C4FNPFW/OhBV+K0OGb0ipgZtRcWGG2o3kqalyJaH29OiQQp7y46VBMIbH4B/cddE1lV9tAHMVKwVn+JsmIZfQEodIZBj6Fu8jnebdjm2xKMU1iKvJ7IaYibb80Vq0/XdAp74B7HHxpePQRp6RXgPl5+5aRu/igaZnP7CMefGbUxfJ1Yq7OR5zpKAie4wmub/MHbw+4dNHgocugGQs0EEpn16D2fwtCzE1XdWnHP28HlAeGTb2ahg+0CIkOrVJsZygX30Kwyc6u+I/+AV3FDJQUjHUf9OQdX3pCrkQg0ycrcyvCgPRXx7gP1+lQ2zv2fOh5SjkRznL+IG3e8+bLx9qYzH2BM+BBMJ6UriABnwzGfbfNINl+Kn6dAnU96ciVrQ/lqTKZjgcdPfctGCFQVR2ZAT/pXlj7GdTAEit0Fr+LFqT2hIe5CtmLDUaD6HLdY3n+CPVSvtj4CGEjR2CmPskvXSWgSM/hiVJ/rY75iH0yd7EVimt+TQMMcRuKC0yVCB6uxJhIJSqOU7ayjeftVwOGrLZ7Ti3pdlBTuekYBEU5wP33ZU0abjH 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)(136003)(396003)(39840400004)(346002)(366004)(376002)(230273577357003)(230173577357003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(6666004)(478600001)(2616005)(83380400001)(5660300002)(1076003)(66574015)(6512007)(6486002)(66556008)(66946007)(66476007)(6506007)(52116002)(316002)(4326008)(41300700001)(86362001)(2906002)(8676002)(8936002)(7416002)(36756003)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?sNIsRgqo53yE68HztynLSagKH9wh?= =?utf-8?q?Ni+r31nUrf9CAQ78gp17I56qulexrqNgvSOGQggBrJUuTefDKD+vSeGWwH71Jr15o?= =?utf-8?q?Te2io7JW/t7obKYfF5vbuEqcG80Ld5L7Y2O97Stx1HsTfy87d1v+JaRDhnQgKNWT1?= =?utf-8?q?7S+lBO5f8qlPuJayIZI6V1iLFaa8sA1xq8cKXe37V+/ewQByCiheCBmU0ynFTj1y1?= =?utf-8?q?v6CrD0nFfJHq8TzDLS4stKnb8rcagpXrLj3Y2EeT+A12uQvX3Z9EocHfInq5/fOb7?= =?utf-8?q?19cB8KKuLQHJH+0zYsRJfCmI6j1IGpm70/6MPEbkHubyoZOjb1m8V1kREnZmt22S3?= =?utf-8?q?k0y9mwe89XAt6iDlrxaRrqEVSGkkvkjuH+1daMBRhl4U7I7UA1I2BqduaYgvRdi6E?= =?utf-8?q?NnQbTAUMJwIbTm8J7QG0AqudX4Mf8Ruxv9nkO2Lv/2eis8t2H19mXktS6qtfL865G?= =?utf-8?q?sIo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m6fTmgATA04UySj4qtRRw6JYadM6pB+LjhZJZHu0zMTjYcSTl2FUfCWvQtqbM?= =?utf-8?q?9/nsybpE0O9xrkXPBQhZ7mHF9jkiDTtT0NZCH47jwAdqsVmeG5mVTCqNy26JzgTXL?= =?utf-8?q?a0dRk2dNFsXofFWmu5ZWFrnEZSdiae2y47j4WjyIxsB1jg8BNOz/p100ObLc2tKfW?= =?utf-8?q?oAk14LXugk6yTeVSMAmoJ5bLVRqQhNXI22tl7TtDRmmiciJHiCswN4K6QJEwsr2BZ?= =?utf-8?q?91uwLaaupw0sn1Oe7YR+JvW0nHB8kUlIA=3D=3D?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: eae7664a-64e5-4ed2-c0cd-08dc0df85413 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2024 14:12:19.4579 (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: 9pPPALFKj05UIt33mO20FNIQoLp77EGDTHwZ/9MbJZGXLsjtZAOA8hMqdmEGolkOm8ElmiCpgICjhvoaM3wqag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P193MB1403 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[] = {