From patchwork Tue Nov 16 11:20:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12692746 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 464B8C433EF for ; Tue, 16 Nov 2021 11:28:44 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1D9D461994 for ; Tue, 16 Nov 2021 11:28:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1D9D461994 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=ZIOwGUo8nRugvN pQb5cOp0E2X9wu4QHnIMTlCKZUebiq0mSwsXxnfLRR3h+cHDhj77zcnfXiApkDbfgZKSvrSugLlVu 9BWW8xxCFAaNz5nBN1Wn7NtvsLAYL5WQ1vAoY6NrpQNUfbPmvmGRO0uluIFNgpScXJu2Ui3p+4jra ypZg+I105vdgVDMdQaYK6orhdHBgT4/rDpkJMuWmTJEerTc75nv9iNVpeNbUvVHfyQhqycitJtQFW 8pBfK5/NMHFLF+RhydsGbAQTKpUGjijOjSycSt81Fysg4pPL9rdxP5ODe4OiilQNutVJftcBh3nHQ Ue7Ivbdn2+dKO8UYkv2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmwcH-001QDz-Vm; Tue, 16 Nov 2021 11:27:10 +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 1mmwWZ-001O7b-Oq for linux-arm-kernel@lists.infradead.org; Tue, 16 Nov 2021 11:21:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1637061675; x=1668597675; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K/FEmA4LkPsJngFC8rtp+wxmQUsyLjyVWQASV+7XuoM=; b=binCnOH02brXwUpsm6Zq9tdIFYVuflJvxBMr3APOk5IGYba9a3Z0KrL0 t0Puc5ekhLOAXTDkK1TpjN2l7HE57pItesjEcPiA2AhPCSeaSyyhrs9Oz vu46j7rXzm+vvZELiyuBA7CQkksBH1j+xxLMbVQKxvHVQ2wU4ilcoTLXb jFPtUWj3YDcts3HlaxR/i7CZp4kMkLdrHcqM1qf81byxPitM8CzJOWa7Q 6GKX8gYrrvlSXQTEMtJfKyenBzl2fyaNGidfkLAd8o8ANyrPiMmBTMMiq dohtTsl2a2oFWnktTjgV+KKj5kMXBVMuoSri4wFj3nbT8qOIlfbkil/3/ A==; IronPort-SDR: 5I2Vtcxo1XNNrl5JKRV9Iz2lWjTf+jEudImraPfg9kfTsmk9Gq7BpbHvQWy8Z76ZizoLZC3vZg BTGwli5YolnlP5P8j2XexhEXs6jh126hdPMjF/YfFzSBYv7O9/IYKm8QZhheb2mNtSo7qIzepI uGgKLlma30lWyEE+YiRlCY3Aj7rc0Z0V17CK3GDQBzM2niE0PCJkK6kq75eTlQsZo7rLEh8ZOI /Gr8YAacR+NXlJAbFzulHwa1LeroQuar2AXH6L9I4Bsy/tOMAubQSpE+HRiHi9X8q8NKuKtoNt R8xnXSG44ai+VvlgIeZKpKym X-IronPort-AV: E=Sophos;i="5.87,239,1631602800"; d="scan'208";a="144082911" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 16 Nov 2021 04:21:14 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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; Tue, 16 Nov 2021 04:21:14 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 16 Nov 2021 04:21:11 -0700 From: Tudor Ambarus To: , , , , Subject: [PATCH 09/13] dmaengine: at_xdmac: Fix concurrency over xfers_list Date: Tue, 16 Nov 2021 13:20:32 +0200 Message-ID: <20211116112036.96349-10-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211116112036.96349-1-tudor.ambarus@microchip.com> References: <20211116112036.96349-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-20211116_032115_858433_AC7C2936 X-CRM114-Status: UNSURE ( 9.14 ) 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)