From patchwork Thu Nov 25 09:00:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12693614 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 D2465C433F5 for ; Thu, 25 Nov 2021 09:05:32 +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=q2MF0NprM1U9bB5Oy2Iu+k0x2RNBMzu+W7svuw8j0h8=; b=KfGkMP72A8ejzO vPGOylA0TQ+MtYxIDlAUU3hL518682zpu0VdZTpHCbOApMgiOkHCaMeNzQwXtQJD26JfkAktJcJ7+ aUe2xpq7NDfXJ8mUl6r8JpZN6x+bXCGt0Zskx13qntIbEfNgRYgAr1vvc7FNHMg+X8f3TXjCkjwR7 ys92WatM08IYeRwZeJmeqhfsLKUiU3XaJSczZz0wIPopl7RlsqspuKvzclTtG/LUYkurqEt50rSyQ yvXEdc+eUZKuLDMKqv71evkH6Yl7IbuUbW3FRJtSHQsgKC7kx7pt2UT6UNosi8bOKncHwFdB2FMST OzZFkVUyzGWOVJkZjSNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqAfd-006ovX-U7; Thu, 25 Nov 2021 09:03:58 +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 1mqAcq-006nZO-E0 for linux-arm-kernel@lists.infradead.org; Thu, 25 Nov 2021 09:01:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1637830864; x=1669366864; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K/FEmA4LkPsJngFC8rtp+wxmQUsyLjyVWQASV+7XuoM=; b=cDRP4N1sn5iKMldWHv1Uu+lxhB9TBX02uAfYnDWju0QfYUcKaT+yacia iQQtsTOO3mUj8mh4UvllMsh81Frc8DOUNhT+mAkmC+uhhyAYY114+9T4k FsAVzXHeQ62k5S5GyS9sLu4W+utfIiQ6gRHAMmRLvUrgIH+6MznTLw4Iz 9+i51F92TjAlfvsYpbb1zKGZyWA4h8AadyIrOYfOQQOI165ooCuNvhXYQ Yf0LG7givg7fuw51voTYfelMxHXdxx48a6+RA6lBhuq9ngP82l9vE9vz/ lL2rjRYHskDESb7HS3QdM7/XZexejkRXPJLjQp7IKZEnm0pyrlQNR6oJp g==; IronPort-SDR: /+Gs0Dgw9sHQuGHVwu3hC6fRTgebf3/L3vAinrlLIXXexeY7pTImM19FOcI7TjxTtCqdewv+lp 7C0hKLW5Zr1XR/7tHfhqHY9aGW0CmZYYfzdeWlsXiaX13gxp3FflOwlwsIXcNcXWtXvRPd4CWF pxaVYUvf84C1JjoI3IzNr5/eAtO9uZrNRrZHLHK7xGRpiMOf/LpxlK1gRy3VMcvV9J7U/8s8OV lIx7420ve58kKdQ4DhcOyzuaX7x6UpQtvowWNjzRVNp0O3XbweGAD2/j7Czo1vqUyRlTQZJE/f qKceAEhpQ2MZGFvE7lzp6JcZ X-IronPort-AV: E=Sophos;i="5.87,262,1631602800"; d="scan'208";a="145121934" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 Nov 2021 02:01:03 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) 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.2176.14; Thu, 25 Nov 2021 02:01:02 -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.2176.14 via Frontend Transport; Thu, 25 Nov 2021 02:00:59 -0700 From: Tudor Ambarus To: , , , , Subject: [PATCH v2 09/13] dmaengine: at_xdmac: Fix concurrency over xfers_list Date: Thu, 25 Nov 2021 11:00:24 +0200 Message-ID: <20211125090028.786832-10-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211125090028.786832-1-tudor.ambarus@microchip.com> References: <20211125090028.786832-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-20211125_010104_542698_2A639801 X-CRM114-Status: UNSURE ( 9.71 ) X-CRM114-Notice: Please train this message. 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: alexandre.belloni@bootlin.com, Tudor Ambarus , mripard@kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, dmaengine@vger.kernel.org, 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 Since tx_submit can be called from a hard irq, xfers_list must be protected with a lock to avoid concurency on the list's elements. Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver") Signed-off-by: Tudor Ambarus --- drivers/dma/at_xdmac.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index 8804a86a9bcc..81f6f1357dcb 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -1608,14 +1608,17 @@ static void at_xdmac_handle_cyclic(struct at_xdmac_chan *atchan) struct at_xdmac_desc *desc; struct dma_async_tx_descriptor *txd; - if (!list_empty(&atchan->xfers_list)) { - desc = list_first_entry(&atchan->xfers_list, - struct at_xdmac_desc, xfer_node); - txd = &desc->tx_dma_desc; - - if (txd->flags & DMA_PREP_INTERRUPT) - dmaengine_desc_get_callback_invoke(txd, NULL); + spin_lock_irq(&atchan->lock); + if (list_empty(&atchan->xfers_list)) { + spin_unlock_irq(&atchan->lock); + return; } + desc = list_first_entry(&atchan->xfers_list, struct at_xdmac_desc, + xfer_node); + spin_unlock_irq(&atchan->lock); + txd = &desc->tx_dma_desc; + if (txd->flags & DMA_PREP_INTERRUPT) + dmaengine_desc_get_callback_invoke(txd, NULL); } static void at_xdmac_handle_error(struct at_xdmac_chan *atchan)