Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp454287pxb; Tue, 15 Feb 2022 18:21:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzaWQDkNAh+85YTEQryYKcwLnHPkuXEqT/Oys0mdnI1DVdgwXZIlkFxPKx5kkVX6a72KID2 X-Received: by 2002:a17:906:2f8b:b0:6b9:1a9a:bf35 with SMTP id w11-20020a1709062f8b00b006b91a9abf35mr637361eji.2.1644978071192; Tue, 15 Feb 2022 18:21:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644978071; cv=none; d=google.com; s=arc-20160816; b=PC4hNkk+ss1xbWqWPqUOuZZsoxE9zAtSmOWD3r33H0WuiEEtIn/o6rkNTLhn1Q7EpB LkNBN6OHTBevJLzBsP2gfdSzT+Mx9ju+CghSwEuA7wu/8oF4/L2P01VvWM8fryXQvwMx tJEDCvyDZUlIb/ZGqW18JHiWEYcvzbWFkluFsYtQBpk2ZGhD3W1EGtXYznc8qbjm8Y+o J/9z07PqCxbrQU4v4kfBxNAunYykupXoFXb06fxEFGzrLsU9oa/UxOiuoM7ethe3P1ME y+SIQLvMMn+zkeaQVKdLIiC2qVnF1+wUO4P/gxwR7bumAJlGo64nq0GbRPog+rHcR1K9 jC0Q== 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:cc:to:subject:from:date; bh=bsRVYl9UNG9Bp3adKilEpMucg4scYuA5vCQSclee/wM=; b=ViGMp26P4Inxv4OxzNf1TResl41jNZQMKi2OnH2SXKiPDXgQ1T0ctZaht0WezlqdYP 7CcGEkSAtPyG4IHk3HVxa285XeKlpfyyar0JiLbOROblgs0k/wDOhGfwt0dIQ/1X1rxW cAXvDa2/TuGYm0Cbb8q9A1YeT58Vu+0yUjx885ihpQLJ+YbxHynqBE3Rpoxd6bkCGs0V JS6vHapBHjmNB8/wK5h3XGI/WV7OkF5uIGr9kQqZDKG2hp/+2mMFaQHBhdtx5B8NSm7o eavo+ainuv+8nQe2IMsDd/Mqec3DsPQIlBGSOhMYfnG040YecndKdmTZV1TViZmxFeMp I4uQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kg4si1066647ejc.171.2022.02.15.18.20.48; Tue, 15 Feb 2022 18:21:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242648AbiBORn7 convert rfc822-to-8bit (ORCPT + 99 others); Tue, 15 Feb 2022 12:43:59 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:35366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbiBORn7 (ORCPT ); Tue, 15 Feb 2022 12:43:59 -0500 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BF77E5406; Tue, 15 Feb 2022 09:43:48 -0800 (PST) Date: Tue, 15 Feb 2022 17:43:35 +0000 From: Paul Cercueil Subject: Re: [PATCH v2 00/12] iio: buffer-dma: write() and new DMABUF based API To: Jonathan Cameron Cc: Michael Hennerich , Lars-Peter Clausen , Christian =?iso-8859-1?b?S/ZuaWc=?= , Sumit Semwal , Jonathan Corbet , Alexandru Ardelean , dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Message-Id: In-Reply-To: <20220213184616.669b490b@jic23-huawei> References: <20220207125933.81634-1-paul@crapouillou.net> <20220213184616.669b490b@jic23-huawei> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-13; format=flowed Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jonathan, Le dim., f?vr. 13 2022 at 18:46:16 +0000, Jonathan Cameron a ?crit : > On Mon, 7 Feb 2022 12:59:21 +0000 > Paul Cercueil wrote: > >> Hi Jonathan, >> >> This is the V2 of my patchset that introduces a new userspace >> interface >> based on DMABUF objects to complement the fileio API, and adds >> write() >> support to the existing fileio API. > > Hi Paul, > > It's been a little while. Perhaps you could summarize the various view > points around the appropriateness of using DMABUF for this? > I appreciate it is a tricky topic to distil into a brief summary but > I know I would find it useful even if no one else does! So we want to have a high-speed interface where buffers of samples are passed around between IIO devices and other devices (e.g. USB or network), or made available to userspace without copying the data. DMABUF is, at least in theory, exactly what we need. Quoting the documentation (https://www.kernel.org/doc/html/v5.15/driver-api/dma-buf.html): "The dma-buf subsystem provides the framework for sharing buffers for hardware (DMA) access across multiple device drivers and subsystems, and for synchronizing asynchronous hardware access. This is used, for example, by drm ?prime? multi-GPU support, but is of course not limited to GPU use cases." The problem is that right now DMABUF is only really used by DRM, and to quote Daniel, "dma-buf looks like something super generic and useful, until you realize that there's a metric ton of gpu/accelerator bagage piled in". Still, it seems to be the only viable option. We could add a custom buffer-passing interface, but that would mean implementing the same buffer-passing interface on the network and USB stacks, and before we know it we re-invented DMABUFs. Cheers, -Paul >> >> Changes since v1: >> >> - the patches that were merged in v1 have been (obviously) dropped >> from >> this patchset; >> - the patch that was setting the write-combine cache setting has >> been >> dropped as well, as it was simply not useful. >> - [01/12]: >> * Only remove the outgoing queue, and keep the incoming queue, >> as we >> want the buffer to start streaming data as soon as it is >> enabled. >> * Remove IIO_BLOCK_STATE_DEQUEUED, since it is now functionally >> the >> same as IIO_BLOCK_STATE_DONE. >> - [02/12]: >> * Fix block->state not being reset in >> iio_dma_buffer_request_update() for output buffers. >> * Only update block->bytes_used once and add a comment about >> why we >> update it. >> * Add a comment about why we're setting a different state for >> output >> buffers in iio_dma_buffer_request_update() >> * Remove useless cast to bool (!!) in iio_dma_buffer_io() >> - [05/12]: >> Only allow the new IOCTLs on the buffer FD created with >> IIO_BUFFER_GET_FD_IOCTL(). >> - [12/12]: >> * Explicitly state that the new interface is optional and is >> not implemented by all drivers. >> * The IOCTLs can now only be called on the buffer FD returned by >> IIO_BUFFER_GET_FD_IOCTL. >> * Move the page up a bit in the index since it is core stuff >> and not >> driver-specific. >> >> The patches not listed here have not been modified since v1. >> >> Cheers, >> -Paul >> >> Alexandru Ardelean (1): >> iio: buffer-dma: split iio_dma_buffer_fileio_free() function >> >> Paul Cercueil (11): >> iio: buffer-dma: Get rid of outgoing queue >> iio: buffer-dma: Enable buffer write support >> iio: buffer-dmaengine: Support specifying buffer direction >> iio: buffer-dmaengine: Enable write support >> iio: core: Add new DMABUF interface infrastructure >> iio: buffer-dma: Use DMABUFs instead of custom solution >> iio: buffer-dma: Implement new DMABUF based userspace API >> iio: buffer-dmaengine: Support new DMABUF based userspace API >> iio: core: Add support for cyclic buffers >> iio: buffer-dmaengine: Add support for cyclic buffers >> Documentation: iio: Document high-speed DMABUF based API >> >> Documentation/driver-api/dma-buf.rst | 2 + >> Documentation/iio/dmabuf_api.rst | 94 +++ >> Documentation/iio/index.rst | 2 + >> drivers/iio/adc/adi-axi-adc.c | 3 +- >> drivers/iio/buffer/industrialio-buffer-dma.c | 610 >> ++++++++++++++---- >> .../buffer/industrialio-buffer-dmaengine.c | 42 +- >> drivers/iio/industrialio-buffer.c | 60 ++ >> include/linux/iio/buffer-dma.h | 38 +- >> include/linux/iio/buffer-dmaengine.h | 5 +- >> include/linux/iio/buffer_impl.h | 8 + >> include/uapi/linux/iio/buffer.h | 30 + >> 11 files changed, 749 insertions(+), 145 deletions(-) >> create mode 100644 Documentation/iio/dmabuf_api.rst >> >