From patchwork Sat Mar 5 10:36:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Youngmin Nam X-Patchwork-Id: 8509811 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C61EFC0553 for ; Sat, 5 Mar 2016 10:37:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A6FBA20260 for ; Sat, 5 Mar 2016 10:37:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C898720218 for ; Sat, 5 Mar 2016 10:37:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759955AbcCEKhP (ORCPT ); Sat, 5 Mar 2016 05:37:15 -0500 Received: from mail-pf0-f178.google.com ([209.85.192.178]:33262 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755993AbcCEKhO (ORCPT ); Sat, 5 Mar 2016 05:37:14 -0500 Received: by mail-pf0-f178.google.com with SMTP id 124so50727296pfg.0; Sat, 05 Mar 2016 02:37:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=ea7mCC8oSBluuYqaCTEBVnNOw4oOoWD6Vv7KVZnba7k=; b=QSjxnPDJoludc3Td9JbvAaDVj1aFLCYfvLxvuhozMAPfQ0LpOELvTRzOpDUj+3zvJ2 H/HPdLdi4OXtDbH2dIPzEMWVjavlgMosOiELZwnBxuoizfBXuQFvGGAINYhL89ao9v6d wep2xBdBxUVtnREApZT13JNudvGANbfZC4RRIXlVJECdLvenr9/Ghu2ScFz99WfLNUoe 2L1nQDWmVgPH2k0haz8XboHfLyNdgiyot0QuGXGWLKGqZ2WUi9jyx15nKRbj5sY0k9mU uuzBBmjOmzSQtUms4PJGNrpDp7Tc7L6780bYTPgKIyEOiKW/IMZOn9pyIzS9jj9x9xDt +kNw== 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; bh=ea7mCC8oSBluuYqaCTEBVnNOw4oOoWD6Vv7KVZnba7k=; b=h+p/y4Z9nRqnftKcgKNsA724gdzvxnTv4i7hwjOx8IeD5NGbI747/MLx18z8Tb13ef tiSjXG48SE+dfHIbpXyS4fOQ9FFeT5vimZxr+zDOiGsX2W02kZMd+wNYzGkOfS3Lwexo YY99/iPUDF3BDYeC2UfMPpDWiMygTLDBEsO1gYXpS3cmizqbG4ugMiy5BgCv3O9vfxDr RpMxQqHwrr8BlKy73nff3Vj5TUSD85alVLr1kUGRPDUtmdyV4LX9OBoE4kfLQfsr9ehI hT1fCxVBjrSgPKg7uADSSazHIYmmCVpUnIE5hrKWZn5c+0DDnuG6MRKzayndKSCsDssU X+LQ== X-Gm-Message-State: AD7BkJK4iaDJqmKv8qlf1WNf452117yyoyKkU0aOTvb2DHf7F4CdZ4WZG2rQ9od25e6DOg== X-Received: by 10.98.64.4 with SMTP id n4mr19113699pfa.58.1457174233439; Sat, 05 Mar 2016 02:37:13 -0800 (PST) Received: from youngmin-870Z5G-880Z5F ([121.168.98.93]) by smtp.gmail.com with ESMTPSA id n66sm11504044pfj.39.2016.03.05.02.37.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Mar 2016 02:37:12 -0800 (PST) Received: by youngmin-870Z5G-880Z5F (Postfix, from userid 1000) id 9AF892E2752; Sat, 5 Mar 2016 19:37:09 +0900 (KST) From: Youngmin Nam To: gregkh@linuxfoundation.org, k.kozlowski@samsung.com Cc: linux-serial@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Youngmin Nam Subject: [PATCH] serial: samsung: optimize UART rx fifo access routine Date: Sat, 5 Mar 2016 19:36:32 +0900 Message-Id: <1457174192-20956-1-git-send-email-ym0914@gmail.com> X-Mailer: git-send-email 2.7.1 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch optimizes UART rx fifo access routine by reading UART SFR when necessary. At first, the "fifocnt" variable will be initialized as Rx FIFO count. So we don't need to access UFSTAT(FIFO status) register every time to check FIFO count because we know that count with "fifocnt". After all data were read out from Rx FIFO, the "fifocnt" will be set as 0. Lastly, UFSTAT will be accessed again to check whether the data remains by any chance. Signed-off-by: Youngmin Nam Reviewed-by: Jung-Ick Guack --- drivers/tty/serial/samsung.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index d72cd73..1fd09c0 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -601,14 +601,21 @@ static void s3c24xx_serial_rx_drain_fifo(struct s3c24xx_uart_port *ourport) { struct uart_port *port = &ourport->port; unsigned int ufcon, ch, flag, ufstat, uerstat; + unsigned int fifocnt = 0; int max_count = port->fifosize; while (max_count-- > 0) { - ufcon = rd_regl(port, S3C2410_UFCON); - ufstat = rd_regl(port, S3C2410_UFSTAT); - - if (s3c24xx_serial_rx_fifocnt(ourport, ufstat) == 0) - break; + /* + * Receive all characters known to be in FIFO + * before reading FIFO level again + */ + if (fifocnt == 0) { + ufstat = rd_regl(port, S3C2410_UFSTAT); + fifocnt = s3c24xx_serial_rx_fifocnt(ourport, ufstat); + if (fifocnt == 0) + break; + } + fifocnt--; uerstat = rd_regl(port, S3C2410_UERSTAT); ch = rd_regb(port, S3C2410_URXH); @@ -623,6 +630,7 @@ static void s3c24xx_serial_rx_drain_fifo(struct s3c24xx_uart_port *ourport) } } else { if (txe) { + ufcon = rd_regl(port, S3C2410_UFCON); ufcon |= S3C2410_UFCON_RESETRX; wr_regl(port, S3C2410_UFCON, ufcon); rx_enabled(port) = 1;