Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3972103pxb; Tue, 25 Jan 2022 00:19:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJy7guEDMOPf/4Rpm58AxN+p8ywr0ioXuFPHZ3Ge5CbY4FBy03sde29VrSMHAaLO4gxukG1I X-Received: by 2002:a17:907:72c5:: with SMTP id du5mr15004556ejc.210.1643098780791; Tue, 25 Jan 2022 00:19:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643098780; cv=none; d=google.com; s=arc-20160816; b=N3uRv74SSX78Lnu2HqiMfNxQuLZKte5cFYL/nd95qOqf/K8RI7+uR8h2Ll9mSSf28i q4boJ6wnuLgBO1Ghx3O5UmRA4JiRqWjel1s8qbxCX0dwKq8F9PDOUN3PTOFXLPjDFXsJ NcbIRUa21ge0HhBgvOU+dZMmeH3i0i2OPBKGzzqwHZJsjZjPZy8W3yM4Hoqjeyf5S+RH /QA6BwxRDpuHCSXIOJHWUGRgEgUOc2/o+fsqOEpSxSvA0Ur4sIDdZlRFqOGYVtGJ59xk s3a4z+FbAaeqqmoI9DtoBLtY96n1FMtc29t8Yd8rnUgCB6GffYmqvRNKgb4ruZb9K1xY 1GJw== 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=k4hQDaIc648SLjIrttXvFh8zlqxarSLDF8M03tcz/oA=; b=nlPgAzYwMo3hb075hILbDLX+9rBKfWQLSoGLKh9xcbiVWoPhyhuUUvkDCq1cVNbR4V amPSpKv5wd1QT8DhTfYc/Y7hqGHLCqdOotaNlEszNVSzKZr07kUUQTQlETq96OgEF/ZP RzfUWajrFbJlmU+JidNJJttrGXGhP3zcA299obH0+OrfDniDxPG0jq9LDmLxaKcmt1O7 XGqqZRldUl3OrWDlNrWp11slWGmaC6leCQTrpavGa1jT/nTPrixWgBjWML7YJc4c0iOK X1DUdCgCfJywtbF//+UT0qGgVUhLvNKlHPo14/be/M2nIwHvUVNmgoaifVgyg38PjOnq 7jIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="d/Pv5e3Y"; 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 qb15si8716421ejc.354.2022.01.25.00.19.15; Tue, 25 Jan 2022 00:19:40 -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="d/Pv5e3Y"; 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 S3413355AbiAYAix (ORCPT + 99 others); Mon, 24 Jan 2022 19:38:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2364408AbiAXXsI (ORCPT ); Mon, 24 Jan 2022 18:48:08 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDC81C07E307; Mon, 24 Jan 2022 13:43:08 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id A56BAB8119E; Mon, 24 Jan 2022 21:43:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 138CEC340E4; Mon, 24 Jan 2022 21:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060586; bh=p0y5hJByeFplk5ECbWCT3NibhmV/f6yWSLLTnzSRmkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d/Pv5e3YmPVi8W8EmUqHE1E5vpGZ/YRBtMG3ZjZx0VPKAH44vvBPZOCduwSiNTr3/ GKz+PET6Q0KHY5GC0MAYtuJMvVAM91k7Feo2h4Ko8/0M21VJ8R85tCghsYFcNRCRs+ dZbeCKGx1QTzBLzJSsX2kbwpoNVAqMUfsRg7bweg= 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.16 0997/1039] dmaengine: at_xdmac: Fix concurrency over xfers_list Date: Mon, 24 Jan 2022 19:46:26 +0100 Message-Id: <20220124184158.799631516@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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 @@ -1619,14 +1619,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)