diff options
author | Tilman Schmidt <tilman@imap.cc> | 2009-10-06 08:18:51 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-10-07 01:21:05 -0400 |
commit | b5f581d55f7fef8d18773386faaa4304dbc2454b (patch) | |
tree | 9f15f00ffe41bb2fd837673fd5ca2e0869923830 /drivers/isdn | |
parent | 05eae94f2a2b6a05f10495c77162d0fecae67264 (diff) |
gigaset: improve error recovery
When the Gigaset base stops responding, try resetting the USB
connection to recover.
Impact: error handling improvement
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn')
-rw-r--r-- | drivers/isdn/gigaset/bas-gigaset.c | 69 |
1 files changed, 45 insertions, 24 deletions
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c index 9e7108a3109b..5ed1d99eb9f3 100644 --- a/drivers/isdn/gigaset/bas-gigaset.c +++ b/drivers/isdn/gigaset/bas-gigaset.c | |||
@@ -134,6 +134,7 @@ struct bas_cardstate { | |||
134 | #define BS_ATRDPEND 0x040 /* urb_cmd_in in use */ | 134 | #define BS_ATRDPEND 0x040 /* urb_cmd_in in use */ |
135 | #define BS_ATWRPEND 0x080 /* urb_cmd_out in use */ | 135 | #define BS_ATWRPEND 0x080 /* urb_cmd_out in use */ |
136 | #define BS_SUSPEND 0x100 /* USB port suspended */ | 136 | #define BS_SUSPEND 0x100 /* USB port suspended */ |
137 | #define BS_RESETTING 0x200 /* waiting for HD_RESET_INTERRUPT_PIPE_ACK */ | ||
137 | 138 | ||
138 | 139 | ||
139 | static struct gigaset_driver *driver = NULL; | 140 | static struct gigaset_driver *driver = NULL; |
@@ -319,6 +320,21 @@ static int gigaset_set_line_ctrl(struct cardstate *cs, unsigned cflag) | |||
319 | return -EINVAL; | 320 | return -EINVAL; |
320 | } | 321 | } |
321 | 322 | ||
323 | /* set/clear bits in base connection state, return previous state | ||
324 | */ | ||
325 | static inline int update_basstate(struct bas_cardstate *ucs, | ||
326 | int set, int clear) | ||
327 | { | ||
328 | unsigned long flags; | ||
329 | int state; | ||
330 | |||
331 | spin_lock_irqsave(&ucs->lock, flags); | ||
332 | state = ucs->basstate; | ||
333 | ucs->basstate = (state & ~clear) | set; | ||
334 | spin_unlock_irqrestore(&ucs->lock, flags); | ||
335 | return state; | ||
336 | } | ||
337 | |||
322 | /* error_hangup | 338 | /* error_hangup |
323 | * hang up any existing connection because of an unrecoverable error | 339 | * hang up any existing connection because of an unrecoverable error |
324 | * This function may be called from any context and takes care of scheduling | 340 | * This function may be called from any context and takes care of scheduling |
@@ -350,12 +366,9 @@ static inline void error_hangup(struct bc_state *bcs) | |||
350 | */ | 366 | */ |
351 | static inline void error_reset(struct cardstate *cs) | 367 | static inline void error_reset(struct cardstate *cs) |
352 | { | 368 | { |
353 | /* close AT command channel to recover (ignore errors) */ | 369 | /* reset interrupt pipe to recover (ignore errors) */ |
354 | req_submit(cs->bcs, HD_CLOSE_ATCHANNEL, 0, BAS_TIMEOUT); | 370 | update_basstate(cs->hw.bas, BS_RESETTING, 0); |
355 | 371 | req_submit(cs->bcs, HD_RESET_INTERRUPT_PIPE, 0, BAS_TIMEOUT); | |
356 | //FIXME try to recover without bothering the user | ||
357 | dev_err(cs->dev, | ||
358 | "unrecoverable error - please disconnect Gigaset base to reset\n"); | ||
359 | } | 372 | } |
360 | 373 | ||
361 | /* check_pending | 374 | /* check_pending |
@@ -398,8 +411,13 @@ static void check_pending(struct bas_cardstate *ucs) | |||
398 | case HD_DEVICE_INIT_ACK: /* no reply expected */ | 411 | case HD_DEVICE_INIT_ACK: /* no reply expected */ |
399 | ucs->pending = 0; | 412 | ucs->pending = 0; |
400 | break; | 413 | break; |
401 | /* HD_READ_ATMESSAGE, HD_WRITE_ATMESSAGE, HD_RESET_INTERRUPTPIPE | 414 | case HD_RESET_INTERRUPT_PIPE: |
402 | * are handled separately and should never end up here | 415 | if (!(ucs->basstate & BS_RESETTING)) |
416 | ucs->pending = 0; | ||
417 | break; | ||
418 | /* | ||
419 | * HD_READ_ATMESSAGE and HD_WRITE_ATMESSAGE are handled separately | ||
420 | * and should never end up here | ||
403 | */ | 421 | */ |
404 | default: | 422 | default: |
405 | dev_warn(&ucs->interface->dev, | 423 | dev_warn(&ucs->interface->dev, |
@@ -449,21 +467,6 @@ static void cmd_in_timeout(unsigned long data) | |||
449 | error_reset(cs); | 467 | error_reset(cs); |
450 | } | 468 | } |
451 | 469 | ||
452 | /* set/clear bits in base connection state, return previous state | ||
453 | */ | ||
454 | inline static int update_basstate(struct bas_cardstate *ucs, | ||
455 | int set, int clear) | ||
456 | { | ||
457 | unsigned long flags; | ||
458 | int state; | ||
459 | |||
460 | spin_lock_irqsave(&ucs->lock, flags); | ||
461 | state = ucs->basstate; | ||
462 | ucs->basstate = (state & ~clear) | set; | ||
463 | spin_unlock_irqrestore(&ucs->lock, flags); | ||
464 | return state; | ||
465 | } | ||
466 | |||
467 | /* read_ctrl_callback | 470 | /* read_ctrl_callback |
468 | * USB completion handler for control pipe input | 471 | * USB completion handler for control pipe input |
469 | * called by the USB subsystem in interrupt context | 472 | * called by the USB subsystem in interrupt context |
@@ -762,7 +765,8 @@ static void read_int_callback(struct urb *urb) | |||
762 | break; | 765 | break; |
763 | 766 | ||
764 | case HD_RESET_INTERRUPT_PIPE_ACK: | 767 | case HD_RESET_INTERRUPT_PIPE_ACK: |
765 | gig_dbg(DEBUG_USBREQ, "HD_RESET_INTERRUPT_PIPE_ACK"); | 768 | update_basstate(ucs, 0, BS_RESETTING); |
769 | dev_notice(cs->dev, "interrupt pipe reset\n"); | ||
766 | break; | 770 | break; |
767 | 771 | ||
768 | case HD_SUSPEND_END: | 772 | case HD_SUSPEND_END: |
@@ -1429,6 +1433,7 @@ static void req_timeout(unsigned long data) | |||
1429 | 1433 | ||
1430 | case HD_CLOSE_ATCHANNEL: | 1434 | case HD_CLOSE_ATCHANNEL: |
1431 | dev_err(bcs->cs->dev, "timeout closing AT channel\n"); | 1435 | dev_err(bcs->cs->dev, "timeout closing AT channel\n"); |
1436 | error_reset(bcs->cs); | ||
1432 | break; | 1437 | break; |
1433 | 1438 | ||
1434 | case HD_CLOSE_B2CHANNEL: | 1439 | case HD_CLOSE_B2CHANNEL: |
@@ -1438,6 +1443,13 @@ static void req_timeout(unsigned long data) | |||
1438 | error_reset(bcs->cs); | 1443 | error_reset(bcs->cs); |
1439 | break; | 1444 | break; |
1440 | 1445 | ||
1446 | case HD_RESET_INTERRUPT_PIPE: | ||
1447 | /* error recovery escalation */ | ||
1448 | dev_err(bcs->cs->dev, | ||
1449 | "reset interrupt pipe timeout, attempting USB reset\n"); | ||
1450 | usb_queue_reset_device(bcs->cs->hw.bas->interface); | ||
1451 | break; | ||
1452 | |||
1441 | default: | 1453 | default: |
1442 | dev_warn(bcs->cs->dev, "request 0x%02x timed out, clearing\n", | 1454 | dev_warn(bcs->cs->dev, "request 0x%02x timed out, clearing\n", |
1443 | pending); | 1455 | pending); |
@@ -1930,6 +1942,15 @@ static int gigaset_write_cmd(struct cardstate *cs, | |||
1930 | goto notqueued; | 1942 | goto notqueued; |
1931 | } | 1943 | } |
1932 | 1944 | ||
1945 | /* translate "+++" escape sequence sent as a single separate command | ||
1946 | * into "close AT channel" command for error recovery | ||
1947 | * The next command will reopen the AT channel automatically. | ||
1948 | */ | ||
1949 | if (len == 3 && !memcmp(buf, "+++", 3)) { | ||
1950 | rc = req_submit(cs->bcs, HD_CLOSE_ATCHANNEL, 0, BAS_TIMEOUT); | ||
1951 | goto notqueued; | ||
1952 | } | ||
1953 | |||
1933 | if (len > IF_WRITEBUF) | 1954 | if (len > IF_WRITEBUF) |
1934 | len = IF_WRITEBUF; | 1955 | len = IF_WRITEBUF; |
1935 | if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) { | 1956 | if (!(cb = kmalloc(sizeof(struct cmdbuf_t) + len, GFP_ATOMIC))) { |