Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp119371pxm; Fri, 25 Feb 2022 05:08:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwj/QNvbONUWQX5qJO4pU7axAdRuzHoO0EF0R3GTGcQw5T0F6wFprcAhWRb8H2IuokbGChR X-Received: by 2002:a50:f0d0:0:b0:413:362a:1563 with SMTP id a16-20020a50f0d0000000b00413362a1563mr7203544edm.393.1645794508073; Fri, 25 Feb 2022 05:08:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645794508; cv=none; d=google.com; s=arc-20160816; b=lzBLUjnfWr9CG+P3SORPKjw3By7ZAX8kuqvH6St45nc1c12YVyoRdGgMIrrk60kFvc jm1pPItNiZvRvyA3kWAS8pzjc210hr3s8tAlnRvefpatNneijzeZvYapy71ah53EWQCC r7uTBJOzAEVQgvGLX2xGhDG7Eh5ysGj6UbvO1yudUQZ914Dw9DBWYAIM+7dbQvNhg4xa G80PohMg/0QKXEcJlNNtvwYKiCOe3OtXb63vYD2nIeYi5YWN4Lc41a5fi+U96TORwVTP 594pe8qP8+PxIIDtEIl7MZsRmeUpBG0OSi0MP9tHvChjKWFOuaiCgI22xGIBk+AElq5P smbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:references:in-reply-to :sensitivity:importance:date:subject:cc:to:from:message-id :mime-version:dkim-signature; bh=ZBa8/L8iW7ShngPtjDMHz5hutdlp2KMJfLYcYHlTSac=; b=xiPc2n8wTDrJVsPrTwqg/I3MU6PfvKpSdqYSJgrzVI6VZb6g968OZgbdnFJFrZtGox z5gWfnMd1fx4ivsXvE9+3M3uiLtja1BTlu8P2M1Hxw3oqiK/K56+Zp0xzjGcFNDwNc74 pKScgpyhkm8kWBDx5X9lGBNxzIYUYDWjLgtzylKbJ4aSN6HbAZSf0M12BNR1Bd/tF5e/ kA1dSYCIvD4zprGwszXNdrLV/IuYAxyOXiQLn5ZGk2oPzelNAHMF85R17v6HE3Pc7wkx yOm+75KVZn00wa8ziM4X4v/nbfjVgJVcouW3aNofV3HAIoIIMSG464NC6gULriwLiHQY OJrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=UjcV5q8j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c16-20020a17090603d000b006d5840345f6si1373018eja.498.2022.02.25.05.07.57; Fri, 25 Feb 2022 05:08:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=UjcV5q8j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237415AbiBYKRk (ORCPT + 99 others); Fri, 25 Feb 2022 05:17:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233238AbiBYKRi (ORCPT ); Fri, 25 Feb 2022 05:17:38 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 261DDB0D3E; Fri, 25 Feb 2022 02:17:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1645784200; bh=ZBa8/L8iW7ShngPtjDMHz5hutdlp2KMJfLYcYHlTSac=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=UjcV5q8jw4HJ1NnJHIbhv9jjKqi803bfJEJkddrABEHqPOz4g0EFxZIJrHAzPmjJN UxH06gb96hwDsFANb6XM/Oi5Mf5S8wmiyoOtDOBH/HsnT1/4jstuZ5qc1EOACf+DHL 9PkfTNLmJixtRvO/oGC9d/zi2N4aRD+MwcbKY7Nk= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [149.172.237.68] ([149.172.237.68]) by web-mail.gmx.net (3c-app-gmx-bs22.server.lan [172.19.170.74]) (via HTTP); Fri, 25 Feb 2022 11:16:40 +0100 MIME-Version: 1.0 Message-ID: From: Lino Sanfilippo To: Jiri Slaby Cc: gregkh@linuxfoundation.org, u.kleine-koenig@pengutronix.de, linux@armlinux.org.uk, richard.genoud@gmail.com, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, ludovic.desroches@microchip.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, lukas@wunner.de, p.rosenberger@kunbus.com Subject: Aw: Re: [PATCH v3 1/9] serial: core: move RS485 configuration tasks from drivers into core Content-Type: text/plain; charset=UTF-8 Date: Fri, 25 Feb 2022 11:16:40 +0100 Importance: normal Sensitivity: Normal In-Reply-To: <8c65bc42-438e-bf3e-fb76-2a4cbc7296c0@kernel.org> References: <20220222011433.8761-1-LinoSanfilippo@gmx.de> <20220222011433.8761-2-LinoSanfilippo@gmx.de> <8c65bc42-438e-bf3e-fb76-2a4cbc7296c0@kernel.org> Content-Transfer-Encoding: quoted-printable X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:ibY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Ivu f+zcgjtNJ1IH3cg8fpihwnW5W+NgXru7XsBA7SLojo9DdHOWkMcNcXJbEaeuZeBuxTZMD/JmG kN19HXC X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, > On 22=2E 02=2E 22, 7:51, Jiri Slaby wrote: > > On 22=2E 02=2E 22, 2:14, Lino Sanfilippo wrote: > >> Several drivers that support setting the RS485 configuration via=20 > >> userspace > >> implement one or more of the following tasks: > >> > >> - in case of an invalid RTS configuration (both RTS after send and RT= S on > >> =C2=A0=C2=A0 send set or both unset) fall back to enable RTS on send = and disable=20 > >> RTS > >> =C2=A0=C2=A0 after send > >> > >> - nullify the padding field of the returned serial_rs485 struct > >> > >> - copy the configuration into the uart port struct > >> > >> - limit RTS delays to 100 ms > >> > >> Move these tasks into the serial core to make them generic and to pro= vide > >> a consistent behaviour among all drivers=2E > >> > >> Signed-off-by: Lino Sanfilippo > >> --- > >> =C2=A0 drivers/tty/serial/serial_core=2Ec | 29 ++++++++++++++++++++++= +++++++ > >> =C2=A0 1 file changed, 29 insertions(+) > >> > >> diff --git a/drivers/tty/serial/serial_core=2Ec=20 > >> b/drivers/tty/serial/serial_core=2Ec > >> index 846192a7b4bf=2E=2E2b3afe038c1c 100644 > >> --- a/drivers/tty/serial/serial_core=2Ec > >> +++ b/drivers/tty/serial/serial_core=2Ec > >> @@ -42,6 +42,11 @@ static struct lock_class_key port_lock_key; > >> =C2=A0 #define HIGH_BITS_OFFSET=C2=A0=C2=A0=C2=A0 ((sizeof(long)-size= of(int))*8) > >> +/* > >> + * Max time with active RTS before/after data is sent=2E > >> + */ > >> +#define RS485_MAX_RTS_DELAY=C2=A0=C2=A0=C2=A0 100 /* msecs */ > >> + > >> =C2=A0 static void uart_change_speed(struct tty_struct *tty, struct= =20 > >> uart_state *state, > >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct ktermios *= old_termios); > >> =C2=A0 static void uart_wait_until_sent(struct tty_struct *tty, int t= imeout); > >> @@ -1282,8 +1287,32 @@ static int uart_set_rs485_config(struct=20 > >> uart_port *port, > >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (copy_from_user(&rs485, rs485_user,= sizeof(*rs485_user))) > >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EFAULT= ; > >> +=C2=A0=C2=A0=C2=A0 /* pick sane settings if the user hasn't */ > >> +=C2=A0=C2=A0=C2=A0 if (!(rs485=2Eflags & SER_RS485_RTS_ON_SEND) =3D= =3D > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 !(rs485=2Eflags & SER_RS4= 85_RTS_AFTER_SEND)) { > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pr_warn("invalid RTS sett= ing, using RTS_ON_SEND instead\n"); > >=20 > > Can't we have a device prefix here, so that everyone knows what device= =20 > > is affected? Without that, it's not that useful=2E At least port->name= &=20 > > port->line could be printed=2E The uart core uses dev_* prints, but pr= ints=20 > > also line as uport->dev can be NULL sometimes=2E >=20 > And this comes from userspace, so should be ratelimited=2E >=20 Right, ratelimiting makes sense here=2E I will change it as suggested in t= he next patch version=2E Thanks a lot for the review=2E Regards, Lino