Lines Matching refs:ap

166 static void __ata_port_freeze(struct ata_port *ap);
168 static void ata_eh_handle_port_suspend(struct ata_port *ap);
169 static void ata_eh_handle_port_resume(struct ata_port *ap);
171 static void ata_eh_handle_port_suspend(struct ata_port *ap) in ata_eh_handle_port_suspend() argument
174 static void ata_eh_handle_port_resume(struct ata_port *ap) in ata_eh_handle_port_resume() argument
256 void ata_port_desc(struct ata_port *ap, const char *fmt, ...) in ata_port_desc() argument
260 WARN_ON(!(ap->pflags & ATA_PFLAG_INITIALIZING)); in ata_port_desc()
262 if (ap->link.eh_info.desc_len) in ata_port_desc()
263 __ata_ehi_push_desc(&ap->link.eh_info, " "); in ata_port_desc()
266 __ata_ehi_pushv_desc(&ap->link.eh_info, fmt, args); in ata_port_desc()
287 void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset, in ata_port_pbar_desc() argument
290 struct pci_dev *pdev = to_pci_dev(ap->host->dev); in ata_port_pbar_desc()
303 ata_port_desc(ap, "%s %s%llu@0x%llx", name, type, len, start); in ata_port_pbar_desc()
305 ata_port_desc(ap, "%s 0x%llx", name, in ata_port_pbar_desc()
479 void ata_eh_acquire(struct ata_port *ap) in ata_eh_acquire() argument
481 mutex_lock(&ap->host->eh_mutex); in ata_eh_acquire()
482 WARN_ON_ONCE(ap->host->eh_owner); in ata_eh_acquire()
483 ap->host->eh_owner = current; in ata_eh_acquire()
496 void ata_eh_release(struct ata_port *ap) in ata_eh_release() argument
498 WARN_ON_ONCE(ap->host->eh_owner != current); in ata_eh_release()
499 ap->host->eh_owner = NULL; in ata_eh_release()
500 mutex_unlock(&ap->host->eh_mutex); in ata_eh_release()
503 static void ata_eh_unload(struct ata_port *ap) in ata_eh_unload() argument
512 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_unload()
519 spin_lock_irqsave(ap->lock, flags); in ata_eh_unload()
521 ata_port_freeze(ap); /* won't be thawed */ in ata_eh_unload()
522 ap->pflags &= ~ATA_PFLAG_EH_PENDING; /* clear pending from freeze */ in ata_eh_unload()
523 ap->pflags |= ATA_PFLAG_UNLOADED; in ata_eh_unload()
525 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_unload()
542 struct ata_port *ap = ata_shost_to_port(host); in ata_scsi_error() local
552 ata_scsi_cmd_error_handler(host, ap, &eh_work_q); in ata_scsi_error()
556 ata_scsi_port_error_handler(host, ap); in ata_scsi_error()
574 void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, in ata_scsi_cmd_error_handler() argument
581 ata_sff_flush_pio_task(ap); in ata_scsi_cmd_error_handler()
597 spin_lock_irqsave(ap->lock, flags); in ata_scsi_cmd_error_handler()
598 if (ap->ops->error_handler) { in ata_scsi_cmd_error_handler()
611 if (ap->ops->lost_interrupt) in ata_scsi_cmd_error_handler()
612 ap->ops->lost_interrupt(ap); in ata_scsi_cmd_error_handler()
617 ata_qc_for_each_raw(ap, qc, i) { in ata_scsi_cmd_error_handler()
637 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in ata_scsi_cmd_error_handler()
648 __ata_port_freeze(ap); in ata_scsi_cmd_error_handler()
652 ap->eh_tries = ATA_EH_MAX_TRIES; in ata_scsi_cmd_error_handler()
654 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_cmd_error_handler()
667 void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap) in ata_scsi_port_error_handler() argument
672 if (ap->ops->error_handler) { in ata_scsi_port_error_handler()
676 ata_eh_acquire(ap); in ata_scsi_port_error_handler()
679 del_timer_sync(&ap->fastdrain_timer); in ata_scsi_port_error_handler()
682 ata_eh_handle_port_resume(ap); in ata_scsi_port_error_handler()
685 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
687 ata_for_each_link(link, ap, HOST_FIRST) { in ata_scsi_port_error_handler()
704 ap->pflags |= ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
705 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
706 ap->excl_link = NULL; /* don't maintain exclusion over EH */ in ata_scsi_port_error_handler()
708 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
711 if (!(ap->pflags & (ATA_PFLAG_UNLOADING | ATA_PFLAG_SUSPENDED))) in ata_scsi_port_error_handler()
712 ap->ops->error_handler(ap); in ata_scsi_port_error_handler()
715 if ((ap->pflags & ATA_PFLAG_UNLOADING) && in ata_scsi_port_error_handler()
716 !(ap->pflags & ATA_PFLAG_UNLOADED)) in ata_scsi_port_error_handler()
717 ata_eh_unload(ap); in ata_scsi_port_error_handler()
718 ata_eh_finish(ap); in ata_scsi_port_error_handler()
722 ata_eh_handle_port_suspend(ap); in ata_scsi_port_error_handler()
728 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
730 if (ap->pflags & ATA_PFLAG_EH_PENDING) { in ata_scsi_port_error_handler()
731 if (--ap->eh_tries) { in ata_scsi_port_error_handler()
732 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
735 ata_port_err(ap, in ata_scsi_port_error_handler()
738 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
742 ata_for_each_link(link, ap, HOST_FIRST) in ata_scsi_port_error_handler()
750 ap->ops->end_eh(ap); in ata_scsi_port_error_handler()
752 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
753 ata_eh_release(ap); in ata_scsi_port_error_handler()
755 WARN_ON(ata_qc_from_tag(ap, ap->link.active_tag) == NULL); in ata_scsi_port_error_handler()
756 ap->ops->eng_timeout(ap); in ata_scsi_port_error_handler()
759 scsi_eh_flush_done_q(&ap->eh_done_q); in ata_scsi_port_error_handler()
762 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
764 if (ap->pflags & ATA_PFLAG_LOADING) in ata_scsi_port_error_handler()
765 ap->pflags &= ~ATA_PFLAG_LOADING; in ata_scsi_port_error_handler()
766 else if ((ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) && in ata_scsi_port_error_handler()
767 !(ap->flags & ATA_FLAG_SAS_HOST)) in ata_scsi_port_error_handler()
768 schedule_delayed_work(&ap->hotplug_task, 0); in ata_scsi_port_error_handler()
770 if (ap->pflags & ATA_PFLAG_RECOVERED) in ata_scsi_port_error_handler()
771 ata_port_info(ap, "EH complete\n"); in ata_scsi_port_error_handler()
773 ap->pflags &= ~(ATA_PFLAG_SCSI_HOTPLUG | ATA_PFLAG_RECOVERED); in ata_scsi_port_error_handler()
776 ap->pflags &= ~ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
777 wake_up_all(&ap->eh_wait_q); in ata_scsi_port_error_handler()
779 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
792 void ata_port_wait_eh(struct ata_port *ap) in ata_port_wait_eh() argument
798 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
800 while (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS)) { in ata_port_wait_eh()
801 prepare_to_wait(&ap->eh_wait_q, &wait, TASK_UNINTERRUPTIBLE); in ata_port_wait_eh()
802 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
804 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
806 finish_wait(&ap->eh_wait_q, &wait); in ata_port_wait_eh()
808 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
811 if (scsi_host_in_recovery(ap->scsi_host)) { in ata_port_wait_eh()
812 ata_msleep(ap, 10); in ata_port_wait_eh()
818 static int ata_eh_nr_in_flight(struct ata_port *ap) in ata_eh_nr_in_flight() argument
825 ata_qc_for_each(ap, qc, tag) { in ata_eh_nr_in_flight()
835 struct ata_port *ap = from_timer(ap, t, fastdrain_timer); in ata_eh_fastdrain_timerfn() local
839 spin_lock_irqsave(ap->lock, flags); in ata_eh_fastdrain_timerfn()
841 cnt = ata_eh_nr_in_flight(ap); in ata_eh_fastdrain_timerfn()
847 if (cnt == ap->fastdrain_cnt) { in ata_eh_fastdrain_timerfn()
854 ata_qc_for_each(ap, qc, tag) { in ata_eh_fastdrain_timerfn()
859 ata_port_freeze(ap); in ata_eh_fastdrain_timerfn()
862 ap->fastdrain_cnt = cnt; in ata_eh_fastdrain_timerfn()
863 ap->fastdrain_timer.expires = in ata_eh_fastdrain_timerfn()
865 add_timer(&ap->fastdrain_timer); in ata_eh_fastdrain_timerfn()
869 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_fastdrain_timerfn()
884 static void ata_eh_set_pending(struct ata_port *ap, int fastdrain) in ata_eh_set_pending() argument
889 if (ap->pflags & ATA_PFLAG_EH_PENDING) in ata_eh_set_pending()
892 ap->pflags |= ATA_PFLAG_EH_PENDING; in ata_eh_set_pending()
898 cnt = ata_eh_nr_in_flight(ap); in ata_eh_set_pending()
903 ap->fastdrain_cnt = cnt; in ata_eh_set_pending()
904 ap->fastdrain_timer.expires = in ata_eh_set_pending()
906 add_timer(&ap->fastdrain_timer); in ata_eh_set_pending()
921 struct ata_port *ap = qc->ap; in ata_qc_schedule_eh() local
925 WARN_ON(!ap->ops->error_handler); in ata_qc_schedule_eh()
928 ata_eh_set_pending(ap, 1); in ata_qc_schedule_eh()
947 void ata_std_sched_eh(struct ata_port *ap) in ata_std_sched_eh() argument
949 WARN_ON(!ap->ops->error_handler); in ata_std_sched_eh()
951 if (ap->pflags & ATA_PFLAG_INITIALIZING) in ata_std_sched_eh()
954 ata_eh_set_pending(ap, 1); in ata_std_sched_eh()
955 scsi_schedule_eh(ap->scsi_host); in ata_std_sched_eh()
973 void ata_std_end_eh(struct ata_port *ap) in ata_std_end_eh() argument
975 struct Scsi_Host *host = ap->scsi_host; in ata_std_end_eh()
992 void ata_port_schedule_eh(struct ata_port *ap) in ata_port_schedule_eh() argument
995 ap->ops->sched_eh(ap); in ata_port_schedule_eh()
998 static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link) in ata_do_link_abort() argument
1003 WARN_ON(!ap->ops->error_handler); in ata_do_link_abort()
1006 ata_eh_set_pending(ap, 0); in ata_do_link_abort()
1009 ata_qc_for_each_with_internal(ap, qc, tag) { in ata_do_link_abort()
1018 ata_port_schedule_eh(ap); in ata_do_link_abort()
1037 return ata_do_link_abort(link->ap, link); in ata_link_abort()
1052 int ata_port_abort(struct ata_port *ap) in ata_port_abort() argument
1054 return ata_do_link_abort(ap, NULL); in ata_port_abort()
1075 static void __ata_port_freeze(struct ata_port *ap) in __ata_port_freeze() argument
1077 WARN_ON(!ap->ops->error_handler); in __ata_port_freeze()
1079 if (ap->ops->freeze) in __ata_port_freeze()
1080 ap->ops->freeze(ap); in __ata_port_freeze()
1082 ap->pflags |= ATA_PFLAG_FROZEN; in __ata_port_freeze()
1084 DPRINTK("ata%u port frozen\n", ap->print_id); in __ata_port_freeze()
1101 int ata_port_freeze(struct ata_port *ap) in ata_port_freeze() argument
1105 WARN_ON(!ap->ops->error_handler); in ata_port_freeze()
1107 __ata_port_freeze(ap); in ata_port_freeze()
1108 nr_aborted = ata_port_abort(ap); in ata_port_freeze()
1126 int sata_async_notification(struct ata_port *ap) in sata_async_notification() argument
1131 if (!(ap->flags & ATA_FLAG_AN)) in sata_async_notification()
1134 rc = sata_scr_read(&ap->link, SCR_NOTIFICATION, &sntf); in sata_async_notification()
1136 sata_scr_write(&ap->link, SCR_NOTIFICATION, sntf); in sata_async_notification()
1138 if (!sata_pmp_attached(ap) || rc) { in sata_async_notification()
1140 if (!sata_pmp_attached(ap)) { in sata_async_notification()
1145 struct ata_device *dev = ap->link.device; in sata_async_notification()
1157 ata_port_schedule_eh(ap); in sata_async_notification()
1165 ata_for_each_link(link, ap, EDGE) { in sata_async_notification()
1178 ata_port_schedule_eh(ap); in sata_async_notification()
1195 void ata_eh_freeze_port(struct ata_port *ap) in ata_eh_freeze_port() argument
1199 if (!ap->ops->error_handler) in ata_eh_freeze_port()
1202 spin_lock_irqsave(ap->lock, flags); in ata_eh_freeze_port()
1203 __ata_port_freeze(ap); in ata_eh_freeze_port()
1204 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_freeze_port()
1216 void ata_eh_thaw_port(struct ata_port *ap) in ata_eh_thaw_port() argument
1220 if (!ap->ops->error_handler) in ata_eh_thaw_port()
1223 spin_lock_irqsave(ap->lock, flags); in ata_eh_thaw_port()
1225 ap->pflags &= ~ATA_PFLAG_FROZEN; in ata_eh_thaw_port()
1227 if (ap->ops->thaw) in ata_eh_thaw_port()
1228 ap->ops->thaw(ap); in ata_eh_thaw_port()
1230 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_thaw_port()
1232 DPRINTK("ata%u port thawed\n", ap->print_id); in ata_eh_thaw_port()
1242 struct ata_port *ap = qc->ap; in __ata_eh_qc_complete() local
1246 spin_lock_irqsave(ap->lock, flags); in __ata_eh_qc_complete()
1250 spin_unlock_irqrestore(ap->lock, flags); in __ata_eh_qc_complete()
1252 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in __ata_eh_qc_complete()
1302 if (ata_msg_drv(dev->link->ap)) in ata_dev_disable()
1326 struct ata_port *ap = link->ap; in ata_eh_detach_dev() local
1332 spin_lock_irqsave(ap->lock, flags); in ata_eh_detach_dev()
1338 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_detach_dev()
1347 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_detach_dev()
1366 struct ata_port *ap = link->ap; in ata_eh_about_to_do() local
1371 spin_lock_irqsave(ap->lock, flags); in ata_eh_about_to_do()
1378 if (!(ehc->i.flags & ATA_EHI_QUIET) && link != ap->slave_link) in ata_eh_about_to_do()
1379 ap->pflags |= ATA_PFLAG_RECOVERED; in ata_eh_about_to_do()
1381 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_about_to_do()
1461 u8 *buf = dev->link->ap->sector_buf; in ata_eh_read_log_10h()
1548 if (qc->ap->pflags & ATA_PFLAG_FROZEN) { in ata_eh_request_sense()
1600 struct ata_port *ap = dev->link->ap; in atapi_eh_request_sense() local
1620 if (ap->flags & ATA_FLAG_PIO_DMA) { in atapi_eh_request_sense()
1696 struct ata_port *ap = link->ap; in ata_eh_analyze_ncq_error() local
1704 if (ap->pflags & ATA_PFLAG_FROZEN) in ata_eh_analyze_ncq_error()
1712 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_analyze_ncq_error()
1736 qc = __ata_qc_from_tag(ap, tag); in ata_eh_analyze_ncq_error()
1807 if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) { in ata_eh_analyze_tf()
2067 (link->ap->cbl != ATA_CBL_SATA || dev->class == ATA_DEV_ATAPI) && in ata_eh_speed_down()
2132 struct ata_port *ap = link->ap; in ata_eh_link_autopsy() local
2167 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_autopsy()
2217 if (ap->pflags & ATA_PFLAG_FROZEN || in ata_eh_link_autopsy()
2235 ap->link.eh_context.i.err_mask |= AC_ERR_TIMEOUT; in ata_eh_link_autopsy()
2262 void ata_eh_autopsy(struct ata_port *ap) in ata_eh_autopsy() argument
2266 ata_for_each_link(link, ap, EDGE) in ata_eh_autopsy()
2273 if (ap->slave_link) { in ata_eh_autopsy()
2274 struct ata_eh_context *mehc = &ap->link.eh_context; in ata_eh_autopsy()
2275 struct ata_eh_context *sehc = &ap->slave_link->eh_context; in ata_eh_autopsy()
2281 ata_eh_link_autopsy(ap->slave_link); in ata_eh_autopsy()
2284 ata_eh_about_to_do(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2288 ata_eh_done(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2294 if (sata_pmp_attached(ap)) in ata_eh_autopsy()
2295 ata_eh_link_autopsy(&ap->link); in ata_eh_autopsy()
2431 struct ata_port *ap = link->ap; in ata_eh_link_report() local
2445 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2461 if (ap->pflags & ATA_PFLAG_FROZEN) in ata_eh_link_report()
2464 if (ap->eh_tries < ATA_EH_MAX_TRIES) in ata_eh_link_report()
2466 ap->eh_tries); in ata_eh_link_report()
2507 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2627 void ata_eh_report(struct ata_port *ap) in ata_eh_report() argument
2631 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_report()
2654 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) in ata_eh_followup_srst_needed()
2663 struct ata_port *ap = link->ap; in ata_eh_reset() local
2664 struct ata_link *slave = ap->slave_link; in ata_eh_reset()
2701 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2702 ap->pflags |= ATA_PFLAG_RESETTING; in ata_eh_reset()
2703 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2723 if (ap->ops->set_piomode) in ata_eh_reset()
2724 ap->ops->set_piomode(ap, dev); in ata_eh_reset()
2785 if ((ap->pflags & ATA_PFLAG_FROZEN) && in ata_eh_reset()
2787 ata_eh_thaw_port(ap); in ata_eh_reset()
2798 ata_eh_freeze_port(ap); in ata_eh_reset()
2899 ata_eh_thaw_port(ap); in ata_eh_reset()
2921 spin_lock_irqsave(link->ap->lock, flags); in ata_eh_reset()
2925 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_eh_reset()
2926 spin_unlock_irqrestore(link->ap->lock, flags); in ata_eh_reset()
2928 if (ap->pflags & ATA_PFLAG_FROZEN) in ata_eh_reset()
2929 ata_eh_thaw_port(ap); in ata_eh_reset()
2989 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2990 ap->pflags &= ~ATA_PFLAG_RESETTING; in ata_eh_reset()
2991 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
3009 ata_eh_thaw_port(ap); in ata_eh_reset()
3021 ata_eh_release(ap); in ata_eh_reset()
3024 ata_eh_acquire(ap); in ata_eh_reset()
3033 ata_eh_thaw_port(ap); in ata_eh_reset()
3049 static inline void ata_eh_pull_park_action(struct ata_port *ap) in ata_eh_pull_park_action() argument
3081 spin_lock_irqsave(ap->lock, flags); in ata_eh_pull_park_action()
3082 reinit_completion(&ap->park_req_pending); in ata_eh_pull_park_action()
3083 ata_for_each_link(link, ap, EDGE) { in ata_eh_pull_park_action()
3092 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_pull_park_action()
3126 struct ata_port *ap = link->ap; in ata_eh_revalidate_and_attach() local
3168 schedule_work(&(ap->scsi_rescan_task)); in ata_eh_revalidate_and_attach()
3201 ata_eh_thaw_port(ap); in ata_eh_revalidate_and_attach()
3211 if (ap->ops->cable_detect) in ata_eh_revalidate_and_attach()
3212 ap->cbl = ap->ops->cable_detect(ap); in ata_eh_revalidate_and_attach()
3213 ata_force_cbl(ap); in ata_eh_revalidate_and_attach()
3236 spin_lock_irqsave(ap->lock, flags); in ata_eh_revalidate_and_attach()
3237 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_revalidate_and_attach()
3238 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_revalidate_and_attach()
3269 struct ata_port *ap = link->ap; in ata_set_mode() local
3285 if (ap->ops->set_mode) in ata_set_mode()
3286 rc = ap->ops->set_mode(link, r_failed_dev); in ata_set_mode()
3323 u8 *sense_buffer = dev->link->ap->sector_buf; in atapi_eh_clear_ua()
3372 struct ata_port *ap = link->ap; in ata_eh_maybe_retry_flush() local
3382 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_maybe_retry_flush()
3421 if (!(ap->pflags & ATA_PFLAG_FROZEN)) in ata_eh_maybe_retry_flush()
3448 struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL; in ata_eh_set_lpm() local
3452 bool no_dipm = link->ap->flags & ATA_FLAG_NO_DIPM; in ata_eh_set_lpm()
3458 if ((link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm)) in ata_eh_set_lpm()
3496 if (ap) { in ata_eh_set_lpm()
3497 rc = ap->ops->set_lpm(link, policy, hints); in ata_eh_set_lpm()
3498 if (!rc && ap->slave_link) in ata_eh_set_lpm()
3499 rc = ap->ops->set_lpm(ap->slave_link, policy, hints); in ata_eh_set_lpm()
3521 if (ap && ap->slave_link) in ata_eh_set_lpm()
3522 ap->slave_link->lpm_policy = policy; in ata_eh_set_lpm()
3548 if (ap && ap->slave_link) in ata_eh_set_lpm()
3549 ap->slave_link->lpm_policy = old_policy; in ata_eh_set_lpm()
3584 struct ata_port *ap = link->ap; in ata_eh_skip_recovery() local
3597 if ((ap->pflags & ATA_PFLAG_FROZEN) || ata_link_nr_enabled(link)) in ata_eh_skip_recovery()
3649 link->ap->ops->set_lpm(link, ATA_LPM_MAX_POWER, in ata_eh_schedule_probe()
3752 int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_eh_recover() argument
3765 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3771 spin_lock_irqsave(ap->lock, flags); in ata_eh_recover()
3773 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_recover()
3802 if (ap->pflags & ATA_PFLAG_UNLOADING) in ata_eh_recover()
3806 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3818 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3839 ata_eh_pull_park_action(ap); in ata_eh_recover()
3842 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3869 ata_eh_release(ap); in ata_eh_recover()
3870 deadline = wait_for_completion_timeout(&ap->park_req_pending, in ata_eh_recover()
3872 ata_eh_acquire(ap); in ata_eh_recover()
3874 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3887 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_recover()
3890 if (sata_pmp_attached(ap) && ata_is_host_link(link)) in ata_eh_recover()
3939 if (link->lpm_policy != ap->target_lpm_policy) { in ata_eh_recover()
3940 rc = ata_eh_set_lpm(link, ap->target_lpm_policy, &dev); in ata_eh_recover()
3954 if (ap->pflags & ATA_PFLAG_FROZEN) { in ata_eh_recover()
3958 if (sata_pmp_attached(ap)) in ata_eh_recover()
3985 void ata_eh_finish(struct ata_port *ap) in ata_eh_finish() argument
3991 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_finish()
4016 WARN_ON(ap->nr_active_links); in ata_eh_finish()
4017 ap->nr_active_links = 0; in ata_eh_finish()
4034 void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_do_eh() argument
4041 ata_eh_autopsy(ap); in ata_do_eh()
4042 ata_eh_report(ap); in ata_do_eh()
4044 rc = ata_eh_recover(ap, prereset, softreset, hardreset, postreset, in ata_do_eh()
4047 ata_for_each_dev(dev, &ap->link, ALL) in ata_do_eh()
4051 ata_eh_finish(ap); in ata_do_eh()
4063 void ata_std_error_handler(struct ata_port *ap) in ata_std_error_handler() argument
4065 struct ata_port_operations *ops = ap->ops; in ata_std_error_handler()
4069 if (hardreset == sata_std_hardreset && !sata_scr_valid(&ap->link)) in ata_std_error_handler()
4072 ata_do_eh(ap, ops->prereset, ops->softreset, hardreset, ops->postreset); in ata_std_error_handler()
4085 static void ata_eh_handle_port_suspend(struct ata_port *ap) in ata_eh_handle_port_suspend() argument
4092 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
4093 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_suspend()
4094 ap->pm_mesg.event & PM_EVENT_RESUME) { in ata_eh_handle_port_suspend()
4095 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4098 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4100 WARN_ON(ap->pflags & ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_suspend()
4107 if (PMSG_IS_AUTO(ap->pm_mesg)) { in ata_eh_handle_port_suspend()
4108 ata_for_each_dev(dev, &ap->link, ENABLED) { in ata_eh_handle_port_suspend()
4115 rc = ata_acpi_on_suspend(ap); in ata_eh_handle_port_suspend()
4120 ata_eh_freeze_port(ap); in ata_eh_handle_port_suspend()
4122 if (ap->ops->port_suspend) in ata_eh_handle_port_suspend()
4123 rc = ap->ops->port_suspend(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
4125 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
4128 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
4130 ap->pflags &= ~ATA_PFLAG_PM_PENDING; in ata_eh_handle_port_suspend()
4132 ap->pflags |= ATA_PFLAG_SUSPENDED; in ata_eh_handle_port_suspend()
4133 else if (ap->pflags & ATA_PFLAG_FROZEN) in ata_eh_handle_port_suspend()
4134 ata_port_schedule_eh(ap); in ata_eh_handle_port_suspend()
4136 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4150 static void ata_eh_handle_port_resume(struct ata_port *ap) in ata_eh_handle_port_resume() argument
4157 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
4158 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_resume()
4159 !(ap->pm_mesg.event & PM_EVENT_RESUME)) { in ata_eh_handle_port_resume()
4160 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
4163 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
4165 WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED)); in ata_eh_handle_port_resume()
4174 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_handle_port_resume()
4178 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_resume()
4180 if (ap->ops->port_resume) in ata_eh_handle_port_resume()
4181 ap->ops->port_resume(ap); in ata_eh_handle_port_resume()
4184 ata_acpi_on_resume(ap); in ata_eh_handle_port_resume()
4187 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
4188 ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_resume()
4189 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()