Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp360720rdb; Wed, 17 Jan 2024 04:27:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IFOzk6Fus2hDyb4yhGXOeZJzK8b4oDxYDk+GHE9SIkMnOT/Ff+Rx63eI3mlaRarXnihGioA X-Received: by 2002:a17:907:3182:b0:a28:f8d2:7897 with SMTP id xe2-20020a170907318200b00a28f8d27897mr5360786ejb.20.1705494429037; Wed, 17 Jan 2024 04:27:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705494429; cv=pass; d=google.com; s=arc-20160816; b=mpiZZeJQNjI3MrkIie65Es0gsMSa8+gTBLfmeSXwDSwFfLpU+dHfK2/8XHDusTPu0g gZkIB722chb3XjYs95xcPPuBDrqEY4rcNiMdRsomNhzexJp8D5IVBH2pcREYENCOvsyx NdFQgVH1UKKMKVVUSaRXrHCvO6pvFliVocF8sDGjXYczeic06Oly+m8xRCAnXn+zr8oD McFVQ3/cmbDSrWJ1Gfw9r/WUgtiieicth0v0yIkzEBgiQ+L16it3iCrrEHmeY32y7D60 dVvNwX7Nmh+m0cWDtAf90JyhzZzuxAP7RuLPal8mrfPxGbaxv4JyYOa2Ra6ai12ze4O2 n29g== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=/sDVLzlV6tVM1+jlnCP4YrSpFonZ8VEXETbEWgRMsuA=; fh=3Xwiw3h4BuSZxa4g5nlxoJvEg1Pn4zGp9h0k4mfsabo=; b=VoOtxR+fgaBtHQSoqDmE58FpfFvd73ONLxyQ7v6zBrQvzvgMAKgkT6ouGBZ7oYIkKm 2ohYXD+UoIwsbx3bcbC+aW6yseOHwmW8TjX4ukL+duDN3bKdMcVhmPFvfK6p/oy2dGYH gZMaZw0xjNO7idboK6+Kr23r+mwhJ4WpSisDkvMq8qdi+EyVA/9mDZTxGR/3Qi5ONilC G8SBDjuuaYY/sbHvPsi/B+1R8RFVhtA1+xxbVojnRIsGlHKnnSNm3G2aiHlANbyon5/W b8CmTqOScFAp1+andAoGhlEF1H/fgq5uEcD9v8M3UBHVTVJ34BzavjIrDPG3VXEvhN9/ jIUw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=AnuJeXJr; 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-28958-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28958-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gq25-20020a170906e25900b00a2e81b272fesi1328009ejb.895.2024.01.17.04.27.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 04:27:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-28958-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=AnuJeXJr; 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-28958-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28958-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 am.mirrors.kernel.org (Postfix) with ESMTPS id A09D01F234CC for ; Wed, 17 Jan 2024 12:27:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 030DA1DFFB; Wed, 17 Jan 2024 12:26:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="AnuJeXJr" 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 97F5F1DFE2; Wed, 17 Jan 2024 12:26:54 +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=1705494416; cv=none; b=cm5TaNsXXZ2NvkQmC5XSZRsjAwinYOEiE2bYCFNcm6oc97+myDqoqUoqonGcvAIjoL+H3TR24zN3afS6zOYAFd1kELpvpXsw90S8p4F/ZFDIc5mrOvIgPYlGoeVMh9oUyK3sGg7HEx/yDQTuUj4a1vNA9CgWfArz5cpO72BlIhU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705494416; c=relaxed/simple; bh=jKj25He18n4jFRUrfK3U0YJkmURbZGCWIaQo843xvqA=; h=DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:X-Spam; b=nowmiBAFoQ+8hVm9fEWrMcwLCOgmzYDyimuBKwMLw4NL0QhwSp7iaq/Wp/NI9eKCeWSi6i3N9sdMJZdgvC2d79s4+SSIxCccVr2doaOlpyrp9nSR4d2rnir9BXVg/XqlOMPjH2f6h8pwxkiML42vaCsXT7swGdGRL5MkJO9nmOE= 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=AnuJeXJr; 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=1705494412; 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; bh=/sDVLzlV6tVM1+jlnCP4YrSpFonZ8VEXETbEWgRMsuA=; b=AnuJeXJrsxDBX4u2PXAQELZ/ATdNATOI3nnJtTFJP8NZyE+fPe7/7Wl72Pf0pufRWaFvP1 sNzzWBdCHYltlr90nl6m+MVGb9eTfWZS+78j7Mt7MuOAR0Qk1audmOo2VqSZdf8a89jbTb IWdLbuxuhZnhf1RqMzfVvZA6GZH3DTg= From: Paul Cercueil To: Greg Kroah-Hartman , Jonathan Corbet , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= Cc: Jonathan Cameron , =?UTF-8?q?Nuno=20S=C3=A1?= , 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 v4 0/4] usb: gadget: functionfs: DMABUF import interface Date: Wed, 17 Jan 2024 13:26:42 +0100 Message-ID: <20240117122646.41616-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 Hi, This is the v4 of my patchset that adds a new DMABUF import interface to FunctionFS. It addresses the points that Daniel raised on the v3 - see changelog below. This interface is being used at Analog Devices, to transfer data from high-speed transceivers to USB in a zero-copy fashion, using also the DMABUF import interface to the IIO subsystem which is being upstreamed in parallel [1]. The two are used by the Libiio software [2]. On a ZCU102 board with a FMComms3 daughter board, using the combination of these two new interfaces yields a drastic improvement of the throughput, from about 127 MiB/s using IIO's buffer read/write interface + read/write to the FunctionFS endpoints, to about 274 MiB/s when passing around DMABUFs, for a lower CPU usage (0.85 load avg. before, vs. 0.65 after). Right now, *technically* there are no users of this interface, as Analog Devices wants to wait until both interfaces are accepted upstream to merge the DMABUF code in Libiio into the main branch, and Jonathan wants to wait and see if this patchset is accepted to greenlight the DMABUF interface in IIO as well. I think this isn't really a problem; once everybody is happy with its part of the cake, we can merge them all at once. This is obviously for 5.9, and based on next-20240117. Changelog: - [3/4]: - Protect the dmabufs list with a mutex - Use incremental sequence number for the dma_fences - Unref attachments and DMABUFs in workers - Remove dead code in ffs_dma_resv_lock() - Fix non-block actually blocking - Use dma_fence_begin/end_signalling() - Add comment about cache-management and dma_buf_unmap_attachment() - Make sure dma_buf_map_attachment() is called with the dma-resv locked Cheers, -Paul [1] https://lore.kernel.org/linux-iio/219abc43b4fdd4a13b307ed2efaa0e6869e68e3f.camel@gmail.com/T/ [2] https://github.com/analogdevicesinc/libiio/tree/pcercuei/dev-new-dmabuf-api Paul Cercueil (4): usb: gadget: Support already-mapped DMA SGs usb: gadget: functionfs: Factorize wait-for-endpoint code usb: gadget: functionfs: Add DMABUF import interface Documentation: usb: Document FunctionFS DMABUF API Documentation/usb/functionfs.rst | 36 ++ drivers/usb/gadget/function/f_fs.c | 500 ++++++++++++++++++++++++++-- drivers/usb/gadget/udc/core.c | 7 +- include/linux/usb/gadget.h | 2 + include/uapi/linux/usb/functionfs.h | 41 +++ 5 files changed, 565 insertions(+), 21 deletions(-) -- 2.43.0