[RFC AR6000 patch] Set hardware unavailable during wext_ioctl when the suspend or rfkill is send
Michael Trimarchi
trimarchi at gandalf.sssup.it
Wed Mar 18 11:57:13 CET 2009
Hi,
Michael Trimarchi wrote:
> >From e477da42a62a7836a0c5e87008e2502572be5e2d Mon Sep 17 00:00:00 2001
> From: michael <michael at panicking.kicks-ass.org>
> Date: Wed, 18 Mar 2009 11:38:36 +0100
> Subject: [PATCH] The ioctl wext etc, seems to be broken because they don't take any lock
> during shutdown. If the user do an echo to the state variabile of the
> rfkill during the network scanning the system can go in panic. It
> introduces a reference count to the ar priv data and a hw_available
> variable and a new spin lock. If a process has a ioctl pending, the
> shutdown process set the hardware unvailable and wait for pending
> request.
>
> Signed-off-by: Michael Trimarchi <michael at panicking.kicks-ass.org>
> ---
> drivers/ar6000/ar6000/ar6000_drv.c | 24 ++-
> drivers/ar6000/ar6000/ar6000_drv.h | 18 ++
> drivers/ar6000/ar6000/wireless_ext.c | 492 ++++++++++++++++++++++++++--------
> 3 files changed, 413 insertions(+), 121 deletions(-)
>
> diff --git a/drivers/ar6000/ar6000/ar6000_drv.c b/drivers/ar6000/ar6000/ar6000_drv.c
> index 8165576..df3a399 100644
> --- a/drivers/ar6000/ar6000/ar6000_drv.c
> +++ b/drivers/ar6000/ar6000/ar6000_drv.c
> @@ -854,6 +854,9 @@ ar6000_avail_ev(HTC_HANDLE HTCHandle)
> }
>
> spin_lock_init(&ar->arLock);
> + spin_lock_init(&ar->arUsed);
> + atomic_set(&ar->refcnt, 0);
> + ar->hw_available = 1;
>
> /* Don't install the init function if BMI is requested */
> if(!bmienable)
> @@ -940,7 +943,18 @@ static void
> ar6000_unavail_ev(void *Instance)
> {
> AR_SOFTC_T *ar = (AR_SOFTC_T *)Instance;
> - /* NULL out it's entry in the global list */
> + /* NULL out it's entry in the global list */
> +retry:
> + spin_lock(&ar->arUsed);
> + ar->hw_available = 0;
> + BUG_ON(atomic_read(&ar->refcnt) < 0);
> + if (atomic_read(&ar->refcnt) > 0) {
> + cpu_relax();
> + spin_unlock(&ar->arUsed);
> + goto retry;
> + }
> + spin_unlock(&ar->arUsed);
> +
>
I must fix this one, the lock is not necessary. :(, I use and atomic
variable here.
This patch is an rfc one, and I write this morning, sorry if there is
some mistakes.
Michael
More information about the openmoko-kernel
mailing list