From patchwork Thu Nov 25 09:00:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12693606 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 84F29C433EF for ; Thu, 25 Nov 2021 09:02:41 +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=A/ZkAnfoIAvl/eN22MFa+mfh95lQO/b8OcP1T3HtugE=; b=f13+aBDcFiZ7MF lWyeNO9UzdEjuqkxnXNkVB1++Leup9j3WS6+9WKtohhFriymN2lpdQIS9aR4L8wyTz8/9AdgN16aV W08033stkD33q9qd21RocNbHpqVqmEJ10JKyxSu14B87N4014EoATXj7DNkAIihS7Hdi9Vn6HeM3M jyVZ/273Y4y8sxcuuPyJjdlQtQMsvJZ8BhxlrKH+6MRbcDSY3MrLqMNnoDek6QLydffAo7Owo1bes 0V4kWJpx5aUc8L0z11EG20pLgNO258TwqPuo1FAlYqJDLxRjLcpKrxB9EYChOD0cNRXzqiZkk1iQG mBZGE+6UOGXzLc9V9Lfg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqAcc-006nVl-Ca; Thu, 25 Nov 2021 09:00:50 +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 1mqAcS-006nUH-CO for linux-arm-kernel@lists.infradead.org; Thu, 25 Nov 2021 09:00:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1637830840; x=1669366840; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wegADxIWSHuMAOObITo7ccUCJ8XjO9VrO3nutuF9azU=; b=IddQff5nzIzIYt2MGx3iR0T6IQcenBdLV3Db9uYNiLf5VnS1tfpghEHB jsrwaUDQe3AIzEPo6xQjxH+IdpajGyJFD/YCZ2tfVG5BCtS5BTfQd9GPs HnNJOiOJkeSHv34bHJjWg5ZvCZmkezozExfowruO4vmcrr1mOrtiaSGd6 EPqGpo7I+CNct6UvL9VFSPLow1Yys9t5UYh7SylMSRIdQjIjMELK81zlT v/tpDKFwiuFLqGS2DziNfjmI+Z8Bs0Y+54K14d5/xrby3i2Z9vv+fRHWl ka6lfqDqCfvqoPJKdvEO2CH0VJmPMhDR56CzL8DH42XZPzX5j3rUDrNqA w==; IronPort-SDR: coeHxv+G7dVW9oV0lE43DmnhXnDqzzmr3cmn6ZJEif15+SwtjIVT1I/ffKpmx0Hn4wQr0+Saum 5vZ+6ddqNasZQEcLslbMBhfWgP5uUPeUNyql89chGXWPDvjl7VUV36XGcDWBPT736MOQjmEhTm f8txXdQkRpTvrC+kSQ0JTV9o0NUOU8VJR5OyVym1JXWET8CB0aTSHHEgrtGdpF9FzMI2tocviK xoKmMIJQHsORMORxZQ95xH6X030N29DvWaGHLno+XH990LXVWatlyd5Z9m1cGp2RJiuxvvl7lR MwX9O8yFJuvWD4vR5fXBjAK/ X-IronPort-AV: E=Sophos;i="5.87,262,1631602800"; d="scan'208";a="77555990" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 Nov 2021 02:00:36 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) 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:00:36 -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:33 -0700 From: Tudor Ambarus To: , , , , Subject: [PATCH v2 01/13] dmaengine: at_xdmac: Don't start transactions at tx_submit level Date: Thu, 25 Nov 2021 11:00:16 +0200 Message-ID: <20211125090028.786832-2-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_010040_526994_563AC20F X-CRM114-Status: UNSURE ( 9.22 ) 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 tx_submit is supposed to push the current transaction descriptor to a pending queue, waiting for issue_pending() to be called. issue_pending() must start the transfer, not tx_submit(). As the at_xdmac_start_xfer() is now called only from at_xdmac_advance_work() when !at_xdmac_chan_is_enabled(), the at_xdmac_chan_is_enabled() check is no longer needed in at_xdmac_start_xfer(), thus remove it. Clients of at_xdmac that assume that tx_submit() starts the transfer must be updated and call dma_async_issue_pending() if they miss to call it (one example is atmel_serial). Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver") Signed-off-by: Tudor Ambarus --- drivers/dma/at_xdmac.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index 275a76f188ae..ccf796a3b9f3 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -385,9 +385,6 @@ static void at_xdmac_start_xfer(struct at_xdmac_chan *atchan, dev_vdbg(chan2dev(&atchan->chan), "%s: desc 0x%p\n", __func__, first); - if (at_xdmac_chan_is_enabled(atchan)) - return; - /* Set transfer as active to not try to start it again. */ first->active_xfer = true; @@ -479,9 +476,6 @@ static dma_cookie_t at_xdmac_tx_submit(struct dma_async_tx_descriptor *tx) dev_vdbg(chan2dev(tx->chan), "%s: atchan 0x%p, add desc 0x%p to xfers_list\n", __func__, atchan, desc); list_add_tail(&desc->xfer_node, &atchan->xfers_list); - if (list_is_singular(&atchan->xfers_list)) - at_xdmac_start_xfer(atchan, desc); - spin_unlock_irqrestore(&atchan->lock, irqflags); return cookie; } From patchwork Thu Nov 25 09:00:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12693607 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 91619C433FE for ; Thu, 25 Nov 2021 09:02:41 +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=kX898B9WHUzE5+OxAM+igQvrvp6n8o2pNAoOU9kV/Fw=; b=OXJ7Y/IRgad4o2 m1XmrbnSGSy8b/y7UcJ6WyS2NrUmItUxI+/pGmL4H9NedC/G5sRWC4sOfTwIKGL2F0HPUzYBeEfyG MIP/M4CZwAirVqi2iwvv9v3o1ABnTzBzHfRuQ1scM2TsrMdYK6v/wKy+UQSSdxI99PmPKl0qmySrZ XKOE/C9PWSNbLJst8U6w6vwBGCFyeOuFj61fuAhAU3CBbs1dEj+Q6pmj+8zj0LlhUi7qNPuyMAuEO si7d1jWc0QdAy+5tJRqn8ZVrcOsvgLgcuSew0G5VQYhM/fiPAlJBPrnh0H5UsG2fYvKvAlA8gRAyJ qWC0/Sx3tXWYibzleAYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqAcn-006nXt-5Q; Thu, 25 Nov 2021 09:01:02 +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 1mqAcW-006nUH-An for linux-arm-kernel@lists.infradead.org; Thu, 25 Nov 2021 09:00:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1637830844; x=1669366844; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Cg+xZ2PGt65To32w9HMZeNhhilFG7R1i38Kj7UwqKts=; b=ow/WyPEzFq/14/+hhp7KniNt+ZYEag5yU+ca3On+oER5+8jzxI2vxWQJ ZKJVkZLNU1LANWOpRZFYnZMkerURtXcNVJeLylt9kX7fVBbku+Tjz71KF idZlOOuzKzZu8nN5vlxiechGSPhQvNQkEYfoB2gQDy5aHAkJ71uPnpDbg C5SjyiU6dyBIWZ7kEqFK2AU7sUJu21PUCZdcsU4RxcmW4AzIQYJpF2PcF sSHut1PEkkBHMYzDzi9TD2CuhvZPvpezoXYA9xgOcBqCKKvWdPt91rERL r6TOJe1g7Bfq48r25N51SBu0eykdNMCsQ4OfR+SrUSvYtJQuFaJyREJv8 w==; IronPort-SDR: ycMZcZFHklBLfUpbzfagNyY871FwnJuGLro2l3NwuVGfKQ21ArXcGJPOMXYGUNjkwv2U6mcoWD 4cKp7ifp7p0UsAy/bblivdSHVY/db7uj4IAggSwPkmpgg1d9yrrPZBoFoOduNMvm3g+Cp5b5W3 9SllRejbN+S6i9npKYvaZyH4gcvpstGqvOiaNhL3ZwwgVWycpZrRzVeTiW5Id6YIlszh9OSzZh FOY+cdI0XpAqxFA12BvASBmTENM+TWKVzKSJN3/ae0r5BBpXwYtkNUnSkdR8hjYYN2tiiD1nUY nwQl/jnuUZSljrjA7AX7I42j X-IronPort-AV: E=Sophos;i="5.87,262,1631602800"; d="scan'208";a="77556012" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 Nov 2021 02:00:43 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) 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:00:39 -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:36 -0700 From: Tudor Ambarus To: , , , , Subject: [PATCH v2 02/13] tty: serial: atmel: Check return code of dmaengine_submit() Date: Thu, 25 Nov 2021 11:00:17 +0200 Message-ID: <20211125090028.786832-3-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_010044_456807_E3DD0824 X-CRM114-Status: GOOD ( 10.97 ) 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 The tx_submit() method of struct dma_async_tx_descriptor is entitled to do sanity checks and return errors if encountered. It's not the case for the DMA controller drivers that this client is using (at_h/xdmac), because they currently don't do sanity checks and always return a positive cookie at tx_submit() method. In case the controller drivers will implement sanity checks and return errors, print a message so that the client will be informed that something went wrong at tx_submit() level. Fixes: 08f738be88bb ("serial: at91: add tx dma support") Signed-off-by: Tudor Ambarus Acked-by: Richard Genoud --- drivers/tty/serial/atmel_serial.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 2c99a47a2535..376f7a9c2868 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -1004,6 +1004,11 @@ static void atmel_tx_dma(struct uart_port *port) desc->callback = atmel_complete_tx_dma; desc->callback_param = atmel_port; atmel_port->cookie_tx = dmaengine_submit(desc); + if (dma_submit_error(atmel_port->cookie_tx)) { + dev_err(port->dev, "dma_submit_error %d\n", + atmel_port->cookie_tx); + return; + } } if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) @@ -1258,6 +1263,11 @@ static int atmel_prepare_rx_dma(struct uart_port *port) desc->callback_param = port; atmel_port->desc_rx = desc; atmel_port->cookie_rx = dmaengine_submit(desc); + if (dma_submit_error(atmel_port->cookie_rx)) { + dev_err(port->dev, "dma_submit_error %d\n", + atmel_port->cookie_rx); + goto chan_err; + } return 0; From patchwork Thu Nov 25 09:00:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12693608 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 89D47C4332F for ; Thu, 25 Nov 2021 09:02:50 +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=o/R6X8F92BMOjrIWLbfWHht1JvnPcuUCMzK/H+lrVMs=; b=fwXpTlpoNzzzbO Xs+g8QxEP4Wf6ZCKHUOW9lZnaWnjStfHUVHJCxyY/SDZvsEKkJFZ5+vvH9LXbRgbaFF8L2Qlaw1Uq jpupi7QZ5U030Cs4QbmH6g5yWH52KGCGEjVn1kc2pjyDcGDzHotSGopf2HWN9nSxz68ZfDis0Vr6l esY/KZNyE1lmYz4OPuJ87WetwTIG5eRQ3mQkXl6hjqQznNKb5vVo6kDpMjsd6Lu5H9GWqdgX/wV8A ymhLe6aWYa98JphOYrxT67+Fp5YYn1i0wskhabUM0P4tFmzlsCna2NUPtY/B9873h9bq1IjEkJNwM ST0lww1Oe5oUza3Ymwtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqAd0-006naz-L1; Thu, 25 Nov 2021 09:01:14 +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 1mqAcY-006nVH-Pd for linux-arm-kernel@lists.infradead.org; Thu, 25 Nov 2021 09:00:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1637830846; x=1669366846; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CIM45Syj4kYFKQaSN/c1s5pHZ3uPQK0krZOBDew05DM=; b=O46lbanNL958YrKfYF02PQzb2lk7fKRNVprYEyl9RgTQbPvinn/0Sxbf Pqgc7+kqANVnBlDspz8j124LUzNXXT9NZ+V96bSpbVkRnYXfptr9rH6Qv FtVcoOHc87Z7pep5GEwPmwUKAYkKRAFp7vVEUKzltY3CxJ8ZsBqIkyWuD 1s8zzvyFSLF50KRVSP8PoU6zWgELUFEZeo1msUuE965cvQUWF/FnoZAN0 q40VxvYKPvhl4Q6P5horMXuHgl1pCEAImYZ/FsAivUA81I+o0etxRB37D 0w9t5qw16iGyiTzZprE8SJRFaF25vsx4xg58btLm3HVMZ547KEejfeWow g==; IronPort-SDR: Nxij3NzZqEF/71SN6wh8X6Zq5Wz54ngQptptk6TV745XvJ67XxLVRSGtoMWyEBrhn9zO+UKsTj MDXQ5xUbIPhz692e5yi3NGOtFMkEWv66y7S15mqsKUJxciYmusrFm6P0tP9DhA4lzP3EBq6PYP FgKmtAgo5atTQJQy66FuaBli7sTX7sIZL3dvVgTFChBcP6b1xdz/ORMMhzMGqhYVZk2LTX/aqR gTUvpU+Su7wfGrcHT9jB5O8oqyrxV92OKOrlUrQOmWcEYd/JkjdQM/16vGz08zOWL3uO1P1u4x sQBArGZkb8DjD+rZvOTsZCXA X-IronPort-AV: E=Sophos;i="5.87,262,1631602800"; d="scan'208";a="137700238" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 Nov 2021 02:00:45 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) 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:00:43 -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:40 -0700 From: Tudor Ambarus To: , , , , Subject: [PATCH v2 03/13] tty: serial: atmel: Call dma_async_issue_pending() Date: Thu, 25 Nov 2021 11:00:18 +0200 Message-ID: <20211125090028.786832-4-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_010046_919349_E0092C30 X-CRM114-Status: UNSURE ( 9.33 ) 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 The driver wrongly assummed that tx_submit() will start the transfer, which is not the case, now that the at_xdmac driver is fixed. tx_submit is supposed to push the current transaction descriptor to a pending queue, waiting for issue_pending to be called. issue_pending must start the transfer, not tx_submit. Fixes: 34df42f59a60 ("serial: at91: add rx dma support") Fixes: 08f738be88bb ("serial: at91: add tx dma support") Signed-off-by: Tudor Ambarus --- drivers/tty/serial/atmel_serial.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 376f7a9c2868..269b4500e9e7 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -1009,6 +1009,8 @@ static void atmel_tx_dma(struct uart_port *port) atmel_port->cookie_tx); return; } + + dma_async_issue_pending(chan); } if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) @@ -1269,6 +1271,8 @@ static int atmel_prepare_rx_dma(struct uart_port *port) goto chan_err; } + dma_async_issue_pending(atmel_port->chan_rx); + return 0; chan_err: From patchwork Thu Nov 25 09:00:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12693609 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 C4701C433F5 for ; Thu, 25 Nov 2021 09:03:04 +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=Zym63QIe8R0rE4skIlkNGbWDStkjQnWpJogefB0xFnw=; b=UXp8gN5xJhhHD+ E9tBADJGOeUPnh3/veZEM0ulfLEyFvjQCjV68hVRv8cn+BYgbSOsoym7x14lZzFXtP9VoYClh/hrF 3ko/RkMGRCaw8/07Guc5jy6ELM71TtV6HLVES4wza8Rx8ri7WBttqn6v+/WoVTnn+fJrSSXPUvmox w/hU8pQAoiqUM4bhf9scDfBwzgYoIN1jSqcOSjiBg16wqb1f7Sk8sa/iJb7nLYPyC1OvM05/NuWSt 6h3a82K7guhJzQzSHZbijLU2+u3NxsN0T0rOADt5l1zkKdXU3JqB8PpI9IYa/6Tq4lB1+ix8dVkpz euwo0XVSmoaZ9v+bsmow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqAdF-006nfJ-Tt; Thu, 25 Nov 2021 09:01:30 +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 1mqAcd-006nW4-Ca for linux-arm-kernel@lists.infradead.org; Thu, 25 Nov 2021 09:00:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1637830851; x=1669366851; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tVeVzCqLqbVxX1jH3+OLNjcxNS2IlcvbF+cf1Wql48c=; b=vnbyhKdwQzLOBeGu6tHb2FvRgiXTZthbhqunbnrNJnfeyYU4ESMVxa/l cHc13jKw9TbDlfP7ismVuDFrK4STFJalEnZK3VLHr3RUTWOOx85XrARp7 W55yUpmOmD25pqi4E8UO/sa2F4ZX7QMG3+xpO75/kMFnlR8uStYzx6vOL Pf9gNe7g/4Jxn/VcBV1PY6kh+a8bkGf4iqoGhqPJUV6hKI1WYFo0T8Xoz xQXy9yu4yrI2jTfF8KVvbB9lVP0RVap835DAJSqah03A6j1cZpDMSB0qc eSYNu/d9JWwFijRmW/V6KEKe4flsl3UGercY+VWKk68SXPKg8Zzga7Jfh Q==; IronPort-SDR: wwdNLaSeDwc3uZjrbnVoHjfv6c3saIjn6b2PUPy/Jnh+fPFqY5h0ByCAKWbZCuT5EsXsayUO1I 2GGDGUbInNcUfliVF6ouY3j7BfHii7/GUxarWU7rrSmf4ExD44lLakQQOSLY95oZE03GLN1tTp X9wq/I6V+gWnXfrQF7WagYn3lmKmgYqQpitsIwEn87d7EylYbgMKnWo72FP7vvUmqEFgEQ78Rl KLi/sCU0wEx5BpdnvKPTyjsE7PvE0NaaZEMCqsVSEcMvIHSdYusGV25Qenxw4a4+bD4KHHeYKK pc+Eoq4Gu0+MAgBfipR4aScO X-IronPort-AV: E=Sophos;i="5.87,262,1631602800"; d="scan'208";a="77556049" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 Nov 2021 02:00:50 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) 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:00:46 -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:43 -0700 From: Tudor Ambarus To: , , , , Subject: [PATCH v2 04/13] dmaengine: at_xdmac: Start transfer for cyclic channels in issue_pending Date: Thu, 25 Nov 2021 11:00:19 +0200 Message-ID: <20211125090028.786832-5-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_010051_517394_F444AB4C X-CRM114-Status: UNSURE ( 8.90 ) 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 Cyclic channels must too call issue_pending in order to start a transfer. This wrongly worked before, because in the past the transfer was started at tx_submit level when only a desc in the transfer list. Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver") Signed-off-by: Tudor Ambarus --- drivers/dma/at_xdmac.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index ccf796a3b9f3..9a5c68eda801 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -1778,11 +1778,9 @@ static void at_xdmac_issue_pending(struct dma_chan *chan) dev_dbg(chan2dev(&atchan->chan), "%s\n", __func__); - if (!at_xdmac_chan_is_cyclic(atchan)) { - spin_lock_irqsave(&atchan->lock, flags); - at_xdmac_advance_work(atchan); - spin_unlock_irqrestore(&atchan->lock, flags); - } + spin_lock_irqsave(&atchan->lock, flags); + at_xdmac_advance_work(atchan); + spin_unlock_irqrestore(&atchan->lock, flags); return; } From patchwork Thu Nov 25 09:00:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12693610 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 DC031C433F5 for ; Thu, 25 Nov 2021 09:03:36 +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=PsxRuWijv+jPT6/T7gvmFmzJT08/iW7aY+2wZ7G6drA=; b=jQplorzuY1a1h3 MHK7c96QQ9e0kkf7DAu0dnlNjDshOSkO1IYhIiyQiLv+LkrW0E86y+GeYwDEjBr7aE2VCWtSrDG1p kTa0VWodDrOSeqWDGY+4zntab59uQ9a4SgQwIJugOvde0qZiqxLEqVY0VjrcWdB9E2tYdPyegFecm NkZSE79v0TWbY+AOZFGWYTA95gu5oKLD89OEhSgwE4eMR4GmKHtc2EKujzkvcLl0SFxDOS5Nw7hzM AL5DRODl8SQzjqX9aJEsaayLCY8Qz1Iy6EbIdN5H2i0Q9hstgwohDZfx/FyMOYpm5b919PvaoOp5d cRh1QWxVWj8aYj4KoguQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqAdg-006npL-IX; Thu, 25 Nov 2021 09:01:57 +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 1mqAcg-006nWb-Os for linux-arm-kernel@lists.infradead.org; Thu, 25 Nov 2021 09:00:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1637830854; x=1669366854; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e0xW+vtVjmLjsFf+6NA01ekbm3ImpiahvMaEB+GwpuM=; b=ZldaVVH5Nz70+EHwPGNmXhgcOjgYrQMsH9nz0h1sZV9+VEr8khPKEiHG 2FGQNXdcY7uEIO5te7Tp6ZiYxt8gkyG+2fhoaU7390RZgGD1n/1U/HXY5 MEavvmySLyLxnaDhCqrNyGmj3zcf+miA/F6+VzAgMwNT7KMWeNLHe7Ty2 XQeGJHyfdOK5wqsdEzGMabFpqor9K4lQu08sUnLu0X9Vyp9Y7tumBvvZZ 6n/gsWDpxSdH9UiKTlwx2sVK+1Qric/a6kHqKYzehSvuZG9plthiEkrX9 eyr3HoXEkUvA2PaCtYLqEzJulMsde6kAzYD6dU9p0cSg6fj7QOL1WVhNm w==; IronPort-SDR: n2gujLM5LqrbMg+iNdjizYWaI56rI1O50LpeIETyYLJLYx8ZxrC8hw5GSoEylWEKLjmVeYZpMj LN4aVJIW0+YyjMk4wA8so92TIBNkl4L8x198mG5ye097qhVYRk9gDgj9quGI81pRese9Vt1/tt Dw1P6jpUvG/Ww7eHAbCk5J5fRrUMoePjCClMGoAbJghu+Vd4i9pd83Ec/z/+D96hdbNToEBB3E qNZ2xLGnhQdpanuv9IySo6+RJJT3sD+0Tre3DZ4+4ueIa11u4wrA+RN13SMTDnij/hdGsdOfn/ WOw80xeX1V56nLvbnw0UkvFp X-IronPort-AV: E=Sophos;i="5.87,262,1631602800"; d="scan'208";a="145121879" 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:00:50 -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:00:49 -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:46 -0700 From: Tudor Ambarus To: , , , , Subject: [PATCH v2 05/13] dmaengine: at_xdmac: Print debug message after realeasing the lock Date: Thu, 25 Nov 2021 11:00:20 +0200 Message-ID: <20211125090028.786832-6-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_010054_847752_E9E915FB X-CRM114-Status: UNSURE ( 8.73 ) 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 It is desirable to do the prints without the lock held if possible. Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver") Signed-off-by: Tudor Ambarus --- drivers/dma/at_xdmac.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index 9a5c68eda801..b45ae4fee9db 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -473,10 +473,12 @@ static dma_cookie_t at_xdmac_tx_submit(struct dma_async_tx_descriptor *tx) spin_lock_irqsave(&atchan->lock, irqflags); cookie = dma_cookie_assign(tx); - dev_vdbg(chan2dev(tx->chan), "%s: atchan 0x%p, add desc 0x%p to xfers_list\n", - __func__, atchan, desc); list_add_tail(&desc->xfer_node, &atchan->xfers_list); spin_unlock_irqrestore(&atchan->lock, irqflags); + + dev_vdbg(chan2dev(tx->chan), "%s: atchan 0x%p, add desc 0x%p to xfers_list\n", + __func__, atchan, desc); + return cookie; } From patchwork Thu Nov 25 09:00:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12693611 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 76194C433EF for ; Thu, 25 Nov 2021 09:03:49 +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=1mliFfovJFwTLsApY/NQA1jJ24Uzh7I38fWW9lfdg+I=; b=ygovBXu6pR4ISk ktQWQXcGloC7DAvCjMBGAPVV7J2muUZXq48J5BrAhTqn4lNoyGnnTFDG3JdwuTOJDWdRrJJotJnaX SDc+PdCRmMYJP3g4U6UiII1pZ85WcoOW+8mCCE44GU1kUzfwQCJPjc77Oo7WcsXvTx4GdqdKJzDsL ZiUV5m+k5OPRSGgzXXl+wtj8twx8iUyejWz0iVb/kG1m1p7rBnOnsiZN4KeZKE7LyFzXC2oVFa615 0qS5QyDhzmzOZQ2c97qKlYXwe76QWgZAaa7klDfHJNqQn3XhSEB7c08Ju2ZpIMzoeIfVEpDmsms9j 9j2cZFKgFfuISi1phrfw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqAdz-006nyK-OP; Thu, 25 Nov 2021 09:02:16 +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 1mqAci-006nX0-Nq for linux-arm-kernel@lists.infradead.org; Thu, 25 Nov 2021 09:00:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1637830856; x=1669366856; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5xHR1pSMET19iq1R2ORya7V1yqiD9c113vKBUFK5yTw=; b=L4XZg4gAll3zuMPyDJ06ZnHtJxvFEVGjd/WjdWb1a3uz+NLcK2QB2m+Z PfFXPEqdRhXIxPVJc+glmBTg6/RspTiWpVlfzWk6dUhxXxWFuI9xhXQzQ JvhtcOKiougplFy1RLowd0hQQJdze8rnfDEANfSB5yRHNWGqPhcMfnXud zCPYRi8rUw6x2xHqWrypZxDYmzAGUKbmBhR8I6WoyP4l/8Is7K2lYWH5C GC7lR8NlVuEME/QTF3UUTr7Xzz1dzqMsNwXQLQzM0XtCGyI+4EXBYlSB/ yPHgSXFEQTBBDJ4xYe50Tqhg6R3bW8aa2+vPlqyHNSp7PY/sNRXRpN22f w==; IronPort-SDR: dabU9dLW4qKDsvn0Eu1nLS3EMTV2WJ8SGT4eW+YHLq5VlzssreaOrMSiNYjP6itM5nM9hNAHXi EkcIksnJwTGYNEFRpJQrBNJ4fV616j5fx6NFntyZ91Oa81DYvOg3aFn0EO4wRlyMigujI0Z7fN Fj/RqCNwlAJBFyNLaeVNZEPIreAB3tVM7Of/QTzzvBSHfPbx3RsxuwjdOH9ZHYRwdP+TRoYJ5q k4qGHL+3eVYMg5uVi6o/dJeyyqgO1/l2U7PwJHyFnVFgPK1ur6dgc5f9NLEnDE/uKxeMsxwt8K aW/E7pTXPORs5JIfMIA0+Z5R X-IronPort-AV: E=Sophos;i="5.87,262,1631602800"; d="scan'208";a="137700269" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 Nov 2021 02:00:52 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) 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.2176.14; Thu, 25 Nov 2021 02:00:53 -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:50 -0700 From: Tudor Ambarus To: , , , , Subject: [PATCH v2 06/13] dmaengine: at_xdmac: Fix concurrency over chan's completed_cookie Date: Thu, 25 Nov 2021 11:00:21 +0200 Message-ID: <20211125090028.786832-7-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_010056_860763_0E3C40AF X-CRM114-Status: UNSURE ( 8.40 ) 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 Caller of dma_cookie_complete is expected to hold a lock to prevent concurrency over the channel's completed cookie marker. Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver") Signed-off-by: Tudor Ambarus --- drivers/dma/at_xdmac.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index b45ae4fee9db..4d8476845c20 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -1703,11 +1703,10 @@ static void at_xdmac_tasklet(struct tasklet_struct *t) } txd = &desc->tx_dma_desc; - + dma_cookie_complete(txd); at_xdmac_remove_xfer(atchan, desc); spin_unlock_irq(&atchan->lock); - dma_cookie_complete(txd); if (txd->flags & DMA_PREP_INTERRUPT) dmaengine_desc_get_callback_invoke(txd, NULL); From patchwork Thu Nov 25 09:00:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12693612 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 87C9BC433F5 for ; Thu, 25 Nov 2021 09:04:29 +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=0QGipSseqlCcver/r9x6xhnrFWkj2qbW75kvey7kBTU=; b=x/abe0ofXKOJfH y+vHGQBsvfsQ6CIWVzXRfWB0nyxW7zNXEwH1JzNuWs/1Xjdi8tQTZ4WVV5Oy0FudXvBnku5P8tWun dFIdoEMxDBHmfzkGKt2w63RrEoVsTMgR+FZsz7rLaAteMMgWMK5qGVPBiR8IjVLOBBR5tYq58JTF4 kSzc+pfA9KWO1d7kxJdVDWDgWXIieiuB+J7uXVSiAgUN6uxwDVLRjmQtt2JAXBp3YeOo5kHkzLAT8 54BQM+iA2QSQU+7B1pTDmfMi2A+eGz2PcMQZzKCMcJWCQN6n3WVIQ1bRrJjK1TodAK766SfkRWztF t2gzyxQvNRh1Crbu/aVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqAed-006oI0-CS; Thu, 25 Nov 2021 09:02:55 +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 1mqAck-006nXI-16 for linux-arm-kernel@lists.infradead.org; Thu, 25 Nov 2021 09:00:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1637830858; x=1669366858; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IzKN39oOHNC3CK9tz3WGrvZQjLqHyTGav61lvPMp9Bg=; b=Tsp90S7DtqNipbH/+p0uxNVwkwR+Xq4hAHjcLlntoV9A3d86buQuqa/5 QpvOvpwqi3RZhM69iRpI0wBnZKJiMPL/BdKVQaff4kIPTRcFkOorw4GAd tJYUvUoQXv5YjDoaCkSbsrRQcH1yVR782atLuSn+xImhl37f/VctmTlo2 0VPCCE5fgeACkMVDAznGn8YHrbKe2BqmV0KEdOgAh/qLWQmlXZu4vczMO i/XwQ0Wai6nXjYTdMk9DJppGUvtrmgFeaLlWGOzMTdObqzYcPMS2U+1U7 cWGKLWf5lbI8wLFAEr++bjFxmZc3YchfYTyoCVmc4sCo/YiQMZdE7e02I g==; IronPort-SDR: vyPr1F2plqj76Swh6q75SBov6E1446XVpQoxgAr6KVcsSSMUVDV0RqXySK++sRL7JGYf0+aGjq 2o6whjre3LV6WsdWDLsfwRGCeHz4oYPU/nnW+IB4sdckhZKALJ3Rn56yJ0NnXmf3FBm590PWUT qHO15mWufasiiOjjK6cInrkIryIu1a5M1Rsj6Q+e8qUrL1/4M6r4qWuNE3Tefoh8+QHasaaRTN 7gVzs61Djc38Op06+HUttKCmNNfjC9mmFCFUbtNpAdW4D2yxjgEdNOEal8e7AkPZ8sBu1bFLFa zIBIaiJsWx9U+3QIORpQ9cwf X-IronPort-AV: E=Sophos;i="5.87,262,1631602800"; d="scan'208";a="144534247" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 Nov 2021 02:00:57 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) 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.2176.14; Thu, 25 Nov 2021 02:00:56 -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:53 -0700 From: Tudor Ambarus To: , , , , Subject: [PATCH v2 07/13] dmaengine: at_xdmac: Fix race for the tx desc callback Date: Thu, 25 Nov 2021 11:00:22 +0200 Message-ID: <20211125090028.786832-8-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_010058_138536_8CEB61C5 X-CRM114-Status: GOOD ( 10.28 ) 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 The transfer descriptors were wrongly moved to the free descriptors list before calling the tx desc callback. As the DMA engine drivers drop any locks before calling the callback function, txd could be taken again, resulting in its callback called prematurely. Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver") Signed-off-by: Tudor Ambarus --- drivers/dma/at_xdmac.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index 4d8476845c20..2cc9af222681 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -1582,20 +1582,6 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie, return ret; } -/* Call must be protected by lock. */ -static void at_xdmac_remove_xfer(struct at_xdmac_chan *atchan, - struct at_xdmac_desc *desc) -{ - dev_dbg(chan2dev(&atchan->chan), "%s: desc 0x%p\n", __func__, desc); - - /* - * Remove the transfer from the transfer list then move the transfer - * descriptors into the free descriptors list. - */ - list_del(&desc->xfer_node); - list_splice_init(&desc->descs_list, &atchan->free_descs_list); -} - static void at_xdmac_advance_work(struct at_xdmac_chan *atchan) { struct at_xdmac_desc *desc; @@ -1704,7 +1690,8 @@ static void at_xdmac_tasklet(struct tasklet_struct *t) txd = &desc->tx_dma_desc; dma_cookie_complete(txd); - at_xdmac_remove_xfer(atchan, desc); + /* Remove the transfer from the transfer list. */ + list_del(&desc->xfer_node); spin_unlock_irq(&atchan->lock); if (txd->flags & DMA_PREP_INTERRUPT) @@ -1713,6 +1700,8 @@ static void at_xdmac_tasklet(struct tasklet_struct *t) dma_run_dependencies(txd); spin_lock_irq(&atchan->lock); + /* Move the xfer descriptors into the free descriptors list. */ + list_splice_init(&desc->descs_list, &atchan->free_descs_list); at_xdmac_advance_work(atchan); spin_unlock_irq(&atchan->lock); } @@ -1859,8 +1848,10 @@ static int at_xdmac_device_terminate_all(struct dma_chan *chan) cpu_relax(); /* Cancel all pending transfers. */ - list_for_each_entry_safe(desc, _desc, &atchan->xfers_list, xfer_node) - at_xdmac_remove_xfer(atchan, desc); + list_for_each_entry_safe(desc, _desc, &atchan->xfers_list, xfer_node) { + list_del(&desc->xfer_node); + list_splice_init(&desc->descs_list, &atchan->free_descs_list); + } clear_bit(AT_XDMAC_CHAN_IS_PAUSED, &atchan->status); clear_bit(AT_XDMAC_CHAN_IS_CYCLIC, &atchan->status); From patchwork Thu Nov 25 09:00:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12693613 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 C3829C433EF for ; Thu, 25 Nov 2021 09:05:13 +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=rPHK7PrqzTen9Gk9sAInxIJvYbANx3oSgRecaoM1boQ=; b=GcMAxWMjPmpvRu 1lpKTAHJZ1xm9RExF5TV/V+rUF7KDzWhxsAAKsRpiKxWG5gD41gp6Za3wvfpSs6gn86GdLjrT1Nzg up+jOsvYJldZxPxuhk1aGxKR1Gzm41B7Th+Afw2UcJhEUqOgcrWVUy7m6+0ulOJ7anW35T+tnNIlL nCdYNHZWEGQGOwpiu4m1SzI+It93OzyRRPFjn47Wc7A8mG5ulcT6r7YeqNbQNvUIaXFFE6iNMxhR5 +QMiLbAacnCuB/piPos+OdtT6+0izkp28KTYfDhtPlKxXE8cVupba8tgBP7jO+BCqsHtDYODNnZrW YlOlVDp0j4Sl2m+aqaow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqAfB-006odV-3l; Thu, 25 Nov 2021 09:03:29 +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 1mqAco-006nXI-MI for linux-arm-kernel@lists.infradead.org; Thu, 25 Nov 2021 09:01:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1637830863; x=1669366863; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nuxqXU7uniwAlyc6jwMoADsVym2af+0HTfirATPA/GM=; b=M1Cln4hGeoj36lPEmmsS5IRAmBvJaPx+165qRNs8es4AqIL7g6uXvKUz j07J7VbfYPsp5MsPeFN47zgPGWtI6AOsCjakHfmBnJbWdN8IrBy9H/9Nq AFQ5mdxQfzVu1A5XxCeUDhcKeDyUm0Drkuv7W4TrAxWgE3KvCyROQUbti VWkeqK4PHGEg2TKNeeemN0EbxoNHldoOP7s16Zul/nZrRltojaiqj7tEj ipOtAlneykl7tVz+II8s6jJt1tbNoUABO96+Pdvh1qgsSH7kMBC09cIko LzoZ9G1xY6t8I8ttGAWZ5znImMKp6Be4dFDplrVpiS9yRUXoSfUBYW2tn w==; IronPort-SDR: +uerOeXV8bj+0gQ+9JOh+w5wh8uzTJguwAtWP/v4VJjgnBqUOQNEgJuBFAvYgHGfX9w9e7d/Mc XniK3hBz6VGEBnTRqrox8c1gYANjZbwJHpfAX6BusXot/8VM7YkiXINOsKjheLyQk5xYjMa0qg hOtONQFp0WIUlm+A98wpPBHkdV1HKR5Z9tAvc703FwxlymWYXLqDfJv6iNdAMFauJhndecyPKc 0BBw+hdOGhMCJiWztIpbe+1gMMPwwySoyOGrqUhKhROtJSeHsrJeW4IkNU8iEf2KW7AKmLEsK4 S9ajYuTp1g2Fg1NaMzxoturi X-IronPort-AV: E=Sophos;i="5.87,262,1631602800"; d="scan'208";a="144534265" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 Nov 2021 02:01:01 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) 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.2176.14; Thu, 25 Nov 2021 02:00:59 -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:56 -0700 From: Tudor Ambarus To: , , , , Subject: [PATCH v2 08/13] dmaengine: at_xdmac: Move the free desc to the tail of the desc list Date: Thu, 25 Nov 2021 11:00:23 +0200 Message-ID: <20211125090028.786832-9-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_010102_837528_A87A6FA1 X-CRM114-Status: UNSURE ( 9.81 ) 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 So that we don't use the same desc over and over again. Signed-off-by: Tudor Ambarus --- drivers/dma/at_xdmac.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index 2cc9af222681..8804a86a9bcc 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -729,7 +729,8 @@ at_xdmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, if (!desc) { dev_err(chan2dev(chan), "can't get descriptor\n"); if (first) - list_splice_init(&first->descs_list, &atchan->free_descs_list); + list_splice_tail_init(&first->descs_list, + &atchan->free_descs_list); goto spin_unlock; } @@ -817,7 +818,8 @@ at_xdmac_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr, if (!desc) { dev_err(chan2dev(chan), "can't get descriptor\n"); if (first) - list_splice_init(&first->descs_list, &atchan->free_descs_list); + list_splice_tail_init(&first->descs_list, + &atchan->free_descs_list); spin_unlock_irqrestore(&atchan->lock, irqflags); return NULL; } @@ -1051,8 +1053,8 @@ at_xdmac_prep_interleaved(struct dma_chan *chan, src_addr, dst_addr, xt, chunk); if (!desc) { - list_splice_init(&first->descs_list, - &atchan->free_descs_list); + list_splice_tail_init(&first->descs_list, + &atchan->free_descs_list); return NULL; } @@ -1132,7 +1134,8 @@ at_xdmac_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, if (!desc) { dev_err(chan2dev(chan), "can't get descriptor\n"); if (first) - list_splice_init(&first->descs_list, &atchan->free_descs_list); + list_splice_tail_init(&first->descs_list, + &atchan->free_descs_list); return NULL; } @@ -1308,8 +1311,8 @@ at_xdmac_prep_dma_memset_sg(struct dma_chan *chan, struct scatterlist *sgl, sg_dma_len(sg), value); if (!desc && first) - list_splice_init(&first->descs_list, - &atchan->free_descs_list); + list_splice_tail_init(&first->descs_list, + &atchan->free_descs_list); if (!first) first = desc; @@ -1701,7 +1704,8 @@ static void at_xdmac_tasklet(struct tasklet_struct *t) spin_lock_irq(&atchan->lock); /* Move the xfer descriptors into the free descriptors list. */ - list_splice_init(&desc->descs_list, &atchan->free_descs_list); + list_splice_tail_init(&desc->descs_list, + &atchan->free_descs_list); at_xdmac_advance_work(atchan); spin_unlock_irq(&atchan->lock); } @@ -1850,7 +1854,8 @@ static int at_xdmac_device_terminate_all(struct dma_chan *chan) /* Cancel all pending transfers. */ list_for_each_entry_safe(desc, _desc, &atchan->xfers_list, xfer_node) { list_del(&desc->xfer_node); - list_splice_init(&desc->descs_list, &atchan->free_descs_list); + list_splice_tail_init(&desc->descs_list, + &atchan->free_descs_list); } clear_bit(AT_XDMAC_CHAN_IS_PAUSED, &atchan->status); 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) From patchwork Thu Nov 25 09:00:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12693615 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 DD2B0C433F5 for ; Thu, 25 Nov 2021 09:05:56 +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=Q4o5zMilcdgbs44Hx6dC/oiQwDOhxPzgg1LLSBLZazY=; b=tlJlK2CtacaK2r 8+90q4P+rfIqng3uh0X49Hq7ya6Sz2o/tLpPHYstU8pj10GdHHUa3nZH7oo9msbjxdcC63dUmac1J nsacOZzoKpOuJlaXIp5Br0Ywv8F93ptDvlaYtzOqizaQx/EGCrZVWzPtrxl5zfzAcWlxQrwRm688o GMOE6CVfPRu2BBBvYpysh/QEjYoNiG2N16X/m/sKZalV9baXl/FTRuwzCOKEFCPW+fxazRXpJhi3w 9nG4S7HKW2Y9ntQQgky7oWZou2dyl9YoWwMbsT/ZbV1rM7KGNj/jpchvWhn031uEvBprKS6oQ+uoC 0sFB6nkDra9j+DVfs9iA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqAfz-006p5K-2v; Thu, 25 Nov 2021 09:04:19 +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 1mqAcv-006naI-BM for linux-arm-kernel@lists.infradead.org; Thu, 25 Nov 2021 09:01:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1637830869; x=1669366869; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4UJToV8z1d1CSnT1DHee/do0TBGgvnsbC5y36KVHVoA=; b=HuCTD1BWrxLQkkjL5/JwOfEwA7qGVHnyQl6B/H3V76gfpaR/+GjsBAoJ QGnxTzmjB1Wg2ZnJI2iQ9NDbMWAh1KkCVRTKBtID74J+l8SasRkgJFMB7 ZE7i+RQsim2DlTGoyVr5DVZc26gRNLjAnXV63aLNXR2mRoo4bFPUzyxk+ XJ324K1MVUnSOUq27PbSlgYoytU5p0+cte9vzygsByVZscfANbap462Le XICVFsjpoVKYizZribiWF9l5HqWb62CQAJzugqRE0IxtaTevWnJt1cJ9B yFsZ1Q2P5IvBBZ1/PkW5uzwmplEsrliq+nuy5fftrJPzawdDbXSTSIDhH A==; IronPort-SDR: WtWwMmOjNZxfcvdh3RCLq++kbEcQo/nEclD5cbDkIS/rCBD81CYk07CWQWQnYDaeE7KAvwaogk mNEFVHTP5jgj2uVEJXtkdhgg8Cgn8NKv8uVPEuqsQQuFHknCi+DaVl6BB9OwMAKZ4rwwy+/4NX wqTNoln0JRUWkwOgmhymkTqfM8WHBCjZAZGtungScl7mzEXfIZMU7eACsYEdMURGJeLFDtEgpr 8m5k9/vnBZSPebapgEyRuocQns36LyoMI872X3LPs/i2Nzs+LuYLdUVIpW4vJOY3E1+RnyWNZu xHUUqFkH+5WG/kQH4HuCi11k X-IronPort-AV: E=Sophos;i="5.87,262,1631602800"; d="scan'208";a="77556153" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 Nov 2021 02:01:08 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) 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:06 -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:01:03 -0700 From: Tudor Ambarus To: , , , , Subject: [PATCH v2 10/13] dmaengine: at_xdmac: Remove a level of indentation in at_xdmac_advance_work() Date: Thu, 25 Nov 2021 11:00:25 +0200 Message-ID: <20211125090028.786832-11-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_010109_484584_2BF3A0FB X-CRM114-Status: GOOD ( 10.21 ) 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 It's easier to read code with fewer levels of indentation. Signed-off-by: Tudor Ambarus --- drivers/dma/at_xdmac.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index 81f6f1357dcb..89d0fc229d68 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -1593,14 +1593,14 @@ static void at_xdmac_advance_work(struct at_xdmac_chan *atchan) * If channel is enabled, do nothing, advance_work will be triggered * after the interruption. */ - if (!at_xdmac_chan_is_enabled(atchan) && !list_empty(&atchan->xfers_list)) { - desc = list_first_entry(&atchan->xfers_list, - struct at_xdmac_desc, - xfer_node); - dev_vdbg(chan2dev(&atchan->chan), "%s: desc 0x%p\n", __func__, desc); - if (!desc->active_xfer) - at_xdmac_start_xfer(atchan, desc); - } + if (at_xdmac_chan_is_enabled(atchan) || list_empty(&atchan->xfers_list)) + return; + + desc = list_first_entry(&atchan->xfers_list, struct at_xdmac_desc, + xfer_node); + dev_vdbg(chan2dev(&atchan->chan), "%s: desc 0x%p\n", __func__, desc); + if (!desc->active_xfer) + at_xdmac_start_xfer(atchan, desc); } static void at_xdmac_handle_cyclic(struct at_xdmac_chan *atchan) From patchwork Thu Nov 25 09:00:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12693616 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 03F5EC433EF for ; Thu, 25 Nov 2021 09:06:24 +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=SFUyZW0xWB7CVKdgm0nyb/aGSxWhF8b6IavVOejbwTs=; b=mnBw4uS7tcRlo8 VrHH82G9TgSGNMHTekEbH3nCJm+1lcRkjYc+hpU2dn5wtIvLeM+o3WB8+kY7ha2ayDPRWouw8VhN4 HlhkjAR/aLVkaLG3saYvaJnUWuaIrKLts30FSnGa7ICgaAJKXfDFF6ky93KdnzDv6IerFhhw+Xh67 XCetiN1SrFzHY1QDbekhSURY34Gmug1x1CwWFk7B/lVD3/1W8DRI6DcWbs+iPxqJyaig1o/UZwxyj VjKCNx/B3wNtbOiZEbR2t9zmFWXTI2fvz+kmX6FIU1e7+krIDI1bsMptTXB7GOyvldbVlYNtuzaMK PZLvrVBScr/NYqtsrwOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqAgP-006pK4-Bs; Thu, 25 Nov 2021 09:04:45 +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 1mqAd2-006nbn-IR for linux-arm-kernel@lists.infradead.org; Thu, 25 Nov 2021 09:01:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1637830876; x=1669366876; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WIpbBPu+LDILnDfRZxv4mO7fUQqnAghfChRhfJnCk4s=; b=iPiRmHIgft2ri8SLuK3BrKZCbxAUW4zNGBfNfRcwJ00x4CErLzrI5cCP NM/nnpyxdcgxqa69b/an5y8fG6O8r3rr+EklnTbPZP/JwGy+w/JCpvm4B Xp5x+Rx3+lIcGI+viNpGXVC9NCSC6GqyiO7qaEnOGHpE/hKXtdSMx4YAl y70wafsT3P1Wyi24Su96JeE++1sBeBlN9qT40xWTx3V9j7Bag7YsrLXZF 9zR8P9T+PYzrd949eNFs+4zjSxZJTSMBz7QY91Jq6iySTtbA35FmTDBa8 0aQIe4hLUngnOQFttu4B0OQQugZERVsvqSrTEqPKfqBA2tu9NMlJUkAgN A==; IronPort-SDR: //kzR0pxn4N+VaD4Z8z0EdlDuYPhJSoF+S51vq0dm61RulaDTUFU4DZ2M3n6uwUkjBLxkuQvrf /SFK4yBtSs9DmwvBjTOk3+iWlDTFnWGmqWqIjxPJ/102XWMRWen4iT2MwGKyGKKGaRKVOYLten kBagW/bMEoQHSPD2oGoHAm3NtEPZSFJ6zFeM4f4a+R8SwiZBasovecpAqyG42HljyaxdgF+Hlm oCWw22YhU98WeUncsC9t6fd/LJOG8UJWNh1Gf+UOg8u8DLwXyhRKRt3aJsPsUQGgeJREEqRILc wS1DPhpoYz/mbhftS3cK6oTc X-IronPort-AV: E=Sophos;i="5.87,262,1631602800"; d="scan'208";a="144534284" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 Nov 2021 02:01:16 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) 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.2176.14; Thu, 25 Nov 2021 02:01:09 -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:01:06 -0700 From: Tudor Ambarus To: , , , , Subject: [PATCH v2 11/13] dmaengine: at_xdmac: Fix lld view setting Date: Thu, 25 Nov 2021 11:00:26 +0200 Message-ID: <20211125090028.786832-12-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_010116_647445_42F6CD3C X-CRM114-Status: UNSURE ( 9.79 ) 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 AT_XDMAC_CNDC_NDVIEW_NDV3 was set even for AT_XDMAC_MBR_UBC_NDV2, because of the wrong bit handling. Fix it. Fixes: ee0fe35c8dcd ("dmaengine: xdmac: Handle descriptor's view 3 registers") Signed-off-by: Tudor Ambarus --- drivers/dma/at_xdmac.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index 89d0fc229d68..ba2fe383fa5e 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -99,6 +99,7 @@ #define AT_XDMAC_CNDC_NDE (0x1 << 0) /* Channel x Next Descriptor Enable */ #define AT_XDMAC_CNDC_NDSUP (0x1 << 1) /* Channel x Next Descriptor Source Update */ #define AT_XDMAC_CNDC_NDDUP (0x1 << 2) /* Channel x Next Descriptor Destination Update */ +#define AT_XDMAC_CNDC_NDVIEW_MASK GENMASK(28, 27) #define AT_XDMAC_CNDC_NDVIEW_NDV0 (0x0 << 3) /* Channel x Next Descriptor View 0 */ #define AT_XDMAC_CNDC_NDVIEW_NDV1 (0x1 << 3) /* Channel x Next Descriptor View 1 */ #define AT_XDMAC_CNDC_NDVIEW_NDV2 (0x2 << 3) /* Channel x Next Descriptor View 2 */ @@ -402,7 +403,8 @@ static void at_xdmac_start_xfer(struct at_xdmac_chan *atchan, */ if (at_xdmac_chan_is_cyclic(atchan)) reg = AT_XDMAC_CNDC_NDVIEW_NDV1; - else if (first->lld.mbr_ubc & AT_XDMAC_MBR_UBC_NDV3) + else if ((first->lld.mbr_ubc & + AT_XDMAC_CNDC_NDVIEW_MASK) == AT_XDMAC_MBR_UBC_NDV3) reg = AT_XDMAC_CNDC_NDVIEW_NDV3; else reg = AT_XDMAC_CNDC_NDVIEW_NDV2; From patchwork Thu Nov 25 09:00:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12693617 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 643D7C433EF for ; Thu, 25 Nov 2021 09:07:00 +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=ee0aRvyNh2VU8/EqbpQxRrUedoi7v8RbA3Q19/IUhSk=; b=aoRfsg1xwmkYix g0ZM5eFETDka6ivxPCN6dxUl8il8wbkUDfDWofvLh4EtMWPYi5rXLPs/TCgVBRrJHhfgzco5uDa9F J44/NrEubr/ZRt6NseC5ahk1DLxM2zGjsjDYsJxtAr9Ult5g3bnoDWeWGzqUd5vJrlv/SYY5PjgHW 9HjPIoJZzXY8O+k7azb1eLr3gs1ezGH7QBxGUukcG2CQy7KhU29YKwGPTtcy5HAhksFh8sNz4TBjn m68/CZYZ9XDQFFaWmlAa/inan5v9QOJFG5ERS0hOD5A+Sm7bd31Wte4gUzvadkiuSQOKomBzQ2SBV vIiCnjlUihSbmvjIwHww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqAgw-006paj-CZ; Thu, 25 Nov 2021 09:05:18 +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 1mqAd5-006nca-I6 for linux-arm-kernel@lists.infradead.org; Thu, 25 Nov 2021 09:01:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1637830879; x=1669366879; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9cKQ8DLE+KtiJG/oBAobTtHTIQZeH+YXTokO734xUTw=; b=fzstjMVja644ShY6NaVbb5EMNPr6NtbxOsK2J9Yj1DK9a71sjBCu77eF RCK8NUmVKhJ5hF3t/S4dzR1wMp94JrW6q99q8D40Kr9DmJ2LXxl2+lqEe 1KWOgg6/umycm1EWF3EUPhHEe9rMtaVe1M+CtmAc6hM5TcUr3Z9p5vEM2 Mpqe1BgBogjNV8I+2XCnaIM3bF0bWO1DhnEUlljroYO2QwzVoena/OmJc Cj8U2/sODNWl9ljMaIMH9RAuYjbXo9nIa+O0joxHzIiGbSms5o8R/EkF6 HqzxkBrGqq74G/8+KxmoqGbYLdadxLDGtP6tRD73vIOT/xWArxz0SfT3A g==; IronPort-SDR: 8RpuItzUzgBGSz62CVpx1t3SlmyO1GkX7itwoz5juWqkyE5KxOQ9iXD8gpZjPVLM3y5HAGDrjK ou1VIP/l7Qr8fVuNltE/2wSy+L7dJKZXcZ/E7hpCuZZzneaVgD6d2/CAf8mdsyPm34fUfXXI6Z kdDh0D5KW7mVXXBS9veTrLe/BKg+SvZ7Ap3u2oW21avM5NVCSoBRSXYM8RyoznxllF9E8P4xKu BER4oLZQA6vAYszZx4bHd9eEdE21HLhyORnkynKBy/KIHknBGo0U5LxHdfgdAzJcJ6kVcir68D 4TJZX1HIi2xkda7m4cwxHd9h X-IronPort-AV: E=Sophos;i="5.87,262,1631602800"; d="scan'208";a="145122004" 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:18 -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:13 -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:01:10 -0700 From: Tudor Ambarus To: , , , , Subject: [PATCH v2 12/13] dmaengine: at_xdmac: Fix at_xdmac_lld struct definition Date: Thu, 25 Nov 2021 11:00:27 +0200 Message-ID: <20211125090028.786832-13-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_010119_638086_019F4F72 X-CRM114-Status: UNSURE ( 8.20 ) 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 The hardware channel next descriptor view structure contains just fields of 32 bits, while dma_addr_t can be of type u64 or u32 depending on CONFIG_ARCH_DMA_ADDR_T_64BIT. Force u32 to comply with what the hardware expects. Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver") Signed-off-by: Tudor Ambarus --- drivers/dma/at_xdmac.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index ba2fe383fa5e..ccd6ddb12b83 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -253,15 +253,15 @@ struct at_xdmac { /* Linked List Descriptor */ struct at_xdmac_lld { - dma_addr_t mbr_nda; /* Next Descriptor Member */ - u32 mbr_ubc; /* Microblock Control Member */ - dma_addr_t mbr_sa; /* Source Address Member */ - dma_addr_t mbr_da; /* Destination Address Member */ - u32 mbr_cfg; /* Configuration Register */ - u32 mbr_bc; /* Block Control Register */ - u32 mbr_ds; /* Data Stride Register */ - u32 mbr_sus; /* Source Microblock Stride Register */ - u32 mbr_dus; /* Destination Microblock Stride Register */ + u32 mbr_nda; /* Next Descriptor Member */ + u32 mbr_ubc; /* Microblock Control Member */ + u32 mbr_sa; /* Source Address Member */ + u32 mbr_da; /* Destination Address Member */ + u32 mbr_cfg; /* Configuration Register */ + u32 mbr_bc; /* Block Control Register */ + u32 mbr_ds; /* Data Stride Register */ + u32 mbr_sus; /* Source Microblock Stride Register */ + u32 mbr_dus; /* Destination Microblock Stride Register */ }; /* 64-bit alignment needed to update CNDA and CUBC registers in an atomic way. */ From patchwork Thu Nov 25 09:00:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12693618 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 9F057C433F5 for ; Thu, 25 Nov 2021 09:07:52 +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=+KUn9uhX6OutMGSiDOzvSymbFDT3/1h7VocqKUhWxkE=; b=FleO1HJIi24K0B 6PpNx9B28lONOkWs5GbIObKPXOXDycoyKb3Gb4mnA6Jd32zOeZ02jHs07I2TQ77bnLkxODbr8hjtm KP1swy3Xswe5+h4/DN/seXXBiKkiJ1+FYsyMCx9qkeH/W6jk7szEAxtDzVWmh+TP08kkqhkabz2jb DuNpjfNRpleIKpb2XP29/MNDFs54XcEQDS3QXxlc0cEROto5F5NNJiy3ydRr3qB/phVVPIhjq7Jla KcxUcUIEGTzOGZ4aMUKgZS1PdrYo8GpHN4/K4VRASdfg9mmnqMqCJdjh944TCD35UEflRBK8vHekA qlBTF19XaRDbkAT0cvhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqAha-006psy-6l; Thu, 25 Nov 2021 09:05:59 +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 1mqAd7-006nca-W0 for linux-arm-kernel@lists.infradead.org; Thu, 25 Nov 2021 09:01:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1637830881; x=1669366881; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wxTxrAyDEObrB+6U2ISe3JfymaOVc1XxubqpmlFsG4s=; b=AHAEaKjFtLAcD0VfYmT8MFDRWDFswNEChR1ZvL1ckj9pcAvz7v64+hNW ngLR7p1o1dlYsaqZVYfZA0Y8xHtvU40618ozElcW4hjrUoVMLdPy+iY8p snKBfilTIZt4+6KTvQPG+RZyTHO52TbGnje31umz5xhY5zCbs3D3k/rAe MQsB2UZF7KEkSwho/UoNUB5sWTAdTGcHC0mG3Q3CQu4V52SjeUXuK74oZ GF0Pu7/iA6pI+i8monTQsPAZ+wo5britYqJMH739+r0mKJhsla11OsJlN aevUBWFpIsbj9fu6lVhpf4Cye40lFYQvwWZ2VfQZiF3o4YhsXagWgHIZ5 g==; IronPort-SDR: Nu8AhUwcC4Ratr26yIMKGc9G1Tj8O578fEcQbMXXZHgRY9h+GsSt8xQCbCD6Y7jJeeHM44pPnb NFWReFkhGS/EGEWrN58IaqgLqBW2aJ+DIWF8tGErl7V/zo/OzvFCKRIpuefktdxRfyRFnz4Mpo Rv5745oUuj4PSnlicw5ZWTCu+1GAbngFFcpvDLalB74ul15p+h+RxvoEsjYUTHuq/JCurw+hFg B5TPfa54iG55s25SFHlukTNjYSkZ3InCW1dUFsZrtpTHOE6039iBs1GmV8qt6Y4eJjuxaQv98V rGcEDrD8L88ee6HqmsyFhwDY X-IronPort-AV: E=Sophos;i="5.87,262,1631602800"; d="scan'208";a="145122015" 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:21 -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:16 -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:01:13 -0700 From: Tudor Ambarus To: , , , , Subject: [PATCH v2 13/13] dmaengine: at_xdmac: Fix race over irq_status Date: Thu, 25 Nov 2021 11:00:28 +0200 Message-ID: <20211125090028.786832-14-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_010122_071932_E24796B8 X-CRM114-Status: GOOD ( 15.01 ) 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 Tasklets run with interrupts enabled, so we need to protect atchan->irq_status with spin_lock_irq() otherwise the tasklet can be interrupted by the IRQ that modifies irq_status. While at this, rewrite at_xdmac_tasklet() so that we get rid of a level of indentation. Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver") Signed-off-by: Tudor Ambarus --- drivers/dma/at_xdmac.c | 80 +++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 43 deletions(-) diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index ccd6ddb12b83..082c18d45188 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -1623,6 +1623,7 @@ static void at_xdmac_handle_cyclic(struct at_xdmac_chan *atchan) dmaengine_desc_get_callback_invoke(txd, NULL); } +/* Called with atchan->lock held. */ static void at_xdmac_handle_error(struct at_xdmac_chan *atchan) { struct at_xdmac *atxdmac = to_at_xdmac(atchan->chan.device); @@ -1641,8 +1642,6 @@ static void at_xdmac_handle_error(struct at_xdmac_chan *atchan) if (atchan->irq_status & AT_XDMAC_CIS_ROIS) dev_err(chan2dev(&atchan->chan), "request overflow error!!!"); - spin_lock_irq(&atchan->lock); - /* Channel must be disabled first as it's not done automatically */ at_xdmac_write(atxdmac, AT_XDMAC_GD, atchan->mask); while (at_xdmac_read(atxdmac, AT_XDMAC_GS) & atchan->mask) @@ -1652,10 +1651,8 @@ static void at_xdmac_handle_error(struct at_xdmac_chan *atchan) struct at_xdmac_desc, xfer_node); - spin_unlock_irq(&atchan->lock); - /* Print bad descriptor's details if needed */ - dev_dbg(chan2dev(&atchan->chan), + dev_err(chan2dev(&atchan->chan), "%s: lld: mbr_sa=%pad, mbr_da=%pad, mbr_ubc=0x%08x\n", __func__, &bad_desc->lld.mbr_sa, &bad_desc->lld.mbr_da, bad_desc->lld.mbr_ubc); @@ -1665,55 +1662,52 @@ static void at_xdmac_handle_error(struct at_xdmac_chan *atchan) static void at_xdmac_tasklet(struct tasklet_struct *t) { + struct dma_async_tx_descriptor *txd; struct at_xdmac_chan *atchan = from_tasklet(atchan, t, tasklet); struct at_xdmac_desc *desc; u32 error_mask; + if (at_xdmac_chan_is_cyclic(atchan)) + return at_xdmac_handle_cyclic(atchan); + + error_mask = AT_XDMAC_CIS_RBEIS | AT_XDMAC_CIS_WBEIS | + AT_XDMAC_CIS_ROIS; + + spin_lock_irq(&atchan->lock); dev_dbg(chan2dev(&atchan->chan), "%s: status=0x%08x\n", __func__, atchan->irq_status); + if (!(atchan->irq_status & AT_XDMAC_CIS_LIS) && + !(atchan->irq_status & error_mask)) { + return spin_unlock_irq(&atchan->lock); + } - error_mask = AT_XDMAC_CIS_RBEIS - | AT_XDMAC_CIS_WBEIS - | AT_XDMAC_CIS_ROIS; - - if (at_xdmac_chan_is_cyclic(atchan)) { - at_xdmac_handle_cyclic(atchan); - } else if ((atchan->irq_status & AT_XDMAC_CIS_LIS) - || (atchan->irq_status & error_mask)) { - struct dma_async_tx_descriptor *txd; - - if (atchan->irq_status & error_mask) - at_xdmac_handle_error(atchan); - - spin_lock_irq(&atchan->lock); - desc = list_first_entry(&atchan->xfers_list, - struct at_xdmac_desc, - xfer_node); - dev_vdbg(chan2dev(&atchan->chan), "%s: desc 0x%p\n", __func__, desc); - if (!desc->active_xfer) { - dev_err(chan2dev(&atchan->chan), "Xfer not active: exiting"); - spin_unlock_irq(&atchan->lock); - return; - } + if (atchan->irq_status & error_mask) + at_xdmac_handle_error(atchan); - txd = &desc->tx_dma_desc; - dma_cookie_complete(txd); - /* Remove the transfer from the transfer list. */ - list_del(&desc->xfer_node); - spin_unlock_irq(&atchan->lock); + desc = list_first_entry(&atchan->xfers_list, struct at_xdmac_desc, + xfer_node); + dev_vdbg(chan2dev(&atchan->chan), "%s: desc 0x%p\n", __func__, desc); + if (!desc->active_xfer) { + dev_err(chan2dev(&atchan->chan), "Xfer not active: exiting"); + return spin_unlock_irq(&atchan->lock); + } - if (txd->flags & DMA_PREP_INTERRUPT) - dmaengine_desc_get_callback_invoke(txd, NULL); + txd = &desc->tx_dma_desc; + dma_cookie_complete(txd); + /* Remove the transfer from the transfer list. */ + list_del(&desc->xfer_node); + spin_unlock_irq(&atchan->lock); - dma_run_dependencies(txd); + if (txd->flags & DMA_PREP_INTERRUPT) + dmaengine_desc_get_callback_invoke(txd, NULL); - spin_lock_irq(&atchan->lock); - /* Move the xfer descriptors into the free descriptors list. */ - list_splice_tail_init(&desc->descs_list, - &atchan->free_descs_list); - at_xdmac_advance_work(atchan); - spin_unlock_irq(&atchan->lock); - } + dma_run_dependencies(txd); + + spin_lock_irq(&atchan->lock); + /* Move the xfer descriptors into the free descriptors list. */ + list_splice_tail_init(&desc->descs_list, &atchan->free_descs_list); + at_xdmac_advance_work(atchan); + spin_unlock_irq(&atchan->lock); } static irqreturn_t at_xdmac_interrupt(int irq, void *dev_id)