aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2003-07-27 18:25:32 (GMT)
committerJouni Malinen <j@w1.fi>2003-07-27 18:25:32 (GMT)
commit8a890bea6d4407704bc963ed6a846b059ba42774 (patch)
tree0f36f292d37888602cedc12678cac635dbad11d5
parentbfbe0abb4bacee733b5f8eb89ee706ff829de0db (diff)
downloadhostap-history-8a890bea6d4407704bc963ed6a846b059ba42774.zip
hostap-history-8a890bea6d4407704bc963ed6a846b059ba42774.tar.gz
hostap-history-8a890bea6d4407704bc963ed6a846b059ba42774.tar.bz2
Yield to other processes instead of busy waiting during card initialization
and buffer allocation.
-rw-r--r--driver/modules/hostap_hw.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/driver/modules/hostap_hw.c b/driver/modules/hostap_hw.c
index 1a72f6c..83db0d5 100644
--- a/driver/modules/hostap_hw.c
+++ b/driver/modules/hostap_hw.c
@@ -152,10 +152,13 @@ static unsigned char bridge_tunnel_header[] =
#define HFA384X_BAP_BUSY_TIMEOUT 50000
/* ca. 10 usec */
-#define HFA384X_INIT_TIMEOUT 50000
#define HFA384X_CMD_COMPL_TIMEOUT 20000
#define HFA384X_DL_COMPL_TIMEOUT 1000000
-#define HFA384X_ALLOC_COMPL_TIMEOUT 5000
+
+/* Wait times for initialization; yield to other processes to avoid busy
+ * waiting for long time. */
+#define HFA384X_INIT_TIMEOUT (HZ / 2) /* 500 ms */
+#define HFA384X_ALLOC_COMPL_TIMEOUT (HZ / 20) /* 50 ms */
static void prism2_hw_reset(struct net_device *dev);
@@ -780,8 +783,8 @@ static void hfa384x_events_only_cmd(struct net_device *dev)
static u16 hfa384x_allocate_fid(struct net_device *dev, int len)
{
- int tries;
u16 fid;
+ unsigned long delay;
/* FIX: this could be replace with hfa384x_cmd() if the Alloc event
* below would be handled like CmdCompl event (sleep here, wake up from
@@ -792,13 +795,11 @@ static u16 hfa384x_allocate_fid(struct net_device *dev, int len)
return 0xffff;
}
- tries = HFA384X_ALLOC_COMPL_TIMEOUT;
+ delay = jiffies + HFA384X_ALLOC_COMPL_TIMEOUT;
while (!(HFA384X_INW(HFA384X_EVSTAT_OFF) & HFA384X_EV_ALLOC) &&
- tries > 0) {
- tries--;
- udelay(10);
- }
- if (tries == 0) {
+ time_before(jiffies, delay))
+ yield();
+ if (!(HFA384X_INW(HFA384X_EVSTAT_OFF) & HFA384X_EV_ALLOC)) {
printk("%s: fid allocate, len=%d - timeout\n", dev->name, len);
return 0xffff;
}
@@ -1050,7 +1051,8 @@ static void prism2_clear_cmd_queue(local_info_t *local)
static int prism2_hw_init(struct net_device *dev, int initial)
{
local_info_t *local = (local_info_t *) dev->priv;
- int ret, i, first = 1;
+ int ret, first = 1;
+ unsigned long start, delay;
PDEBUG(DEBUG_FLOW, "prism2_hw_init()\n");
@@ -1064,12 +1066,8 @@ static int prism2_hw_init(struct net_device *dev, int initial)
dev_info);
return 1;
}
- i = HFA384X_INIT_TIMEOUT;
- while (!(HFA384X_INW(HFA384X_EVSTAT_OFF) & HFA384X_EV_CMD) && i > 0) {
- i--;
- udelay(10);
- }
- if (first && i == HFA384X_INIT_TIMEOUT) {
+
+ if (first && (HFA384X_INW(HFA384X_EVSTAT_OFF) & HFA384X_EV_CMD)) {
/* EvStat has Cmd bit set in some cases, so retry once if no
* wait was needed */
HFA384X_OUTW(HFA384X_EV_CMD, HFA384X_EVACK_OFF);
@@ -1078,12 +1076,18 @@ static int prism2_hw_init(struct net_device *dev, int initial)
first = 0;
goto init;
}
- if (i == 0) {
+
+ start = jiffies;
+ delay = jiffies + HFA384X_INIT_TIMEOUT;
+ while (!(HFA384X_INW(HFA384X_EVSTAT_OFF) & HFA384X_EV_CMD) &&
+ time_before(jiffies, delay))
+ yield();
+ if (!(HFA384X_INW(HFA384X_EVSTAT_OFF) & HFA384X_EV_CMD)) {
printk("%s: card initialization timed out\n", dev_info);
return 1;
}
- printk(KERN_DEBUG "prism2_hw_init: initialized in %d iterations\n",
- HFA384X_INIT_TIMEOUT - i);
+ printk(KERN_DEBUG "prism2_hw_init: initialized in %lu ms\n",
+ (jiffies - start) * 1000 / HZ);
HFA384X_OUTW(HFA384X_EV_CMD, HFA384X_EVACK_OFF);
return 0;
}