Lines Matching full:ap
153 static void __ata_port_freeze(struct ata_port *ap);
157 static void ata_eh_handle_port_suspend(struct ata_port *ap);
158 static void ata_eh_handle_port_resume(struct ata_port *ap);
160 static void ata_eh_handle_port_suspend(struct ata_port *ap) in ata_eh_handle_port_suspend() argument
163 static void ata_eh_handle_port_resume(struct ata_port *ap) in ata_eh_handle_port_resume() argument
237 * @ap: target ATA port
248 void ata_port_desc(struct ata_port *ap, const char *fmt, ...) in ata_port_desc() argument
252 WARN_ON(!(ap->pflags & ATA_PFLAG_INITIALIZING)); in ata_port_desc()
254 if (ap->link.eh_info.desc_len) in ata_port_desc()
255 __ata_ehi_push_desc(&ap->link.eh_info, " "); in ata_port_desc()
258 __ata_ehi_pushv_desc(&ap->link.eh_info, fmt, args); in ata_port_desc()
266 * @ap: target ATA port
279 void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset, in ata_port_pbar_desc() argument
282 struct pci_dev *pdev = to_pci_dev(ap->host->dev); in ata_port_pbar_desc()
295 ata_port_desc(ap, "%s %s%llu@0x%llx", name, type, len, start); in ata_port_pbar_desc()
297 ata_port_desc(ap, "%s 0x%llx", name, in ata_port_pbar_desc()
462 * @ap: ATA port to acquire EH ownership for
464 * Acquire EH ownership for @ap. This is the basic exclusion
471 void ata_eh_acquire(struct ata_port *ap) in ata_eh_acquire() argument
473 mutex_lock(&ap->host->eh_mutex); in ata_eh_acquire()
474 WARN_ON_ONCE(ap->host->eh_owner); in ata_eh_acquire()
475 ap->host->eh_owner = current; in ata_eh_acquire()
480 * @ap: ATA port to release EH ownership for
482 * Release EH ownership for @ap if the caller. The caller must
488 void ata_eh_release(struct ata_port *ap) in ata_eh_release() argument
490 WARN_ON_ONCE(ap->host->eh_owner != current); in ata_eh_release()
491 ap->host->eh_owner = NULL; in ata_eh_release()
492 mutex_unlock(&ap->host->eh_mutex); in ata_eh_release()
495 static void ata_eh_unload(struct ata_port *ap) in ata_eh_unload() argument
504 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_unload()
511 spin_lock_irqsave(ap->lock, flags); in ata_eh_unload()
513 ata_port_freeze(ap); /* won't be thawed */ in ata_eh_unload()
514 ap->pflags &= ~ATA_PFLAG_EH_PENDING; /* clear pending from freeze */ in ata_eh_unload()
515 ap->pflags |= ATA_PFLAG_UNLOADED; in ata_eh_unload()
517 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_unload()
534 struct ata_port *ap = ata_shost_to_port(host); in ata_scsi_error() local
542 ata_scsi_cmd_error_handler(host, ap, &eh_work_q); in ata_scsi_error()
546 ata_scsi_port_error_handler(host, ap); in ata_scsi_error()
556 * @ap: ATA port within the host
560 * ap->eh_done_q. This function is the first part of the libata error
563 void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, in ata_scsi_cmd_error_handler() argument
570 ata_sff_flush_pio_task(ap); in ata_scsi_cmd_error_handler()
586 spin_lock_irqsave(ap->lock, flags); in ata_scsi_cmd_error_handler()
587 if (ap->ops->error_handler) { in ata_scsi_cmd_error_handler()
591 /* This must occur under the ap->lock as we don't want in ata_scsi_cmd_error_handler()
600 if (ap->ops->lost_interrupt) in ata_scsi_cmd_error_handler()
601 ap->ops->lost_interrupt(ap); in ata_scsi_cmd_error_handler()
606 ata_qc_for_each_raw(ap, qc, i) { in ata_scsi_cmd_error_handler()
626 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in ata_scsi_cmd_error_handler()
637 __ata_port_freeze(ap); in ata_scsi_cmd_error_handler()
641 ap->eh_tries = ATA_EH_MAX_TRIES; in ata_scsi_cmd_error_handler()
643 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_cmd_error_handler()
651 * @ap: the ATA port
653 * Handle the recovery of the port @ap after all the commands
656 void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap) in ata_scsi_port_error_handler() argument
661 if (ap->ops->error_handler) { in ata_scsi_port_error_handler()
665 ata_eh_acquire(ap); in ata_scsi_port_error_handler()
668 del_timer_sync(&ap->fastdrain_timer); in ata_scsi_port_error_handler()
671 ata_eh_handle_port_resume(ap); in ata_scsi_port_error_handler()
674 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
676 ata_for_each_link(link, ap, HOST_FIRST) { in ata_scsi_port_error_handler()
693 ap->pflags |= ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
694 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
695 ap->excl_link = NULL; /* don't maintain exclusion over EH */ in ata_scsi_port_error_handler()
697 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
700 if (!(ap->pflags & (ATA_PFLAG_UNLOADING | ATA_PFLAG_SUSPENDED))) in ata_scsi_port_error_handler()
701 ap->ops->error_handler(ap); in ata_scsi_port_error_handler()
704 if ((ap->pflags & ATA_PFLAG_UNLOADING) && in ata_scsi_port_error_handler()
705 !(ap->pflags & ATA_PFLAG_UNLOADED)) in ata_scsi_port_error_handler()
706 ata_eh_unload(ap); in ata_scsi_port_error_handler()
707 ata_eh_finish(ap); in ata_scsi_port_error_handler()
711 ata_eh_handle_port_suspend(ap); in ata_scsi_port_error_handler()
717 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
719 if (ap->pflags & ATA_PFLAG_EH_PENDING) { in ata_scsi_port_error_handler()
720 if (--ap->eh_tries) { in ata_scsi_port_error_handler()
721 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
724 ata_port_err(ap, in ata_scsi_port_error_handler()
727 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
731 ata_for_each_link(link, ap, HOST_FIRST) in ata_scsi_port_error_handler()
735 * ap->lock such that if exception occurs after this in ata_scsi_port_error_handler()
739 ap->ops->end_eh(ap); in ata_scsi_port_error_handler()
741 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
742 ata_eh_release(ap); in ata_scsi_port_error_handler()
744 WARN_ON(ata_qc_from_tag(ap, ap->link.active_tag) == NULL); in ata_scsi_port_error_handler()
745 ap->ops->eng_timeout(ap); in ata_scsi_port_error_handler()
748 scsi_eh_flush_done_q(&ap->eh_done_q); in ata_scsi_port_error_handler()
751 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
753 if (ap->pflags & ATA_PFLAG_LOADING) in ata_scsi_port_error_handler()
754 ap->pflags &= ~ATA_PFLAG_LOADING; in ata_scsi_port_error_handler()
755 else if ((ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) && in ata_scsi_port_error_handler()
756 !(ap->flags & ATA_FLAG_SAS_HOST)) in ata_scsi_port_error_handler()
757 schedule_delayed_work(&ap->hotplug_task, 0); in ata_scsi_port_error_handler()
759 if (ap->pflags & ATA_PFLAG_RECOVERED) in ata_scsi_port_error_handler()
760 ata_port_info(ap, "EH complete\n"); in ata_scsi_port_error_handler()
762 ap->pflags &= ~(ATA_PFLAG_SCSI_HOTPLUG | ATA_PFLAG_RECOVERED); in ata_scsi_port_error_handler()
765 ap->pflags &= ~ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
766 wake_up_all(&ap->eh_wait_q); in ata_scsi_port_error_handler()
768 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
774 * @ap: Port to wait EH for
781 void ata_port_wait_eh(struct ata_port *ap) in ata_port_wait_eh() argument
787 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
789 while (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS)) { in ata_port_wait_eh()
790 prepare_to_wait(&ap->eh_wait_q, &wait, TASK_UNINTERRUPTIBLE); in ata_port_wait_eh()
791 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
793 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
795 finish_wait(&ap->eh_wait_q, &wait); in ata_port_wait_eh()
797 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
800 if (scsi_host_in_recovery(ap->scsi_host)) { in ata_port_wait_eh()
801 ata_msleep(ap, 10); in ata_port_wait_eh()
807 static unsigned int ata_eh_nr_in_flight(struct ata_port *ap) in ata_eh_nr_in_flight() argument
814 ata_qc_for_each(ap, qc, tag) { in ata_eh_nr_in_flight()
824 struct ata_port *ap = from_timer(ap, t, fastdrain_timer); in ata_eh_fastdrain_timerfn() local
828 spin_lock_irqsave(ap->lock, flags); in ata_eh_fastdrain_timerfn()
830 cnt = ata_eh_nr_in_flight(ap); in ata_eh_fastdrain_timerfn()
836 if (cnt == ap->fastdrain_cnt) { in ata_eh_fastdrain_timerfn()
843 ata_qc_for_each(ap, qc, tag) { in ata_eh_fastdrain_timerfn()
848 ata_port_freeze(ap); in ata_eh_fastdrain_timerfn()
851 ap->fastdrain_cnt = cnt; in ata_eh_fastdrain_timerfn()
852 ap->fastdrain_timer.expires = in ata_eh_fastdrain_timerfn()
854 add_timer(&ap->fastdrain_timer); in ata_eh_fastdrain_timerfn()
858 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_fastdrain_timerfn()
863 * @ap: target ATA port
873 static void ata_eh_set_pending(struct ata_port *ap, int fastdrain) in ata_eh_set_pending() argument
878 if (ap->pflags & ATA_PFLAG_EH_PENDING) in ata_eh_set_pending()
881 ap->pflags |= ATA_PFLAG_EH_PENDING; in ata_eh_set_pending()
887 cnt = ata_eh_nr_in_flight(ap); in ata_eh_set_pending()
892 ap->fastdrain_cnt = cnt; in ata_eh_set_pending()
893 ap->fastdrain_timer.expires = in ata_eh_set_pending()
895 add_timer(&ap->fastdrain_timer); in ata_eh_set_pending()
910 struct ata_port *ap = qc->ap; in ata_qc_schedule_eh() local
912 WARN_ON(!ap->ops->error_handler); in ata_qc_schedule_eh()
915 ata_eh_set_pending(ap, 1); in ata_qc_schedule_eh()
927 * @ap: ATA port to schedule EH for
932 void ata_std_sched_eh(struct ata_port *ap) in ata_std_sched_eh() argument
934 WARN_ON(!ap->ops->error_handler); in ata_std_sched_eh()
936 if (ap->pflags & ATA_PFLAG_INITIALIZING) in ata_std_sched_eh()
939 ata_eh_set_pending(ap, 1); in ata_std_sched_eh()
940 scsi_schedule_eh(ap->scsi_host); in ata_std_sched_eh()
942 trace_ata_std_sched_eh(ap); in ata_std_sched_eh()
948 * @ap: ATA port to end EH for
951 * shost, so host fields can be directly manipulated under ap->lock, in
958 void ata_std_end_eh(struct ata_port *ap) in ata_std_end_eh() argument
960 struct Scsi_Host *host = ap->scsi_host; in ata_std_end_eh()
969 * @ap: ATA port to schedule EH for
971 * Schedule error handling for @ap. EH will kick in as soon as
977 void ata_port_schedule_eh(struct ata_port *ap) in ata_port_schedule_eh() argument
980 ap->ops->sched_eh(ap); in ata_port_schedule_eh()
984 static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link) in ata_do_link_abort() argument
989 WARN_ON(!ap->ops->error_handler); in ata_do_link_abort()
992 ata_eh_set_pending(ap, 0); in ata_do_link_abort()
995 ata_qc_for_each_with_internal(ap, qc, tag) { in ata_do_link_abort()
1004 ata_port_schedule_eh(ap); in ata_do_link_abort()
1023 return ata_do_link_abort(link->ap, link); in ata_link_abort()
1029 * @ap: ATA port to abort qc's for
1031 * Abort all active qc's of @ap and schedule EH.
1039 int ata_port_abort(struct ata_port *ap) in ata_port_abort() argument
1041 return ata_do_link_abort(ap, NULL); in ata_port_abort()
1047 * @ap: ATA port to freeze
1054 * ap->ops->freeze() callback can be used for freezing the port
1063 static void __ata_port_freeze(struct ata_port *ap) in __ata_port_freeze() argument
1065 WARN_ON(!ap->ops->error_handler); in __ata_port_freeze()
1067 if (ap->ops->freeze) in __ata_port_freeze()
1068 ap->ops->freeze(ap); in __ata_port_freeze()
1070 ap->pflags |= ATA_PFLAG_FROZEN; in __ata_port_freeze()
1072 trace_ata_port_freeze(ap); in __ata_port_freeze()
1077 * @ap: ATA port to freeze
1079 * Abort and freeze @ap. The freeze operation must be called
1089 int ata_port_freeze(struct ata_port *ap) in ata_port_freeze() argument
1091 WARN_ON(!ap->ops->error_handler); in ata_port_freeze()
1093 __ata_port_freeze(ap); in ata_port_freeze()
1095 return ata_port_abort(ap); in ata_port_freeze()
1101 * @ap: ATA port to freeze
1103 * Freeze @ap.
1108 void ata_eh_freeze_port(struct ata_port *ap) in ata_eh_freeze_port() argument
1112 if (!ap->ops->error_handler) in ata_eh_freeze_port()
1115 spin_lock_irqsave(ap->lock, flags); in ata_eh_freeze_port()
1116 __ata_port_freeze(ap); in ata_eh_freeze_port()
1117 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_freeze_port()
1123 * @ap: ATA port to thaw
1125 * Thaw frozen port @ap.
1130 void ata_eh_thaw_port(struct ata_port *ap) in ata_eh_thaw_port() argument
1134 if (!ap->ops->error_handler) in ata_eh_thaw_port()
1137 spin_lock_irqsave(ap->lock, flags); in ata_eh_thaw_port()
1139 ap->pflags &= ~ATA_PFLAG_FROZEN; in ata_eh_thaw_port()
1141 if (ap->ops->thaw) in ata_eh_thaw_port()
1142 ap->ops->thaw(ap); in ata_eh_thaw_port()
1144 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_thaw_port()
1146 trace_ata_port_thaw(ap); in ata_eh_thaw_port()
1156 struct ata_port *ap = qc->ap; in __ata_eh_qc_complete() local
1160 spin_lock_irqsave(ap->lock, flags); in __ata_eh_qc_complete()
1164 spin_unlock_irqrestore(ap->lock, flags); in __ata_eh_qc_complete()
1166 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in __ata_eh_qc_complete()
1240 struct ata_port *ap = link->ap; in ata_eh_detach_dev() local
1246 spin_lock_irqsave(ap->lock, flags); in ata_eh_detach_dev()
1252 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_detach_dev()
1261 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_detach_dev()
1280 struct ata_port *ap = link->ap; in ata_eh_about_to_do() local
1287 spin_lock_irqsave(ap->lock, flags); in ata_eh_about_to_do()
1294 if (!(ehc->i.flags & ATA_EHI_QUIET) && link != ap->slave_link) in ata_eh_about_to_do()
1295 ap->pflags |= ATA_PFLAG_RECOVERED; in ata_eh_about_to_do()
1297 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_about_to_do()
1409 if (qc->ap->pflags & ATA_PFLAG_FROZEN) { in ata_eh_request_sense()
1459 struct ata_port *ap = dev->link->ap; in atapi_eh_request_sense() local
1477 if (ap->flags & ATA_FLAG_PIO_DMA) { in atapi_eh_request_sense()
1591 if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) { in ata_eh_analyze_tf()
1851 (link->ap->cbl != ATA_CBL_SATA || dev->class == ATA_DEV_ATAPI) && in ata_eh_speed_down()
1915 struct ata_port *ap = link->ap; in ata_eh_link_autopsy() local
1948 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_autopsy()
1998 if (ap->pflags & ATA_PFLAG_FROZEN || in ata_eh_link_autopsy()
2016 ap->link.eh_context.i.err_mask |= AC_ERR_TIMEOUT; in ata_eh_link_autopsy()
2034 * @ap: host port to perform autopsy on
2036 * Analyze all links of @ap and determine why they failed and
2042 void ata_eh_autopsy(struct ata_port *ap) in ata_eh_autopsy() argument
2046 ata_for_each_link(link, ap, EDGE) in ata_eh_autopsy()
2053 if (ap->slave_link) { in ata_eh_autopsy()
2054 struct ata_eh_context *mehc = &ap->link.eh_context; in ata_eh_autopsy()
2055 struct ata_eh_context *sehc = &ap->slave_link->eh_context; in ata_eh_autopsy()
2061 ata_eh_link_autopsy(ap->slave_link); in ata_eh_autopsy()
2064 ata_eh_about_to_do(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2068 ata_eh_done(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2074 if (sata_pmp_attached(ap)) in ata_eh_autopsy()
2075 ata_eh_link_autopsy(&ap->link); in ata_eh_autopsy()
2211 struct ata_port *ap = link->ap; in ata_eh_link_report() local
2225 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2241 if (ap->pflags & ATA_PFLAG_FROZEN) in ata_eh_link_report()
2244 if (ap->eh_tries < ATA_EH_MAX_TRIES) in ata_eh_link_report()
2246 ap->eh_tries); in ata_eh_link_report()
2287 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2397 * @ap: ATA port to report EH about
2404 void ata_eh_report(struct ata_port *ap) in ata_eh_report() argument
2408 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_report()
2431 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) in ata_eh_followup_srst_needed()
2440 struct ata_port *ap = link->ap; in ata_eh_reset() local
2441 struct ata_link *slave = ap->slave_link; in ata_eh_reset()
2478 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2479 ap->pflags |= ATA_PFLAG_RESETTING; in ata_eh_reset()
2480 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2500 if (ap->ops->set_piomode) in ata_eh_reset()
2501 ap->ops->set_piomode(ap, dev); in ata_eh_reset()
2562 if ((ap->pflags & ATA_PFLAG_FROZEN) && in ata_eh_reset()
2564 ata_eh_thaw_port(ap); in ata_eh_reset()
2575 ata_eh_freeze_port(ap); in ata_eh_reset()
2689 ata_eh_thaw_port(ap); in ata_eh_reset()
2714 spin_lock_irqsave(link->ap->lock, flags); in ata_eh_reset()
2718 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_eh_reset()
2719 spin_unlock_irqrestore(link->ap->lock, flags); in ata_eh_reset()
2721 if (ap->pflags & ATA_PFLAG_FROZEN) in ata_eh_reset()
2722 ata_eh_thaw_port(ap); in ata_eh_reset()
2782 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2783 ap->pflags &= ~ATA_PFLAG_RESETTING; in ata_eh_reset()
2784 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2802 ata_eh_thaw_port(ap); in ata_eh_reset()
2814 ata_eh_release(ap); in ata_eh_reset()
2817 ata_eh_acquire(ap); in ata_eh_reset()
2826 ata_eh_thaw_port(ap); in ata_eh_reset()
2842 static inline void ata_eh_pull_park_action(struct ata_port *ap) in ata_eh_pull_park_action() argument
2860 * Additionally, all write accesses to &ap->park_req_pending in ata_eh_pull_park_action()
2865 * *all* devices on port ap have been pulled into the in ata_eh_pull_park_action()
2870 * ap and we have to cycle over the do {} while () loop in in ata_eh_pull_park_action()
2874 spin_lock_irqsave(ap->lock, flags); in ata_eh_pull_park_action()
2875 reinit_completion(&ap->park_req_pending); in ata_eh_pull_park_action()
2876 ata_for_each_link(link, ap, EDGE) { in ata_eh_pull_park_action()
2885 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_pull_park_action()
2919 struct ata_port *ap = link->ap; in ata_eh_revalidate_and_attach() local
2948 * to ap->target_lpm_policy after revalidation is done. in ata_eh_revalidate_and_attach()
2976 schedule_work(&(ap->scsi_rescan_task)); in ata_eh_revalidate_and_attach()
3009 ata_eh_thaw_port(ap); in ata_eh_revalidate_and_attach()
3019 if (ap->ops->cable_detect) in ata_eh_revalidate_and_attach()
3020 ap->cbl = ap->ops->cable_detect(ap); in ata_eh_revalidate_and_attach()
3021 ata_force_cbl(ap); in ata_eh_revalidate_and_attach()
3044 spin_lock_irqsave(ap->lock, flags); in ata_eh_revalidate_and_attach()
3045 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_revalidate_and_attach()
3046 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_revalidate_and_attach()
3076 struct ata_port *ap = link->ap; in ata_set_mode() local
3092 if (ap->ops->set_mode) in ata_set_mode()
3093 rc = ap->ops->set_mode(link, r_failed_dev); in ata_set_mode()
3130 u8 *sense_buffer = dev->link->ap->sector_buf; in atapi_eh_clear_ua()
3179 struct ata_port *ap = link->ap; in ata_eh_maybe_retry_flush() local
3189 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_maybe_retry_flush()
3228 if (!(ap->pflags & ATA_PFLAG_FROZEN)) in ata_eh_maybe_retry_flush()
3255 struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL; in ata_eh_set_lpm() local
3259 bool no_dipm = link->ap->flags & ATA_FLAG_NO_DIPM; in ata_eh_set_lpm()
3266 (link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm)) in ata_eh_set_lpm()
3304 if (ap) { in ata_eh_set_lpm()
3305 rc = ap->ops->set_lpm(link, policy, hints); in ata_eh_set_lpm()
3306 if (!rc && ap->slave_link) in ata_eh_set_lpm()
3307 rc = ap->ops->set_lpm(ap->slave_link, policy, hints); in ata_eh_set_lpm()
3329 if (ap && ap->slave_link) in ata_eh_set_lpm()
3330 ap->slave_link->lpm_policy = policy; in ata_eh_set_lpm()
3356 if (ap && ap->slave_link) in ata_eh_set_lpm()
3357 ap->slave_link->lpm_policy = old_policy; in ata_eh_set_lpm()
3392 struct ata_port *ap = link->ap; in ata_eh_skip_recovery() local
3405 if ((ap->pflags & ATA_PFLAG_FROZEN) || ata_link_nr_enabled(link)) in ata_eh_skip_recovery()
3457 link->ap->ops->set_lpm(link, ATA_LPM_MAX_POWER, in ata_eh_schedule_probe()
3540 * @ap: host port to recover
3560 int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_eh_recover() argument
3571 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3577 spin_lock_irqsave(ap->lock, flags); in ata_eh_recover()
3579 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_recover()
3608 if (ap->pflags & ATA_PFLAG_UNLOADING) in ata_eh_recover()
3612 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3624 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3643 * ap->park_req_pending in ata_eh_recover()
3645 ata_eh_pull_park_action(ap); in ata_eh_recover()
3648 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3675 ata_eh_release(ap); in ata_eh_recover()
3676 deadline = wait_for_completion_timeout(&ap->park_req_pending, in ata_eh_recover()
3678 ata_eh_acquire(ap); in ata_eh_recover()
3680 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3693 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_recover()
3696 if (sata_pmp_attached(ap) && ata_is_host_link(link)) in ata_eh_recover()
3745 if (link->lpm_policy != ap->target_lpm_policy) { in ata_eh_recover()
3746 rc = ata_eh_set_lpm(link, ap->target_lpm_policy, &dev); in ata_eh_recover()
3760 if (ap->pflags & ATA_PFLAG_FROZEN) { in ata_eh_recover()
3764 if (sata_pmp_attached(ap)) in ata_eh_recover()
3782 * @ap: host port to finish EH for
3790 void ata_eh_finish(struct ata_port *ap) in ata_eh_finish() argument
3796 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_finish()
3821 WARN_ON(ap->nr_active_links); in ata_eh_finish()
3822 ap->nr_active_links = 0; in ata_eh_finish()
3827 * @ap: host port to handle error for
3839 void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_do_eh() argument
3846 ata_eh_autopsy(ap); in ata_do_eh()
3847 ata_eh_report(ap); in ata_do_eh()
3849 rc = ata_eh_recover(ap, prereset, softreset, hardreset, postreset, in ata_do_eh()
3852 ata_for_each_dev(dev, &ap->link, ALL) in ata_do_eh()
3856 ata_eh_finish(ap); in ata_do_eh()
3861 * @ap: host port to handle error for
3868 void ata_std_error_handler(struct ata_port *ap) in ata_std_error_handler() argument
3870 struct ata_port_operations *ops = ap->ops; in ata_std_error_handler()
3874 if (hardreset == sata_std_hardreset && !sata_scr_valid(&ap->link)) in ata_std_error_handler()
3877 ata_do_eh(ap, ops->prereset, ops->softreset, hardreset, ops->postreset); in ata_std_error_handler()
3884 * @ap: port to suspend
3886 * Suspend @ap.
3891 static void ata_eh_handle_port_suspend(struct ata_port *ap) in ata_eh_handle_port_suspend() argument
3898 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
3899 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_suspend()
3900 ap->pm_mesg.event & PM_EVENT_RESUME) { in ata_eh_handle_port_suspend()
3901 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
3904 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
3906 WARN_ON(ap->pflags & ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_suspend()
3913 if (PMSG_IS_AUTO(ap->pm_mesg)) { in ata_eh_handle_port_suspend()
3914 ata_for_each_dev(dev, &ap->link, ENABLED) { in ata_eh_handle_port_suspend()
3921 ata_eh_freeze_port(ap); in ata_eh_handle_port_suspend()
3923 if (ap->ops->port_suspend) in ata_eh_handle_port_suspend()
3924 rc = ap->ops->port_suspend(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
3926 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
3929 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
3931 ap->pflags &= ~ATA_PFLAG_PM_PENDING; in ata_eh_handle_port_suspend()
3933 ap->pflags |= ATA_PFLAG_SUSPENDED; in ata_eh_handle_port_suspend()
3934 else if (ap->pflags & ATA_PFLAG_FROZEN) in ata_eh_handle_port_suspend()
3935 ata_port_schedule_eh(ap); in ata_eh_handle_port_suspend()
3937 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
3944 * @ap: port to resume
3946 * Resume @ap.
3951 static void ata_eh_handle_port_resume(struct ata_port *ap) in ata_eh_handle_port_resume() argument
3958 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
3959 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_resume()
3960 !(ap->pm_mesg.event & PM_EVENT_RESUME)) { in ata_eh_handle_port_resume()
3961 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
3964 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
3966 WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED)); in ata_eh_handle_port_resume()
3975 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_handle_port_resume()
3979 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_resume()
3981 if (ap->ops->port_resume) in ata_eh_handle_port_resume()
3982 ap->ops->port_resume(ap); in ata_eh_handle_port_resume()
3985 ata_acpi_on_resume(ap); in ata_eh_handle_port_resume()
3988 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
3989 ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_resume()
3990 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()