From patchwork Wed Dec 15 11:01:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12696251 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 E5454C433F5 for ; Wed, 15 Dec 2021 11:07:17 +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=6HZKj+EYI+w2a9P6xYMw9bbs3GIIhMKy4SYi9LDL6hU=; b=tDcupo1neqlNXq ejCWG6X+ovPDgN69oc1h3IFupyer4/VoWzvSTAz7NU1wcHl0TkIi/JRj47Fqkd0YKXEyxP8jAETKA jkK1St9Tb9Sog3bsOe5fxjoyYR4L9oprVK42+CJbiYp97nzjKcZ0klJ544KH7A7dkDATxXnJV+ga+ iEMbIETHWpcjISkh7pHt7vZOw6pwEVZizyxpGUE9akwxGbJEWRJvx2ynlA14gvQOaynSd9R95cLOk 37GHQULZ1RXxuGMCOh0rKsNv26bA/J53RnNGDwlJMeRjfdDw09zkYBbS2WDeY5cJH1J77/e/i4BUC oEOm0IoF5svhyf58G+Xg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxS6L-000OKZ-9C; Wed, 15 Dec 2021 11:05:37 +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 1mxS2G-000M9D-JC for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 11:01:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1639566084; x=1671102084; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7qVcImxGBTHjFh5448/P7RQSE1s+vXFl/SCN0Q3y0cQ=; b=TP7heWgyQ3jxvC5IBc0No5hS/mmhzjgyGDbHJ1cwuWoLTsz2oI45Lwug V3xPC5qNosojcm2aIvmHaZQfUhBz5gPbmkR/Mc6wSmJAxN+nLfM+rmSPm hmnyTjeR5noFUwixPZhAP7c5cEcmf1ug96D5CoK/R5TWxYoj0eIu/3VXL oHOjVlArM7zur0kIL0SNBuWbdIKehwzhWalg2lC8J6dzKzPc4IqrY7O01 ybaa5xt0Aojsr0fQ1dKfJ5Y/LyAx8SJ3vrNKdKHK0XKRuIhO75JN6xTcf hJ8FW455bMJ4QWpjZOfGYEejNAR0scRHTxeQq5SjKgWTwNKAoWBpd8lg4 w==; IronPort-SDR: LZPjOc+QbtJc7YRYwDKlCAlUIbmb2qmil+NdK+LW2Kbr9NF/jT+M0HUal27EU+/fJoMiK7IdrA 9tNZPy1eTSgygCEsN2yfcnO4RPn56aCMyhpmIIDgICAWtA3riX5W4IvlqVCOn94yJyLh0EjXZL LZ2zKl/afmRwm6AVmBcWBlII4TqYe0+z28lYXz38FdFc+Tv5m4J2Ta+TuvZpYJ+uk16lhNSVaG 0Lze1GVFliVh/13fY5KHVhsijoZlKYkgDmMl4WE39dz/SweVvmirt22Oa1/msPJeQ4xrxJxhIh Ef/7RTQ3mHRlYNBsBzMDI663 X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="147304259" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Dec 2021 04:01:23 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) 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.2375.17; Wed, 15 Dec 2021 04:01:22 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Wed, 15 Dec 2021 04:01:20 -0700 From: Tudor Ambarus To: Subject: [PATCH v3 01/12] dmaengine: at_xdmac: Don't start transactions at tx_submit level Date: Wed, 15 Dec 2021 13:01:04 +0200 Message-ID: <20211215110115.191749-2-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215110115.191749-1-tudor.ambarus@microchip.com> References: <20211215110115.191749-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211215_030124_698395_DE1B9DB3 X-CRM114-Status: UNSURE ( 8.84 ) 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: Tudor Ambarus , mripard@kernel.org, linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, 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(), thus remove at_xdmac_start_xfer() from at_xdmac_tx_submit(). 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). 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. 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 e42dede5b243..4ff12b083136 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 Wed Dec 15 11:01:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12696252 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 37CF5C433EF for ; Wed, 15 Dec 2021 11:07:54 +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=cotavFvka6kfdYwtfgTRWsc2vjv/nXMQb+pj7KDh4dY=; b=u13ingshmYz1ND OhGKsO3c1bxIOqt4Nm/uaWkkFRKVcHEvx/rrFNhFSf2Hb7s4LblfD/Yg+Uk+vQ1tu4Y2jZyh0r09y NkDlXqnFwalw+ngGVlF9dtl8hNzRtDl5V1hkcwTY71hRyf2kKXHKVMH0YHq2n4iFU7/woEA4Hq4a6 jK0TGSkFF3hwTAVVIqrc+n+KdWksr04mOZWjoFiJcWkX/W/cJfdMezD60ITZb4OwXG/KiLK/7BS0d WCDTy3VoVcXRDZVCxcliU8dRg1dkWa3M0SxsnL8x1TDc6JJYtpSU2ABrmI9KhGJ3iIUTA5+Dl2pM7 wHR+rtfBe0BEC7kqWp7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxS71-000Ogd-2D; Wed, 15 Dec 2021 11:06: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 1mxS2N-000MDb-Si for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 11:01:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1639566092; x=1671102092; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FJoZ3/X+f//Ot1xushVx/AGt8XPLPpyGKxiMYuKplkY=; b=VQvUHOx5hKGPjbiHvkG1SztRm5PX9BGpgexUKmzEpheSDJSd5hNkl9Nc VUlPlpOwxHXBIHhXGeAKlT67QT2mH9JzQvuL/24frhAtZBq4gumxNIdhb 1OiKU5AEC66VnzOpYOWE3nj856DWlVbYMhUGWFsgQd23HbP+x1z1ntyck yzgtspGRxaohpC+3TcJPmf5ddQAww5LgAix/th4PMYpdXqDzkb7K44tSe uuuGXkW8KnArOf+mlRrimx8nuY4CYuG4pdz+0HXZfFVSF7RFRSwJby6VY K2pzFkCIUsjVTQk9CruUEKC1CD5cq+xWH6wQEZTCylmyrjiuo1N6l6rPR A==; IronPort-SDR: 24p0OL/8SfbTQ6kN8CmBXbEEVngV9Osvo3Uv1duiYezK5pv7arGf1cUL96S0edQE4+rGr3srVR 3OvYEQnhfi+pjwoEvD68U/xbR/E/IfoIYzhXbzSzVrJpl2IpoLrjXk28XA/Sme2R4rZXxf7kDj yZ+eij7TsRxr0HMwS/hgcZ3ItTD6jA2Cu8lRlETil4V31kVSBJnVn7pMpwqWemjrYHma1oHXCs olq4Zl8413xYqc7LkHWDz5KMWmf+srwLnRpsz4mmMsW92LaDNSnrTawdMutV/jSVbJdGDUKAjd zeB7zto0Te1izo6CYDef5WQm X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="142483350" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Dec 2021 04:01:26 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) 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.2375.17; Wed, 15 Dec 2021 04:01:25 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Wed, 15 Dec 2021 04:01:23 -0700 From: Tudor Ambarus To: Subject: [PATCH v3 02/12] dmaengine: at_xdmac: Start transfer for cyclic channels in issue_pending Date: Wed, 15 Dec 2021 13:01:05 +0200 Message-ID: <20211215110115.191749-3-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215110115.191749-1-tudor.ambarus@microchip.com> References: <20211215110115.191749-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211215_030132_063491_417B22FF X-CRM114-Status: UNSURE ( 8.93 ) 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: Tudor Ambarus , mripard@kernel.org, linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, 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. Start the transfer in issue_pending regardless of the type of channel. 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 4ff12b083136..c3d3e1270236 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 Wed Dec 15 11:01:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12696253 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 1FAFEC433EF for ; Wed, 15 Dec 2021 11:08:42 +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=EjrV43gfyNV4z4eWFN5ID8/Cdz7Uzh8sTrdUB9Vpu1Y=; b=bz6fJwdaAWol74 Mg3v7LdtdECHAZ0dFZONbZW11HApPPveZ5rE1wkHt4YMKcYYYV71Uu5krm4n2DwrIU7sw0egKcyGb i7pPsG5sWlVq96HBKn86TKYoCSVLbZxf176UR1FJ2yrBI9U3sgdp69Rb80vd/uUtEsIzuv2qjnjkX MvHXhPqaR6kWnmJWg0SMzGhcpMlPfWKldHEbLpy44EHqZPHMrTjcIq4qsTcJCOhnUemQBTTueJIG5 /MmTmkpYdAldfnSSIs7eBt6KSsV1lQitlzDga6wQSO5rh52e24+WFrIYXaojBmqvCl+yPQAuqyxVU VeGSz8XCHtv6F1Zi9FrQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxS7i-000P4t-Fn; Wed, 15 Dec 2021 11:07:03 +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 1mxS2P-000MDb-GZ for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 11:01:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1639566093; x=1671102093; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3k8a8xCqtq8m/zip3YHJv9qzx7jb4XAorSSZVUzxzPw=; b=mvU3ASKs/VJh/+4I8obhWaTCuxSt2xeuUUSViCXiCpRHBT9ZQUBQdFjl LDg5WHZTlS2zp9idFlbnEmL46e3x41AMDC4eo+Rs7MZ5lHwPj5igirK+0 t1wouOJlltZ1iBB2dVptE+srQjjhK+jQIlNgrmBMM8LCMrq4OdG01U2us pU6rZe1aFkq+8qaQhMeuvUXi2muOgtpuwp3BdKYd5lkwbCSeNCLScVRdU PLpC+JdPWwkbp3gPis/lbcvOvIPwLrU9FM1FJfo9LdaZbwi8dPTKEX51X RolqBffAwaMLtBHpTD3n2bAU8JfrSLEcMDUcytPHWQl8Z56NxxSYIR2nw g==; IronPort-SDR: mxQk44P8fKjrH3MGpoj26/z9Z2F54hSlvCknTspKuGZHLO+FyWmY03WQO2//StEO8Z8PLpUJMN oN6qDgp4/rK+y+FyapAvme9GE7wy7fYftuR9bDUDcvyek0kBHqPd8YrlAB90GPtvBNQnVSaugl QW9D+NAQ5KEN7OmS0CRChgXR5GwXD3GJx5JI/oB5+I6YyW2Ga6Ug9PJ2lHguYTpQfBqvux7ir1 Upf6welnS4wf7dgAguKrg+BACWAC7nPfashZjC6XNBBgllEw5zl2y+T8AfIHPfnX/iLlXWMrXm l3QzkxkjucUm81gX4/1t6wB1 X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="142483354" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Dec 2021 04:01:28 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) 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.2375.17; Wed, 15 Dec 2021 04:01:27 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Wed, 15 Dec 2021 04:01:25 -0700 From: Tudor Ambarus To: Subject: [PATCH v3 03/12] dmaengine: at_xdmac: Print debug message after realeasing the lock Date: Wed, 15 Dec 2021 13:01:06 +0200 Message-ID: <20211215110115.191749-4-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215110115.191749-1-tudor.ambarus@microchip.com> References: <20211215110115.191749-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211215_030133_669204_F128A87F X-CRM114-Status: UNSURE ( 8.48 ) 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: Tudor Ambarus , mripard@kernel.org, linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, 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, so move the print after the lock is released. 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 c3d3e1270236..7d3560acedbb 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 Wed Dec 15 11:01:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12696255 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 8EDFBC433EF for ; Wed, 15 Dec 2021 11:10:10 +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=GuSulUvWGj3VJe0PA/hcvGvfHjk0O6Gg1KrXDuJ/aww=; b=Do8FzUxWJE46Jv kQi78PC0gV/kz1X4eyqThepVCFF/NQvZj4HBw6ahzJkgtqhwOCq64cMF/6dnILqswWXLRoVNBcUtE +AeWblFy7O/UCqjgnaZLOUlBMXhQ936wjaveA8SQ4T0ZVnpfBR/0eCnHzMLvQwQ3RybyHzAo4NcDL CgdsWiDh/uA1ghPp93a2Lvy7PlXiYpGvL+ypSNro6IcfsfkVDsuAVxvlknKZMqVAEJXwXsCgs1/0T EfWSocKcDxkOMjhwgUOErA23twEk5vJ6o6UDbbvTimVY9d6+gaQDzx1y5NLERLqZA71fygM3qSQub Vzr+rDBZb5tV5w8V72Mg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxS8z-000PjZ-Sq; Wed, 15 Dec 2021 11:08:22 +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 1mxS2R-000MDb-1X for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 11:01:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1639566095; x=1671102095; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Gg1aOoAbFdXCK2iIdjdkeyi1r5cweAwvByOXGAnrlsg=; b=2qtef4uvWYCjJEXbK/I3Me9ezAGurzRiwP70hq29tNfqCFU9McpHRsyZ 2gFTIKRxnnVR9O0VGVqZfv2NDaO+sa7s1ZLBce09+jHaABhe+/M4EpEt+ AMbLZjgKwV7gWZkIzvZYYns78Cqo6/qvDIqRMN/nfFCB22hIBis6oa3l0 RTR+iezZCiMrN2quXrhfDRSmx4doBK2TyA1QX9TxNofhRneraZdSg/XC9 7MMbWFc97o+DCIEHEmQpVyjRtjO7La3D8qqWgxXNUDwevIEs+E2CP2pJu 2MMYrm+2exiBf/E3NkZErO1Igm116cOCCUuJrUQnsZmLAtpLOauYUI83H A==; IronPort-SDR: 8U7SQuFLe/DgjTBD8N8bpNi/8HrOYuJlk2UrEq+CgbILcNxq6FpAx5R0OtA1EXv0QFok3r7+Yr ouGkW7B76ONMlDwh3zbCaBXHudGRjKetG424hiW6VzGQk38xGtjPqN/5CATRRmkSh5ayqGfF67 cmJyMl1Nmve6dcN/Y/5Nfl4/KphiQL/t3ZCp4vkvbaxV1166mymniSN9EmWcqxf2HTqCOYepvo L1Y7S5jvUWNv2BLMSAUtj9NwimlEX9SzVF1f0T9gfTjBRMN+kPMcDXQjZNEIG3KScIV7htDK/S 5MIvlG/ewl3mtZzOn5ch8jfy X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="142483369" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Dec 2021 04:01:33 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) 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.2375.17; Wed, 15 Dec 2021 04:01:30 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Wed, 15 Dec 2021 04:01:28 -0700 From: Tudor Ambarus To: Subject: [PATCH v3 04/12] dmaengine: at_xdmac: Fix concurrency over chan's completed_cookie Date: Wed, 15 Dec 2021 13:01:07 +0200 Message-ID: <20211215110115.191749-5-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215110115.191749-1-tudor.ambarus@microchip.com> References: <20211215110115.191749-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211215_030135_223360_5FD661B3 X-CRM114-Status: UNSURE ( 8.43 ) 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: Tudor Ambarus , mripard@kernel.org, linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, 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. Call dma_cookie_complete() with the lock held. 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 7d3560acedbb..83c031207530 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 Wed Dec 15 11:01:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12696254 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 E8250C433EF for ; Wed, 15 Dec 2021 11:09:27 +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=gv/U0tD71wIp+VD0+Os1Gk4wtC6xSnufgn8p49Qk+CI=; b=rTwg7OfxW4Y9Ws FQI0AOdYvWQRvMwrQwgME3trNf4zwTWRj1LwWsds1o8K4Y8pX349a0OrOdA6IqcbddVh7dGxMqQkx +DffnyRep5ALu0syVRBatSMetICq1VZ9pmJsx9UFkPxigek92FM4T8HTW38eoa5q/CcBQFegrcczf yQT+G3qsRGKnr+ChLgxBs2Dtw7BsQF7oP69QyzpDgVbytN9hB3N353kR0d8XHR6PJryyRXPhc0Ueb cUxPkUvVMXMyR5HEpSDtj3BjW+MoW/5w6chJ24HkDvqf1dyuzZykYX10wsJyMSqkKNhGiAqzYdw5p GztLloe7IQ6Q28aCUqgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxS8L-000PP0-Pn; Wed, 15 Dec 2021 11:07:42 +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 1mxS2Q-000MFN-2E for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 11:01:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1639566093; x=1671102093; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4X8BJvNzEUcQqoMWQpov9DWaBKuYhadvuaqzWzFzBHw=; b=Yna+Pnop/z9nBVz00MwEulQ0mMNeFx+JQz22Xk/1p+CLhrtYy/Mbh+Rs gShDzj/Tt1KZsLspZIecA+9T7ondMwYMjO+E4qAaV8FdHeNXw3Vfh7p8q 9RJ4tHQxvmMLgVSPlYUEmYaeo7X4LnL/dv9NNCUy4BOOo1VCgoz+II8U0 aMoPLOcIJRdIPQReUyJv2aq47MUI8DE3eA3KzKSW0kxM2/t6ry8IZIOs1 Cgy3gh2xuN84J6SIEj/9TKarQtkTH5bJMVKFt/tQMQYD4MFAZk22ngidh kIqV0bQVc0fOVsIURxcPvsyZnSvSvksqOvRx0lEYi0cJ3ttyloEDnwniw Q==; IronPort-SDR: 5144dnubbSn42QemwMCTwZaOM6kP58KT4tTkUJEtFCZkYQpFbIhDXDKuLbymvtzEgIDnn8+CFk uBAg6Psn3qTRey/XPwckMnhzBEoPaGwD+Vxo9WcTmcTDuwuga1pgYLV4JoSUKKM7RTDpAzpf7Z wvq6FYpnSlvarZkqcLCttwPB7Bxbob44IfF027f09Hy3X2uaFskVUk+Y69To2eVQpLIAEzEzpY 2ze8Qp2ltApX5tQ+9iLfRxKgHLtqMQCosvb0W3TotrTysiDv7ewiJDSpVzC9vGQV17zAFe+Lj3 Xa3ipGFZ0gXjekR9tfAhEhuF X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="139842688" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Dec 2021 04:01:33 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Wed, 15 Dec 2021 04:01:32 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Wed, 15 Dec 2021 04:01:30 -0700 From: Tudor Ambarus To: Subject: [PATCH v3 05/12] dmaengine: at_xdmac: Fix race for the tx desc callback Date: Wed, 15 Dec 2021 13:01:08 +0200 Message-ID: <20211215110115.191749-6-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215110115.191749-1-tudor.ambarus@microchip.com> References: <20211215110115.191749-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211215_030134_263501_8DA7F830 X-CRM114-Status: GOOD ( 10.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tudor Ambarus , mripard@kernel.org, linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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. Fix the race for the tx desc callback by moving the xfer desc into the free desc list after the callback is invoked. 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 83c031207530..d5b37459f906 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 Wed Dec 15 11:01:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12696256 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 B6547C433EF for ; Wed, 15 Dec 2021 11:10:53 +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=UGUb0Z0T2jXHjd1jEfJlGiN/smxJBvis/7dob7l9MTw=; b=TOD03ZP0jVO21i DZr1dtceewvQ22kDZ/VwW3wskxkXIp0r7Zg5mKUJQEwR/V8gPQma8Pzn7bDGHiunGcyx0nHSYH6RB L6rP8PzuqBYtoXcOVjrBt8NSO32SB5hILEiqyzH60A/vHK1EYH/iwZbxmV6uzTmx/OaqEXZLZtwVe Mo22iIHlKoEHExgbaUHF4fJlFr+4ioq57om6WV4brcdbQ5X0JxvlIvel09E6voS1r3iSeyG7NnAHR RrnJiJr/NHynFHIQqLZW7U7/WPs+kPu2zQu9/A+k121XxZ/cOreVX8lSZdZBKILtwsylwwoUgQmeo 6gKdhSktr5HdabBLePUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxS9n-000Q5W-AQ; Wed, 15 Dec 2021 11:09:13 +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 1mxS2S-000MFN-O9 for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 11:01:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1639566096; x=1671102096; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AQkjKqLl7OD/SJ7eimyxbgKCIhwnCiF/+RQW769Dfrw=; b=RDJzpaYHu8W6yBF72KDStwXeMayMN4UpW1iZuoSfQ70oLyQeyX5i4r3/ qFEFbJX4avAy7e2eSSwrT1NEoUSwHbQR4+5tgzIH7SNKKAWwHfZoO+xHo Wqu9hqtewJqWRyvQWu65t5qrTA4w+2hWMUgrr4lUSp/HwPDF+7mqTAhgr 4/KveMB7tlR8YUNYjJtGqwORIWax+s+toHsXxguEBkiuVT/c/NfETLfXk UsKapSQTnvQRbiw8Hu0pfdyoJQWM1kDlLfbpqswlJMRY7etNqB+lZ8//g CGwrn/Y0S4kgA4qiHr/3DwEFqC3TVsYg3kNZ8ijvWjYJ+9YZ01fmowztj w==; IronPort-SDR: IWPwniik5XjRmTKPGMzxA9VRlDdA8LRdxQu6ieEFAgRq1o+ye3q1HuxGh1VrkZFuaFkDrBnr6e 2rqN2HJ/zok3wNZpHGYcEKm6PTAKzXThiMfGi2ndA1aRnYCjvH5/X2QHu3+U1RkSRbyFyLR9ni AWtTYG0vquk5AeEKgc+axKI2JdtZjRNjoRNUfWcye9H670x1eNt+qwHcq4LtQ/TxulnVBRM5lY zQKsYcI6K73/qKTEqyjXwozfIfmZndyS2C4Em+IOPjaLb2YOco36IpC6maTQzmbtNMLw1BjOLY Pef7TKZM4lmnte+mNmDTaEWP X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="139842698" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Dec 2021 04:01:36 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Wed, 15 Dec 2021 04:01:35 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Wed, 15 Dec 2021 04:01:33 -0700 From: Tudor Ambarus To: Subject: [PATCH v3 06/12] dmaengine: at_xdmac: Move the free desc to the tail of the desc list Date: Wed, 15 Dec 2021 13:01:09 +0200 Message-ID: <20211215110115.191749-7-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215110115.191749-1-tudor.ambarus@microchip.com> References: <20211215110115.191749-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211215_030136_936538_E8FF871B X-CRM114-Status: GOOD ( 10.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tudor Ambarus , mripard@kernel.org, linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move the free desc to the tail of the list, so that the sequence of descriptors is more track-able in case of debug. One would know which descriptor should come next and could easier catch concurrency over descriptors for example. virt-dma uses list_splice_tail_init() as well, follow the core driver. 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 d5b37459f906..b6547f1b5645 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 Wed Dec 15 11:01:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12696257 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C06F9C43219 for ; Wed, 15 Dec 2021 11:11:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZDA2leCuj6lOF37DCACXlJLp6qWJIbO2irjpUiklZis=; b=D550fgojboeKPD pXO9NyLHEzKosmRQ4KcxlUaGlgFf/1l655Av0hS2hTrqXmUAb4SF+GyvNjcQr61mWrZ3wBh0EBOrg hVDKYH8L4riOGA04eWvw3w540SMNSUbHAaklMltVLZ3Jt522fDDbcWiecHJQ/noEli+K31Mld61UK iJK7haosYsLfu4XAnzVZVCyJ6eGjZnpymCORAaDY0IsL6wQJVDerHhD1IQD5AGjhJEKrl55GjGkhR 0bzV4Z7OlrtcvCY4uj7qq/sayzXJSqJKvpR1NCnZbjfXpw8XW7KYCbXzkC+k1MJMFDmd517VKytfk /zN+gRXI/khJJUFWMt3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxSAR-000QSD-4G; Wed, 15 Dec 2021 11:09:51 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxS2V-000MDb-9M for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 11:01:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1639566099; x=1671102099; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XvtFfCx1rLVyUeXpqg4YPLygK1ixJghu3MJP5+44Jns=; b=pwzqVx+7GQPjEG8nXd2tn0a9bk5TInIaTdgDL2kqDhuG8BCzuiF6puXb iCwgmI3+blBxSPVRNBWJMrnJPKraJdZERFteL2ohU0IyrmxBUSNGDh+GG d3TYFUe95GYtRmfuq7gDql9gBBaKaho1lkxwzUaXrfG2nn28npQWjK+pY 4vzzcU8azxylcS/COisAt/Eo4qoVUppl5h6XWtJUKv/zr4LPPgNbWDlhI SEASkkrtTQbTd+HTObcVnqPUSodKpLpYMk2IeuAZ3JAg/tvs9rGYXvLGl Jlo+EZPfibeUf7JEqcbehZpcQnZTPDsPmvmX4KdxBMhB1a+BIiXaJbfU7 A==; IronPort-SDR: Im18tkvGcN0wtb6sizqdmXMoVo4izt4F/wxC+1nfh2QTsEdvS47omxlOVWPdCBeL5gdIgUs9BP 6AsaEWGTwgALAKxF+g0p/wLcmMf5pgcqIitRLvc95SB0hVbt7+DgOIw4T+41oOc/M7+4wloLm6 Uetpkgn68rrD2HJFuC597wQcomV2ib4cZULCDLuAGmjGV+7JEBQIn2SU4qllekuRTaCY3TNZzG tz+oSdFflhBeZ1TgEBBrtVrgeUmHLG0CfFW6C8pQEbFBSoAZKUmuuwpBrvNwkSf8di8fgh9Rqi KMqtx/UEZt9sg8Nc2cokB3S5 X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="142483384" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Dec 2021 04:01:38 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Wed, 15 Dec 2021 04:01:38 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Wed, 15 Dec 2021 04:01:36 -0700 From: Tudor Ambarus To: Subject: [PATCH v3 07/12] dmaengine: at_xdmac: Fix concurrency over xfers_list Date: Wed, 15 Dec 2021 13:01:10 +0200 Message-ID: <20211215110115.191749-8-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215110115.191749-1-tudor.ambarus@microchip.com> References: <20211215110115.191749-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211215_030139_467177_FA8D2756 X-CRM114-Status: GOOD ( 10.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tudor Ambarus , mripard@kernel.org, linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since tx_submit can be called from a hard IRQ, xfers_list must be protected with a lock to avoid concurency on the list's elements. Since at_xdmac_handle_cyclic() is called from a tasklet, spin_lock_irq is enough to protect from a hard IRQ. Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver") Signed-off-by: Tudor Ambarus --- drivers/dma/at_xdmac.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index b6547f1b5645..eeb03065d484 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -1608,14 +1608,17 @@ static void at_xdmac_handle_cyclic(struct at_xdmac_chan *atchan) struct at_xdmac_desc *desc; struct dma_async_tx_descriptor *txd; - if (!list_empty(&atchan->xfers_list)) { - desc = list_first_entry(&atchan->xfers_list, - struct at_xdmac_desc, xfer_node); - txd = &desc->tx_dma_desc; - - if (txd->flags & DMA_PREP_INTERRUPT) - dmaengine_desc_get_callback_invoke(txd, NULL); + spin_lock_irq(&atchan->lock); + if (list_empty(&atchan->xfers_list)) { + spin_unlock_irq(&atchan->lock); + return; } + desc = list_first_entry(&atchan->xfers_list, struct at_xdmac_desc, + xfer_node); + spin_unlock_irq(&atchan->lock); + txd = &desc->tx_dma_desc; + if (txd->flags & DMA_PREP_INTERRUPT) + dmaengine_desc_get_callback_invoke(txd, NULL); } static void at_xdmac_handle_error(struct at_xdmac_chan *atchan) From patchwork Wed Dec 15 11:01:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12696258 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 61E87C433F5 for ; Wed, 15 Dec 2021 11:12: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=fpOWF2xE6lCus3XLEvjR3eG1tgSgpY1gXak4QPdJ6qM=; b=airDma32FnFNfn OxaOc1yR/c38Yq/oHtz46YtH4W/ERbsDXUv11KFgeRuSL5rbTrz/pxUPeGwvUWn9UUdUXR56YVdUt mV2cvJgDKk3NT0pwWRv+V+UL6smhOedLCX5+OCoPJdFnItVBNFeQLiYlHd3sMZc+MtHe0xmLRrLKZ 21YhklbD4+hr8PTsghWzeNZKMgAhEudN7RfCk2+t4rH90cCjvsC+WUskYhtcMhvrhypRLiDrfV6ki Ztl73FbTknZpJp4qgfo2MLvlBaWSi8sC8Zf3lP3BUb6IGjTzAc+BH/8Ra0qh+2KK2fqGrNxRlErZ6 zBJUGwevGr/hRSCbfKCw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxSB3-000Qml-Ug; Wed, 15 Dec 2021 11:10: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 1mxS2X-000MFN-OK for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 11:01:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1639566101; x=1671102101; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l7DYN6EzzogTUQIaI5uuaqM3uDK/flgG0AmVT1JLkvc=; b=BOxnIxqHEZT4yFvlIsdEWxR8ztnohM4CXc6OMIlY4cwzhEWfyIdf5j7g lD+aq5kesIandk506N4tn/f6t4gStMOSQEz8pNkTK+VxExFUlJ9hc23L9 pn5Hva7SvzrmwvJIL8WTf3Opv7ttm4xN5c/IIYiuqx4D/1Uy2DGxTMnoi tV7pNsT+kMzw/TvXTKCB9jRk7oV/qckmBAFESWDU1J+zv9fkx9LhXW1V0 RVmVaOp46GKVkYXdGkQhfi31cYSclRcjvR1gy/ZhZew2jvc9AUxO3/0PK ZuwO9fPO26V68O2NpCTStZealFdiJGQJjlutMb/KuZzerCipvJ5E5cgLF g==; IronPort-SDR: o8CfNR0+lg6WOMERCQ3lgZrBaKvbjM3bGNy3ji3gY7rMCybmSm+hsrJpNX0/Mj62JVczP2CEaW 6afEJgknx9Z3RQVOjiIFOGtto1dW+FfD1hnSviiwSOkeIzPwNTZZbT2uGt8ILox9FNEQ16kMCG oaNXPfF7gQ6P7zKeov2uKPv7PXrq2QmiDayJTDLlKUJ+KIN6o/9BGw9lYQq6H5nTtYl5wIFcEy +TGuZWgcQsYeFIBeSisHN2yWdUEUah28hGZljC6MwdDSF0ecqvdM1M5A9cp1mChbtsmU2vuMAB pBcZ24Zz9xKKEeEDhK4uIgaG X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="139842702" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Dec 2021 04:01:41 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Wed, 15 Dec 2021 04:01:40 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Wed, 15 Dec 2021 04:01:38 -0700 From: Tudor Ambarus To: Subject: [PATCH v3 08/12] dmaengine: at_xdmac: Remove a level of indentation in at_xdmac_advance_work() Date: Wed, 15 Dec 2021 13:01:11 +0200 Message-ID: <20211215110115.191749-9-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215110115.191749-1-tudor.ambarus@microchip.com> References: <20211215110115.191749-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211215_030141_922012_6B528CD5 X-CRM114-Status: GOOD ( 10.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tudor Ambarus , mripard@kernel.org, linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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, remove a level of indentation in at_xdmac_advance_work() if (!foo() & !bar()) { } was replaced by: if (foo() || bar()) return; 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 eeb03065d484..0b09ec752db4 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 Wed Dec 15 11:01:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12696259 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 3EEC6C433F5 for ; Wed, 15 Dec 2021 11:13:18 +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=NbUZ+PG26/55RonY/T7Z2vbRigB5jTSjE4YhCuooN3Q=; b=B+PkGGnIXGdK2Z Heldwdl2rtnCD027Y59QBzd5zgK32eBdWDaI1kqm+7zcZ2Wsf0D9czOwbiojoqP83avPvSst9Ey5w xKR/OPVzbpEdE6irFUrE4Zc7t00uvSbjNVIveR2/JPIakeEEyXxAEmSPDSHMjFDMdH8F/1QNehV3k 52rQTdXuJhXvmzjfX0emuB3HWGTAgCkMzYOl316ilBS3QWF0xhRAyQBFMeGBq3uOlBgmYV822huGz 4qZjA5YxOh4fcwJFn1/gSKl8L/k045jugGIQtjzY5aBuD10YPr4aU7sSqU9PM5sAaXgbP1dpvF0kB sLX5TDaot0kN/88mD1Yg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxSBv-000RHy-E7; Wed, 15 Dec 2021 11:11:24 +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 1mxS2b-000MLf-4g for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 11:01:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1639566104; x=1671102104; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wRIv3ubIX5xAKe7fyTIOsp2EcT/w6mzbj8LN+1DMbDQ=; b=Qvn34RVzvRxx8dy7yeQzNaoT/29mLwfDfGzYtGz/5CgxZVAwaUV4txW7 orpS0HxDTnVqoczez3xDcmF3XuzN77gMxVJ0N2/J62hBxt74d7+PPwTbD 29fliBAcI2zotPPUVtNggF8PDnJwIyHQHCKdYmAkL5Y5FnkyY92VP7RP9 rnI/KCv7Q+LsXUok7c7mqK4MVqK1l8R2O3cwQ63x1cs9hP0rvErZKOZxo MBZxBbkwWlGUq+caUK7e+WC6rgitZY5KS95lhbDOBN4qWwojxxLE5t1q1 bMu8vbrCAXF0yXKR6YFnErDAbGkb+C/UX1DOIVckJxV4VJ7G0I9PytBtk Q==; IronPort-SDR: Fsz88XrgCtebLa3EfjLEQf4u+oi9crAkKTf3DVfGNDskAz0axCJ2nHMeZLPybHbqK2AfeUd2m0 ac0NO21yMNuesZ4fQHC410CzbRr5PnAsA78colDNt3bKuntRpPj0cLmzt46xds/Hq/KCVSzmwA 9bx9PLxwqsSSUsxNADoJpLGv4LcWOfW5evAQGa0/nK1pl24KPgG5weDNoQXjae7YUYyTUmkZNi 19lWsopd1+rXYwe6E4FoJ/R7uHV+CUvxaTFXMEbOGA9JUl9mxD4InhogpfqzDclyrrnANQiK8I 2Lc7ni0R4+8mCSqwAGSU4ekf X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="155559242" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Dec 2021 04:01:43 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) 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.2375.17; Wed, 15 Dec 2021 04:01:43 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Wed, 15 Dec 2021 04:01:41 -0700 From: Tudor Ambarus To: Subject: [PATCH v3 09/12] dmaengine: at_xdmac: Fix lld view setting Date: Wed, 15 Dec 2021 13:01:12 +0200 Message-ID: <20211215110115.191749-10-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215110115.191749-1-tudor.ambarus@microchip.com> References: <20211215110115.191749-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211215_030145_244206_6D8D348A X-CRM114-Status: UNSURE ( 9.63 ) 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: Tudor Ambarus , mripard@kernel.org, linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, 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 0b09ec752db4..6e5bfc9b3825 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 Wed Dec 15 11:01:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12696260 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 00BF9C433EF for ; Wed, 15 Dec 2021 11:14:34 +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=RVF0GDDbhYh4JZHYvK4jW8fzlvf2eqCy7vDOYevQDns=; b=CqOO9XK9TA0sXb t0keW5VAXl62xJpYBw1UyOAm6e3DSsNHzF4KuawN8488XeEQeEeWfQjSsKhMqODYMkc4L5nMeJFJh frjuCf8XaSkSc6MvHF4FNZevv4Loa7+TO7cDHIseofyWKyG/2FUkcAAnUzXziV11rlR7BtmNYZO+3 BKyhCRuXlMmvNJSEErvciS8ZcRHNjl4x6LWqmESinbY5Vu4iba8h48wIY6ebE9jw/TCL13eVDUzv9 krLIFhlhv/q4rQ/nMhFkKCzwShWywBvTYUgBgtBftHq/ugULmMDOo8VMHuFFg/aexUhfEHML/As13 SdqM9co+quuT0xlT8ZVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxSDC-000RuM-J0; Wed, 15 Dec 2021 11:12:44 +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 1mxS2d-000MFN-2t for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 11:01:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1639566106; x=1671102106; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8RYbGapbxedXgpRLmZEbbzAVzO7YuLjgxhiAaZYRrrQ=; b=tVMyev2mQUOBD+OlXmhZpCkGhhegPmbQHvLjqValBMZJZkFzUUgdi02z 2XwH6QIIZffnCzay788wK0ZBnnzujVg8bRYk2WuuPJj3/8qJ+UJ+p4fqX JgD7eMvc4JG9fcVa7otkwLgEKM09WLQhvoHhVEtROTxpo5LBJwUNDBlI8 lmX83idgEE/dMYUThn+7ahksOgMySxluwFMb+1XMTDJc3iQ9IuDoWA+J/ 3JBwHhfV4MXaMlFuw7HiwsJzn0Gd5MAYYzdGbS7fuHc/zj6L8RUZypOnf P/M+Qqe/X2XzS2mciXdSq4HYk+zkbxsp6nT1SW93WhwLnbf/yhCeTYSAE w==; IronPort-SDR: bPjJrCgEAhaWqGBOXZUmFz/AXofXvRlH40bZwQRZtjEoICIRpJl0pk76Jekwyua1Qq5mi/dje0 ay01HCpO4GE5xIV09wy5UHyLFGn9DWT5N39mdHL2tMkixOb1NfzEsgHxbKeGq2xLYNdYKFo6xt 2CTuSf6vcpkNE1kc4/J+oRNWwtmTF8L1GFKzJmVG66yBXxEeC6/quDVnGwIFotj5alTKIGWkL1 sC4z9s8wj88Aexo6Y8gRZCMec+Ac2Qbm1RNnrzIaj1jO37v6V5MnqLxumzSEeEdi2TdWqvdLbx cr2zZpz99zBG9c7OQ07VprIM X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="139842714" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Dec 2021 04:01:46 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) 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.2375.17; Wed, 15 Dec 2021 04:01:45 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Wed, 15 Dec 2021 04:01:43 -0700 From: Tudor Ambarus To: Subject: [PATCH v3 10/12] dmaengine: at_xdmac: Fix at_xdmac_lld struct definition Date: Wed, 15 Dec 2021 13:01:13 +0200 Message-ID: <20211215110115.191749-11-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215110115.191749-1-tudor.ambarus@microchip.com> References: <20211215110115.191749-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211215_030147_269542_0FEFF70F X-CRM114-Status: UNSURE ( 7.93 ) 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: Tudor Ambarus , mripard@kernel.org, linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, 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 6e5bfc9b3825..abe8c4615e65 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 Wed Dec 15 11:01:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12696261 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 80BEFC433F5 for ; Wed, 15 Dec 2021 11:15:54 +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=Kec6d6Rje5t0auZCtEOMLAXMnzxJCHXcd/PmcT7Axos=; b=a5WsDp1p5Wb3FU trfezxskeqk2xYU8apFqwuS0hnNAaEUEzHks6cGFrcZHcy6oA/DHU6197BK9eFvP7N54JpCM4bbzT y8Q7ZGnAGBunCjU4LWEQBGPD9Ro8Sm23l8TqVIOsxDlVLXUNIttTk9Ji+P4dVLLEeQbC/ZWVe1Hut 1X+B9ILTlH25OsIG20zS2Ulg4VrbR8yG1YhFqDD2py6HXfdmiEaBjqbPS+MhDWl9F4/xwsdULdOtZ 5fx/NRO9Q3rPQ175Btb8xA4DICve/yIr9FehC9D5jQMKTzzA6hau/dTMwP8ucPccv9zQifpMQU0lx 8+m3D5evrGFGqbmNIURw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxSET-000SZX-3n; Wed, 15 Dec 2021 11:14:03 +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 1mxS2f-000MFN-Ha for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 11:01:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1639566109; x=1671102109; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xmF5KOk6wLZ0TwZsu8nvDmLPx1dYcRpG1UMV30FGRhQ=; b=BNn9vqspvbCRLOsM2p3KP6yqzVt5lW1PKFeIvhDoAQtzEDPUxCRirUVZ JyiGpcIlp18vn4D8dcZlX4NOkdYb9e2+fLncWUyuyowsONy7d0jZzQ0Vm vSKQC7o551X0zwFX2tkUBo5O1RMO/+IoWlXTNuSjJtmvLLTKKe6XdwwSR o8P7Er+UmGKVpBHSPQyiPpZMHxxSkxS1DdRw11QnLuiKA1dmRo/2Yjvic UPCOdhfMCvQxAw4j63eYcja/xzsaGuc7nUf1exSEOqj42iWj7Pnf7ST5b 3WeFf9gQIZd6DOKP8oe3cGO39gOQ75HBju4hE/q0YwbyBmhgeMNpgBhlZ w==; IronPort-SDR: rPY4p4r0SuDwn9mAd3+2mVKhSWUTfe7YGJyZf8HAb8n5t3lMoijNgA+FL8yWL8pcN/i3Wovbui bbPbf6w2+Y1T0sxS1Ts+C9LdSYGGqGRVaQPPoaYYRdgsE6enL80Fu7Bl+eQe+uF09T+84OZn4Q 6D3lbSbNNOI6q9KuRF0fQ0BRP37ozTCEX23ms3oh72IXSPc4uu0cWeU7klmDYl58gPmcuFcHWQ h7ZnFHJidxDVdVYyn7d/h7Xy3l6zLrqizpQXYD8hJPEYqdAdtO+vJhRDqbn4lZ57rizmqRk0y6 SLqWWHy1j5DUp1C6yZafSmOM X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="139842729" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Dec 2021 04:01:48 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Wed, 15 Dec 2021 04:01:48 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Wed, 15 Dec 2021 04:01:46 -0700 From: Tudor Ambarus To: Subject: [PATCH v3 11/12] dmaengine: at_xdmac: Remove a level of indentation in at_xdmac_tasklet() Date: Wed, 15 Dec 2021 13:01:14 +0200 Message-ID: <20211215110115.191749-12-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215110115.191749-1-tudor.ambarus@microchip.com> References: <20211215110115.191749-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211215_030149_740367_30BA40FB X-CRM114-Status: GOOD ( 14.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tudor Ambarus , mripard@kernel.org, linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Apart of making the code easier to read, this patch is a prerequisite for a functional change: 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. atchan->irq_status will be protected in a further patch. Signed-off-by: Tudor Ambarus --- drivers/dma/at_xdmac.c | 70 ++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index abe8c4615e65..ba727751a9f6 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -1667,53 +1667,51 @@ static void at_xdmac_tasklet(struct tasklet_struct *t) { struct at_xdmac_chan *atchan = from_tasklet(atchan, t, tasklet); struct at_xdmac_desc *desc; + struct dma_async_tx_descriptor *txd; u32 error_mask; dev_dbg(chan2dev(&atchan->chan), "%s: status=0x%08x\n", __func__, atchan->irq_status); - 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 (at_xdmac_chan_is_cyclic(atchan)) + return at_xdmac_handle_cyclic(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); + error_mask = AT_XDMAC_CIS_RBEIS | AT_XDMAC_CIS_WBEIS | + AT_XDMAC_CIS_ROIS; - if (txd->flags & DMA_PREP_INTERRUPT) - dmaengine_desc_get_callback_invoke(txd, NULL); + if (!(atchan->irq_status & AT_XDMAC_CIS_LIS) && + !(atchan->irq_status & error_mask)) + return; - dma_run_dependencies(txd); + if (atchan->irq_status & error_mask) + at_xdmac_handle_error(atchan); - 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_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; } + + 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); + + if (txd->flags & DMA_PREP_INTERRUPT) + dmaengine_desc_get_callback_invoke(txd, NULL); + + 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) From patchwork Wed Dec 15 11:01:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12696262 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 2E68AC433FE for ; Wed, 15 Dec 2021 11:17:07 +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=5CFm6gApsBg258XM9iPFZhgC1fKykJWOgkuTF4z7CFA=; b=C8rn5VuVbV/cY8 2Ayd3IQqEfjXoIXadXluSV3CWUZrPmPB8/j7jCBqMuOjbIQO27x6/k0Mw8B6KJM0GYxg19R/he2O+ RGLs+qwYtYl+JO/dPjtfz3EtU/QbdWzpMkQmuk9YQwCsSUfSrmo2n2q2lgW2dhCeo5rzYnN0c+iss PQPG3qUBM/XcggLdnbCsbY/mpxarEDoVKR5dSeK9mpLeS6o3BMAeqEH7bHxBg+gbMl+ggP2kCfLx/ NCfUzskh5DE7UAk2vK3V6tsYVRb33sao4fPtrqsNNLeidfv08vuu1J9IVrHtySJumjQJPVwr6DeUn lH0wNswb8vOsiXp8B1+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxSFc-000T53-10; Wed, 15 Dec 2021 11:15:13 +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 1mxS2h-000MFN-US for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 11:01:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1639566111; x=1671102111; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=livyu8Olu9F9Ywh/gQcsyDAU8oKSPgD+q4+UxxEb734=; b=SNJpg7CWyCFPdmXLKn4GSCD4x6TbtRPMeTvmBCojq5H+2uZlhN9065gK KS/KvA7iVqiK9sgnwEN3YJfasRH2d1WlnjT9rSxXTWqCAT9rMeGDayLsY NMdtynY6kTElOdMXbtCWZZK/wj3E3iaryQG9Uhm0ZHaiKdOlQ92fDXA+F NePEhaygoJYqFaQaw9PMr1NzkxB8HxBZ40VLKsKkpn/c0ZZyEXFUtR+sp DtuNPE/sGwguzFi6JHMBA3DLrkjSEcuxso9/XOA0XWBQqJKJaJ0jdIGlC 6/MH6R8dicggTr3IiNZksaH8ahCnYqD83N2x4AcmbVexX3ZkAfFzepBRJ g==; IronPort-SDR: law3cO30f8LFLnfWd/Rjq4CEuz7T4Bx4DvtkSXmrdYQrIERp0Mxn4pOP7NmvXPxSkG3PqGKMiq XjPu05B9Y6dwIRL+6vs5GiM0jZyVdbievZ/vQAB11aOR69853E5NknJVUqnBvLAcbBHCDE2VMz uPYp7fUKVMzMhmnAr4LLCbtRNjib021fXDkN76B5tpwYIAwfbd6ks3Jf7uKPT4lOoHUxvxPl59 IUfBdty4gdUjhjdm6QnaVCKaEmK6j6B2zjF/xthNrkdTNwIOA6mID4d1lcqqgNk2Lg0kVaXFAR qR6Wc3cOyh1rwSOPitr0sGuh X-IronPort-AV: E=Sophos;i="5.88,207,1635231600"; d="scan'208";a="139842746" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Dec 2021 04:01:51 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Wed, 15 Dec 2021 04:01:51 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Wed, 15 Dec 2021 04:01:48 -0700 From: Tudor Ambarus To: Subject: [PATCH v3 12/12] dmaengine: at_xdmac: Fix race over irq_status Date: Wed, 15 Dec 2021 13:01:15 +0200 Message-ID: <20211215110115.191749-13-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211215110115.191749-1-tudor.ambarus@microchip.com> References: <20211215110115.191749-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211215_030152_140421_40A5EF29 X-CRM114-Status: GOOD ( 10.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tudor Ambarus , mripard@kernel.org, linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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. Move the dev_dbg that prints the irq_status in at_xdmac_handle_cyclic() and lower in at_xdmac_tasklet() where the IRQ is disabled. 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 ba727751a9f6..a1da2b4b6d73 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -1611,6 +1611,8 @@ static void at_xdmac_handle_cyclic(struct at_xdmac_chan *atchan) struct dma_async_tx_descriptor *txd; spin_lock_irq(&atchan->lock); + dev_dbg(chan2dev(&atchan->chan), "%s: status=0x%08x\n", + __func__, atchan->irq_status); if (list_empty(&atchan->xfers_list)) { spin_unlock_irq(&atchan->lock); return; @@ -1623,6 +1625,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 +1644,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,8 +1653,6 @@ 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), "%s: lld: mbr_sa=%pad, mbr_da=%pad, mbr_ubc=0x%08x\n", @@ -1670,15 +1669,17 @@ static void at_xdmac_tasklet(struct tasklet_struct *t) struct dma_async_tx_descriptor *txd; u32 error_mask; - dev_dbg(chan2dev(&atchan->chan), "%s: status=0x%08x\n", - __func__, atchan->irq_status); - 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; @@ -1686,7 +1687,6 @@ static void at_xdmac_tasklet(struct tasklet_struct *t) 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);