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
1553 if ((ap->flags & ATA_FLAG_PIO_DMA) && !(dev->flags & ATA_DFLAG_PIO)) { in atapi_eh_request_sense()
1674 if (!ata_port_is_frozen(qc->ap)) { in ata_eh_analyze_tf()
1933 (link->ap->cbl != ATA_CBL_SATA || dev->class == ATA_DEV_ATAPI) && in ata_eh_speed_down()
1986 struct ata_port *ap = link->ap; in ata_eh_get_non_ncq_success_sense() local
1989 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_get_non_ncq_success_sense()
2014 struct ata_port *ap = link->ap; in ata_eh_get_success_sense() local
2022 if (ata_port_is_frozen(ap)) { in ata_eh_get_success_sense()
2054 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_get_success_sense()
2089 struct ata_port *ap = link->ap; in ata_eh_link_autopsy() local
2130 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_autopsy()
2182 if (ata_port_is_frozen(ap) || in ata_eh_link_autopsy()
2200 ap->link.eh_context.i.err_mask |= AC_ERR_TIMEOUT; in ata_eh_link_autopsy()
2218 * @ap: host port to perform autopsy on
2220 * Analyze all links of @ap and determine why they failed and
2226 void ata_eh_autopsy(struct ata_port *ap) in ata_eh_autopsy() argument
2230 ata_for_each_link(link, ap, EDGE) in ata_eh_autopsy()
2237 if (ap->slave_link) { in ata_eh_autopsy()
2238 struct ata_eh_context *mehc = &ap->link.eh_context; in ata_eh_autopsy()
2239 struct ata_eh_context *sehc = &ap->slave_link->eh_context; in ata_eh_autopsy()
2245 ata_eh_link_autopsy(ap->slave_link); in ata_eh_autopsy()
2248 ata_eh_about_to_do(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2252 ata_eh_done(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2258 if (sata_pmp_attached(ap)) in ata_eh_autopsy()
2259 ata_eh_link_autopsy(&ap->link); in ata_eh_autopsy()
2395 struct ata_port *ap = link->ap; in ata_eh_link_report() local
2409 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2425 if (ata_port_is_frozen(ap)) in ata_eh_link_report()
2428 if (ap->eh_tries < ATA_EH_MAX_TRIES) in ata_eh_link_report()
2430 ap->eh_tries); in ata_eh_link_report()
2471 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2581 * @ap: ATA port to report EH about
2588 void ata_eh_report(struct ata_port *ap) in ata_eh_report() argument
2592 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_report()
2615 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) in ata_eh_followup_srst_needed()
2624 struct ata_port *ap = link->ap; in ata_eh_reset() local
2625 struct ata_link *slave = ap->slave_link; in ata_eh_reset()
2662 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2663 ap->pflags |= ATA_PFLAG_RESETTING; in ata_eh_reset()
2664 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2684 if (ap->ops->set_piomode) in ata_eh_reset()
2685 ap->ops->set_piomode(ap, dev); in ata_eh_reset()
2746 if (ata_port_is_frozen(ap) && ata_is_host_link(link)) in ata_eh_reset()
2747 ata_eh_thaw_port(ap); in ata_eh_reset()
2758 ata_eh_freeze_port(ap); in ata_eh_reset()
2872 ata_eh_thaw_port(ap); in ata_eh_reset()
2891 spin_lock_irqsave(link->ap->lock, flags); in ata_eh_reset()
2895 spin_unlock_irqrestore(link->ap->lock, flags); in ata_eh_reset()
2955 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2956 ap->pflags &= ~ATA_PFLAG_RESETTING; in ata_eh_reset()
2957 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2975 ata_eh_thaw_port(ap); in ata_eh_reset()
2989 ata_eh_release(ap); in ata_eh_reset()
2992 ata_eh_acquire(ap); in ata_eh_reset()
3001 ata_eh_thaw_port(ap); in ata_eh_reset()
3017 static inline void ata_eh_pull_park_action(struct ata_port *ap) in ata_eh_pull_park_action() argument
3035 * Additionally, all write accesses to &ap->park_req_pending in ata_eh_pull_park_action()
3040 * *all* devices on port ap have been pulled into the in ata_eh_pull_park_action()
3045 * ap and we have to cycle over the do {} while () loop in in ata_eh_pull_park_action()
3049 spin_lock_irqsave(ap->lock, flags); in ata_eh_pull_park_action()
3050 reinit_completion(&ap->park_req_pending); in ata_eh_pull_park_action()
3051 ata_for_each_link(link, ap, EDGE) { in ata_eh_pull_park_action()
3060 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_pull_park_action()
3094 struct ata_port *ap = link->ap; in ata_eh_revalidate_and_attach() local
3123 * to ap->target_lpm_policy after revalidation is done. in ata_eh_revalidate_and_attach()
3151 schedule_delayed_work(&ap->scsi_rescan_task, 0); in ata_eh_revalidate_and_attach()
3184 ata_eh_thaw_port(ap); in ata_eh_revalidate_and_attach()
3194 if (ap->ops->cable_detect) in ata_eh_revalidate_and_attach()
3195 ap->cbl = ap->ops->cable_detect(ap); in ata_eh_revalidate_and_attach()
3196 ata_force_cbl(ap); in ata_eh_revalidate_and_attach()
3219 spin_lock_irqsave(ap->lock, flags); in ata_eh_revalidate_and_attach()
3220 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_revalidate_and_attach()
3221 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_revalidate_and_attach()
3252 struct ata_port *ap = link->ap; in ata_set_mode() local
3268 if (ap->ops->set_mode) in ata_set_mode()
3269 rc = ap->ops->set_mode(link, r_failed_dev); in ata_set_mode()
3355 struct ata_port *ap = link->ap; in ata_eh_maybe_retry_flush() local
3365 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_maybe_retry_flush()
3404 if (!ata_port_is_frozen(ap)) in ata_eh_maybe_retry_flush()
3431 struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL; in ata_eh_set_lpm() local
3435 bool no_dipm = link->ap->flags & ATA_FLAG_NO_DIPM; in ata_eh_set_lpm()
3442 (link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm)) in ata_eh_set_lpm()
3480 if (ap) { in ata_eh_set_lpm()
3481 rc = ap->ops->set_lpm(link, policy, hints); in ata_eh_set_lpm()
3482 if (!rc && ap->slave_link) in ata_eh_set_lpm()
3483 rc = ap->ops->set_lpm(ap->slave_link, policy, hints); in ata_eh_set_lpm()
3505 if (ap && ap->slave_link) in ata_eh_set_lpm()
3506 ap->slave_link->lpm_policy = policy; in ata_eh_set_lpm()
3532 if (ap && ap->slave_link) in ata_eh_set_lpm()
3533 ap->slave_link->lpm_policy = old_policy; in ata_eh_set_lpm()
3568 struct ata_port *ap = link->ap; in ata_eh_skip_recovery() local
3581 if (ata_port_is_frozen(ap) || ata_link_nr_enabled(link)) in ata_eh_skip_recovery()
3633 link->ap->ops->set_lpm(link, ATA_LPM_MAX_POWER, in ata_eh_schedule_probe()
3716 * @ap: host port to recover
3736 int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_eh_recover() argument
3747 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3753 spin_lock_irqsave(ap->lock, flags); in ata_eh_recover()
3755 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_recover()
3784 if (ap->pflags & ATA_PFLAG_UNLOADING) in ata_eh_recover()
3788 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3800 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3819 * ap->park_req_pending in ata_eh_recover()
3821 ata_eh_pull_park_action(ap); in ata_eh_recover()
3824 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3851 ata_eh_release(ap); in ata_eh_recover()
3852 deadline = wait_for_completion_timeout(&ap->park_req_pending, in ata_eh_recover()
3854 ata_eh_acquire(ap); in ata_eh_recover()
3856 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3869 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_recover()
3872 if (sata_pmp_attached(ap) && ata_is_host_link(link)) in ata_eh_recover()
3932 if (link->lpm_policy != ap->target_lpm_policy) { in ata_eh_recover()
3933 rc = ata_eh_set_lpm(link, ap->target_lpm_policy, &dev); in ata_eh_recover()
3947 if (ata_port_is_frozen(ap)) { in ata_eh_recover()
3951 if (sata_pmp_attached(ap)) in ata_eh_recover()
3969 * @ap: host port to finish EH for
3977 void ata_eh_finish(struct ata_port *ap) in ata_eh_finish() argument
3983 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_finish()
4022 WARN_ON(ap->nr_active_links); in ata_eh_finish()
4023 ap->nr_active_links = 0; in ata_eh_finish()
4028 * @ap: host port to handle error for
4040 void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_do_eh() argument
4047 ata_eh_autopsy(ap); in ata_do_eh()
4048 ata_eh_report(ap); in ata_do_eh()
4050 rc = ata_eh_recover(ap, prereset, softreset, hardreset, postreset, in ata_do_eh()
4053 ata_for_each_dev(dev, &ap->link, ALL) in ata_do_eh()
4057 ata_eh_finish(ap); in ata_do_eh()
4062 * @ap: host port to handle error for
4069 void ata_std_error_handler(struct ata_port *ap) in ata_std_error_handler() argument
4071 struct ata_port_operations *ops = ap->ops; in ata_std_error_handler()
4075 if (hardreset == sata_std_hardreset && !sata_scr_valid(&ap->link)) in ata_std_error_handler()
4078 ata_do_eh(ap, ops->prereset, ops->softreset, hardreset, ops->postreset); in ata_std_error_handler()
4085 * @ap: port to suspend
4087 * Suspend @ap.
4092 static void ata_eh_handle_port_suspend(struct ata_port *ap) in ata_eh_handle_port_suspend() argument
4100 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
4101 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_suspend()
4102 ap->pm_mesg.event & PM_EVENT_RESUME) { in ata_eh_handle_port_suspend()
4103 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4106 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4108 WARN_ON(ap->pflags & ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_suspend()
4118 if (!(ap->pm_mesg.event & PM_EVENT_FREEZE)) { in ata_eh_handle_port_suspend()
4120 ata_for_each_link(link, ap, HOST_FIRST) { in ata_eh_handle_port_suspend()
4131 if (PMSG_IS_AUTO(ap->pm_mesg)) { in ata_eh_handle_port_suspend()
4132 ata_for_each_dev(dev, &ap->link, ENABLED) { in ata_eh_handle_port_suspend()
4139 ata_eh_freeze_port(ap); in ata_eh_handle_port_suspend()
4141 if (ap->ops->port_suspend) in ata_eh_handle_port_suspend()
4142 rc = ap->ops->port_suspend(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
4144 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
4147 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
4149 ap->pflags &= ~ATA_PFLAG_PM_PENDING; in ata_eh_handle_port_suspend()
4151 ap->pflags |= ATA_PFLAG_SUSPENDED; in ata_eh_handle_port_suspend()
4152 else if (ata_port_is_frozen(ap)) in ata_eh_handle_port_suspend()
4153 ata_port_schedule_eh(ap); in ata_eh_handle_port_suspend()
4155 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4162 * @ap: port to resume
4164 * Resume @ap.
4169 static void ata_eh_handle_port_resume(struct ata_port *ap) in ata_eh_handle_port_resume() argument
4176 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
4177 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_resume()
4178 !(ap->pm_mesg.event & PM_EVENT_RESUME)) { in ata_eh_handle_port_resume()
4179 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
4182 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
4184 WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED)); in ata_eh_handle_port_resume()
4193 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_handle_port_resume()
4197 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_resume()
4199 if (ap->ops->port_resume) in ata_eh_handle_port_resume()
4200 ap->ops->port_resume(ap); in ata_eh_handle_port_resume()
4203 ata_acpi_on_resume(ap); in ata_eh_handle_port_resume()
4206 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
4207 ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_resume()
4208 ap->pflags |= ATA_PFLAG_RESUMING; in ata_eh_handle_port_resume()
4209 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()