Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp680161iob; Tue, 3 May 2022 07:30:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiTR3c2UP3INKqDDzZYUbeAULWYWSP9L8PSR3SwgWOGSmwdZfoPm6OUl5y4tnjm48er46A X-Received: by 2002:a05:6a00:1a92:b0:50d:a348:6bc7 with SMTP id e18-20020a056a001a9200b0050da3486bc7mr15767190pfv.83.1651588235163; Tue, 03 May 2022 07:30:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651588235; cv=none; d=google.com; s=arc-20160816; b=Y1TqTdhhYkNj4dC/5ZI6O2Cq+DjFUAXONcGwYsBajd+d2prxv5W5WZ/4fF0BSAYcXG UWB+wlq29UhFpP36z4sEmg+Ar1A2bMXlYqpRG9V76DJkbw2RqWF/wxrqOJmIK1+bAQGP zYg2EQQNDgACfDYUtNWDtLyxgzmS8Nio8QhtLoPMXSmJrPGc/94dOdIYiw97i8uKrFqP PeOaDj4FRcIZUUVla/P0MziuzmH/k0Wynnuk5tjoiZjUEpBmsSyaYsXVIlM2RppILewG raCFa+dL+gVvQatNYujEdolhOnNiN6lOdjt0DahxMFZFpfO+k/yICnK18FjgHEFjaBgs ppCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=0ZY4eZA8TU/JFu/sgVc8ZGWUJ92szGRyRslgx5G5fOQ=; b=agYhuD6I6Cf4sa8sAlzPFClSsky64jlivhpx6lden3tvZYHi/zWNXOMUmuHGO/jIPc ZOp1Kv9CH0uiQpeFNDeks42SNKRnr4UK8CgSFMqGlY5Y5Lgxcm2pdkzvf1tiNh7Kr/rf xO5w8yfR+cECkMxCpbmzglAfSKnchHqBOm6bi+nzMC66MBDMfWdaHcLtGQAQUAwtLPfc tn+Yd9ZVppY4xda51QJPyYTjE5vwRx3ttvjJ+MoB8IXbmWGMVYK7VjSLYXSMpKXa4HFG xsqjbKT9aidw5m+rWPeSA7D9THRl/i1VLrTAnygvWVlt8WHMgwc1aaWcmuKFhINnB5zp rUgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=CZ8WyMUW; dkim=neutral (no key) header.i=@suse.cz; 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 v14-20020a17090ad58e00b001cd6a811925si2102442pju.48.2022.05.03.07.30.17; Tue, 03 May 2022 07:30: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; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=CZ8WyMUW; dkim=neutral (no key) header.i=@suse.cz; 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 S232665AbiECIL6 (ORCPT + 99 others); Tue, 3 May 2022 04:11:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231830AbiECILm (ORCPT ); Tue, 3 May 2022 04:11:42 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51ACE20F63; Tue, 3 May 2022 01:08:11 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 09783210E3; Tue, 3 May 2022 08:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1651565290; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0ZY4eZA8TU/JFu/sgVc8ZGWUJ92szGRyRslgx5G5fOQ=; b=CZ8WyMUWfh9MImP/7fvYx6qum0uaHtM8hG7wB9E0dGt9+pgnaUBTj3yP6v0ET2+NtutCJY ekLYL5QqLkhyjva9YAJygn5LVQNugTwk9DL90L+BBf/Rhr8+UO4Xq7l0n2QVX2736flrIb gMNs0ImIkUtkXN6BiVRXJQM3GTHm8w8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1651565290; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0ZY4eZA8TU/JFu/sgVc8ZGWUJ92szGRyRslgx5G5fOQ=; b=hvx8J/VTBmruN6YHQVpsRyIvx5npIZnj48UU0FYFR5I9ucJ7mP1Zm/CecVoeSqOGKydknN ldRBR+3LeGKkYiCw== Received: from localhost.localdomain (unknown [10.100.208.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id BF73B2C143; Tue, 3 May 2022 08:08:09 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 3/7] serial: pch: decomission pch_uart_hal_write() Date: Tue, 3 May 2022 10:08:04 +0200 Message-Id: <20220503080808.28332-2-jslaby@suse.cz> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220503080808.28332-1-jslaby@suse.cz> References: <20220503080613.27601-1-jslaby@suse.cz> <20220503080808.28332-1-jslaby@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,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 It's horrid and if we inline it into callers, we can get rid of a lot of sugar around. So: * x_char handling becomes a single iowrite8. * xmit->buf handling is a single loop simply writing characters one by one directly from the buf instead of complex cnt_to_end computations. Until the buf is empty or fifo size is reached. Signed-off-by: Jiri Slaby --- drivers/tty/serial/pch_uart.c | 46 ++++++++++------------------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c index 6cb631487383..4fcb6c144b54 100644 --- a/drivers/tty/serial/pch_uart.c +++ b/drivers/tty/serial/pch_uart.c @@ -550,18 +550,6 @@ static u8 pch_uart_hal_get_modem(struct eg20t_port *priv) return (u8)msr; } -static void pch_uart_hal_write(struct eg20t_port *priv, - const unsigned char *buf, int tx_size) -{ - int i; - unsigned int thr; - - for (i = 0; i < tx_size;) { - thr = buf[i++]; - iowrite8(thr, priv->membase + PCH_UART_THR); - } -} - static int pch_uart_hal_read(struct eg20t_port *priv, unsigned char *buf, int rx_size) { @@ -769,23 +757,21 @@ static void pch_dma_tx_complete(void *arg) pch_uart_hal_enable_interrupt(priv, PCH_UART_HAL_TX_INT); } -static int pop_tx(struct eg20t_port *priv, int size) +static bool pop_tx(struct eg20t_port *priv, unsigned int size) { - int count = 0; + unsigned int count = 0; struct uart_port *port = &priv->port; struct circ_buf *xmit = &port->state->xmit; - if (uart_tx_stopped(port) || uart_circ_empty(xmit)) + if (uart_tx_stopped(port)) goto pop_tx_end; - do { - int cnt_to_end = - CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); - int sz = min(size - count, cnt_to_end); - pch_uart_hal_write(priv, &xmit->buf[xmit->tail], sz); - xmit->tail = (xmit->tail + sz) & (UART_XMIT_SIZE - 1); - count += sz; - } while (!uart_circ_empty(xmit) && count < size); + while (!uart_circ_empty(xmit) && count < size) { + iowrite8(xmit->buf[xmit->tail], priv->membase + PCH_UART_THR); + xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); + port->icount.tx++; + count++; + } pop_tx_end: dev_dbg(priv->port.dev, "%d characters. Remained %d characters.(%lu)\n", @@ -859,7 +845,6 @@ static unsigned int handle_tx(struct eg20t_port *priv) struct uart_port *port = &priv->port; struct circ_buf *xmit = &port->state->xmit; int fifo_size; - int tx_size; int size; int tx_empty; @@ -874,7 +859,7 @@ static unsigned int handle_tx(struct eg20t_port *priv) fifo_size = max(priv->fifo_size, 1); tx_empty = 1; if (port->x_char) { - pch_uart_hal_write(priv, &port->x_char, 1); + iowrite8(port->x_char, priv->membase + PCH_UART_THR); port->icount.tx++; port->x_char = 0; tx_empty = 0; @@ -884,13 +869,8 @@ static unsigned int handle_tx(struct eg20t_port *priv) size = min(xmit->head - xmit->tail, fifo_size); if (size < 0) size = fifo_size; - if (size) { - tx_size = pop_tx(priv, size); - if (tx_size > 0) { - port->icount.tx += tx_size; - tx_empty = 0; - } - } + if (size && pop_tx(priv, size)) + tx_empty = 0; priv->tx_empty = tx_empty; @@ -935,7 +915,7 @@ static unsigned int dma_handle_tx(struct eg20t_port *priv) fifo_size = max(priv->fifo_size, 1); if (port->x_char) { - pch_uart_hal_write(priv, &port->x_char, 1); + iowrite8(port->x_char, priv->membase + PCH_UART_THR); port->icount.tx++; port->x_char = 0; fifo_size--; -- 2.36.0