Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb usb(4): Sprinkle kernel lock assertions.
details: https://anonhg.NetBSD.org/src/rev/bc634243fd5d
branches: trunk
changeset: 1021643:bc634243fd5d
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Jun 12 12:13:10 2021 +0000
description:
usb(4): Sprinkle kernel lock assertions.
diffstat:
sys/dev/usb/uhub.c | 10 ++++++++--
sys/dev/usb/usb.c | 9 +++++++--
sys/dev/usb/usb_subr.c | 13 +++++++++++--
sys/dev/usb/xhci.c | 6 ++++--
4 files changed, 30 insertions(+), 8 deletions(-)
diffs (171 lines):
diff -r 63a0f9f5b175 -r bc634243fd5d sys/dev/usb/uhub.c
--- a/sys/dev/usb/uhub.c Sat Jun 12 12:12:11 2021 +0000
+++ b/sys/dev/usb/uhub.c Sat Jun 12 12:13:10 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uhub.c,v 1.148 2021/06/12 12:11:01 riastradh Exp $ */
+/* $NetBSD: uhub.c,v 1.149 2021/06/12 12:13:10 riastradh Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */
/* $OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.148 2021/06/12 12:11:01 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.149 2021/06/12 12:13:10 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -533,6 +533,8 @@
device_unit(sc->sc_dev), (uintptr_t)dev, dev->ud_addr,
dev->ud_speed);
+ KASSERT(KERNEL_LOCKED_P());
+
if (!sc->sc_running)
return USBD_NOT_STARTED;
@@ -930,6 +932,8 @@
struct usbd_device *dev;
int port;
+ KASSERT(KERNEL_LOCKED_P());
+
if (uhub_explore_enter(sc) != 0)
return EBUSY;
for (port = 1; port <= hub->uh_hubdesc.bNbrPorts; port++) {
@@ -953,6 +957,8 @@
int port;
int i;
+ KASSERT(KERNEL_LOCKED_P());
+
if (!devhub->ud_hub)
/* should never happen; children are only created after init */
panic("hub not fully initialised, but child deleted?");
diff -r 63a0f9f5b175 -r bc634243fd5d sys/dev/usb/usb.c
--- a/sys/dev/usb/usb.c Sat Jun 12 12:12:11 2021 +0000
+++ b/sys/dev/usb/usb.c Sat Jun 12 12:13:10 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usb.c,v 1.194 2021/06/12 12:11:38 riastradh Exp $ */
+/* $NetBSD: usb.c,v 1.195 2021/06/12 12:13:10 riastradh Exp $ */
/*
* Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.194 2021/06/12 12:11:38 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.195 2021/06/12 12:13:10 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -453,6 +453,8 @@
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
+ KASSERT(KERNEL_LOCKED_P());
+
/* Protected by KERNEL_LOCK */
nusbbusses++;
@@ -690,6 +692,8 @@
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
+ KASSERT(KERNEL_LOCKED_P());
+
/*
* In case this controller is a companion controller to an
* EHCI controller we need to wait until the EHCI controller
@@ -1146,6 +1150,7 @@
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
+ KASSERT(KERNEL_LOCKED_P());
KASSERT(mutex_owned(bus->ub_lock));
if (usb_noexplore > 1)
diff -r 63a0f9f5b175 -r bc634243fd5d sys/dev/usb/usb_subr.c
--- a/sys/dev/usb/usb_subr.c Sat Jun 12 12:12:11 2021 +0000
+++ b/sys/dev/usb/usb_subr.c Sat Jun 12 12:13:10 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usb_subr.c,v 1.252 2021/06/12 12:11:27 riastradh Exp $ */
+/* $NetBSD: usb_subr.c,v 1.253 2021/06/12 12:13:10 riastradh Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
/*
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.252 2021/06/12 12:11:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.253 2021/06/12 12:13:10 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -957,6 +957,9 @@
int i, j, loc;
device_t dv;
+ /* Needed for access to dev->ud_subdevs. */
+ KASSERT(KERNEL_LOCKED_P());
+
nifaces = dev->ud_cdesc->bNumInterface;
ifaces = kmem_zalloc(nifaces * sizeof(*ifaces), KM_SLEEP);
for (i = 0; i < nifaces; i++) {
@@ -1047,6 +1050,8 @@
int confi, nifaces;
usbd_status err;
+ KASSERT(KERNEL_LOCKED_P());
+
/* First try with device specific drivers. */
err = usbd_attachwholedevice(parent, dev, port, 0);
if (dev->ud_nifaces_claimed || err)
@@ -1111,6 +1116,8 @@
{
int i, loc;
+ KASSERT(KERNEL_LOCKED_P());
+
if (locators != NULL) {
loc = locators[USBIFIFCF_PORT];
if (loc != USBIFIFCF_PORT_DEFAULT && loc != port)
@@ -1169,6 +1176,8 @@
int i;
int p;
+ KASSERT(KERNEL_LOCKED_P());
+
if (bus->ub_methods->ubm_newdev != NULL)
return (bus->ub_methods->ubm_newdev)(parent, bus, depth, speed,
port, up);
diff -r 63a0f9f5b175 -r bc634243fd5d sys/dev/usb/xhci.c
--- a/sys/dev/usb/xhci.c Sat Jun 12 12:12:11 2021 +0000
+++ b/sys/dev/usb/xhci.c Sat Jun 12 12:13:10 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xhci.c,v 1.144 2021/06/06 18:37:20 jdolecek Exp $ */
+/* $NetBSD: xhci.c,v 1.145 2021/06/12 12:13:10 riastradh Exp $ */
/*
* Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.144 2021/06/06 18:37:20 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.145 2021/06/12 12:13:10 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -2778,6 +2778,8 @@
XHCIHIST_CALLARGS("port %ju depth %ju speed %ju up %#jx",
port, depth, speed, (uintptr_t)up);
+ KASSERT(KERNEL_LOCKED_P());
+
dev = kmem_zalloc(sizeof(*dev), KM_SLEEP);
dev->ud_bus = bus;
dev->ud_quirks = &usbd_no_quirk;
Home |
Main Index |
Thread Index |
Old Index