From patchwork Tue Jun 18 10:02:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erwan Le Ray X-Patchwork-Id: 167127 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4002012ilk; Tue, 18 Jun 2019 03:03:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyY6RoO8zkso9wZWJ6K5lTE6jODmmbTCcFQYSah8EC0nI+V4xoVWG9VEmeWoFlrqBZDqjvb X-Received: by 2002:a63:516:: with SMTP id 22mr1885287pgf.116.1560852182365; Tue, 18 Jun 2019 03:03:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560852182; cv=none; d=google.com; s=arc-20160816; b=TVTz/M/QXT+xw+Z/q+6XE7Rpe157vV/fCScqFtGL9immmxtYUzipU3Ftx3Q7GcsYDz 8I2zxYFJAjPcghmCixiJvT+ARzN/zGNXj8DfY5BRwOvK2GrIE5h2lVFgwBFwtmzk49Kk SQLPx6kCiLnKOH5ENpax6JH7BJrEkk17HobTjodbkOSxJSL3I3gsHOF8qR5b93Bhtsr7 IHXCikFxM/nKS1t8QSq17YljcaRjISayqMazYJNwsq4LLWzAeRy4s6LTj6r1iHdDdQKC k6R3Ja0GPrlSEHfpPxkA3yYkKS9TIgEOwVlHS13/9SgFhC26yEGHCs7j8OevostzOwKa Mjkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=h01JWVwcjqILFh4YSO7W65sajs6sEQaVQ79mN3RX8qQ=; b=Aa8ZUQJERrPGGY6vTAmdHsQ4R2GQHDR4Ugr+6GC5MpHVkMkLOLvy5JvICQlqtoHhVR jl6x4TjF91Hs9LF/KHRAbu34RuoaLAihobgUT1aOnHAwL2RAorHi9zz7jMNkWEmnrkkp 3JQzNQ2jPi0oSYL4Em9zU66tLMVXe3PNmvOsnx4omP7Yby6FRel/WqkYbsvoXtXgpG2p JBcu+eoYB5go8vtTZvjxCq8XT5kLZ3PraKz6ySyvLfpMpb7ytcThVuxQ+UG4beOrLYC2 pcJ+aSWHy2UkKjNbuRhttNNaAVFaVRZ2uQbqX0Bl2GoPm/xoA1UDz85j8vqCzkPfVDlV 2Lyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=QLNmM8Ym; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z8si1903268pjn.51.2019.06.18.03.03.02; Tue, 18 Jun 2019 03:03:02 -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=pass header.i=@st.com header.s=STMicroelectronics header.b=QLNmM8Ym; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728195AbfFRKDB (ORCPT + 1 other); Tue, 18 Jun 2019 06:03:01 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:25738 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725913AbfFRKDB (ORCPT ); Tue, 18 Jun 2019 06:03:01 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5I9ug4W007561; Tue, 18 Jun 2019 12:02:37 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=h01JWVwcjqILFh4YSO7W65sajs6sEQaVQ79mN3RX8qQ=; b=QLNmM8Ym6XwFgwWEWHrCnihEcWc1VtywI4qxDJ1y07gq6pLzS6LqMBnyj+bx4Bz4vXzd /TauvCyjVPOhiJO1QvGhcOV9gNzPdMDgl/GxNPp4z5LOLi4df/L7Z1FttIduxDTgwc/5 +rvAI7NUxvqoGC+yZ9akFbW1Mqqn3IAsKFMW42TK/ijPpv/W9zYZW5UtN1QbZr82blPr ecRstm6j6+unZ/8cvQeAe/NkKYJVT5fy9fmxLvP5GitcPz3ZfWMEkMcjagxZRRWcyzpD xQop4ni9R2rTwxlJiJRvhUxq6sRrqRYCZYrkiR7qtt/S4V3reILsXQ6wTStX/5lhAhy1 8Q== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2t4nt883jd-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 18 Jun 2019 12:02:37 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 7A74438; Tue, 18 Jun 2019 10:02:36 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas24.st.com [10.75.90.94]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 59DB025D7; Tue, 18 Jun 2019 10:02:36 +0000 (GMT) Received: from SAFEX1HUBCAS23.st.com (10.75.90.47) by Safex1hubcas24.st.com (10.75.90.94) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 18 Jun 2019 12:02:36 +0200 Received: from localhost (10.201.23.31) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 18 Jun 2019 12:02:35 +0200 From: Erwan Le Ray To: Greg Kroah-Hartman , Jiri Slaby , Maxime Coquelin , "Alexandre Torgue" CC: , , , , "Erwan Le Ray" , Fabrice Gasnier Subject: [PATCH 2/5] serial: stm32: update PIO transmission Date: Tue, 18 Jun 2019 12:02:23 +0200 Message-ID: <1560852146-3393-3-git-send-email-erwan.leray@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1560852146-3393-1-git-send-email-erwan.leray@st.com> References: <1560852146-3393-1-git-send-email-erwan.leray@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.23.31] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-06-18_05:, , signatures=0 Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Improves PIO transmission: - Replaces the FIFO filling per character by a filling per blocks of characters, which provides better performances - Replaces the active waiting loop by TX empty interrupt dynamic handling. TXE interrupt is now enabled when data has to be sent (ie when uart_circ is not empty), and inhibited when there is no more data to send (ie when uart_circ is empty). Signed-off-by: Erwan Le Ray -- 1.9.1 diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index e1cfb1e..8316e19 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -303,27 +303,26 @@ static void stm32_transmit_chars_pio(struct uart_port *port) struct stm32_port *stm32_port = to_stm32_port(port); struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; struct circ_buf *xmit = &port->state->xmit; - unsigned int isr; - int ret; if (stm32_port->tx_dma_busy) { stm32_clr_bits(port, ofs->cr3, USART_CR3_DMAT); stm32_port->tx_dma_busy = false; } - ret = readl_relaxed_poll_timeout_atomic(port->membase + ofs->isr, - isr, - (isr & USART_SR_TXE), - 10, 100000); - - if (ret) - dev_err(port->dev, "tx empty not set\n"); - - stm32_set_bits(port, ofs->cr1, USART_CR1_TXEIE); + while (!uart_circ_empty(xmit)) { + /* Check that TDR is empty before filling FIFO */ + if (!(readl_relaxed(port->membase + ofs->isr) & USART_SR_TXE)) + break; + writel_relaxed(xmit->buf[xmit->tail], port->membase + ofs->tdr); + xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); + port->icount.tx++; + } - writel_relaxed(xmit->buf[xmit->tail], port->membase + ofs->tdr); - xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); - port->icount.tx++; + /* rely on TXE irq (mask or unmask) for sending remaining data */ + if (uart_circ_empty(xmit)) + stm32_clr_bits(port, ofs->cr1, USART_CR1_TXEIE); + else + stm32_set_bits(port, ofs->cr1, USART_CR1_TXEIE); } static void stm32_transmit_chars_dma(struct uart_port *port)