Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4592219pxj; Wed, 12 May 2021 08:51:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9udbQjUxRYCI8Aw2FplJR8xQBVCRg+LBgppcO467+bMZSF10frNwuoNCVq1+2FQzH1Xd3 X-Received: by 2002:aa7:cd0c:: with SMTP id b12mr43910309edw.236.1620834680898; Wed, 12 May 2021 08:51:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620834680; cv=none; d=google.com; s=arc-20160816; b=vc7xnu8gDsZy6H4MBN7/AxuimR9dg+RXtcLjXBuUvUkz+Y+AmmdVW7BcH3uMwrh7BU hXwjx+iiEfoCFr0YbTOuSCDo1ENMBaawKVmfXoF8f7LNywlEcPilx6YILsrpRRvCFCKf kjDKao0sDuwZTH49a+aDzRVqHGSsm/sG3sTESdxmqycCFaeGlwnR8zm5sfgeZwX0kwMx AoQfhuw2gZzWpBguW2S9DA6/d5AXNCpIz39ljMreSBPwnjFAtaFNhtMSyYJExLBv9pWK leCOF8j+0Dr/yRcO8DLjCEaNw48cc1c0KuhklCEm2o/ZiYEIXX22ZxiYlI9QUIGwpe1E CGMA== 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=EKnyXysmmRNlwEp6fGsSSlEbf+79EFNBDCv4+hoNvco=; b=qumNwJFiQEoDzAvgNHWpcyOiyfJ51LDD7EwD292q9dmK+F728+YOLuaTb86XCjyZSv TpwcHvLg13ltrc52p24iRV7avcVemLnuxXeOGplGiOg7RQWW+tSbQLRb8WOaYDlo0UYy Qc/5dK7tos34jN2EQd2YA56UvQ/TnhOyU5EnareGnZbIeFbqc9BKORlH3K4+Ofu/+/Fk nxRwWyZVt2tSg27d5TvKeTWioj1KY5eB7JRiPU7PJVsJHCMSaa+sxZLyyqkUs3elJGxX 0uUXErBhrhKAwoNRAX8DeegGy3JMAn/ow/BnJEE3Dw84zxsEwBdStQzJXXAKS578PWt9 RINg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Uzqe/QtK"; 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 v21si90220edx.267.2021.05.12.08.50.55; Wed, 12 May 2021 08:51:20 -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="Uzqe/QtK"; 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 S237438AbhELPu3 (ORCPT + 99 others); Wed, 12 May 2021 11:50:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:38784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234291AbhELPYm (ORCPT ); Wed, 12 May 2021 11:24:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D77A7619B6; Wed, 12 May 2021 15:10:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832210; bh=h44MHavJuuArjrpAwtzhkwqsgKm4E5Xw3coWdkO0kow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uzqe/QtKHKaGHbpjaJN0edLFBI7/VkEUkSXAxC8bVk+Zr14o5Pc8210BecZL8F5xk fK5reTgjoBzLgIQ4L2WnxPRWrHF45CyaUG9oAyz7gDPug8VfNnnb+jgXvWB3fO5SmJ IBZoI+AS/TyKRpzqo5tx0vGqfUOfNoEv93DGiK3A= 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 5.10 142/530] serial: stm32: fix tx_empty condition Date: Wed, 12 May 2021 16:44:12 +0200 Message-Id: <20210512144824.486253533@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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 cb8c2bece6d6..2cf9fc915510 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -514,7 +514,10 @@ static unsigned int stm32_usart_tx_empty(struct uart_port *port) struct stm32_port *stm32_port = to_stm32_port(port); const 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_usart_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 cb4f327c46db..94b568aa46bb 100644 --- a/drivers/tty/serial/stm32-usart.h +++ b/drivers/tty/serial/stm32-usart.h @@ -127,9 +127,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