Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3577099pxb; Mon, 24 Jan 2022 12:38:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxvh1xLGQucfD9LxYBPEDG6v/7ywAkJ/bH08npMLw+v/eH8juDGGCrs7hVwH7KC5Sf1wWn X-Received: by 2002:a05:6a00:1693:b0:44c:64a3:d318 with SMTP id k19-20020a056a00169300b0044c64a3d318mr15468943pfc.81.1643056713029; Mon, 24 Jan 2022 12:38:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056713; cv=none; d=google.com; s=arc-20160816; b=JL20dK8rdALHUi4jiyKbHT184FfFERj3wQ6LFVqT8GLk4Y6NXmlLFXTf+RB7kzvs0R 9VTSWgy717D1uFxfbR7v8PA2sG71ZMXgazhPmTYeyLwZC1U38YDtts3jGn5vn34V7rr5 KtRi8IgBlShaVv8YCEy9l7HkjyxdpTJAzZ6geBVzQrwr+wp6b9url2Ap/jjFTGd+xPe7 eZpABDnAaBExWSY63iApfpOG//+3HZKe/NGr8dCPHpNFQkPDKYcHAPZ9zoxKyB7m9n5e D0p3Dg11NpcL/SXCNxguTCU1ers1OyGf5OnwTHfDmJO+gWNs1xt8mZZF3sBpaXbay3kW Xt/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=V5joh4rb0KcQ/9HJYtiVfxjAUcSut7ESFPLrP9p1bwo=; b=I0HiF4c+9eS3xz6Y4CHiygEe9cNdtgB7XZElhar++yxsyEN3OsRIrm+JgjFxXuH//I 8LoP5PJ5F7/ZZPJZt5C42Zu/sHVjSTpuGwmEp98gIsXV56n0jdLRlqTXphMC1lbou0yW JI2uPeWZf/ahEC3Nfxdo+z8u3U8FzDVt0vkaJ2agj2eE3Dz3hC2SfPNNXpwDjyOU6ycq CesupEOwqlmr8bGtgkP7bVVxXYRLQ2ACEYzCpLyYm7okwD0P2wlk36Z1Eha2UOy7EBun H0zooKyL/6xDJ0BvsN4ZOugG5jSQTQK5MegdyUDVlJ5Vo4RRRgT0HooSkfk0+aGp/rIP ZAgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="txNtJGR/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s6si10076127plg.590.2022.01.24.12.38.14; Mon, 24 Jan 2022 12:38:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="txNtJGR/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357521AbiAXTuM (ORCPT + 99 others); Mon, 24 Jan 2022 14:50:12 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:37498 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355098AbiAXTkB (ORCPT ); Mon, 24 Jan 2022 14:40:01 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C2D7D61523; Mon, 24 Jan 2022 19:39:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E309C340E5; Mon, 24 Jan 2022 19:39:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643053199; bh=Jxtv+A1161cRIGR/Gk7IFvyFKod5JdGJGCILTRds53I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=txNtJGR/Epvaq8MkmgwEtWJ6NTHCniCAssO7nTA6Ce2HUgp7b4GdZrwqP0D/7cWmw x19iE08VDaxKLeH76msEOD34MyOpJ+RfYWBTp7v6Es/IyOorMNbZm7tOqRty7zBPwt OMvSav/oUz6bQdGe8JWtJxipwsoGx/BkytyIebxg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tudor Ambarus , Vinod Koul Subject: [PATCH 5.4 307/320] dmaengine: at_xdmac: Fix concurrency over xfers_list Date: Mon, 24 Jan 2022 19:44:51 +0100 Message-Id: <20220124184004.387740545@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tudor Ambarus commit 18deddea9184b62941395889ff7659529c877326 upstream. 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 Link: https://lore.kernel.org/r/20211215110115.191749-8-tudor.ambarus@microchip.com Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- drivers/dma/at_xdmac.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -1564,14 +1564,17 @@ static void at_xdmac_handle_cyclic(struc 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)