From patchwork Tue Oct 25 09:02:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 13018834 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 2F3FFC38A2D for ; Tue, 25 Oct 2022 09:11:29 +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=4V9vBr8Tk7JaCtOEDYm02/MXiJ5H5PiA7hUMaSOHn08=; b=kZrMTi7YHfWiZi 6AlIXSuZIkwvUdBxDpwpK1T65AE7YFsTexGpGnKUHHuh7bffNEYUkYd35PEXblFs6izy+5NvJ1U2Y TaSw5cOXHRNB30Kt3ULENs9Zyv35BHII2N7Jup8b2FpGpLaGr3M1Dxo1m8be8giXsSWvbWcaeVWH4 Cc7rZbOul6qRpASA064umiCvQ+sLqob2e6aznwjlvZYsJ9EvegCaDUccUftEUlMiPRho/1F4TWjyr 31FvG+6kMPAHamDBBh2bVJL+Ud/x1peYcEjMnu+0oooy4ZP+hntAKumDQ9DFDiiEsPx4U5aAn0TP3 sttycn77Cxgz6hAi7X+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1onFwr-004SZP-3q; Tue, 25 Oct 2022 09:10:13 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1onFql-004POC-41 for linux-arm-kernel@lists.infradead.org; Tue, 25 Oct 2022 09:03:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1666688634; x=1698224634; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Mnc0LDzNnye3Pe9OLiPnC3vdVr+IETqhaLn7lpRl7MU=; b=yojwudRVf5y1cvzj4uL7u2B/8KBkjF1Gvy9M1atkwL13GMvPnZpwXshD iJPzkdJiK7JfL2Wo4hDZRR9RWsbCi9rUt5ZGhuPv2g5uFVgVI4SAVXM7Y C9Ay1RocpXAnXywfP2I7V/3Epr7OHEn8C5kkeJKjjH9lqhYfJ9ALRZOEu kU51R4ZqvmaP3sommycf8GWNRIcR1ZAtsQHPAK+dcFcnYaMR/MaaSxH2k fko1KmM1bmJzP1pdTUmXdN9/HX9ZUt7eGcXLvYaK0qIlx9sQhr+a1d35F Z1MCJ9Q42pY3mj3Otrx68Z4orqIbHKP/9IVDa0d3Xc7bQwS7N461znuwj g==; X-IronPort-AV: E=Sophos;i="5.95,211,1661842800"; d="scan'208";a="196910067" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 Oct 2022 02:03:54 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Tue, 25 Oct 2022 02:03:45 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Tue, 25 Oct 2022 02:03:43 -0700 From: Tudor Ambarus To: , , Subject: [PATCH v2 11/32] dmaengine: at_hdmac: Fix descriptor handling when issuing it to hardware Date: Tue, 25 Oct 2022 12:02:45 +0300 Message-ID: <20221025090306.297886-12-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221025090306.297886-1-tudor.ambarus@microchip.com> References: <20221025090306.297886-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-20221025_020355_188095_D63368DD X-CRM114-Status: GOOD ( 11.96 ) 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 , maciej.sosnowski@intel.com, linux-kernel@vger.kernel.org, mripard@kernel.org, linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, stable@vger.kernel.org, torfl6749@gmail.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org As it was before, the descriptor was issued to the hardware without adding it to the active (issued) list. This could result in a completion of other descriptor, or/and in the descriptor never being completed. 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 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c index b53a9fc15dd9..9e5a30396c1c 100644 --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c @@ -510,8 +510,11 @@ static void atc_advance_work(struct at_dma_chan *atchan) /* advance work */ spin_lock_irqsave(&atchan->lock, flags); - if (!list_empty(&atchan->active_list)) - atc_dostart(atchan, atc_first_active(atchan)); + if (!list_empty(&atchan->active_list)) { + desc = atc_first_queued(atchan); + list_move_tail(&desc->desc_node, &atchan->active_list); + atc_dostart(atchan, desc); + } spin_unlock_irqrestore(&atchan->lock, flags); } @@ -523,6 +526,7 @@ static void atc_advance_work(struct at_dma_chan *atchan) static void atc_handle_error(struct at_dma_chan *atchan) { struct at_desc *bad_desc; + struct at_desc *desc; struct at_desc *child; unsigned long flags; @@ -540,8 +544,11 @@ static void atc_handle_error(struct at_dma_chan *atchan) list_splice_init(&atchan->queue, atchan->active_list.prev); /* Try to restart the controller */ - if (!list_empty(&atchan->active_list)) - atc_dostart(atchan, atc_first_active(atchan)); + if (!list_empty(&atchan->active_list)) { + desc = atc_first_queued(atchan); + list_move_tail(&desc->desc_node, &atchan->active_list); + atc_dostart(atchan, desc); + } /* * KERN_CRITICAL may seem harsh, but since this only happens