From nobody Wed Oct 12 15:54:21 2022 X-Original-To: dev-commits-src-all@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 4Mncf56wlMz4fdN8; Wed, 12 Oct 2022 15:54:21 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Mncf56NQWz3H9H; Wed, 12 Oct 2022 15:54:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665590061; 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=hfmmtc70wmSr/YV+XsphqDrFs5XZrRLsPnJAtCoxJmo=; b=PBSCSp1v5R+yiXxOI0LPcjxyw4GxzZhqQBPjtmCDxfj2sOg7O9gj5pTqFb7SBFHMzk920p 825Bl+VuGD1VPKpTv33KGAwq+4JSU441GL6ofvYEEMQA1gthzeq57mdacyJ0hEJNqY2sbw mTyiqG1SlWgqSHkdRaIdjVHg3YvCy93GE5zEg/52S7lJ3+/mDZZEpWWK9JTVs5f/t77APy TRgChL60zNk2hOF9SV04NWAqcRjF9zA6iIcSrFT0M/SOBjZ7dbWh0HmgyG21PZK0fSQinf OZEkvfTzbIH9AQAiRkZLPa15IeR6BIr5llhzMrOO9L4gzQV4RFdCX35/6zt/rw== 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 4Mncf55T05z1M7Z; Wed, 12 Oct 2022 15:54:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29CFsLgd043958; Wed, 12 Oct 2022 15:54:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29CFsL6t043957; Wed, 12 Oct 2022 15:54:21 GMT (envelope-from git) Date: Wed, 12 Oct 2022 15:54:21 GMT Message-Id: <202210121554.29CFsL6t043957@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: e4e79af3f957 - stable/13 - libusb(3): Implement libusb_interrupt_event_handler() by exposing existing function. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e4e79af3f9573cbc2db5a8e96f42236d9921662f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665590061; 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=hfmmtc70wmSr/YV+XsphqDrFs5XZrRLsPnJAtCoxJmo=; b=HSDn0K+ooi+4rAs0K3EqiHbyfWHWMxDO164thiEAUzQMzhGVZyaMwU/2wuWC0XytixTwXP UtPwPhmh2l1UjEHm9ziPadm1SFVIej+Np+UhvgNOnCpYw+6sA/8j65UvHVesxbDaj/KhtU 0TbeCltF3C5b3wsjzxDESj8oz5fQ+YYXpjwRHIm1Nby3YeFrTsa4xPdbKEtfaLLbk3KDEH maxetMI7UPtq03h+tR6yGgnH+YZ7dFdYvAT48hfSxRIBlkFXvqZ7muLxkqvE8SPkz1y7RN 59jm+c2248MHY2M/u9ZI92E67mTQGCXNKWxtR1Da9keBdfMSVEPs/MW522CR7A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665590061; a=rsa-sha256; cv=none; b=PgQDTOQcmnKhIEXLhDoaD+erVJkl9/FDD+J2BpoEv/3TXsftq8+g1UC82wHtJJDO7pt/hv PIXILUpE3BgiJGzh7K1USTsU6J41CjkmWU7vTG3cKl/ShgkJtvNIAsmdorEoTNoCjlIvdG A8fCBP7qYFJhy0HlQEI6p+cOD9P/pWfDpPaDcLkOGb2AkrWMTVyeYwuTBZyjUSyClVqI/0 8Q+sc8JomfLUl1pJYdTBEer++4aT8hVxOpQojat2Y6keCe2FCLCY29d8jbP/zD+5X2QlyQ VNXtEuBBIyfc25iNe7mj2IFTg4G10hnvUeAj+eJkk7uVC4egwziF6PEduvGEzw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=e4e79af3f9573cbc2db5a8e96f42236d9921662f commit e4e79af3f9573cbc2db5a8e96f42236d9921662f Author: Hans Petter Selasky AuthorDate: 2022-10-02 15:30:40 +0000 Commit: Hans Petter Selasky CommitDate: 2022-10-12 15:53:22 +0000 libusb(3): Implement libusb_interrupt_event_handler() by exposing existing function. Sponsored by: NVIDIA Networking (cherry picked from commit aa87aa52326be7b726664dba65e91ec3d8160f48) --- lib/libusb/Makefile | 1 + lib/libusb/libusb.3 | 13 ++++++++++--- lib/libusb/libusb.h | 1 + lib/libusb/libusb10.c | 22 +++++++++++++--------- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/lib/libusb/Makefile b/lib/libusb/Makefile index 83c9f1ade075..3982fda478fb 100644 --- a/lib/libusb/Makefile +++ b/lib/libusb/Makefile @@ -135,6 +135,7 @@ MLINKS += libusb.3 libusb_lock_events.3 MLINKS += libusb.3 libusb_unlock_events.3 MLINKS += libusb.3 libusb_event_handling_ok.3 MLINKS += libusb.3 libusb_event_handler_active.3 +MLINKS += libusb.3 libusb_interrupt_event_handler.3 MLINKS += libusb.3 libusb_lock_event_waiters.3 MLINKS += libusb.3 libusb_unlock_event_waiters.3 MLINKS += libusb.3 libusb_wait_for_event.3 diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3 index 0d0e2b1a4ef1..d4c638d986e4 100644 --- a/lib/libusb/libusb.3 +++ b/lib/libusb/libusb.3 @@ -1,8 +1,6 @@ .\" .\" Copyright (c) 2009 Sylvestre Gallon .\" -.\" All rights reserved. -.\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: @@ -26,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 9, 2020 +.Dd October, 2, 2022 .Dt LIBUSB 3 .Os .Sh NAME @@ -604,6 +602,15 @@ Returns 1 if there is a thread handling events and 0 if there are no threads currently handling events. .Pp .Ft void +.Fn libusb_interrupt_event_handler "libusb_context *ctx" +Causes the +.Fn libusb_handle_events +familiy of functions to return to the caller one time. +The +.Fn libusb_handle_events +functions may be called again after calling this function. +.Pp +.Ft void .Fn libusb_lock_event_waiters "libusb_context *ctx" Acquire the event_waiters lock. This lock is designed to be obtained in the diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h index 3d353402ea06..9eaee671b8b3 100644 --- a/lib/libusb/libusb.h +++ b/lib/libusb/libusb.h @@ -550,6 +550,7 @@ void libusb_lock_events(libusb_context * ctx); void libusb_unlock_events(libusb_context * ctx); int libusb_event_handling_ok(libusb_context * ctx); int libusb_event_handler_active(libusb_context * ctx); +void libusb_interrupt_event_handler(libusb_context *ctx); void libusb_lock_event_waiters(libusb_context * ctx); void libusb_unlock_event_waiters(libusb_context * ctx); int libusb_wait_for_event(libusb_context * ctx, struct timeval *tv); diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c index ecfffde555aa..1fc89fc409f0 100644 --- a/lib/libusb/libusb10.c +++ b/lib/libusb/libusb10.c @@ -116,12 +116,16 @@ libusb_set_nonblocking(int f) fcntl(f, F_SETFL, flags); } -static void -libusb10_wakeup_event_loop(libusb_context *ctx) +void +libusb_interrupt_event_handler(libusb_context *ctx) { - uint8_t dummy = 0; + uint8_t dummy; int err; + if (ctx == NULL) + return; + + dummy = 0; err = write(ctx->ctrl_pipe[1], &dummy, sizeof(dummy)); if (err < (int)sizeof(dummy)) { /* ignore error, if any */ @@ -545,7 +549,7 @@ libusb_open(libusb_device *dev, libusb_device_handle **devh) POLLOUT | POLLRDNORM | POLLWRNORM); /* make sure our event loop detects the new device */ - libusb10_wakeup_event_loop(ctx); + libusb_interrupt_event_handler(ctx); *devh = pdev; @@ -614,7 +618,7 @@ libusb_close(struct libusb20_device *pdev) libusb_unref_device(dev); /* make sure our event loop detects the closed device */ - libusb10_wakeup_event_loop(ctx); + libusb_interrupt_event_handler(ctx); } libusb_device * @@ -1443,7 +1447,7 @@ found: failure: libusb10_complete_transfer(pxfer0, sxfer, LIBUSB_TRANSFER_ERROR); /* make sure our event loop spins the done handler */ - libusb10_wakeup_event_loop(dev->ctx); + libusb_interrupt_event_handler(dev->ctx); } /* The following function must be called unlocked */ @@ -1555,7 +1559,7 @@ libusb_cancel_transfer(struct libusb_transfer *uxfer) libusb10_complete_transfer(NULL, sxfer, LIBUSB_TRANSFER_CANCELLED); /* make sure our event loop spins the done handler */ - libusb10_wakeup_event_loop(dev->ctx); + libusb_interrupt_event_handler(dev->ctx); } else if (pxfer0 == NULL || pxfer1 == NULL) { /* not started */ retval = LIBUSB_ERROR_NOT_FOUND; @@ -1566,7 +1570,7 @@ libusb_cancel_transfer(struct libusb_transfer *uxfer) /* clear transfer pointer */ libusb20_tr_set_priv_sc1(pxfer0, NULL); /* make sure our event loop spins the done handler */ - libusb10_wakeup_event_loop(dev->ctx); + libusb_interrupt_event_handler(dev->ctx); } else { libusb20_tr_stop(pxfer0); /* make sure the queue doesn't stall */ @@ -1580,7 +1584,7 @@ libusb_cancel_transfer(struct libusb_transfer *uxfer) /* clear transfer pointer */ libusb20_tr_set_priv_sc1(pxfer1, NULL); /* make sure our event loop spins the done handler */ - libusb10_wakeup_event_loop(dev->ctx); + libusb_interrupt_event_handler(dev->ctx); } else { libusb20_tr_stop(pxfer1); /* make sure the queue doesn't stall */