Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp89466rdb; Tue, 19 Dec 2023 10:07:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGO4wEzNBkoUnGHRKwE/ePigU76UIQ+my6ZV0IFfWeF6uok0fZR/Fp0NmIvoXTGdTE7DP8 X-Received: by 2002:a05:6512:31d2:b0:50e:15c8:6ea4 with SMTP id j18-20020a05651231d200b0050e15c86ea4mr5289650lfe.10.1703009223266; Tue, 19 Dec 2023 10:07:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703009223; cv=none; d=google.com; s=arc-20160816; b=KHFIafxH9E361AjrIXtm4PY+6wm+r7uOIEx003ZxJJIba7WxlyWS51C4e2sgKgoWEf BMqI7i07wEAzq3QAezrUJLoakc/5qwIspLP4f9yKmJe6Tszy1exSOwuZpaTQ7HJjoYQm 7s4UTMmb1J1nnPGNCu09+CAYiXe0F6CoGpR2tR+sTGvmPyYJrRvoIwWivYLpQqkKEgQr ekEGfYkMxO961jOqemkerXT4ezwaHy5m9zsAZ0t/EtO6ni0orx/igxL4/MvAKxpwTesf PDivlhmLCUUa3mJI1ZHdvwTv3ppqmTbG9hc1JfGtfX8O0Jg8hzAUm7Re0cRcV5PL6bC1 SkkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=AixFPBmj0sGmUeQqUl8x5UZmHCNRunKymgdO2FCRupY=; fh=auNSsmEiVxlQmEqX4u8fIxXR19mbteTVXbUGSektHww=; b=G59LoVKPuXHLvj7QRGRQ3LFCRnI9wo0NBdjnzihVMDbCZaBnRaszx2f31bdzxSp8O3 7DpKOY3ZMQI8e+6WAj4MLmRl9gGgEoFaWHwwlWjOeOuI5Rdx6uWNBPUjWJipmCAiHyUh 70fzRokhqpjc7QDPLIpgROQBILnqJ/0nnqtJd3DwAPFhZ6fEkK9xN5zLF1i7JnuPNmBl lbuD0PkwpFjFWmzYYHEqUZHZYMwOOKRXVbi/ecKtvjGv3Pi8x8odZC/W9r9CiUbOfxQI dPLs5khjawvJvJtexOSLX1zQz+B6VUjEab01r5w7rN7iaZVKZwp38wEev1FfyPRZtN4I aPwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=qWWR0Z7q; spf=pass (google.com: domain of linux-kernel+bounces-5739-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5739-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c26-20020a17090603da00b00a2471c25b4dsi666916eja.604.2023.12.19.10.07.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 10:07:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5739-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=qWWR0Z7q; spf=pass (google.com: domain of linux-kernel+bounces-5739-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5739-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 710A11F27A3E for ; Tue, 19 Dec 2023 17:56:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E78D541212; Tue, 19 Dec 2023 17:51:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="qWWR0Z7q" X-Original-To: linux-kernel@vger.kernel.org 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 AB28D41C89; Tue, 19 Dec 2023 17:50:59 +0000 (UTC) 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=1703008222; 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=AixFPBmj0sGmUeQqUl8x5UZmHCNRunKymgdO2FCRupY=; b=qWWR0Z7qkmRWWymGyFIo/XJHgX93Knhnb6x7GekZLkk6eJQizJJmBXilQb6b6wrPs8t+2e /G+WTm6qRjjc01LibcFoqkI8tErybF7UjG6VN5cbkdXp41/lQUn1K3pO7Z2HFQL6+8RP6y ZXeQXJEE7D5Ui63jg4NT+A//fyfv3Ks= From: Paul Cercueil To: Jonathan Cameron , Lars-Peter Clausen , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= , Vinod Koul , Jonathan Corbet Cc: 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, =?UTF-8?q?Nuno=20S=C3=A1?= , Michael Hennerich , Paul Cercueil Subject: [PATCH v5 4/8] dmaengine: dma-axi-dmac: Implement device_prep_slave_dma_vec Date: Tue, 19 Dec 2023 18:50:05 +0100 Message-ID: <20231219175009.65482-5-paul@crapouillou.net> In-Reply-To: <20231219175009.65482-1-paul@crapouillou.net> References: <20231219175009.65482-1-paul@crapouillou.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam: Yes Add implementation of the .device_prep_slave_dma_vec() callback. Signed-off-by: Paul Cercueil --- v3: New patch v5: Implement .device_prep_slave_dma_vec() instead of v3's .device_prep_slave_dma_array(). --- drivers/dma/dma-axi-dmac.c | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c index 2457a420c13d..363808088cc5 100644 --- a/drivers/dma/dma-axi-dmac.c +++ b/drivers/dma/dma-axi-dmac.c @@ -535,6 +535,45 @@ 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_vec(struct dma_chan *c, const struct dma_vec *vecs, + 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(vecs[i].len, 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, vecs[i].addr) || + !axi_dmac_check_len(chan, vecs[i].len)) { + kfree(desc); + return NULL; + } + + dsg = axi_dmac_fill_linear_sg(chan, direction, vecs[i].addr, 1, + vecs[i].len, 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, @@ -957,6 +996,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_vec = axi_dmac_prep_slave_dma_vec; 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.43.0