Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp720641imm; Wed, 6 Jun 2018 05:06:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIOjSshAwKYnda3whZtcc1lbVGuJBbWXgrHjWtft2M633GkNCSdrhrAugbWi9deSo7Ruwqu X-Received: by 2002:a17:902:8bc4:: with SMTP id r4-v6mr2921510plo.381.1528286763766; Wed, 06 Jun 2018 05:06:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528286763; cv=none; d=google.com; s=arc-20160816; b=bhbM7RB+lxSbYvexkRO3i54zMmRQTr0REK2KD9y29WaCbvg4vEIALTowMIwuT0SdES llH9JvzZS1FpnoLmPP0cUaXkmo+y42x2kaGutQIBsS/s+gD4yfQpG/WXr7E+bHEK+CXJ oeNKtIzXCEjKY6THZDgqrtw8Mh3hU2vLvl2QWkkKPlVk1ev+Kl9DGWL12ccsEgJdjU4Z mLB8y8jZ9ZCkUrB5zVkbfOWHNHhcup+B0l3Zo6QoP03YRA17THeMvMUTrKoKpicflBHV DjHjJ5KnshlK2QlZAzbgztspHMa3y3FDrg6pasLhI8xEaBsLMECKl1oYcBpCapXGYhUb Aj+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:date:cc:to:from:subject :message-id:arc-authentication-results; bh=hw5eXiAv34yUPUVe43d+lImhjGNsUQ3Uhpadc9fedZw=; b=dyU48Tfgg6yEDqwVObx8bNvipsgnLOtbEpbsQoOO4nOlxjOaq0Tq/xv5XX4hImN+Wn F35iBlzmJkkvd52k+Wj81ltslBZE1bGAr2qawqcnF4gRY7xCnyhA2zAHATxG/5XsMgzi 7nstd5+ZlnRgOQoSoQmCv4WQ1rc/5SbLS/xa2NgvvSgK06nIal6rHt6yjjwi9L7vQ5cM 7Td5eAID3rH73rP0Y7CJc7h0Esa2WlHsrjV6sgCaqWS91evFBa4UKt2Ld8HZuUYt1v/P EiFKG7TKuXjtfPu47vWT1inSwZlyuLXGun5pRPiMwIHYvjjHpEo8t/nhkbpnuYCdpF9R e2mw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si52591914plu.564.2018.06.06.05.05.49; Wed, 06 Jun 2018 05:06:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752033AbeFFMDp (ORCPT + 99 others); Wed, 6 Jun 2018 08:03:45 -0400 Received: from mga07.intel.com ([134.134.136.100]:25923 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750864AbeFFMDo (ORCPT ); Wed, 6 Jun 2018 08:03:44 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2018 05:03:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,483,1520924400"; d="scan'208";a="234863348" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.86]) by fmsmga005.fm.intel.com with ESMTP; 06 Jun 2018 05:03:41 -0700 Message-ID: Subject: Re: [PATCH 4/4] serial: core: Mask mctrl with TIOCM_RTS too if rs485 on and RTS_AFTER_SEND set. From: Andy Shevchenko To: Giulio Benetti Cc: matwey.kornilov@gmail.com, Greg Kroah-Hartman , Jiri Slaby , Matthias Brugger , Kees Cook , Sean Young , "open list:SERIAL DRIVERS" , open list Date: Wed, 06 Jun 2018 15:03:40 +0300 In-Reply-To: <20180606094942.71190-3-giulio.benetti@micronovasrl.com> References: <20180606094942.71190-1-giulio.benetti@micronovasrl.com> <20180606094942.71190-3-giulio.benetti@micronovasrl.com> Organization: Intel Finland Oy Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2018-06-06 at 11:49 +0200, Giulio Benetti wrote: > If rs485 is enabled and RTS_AFTER_SEND is set on startup need to keep > TIOCM_RTS asserted to keep rs485 transceiver in RX when idle. > > Check if rs485 is on and RTS_AFTER_SEND is set and mask port->mctrl > with > TIOCM_RTS too and not only TIOCM_DTR. > This one feels wrong to be in serial_core.c. Perhaps in 8250/8250*.c. > Signed-off-by: Giulio Benetti > --- > drivers/tty/serial/serial_core.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/serial_core.c > b/drivers/tty/serial/serial_core.c > index 0466f9f08a91..06d9441f6d20 100644 > --- a/drivers/tty/serial/serial_core.c > +++ b/drivers/tty/serial/serial_core.c > @@ -2288,6 +2288,16 @@ uart_configure_port(struct uart_driver *drv, > struct uart_state *state, > > if (port->type != PORT_UNKNOWN) { > unsigned long flags; > + int rs485_on = port->rs485_config && > + (port->rs485.flags & SER_RS485_ENABLED); > + int RTS_after_send = !!(port->rs485.flags & > + SER_RS485_RTS_AFTER_SEND); > + int mctrl; > + > + if (rs485_on && RTS_after_send) > + mctrl = port->mctrl & (TIOCM_DTR | > TIOCM_RTS); > + else > + mctrl = port->mctrl & TIOCM_DTR; > > uart_report_port(drv, port); > > @@ -2300,7 +2310,7 @@ uart_configure_port(struct uart_driver *drv, > struct uart_state *state, > * We probably don't need a spinlock around this, but > */ > spin_lock_irqsave(&port->lock, flags); > - port->ops->set_mctrl(port, port->mctrl & TIOCM_DTR); > + port->ops->set_mctrl(port, mctrl); > spin_unlock_irqrestore(&port->lock, flags); > > /* -- Andy Shevchenko Intel Finland Oy