Received: by 2002:a05:6500:1b8a:b0:1ef:a0f1:aef6 with SMTP id df10csp73816lqb; Sun, 10 Mar 2024 05:49:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXbGUXYXBYR+nf9I95rktEcph/4hIi1gWFbwQeky/kcpJ4M79PE/2q+jRqbZDMe6nUYusu5KwBqRzrZafipirklcupZoaZFvO+3A/z2Xg== X-Google-Smtp-Source: AGHT+IGj62mHv3AoaIvwn1KzgYeTFOCvzEYF+guYn35LHVxrVB3RmdyWVqPXlGgekxvtVgrPhsSX X-Received: by 2002:a17:902:ccc5:b0:1dd:8b3a:cd31 with SMTP id z5-20020a170902ccc500b001dd8b3acd31mr2049199ple.38.1710074990157; Sun, 10 Mar 2024 05:49:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710074990; cv=pass; d=google.com; s=arc-20160816; b=h7zThRC3vkVEmMI3WZVIUrnWzKKT/oT8lbY0ncm8BMFw2tEqFHJDyHdwfizjmQ2j/G z7VRClLaYiTktdD6DqdpILT7iAxfNo8x6HJYi1inzBJmP8ee0LCrC5Qhm9+ToUYM0/rn tPdViCRisusKaxX54DvZRJoyX18MKkc5QigUE66GQEO16DpUM3oPqIxLoGLlqA63na1H uXGIQUiP2h2aTfjtXIuWBk6HolxAFtb82gJ0ejB9saJCfgcc9MH3iHq1c2K4iyArZoBJ bEOVj+gU767o/T4O6X3up9JnfnH/ybIb5cLemJHwv+ZChp0GBXUrw0qFKwQv1LScAJPk LElA== 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=PjvoUKlgmpVRFBTxXrdnvi/nwXFX/U+mB+guf1J9iJo=; fh=yZS2g+QQKdMrQ3jorRH5H6dPNDM7GRj3yrDB9sYJ3mc=; b=HRlBvrPEMwSvnrR91gu1tPwvztMe9kLScUu93qL86Sxojy3LH8f/x7h8rihMSGu0ca USOHjjMi4gVzyJu859bCh6WvZ6V0At+viScN9+fNLcoQPKZ9KLGDWZ/gFh/yO9KFEqjn gqxtWpXbbCxJwkBFy1r626hDbQxgETggKsRGNEgx8bGQkBTJDgB3PryAv+OtLawZBelt KeR2zlKVchDqskdRVA7wKuajFewEV6Fz5roeirzZQ0SW+ZGUFIZptfOsQSopcjqMN0A4 yG1lUXTEzOOsPj6jD5dWB4dR6cNtcjrHJpjh+z5mmuKI41jSiHsVAlZRA8sciR2B4Jih 5lhQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=vqBULXUj; 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-98216-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98216-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z15-20020a170902d54f00b001dd8be49c5fsi1484098plf.94.2024.03.10.05.49.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Mar 2024 05:49:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-98216-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=vqBULXUj; 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-98216-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98216-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A47052818CA for ; Sun, 10 Mar 2024 12:49:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 51EBA33CC4; Sun, 10 Mar 2024 12:49:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="vqBULXUj" 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 05D4C37160; Sun, 10 Mar 2024 12:49:09 +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=1710074951; cv=none; b=ULHoZRuYQsuVn8cXK6rdFOmM3MIpyZw5AP2qVt6mZQhl80kTEqRUbYKqoUIpDzd/xdidL/E6UH1CkNvTRXx1TnfdtiDxkhods9dUMFzl9oDoVZpD/fbqF4CpTrOBcRnQCovrtsUGMT+HVFEHpOSpX0Wy+UaK4FwKxHmN+oHPZn0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710074951; c=relaxed/simple; bh=ZhmvVT6lU67dXoutG2KJiVlBeMvZhpUdEWXzTsc46aU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V1WHG5z1Y4IhyDQwjwGhT+jdsWuGiKFdrZ+CpowZMlb1addK4fweiKelRnYNMIzY2YmjR4m3dkPGeHfSK3ewu2NdEYbIfXv7vaVgCwJU/qdHODPKAN6mSMAL1vdkgoBEOM85OVDELEOKKyudL6zettXSupf7k7fByAzF8SyOX6s= 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=vqBULXUj; 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=1710074927; 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=PjvoUKlgmpVRFBTxXrdnvi/nwXFX/U+mB+guf1J9iJo=; b=vqBULXUjdG6tlqPAJadPrdjskwoLnay11dyOfJzRJH+37MvC0OhlB0LKROxi2QEu3KBC3C jOkvzcGFW69gzvgj4R0Jz6WtZLQBKoPkzNCa7Nz6wdsXZMu+woDOZIh/QR0+fbXW5wR1vG IMCdyXw2gJRY0PWgFNeC6jIsfzp0ip0= From: Paul Cercueil To: Jonathan Cameron , =?UTF-8?q?Christian=20K=C3=B6nig?= , Jonathan Corbet , Lars-Peter Clausen , Vinod Koul , Sumit Semwal Cc: 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, Paul Cercueil Subject: [PATCH v9 2/6] dmaengine: dma-axi-dmac: Implement device_prep_peripheral_dma_vec Date: Sun, 10 Mar 2024 13:48:31 +0100 Message-ID: <20240310124836.31863-3-paul@crapouillou.net> In-Reply-To: <20240310124836.31863-1-paul@crapouillou.net> References: <20240310124836.31863-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. --- 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 4e339c04fc1e..d03cbf1d28e8 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 prep_flags, 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, prep_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, @@ -1055,6 +1094,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