From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2DAEC4332F for ; Tue, 14 Nov 2023 12:43:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232468AbjKNMno (ORCPT ); Tue, 14 Nov 2023 07:43:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjKNMnm (ORCPT ); Tue, 14 Nov 2023 07:43:42 -0500 Received: from mail.pcs.gmbh (mail.pcs.gmbh [89.27.162.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AF6F184; Tue, 14 Nov 2023 04:43:37 -0800 (PST) Received: from mail.csna.de (mail.csna.de [89.27.162.50]) by mail.pcs.gmbh with ESMTPA ; Tue, 14 Nov 2023 13:22:06 +0100 Received: from EXCHANGE2019.pcs.ditec.de (mail.pcs.com [89.27.162.5]) by mail.csna.de with ESMTPSA (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256) ; Tue, 14 Nov 2023 13:22:06 +0100 Received: from EXCHANGE2019.pcs.ditec.de (192.168.8.214) by EXCHANGE2019.pcs.ditec.de (192.168.8.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Tue, 14 Nov 2023 13:22:06 +0100 Received: from lxtpfaff.pcs.ditec.de (192.168.9.96) by EXCHANGE2019.pcs.ditec.de (192.168.8.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42 via Frontend Transport; Tue, 14 Nov 2023 13:22:06 +0100 Date: Tue, 14 Nov 2023 13:22:06 +0100 From: Thomas Pfaff To: , CC: , , , , Subject: [PATCH RFC 1/2 stable-6.1] dmaengine: at_hdmac: get next dma transfer from the right list Message-ID: <15c92c2f-71e7-f4fd-b90b-412ab53e5a25@pcs.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-KSE-ServerInfo: EXCHANGE2019.pcs.ditec.de, 9 X-KSE-AntiSpam-Interceptor-Info: white sender email list X-KSE-AttachmentFiltering-Interceptor-Info: protection disabled X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 14.11.2023 10:04:00 X-KSE-BulkMessagesFiltering-Scan-Result: protection disabled Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Pfaff In kernel 6.1, atc_advance_work and atc_handle_error are checking for the next dma transfer inside active list, but the descriptor is taken from the queue instead. Signed-off-by: Thomas Pfaff --- diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c index 858bd64f1313..68c1bfbefc5c 100644 --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c @@ -490,6 +490,27 @@ atc_chain_complete(struct at_dma_chan *atchan, struct at_desc *desc) } } +/** + * atc_start_next - start next pending transaction if any + * @atchan: channel where the transaction ended + * + * Called with atchan->lock held + */ +static void atc_start_next(struct at_dma_chan *atchan) +{ + struct at_desc *desc = NULL; + + if (!list_empty(&atchan->active_list)) + desc = atc_first_active(atchan); + else if (!list_empty(&atchan->queue)) { + desc = atc_first_queued(atchan); + list_move_tail(&desc->desc_node, &atchan->active_list); + } + + if (desc) + atc_dostart(atchan, desc); +} + /** * atc_advance_work - at the end of a transaction, move forward * @atchan: channel where the transaction ended @@ -513,11 +534,7 @@ static void atc_advance_work(struct at_dma_chan *atchan) /* advance work */ spin_lock_irqsave(&atchan->lock, flags); - if (!list_empty(&atchan->active_list)) { - desc = atc_first_queued(atchan); - list_move_tail(&desc->desc_node, &atchan->active_list); - atc_dostart(atchan, desc); - } + atc_start_next(atchan); spin_unlock_irqrestore(&atchan->lock, flags); } @@ -529,7 +546,6 @@ 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; @@ -543,11 +559,7 @@ static void atc_handle_error(struct at_dma_chan *atchan) list_del_init(&bad_desc->desc_node); /* Try to restart the controller */ - if (!list_empty(&atchan->active_list)) { - desc = atc_first_queued(atchan); - list_move_tail(&desc->desc_node, &atchan->active_list); - atc_dostart(atchan, desc); - } + atc_start_next(atchan); /* * KERN_CRITICAL may seem harsh, but since this only happens