From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 854782376FD; Fri, 19 Dec 2025 10:43:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766140983; cv=none; b=GAJxY/SLTRBY55SJYQCM00S9p4zUDp5MFn7cVRpwMsek1H+x10yPUdodcbJe1H9VzPeypexoga/Gll1zb2Rl/+d2eJtfQL6KoCUYwMJqXmXi2ThUaGjjArUoIgQvK4hX0P7GwD7APze+8DV+DPFb4fzTYP4QcQu/hDuyrpu60vM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766140983; c=relaxed/simple; bh=xkz5LUlBElFB9CvO+KaW9xJq6o3zkwL/JUJof/pyJKA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=duZNV3qQdGCYfd5z6Oj72GMxTB9ZKoUFQsLH73hhV6vhcCD5NVQjf5pDGfUYJqK3T9srdXHdCUA5/uyvJkptI4+NLouOK7O6QdKddL8lbWdRYfhcBy6n4staKKUQE3g2ukU+yXFDFs4M700A4VTMDsoklK9q1tINDt28ves/cKo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IoSCk23s; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IoSCk23s" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFA22C116B1; Fri, 19 Dec 2025 10:42:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1766140982; bh=xkz5LUlBElFB9CvO+KaW9xJq6o3zkwL/JUJof/pyJKA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=IoSCk23sz5zIAMhhpVSs+yWPq39dQ9XP469p2h5DRvRKuQSWJCW2G3aAoGFxmnsjR Y32S/nKLSMqJ8XvXJKKPt1Pzpofi4UzTmoFWnZQTyGWFQz4ePg61LHGxoS+EcGC+NQ rfPbh8jYbxXKaB/AGYclGcYhStpeiAoJ/12kcGwbssjeStmDEloHn/SePTEosz4mwy G+vuPh2d0k95qzFbVEsc/KQWud+YIsUIaPB8UK+YQUGKiFYja2/8mIkLB/xrgH7i4X V+i7y2DKw0yuhlxec2sGVW+fAC912w7KlOivIwf7iRrBCC+ahIV3bcQIFwCrmc/BQQ Lj3bhY4plfj4w== Message-ID: <0fa95ea2-4539-472b-adae-300e46a78f20@kernel.org> Date: Fri, 19 Dec 2025 19:42:57 +0900 Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 6/8] nvmet: pci-epf: Use dmaengine_prep_config_single_safe() API To: Frank Li , Vinod Koul , Manivannan Sadhasivam , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Herbert Xu , "David S. Miller" , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Koichiro Den , Niklas Cassel Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-nvme@lists.infradead.org, mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev References: <20251218-dma_prep_config-v2-0-c07079836128@nxp.com> <20251218-dma_prep_config-v2-6-c07079836128@nxp.com> Content-Language: en-US From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <20251218-dma_prep_config-v2-6-c07079836128@nxp.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/19/25 00:56, Frank Li wrote: > Use the new dmaengine_prep_config_single_safe() API to combine the > configuration and descriptor preparation into a single call. > > Since dmaengine_prep_config_single_safe() performs the configuration and > preparation atomically and dw edma driver implement prep_config_sg() call > back, so dmaengine_prep_config_single() is reentriable, the mutex can be > removed. What about for platforms other than DesignWare EDMA ? This is a generic endpoint driver that can work on any platform that is endpoint capable and that has a DMA channel for the PCI endpoint. The dmaengine_prep_config_single_safe() API should be handling everything transparently for any platform, regardless of the DMA channel driver implementing or not the prep_config_sg() callback. For platforms that do not implement it, I suspect that the mutex will still be needed here. So how to we resolve this ? Ideally, all of that should be hidden by the DMA API. The endpoint driver should not need to deal with these differences. > > Tested-by: Niklas Cassel > Signed-off-by: Frank Li > --- > drivers/nvme/target/pci-epf.c | 18 ++++-------------- > 1 file changed, 4 insertions(+), 14 deletions(-) > > diff --git a/drivers/nvme/target/pci-epf.c b/drivers/nvme/target/pci-epf.c > index 56b1c6a7706a9e2dd9d8aaf17b440129b948486c..8b5ea5d4c79dfd461b767cfd4033a9e4604c94b1 100644 > --- a/drivers/nvme/target/pci-epf.c > +++ b/drivers/nvme/target/pci-epf.c > @@ -388,22 +388,15 @@ static int nvmet_pci_epf_dma_transfer(struct nvmet_pci_epf *nvme_epf, > return -EINVAL; > } > > - mutex_lock(lock); > - > dma_dev = dmaengine_get_dma_device(chan); > dma_addr = dma_map_single(dma_dev, seg->buf, seg->length, dir); > ret = dma_mapping_error(dma_dev, dma_addr); > if (ret) > - goto unlock; > - > - ret = dmaengine_slave_config(chan, &sconf); > - if (ret) { > - dev_err(dev, "Failed to configure DMA channel\n"); > - goto unmap; > - } > + return ret; > > - desc = dmaengine_prep_slave_single(chan, dma_addr, seg->length, > - sconf.direction, DMA_CTRL_ACK); > + desc = dmaengine_prep_config_single_safe(chan, dma_addr, seg->length, > + sconf.direction, > + DMA_CTRL_ACK, &sconf); > if (!desc) { > dev_err(dev, "Failed to prepare DMA\n"); > ret = -EIO; > @@ -426,9 +419,6 @@ static int nvmet_pci_epf_dma_transfer(struct nvmet_pci_epf *nvme_epf, > unmap: > dma_unmap_single(dma_dev, dma_addr, seg->length, dir); > > -unlock: > - mutex_unlock(lock); > - > return ret; > } > > -- Damien Le Moal Western Digital Research