Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp829747rwb; Mon, 26 Sep 2022 06:26:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4nsKV5Qh4ichQE2hq8L0tUtG7dWWJdmNfWRF5EsZ/o1GgKgBNlF+VWzJv6iHkHzfV9aMmu X-Received: by 2002:a17:906:5d04:b0:77f:ca9f:33d1 with SMTP id g4-20020a1709065d0400b0077fca9f33d1mr18581930ejt.526.1664198809300; Mon, 26 Sep 2022 06:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664198809; cv=none; d=google.com; s=arc-20160816; b=0dlEnoj3JudDoy9mQI+EO8qhCJvv5ZtWoonY6ULmynnK33274syKvtkpR4mDaiGwSa hZ5Arxlhm4C8Dc1cDqeFG9iljCIIz/ySBBH3GLlqaOUd1ZrACFRGl/V/QENPGXxQceLI dYrIF+m8DxW3+aiXvD3qSJR2MzqnkrxChJa0KoZKGNiJ0F9bwJSfK4X2I6DsoMuzUUaV jb/aZb8j2ncXg2yf4htgsp9IZPLCfGokwjyRwT4ZB8nNEJikKw2E9PMoHqoh9blrWxnE wHCWupafkh6zDOYpL4sqdUYUtVkOyt21VS8RWt3eeznHiz0Bh7cnYr2dTNypcn19Fxck ABKw== 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=x5RflXWbMoteEBK957uTkyzWlJgzYtbHPXip8VOtZOQ=; b=dLdk0BKyeLbJ2XTcTB6TkGEs+/Ah29maGoUb9G47bMjByGn+RxmqT+cr+jEWp3mNFl HRMkvaTtHu4prRlkGnrzlLBI+sXUFNflVM1Ud4CqfiqNJvIeaGAjlJF+j7NabKYYGn2T bUFLfi27H3glKUbDN6bqbMRn9rSCLxUw66GiIGnB7eDheUnN3/QER5clN1a7jmp8dnYK WOmyu6bUx7Gbx/ZgadMNi1IjVA15DpzEeLxAYY7x6fxL3/xqFFw5fTudwbhqZQ/4PEDY jrXBmo32S5zGddBMo7NPm6VsXgmm6PKD01xD9GsQ63tXmlUNtAsju8+aPvxa8h6vOgcy 9oHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dZhev1lS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he6-20020a1709073d8600b00782d7448ce5si9395976ejc.734.2022.09.26.06.26.23; Mon, 26 Sep 2022 06:26:49 -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=@linuxfoundation.org header.s=korg header.b=dZhev1lS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236366AbiIZKp5 (ORCPT + 99 others); Mon, 26 Sep 2022 06:45:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236411AbiIZKnh (ORCPT ); Mon, 26 Sep 2022 06:43:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB05511C13; Mon, 26 Sep 2022 03:24:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 67AACB80682; Mon, 26 Sep 2022 10:24:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6851C433D7; Mon, 26 Sep 2022 10:24:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664187885; bh=rMQyFM4XEKYxbNi+Pl2ZddmOL/oLdGY390SQioJnnPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dZhev1lSOWlxa2TOH+d4Cli3qW3mY1HF3Usm6j55XNxpCcfPb8hIOdR7Yba330HaO Vv8RdV9vCc1mM2TjS3cdDgS9XhQrhxfjIsGfUF/qzsvRW/+9EdmkntZft33S9YcsJB xHBsxz2yIvgAupuXGzlXyOd/DqaRIlnVVOFRCbAo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 5.4 091/120] serial: tegra: Use uart_xmit_advance(), fixes icount.tx accounting Date: Mon, 26 Sep 2022 12:12:04 +0200 Message-Id: <20220926100754.346443606@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100750.519221159@linuxfoundation.org> References: <20220926100750.519221159@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 From: Ilpo Järvinen commit 754f68044c7dd6c52534ba3e0f664830285c4b15 upstream. DMA complete & stop paths did not correctly account Tx'ed characters into icount.tx. Using uart_xmit_advance() fixes the problem. Fixes: e9ea096dd225 ("serial: tegra: add serial driver") Cc: # serial: Create uart_xmit_advance() Reviewed-by: Andy Shevchenko Signed-off-by: Ilpo Järvinen Link: https://lore.kernel.org/r/20220901143934.8850-3-ilpo.jarvinen@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/serial-tegra.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/drivers/tty/serial/serial-tegra.c +++ b/drivers/tty/serial/serial-tegra.c @@ -519,7 +519,7 @@ static void tegra_uart_tx_dma_complete(v count = tup->tx_bytes_requested - state.residue; async_tx_ack(tup->tx_dma_desc); spin_lock_irqsave(&tup->uport.lock, flags); - xmit->tail = (xmit->tail + count) & (UART_XMIT_SIZE - 1); + uart_xmit_advance(&tup->uport, count); tup->tx_in_progress = 0; if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) uart_write_wakeup(&tup->uport); @@ -606,7 +606,6 @@ static unsigned int tegra_uart_tx_empty( static void tegra_uart_stop_tx(struct uart_port *u) { struct tegra_uart_port *tup = to_tegra_uport(u); - struct circ_buf *xmit = &tup->uport.state->xmit; struct dma_tx_state state; unsigned int count; @@ -617,7 +616,7 @@ static void tegra_uart_stop_tx(struct ua dmaengine_tx_status(tup->tx_dma_chan, tup->tx_cookie, &state); count = tup->tx_bytes_requested - state.residue; async_tx_ack(tup->tx_dma_desc); - xmit->tail = (xmit->tail + count) & (UART_XMIT_SIZE - 1); + uart_xmit_advance(&tup->uport, count); tup->tx_in_progress = 0; }