Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp776551rwb; Mon, 26 Sep 2022 05:51:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6gCci0b0DLPkR0H7LlOGBD70HeuyjZ28++e8D2omjQtxqvDREKu0WAIDgZWWUu4NPyGjLI X-Received: by 2002:a17:90b:1b50:b0:202:f495:6b43 with SMTP id nv16-20020a17090b1b5000b00202f4956b43mr36760971pjb.85.1664196696838; Mon, 26 Sep 2022 05:51:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664196696; cv=none; d=google.com; s=arc-20160816; b=IOe6fvJkWNgoKpUWK+YgMx0/w7L91fKxGcujp9/r2QXMQ4Qb6T2ti62UNf2LleClF0 XAQoT43z3AtTbjFnAc5xSz925MwMa/xPNgGfH7FgqOqnc6exuYQyqhClktO7tWJP37K2 140qZu2Fc0QujclXHE/u1533LLBPrJL6Dsj9rpp+dlgZBCEsWFmEOv3EITIMe9DPeNqP i1mfKgyMx/X3pJq0yqWEJySUsLTOgnaYLF4Bl0aIryyPA5YOBkPv15cNsjgcqCgqYryL 3UvUKh4wP30yNg3mLlSMF0yqqPvGEdq+0EX82BqiU6BOQqGeb91w6H8VZ9ob5P2Vs6rw 7ctQ== 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=1meOJgGlNfgK7l2FnQQZ1P4x4AmlhVBq91RMr09yTR4=; b=w2rwPSu2Yd0X8aFaRSKhImYjOjXnlnQ55MjWUguK9txLH0E0HTcBnC1jVYuZ25JABy tkDJb05GIqI9EVbcWZKJlUKQ3AAMYugJ+kcBOct0J2/d9fNBF9i/6Y+9iWH1gnMiLo17 gcorNmPuEOBP5GV8CeX56P7hezC7THKKygXq0whFhjks7uP2QbhHkIK1LABliGH9ckie IiuvWk4MIOZ9nji0lDfxTNuO2l8nee3MpnQQfqXlAqKCnsrHTtkP9audlAGpgiAGLrib cAYPIMLdL3zsnuDKMu2AFp5Ftk1pY43NO7MFclWppLxC2g+KjWsPHE1hIzOGHPQdTsYe icnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KNbWDlr1; 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 n7-20020a170902d2c700b0017555e9de54si11785897plc.427.2022.09.26.05.51.25; Mon, 26 Sep 2022 05:51:36 -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=KNbWDlr1; 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 S235897AbiIZKdb (ORCPT + 99 others); Mon, 26 Sep 2022 06:33:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235876AbiIZKc7 (ORCPT ); Mon, 26 Sep 2022 06:32:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 115AD1AF0F; Mon, 26 Sep 2022 03:20:09 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 42DB660B7E; Mon, 26 Sep 2022 10:20:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D6F1C433D6; Mon, 26 Sep 2022 10:19:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664187599; bh=UrYpoJkOcC+Z/4HedVZyNA5cwMtyJQfPL+QJGcXp3k0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KNbWDlr1TQJpJDk2DG2FdQ3fCkqT5gZJMxrcxE4sUnwEj8uMY1bm9DNah2jb5/Zu0 agDBPfyIdPudnVKg0dMYdRtgbIIIl3rwHu9ZQtNHhsy5Fngl/4JeC5fzMsOMvj/ZUg 5rKYLKwx5f96t+81l2d3bLhTcNVB9ED4EKZI2HJw= 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 4.19 51/58] serial: tegra: Use uart_xmit_advance(), fixes icount.tx accounting Date: Mon, 26 Sep 2022 12:12:10 +0200 Message-Id: <20220926100743.320354793@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100741.430882406@linuxfoundation.org> References: <20220926100741.430882406@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 @@ -398,7 +398,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); @@ -482,7 +482,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; @@ -493,7 +492,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; }