Received: by 2002:a05:7412:e79e:b0:f3:1519:9f41 with SMTP id o30csp230160rdd; Wed, 22 Nov 2023 14:19:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbAdEsVxhJEgUQGDN0qPaiohxp5xV3W65RmVW4JUAIxgG9QjIN+WZITSh2es8qaG/zGYS0 X-Received: by 2002:a17:90a:7405:b0:27e:31a:2ab2 with SMTP id a5-20020a17090a740500b0027e031a2ab2mr3575178pjg.34.1700691593127; Wed, 22 Nov 2023 14:19:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700691593; cv=none; d=google.com; s=arc-20160816; b=ZdA/fKgDcOHdeia1ae4fTdasJLJNfnOm+rn116wuTAvrTCYiX8Vh6Uk3Tmv9wB7jpI yngMt2+fqPM56I+7xfacVRuT4JaO2nuXkAhyVzrq/6hjF+v8vgPQKVj6g5G9vbkF3Xwo kNc8m9DZWQEmRBnVW43RHIqf2pE0HC0LFZoxCAPZtqEDa0kBK/OfxNrO1LZVcTbnky59 epdo/59l17sHULXPTEU4GB4ud1/wsxLtxRNZn+w6YDsr2zqprTn+fcqQJIfd8Qu80Cjw PSV20c6zlcr/qceJeo5swY2A7cv6PZUDzQ+/pJh+mFQpszyuW0yiKPUqo5qAv6WicZzR kgVw== 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:dkim-filter; bh=fRcRZDTsd7kJTaGjL723vrYFFja9y139VFQGM81sxdU=; fh=RXS5JGpuDELDxQ/4dQrraI6J+NZvDTOAkF/AHQypleY=; b=fA1ZXjS7RVMIo3Ti+KxfExXq6ulrPugLM4rDXToUn0dsznnCO0jGf4tfHjsZalQizP dW8nHv/ULzCADXztAl2CRDO2vwdE1RNcDW5zoYNzZHbKYS1VdOKSPK+PzKd4He+U8jUz hf+wCua+qE+heXtAh+hC8pw0tYOlcsaHc2hCt8qIrH8J2+0AR+ZyWDAuPcsovz4pm8TZ 2g/X+nn3gH6dr1B9hOZ2lwazkFhGH3vzEKBf+E1aTxoKbY2OLNaVo0fa1zipgRjoSeuR TEJD++GHBio6394K7BFUqmWfGlwcNiM98GtSVK1tWahCrq3CPpdAugATWUYa2Rj5iKqK N12g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@alatek.krakow.pl header.s=99EE5E86-D06A-11EC-BE24-DBCCD0A148D3 header.b=agfn9OWi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alatek.krakow.pl Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id ij25-20020a170902ab5900b001cc0c0f6332si325549plb.70.2023.11.22.14.19.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 14:19:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=fail header.i=@alatek.krakow.pl header.s=99EE5E86-D06A-11EC-BE24-DBCCD0A148D3 header.b=agfn9OWi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alatek.krakow.pl Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E9C848217EDA; Wed, 22 Nov 2023 14:19:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343586AbjKVWTo (ORCPT + 99 others); Wed, 22 Nov 2023 17:19:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235246AbjKVWTm (ORCPT ); Wed, 22 Nov 2023 17:19:42 -0500 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> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 14:19:50 -0800 (PST) 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-reg= s.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; } =20 +/** + * 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 =3D to_xdma_chan(chan); + struct xdma_device *xdev =3D xchan->xdev_hdl; + struct virt_dma_desc *vd; + LIST_HEAD(head); + + /* Clear the RUN bit to stop the transfer */ + ret =3D regmap_write(xdev->rmap, xchan->base + XDMA_CHAN_CONTROL_W1C, + CHAN_CTRL_RUN_STOP); + if (ret) + return ret; + + /* Clear the channel status register */ + ret =3D 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 =3D 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 =3D false; + spin_unlock_irqrestore(&xchan->vchan.lock, flags); + + return 0; +} + +/** + * xdma_synchronize - Synchronize current execution context to the DMA c= hannel + * @chan: DMA channel + */ +static void xdma_synchronize(struct dma_chan *chan) +{ + struct xdma_chan *xchan =3D 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 =3D pdata->device_map_cnt; xdev->dma_dev.filter.fn =3D xdma_filter_fn; xdev->dma_dev.device_prep_dma_cyclic =3D xdma_prep_dma_cyclic; + xdev->dma_dev.device_terminate_all =3D xdma_terminate_all; + xdev->dma_dev.device_synchronize =3D xdma_synchronize; =20 ret =3D dma_async_device_register(&xdev->dma_dev); if (ret) { --=20 2.34.1