Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp224551lqr; Wed, 5 Jun 2024 04:24:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWOGaT3ONl9GYpu2la7jC9Ge5zIiampmzR7qQqXHuO90kqkjyiGJiNFMgiyzVBvnYhgC2Ulun2D4arElkVls8LSkmNb+hU4H2Bmd+5JaQ== X-Google-Smtp-Source: AGHT+IHfV7gFw/1AzXzjfjk8qiksZWD1scq+DSpFlAmRwXwWpwhvAByunbmYAjudyrPTE/73PB0Q X-Received: by 2002:a05:6871:7994:b0:24e:4fef:61d9 with SMTP id 586e51a60fabf-251228b01c6mr2369061fac.43.1717586666756; Wed, 05 Jun 2024 04:24:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717586666; cv=pass; d=google.com; s=arc-20160816; b=IHUCEB7HZyh9IFKH5Q+Vn1Fjci3J5S0PzZWyM7vVSn7JOnfm5I5a9JrkE/4a8cBjz6 2m+6IgnPOeGYwaAbwhauz5NXEQh5Itcw5+7rn4g2K94NpS6rQA6wNqr94gUr9BKxPqVo e12DNa/3HKaLh9xkbjgIpn2RWwwG6zRWw8enrd9y7hQVWj8P9m+3SsPDPCNymyL79Ux3 2SN8K7REGqCLpajAkK5sk46FNuEz97dXyuiqKB+6Ss+HFjKXsEY4b70ZfY1vwpSgUF8q NEbABNg3NNitBrsOW1MM3SQ0W65qT+7Xe+hpE+/TjuALitbbw1pHDYEv6wA0OIcx7vrt bp+w== 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=zZ1Ob78ZjWlZgX+z9DrKajLPpBuBZCqRum8/eJrHWnI=; fh=gIPS46kF5oiVtxHOjYLqoXg82bH7WL+T2QnpDaGuRdA=; b=VQt7IGRJCeBEpgZHsA5e8cP0LhVz9CY7eBiQJzBkOwSMg9aXSNiq7nrpEi4gjdm2aH L6nbt+I4z2QUGZ4NwMpWhpW6OwcTyPDIwwy+VBQk3kMoW9qUbbNXaFxafeeOKhiaXnhE 5Ubxf/mgutNHWy2e9zwX/COQMJCl6de32NUbgMMNJwWVpglpktW6UhgRLQjHtyqQJoea DiinfUt7Tr1XS5Zj+BOXFaB5TdIJJpmD0MMtBvDz1EpvE5phw/lt0Jf1j4i28PbcaQ4W r1MUCIIobr9yuTihSQEG96egJ3p9QIGUMrCJkjqfHNGYRFUdW4HWB6yq28i4y7SmIAVL 2CPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=XzmtI09r; 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-202239-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202239-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c35d3b3df4si2255476a12.804.2024.06.05.04.24.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 04:24:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202239-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=XzmtI09r; 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-202239-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202239-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 5D15BB237CB for ; Wed, 5 Jun 2024 11:11:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EF53A194A4F; Wed, 5 Jun 2024 11:09:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="XzmtI09r" 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 990BC190490; Wed, 5 Jun 2024 11:09:57 +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=1717585799; cv=none; b=kYRzDQEy+7Pch36wHbpGK/BIFS/ein9n52QkmKK7ZY9tlioT8Kh0eFFoGExrINALjgmWLmHJQZTLDiwYrV7ZnxBP95pXnmXldddXfyWx6mtROWD0nDBYSlF4fljvrEaoVKcCCvHKn60m6Gaq3+SIlSTUC+nN4DvkUs1Gzdd6nK4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717585799; c=relaxed/simple; bh=HzcPhbufi5cXlv2G7/7Dg+cEaQz53uXcRQczeDy0Lfs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V2vLPM1TAoDjBRts65zdi47U5vdEHkDq0192jk8mRR7OcAm6HvqOCYc4vntgM1SASXbzmP5kxSkupdoK2DIzI2oHY5868Md2YRQj0yyL1sUiXB1phorH/TMWKFEsGjDqYXDSVY8OMueDJYBuaVo/wuZ+tNaiYYzJSoU3Q7KhjFk= 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=XzmtI09r; 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=1717585744; 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=zZ1Ob78ZjWlZgX+z9DrKajLPpBuBZCqRum8/eJrHWnI=; b=XzmtI09rBY87MWojYhpPffNwV+tIMJP6oV+FTMNTTJFdgqd6aGorPN8QY9MEhjGs0p30GT UDdqbOzhHbVGVhxE6bULS4PlV2hNYB8TNXt+MPSR3S/QMXX9ISC/bgsOfQE1l+Dn8t2dnY BAIpk7/OcL7arzBDOyPGSrn5rpSGGuY= From: Paul Cercueil To: Jonathan Cameron , Lars-Peter Clausen , Vinod Koul , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= Cc: Jonathan Corbet , Nuno Sa , linux-iio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, Paul Cercueil Subject: [PATCH v10 6/6] Documentation: iio: Document high-speed DMABUF based API Date: Wed, 5 Jun 2024 13:08:45 +0200 Message-ID: <20240605110845.86740-7-paul@crapouillou.net> In-Reply-To: <20240605110845.86740-1-paul@crapouillou.net> References: <20240605110845.86740-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 Document the new DMABUF based API. Signed-off-by: Paul Cercueil Signed-off-by: Nuno Sa --- v2: - 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. v3: Update the documentation to reflect the new API. v5: Use description lists for the documentation of the three new IOCTLs instead of abusing subsections. v8: Renamed dmabuf_api.rst -> iio_dmabuf_api.rst, and updated index.rst whose format changed in iio/togreg. --- Documentation/iio/iio_dmabuf_api.rst | 54 ++++++++++++++++++++++++++++ Documentation/iio/index.rst | 1 + 2 files changed, 55 insertions(+) create mode 100644 Documentation/iio/iio_dmabuf_api.rst diff --git a/Documentation/iio/iio_dmabuf_api.rst b/Documentation/iio/iio_dmabuf_api.rst new file mode 100644 index 000000000000..1cd6cd51a582 --- /dev/null +++ b/Documentation/iio/iio_dmabuf_api.rst @@ -0,0 +1,54 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=================================== +High-speed DMABUF interface for IIO +=================================== + +1. Overview +=========== + +The Industrial I/O subsystem supports access to buffers through a +file-based interface, with read() and write() access calls through the +IIO device's dev node. + +It additionally supports a DMABUF based interface, where the userspace +can attach DMABUF objects (externally created) to a IIO buffer, and +subsequently use them for data transfers. + +A userspace application can then use this interface to share DMABUF +objects between several interfaces, allowing it to transfer data in a +zero-copy fashion, for instance between IIO and the USB stack. + +The userspace application can also memory-map the DMABUF objects, and +access the sample data directly. The advantage of doing this vs. the +read() interface is that it avoids an extra copy of the data between the +kernel and userspace. This is particularly useful for high-speed devices +which produce several megabytes or even gigabytes of data per second. +It does however increase the userspace-kernelspace synchronization +overhead, as the DMA_BUF_SYNC_START and DMA_BUF_SYNC_END IOCTLs have to +be used for data integrity. + +2. User API +=========== + +As part of this interface, three new IOCTLs have been added. These three +IOCTLs have to be performed on the IIO buffer's file descriptor, +obtained using the IIO_BUFFER_GET_FD_IOCTL() ioctl. + + ``IIO_BUFFER_DMABUF_ATTACH_IOCTL(int)`` + Attach the DMABUF object, identified by its file descriptor, to the + IIO buffer. Returns zero on success, and a negative errno value on + error. + + ``IIO_BUFFER_DMABUF_DETACH_IOCTL(int)`` + Detach the given DMABUF object, identified by its file descriptor, + from the IIO buffer. Returns zero on success, and a negative errno + value on error. + + Note that closing the IIO buffer's file descriptor will + automatically detach all previously attached DMABUF objects. + + ``IIO_BUFFER_DMABUF_ENQUEUE_IOCTL(struct iio_dmabuf *iio_dmabuf)`` + Enqueue a previously attached DMABUF object to the buffer queue. + Enqueued DMABUFs will be read from (if output buffer) or written to + (if input buffer) as long as the buffer is enabled. diff --git a/Documentation/iio/index.rst b/Documentation/iio/index.rst index 4c13bfa2865c..9cb4c50cb20d 100644 --- a/Documentation/iio/index.rst +++ b/Documentation/iio/index.rst @@ -9,6 +9,7 @@ Industrial I/O iio_configfs iio_devbuf + iio_dmabuf_api iio_tools Industrial I/O Kernel Drivers -- 2.43.0