Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb emdtv(4): Fix issues in detach.
details: https://anonhg.NetBSD.org/src/rev/71ca0abcdb8d
branches: trunk
changeset: 364564:71ca0abcdb8d
user: riastradh <riastradh%NetBSD.org@localhost>
date: Tue Mar 29 09:08:44 2022 +0000
description:
emdtv(4): Fix issues in detach.
- Use config_detach_children, and do it up front, and handle failure
(not relevant for yanking usb but relevant for drvctl which doesn't
pass DETACH_FORCE).
- Fix teardown order: stop interrupts so we stop issuing new work,
and _then_ wait for pending work to drain and destroy the
workqueue.
- Omit needless empty mutex_enter(lock); mutex_exit(lock) dance
which probably only appeared necessary because of the wrong
teardown order.
diffstat:
sys/dev/usb/emdtv.c | 9 +++++++--
sys/dev/usb/emdtv_dtv.c | 10 +++-------
sys/dev/usb/emdtv_ir.c | 14 +++++---------
3 files changed, 15 insertions(+), 18 deletions(-)
diffs (109 lines):
diff -r beb79cb6862d -r 71ca0abcdb8d sys/dev/usb/emdtv.c
--- a/sys/dev/usb/emdtv.c Tue Mar 29 06:59:19 2022 +0000
+++ b/sys/dev/usb/emdtv.c Tue Mar 29 09:08:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emdtv.c,v 1.16 2022/03/12 18:31:39 riastradh Exp $ */
+/* $NetBSD: emdtv.c,v 1.17 2022/03/29 09:08:44 riastradh Exp $ */
/*-
* Copyright (c) 2008, 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emdtv.c,v 1.16 2022/03/12 18:31:39 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emdtv.c,v 1.17 2022/03/29 09:08:44 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -155,9 +155,14 @@
{
struct emdtv_softc *sc = device_private(self);
usbd_status status;
+ int error;
sc->sc_dying = true;
+ error = config_detach_children(self, flags);
+ if (error)
+ return error;
+
emdtv_ir_detach(sc, flags);
emdtv_dtv_detach(sc, flags);
diff -r beb79cb6862d -r 71ca0abcdb8d sys/dev/usb/emdtv_dtv.c
--- a/sys/dev/usb/emdtv_dtv.c Tue Mar 29 06:59:19 2022 +0000
+++ b/sys/dev/usb/emdtv_dtv.c Tue Mar 29 09:08:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emdtv_dtv.c,v 1.16 2021/08/07 16:19:16 thorpej Exp $ */
+/* $NetBSD: emdtv_dtv.c,v 1.17 2022/03/29 09:08:44 riastradh Exp $ */
/*-
* Copyright (c) 2008, 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emdtv_dtv.c,v 1.16 2021/08/07 16:19:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emdtv_dtv.c,v 1.17 2022/03/29 09:08:44 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -142,13 +142,9 @@
void
emdtv_dtv_detach(struct emdtv_softc *sc, int flags)
{
+
sc->sc_streaming = false;
- if (sc->sc_dtvdev != NULL) {
- config_detach(sc->sc_dtvdev, flags);
- sc->sc_dtvdev = NULL;
- }
-
if (sc->sc_xc3028)
xc3028_close(sc->sc_xc3028);
if (sc->sc_lg3303)
diff -r beb79cb6862d -r 71ca0abcdb8d sys/dev/usb/emdtv_ir.c
--- a/sys/dev/usb/emdtv_ir.c Tue Mar 29 06:59:19 2022 +0000
+++ b/sys/dev/usb/emdtv_ir.c Tue Mar 29 09:08:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: emdtv_ir.c,v 1.4 2021/08/07 16:19:16 thorpej Exp $ */
+/* $NetBSD: emdtv_ir.c,v 1.5 2022/03/29 09:08:44 riastradh Exp $ */
/*-
* Copyright (c) 2008 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emdtv_ir.c,v 1.4 2021/08/07 16:19:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emdtv_ir.c,v 1.5 2022/03/29 09:08:44 riastradh Exp $");
#include <sys/select.h>
#include <sys/param.h>
@@ -108,8 +108,6 @@
void
emdtv_ir_detach(struct emdtv_softc *sc, int flags)
{
- if (sc->sc_ir_wq != NULL)
- workqueue_destroy(sc->sc_ir_wq);
if (sc->sc_intr_pipe != NULL) {
usbd_abort_pipe(sc->sc_intr_pipe);
@@ -117,12 +115,10 @@
sc->sc_intr_pipe = NULL;
}
- mutex_enter(&sc->sc_ir_mutex);
- mutex_exit(&sc->sc_ir_mutex);
+ if (sc->sc_ir_wq != NULL)
+ workqueue_destroy(sc->sc_ir_wq);
+
mutex_destroy(&sc->sc_ir_mutex);
-
- if (sc->sc_cirdev != NULL)
- config_detach(sc->sc_cirdev, flags);
}
static void
Home |
Main Index |
Thread Index |
Old Index