Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp432836pxj; Thu, 20 May 2021 12:45:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw9bes1sGNd1gluGInInWeQTmnVNJQs8VW9rKO/xA9VfpcFALLfjYoyuTdJHTX9JBI93BQ X-Received: by 2002:a05:6402:3548:: with SMTP id f8mr6560313edd.251.1621539957187; Thu, 20 May 2021 12:45:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621539957; cv=none; d=google.com; s=arc-20160816; b=lkUaDwZO4b3P6QwNReN1RtJ+UTvRlllsBEE1Ams5ElALTirnP6LCsQf9F5hh4CjqhC bpBXeGPoJuMFni8Q3gc8eOzneP0JnvFOjIjhwuOjVoiB0YTxQA8+tkfvQk/1e+FExhGa UBoS4T/tftA2YwcYHYjuyPc807OwGwLgudG39OrNxL0pgWpsgMhcuQINyR+cNEACn78b Bb6Ov4xOmP9PeD1EGprcXnxIjeStvObPLOFw+6M65SAQxIdnkI1YH+JB20fT8mllhflI xG7xzrSxwny1r6+yvcLY/lPdLBhLOV1lqacV4HtoiNwoN6RnUeI786V4RKs2qkHf5daE xhUQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ylWSgF/kQUGaPYcXozYyza+u0TAk8XQ6VI32j/IC/bY=; b=ZH1tN8Cyrui6MQEB/EtNb5ydr4gWVWM+3cMdxwzhGvgY9in/F5Ejd3kjoY3/QtdFQH Parh8x2ZSIGkK4LIrH4eWnDhKjQIC6Y5Jeg6r6ec0UwIkTT87MHbuK22ZbkThbwWTcZP t7gzZ5Bcv1phoVhokpRTcazg3vng6nbF0eSDxTWB1YsnT7gCx1PZPpzyUSmcq6L1K3o7 /MkMuD4rF+QDJEryqYmuwM4AH2QklK3jSAkYcHJUKcrdoz5npomQgXoV2L/0is8mhMlI E7osOZbhYY9u6pFTARyGUbi6lnD+xFOgbE0qDfdUaYUop3bCBYbm19sMcHjdeZM3urvU /Alw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yYZdapgU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f2si3361694ejh.498.2021.05.20.12.45.32; Thu, 20 May 2021 12:45:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yYZdapgU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236011AbhETKmG (ORCPT + 99 others); Thu, 20 May 2021 06:42:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:54242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236422AbhETK0Z (ORCPT ); Thu, 20 May 2021 06:26:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9056A61C24; Thu, 20 May 2021 09:50:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504211; bh=9q53dVbRJ4/lK7UlsyJsJs2G0m4XJoVNBPMKmJNYzss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yYZdapgUie3J+e48qp7ys1B+D0VKfJCOimXXxsRNLhtjmw/2ahnGH6lDvK+dhgxsM f3zlyZ+uVlnuPX3nyb5OevOBAYyGlvQgDty1oAF9CUh5u/t2q+fMYxf7YcW2CgyJzr zAh+9X0KiNIH7HMm63Qe8SQvckT3vG5wHWD4RzRw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Erwan Le Ray , Sasha Levin Subject: [PATCH 4.14 143/323] serial: stm32: fix tx_empty condition Date: Thu, 20 May 2021 11:20:35 +0200 Message-Id: <20210520092125.007021822@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Erwan Le Ray [ Upstream commit 3db1d52466dc11dca4e47ef12a6e6e97f846af62 ] In "tx_empty", we should poll TC bit in both DMA and PIO modes (instead of TXE) to check transmission data register has been transmitted independently of the FIFO mode. TC indicates that both transmit register and shift register are empty. When shift register is empty, tx_empty should return TIOCSER_TEMT instead of TC value. Cleans the USART_CR_TC TCCF register define (transmission complete clear flag) as it is duplicate of USART_ICR_TCCF. Fixes: 48a6092fb41f ("serial: stm32-usart: Add STM32 USART Driver") Signed-off-by: Erwan Le Ray Link: https://lore.kernel.org/r/20210304162308.8984-13-erwan.leray@foss.st.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/stm32-usart.c | 5 ++++- drivers/tty/serial/stm32-usart.h | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 6ad982cf31fc..a10335e904ea 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -365,7 +365,10 @@ static unsigned int stm32_tx_empty(struct uart_port *port) struct stm32_port *stm32_port = to_stm32_port(port); struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; - return readl_relaxed(port->membase + ofs->isr) & USART_SR_TXE; + if (readl_relaxed(port->membase + ofs->isr) & USART_SR_TC) + return TIOCSER_TEMT; + + return 0; } static void stm32_set_mctrl(struct uart_port *port, unsigned int mctrl) diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h index 9d087881913a..55142df8e24b 100644 --- a/drivers/tty/serial/stm32-usart.h +++ b/drivers/tty/serial/stm32-usart.h @@ -123,9 +123,6 @@ struct stm32_usart_info stm32h7_info = { /* Dummy bits */ #define USART_SR_DUMMY_RX BIT(16) -/* USART_ICR (F7) */ -#define USART_CR_TC BIT(6) - /* USART_DR */ #define USART_DR_MASK GENMASK(8, 0) -- 2.30.2