Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4730771rwl; Mon, 3 Apr 2023 08:52:16 -0700 (PDT) X-Google-Smtp-Source: AKy350bIb4IeMMGRFwHmb8bEmfnvq6kCRnXzdIJhr5dXwc9tYonOlCv5kxUNuOmGPfiF5zCMvFtA X-Received: by 2002:a17:906:2695:b0:920:7827:302 with SMTP id t21-20020a170906269500b0092078270302mr17586469ejc.18.1680537135896; Mon, 03 Apr 2023 08:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680537135; cv=none; d=google.com; s=arc-20160816; b=QN+in4pgIml+sxyD6WKC+7WLHfv4CzXxTacVMY1qmN3doon/DFZy+mNKoXqir1gnNI 8T/yYBIfXEjUs5CRKOTal4VEtBA0IcqJqOFV7YbV6tVylf89rrT+rJvmzm3nlgQ+wq/d NUbcY1Ph27miYM8sosfYu/FLQYcB8+KezPzu0Ed7wW3ihTSTT2tyqMkMI8T4uriUIY+Z VhPcnMbYGVh8EJy6WOs9tiQJpu4ixEDeJ6ZptAUc5JRxUMvEgCMLba2hdVtbz47nVwpK vp86LCXGshuTXT5AOCRzHRN4oVu5i6g0wqh2wAWMdD1t5WxQuk2hv7WXnb4EBrHRrVkK kS5w== 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=nBi7PX/7n3UhrKXex6m7UfXrnlhGP3WO/OYjpM7zL0o=; b=XII5SYOkiJWJcWGBx9xlkK7SH7CX25c3DNFrvqpFMHwpA3i1bs3xHgS51OB1rjhECS XzRuf5DTBFPvXfpLWiGqa4HTTVn2s7zahCZ2Ab7I7gkJThzFQ5lLVRB172iXk3/E+mTL AY+vgScxMutGDeByP8Aq249daGXOCmX7Fq75x+FPRToSBckVCupYkxfZOmnb/C/CW0hH T8yj7n+15UmX6WXWgBecjez9KFXWc+9PDLPle29A9Yn1zCv/K3Owqo1kiiIStF2sEzv9 mIOwRw4/qGkIo+67qmjrkmUamAWVrLXEUIcuxVWUbg0QTgqt3QGD+7lz61BO2PrVBY2/ Uogw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=QW2FI1x4; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gz16-20020a170907a05000b009311eb6863dsi8932366ejc.634.2023.04.03.08.51.50; Mon, 03 Apr 2023 08:52:15 -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=QW2FI1x4; 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 S232554AbjDCPuU (ORCPT + 99 others); Mon, 3 Apr 2023 11:50:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232672AbjDCPuJ (ORCPT ); Mon, 3 Apr 2023 11:50:09 -0400 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8B663AB1; Mon, 3 Apr 2023 08:49:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1680536891; 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=nBi7PX/7n3UhrKXex6m7UfXrnlhGP3WO/OYjpM7zL0o=; b=QW2FI1x44F8Zk1JtxUeC1uKCao8FhfoJddmDLG200LbZ6MiogX5rGWrXhlIhSP9w7IWGeT h8wDfNhQW7P/fOr2orBwPD215WIhvGp6p/oT1Qp5GAZTQwTcneLKHtu3nlaIWA8TuvfaZN /g+CFxG9a3QwUlJqgjTZMaXVDkI185M= From: Paul Cercueil To: Jonathan Cameron , Lars-Peter Clausen , Vinod Koul , Michael Hennerich , =?UTF-8?q?Nuno=20S=C3=A1?= , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= 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 Subject: [PATCH v3 02/11] dmaengine: dma-axi-dmac: Implement device_prep_slave_dma_array Date: Mon, 3 Apr 2023 17:47:51 +0200 Message-Id: <20230403154800.215924-3-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: X-Mailing-List: linux-kernel@vger.kernel.org Add implementation of the .device_prep_slave_dma_array() callback. Signed-off-by: Paul Cercueil --- v3: New patch --- drivers/dma/dma-axi-dmac.c | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c index a812b9b00e6b..61a796aca631 100644 --- a/drivers/dma/dma-axi-dmac.c +++ b/drivers/dma/dma-axi-dmac.c @@ -536,6 +536,46 @@ static struct axi_dmac_sg *axi_dmac_fill_linear_sg(struct axi_dmac_chan *chan, return sg; } +static struct dma_async_tx_descriptor * +axi_dmac_prep_slave_dma_array(struct dma_chan *c, dma_addr_t *addrs, + size_t *lengths, size_t nb, + enum dma_transfer_direction direction, + unsigned long flags) +{ + struct axi_dmac_chan *chan = to_axi_dmac_chan(c); + struct axi_dmac_desc *desc; + unsigned int num_sgs = 0; + struct axi_dmac_sg *dsg; + size_t i; + + if (direction != chan->direction) + return NULL; + + for (i = 0; i < nb; i++) + num_sgs += DIV_ROUND_UP(lengths[i], chan->max_length); + + desc = axi_dmac_alloc_desc(num_sgs); + if (!desc) + return NULL; + + dsg = desc->sg; + + for (i = 0; i < nb; i++) { + if (!axi_dmac_check_addr(chan, addrs[i]) || + !axi_dmac_check_len(chan, lengths[i])) { + kfree(desc); + return NULL; + } + + dsg = axi_dmac_fill_linear_sg(chan, direction, addrs[i], 1, + lengths[i], dsg); + } + + desc->cyclic = false; + + return vchan_tx_prep(&chan->vchan, &desc->vdesc, flags); +} + static struct dma_async_tx_descriptor *axi_dmac_prep_slave_sg( struct dma_chan *c, struct scatterlist *sgl, unsigned int sg_len, enum dma_transfer_direction direction, @@ -958,6 +998,7 @@ static int axi_dmac_probe(struct platform_device *pdev) dma_dev->device_tx_status = dma_cookie_status; dma_dev->device_issue_pending = axi_dmac_issue_pending; dma_dev->device_prep_slave_sg = axi_dmac_prep_slave_sg; + dma_dev->device_prep_slave_dma_array = axi_dmac_prep_slave_dma_array; dma_dev->device_prep_dma_cyclic = axi_dmac_prep_dma_cyclic; dma_dev->device_prep_interleaved_dma = axi_dmac_prep_interleaved; dma_dev->device_terminate_all = axi_dmac_terminate_all; -- 2.39.2