From patchwork Tue Jan 30 12:23:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 194159 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1194440dyb; Tue, 30 Jan 2024 04:49:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IGpiZlKqcUJvlLLvifcm4diGQ5jaAD/GpGcF+KdAcI0zEshebzl8835GIV8Yb1NXhGlFiGl X-Received: by 2002:a05:6808:2e94:b0:3be:33a0:739c with SMTP id gt20-20020a0568082e9400b003be33a0739cmr9518914oib.15.1706618987432; Tue, 30 Jan 2024 04:49:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706618987; cv=pass; d=google.com; s=arc-20160816; b=z+k0Us305uEjTFWyGkuhmy6BAeU3RtMXKvTrLyjftQ8VLXgcdfPC+WUWnOTD89S/OW MfbP5XTwXA9IMTcfe+JrF2RbyZXg8sILdrNFHVwpyP1JTc67oNjhw34FcAovt0o/3Pf2 2XawOwwmQULDh/HkxU3/KVESH7yxQFLe5MPEjgaElCJtIzi6Rcc9SyMDwNbpPd7im0CU rjgztt//EdcLAVe9mYd/lHmFAFI6AckWssg6F1vi5F8mlr/EULERVvRM+HdWb/CCyOql ak2gIQnaAwrYzYAnPvU3f1kTqa2vCFAE/12QEhuYAstyBaffZ6P1LsdmTIgjONptpkp8 GSfw== 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=zL3Tp6j0FI2WH0LNy5N+K5/yV+yjLiDhRH8Apc3kyR0=; fh=rOwklx3n4HddILOil3p/QTffAKooJ/gOk0lSkLfkcvQ=; b=A1aVmdcpSpOWYt/uXWRWzBpxIHxjZ1lQjIh3S6vOCGVSNQ//pcWpNbJ+sE+KU/jiLS zxyLt9dDqt7TSM69TnxEn5bpx0v0ThqaTXkj7soQn8grmM+VYdzNuzO7CTq5323/hISP kuNE5//srmkxiZEf6Ntag2Xkzb6vK4rI57PdSaaAWZAbSB0x5D9mJUB7TYc+IZKF+gmR LzEo6s+a6NumCdPAd9x+pjh4YmCP5LV2z1A+XnSS+YwVzgVSZLoufP4NTCvigjfiEPGr suUHXXuDVQBC3dSC2e02mfzb0gkDNzVhHKlBnGEuK9ogFJvgHVcRittu0SZ4SxK60I0s f5OA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=vWr2oYgi; 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-44599-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44599-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i14-20020a056a00004e00b006d9ac80ad3dsi7404633pfk.146.2024.01.30.04.49.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:49:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44599-ouuuleilei=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=vWr2oYgi; 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-44599-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44599-ouuuleilei=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 25114B27451 for ; Tue, 30 Jan 2024 12:25:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B9626D1BC; Tue, 30 Jan 2024 12:24:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="vWr2oYgi" 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 601296A035; Tue, 30 Jan 2024 12:24:24 +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=1706617465; cv=none; b=INAx3ibGqMWZqZBtfrnl6+EeYgV24rn38JRHKih0lNUc0KLyaxzIaY8fpiLszu0PTki6KV5iVRAb1iwEy/5kCO7y434l3e5qcbH5uPGGrh57huFeCK1YC+Qx9C9DKGFW0fPbec1utTYLWHDXNQvxI0xKyBTMZk6UHK3s94zXuBY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706617465; c=relaxed/simple; bh=cJbgWol1KPqWfYEC1f0fo3P+Gvr3uUpwLWEV8WXaueM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K+ubo4LuHBmvdqR4Ka/ggToftVThCSvNIX2MzacFwAet80xlu/6Ub37lE5eNKr+8PGTT7rEyftSwB3aDJ5ztHWRx34cs7YK2mraPIT5B3TLjTI32MsWr1ZMgUmvdvLFPrhiaymmLYIgDjRqZomxQG6Q0vQxZC10cqcR1ZVbUYmk= 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=vWr2oYgi; 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=1706617430; 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=vWr2oYgiEkvETCuZs/8NQXdO8VjlAhSkCj9bk153RIvE9EwoHvlPQ952ZQGv+igCZ1AT0e cXr+/5L1v9tbOkUMhS4DGoIyyRj2/08NDMPa/y85LNGidr13f3FRq3itaNBi7jPJqb8mPJ 74BHeddIzjwI7mxWHT6QLnlZTcLFDy0= From: Paul Cercueil To: Greg Kroah-Hartman , Jonathan Corbet , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= Cc: =?utf-8?q?Nuno_S=C3=A1?= , Jonathan Cameron , Michael Hennerich , 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 v6 4/4] Documentation: usb: Document FunctionFS DMABUF API Date: Tue, 30 Jan 2024 13:23:40 +0100 Message-ID: <20240130122340.54813-5-paul@crapouillou.net> In-Reply-To: <20240130122340.54813-1-paul@crapouillou.net> References: <20240130122340.54813-1-paul@crapouillou.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789519711457123494 X-GMAIL-MSGID: 1789519711457123494 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.