Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2174929pxb; Mon, 22 Feb 2021 23:42:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzS54Nqd5u1x5WTlyptoJMBnrsj43C8SGZeZPNTiTDuacaS3t38WtRKtQrhfZ2m6Dqw8SwR X-Received: by 2002:a17:906:5043:: with SMTP id e3mr24676805ejk.260.1614066151253; Mon, 22 Feb 2021 23:42:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614066151; cv=none; d=google.com; s=arc-20160816; b=KlZ1a4eIeSZvB5ZjGukqW9iV9w1FXVw4qfR8LDAwb7pLMU0oa1mBFQnqWYbZzZwNpy bcyjsGRpYWiJ0F/80TbEFC9hkONjJ6voMfvY9pkDcEWISOTzKgmfZ9BD6TX1PxvFETtR tlhHwFC2kK7mhxy1F0I0aWH7hKQBAb64j/2/PkOmqq9ETGrv0Fq/J2zAFQwQj7MGgBt9 S/8b4ZH6Rm9sXNJRH7owNZ3pY1VcyptF2Ff95XP9AtO1ccRGUJ2/tPg8EPC32YAo16zn t5ulU6/VMjHDE0GECjAG+trSHEv8QaM1TMcR4w19snYwtcDtvFx1ygnb787xNFDxpTIw 873g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=FBq/fDzJJZK8J6HmNcmzMw7q0LORfsgo8PXuQM6yZUs=; b=v+Xg4XKQHXlLQOXdO+qJbqaQ4DBvisxaEFYjS+KOPw4bD47tRDpA1bG4ThB5qZCJ5q mfInQPG28oJO7ec4r0QLA37EaqryNFuWCn117shkaMkt8JcARNHBhd83ljUcAZM60TU0 VqkNaZY5zXTR7XJn53c9Gu+s0AckFsprQlRWnN6G8RnZPyrAppwKcqDzzBbAzJ4rN8DH IzSMgAAj9Lz6yaKdMSqKN2yR/LAa0+2LKHmuHDwxHMf407q6VBI2EyHvgchPuNO5HU9S OXlalHrGm6NlpWFZDEwqQ6WiqKTuUvKUhyd0u1ZGQEKZyrpLwzjsaqD872nHYi9pWrki HAsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=e6Pwqemd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d21si13667945ejr.650.2021.02.22.23.42.07; Mon, 22 Feb 2021 23:42:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=e6Pwqemd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230296AbhBWGfn (ORCPT + 99 others); Tue, 23 Feb 2021 01:35:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbhBWGfk (ORCPT ); Tue, 23 Feb 2021 01:35:40 -0500 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB6C7C061574; Mon, 22 Feb 2021 22:35:00 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id s24so15971163iob.6; Mon, 22 Feb 2021 22:35:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FBq/fDzJJZK8J6HmNcmzMw7q0LORfsgo8PXuQM6yZUs=; b=e6PwqemdISkuwn9ya9rgdpLdsO9YhOPBMVAL99GFNpw1x2EQgzBZJ5DVeJNkcRI3kC iGyTUt6cYcsDBYBb8X6O+EZHaO3gQ1Ma4UPdyZ6VSx46K3c/zBGMDJq/rhO6bnPPL6kK cP54CTDyxexzoL2/jynLqO6ORMChillnpgFl38a8G/6QbCdYA4kOEb0TF0BUnvTM6Pn+ 4HvDFjE9loe7Fk1yMwCvcYpD90v8tkjf0c4CmK0cslkPoJq/aSC3Br4E1K1U2dhaMEEh ywcjAO4C8/qIzxgnmbECmRIa+PNow2vGhuw/ukFQE+22Rhff2tW43LlkDSiG6+QWMJGn R4Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FBq/fDzJJZK8J6HmNcmzMw7q0LORfsgo8PXuQM6yZUs=; b=XagTnv6A0olyyZkMToOZp0Y4S4k17Ayi87pkd79SUK+NWrjFeU2x72hzFgkGXKyHBG ifsAsNO7Ru75DZ419mVuNqtWxGEW3DtwX46fJ82wpHkvjnVLdsSfmNTNVCuYq7pPOwJ8 2USqJ9abJQZrGjMU/EevJsPzXZN/Tzn8JG9+9Fodi7BaWTiVVio9Cw9W9n55PrXTOWB+ E44fC2M871ytletc+ccbucQArLygbdzoZlfe4FLhePqa5gKfKKzr78SPX+eYwMS6qEx7 JCdwFFhwaR7S4862eEhwhVHlDMTFY1nQK6w5qBTCejxB2PZzt9wvTKl67XQth1q1tLOq Febw== X-Gm-Message-State: AOAM5316l51vVSoQl6zEmjwO+kFp5g9HRYp0ze0Gjs42FtD9RA3G4nF7 V3P50Oj93QV3MSO+BGi+Ood5Ot4WrAS30JXR8a8hkwgplqmG3g== X-Received: by 2002:a02:390a:: with SMTP id l10mr25595005jaa.88.1614062100095; Mon, 22 Feb 2021 22:35:00 -0800 (PST) MIME-Version: 1.0 References: <20210219124012.92897-1-alexandru.ardelean@analog.com> <20210219124012.92897-7-alexandru.ardelean@analog.com> <20210221120958.7623e02c@archlinux> In-Reply-To: <20210221120958.7623e02c@archlinux> From: Alexandru Ardelean Date: Tue, 23 Feb 2021 08:34:46 +0200 Message-ID: Subject: Re: [PATCH v3 6/6] iio: buffer-dma: add support for cyclic DMA transfers To: Jonathan Cameron Cc: Alexandru Ardelean , LKML , linux-iio , Lars-Peter Clausen , "Hennerich, Michael" , =?UTF-8?B?TnVubyBTw6E=?= , "Bogdan, Dragos" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 21, 2021 at 2:11 PM Jonathan Cameron wrote: > > On Fri, 19 Feb 2021 14:40:12 +0200 > Alexandru Ardelean wrote: > > > From: Lars-Peter Clausen > > > > This change adds support for cyclic DMA transfers using the IIO buffer DMA > > infrastructure. > > To do this, userspace must set the IIO_BUFFER_BLOCK_FLAG_CYCLIC flag on the > > block when enqueueing them via the ENQUEUE_BLOCK ioctl(). > > > > Signed-off-by: Lars-Peter Clausen > > Signed-off-by: Alexandru Ardelean > Series in general looks good to me, but this change needs a little more > detail + probably some level of example userspace flow. > > I don't really understand how this is used! > > Also, it's easy to test output buffers with the kfifo support so we > should be able to move forward quickly with that part (1-3, 4 is probably > fine as well as clearly harmless). > > The dma stuff worries me more, at least partly based on the experience > of the original dma buffers which basically sat their unused (in upstream) > for a very long time. So to move these forward, they need to come > with users... So, this series will need to be re-sent/re-tested by someone else. I'm on my last week at ADI and I'm on vacation. Maybe I can manage to setup something to test as well, but it will take a while. > > Thanks, > > Jonathan > > > --- > > .../buffer/industrialio-buffer-dmaengine.c | 24 ++++++++++++------- > > include/uapi/linux/iio/buffer.h | 1 + > > 2 files changed, 17 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/iio/buffer/industrialio-buffer-dmaengine.c b/drivers/iio/buffer/industrialio-buffer-dmaengine.c > > index 65458a6cc81a..39cc230c7991 100644 > > --- a/drivers/iio/buffer/industrialio-buffer-dmaengine.c > > +++ b/drivers/iio/buffer/industrialio-buffer-dmaengine.c > > @@ -82,14 +82,22 @@ static int iio_dmaengine_buffer_submit_block(struct iio_dma_buffer_queue *queue, > > > > direction = dmaengine_buffer->is_tx ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; > > > > - desc = dmaengine_prep_slave_single(dmaengine_buffer->chan, > > - block->phys_addr, block->block.bytes_used, direction, > > - DMA_PREP_INTERRUPT); > > - if (!desc) > > - return -ENOMEM; > > - > > - desc->callback_result = iio_dmaengine_buffer_block_done; > > - desc->callback_param = block; > > + if (block->block.flags & IIO_BUFFER_BLOCK_FLAG_CYCLIC) { > > + desc = dmaengine_prep_dma_cyclic(dmaengine_buffer->chan, > > + block->phys_addr, block->block.bytes_used, > > + block->block.bytes_used, direction, 0); > > + if (!desc) > > + return -ENOMEM; > > + } else { > > + desc = dmaengine_prep_slave_single(dmaengine_buffer->chan, > > + block->phys_addr, block->block.bytes_used, direction, > > + DMA_PREP_INTERRUPT); > > + if (!desc) > > + return -ENOMEM; > > + > > + desc->callback_result = iio_dmaengine_buffer_block_done; > > + desc->callback_param = block; > > + } > > > > cookie = dmaengine_submit(desc); > > if (dma_submit_error(cookie)) > > diff --git a/include/uapi/linux/iio/buffer.h b/include/uapi/linux/iio/buffer.h > > index 4e4ee9befea1..1bde508fe1b9 100644 > > --- a/include/uapi/linux/iio/buffer.h > > +++ b/include/uapi/linux/iio/buffer.h > > @@ -33,6 +33,7 @@ struct iio_buffer_block_alloc_req { > > > > /* A function will be assigned later for BIT(0) */ > > #define IIO_BUFFER_BLOCK_FLAG_RESERVED (1 << 0) > > +#define IIO_BUFFER_BLOCK_FLAG_CYCLIC (1 << 1) > > > > /** > > * struct iio_buffer_block - Descriptor for a single IIO block >