linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Arend van Spriel" <arend@broadcom.com>
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org,
	"Roland Vossen" <rvossen@broadcom.com>,
	"Arend van Spriel" <arend@broadcom.com>
Subject: [PATCH 02/22] brcm80211: smac: decreased timer callback irq level
Date: Wed, 12 Oct 2011 20:51:12 +0200	[thread overview]
Message-ID: <1318445492-24207-3-git-send-email-arend@broadcom.com> (raw)
In-Reply-To: <1318445492-24207-1-git-send-email-arend@broadcom.com>

From: Roland Vossen <rvossen@broadcom.com>

Timer functions were called at soft-irq level, leading to the limitation
that mutexes could not be used. Lifted this limitation by migrating to
work queues.

Reviewed-by: Alwin Beukers <alwin@broadcom.com>
Reviewed-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
---
 .../net/wireless/brcm80211/brcmsmac/mac80211_if.c  |   40 ++++++++-----------
 .../net/wireless/brcm80211/brcmsmac/mac80211_if.h  |   12 +++--
 2 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
index b665aaf..6ce773a 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
@@ -1409,18 +1409,22 @@ void brcms_down(struct brcms_info *wl)
 /*
 * precondition: perimeter lock is not acquired
  */
-void brcms_timer(struct brcms_timer *t)
+static void _brcms_timer(struct work_struct *work)
 {
+	struct brcms_timer *t = container_of(work, struct brcms_timer,
+					     dly_wrk.work);
+
 	spin_lock_bh(&t->wl->lock);
 
 	if (t->set) {
 		if (t->periodic) {
-			t->timer.expires = jiffies + t->ms * HZ / 1000;
 			atomic_inc(&t->wl->callbacks);
-			add_timer(&t->timer);
-			t->set = true;
-		} else
+			ieee80211_queue_delayed_work(t->wl->pub->ieee_hw,
+						     &t->dly_wrk,
+						     msecs_to_jiffies(t->ms));
+		} else {
 			t->set = false;
+		}
 
 		t->fn(t->arg);
 	}
@@ -1431,14 +1435,6 @@ void brcms_timer(struct brcms_timer *t)
 }
 
 /*
- * is called by the kernel from software irq context
- */
-static void _brcms_timer(unsigned long data)
-{
-	brcms_timer((struct brcms_timer *) data);
-}
-
-/*
  * Adds a timer to the list. Caller supplies a timer function.
  * Is called from wlc.
  *
@@ -1454,9 +1450,7 @@ struct brcms_timer *brcms_init_timer(struct brcms_info *wl,
 	if (!t)
 		return NULL;
 
-	init_timer(&t->timer);
-	t->timer.data = (unsigned long) t;
-	t->timer.function = _brcms_timer;
+	INIT_DELAYED_WORK(&t->dly_wrk, _brcms_timer);
 	t->wl = wl;
 	t->fn = fn;
 	t->arg = arg;
@@ -1478,22 +1472,22 @@ struct brcms_timer *brcms_init_timer(struct brcms_info *wl,
  *
  * precondition: perimeter lock has been acquired
  */
