From patchwork Wed Nov 22 22:09:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kuliga X-Patchwork-Id: 13465504 Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=alatek.krakow.pl header.i=@alatek.krakow.pl header.b="agfn9OWi" Received: from helios.alatek.com.pl (helios.alatek.com.pl [85.14.123.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31B1912A; Wed, 22 Nov 2023 14:19:38 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by helios.alatek.com.pl (Postfix) with ESMTP id 21FE12D00B5F; Wed, 22 Nov 2023 23:09:40 +0100 (CET) Received: from helios.alatek.com.pl ([127.0.0.1]) by localhost (helios.alatek.com.pl [127.0.0.1]) (amavis, port 10032) with ESMTP id jqwYF8fSHqPJ; Wed, 22 Nov 2023 23:09:35 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by helios.alatek.com.pl (Postfix) with ESMTP id E12642D00B5E; Wed, 22 Nov 2023 23:09:35 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 helios.alatek.com.pl E12642D00B5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alatek.krakow.pl; s=99EE5E86-D06A-11EC-BE24-DBCCD0A148D3; t=1700690975; bh=fRcRZDTsd7kJTaGjL723vrYFFja9y139VFQGM81sxdU=; h=From:To:Date:Message-Id:MIME-Version; b=agfn9OWi6jQz1ZdDBZXwTf2z4wG9cn2rhWQuNDK2iljulBEVzXbaIEoeWH/fx6mkL nRpC7NpLNtw8lg/H58kHJJwQebR2Pkb/IOYdTZSe+CldPiPthLAcddgcGI8eLiamaD i3hPx75ylcdk9fzaUS9iNxhYkalc9Wzt5Ym8wezpnbGknEvJZKTkrO0Yv2BBJfjCHD gdH2tijOO+Je6WZBjKmWpepJ7qnuouuYdmM1U7vF7auSV0k0TGubvDw8qlHAI7NDft 5p9OfCFmhc2SJtPqo5D80zxteu45WzF/oH3lozKP5/PqA/M4YnGVEcg1uixScPal3U aqzXsNukIsSMQ== X-Virus-Scanned: amavis at alatek.com.pl Received: from helios.alatek.com.pl ([127.0.0.1]) by localhost (helios.alatek.com.pl [127.0.0.1]) (amavis, port 10026) with ESMTP id ZSCcmxY_ej70; Wed, 22 Nov 2023 23:09:35 +0100 (CET) Received: from ideapad.. (unknown [10.0.2.2]) by helios.alatek.com.pl (Postfix) with ESMTPSA id B2FAE2D00B5D; Wed, 22 Nov 2023 23:09:35 +0100 (CET) From: Jan Kuliga To: lizhi.hou@amd.com, brian.xu@amd.com, raj.kumar.rampelli@amd.com, vkoul@kernel.org, michal.simek@amd.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jan Kuliga Subject: [PATCH 1/5] dmaengine: xilinx: xdma: Add transfer termination callbacks Date: Wed, 22 Nov 2023 23:09:17 +0100 Message-Id: <20231122220921.117428-2-jankul@alatek.krakow.pl> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231122220830.117403-1-jankul@alatek.krakow.pl> References: <20231122220830.117403-1-jankul@alatek.krakow.pl> Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The xdma driver currently doesn't implement proper transfer termination callbacks. Therefore, there is no way to gracefully terminate the on-going DMA transactions. That is particularly useful for cyclic DMA transfers. Implement these callbacks. Signed-off-by: Jan Kuliga --- drivers/dma/xilinx/xdma-regs.h | 1 + drivers/dma/xilinx/xdma.c | 55 ++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/drivers/dma/xilinx/xdma-regs.h b/drivers/dma/xilinx/xdma-regs.h index e641a5083e14..1f17ce165f92 100644 --- a/drivers/dma/xilinx/xdma-regs.h +++ b/drivers/dma/xilinx/xdma-regs.h @@ -76,6 +76,7 @@ struct xdma_hw_desc { #define XDMA_CHAN_CONTROL_W1S 0x8 #define XDMA_CHAN_CONTROL_W1C 0xc #define XDMA_CHAN_STATUS 0x40 +#define XDMA_CHAN_STATUS_RC 0x44 #define XDMA_CHAN_COMPLETED_DESC 0x48 #define XDMA_CHAN_ALIGNMENTS 0x4c #define XDMA_CHAN_INTR_ENABLE 0x90 diff --git a/drivers/dma/xilinx/xdma.c b/drivers/dma/xilinx/xdma.c index 84a88029226f..58539a093de2 100644 --- a/drivers/dma/xilinx/xdma.c +++ b/drivers/dma/xilinx/xdma.c @@ -632,6 +632,59 @@ xdma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t address, return NULL; } +/** + * xdma_terminate_all - Halt the DMA channel + * @chan: DMA channel + */ +static int xdma_terminate_all(struct dma_chan *chan) +{ + int ret; + u32 val; + unsigned long flags; + struct xdma_chan *xchan = to_xdma_chan(chan); + struct xdma_device *xdev = xchan->xdev_hdl; + struct virt_dma_desc *vd; + LIST_HEAD(head); + + /* Clear the RUN bit to stop the transfer */ + ret = regmap_write(xdev->rmap, xchan->base + XDMA_CHAN_CONTROL_W1C, + CHAN_CTRL_RUN_STOP); + if (ret) + return ret; + + /* Clear the channel status register */ + ret = regmap_read(xdev->rmap, xchan->base + XDMA_CHAN_STATUS_RC, &val); + if (ret) + return ret; + + spin_lock_irqsave(&xchan->vchan.lock, flags); + + /* Don't care if there were no descriptors issued */ + vd = vchan_next_desc(&xchan->vchan); + if (vd) { + list_del(&vd->node); + vchan_terminate_vdesc(vd); + } + vchan_get_all_descriptors(&xchan->vchan, &head); + list_splice_tail_init(&head, &xchan->vchan.desc_terminated); + + xchan->busy = false; + spin_unlock_irqrestore(&xchan->vchan.lock, flags); + + return 0; +} + +/** + * xdma_synchronize - Synchronize current execution context to the DMA channel + * @chan: DMA channel + */ +static void xdma_synchronize(struct dma_chan *chan) +{ + struct xdma_chan *xchan = to_xdma_chan(chan); + + vchan_synchronize(&xchan->vchan); +} + /** * xdma_device_config - Configure the DMA channel * @chan: DMA channel @@ -1093,6 +1146,8 @@ static int xdma_probe(struct platform_device *pdev) xdev->dma_dev.filter.mapcnt = pdata->device_map_cnt; xdev->dma_dev.filter.fn = xdma_filter_fn; xdev->dma_dev.device_prep_dma_cyclic = xdma_prep_dma_cyclic; + xdev->dma_dev.device_terminate_all = xdma_terminate_all; + xdev->dma_dev.device_synchronize = xdma_synchronize; ret = dma_async_device_register(&xdev->dma_dev); if (ret) { From patchwork Wed Nov 22 22:09:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kuliga X-Patchwork-Id: 13465475 Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=alatek.krakow.pl header.i=@alatek.krakow.pl header.b="QzalEWDB" X-Greylist: delayed 122 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 22 Nov 2023 14:10:56 PST Received: from helios.alatek.com.pl (helios.alatek.com.pl [85.14.123.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DDCCB9; Wed, 22 Nov 2023 14:10:56 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by helios.alatek.com.pl (Postfix) with ESMTP id 3A0782D00B62; Wed, 22 Nov 2023 23:10:54 +0100 (CET) Received: from helios.alatek.com.pl ([127.0.0.1]) by localhost (helios.alatek.com.pl [127.0.0.1]) (amavis, port 10032) with ESMTP id 7_61pp17CotE; Wed, 22 Nov 2023 23:10:53 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by helios.alatek.com.pl (Postfix) with ESMTP id BA0802D00B61; Wed, 22 Nov 2023 23:10:53 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 helios.alatek.com.pl BA0802D00B61 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alatek.krakow.pl; s=99EE5E86-D06A-11EC-BE24-DBCCD0A148D3; t=1700691053; bh=zqhIViRnFAruL/za3c8L0vX7XiguXIze1f1rq462g3c=; h=From:To:Date:Message-Id:MIME-Version; b=QzalEWDBuAGVa1ZsyGuBY5GIO6DI2q0cyCpPEznHTAzEnx4cW8hyU2I5NDijb19+6 /5+gITOl16ULH/mXAMmZWBmzOpECtVf0+ktncgaPU2fYQxNMVgsyZq3nkGprJIFHf6 ODGGu9KTQXxoGJF02NwqAdf+3Eo28aZDyv92awIcmZkZrvYZgBqiOCqdhlYAeO4odP LOIVFvzrzI7bIDEHSuSYwvKOGHZg5GGUdEqfXBZHspUYYfJmPvX+VR7IWGxJY/6V8L ObZRn6J/9OWJnNdFsU0dVjo89cJzJNt1q/ls713GLjoC5uw1Ss/CYXylv0Jb95qfIL 0LuGAgnIjAXcQ== X-Virus-Scanned: amavis at alatek.com.pl Received: from helios.alatek.com.pl ([127.0.0.1]) by localhost (helios.alatek.com.pl [127.0.0.1]) (amavis, port 10026) with ESMTP id a-T0EIX3QnDb; Wed, 22 Nov 2023 23:10:53 +0100 (CET) Received: from ideapad.. (unknown [10.0.2.2]) by helios.alatek.com.pl (Postfix) with ESMTPSA id 81AD02D00B60; Wed, 22 Nov 2023 23:10:53 +0100 (CET) From: Jan Kuliga To: lizhi.hou@amd.com, brian.xu@amd.com, raj.kumar.rampelli@amd.com, vkoul@kernel.org, michal.simek@amd.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jan Kuliga Subject: [PATCH 2/5] dmaengine: xilinx: xdma: Get rid of duplicated macros definitions Date: Wed, 22 Nov 2023 23:09:18 +0100 Message-Id: <20231122220921.117428-3-jankul@alatek.krakow.pl> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231122220830.117403-1-jankul@alatek.krakow.pl> References: <20231122220830.117403-1-jankul@alatek.krakow.pl> Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 These macros are defined earlier in the file. Signed-off-by: Jan Kuliga --- drivers/dma/xilinx/xdma-regs.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/dma/xilinx/xdma-regs.h b/drivers/dma/xilinx/xdma-regs.h index 1f17ce165f92..7a169377b483 100644 --- a/drivers/dma/xilinx/xdma-regs.h +++ b/drivers/dma/xilinx/xdma-regs.h @@ -135,18 +135,6 @@ struct xdma_hw_desc { #define XDMA_SGDMA_DESC_ADJ 0x4088 #define XDMA_SGDMA_DESC_CREDIT 0x408c -/* bits of the SG DMA control register */ -#define XDMA_CTRL_RUN_STOP BIT(0) -#define XDMA_CTRL_IE_DESC_STOPPED BIT(1) -#define XDMA_CTRL_IE_DESC_COMPLETED BIT(2) -#define XDMA_CTRL_IE_DESC_ALIGN_MISMATCH BIT(3) -#define XDMA_CTRL_IE_MAGIC_STOPPED BIT(4) -#define XDMA_CTRL_IE_IDLE_STOPPED BIT(6) -#define XDMA_CTRL_IE_READ_ERROR GENMASK(13, 9) -#define XDMA_CTRL_IE_DESC_ERROR GENMASK(23, 19) -#define XDMA_CTRL_NON_INCR_ADDR BIT(25) -#define XDMA_CTRL_POLL_MODE_WB BIT(26) - /* * interrupt registers */ From patchwork Wed Nov 22 22:09:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kuliga X-Patchwork-Id: 13465476 Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=alatek.krakow.pl header.i=@alatek.krakow.pl header.b="f4s1fWSQ" Received: from helios.alatek.com.pl (helios.alatek.com.pl [85.14.123.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D185E1A5; Wed, 22 Nov 2023 14:11:05 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by helios.alatek.com.pl (Postfix) with ESMTP id C22492D00B62; Wed, 22 Nov 2023 23:11:03 +0100 (CET) Received: from helios.alatek.com.pl ([127.0.0.1]) by localhost (helios.alatek.com.pl [127.0.0.1]) (amavis, port 10032) with ESMTP id pdB1MUBkCbJE; Wed, 22 Nov 2023 23:11:03 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by helios.alatek.com.pl (Postfix) with ESMTP id 8278E2D00B61; Wed, 22 Nov 2023 23:11:03 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 helios.alatek.com.pl 8278E2D00B61 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alatek.krakow.pl; s=99EE5E86-D06A-11EC-BE24-DBCCD0A148D3; t=1700691063; bh=H3UOebWbztiN0l07oDLxMwZHegqQNqhnZ63Q4IX1xxM=; h=From:To:Date:Message-Id:MIME-Version; b=f4s1fWSQb78tnRN8iWTm6t5zobvN/vf5Y+pkArUjEzkaWzD6VOiUuNW6iQDsyJXTm kfPax90sQk4wNCApvnYZfwy08Anb/vZYR5G/3J8vvbbHaelNO2pRiEnzukOL5N9sQN A341E0ydkBBeZcEMgZN/q/+DtcgAYjBBC0QNYTzzmpaacYEnFxe6CVSaDds3UaUqoI hO5OGNq0iN5PcEMxfqpYHTxcDDYvOcijYkxT6LRGtJ9tCDr/Qau6I3IzuTrNPlRGNH +eE9d+dmlEwQq58xQuZJnOVZDx8btyBblyjqfdEbo5gnIyRYiDnT/fArCW3NuUI+tp H9sk3TGlzZIQA== X-Virus-Scanned: amavis at alatek.com.pl Received: from helios.alatek.com.pl ([127.0.0.1]) by localhost (helios.alatek.com.pl [127.0.0.1]) (amavis, port 10026) with ESMTP id MVhGrBPj2ONb; Wed, 22 Nov 2023 23:11:03 +0100 (CET) Received: from ideapad.. (unknown [10.0.2.2]) by helios.alatek.com.pl (Postfix) with ESMTPSA id 4C4D32D00B60; Wed, 22 Nov 2023 23:11:03 +0100 (CET) From: Jan Kuliga To: lizhi.hou@amd.com, brian.xu@amd.com, raj.kumar.rampelli@amd.com, vkoul@kernel.org, michal.simek@amd.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jan Kuliga Subject: [PATCH 3/5] dmaengine: xilinx: xdma: Complete lacking register description Date: Wed, 22 Nov 2023 23:09:19 +0100 Message-Id: <20231122220921.117428-4-jankul@alatek.krakow.pl> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231122220830.117403-1-jankul@alatek.krakow.pl> References: <20231122220830.117403-1-jankul@alatek.krakow.pl> Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Complete lacking bits, that describe the status/control register values. Signed-off-by: Jan Kuliga --- drivers/dma/xilinx/xdma-regs.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/dma/xilinx/xdma-regs.h b/drivers/dma/xilinx/xdma-regs.h index 7a169377b483..654c5e41112d 100644 --- a/drivers/dma/xilinx/xdma-regs.h +++ b/drivers/dma/xilinx/xdma-regs.h @@ -102,6 +102,7 @@ struct xdma_hw_desc { #define CHAN_CTRL_IE_MAGIC_STOPPED BIT(4) #define CHAN_CTRL_IE_IDLE_STOPPED BIT(6) #define CHAN_CTRL_IE_READ_ERROR GENMASK(13, 9) +#define CHAN_CTRL_IE_WRITE_ERROR GENMASK(18, 14) #define CHAN_CTRL_IE_DESC_ERROR GENMASK(23, 19) #define CHAN_CTRL_NON_INCR_ADDR BIT(25) #define CHAN_CTRL_POLL_MODE_WB BIT(26) @@ -112,6 +113,7 @@ struct xdma_hw_desc { CHAN_CTRL_IE_DESC_ALIGN_MISMATCH | \ CHAN_CTRL_IE_MAGIC_STOPPED | \ CHAN_CTRL_IE_READ_ERROR | \ + CHAN_CTRL_IE_WRITE_ERROR | \ CHAN_CTRL_IE_DESC_ERROR) /* bits of the channel interrupt enable mask */ From patchwork Wed Nov 22 22:09:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kuliga X-Patchwork-Id: 13465477 Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=alatek.krakow.pl header.i=@alatek.krakow.pl header.b="hNI956b+" Received: from helios.alatek.com.pl (helios.alatek.com.pl [85.14.123.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A7F8D60; Wed, 22 Nov 2023 14:11:15 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by helios.alatek.com.pl (Postfix) with ESMTP id 33FF92D00B64; Wed, 22 Nov 2023 23:11:13 +0100 (CET) Received: from helios.alatek.com.pl ([127.0.0.1]) by localhost (helios.alatek.com.pl [127.0.0.1]) (amavis, port 10032) with ESMTP id lZtZOJ0CpnMK; Wed, 22 Nov 2023 23:11:12 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by helios.alatek.com.pl (Postfix) with ESMTP id DA8372D00B62; Wed, 22 Nov 2023 23:11:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 helios.alatek.com.pl DA8372D00B62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alatek.krakow.pl; s=99EE5E86-D06A-11EC-BE24-DBCCD0A148D3; t=1700691072; bh=2g2bmVj9SU3TVbirdM1FQyRxNd9ZH2+KEdtfAh0SdvE=; h=From:To:Date:Message-Id:MIME-Version; b=hNI956b+XzSkkYw/4p2g3NaXQ4e+U/EUUMMsoB+G11hxr+oboFsusaUDx1HKfxl48 SDhFOuAzPXXhVSjsqaTQDY0NQcgvPtQNBZZFxzcBvqgLWjh0nX+Efa5L4j30b7Oo97 zuymZw3vcVM+j+wFomhfPRvv10ZkKRIZeamhLoH4MUAGBnWNUtqHm3qUbX7XMo2hy0 wSfp63o9zVSVdsEWJFkLlZdXxs19wr/h85yZUFT/q9YuuoRgBIpd8Xtj2ZEclVk376 UB9Viy7/G7xCICepLkEVcSVGZS9L5zaZP5rTvVqQuCxj24QartfynnuRvS9jGyoXKY /esb985kjZKKw== X-Virus-Scanned: amavis at alatek.com.pl Received: from helios.alatek.com.pl ([127.0.0.1]) by localhost (helios.alatek.com.pl [127.0.0.1]) (amavis, port 10026) with ESMTP id 5SsUR_9Zgj94; Wed, 22 Nov 2023 23:11:12 +0100 (CET) Received: from ideapad.. (unknown [10.0.2.2]) by helios.alatek.com.pl (Postfix) with ESMTPSA id 966852D00B60; Wed, 22 Nov 2023 23:11:12 +0100 (CET) From: Jan Kuliga To: lizhi.hou@amd.com, brian.xu@amd.com, raj.kumar.rampelli@amd.com, vkoul@kernel.org, michal.simek@amd.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jan Kuliga Subject: [PATCH 4/5] dmaengine: xilinx: xdma: Rework xdma_channel_isr() Date: Wed, 22 Nov 2023 23:09:20 +0100 Message-Id: <20231122220921.117428-5-jankul@alatek.krakow.pl> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231122220830.117403-1-jankul@alatek.krakow.pl> References: <20231122220830.117403-1-jankul@alatek.krakow.pl> Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The xdma's channel status register may be read and cleared simultaneously, by accessing it via separate XDMA_CHAN_STATUS_RC register. Therefore, it is possible to simplify the code by just getting rid of a separate redundant write. Also, implement the actual status register checking as well. Previously, the cyclic callback would be scheduled regardless of the status register state. Fix it. Signed-off-by: Jan Kuliga --- drivers/dma/xilinx/xdma-regs.h | 2 ++ drivers/dma/xilinx/xdma.c | 17 +++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/dma/xilinx/xdma-regs.h b/drivers/dma/xilinx/xdma-regs.h index 654c5e41112d..6bf7ae84e452 100644 --- a/drivers/dma/xilinx/xdma-regs.h +++ b/drivers/dma/xilinx/xdma-regs.h @@ -116,6 +116,8 @@ struct xdma_hw_desc { CHAN_CTRL_IE_WRITE_ERROR | \ CHAN_CTRL_IE_DESC_ERROR) +#define XDMA_CHAN_STATUS_MASK CHAN_CTRL_START + /* bits of the channel interrupt enable mask */ #define CHAN_IM_DESC_ERROR BIT(19) #define CHAN_IM_READ_ERROR BIT(9) diff --git a/drivers/dma/xilinx/xdma.c b/drivers/dma/xilinx/xdma.c index 58539a093de2..dc7f43f17103 100644 --- a/drivers/dma/xilinx/xdma.c +++ b/drivers/dma/xilinx/xdma.c @@ -809,15 +809,16 @@ static irqreturn_t xdma_channel_isr(int irq, void *dev_id) desc->completed_desc_num += complete_desc_num; - if (desc->cyclic) { - ret = regmap_read(xdev->rmap, xchan->base + XDMA_CHAN_STATUS, - &st); - if (ret) - goto out; - - regmap_write(xdev->rmap, xchan->base + XDMA_CHAN_STATUS, st); + /* clear-on-read the status register */ + ret = regmap_read(xdev->rmap, xchan->base + XDMA_CHAN_STATUS_RC, + &st); + if (ret) + goto out; - vchan_cyclic_callback(vd); + if (desc->cyclic) { + st &= XDMA_CHAN_STATUS_MASK; + if (st & CHAN_CTRL_IE_DESC_COMPLETED) + vchan_cyclic_callback(vd); goto out; } From patchwork Wed Nov 22 22:09:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kuliga X-Patchwork-Id: 13465478 Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=alatek.krakow.pl header.i=@alatek.krakow.pl header.b="ub4fzT4y" Received: from helios.alatek.com.pl (helios.alatek.com.pl [85.14.123.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41571D4F; Wed, 22 Nov 2023 14:11:21 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by helios.alatek.com.pl (Postfix) with ESMTP id 399FC2D00B67; Wed, 22 Nov 2023 23:11:19 +0100 (CET) Received: from helios.alatek.com.pl ([127.0.0.1]) by localhost (helios.alatek.com.pl [127.0.0.1]) (amavis, port 10032) with ESMTP id myf48UbQDSqH; Wed, 22 Nov 2023 23:11:19 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by helios.alatek.com.pl (Postfix) with ESMTP id DE31B2D00B66; Wed, 22 Nov 2023 23:11:18 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 helios.alatek.com.pl DE31B2D00B66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alatek.krakow.pl; s=99EE5E86-D06A-11EC-BE24-DBCCD0A148D3; t=1700691078; bh=uZ+7hCD2vT8n0SaxTdHVUD9PS0Q6BCcg7P18KUDliew=; h=From:To:Date:Message-Id:MIME-Version; b=ub4fzT4ygt8aOn+/jnwPW50jLQbpPDijox4ElW+v78BfJpHRHWKCQyu8YjrytjqVU lFcD1bco8NAaDw5TEFXPK1id6VTKWXIo7XXhuUDg9VaSJCd9P/WVtpn267AKtynv+U B2fyt0Hkxje5DqNaxT3Ew/xg5PQnHOY9CN4iGb4Y6snEgCNbWea13GUiKEdB/A63Xp R9/r0E2hdP4vPQM8yLLm6ufY8H5JyiExCWqBQBqXGiXm+4jEHkBsNPuZjOY/BHzRok QOMim/tlglzdJ2YVnp/zKCbO1+nUQ0jjSMv7mla6hcKhdI92UWDsycAxDlNsb48Lug ceZwUc8A2WkOg== X-Virus-Scanned: amavis at alatek.com.pl Received: from helios.alatek.com.pl ([127.0.0.1]) by localhost (helios.alatek.com.pl [127.0.0.1]) (amavis, port 10026) with ESMTP id D11LkTmYqi1Q; Wed, 22 Nov 2023 23:11:18 +0100 (CET) Received: from ideapad.. (unknown [10.0.2.2]) by helios.alatek.com.pl (Postfix) with ESMTPSA id A68B92D00B64; Wed, 22 Nov 2023 23:11:18 +0100 (CET) From: Jan Kuliga To: lizhi.hou@amd.com, brian.xu@amd.com, raj.kumar.rampelli@amd.com, vkoul@kernel.org, michal.simek@amd.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jan Kuliga Subject: [PATCH 5/5] dmaengine: xilinx: xdma: Ease dma_pool alignment requirements Date: Wed, 22 Nov 2023 23:09:21 +0100 Message-Id: <20231122220921.117428-6-jankul@alatek.krakow.pl> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231122220830.117403-1-jankul@alatek.krakow.pl> References: <20231122220830.117403-1-jankul@alatek.krakow.pl> Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 According to the XDMA datasheet (PG195), the address of any descriptor must be 32 byte aligned. The datasheet also states that a contiguous block of descriptors must not cross a 4k address boundary. Therefore, it is possible to ease the pressure put on the dma_pool allocator just by requiring sufficient alignment and boundary values. Add proper macro definition and change the values passed into the dma_pool_create(). Signed-off-by: Jan Kuliga --- drivers/dma/xilinx/xdma-regs.h | 7 ++++--- drivers/dma/xilinx/xdma.c | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/dma/xilinx/xdma-regs.h b/drivers/dma/xilinx/xdma-regs.h index 6bf7ae84e452..d5cb12e6b8d4 100644 --- a/drivers/dma/xilinx/xdma-regs.h +++ b/drivers/dma/xilinx/xdma-regs.h @@ -64,9 +64,10 @@ struct xdma_hw_desc { __le64 next_desc; }; -#define XDMA_DESC_SIZE sizeof(struct xdma_hw_desc) -#define XDMA_DESC_BLOCK_SIZE (XDMA_DESC_SIZE * XDMA_DESC_ADJACENT) -#define XDMA_DESC_BLOCK_ALIGN 4096 +#define XDMA_DESC_SIZE sizeof(struct xdma_hw_desc) +#define XDMA_DESC_BLOCK_SIZE (XDMA_DESC_SIZE * XDMA_DESC_ADJACENT) +#define XDMA_DESC_BLOCK_ALIGN 32 +#define XDMA_DESC_BLOCK_BOUNDARY 4096 /* * Channel registers diff --git a/drivers/dma/xilinx/xdma.c b/drivers/dma/xilinx/xdma.c index dc7f43f17103..9e382ce524a4 100644 --- a/drivers/dma/xilinx/xdma.c +++ b/drivers/dma/xilinx/xdma.c @@ -730,9 +730,9 @@ static int xdma_alloc_chan_resources(struct dma_chan *chan) return -EINVAL; } - xdma_chan->desc_pool = dma_pool_create(dma_chan_name(chan), - dev, XDMA_DESC_BLOCK_SIZE, - XDMA_DESC_BLOCK_ALIGN, 0); + xdma_chan->desc_pool = dma_pool_create(dma_chan_name(chan), dev, + XDMA_DESC_BLOCK_SIZE, XDMA_DESC_BLOCK_ALIGN, + XDMA_DESC_BLOCK_BOUNDARY); if (!xdma_chan->desc_pool) { xdma_err(xdev, "unable to allocate descriptor pool"); return -ENOMEM;