Message ID | 20230928221246.13689-1-LinoSanfilippo@gmx.de |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3665349vqu; Thu, 28 Sep 2023 16:28:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFsF2Q4Tfv35iNvQzFKZcEt4kcxFPoPqtbE1IZfX+7ENJGkQBQagYbKCpIgKOkD1nsjH9UM X-Received: by 2002:a05:6a00:10c2:b0:691:da6:490 with SMTP id d2-20020a056a0010c200b006910da60490mr2942650pfu.5.1695943706479; Thu, 28 Sep 2023 16:28:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695943706; cv=none; d=google.com; s=arc-20160816; b=cx63AwCkQPe6ijcmm7khBO97tdg6UDgnTCX0J7XdNb9V76jX83X2xSQAtIfqDOci3a lx8uOYBIN+sqEJir/CBfqlzSmP4MIjBJouXXyIZSQIqdSY/ljDKqOKi0nzKGf/3mTqRt Y8SH77ae6oUqUWDCJVzzBpr/gpH5EPpYHVHLmQGCJ+j/D4/So2iGEBdlPZTgywtwGbbo IwXg/LDLpmVkh8sKsdQO0ZMllDXuANKwWYLySDq0Zz9X9jwrrOxN9wupxZltfiahP4tg O9VlVKmF3y0cgor2pVogtOH/aEB6Ecry1cQsRIpLm59GrvQdW+yklnTVmD2/8YqsgabA 1b5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=6YXjvZ327kvgfe7ZgwF0JxtwqUgfKrPOEWMiLQRBa+Q=; fh=SRJym8t1gs6ROJtIUNhOjWeP7E9fpzxhK4sMUQMqITs=; b=WCF8st8T2j/Ums3i5P0vvSIIgje6Lc2lIdaxSorVL/BfO5xcwl9qX3cOU8nESIpEJQ gYovSwBMZMCfGTO0fDdCUpp/pgEeLqBaTVendOdm/V+bJhZ6FZE4ouGumx3kULt/T9Rv PoUe4te3+BFqLuyV/6HC/jTcQ8SC3XlFDX27ywEKztb/GH7y81M60EB3RGd+cNxn9kKG S65S0z9XY+3iZ7hTpW0EQYfbKxnyYYSKGMQesB9TQx3jNEgT39/neGDiZpZ2BChif8j7 VkGScKsqOxDGRiVN5TpA8l9L4JVH/EHD2eVY/b7lMqJEaJ7wQozJB4osKnKtjA2N9RFu GaYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=UkXBir7E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id k18-20020aa788d2000000b00690d79b95f7si20394996pff.288.2023.09.28.16.28.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 16:28:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=UkXBir7E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id BE63D83C8F92; Thu, 28 Sep 2023 15:14:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232604AbjI1WN6 (ORCPT <rfc822;pwkd43@gmail.com> + 21 others); Thu, 28 Sep 2023 18:13:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232525AbjI1WNv (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 28 Sep 2023 18:13:51 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6592719E; Thu, 28 Sep 2023 15:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1695939212; x=1696544012; i=linosanfilippo@gmx.de; bh=6YXjvZ327kvgfe7ZgwF0JxtwqUgfKrPOEWMiLQRBa+Q=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=UkXBir7EKKoL6ETns/eYpZcNxS/EFybdW98pz2fkpCuwodQ/pRST0GJVnmVcQ5XErXuFxe1LYiI chX+mJCgJfw60gGob+0Grbq+pZN2Rz+a4FyHjzSCWDm0nAxv79URflipPGg4oATlNuzpvGkp1ydM+ 2larUeeVsRkUiQNEsUB12t1IfmrF4jrcf/nLRFwxfJoHt/EG4TO9O69xbZO8Moos9or6QXkyaWG0G UFiDi8IqOCEBaL8kRknnifp+G+pokLEND0RZSHjXQcz4Nyej8kQhTjEUjHe8mezHoMa2TJPn23dHh DX29AxMML6ztMJU8AWeBCVXLaW0SpRoTUJfA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from Venus.speedport.ip ([84.162.21.41]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mjj8D-1rWHFH2Y95-00lBlB; Fri, 29 Sep 2023 00:13:32 +0200 From: Lino Sanfilippo <LinoSanfilippo@gmx.de> To: gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, ilpo.jarvinen@linux.intel.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, l.sanfilippo@kunbus.com, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com Subject: [PATCH 0/6] Fixes and improvements for RS485 Date: Fri, 29 Sep 2023 00:12:40 +0200 Message-Id: <20230928221246.13689-1-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: base64 X-Provags-ID: V03:K1:XYHlM2JmTJQzcsNbI6z7rvM3CB8aCcSxFT62l97yn4OV2I8LuNz XfspHS9pqyP64h9MXoMXaKtPVkkB6HwSzIdZMDRe1bJtjQnOvPo6zHEEALJcJ9bWnQU8zcy CjwVx6R3Kt41gx6DkXhKesd90wYgJ0cMFpSoIV4ic0LRZnrccqyLBlOsO+M/rTue7sdVjgs kHXTiAy3juLbWIc8ZRCLA== UI-OutboundReport: notjunk:1;M01:P0:xyROAPD/bm8=;kBRi3odMGDPCMhkJ33GJl+VyJwR rxYEQBCoz+hY0sBr3Jr7ePE5Ai5cgBooSBBr4PCqvVtfg0Ptf7dlk3USf7g/9gDT6BLK0RBqL e3BGFcFYvsAXbpCB/Ghj83LaQQGxOxgLBIxAh81X1o7dCEtV2NHZkKQTErggncua5oJllgjS4 xafbch9ckaUpdQUDUSS7hOTgyOH2StfcBVpQoUgN/xKXNXa7a4tBbD+jDP1kuypW924knSQRm rXexz2hxnlAT9zvUN2bLkXm47GHYKYlG9K0THoqdPRBoQmBtYKg1Z/nudTX33V+SZHXFfvMT3 5Ex1Pg1EThS/fqmrt5Q3+4TBvJ3iN4BqtN46LdlRAIPacnHbaiX7OIqY/J/gQ4kbyf/1gtcwD ygSNPT250TmMt739sda2Qr9Go5rjM+UNO+vRL2Xusn8XTQ/UyvVitlF7/grFl3ti7nJSPzZL2 zLq9Fkr7sqfxeBf88m79nJ4CH3T5+3iTPb+PNos34yYLxXSYn68jqD2mtPU/pNQthrYnCPbmj 5EUrt0ISFNMdIylyBI3dOoBUdxboJ2GI5jGmXCQknwS77MqbIqYCxqtuJ8Iv2ViUchSiWr5hK lUAchrkyFuZLyduTUVY7e0wL7hd27g+4L+ZdJzk94vNZkOu+LG1HNtWqDIedZL5tbd7sKBo+u C4ZTZ+gjesnyrOZ+pQZoItvUd1ettoBITfhCWnwm7wyV04ZyBoPUUsTWIXkSdApa1bbyBCB9N Ree0L4dAPb8bb6fUg2VGTk6woktpnhvHSTaj1s7Rd83IOVZ0DAeJL2FBp4v450QStXNkOL+VO YHzTur+508NRFaZqobsoc2ufKK1/S6eNeuWime6wOsk7ZCTzUjQMe4u174t5Ns1IK5KDWpuuh OcHXDH3EznLnudRLvOXE1XGf8kx8ZMd7Sb4ckOuAlXkmR1dYpRVJUrjg+WP6pWZNIswXH5t5Z +OIKNA== X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MIME_BASE64_TEXT, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 28 Sep 2023 15:14:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778325868111836306 X-GMAIL-MSGID: 1778325868111836306 |
Series | Fixes and improvements for RS485 | |
Message
Lino Sanfilippo
Sept. 28, 2023, 10:12 p.m. UTC
From: Lino Sanfilippo <l.sanfilippo@kunbus.com>
Patch 1: Do not hold the port lock when setting rx-during-tx GPIO
Patch 2: Get rid of useless wrapper pl011_get_rs485_mode()
Patch 3: set missing supported flag for RX during TX GPIO
Patch 4: fix sanitizing check for RTS settings
Patch 5: make sure RS485 is cannot be enabled when it is not supported
Patch 6: IMX: do not set RS485 enabled if it is not supported
Lino Sanfilippo (6):
serial: Do not hold the port lock when setting rx-during-tx GPIO
serial: amba-pl011: get rid of useless wrapper pl011_get_rs485_mode()
serial: core: set missing supported flag for RX during TX GPIO
serial: core: fix sanitizing check for RTS settings
serial: core: make sure RS485 is cannot be enabled when it is not
supported
serial: imx: do not set RS485 enabled if it is not supported
drivers/tty/serial/amba-pl011.c | 14 +---------
drivers/tty/serial/imx.c | 18 +++++--------
drivers/tty/serial/serial_core.c | 45 +++++++++++++++++++++-----------
drivers/tty/serial/stm32-usart.c | 5 +---
4 files changed, 38 insertions(+), 44 deletions(-)
base-commit: 9ed22ae6be817d7a3f5c15ca22cbc9d3963b481d
Comments
On Fri, Sep 29, 2023 at 12:12:41AM +0200, Lino Sanfilippo wrote: > From: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > Both the imx and stm32 driver set the rx-during-tx GPIO in the > rs485_config() function by means of gpiod_set_value(). Since rs485_config() > 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 setting the GPIO outside of the port lock in the serial > core and by using gpiod_set_value_cansleep() instead of gpiod_set_value(). > > Since now both the term and the rx-during-tx GPIO are set within the serial > core use a common function uart_set_rs485_gpios() to set both. > > With moving it into the serial core setting the rx-during-tx GPIO is now > automatically done for all drivers that support such a GPIO. > > Cc: stable@vger.kernel.org > Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> You cc: stable on many of these, but do not provide a "Fixes:" tag showing just how far back they should go. Can you do that so that we have a hint as to what to do here? thanks, greg k-h
On Fri, Sep 29, 2023 at 12:12:46AM +0200, Lino Sanfilippo wrote: > From: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > If the imx driver cannot support RS485 it sets the UARTS rs485_supported > structure to NULL. But it still calls uart_get_rs485_mode() which may set > the RS485_ENABLED flag. > The flag however is evaluated by the serial core in uart_configure_port() > at port startup and thus may lead to an attempt to configure RS485 even if > it is not supported. > > Avoid this by calling uart_get_rs485_mode() only if RS485 is actually > supported by the driver. Remove also a check for an error condition > that is not possible any more now. > > Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> > --- > drivers/tty/serial/imx.c | 14 ++++++-------- > 1 file changed, 6 insertions(+), 8 deletions(-) Why is this patch not marked for stable? thanks, greg k-h
On Fri, Sep 29, 2023 at 12:12:46AM +0200, Lino Sanfilippo wrote: > From: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > If the imx driver cannot support RS485 it sets the UARTS rs485_supported > structure to NULL. But it still calls uart_get_rs485_mode() which may set > the RS485_ENABLED flag. > The flag however is evaluated by the serial core in uart_configure_port() I wonder if this is the code location where this problem should be addressed. Or alternatively don't let uart_get_rs485_mode() set RS485_ENABLED (and other flags) if rs485_supported doesn't suggest that this works? > [...] > > Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> I don't know how picky Greg is here, but formally you missed to add an S-o-b line for the sender of this patch (i.e. you with your gmx address). Best regards Uwe
Hi, On 29.09.23 07:50, Greg KH wrote: > On Fri, Sep 29, 2023 at 12:12:41AM +0200, Lino Sanfilippo wrote: >> From: Lino Sanfilippo <l.sanfilippo@kunbus.com> >> >> Both the imx and stm32 driver set the rx-during-tx GPIO in the >> rs485_config() function by means of gpiod_set_value(). Since rs485_config() >> 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 setting the GPIO outside of the port lock in the serial >> core and by using gpiod_set_value_cansleep() instead of gpiod_set_value(). >> >> Since now both the term and the rx-during-tx GPIO are set within the serial >> core use a common function uart_set_rs485_gpios() to set both. >> >> With moving it into the serial core setting the rx-during-tx GPIO is now >> automatically done for all drivers that support such a GPIO. >> >> Cc: stable@vger.kernel.org >> Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > You cc: stable on many of these, but do not provide a "Fixes:" tag > showing just how far back they should go. Can you do that so that we > have a hint as to what to do here? > Yes, will do so in the next version. BR, Lino > thanks, > > greg k-h
On 29.09.23 07:51, Greg KH wrote: > On Fri, Sep 29, 2023 at 12:12:46AM +0200, Lino Sanfilippo wrote: >> From: Lino Sanfilippo <l.sanfilippo@kunbus.com> >> >> If the imx driver cannot support RS485 it sets the UARTS rs485_supported >> structure to NULL. But it still calls uart_get_rs485_mode() which may set >> the RS485_ENABLED flag. >> The flag however is evaluated by the serial core in uart_configure_port() >> at port startup and thus may lead to an attempt to configure RS485 even if >> it is not supported. >> >> Avoid this by calling uart_get_rs485_mode() only if RS485 is actually >> supported by the driver. Remove also a check for an error condition >> that is not possible any more now. >> >> Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> >> --- >> drivers/tty/serial/imx.c | 14 ++++++-------- >> 1 file changed, 6 insertions(+), 8 deletions(-) > > Why is this patch not marked for stable? > Right, it should be, I will correct this, thanks!
Hi, On 29.09.23 08:39, Uwe Kleine-König wrote: > On Fri, Sep 29, 2023 at 12:12:46AM +0200, Lino Sanfilippo wrote: >> From: Lino Sanfilippo <l.sanfilippo@kunbus.com> >> >> If the imx driver cannot support RS485 it sets the UARTS rs485_supported >> structure to NULL. But it still calls uart_get_rs485_mode() which may set >> the RS485_ENABLED flag. >> The flag however is evaluated by the serial core in uart_configure_port() > > I wonder if this is the code location where this problem should be > addressed. Or alternatively don't let uart_get_rs485_mode() set > RS485_ENABLED (and other flags) if rs485_supported doesn't suggest that > this works? > This is indeed the better solution. Especially since the check is then in the serial core and all RS485 supporting drivers benefit from it. I will change this for v2, thanks! >> [...] >> >> Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > I don't know how picky Greg is here, but formally you missed to add an > S-o-b line for the sender of this patch (i.e. you with your gmx > address). > Hm, until now there have never been complaints about this. Is this really an issue? Of course I can also S-o-b with my gmx address but adding two S-o-b's for the same person seems a bit odd to me... BR, Lino > Best regards > Uwe >
Hello Lino, On Fri, Sep 29, 2023 at 03:46:52PM +0200, Lino Sanfilippo wrote: > On 29.09.23 08:39, Uwe Kleine-König wrote: > > On Fri, Sep 29, 2023 at 12:12:46AM +0200, Lino Sanfilippo wrote: > >> Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > > > I don't know how picky Greg is here, but formally you missed to add an > > S-o-b line for the sender of this patch (i.e. you with your gmx > > address). > > > > Hm, until now there have never been complaints about this. Is this really an issue? Of > course I can also S-o-b with my gmx address but adding two S-o-b's for the same person seems > a bit odd to me... The obvious and easy fix is of course to use the author address to send the patches. :-) Best regards Uwe