Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp824885rwb; Mon, 26 Sep 2022 06:23:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4mbAW5cNSSCnKFuoo0B9TDKSrlQ/oB4XHvxSPBxlqXKsIckFuGpd1GCiz8LdgnrqDgdYm9 X-Received: by 2002:a17:907:a0c7:b0:77c:b9cb:be17 with SMTP id hw7-20020a170907a0c700b0077cb9cbbe17mr18050311ejc.335.1664198591828; Mon, 26 Sep 2022 06:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664198591; cv=none; d=google.com; s=arc-20160816; b=W84p54osocvikrOQuHvxSZJRd/YQFjcigCA2JD8KbTB3ZwvTnWQsrO9zVxWfoG3/0I 4W5dRYh8e6j84vx7OAW8NWUZviXgh+7icGWYuOWUIsKcxggzxeUDt2uowG1Cs9eA2peU sVwRSmWS/YCgitcXGN5X7k+24bS8V75eTn8YVimlOsazNMV1rF7lxhLSUbOlx5nfn3Cx W8Mt+zCA86O81An1BRZPCKpJI/+Fyv2p3PrzFXt28OBRCjPbToXyPmvLjimReVJW1bx0 bRpunHCO5ms7I3wDP7S5/os29QITgZDQTRBs59vHYlpU0kggP+yMJ64iyX5QY3gEn6Xm LaYg== 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=ICiDwkdE64r8S8pt4uFeLRBsDznCAzI3220GAbxzxdc=; b=thrDfe+vTddL6z8pXGFhgYubUl7qD1+k4qZugwLsA1d+viJQJMFjmlpGY16fKetDOO URuIHkd9pXclB503FlaVoO/E2DvsBobielT7kIx8+S88Ok5bAJS97vYkVaoF0Ez+PVP8 W/IFMuRhooP7VIbMN/vIVRhFXjm5r3gxyQictnZAt6bflJy/qjhO2u26JBfff/Li5+2B l3HUdp+f/IOJO/NWUjTywfZjfVd9dbJV3jZNUETCBltbUzgDzQpsSYumOgABOB2ngw09 W5qq108trackdyaqTc6IspZX3oklpFCvlYTwkyl7TVxiJvI/CUO95/FbFRQ0e/R9Eshw dcaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Bjrh8jiE; 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 bf18-20020a0564021a5200b004575a5c88cbsi1477095edb.32.2022.09.26.06.22.46; Mon, 26 Sep 2022 06:23:11 -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=Bjrh8jiE; 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 S238843AbiIZL4e (ORCPT + 99 others); Mon, 26 Sep 2022 07:56:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238849AbiIZLx6 (ORCPT ); Mon, 26 Sep 2022 07:53:58 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA82F101D3; Mon, 26 Sep 2022 03:49:44 -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 6D290B8095B; Mon, 26 Sep 2022 10:49:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAA39C433C1; Mon, 26 Sep 2022 10:49:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664189367; bh=vOPXaVottFLXDjh23uGbUV0JWH7K6CBH8tJz+br+0xQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bjrh8jiETcnXiLhJw1t/jEWZya9YApJXy8sHPIOtahtSZ0iHH7iUUapSKE6KviKto CFcv+svloLt8E/QwFDQ852dRgYVBOEI1wuLZ9v1SA0wmhAxM2lFACX/Ipi4oeUYG+1 nVrP82hAc87VKQ6ES9rhvH8fvvim7cpUlCDQ/c5Q= 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.19 162/207] serial: tegra: Use uart_xmit_advance(), fixes icount.tx accounting Date: Mon, 26 Sep 2022 12:12:31 +0200 Message-Id: <20220926100813.921698308@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100806.522017616@linuxfoundation.org> References: <20220926100806.522017616@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 @@ -525,7 +525,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); @@ -613,7 +613,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; @@ -624,7 +623,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; }