From patchwork Thu Jun 16 18:24:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 70208 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp396261qgy; Thu, 16 Jun 2016 11:24:41 -0700 (PDT) X-Received: by 10.66.167.168 with SMTP id zp8mr6744826pab.20.1466101481388; Thu, 16 Jun 2016 11:24:41 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ie10si22466043pad.48.2016.06.16.11.24.41; Thu, 16 Jun 2016 11:24:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753796AbcFPSYj (ORCPT + 2 others); Thu, 16 Jun 2016 14:24:39 -0400 Received: from mail-pf0-f173.google.com ([209.85.192.173]:34871 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752512AbcFPSYi (ORCPT ); Thu, 16 Jun 2016 14:24:38 -0400 Received: by mail-pf0-f173.google.com with SMTP id c2so22346567pfa.2 for ; Thu, 16 Jun 2016 11:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to; bh=mhJADuCzFhM9WnwI2RJ3cnkASKKFPg/N5mShUOhtWXY=; b=fl+Vv7RGrxlBPu/ZQatGkd6DryYoHz7/PgNzl2k9g6VVHjJMeUWYiRvcGFoy2uD5IY 9WssfffNhjtrp524qMMYtqI4AWYz+nYgzLXyjQ2apy7exeXjt1aGeh5oC/IodbEuFRS6 g/LR66ai44hSQlpUmlg/8k4r+LQVqZoOOjh4o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to; bh=mhJADuCzFhM9WnwI2RJ3cnkASKKFPg/N5mShUOhtWXY=; b=YVFjmOktXh6oW3LE2P4T1vUV/qi1YVS6/nlrVM0aLIXh+Gc+KR2vjNybn+237VytHS pZxhLIl6JtTQN3fGVaNcXsfQnsXEcIGHmhyAPFuiBv0+C3JHteudwQlc4yXEWQmWMxLl qtM/73iG6D/H+HrmhX9emjDhWMuPc9nW9eY+06yZ3EUSBejJAk70hXn9LSHb6Oa6IWVY ycdymafG0ggHk+X5yOWMH9Xigu3huQ6iCsTQamKvrJnl4MGjQ8oyQFxTTQvTv2Px/ruk bpyjLJl5EIddrAP35B1YwbFYUsLkUJlJjr2Y2mpheUN0ZsWOfuNc+ePhlXNDtvVXqBcX D3Ag== X-Gm-Message-State: ALyK8tJSxCnWpiXyfJYmFuTbndL4VE/0FGQCa8033Sm3FxxuADZBAbVkvHPqQr5UJChBJa9K X-Received: by 10.98.96.67 with SMTP id u64mr6746931pfb.152.1466101478208; Thu, 16 Jun 2016 11:24:38 -0700 (PDT) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id 75sm32042594pfy.32.2016.06.16.11.24.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jun 2016 11:24:37 -0700 (PDT) From: Bjorn Andersson To: Andy Gross , Stephen Boyd , David Brown Cc: Greg Kroah-Hartman , Jiri Slaby , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] tty: serial: msm: Don't reconfigure same baud rate Date: Thu, 16 Jun 2016 11:24:35 -0700 Message-Id: <1466101475-8851-1-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1465844571-1229-1-git-send-email-bjorn.andersson@linaro.org> Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org msm_set_termios() is called whenever the tty is opened. Setting the baud rate requires a full reset of the msm serial block, even when the rate is unchanged. In the case when the same uart is used as console this reset will discard any console output data still being clocked out of the TX fifo. By skipping the rate-change in the case where the baud rate is unchanged since last request we can avoid the reset and the discarding of the data. Signed-off-by: Bjorn Andersson --- drivers/tty/serial/msm_serial.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c index b7d80bd57db9..206149f104fa 100644 --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c @@ -76,6 +76,7 @@ struct msm_port { bool break_detected; struct msm_dma tx_dma; struct msm_dma rx_dma; + unsigned int last_baud; }; static void msm_handle_tx(struct uart_port *port); @@ -1072,11 +1073,16 @@ static void msm_set_termios(struct uart_port *port, struct ktermios *termios, if (dma->chan) /* Terminate if any */ msm_stop_dma(port, dma); - /* calculate and set baud rate */ + /* calculate and set baud rate, if changed from last request */ baud = uart_get_baud_rate(port, termios, old, 300, 4000000); - baud = msm_set_baud_rate(port, baud, &flags); - if (tty_termios_baud_rate(termios)) - tty_termios_encode_baud_rate(termios, baud, baud); + if (baud != msm_port->last_baud) { + msm_port->last_baud = baud; + + baud = msm_set_baud_rate(port, baud, &flags); + if (tty_termios_baud_rate(termios)) + tty_termios_encode_baud_rate(termios, baud, baud); + uart_update_timeout(port, termios->c_cflag, baud); + } /* calculate parity */ mr = msm_read(port, UART_MR2); @@ -1134,8 +1140,6 @@ static void msm_set_termios(struct uart_port *port, struct ktermios *termios, if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK)) port->read_status_mask |= UART_SR_RX_BREAK; - uart_update_timeout(port, termios->c_cflag, baud); - /* Try to use DMA */ msm_start_rx_dma(msm_port);