Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2105419iog; Sun, 26 Jun 2022 06:53:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vWoDdmR9yVOy7pIvRu0JI/PV8Bqpqbpt9mTmnx9gp/8jz/y7coWSvWjjN08NFLr7X/WT1d X-Received: by 2002:a05:6a00:22c3:b0:525:628f:a835 with SMTP id f3-20020a056a0022c300b00525628fa835mr9873176pfj.58.1656251618373; Sun, 26 Jun 2022 06:53:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656251618; cv=none; d=google.com; s=arc-20160816; b=GKzLgkWzyUP08R3q2V2X/fHOrcLVE2x5qdCwsIirIGzcEwvBdJJTLGEHS+t/NKJNT4 uvDyt6g7t9mm2KpLFb4K3KbtkSijpIr0OPGb6j/SSoP5JAbEg5ZQ72/7pgfC7EkVTBvo s2aGtISEy+BkmTSznwZOzj8GyjUJs3xl2kHtk1dkVOCpJztsy+z00A3zlXkFafmywieG xn6rgqIuvxthBfPAI3jzlzvevDw2q+I5cUI1F/Wwi7ZSN4Nxdepr4OMBwBuCrUhyCMhk Jmo7vu4CqyBWQFAo93QKyQIlWk23iTjr5+tUMe5h14HBHQauxaTq2ueTnB2qU2w/H8et EyNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=NyIJ9qus9ZgEeJY8L0nVY557Z//zUy/Ut0aCtLvAXL4=; b=pYQJ6t4a7w725QMHyDDPeI6b8ipUyOoeVqzk+mdrntZIGW5UKq6KdTFmQRA7d8BHIu qU/G4t2J7qI33aqBKll8C0TeRCTAD6x5OXRPHwM4GroDS2znL7hhaqey7pxbFQcG2Zto m2NKNv7TqE+pCcRfmR4edyApr/1B/v9Izionl15qpiAEjntG9DsF+DS4fO0x4G1BxCtb gsCVrEhT/KCauitnP6vWBXH3cJN/kQq2bI8PNjwUcBDMaTIMrY+gAxsd43HfgX3971g6 ZxnLPvB7fCY+Di3QWb4fMMIazRgvMliCm4k36OkX0tSULvM9iTkGBlTRjLHwpPVbXrFF q0Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b="b9ZE/z5G"; 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 j8-20020a17090276c800b0016a07ea480bsi9756580plt.54.2022.06.26.06.53.13; Sun, 26 Jun 2022 06:53:38 -0700 (PDT) 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="b9ZE/z5G"; 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 S234604AbiFZNgq (ORCPT + 99 others); Sun, 26 Jun 2022 09:36:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233597AbiFZNgo (ORCPT ); Sun, 26 Jun 2022 09:36:44 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92663F5B0; Sun, 26 Jun 2022 06:36:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656250581; bh=hZku3pKad6YdlzoC5bnphtrI9Ac066vFM1ZhUPMS+rw=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=b9ZE/z5GSMtb3BZtVIzM6M5tJ8rCPS4Q1ppvhyuXq4Hw9hlcyZwxKwPJhrWT9fB0s Tuy0KbphosNndDXxRMpFLwjeAyXNEKai+9tbiZDE83nEEbKyYWz8uplZro+WQAiFKy tVjed0FRXJRJ91nKtCAfYoChINNKhwngzRw9U+iE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.0.33] ([46.223.2.248]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N79yG-1nZciH1HW0-017XzA; Sun, 26 Jun 2022 15:36:21 +0200 Subject: Re: [PATCH 2/8] serial: core, 8250: set RS485 termination gpio in serial core To: Lukas Wunner Cc: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, andriy.shevchenko@linux.intel.com, vz@mleia.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, p.rosenberger@kunbus.com, Lino Sanfilippo References: <20220622154659.8710-1-LinoSanfilippo@gmx.de> <20220622154659.8710-3-LinoSanfilippo@gmx.de> <20220625195844.GB2879@wunner.de> From: Lino Sanfilippo Message-ID: <067e6fa2-6015-2eea-5719-8b75fb08882c@gmx.de> Date: Sun, 26 Jun 2022 15:36:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20220625195844.GB2879@wunner.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:hGacXh8oLZwt9FXVfKQ60JrkzhKSJzVtnlbg7gxtB/Y8cLL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6eeGOpBeh7tM4wEjKT1AOFTcVoqezR3Xm986Cpni tTkSzyG3vAmV4SfYpILmmtQ65QsKYFMwEGaJoKDj5aeLFWKHM22CEEbHfObEvIzMAMnz2W7Om BZ9qk9IXnyF7iCpCbqCp+/IVNCuFWPy4tW4Ug0JAfEKBdqpeDPT6dCb7TUU5clGpITG2vS2lr kn35cd+DVX2YnHAYAtGnEfeptJPWDumIF04r+TDyvxJ16tjGoeBxwKY0lAUA1/Hk7FElzNBtR i3ce1JeFkkRsUjpftXWlVQz/MdFnwkhKtyLaQf26XHaoLR2nWYGlnwa/A== X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,NICE_REPLY_A,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 On 25.06.22 at 21:58, Lukas Wunner wrote: > On Wed, Jun 22, 2022 at 05:46:53PM +0200, Lino Sanfilippo wrote: >> From: Lino Sanfilippo >> >> In serial8250_em485_config() the termination GPIO is set with the uart_= port >> spinlock held. This is an issue if setting the GPIO line can sleep (e.g= . >> since the concerning GPIO expander is connected via SPI or I2C). >> >> Fix this by setting the termination line outside of the uart_port spinl= ock >> in the serial core. > [...] >> --- a/drivers/tty/serial/serial_core.c >> +++ b/drivers/tty/serial/serial_core.c >> @@ -1400,6 +1411,7 @@ static int uart_set_rs485_config(struct uart_port= *port, >> if (ret) >> return ret; >> uart_sanitize_serial_rs485(port, &rs485); >> + uart_set_rs485_termination(port, &rs485); >> >> spin_lock_irqsave(&port->lock, flags); >> ret =3D port->rs485_config(port, &rs485); > > That's one way to solve the issue. Another would be to push > acquisition of the port spinlock down into drivers. > > I think in most drivers we don't need to take the port spinlock at all > or only for a few specific register accesses. So taking the lock here > in the midlayer is likely unwarranted. However, changing that requires > going through every single driver's ->rs485_config() callback and > checking whether it needs the lock or not. As a first step its sufficient to take the lock in each drivers rs485_conf= ig() function and remove it from uart_set_rs485_config(). Then after time sort = out the drivers that dont require the lock and remove it from their function. However the point of this patch was also to generalize the handling of the termination GPIO, so I would still see this placed in uart_set_rs485_confi= g(). Regards, Lino