Skip to content

Commit

Permalink
net: wireless: bcmdhd: Make responce waiting uninterruptible
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
  • Loading branch information
Dmitry Shmidt authored and Kali- committed Jun 1, 2012
1 parent 99e315b commit 83a4438
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
34 changes: 9 additions & 25 deletions drivers/net/wireless/bcmdhd/dhd_linux.c
Expand Up @@ -671,16 +671,12 @@ dhd_timeout_expired(dhd_timeout_t *tmo)
} else {
wait_queue_head_t delay_wait;
DECLARE_WAITQUEUE(wait, current);
int pending;
init_waitqueue_head(&delay_wait);
add_wait_queue(&delay_wait, &wait);
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(1);
pending = signal_pending(current);
remove_wait_queue(&delay_wait, &wait);
set_current_state(TASK_RUNNING);
if (pending)
return 1; /* Interrupted */
}

return 0;
Expand Down Expand Up @@ -3912,7 +3908,6 @@ int
dhd_os_ioctl_resp_wait(dhd_pub_t *pub, uint *condition, bool *pending)
{
dhd_info_t * dhd = (dhd_info_t *)(pub->info);
DECLARE_WAITQUEUE(wait, current);
int timeout = dhd_ioctl_timeout_msec;

/* Convert timeout in millsecond to jiffies */
Expand All @@ -3922,23 +3917,7 @@ dhd_os_ioctl_resp_wait(dhd_pub_t *pub, uint *condition, bool *pending)
timeout = timeout * HZ / 1000;
#endif

/* Wait until control frame is available */
add_wait_queue(&dhd->ioctl_resp_wait, &wait);
set_current_state(TASK_INTERRUPTIBLE);

/* Memory barrier to support multi-processing
* As the variable "condition", which points to dhd->rxlen (dhd_bus_rxctl[dhd_sdio.c])
* Can be changed by another processor.
*/
smp_mb();
while (!(*condition) && timeout) {
timeout = schedule_timeout(timeout);
smp_mb();
}

set_current_state(TASK_RUNNING);
remove_wait_queue(&dhd->ioctl_resp_wait, &wait);

timeout = wait_event_timeout(dhd->ioctl_resp_wait, (*condition), timeout);
return timeout;
}

Expand All @@ -3948,7 +3927,7 @@ dhd_os_ioctl_resp_wake(dhd_pub_t *pub)
dhd_info_t *dhd = (dhd_info_t *)(pub->info);

if (waitqueue_active(&dhd->ioctl_resp_wait)) {
wake_up_interruptible(&dhd->ioctl_resp_wait);
wake_up(&dhd->ioctl_resp_wait);
}

return 0;
Expand Down Expand Up @@ -4297,8 +4276,13 @@ void dhd_wait_for_event(dhd_pub_t *dhd, bool *lockvar)
{
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
struct dhd_info *dhdinfo = dhd->info;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
int timeout = msecs_to_jiffies(2000);
#else
int timeout = 2 * HZ;
#endif
dhd_os_sdunlock(dhd);
wait_event_interruptible_timeout(dhdinfo->ctrl_wait, (*lockvar == FALSE), HZ * 2);
wait_event_timeout(dhdinfo->ctrl_wait, (*lockvar == FALSE), timeout);
dhd_os_sdlock(dhd);
#endif
return;
Expand All @@ -4309,7 +4293,7 @@ void dhd_wait_event_wakeup(dhd_pub_t *dhd)
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
struct dhd_info *dhdinfo = dhd->info;
if (waitqueue_active(&dhdinfo->ctrl_wait))
wake_up_interruptible(&dhdinfo->ctrl_wait);
wake_up(&dhdinfo->ctrl_wait);
#endif
return;
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/wireless/bcmdhd/dhd_sdio.c
Expand Up @@ -3124,9 +3124,9 @@ dhd_bus_init(dhd_pub_t *dhdp, bool enforce_mutex)
dhd_timeout_start(&tmo, DHD_WAIT_F2RDY * 1000);

ready = 0;
while (ready != enable && !dhd_timeout_expired(&tmo))
ready = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_IORDY, NULL);

do {
ready = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_IORDY, NULL);
} while (ready != enable && !dhd_timeout_expired(&tmo));

DHD_INFO(("%s: enable 0x%02x, ready 0x%02x (waited %uus)\n",
__FUNCTION__, enable, ready, tmo.elapsed));
Expand Down

0 comments on commit 83a4438

Please sign in to comment.