Author: colin Date: 2009-12-29 23:00:28 +0100 (Tue, 29 Dec 2009) New Revision: 34812 Changeset: http://dev.haiku-os.org/changeset/34812/haiku Modified: haiku/trunk/src/add-ons/kernel/drivers/network/wlan/broadcom43xx/dev/bwi/if_bwi.c haiku/trunk/src/add-ons/kernel/drivers/network/wlan/broadcom43xx/dev/bwi/if_bwivar.h haiku/trunk/src/add-ons/kernel/drivers/network/wlan/broadcom43xx/glue.c Log: * Reworked interrupt handlink so that the interrupt status is read only once per interrupt. Moreover the interrupt is disabled only once now too. * Using atomic_{set|get} operations for synchronizing the interrupt status as proposed by Axel. * Coding style cleanup. Modified: haiku/trunk/src/add-ons/kernel/drivers/network/wlan/broadcom43xx/dev/bwi/if_bwi.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/wlan/broadcom43xx/dev/bwi/if_bwi.c 2009-12-29 18:24:35 UTC (rev 34811) +++ haiku/trunk/src/add-ons/kernel/drivers/network/wlan/broadcom43xx/dev/bwi/if_bwi.c 2009-12-29 22:00:28 UTC (rev 34812) @@ -1,13 +1,13 @@ /* * Copyright (c) 2007 The DragonFly Project. All rights reserved. - * + * * This code is derived from software contributed to The DragonFly Project * by Sepherosa Ziehau <sepherosa@xxxxxxxxx> - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright @@ -17,7 +17,7 @@ * 3. Neither the name of The DragonFly Project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific, prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -30,7 +30,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * $DragonFly: src/sys/dev/netif/bwi/if_bwi.c,v 1.19 2008/02/15 11:15:38 sephe Exp $ */ @@ -52,7 +52,7 @@ #include <sys/sysctl.h> #include <sys/systm.h> #include <sys/taskqueue.h> - + #include <net/if.h> #include <net/if_dl.h> #include <net/if_media.h> @@ -70,7 +70,7 @@ #include <net/bpf.h> #ifdef INET -#include <netinet/in.h> +#include <netinet/in.h> #include <netinet/if_ether.h> #endif @@ -1567,6 +1567,7 @@ BWI_LOCK(sc); +#if !defined(__HAIKU__) if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || (sc->sc_flags & BWI_F_STOP)) { BWI_UNLOCK(sc); @@ -1580,6 +1581,9 @@ BWI_UNLOCK(sc); return; } +#else + intr_status = atomic_get((int32 *)&sc->sc_intr_status); +#endif DPRINTF(sc, BWI_DBG_INTR, "intr status 0x%08x\n", intr_status); @@ -1626,8 +1630,10 @@ for (i = 0; i < BWI_TXRX_NRING; ++i) CSR_WRITE_4(sc, BWI_TXRX_INTR_STATUS(i), txrx_intr_status[i]); +#if !defined(__HAIKU__) /* Disable all interrupts */ bwi_disable_intrs(sc, BWI_ALL_INTRS); +#endif /* * http://bcm-specs.sipsolutions.net/Interrupts @@ -1802,7 +1808,7 @@ * the same AP, this will reinialize things * correctly... */ - if (ic->ic_opmode == IEEE80211_M_STA && + if (ic->ic_opmode == IEEE80211_M_STA && !(sc->sc_flags & BWI_F_STOP)) bwi_set_bssid(sc, bwi_zero_addr); } Modified: haiku/trunk/src/add-ons/kernel/drivers/network/wlan/broadcom43xx/dev/bwi/if_bwivar.h =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/wlan/broadcom43xx/dev/bwi/if_bwivar.h 2009-12-29 18:24:35 UTC (rev 34811) +++ haiku/trunk/src/add-ons/kernel/drivers/network/wlan/broadcom43xx/dev/bwi/if_bwivar.h 2009-12-29 22:00:28 UTC (rev 34812) @@ -1,13 +1,13 @@ /* * Copyright (c) 2007 The DragonFly Project. All rights reserved. - * + * * This code is derived from software contributed to The DragonFly Project * by Sepherosa Ziehau <sepherosa@xxxxxxxxx> - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright @@ -17,7 +17,7 @@ * 3. Neither the name of The DragonFly Project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific, prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -30,7 +30,7 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * $DragonFly: src/sys/dev/netif/bwi/if_bwivar.h,v 1.14 2008/02/15 11:15:38 sephe Exp $ * $FreeBSD$ */ @@ -648,6 +648,10 @@ int sc_led_blink; int sc_txpwr_calib; uint32_t sc_debug; /* BWI_DBG_ */ + +#if defined(__HAIKU__) + uint32_t sc_intr_status; +#endif }; #define BWI_F_BUS_INITED 0x1 Modified: haiku/trunk/src/add-ons/kernel/drivers/network/wlan/broadcom43xx/glue.c =================================================================== --- haiku/trunk/src/add-ons/kernel/drivers/network/wlan/broadcom43xx/glue.c 2009-12-29 18:24:35 UTC (rev 34811) +++ haiku/trunk/src/add-ons/kernel/drivers/network/wlan/broadcom43xx/glue.c 2009-12-29 22:00:28 UTC (rev 34812) @@ -21,6 +21,7 @@ HAIKU_FBSD_WLAN_DRIVER_GLUE(broadcom43xx, bwi, pci) NO_HAIKU_FBSD_MII_DRIVER(); +NO_HAIKU_REENABLE_INTERRUPTS(); HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_WLAN); HAIKU_FIRMWARE_VERSION(0); @@ -28,29 +29,22 @@ HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev) { struct bwi_softc* sc = (struct bwi_softc*)device_get_softc(dev); - HAIKU_INTR_REGISTER_STATE; - - HAIKU_INTR_REGISTER_ENTER(); - if (CSR_READ_4(sc, BWI_MAC_INTR_STATUS) == 0xffffffff) { - /* Not for us */ - HAIKU_INTR_REGISTER_LEAVE(); + struct ifnet* ifp = sc->sc_ifp; + uint32 intr_status; + + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 + || (sc->sc_flags & BWI_F_STOP)) return 0; - } - /* Disable all interrupts */ + intr_status = CSR_READ_4(sc, BWI_MAC_INTR_STATUS); + if (intr_status == 0xffffffff) + // Not for us + return 0; + + atomic_set((int32*)&sc->sc_intr_status, intr_status); + CSR_CLRBITS_4(sc, BWI_MAC_INTR_MASK, BWI_ALL_INTRS); - - HAIKU_INTR_REGISTER_LEAVE(); + // Disable all interrupts return 1; } - - -void -HAIKU_REENABLE_INTERRUPTS(device_t dev) -{ - struct bwi_softc* sc = (struct bwi_softc*)device_get_softc(dev); - - /* enable interrupts */ - CSR_SETBITS_4(sc, BWI_MAC_INTR_MASK, BWI_INIT_INTRS); -}