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()
629 ata_qc_for_each_raw(ap, qc, i) { in ata_scsi_cmd_error_handler()
650 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in ata_scsi_cmd_error_handler()
662 __ata_port_freeze(ap); in ata_scsi_cmd_error_handler()
665 ap->eh_tries = ATA_EH_MAX_TRIES; in ata_scsi_cmd_error_handler()
667 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_cmd_error_handler()
679 void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap) in ata_scsi_port_error_handler() argument
685 ata_eh_acquire(ap); in ata_scsi_port_error_handler()
688 del_timer_sync(&ap->fastdrain_timer); in ata_scsi_port_error_handler()
691 ata_eh_handle_port_resume(ap); in ata_scsi_port_error_handler()
694 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
696 ata_for_each_link(link, ap, HOST_FIRST) { in ata_scsi_port_error_handler()
712 if (ap->pflags & ATA_PFLAG_RESUMING) { in ata_scsi_port_error_handler()
719 ap->pflags |= ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
720 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
721 ap->excl_link = NULL; /* don't maintain exclusion over EH */ in ata_scsi_port_error_handler()
723 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
726 if (!(ap->pflags & (ATA_PFLAG_UNLOADING | ATA_PFLAG_SUSPENDED))) in ata_scsi_port_error_handler()
727 ap->ops->error_handler(ap); in ata_scsi_port_error_handler()
730 if ((ap->pflags & ATA_PFLAG_UNLOADING) && in ata_scsi_port_error_handler()
731 !(ap->pflags & ATA_PFLAG_UNLOADED)) in ata_scsi_port_error_handler()
732 ata_eh_unload(ap); in ata_scsi_port_error_handler()
733 ata_eh_finish(ap); in ata_scsi_port_error_handler()
737 ata_eh_handle_port_suspend(ap); in ata_scsi_port_error_handler()
743 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
745 if (ap->pflags & ATA_PFLAG_EH_PENDING) { in ata_scsi_port_error_handler()
746 if (--ap->eh_tries) { in ata_scsi_port_error_handler()
747 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
750 ata_port_err(ap, in ata_scsi_port_error_handler()
753 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
757 ata_for_each_link(link, ap, HOST_FIRST) in ata_scsi_port_error_handler()
765 ap->ops->end_eh(ap); in ata_scsi_port_error_handler()
767 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
768 ata_eh_release(ap); in ata_scsi_port_error_handler()
770 scsi_eh_flush_done_q(&ap->eh_done_q); in ata_scsi_port_error_handler()
773 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
775 ap->pflags &= ~ATA_PFLAG_RESUMING; in ata_scsi_port_error_handler()
777 if (ap->pflags & ATA_PFLAG_LOADING) in ata_scsi_port_error_handler()
778 ap->pflags &= ~ATA_PFLAG_LOADING; in ata_scsi_port_error_handler()
779 else if ((ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) && in ata_scsi_port_error_handler()
780 !(ap->flags & ATA_FLAG_SAS_HOST)) in ata_scsi_port_error_handler()
781 schedule_delayed_work(&ap->hotplug_task, 0); in ata_scsi_port_error_handler()
783 if (ap->pflags & ATA_PFLAG_RECOVERED) in ata_scsi_port_error_handler()
784 ata_port_info(ap, "EH complete\n"); in ata_scsi_port_error_handler()
786 ap->pflags &= ~(ATA_PFLAG_SCSI_HOTPLUG | ATA_PFLAG_RECOVERED); in ata_scsi_port_error_handler()
789 ap->pflags &= ~ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
790 wake_up_all(&ap->eh_wait_q); in ata_scsi_port_error_handler()
792 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
805 void ata_port_wait_eh(struct ata_port *ap) in ata_port_wait_eh() argument
811 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
813 while (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS)) { in ata_port_wait_eh()
814 prepare_to_wait(&ap->eh_wait_q, &wait, TASK_UNINTERRUPTIBLE); in ata_port_wait_eh()
815 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
817 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
819 finish_wait(&ap->eh_wait_q, &wait); in ata_port_wait_eh()
821 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
824 if (scsi_host_in_recovery(ap->scsi_host)) { in ata_port_wait_eh()
825 ata_msleep(ap, 10); in ata_port_wait_eh()
831 static unsigned int ata_eh_nr_in_flight(struct ata_port *ap) in ata_eh_nr_in_flight() argument
838 ata_qc_for_each(ap, qc, tag) { in ata_eh_nr_in_flight()
848 struct ata_port *ap = from_timer(ap, t, fastdrain_timer); in ata_eh_fastdrain_timerfn() local
852 spin_lock_irqsave(ap->lock, flags); in ata_eh_fastdrain_timerfn()
854 cnt = ata_eh_nr_in_flight(ap); in ata_eh_fastdrain_timerfn()
860 if (cnt == ap->fastdrain_cnt) { in ata_eh_fastdrain_timerfn()
867 ata_qc_for_each(ap, qc, tag) { in ata_eh_fastdrain_timerfn()
872 ata_port_freeze(ap); in ata_eh_fastdrain_timerfn()
875 ap->fastdrain_cnt = cnt; in ata_eh_fastdrain_timerfn()
876 ap->fastdrain_timer.expires = in ata_eh_fastdrain_timerfn()
878 add_timer(&ap->fastdrain_timer); in ata_eh_fastdrain_timerfn()
882 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_fastdrain_timerfn()
897 static void ata_eh_set_pending(struct ata_port *ap, int fastdrain) in ata_eh_set_pending() argument
902 if (ap->pflags & ATA_PFLAG_EH_PENDING) in ata_eh_set_pending()
905 ap->pflags |= ATA_PFLAG_EH_PENDING; in ata_eh_set_pending()
911 cnt = ata_eh_nr_in_flight(ap); in ata_eh_set_pending()
916 ap->fastdrain_cnt = cnt; in ata_eh_set_pending()
917 ap->fastdrain_timer.expires = in ata_eh_set_pending()
919 add_timer(&ap->fastdrain_timer); in ata_eh_set_pending()
934 struct ata_port *ap = qc->ap; in ata_qc_schedule_eh() local
937 ata_eh_set_pending(ap, 1); in ata_qc_schedule_eh()
954 void ata_std_sched_eh(struct ata_port *ap) in ata_std_sched_eh() argument
956 if (ap->pflags & ATA_PFLAG_INITIALIZING) in ata_std_sched_eh()
959 ata_eh_set_pending(ap, 1); in ata_std_sched_eh()
960 scsi_schedule_eh(ap->scsi_host); in ata_std_sched_eh()
962 trace_ata_std_sched_eh(ap); in ata_std_sched_eh()
978 void ata_std_end_eh(struct ata_port *ap) in ata_std_end_eh() argument
980 struct Scsi_Host *host = ap->scsi_host; in ata_std_end_eh()
997 void ata_port_schedule_eh(struct ata_port *ap) in ata_port_schedule_eh() argument
1000 ap->ops->sched_eh(ap); in ata_port_schedule_eh()
1004 static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link) in ata_do_link_abort() argument
1010 ata_eh_set_pending(ap, 0); in ata_do_link_abort()
1013 ata_qc_for_each_with_internal(ap, qc, tag) { in ata_do_link_abort()
1022 ata_port_schedule_eh(ap); in ata_do_link_abort()
1041 return ata_do_link_abort(link->ap, link); in ata_link_abort()
1057 int ata_port_abort(struct ata_port *ap) in ata_port_abort() argument
1059 return ata_do_link_abort(ap, NULL); in ata_port_abort()
1081 static void __ata_port_freeze(struct ata_port *ap) in __ata_port_freeze() argument
1083 if (ap->ops->freeze) in __ata_port_freeze()
1084 ap->ops->freeze(ap); in __ata_port_freeze()
1086 ap->pflags |= ATA_PFLAG_FROZEN; in __ata_port_freeze()
1088 trace_ata_port_freeze(ap); in __ata_port_freeze()
1105 int ata_port_freeze(struct ata_port *ap) in ata_port_freeze() argument
1107 __ata_port_freeze(ap); in ata_port_freeze()
1109 return ata_port_abort(ap); in ata_port_freeze()
1122 void ata_eh_freeze_port(struct ata_port *ap) in ata_eh_freeze_port() argument
1126 spin_lock_irqsave(ap->lock, flags); in ata_eh_freeze_port()
1127 __ata_port_freeze(ap); in ata_eh_freeze_port()
1128 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_freeze_port()
1141 void ata_eh_thaw_port(struct ata_port *ap) in ata_eh_thaw_port() argument
1145 spin_lock_irqsave(ap->lock, flags); in ata_eh_thaw_port()
1147 ap->pflags &= ~ATA_PFLAG_FROZEN; in ata_eh_thaw_port()
1149 if (ap->ops->thaw) in ata_eh_thaw_port()
1150 ap->ops->thaw(ap); in ata_eh_thaw_port()
1152 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_thaw_port()
1154 trace_ata_port_thaw(ap); in ata_eh_thaw_port()
1164 struct ata_port *ap = qc->ap; in __ata_eh_qc_complete() local
1168 spin_lock_irqsave(ap->lock, flags); in __ata_eh_qc_complete()
1172 spin_unlock_irqrestore(ap->lock, flags); in __ata_eh_qc_complete()
1174 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in __ata_eh_qc_complete()
1248 struct ata_port *ap = link->ap; in ata_eh_detach_dev() local
1261 spin_lock_irqsave(ap->lock, flags); in ata_eh_detach_dev()
1267 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_detach_dev()
1276 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_detach_dev()
1295 struct ata_port *ap = link->ap; in ata_eh_about_to_do() local
1302 spin_lock_irqsave(ap->lock, flags); in ata_eh_about_to_do()
1309 if (!(ehc->i.flags & ATA_EHI_QUIET) && link != ap->slave_link) in ata_eh_about_to_do()
1310 ap->pflags |= ATA_PFLAG_RECOVERED; in ata_eh_about_to_do()
1312 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_about_to_do()
1427 if (ata_port_is_frozen(qc->ap)) { in ata_eh_request_sense()
1482 struct ata_port *ap = dev->link->ap; in atapi_eh_request_sense() local
1500 if (ap->flags & ATA_FLAG_PIO_DMA) { in atapi_eh_request_sense()
1621 if (!ata_port_is_frozen(qc->ap)) { in ata_eh_analyze_tf()
1879 (link->ap->cbl != ATA_CBL_SATA || dev->class == ATA_DEV_ATAPI) && in ata_eh_speed_down()
1932 struct ata_port *ap = link->ap; in ata_eh_read_sense_success_non_ncq() local
1935 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_read_sense_success_non_ncq()
1961 struct ata_port *ap = link->ap; in ata_eh_get_success_sense() local
1969 if (ata_port_is_frozen(ap)) { in ata_eh_get_success_sense()
2001 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_get_success_sense()
2036 struct ata_port *ap = link->ap; in ata_eh_link_autopsy() local
2077 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_autopsy()
2129 if (ata_port_is_frozen(ap) || in ata_eh_link_autopsy()
2147 ap->link.eh_context.i.err_mask |= AC_ERR_TIMEOUT; in ata_eh_link_autopsy()
2173 void ata_eh_autopsy(struct ata_port *ap) in ata_eh_autopsy() argument
2177 ata_for_each_link(link, ap, EDGE) in ata_eh_autopsy()
2184 if (ap->slave_link) { in ata_eh_autopsy()
2185 struct ata_eh_context *mehc = &ap->link.eh_context; in ata_eh_autopsy()
2186 struct ata_eh_context *sehc = &ap->slave_link->eh_context; in ata_eh_autopsy()
2192 ata_eh_link_autopsy(ap->slave_link); in ata_eh_autopsy()
2195 ata_eh_about_to_do(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2199 ata_eh_done(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2205 if (sata_pmp_attached(ap)) in ata_eh_autopsy()
2206 ata_eh_link_autopsy(&ap->link); in ata_eh_autopsy()
2342 struct ata_port *ap = link->ap; in ata_eh_link_report() local
2356 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2372 if (ata_port_is_frozen(ap)) in ata_eh_link_report()
2375 if (ap->eh_tries < ATA_EH_MAX_TRIES) in ata_eh_link_report()
2377 ap->eh_tries); in ata_eh_link_report()
2418 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2535 void ata_eh_report(struct ata_port *ap) in ata_eh_report() argument
2539 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_report()
2562 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) in ata_eh_followup_srst_needed()
2571 struct ata_port *ap = link->ap; in ata_eh_reset() local
2572 struct ata_link *slave = ap->slave_link; in ata_eh_reset()
2609 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2610 ap->pflags |= ATA_PFLAG_RESETTING; in ata_eh_reset()
2611 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2631 if (ap->ops->set_piomode) in ata_eh_reset()
2632 ap->ops->set_piomode(ap, dev); in ata_eh_reset()
2693 if (ata_port_is_frozen(ap) && ata_is_host_link(link)) in ata_eh_reset()
2694 ata_eh_thaw_port(ap); in ata_eh_reset()
2705 ata_eh_freeze_port(ap); in ata_eh_reset()
2819 ata_eh_thaw_port(ap); in ata_eh_reset()
2838 spin_lock_irqsave(link->ap->lock, flags); in ata_eh_reset()
2842 spin_unlock_irqrestore(link->ap->lock, flags); in ata_eh_reset()
2902 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2903 ap->pflags &= ~ATA_PFLAG_RESETTING; in ata_eh_reset()
2904 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2922 ata_eh_thaw_port(ap); in ata_eh_reset()
2934 ata_eh_release(ap); in ata_eh_reset()
2937 ata_eh_acquire(ap); in ata_eh_reset()
2946 ata_eh_thaw_port(ap); in ata_eh_reset()
2962 static inline void ata_eh_pull_park_action(struct ata_port *ap) in ata_eh_pull_park_action() argument
2994 spin_lock_irqsave(ap->lock, flags); in ata_eh_pull_park_action()
2995 reinit_completion(&ap->park_req_pending); in ata_eh_pull_park_action()
2996 ata_for_each_link(link, ap, EDGE) { in ata_eh_pull_park_action()
3005 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_pull_park_action()
3039 struct ata_port *ap = link->ap; in ata_eh_revalidate_and_attach() local
3105 schedule_delayed_work(&ap->scsi_rescan_task, 0); in ata_eh_revalidate_and_attach()
3138 ata_eh_thaw_port(ap); in ata_eh_revalidate_and_attach()
3148 if (ap->ops->cable_detect) in ata_eh_revalidate_and_attach()
3149 ap->cbl = ap->ops->cable_detect(ap); in ata_eh_revalidate_and_attach()
3150 ata_force_cbl(ap); in ata_eh_revalidate_and_attach()
3173 spin_lock_irqsave(ap->lock, flags); in ata_eh_revalidate_and_attach()
3174 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_revalidate_and_attach()
3175 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_revalidate_and_attach()
3206 struct ata_port *ap = link->ap; in ata_set_mode() local
3222 if (ap->ops->set_mode) in ata_set_mode()
3223 rc = ap->ops->set_mode(link, r_failed_dev); in ata_set_mode()
3260 u8 *sense_buffer = dev->link->ap->sector_buf; in atapi_eh_clear_ua()
3309 struct ata_port *ap = link->ap; in ata_eh_maybe_retry_flush() local
3319 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_maybe_retry_flush()
3358 if (!ata_port_is_frozen(ap)) in ata_eh_maybe_retry_flush()
3385 struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL; in ata_eh_set_lpm() local
3389 bool no_dipm = link->ap->flags & ATA_FLAG_NO_DIPM; in ata_eh_set_lpm()
3396 (link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm)) in ata_eh_set_lpm()
3434 if (ap) { in ata_eh_set_lpm()
3435 rc = ap->ops->set_lpm(link, policy, hints); in ata_eh_set_lpm()
3436 if (!rc && ap->slave_link) in ata_eh_set_lpm()
3437 rc = ap->ops->set_lpm(ap->slave_link, policy, hints); in ata_eh_set_lpm()
3459 if (ap && ap->slave_link) in ata_eh_set_lpm()
3460 ap->slave_link->lpm_policy = policy; in ata_eh_set_lpm()
3486 if (ap && ap->slave_link) in ata_eh_set_lpm()
3487 ap->slave_link->lpm_policy = old_policy; in ata_eh_set_lpm()
3522 struct ata_port *ap = link->ap; in ata_eh_skip_recovery() local
3535 if (ata_port_is_frozen(ap) || ata_link_nr_enabled(link)) in ata_eh_skip_recovery()
3587 link->ap->ops->set_lpm(link, ATA_LPM_MAX_POWER, in ata_eh_schedule_probe()
3690 int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_eh_recover() argument
3701 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3707 spin_lock_irqsave(ap->lock, flags); in ata_eh_recover()
3709 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_recover()
3738 if (ap->pflags & ATA_PFLAG_UNLOADING) in ata_eh_recover()
3742 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3754 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3775 ata_eh_pull_park_action(ap); in ata_eh_recover()
3778 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3805 ata_eh_release(ap); in ata_eh_recover()
3806 deadline = wait_for_completion_timeout(&ap->park_req_pending, in ata_eh_recover()
3808 ata_eh_acquire(ap); in ata_eh_recover()
3810 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3823 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_recover()
3826 if (sata_pmp_attached(ap) && ata_is_host_link(link)) in ata_eh_recover()
3875 if (link->lpm_policy != ap->target_lpm_policy) { in ata_eh_recover()
3876 rc = ata_eh_set_lpm(link, ap->target_lpm_policy, &dev); in ata_eh_recover()
3890 if (ata_port_is_frozen(ap)) { in ata_eh_recover()
3894 if (sata_pmp_attached(ap)) in ata_eh_recover()
3920 void ata_eh_finish(struct ata_port *ap) in ata_eh_finish() argument
3926 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_finish()
3965 WARN_ON(ap->nr_active_links); in ata_eh_finish()
3966 ap->nr_active_links = 0; in ata_eh_finish()
3983 void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_do_eh() argument
3990 ata_eh_autopsy(ap); in ata_do_eh()
3991 ata_eh_report(ap); in ata_do_eh()
3993 rc = ata_eh_recover(ap, prereset, softreset, hardreset, postreset, in ata_do_eh()
3996 ata_for_each_dev(dev, &ap->link, ALL) in ata_do_eh()
4000 ata_eh_finish(ap); in ata_do_eh()
4012 void ata_std_error_handler(struct ata_port *ap) in ata_std_error_handler() argument
4014 struct ata_port_operations *ops = ap->ops; in ata_std_error_handler()
4018 if (hardreset == sata_std_hardreset && !sata_scr_valid(&ap->link)) in ata_std_error_handler()
4021 ata_do_eh(ap, ops->prereset, ops->softreset, hardreset, ops->postreset); in ata_std_error_handler()
4035 static void ata_eh_handle_port_suspend(struct ata_port *ap) in ata_eh_handle_port_suspend() argument
4043 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
4044 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_suspend()
4045 ap->pm_mesg.event & PM_EVENT_RESUME) { in ata_eh_handle_port_suspend()
4046 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4049 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4051 WARN_ON(ap->pflags & ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_suspend()
4061 if (!(ap->pm_mesg.event & PM_EVENT_FREEZE)) { in ata_eh_handle_port_suspend()
4063 ata_for_each_link(link, ap, HOST_FIRST) { in ata_eh_handle_port_suspend()
4074 if (PMSG_IS_AUTO(ap->pm_mesg)) { in ata_eh_handle_port_suspend()
4075 ata_for_each_dev(dev, &ap->link, ENABLED) { in ata_eh_handle_port_suspend()
4082 ata_eh_freeze_port(ap); in ata_eh_handle_port_suspend()
4084 if (ap->ops->port_suspend) in ata_eh_handle_port_suspend()
4085 rc = ap->ops->port_suspend(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
4087 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
4090 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
4092 ap->pflags &= ~ATA_PFLAG_PM_PENDING; in ata_eh_handle_port_suspend()
4094 ap->pflags |= ATA_PFLAG_SUSPENDED; in ata_eh_handle_port_suspend()
4095 else if (ata_port_is_frozen(ap)) in ata_eh_handle_port_suspend()
4096 ata_port_schedule_eh(ap); in ata_eh_handle_port_suspend()
4098 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4112 static void ata_eh_handle_port_resume(struct ata_port *ap) in ata_eh_handle_port_resume() argument
4119 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
4120 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_resume()
4121 !(ap->pm_mesg.event & PM_EVENT_RESUME)) { in ata_eh_handle_port_resume()
4122 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
4125 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
4127 WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED)); in ata_eh_handle_port_resume()
4136 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_handle_port_resume()
4140 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_resume()
4142 if (ap->ops->port_resume) in ata_eh_handle_port_resume()
4143 ap->ops->port_resume(ap); in ata_eh_handle_port_resume()
4146 ata_acpi_on_resume(ap); in ata_eh_handle_port_resume()
4149 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
4150 ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_resume()
4151 ap->pflags |= ATA_PFLAG_RESUMING; in ata_eh_handle_port_resume()
4152 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()