diff options
author | Shaun Ruffell <sruffell@digium.com> | 2010-02-08 22:49:32 +0000 |
---|---|---|
committer | Shaun Ruffell <sruffell@digium.com> | 2010-02-08 22:49:32 +0000 |
commit | 42e275be0f7ce08a9fe2adf4815f7fd926a341bb (patch) | |
tree | 7aa554e74ca4bf83805d382073efc91967f27f6c /drivers/dahdi/voicebus | |
parent | 791a3df5afe66a8cbe15ebe030c2956fd2e00818 (diff) |
vpmadt032,wcte12xp: Use a timeout on the read/write commands and during load.
It is possible for poorly behaving hardware (and driver bugs) to lockup the
modprobe process by having it wait indefinitely for a command to complete that
never will. DAHDI-451.
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@8003 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/voicebus')
-rw-r--r-- | drivers/dahdi/voicebus/GpakCust.c | 15 | ||||
-rw-r--r-- | drivers/dahdi/voicebus/voicebus.c | 19 |
2 files changed, 13 insertions, 21 deletions
diff --git a/drivers/dahdi/voicebus/GpakCust.c b/drivers/dahdi/voicebus/GpakCust.c index 9491818..cce3308 100644 --- a/drivers/dahdi/voicebus/GpakCust.c +++ b/drivers/dahdi/voicebus/GpakCust.c @@ -133,9 +133,18 @@ static int vpmadt032_getreg_full_return(struct vpmadt032 *vpm, int pagechange, u16 addr, u16 *outbuf, struct vpmadt032_cmd *cmd) { unsigned long flags; - int ret = -EIO; + unsigned long ret; BUG_ON(!cmd); - wait_for_completion(&cmd->complete); + + /* We'll wait for 200ms */ + ret = wait_for_completion_timeout(&cmd->complete, HZ/5); + if (unlikely(!ret)) { + spin_lock_irqsave(&vpm->list_lock, flags); + list_add_tail(&cmd->node, &vpm->free_cmds); + spin_unlock_irqrestore(&vpm->list_lock, flags); + return -EIO; + } + if (cmd->desc & __VPM150M_FIN) { *outbuf = cmd->data; cmd->desc = 0; @@ -146,7 +155,7 @@ static int vpmadt032_getreg_full_return(struct vpmadt032 *vpm, int pagechange, spin_lock_irqsave(&vpm->list_lock, flags); list_add_tail(&cmd->node, &vpm->free_cmds); spin_unlock_irqrestore(&vpm->list_lock, flags); - return ret; + return 0; } /* Read one of the registers on the VPMADT032 */ diff --git a/drivers/dahdi/voicebus/voicebus.c b/drivers/dahdi/voicebus/voicebus.c index ffbe971..2646302 100644 --- a/drivers/dahdi/voicebus/voicebus.c +++ b/drivers/dahdi/voicebus/voicebus.c @@ -997,23 +997,6 @@ vb_clear_start_receive_bit(struct voicebus *vb) VBUNLOCK(vb); } -static unsigned long -vb_wait_for_completion_timeout(struct completion *x, unsigned long timeout) -{ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 11) - /* There is a race condition here. If x->done is reset to 0 - * before the call to wait_for_completion after this thread wakes. - */ - timeout = wait_event_timeout(x->wait, x->done, timeout); - if (timeout) - wait_for_completion(x); - - return timeout; -#else - return wait_for_completion_timeout(x, timeout); -#endif -} - /*! * \brief Stops the VoiceBus interface. * @@ -1036,7 +1019,7 @@ voicebus_stop(struct voicebus *vb) set_bit(STOP, &vb->flags); vb_clear_start_transmit_bit(vb); vb_clear_start_receive_bit(vb); - if (vb_wait_for_completion_timeout(&vb->stopped_completion, HZ)) { + if (wait_for_completion_timeout(&vb->stopped_completion, HZ)) { BUG_ON(!vb_is_stopped(vb)); } else { dev_warn(&vb->pdev->dev, "Timeout while waiting for board to " |