Lines Matching refs:ap

155 static void __ata_port_freeze(struct ata_port *ap);
159 static void ata_eh_handle_port_suspend(struct ata_port *ap);
160 static void ata_eh_handle_port_resume(struct ata_port *ap);
162 static void ata_eh_handle_port_suspend(struct ata_port *ap) in ata_eh_handle_port_suspend() argument
165 static void ata_eh_handle_port_resume(struct ata_port *ap) in ata_eh_handle_port_resume() argument
250 void ata_port_desc(struct ata_port *ap, const char *fmt, ...) in ata_port_desc() argument
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()
281 void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset, in ata_port_pbar_desc() argument
284 struct pci_dev *pdev = to_pci_dev(ap->host->dev); in ata_port_pbar_desc()
297 ata_port_desc(ap, "%s %s%llu@0x%llx", name, type, len, start); in ata_port_pbar_desc()
299 ata_port_desc(ap, "%s 0x%llx", name, in ata_port_pbar_desc()
473 void ata_eh_acquire(struct ata_port *ap) in ata_eh_acquire() argument
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()
490 void ata_eh_release(struct ata_port *ap) in ata_eh_release() argument
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()
497 static void ata_eh_unload(struct ata_port *ap) in ata_eh_unload() argument
508 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_unload()
518 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_unload()
525 spin_lock_irqsave(ap->lock, flags); in ata_eh_unload()
527 ata_port_freeze(ap); /* won't be thawed */ in ata_eh_unload()
528 ap->pflags &= ~ATA_PFLAG_EH_PENDING; /* clear pending from freeze */ in ata_eh_unload()
529 ap->pflags |= ATA_PFLAG_UNLOADED; in ata_eh_unload()
531 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_unload()
548 struct ata_port *ap = ata_shost_to_port(host); in ata_scsi_error() local
556 ata_scsi_cmd_error_handler(host, ap, &eh_work_q); in ata_scsi_error()
560 ata_scsi_port_error_handler(host, ap); in ata_scsi_error()
577 void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, in ata_scsi_cmd_error_handler() argument
586 ata_sff_flush_pio_task(ap); in ata_scsi_cmd_error_handler()
603 spin_lock_irqsave(ap->lock, flags); in ata_scsi_cmd_error_handler()
615 if (ap->ops->lost_interrupt) in ata_scsi_cmd_error_handler()
616 ap->ops->lost_interrupt(ap); in ata_scsi_cmd_error_handler()
621 ata_qc_for_each_raw(ap, qc, i) { in ata_scsi_cmd_error_handler()
641 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in ata_scsi_cmd_error_handler()
653 __ata_port_freeze(ap); in ata_scsi_cmd_error_handler()
656 ap->eh_tries = ATA_EH_MAX_TRIES; in ata_scsi_cmd_error_handler()
658 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_cmd_error_handler()
670 void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap) in ata_scsi_port_error_handler() argument
676 ata_eh_acquire(ap); in ata_scsi_port_error_handler()
679 del_timer_sync(&ap->fastdrain_timer); in ata_scsi_port_error_handler()
682 ata_eh_handle_port_resume(ap); in ata_scsi_port_error_handler()
685 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
687 ata_for_each_link(link, ap, HOST_FIRST) { in ata_scsi_port_error_handler()
703 if (ap->pflags & ATA_PFLAG_RESUMING) in ata_scsi_port_error_handler()
708 ap->pflags |= ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
709 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
710 ap->excl_link = NULL; /* don't maintain exclusion over EH */ in ata_scsi_port_error_handler()
712 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
715 if (!(ap->pflags & (ATA_PFLAG_UNLOADING | ATA_PFLAG_SUSPENDED))) in ata_scsi_port_error_handler()
716 ap->ops->error_handler(ap); in ata_scsi_port_error_handler()
719 if ((ap->pflags & ATA_PFLAG_UNLOADING) && in ata_scsi_port_error_handler()
720 !(ap->pflags & ATA_PFLAG_UNLOADED)) in ata_scsi_port_error_handler()
721 ata_eh_unload(ap); in ata_scsi_port_error_handler()
722 ata_eh_finish(ap); in ata_scsi_port_error_handler()
726 ata_eh_handle_port_suspend(ap); in ata_scsi_port_error_handler()
732 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
734 if (ap->pflags & ATA_PFLAG_EH_PENDING) { in ata_scsi_port_error_handler()
735 if (--ap->eh_tries) { in ata_scsi_port_error_handler()
736 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
739 ata_port_err(ap, in ata_scsi_port_error_handler()
742 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
746 ata_for_each_link(link, ap, HOST_FIRST) in ata_scsi_port_error_handler()
754 ap->ops->end_eh(ap); in ata_scsi_port_error_handler()
756 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
757 ata_eh_release(ap); in ata_scsi_port_error_handler()
759 scsi_eh_flush_done_q(&ap->eh_done_q); in ata_scsi_port_error_handler()
762 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
764 ap->pflags &= ~ATA_PFLAG_RESUMING; in ata_scsi_port_error_handler()
766 if (ap->pflags & ATA_PFLAG_LOADING) in ata_scsi_port_error_handler()
767 ap->pflags &= ~ATA_PFLAG_LOADING; in ata_scsi_port_error_handler()
768 else if ((ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) && in ata_scsi_port_error_handler()
769 !(ap->flags & ATA_FLAG_SAS_HOST)) in ata_scsi_port_error_handler()
770 schedule_delayed_work(&ap->hotplug_task, 0); in ata_scsi_port_error_handler()
772 if (ap->pflags & ATA_PFLAG_RECOVERED) in ata_scsi_port_error_handler()
773 ata_port_info(ap, "EH complete\n"); in ata_scsi_port_error_handler()
775 ap->pflags &= ~(ATA_PFLAG_SCSI_HOTPLUG | ATA_PFLAG_RECOVERED); in ata_scsi_port_error_handler()
778 ap->pflags &= ~ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
779 wake_up_all(&ap->eh_wait_q); in ata_scsi_port_error_handler()
781 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
794 void ata_port_wait_eh(struct ata_port *ap) in ata_port_wait_eh() argument
800 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
802 while (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS)) { in ata_port_wait_eh()
803 prepare_to_wait(&ap->eh_wait_q, &wait, TASK_UNINTERRUPTIBLE); in ata_port_wait_eh()
804 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
806 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
808 finish_wait(&ap->eh_wait_q, &wait); in ata_port_wait_eh()
810 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
813 if (scsi_host_in_recovery(ap->scsi_host)) { in ata_port_wait_eh()
814 ata_msleep(ap, 10); in ata_port_wait_eh()
820 static unsigned int ata_eh_nr_in_flight(struct ata_port *ap) in ata_eh_nr_in_flight() argument
827 ata_qc_for_each(ap, qc, tag) { in ata_eh_nr_in_flight()
837 struct ata_port *ap = from_timer(ap, t, fastdrain_timer); in ata_eh_fastdrain_timerfn() local
841 spin_lock_irqsave(ap->lock, flags); in ata_eh_fastdrain_timerfn()
843 cnt = ata_eh_nr_in_flight(ap); in ata_eh_fastdrain_timerfn()
849 if (cnt == ap->fastdrain_cnt) { in ata_eh_fastdrain_timerfn()
856 ata_qc_for_each(ap, qc, tag) { in ata_eh_fastdrain_timerfn()
861 ata_port_freeze(ap); in ata_eh_fastdrain_timerfn()
864 ap->fastdrain_cnt = cnt; in ata_eh_fastdrain_timerfn()
865 ap->fastdrain_timer.expires = in ata_eh_fastdrain_timerfn()
867 add_timer(&ap->fastdrain_timer); in ata_eh_fastdrain_timerfn()
871 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_fastdrain_timerfn()
886 static void ata_eh_set_pending(struct ata_port *ap, int fastdrain) in ata_eh_set_pending() argument
891 if (ap->pflags & ATA_PFLAG_EH_PENDING) in ata_eh_set_pending()
894 ap->pflags |= ATA_PFLAG_EH_PENDING; in ata_eh_set_pending()
900 cnt = ata_eh_nr_in_flight(ap); in ata_eh_set_pending()
905 ap->fastdrain_cnt = cnt; in ata_eh_set_pending()
906 ap->fastdrain_timer.expires = in ata_eh_set_pending()
908 add_timer(&ap->fastdrain_timer); in ata_eh_set_pending()
923 struct ata_port *ap = qc->ap; in ata_qc_schedule_eh() local
926 ata_eh_set_pending(ap, 1); in ata_qc_schedule_eh()
943 void ata_std_sched_eh(struct ata_port *ap) in ata_std_sched_eh() argument
945 if (ap->pflags & ATA_PFLAG_INITIALIZING) in ata_std_sched_eh()
948 ata_eh_set_pending(ap, 1); in ata_std_sched_eh()
949 scsi_schedule_eh(ap->scsi_host); in ata_std_sched_eh()
951 trace_ata_std_sched_eh(ap); in ata_std_sched_eh()
967 void ata_std_end_eh(struct ata_port *ap) in ata_std_end_eh() argument
969 struct Scsi_Host *host = ap->scsi_host; in ata_std_end_eh()
986 void ata_port_schedule_eh(struct ata_port *ap) in ata_port_schedule_eh() argument
989 ap->ops->sched_eh(ap); in ata_port_schedule_eh()
993 static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link) in ata_do_link_abort() argument
999 ata_eh_set_pending(ap, 0); in ata_do_link_abort()
1002 ata_qc_for_each_with_internal(ap, qc, tag) { in ata_do_link_abort()
1011 ata_port_schedule_eh(ap); in ata_do_link_abort()
1030 return ata_do_link_abort(link->ap, link); in ata_link_abort()
1046 int ata_port_abort(struct ata_port *ap) in ata_port_abort() argument
1048 return ata_do_link_abort(ap, NULL); in ata_port_abort()
1070 static void __ata_port_freeze(struct ata_port *ap) in __ata_port_freeze() argument
1072 if (ap->ops->freeze) in __ata_port_freeze()
1073 ap->ops->freeze(ap); in __ata_port_freeze()
1075 ap->pflags |= ATA_PFLAG_FROZEN; in __ata_port_freeze()
1077 trace_ata_port_freeze(ap); in __ata_port_freeze()
1094 int ata_port_freeze(struct ata_port *ap) in ata_port_freeze() argument
1096 __ata_port_freeze(ap); in ata_port_freeze()
1098 return ata_port_abort(ap); in ata_port_freeze()
1111 void ata_eh_freeze_port(struct ata_port *ap) in ata_eh_freeze_port() argument
1115 spin_lock_irqsave(ap->lock, flags); in ata_eh_freeze_port()
1116 __ata_port_freeze(ap); in ata_eh_freeze_port()
1117 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_freeze_port()
1130 void ata_eh_thaw_port(struct ata_port *ap) in ata_eh_thaw_port() argument
1134 spin_lock_irqsave(ap->lock, flags); in ata_eh_thaw_port()
1136 ap->pflags &= ~ATA_PFLAG_FROZEN; in ata_eh_thaw_port()
1138 if (ap->ops->thaw) in ata_eh_thaw_port()
1139 ap->ops->thaw(ap); in ata_eh_thaw_port()
1141 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_thaw_port()
1143 trace_ata_port_thaw(ap); in ata_eh_thaw_port()
1153 struct ata_port *ap = qc->ap; in __ata_eh_qc_complete() local
1157 spin_lock_irqsave(ap->lock, flags); in __ata_eh_qc_complete()
1161 spin_unlock_irqrestore(ap->lock, flags); in __ata_eh_qc_complete()
1163 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in __ata_eh_qc_complete()
1237 struct ata_port *ap = link->ap; in ata_eh_detach_dev() local
1250 spin_lock_irqsave(ap->lock, flags); in ata_eh_detach_dev()
1256 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_detach_dev()
1265 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_detach_dev()
1284 struct ata_port *ap = link->ap; in ata_eh_about_to_do() local
1291 spin_lock_irqsave(ap->lock, flags); in ata_eh_about_to_do()
1298 if (!(ehc->i.flags & ATA_EHI_QUIET) && link != ap->slave_link) in ata_eh_about_to_do()
1299 ap->pflags |= ATA_PFLAG_RECOVERED; in ata_eh_about_to_do()
1301 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_about_to_do()
1416 if (ata_port_is_frozen(qc->ap)) { in ata_eh_request_sense()
1471 struct ata_port *ap = dev->link->ap; in atapi_eh_request_sense() local
1489 if (ap->flags & ATA_FLAG_PIO_DMA) { in atapi_eh_request_sense()
1610 if (!ata_port_is_frozen(qc->ap)) { in ata_eh_analyze_tf()
1868 (link->ap->cbl != ATA_CBL_SATA || dev->class == ATA_DEV_ATAPI) && in ata_eh_speed_down()
1921 struct ata_port *ap = link->ap; in ata_eh_read_sense_success_non_ncq() local
1924 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_read_sense_success_non_ncq()
1950 struct ata_port *ap = link->ap; in ata_eh_get_success_sense() local
1958 if (ata_port_is_frozen(ap)) { in ata_eh_get_success_sense()
1990 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_get_success_sense()
2025 struct ata_port *ap = link->ap; in ata_eh_link_autopsy() local
2066 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_autopsy()
2118 if (ata_port_is_frozen(ap) || in ata_eh_link_autopsy()
2136 ap->link.eh_context.i.err_mask |= AC_ERR_TIMEOUT; in ata_eh_link_autopsy()
2162 void ata_eh_autopsy(struct ata_port *ap) in ata_eh_autopsy() argument
2166 ata_for_each_link(link, ap, EDGE) in ata_eh_autopsy()
2173 if (ap->slave_link) { in ata_eh_autopsy()
2174 struct ata_eh_context *mehc = &ap->link.eh_context; in ata_eh_autopsy()
2175 struct ata_eh_context *sehc = &ap->slave_link->eh_context; in ata_eh_autopsy()
2181 ata_eh_link_autopsy(ap->slave_link); in ata_eh_autopsy()
2184 ata_eh_about_to_do(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2188 ata_eh_done(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2194 if (sata_pmp_attached(ap)) in ata_eh_autopsy()
2195 ata_eh_link_autopsy(&ap->link); in ata_eh_autopsy()
2331 struct ata_port *ap = link->ap; in ata_eh_link_report() local
2345 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2361 if (ata_port_is_frozen(ap)) in ata_eh_link_report()
2364 if (ap->eh_tries < ATA_EH_MAX_TRIES) in ata_eh_link_report()
2366 ap->eh_tries); in ata_eh_link_report()
2407 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2524 void ata_eh_report(struct ata_port *ap) in ata_eh_report() argument
2528 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_report()
2551 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) in ata_eh_followup_srst_needed()
2560 struct ata_port *ap = link->ap; in ata_eh_reset() local
2561 struct ata_link *slave = ap->slave_link; in ata_eh_reset()
2598 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2599 ap->pflags |= ATA_PFLAG_RESETTING; in ata_eh_reset()
2600 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2620 if (ap->ops->set_piomode) in ata_eh_reset()
2621 ap->ops->set_piomode(ap, dev); in ata_eh_reset()
2682 if (ata_port_is_frozen(ap) && ata_is_host_link(link)) in ata_eh_reset()
2683 ata_eh_thaw_port(ap); in ata_eh_reset()
2694 ata_eh_freeze_port(ap); in ata_eh_reset()
2808 ata_eh_thaw_port(ap); in ata_eh_reset()
2827 spin_lock_irqsave(link->ap->lock, flags); in ata_eh_reset()
2831 spin_unlock_irqrestore(link->ap->lock, flags); in ata_eh_reset()
2891 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2892 ap->pflags &= ~ATA_PFLAG_RESETTING; in ata_eh_reset()
2893 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2911 ata_eh_thaw_port(ap); in ata_eh_reset()
2923 ata_eh_release(ap); in ata_eh_reset()
2926 ata_eh_acquire(ap); in ata_eh_reset()
2935 ata_eh_thaw_port(ap); in ata_eh_reset()
2951 static inline void ata_eh_pull_park_action(struct ata_port *ap) in ata_eh_pull_park_action() argument
2983 spin_lock_irqsave(ap->lock, flags); in ata_eh_pull_park_action()
2984 reinit_completion(&ap->park_req_pending); in ata_eh_pull_park_action()
2985 ata_for_each_link(link, ap, EDGE) { in ata_eh_pull_park_action()
2994 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_pull_park_action()
3028 struct ata_port *ap = link->ap; in ata_eh_revalidate_and_attach() local
3094 schedule_delayed_work(&ap->scsi_rescan_task, 0); in ata_eh_revalidate_and_attach()
3127 ata_eh_thaw_port(ap); in ata_eh_revalidate_and_attach()
3137 if (ap->ops->cable_detect) in ata_eh_revalidate_and_attach()
3138 ap->cbl = ap->ops->cable_detect(ap); in ata_eh_revalidate_and_attach()
3139 ata_force_cbl(ap); in ata_eh_revalidate_and_attach()
3162 spin_lock_irqsave(ap->lock, flags); in ata_eh_revalidate_and_attach()
3163 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_revalidate_and_attach()
3164 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_revalidate_and_attach()
3194 struct ata_port *ap = link->ap; in ata_set_mode() local
3210 if (ap->ops->set_mode) in ata_set_mode()
3211 rc = ap->ops->set_mode(link, r_failed_dev); in ata_set_mode()
3248 u8 *sense_buffer = dev->link->ap->sector_buf; in atapi_eh_clear_ua()
3297 struct ata_port *ap = link->ap; in ata_eh_maybe_retry_flush() local
3307 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_maybe_retry_flush()
3346 if (!ata_port_is_frozen(ap)) in ata_eh_maybe_retry_flush()
3373 struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL; in ata_eh_set_lpm() local
3377 bool no_dipm = link->ap->flags & ATA_FLAG_NO_DIPM; in ata_eh_set_lpm()
3384 (link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm)) in ata_eh_set_lpm()
3422 if (ap) { in ata_eh_set_lpm()
3423 rc = ap->ops->set_lpm(link, policy, hints); in ata_eh_set_lpm()
3424 if (!rc && ap->slave_link) in ata_eh_set_lpm()
3425 rc = ap->ops->set_lpm(ap->slave_link, policy, hints); in ata_eh_set_lpm()
3447 if (ap && ap->slave_link) in ata_eh_set_lpm()
3448 ap->slave_link->lpm_policy = policy; in ata_eh_set_lpm()
3474 if (ap && ap->slave_link) in ata_eh_set_lpm()
3475 ap->slave_link->lpm_policy = old_policy; in ata_eh_set_lpm()
3510 struct ata_port *ap = link->ap; in ata_eh_skip_recovery() local
3523 if (ata_port_is_frozen(ap) || ata_link_nr_enabled(link)) in ata_eh_skip_recovery()
3575 link->ap->ops->set_lpm(link, ATA_LPM_MAX_POWER, in ata_eh_schedule_probe()
3678 int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_eh_recover() argument
3689 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3695 spin_lock_irqsave(ap->lock, flags); in ata_eh_recover()
3697 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_recover()
3726 if (ap->pflags & ATA_PFLAG_UNLOADING) in ata_eh_recover()
3730 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3742 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3763 ata_eh_pull_park_action(ap); in ata_eh_recover()
3766 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3793 ata_eh_release(ap); in ata_eh_recover()
3794 deadline = wait_for_completion_timeout(&ap->park_req_pending, in ata_eh_recover()
3796 ata_eh_acquire(ap); in ata_eh_recover()
3798 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3811 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_recover()
3814 if (sata_pmp_attached(ap) && ata_is_host_link(link)) in ata_eh_recover()
3863 if (link->lpm_policy != ap->target_lpm_policy) { in ata_eh_recover()
3864 rc = ata_eh_set_lpm(link, ap->target_lpm_policy, &dev); in ata_eh_recover()
3878 if (ata_port_is_frozen(ap)) { in ata_eh_recover()
3882 if (sata_pmp_attached(ap)) in ata_eh_recover()
3908 void ata_eh_finish(struct ata_port *ap) in ata_eh_finish() argument
3914 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_finish()
3953 WARN_ON(ap->nr_active_links); in ata_eh_finish()
3954 ap->nr_active_links = 0; in ata_eh_finish()
3971 void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_do_eh() argument
3978 ata_eh_autopsy(ap); in ata_do_eh()
3979 ata_eh_report(ap); in ata_do_eh()
3981 rc = ata_eh_recover(ap, prereset, softreset, hardreset, postreset, in ata_do_eh()
3984 ata_for_each_dev(dev, &ap->link, ALL) in ata_do_eh()
3988 ata_eh_finish(ap); in ata_do_eh()
4000 void ata_std_error_handler(struct ata_port *ap) in ata_std_error_handler() argument
4002 struct ata_port_operations *ops = ap->ops; in ata_std_error_handler()
4006 if (hardreset == sata_std_hardreset && !sata_scr_valid(&ap->link)) in ata_std_error_handler()
4009 ata_do_eh(ap, ops->prereset, ops->softreset, hardreset, ops->postreset); in ata_std_error_handler()
4023 static void ata_eh_handle_port_suspend(struct ata_port *ap) in ata_eh_handle_port_suspend() argument
4031 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
4032 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_suspend()
4033 ap->pm_mesg.event & PM_EVENT_RESUME) { in ata_eh_handle_port_suspend()
4034 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4037 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4039 WARN_ON(ap->pflags & ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_suspend()
4042 ata_for_each_link(link, ap, HOST_FIRST) { in ata_eh_handle_port_suspend()
4052 if (PMSG_IS_AUTO(ap->pm_mesg)) { in ata_eh_handle_port_suspend()
4053 ata_for_each_dev(dev, &ap->link, ENABLED) { in ata_eh_handle_port_suspend()
4060 ata_eh_freeze_port(ap); in ata_eh_handle_port_suspend()
4062 if (ap->ops->port_suspend) in ata_eh_handle_port_suspend()
4063 rc = ap->ops->port_suspend(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
4065 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
4068 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
4070 ap->pflags &= ~ATA_PFLAG_PM_PENDING; in ata_eh_handle_port_suspend()
4072 ap->pflags |= ATA_PFLAG_SUSPENDED; in ata_eh_handle_port_suspend()
4073 else if (ata_port_is_frozen(ap)) in ata_eh_handle_port_suspend()
4074 ata_port_schedule_eh(ap); in ata_eh_handle_port_suspend()
4076 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4090 static void ata_eh_handle_port_resume(struct ata_port *ap) in ata_eh_handle_port_resume() argument
4097 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
4098 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_resume()
4099 !(ap->pm_mesg.event & PM_EVENT_RESUME)) { in ata_eh_handle_port_resume()
4100 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
4103 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
4105 WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED)); in ata_eh_handle_port_resume()
4114 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_handle_port_resume()
4118 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_resume()
4120 if (ap->ops->port_resume) in ata_eh_handle_port_resume()
4121 ap->ops->port_resume(ap); in ata_eh_handle_port_resume()
4124 ata_acpi_on_resume(ap); in ata_eh_handle_port_resume()
4127 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
4128 ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_resume()
4129 ap->pflags |= ATA_PFLAG_RESUMING; in ata_eh_handle_port_resume()
4130 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()