usbnet: Print diagnostic about refcnt stragglers.

I don't think there can be any, but this message, if printed, would
falsify my hypothesis!
This commit is contained in:
riastradh 2022-03-03 05:50:31 +00:00
parent 2cb1302a9a
commit ad98cb4e29
1 changed files with 6 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: usbnet.c,v 1.71 2022/03/03 05:50:22 riastradh Exp $ */
/* $NetBSD: usbnet.c,v 1.72 2022/03/03 05:50:31 riastradh Exp $ */
/*
* Copyright (c) 2019 Matthew R. Green
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.71 2022/03/03 05:50:22 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.72 2022/03/03 05:50:31 riastradh Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -1671,6 +1671,10 @@ usbnet_detach(device_t self, int flags)
mutex_enter(&unp->unp_core_lock);
unp->unp_refcnt--;
if (unp->unp_refcnt >= 0) {
aprint_error_dev(un->un_dev, "%d stragglers\n",
unp->unp_refcnt + 1);
}
while (unp->unp_refcnt >= 0) {
/* Wait for processes to go away */
cv_wait(&unp->unp_detachcv, &unp->unp_core_lock);