From fc35866e55aebe23982d924f71d4444137a3703c Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 4 Aug 2018 12:21:08 -0400 Subject: [PATCH] iprowifi4965: Rework interrupts glue code. Untested, but this now better matches how the FreeBSD code does it. Potentially fixes a bug where interrupts would be spuriously re-enabled after the driver had disabled them, which may fix a KDL humdinger reported to me via IRC. --- .../drivers/network/wlan/iprowifi4965/glue.c | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/add-ons/kernel/drivers/network/wlan/iprowifi4965/glue.c b/src/add-ons/kernel/drivers/network/wlan/iprowifi4965/glue.c index 1d0b7af6ed..6688418302 100644 --- a/src/add-ons/kernel/drivers/network/wlan/iprowifi4965/glue.c +++ b/src/add-ons/kernel/drivers/network/wlan/iprowifi4965/glue.c @@ -1,6 +1,6 @@ /* - * Copyright 2009, Colin Günther, coling@gmx.de. - * All Rights Reserved. Distributed under the terms of the MIT License. + * Copyright 2018, Colin Günther, coling@gmx.de. All rights reserved. + * Distributed under the terms of the MIT license. */ @@ -46,25 +46,24 @@ HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev) struct iwn_softc* sc = (struct iwn_softc*)device_get_softc(dev); uint32 r1, r2; + /* Disable interrupts. */ + IWN_WRITE(sc, IWN_INT_MASK, 0); + r1 = IWN_READ(sc, IWN_INT); + if (r1 == 0xffffffff || (r1 & 0xfffffff0) == 0xa5a5a5a0) { + return 0; /* Hardware gone! */ + } r2 = IWN_READ(sc, IWN_FH_INT); if (r1 == 0 && r2 == 0) { // not for us - IWN_WRITE(sc, IWN_INT_MASK, sc->int_mask); - return 0; - } - - if (r1 == 0xffffffff) { - // hardware gone + if (sc->sc_flags & IWN_FLAG_RUNNING) + IWN_WRITE(sc, IWN_INT_MASK, sc->int_mask); return 0; } atomic_set((int32*)&sc->sc_intr_status_1, r1); atomic_set((int32*)&sc->sc_intr_status_2, r2); - IWN_WRITE(sc, IWN_INT_MASK, 0); - // disable interrupts - return 1; }