Message ID | 20230403154800.215924-2-paul@crapouillou.net |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2416925vqo; Mon, 3 Apr 2023 09:11:26 -0700 (PDT) X-Google-Smtp-Source: AKy350bbeGQyygLmbiAz5tmTpZNqJrB4dGyJ19Xl2O48eGuR+lwMurYUrG+wRE+YlhzpuF6MlkCu X-Received: by 2002:a05:6402:1390:b0:502:2382:5c24 with SMTP id b16-20020a056402139000b0050223825c24mr31742117edv.39.1680538286167; Mon, 03 Apr 2023 09:11:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680538286; cv=none; d=google.com; s=arc-20160816; b=ovPPBHMuLPumnreh0R9Tq/bXxwBeG81L/AYk/pG7rKkgqlvdp0R/XZeURG4USbbfr6 hJrEwPoqcM3nrjC0RhbNkel0vO4wbnR47lq3aE9cj5BNPfWf4Ua1zFeIbe76oefZn2Vo WDyuifvqNeF9x+YQI5IbSJoUNvycvkK5OhCi5AGX4AHD34StKUaRNY3P0bg3pDnuJ/Wn B/jXOeIKu+jmPGjoMZxDtJWj9czzGDWtSrx5/CBGomDDlQKtCLyD7zyjJwl+PeYG/A9B 0ECA1/0j0emUFtfkzFFfmQ2ETzIgQ0qMVCKl9pdib65fn4Nw3qa/QnOtRRWgNqo2b2Mn 503Q== 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=Dku4wXuwudT4q34STxa4FMfMek4fO2ojnwUzBKSuXjA=; b=F7jguF+7l1nK+4Q5Lj0iICuqaFT++45Kra3ua2BdS0ejP8PiNBfqiG1udrN+GB2ugw WUWK/Ujl36kJezeAmyN3ljiPAg0L2WqXv/jbKlQAA7LdQRr0BFMvzvSDkOlJZ6LvHiJM RJj7seeGeRfxPaFRnrGvzLtu6EgyuD/8dx+6RY1iU0LCCr8ljXay6UReQx98VZv2WctS OQ//VlVJ8sPZj4oio8akLU5cTifX79r5V14BbFc33mfNlNGi457S311NDLJtmUPZtWYy FZdu+/N56Ftyzirr0p/e9We62l7UvP4050eYIYbIw1ML+yLTWD55/0nCSRkwdMV8M0jn Gztw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=ecN8+hUA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h13-20020a50ed8d000000b004aad0c7e385si9029940edr.270.2023.04.03.09.11.01; Mon, 03 Apr 2023 09:11:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=ecN8+hUA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232390AbjDCPtp (ORCPT <rfc822;zwp10758@gmail.com> + 99 others); Mon, 3 Apr 2023 11:49:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232181AbjDCPtl (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 3 Apr 2023 11:49:41 -0400 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82AD640F2; Mon, 3 Apr 2023 08:49:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1680536890; 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=Dku4wXuwudT4q34STxa4FMfMek4fO2ojnwUzBKSuXjA=; b=ecN8+hUAzZ3PoWqKSNgaK36hhfmHEAL9q+kQOHkW6Xy1qm2ThwiFt1rf+FyO66SEq6ps3E XRiKDUUYLbEOIC2dIXXyQmp5xjVMBM+BNUcZvgMI0LaDHcIMDkJ4KonmDEz5mxYRKkJNSf ThVDFZ59kByB/lZJ8kyH48P0wXH40/U= From: Paul Cercueil <paul@crapouillou.net> To: Jonathan Cameron <jic23@kernel.org>, Lars-Peter Clausen <lars@metafoo.de>, Vinod Koul <vkoul@kernel.org>, Michael Hennerich <Michael.Hennerich@analog.com>, =?utf-8?q?Nuno_S=C3=A1?= <noname.nuno@gmail.com>, Sumit Semwal <sumit.semwal@linaro.org>, =?utf-8?q?Christian_K=C3=B6nig?= <christian.koenig@amd.com> Cc: 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, Paul Cercueil <paul@crapouillou.net> Subject: [PATCH v3 01/11] dmaengine: Add API function dmaengine_prep_slave_dma_array() Date: Mon, 3 Apr 2023 17:47:50 +0200 Message-Id: <20230403154800.215924-2-paul@crapouillou.net> In-Reply-To: <20230403154800.215924-1-paul@crapouillou.net> References: <20230403154800.215924-1-paul@crapouillou.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam: Yes X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762172114304684248?= X-GMAIL-MSGID: =?utf-8?q?1762172114304684248?= |
Series |
iio: new DMABUF based API, v3
|
|
Commit Message
Paul Cercueil
April 3, 2023, 3:47 p.m. UTC
This function can be used to initiate a scatter-gather DMA transfer
where the DMA addresses and lengths are located inside arrays.
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.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
v3: New patch
---
include/linux/dmaengine.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
Comments
On 03-04-23, 17:47, Paul Cercueil wrote: > This function can be used to initiate a scatter-gather DMA transfer > where the DMA addresses and lengths are located inside arrays. > > 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. Do we need a new API for this? why not use device_prep_interleaved_dma? > > Signed-off-by: Paul Cercueil <paul@crapouillou.net> > > --- > v3: New patch > --- > include/linux/dmaengine.h | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h > index c3656e590213..62efa28c009a 100644 > --- a/include/linux/dmaengine.h > +++ b/include/linux/dmaengine.h > @@ -912,6 +912,11 @@ struct dma_device { > struct dma_async_tx_descriptor *(*device_prep_dma_interrupt)( > struct dma_chan *chan, unsigned long flags); > > + struct dma_async_tx_descriptor *(*device_prep_slave_dma_array)( > + struct dma_chan *chan, dma_addr_t *addrs, > + size_t *lengths, size_t nb, > + enum dma_transfer_direction direction, > + unsigned long flags); > struct dma_async_tx_descriptor *(*device_prep_slave_sg)( > struct dma_chan *chan, struct scatterlist *sgl, > unsigned int sg_len, enum dma_transfer_direction direction, > @@ -974,6 +979,17 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_slave_single( > dir, flags, NULL); > } > > +static inline struct dma_async_tx_descriptor *dmaengine_prep_slave_dma_array( > + struct dma_chan *chan, dma_addr_t *addrs, size_t *lengths, > + size_t nb, enum dma_transfer_direction dir, unsigned long flags) > +{ > + if (!chan || !chan->device || !chan->device->device_prep_slave_dma_array) > + return NULL; > + > + return chan->device->device_prep_slave_dma_array(chan, addrs, lengths, > + nb, dir, flags); > +} > + > static inline struct dma_async_tx_descriptor *dmaengine_prep_slave_sg( > struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len, > enum dma_transfer_direction dir, unsigned long flags) > -- > 2.39.2
Hi Vinod, Le mercredi 12 avril 2023 à 22:53 +0530, Vinod Koul a écrit : > On 03-04-23, 17:47, Paul Cercueil wrote: > > This function can be used to initiate a scatter-gather DMA transfer > > where the DMA addresses and lengths are located inside arrays. > > > > 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. > > Do we need a new API for this? why not use > device_prep_interleaved_dma? I admit that I discarded the interleaved DMA without trying it, because reading the doc, e.g. the one for "struct data_chunk", It looked like it was not usable for when the DMA addresses are scattered in memory; it assumes that the following DMA addresses will always come after the previous one. Cheers, -Paul > > > > Signed-off-by: Paul Cercueil <paul@crapouillou.net> > > > > --- > > v3: New patch > > --- > > include/linux/dmaengine.h | 16 ++++++++++++++++ > > 1 file changed, 16 insertions(+) > > > > diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h > > index c3656e590213..62efa28c009a 100644 > > --- a/include/linux/dmaengine.h > > +++ b/include/linux/dmaengine.h > > @@ -912,6 +912,11 @@ struct dma_device { > > struct dma_async_tx_descriptor > > *(*device_prep_dma_interrupt)( > > struct dma_chan *chan, unsigned long flags); > > > > + struct dma_async_tx_descriptor > > *(*device_prep_slave_dma_array)( > > + struct dma_chan *chan, dma_addr_t *addrs, > > + size_t *lengths, size_t nb, > > + enum dma_transfer_direction direction, > > + unsigned long flags); > > struct dma_async_tx_descriptor *(*device_prep_slave_sg)( > > struct dma_chan *chan, struct scatterlist *sgl, > > unsigned int sg_len, enum dma_transfer_direction > > direction, > > @@ -974,6 +979,17 @@ static inline struct dma_async_tx_descriptor > > *dmaengine_prep_slave_single( > > dir, flags, > > NULL); > > } > > > > +static inline struct dma_async_tx_descriptor > > *dmaengine_prep_slave_dma_array( > > + struct dma_chan *chan, dma_addr_t *addrs, size_t *lengths, > > + size_t nb, enum dma_transfer_direction dir, unsigned long > > flags) > > +{ > > + if (!chan || !chan->device || !chan->device- > > >device_prep_slave_dma_array) > > + return NULL; > > + > > + return chan->device->device_prep_slave_dma_array(chan, > > addrs, lengths, > > + nb, dir, > > flags); > > +} > > + > > static inline struct dma_async_tx_descriptor > > *dmaengine_prep_slave_sg( > > struct dma_chan *chan, struct scatterlist *sgl, unsigned > > int sg_len, > > enum dma_transfer_direction dir, unsigned long flags) > > -- > > 2.39.2 >
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index c3656e590213..62efa28c009a 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -912,6 +912,11 @@ struct dma_device { struct dma_async_tx_descriptor *(*device_prep_dma_interrupt)( struct dma_chan *chan, unsigned long flags); + struct dma_async_tx_descriptor *(*device_prep_slave_dma_array)( + struct dma_chan *chan, dma_addr_t *addrs, + size_t *lengths, size_t nb, + enum dma_transfer_direction direction, + unsigned long flags); struct dma_async_tx_descriptor *(*device_prep_slave_sg)( struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len, enum dma_transfer_direction direction, @@ -974,6 +979,17 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_slave_single( dir, flags, NULL); } +static inline struct dma_async_tx_descriptor *dmaengine_prep_slave_dma_array( + struct dma_chan *chan, dma_addr_t *addrs, size_t *lengths, + size_t nb, enum dma_transfer_direction dir, unsigned long flags) +{ + if (!chan || !chan->device || !chan->device->device_prep_slave_dma_array) + return NULL; + + return chan->device->device_prep_slave_dma_array(chan, addrs, lengths, + nb, dir, flags); +} + static inline struct dma_async_tx_descriptor *dmaengine_prep_slave_sg( struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len, enum dma_transfer_direction dir, unsigned long flags)