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()
509 static void ata_eh_unload(struct ata_port *ap) in ata_eh_unload() argument
520 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_unload()
530 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_unload()
537 spin_lock_irqsave(ap->lock, flags); in ata_eh_unload()
539 ata_port_freeze(ap); /* won't be thawed */ in ata_eh_unload()
540 ap->pflags &= ~ATA_PFLAG_EH_PENDING; /* clear pending from freeze */ in ata_eh_unload()
541 ap->pflags |= ATA_PFLAG_UNLOADED; in ata_eh_unload()
543 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_unload()
560 struct ata_port *ap = ata_shost_to_port(host); in ata_scsi_error() local
568 ata_scsi_cmd_error_handler(host, ap, &eh_work_q); in ata_scsi_error()
572 ata_scsi_port_error_handler(host, ap); in ata_scsi_error()
582 * @ap: ATA port within the host
586 * ap->eh_done_q. This function is the first part of the libata error
589 void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, in ata_scsi_cmd_error_handler() argument
598 ata_sff_flush_pio_task(ap); in ata_scsi_cmd_error_handler()
615 spin_lock_irqsave(ap->lock, flags); in ata_scsi_cmd_error_handler()
618 * This must occur under the ap->lock as we don't want in ata_scsi_cmd_error_handler()
627 if (ap->ops->lost_interrupt) in ata_scsi_cmd_error_handler()
628 ap->ops->lost_interrupt(ap); in ata_scsi_cmd_error_handler()
633 ata_qc_for_each_raw(ap, qc, i) { in ata_scsi_cmd_error_handler()
653 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in ata_scsi_cmd_error_handler()
665 __ata_port_freeze(ap); in ata_scsi_cmd_error_handler()
668 ap->eh_tries = ATA_EH_MAX_TRIES; in ata_scsi_cmd_error_handler()
670 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_cmd_error_handler()
677 * @ap: the ATA port
679 * Handle the recovery of the port @ap after all the commands
682 void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap) in ata_scsi_port_error_handler() argument
688 ata_eh_acquire(ap); in ata_scsi_port_error_handler()
691 del_timer_sync(&ap->fastdrain_timer); in ata_scsi_port_error_handler()
694 ata_eh_handle_port_resume(ap); in ata_scsi_port_error_handler()
697 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
699 ata_for_each_link(link, ap, HOST_FIRST) { in ata_scsi_port_error_handler()
715 if (ap->pflags & ATA_PFLAG_RESUMING) in ata_scsi_port_error_handler()
720 ap->pflags |= ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
721 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
722 ap->excl_link = NULL; /* don't maintain exclusion over EH */ in ata_scsi_port_error_handler()
724 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
727 if (!(ap->pflags & (ATA_PFLAG_UNLOADING | ATA_PFLAG_SUSPENDED))) in ata_scsi_port_error_handler()
728 ap->ops->error_handler(ap); in ata_scsi_port_error_handler()
731 if ((ap->pflags & ATA_PFLAG_UNLOADING) && in ata_scsi_port_error_handler()
732 !(ap->pflags & ATA_PFLAG_UNLOADED)) in ata_scsi_port_error_handler()
733 ata_eh_unload(ap); in ata_scsi_port_error_handler()
734 ata_eh_finish(ap); in ata_scsi_port_error_handler()
738 ata_eh_handle_port_suspend(ap); in ata_scsi_port_error_handler()
744 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
746 if (ap->pflags & ATA_PFLAG_EH_PENDING) { in ata_scsi_port_error_handler()
747 if (--ap->eh_tries) { in ata_scsi_port_error_handler()
748 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
751 ata_port_err(ap, in ata_scsi_port_error_handler()
754 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
758 ata_for_each_link(link, ap, HOST_FIRST) in ata_scsi_port_error_handler()
762 * end eh (clear host_eh_scheduled) while holding ap->lock such that if in ata_scsi_port_error_handler()
766 ap->ops->end_eh(ap); in ata_scsi_port_error_handler()
768 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
769 ata_eh_release(ap); in ata_scsi_port_error_handler()
771 scsi_eh_flush_done_q(&ap->eh_done_q); in ata_scsi_port_error_handler()
774 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
776 ap->pflags &= ~ATA_PFLAG_RESUMING; in ata_scsi_port_error_handler()
778 if (ap->pflags & ATA_PFLAG_LOADING) in ata_scsi_port_error_handler()
779 ap->pflags &= ~ATA_PFLAG_LOADING; in ata_scsi_port_error_handler()
780 else if ((ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) && in ata_scsi_port_error_handler()
781 !(ap->flags & ATA_FLAG_SAS_HOST)) in ata_scsi_port_error_handler()
782 schedule_delayed_work(&ap->hotplug_task, 0); in ata_scsi_port_error_handler()
784 if (ap->pflags & ATA_PFLAG_RECOVERED) in ata_scsi_port_error_handler()
785 ata_port_info(ap, "EH complete\n"); in ata_scsi_port_error_handler()
787 ap->pflags &= ~(ATA_PFLAG_SCSI_HOTPLUG | ATA_PFLAG_RECOVERED); in ata_scsi_port_error_handler()
790 ap->pflags &= ~ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
791 wake_up_all(&ap->eh_wait_q); in ata_scsi_port_error_handler()
793 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
799 * @ap: Port to wait EH for
806 void ata_port_wait_eh(struct ata_port *ap) in ata_port_wait_eh() argument
812 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
814 while (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS)) { in ata_port_wait_eh()
815 prepare_to_wait(&ap->eh_wait_q, &wait, TASK_UNINTERRUPTIBLE); in ata_port_wait_eh()
816 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
818 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
820 finish_wait(&ap->eh_wait_q, &wait); in ata_port_wait_eh()
822 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
825 if (scsi_host_in_recovery(ap->scsi_host)) { in ata_port_wait_eh()
826 ata_msleep(ap, 10); in ata_port_wait_eh()
832 static unsigned int ata_eh_nr_in_flight(struct ata_port *ap) in ata_eh_nr_in_flight() argument
839 ata_qc_for_each(ap, qc, tag) { in ata_eh_nr_in_flight()
849 struct ata_port *ap = from_timer(ap, t, fastdrain_timer); in ata_eh_fastdrain_timerfn() local
853 spin_lock_irqsave(ap->lock, flags); in ata_eh_fastdrain_timerfn()
855 cnt = ata_eh_nr_in_flight(ap); in ata_eh_fastdrain_timerfn()
861 if (cnt == ap->fastdrain_cnt) { in ata_eh_fastdrain_timerfn()
868 ata_qc_for_each(ap, qc, tag) { in ata_eh_fastdrain_timerfn()
873 ata_port_freeze(ap); in ata_eh_fastdrain_timerfn()
876 ap->fastdrain_cnt = cnt; in ata_eh_fastdrain_timerfn()
877 ap->fastdrain_timer.expires = in ata_eh_fastdrain_timerfn()
879 add_timer(&ap->fastdrain_timer); in ata_eh_fastdrain_timerfn()
883 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_fastdrain_timerfn()
888 * @ap: target ATA port
898 static void ata_eh_set_pending(struct ata_port *ap, int fastdrain) in ata_eh_set_pending() argument
903 if (ap->pflags & ATA_PFLAG_EH_PENDING) in ata_eh_set_pending()
906 ap->pflags |= ATA_PFLAG_EH_PENDING; in ata_eh_set_pending()
912 cnt = ata_eh_nr_in_flight(ap); in ata_eh_set_pending()
917 ap->fastdrain_cnt = cnt; in ata_eh_set_pending()
918 ap->fastdrain_timer.expires = in ata_eh_set_pending()
920 add_timer(&ap->fastdrain_timer); in ata_eh_set_pending()
935 struct ata_port *ap = qc->ap; in ata_qc_schedule_eh() local
938 ata_eh_set_pending(ap, 1); in ata_qc_schedule_eh()
950 * @ap: ATA port to schedule EH for
955 void ata_std_sched_eh(struct ata_port *ap) in ata_std_sched_eh() argument
957 if (ap->pflags & ATA_PFLAG_INITIALIZING) in ata_std_sched_eh()
960 ata_eh_set_pending(ap, 1); in ata_std_sched_eh()
961 scsi_schedule_eh(ap->scsi_host); in ata_std_sched_eh()
963 trace_ata_std_sched_eh(ap); in ata_std_sched_eh()
969 * @ap: ATA port to end EH for
972 * shost, so host fields can be directly manipulated under ap->lock, in
979 void ata_std_end_eh(struct ata_port *ap) in ata_std_end_eh() argument
981 struct Scsi_Host *host = ap->scsi_host; in ata_std_end_eh()
990 * @ap: ATA port to schedule EH for
992 * Schedule error handling for @ap. EH will kick in as soon as
998 void ata_port_schedule_eh(struct ata_port *ap) in ata_port_schedule_eh() argument
1001 ap->ops->sched_eh(ap); in ata_port_schedule_eh()
1005 static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link) in ata_do_link_abort() argument
1011 ata_eh_set_pending(ap, 0); in ata_do_link_abort()
1014 ata_qc_for_each_with_internal(ap, qc, tag) { in ata_do_link_abort()
1023 ata_port_schedule_eh(ap); in ata_do_link_abort()
1042 return ata_do_link_abort(link->ap, link); in ata_link_abort()
1048 * @ap: ATA port to abort qc's for
1050 * Abort all active qc's of @ap and schedule EH.
1058 int ata_port_abort(struct ata_port *ap) in ata_port_abort() argument
1060 return ata_do_link_abort(ap, NULL); in ata_port_abort()
1066 * @ap: ATA port to freeze
1073 * ap->ops->freeze() callback can be used for freezing the port
1082 static void __ata_port_freeze(struct ata_port *ap) in __ata_port_freeze() argument
1084 if (ap->ops->freeze) in __ata_port_freeze()
1085 ap->ops->freeze(ap); in __ata_port_freeze()
1087 ap->pflags |= ATA_PFLAG_FROZEN; in __ata_port_freeze()
1089 trace_ata_port_freeze(ap); in __ata_port_freeze()
1094 * @ap: ATA port to freeze
1096 * Abort and freeze @ap. The freeze operation must be called
1106 int ata_port_freeze(struct ata_port *ap) in ata_port_freeze() argument
1108 __ata_port_freeze(ap); in ata_port_freeze()
1110 return ata_port_abort(ap); in ata_port_freeze()
1116 * @ap: ATA port to freeze
1118 * Freeze @ap.
1123 void ata_eh_freeze_port(struct ata_port *ap) in ata_eh_freeze_port() argument
1127 spin_lock_irqsave(ap->lock, flags); in ata_eh_freeze_port()
1128 __ata_port_freeze(ap); in ata_eh_freeze_port()
1129 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_freeze_port()
1135 * @ap: ATA port to thaw
1137 * Thaw frozen port @ap.
1142 void ata_eh_thaw_port(struct ata_port *ap) in ata_eh_thaw_port() argument
1146 spin_lock_irqsave(ap->lock, flags); in ata_eh_thaw_port()
1148 ap->pflags &= ~ATA_PFLAG_FROZEN; in ata_eh_thaw_port()
1150 if (ap->ops->thaw) in ata_eh_thaw_port()
1151 ap->ops->thaw(ap); in ata_eh_thaw_port()
1153 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_thaw_port()
1155 trace_ata_port_thaw(ap); in ata_eh_thaw_port()
1165 struct ata_port *ap = qc->ap; in __ata_eh_qc_complete() local
1169 spin_lock_irqsave(ap->lock, flags); in __ata_eh_qc_complete()
1173 spin_unlock_irqrestore(ap->lock, flags); in __ata_eh_qc_complete()
1175 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in __ata_eh_qc_complete()
1243 struct ata_port *ap = link->ap; in ata_eh_detach_dev() local
1256 spin_lock_irqsave(ap->lock, flags); in ata_eh_detach_dev()
1262 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_detach_dev()
1271 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_detach_dev()
1290 struct ata_port *ap = link->ap; in ata_eh_about_to_do() local
1297 spin_lock_irqsave(ap->lock, flags); in ata_eh_about_to_do()
1304 if (!(ehc->i.flags & ATA_EHI_QUIET) && link != ap->slave_link) in ata_eh_about_to_do()
1305 ap->pflags |= ATA_PFLAG_RECOVERED; in ata_eh_about_to_do()
1307 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_about_to_do()
1422 if (ata_port_is_frozen(qc->ap)) { in ata_eh_request_sense()
1477 struct ata_port *ap = dev->link->ap; in atapi_eh_request_sense() local
1495 if (ap->flags & ATA_FLAG_PIO_DMA) { in atapi_eh_request_sense()
1616 if (!ata_port_is_frozen(qc->ap)) { in ata_eh_analyze_tf()
1874 (link->ap->cbl != ATA_CBL_SATA || dev->class == ATA_DEV_ATAPI) && in ata_eh_speed_down()
1927 struct ata_port *ap = link->ap; in ata_eh_read_sense_success_non_ncq() local
1930 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_read_sense_success_non_ncq()
1956 struct ata_port *ap = link->ap; in ata_eh_get_success_sense() local
1964 if (ata_port_is_frozen(ap)) { in ata_eh_get_success_sense()
1996 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_get_success_sense()
2031 struct ata_port *ap = link->ap; in ata_eh_link_autopsy() local
2072 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_autopsy()
2124 if (ata_port_is_frozen(ap) || in ata_eh_link_autopsy()
2142 ap->link.eh_context.i.err_mask |= AC_ERR_TIMEOUT; in ata_eh_link_autopsy()
2160 * @ap: host port to perform autopsy on
2162 * Analyze all links of @ap and determine why they failed and
2168 void ata_eh_autopsy(struct ata_port *ap) in ata_eh_autopsy() argument
2172 ata_for_each_link(link, ap, EDGE) in ata_eh_autopsy()
2179 if (ap->slave_link) { in ata_eh_autopsy()
2180 struct ata_eh_context *mehc = &ap->link.eh_context; in ata_eh_autopsy()
2181 struct ata_eh_context *sehc = &ap->slave_link->eh_context; in ata_eh_autopsy()
2187 ata_eh_link_autopsy(ap->slave_link); in ata_eh_autopsy()
2190 ata_eh_about_to_do(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2194 ata_eh_done(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2200 if (sata_pmp_attached(ap)) in ata_eh_autopsy()
2201 ata_eh_link_autopsy(&ap->link); in ata_eh_autopsy()
2337 struct ata_port *ap = link->ap; in ata_eh_link_report() local
2351 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2367 if (ata_port_is_frozen(ap)) in ata_eh_link_report()
2370 if (ap->eh_tries < ATA_EH_MAX_TRIES) in ata_eh_link_report()
2372 ap->eh_tries); in ata_eh_link_report()
2413 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2523 * @ap: ATA port to report EH about
2530 void ata_eh_report(struct ata_port *ap) in ata_eh_report() argument
2534 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_report()
2557 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) in ata_eh_followup_srst_needed()
2566 struct ata_port *ap = link->ap; in ata_eh_reset() local
2567 struct ata_link *slave = ap->slave_link; in ata_eh_reset()
2604 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2605 ap->pflags |= ATA_PFLAG_RESETTING; in ata_eh_reset()
2606 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2626 if (ap->ops->set_piomode) in ata_eh_reset()
2627 ap->ops->set_piomode(ap, dev); in ata_eh_reset()
2688 if (ata_port_is_frozen(ap) && ata_is_host_link(link)) in ata_eh_reset()
2689 ata_eh_thaw_port(ap); in ata_eh_reset()
2700 ata_eh_freeze_port(ap); in ata_eh_reset()
2814 ata_eh_thaw_port(ap); in ata_eh_reset()
2833 spin_lock_irqsave(link->ap->lock, flags); in ata_eh_reset()
2837 spin_unlock_irqrestore(link->ap->lock, flags); in ata_eh_reset()
2897 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2898 ap->pflags &= ~ATA_PFLAG_RESETTING; in ata_eh_reset()
2899 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2917 ata_eh_thaw_port(ap); in ata_eh_reset()
2931 ata_eh_release(ap); in ata_eh_reset()
2934 ata_eh_acquire(ap); in ata_eh_reset()
2943 ata_eh_thaw_port(ap); in ata_eh_reset()
2959 static inline void ata_eh_pull_park_action(struct ata_port *ap) in ata_eh_pull_park_action() argument
2977 * Additionally, all write accesses to &ap->park_req_pending in ata_eh_pull_park_action()
2982 * *all* devices on port ap have been pulled into the in ata_eh_pull_park_action()
2987 * ap and we have to cycle over the do {} while () loop in in ata_eh_pull_park_action()
2991 spin_lock_irqsave(ap->lock, flags); in ata_eh_pull_park_action()
2992 reinit_completion(&ap->park_req_pending); in ata_eh_pull_park_action()
2993 ata_for_each_link(link, ap, EDGE) { in ata_eh_pull_park_action()
3002 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_pull_park_action()
3036 struct ata_port *ap = link->ap; in ata_eh_revalidate_and_attach() local
3065 * to ap->target_lpm_policy after revalidation is done. in ata_eh_revalidate_and_attach()
3093 schedule_delayed_work(&ap->scsi_rescan_task, 0); in ata_eh_revalidate_and_attach()
3126 ata_eh_thaw_port(ap); in ata_eh_revalidate_and_attach()
3136 if (ap->ops->cable_detect) in ata_eh_revalidate_and_attach()
3137 ap->cbl = ap->ops->cable_detect(ap); in ata_eh_revalidate_and_attach()
3138 ata_force_cbl(ap); in ata_eh_revalidate_and_attach()
3161 spin_lock_irqsave(ap->lock, flags); in ata_eh_revalidate_and_attach()
3162 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_revalidate_and_attach()
3163 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_revalidate_and_attach()
3193 struct ata_port *ap = link->ap; in ata_set_mode() local
3209 if (ap->ops->set_mode) in ata_set_mode()
3210 rc = ap->ops->set_mode(link, r_failed_dev); in ata_set_mode()
3247 u8 *sense_buffer = dev->link->ap->sector_buf; in atapi_eh_clear_ua()
3296 struct ata_port *ap = link->ap; in ata_eh_maybe_retry_flush() local
3306 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_maybe_retry_flush()
3345 if (!ata_port_is_frozen(ap)) in ata_eh_maybe_retry_flush()
3372 struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL; in ata_eh_set_lpm() local
3376 bool no_dipm = link->ap->flags & ATA_FLAG_NO_DIPM; in ata_eh_set_lpm()
3383 (link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm)) in ata_eh_set_lpm()
3421 if (ap) { in ata_eh_set_lpm()
3422 rc = ap->ops->set_lpm(link, policy, hints); in ata_eh_set_lpm()
3423 if (!rc && ap->slave_link) in ata_eh_set_lpm()
3424 rc = ap->ops->set_lpm(ap->slave_link, policy, hints); in ata_eh_set_lpm()
3446 if (ap && ap->slave_link) in ata_eh_set_lpm()
3447 ap->slave_link->lpm_policy = policy; in ata_eh_set_lpm()
3473 if (ap && ap->slave_link) in ata_eh_set_lpm()
3474 ap->slave_link->lpm_policy = old_policy; in ata_eh_set_lpm()
3509 struct ata_port *ap = link->ap; in ata_eh_skip_recovery() local
3522 if (ata_port_is_frozen(ap) || ata_link_nr_enabled(link)) in ata_eh_skip_recovery()
3574 link->ap->ops->set_lpm(link, ATA_LPM_MAX_POWER, in ata_eh_schedule_probe()
3657 * @ap: host port to recover
3677 int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_eh_recover() argument
3688 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3694 spin_lock_irqsave(ap->lock, flags); in ata_eh_recover()
3696 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_recover()
3725 if (ap->pflags & ATA_PFLAG_UNLOADING) in ata_eh_recover()
3729 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3741 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3760 * ap->park_req_pending in ata_eh_recover()
3762 ata_eh_pull_park_action(ap); in ata_eh_recover()
3765 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3792 ata_eh_release(ap); in ata_eh_recover()
3793 deadline = wait_for_completion_timeout(&ap->park_req_pending, in ata_eh_recover()
3795 ata_eh_acquire(ap); in ata_eh_recover()
3797 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3810 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_recover()
3813 if (sata_pmp_attached(ap) && ata_is_host_link(link)) in ata_eh_recover()
3873 if (link->lpm_policy != ap->target_lpm_policy) { in ata_eh_recover()
3874 rc = ata_eh_set_lpm(link, ap->target_lpm_policy, &dev); in ata_eh_recover()
3888 if (ata_port_is_frozen(ap)) { in ata_eh_recover()
3892 if (sata_pmp_attached(ap)) in ata_eh_recover()
3910 * @ap: host port to finish EH for
3918 void ata_eh_finish(struct ata_port *ap) in ata_eh_finish() argument
3924 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_finish()
3963 WARN_ON(ap->nr_active_links); in ata_eh_finish()
3964 ap->nr_active_links = 0; in ata_eh_finish()
3969 * @ap: host port to handle error for
3981 void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_do_eh() argument
3988 ata_eh_autopsy(ap); in ata_do_eh()
3989 ata_eh_report(ap); in ata_do_eh()
3991 rc = ata_eh_recover(ap, prereset, softreset, hardreset, postreset, in ata_do_eh()
3994 ata_for_each_dev(dev, &ap->link, ALL) in ata_do_eh()
3998 ata_eh_finish(ap); in ata_do_eh()
4003 * @ap: host port to handle error for
4010 void ata_std_error_handler(struct ata_port *ap) in ata_std_error_handler() argument
4012 struct ata_port_operations *ops = ap->ops; in ata_std_error_handler()
4016 if (hardreset == sata_std_hardreset && !sata_scr_valid(&ap->link)) in ata_std_error_handler()
4019 ata_do_eh(ap, ops->prereset, ops->softreset, hardreset, ops->postreset); in ata_std_error_handler()
4026 * @ap: port to suspend
4028 * Suspend @ap.
4033 static void ata_eh_handle_port_suspend(struct ata_port *ap) in ata_eh_handle_port_suspend() argument
4041 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
4042 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_suspend()
4043 ap->pm_mesg.event & PM_EVENT_RESUME) { in ata_eh_handle_port_suspend()
4044 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4047 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4049 WARN_ON(ap->pflags & ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_suspend()
4052 ata_for_each_link(link, ap, HOST_FIRST) { in ata_eh_handle_port_suspend()
4062 if (PMSG_IS_AUTO(ap->pm_mesg)) { in ata_eh_handle_port_suspend()
4063 ata_for_each_dev(dev, &ap->link, ENABLED) { in ata_eh_handle_port_suspend()
4070 ata_eh_freeze_port(ap); in ata_eh_handle_port_suspend()
4072 if (ap->ops->port_suspend) in ata_eh_handle_port_suspend()
4073 rc = ap->ops->port_suspend(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
4075 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
4078 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
4080 ap->pflags &= ~ATA_PFLAG_PM_PENDING; in ata_eh_handle_port_suspend()
4082 ap->pflags |= ATA_PFLAG_SUSPENDED; in ata_eh_handle_port_suspend()
4083 else if (ata_port_is_frozen(ap)) in ata_eh_handle_port_suspend()
4084 ata_port_schedule_eh(ap); in ata_eh_handle_port_suspend()
4086 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4093 * @ap: port to resume
4095 * Resume @ap.
4100 static void ata_eh_handle_port_resume(struct ata_port *ap) in ata_eh_handle_port_resume() argument
4107 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
4108 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_resume()
4109 !(ap->pm_mesg.event & PM_EVENT_RESUME)) { in ata_eh_handle_port_resume()
4110 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
4113 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
4115 WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED)); in ata_eh_handle_port_resume()
4124 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_handle_port_resume()
4128 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_resume()
4130 if (ap->ops->port_resume) in ata_eh_handle_port_resume()
4131 ap->ops->port_resume(ap); in ata_eh_handle_port_resume()
4134 ata_acpi_on_resume(ap); in ata_eh_handle_port_resume()
4137 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
4138 ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_resume()
4139 ap->pflags |= ATA_PFLAG_RESUMING; in ata_eh_handle_port_resume()
4140 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()