From d2e3ed5af6901fb0b0183c95ccdd174121ca0f4e Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Fri, 24 Jul 2015 04:56:46 +0000 Subject: [PATCH] Panic when a device is trying to recursively acquire rather than hang indefinitely. Improve error messages from other panics. --- sys/dev/gpio/gpiobus.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sys/dev/gpio/gpiobus.c b/sys/dev/gpio/gpiobus.c index 3d6a6cfe4bd..e741d288dbe 100644 --- a/sys/dev/gpio/gpiobus.c +++ b/sys/dev/gpio/gpiobus.c @@ -564,6 +564,10 @@ gpiobus_acquire_bus(device_t busdev, device_t child, int how) GPIOBUS_ASSERT_UNLOCKED(sc); GPIOBUS_LOCK(sc); if (sc->sc_owner != NULL) { + if (sc->sc_owner == child) + panic("%s: %s still owns the bus.", + device_get_nameunit(busdev), + device_get_nameunit(child)); if (how == GPIOBUS_DONTWAIT) { GPIOBUS_UNLOCK(sc); return (EWOULDBLOCK); @@ -586,9 +590,14 @@ gpiobus_release_bus(device_t busdev, device_t child) GPIOBUS_ASSERT_UNLOCKED(sc); GPIOBUS_LOCK(sc); if (sc->sc_owner == NULL) - panic("gpiobus: releasing unowned bus."); + panic("%s: %s releasing unowned bus.", + device_get_nameunit(busdev), + device_get_nameunit(child)); if (sc->sc_owner != child) - panic("gpiobus: you don't own the bus. game over."); + panic("%s: %s trying to release bus owned by %s", + device_get_nameunit(busdev), + device_get_nameunit(child), + device_get_nameunit(sc->sc_owner)); sc->sc_owner = NULL; wakeup(sc); GPIOBUS_UNLOCK(sc);