diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2010-08-12 15:04:01 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2010-08-12 15:04:01 +0000 |
commit | 40ad5e5f1bda27bfeb7bfdad8f6678d2a3dac781 (patch) | |
tree | 7ec7e7372217fa6522f526fee7d6f3d957525274 /sys/dev/pci/if_iwi.c | |
parent | efcc9540fb5c0cb70f9a83b72d2a388401581f71 (diff) |
Instead of returning EBUSY when the busy flag is set in the ioctl, sleep
until whoever has it is done with it.
This is kept as flag/sleep condvars instead of a rwlock because later we
may want to quiesce the handler before suspend to make sure nothing is
sleeping on a chip that is about to be whacked (doing so will change the
proc so rwlocks won't work).
ok damien@
Diffstat (limited to 'sys/dev/pci/if_iwi.c')
-rw-r--r-- | sys/dev/pci/if_iwi.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/dev/pci/if_iwi.c b/sys/dev/pci/if_iwi.c index febc0c50180..c6b770452e9 100644 --- a/sys/dev/pci/if_iwi.c +++ b/sys/dev/pci/if_iwi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwi.c,v 1.105 2010/08/03 18:26:25 kettenis Exp $ */ +/* $OpenBSD: if_iwi.c,v 1.106 2010/08/12 15:03:59 oga Exp $ */ /*- * Copyright (c) 2004-2008 @@ -381,12 +381,15 @@ iwi_power(int why, void *arg) pci_conf_write(sc->sc_pct, sc->sc_pcitag, 0x40, data); s = splnet(); + while (sc->sc_flags & IWI_FLAG_BUSY) + tsleep(&sc->sc_flags, 0, "iwipwr", 0); sc->sc_flags |= IWI_FLAG_BUSY; if (ifp->if_flags & IFF_UP) iwi_init(ifp); sc->sc_flags &= ~IWI_FLAG_BUSY; + wakeup(&sc->sc_flags); splx(s); } @@ -1486,9 +1489,11 @@ iwi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) * Prevent processes from entering this function while another * process is tsleep'ing in it. */ - if (sc->sc_flags & IWI_FLAG_BUSY) { + while (sc->sc_flags & IWI_FLAG_BUSY && error == 0) + error = tsleep(&sc->sc_flags, PCATCH, "iwiioc", 0); + if (error) { splx(s); - return EBUSY; + return error; } sc->sc_flags |= IWI_FLAG_BUSY; @@ -1545,6 +1550,7 @@ iwi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } sc->sc_flags &= ~IWI_FLAG_BUSY; + wakeup(&sc->sc_flags); splx(s); return error; } |