* 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.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34812 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Colin Günther
2009-12-29 22:00:28 +00:00
parent 168aaf2f9d
commit b69688c36e
3 changed files with 38 additions and 34 deletions
@@ -1567,6 +1567,7 @@ bwi_intr(void *xsc)
BWI_LOCK(sc); BWI_LOCK(sc);
#if !defined(__HAIKU__)
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 ||
(sc->sc_flags & BWI_F_STOP)) { (sc->sc_flags & BWI_F_STOP)) {
BWI_UNLOCK(sc); BWI_UNLOCK(sc);
@@ -1580,6 +1581,9 @@ bwi_intr(void *xsc)
BWI_UNLOCK(sc); BWI_UNLOCK(sc);
return; return;
} }
#else
intr_status = atomic_get((int32 *)&sc->sc_intr_status);
#endif
DPRINTF(sc, BWI_DBG_INTR, "intr status 0x%08x\n", intr_status); DPRINTF(sc, BWI_DBG_INTR, "intr status 0x%08x\n", intr_status);
@@ -1626,8 +1630,10 @@ bwi_intr(void *xsc)
for (i = 0; i < BWI_TXRX_NRING; ++i) for (i = 0; i < BWI_TXRX_NRING; ++i)
CSR_WRITE_4(sc, BWI_TXRX_INTR_STATUS(i), txrx_intr_status[i]); CSR_WRITE_4(sc, BWI_TXRX_INTR_STATUS(i), txrx_intr_status[i]);
#if !defined(__HAIKU__)
/* Disable all interrupts */ /* Disable all interrupts */
bwi_disable_intrs(sc, BWI_ALL_INTRS); bwi_disable_intrs(sc, BWI_ALL_INTRS);
#endif
/* /*
* http://bcm-specs.sipsolutions.net/Interrupts * http://bcm-specs.sipsolutions.net/Interrupts
@@ -648,6 +648,10 @@ struct bwi_softc {
int sc_led_blink; int sc_led_blink;
int sc_txpwr_calib; int sc_txpwr_calib;
uint32_t sc_debug; /* BWI_DBG_ */ uint32_t sc_debug; /* BWI_DBG_ */
#if defined(__HAIKU__)
uint32_t sc_intr_status;
#endif
}; };
#define BWI_F_BUS_INITED 0x1 #define BWI_F_BUS_INITED 0x1
@@ -21,6 +21,7 @@
HAIKU_FBSD_WLAN_DRIVER_GLUE(broadcom43xx, bwi, pci) HAIKU_FBSD_WLAN_DRIVER_GLUE(broadcom43xx, bwi, pci)
NO_HAIKU_FBSD_MII_DRIVER(); NO_HAIKU_FBSD_MII_DRIVER();
NO_HAIKU_REENABLE_INTERRUPTS();
HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_WLAN); HAIKU_DRIVER_REQUIREMENTS(FBSD_TASKQUEUES | FBSD_WLAN);
HAIKU_FIRMWARE_VERSION(0); HAIKU_FIRMWARE_VERSION(0);
@@ -28,29 +29,22 @@ int
HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev) HAIKU_CHECK_DISABLE_INTERRUPTS(device_t dev)
{ {
struct bwi_softc* sc = (struct bwi_softc*)device_get_softc(dev); struct bwi_softc* sc = (struct bwi_softc*)device_get_softc(dev);
HAIKU_INTR_REGISTER_STATE; struct ifnet* ifp = sc->sc_ifp;
uint32 intr_status;
HAIKU_INTR_REGISTER_ENTER(); if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0
if (CSR_READ_4(sc, BWI_MAC_INTR_STATUS) == 0xffffffff) { || (sc->sc_flags & BWI_F_STOP))
/* Not for us */
HAIKU_INTR_REGISTER_LEAVE();
return 0; 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); CSR_CLRBITS_4(sc, BWI_MAC_INTR_MASK, BWI_ALL_INTRS);
// Disable all interrupts
HAIKU_INTR_REGISTER_LEAVE();
return 1; 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);
}