From 05787332bc8ef339be2fe15700ae52b48d4a382d Mon Sep 17 00:00:00 2001 From: kevlo Date: Fri, 20 Aug 2021 01:40:51 +0000 Subject: [PATCH] When plugging and unplugging an adapter continuously, it waits for a timeout over and over again. The problem is that the device has been unplugged, but the attach handler still issues USB requests via ure_ctl(). The easiest solution is to deactivate the device proactively in ure_ctl() when we see that error there. From Christian Ludwig --- sys/dev/usb/if_ure.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/dev/usb/if_ure.c b/sys/dev/usb/if_ure.c index ef2bc75a7c0..75d7cbaf215 100644 --- a/sys/dev/usb/if_ure.c +++ b/sys/dev/usb/if_ure.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ure.c,v 1.26 2021/08/13 01:24:22 gnezdo Exp $ */ +/* $OpenBSD: if_ure.c,v 1.27 2021/08/20 01:40:51 kevlo Exp $ */ /*- * Copyright (c) 2015, 2016, 2019 Kevin Lo * Copyright (c) 2020 Jonathon Fletcher @@ -223,7 +223,7 @@ ure_ctl(struct ure_softc *sc, uint8_t rw, uint16_t val, uint16_t index, usbd_status err; if (usbd_is_dying(sc->ure_udev)) - return 0; + return -1; if (rw == URE_CTL_WRITE) req.bmRequestType = UT_WRITE_VENDOR_DEVICE; @@ -239,6 +239,8 @@ ure_ctl(struct ure_softc *sc, uint8_t rw, uint16_t val, uint16_t index, err = usbd_do_request(sc->ure_udev, &req, buf); if (err) { DPRINTF(("ure_ctl: error %d\n", err)); + if (err == USBD_CANCELLED || err == USBD_TIMEOUT) + usbd_deactivate(sc->ure_udev); return -1; } -- 2.20.1