Lines Matching +full:non +full:- +full:descriptive

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * libata-eh.c - libata error handling
8 * as Documentation/driver-api/libata.rst
11 * http://www.sata-io.org/
59 /* Waiting in ->prereset can never be reliable. It's
97 15000, /* Some drives are slow to read log pages when waking-up */
129 * ehc->cmd_timeout_idx keeps track of which timeout to use per
172 ehi->desc_len += vscnprintf(ehi->desc + ehi->desc_len, in __ata_ehi_pushv_desc()
173 ATA_EH_DESC_LEN - ehi->desc_len, in __ata_ehi_pushv_desc()
178 * __ata_ehi_push_desc - push error description without adding separator
182 * Format string according to @fmt and append it to @ehi->desc.
198 * ata_ehi_push_desc - push error description with separator
202 * Format string according to @fmt and append it to @ehi->desc.
203 * If @ehi->desc is not empty, ", " is added in-between.
212 if (ehi->desc_len) in ata_ehi_push_desc()
222 * ata_ehi_clear_desc - clean error description
225 * Clear @ehi->desc.
232 ehi->desc[0] = '\0'; in ata_ehi_clear_desc()
233 ehi->desc_len = 0; in ata_ehi_clear_desc()
238 * ata_port_desc - append port description
244 * in-between. This function is to be used while initializing
254 WARN_ON(!(ap->pflags & ATA_PFLAG_INITIALIZING)); in ata_port_desc()
256 if (ap->link.eh_info.desc_len) in ata_port_desc()
257 __ata_ehi_push_desc(&ap->link.eh_info, " "); in ata_port_desc()
260 __ata_ehi_pushv_desc(&ap->link.eh_info, fmt, args); in ata_port_desc()
267 * ata_port_pbar_desc - append PCI BAR description
284 struct pci_dev *pdev = to_pci_dev(ap->host->dev); in ata_port_pbar_desc()
317 return -1; in ata_lookup_timeout_table()
321 * ata_internal_cmd_timeout - determine timeout for an internal command
335 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_internal_cmd_timeout()
342 idx = ehc->cmd_timeout_idx[dev->devno][ent]; in ata_internal_cmd_timeout()
347 * ata_internal_cmd_timed_out - notification for internal command timeout
360 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_internal_cmd_timed_out()
367 idx = ehc->cmd_timeout_idx[dev->devno][ent]; in ata_internal_cmd_timed_out()
369 ehc->cmd_timeout_idx[dev->devno][ent]++; in ata_internal_cmd_timed_out()
379 ering->cursor++; in ata_ering_record()
380 ering->cursor %= ATA_ERING_SIZE; in ata_ering_record()
382 ent = &ering->ring[ering->cursor]; in ata_ering_record()
383 ent->eflags = eflags; in ata_ering_record()
384 ent->err_mask = err_mask; in ata_ering_record()
385 ent->timestamp = get_jiffies_64(); in ata_ering_record()
390 struct ata_ering_entry *ent = &ering->ring[ering->cursor]; in ata_ering_top()
392 if (ent->err_mask) in ata_ering_top()
404 idx = ering->cursor; in ata_ering_map()
406 ent = &ering->ring[idx]; in ata_ering_map()
407 if (!ent->err_mask) in ata_ering_map()
412 idx = (idx - 1 + ATA_ERING_SIZE) % ATA_ERING_SIZE; in ata_ering_map()
413 } while (idx != ering->cursor); in ata_ering_map()
420 ent->eflags |= ATA_EFLAG_OLD_ER; in ata_ering_clear_cb()
431 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_eh_dev_action()
433 return ehc->i.action | ehc->i.dev_action[dev->devno]; in ata_eh_dev_action()
442 ehi->action &= ~action; in ata_eh_clear_action()
444 ehi->dev_action[tdev->devno] &= ~action; in ata_eh_clear_action()
446 /* doesn't make sense for port-wide EH actions */ in ata_eh_clear_action()
449 /* break ehi->action into ehi->dev_action */ in ata_eh_clear_action()
450 if (ehi->action & action) { in ata_eh_clear_action()
452 ehi->dev_action[tdev->devno] |= in ata_eh_clear_action()
453 ehi->action & action; in ata_eh_clear_action()
454 ehi->action &= ~action; in ata_eh_clear_action()
457 /* turn off the specified per-dev action */ in ata_eh_clear_action()
458 ehi->dev_action[dev->devno] &= ~action; in ata_eh_clear_action()
463 * ata_eh_acquire - acquire EH ownership
475 mutex_lock(&ap->host->eh_mutex); in ata_eh_acquire()
476 WARN_ON_ONCE(ap->host->eh_owner); in ata_eh_acquire()
477 ap->host->eh_owner = current; in ata_eh_acquire()
481 * ata_eh_release - release EH ownership
492 WARN_ON_ONCE(ap->host->eh_owner != current); in ata_eh_release()
493 ap->host->eh_owner = NULL; in ata_eh_release()
494 mutex_unlock(&ap->host->eh_mutex); in ata_eh_release()
501 dev->class++; in ata_eh_dev_disable()
507 ata_ering_clear(&dev->ering); in ata_eh_dev_disable()
534 sata_scr_write(link, SCR_CONTROL, link->saved_scontrol & 0xff0); in ata_eh_unload()
540 spin_lock_irqsave(ap->lock, flags); in ata_eh_unload()
543 ap->pflags &= ~ATA_PFLAG_EH_PENDING; /* clear pending from freeze */ in ata_eh_unload()
544 ap->pflags |= ATA_PFLAG_UNLOADED; in ata_eh_unload()
546 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_unload()
550 * ata_scsi_error - SCSI layer error handler callback
553 * Handles SCSI-layer-thrown error events.
567 spin_lock_irqsave(host->host_lock, flags); in ata_scsi_error()
568 list_splice_init(&host->eh_cmd_q, &eh_work_q); in ata_scsi_error()
569 spin_unlock_irqrestore(host->host_lock, flags); in ata_scsi_error()
583 * ata_scsi_cmd_error_handler - error callback for a list of commands
589 * ap->eh_done_q. This function is the first part of the libata error
606 * For EH, all qcs are finished in one of three ways - in ata_scsi_cmd_error_handler()
618 spin_lock_irqsave(ap->lock, flags); in ata_scsi_cmd_error_handler()
621 * This must occur under the ap->lock as we don't want in ata_scsi_cmd_error_handler()
625 * non-notified command and completes much like an IRQ handler. in ata_scsi_cmd_error_handler()
630 if (ap->ops->lost_interrupt) in ata_scsi_cmd_error_handler()
631 ap->ops->lost_interrupt(ap); in ata_scsi_cmd_error_handler()
637 * If the scmd was added to EH, via ata_qc_schedule_eh() -> in ata_scsi_cmd_error_handler()
638 * scsi_timeout() -> scsi_eh_scmd_add(), scsi_timeout() will in ata_scsi_cmd_error_handler()
645 if (qc->flags & ATA_QCFLAG_ACTIVE && in ata_scsi_cmd_error_handler()
646 qc->scsicmd == scmd) in ata_scsi_cmd_error_handler()
652 if (!(qc->flags & ATA_QCFLAG_EH)) { in ata_scsi_cmd_error_handler()
655 qc->err_mask |= AC_ERR_TIMEOUT; in ata_scsi_cmd_error_handler()
656 qc->flags |= ATA_QCFLAG_EH; in ata_scsi_cmd_error_handler()
664 scmd->retries = scmd->allowed; in ata_scsi_cmd_error_handler()
665 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in ata_scsi_cmd_error_handler()
680 ap->eh_tries = ATA_EH_MAX_TRIES; in ata_scsi_cmd_error_handler()
682 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_cmd_error_handler()
687 * ata_scsi_port_error_handler - recover the port after the commands
703 del_timer_sync(&ap->fastdrain_timer); in ata_scsi_port_error_handler()
709 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
712 struct ata_eh_context *ehc = &link->eh_context; in ata_scsi_port_error_handler()
715 memset(&link->eh_context, 0, sizeof(link->eh_context)); in ata_scsi_port_error_handler()
716 link->eh_context.i = link->eh_info; in ata_scsi_port_error_handler()
717 memset(&link->eh_info, 0, sizeof(link->eh_info)); in ata_scsi_port_error_handler()
720 int devno = dev->devno; in ata_scsi_port_error_handler()
722 ehc->saved_xfer_mode[devno] = dev->xfer_mode; in ata_scsi_port_error_handler()
724 ehc->saved_ncq_enabled |= 1 << devno; in ata_scsi_port_error_handler()
727 if (ap->pflags & ATA_PFLAG_RESUMING) { in ata_scsi_port_error_handler()
728 dev->flags |= ATA_DFLAG_RESUMING; in ata_scsi_port_error_handler()
729 ehc->i.dev_action[devno] |= ATA_EH_SET_ACTIVE; in ata_scsi_port_error_handler()
734 ap->pflags |= ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
735 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
736 ap->excl_link = NULL; /* don't maintain exclusion over EH */ in ata_scsi_port_error_handler()
738 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
741 if (!(ap->pflags & (ATA_PFLAG_UNLOADING | ATA_PFLAG_SUSPENDED))) in ata_scsi_port_error_handler()
742 ap->ops->error_handler(ap); in ata_scsi_port_error_handler()
745 if ((ap->pflags & ATA_PFLAG_UNLOADING) && in ata_scsi_port_error_handler()
746 !(ap->pflags & ATA_PFLAG_UNLOADED)) in ata_scsi_port_error_handler()
755 * Exception might have happened after ->error_handler recovered the in ata_scsi_port_error_handler()
758 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
760 if (ap->pflags & ATA_PFLAG_EH_PENDING) { in ata_scsi_port_error_handler()
761 if (--ap->eh_tries) { in ata_scsi_port_error_handler()
762 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
768 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
773 memset(&link->eh_info, 0, sizeof(link->eh_info)); in ata_scsi_port_error_handler()
776 * end eh (clear host_eh_scheduled) while holding ap->lock such that if in ata_scsi_port_error_handler()
778 * midlayer will re-initiate EH. in ata_scsi_port_error_handler()
780 ap->ops->end_eh(ap); in ata_scsi_port_error_handler()
782 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
785 scsi_eh_flush_done_q(&ap->eh_done_q); in ata_scsi_port_error_handler()
788 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
790 ap->pflags &= ~ATA_PFLAG_RESUMING; in ata_scsi_port_error_handler()
792 if (ap->pflags & ATA_PFLAG_LOADING) in ata_scsi_port_error_handler()
793 ap->pflags &= ~ATA_PFLAG_LOADING; in ata_scsi_port_error_handler()
794 else if ((ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) && in ata_scsi_port_error_handler()
795 !(ap->flags & ATA_FLAG_SAS_HOST)) in ata_scsi_port_error_handler()
796 schedule_delayed_work(&ap->hotplug_task, 0); in ata_scsi_port_error_handler()
798 if (ap->pflags & ATA_PFLAG_RECOVERED) in ata_scsi_port_error_handler()
801 ap->pflags &= ~(ATA_PFLAG_SCSI_HOTPLUG | ATA_PFLAG_RECOVERED); in ata_scsi_port_error_handler()
804 ap->pflags &= ~ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
805 wake_up_all(&ap->eh_wait_q); in ata_scsi_port_error_handler()
807 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
812 * ata_port_wait_eh - Wait for the currently pending EH to complete
826 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
828 while (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS)) { in ata_port_wait_eh()
829 prepare_to_wait(&ap->eh_wait_q, &wait, TASK_UNINTERRUPTIBLE); in ata_port_wait_eh()
830 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
832 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
834 finish_wait(&ap->eh_wait_q, &wait); in ata_port_wait_eh()
836 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
839 if (scsi_host_in_recovery(ap->scsi_host)) { in ata_port_wait_eh()
852 /* count only non-internal commands */ in ata_eh_nr_in_flight()
867 spin_lock_irqsave(ap->lock, flags); in ata_eh_fastdrain_timerfn()
875 if (cnt == ap->fastdrain_cnt) { in ata_eh_fastdrain_timerfn()
880 * in-flight qcs as timed out and freeze the port. in ata_eh_fastdrain_timerfn()
884 qc->err_mask |= AC_ERR_TIMEOUT; in ata_eh_fastdrain_timerfn()
890 ap->fastdrain_cnt = cnt; in ata_eh_fastdrain_timerfn()
891 ap->fastdrain_timer.expires = in ata_eh_fastdrain_timerfn()
893 add_timer(&ap->fastdrain_timer); in ata_eh_fastdrain_timerfn()
897 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_fastdrain_timerfn()
901 * ata_eh_set_pending - set ATA_PFLAG_EH_PENDING and activate fast drain
906 * is non-zero and EH wasn't pending before. Fast drain ensures
917 if (ap->pflags & ATA_PFLAG_EH_PENDING) in ata_eh_set_pending()
920 ap->pflags |= ATA_PFLAG_EH_PENDING; in ata_eh_set_pending()
925 /* do we have in-flight qcs? */ in ata_eh_set_pending()
931 ap->fastdrain_cnt = cnt; in ata_eh_set_pending()
932 ap->fastdrain_timer.expires = in ata_eh_set_pending()
934 add_timer(&ap->fastdrain_timer); in ata_eh_set_pending()
938 * ata_qc_schedule_eh - schedule qc for error handling
949 struct ata_port *ap = qc->ap; in ata_qc_schedule_eh()
951 qc->flags |= ATA_QCFLAG_EH; in ata_qc_schedule_eh()
959 blk_abort_request(scsi_cmd_to_rq(qc->scsicmd)); in ata_qc_schedule_eh()
963 * ata_std_sched_eh - non-libsas ata_ports issue eh with this common routine
971 if (ap->pflags & ATA_PFLAG_INITIALIZING) in ata_std_sched_eh()
975 scsi_schedule_eh(ap->scsi_host); in ata_std_sched_eh()
982 * ata_std_end_eh - non-libsas ata_ports complete eh with this common routine
986 * shost, so host fields can be directly manipulated under ap->lock, in
987 * the libsas case we need to hold a lock at the ha->level to coordinate
995 struct Scsi_Host *host = ap->scsi_host; in ata_std_end_eh()
997 host->host_eh_scheduled = 0; in ata_std_end_eh()
1003 * ata_port_schedule_eh - schedule error handling without a qc
1015 ap->ops->sched_eh(ap); in ata_port_schedule_eh()
1029 if (qc && (!link || qc->dev->link == link)) { in ata_do_link_abort()
1030 qc->flags |= ATA_QCFLAG_EH; in ata_do_link_abort()
1043 * ata_link_abort - abort all qc's on the link
1056 return ata_do_link_abort(link->ap, link); in ata_link_abort()
1061 * ata_port_abort - abort all qc's on the port
1079 * __ata_port_freeze - freeze port
1087 * ap->ops->freeze() callback can be used for freezing the port
1088 * hardware-wise (e.g. mask interrupt and stop DMA engine). If a
1089 * port cannot be frozen hardware-wise, the interrupt handler
1098 if (ap->ops->freeze) in __ata_port_freeze()
1099 ap->ops->freeze(ap); in __ata_port_freeze()
1101 ap->pflags |= ATA_PFLAG_FROZEN; in __ata_port_freeze()
1107 * ata_port_freeze - abort & freeze port
1129 * ata_eh_freeze_port - EH helper to freeze port
1141 spin_lock_irqsave(ap->lock, flags); in ata_eh_freeze_port()
1143 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_freeze_port()
1148 * ata_eh_thaw_port - EH helper to thaw port
1160 spin_lock_irqsave(ap->lock, flags); in ata_eh_thaw_port()
1162 ap->pflags &= ~ATA_PFLAG_FROZEN; in ata_eh_thaw_port()
1164 if (ap->ops->thaw) in ata_eh_thaw_port()
1165 ap->ops->thaw(ap); in ata_eh_thaw_port()
1167 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_thaw_port()
1179 struct ata_port *ap = qc->ap; in __ata_eh_qc_complete()
1180 struct scsi_cmnd *scmd = qc->scsicmd; in __ata_eh_qc_complete()
1183 spin_lock_irqsave(ap->lock, flags); in __ata_eh_qc_complete()
1184 qc->scsidone = ata_eh_scsidone; in __ata_eh_qc_complete()
1186 WARN_ON(ata_tag_valid(qc->tag)); in __ata_eh_qc_complete()
1187 spin_unlock_irqrestore(ap->lock, flags); in __ata_eh_qc_complete()
1189 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in __ata_eh_qc_complete()
1193 * ata_eh_qc_complete - Complete an active ATA command from EH
1201 struct scsi_cmnd *scmd = qc->scsicmd; in ata_eh_qc_complete()
1202 scmd->retries = scmd->allowed; in ata_eh_qc_complete()
1207 * ata_eh_qc_retry - Tell midlayer to retry an ATA command after EH
1213 * SCSI midlayer limits the number of retries to scmd->allowed.
1214 * scmd->allowed is incremented for commands which get retried
1215 * due to unrelated failures (qc->err_mask is zero).
1219 struct scsi_cmnd *scmd = qc->scsicmd; in ata_eh_qc_retry()
1220 if (!qc->err_mask) in ata_eh_qc_retry()
1221 scmd->allowed++; in ata_eh_qc_retry()
1226 * ata_dev_disable - disable ATA device
1246 * ata_eh_detach_dev - detach ATA device
1256 struct ata_link *link = dev->link; in ata_eh_detach_dev()
1257 struct ata_port *ap = link->ap; in ata_eh_detach_dev()
1258 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_detach_dev()
1270 spin_lock_irqsave(ap->lock, flags); in ata_eh_detach_dev()
1272 dev->flags &= ~ATA_DFLAG_DETACH; in ata_eh_detach_dev()
1275 dev->flags |= ATA_DFLAG_DETACHED; in ata_eh_detach_dev()
1276 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_detach_dev()
1279 /* clear per-dev EH info */ in ata_eh_detach_dev()
1280 ata_eh_clear_action(link, dev, &link->eh_info, ATA_EH_PERDEV_MASK); in ata_eh_detach_dev()
1281 ata_eh_clear_action(link, dev, &link->eh_context.i, ATA_EH_PERDEV_MASK); in ata_eh_detach_dev()
1282 ehc->saved_xfer_mode[dev->devno] = 0; in ata_eh_detach_dev()
1283 ehc->saved_ncq_enabled &= ~(1 << dev->devno); in ata_eh_detach_dev()
1285 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_detach_dev()
1289 * ata_eh_about_to_do - about to perform eh_action
1291 * @dev: target ATA dev for per-dev action (can be NULL)
1295 * in @link->eh_info such that eh actions are not unnecessarily
1304 struct ata_port *ap = link->ap; in ata_eh_about_to_do()
1305 struct ata_eh_info *ehi = &link->eh_info; in ata_eh_about_to_do()
1306 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_about_to_do()
1309 trace_ata_eh_about_to_do(link, dev ? dev->devno : 0, action); in ata_eh_about_to_do()
1311 spin_lock_irqsave(ap->lock, flags); in ata_eh_about_to_do()
1318 if (!(ehc->i.flags & ATA_EHI_QUIET) && link != ap->slave_link) in ata_eh_about_to_do()
1319 ap->pflags |= ATA_PFLAG_RECOVERED; in ata_eh_about_to_do()
1321 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_about_to_do()
1325 * ata_eh_done - EH action complete
1327 * @dev: target ATA dev for per-dev action (can be NULL)
1331 * in @link->eh_context.
1339 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_done()
1341 trace_ata_eh_done(link, dev ? dev->devno : 0, action); in ata_eh_done()
1343 ata_eh_clear_action(link, dev, &ehc->i, action); in ata_eh_done()
1347 * ata_err_string - convert err_mask to descriptive string
1350 * Convert @err_mask to descriptive string. Errors are
1358 * Descriptive string for @err_mask
1386 * atapi_eh_tur - perform ATAPI TEST_UNIT_READY
1417 * ata_eh_decide_disposition - Disposition a qc based on sense data
1450 return scsi_check_sense(qc->scsicmd); in ata_eh_decide_disposition()
1454 * ata_eh_request_sense - perform REQUEST_SENSE_DATA_EXT
1468 struct scsi_cmnd *cmd = qc->scsicmd; in ata_eh_request_sense()
1469 struct ata_device *dev = qc->dev; in ata_eh_request_sense()
1473 if (ata_port_is_frozen(qc->ap)) { in ata_eh_request_sense()
1478 if (!ata_id_sense_reporting_enabled(dev->id)) { in ata_eh_request_sense()
1479 ata_dev_warn(qc->dev, "sense data reporting disabled\n"); in ata_eh_request_sense()
1493 /* Set sense without also setting scsicmd->result */ in ata_eh_request_sense()
1494 scsi_build_sense_buffer(dev->flags & ATA_DFLAG_D_SENSE, in ata_eh_request_sense()
1495 cmd->sense_buffer, tf.lbah, in ata_eh_request_sense()
1497 qc->flags |= ATA_QCFLAG_SENSE_VALID; in ata_eh_request_sense()
1509 * atapi_eh_request_sense - perform ATAPI REQUEST_SENSE
1528 struct ata_port *ap = dev->link->ap; in atapi_eh_request_sense()
1534 * for the case where they are -not- overwritten in atapi_eh_request_sense()
1546 if (ap->flags & ATA_FLAG_PIO_DMA) { in atapi_eh_request_sense()
1560 * ata_eh_analyze_serror - analyze SError for a failed port
1571 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_analyze_serror()
1572 u32 serror = ehc->i.serror; in ata_eh_analyze_serror()
1594 if (link->lpm_policy > ATA_LPM_MAX_POWER) in ata_eh_analyze_serror()
1596 else if (!(link->flags & ATA_LFLAG_DISABLED) || ata_is_host_link(link)) in ata_eh_analyze_serror()
1602 ata_ehi_hotplugged(&ehc->i); in ata_eh_analyze_serror()
1604 ehc->i.err_mask |= err_mask; in ata_eh_analyze_serror()
1605 ehc->i.action |= action; in ata_eh_analyze_serror()
1609 * ata_eh_analyze_tf - analyze taskfile of a failed qc
1624 const struct ata_taskfile *tf = &qc->result_tf; in ata_eh_analyze_tf()
1626 u8 stat = tf->status, err = tf->error; in ata_eh_analyze_tf()
1629 qc->err_mask |= AC_ERR_HSM; in ata_eh_analyze_tf()
1634 qc->err_mask |= AC_ERR_DEV; in ata_eh_analyze_tf()
1645 switch (qc->dev->class) { in ata_eh_analyze_tf()
1650 * -It was a non-NCQ command that failed, or in ata_eh_analyze_tf()
1651 * -It was a NCQ command that failed, but the sense data in ata_eh_analyze_tf()
1655 if (!(qc->flags & ATA_QCFLAG_SENSE_VALID) && in ata_eh_analyze_tf()
1657 set_status_byte(qc->scsicmd, SAM_STAT_CHECK_CONDITION); in ata_eh_analyze_tf()
1659 qc->err_mask |= AC_ERR_ATA_BUS; in ata_eh_analyze_tf()
1661 qc->err_mask |= AC_ERR_MEDIA; in ata_eh_analyze_tf()
1663 qc->err_mask |= AC_ERR_INVALID; in ata_eh_analyze_tf()
1667 if (!ata_port_is_frozen(qc->ap)) { in ata_eh_analyze_tf()
1668 tmp = atapi_eh_request_sense(qc->dev, in ata_eh_analyze_tf()
1669 qc->scsicmd->sense_buffer, in ata_eh_analyze_tf()
1670 qc->result_tf.error >> 4); in ata_eh_analyze_tf()
1672 qc->flags |= ATA_QCFLAG_SENSE_VALID; in ata_eh_analyze_tf()
1674 qc->err_mask |= tmp; in ata_eh_analyze_tf()
1678 if (qc->flags & ATA_QCFLAG_SENSE_VALID) { in ata_eh_analyze_tf()
1691 qc->flags |= ATA_QCFLAG_RETRY; in ata_eh_analyze_tf()
1692 qc->err_mask |= AC_ERR_OTHER; in ata_eh_analyze_tf()
1694 qc->err_mask |= AC_ERR_HSM; in ata_eh_analyze_tf()
1697 if (qc->err_mask & (AC_ERR_HSM | AC_ERR_TIMEOUT | AC_ERR_ATA_BUS)) in ata_eh_analyze_tf()
1742 if ((ent->eflags & ATA_EFLAG_OLD_ER) || (ent->timestamp < arg->since)) in speed_down_verdict_cb()
1743 return -1; in speed_down_verdict_cb()
1745 cat = ata_eh_categorize_error(ent->eflags, ent->err_mask, in speed_down_verdict_cb()
1746 &arg->xfer_ok); in speed_down_verdict_cb()
1747 arg->nr_errors[cat]++; in speed_down_verdict_cb()
1753 * ata_eh_speed_down_verdict - Determine speed down verdict
1780 * taken per error. An action triggered by non-DUBIOUS errors
1818 arg.since = j64 - min(j64, j5mins); in ata_eh_speed_down_verdict()
1819 ata_ering_map(&dev->ering, speed_down_verdict_cb, &arg); in ata_eh_speed_down_verdict()
1837 arg.since = j64 - min(j64, j10mins); in ata_eh_speed_down_verdict()
1838 ata_ering_map(&dev->ering, speed_down_verdict_cb, &arg); in ata_eh_speed_down_verdict()
1853 * ata_eh_speed_down - record error and speed down if necessary
1877 /* don't bother if Cat-0 error */ in ata_eh_speed_down()
1882 ata_ering_record(&dev->ering, eflags, err_mask); in ata_eh_speed_down()
1887 dev->flags |= ATA_DFLAG_NCQ_OFF; in ata_eh_speed_down()
1901 if (dev->spdn_cnt < 2) { in ata_eh_speed_down()
1908 if (dev->xfer_shift != ATA_SHIFT_PIO) in ata_eh_speed_down()
1909 sel = dma_dnxfer_sel[dev->spdn_cnt]; in ata_eh_speed_down()
1911 sel = pio_dnxfer_sel[dev->spdn_cnt]; in ata_eh_speed_down()
1913 dev->spdn_cnt++; in ata_eh_speed_down()
1925 if ((verdict & ATA_EH_SPDN_FALLBACK_TO_PIO) && (dev->spdn_cnt >= 2) && in ata_eh_speed_down()
1926 (link->ap->cbl != ATA_CBL_SATA || dev->class == ATA_DEV_ATAPI) && in ata_eh_speed_down()
1927 (dev->xfer_shift != ATA_SHIFT_PIO)) { in ata_eh_speed_down()
1929 dev->spdn_cnt = 0; in ata_eh_speed_down()
1939 ata_ering_clear(&dev->ering); in ata_eh_speed_down()
1944 * ata_eh_worth_retry - analyze error and decide whether to retry
1949 * because the drive itself has probably already taken 10-30 seconds
1954 if (qc->err_mask & AC_ERR_MEDIA) in ata_eh_worth_retry()
1956 if (qc->flags & ATA_QCFLAG_IO) in ata_eh_worth_retry()
1958 if (qc->err_mask & AC_ERR_INVALID) in ata_eh_worth_retry()
1960 return qc->err_mask != AC_ERR_DEV; /* retry if not dev error */ in ata_eh_worth_retry()
1964 * ata_eh_quiet - check if we need to be quiet about a command error
1972 if (qc->scsicmd && scsi_cmd_to_rq(qc->scsicmd)->rq_flags & RQF_QUIET) in ata_eh_quiet()
1973 qc->flags |= ATA_QCFLAG_QUIET; in ata_eh_quiet()
1974 return qc->flags & ATA_QCFLAG_QUIET; in ata_eh_quiet()
1979 struct ata_port *ap = link->ap; in ata_eh_get_non_ncq_success_sense()
1982 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_get_non_ncq_success_sense()
1984 return -EIO; in ata_eh_get_non_ncq_success_sense()
1986 if (!(qc->flags & ATA_QCFLAG_EH) || in ata_eh_get_non_ncq_success_sense()
1987 !(qc->flags & ATA_QCFLAG_EH_SUCCESS_CMD) || in ata_eh_get_non_ncq_success_sense()
1988 qc->err_mask) in ata_eh_get_non_ncq_success_sense()
1989 return -EIO; in ata_eh_get_non_ncq_success_sense()
1992 return -EIO; in ata_eh_get_non_ncq_success_sense()
2005 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_get_success_sense()
2006 struct ata_device *dev = link->device; in ata_eh_get_success_sense()
2007 struct ata_port *ap = link->ap; in ata_eh_get_success_sense()
2011 if (!(ehc->i.dev_action[dev->devno] & ATA_EH_GET_SUCCESS_SENSE)) in ata_eh_get_success_sense()
2024 * data. Otherwise, we are dealing with a non-NCQ command and use in ata_eh_get_success_sense()
2027 if (link->sactive) in ata_eh_get_success_sense()
2048 if (!(qc->flags & ATA_QCFLAG_EH) || in ata_eh_get_success_sense()
2049 !(qc->flags & ATA_QCFLAG_EH_SUCCESS_CMD) || in ata_eh_get_success_sense()
2050 qc->err_mask || in ata_eh_get_success_sense()
2051 ata_dev_phys_link(qc->dev) != link) in ata_eh_get_success_sense()
2055 if (qc->flags & ATA_QCFLAG_SENSE_VALID) in ata_eh_get_success_sense()
2059 if (!(qc->result_tf.status & ATA_SENSE)) in ata_eh_get_success_sense()
2063 ata_scsi_set_sense(dev, qc->scsicmd, ABORTED_COMMAND, 0, 0); in ata_eh_get_success_sense()
2064 qc->flags |= ATA_QCFLAG_SENSE_VALID; in ata_eh_get_success_sense()
2070 * ata_eh_link_autopsy - analyze error and determine recovery action
2082 struct ata_port *ap = link->ap; in ata_eh_link_autopsy()
2083 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_link_autopsy()
2091 if (ehc->i.flags & ATA_EHI_NO_AUTOPSY) in ata_eh_link_autopsy()
2097 ehc->i.serror |= serror; in ata_eh_link_autopsy()
2099 } else if (rc != -EOPNOTSUPP) { in ata_eh_link_autopsy()
2101 ehc->i.probe_mask |= ATA_ALL_DEVICES; in ata_eh_link_autopsy()
2102 ehc->i.action |= ATA_EH_RESET; in ata_eh_link_autopsy()
2103 ehc->i.err_mask |= AC_ERR_OTHER; in ata_eh_link_autopsy()
2118 if (ehc->i.err_mask & ~AC_ERR_OTHER) in ata_eh_link_autopsy()
2119 ehc->i.err_mask &= ~AC_ERR_OTHER; in ata_eh_link_autopsy()
2121 all_err_mask |= ehc->i.err_mask; in ata_eh_link_autopsy()
2124 if (!(qc->flags & ATA_QCFLAG_EH) || in ata_eh_link_autopsy()
2125 qc->flags & ATA_QCFLAG_RETRY || in ata_eh_link_autopsy()
2126 qc->flags & ATA_QCFLAG_EH_SUCCESS_CMD || in ata_eh_link_autopsy()
2127 ata_dev_phys_link(qc->dev) != link) in ata_eh_link_autopsy()
2131 qc->err_mask |= ehc->i.err_mask; in ata_eh_link_autopsy()
2134 ehc->i.action |= ata_eh_analyze_tf(qc); in ata_eh_link_autopsy()
2137 if (qc->err_mask & AC_ERR_ATA_BUS) in ata_eh_link_autopsy()
2138 qc->err_mask &= ~(AC_ERR_DEV | AC_ERR_MEDIA | in ata_eh_link_autopsy()
2142 if (qc->err_mask & ~AC_ERR_OTHER) in ata_eh_link_autopsy()
2143 qc->err_mask &= ~AC_ERR_OTHER; in ata_eh_link_autopsy()
2152 if (qc->flags & ATA_QCFLAG_SENSE_VALID) in ata_eh_link_autopsy()
2153 qc->err_mask &= ~(AC_ERR_DEV | AC_ERR_OTHER); in ata_eh_link_autopsy()
2155 qc->flags |= ATA_QCFLAG_RETRY; in ata_eh_link_autopsy()
2158 ehc->i.dev = qc->dev; in ata_eh_link_autopsy()
2159 all_err_mask |= qc->err_mask; in ata_eh_link_autopsy()
2160 if (qc->flags & ATA_QCFLAG_IO) in ata_eh_link_autopsy()
2172 ehc->i.flags |= ATA_EHI_QUIET; in ata_eh_link_autopsy()
2177 ehc->i.action |= ATA_EH_RESET; in ata_eh_link_autopsy()
2180 ehc->i.action |= ATA_EH_REVALIDATE; in ata_eh_link_autopsy()
2183 * perform per-dev EH action only on the offending device. in ata_eh_link_autopsy()
2185 if (ehc->i.dev) { in ata_eh_link_autopsy()
2186 ehc->i.dev_action[ehc->i.dev->devno] |= in ata_eh_link_autopsy()
2187 ehc->i.action & ATA_EH_PERDEV_MASK; in ata_eh_link_autopsy()
2188 ehc->i.action &= ~ATA_EH_PERDEV_MASK; in ata_eh_link_autopsy()
2193 ap->link.eh_context.i.err_mask |= AC_ERR_TIMEOUT; in ata_eh_link_autopsy()
2196 dev = ehc->i.dev; in ata_eh_link_autopsy()
2198 ata_dev_enabled(link->device)))) in ata_eh_link_autopsy()
2199 dev = link->device; in ata_eh_link_autopsy()
2202 if (dev->flags & ATA_DFLAG_DUBIOUS_XFER) in ata_eh_link_autopsy()
2204 ehc->i.action |= ata_eh_speed_down(dev, eflags, all_err_mask); in ata_eh_link_autopsy()
2205 trace_ata_eh_link_autopsy(dev, ehc->i.action, all_err_mask); in ata_eh_link_autopsy()
2210 * ata_eh_autopsy - analyze error and determine recovery action
2230 if (ap->slave_link) { in ata_eh_autopsy()
2231 struct ata_eh_context *mehc = &ap->link.eh_context; in ata_eh_autopsy()
2232 struct ata_eh_context *sehc = &ap->slave_link->eh_context; in ata_eh_autopsy()
2235 sehc->i.flags |= mehc->i.flags & ATA_EHI_TO_SLAVE_MASK; in ata_eh_autopsy()
2238 ata_eh_link_autopsy(ap->slave_link); in ata_eh_autopsy()
2241 ata_eh_about_to_do(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2242 mehc->i.action |= sehc->i.action; in ata_eh_autopsy()
2243 mehc->i.dev_action[1] |= sehc->i.dev_action[1]; in ata_eh_autopsy()
2244 mehc->i.flags |= sehc->i.flags; in ata_eh_autopsy()
2245 ata_eh_done(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2252 ata_eh_link_autopsy(&ap->link); in ata_eh_autopsy()
2256 * ata_get_cmd_name - get name for ATA command
2299 { ATA_CMD_NCQ_NON_DATA, "NCQ NON-DATA" }, in ata_get_cmd_name()
2328 { ATA_CMD_TRUSTED_NONDATA, "TRUSTED NON-DATA" }, in ata_get_cmd_name()
2378 * ata_eh_link_report - report error handling to user
2388 struct ata_port *ap = link->ap; in ata_eh_link_report()
2389 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_link_report()
2395 if (ehc->i.flags & ATA_EHI_QUIET) in ata_eh_link_report()
2399 if (ehc->i.desc[0] != '\0') in ata_eh_link_report()
2400 desc = ehc->i.desc; in ata_eh_link_report()
2403 if (!(qc->flags & ATA_QCFLAG_EH) || in ata_eh_link_report()
2404 ata_dev_phys_link(qc->dev) != link || in ata_eh_link_report()
2405 ((qc->flags & ATA_QCFLAG_QUIET) && in ata_eh_link_report()
2406 qc->err_mask == AC_ERR_DEV)) in ata_eh_link_report()
2408 if (qc->flags & ATA_QCFLAG_SENSE_VALID && !qc->err_mask) in ata_eh_link_report()
2414 if (!nr_failed && !ehc->i.err_mask) in ata_eh_link_report()
2421 if (ap->eh_tries < ATA_EH_MAX_TRIES) in ata_eh_link_report()
2423 ap->eh_tries); in ata_eh_link_report()
2425 if (ehc->i.dev) { in ata_eh_link_report()
2426 ata_dev_err(ehc->i.dev, "exception Emask 0x%x " in ata_eh_link_report()
2428 ehc->i.err_mask, link->sactive, ehc->i.serror, in ata_eh_link_report()
2429 ehc->i.action, frozen, tries_buf); in ata_eh_link_report()
2431 ata_dev_err(ehc->i.dev, "%s\n", desc); in ata_eh_link_report()
2435 ehc->i.err_mask, link->sactive, ehc->i.serror, in ata_eh_link_report()
2436 ehc->i.action, frozen, tries_buf); in ata_eh_link_report()
2442 if (ehc->i.serror) in ata_eh_link_report()
2445 ehc->i.serror & SERR_DATA_RECOVERED ? "RecovData " : "", in ata_eh_link_report()
2446 ehc->i.serror & SERR_COMM_RECOVERED ? "RecovComm " : "", in ata_eh_link_report()
2447 ehc->i.serror & SERR_DATA ? "UnrecovData " : "", in ata_eh_link_report()
2448 ehc->i.serror & SERR_PERSISTENT ? "Persist " : "", in ata_eh_link_report()
2449 ehc->i.serror & SERR_PROTOCOL ? "Proto " : "", in ata_eh_link_report()
2450 ehc->i.serror & SERR_INTERNAL ? "HostInt " : "", in ata_eh_link_report()
2451 ehc->i.serror & SERR_PHYRDY_CHG ? "PHYRdyChg " : "", in ata_eh_link_report()
2452 ehc->i.serror & SERR_PHY_INT_ERR ? "PHYInt " : "", in ata_eh_link_report()
2453 ehc->i.serror & SERR_COMM_WAKE ? "CommWake " : "", in ata_eh_link_report()
2454 ehc->i.serror & SERR_10B_8B_ERR ? "10B8B " : "", in ata_eh_link_report()
2455 ehc->i.serror & SERR_DISPARITY ? "Dispar " : "", in ata_eh_link_report()
2456 ehc->i.serror & SERR_CRC ? "BadCRC " : "", in ata_eh_link_report()
2457 ehc->i.serror & SERR_HANDSHAKE ? "Handshk " : "", in ata_eh_link_report()
2458 ehc->i.serror & SERR_LINK_SEQ_ERR ? "LinkSeq " : "", in ata_eh_link_report()
2459 ehc->i.serror & SERR_TRANS_ST_ERROR ? "TrStaTrns " : "", in ata_eh_link_report()
2460 ehc->i.serror & SERR_UNRECOG_FIS ? "UnrecFIS " : "", in ata_eh_link_report()
2461 ehc->i.serror & SERR_DEV_XCHG ? "DevExch " : ""); in ata_eh_link_report()
2465 struct ata_taskfile *cmd = &qc->tf, *res = &qc->result_tf; in ata_eh_link_report()
2469 if (!(qc->flags & ATA_QCFLAG_EH) || in ata_eh_link_report()
2470 ata_dev_phys_link(qc->dev) != link || !qc->err_mask) in ata_eh_link_report()
2473 if (qc->dma_dir != DMA_NONE) { in ata_eh_link_report()
2481 switch (qc->tf.protocol) { in ata_eh_link_report()
2511 prot_str, qc->nbytes, dma_str[qc->dma_dir]); in ata_eh_link_report()
2514 if (ata_is_atapi(qc->tf.protocol)) { in ata_eh_link_report()
2515 const u8 *cdb = qc->cdb; in ata_eh_link_report()
2516 size_t cdb_len = qc->dev->cdb_len; in ata_eh_link_report()
2518 if (qc->scsicmd) { in ata_eh_link_report()
2519 cdb = qc->scsicmd->cmnd; in ata_eh_link_report()
2520 cdb_len = qc->scsicmd->cmd_len; in ata_eh_link_report()
2525 ata_dev_err(qc->dev, "failed command: %s\n", in ata_eh_link_report()
2526 ata_get_cmd_name(cmd->command)); in ata_eh_link_report()
2528 ata_dev_err(qc->dev, in ata_eh_link_report()
2533 cmd->command, cmd->feature, cmd->nsect, in ata_eh_link_report()
2534 cmd->lbal, cmd->lbam, cmd->lbah, in ata_eh_link_report()
2535 cmd->hob_feature, cmd->hob_nsect, in ata_eh_link_report()
2536 cmd->hob_lbal, cmd->hob_lbam, cmd->hob_lbah, in ata_eh_link_report()
2537 cmd->device, qc->tag, data_buf, cdb_buf, in ata_eh_link_report()
2538 res->status, res->error, res->nsect, in ata_eh_link_report()
2539 res->lbal, res->lbam, res->lbah, in ata_eh_link_report()
2540 res->hob_feature, res->hob_nsect, in ata_eh_link_report()
2541 res->hob_lbal, res->hob_lbam, res->hob_lbah, in ata_eh_link_report()
2542 res->device, qc->err_mask, ata_err_string(qc->err_mask), in ata_eh_link_report()
2543 qc->err_mask & AC_ERR_NCQ ? " <F>" : ""); in ata_eh_link_report()
2546 if (res->status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | in ata_eh_link_report()
2548 if (res->status & ATA_BUSY) in ata_eh_link_report()
2549 ata_dev_err(qc->dev, "status: { Busy }\n"); in ata_eh_link_report()
2551 ata_dev_err(qc->dev, "status: { %s%s%s%s%s}\n", in ata_eh_link_report()
2552 res->status & ATA_DRDY ? "DRDY " : "", in ata_eh_link_report()
2553 res->status & ATA_DF ? "DF " : "", in ata_eh_link_report()
2554 res->status & ATA_DRQ ? "DRQ " : "", in ata_eh_link_report()
2555 res->status & ATA_SENSE ? "SENSE " : "", in ata_eh_link_report()
2556 res->status & ATA_ERR ? "ERR " : ""); in ata_eh_link_report()
2559 if (cmd->command != ATA_CMD_PACKET && in ata_eh_link_report()
2560 (res->error & (ATA_ICRC | ATA_UNC | ATA_AMNF | ATA_IDNF | in ata_eh_link_report()
2562 ata_dev_err(qc->dev, "error: { %s%s%s%s%s}\n", in ata_eh_link_report()
2563 res->error & ATA_ICRC ? "ICRC " : "", in ata_eh_link_report()
2564 res->error & ATA_UNC ? "UNC " : "", in ata_eh_link_report()
2565 res->error & ATA_AMNF ? "AMNF " : "", in ata_eh_link_report()
2566 res->error & ATA_IDNF ? "IDNF " : "", in ata_eh_link_report()
2567 res->error & ATA_ABORTED ? "ABRT " : ""); in ata_eh_link_report()
2573 * ata_eh_report - report error handling to user
2597 classes[dev->devno] = ATA_DEV_UNKNOWN; in ata_do_reset()
2604 if ((link->flags & ATA_LFLAG_NO_SRST) || ata_link_offline(link)) in ata_eh_followup_srst_needed()
2606 if (rc == -EAGAIN) in ata_eh_followup_srst_needed()
2608 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) in ata_eh_followup_srst_needed()
2617 struct ata_port *ap = link->ap; in ata_eh_reset()
2618 struct ata_link *slave = ap->slave_link; in ata_eh_reset()
2619 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_reset()
2620 struct ata_eh_context *sehc = slave ? &slave->eh_context : NULL; in ata_eh_reset()
2621 unsigned int *classes = ehc->classes; in ata_eh_reset()
2622 unsigned int lflags = link->flags; in ata_eh_reset()
2623 int verbose = !(ehc->i.flags & ATA_EHI_QUIET); in ata_eh_reset()
2638 if (link->flags & ATA_LFLAG_RST_ONCE) in ata_eh_reset()
2640 if (link->flags & ATA_LFLAG_NO_HRST) in ata_eh_reset()
2642 if (link->flags & ATA_LFLAG_NO_SRST) in ata_eh_reset()
2646 if (ehc->i.flags & ATA_EHI_DID_RESET) { in ata_eh_reset()
2648 WARN_ON(time_after(ehc->last_reset, now)); in ata_eh_reset()
2649 deadline = ata_deadline(ehc->last_reset, in ata_eh_reset()
2652 schedule_timeout_uninterruptible(deadline - now); in ata_eh_reset()
2655 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2656 ap->pflags |= ATA_PFLAG_RESETTING; in ata_eh_reset()
2657 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2669 dev->pio_mode = XFER_PIO_0; in ata_eh_reset()
2670 dev->dma_mode = 0xff; in ata_eh_reset()
2677 if (ap->ops->set_piomode) in ata_eh_reset()
2678 ap->ops->set_piomode(ap, dev); in ata_eh_reset()
2683 ehc->i.action &= ~ATA_EH_RESET; in ata_eh_reset()
2686 ehc->i.action |= ATA_EH_HARDRESET; in ata_eh_reset()
2689 ehc->i.action |= ATA_EH_SOFTRESET; in ata_eh_reset()
2697 sehc->i.action &= ~ATA_EH_RESET; in ata_eh_reset()
2698 sehc->i.action |= ehc->i.action; in ata_eh_reset()
2705 * -ENOENT or clear ATA_EH_RESET. in ata_eh_reset()
2707 if (slave && (rc == 0 || rc == -ENOENT)) { in ata_eh_reset()
2711 if (tmp != -ENOENT) in ata_eh_reset()
2714 ehc->i.action |= sehc->i.action; in ata_eh_reset()
2718 if (rc == -ENOENT) { in ata_eh_reset()
2719 ata_link_dbg(link, "port disabled--ignoring\n"); in ata_eh_reset()
2720 ehc->i.action &= ~ATA_EH_RESET; in ata_eh_reset()
2723 classes[dev->devno] = ATA_DEV_NONE; in ata_eh_reset()
2736 if (reset && !(ehc->i.action & ATA_EH_RESET)) { in ata_eh_reset()
2738 classes[dev->devno] = ATA_DEV_NONE; in ata_eh_reset()
2761 ehc->last_reset = jiffies; in ata_eh_reset()
2763 ehc->i.flags |= ATA_EHI_DID_HARDRESET; in ata_eh_reset()
2766 ehc->i.flags |= ATA_EHI_DID_SOFTRESET; in ata_eh_reset()
2775 if (rc && rc != -EAGAIN) { in ata_eh_reset()
2794 case -EAGAIN: in ata_eh_reset()
2795 rc = -EAGAIN; in ata_eh_reset()
2806 /* perform follow-up SRST if necessary */ in ata_eh_reset()
2813 "follow-up softreset required but no softreset available\n"); in ata_eh_reset()
2815 rc = -EINVAL; in ata_eh_reset()
2837 * Post-reset processing in ata_eh_reset()
2844 dev->pio_mode = XFER_PIO_0; in ata_eh_reset()
2845 dev->flags &= ~ATA_DFLAG_SLEEPING; in ata_eh_reset()
2852 classes[dev->devno] = ATA_DEV_ATA; in ata_eh_reset()
2854 classes[dev->devno] = ATA_DEV_SEMB_UNSUP; in ata_eh_reset()
2859 link->sata_spd = (sstatus >> 4) & 0xf; in ata_eh_reset()
2861 slave->sata_spd = (sstatus >> 4) & 0xf; in ata_eh_reset()
2884 spin_lock_irqsave(link->ap->lock, flags); in ata_eh_reset()
2885 link->eh_info.serror = 0; in ata_eh_reset()
2887 slave->eh_info.serror = 0; in ata_eh_reset()
2888 spin_unlock_irqrestore(link->ap->lock, flags); in ata_eh_reset()
2901 if (classes[dev->devno] == ATA_DEV_UNKNOWN) { in ata_eh_reset()
2903 classes[dev->devno] = ATA_DEV_NONE; in ata_eh_reset()
2907 if (ata_class_enabled(classes[dev->devno])) in ata_eh_reset()
2910 classes[dev->devno]); in ata_eh_reset()
2911 classes[dev->devno] = ATA_DEV_NONE; in ata_eh_reset()
2912 } else if (classes[dev->devno] == ATA_DEV_UNKNOWN) { in ata_eh_reset()
2915 classes[dev->devno] = ATA_DEV_NONE; in ata_eh_reset()
2925 rc = -EAGAIN; in ata_eh_reset()
2937 ehc->last_reset = jiffies; /* update to completion time */ in ata_eh_reset()
2938 ehc->i.action |= ATA_EH_REVALIDATE; in ata_eh_reset()
2939 link->lpm_policy = ATA_LPM_UNKNOWN; /* reset LPM state */ in ata_eh_reset()
2944 ehc->i.flags &= ~ATA_EHI_HOTPLUGGED; in ata_eh_reset()
2946 sehc->i.flags &= ~ATA_EHI_HOTPLUGGED; in ata_eh_reset()
2948 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2949 ap->pflags &= ~ATA_PFLAG_RESETTING; in ata_eh_reset()
2950 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2955 /* if SCR isn't accessible on a fan-out port, PMP needs to be reset */ in ata_eh_reset()
2958 rc = -ERESTART; in ata_eh_reset()
2976 unsigned long delta = deadline - now; in ata_eh_reset()
2990 * They need to be reset - as well as the PMP - before retrying. in ata_eh_reset()
2992 if (rc == -ERESTART) { in ata_eh_reset()
2998 if (try == max_tries - 1) { in ata_eh_reset()
3002 } else if (rc == -EPIPE) in ata_eh_reset()
3028 * Additionally, all write accesses to &ap->park_req_pending in ata_eh_pull_park_action()
3035 * park_req_pending.done is non-zero by the time we reach in ata_eh_pull_park_action()
3042 spin_lock_irqsave(ap->lock, flags); in ata_eh_pull_park_action()
3043 reinit_completion(&ap->park_req_pending); in ata_eh_pull_park_action()
3046 struct ata_eh_info *ehi = &link->eh_info; in ata_eh_pull_park_action()
3048 link->eh_context.i.dev_action[dev->devno] |= in ata_eh_pull_park_action()
3049 ehi->dev_action[dev->devno] & ATA_EH_PARK; in ata_eh_pull_park_action()
3053 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_pull_park_action()
3058 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_eh_park_issue_cmd()
3064 ehc->unloaded_mask |= 1 << dev->devno; in ata_eh_park_issue_cmd()
3071 ehc->unloaded_mask &= ~(1 << dev->devno); in ata_eh_park_issue_cmd()
3080 ehc->unloaded_mask &= ~(1 << dev->devno); in ata_eh_park_issue_cmd()
3087 struct ata_port *ap = link->ap; in ata_eh_revalidate_and_attach()
3088 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_revalidate_and_attach()
3095 * be done backwards such that PDIAG- is released by the slave in ata_eh_revalidate_and_attach()
3102 if (ehc->i.flags & ATA_EHI_DID_RESET) in ata_eh_revalidate_and_attach()
3106 WARN_ON(dev->class == ATA_DEV_PMP); in ata_eh_revalidate_and_attach()
3116 * to ap->target_lpm_policy after revalidation is done. in ata_eh_revalidate_and_attach()
3118 if (link->lpm_policy > ATA_LPM_MAX_POWER) { in ata_eh_revalidate_and_attach()
3126 rc = -EIO; in ata_eh_revalidate_and_attach()
3131 rc = ata_dev_revalidate(dev, ehc->classes[dev->devno], in ata_eh_revalidate_and_attach()
3141 ehc->i.flags |= ATA_EHI_SETMODE; in ata_eh_revalidate_and_attach()
3144 schedule_delayed_work(&ap->scsi_rescan_task, 0); in ata_eh_revalidate_and_attach()
3145 } else if (dev->class == ATA_DEV_UNKNOWN && in ata_eh_revalidate_and_attach()
3146 ehc->tries[dev->devno] && in ata_eh_revalidate_and_attach()
3147 ata_class_enabled(ehc->classes[dev->devno])) { in ata_eh_revalidate_and_attach()
3148 /* Temporarily set dev->class, it will be in ata_eh_revalidate_and_attach()
3154 dev->class = ehc->classes[dev->devno]; in ata_eh_revalidate_and_attach()
3156 if (dev->class == ATA_DEV_PMP) in ata_eh_revalidate_and_attach()
3159 rc = ata_dev_read_id(dev, &dev->class, in ata_eh_revalidate_and_attach()
3160 readid_flags, dev->id); in ata_eh_revalidate_and_attach()
3163 ehc->classes[dev->devno] = dev->class; in ata_eh_revalidate_and_attach()
3164 dev->class = ATA_DEV_UNKNOWN; in ata_eh_revalidate_and_attach()
3169 ata_ering_clear(&dev->ering); in ata_eh_revalidate_and_attach()
3170 new_mask |= 1 << dev->devno; in ata_eh_revalidate_and_attach()
3172 case -ENOENT: in ata_eh_revalidate_and_attach()
3173 /* IDENTIFY was issued to non-existent in ata_eh_revalidate_and_attach()
3185 /* PDIAG- should have been released, ask cable type if post-reset */ in ata_eh_revalidate_and_attach()
3186 if ((ehc->i.flags & ATA_EHI_DID_RESET) && ata_is_host_link(link)) { in ata_eh_revalidate_and_attach()
3187 if (ap->ops->cable_detect) in ata_eh_revalidate_and_attach()
3188 ap->cbl = ap->ops->cable_detect(ap); in ata_eh_revalidate_and_attach()
3196 if (!(new_mask & (1 << dev->devno))) in ata_eh_revalidate_and_attach()
3199 dev->class = ehc->classes[dev->devno]; in ata_eh_revalidate_and_attach()
3201 if (dev->class == ATA_DEV_PMP) in ata_eh_revalidate_and_attach()
3204 ehc->i.flags |= ATA_EHI_PRINTINFO; in ata_eh_revalidate_and_attach()
3206 ehc->i.flags &= ~ATA_EHI_PRINTINFO; in ata_eh_revalidate_and_attach()
3208 dev->class = ATA_DEV_UNKNOWN; in ata_eh_revalidate_and_attach()
3212 spin_lock_irqsave(ap->lock, flags); in ata_eh_revalidate_and_attach()
3213 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_revalidate_and_attach()
3214 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_revalidate_and_attach()
3217 ehc->i.flags |= ATA_EHI_SETMODE; in ata_eh_revalidate_and_attach()
3223 dev->flags &= ~ATA_DFLAG_RESUMING; in ata_eh_revalidate_and_attach()
3229 * ata_set_mode - Program timings and issue SET FEATURES - XFER
3245 struct ata_port *ap = link->ap; in ata_set_mode()
3251 if (!(dev->flags & ATA_DFLAG_DUBIOUS_XFER)) { in ata_set_mode()
3254 ent = ata_ering_top(&dev->ering); in ata_set_mode()
3256 ent->eflags &= ~ATA_EFLAG_DUBIOUS_XFER; in ata_set_mode()
3261 if (ap->ops->set_mode) in ata_set_mode()
3262 rc = ap->ops->set_mode(link, r_failed_dev); in ata_set_mode()
3268 struct ata_eh_context *ehc = &link->eh_context; in ata_set_mode()
3269 u8 saved_xfer_mode = ehc->saved_xfer_mode[dev->devno]; in ata_set_mode()
3270 u8 saved_ncq = !!(ehc->saved_ncq_enabled & (1 << dev->devno)); in ata_set_mode()
3272 if (dev->xfer_mode != saved_xfer_mode || in ata_set_mode()
3274 dev->flags |= ATA_DFLAG_DUBIOUS_XFER; in ata_set_mode()
3281 * atapi_eh_clear_ua - Clear ATAPI UNIT ATTENTION after reset
3292 * 0 on success, -errno on failure.
3299 u8 *sense_buffer = dev->sector_buf; in atapi_eh_clear_ua()
3308 return -EIO; in atapi_eh_clear_ua()
3318 return -EIO; in atapi_eh_clear_ua()
3329 * ata_eh_maybe_retry_flush - Retry FLUSH if necessary
3343 * 0 if EH can continue, -errno if EH needs to be repeated.
3347 struct ata_link *link = dev->link; in ata_eh_maybe_retry_flush()
3348 struct ata_port *ap = link->ap; in ata_eh_maybe_retry_flush()
3355 if (!ata_tag_valid(link->active_tag)) in ata_eh_maybe_retry_flush()
3358 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_maybe_retry_flush()
3359 if (qc->dev != dev || (qc->tf.command != ATA_CMD_FLUSH_EXT && in ata_eh_maybe_retry_flush()
3360 qc->tf.command != ATA_CMD_FLUSH)) in ata_eh_maybe_retry_flush()
3364 if (qc->err_mask & AC_ERR_DEV) in ata_eh_maybe_retry_flush()
3370 tf.command = qc->tf.command; in ata_eh_maybe_retry_flush()
3375 tf.command, qc->err_mask); in ata_eh_maybe_retry_flush()
3383 * retrying it should do the trick - whatever was in in ata_eh_maybe_retry_flush()
3387 qc->scsicmd->allowed = max(qc->scsicmd->allowed, 1); in ata_eh_maybe_retry_flush()
3391 rc = -EIO; in ata_eh_maybe_retry_flush()
3395 qc->err_mask |= AC_ERR_DEV; in ata_eh_maybe_retry_flush()
3396 qc->result_tf = tf; in ata_eh_maybe_retry_flush()
3405 * ata_eh_set_lpm - configure SATA interface power management
3419 * 0 on success, -errno on failure.
3424 struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL; in ata_eh_set_lpm()
3425 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_set_lpm()
3427 enum ata_lpm_policy old_policy = link->lpm_policy; in ata_eh_set_lpm()
3428 bool no_dipm = link->ap->flags & ATA_FLAG_NO_DIPM; in ata_eh_set_lpm()
3435 (link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm)) in ata_eh_set_lpm()
3445 bool hipm = ata_id_has_hipm(dev->id); in ata_eh_set_lpm()
3446 bool dipm = ata_id_has_dipm(dev->id) && !no_dipm; in ata_eh_set_lpm()
3467 rc = -EIO; in ata_eh_set_lpm()
3474 rc = ap->ops->set_lpm(link, policy, hints); in ata_eh_set_lpm()
3475 if (!rc && ap->slave_link) in ata_eh_set_lpm()
3476 rc = ap->ops->set_lpm(ap->slave_link, policy, hints); in ata_eh_set_lpm()
3485 if (rc == -EOPNOTSUPP) { in ata_eh_set_lpm()
3486 link->flags |= ATA_LFLAG_NO_LPM; in ata_eh_set_lpm()
3497 link->lpm_policy = policy; in ata_eh_set_lpm()
3498 if (ap && ap->slave_link) in ata_eh_set_lpm()
3499 ap->slave_link->lpm_policy = policy; in ata_eh_set_lpm()
3504 ata_id_has_dipm(dev->id)) { in ata_eh_set_lpm()
3511 rc = -EIO; in ata_eh_set_lpm()
3517 link->last_lpm_change = jiffies; in ata_eh_set_lpm()
3518 link->flags |= ATA_LFLAG_CHANGED; in ata_eh_set_lpm()
3524 link->lpm_policy = old_policy; in ata_eh_set_lpm()
3525 if (ap && ap->slave_link) in ata_eh_set_lpm()
3526 ap->slave_link->lpm_policy = old_policy; in ata_eh_set_lpm()
3529 if (!dev || ehc->tries[dev->devno] <= 2) { in ata_eh_set_lpm()
3531 link->flags |= ATA_LFLAG_NO_LPM; in ata_eh_set_lpm()
3554 if (dev->class == ATA_DEV_UNKNOWN) in ata_link_nr_vacant()
3561 struct ata_port *ap = link->ap; in ata_eh_skip_recovery()
3562 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_skip_recovery()
3566 if (link->flags & ATA_LFLAG_DISABLED) in ata_eh_skip_recovery()
3570 if (ehc->i.flags & ATA_EHI_NO_RECOVERY) in ata_eh_skip_recovery()
3578 if ((ehc->i.action & ATA_EH_RESET) && in ata_eh_skip_recovery()
3579 !(ehc->i.flags & ATA_EHI_DID_RESET)) in ata_eh_skip_recovery()
3584 if (dev->class == ATA_DEV_UNKNOWN && in ata_eh_skip_recovery()
3585 ehc->classes[dev->devno] != ATA_DEV_NONE) in ata_eh_skip_recovery()
3598 if ((ent->eflags & ATA_EFLAG_OLD_ER) || in ata_count_probe_trials_cb()
3599 (ent->timestamp < now - min(now, interval))) in ata_count_probe_trials_cb()
3600 return -1; in ata_count_probe_trials_cb()
3608 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_eh_schedule_probe()
3612 if (!(ehc->i.probe_mask & (1 << dev->devno)) || in ata_eh_schedule_probe()
3613 (ehc->did_probe_mask & (1 << dev->devno))) in ata_eh_schedule_probe()
3618 ehc->did_probe_mask |= (1 << dev->devno); in ata_eh_schedule_probe()
3619 ehc->i.action |= ATA_EH_RESET; in ata_eh_schedule_probe()
3620 ehc->saved_xfer_mode[dev->devno] = 0; in ata_eh_schedule_probe()
3621 ehc->saved_ncq_enabled &= ~(1 << dev->devno); in ata_eh_schedule_probe()
3624 if (link->lpm_policy > ATA_LPM_MAX_POWER) { in ata_eh_schedule_probe()
3626 link->ap->ops->set_lpm(link, ATA_LPM_MAX_POWER, in ata_eh_schedule_probe()
3646 ata_ering_record(&dev->ering, 0, AC_ERR_OTHER); in ata_eh_schedule_probe()
3647 ata_ering_map(&dev->ering, ata_count_probe_trials_cb, &trials); in ata_eh_schedule_probe()
3657 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_eh_handle_dev_fail()
3659 /* -EAGAIN from EH routine indicates retry without prejudice. in ata_eh_handle_dev_fail()
3662 if (err != -EAGAIN) in ata_eh_handle_dev_fail()
3663 ehc->tries[dev->devno]--; in ata_eh_handle_dev_fail()
3666 case -ENODEV: in ata_eh_handle_dev_fail()
3668 ehc->i.probe_mask |= (1 << dev->devno); in ata_eh_handle_dev_fail()
3670 case -EINVAL: in ata_eh_handle_dev_fail()
3672 ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1); in ata_eh_handle_dev_fail()
3674 case -EIO: in ata_eh_handle_dev_fail()
3675 if (ehc->tries[dev->devno] == 1) { in ata_eh_handle_dev_fail()
3680 if (dev->pio_mode > XFER_PIO_0) in ata_eh_handle_dev_fail()
3685 if (ata_dev_enabled(dev) && !ehc->tries[dev->devno]) { in ata_eh_handle_dev_fail()
3695 ehc->tries[dev->devno] = ATA_EH_DEV_TRIES; in ata_eh_handle_dev_fail()
3696 memset(ehc->cmd_timeout_idx[dev->devno], 0, in ata_eh_handle_dev_fail()
3697 sizeof(ehc->cmd_timeout_idx[dev->devno])); in ata_eh_handle_dev_fail()
3702 ehc->i.action |= ATA_EH_RESET; in ata_eh_handle_dev_fail()
3708 * ata_eh_recover - recover host port after error
3727 * 0 on success, -errno on failure.
3741 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3743 /* re-enable link? */ in ata_eh_recover()
3744 if (ehc->i.action & ATA_EH_ENABLE_LINK) { in ata_eh_recover()
3746 spin_lock_irqsave(ap->lock, flags); in ata_eh_recover()
3747 link->flags &= ~ATA_LFLAG_DISABLED; in ata_eh_recover()
3748 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_recover()
3753 if (link->flags & ATA_LFLAG_NO_RETRY) in ata_eh_recover()
3754 ehc->tries[dev->devno] = 1; in ata_eh_recover()
3756 ehc->tries[dev->devno] = ATA_EH_DEV_TRIES; in ata_eh_recover()
3759 ehc->i.action |= ehc->i.dev_action[dev->devno] & in ata_eh_recover()
3761 ehc->i.dev_action[dev->devno] &= ATA_EH_PERDEV_MASK; in ata_eh_recover()
3764 if (dev->flags & ATA_DFLAG_DETACH) in ata_eh_recover()
3777 if (ap->pflags & ATA_PFLAG_UNLOADING) in ata_eh_recover()
3782 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3786 ehc->i.action = 0; in ata_eh_recover()
3789 ehc->classes[dev->devno] = ATA_DEV_UNKNOWN; in ata_eh_recover()
3794 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3796 if (!(ehc->i.action & ATA_EH_RESET)) in ata_eh_recover()
3812 * ap->park_req_pending in ata_eh_recover()
3819 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3822 if (dev->class != ATA_DEV_ATA && in ata_eh_recover()
3823 dev->class != ATA_DEV_ZAC) in ata_eh_recover()
3825 if (!(ehc->i.dev_action[dev->devno] & in ata_eh_recover()
3828 tmp = dev->unpark_deadline; in ata_eh_recover()
3833 if (ehc->unloaded_mask & (1 << dev->devno)) in ata_eh_recover()
3845 deadline = wait_for_completion_timeout(&ap->park_req_pending, in ata_eh_recover()
3846 deadline - now); in ata_eh_recover()
3851 if (!(link->eh_context.unloaded_mask & in ata_eh_recover()
3852 (1 << dev->devno))) in ata_eh_recover()
3863 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3874 if (link->device->class == ATA_DEV_PMP) { in ata_eh_recover()
3875 ehc->i.action = 0; in ata_eh_recover()
3880 if (ehc->i.flags & ATA_EHI_SETMODE) { in ata_eh_recover()
3884 ehc->i.flags &= ~ATA_EHI_SETMODE; in ata_eh_recover()
3890 if (ehc->i.flags & ATA_EHI_DID_RESET) { in ata_eh_recover()
3892 if (dev->class != ATA_DEV_ATAPI) in ata_eh_recover()
3907 if (ehc->i.dev_action[dev->devno] & ATA_EH_SET_ACTIVE) { in ata_eh_recover()
3915 if (dev->class != ATA_DEV_ATA && in ata_eh_recover()
3916 dev->class != ATA_DEV_ZAC) in ata_eh_recover()
3925 if (link->lpm_policy != ap->target_lpm_policy) { in ata_eh_recover()
3926 rc = ata_eh_set_lpm(link, ap->target_lpm_policy, &dev); in ata_eh_recover()
3932 ehc->i.flags = 0; in ata_eh_recover()
3961 * ata_eh_finish - finish up EH
3977 if (!(qc->flags & ATA_QCFLAG_EH)) in ata_eh_finish()
3980 if (qc->err_mask) { in ata_eh_finish()
3985 if (qc->flags & ATA_QCFLAG_RETRY) { in ata_eh_finish()
3987 * Since qc->err_mask is set, ata_eh_qc_retry() in ata_eh_finish()
3988 * will not increment scmd->allowed, so upper in ata_eh_finish()
3997 if (qc->flags & ATA_QCFLAG_SENSE_VALID || in ata_eh_finish()
3998 qc->flags & ATA_QCFLAG_EH_SUCCESS_CMD) { in ata_eh_finish()
4002 memset(&qc->result_tf, 0, sizeof(qc->result_tf)); in ata_eh_finish()
4004 * Since qc->err_mask is not set, in ata_eh_finish()
4006 * scmd->allowed, so upper layer is guaranteed in ata_eh_finish()
4015 WARN_ON(ap->nr_active_links); in ata_eh_finish()
4016 ap->nr_active_links = 0; in ata_eh_finish()
4020 * ata_do_eh - do standard error handling
4046 ata_for_each_dev(dev, &ap->link, ALL) in ata_do_eh()
4054 * ata_std_error_handler - standard error handler
4064 struct ata_port_operations *ops = ap->ops; in ata_std_error_handler()
4065 ata_reset_fn_t hardreset = ops->hardreset; in ata_std_error_handler()
4067 /* ignore built-in hardreset if SCR access is not available */ in ata_std_error_handler()
4068 if (hardreset == sata_std_hardreset && !sata_scr_valid(&ap->link)) in ata_std_error_handler()
4071 ata_do_eh(ap, ops->prereset, ops->softreset, hardreset, ops->postreset); in ata_std_error_handler()
4077 * ata_eh_handle_port_suspend - perform port suspend operation
4093 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
4094 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_suspend()
4095 ap->pm_mesg.event & PM_EVENT_RESUME) { in ata_eh_handle_port_suspend()
4096 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4099 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4101 WARN_ON(ap->pflags & ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_suspend()
4111 if (!(ap->pm_mesg.event & PM_EVENT_FREEZE)) { in ata_eh_handle_port_suspend()
4124 if (PMSG_IS_AUTO(ap->pm_mesg)) { in ata_eh_handle_port_suspend()
4125 ata_for_each_dev(dev, &ap->link, ENABLED) { in ata_eh_handle_port_suspend()
4134 if (ap->ops->port_suspend) in ata_eh_handle_port_suspend()
4135 rc = ap->ops->port_suspend(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
4137 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
4140 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
4142 ap->pflags &= ~ATA_PFLAG_PM_PENDING; in ata_eh_handle_port_suspend()
4144 ap->pflags |= ATA_PFLAG_SUSPENDED; in ata_eh_handle_port_suspend()
4148 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4154 * ata_eh_handle_port_resume - perform port resume operation
4169 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
4170 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_resume()
4171 !(ap->pm_mesg.event & PM_EVENT_RESUME)) { in ata_eh_handle_port_resume()
4172 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
4175 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
4177 WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED)); in ata_eh_handle_port_resume()
4188 ata_ering_clear(&dev->ering); in ata_eh_handle_port_resume()
4190 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_resume()
4192 if (ap->ops->port_resume) in ata_eh_handle_port_resume()
4193 ap->ops->port_resume(ap); in ata_eh_handle_port_resume()
4199 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
4200 ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_resume()
4201 ap->pflags |= ATA_PFLAG_RESUMING; in ata_eh_handle_port_resume()
4202 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()