From 49109f68fe2b58e0d700eeb9f1cb6c1f9521e6d4 Mon Sep 17 00:00:00 2001 From: kettenis Date: Thu, 22 Jul 2010 10:22:37 +0000 Subject: [PATCH] Prevent a process from entering wpi_ioctl while another process is tsleep'ing (for example waiting for the firmware to become alive) in iwn_init. ok damien@ --- sys/dev/pci/if_wpi.c | 12 +++++++++++- sys/dev/pci/if_wpivar.h | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c index 51aa491c83a..87f13e0e775 100644 --- a/sys/dev/pci/if_wpi.c +++ b/sys/dev/pci/if_wpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wpi.c,v 1.100 2010/04/20 22:05:43 tedu Exp $ */ +/* $OpenBSD: if_wpi.c,v 1.101 2010/07/22 10:22:37 kettenis Exp $ */ /*- * Copyright (c) 2006-2008 @@ -1963,6 +1963,15 @@ wpi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) int s, error = 0; s = splnet(); + /* + * Prevent processes from entering this function while another + * process is tsleep'ing in it. + */ + if (sc->sc_flags & WPI_FLAG_BUSY) { + splx(s); + return EBUSY; + } + sc->sc_flags |= WPI_FLAG_BUSY; switch (cmd) { case SIOCSIFADDR: @@ -2022,6 +2031,7 @@ wpi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } } + sc->sc_flags &= ~WPI_FLAG_BUSY; splx(s); return error; } diff --git a/sys/dev/pci/if_wpivar.h b/sys/dev/pci/if_wpivar.h index 960198346b5..300de136bca 100644 --- a/sys/dev/pci/if_wpivar.h +++ b/sys/dev/pci/if_wpivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wpivar.h,v 1.20 2009/11/17 20:35:53 damien Exp $ */ +/* $OpenBSD: if_wpivar.h,v 1.21 2010/07/22 10:22:37 kettenis Exp $ */ /*- * Copyright (c) 2006-2008 @@ -142,6 +142,7 @@ struct wpi_softc { u_int sc_flags; #define WPI_FLAG_HAS_5GHZ (1 << 0) +#define WPI_FLAG_BUSY (1 << 1) /* Shared area. */ struct wpi_dma_info shared_dma; -- 2.20.1