Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp693715lqc; Fri, 8 Mar 2024 09:02:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVzij/xSYvpyzi6KOWOeafbk6Tunv9xUn+78Cx6BzaJSXM4bXk9C0SdyDcPzA1petjmoWPakDgy2hxtmnJIs6TwqCz0clvYxtx8qRn+gA== X-Google-Smtp-Source: AGHT+IEYZhICDZTVmAKCOxbQCoJYSuARXjn/OPqaxPwxzyR6yu7d4i6mzphlGsYtxHNrNzq5mEdI X-Received: by 2002:a50:9ee9:0:b0:568:1907:a48d with SMTP id a96-20020a509ee9000000b005681907a48dmr2499143edf.11.1709917322591; Fri, 08 Mar 2024 09:02:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709917322; cv=pass; d=google.com; s=arc-20160816; b=ayNs+ZqWNdhpIpoP4Sc1Xxa4yZR74KlaW0hu1edN/GIosseDPIwTd7/h3jsDJBY+9b aRonPhEo6amyK1F90dqLS62GJ2KGPFLXwtX+frpR0rqU56faPdAFgk3wlZntZhZdADvI I5m5baE148CB722OSXZrLI5oGSNdAhF0wWblDQPcxvo3TOMfCEIr2MgtfW3i3HOo1F80 cF2nw/VaLEmtaQvjszD3e3l7wFhyZme8CAfB6abuRQQkT2S0yF/OQFFFxF0qzRSm0AOl acu/J2Mvi4SfxHzzDc18+6T6rkyELer7CEi4llyuw+2SA4MDxKU6DA/YTWMw8KvqOFz9 m0yg== 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=wmr+L9BLlMUsLohFo0Nx28l2Ai/PSi/ylvUuf0B/qqWbR3n6DaBitGGpmdT78fXX5y aP16fEb6oYVfSmwfkkREC7paq3tko4lX25vCV0XeSmGr7ZL3qcnH3B94uzu3hVf9Jr4B 4hlTOOUCClMGO/9idgZQ6fECBCqXdtdMTd0g4aFxdIRjoci7yTFti5tIaGhS3clocMkq 2Qd9cRZ0w5/yEbUDUyn/MevcaCAfwEuuqVSQfz5GVCi1v3cr/RnAE9APCGhDHFfx7TIR wqgFISUvfmqdwfIvRQAQin39pXf/G8SsKoir1Grwe8Sq5Ww2GEYiyuQecfEoOYCexUzb m6xA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=mOcr7cNW; 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-97341-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97341-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 el15-20020a056402360f00b005682d3bdd4dsi649564edb.240.2024.03.08.09.02.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 09:02:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97341-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=mOcr7cNW; 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-97341-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97341-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 2ADBF1F20EF8 for ; Fri, 8 Mar 2024 17:02:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74001208DF; Fri, 8 Mar 2024 17:01:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="mOcr7cNW" 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 0665B1D69D; Fri, 8 Mar 2024 17:01:30 +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=1709917292; cv=none; b=kw87Gk5rrr4/eoMaOaYQc7jd0LfaP0V1XGdZQIewk+SvunvPYCOaBG/UT9XOhIe7eISazJnJR7LvOdk49gKjFJBK/bcdtMm8Nb2TS+K0Ngri1F20QJrSvGgjDmQX27OqXqmNo8lAzlVZJLj67167AR2H1mj9Tz5X+FWDPFNR5mY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709917292; c=relaxed/simple; bh=ZhmvVT6lU67dXoutG2KJiVlBeMvZhpUdEWXzTsc46aU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aH3IfVMtQamBTqRPoYk+oqy4wzErwA2pjNByrE+3nHgh68OQMnxJzl6T/PTwOCvxqTiXq7a5PONEGG+mWF1NooOtf2kVtiFGeHA+gkzUydfEwsMhXLCwDb9mYFqHr7IYGHINxHvJjzTUYsWYRaHR6tgX+Ws8hGG0b6I5+WPTYIQ= 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=mOcr7cNW; 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=1709917269; 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=mOcr7cNWn98JJqHjq6VB5WdiijfbR38BDGCiwRyyVq/dwoqf+XLF3rGlCk1NyC7OtXKXmW LYh1dptaWBjAw5uHMNf3isp1wZqZZOJ0t+oZVd/m1lR1A+MNyHygGyMudAlT8jKuL3BYY4 ApWHgXtrpGzRR+30emlAH/FO9pOw0ww= 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 v8 2/6] dmaengine: dma-axi-dmac: Implement device_prep_peripheral_dma_vec Date: Fri, 8 Mar 2024 18:00:42 +0100 Message-ID: <20240308170046.92899-3-paul@crapouillou.net> In-Reply-To: <20240308170046.92899-1-paul@crapouillou.net> References: <20240308170046.92899-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