Lines Matching full:ap

145 static void __ata_port_freeze(struct ata_port *ap);
147 static void ata_eh_handle_port_suspend(struct ata_port *ap);
148 static void ata_eh_handle_port_resume(struct ata_port *ap);
150 static void ata_eh_handle_port_suspend(struct ata_port *ap) in ata_eh_handle_port_suspend() argument
153 static void ata_eh_handle_port_resume(struct ata_port *ap) in ata_eh_handle_port_resume() argument
227 * @ap: target ATA port
238 void ata_port_desc(struct ata_port *ap, const char *fmt, ...) in ata_port_desc() argument
242 WARN_ON(!(ap->pflags & ATA_PFLAG_INITIALIZING)); in ata_port_desc()
244 if (ap->link.eh_info.desc_len) in ata_port_desc()
245 __ata_ehi_push_desc(&ap->link.eh_info, " "); in ata_port_desc()
248 __ata_ehi_pushv_desc(&ap->link.eh_info, fmt, args); in ata_port_desc()
256 * @ap: target ATA port
269 void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset, in ata_port_pbar_desc() argument
272 struct pci_dev *pdev = to_pci_dev(ap->host->dev); in ata_port_pbar_desc()
285 ata_port_desc(ap, "%s %s%llu@0x%llx", name, type, len, start); in ata_port_pbar_desc()
287 ata_port_desc(ap, "%s 0x%llx", name, in ata_port_pbar_desc()
452 * @ap: ATA port to acquire EH ownership for
454 * Acquire EH ownership for @ap. This is the basic exclusion
461 void ata_eh_acquire(struct ata_port *ap) in ata_eh_acquire() argument
463 mutex_lock(&ap->host->eh_mutex); in ata_eh_acquire()
464 WARN_ON_ONCE(ap->host->eh_owner); in ata_eh_acquire()
465 ap->host->eh_owner = current; in ata_eh_acquire()
470 * @ap: ATA port to release EH ownership for
472 * Release EH ownership for @ap if the caller. The caller must
478 void ata_eh_release(struct ata_port *ap) in ata_eh_release() argument
480 WARN_ON_ONCE(ap->host->eh_owner != current); in ata_eh_release()
481 ap->host->eh_owner = NULL; in ata_eh_release()
482 mutex_unlock(&ap->host->eh_mutex); in ata_eh_release()
485 static void ata_eh_unload(struct ata_port *ap) in ata_eh_unload() argument
494 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_unload()
501 spin_lock_irqsave(ap->lock, flags); in ata_eh_unload()
503 ata_port_freeze(ap); /* won't be thawed */ in ata_eh_unload()
504 ap->pflags &= ~ATA_PFLAG_EH_PENDING; /* clear pending from freeze */ in ata_eh_unload()
505 ap->pflags |= ATA_PFLAG_UNLOADED; in ata_eh_unload()
507 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_unload()
524 struct ata_port *ap = ata_shost_to_port(host); in ata_scsi_error() local
534 ata_scsi_cmd_error_handler(host, ap, &eh_work_q); in ata_scsi_error()
538 ata_scsi_port_error_handler(host, ap); in ata_scsi_error()
549 * @ap: ATA port within the host
553 * ap->eh_done_q. This function is the first part of the libata error
556 void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, in ata_scsi_cmd_error_handler() argument
563 ata_sff_flush_pio_task(ap); in ata_scsi_cmd_error_handler()
579 spin_lock_irqsave(ap->lock, flags); in ata_scsi_cmd_error_handler()
580 if (ap->ops->error_handler) { in ata_scsi_cmd_error_handler()
584 /* This must occur under the ap->lock as we don't want in ata_scsi_cmd_error_handler()
593 if (ap->ops->lost_interrupt) in ata_scsi_cmd_error_handler()
594 ap->ops->lost_interrupt(ap); in ata_scsi_cmd_error_handler()
599 ata_qc_for_each_raw(ap, qc, i) { in ata_scsi_cmd_error_handler()
619 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in ata_scsi_cmd_error_handler()
630 __ata_port_freeze(ap); in ata_scsi_cmd_error_handler()
634 ap->eh_tries = ATA_EH_MAX_TRIES; in ata_scsi_cmd_error_handler()
636 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_cmd_error_handler()
644 * @ap: the ATA port
646 * Handle the recovery of the port @ap after all the commands
649 void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap) in ata_scsi_port_error_handler() argument
654 if (ap->ops->error_handler) { in ata_scsi_port_error_handler()
658 ata_eh_acquire(ap); in ata_scsi_port_error_handler()
661 del_timer_sync(&ap->fastdrain_timer); in ata_scsi_port_error_handler()
664 ata_eh_handle_port_resume(ap); in ata_scsi_port_error_handler()
667 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
669 ata_for_each_link(link, ap, HOST_FIRST) { in ata_scsi_port_error_handler()
686 ap->pflags |= ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
687 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
688 ap->excl_link = NULL; /* don't maintain exclusion over EH */ in ata_scsi_port_error_handler()
690 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
693 if (!(ap->pflags & (ATA_PFLAG_UNLOADING | ATA_PFLAG_SUSPENDED))) in ata_scsi_port_error_handler()
694 ap->ops->error_handler(ap); in ata_scsi_port_error_handler()
697 if ((ap->pflags & ATA_PFLAG_UNLOADING) && in ata_scsi_port_error_handler()
698 !(ap->pflags & ATA_PFLAG_UNLOADED)) in ata_scsi_port_error_handler()
699 ata_eh_unload(ap); in ata_scsi_port_error_handler()
700 ata_eh_finish(ap); in ata_scsi_port_error_handler()
704 ata_eh_handle_port_suspend(ap); in ata_scsi_port_error_handler()
710 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
712 if (ap->pflags & ATA_PFLAG_EH_PENDING) { in ata_scsi_port_error_handler()
713 if (--ap->eh_tries) { in ata_scsi_port_error_handler()
714 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
717 ata_port_err(ap, in ata_scsi_port_error_handler()
720 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
724 ata_for_each_link(link, ap, HOST_FIRST) in ata_scsi_port_error_handler()
728 * ap->lock such that if exception occurs after this in ata_scsi_port_error_handler()
732 ap->ops->end_eh(ap); in ata_scsi_port_error_handler()
734 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
735 ata_eh_release(ap); in ata_scsi_port_error_handler()
737 WARN_ON(ata_qc_from_tag(ap, ap->link.active_tag) == NULL); in ata_scsi_port_error_handler()
738 ap->ops->eng_timeout(ap); in ata_scsi_port_error_handler()
741 scsi_eh_flush_done_q(&ap->eh_done_q); 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_LOADING) in ata_scsi_port_error_handler()
747 ap->pflags &= ~ATA_PFLAG_LOADING; in ata_scsi_port_error_handler()
748 else if ((ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) && in ata_scsi_port_error_handler()
749 !(ap->flags & ATA_FLAG_SAS_HOST)) in ata_scsi_port_error_handler()
750 schedule_delayed_work(&ap->hotplug_task, 0); in ata_scsi_port_error_handler()
752 if (ap->pflags & ATA_PFLAG_RECOVERED) in ata_scsi_port_error_handler()
753 ata_port_info(ap, "EH complete\n"); in ata_scsi_port_error_handler()
755 ap->pflags &= ~(ATA_PFLAG_SCSI_HOTPLUG | ATA_PFLAG_RECOVERED); in ata_scsi_port_error_handler()
758 ap->pflags &= ~ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
759 wake_up_all(&ap->eh_wait_q); in ata_scsi_port_error_handler()
761 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
767 * @ap: Port to wait EH for
774 void ata_port_wait_eh(struct ata_port *ap) in ata_port_wait_eh() argument
780 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
782 while (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS)) { in ata_port_wait_eh()
783 prepare_to_wait(&ap->eh_wait_q, &wait, TASK_UNINTERRUPTIBLE); in ata_port_wait_eh()
784 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
786 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
788 finish_wait(&ap->eh_wait_q, &wait); in ata_port_wait_eh()
790 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
793 if (scsi_host_in_recovery(ap->scsi_host)) { in ata_port_wait_eh()
794 ata_msleep(ap, 10); in ata_port_wait_eh()
800 static int ata_eh_nr_in_flight(struct ata_port *ap) in ata_eh_nr_in_flight() argument
807 ata_qc_for_each(ap, qc, tag) { in ata_eh_nr_in_flight()
817 struct ata_port *ap = from_timer(ap, t, fastdrain_timer); in ata_eh_fastdrain_timerfn() local
821 spin_lock_irqsave(ap->lock, flags); in ata_eh_fastdrain_timerfn()
823 cnt = ata_eh_nr_in_flight(ap); in ata_eh_fastdrain_timerfn()
829 if (cnt == ap->fastdrain_cnt) { in ata_eh_fastdrain_timerfn()
836 ata_qc_for_each(ap, qc, tag) { in ata_eh_fastdrain_timerfn()
841 ata_port_freeze(ap); in ata_eh_fastdrain_timerfn()
844 ap->fastdrain_cnt = cnt; in ata_eh_fastdrain_timerfn()
845 ap->fastdrain_timer.expires = in ata_eh_fastdrain_timerfn()
847 add_timer(&ap->fastdrain_timer); in ata_eh_fastdrain_timerfn()
851 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_fastdrain_timerfn()
856 * @ap: target ATA port
866 static void ata_eh_set_pending(struct ata_port *ap, int fastdrain) in ata_eh_set_pending() argument
871 if (ap->pflags & ATA_PFLAG_EH_PENDING) in ata_eh_set_pending()
874 ap->pflags |= ATA_PFLAG_EH_PENDING; in ata_eh_set_pending()
880 cnt = ata_eh_nr_in_flight(ap); in ata_eh_set_pending()
885 ap->fastdrain_cnt = cnt; in ata_eh_set_pending()
886 ap->fastdrain_timer.expires = in ata_eh_set_pending()
888 add_timer(&ap->fastdrain_timer); in ata_eh_set_pending()
903 struct ata_port *ap = qc->ap; in ata_qc_schedule_eh() local
905 WARN_ON(!ap->ops->error_handler); in ata_qc_schedule_eh()
908 ata_eh_set_pending(ap, 1); in ata_qc_schedule_eh()
920 * @ap: ATA port to schedule EH for
925 void ata_std_sched_eh(struct ata_port *ap) in ata_std_sched_eh() argument
927 WARN_ON(!ap->ops->error_handler); in ata_std_sched_eh()
929 if (ap->pflags & ATA_PFLAG_INITIALIZING) in ata_std_sched_eh()
932 ata_eh_set_pending(ap, 1); in ata_std_sched_eh()
933 scsi_schedule_eh(ap->scsi_host); in ata_std_sched_eh()
941 * @ap: ATA port to end EH for
944 * shost, so host fields can be directly manipulated under ap->lock, in
951 void ata_std_end_eh(struct ata_port *ap) in ata_std_end_eh() argument
953 struct Scsi_Host *host = ap->scsi_host; in ata_std_end_eh()
962 * @ap: ATA port to schedule EH for
964 * Schedule error handling for @ap. EH will kick in as soon as
970 void ata_port_schedule_eh(struct ata_port *ap) in ata_port_schedule_eh() argument
973 ap->ops->sched_eh(ap); in ata_port_schedule_eh()
977 static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link) in ata_do_link_abort() argument
982 WARN_ON(!ap->ops->error_handler); in ata_do_link_abort()
985 ata_eh_set_pending(ap, 0); in ata_do_link_abort()
988 ata_qc_for_each_with_internal(ap, qc, tag) { in ata_do_link_abort()
997 ata_port_schedule_eh(ap); in ata_do_link_abort()
1016 return ata_do_link_abort(link->ap, link); in ata_link_abort()
1022 * @ap: ATA port to abort qc's for
1024 * Abort all active qc's of @ap and schedule EH.
1032 int ata_port_abort(struct ata_port *ap) in ata_port_abort() argument
1034 return ata_do_link_abort(ap, NULL); in ata_port_abort()
1040 * @ap: ATA port to freeze
1047 * ap->ops->freeze() callback can be used for freezing the port
1056 static void __ata_port_freeze(struct ata_port *ap) in __ata_port_freeze() argument
1058 WARN_ON(!ap->ops->error_handler); in __ata_port_freeze()
1060 if (ap->ops->freeze) in __ata_port_freeze()
1061 ap->ops->freeze(ap); in __ata_port_freeze()
1063 ap->pflags |= ATA_PFLAG_FROZEN; in __ata_port_freeze()
1065 DPRINTK("ata%u port frozen\n", ap->print_id); in __ata_port_freeze()
1070 * @ap: ATA port to freeze
1072 * Abort and freeze @ap. The freeze operation must be called
1082 int ata_port_freeze(struct ata_port *ap) in ata_port_freeze() argument
1086 WARN_ON(!ap->ops->error_handler); in ata_port_freeze()
1088 __ata_port_freeze(ap); in ata_port_freeze()
1089 nr_aborted = ata_port_abort(ap); in ata_port_freeze()
1097 * @ap: ATA port to freeze
1099 * Freeze @ap.
1104 void ata_eh_freeze_port(struct ata_port *ap) in ata_eh_freeze_port() argument
1108 if (!ap->ops->error_handler) in ata_eh_freeze_port()
1111 spin_lock_irqsave(ap->lock, flags); in ata_eh_freeze_port()
1112 __ata_port_freeze(ap); in ata_eh_freeze_port()
1113 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_freeze_port()
1119 * @ap: ATA port to thaw
1121 * Thaw frozen port @ap.
1126 void ata_eh_thaw_port(struct ata_port *ap) in ata_eh_thaw_port() argument
1130 if (!ap->ops->error_handler) in ata_eh_thaw_port()
1133 spin_lock_irqsave(ap->lock, flags); in ata_eh_thaw_port()
1135 ap->pflags &= ~ATA_PFLAG_FROZEN; in ata_eh_thaw_port()
1137 if (ap->ops->thaw) in ata_eh_thaw_port()
1138 ap->ops->thaw(ap); in ata_eh_thaw_port()
1140 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_thaw_port()
1142 DPRINTK("ata%u port thawed\n", ap->print_id); in ata_eh_thaw_port()
1152 struct ata_port *ap = qc->ap; in __ata_eh_qc_complete() local
1156 spin_lock_irqsave(ap->lock, flags); in __ata_eh_qc_complete()
1160 spin_unlock_irqrestore(ap->lock, flags); in __ata_eh_qc_complete()
1162 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in __ata_eh_qc_complete()
1212 if (ata_msg_drv(dev->link->ap)) in ata_dev_disable()
1237 struct ata_port *ap = link->ap; in ata_eh_detach_dev() local
1243 spin_lock_irqsave(ap->lock, flags); in ata_eh_detach_dev()
1249 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_detach_dev()
1258 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_detach_dev()
1277 struct ata_port *ap = link->ap; in ata_eh_about_to_do() local
1282 spin_lock_irqsave(ap->lock, flags); in ata_eh_about_to_do()
1289 if (!(ehc->i.flags & ATA_EHI_QUIET) && link != ap->slave_link) in ata_eh_about_to_do()
1290 ap->pflags |= ATA_PFLAG_RECOVERED; in ata_eh_about_to_do()
1292 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_about_to_do()
1403 if (qc->ap->pflags & ATA_PFLAG_FROZEN) { in ata_eh_request_sense()
1455 struct ata_port *ap = dev->link->ap; in atapi_eh_request_sense() local
1475 if (ap->flags & ATA_FLAG_PIO_DMA) { in atapi_eh_request_sense()
1590 if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) { in ata_eh_analyze_tf()
1850 (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
1950 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_autopsy()
2000 if (ap->pflags & ATA_PFLAG_FROZEN || in ata_eh_link_autopsy()
2018 ap->link.eh_context.i.err_mask |= AC_ERR_TIMEOUT; in ata_eh_link_autopsy()
2037 * @ap: host port to perform autopsy on
2039 * Analyze all links of @ap and determine why they failed and
2045 void ata_eh_autopsy(struct ata_port *ap) in ata_eh_autopsy() argument
2049 ata_for_each_link(link, ap, EDGE) in ata_eh_autopsy()
2056 if (ap->slave_link) { in ata_eh_autopsy()
2057 struct ata_eh_context *mehc = &ap->link.eh_context; in ata_eh_autopsy()
2058 struct ata_eh_context *sehc = &ap->slave_link->eh_context; in ata_eh_autopsy()
2064 ata_eh_link_autopsy(ap->slave_link); in ata_eh_autopsy()
2067 ata_eh_about_to_do(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2071 ata_eh_done(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2077 if (sata_pmp_attached(ap)) in ata_eh_autopsy()
2078 ata_eh_link_autopsy(&ap->link); in ata_eh_autopsy()
2214 struct ata_port *ap = link->ap; in ata_eh_link_report() local
2228 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2244 if (ap->pflags & ATA_PFLAG_FROZEN) in ata_eh_link_report()
2247 if (ap->eh_tries < ATA_EH_MAX_TRIES) in ata_eh_link_report()
2249 ap->eh_tries); in ata_eh_link_report()
2290 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2403 * @ap: ATA port to report EH about
2410 void ata_eh_report(struct ata_port *ap) in ata_eh_report() argument
2414 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_report()
2437 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) in ata_eh_followup_srst_needed()
2446 struct ata_port *ap = link->ap; in ata_eh_reset() local
2447 struct ata_link *slave = ap->slave_link; in ata_eh_reset()
2484 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2485 ap->pflags |= ATA_PFLAG_RESETTING; in ata_eh_reset()
2486 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2506 if (ap->ops->set_piomode) in ata_eh_reset()
2507 ap->ops->set_piomode(ap, dev); in ata_eh_reset()
2568 if ((ap->pflags & ATA_PFLAG_FROZEN) && in ata_eh_reset()
2570 ata_eh_thaw_port(ap); in ata_eh_reset()
2581 ata_eh_freeze_port(ap); in ata_eh_reset()
2682 ata_eh_thaw_port(ap); in ata_eh_reset()
2704 spin_lock_irqsave(link->ap->lock, flags); in ata_eh_reset()
2708 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_eh_reset()
2709 spin_unlock_irqrestore(link->ap->lock, flags); in ata_eh_reset()
2711 if (ap->pflags & ATA_PFLAG_FROZEN) in ata_eh_reset()
2712 ata_eh_thaw_port(ap); in ata_eh_reset()
2772 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2773 ap->pflags &= ~ATA_PFLAG_RESETTING; in ata_eh_reset()
2774 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2792 ata_eh_thaw_port(ap); in ata_eh_reset()
2804 ata_eh_release(ap); in ata_eh_reset()
2807 ata_eh_acquire(ap); in ata_eh_reset()
2816 ata_eh_thaw_port(ap); in ata_eh_reset()
2832 static inline void ata_eh_pull_park_action(struct ata_port *ap) in ata_eh_pull_park_action() argument
2850 * Additionally, all write accesses to &ap->park_req_pending in ata_eh_pull_park_action()
2855 * *all* devices on port ap have been pulled into the in ata_eh_pull_park_action()
2860 * ap and we have to cycle over the do {} while () loop in in ata_eh_pull_park_action()
2864 spin_lock_irqsave(ap->lock, flags); in ata_eh_pull_park_action()
2865 reinit_completion(&ap->park_req_pending); in ata_eh_pull_park_action()
2866 ata_for_each_link(link, ap, EDGE) { in ata_eh_pull_park_action()
2875 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_pull_park_action()
2909 struct ata_port *ap = link->ap; in ata_eh_revalidate_and_attach() local
2951 schedule_work(&(ap->scsi_rescan_task)); in ata_eh_revalidate_and_attach()
2984 ata_eh_thaw_port(ap); in ata_eh_revalidate_and_attach()
2994 if (ap->ops->cable_detect) in ata_eh_revalidate_and_attach()
2995 ap->cbl = ap->ops->cable_detect(ap); in ata_eh_revalidate_and_attach()
2996 ata_force_cbl(ap); in ata_eh_revalidate_and_attach()
3019 spin_lock_irqsave(ap->lock, flags); in ata_eh_revalidate_and_attach()
3020 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_revalidate_and_attach()
3021 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_revalidate_and_attach()
3052 struct ata_port *ap = link->ap; in ata_set_mode() local
3068 if (ap->ops->set_mode) in ata_set_mode()
3069 rc = ap->ops->set_mode(link, r_failed_dev); in ata_set_mode()
3106 u8 *sense_buffer = dev->link->ap->sector_buf; in atapi_eh_clear_ua()
3155 struct ata_port *ap = link->ap; in ata_eh_maybe_retry_flush() local
3165 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_maybe_retry_flush()
3204 if (!(ap->pflags & ATA_PFLAG_FROZEN)) in ata_eh_maybe_retry_flush()
3231 struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL; in ata_eh_set_lpm() local
3235 bool no_dipm = link->ap->flags & ATA_FLAG_NO_DIPM; in ata_eh_set_lpm()
3242 (link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm)) in ata_eh_set_lpm()
3280 if (ap) { in ata_eh_set_lpm()
3281 rc = ap->ops->set_lpm(link, policy, hints); in ata_eh_set_lpm()
3282 if (!rc && ap->slave_link) in ata_eh_set_lpm()
3283 rc = ap->ops->set_lpm(ap->slave_link, policy, hints); in ata_eh_set_lpm()
3305 if (ap && ap->slave_link) in ata_eh_set_lpm()
3306 ap->slave_link->lpm_policy = policy; in ata_eh_set_lpm()
3332 if (ap && ap->slave_link) in ata_eh_set_lpm()
3333 ap->slave_link->lpm_policy = old_policy; in ata_eh_set_lpm()
3368 struct ata_port *ap = link->ap; in ata_eh_skip_recovery() local
3381 if ((ap->pflags & ATA_PFLAG_FROZEN) || ata_link_nr_enabled(link)) in ata_eh_skip_recovery()
3433 link->ap->ops->set_lpm(link, ATA_LPM_MAX_POWER, in ata_eh_schedule_probe()
3516 * @ap: host port to recover
3536 int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_eh_recover() argument
3549 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3555 spin_lock_irqsave(ap->lock, flags); in ata_eh_recover()
3557 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_recover()
3586 if (ap->pflags & ATA_PFLAG_UNLOADING) in ata_eh_recover()
3590 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3602 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3621 * ap->park_req_pending in ata_eh_recover()
3623 ata_eh_pull_park_action(ap); in ata_eh_recover()
3626 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3653 ata_eh_release(ap); in ata_eh_recover()
3654 deadline = wait_for_completion_timeout(&ap->park_req_pending, in ata_eh_recover()
3656 ata_eh_acquire(ap); in ata_eh_recover()
3658 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3671 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_recover()
3674 if (sata_pmp_attached(ap) && ata_is_host_link(link)) in ata_eh_recover()
3723 if (link->lpm_policy != ap->target_lpm_policy) { in ata_eh_recover()
3724 rc = ata_eh_set_lpm(link, ap->target_lpm_policy, &dev); in ata_eh_recover()
3738 if (ap->pflags & ATA_PFLAG_FROZEN) { in ata_eh_recover()
3742 if (sata_pmp_attached(ap)) in ata_eh_recover()
3761 * @ap: host port to finish EH for
3769 void ata_eh_finish(struct ata_port *ap) in ata_eh_finish() argument
3775 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_finish()
3800 WARN_ON(ap->nr_active_links); in ata_eh_finish()
3801 ap->nr_active_links = 0; in ata_eh_finish()
3806 * @ap: host port to handle error for
3818 void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_do_eh() argument
3825 ata_eh_autopsy(ap); in ata_do_eh()
3826 ata_eh_report(ap); in ata_do_eh()
3828 rc = ata_eh_recover(ap, prereset, softreset, hardreset, postreset, in ata_do_eh()
3831 ata_for_each_dev(dev, &ap->link, ALL) in ata_do_eh()
3835 ata_eh_finish(ap); in ata_do_eh()
3840 * @ap: host port to handle error for
3847 void ata_std_error_handler(struct ata_port *ap) in ata_std_error_handler() argument
3849 struct ata_port_operations *ops = ap->ops; in ata_std_error_handler()
3853 if (hardreset == sata_std_hardreset && !sata_scr_valid(&ap->link)) in ata_std_error_handler()
3856 ata_do_eh(ap, ops->prereset, ops->softreset, hardreset, ops->postreset); in ata_std_error_handler()
3863 * @ap: port to suspend
3865 * Suspend @ap.
3870 static void ata_eh_handle_port_suspend(struct ata_port *ap) in ata_eh_handle_port_suspend() argument
3877 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
3878 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_suspend()
3879 ap->pm_mesg.event & PM_EVENT_RESUME) { in ata_eh_handle_port_suspend()
3880 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
3883 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
3885 WARN_ON(ap->pflags & ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_suspend()
3892 if (PMSG_IS_AUTO(ap->pm_mesg)) { in ata_eh_handle_port_suspend()
3893 ata_for_each_dev(dev, &ap->link, ENABLED) { in ata_eh_handle_port_suspend()
3900 rc = ata_acpi_on_suspend(ap); in ata_eh_handle_port_suspend()
3905 ata_eh_freeze_port(ap); in ata_eh_handle_port_suspend()
3907 if (ap->ops->port_suspend) in ata_eh_handle_port_suspend()
3908 rc = ap->ops->port_suspend(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
3910 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
3913 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
3915 ap->pflags &= ~ATA_PFLAG_PM_PENDING; in ata_eh_handle_port_suspend()
3917 ap->pflags |= ATA_PFLAG_SUSPENDED; in ata_eh_handle_port_suspend()
3918 else if (ap->pflags & ATA_PFLAG_FROZEN) in ata_eh_handle_port_suspend()
3919 ata_port_schedule_eh(ap); in ata_eh_handle_port_suspend()
3921 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
3928 * @ap: port to resume
3930 * Resume @ap.
3935 static void ata_eh_handle_port_resume(struct ata_port *ap) in ata_eh_handle_port_resume() argument
3942 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
3943 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_resume()
3944 !(ap->pm_mesg.event & PM_EVENT_RESUME)) { in ata_eh_handle_port_resume()
3945 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
3948 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
3950 WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED)); in ata_eh_handle_port_resume()
3959 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_handle_port_resume()
3963 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_resume()
3965 if (ap->ops->port_resume) in ata_eh_handle_port_resume()
3966 ap->ops->port_resume(ap); in ata_eh_handle_port_resume()
3969 ata_acpi_on_resume(ap); in ata_eh_handle_port_resume()
3972 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
3973 ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_resume()
3974 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()