From patchwork Sat Aug 20 12:56:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12949681 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4AB74C25B08 for ; Sat, 20 Aug 2022 13:02:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=x/MKk0MI+qggb0hIjfmZ3933tXyMApMddvADF8ndDTw=; b=qxaIjCK9vD6t/C N/0cFAZQ4r4ovSHBHGmM0tC/7CrAii2FWSUCjhNYp4OoNgBEc21dP/CBS2SPzYNj7pBttjSko1ogC E/j+xTQAWlXbXETWw3GRtvtUUjjkMdhbYvHjg5O/So9Ytj1ZQmS4a7ShZ5EbAo7Uuy+p9S7UaNtkB zrzba1KBaueaXXiU9u6vUJAS7XhVUQkKXI67wvijXhQuzoue8n3F3ttSnUSVsXj+k8NATerOA5zZ9 GSSXCZNZ5TefUNvW058EwILvA+khk+L8gSNwrpmUsQRvEFaMag1+AVyvnsX9YT03QEjdGF3wBU6ot KyuIgcxljqHyrWXOQrsA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oPO5s-00AE0Q-SG; Sat, 20 Aug 2022 13:00:52 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oPO35-00ACWd-DM for linux-arm-kernel@lists.infradead.org; Sat, 20 Aug 2022 12:58:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1661000279; x=1692536279; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x8AZUEEXp2aHpZGcwDmioSQ2fEKe+n6TrnEWupdslZs=; b=nHgniFR+7ZpGxZtwlj2Ai/PISZLNDV8rPHTPNQtKQcuyP2YgzQ2VeqQC Nb76JN9Pa1vz2p4ZqKQTq2R+ATatB6JKbUnYJRH1g19j4ZoK8VKjf7sEg e9W7n5cjtUFAMVc5UU/gk1pUpId9+0EV2n4o0zymToZ6s7NK2q9Pz8t64 GuzgE3oA9/a/ujnF0H3GC6ibOnDEAYAijmm1O/cVQHL70n9wR1TxvzTol Tbrx/A60HcCK0x9DcAJVbS1ooUE1eBh08mgUi+IKFbaNRK1b2UJKO9910 jjcrjJuPYAPOmKBmZvgP0K/4k96SAsOZ5dXTbYAbecH+pyzK4p7ejKIQp A==; X-IronPort-AV: E=Sophos;i="5.93,251,1654585200"; d="scan'208";a="109911348" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 20 Aug 2022 05:57:58 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Sat, 20 Aug 2022 05:57:57 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Sat, 20 Aug 2022 05:57:53 -0700 From: Tudor Ambarus To: , , , Subject: [PATCH 10/33] dmaengine: at_hdmac: Fix premature completion of desc in issue_pending Date: Sat, 20 Aug 2022 15:56:54 +0300 Message-ID: <20220820125717.588722-11-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220820125717.588722-1-tudor.ambarus@microchip.com> References: <20220820125717.588722-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220820_055759_571793_BA7AD310 X-CRM114-Status: GOOD ( 10.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tudor.ambarus@microchip.com, linux-kernel@vger.kernel.org, maciej.sosnowski@intel.com, mripard@kernel.org, torfl6749@gmail.com, ludovic.desroches@microchip.com, stable@vger.kernel.org, dmaengine@vger.kernel.org, dan.j.williams@intel.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Multiple calls to atc_issue_pending() could result in a premature completion of a descriptor from the atchan->active list, as the method always completed the first active descriptor from the list. Instead, issue_pending() should just take the first transaction descriptor from the pending queue, move it to active_list and start the transfer. Fixes: dc78baa2b90b ("dmaengine: at_hdmac: new driver for the Atmel AHB DMA Controller") Reported-by: Peter Rosin Signed-off-by: Tudor Ambarus Cc: stable@vger.kernel.org Link: https://lore.kernel.org/lkml/13c6c9a2-6db5-c3bf-349b-4c127ad3496a@axentia.se/ --- drivers/dma/at_hdmac.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c index d9f492081e76..c445575f8646 100644 --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c @@ -1963,16 +1963,26 @@ atc_tx_status(struct dma_chan *chan, } /** - * atc_issue_pending - try to finish work + * atc_issue_pending - takes the first transaction descriptor in the pending + * queue and starts the transfer. * @chan: target DMA channel */ static void atc_issue_pending(struct dma_chan *chan) { - struct at_dma_chan *atchan = to_at_dma_chan(chan); + struct at_dma_chan *atchan = to_at_dma_chan(chan); + struct at_desc *desc; + unsigned long flags; dev_vdbg(chan2dev(chan), "issue_pending\n"); - atc_advance_work(atchan); + spin_lock_irqsave(&atchan->lock, flags); + if (atc_chan_is_enabled(atchan) || list_empty(&atchan->queue)) + return spin_unlock_irqrestore(&atchan->lock, flags); + + desc = atc_first_queued(atchan); + list_move_tail(&desc->desc_node, &atchan->active_list); + atc_dostart(atchan, desc); + spin_unlock_irqrestore(&atchan->lock, flags); } /**