Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1573296iog; Sat, 25 Jun 2022 13:06:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uYBTlyTYKSk2gSOoza3aQNHyY1T5bYuHLw7bdq142X5UgljJsEj1Iqz2dW078nOp6LwzOg X-Received: by 2002:a05:6a00:21c8:b0:4fd:f89f:ec0e with SMTP id t8-20020a056a0021c800b004fdf89fec0emr5906240pfj.83.1656187595617; Sat, 25 Jun 2022 13:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656187595; cv=none; d=google.com; s=arc-20160816; b=v5pzLq0FQYVA+Oxaw6/PDqdNH+xZd5KyQzoejcsNOVOZ6fCFzs5jgUrmwEk+7pT7+s 55D+cxxpULpkd+xmMoueO6sew1GWkA5VWXnL5hF08tE7N98mrl3K928pYHZL9YlCoJ0f 7kQGg/KwI/k2W+lOCFDp5BDlNiGwoHIQ0hq3AYihysn88kHIN+vEqUfa7+FOYAYYb22S Sq1+DSQCoEqAjGzzxj/Gq/jshzi+BQXyWTs0NDR9FvlmzeLC1wILSELVNZo7Q/WfWBRX SH6rufzCWF6xPdZ2YNXRBpu31VM4Pp6qYoyaA2kGm1OgcIuTBNuGOOSKKIIJ6VDW0TqZ 3lUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=eSqmpmuNNnYQZdW4voRCmm9lubz+RuPSTz02hAmMuXU=; b=BWA7iZDIBw+EceQvsaSQmXtsduLGqIKE+CELhfSG/8yQZV7UkaqA/HS9/SEZpEBGsO xvM9v5Tn0ndXsKoivdmazTSLY0fuHIvq5hRQTlhUHw1S8nV2jp9g+G0GGsTc+mPDI375 lhkxC491kon0yrYM3J5G7MxglgLtRB93abpt5SqDIRTlxfpogz9q7AKyqYZyNvSZbdyd nXzoytfir0qhKLTxpcAwTvlxCrCwkPmOsBXnUkXj3fOzcH9R49uBSACkjabsbFu+rCnc rVsU1R71LngR/JnVnRwvB8JR8loOa9S6nvJR3zuFP1299IRqH/zFVQAXm3wSwIsERB2t euNg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ha18-20020a17090af3d200b001eaf9cbf739si7212306pjb.38.2022.06.25.13.06.23; Sat, 25 Jun 2022 13:06:35 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233272AbiFYT6s (ORCPT + 99 others); Sat, 25 Jun 2022 15:58:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231474AbiFYT6r (ORCPT ); Sat, 25 Jun 2022 15:58:47 -0400 Received: from bmailout3.hostsharing.net (bmailout3.hostsharing.net [IPv6:2a01:4f8:150:2161:1:b009:f23e:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B8BBA187; Sat, 25 Jun 2022 12:58:46 -0700 (PDT) Received: from h08.hostsharing.net (h08.hostsharing.net [IPv6:2a01:37:1000::53df:5f1c:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "*.hostsharing.net", Issuer "RapidSSL TLS DV RSA Mixed SHA256 2020 CA-1" (verified OK)) by bmailout3.hostsharing.net (Postfix) with ESMTPS id B874A10045BFD; Sat, 25 Jun 2022 21:58:44 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 936301191F2; Sat, 25 Jun 2022 21:58:44 +0200 (CEST) Date: Sat, 25 Jun 2022 21:58:44 +0200 From: Lukas Wunner To: Lino Sanfilippo 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 Subject: Re: [PATCH 2/8] serial: core, 8250: set RS485 termination gpio in serial core Message-ID: <20220625195844.GB2879@wunner.de> References: <20220622154659.8710-1-LinoSanfilippo@gmx.de> <20220622154659.8710-3-LinoSanfilippo@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220622154659.8710-3-LinoSanfilippo@gmx.de> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE, 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 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 spinlock > 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 = 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. That's painful, but unavoidable in the long run. This patch just kicks the can down the road... Thanks, Lukas