Commit a5e6ced5 authored by David Vrabel's avatar David Vrabel

wusb: timeout when waiting for ASL/PZL updates in whci-hcd

Timeout if an ASL or PZL update doesn't not complete and reset the
hardware.
Signed-off-by: default avatarDavid Vrabel <david.vrabel@csr.com>
parent a23e66f3
...@@ -170,12 +170,17 @@ void asl_stop(struct whc *whc) ...@@ -170,12 +170,17 @@ void asl_stop(struct whc *whc)
void asl_update(struct whc *whc, uint32_t wusbcmd) void asl_update(struct whc *whc, uint32_t wusbcmd)
{ {
struct wusbhc *wusbhc = &whc->wusbhc; struct wusbhc *wusbhc = &whc->wusbhc;
long t;
mutex_lock(&wusbhc->mutex); mutex_lock(&wusbhc->mutex);
if (wusbhc->active) { if (wusbhc->active) {
whc_write_wusbcmd(whc, wusbcmd, wusbcmd); whc_write_wusbcmd(whc, wusbcmd, wusbcmd);
wait_event(whc->async_list_wq, t = wait_event_timeout(
(le_readl(whc->base + WUSBCMD) & WUSBCMD_ASYNC_UPDATED) == 0); whc->async_list_wq,
(le_readl(whc->base + WUSBCMD) & WUSBCMD_ASYNC_UPDATED) == 0,
msecs_to_jiffies(1000));
if (t == 0)
whc_hw_error(whc, "ASL update timeout");
} }
mutex_unlock(&wusbhc->mutex); mutex_unlock(&wusbhc->mutex);
} }
......
...@@ -87,3 +87,18 @@ out: ...@@ -87,3 +87,18 @@ out:
return ret; return ret;
} }
/**
* whc_hw_error - recover from a hardware error
* @whc: the WHCI HC that broke.
* @reason: a description of the failure.
*
* Recover from broken hardware with a full reset.
*/
void whc_hw_error(struct whc *whc, const char *reason)
{
struct wusbhc *wusbhc = &whc->wusbhc;
dev_err(&whc->umc->dev, "hardware error: %s\n", reason);
wusbhc_reset_all(wusbhc);
}
...@@ -183,12 +183,17 @@ void pzl_stop(struct whc *whc) ...@@ -183,12 +183,17 @@ void pzl_stop(struct whc *whc)
void pzl_update(struct whc *whc, uint32_t wusbcmd) void pzl_update(struct whc *whc, uint32_t wusbcmd)
{ {
struct wusbhc *wusbhc = &whc->wusbhc; struct wusbhc *wusbhc = &whc->wusbhc;
long t;
mutex_lock(&wusbhc->mutex); mutex_lock(&wusbhc->mutex);
if (wusbhc->active) { if (wusbhc->active) {
whc_write_wusbcmd(whc, wusbcmd, wusbcmd); whc_write_wusbcmd(whc, wusbcmd, wusbcmd);
wait_event(whc->periodic_list_wq, t = wait_event_timeout(
(le_readl(whc->base + WUSBCMD) & WUSBCMD_PERIODIC_UPDATED) == 0); whc->periodic_list_wq,
(le_readl(whc->base + WUSBCMD) & WUSBCMD_PERIODIC_UPDATED) == 0,
msecs_to_jiffies(1000));
if (t == 0)
whc_hw_error(whc, "PZL update timeout");
} }
mutex_unlock(&wusbhc->mutex); mutex_unlock(&wusbhc->mutex);
} }
......
...@@ -137,6 +137,7 @@ void whc_clean_up(struct whc *whc); ...@@ -137,6 +137,7 @@ void whc_clean_up(struct whc *whc);
/* hw.c */ /* hw.c */
void whc_write_wusbcmd(struct whc *whc, u32 mask, u32 val); void whc_write_wusbcmd(struct whc *whc, u32 mask, u32 val);
int whc_do_gencmd(struct whc *whc, u32 cmd, u32 params, void *addr, size_t len); int whc_do_gencmd(struct whc *whc, u32 cmd, u32 params, void *addr, size_t len);
void whc_hw_error(struct whc *whc, const char *reason);
/* wusb.c */ /* wusb.c */
int whc_wusbhc_start(struct wusbhc *wusbhc); int whc_wusbhc_start(struct wusbhc *wusbhc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment