Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp157785pxb; Mon, 16 Aug 2021 02:22:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/er4CbyfrxSvLqmKOp2ldvC683yaNCtr799FY9ErfyM2+POjX9Qq7VGa2vOOvM25cQD+N X-Received: by 2002:a92:d647:: with SMTP id x7mr6376528ilp.123.1629105752536; Mon, 16 Aug 2021 02:22:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629105752; cv=none; d=google.com; s=arc-20160816; b=GgeeREtd2eK02GCys9sYUwsiqeru9uE7+hU+UZIDKwU4eD5CbK4rBAOB2SOefDrb1V VNPM52fUGm5E6TRoTTnBfvqqGmMTaeXnS3AHEeEnjRCbtkzA7Y7Hd4fvJ97oXOwVWurk 95VFSWtqpwx3TPOA+1yJ0kGOe9qsuHv/iSOHFD0LovIQ5sfoUnd716BHEqz77O7kCItO nx718gyZtptOsNVDmPU07DQszbUJohB9whNSRAR1UDyNY+7Ojarq3ZiLpYZPmoOE6w0j svtXar6EFXBp21C81DBefBgbLpzX3sLydO7BdIcxTbVI0R994EK2SJSZ/K3VctJ0j7hr 3RCQ== 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=CjNs687ih9WaCRVON2kaxdTKvduDQBXS1ne249B8fkc=; b=Xg9hl2Q8JfjLD2RpfTG3rNjgY+INezXnK/EWdnaS4epFXFbklvweaU08igixZz+cF+ e4fXEkATZTH4A4ryMu/wmhxxfAfu7R8KO2RR0LBvLqDu0MLAIKtm2QZ6r3W7k73TbxlN B0PEVW97XyWZh+BaIqe8nigvQ7jYLsmhz7ln/kl8FOOrVzpaVg8d6tJN2jgJRYiiui8r GyXWdFwrd6rql2pEMTYV3ZneTMwP8T8O+cYmg4aItZpmujlQ9WpCJASVSC+fbWwO/BW0 oIZ4/QEBvZ4/XNSEq9LO9ZULeglc+h7AzvdPzb2odu1r4Un67Ysvl4F7NJ0tlKb65d/3 Oneg== 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=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g7si6648071jar.3.2021.08.16.02.22.19; Mon, 16 Aug 2021 02:22:32 -0700 (PDT) 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=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235341AbhHPJVI convert rfc822-to-8bit (ORCPT + 99 others); Mon, 16 Aug 2021 05:21:08 -0400 Received: from aposti.net ([89.234.176.197]:50528 "EHLO aposti.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235163AbhHPJVI (ORCPT ); Mon, 16 Aug 2021 05:21:08 -0400 Date: Mon, 16 Aug 2021 11:20:25 +0200 From: Paul Cercueil Subject: Re: IIO, dmabuf, io_uring To: Pavel Begunkov , Jonathan Lemon Cc: Jonathan Cameron , Sumit Semwal , Christian =?iso-8859-1?b?S/ZuaWc=?= , Christoph Hellwig , linux-iio@vger.kernel.org, io-uring@vger.kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Hennerich , Alexandru Ardelean Message-Id: <1YDXXQ.FDQ4R2DPJ42F@crapouillou.net> In-Reply-To: References: <2H0SXQ.2KIK2PBVRFWH2@crapouillou.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Le ven., ao?t 13 2021 at 18:20:19 +0100, Pavel Begunkov a ?crit : > Hi Paul, > > On 8/13/21 12:41 PM, Paul Cercueil wrote: >> Hi, >> >> A few months ago we (ADI) tried to upstream the interface we use >> with our high-speed ADCs and DACs. It is a system with custom ioctls >> on the iio device node to dequeue and enqueue buffers (allocated >> with dma_alloc_coherent), that can then be mmap'd by userspace >> applications. Anyway, it was ultimately denied entry [1]; this API >> was okay in ~2014 when it was designed but it feels like >> re-inventing the wheel in 2021. >> >> Back to the drawing table, and we'd like to design something that >> we can actually upstream. This high-speed interface looks awfully >> similar to DMABUF, so we may try to implement a DMABUF interface for >> IIO, unless someone has a better idea. >> >> Our first usecase is, we want userspace applications to be able to >> dequeue buffers of samples (from ADCs), and/or enqueue buffers of >> samples (for DACs), and to be able to manipulate them (mmapped >> buffers). With a DMABUF interface, I guess the userspace application >> would dequeue a dma buffer from the driver, mmap it, read/write the >> data, unmap it, then enqueue it to the IIO driver again so that it >> can be disposed of. Does that sound sane? >> >> Our second usecase is - and that's where things get tricky - to be >> able to stream the samples to another computer for processing, over >> Ethernet or USB. Our typical setup is a high-speed ADC/DAC on a dev >> board with a FPGA and a weak soft-core or low-power CPU; processing >> the data in-situ is not an option. Copying the data from one buffer >> to another is not an option either (way too slow), so we absolutely >> want zero-copy. >> >> Usual userspace zero-copy techniques (vmsplice+splice, MSG_ZEROCOPY >> etc) don't really work with mmapped kernel buffers allocated for DMA >> [2] and/or have a huge overhead, so the way I see it, we would also >> need DMABUF support in both the Ethernet stack and USB (functionfs) >> stack. However, as far as I understood, DMABUF is mostly a DRM/V4L2 >> thing, so I am really not sure we have the right idea here. >> >> And finally, there is the new kid in town, io_uring. I am not very >> literate about the topic, but it does not seem to be able to handle >> DMA buffers (yet?). The idea that we could dequeue a buffer of >> samples from the IIO device and send it over the network in one >> single syscall is appealing, though. > > You might be interested to look up zctap, previously a.k.a netgpu. CCing Jonathan (Lemon) then. Jonathan: Am I right that zctap supports importing/exporting dmabufs? Because that would solve half of my problem. Cheers, -Paul > For io_uring, it's work in progress as well. > >> >> Any thoughts? Feedback would be greatly appreciated. >> >> Cheers, >> -Paul >> >> [1]: >> https://lore.kernel.org/linux-iio/20210217073638.21681-1-alexandru.ardelean@analog.com/T/#m6b853addb77959c55e078fbb06828db33d4bf3d7 >> [2]: >> https://newbedev.com/zero-copy-user-space-tcp-send-of-dma-mmap-coherent-mapped-memory > > -- > Pavel Begunkov