From patchwork Fri Sep 22 16:20:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 143648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5852163vqi; Fri, 22 Sep 2023 13:36:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMZ+aLJJjTsu6FX11rebrlmsE3ESY7sBBPDD5LRZggDKkseTeuHGc/tMHTLzSTpei5DiAJ X-Received: by 2002:a17:902:e54c:b0:1c1:ec40:9321 with SMTP id n12-20020a170902e54c00b001c1ec409321mr657013plf.60.1695415001740; Fri, 22 Sep 2023 13:36:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695415001; cv=none; d=google.com; s=arc-20160816; b=L2LW+udQaGi9TLbFgMANBVMkTMzhFZOOez4YlDsg0Q7BULApuUSTFGbvEItMO5YJM6 jcL6Wqaa9NITmWmol5mt8HAQAA6iB4cxF/PTQjXfUkuhHt0kufG5xXX8Apk6yA5BcI/1 EfnID40kzXQEBrR0diR8yoCMdXLgsjs6SdS/ppSjk3fiLoMHoxC7PospeM2qGBIWdQl8 tI6Yq+TYG+tj9ae4pme6rAS+5MTOiygQSQXIVnew1NeIVmbEP+JrAbS/69zl8lpk1ozu i6ldSk0gyWlFFmHHCn3o8tyyiYEJQxCOsV/Q7vtoHCqlZKvGxq643B0rh8a8/cPwjEQu JbTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3n0vwmgGryrUp3/6Ss9kZWLenWVOSWlr6mGiYIMJzv4=; fh=tywAdliBLaC/RMgy7zSP3YxJOfCkdci4rwwkuNbi5gM=; b=tykPkdEqSvxl4q5NS+ubdZ1Yc3WYUod4bz0XbhlGxeouWQVs7kZJs2h+kkDRnoYw1v c8Fw9jeWBrDcef0OYOsSLROOg1BEDrAe6GB98u/gQcPnRdx5A+amYDu/vFQ0bZGTiDXa QqixzSm2GJKWaJV12ptvVA804yaPnBmuZZQQmB8ArSVuhqCKiQ5dmCvYq/PQR6YUYjQ4 rjNlOE/2Osbm9J3olytEsS3pla026A+1pot0e2x5T9gcPj1fWQnatdvDsvmM4U1JEc1T sKWY8QbExztfIqq+D33VLt58jpChnZBtzmV+f2KYGwVWM8meb+oCzAduLbpsia35oyPU 9xRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="OgKk6S/r"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id kz4-20020a170902f9c400b001c20db25108si4216290plb.41.2023.09.22.13.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 13:36:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="OgKk6S/r"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 4CEDF83C5BAB; Fri, 22 Sep 2023 09:21:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231128AbjIVQVM (ORCPT + 29 others); Fri, 22 Sep 2023 12:21:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229698AbjIVQVL (ORCPT ); Fri, 22 Sep 2023 12:21:11 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BC50197; Fri, 22 Sep 2023 09:21:04 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 01453E0004; Fri, 22 Sep 2023 16:21:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1695399662; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3n0vwmgGryrUp3/6Ss9kZWLenWVOSWlr6mGiYIMJzv4=; b=OgKk6S/r44Py+XcCLS/dK0iZ3mOTBl8kEguo0y8rjlnZIOUeg+AJfLZHE+qP1QIVhWYOpr tiCwAQ90EUZcIxuCEeBMQf4r+Vxc6uOcIJeorypNBKnmEi5p1NvMBYSjGWtKq/xrmNF7pU /8RrLHLnzrfWld0oPPkOja4xprELWiWQYxQHW12NqGhBFKVC/DOUDl1JECNA5oNfaod5Eo 1ZgBAniOds503plyicEYdnXJ9NvderpZYjKdlmQucX2xNOJClTOrQuhDVV872kwxZfByJ/ tB5u5k0JbKmRI4qWiueDMbVNTTai53ipD59J1+gon96qoPU3ycpv3HbYZoAYrQ== From: Miquel Raynal To: Lizhi Hou , Brian Xu , Raj Kumar Rampelli , Vinod Koul , Michal Simek Cc: dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , , Miquel Raynal Subject: [PATCH v2 1/2] dmaengine: xilinx: xdma: Prepare the introduction of cyclic transfers Date: Fri, 22 Sep 2023 18:20:55 +0200 Message-Id: <20230922162056.594933-2-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922162056.594933-1-miquel.raynal@bootlin.com> References: <20230922162056.594933-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: miquel.raynal@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 22 Sep 2023 09:21:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777771480804777432 X-GMAIL-MSGID: 1777771480804777432 In order to reduce and clarify the diff when introducing cyclic transfers support, let's first prepare the driver a bit. There is no functional change. Signed-off-by: Miquel Raynal --- drivers/dma/xilinx/xdma.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/dma/xilinx/xdma.c b/drivers/dma/xilinx/xdma.c index e0bfd129d563..09ed13d6666d 100644 --- a/drivers/dma/xilinx/xdma.c +++ b/drivers/dma/xilinx/xdma.c @@ -137,10 +137,10 @@ static inline void *xdma_blk_last_desc(struct xdma_desc_block *block) } /** - * xdma_link_desc_blocks - Link descriptor blocks for DMA transfer + * xdma_link_sg_desc_blocks - Link SG descriptor blocks for DMA transfer * @sw_desc: Tx descriptor pointer */ -static void xdma_link_desc_blocks(struct xdma_desc *sw_desc) +static void xdma_link_sg_desc_blocks(struct xdma_desc *sw_desc) { struct xdma_desc_block *block; u32 last_blk_desc, desc_control; @@ -239,6 +239,7 @@ xdma_alloc_desc(struct xdma_chan *chan, u32 desc_num) struct xdma_hw_desc *desc; dma_addr_t dma_addr; u32 dblk_num; + u32 control; void *addr; int i, j; @@ -254,6 +255,8 @@ xdma_alloc_desc(struct xdma_chan *chan, u32 desc_num) if (!sw_desc->desc_blocks) goto failed; + control = XDMA_DESC_CONTROL(1, 0); + sw_desc->dblk_num = dblk_num; for (i = 0; i < sw_desc->dblk_num; i++) { addr = dma_pool_alloc(chan->desc_pool, GFP_NOWAIT, &dma_addr); @@ -263,10 +266,10 @@ xdma_alloc_desc(struct xdma_chan *chan, u32 desc_num) sw_desc->desc_blocks[i].virt_addr = addr; sw_desc->desc_blocks[i].dma_addr = dma_addr; for (j = 0, desc = addr; j < XDMA_DESC_ADJACENT; j++) - desc[j].control = cpu_to_le32(XDMA_DESC_CONTROL(1, 0)); + desc[j].control = cpu_to_le32(control); } - xdma_link_desc_blocks(sw_desc); + xdma_link_sg_desc_blocks(sw_desc); return sw_desc; @@ -577,6 +580,12 @@ static int xdma_alloc_chan_resources(struct dma_chan *chan) return 0; } +static enum dma_status xdma_tx_status(struct dma_chan *chan, dma_cookie_t cookie, + struct dma_tx_state *state) +{ + return dma_cookie_status(chan, cookie, state); +} + /** * xdma_channel_isr - XDMA channel interrupt handler * @irq: IRQ number @@ -925,7 +934,7 @@ static int xdma_probe(struct platform_device *pdev) xdev->dma_dev.dev = &pdev->dev; xdev->dma_dev.device_free_chan_resources = xdma_free_chan_resources; xdev->dma_dev.device_alloc_chan_resources = xdma_alloc_chan_resources; - xdev->dma_dev.device_tx_status = dma_cookie_status; + xdev->dma_dev.device_tx_status = xdma_tx_status; xdev->dma_dev.device_prep_slave_sg = xdma_prep_device_sg; xdev->dma_dev.device_config = xdma_device_config; xdev->dma_dev.device_issue_pending = xdma_issue_pending;