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 43FD4C4332F for ; Wed, 15 Dec 2021 11:01:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241930AbhLOLBl (ORCPT ); Wed, 15 Dec 2021 06:01:41 -0500 Received: from esa.microchip.iphmx.com ([68.232.154.123]:23511 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236806AbhLOLBj (ORCPT ); Wed, 15 Dec 2021 06:01:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1639566099; x=1671102099; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XvtFfCx1rLVyUeXpqg4YPLygK1ixJghu3MJP5+44Jns=; b=pwzqVx+7GQPjEG8nXd2tn0a9bk5TInIaTdgDL2kqDhuG8BCzuiF6puXb iCwgmI3+blBxSPVRNBWJMrnJPKraJdZERFteL2ohU0IyrmxBUSNGDh+GG d3TYFUe95GYtRmfuq7gDql9gBBaKaho1lkxwzUaXrfG2nn28npQWjK+pY 4vzzcU8azxylcS/COisAt/Eo4qoVUppl5h6XWtJUKv/zr4LPPgNbWDlhI SEASkkrtTQbTd+HTObcVnqPUSodKpLpYMk2IeuAZ3JAg/tvs9rGYXvLGl Jlo+EZPfibeUf7JEqcbehZpcQnZTPDsPmvmX4KdxBMhB1a+BIiXaJbfU7 A==; IronPort-SDR: Im18tkvGcN0wtb6sizqdmXMoVo4izt4F/wxC+1nfh2QTsEdvS47omxlOVWPdCBeL5gdIgUs9BP 6AsaEWGTwgALAKxF+g0p/wLcmMf5pgcqIitRLvc95SB0hVbt7+DgOIw4T+41oOc/M7+4wloLm6 Uetpkgn68rrD2HJFuC597wQcomV2ib4cZULCDLuAGmjGV+7JEBQIn2SU4qllekuRTaCY3TNZzG tz+oSdFflhBeZ1TgEBBrtVrgeUmHLG0CfFW6C8pQEbFBSoAZKUmuuwpBrvNwkSf8di8fgh9Rqi KMqtx/UEZt9sg8Nc2cokB3S5 X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="142483384" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Dec 2021 04:01:38 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Wed, 15 Dec 2021 04:01:38 -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.2375.17 via Frontend Transport; Wed, 15 Dec 2021 04:01:36 -0700 From: Tudor Ambarus To: CC: , , , , , , Tudor Ambarus Subject: [PATCH v3 07/12] dmaengine: at_xdmac: Fix concurrency over xfers_list Date: Wed, 15 Dec 2021 13:01:10 +0200 Message-ID: <20211215110115.191749-8-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215110115.191749-1-tudor.ambarus@microchip.com> References: <20211215110115.191749-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.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. Since at_xdmac_handle_cyclic() is called from a tasklet, spin_lock_irq is enough to protect from a hard IRQ. 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 b6547f1b5645..eeb03065d484 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) -- 2.25.1 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 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 C06F9C43219 for ; Wed, 15 Dec 2021 11:11:23 +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=ZDA2leCuj6lOF37DCACXlJLp6qWJIbO2irjpUiklZis=; b=D550fgojboeKPD pXO9NyLHEzKosmRQ4KcxlUaGlgFf/1l655Av0hS2hTrqXmUAb4SF+GyvNjcQr61mWrZ3wBh0EBOrg hVDKYH8L4riOGA04eWvw3w540SMNSUbHAaklMltVLZ3Jt522fDDbcWiecHJQ/noEli+K31Mld61UK iJK7haosYsLfu4XAnzVZVCyJ6eGjZnpymCORAaDY0IsL6wQJVDerHhD1IQD5AGjhJEKrl55GjGkhR 0bzV4Z7OlrtcvCY4uj7qq/sayzXJSqJKvpR1NCnZbjfXpw8XW7KYCbXzkC+k1MJMFDmd517VKytfk /zN+gRXI/khJJUFWMt3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxSAR-000QSD-4G; Wed, 15 Dec 2021 11:09:51 +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 1mxS2V-000MDb-9M for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 11:01:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1639566099; x=1671102099; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XvtFfCx1rLVyUeXpqg4YPLygK1ixJghu3MJP5+44Jns=; b=pwzqVx+7GQPjEG8nXd2tn0a9bk5TInIaTdgDL2kqDhuG8BCzuiF6puXb iCwgmI3+blBxSPVRNBWJMrnJPKraJdZERFteL2ohU0IyrmxBUSNGDh+GG d3TYFUe95GYtRmfuq7gDql9gBBaKaho1lkxwzUaXrfG2nn28npQWjK+pY 4vzzcU8azxylcS/COisAt/Eo4qoVUppl5h6XWtJUKv/zr4LPPgNbWDlhI SEASkkrtTQbTd+HTObcVnqPUSodKpLpYMk2IeuAZ3JAg/tvs9rGYXvLGl Jlo+EZPfibeUf7JEqcbehZpcQnZTPDsPmvmX4KdxBMhB1a+BIiXaJbfU7 A==; IronPort-SDR: Im18tkvGcN0wtb6sizqdmXMoVo4izt4F/wxC+1nfh2QTsEdvS47omxlOVWPdCBeL5gdIgUs9BP 6AsaEWGTwgALAKxF+g0p/wLcmMf5pgcqIitRLvc95SB0hVbt7+DgOIw4T+41oOc/M7+4wloLm6 Uetpkgn68rrD2HJFuC597wQcomV2ib4cZULCDLuAGmjGV+7JEBQIn2SU4qllekuRTaCY3TNZzG tz+oSdFflhBeZ1TgEBBrtVrgeUmHLG0CfFW6C8pQEbFBSoAZKUmuuwpBrvNwkSf8di8fgh9Rqi KMqtx/UEZt9sg8Nc2cokB3S5 X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="142483384" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Dec 2021 04:01:38 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Wed, 15 Dec 2021 04:01:38 -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.2375.17 via Frontend Transport; Wed, 15 Dec 2021 04:01:36 -0700 From: Tudor Ambarus To: Subject: [PATCH v3 07/12] dmaengine: at_xdmac: Fix concurrency over xfers_list Date: Wed, 15 Dec 2021 13:01:10 +0200 Message-ID: <20211215110115.191749-8-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215110115.191749-1-tudor.ambarus@microchip.com> References: <20211215110115.191749-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-20211215_030139_467177_FA8D2756 X-CRM114-Status: GOOD ( 10.05 ) 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 , mripard@kernel.org, linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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. Since at_xdmac_handle_cyclic() is called from a tasklet, spin_lock_irq is enough to protect from a hard IRQ. 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 b6547f1b5645..eeb03065d484 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) -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel