Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7987988pxb; Fri, 19 Feb 2021 04:44:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJwSX61a4wSMl8XIn2SMiM2EF/Ig3DgTS5I5xooLwgURCdUXpVQYYP9X7weokNypQCMiRcSt X-Received: by 2002:a17:906:753:: with SMTP id z19mr8440572ejb.15.1613738648051; Fri, 19 Feb 2021 04:44:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613738648; cv=none; d=google.com; s=arc-20160816; b=l0UUAepMRppGneD/GsjzYtnH7r6WRPzDOkYZ/aGQYzDJRfsQjcdaYi5cpR9NfLujcy xWXkKfr7/N2vrlPmRqm95owWqzzu3fTAIAtrCA/kzt/rh20oVPILlyl2lSZwDnWaT3x+ tMPUIU6q1oZrTSFByr0U4t/8D3OzXvj3lFUH12sLzPSZAJ3IrgIzDOOMlbFs+YTfskoc 2HD/4rl4BefAmoHuyuEGFWcSsW0olo2vH0bXo8P/3OEycYsK/sPlWR9UvZzmdWUUZR5x p0ey48ZeKn5dvo1MlEPCUOzaT58hj3GnSN5uuXY//DOELG0qjfnUnRpxP6gZ2i+8dw6E Hemw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=6cB9IJ2+3LJSXzjxVn8a4czwLSoPVMrEAJLw6nEmJe0=; b=yk+CezruTlugGI7srklBjklOBX1J+gzm4IlQsXyxGAROqey14y6kuiy25vimDBB5Be KBti/ASabaYuavUyY82CLqfdT7/QY0tejG8cpxUZjN3S0ZMpAh/K12kKD/fQdl8enh8R hzNDSAFvCmhq0R0U0MB/Y4TxlcVcRJ3fUDo0o9a6H2260tvY8sK2kaG9xdxc4Bx2F/Fm huUQ7XZABxoK40EjybFj739VtPFY7lNveTqz+KvT4v/28C/a7WK+NJDsSF4kPWAZR5cl sD+U/M6+/Zh2kEOyoAHwwrcw5gSlvC+UelOvHlgS108aqu65swwLlePSV21XrmOmWhqT CfYg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z1si5787756edp.254.2021.02.19.04.43.44; Fri, 19 Feb 2021 04:44:08 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230446AbhBSMlz (ORCPT + 99 others); Fri, 19 Feb 2021 07:41:55 -0500 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:61646 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230308AbhBSMlX (ORCPT ); Fri, 19 Feb 2021 07:41:23 -0500 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11JCOn5a000385; Fri, 19 Feb 2021 07:40:31 -0500 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com with ESMTP id 36p9gbadc5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 07:40:31 -0500 Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 11JCeUAr052017 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 19 Feb 2021 07:40:30 -0500 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.721.2; Fri, 19 Feb 2021 07:40:29 -0500 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB4.ad.analog.com (10.64.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.721.2; Fri, 19 Feb 2021 07:40:29 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.721.2 via Frontend Transport; Fri, 19 Feb 2021 07:40:29 -0500 Received: from saturn.ad.analog.com ([10.48.65.120]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 11JCeH4v008911; Fri, 19 Feb 2021 07:40:26 -0500 From: Alexandru Ardelean To: , CC: , , , , , Alexandru Ardelean Subject: [PATCH v3 6/6] iio: buffer-dma: add support for cyclic DMA transfers Date: Fri, 19 Feb 2021 14:40:12 +0200 Message-ID: <20210219124012.92897-7-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210219124012.92897-1-alexandru.ardelean@analog.com> References: <20210219124012.92897-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-02-19_05:2021-02-18,2021-02-19 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 clxscore=1015 mlxscore=0 priorityscore=1501 impostorscore=0 adultscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102190101 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- .../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 -- 2.27.0