Lines Matching full: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
239 * @ap: target ATA port
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()
268 * @ap: target ATA port
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()
464 * @ap: ATA port to acquire EH ownership for
466 * Acquire EH ownership for @ap. This is the basic exclusion
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()
482 * @ap: ATA port to release EH ownership for
484 * Release EH ownership for @ap if the caller. The caller must
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()
512 static void ata_eh_unload(struct ata_port *ap) in ata_eh_unload() argument
523 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_unload()
533 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_unload()
540 spin_lock_irqsave(ap->lock, flags); in ata_eh_unload()
542 ata_port_freeze(ap); /* won't be thawed */ 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()
563 struct ata_port *ap = ata_shost_to_port(host); in ata_scsi_error() local
571 ata_scsi_cmd_error_handler(host, ap, &eh_work_q); in ata_scsi_error()
575 ata_scsi_port_error_handler(host, ap); in ata_scsi_error()
585 * @ap: ATA port within the host
589 * ap->eh_done_q. This function is the first part of the libata error
592 void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, in ata_scsi_cmd_error_handler() argument
601 ata_sff_flush_pio_task(ap); 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()
630 if (ap->ops->lost_interrupt) in ata_scsi_cmd_error_handler()
631 ap->ops->lost_interrupt(ap); in ata_scsi_cmd_error_handler()
644 ata_qc_for_each_raw(ap, qc, i) { in ata_scsi_cmd_error_handler()
665 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in ata_scsi_cmd_error_handler()
677 __ata_port_freeze(ap); 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()
689 * @ap: the ATA port
691 * Handle the recovery of the port @ap after all the commands
694 void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap) in ata_scsi_port_error_handler() argument
700 ata_eh_acquire(ap); in ata_scsi_port_error_handler()
703 del_timer_sync(&ap->fastdrain_timer); in ata_scsi_port_error_handler()
706 ata_eh_handle_port_resume(ap); in ata_scsi_port_error_handler()
709 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
711 ata_for_each_link(link, ap, HOST_FIRST) { in ata_scsi_port_error_handler()
727 if (ap->pflags & ATA_PFLAG_RESUMING) { 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()
747 ata_eh_unload(ap); in ata_scsi_port_error_handler()
748 ata_eh_finish(ap); in ata_scsi_port_error_handler()
752 ata_eh_handle_port_suspend(ap); 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()
765 ata_port_err(ap, in ata_scsi_port_error_handler()
768 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
772 ata_for_each_link(link, ap, HOST_FIRST) 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()
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()
783 ata_eh_release(ap); 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()
799 ata_port_info(ap, "EH complete\n"); 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()
813 * @ap: Port to wait EH for
820 void ata_port_wait_eh(struct ata_port *ap) in ata_port_wait_eh() argument
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()
840 ata_msleep(ap, 10); in ata_port_wait_eh()
846 static unsigned int ata_eh_nr_in_flight(struct ata_port *ap) in ata_eh_nr_in_flight() argument
853 ata_qc_for_each(ap, qc, tag) { in ata_eh_nr_in_flight()
863 struct ata_port *ap = from_timer(ap, t, fastdrain_timer); in ata_eh_fastdrain_timerfn() local
867 spin_lock_irqsave(ap->lock, flags); in ata_eh_fastdrain_timerfn()
869 cnt = ata_eh_nr_in_flight(ap); in ata_eh_fastdrain_timerfn()
875 if (cnt == ap->fastdrain_cnt) { in ata_eh_fastdrain_timerfn()
882 ata_qc_for_each(ap, qc, tag) { in ata_eh_fastdrain_timerfn()
887 ata_port_freeze(ap); 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()
902 * @ap: target ATA port
912 static void ata_eh_set_pending(struct ata_port *ap, int fastdrain) in ata_eh_set_pending() argument
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()
926 cnt = ata_eh_nr_in_flight(ap); 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()
949 struct ata_port *ap = qc->ap; in ata_qc_schedule_eh() local
952 ata_eh_set_pending(ap, 1); in ata_qc_schedule_eh()
964 * @ap: ATA port to schedule EH for
969 void ata_std_sched_eh(struct ata_port *ap) in ata_std_sched_eh() argument
971 if (ap->pflags & ATA_PFLAG_INITIALIZING) in ata_std_sched_eh()
974 ata_eh_set_pending(ap, 1); in ata_std_sched_eh()
975 scsi_schedule_eh(ap->scsi_host); in ata_std_sched_eh()
977 trace_ata_std_sched_eh(ap); in ata_std_sched_eh()
983 * @ap: ATA port to end EH for
986 * shost, so host fields can be directly manipulated under ap->lock, in
993 void ata_std_end_eh(struct ata_port *ap) in ata_std_end_eh() argument
995 struct Scsi_Host *host = ap->scsi_host; in ata_std_end_eh()
1004 * @ap: ATA port to schedule EH for
1006 * Schedule error handling for @ap. EH will kick in as soon as
1012 void ata_port_schedule_eh(struct ata_port *ap) in ata_port_schedule_eh() argument
1015 ap->ops->sched_eh(ap); in ata_port_schedule_eh()
1019 static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link) in ata_do_link_abort() argument
1025 ata_eh_set_pending(ap, 0); in ata_do_link_abort()
1028 ata_qc_for_each_with_internal(ap, qc, tag) { in ata_do_link_abort()
1037 ata_port_schedule_eh(ap); in ata_do_link_abort()
1056 return ata_do_link_abort(link->ap, link); in ata_link_abort()
1062 * @ap: ATA port to abort qc's for
1064 * Abort all active qc's of @ap and schedule EH.
1072 int ata_port_abort(struct ata_port *ap) in ata_port_abort() argument
1074 return ata_do_link_abort(ap, NULL); in ata_port_abort()
1080 * @ap: ATA port to freeze
1087 * ap->ops->freeze() callback can be used for freezing the port
1096 static void __ata_port_freeze(struct ata_port *ap) in __ata_port_freeze() argument
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()
1103 trace_ata_port_freeze(ap); in __ata_port_freeze()
1108 * @ap: ATA port to freeze
1110 * Abort and freeze @ap. The freeze operation must be called
1120 int ata_port_freeze(struct ata_port *ap) in ata_port_freeze() argument
1122 __ata_port_freeze(ap); in ata_port_freeze()
1124 return ata_port_abort(ap); in ata_port_freeze()
1130 * @ap: ATA port to freeze
1132 * Freeze @ap.
1137 void ata_eh_freeze_port(struct ata_port *ap) in ata_eh_freeze_port() argument
1141 spin_lock_irqsave(ap->lock, flags); in ata_eh_freeze_port()
1142 __ata_port_freeze(ap); in ata_eh_freeze_port()
1143 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_freeze_port()
1149 * @ap: ATA port to thaw
1151 * Thaw frozen port @ap.
1156 void ata_eh_thaw_port(struct ata_port *ap) in ata_eh_thaw_port() argument
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()
1169 trace_ata_port_thaw(ap); in ata_eh_thaw_port()
1179 struct ata_port *ap = qc->ap; in __ata_eh_qc_complete() local
1183 spin_lock_irqsave(ap->lock, flags); 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()
1257 struct ata_port *ap = link->ap; in ata_eh_detach_dev() local
1270 spin_lock_irqsave(ap->lock, flags); in ata_eh_detach_dev()
1276 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_detach_dev()
1285 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_detach_dev()
1304 struct ata_port *ap = link->ap; in ata_eh_about_to_do() local
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()
1473 if (ata_port_is_frozen(qc->ap)) { in ata_eh_request_sense()
1528 struct ata_port *ap = dev->link->ap; in atapi_eh_request_sense() local
1546 if (ap->flags & ATA_FLAG_PIO_DMA) { in atapi_eh_request_sense()
1667 if (!ata_port_is_frozen(qc->ap)) { in ata_eh_analyze_tf()
1926 (link->ap->cbl != ATA_CBL_SATA || dev->class == ATA_DEV_ATAPI) && in ata_eh_speed_down()
1979 struct ata_port *ap = link->ap; in ata_eh_get_non_ncq_success_sense() local
1982 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_get_non_ncq_success_sense()
2007 struct ata_port *ap = link->ap; in ata_eh_get_success_sense() local
2015 if (ata_port_is_frozen(ap)) { in ata_eh_get_success_sense()
2047 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_get_success_sense()
2082 struct ata_port *ap = link->ap; in ata_eh_link_autopsy() local
2123 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_autopsy()
2175 if (ata_port_is_frozen(ap) || in ata_eh_link_autopsy()
2193 ap->link.eh_context.i.err_mask |= AC_ERR_TIMEOUT; in ata_eh_link_autopsy()
2211 * @ap: host port to perform autopsy on
2213 * Analyze all links of @ap and determine why they failed and
2219 void ata_eh_autopsy(struct ata_port *ap) in ata_eh_autopsy() argument
2223 ata_for_each_link(link, ap, EDGE) in ata_eh_autopsy()
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()
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()
2245 ata_eh_done(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2251 if (sata_pmp_attached(ap)) in ata_eh_autopsy()
2252 ata_eh_link_autopsy(&ap->link); in ata_eh_autopsy()
2388 struct ata_port *ap = link->ap; in ata_eh_link_report() local
2402 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2418 if (ata_port_is_frozen(ap)) 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()
2464 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2574 * @ap: ATA port to report EH about
2581 void ata_eh_report(struct ata_port *ap) in ata_eh_report() argument
2585 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_report()
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() local
2618 struct ata_link *slave = ap->slave_link; 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()
2677 if (ap->ops->set_piomode) in ata_eh_reset()
2678 ap->ops->set_piomode(ap, dev); in ata_eh_reset()
2739 if (ata_port_is_frozen(ap) && ata_is_host_link(link)) in ata_eh_reset()
2740 ata_eh_thaw_port(ap); in ata_eh_reset()
2751 ata_eh_freeze_port(ap); in ata_eh_reset()
2865 ata_eh_thaw_port(ap); in ata_eh_reset()
2884 spin_lock_irqsave(link->ap->lock, flags); in ata_eh_reset()
2888 spin_unlock_irqrestore(link->ap->lock, flags); 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()
2968 ata_eh_thaw_port(ap); in ata_eh_reset()
2982 ata_eh_release(ap); in ata_eh_reset()
2985 ata_eh_acquire(ap); in ata_eh_reset()
2994 ata_eh_thaw_port(ap); in ata_eh_reset()
3010 static inline void ata_eh_pull_park_action(struct ata_port *ap) in ata_eh_pull_park_action() argument
3028 * Additionally, all write accesses to &ap->park_req_pending in ata_eh_pull_park_action()
3033 * *all* devices on port ap have been pulled into the in ata_eh_pull_park_action()
3038 * ap and we have to cycle over the do {} while () loop in 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()
3044 ata_for_each_link(link, ap, EDGE) { in ata_eh_pull_park_action()
3053 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_pull_park_action()
3087 struct ata_port *ap = link->ap; in ata_eh_revalidate_and_attach() local
3116 * to ap->target_lpm_policy after revalidation is done. in ata_eh_revalidate_and_attach()
3144 schedule_delayed_work(&ap->scsi_rescan_task, 0); in ata_eh_revalidate_and_attach()
3177 ata_eh_thaw_port(ap); 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()
3189 ata_force_cbl(ap); 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()
3245 struct ata_port *ap = link->ap; in ata_set_mode() local
3261 if (ap->ops->set_mode) in ata_set_mode()
3262 rc = ap->ops->set_mode(link, r_failed_dev); in ata_set_mode()
3348 struct ata_port *ap = link->ap; in ata_eh_maybe_retry_flush() local
3358 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_maybe_retry_flush()
3397 if (!ata_port_is_frozen(ap)) in ata_eh_maybe_retry_flush()
3424 struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL; in ata_eh_set_lpm() local
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()
3473 if (ap) { 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()
3498 if (ap && ap->slave_link) in ata_eh_set_lpm()
3499 ap->slave_link->lpm_policy = 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()
3561 struct ata_port *ap = link->ap; in ata_eh_skip_recovery() local
3574 if (ata_port_is_frozen(ap) || ata_link_nr_enabled(link)) in ata_eh_skip_recovery()
3626 link->ap->ops->set_lpm(link, ATA_LPM_MAX_POWER, in ata_eh_schedule_probe()
3709 * @ap: host port to recover
3729 int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_eh_recover() argument
3740 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3746 spin_lock_irqsave(ap->lock, flags); in ata_eh_recover()
3748 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_recover()
3777 if (ap->pflags & ATA_PFLAG_UNLOADING) in ata_eh_recover()
3781 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3793 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3812 * ap->park_req_pending in ata_eh_recover()
3814 ata_eh_pull_park_action(ap); in ata_eh_recover()
3817 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3844 ata_eh_release(ap); in ata_eh_recover()
3845 deadline = wait_for_completion_timeout(&ap->park_req_pending, in ata_eh_recover()
3847 ata_eh_acquire(ap); in ata_eh_recover()
3849 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3862 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_recover()
3865 if (sata_pmp_attached(ap) && ata_is_host_link(link)) 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()
3940 if (ata_port_is_frozen(ap)) { in ata_eh_recover()
3944 if (sata_pmp_attached(ap)) in ata_eh_recover()
3962 * @ap: host port to finish EH for
3970 void ata_eh_finish(struct ata_port *ap) in ata_eh_finish() argument
3976 ata_qc_for_each_raw(ap, qc, tag) { 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()
4021 * @ap: host port to handle error for
4033 void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_do_eh() argument
4040 ata_eh_autopsy(ap); in ata_do_eh()
4041 ata_eh_report(ap); in ata_do_eh()
4043 rc = ata_eh_recover(ap, prereset, softreset, hardreset, postreset, in ata_do_eh()
4046 ata_for_each_dev(dev, &ap->link, ALL) in ata_do_eh()
4050 ata_eh_finish(ap); in ata_do_eh()
4055 * @ap: host port to handle error for
4062 void ata_std_error_handler(struct ata_port *ap) in ata_std_error_handler() argument
4064 struct ata_port_operations *ops = ap->ops; 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()
4078 * @ap: port to suspend
4080 * Suspend @ap.
4085 static void ata_eh_handle_port_suspend(struct ata_port *ap) in ata_eh_handle_port_suspend() argument
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()
4113 ata_for_each_link(link, ap, HOST_FIRST) { 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()
4132 ata_eh_freeze_port(ap); 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()
4145 else if (ata_port_is_frozen(ap)) in ata_eh_handle_port_suspend()
4146 ata_port_schedule_eh(ap); in ata_eh_handle_port_suspend()
4148 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4155 * @ap: port to resume
4157 * Resume @ap.
4162 static void ata_eh_handle_port_resume(struct ata_port *ap) in ata_eh_handle_port_resume() argument
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()
4186 ata_for_each_link(link, ap, HOST_FIRST) 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()
4196 ata_acpi_on_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()