Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp217401lqr; Wed, 5 Jun 2024 04:09:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXTAG3KMkRXdQseVSSh7ceH7VjOuQ8mlAp2w2/mDGberWAMGxuzghMFV2qwg7Ne85Zrq0J5TE98JC6Y+Ptg4Z3BN+3MHr4OqbOJ7yv39Q== X-Google-Smtp-Source: AGHT+IGsQRiUB0d5bme8F1RlLSp17yYD4CmXHyMqEe3y9RrABWUZi48yJD6nIamxHurA5eoKZbQa X-Received: by 2002:a05:6214:3c8a:b0:6af:252b:a8d9 with SMTP id 6a1803df08f44-6b030a3d645mr33710336d6.47.1717585797477; Wed, 05 Jun 2024 04:09:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717585797; cv=pass; d=google.com; s=arc-20160816; b=oscBJmorl5hEg7JUqikHsdA1JNK7u3JGmHcGZW1myhHsIoinefiDwEmBpFCp/ORZdx d8nv/h5rvqouOkI3J3ncic0sBmqMiqfFdB89WDFfoxECGJUHf3bkpGM1tnbOGSdJYhRo /wCN4KFGazhRvZWycQsJMsYkVWKxHxezZtdKorHxYZ8nPbxz0wXriDDNW4dL2/gzTNKJ kRHey1VMD9EmwLUtXZdtXgYvOSQ4Dx7NHGLatM7K3rYqOCqH/Xse4RdxZwUg4lrLnK9f y0jTJS0rDkO76B/1qg1TembzZ1L0ZqqoTwnWRnUSXnnKA8yn6FI1ZZi4NSTRCNNim5xY 06zQ== ARC-Message-Signature: i=2; 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=0rExFYS6khdsCSlBR5bP9i537aaNkMfpn8D9ODCG2PM=; fh=gIPS46kF5oiVtxHOjYLqoXg82bH7WL+T2QnpDaGuRdA=; b=IrptVcPCdQaNBAaAO6gZ0fPbE3TbDw+rM0SLYXsroBP1M0eZ+nEBjtgT8L892ZzeNE Efjj69P8dwmv6+Nmhf7dNY/7XXOW/r6TkjdkHUphFgrwZYsc+AvU+NKDyM7To1HfwnSM SZGNLRjcmiG/Z2/1JbSOybgLvo5uUSfBKe0QcS8xhFl275UR5kZFpKA8nuhHspuZdsG6 3gE3FzAT7QLlv42xYEv2xRNcedlO3mre9wdEPORSGSMjIGUn3T3f0RjJj8Sp0Tww7aR9 NoiX7ROpqZ8IfuUdlL1FBLFC/2hr2PSgo88su0xPhz7b/xMMxEBql+P1Rx8K7iGZTIbO ha7Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=Tj8ZZwCv; 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-202234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202234-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4a742af8si30356686d6.174.2024.06.05.04.09.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 04:09:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=Tj8ZZwCv; 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-202234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202234-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 3529F1C21A0F for ; Wed, 5 Jun 2024 11:09:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5811E19306C; Wed, 5 Jun 2024 11:09:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="Tj8ZZwCv" 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 E515F1922EE; Wed, 5 Jun 2024 11:09:23 +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=1717585765; cv=none; b=e0yNwZzafHA/LFwB2KPvlkg9J6zbL2u08nBcOf3IqCq5w9gu/qR32n1/P2khvKrI0JEChtclDSDtmg8aHdgJ1muFjxgh894xCXjflAhF9vE642suuBuqZmRE4FTrV5N/3Db5h0kAoKOJ+EUau+JdDJUFP9jECWs1vkSq+/I8FKI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717585765; c=relaxed/simple; bh=1gk6+q2m6wj2ue0Uabh2pGZEJQXAHRQC/hxrkHHjz2s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h4aSK+n7ZLvIz/7UG/20klLjIxn6eL4K1MVFan4heAjZhCM2Syc2+93MQm/Kd5y6mGTsxxk6tI2pkcyvEhuL52g44qcCau2cbzeuqnHYIvdXhMj3v6NZdTL4vVADX3jbpaEtpZygb9kr6EgjWtnWbjAQVLsMqWQt/E5xzGlz5Ek= 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=Tj8ZZwCv; 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=1717585740; 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=0rExFYS6khdsCSlBR5bP9i537aaNkMfpn8D9ODCG2PM=; b=Tj8ZZwCvftzO8JbVDVmyY4HqlhTZ0aaTOKnXTxi/4be4/131J/+GFEZ/ykctz+RVKZpH/j eZSbt1KvObg94HhXp0SuK+ujdmsUszUdkRnav2vBvFdqhndeEAJFP+efnRpyXxWtt60MKK +Ax+mkEg3PGmyhkEbqIiZy/4ZbCpyKU= From: Paul Cercueil To: Jonathan Cameron , Lars-Peter Clausen , Vinod Koul , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= Cc: Jonathan Corbet , Nuno Sa , linux-iio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, Paul Cercueil Subject: [PATCH v10 2/6] dmaengine: dma-axi-dmac: Implement device_prep_peripheral_dma_vec Date: Wed, 5 Jun 2024 13:08:41 +0200 Message-ID: <20240605110845.86740-3-paul@crapouillou.net> In-Reply-To: <20240605110845.86740-1-paul@crapouillou.net> References: <20240605110845.86740-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 Add implementation of the .device_prep_peripheral_dma_vec() callback. Signed-off-by: Paul Cercueil Signed-off-by: Nuno Sa --- v3: New patch v5: Implement .device_prep_slave_dma_vec() instead of v3's .device_prep_slave_dma_array(). v6: Use new prototype for axi_dmac_alloc_desc() as it changed upstream. v7: Adapted patch for the changes made in patch 1. v10: Use the new function prototype (without the extra prep_flags). --- 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 bdb752f11869..36943b0c6d60 100644 --- a/drivers/dma/dma-axi-dmac.c +++ b/drivers/dma/dma-axi-dmac.c @@ -620,6 +620,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_peripheral_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(chan, 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, @@ -1061,6 +1100,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_peripheral_dma_vec = axi_dmac_prep_peripheral_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