Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1155879rdb; Tue, 30 Jan 2024 09:23:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IF9vv6kc88zxqj0E7j197Y66HTv5eE9QMLLrO9aV8GVzcQuRdofYafr7T0RHFe24WLslFTa X-Received: by 2002:ad4:5d61:0:b0:686:ad15:5027 with SMTP id fn1-20020ad45d61000000b00686ad155027mr10911779qvb.106.1706635436917; Tue, 30 Jan 2024 09:23:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706635436; cv=pass; d=google.com; s=arc-20160816; b=i/EwaqDH2zwBx4aIsZK5Nyrw6k8AC+duciO6XexCEwanEOeM/xYyMUaBDMo4su1c/o wGpA1fkLmTLkuyB2EVqQ1DBxXdbLXECzen2AQnNvy6+g+ihAenSHWF/Dv6jNcQSGkCso gmSHeA258PbfRHyI2aoRTwJRvzOirCFrkc+ku2hdT9mYPNQvdTUpY/6qNcanl0CJCIIG zwXMPyFsJme7adPVs5lssojxZ30K4Vt2cOrmmTVrbAcKwLzLTHBltYaqLDpzpjlSWQJ4 4td4MwO7PVFLR+Gyw8MRUmF16hKgTJOvo1F2up7VyXTWd0rMZyylZWIagZJferaKfmo1 YLMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:autocrypt:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=5yttsGv/nZzm8P4I37O+sbjW65Bb56qxCJ5ApCblXiM=; fh=qET/dqFlE1T6WVO91N0BQ9P7vfVfOrFLtr1WwkSYF98=; b=mcX8tIwdP8ecL2AV7SNSrVeMJK+EaibZkuzK4jA6MoMWYzud5Jh/16N2c+wssNtpb7 Rtd9VVK8zFOIYQEreLfa8lbtOWyIb17WZQcMdQcXQtM70FoKiVaYAfP9TpxuW0uhxKn4 H+Ua1Z2PMEyFw24aM3NtFi4U7GYeCRqYdztSDQTP34ILB717zZgnuLZX88Valcx25rUb v8iovarhs5QaRvO7tYE0pMf8tY3S9aQ3pm9rM2+fRr7h9bFlUyGxWTiRHSMhwW/bt6+e k96Vr2KyZjBuCmonyCsjs8x30mi/vRY/vTQfulPr0wXqDJIN38BvFx6IwQvXiRG3L5AJ wV9w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=faZH3sia; arc=pass (i=1 spf=pass spfdomain=crapouillou.net dkim=pass dkdomain=crapouillou.net dmarc=pass fromdomain=crapouillou.net); spf=pass (google.com: domain of linux-kernel+bounces-45036-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45036-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o7-20020a0562140e4700b0068c5de04debsi2150513qvc.458.2024.01.30.09.23.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 09:23:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45036-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=faZH3sia; arc=pass (i=1 spf=pass spfdomain=crapouillou.net dkim=pass dkdomain=crapouillou.net dmarc=pass fromdomain=crapouillou.net); spf=pass (google.com: domain of linux-kernel+bounces-45036-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45036-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net 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 9B4C01C22C48 for ; Tue, 30 Jan 2024 17:23:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EDDC9129A7B; Tue, 30 Jan 2024 17:23:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="faZH3sia" Received: from aposti.net (aposti.net [89.234.176.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A0F51292DB; Tue, 30 Jan 2024 17:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=89.234.176.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706635424; cv=none; b=a6YS80yO9Fpne4k7aSC7cu2k+SjbuViZzycbzSEQVj7RajDB56tbK8hJNcLJTGk9YSv10aCoH4pnR2PiPqyRP7dYqHrGTaIvPxYK+qLUDxSlxvSrfwyzAkZ/GH2AyGYdiOuZ5Z035OqxnjZ3qYtnzyMvqt1qdp38KSFLANC9EPY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706635424; c=relaxed/simple; bh=WVZMJ2S0EugNJB6BTz7XzKnB3cgJOgtM05Qu3n6r5dg=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=GtQFSyWJ/e/0oPyBH2LU/Ql7T6RIcNRGErl+9CitIIqsC9cArr+at6r7rFd+JxJHRSNO0XOXrxwN8phpjSGNRa+YQ9OSCb51rxEZao7qgOPNJSE5i/QvIuowF01TgUIL49OdGcChqrmHeKogi1qS4X+sq8M7FengOk0RzKWfMjg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=crapouillou.net; spf=pass smtp.mailfrom=crapouillou.net; dkim=pass (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b=faZH3sia; arc=none smtp.client-ip=89.234.176.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=crapouillou.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=crapouillou.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1706635413; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=5yttsGv/nZzm8P4I37O+sbjW65Bb56qxCJ5ApCblXiM=; b=faZH3siafi9jEi315A2HIps30mZcyIsINRLU55uymIvXMB5fB98He1hDz67Ccd+M0kvtEM 1P9kAwCBxym7GHnLVrowoWysHJFkzjEI6d0v+0a+ThZomANVbwAxP3yndvdPm247qwjdQX 2Z7gnNBfPsjBkxG2zNvElx2YtbwW6sw= Message-ID: Subject: Re: [PATCH v6 1/6] dmaengine: Add API function dmaengine_prep_slave_dma_vec() From: Paul Cercueil To: Vinod Koul Cc: Jonathan Cameron , Jonathan Corbet , Lars-Peter Clausen , Sumit Semwal , Christian =?ISO-8859-1?Q?K=F6nig?= , Daniel Vetter , Nuno Sa , Michael Hennerich , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-iio@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Date: Tue, 30 Jan 2024 18:23:31 +0100 In-Reply-To: References: <20240129170201.133785-1-paul@crapouillou.net> <20240129170201.133785-2-paul@crapouillou.net> Autocrypt: addr=paul@crapouillou.net; prefer-encrypt=mutual; keydata=mQENBF0KhcEB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Z3J2D4oAcIAEXTymRQ2+hr3Hf7I61KMHWeSkCvCG2decTYsHlw5Erix/jYWqVOtX0roOOLqWkqpQQJWtU+biWrAksmFmCp5fXIg1Nlg39v21xCXBGxJkxyTYuhdWyu1yDQ+LSIUAEQEAAYkBNgQYAQoAIBYhBNdHYd8OeCBwpMuVxnPua9InSr1BBQJdCoXBAhsMAAoJEHPua9InSr1B4wsH/Az767YCT0FSsMNt1jkkdLCBi7nY0GTW+PLP1a4zvVqFMo/vD6uz1ZflVTUAEvcTi3VHYZrlgjcxmcGu239oruqUS8Qy/xgZBp9KF0NTWQSl1iBfVbIU5VV1vHS6r77W5x0qXgfvAUWOH4gmN3MnF01SH2zMcLiaUGF+mcwl15rHbjnT3Nu2399aSE6cep86igfCAyFUOXjYEGlJy+c6UyT+DUylpjQg0nl8MlZ/7Whg2fAU9+FALIbQYQzGlT4c71SibR9T741jnegHhlmV4WXXUD6roFt54t0MSAFSVxzG8mLcSjR2cLUJ3NIPXixYUSEn3tQhfZj07xIIjWxAYZo= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Hi Vinod, Le mardi 30 janvier 2024 =C3=A0 21:38 +0530, Vinod Koul a =C3=A9crit=C2=A0: > On 29-01-24, 18:01, Paul Cercueil wrote: > > This function can be used to initiate a scatter-gather DMA > > transfer, > > where the address and size of each segment is located in one entry > > of > > the dma_vec array. > >=20 > > The major difference with dmaengine_prep_slave_sg() is that it > > supports > > specifying the lengths of each DMA transfer; as trying to override > > the > > length of the transfer with dmaengine_prep_slave_sg() is a very > > tedious > > process. The introduction of a new API function is also justified > > by the > > fact that scatterlists are on their way out. > >=20 > > Note that dmaengine_prep_interleaved_dma() is not helpful either in > > that > > case, as it assumes that the address of each segment will be higher > > than > > the one of the previous segment, which we just cannot guarantee in > > case > > of a scatter-gather transfer. > >=20 > > Signed-off-by: Paul Cercueil > >=20 > > --- > > v3: New patch > >=20 > > v5: Replace with function dmaengine_prep_slave_dma_vec(), and > > struct > > =C2=A0=C2=A0=C2=A0 'dma_vec'. > > =C2=A0=C2=A0=C2=A0 Note that at some point we will need to support cycl= ic > > transfers > > =C2=A0=C2=A0=C2=A0 using dmaengine_prep_slave_dma_vec(). Maybe with a n= ew "flags" > > =C2=A0=C2=A0=C2=A0 parameter to the function? >=20 > that would be better Ok, I think it'd be better that I add a new "flags" parameter now - even if it means passing 0 until we actually have flags for it. >=20 > > --- > > =C2=A0include/linux/dmaengine.h | 25 +++++++++++++++++++++++++ > > =C2=A01 file changed, 25 insertions(+) > >=20 > > diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h > > index 3df70d6131c8..ee5931ddb42f 100644 > > --- a/include/linux/dmaengine.h > > +++ b/include/linux/dmaengine.h > > @@ -160,6 +160,16 @@ struct dma_interleaved_template { > > =C2=A0 struct data_chunk sgl[]; > > =C2=A0}; > > =C2=A0 > > +/** > > + * struct dma_vec - DMA vector > > + * @addr: Bus address of the start of the vector > > + * @len: Length in bytes of the DMA vector > > + */ > > +struct dma_vec { > > + dma_addr_t addr; > > + size_t len; > > +}; > > + > > =C2=A0/** > > =C2=A0 * enum dma_ctrl_flags - DMA flags to augment operation > > preparation, > > =C2=A0 *=C2=A0 control completion, and communicate status. > > @@ -910,6 +920,10 @@ struct dma_device { > > =C2=A0 struct dma_async_tx_descriptor > > *(*device_prep_dma_interrupt)( > > =C2=A0 struct dma_chan *chan, unsigned long flags); > > =C2=A0 > > + struct dma_async_tx_descriptor > > *(*device_prep_slave_dma_vec)( > > + struct dma_chan *chan, const struct dma_vec *vecs, > > + size_t nents, enum dma_transfer_direction > > direction, > > + unsigned long flags); >=20 > s/slave/peripheral >=20 > I had requested it a bit while ago as well You did. Sorry, I forgot about it when working on the v6. Cheers, -Paul > > =C2=A0 struct dma_async_tx_descriptor *(*device_prep_slave_sg)( > > =C2=A0 struct dma_chan *chan, struct scatterlist *sgl, > > =C2=A0 unsigned int sg_len, enum dma_transfer_direction > > direction, > > @@ -972,6 +986,17 @@ static inline struct dma_async_tx_descriptor > > *dmaengine_prep_slave_single( > > =C2=A0 =C2=A0 dir, flags, > > NULL); > > =C2=A0} > > =C2=A0 > > +static inline struct dma_async_tx_descriptor > > *dmaengine_prep_slave_dma_vec( > > + struct dma_chan *chan, const struct dma_vec *vecs, size_t > > nents, > > + enum dma_transfer_direction dir, unsigned long flags) > > +{ > > + if (!chan || !chan->device || !chan->device- > > >device_prep_slave_dma_vec) > > + return NULL; > > + > > + return chan->device->device_prep_slave_dma_vec(chan, vecs, > > nents, > > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dir, > > flags); > > +} > > + > > =C2=A0static inline struct dma_async_tx_descriptor > > *dmaengine_prep_slave_sg( > > =C2=A0 struct dma_chan *chan, struct scatterlist > > *sgl, unsigned int sg_len, > > =C2=A0 enum dma_transfer_direction dir, unsigned long flags) > > --=20 > > 2.43.0 >=20