Message ID | 20230314105257.17345-1-paul@crapouillou.net |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1695496wrd; Tue, 14 Mar 2023 04:20:36 -0700 (PDT) X-Google-Smtp-Source: AK7set9fCFiL/TWz+zk7za9WFT22nqUNwb5iu1lMPkQ2CGxsBq1kt4o2srcE4quDY+7qg1Zd/Ome X-Received: by 2002:a17:90b:1c05:b0:23a:ccb4:64de with SMTP id oc5-20020a17090b1c0500b0023accb464demr13406842pjb.6.1678792836667; Tue, 14 Mar 2023 04:20:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678792836; cv=none; d=google.com; s=arc-20160816; b=V96OJMGfNiH6lrWRy5iPJFNRpAriLxLFO61gPJ92uY+kJLjBwJUu+X4qh/aGBZ3G2X d2gzUmNr3sUBSXsG+qaSwgHvADDwaYICwRV+Ug3lu134oysGotZgIy8uFOvA/ci6fgMU 9tXGCPcJIjg3u++QjV5qDiCnoEhOTx+DYZw1V5izZSKXFEz6IiiG+O9rlYuPKXjwrmgy wj8Hkju/XPggFHbcxfyM4otN5+TQO9/kJySK5Qi8a1xYpVzJbrq5IlxlgZiK2UcOxIUN VrKm5i7L6tY7gwW0wAEb4NnInzf7cqNaGICmfw62n1MLBqkadjHPUVrntR3hfreOwYhs Oy+g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=lWG+KFc/Ei6/o+9Wu4zuAiJ8/qhoZmSrQx365/6Oshk=; b=yNl0rML0Ow8e1iHbvZ1e+COXhsvscK+EZM+4Q4wgL5mG6tR1cXYEai7HIMDcwnVKho 9zKjUMFUcG4UX9MraKLYNXAub+VWe4KYlmWNI/gcVcDIf8t6JdRGqhDmDKSobybkGQe5 xnl/f35WnZYKyUJucYAVQiwmSkFITDHmBiyHLK+dOxa7RjHnRcWMSw5509duLuRm5grB Q7F4n2g0wZSv3/caYF4VkVfA4M1qQ5x78W+nveLxtrUc2fWdsio+IeWOcAsw4RONBZib 8pxP1FONWcaL8QivAdE3p8VI3J5J6Y7Dsl6Kzid+TNRzxB/5sf+ETIPEoNKLEa6qjjFK ycuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b="fUjwl/GT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id me6-20020a17090b17c600b0023312fad927si2539182pjb.100.2023.03.14.04.20.24; Tue, 14 Mar 2023 04:20:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b="fUjwl/GT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229932AbjCNKxn (ORCPT <rfc822;realc9580@gmail.com> + 99 others); Tue, 14 Mar 2023 06:53:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbjCNKxf (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 14 Mar 2023 06:53:35 -0400 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2A263E625; Tue, 14 Mar 2023 03:53:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1678791191; 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=lWG+KFc/Ei6/o+9Wu4zuAiJ8/qhoZmSrQx365/6Oshk=; b=fUjwl/GTGcJeOfWYXXFY58YwTQ3Vq4QMsk3coead00trx0lcSAqYvNHlYUHM1jjAik9aEC e41Tc9t2VdvlK6F3/9913vt7NWs9yRmfxb9QXk+Ap583R8pZEVWs7vkah6OnQY1EIdjzFM hnjvZbaZk1hiQncj6By5PKHHSAkrNaE= From: Paul Cercueil <paul@crapouillou.net> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Sumit Semwal <sumit.semwal@linaro.org>, =?utf-8?q?Christian_K=C3=B6nig?= <christian.koenig@amd.com> Cc: michael.hennerich@analog.com, nuno.sa@analog.com, linux-usb@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 <paul@crapouillou.net> Subject: [PATCH 0/2] usb: gadget: functionfs: DMABUF import interface Date: Tue, 14 Mar 2023 11:52:55 +0100 Message-Id: <20230314105257.17345-1-paul@crapouillou.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760341877700973977?= X-GMAIL-MSGID: =?utf-8?q?1760341877700973977?= |
Series |
usb: gadget: functionfs: DMABUF import interface
|
|
Message
Paul Cercueil
March 14, 2023, 10:52 a.m. UTC
Hi, This small patchset adds three new IOCTLs that can be used to attach, detach, or transfer from/to a DMABUF object. This was surprisingly easy to add, as the functionfs code only uses scatterlists for transfers and allows specifying the number of bytes to transfer. The bulk of the code is then for general DMABUF accounting. The patchset isn't tagged RFC but comments are very welcome, there are some things I am not 100% sure about: ffs_dma_resv_lock (with no ww_acquire_ctx), and I'm using pr_debug which feels wrong. Also, I should probably add documentation? The current IOCTLs for functionfs were not documented, as far as I can tell. We use it with DMABUFs created with udmabuf, that we attach to the functionfs interface and to IIO devices (with a DMABUF interface for IIO, on its way to upstream too), to transfer samples from high-speed transceivers to USB in a zero-copy fashion. Cheers, -Paul Paul Cercueil (2): usb: gadget: Support already-mapped DMA SGs usb: gadget: functionfs: Add DMABUF import interface drivers/usb/gadget/function/f_fs.c | 398 ++++++++++++++++++++++++++++ drivers/usb/gadget/udc/core.c | 7 +- include/linux/usb/gadget.h | 2 + include/uapi/linux/usb/functionfs.h | 14 +- 4 files changed, 419 insertions(+), 2 deletions(-)
Comments
Am 14.03.23 um 11:52 schrieb Paul Cercueil: > Hi, > > This small patchset adds three new IOCTLs that can be used to attach, > detach, or transfer from/to a DMABUF object. > > This was surprisingly easy to add, as the functionfs code only uses > scatterlists for transfers and allows specifying the number of bytes to > transfer. The bulk of the code is then for general DMABUF accounting. > > The patchset isn't tagged RFC but comments are very welcome, there are > some things I am not 100% sure about: ffs_dma_resv_lock (with no > ww_acquire_ctx), That is perfectly fine as long as you only want to lock one dma_resv object. I've made a few notes what should be fixed and could potentially be improved, but from the DMA-buf side that looks like it should mostly work. Regards, Christian. > and I'm using pr_debug which feels wrong. Also, I > should probably add documentation? The current IOCTLs for functionfs > were not documented, as far as I can tell. > > We use it with DMABUFs created with udmabuf, that we attach to the > functionfs interface and to IIO devices (with a DMABUF interface for > IIO, on its way to upstream too), to transfer samples from high-speed > transceivers to USB in a zero-copy fashion. > > Cheers, > -Paul > > > Paul Cercueil (2): > usb: gadget: Support already-mapped DMA SGs > usb: gadget: functionfs: Add DMABUF import interface > > drivers/usb/gadget/function/f_fs.c | 398 ++++++++++++++++++++++++++++ > drivers/usb/gadget/udc/core.c | 7 +- > include/linux/usb/gadget.h | 2 + > include/uapi/linux/usb/functionfs.h | 14 +- > 4 files changed, 419 insertions(+), 2 deletions(-) >