Received: by 2002:a05:7412:a9a3:b0:f9:327e:43ab with SMTP id o35csp42629rdh; Mon, 18 Dec 2023 04:00:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCs8Vel2f6KvUdBnvxY+xbYztpo2Fh+46AN5PH2G65u2YcUEc86A8s0zfWmXKDW96/TPwK X-Received: by 2002:ad4:5d6c:0:b0:67f:62b:319b with SMTP id fn12-20020ad45d6c000000b0067f062b319bmr10358408qvb.6.1702900849492; Mon, 18 Dec 2023 04:00:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702900849; cv=none; d=google.com; s=arc-20160816; b=KZuCDm6YRHzjNJjNYDFTSgtXvLGljOfZNeAmpipb3FUykxSY6zB5C3V2eXv9wBu02Z E8qfsBgRsPles2NODMcqMDtLYc5BTuCe5g2r+hR2jZZroDdDA6CVYzXjcNwtnlQKBOTh 5UssnRPbjhoN6aYtRYudu8HEK6T5dRijFQevtyMzzGEir2DSDM29i51bIl95qz4+IQkX 9vmsqsDQhkrbBrpMGPOFo5PFpM0fikytyJApnuhd3z/SMQYY7vHqoFytfyNy3RR7SKG9 m6N1OyCvBT/J9qRMojnGQkxPtJPTUioDIcD/fPthBfRd0W9VBcklmfai823BuglWizLX fv6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature :dkim-filter; bh=pgFYSPvqKsZ76d/HoygOZjY81UNiyQPNXJuryyJ5YgI=; fh=8RwCgCW4pfY1TnUv9EvhKc09KSipuWbZdqLf3zx6S6E=; b=ctuVPxR1BVjMlFuwTOuhNnIbofHqtHh4eCg4CX8htMfoGBY48wAq3JH/YYu7yYIxM7 GzR2W59Bhv12JNcGEkFLi8+33W3ATgVVk/ydxJlwAtuDi+BzUUwQx3tbQAqLlKFBcYm0 rfgr9M4A+2vRyqXMVkC58BlG60wALu0FPgWFWl6iDFQgE/YNm26cZudJRTcU4CJp/tf3 T7gYOdoV4K1snKpG/bxpxR5NEk2TzVU2r3NysdNoDY4W+gMYhg8Fkyh56qXPakKc/Vki MPA0cAEtWRjkHOD7bR1VVRrWz9rLV5/6VyFHm0NHtxNs6pULGRawJ5U+PUlgO5wBDXXb znxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@alatek.krakow.pl header.s=99EE5E86-D06A-11EC-BE24-DBCCD0A148D3 header.b=gwYdAwLw; spf=pass (google.com: domain of linux-kernel+bounces-3512-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3512-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alatek.krakow.pl Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ay29-20020a05622a229d00b00423a30ba7a3si24652791qtb.125.2023.12.18.04.00.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 04:00:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3512-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=fail header.i=@alatek.krakow.pl header.s=99EE5E86-D06A-11EC-BE24-DBCCD0A148D3 header.b=gwYdAwLw; spf=pass (google.com: domain of linux-kernel+bounces-3512-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3512-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alatek.krakow.pl Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 32BFA1C233E5 for ; Mon, 18 Dec 2023 12:00:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1F1D41C86; Mon, 18 Dec 2023 11:52:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=alatek.krakow.pl header.i=@alatek.krakow.pl header.b="gwYdAwLw" X-Original-To: linux-kernel@vger.kernel.org Received: from helios.alatek.com.pl (helios.alatek.com.pl [85.14.123.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8E8641212; Mon, 18 Dec 2023 11:52:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alatek.krakow.pl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alatek.krakow.pl Received: from localhost (localhost [127.0.0.1]) by helios.alatek.com.pl (Postfix) with ESMTP id D39B22D01875; Mon, 18 Dec 2023 12:52:30 +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 ojvRBzrblCMI; Mon, 18 Dec 2023 12:52:26 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by helios.alatek.com.pl (Postfix) with ESMTP id D5ADD2D01877; Mon, 18 Dec 2023 12:52:26 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 helios.alatek.com.pl D5ADD2D01877 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alatek.krakow.pl; s=99EE5E86-D06A-11EC-BE24-DBCCD0A148D3; t=1702900346; bh=pgFYSPvqKsZ76d/HoygOZjY81UNiyQPNXJuryyJ5YgI=; h=Message-ID:Date:MIME-Version:To:From; b=gwYdAwLwPzOv7TzzKPBainbIFgrssAJfXlK0vlYm3XVUL7hKnWxXpUneM0S32+uaj iXnhrRD9r0ZmGqf2GNuQXfyFcjSlH4rkYnvS1CjOk/b62ZGu9E+kUkuMnAb08Pyc7u TItVfQcam071NDZy8riZzR6+2LafNYX6BJxijU3oOQOZn6hHTOdz+n2k5bwOTfy+uT BZAs7E0hVyTB6WdBXnpZvrcVyEohVVZEQi6KjIq67/CkGo/TVPlE1hPdKxjLMWLMvf EUkH2TZj4HLZV6ixuz7rNrqiu/+/hLnuc0v+6eVqUEs5+2IJskJalBzYZtQrqxS1dU c3Vz7rNTW6U1w== 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 TCCewzLwpviW; Mon, 18 Dec 2023 12:52:26 +0100 (CET) Received: from [192.168.1.103] (unknown [10.0.2.2]) by helios.alatek.com.pl (Postfix) with ESMTPSA id A6A912D01875; Mon, 18 Dec 2023 12:52:26 +0100 (CET) Message-ID: <49d892ae-5986-43c2-bdad-2ad09be298f2@alatek.krakow.pl> Date: Mon, 18 Dec 2023 12:52:26 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 4/8] dmaengine: xilinx: xdma: Rework xdma_terminate_all() To: Vinod Koul Cc: lizhi.hou@amd.com, brian.xu@amd.com, raj.kumar.rampelli@amd.com, michal.simek@amd.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, miquel.raynal@bootlin.com References: <20231208134838.49500-1-jankul@alatek.krakow.pl> <20231208134929.49523-5-jankul@alatek.krakow.pl> Content-Language: en-US From: Jan Kuliga In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Vinod, Thanks for reviewing my patchset. On 11.12.2023 11:54, Vinod Koul wrote: > On 08-12-23, 14:49, Jan Kuliga wrote: >> Simplify xdma_xfer_stop(). Stop the dma engine and clear its status >> register unconditionally - just do what its name states. This change >> also allows to call it without grabbing a lock, which minimizes >> the total time spent with a spinlock held. >> >> Delete the currently processed vd.node from the vc.desc_issued list >> prior to passing it to vchan_terminate_vdesc(). In case there's more >> than one descriptor pending on vc.desc_issued list, calling >> vchan_terminate_desc() results in losing the link between >> vc.desc_issued list head and the second descriptor on the list. Doing so >> results in resources leakege, as vchan_dma_desc_free_list() won't be >> able to properly free memory resources attached to descriptors, >> resulting in dma_pool_destroy() failure. >> >> Don't call vchan_dma_desc_free_list() from within xdma_terminate_all(). >> Move all terminated descriptors to the vc.desc_terminated list instead. >> This allows to postpone freeing memory resources associated with >> descriptors until the call to vchan_synchronize(), which is called from >> xdma_synchronize() callback. This is the right way to do it - >> xdma_terminate_all() should return as soon as possible, while freeing >> resources (that may be time consuming in case of large number of >> descriptors) can be done safely later. >> >> Fixes: 290bb5d2d1e2 >> ("dmaengine: xilinx: xdma: Add terminate_all/synchronize callbacks") >> >> Signed-off-by: Jan Kuliga >> --- >> drivers/dma/xilinx/xdma.c | 32 ++++++++++++++++---------------- >> 1 file changed, 16 insertions(+), 16 deletions(-) >> >> diff --git a/drivers/dma/xilinx/xdma.c b/drivers/dma/xilinx/xdma.c >> index 1bce48e5d86c..521ba2a653b6 100644 >> --- a/drivers/dma/xilinx/xdma.c >> +++ b/drivers/dma/xilinx/xdma.c >> @@ -379,20 +379,20 @@ static int xdma_xfer_start(struct xdma_chan *xchan) >> */ >> static int xdma_xfer_stop(struct xdma_chan *xchan) >> { >> - struct virt_dma_desc *vd = vchan_next_desc(&xchan->vchan); >> - struct xdma_device *xdev = xchan->xdev_hdl; >> int ret; >> - >> - if (!vd || !xchan->busy) >> - return -EINVAL; >> + u32 val; >> + struct xdma_device *xdev = xchan->xdev_hdl; >> >> /* clear run stop bit to prevent any further auto-triggering */ >> ret = regmap_write(xdev->rmap, xchan->base + XDMA_CHAN_CONTROL_W1C, >> - CHAN_CTRL_RUN_STOP); >> + CHAN_CTRL_RUN_STOP); > > Why this change, checkpatch would tell you this is not expected > alignment (run with strict) Actually, it does not. I've run it like this: $LINUX_DIR/scripts/checkpatch.pl --strict -g and it produced no output related to this line. Anyway, I've already prepared v5 patchset, that conforms to your hint: Message-Id: 20231218113904.9071-1-jankul@alatek.krakow.pl > >> i.f (ret) >> return ret; >> >> - xchan->busy = false; >> + /* Clear the channel status register */ >> + ret = regmap_read(xdev->rmap, xchan->base + XDMA_CHAN_STATUS_RC, &val); >> + if (ret) >> + return ret; >> >> return 0; >> } >> @@ -505,25 +505,25 @@ static void xdma_issue_pending(struct dma_chan *chan) >> static int xdma_terminate_all(struct dma_chan *chan) >> { >> struct xdma_chan *xdma_chan = to_xdma_chan(chan); >> - struct xdma_desc *desc = NULL; >> struct virt_dma_desc *vd; >> unsigned long flags; >> LIST_HEAD(head); >> >> - spin_lock_irqsave(&xdma_chan->vchan.lock, flags); >> xdma_xfer_stop(xdma_chan); >> >> + spin_lock_irqsave(&xdma_chan->vchan.lock, flags); >> + >> + xdma_chan->busy = false; >> vd = vchan_next_desc(&xdma_chan->vchan); >> - if (vd) >> - desc = to_xdma_desc(vd); >> - if (desc) { >> - dma_cookie_complete(&desc->vdesc.tx); >> - vchan_terminate_vdesc(&desc->vdesc); >> + if (vd) { >> + list_del(&vd->node); >> + dma_cookie_complete(&vd->tx); >> + vchan_terminate_vdesc(vd); >> } >> - >> vchan_get_all_descriptors(&xdma_chan->vchan, &head); >> + list_splice_tail(&head, &xdma_chan->vchan.desc_terminated); >> + >> spin_unlock_irqrestore(&xdma_chan->vchan.lock, flags); >> - vchan_dma_desc_free_list(&xdma_chan->vchan, &head); >> >> return 0; >> } >> -- >> 2.34.1 > Thanks, Jan