From nobody Mon Jul 21 06:17:15 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4blqtg5zl6z62D7d; Mon, 21 Jul 2025 06:17:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4blqtg3DThz3Sk5; Mon, 21 Jul 2025 06:17:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753078635; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3mO631SF39AILQKZb9n0saDhXJwlN0BASHAyZv2XnyY=; b=n174vCgJ8T6UICxHx9XqZ28JJyk872wVbCE5NHRXxzSIXe2Py7Cf85P4xCDyWuCUnTeWFd KWagh2EdxArrEYdRmpL1ADPMOpcQn90PrfrrUPmCWDDh/2lm5WbyyOMtcX8FI6FgPbTBEK WbsNq2swttnVb+7y5maq/2CdY7ImbFOQvN1JSDwbz7RN2jSjnu9qMOyBYL1f41nQGmmjYu 8LcfSUKZMIAE/lo+bpV5Fe9pB0Yk8A8CygxTXp+5qI7jInUsE1UMhtfot/dF2VYgVkqXXK IF6CTghflHUvqhEGS+lN6BT4Sti2yD6Ci175YSAwyI7N4mPHshTpMbpH+MF9Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753078635; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3mO631SF39AILQKZb9n0saDhXJwlN0BASHAyZv2XnyY=; b=ReWZF+jgPivW+1+c3ccJDYBeYX6XwJi4UmbyrvO3p8qm8j7syQEhV1hFfGq3iFRkizSYGS XRlXkuxYC6GlwWDtRf+L63CPhX/LCLc6YcQ3ZkCo6a9CrGT4DmoM/M960p/NtF8SsKap5r 3+iW9IKAENLlmiNkk8RUmlJMJjTRqoOT7ZytkCLdyFVsmvMqpQ8V16J81tDJr0KktK8oZD +sG9fLeQup1NGtOGRtZa0Ht/LqfiUXAQvXVJQIhm9QuTyxjGYiis9OteE/iSKbo0QH6k0c kNONGrSNmYF+ySRAQUjY7SFwA7Edvp/deAdXycy/74mDmotfnPYwqR7H/ummRA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1753078635; a=rsa-sha256; cv=none; b=Joqm2J7LdvzcIixJYRokF+4Qg5MwDBBjYA8qgItPt5LQsaychugqz9sY+sIITG0cLGm0fR D90YpZFcFFH1A9yfs5bOgvs7tUMoMAdrQhcY2liPRfC9Dsk0QurxIwf9zcOM5V5TdOVk3g na/AZ7cQkkp3Beb7OrkFTEjC56fkUhCghyKUyroCCEFPHtbTt4hy4R9fcAe43i0cwoQEuq MjQrM9sJOi6sPZZgN/cgn0ya6riD2r2/1s95G6RObtPldTJfsR1JUv87qEcJToQXBoSnXb cElfDmPl6jGGyuCDOpskXyr5KtDvsvxUS0eNmFzlaVCmI8+r/GI6etNMsHH0Tg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4blqtg2pFBzm5L; Mon, 21 Jul 2025 06:17:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 56L6HFB0071336; Mon, 21 Jul 2025 06:17:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56L6HFFL071333; Mon, 21 Jul 2025 06:17:15 GMT (envelope-from git) Date: Mon, 21 Jul 2025 06:17:15 GMT Message-Id: <202507210617.56L6HFFL071333@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: ShengYi Hung Subject: git: 776e26f56832 - main - libusb: implement libusb_dev_mem_{alloc,free} List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: aokblast X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 776e26f56832cb25dc70713acfb579bda6105024 Auto-Submitted: auto-generated The branch main has been updated by aokblast: URL: https://cgit.FreeBSD.org/src/commit/?id=776e26f56832cb25dc70713acfb579bda6105024 commit 776e26f56832cb25dc70713acfb579bda6105024 Author: ShengYi Hung AuthorDate: 2025-07-09 08:11:34 +0000 Commit: ShengYi Hung CommitDate: 2025-07-21 06:16:07 +0000 libusb: implement libusb_dev_mem_{alloc,free} libusb provides an API to create DMA buffers for USB packets from the kernel. However, this feature is only available on Linux. On unsupported platforms, the allocation function returns NULL, and the free function returns 'not supported'. Approved by: markj (mentor), lwhsu(mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D51222 --- lib/libusb/libusb.3 | 19 ++++++++++++++++++- lib/libusb/libusb.h | 3 +++ lib/libusb/libusb10.c | 13 +++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3 index 2e2ac8b1e98b..9dc752f0fd7b 100644 --- a/lib/libusb/libusb.3 +++ b/lib/libusb/libusb.3 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd June 13, 2025 +.Dd July 9, 2025 .Dt LIBUSB 3 .Os .Sh NAME @@ -366,6 +366,23 @@ argument is non-zero the feature is enabled. Else disabled. Returns 0 on success and a LIBUSB_ERROR code on failure. +.Pp +.Ft unsigned char * +.Fn libusb_dev_mem_alloc "libusb_device_handle *devh" +This function attempts to allocate a DMA memory block from the given +.Fa devh +so that we can enjoy the zero-copy transfer from kernel. +This function is provided for compatibility and is currently unimplemented and always returns NULL. +.Pp +.Ft int +.Fn libusb_dev_mem_free "libusb_device_handle *devh" "unsigned char *buffer" "size_t size" +This function frees the DMA memory in +.Fa devh +from the given +.Fa buffer +with +.Fa size . +This function is unimplemented and always returns LIBUSB_ERROR_NOT_SUPPORTED. .Sh USB DESCRIPTORS .Ft int .Fn libusb_get_device_descriptor "libusb_device *dev" "libusb_device_descriptor *desc" diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h index 520b81da3a75..57478c1787ee 100644 --- a/lib/libusb/libusb.h +++ b/lib/libusb/libusb.h @@ -513,6 +513,9 @@ int libusb_detach_kernel_driver(libusb_device_handle * devh, int interface); int libusb_attach_kernel_driver(libusb_device_handle * devh, int interface); int libusb_set_auto_detach_kernel_driver(libusb_device_handle *dev, int enable); int libusb_set_interface_alt_setting(libusb_device_handle * devh, int interface_number, int alternate_setting); +unsigned char *libusb_dev_mem_alloc(libusb_device_handle *devh); +int libusb_dev_mem_free(libusb_device_handle *devh, unsigned char *buffer, + size_t size); /* USB Descriptors */ diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c index 6f1ca877fc28..6bfc01eb8c4e 100644 --- a/lib/libusb/libusb10.c +++ b/lib/libusb/libusb10.c @@ -1904,3 +1904,16 @@ libusb_setlocale(const char *locale) return (LIBUSB_ERROR_INVALID_PARAM); } + +unsigned char * +libusb_dev_mem_alloc(libusb_device_handle *devh) +{ + return (NULL); +} + +int +libusb_dev_mem_free(libusb_device_handle *devh, unsigned char *buffer, + size_t size) +{ + return (LIBUSB_ERROR_NOT_SUPPORTED); +}