libata-eh.c (d8af0eb6046c56e7238171ca420622541db24926) | libata-eh.c (87fbc5a060faf2394bee88a93519f9b9d434727c) |
---|---|
1/* 2 * libata-eh.c - libata error handling 3 * 4 * Maintained by: Jeff Garzik <jgarzik@pobox.com> 5 * Please ALWAYS copy linux-ide@vger.kernel.org 6 * on emails. 7 * 8 * Copyright 2006 Tejun Heo <htejun@gmail.com> --- 53 unchanged lines hidden (view full) --- 62 ATA_ECAT_TOUT_HSM = 2, 63 ATA_ECAT_UNK_DEV = 3, 64 ATA_ECAT_DUBIOUS_NONE = 4, 65 ATA_ECAT_DUBIOUS_ATA_BUS = 5, 66 ATA_ECAT_DUBIOUS_TOUT_HSM = 6, 67 ATA_ECAT_DUBIOUS_UNK_DEV = 7, 68 ATA_ECAT_NR = 8, 69 | 1/* 2 * libata-eh.c - libata error handling 3 * 4 * Maintained by: Jeff Garzik <jgarzik@pobox.com> 5 * Please ALWAYS copy linux-ide@vger.kernel.org 6 * on emails. 7 * 8 * Copyright 2006 Tejun Heo <htejun@gmail.com> --- 53 unchanged lines hidden (view full) --- 62 ATA_ECAT_TOUT_HSM = 2, 63 ATA_ECAT_UNK_DEV = 3, 64 ATA_ECAT_DUBIOUS_NONE = 4, 65 ATA_ECAT_DUBIOUS_ATA_BUS = 5, 66 ATA_ECAT_DUBIOUS_TOUT_HSM = 6, 67 ATA_ECAT_DUBIOUS_UNK_DEV = 7, 68 ATA_ECAT_NR = 8, 69 |
70 ATA_EH_CMD_DFL_TIMEOUT = 5000, 71 |
|
70 /* always put at least this amount of time between resets */ 71 ATA_EH_RESET_COOL_DOWN = 5000, 72 73 /* Waiting in ->prereset can never be reliable. It's 74 * sometimes nice to wait there but it can't be depended upon; 75 * otherwise, we wouldn't be resetting. Just give it enough 76 * time for most drives to spin up. 77 */ --- 10 unchanged lines hidden (view full) --- 88static const unsigned long ata_eh_reset_timeouts[] = { 89 10000, /* most drives spin up by 10sec */ 90 10000, /* > 99% working drives spin up before 20sec */ 91 35000, /* give > 30 secs of idleness for retarded devices */ 92 5000, /* and sweet one last chance */ 93 ULONG_MAX, /* > 1 min has elapsed, give up */ 94}; 95 | 72 /* always put at least this amount of time between resets */ 73 ATA_EH_RESET_COOL_DOWN = 5000, 74 75 /* Waiting in ->prereset can never be reliable. It's 76 * sometimes nice to wait there but it can't be depended upon; 77 * otherwise, we wouldn't be resetting. Just give it enough 78 * time for most drives to spin up. 79 */ --- 10 unchanged lines hidden (view full) --- 90static const unsigned long ata_eh_reset_timeouts[] = { 91 10000, /* most drives spin up by 10sec */ 92 10000, /* > 99% working drives spin up before 20sec */ 93 35000, /* give > 30 secs of idleness for retarded devices */ 94 5000, /* and sweet one last chance */ 95 ULONG_MAX, /* > 1 min has elapsed, give up */ 96}; 97 |
98static const unsigned long ata_eh_identify_timeouts[] = { 99 5000, /* covers > 99% of successes and not too boring on failures */ 100 10000, /* combined time till here is enough even for media access */ 101 30000, /* for true idiots */ 102 ULONG_MAX, 103}; 104 105static const unsigned long ata_eh_other_timeouts[] = { 106 5000, /* same rationale as identify timeout */ 107 10000, /* ditto */ 108 /* but no merciful 30sec for other commands, it just isn't worth it */ 109 ULONG_MAX, 110}; 111 112struct ata_eh_cmd_timeout_ent { 113 const u8 *commands; 114 const unsigned long *timeouts; 115}; 116 117/* The following table determines timeouts to use for EH internal 118 * commands. Each table entry is a command class and matches the 119 * commands the entry applies to and the timeout table to use. 120 * 121 * On the retry after a command timed out, the next timeout value from 122 * the table is used. If the table doesn't contain further entries, 123 * the last value is used. 124 * 125 * ehc->cmd_timeout_idx keeps track of which timeout to use per 126 * command class, so if SET_FEATURES times out on the first try, the 127 * next try will use the second timeout value only for that class. 128 */ 129#define CMDS(cmds...) (const u8 []){ cmds, 0 } 130static const struct ata_eh_cmd_timeout_ent 131ata_eh_cmd_timeout_table[ATA_EH_CMD_TIMEOUT_TABLE_SIZE] = { 132 { .commands = CMDS(ATA_CMD_ID_ATA, ATA_CMD_ID_ATAPI), 133 .timeouts = ata_eh_identify_timeouts, }, 134 { .commands = CMDS(ATA_CMD_READ_NATIVE_MAX, ATA_CMD_READ_NATIVE_MAX_EXT), 135 .timeouts = ata_eh_other_timeouts, }, 136 { .commands = CMDS(ATA_CMD_SET_MAX, ATA_CMD_SET_MAX_EXT), 137 .timeouts = ata_eh_other_timeouts, }, 138 { .commands = CMDS(ATA_CMD_SET_FEATURES), 139 .timeouts = ata_eh_other_timeouts, }, 140 { .commands = CMDS(ATA_CMD_INIT_DEV_PARAMS), 141 .timeouts = ata_eh_other_timeouts, }, 142}; 143#undef CMDS 144 |
|
96static void __ata_port_freeze(struct ata_port *ap); 97#ifdef CONFIG_PM 98static void ata_eh_handle_port_suspend(struct ata_port *ap); 99static void ata_eh_handle_port_resume(struct ata_port *ap); 100#else /* CONFIG_PM */ 101static void ata_eh_handle_port_suspend(struct ata_port *ap) 102{ } 103 --- 129 unchanged lines hidden (view full) --- 233 ata_port_desc(ap, "%s %s%llu@0x%llx", name, type, len, start); 234 else 235 ata_port_desc(ap, "%s 0x%llx", name, 236 start + (unsigned long long)offset); 237} 238 239#endif /* CONFIG_PCI */ 240 | 145static void __ata_port_freeze(struct ata_port *ap); 146#ifdef CONFIG_PM 147static void ata_eh_handle_port_suspend(struct ata_port *ap); 148static void ata_eh_handle_port_resume(struct ata_port *ap); 149#else /* CONFIG_PM */ 150static void ata_eh_handle_port_suspend(struct ata_port *ap) 151{ } 152 --- 129 unchanged lines hidden (view full) --- 282 ata_port_desc(ap, "%s %s%llu@0x%llx", name, type, len, start); 283 else 284 ata_port_desc(ap, "%s 0x%llx", name, 285 start + (unsigned long long)offset); 286} 287 288#endif /* CONFIG_PCI */ 289 |
290static int ata_lookup_timeout_table(u8 cmd) 291{ 292 int i; 293 294 for (i = 0; i < ATA_EH_CMD_TIMEOUT_TABLE_SIZE; i++) { 295 const u8 *cur; 296 297 for (cur = ata_eh_cmd_timeout_table[i].commands; *cur; cur++) 298 if (*cur == cmd) 299 return i; 300 } 301 302 return -1; 303} 304 305/** 306 * ata_internal_cmd_timeout - determine timeout for an internal command 307 * @dev: target device 308 * @cmd: internal command to be issued 309 * 310 * Determine timeout for internal command @cmd for @dev. 311 * 312 * LOCKING: 313 * EH context. 314 * 315 * RETURNS: 316 * Determined timeout. 317 */ 318unsigned long ata_internal_cmd_timeout(struct ata_device *dev, u8 cmd) 319{ 320 struct ata_eh_context *ehc = &dev->link->eh_context; 321 int ent = ata_lookup_timeout_table(cmd); 322 int idx; 323 324 if (ent < 0) 325 return ATA_EH_CMD_DFL_TIMEOUT; 326 327 idx = ehc->cmd_timeout_idx[dev->devno][ent]; 328 return ata_eh_cmd_timeout_table[ent].timeouts[idx]; 329} 330 331/** 332 * ata_internal_cmd_timed_out - notification for internal command timeout 333 * @dev: target device 334 * @cmd: internal command which timed out 335 * 336 * Notify EH that internal command @cmd for @dev timed out. This 337 * function should be called only for commands whose timeouts are 338 * determined using ata_internal_cmd_timeout(). 339 * 340 * LOCKING: 341 * EH context. 342 */ 343void ata_internal_cmd_timed_out(struct ata_device *dev, u8 cmd) 344{ 345 struct ata_eh_context *ehc = &dev->link->eh_context; 346 int ent = ata_lookup_timeout_table(cmd); 347 int idx; 348 349 if (ent < 0) 350 return; 351 352 idx = ehc->cmd_timeout_idx[dev->devno][ent]; 353 if (ata_eh_cmd_timeout_table[ent].timeouts[idx + 1] != ULONG_MAX) 354 ehc->cmd_timeout_idx[dev->devno][ent]++; 355} 356 |
|
241static void ata_ering_record(struct ata_ering *ering, unsigned int eflags, 242 unsigned int err_mask) 243{ 244 struct ata_ering_entry *ent; 245 246 WARN_ON(!err_mask); 247 248 ering->cursor++; --- 2346 unchanged lines hidden (view full) --- 2595 /* disable device if it has used up all its chances */ 2596 ata_dev_disable(dev); 2597 2598 /* detach if offline */ 2599 if (ata_link_offline(dev->link)) 2600 ata_eh_detach_dev(dev); 2601 2602 /* schedule probe if necessary */ | 357static void ata_ering_record(struct ata_ering *ering, unsigned int eflags, 358 unsigned int err_mask) 359{ 360 struct ata_ering_entry *ent; 361 362 WARN_ON(!err_mask); 363 364 ering->cursor++; --- 2346 unchanged lines hidden (view full) --- 2711 /* disable device if it has used up all its chances */ 2712 ata_dev_disable(dev); 2713 2714 /* detach if offline */ 2715 if (ata_link_offline(dev->link)) 2716 ata_eh_detach_dev(dev); 2717 2718 /* schedule probe if necessary */ |
2603 if (ata_eh_schedule_probe(dev)) | 2719 if (ata_eh_schedule_probe(dev)) { |
2604 ehc->tries[dev->devno] = ATA_EH_DEV_TRIES; | 2720 ehc->tries[dev->devno] = ATA_EH_DEV_TRIES; |
2721 memset(ehc->cmd_timeout_idx[dev->devno], 0, 2722 sizeof(ehc->cmd_timeout_idx[dev->devno])); 2723 } |
|
2605 2606 return 1; 2607 } else { 2608 ehc->i.action |= ATA_EH_RESET; 2609 return 0; 2610 } 2611} 2612 --- 363 unchanged lines hidden --- | 2724 2725 return 1; 2726 } else { 2727 ehc->i.action |= ATA_EH_RESET; 2728 return 0; 2729 } 2730} 2731 --- 363 unchanged lines hidden --- |