-void brcms_add_timer(struct brcms_timer *t, uint ms,
-		     int periodic)
+void brcms_add_timer(struct brcms_timer *t, uint ms, int periodic)
 {
+	struct ieee80211_hw *hw = t->wl->pub->ieee_hw;
+
 #ifdef BCMDBG
 	if (t->set)
-		wiphy_err(t->wl->wiphy, "%s: Already set. Name: %s, per %d\n",
+		wiphy_err(hw->wiphy, "%s: Already set. Name: %s, per %d\n",
 			  __func__, t->name, periodic);
-
 #endif
 	t->ms = ms;
 	t->periodic = (bool) periodic;
 	t->set = true;
-	t->timer.expires = jiffies + ms * HZ / 1000;
 
 	atomic_inc(&t->wl->callbacks);
-	add_timer(&t->timer);
+
+	ieee80211_queue_delayed_work(hw, &t->dly_wrk, msecs_to_jiffies(ms));
 }
 
 /*
@@ -1505,7 +1499,7 @@ bool brcms_del_timer(struct brcms_timer *t)
 {
 	if (t->set) {
 		t->set = false;
-		if (!del_timer(&t->timer))
+		if (!cancel_delayed_work(&t->dly_wrk))
 			return false;
 
 		atomic_dec(&t->wl->callbacks);
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h
index 91e5f2a..177f0e4 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h
+++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h
@@ -19,6 +19,8 @@
 
 #include <linux/timer.h>
 #include <linux/interrupt.h>
+#include <linux/workqueue.h>
+
 #include "ucode_loader.h"
 /*
  * Starting index for 5G rates in the
@@ -30,14 +32,14 @@
 #define BRCMS_SET_SHORTSLOT_OVERRIDE		146
 
 struct brcms_timer {
-	struct timer_list timer;
+	struct delayed_work dly_wrk;
 	struct brcms_info *wl;
-	void (*fn) (void *);
-	void *arg;		/* argument to fn */
+	void (*fn) (void *);	/* function called upon expiration */
+	void *arg;		/* fixed argument provided to called function */
 	uint ms;
 	bool periodic;
-	bool set;
-	struct brcms_timer *next;
+	bool set;		/* indicates if timer is active */
+	struct brcms_timer *next;	/* for freeing on unload */
 #ifdef BCMDBG
 	char *name;		/* Description of the timer */
 #endif
-- 
1.7.4.1



  parent reply	other threads:[~2011-10-12 18:51 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-12 18:51 [PATCH 00/22] brcm80211: mainline patch related cleanup Arend van Spriel
2011-10-12 18:51 ` [PATCH 01/22] brcm80211: smac: removed redundant timer function parameters Arend van Spriel
2011-10-12 18:51 ` Arend van Spriel [this message]
2011-10-12 18:51 ` [PATCH 03/22] brcm80211: cleanup function prototypes Arend van Spriel
2011-10-12 18:51 ` [PATCH 04/22] brcm80211: remove sparse warning in fullmac debug function Arend van Spriel
2011-10-12 18:51 ` [PATCH 05/22] brcm80211: fix sparse endianess error in mac80211_if.c Arend van Spriel
2011-10-12 18:51 ` [PATCH 06/22] brcm80211: add endian annotation to packet filter structures Arend van Spriel
2011-10-12 18:51 ` [PATCH 07/22] brcm80211: rename variable in _brcmf_set_multicast_list() Arend van Spriel
2011-10-12 18:51 ` [PATCH 08/22] brcm80211: fix annotations in TOE configuration functions Arend van Spriel
2011-10-12 18:51 ` [PATCH 09/22] brcm80211: use endian annotations in scan related function Arend van Spriel
2011-10-12 18:51 ` [PATCH 10/22] brcm80211: use endian annotation for pmk related structure Arend van Spriel
2011-10-12 18:51 ` [PATCH 11/22] brcm80211: use endian annotations for assoc ie length request Arend van Spriel
2011-10-12 18:51 ` [PATCH 12/22] brcm80211: use endian annotation for roaming related parameters Arend van Spriel
2011-10-12 18:51 ` [PATCH 13/22] brcm80211: use endian annotation for scan time configuration Arend van Spriel
2011-10-12 18:51 ` [PATCH 14/22] brcm80211: fmac: fixed weird indentation Arend van Spriel
2011-10-12 18:51 ` [PATCH 15/22] brcm80211: removed unused functions Arend van Spriel
2011-10-12 18:51 ` [PATCH 16/22] brcm80211: moved power conversion functions Arend van Spriel
2011-10-12 18:51 ` [PATCH 17/22] brcm80211: moved function brcmu_chipname Arend van Spriel
2011-10-12 18:51 ` [PATCH 18/22] brcm80211: moved function brcmu_parse_tlvs Arend van Spriel
2011-10-12 18:51 ` [PATCH 19/22] brcm80211: moved function brcmu_chspec_malformed Arend van Spriel
2011-10-12 18:51 ` [PATCH 20/22] brcm80211: moved function brcmu_mkiovar Arend van Spriel
2011-10-12 18:51 ` [PATCH 21/22] brcm80211: moved function brcmu_format_flags Arend van Spriel
2011-10-12 18:51 ` [PATCH 22/22] brcm80211: removed file wifi.c Arend van Spriel
2011-10-12 19:13   ` Johannes Berg
2011-10-12 19:20     ` Arend van Spriel
2011-10-12 19:28       ` Johannes Berg
2011-10-12 21:54   ` Luis R. Rodriguez
2011-10-13  8:51     ` Arend van Spriel
2011-10-13 18:08       ` Luis R. Rodriguez
2011-10-13 18:23         ` John W. Linville
2011-10-13 18:32           ` Arend van Spriel
2011-10-13 18:27         ` Arend van Spriel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1318445492-24207-3-git-send-email-arend@broadcom.com \
    --to=arend@broadcom.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=rvossen@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).