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: 9181487 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B929060776 for ; Thu, 16 Jun 2016 18:24:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B11E22835E for ; Thu, 16 Jun 2016 18:24:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5B1C2837F; Thu, 16 Jun 2016 18:24:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57AB02835E for ; Thu, 16 Jun 2016 18:24:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754196AbcFPSYp (ORCPT ); Thu, 16 Jun 2016 14:24:45 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:34642 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753256AbcFPSYo (ORCPT ); Thu, 16 Jun 2016 14:24:44 -0400 Received: by mail-pf0-f170.google.com with SMTP id h14so7125081pfe.1 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=Oty0LdfwocVkSfRLlhuewYrvRQsoaWt8Kg2PEr1huhTZkUY39wkqGIkp43DqExWeDZ 20AL8EbNo07B1T7AGPnszyZHfW59cYGb+50zO0f/cgEiA8aNRQp9a1WCBQExON9rFmoi sa4nOC2WXQTnh3ItBWjPzyXDgxXSJ8pUtdupNjXPxbXRvyNnx/5aT1GuGPufJxR878p7 CWFQfFTMcNxCrT5G1GtQ0amY6NzZQi1TXRG/UawEgSvD2IPnfG+LJ3giikFsUDvrqai2 uRsEFnPlM4qv/zt3TBQXd6vEicJ9zVwxbtNkwWx6d/urrgy1fo1HpqpfINsLolChNHXC peXw== X-Gm-Message-State: ALyK8tJ1mZhHLH6ktZ24Mc5PyVfBZzATaRj3OCIymIrCElDTxO8tPLmL+doOHCDfHly2r18d 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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Tested-by: Nicolas Dechesne Reviewed-by: Stephen Boyd --- drivers/tty/serial/msm_serial.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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);