Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1577847rdb; Mon, 8 Jan 2024 04:02:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGxP/Qv2flAVZz37CftxZL+1rsnlRgKA9Mf6Qe9rcOTR1xzPJiSP/7lJYjtsh2eCpIX1Spd X-Received: by 2002:a05:6102:d87:b0:467:df3d:6aa9 with SMTP id d7-20020a0561020d8700b00467df3d6aa9mr127357vst.18.1704715363370; Mon, 08 Jan 2024 04:02:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704715363; cv=none; d=google.com; s=arc-20160816; b=gcBI3hzJqYqCJBXV1mpdBW2y5W3+0iHgGs3c4Qihfy9jKRO85FMruGEYdUvwXHvaEV yLxLHSMOARmqyLV6jLjhgui+FFhsrRPqfDvMOu3K52Q4e8LixkarxosT918sZqga5jU/ K4BbAClRhJWNL5FwLgTiaJ4JbbJcS4tTt6MO+peIeUO/jEeYT6dp5NhhdiJ0AGM3wA5o EgGXCb9zTMMrsyb0DkiDCT4vZVi0SspsadYvqeI+86H1QoQ1vu7rEGJGKfi3wFSKVeJX c/ZqUGYTmzvN+bydQ0Wl2aUSCmmghSok33NApwy3b8yRwMLX5WG0/UJ57hdyckS0uLWn 95kw== ARC-Message-Signature: i=1; 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=zL3Tp6j0FI2WH0LNy5N+K5/yV+yjLiDhRH8Apc3kyR0=; fh=uCl+pDf5A/h9/EhC2a7e6oA3XsaNDDsC5zMoVf40Kzc=; b=grHB5RNd1VH8k6CjblLE17K12K3knU1vzHOc6aJvSJhPiIoEWeOTIWTaG/bV6M/1GS z8gpVTpdUUlu5Atjw5VKImKD0GYZgmIF+swDavQXnptSGQmMtIkSz7BWiALILefbdH/E xQPF+vPmICjx1q/20Nr7YAzDFA/ME/Mm05puvAklyME+gH1qGShrylffC0dXBUqLRWhE ZX4Fqpv+UKGXdXdYYidh8HosZvONsI2Cn8uI/jOlWSqDJ3UXMlQXoj7TblMpcwik5tZ7 AIY5PY3+OixYjbWJxMYhvyw4dwZSCHR3S558oDDTJ4QLJ+QemPk+WVJikMeKG+NuZ11J IhDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=cgWfNFnB; spf=pass (google.com: domain of linux-kernel+bounces-19464-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19464-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id q8-20020a67b908000000b004670430b51csi502272vsn.602.2024.01.08.04.02.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 04:02:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19464-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=cgWfNFnB; spf=pass (google.com: domain of linux-kernel+bounces-19464-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19464-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 20B871C22325 for ; Mon, 8 Jan 2024 12:02:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9B6D2EB07; Mon, 8 Jan 2024 12:01:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="cgWfNFnB" X-Original-To: linux-kernel@vger.kernel.org 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 9B59B29412; Mon, 8 Jan 2024 12:01:43 +0000 (UTC) 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=1704715266; 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=zL3Tp6j0FI2WH0LNy5N+K5/yV+yjLiDhRH8Apc3kyR0=; b=cgWfNFnBlx8XcxRkz6PLY+lsRV8zjLvwNCEb+L6VVnv8ksJAaPibrjKhNtF2TaQWErgXH7 Y9cBoaxDQIPQTzwMdqXvjv+LRDIlmk+keUTPfMvZiGpAlwBPhtwUQ3ucK2+vQTwRu7HRpY TyoFiLpGf5rG8lSa0r3vZX5fMmkmdB0= From: Paul Cercueil To: Greg Kroah-Hartman , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= , Jonathan Corbet Cc: Jonathan Cameron , =?UTF-8?q?Nuno=20S=C3=A1?= , Michael Hennerich , Andrzej Pietrasiewicz , linux-usb@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, Paul Cercueil Subject: [PATCH v3 4/4] Documentation: usb: Document FunctionFS DMABUF API Date: Mon, 8 Jan 2024 13:00:56 +0100 Message-ID: <20240108120056.22165-5-paul@crapouillou.net> In-Reply-To: <20240108120056.22165-1-paul@crapouillou.net> References: <20240108120056.22165-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 X-Spam: Yes Add documentation for the three ioctls used to attach or detach externally-created DMABUFs, and to request transfers from/to previously attached DMABUFs. Signed-off-by: Paul Cercueil --- v3: New patch --- Documentation/usb/functionfs.rst | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Documentation/usb/functionfs.rst b/Documentation/usb/functionfs.rst index a3054bea38f3..d05a775bc45b 100644 --- a/Documentation/usb/functionfs.rst +++ b/Documentation/usb/functionfs.rst @@ -2,6 +2,9 @@ How FunctionFS works ==================== +Overview +======== + From kernel point of view it is just a composite function with some unique behaviour. It may be added to an USB configuration only after the user space driver has registered by writing descriptors and @@ -66,3 +69,36 @@ have been written to their ep0's. Conversely, the gadget is unregistered after the first USB function closes its endpoints. + +DMABUF interface +================ + +FunctionFS additionally supports a DMABUF based interface, where the +userspace can attach DMABUF objects (externally created) to an endpoint, +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. + +As part of this interface, three new IOCTLs have been added. These three +IOCTLs have to be performed on a data endpoint (ie. not ep0). They are: + + ``FUNCTIONFS_DMABUF_ATTACH(int)`` + Attach the DMABUF object, identified by its file descriptor, to the + data endpoint. Returns zero on success, and a negative errno value + on error. + + ``FUNCTIONFS_DMABUF_DETACH(int)`` + Detach the given DMABUF object, identified by its file descriptor, + from the data endpoint. Returns zero on success, and a negative + errno value on error. Note that closing the endpoint's file + descriptor will automatically detach all attached DMABUFs. + + ``FUNCTIONFS_DMABUF_TRANSFER(struct usb_ffs_dmabuf_transfer_req *)`` + Enqueue the previously attached DMABUF to the transfer queue. + The argument is a structure that packs the DMABUF's file descriptor, + the size in bytes to transfer (which should generally correspond to + the size of the DMABUF), and a 'flags' field which is unused + for now. Returns zero on success, and a negative errno value on + error. -- 2.43.0