From patchwork Sat Oct 22 07:28:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7778 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1121302wrr; Sat, 22 Oct 2022 02:28:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM552D15w3IM7j5P46Egg9zPiRn9uK/c/KsYNVZxPVlsaLYxn03aoiUu2+CpYXct8ycH1yiq X-Received: by 2002:a63:cc4a:0:b0:439:1c48:2fed with SMTP id q10-20020a63cc4a000000b004391c482fedmr19844516pgi.618.1666430888170; Sat, 22 Oct 2022 02:28:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666430888; cv=none; d=google.com; s=arc-20160816; b=FvTCPH0Uog5qBoRlKCTjzrvE77bVv8Pgtd2RDJuJ+BUSTETApjRWiP0wP8TNpBhDvW cFm/TyHW4yWB8fwTTJVhppAZlvifJcSD35ucMTtvfQdrpE87A8MFJXi0ZwkF0BWC5+zu sU2wGNWt1Jqo7rKVR331sqdt01KzZ5twNi+rhJDvb7Sk7k+FeBIGX9kOSb4ZXFAoKAik ZgdcFAtkFzmSisu1yDmWl6xkDWjF6u8jKokbqvhnToF2tiRKNyULhc42h2b5aLJPwtRI /32X/CCqP88Z0J4KggDTPmOcXZ7JsfXt2k51pD/04g1/FXgzQm2o3tNeU505Z4WFz9AU /rfw== 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=iGWVMjzuvGo5lj1+uXc7eAKNp3H0ETUNtDk9fSJTgWk=; b=PgMUytemVvjem3wsd7LBqKLGtw1CTV5p2TQIxg9Cc4jfG0Mr4zN8Xh/5yTGhybQQ7w oXKo298X6uJfYsmk4zaO1ubt8iFtokHf6oab8W0vs8baFVdjs1a6lv8ftTk2pvpf6dmY S9f2pz9qGq0gSgiMxW1TrGvEqqHYasF7mzdsVYPSoGV9wWr1UVUtAKsdxUK0ne4IEZEI V8Ksq8ZpDiJO4ShZFwW30+t2puOvBrE8ZyjhR1AZGBQUcFgMCxtxJQPxCKseCjqpHhqZ TI/lNkQ+rqPe5T18J/Hx5Mv56NVRK4Am1X1EyHXF9ofdVO5EzaI1tdcU+3RU0FGvhpdV cuEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hFZI1nF9; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l17-20020a656811000000b0045a2d89c9cfsi28301602pgt.348.2022.10.22.02.27.55; Sat, 22 Oct 2022 02:28:08 -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=hFZI1nF9; 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 S233297AbiJVJEh (ORCPT + 99 others); Sat, 22 Oct 2022 05:04:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235090AbiJVJD1 (ORCPT ); Sat, 22 Oct 2022 05:03:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95EE52FACF4; Sat, 22 Oct 2022 01:18:36 -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 13DA260B39; Sat, 22 Oct 2022 08:06:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06459C433D6; Sat, 22 Oct 2022 08:06:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666426006; bh=M+GQYKj7W9Q9eqQVTrqZvdk+oerpuJZZbVXvQ6MtdVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hFZI1nF9mVHWZOEz8hQ2MZcejhXv/TpTeQte8aGQDMH0uycwmr+fG77wlX/YJTYIA BFRxYtn+x7kYh5y9gd4jJuypJSUuM57u+L+z1OSJajDp9F2OwxNSApn76ht/zxwwDP hDmoCo9iczHC54QvgS9H5lcW3vq9rtIeMDKQsOIA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vaishnav Achath , Peter Ujfalusi , Vinod Koul , Sasha Levin Subject: [PATCH 5.19 658/717] dmaengine: ti: k3-udma: Reset UDMA_CHAN_RT byte counters to prevent overflow Date: Sat, 22 Oct 2022 09:28:57 +0200 Message-Id: <20221022072527.497849815@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747379435059121760?= X-GMAIL-MSGID: =?utf-8?q?1747379435059121760?= From: Vaishnav Achath [ Upstream commit 7c94dcfa8fcff2dba53915f1dabfee49a3df8b88 ] UDMA_CHAN_RT_*BCNT_REG stores the real-time channel bytecount statistics. These registers are 32-bit hardware counters and the driver uses these counters to monitor the operational progress status for a channel, when transferring more than 4GB of data it was observed that these counters overflow and completion calculation of a operation gets affected and the transfer hangs indefinitely. This commit adds changes to decrease the byte count for every complete transaction so that these registers never overflow and the proper byte count statistics is maintained for ongoing transaction by the RT counters. Earlier uc->bcnt used to maintain a count of the completed bytes at driver side, since the RT counters maintain the statistics of current transaction now, the maintenance of uc->bcnt is not necessary. Signed-off-by: Vaishnav Achath Acked-by: Peter Ujfalusi Link: https://lore.kernel.org/r/20220802054835.19482-1-vaishnav.a@ti.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/ti/k3-udma.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c index 2f0d2c68c93c..fcfcde947b30 100644 --- a/drivers/dma/ti/k3-udma.c +++ b/drivers/dma/ti/k3-udma.c @@ -300,8 +300,6 @@ struct udma_chan { struct udma_tx_drain tx_drain; - u32 bcnt; /* number of bytes completed since the start of the channel */ - /* Channel configuration parameters */ struct udma_chan_config config; @@ -757,6 +755,20 @@ static void udma_reset_rings(struct udma_chan *uc) } } +static void udma_decrement_byte_counters(struct udma_chan *uc, u32 val) +{ + if (uc->desc->dir == DMA_DEV_TO_MEM) { + udma_rchanrt_write(uc, UDMA_CHAN_RT_BCNT_REG, val); + udma_rchanrt_write(uc, UDMA_CHAN_RT_SBCNT_REG, val); + udma_rchanrt_write(uc, UDMA_CHAN_RT_PEER_BCNT_REG, val); + } else { + udma_tchanrt_write(uc, UDMA_CHAN_RT_BCNT_REG, val); + udma_tchanrt_write(uc, UDMA_CHAN_RT_SBCNT_REG, val); + if (!uc->bchan) + udma_tchanrt_write(uc, UDMA_CHAN_RT_PEER_BCNT_REG, val); + } +} + static void udma_reset_counters(struct udma_chan *uc) { u32 val; @@ -790,8 +802,6 @@ static void udma_reset_counters(struct udma_chan *uc) val = udma_rchanrt_read(uc, UDMA_CHAN_RT_PEER_BCNT_REG); udma_rchanrt_write(uc, UDMA_CHAN_RT_PEER_BCNT_REG, val); } - - uc->bcnt = 0; } static int udma_reset_chan(struct udma_chan *uc, bool hard) @@ -1115,7 +1125,7 @@ static void udma_check_tx_completion(struct work_struct *work) if (uc->desc) { struct udma_desc *d = uc->desc; - uc->bcnt += d->residue; + udma_decrement_byte_counters(uc, d->residue); udma_start(uc); vchan_cookie_complete(&d->vd); break; @@ -1168,7 +1178,7 @@ static irqreturn_t udma_ring_irq_handler(int irq, void *data) vchan_cyclic_callback(&d->vd); } else { if (udma_is_desc_really_done(uc, d)) { - uc->bcnt += d->residue; + udma_decrement_byte_counters(uc, d->residue); udma_start(uc); vchan_cookie_complete(&d->vd); } else { @@ -1204,7 +1214,7 @@ static irqreturn_t udma_udma_irq_handler(int irq, void *data) vchan_cyclic_callback(&d->vd); } else { /* TODO: figure out the real amount of data */ - uc->bcnt += d->residue; + udma_decrement_byte_counters(uc, d->residue); udma_start(uc); vchan_cookie_complete(&d->vd); } @@ -3809,7 +3819,6 @@ static enum dma_status udma_tx_status(struct dma_chan *chan, bcnt = udma_tchanrt_read(uc, UDMA_CHAN_RT_BCNT_REG); } - bcnt -= uc->bcnt; if (bcnt && !(bcnt % uc->desc->residue)) residue = 0; else