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()
525 struct ata_port *ap = ata_shost_to_port(host); in ata_scsi_timed_out() local
532 if (ap->ops->error_handler) { in ata_scsi_timed_out()
538 spin_lock_irqsave(ap->lock, flags); in ata_scsi_timed_out()
539 qc = ata_qc_from_tag(ap, ap->link.active_tag); in ata_scsi_timed_out()
546 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_timed_out()
553 static void ata_eh_unload(struct ata_port *ap) in ata_eh_unload() argument
562 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_unload()
569 spin_lock_irqsave(ap->lock, flags); in ata_eh_unload()
571 ata_port_freeze(ap); /* won't be thawed */ in ata_eh_unload()
572 ap->pflags &= ~ATA_PFLAG_EH_PENDING; /* clear pending from freeze */ in ata_eh_unload()
573 ap->pflags |= ATA_PFLAG_UNLOADED; in ata_eh_unload()
575 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_unload()
592 struct ata_port *ap = ata_shost_to_port(host); in ata_scsi_error() local
602 ata_scsi_cmd_error_handler(host, ap, &eh_work_q); in ata_scsi_error()
606 ata_scsi_port_error_handler(host, ap); in ata_scsi_error()
624 void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, in ata_scsi_cmd_error_handler() argument
631 ata_sff_flush_pio_task(ap); in ata_scsi_cmd_error_handler()
647 if (ap->ops->error_handler) { in ata_scsi_cmd_error_handler()
651 spin_lock_irqsave(ap->lock, flags); in ata_scsi_cmd_error_handler()
662 if (ap->ops->lost_interrupt) in ata_scsi_cmd_error_handler()
663 ap->ops->lost_interrupt(ap); in ata_scsi_cmd_error_handler()
669 qc = __ata_qc_from_tag(ap, i); in ata_scsi_cmd_error_handler()
689 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in ata_scsi_cmd_error_handler()
700 __ata_port_freeze(ap); in ata_scsi_cmd_error_handler()
702 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_cmd_error_handler()
705 ap->eh_tries = ATA_EH_MAX_TRIES; in ata_scsi_cmd_error_handler()
707 spin_unlock_wait(ap->lock); in ata_scsi_cmd_error_handler()
720 void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap) in ata_scsi_port_error_handler() argument
725 if (ap->ops->error_handler) { in ata_scsi_port_error_handler()
729 ata_eh_acquire(ap); in ata_scsi_port_error_handler()
732 del_timer_sync(&ap->fastdrain_timer); in ata_scsi_port_error_handler()
735 ata_eh_handle_port_resume(ap); in ata_scsi_port_error_handler()
738 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
740 ata_for_each_link(link, ap, HOST_FIRST) { in ata_scsi_port_error_handler()
757 ap->pflags |= ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
758 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
759 ap->excl_link = NULL; /* don't maintain exclusion over EH */ in ata_scsi_port_error_handler()
761 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
764 if (!(ap->pflags & (ATA_PFLAG_UNLOADING | ATA_PFLAG_SUSPENDED))) in ata_scsi_port_error_handler()
765 ap->ops->error_handler(ap); in ata_scsi_port_error_handler()
768 if ((ap->pflags & ATA_PFLAG_UNLOADING) && in ata_scsi_port_error_handler()
769 !(ap->pflags & ATA_PFLAG_UNLOADED)) in ata_scsi_port_error_handler()
770 ata_eh_unload(ap); in ata_scsi_port_error_handler()
771 ata_eh_finish(ap); in ata_scsi_port_error_handler()
775 ata_eh_handle_port_suspend(ap); in ata_scsi_port_error_handler()
781 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
783 if (ap->pflags & ATA_PFLAG_EH_PENDING) { in ata_scsi_port_error_handler()
784 if (--ap->eh_tries) { in ata_scsi_port_error_handler()
785 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
788 ata_port_err(ap, in ata_scsi_port_error_handler()
791 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
795 ata_for_each_link(link, ap, HOST_FIRST) in ata_scsi_port_error_handler()
803 ap->ops->end_eh(ap); in ata_scsi_port_error_handler()
805 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
806 ata_eh_release(ap); in ata_scsi_port_error_handler()
808 WARN_ON(ata_qc_from_tag(ap, ap->link.active_tag) == NULL); in ata_scsi_port_error_handler()
809 ap->ops->eng_timeout(ap); in ata_scsi_port_error_handler()
812 scsi_eh_flush_done_q(&ap->eh_done_q); in ata_scsi_port_error_handler()
815 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
817 if (ap->pflags & ATA_PFLAG_LOADING) in ata_scsi_port_error_handler()
818 ap->pflags &= ~ATA_PFLAG_LOADING; in ata_scsi_port_error_handler()
819 else if (ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) in ata_scsi_port_error_handler()
820 schedule_delayed_work(&ap->hotplug_task, 0); in ata_scsi_port_error_handler()
822 if (ap->pflags & ATA_PFLAG_RECOVERED) in ata_scsi_port_error_handler()
823 ata_port_info(ap, "EH complete\n"); in ata_scsi_port_error_handler()
825 ap->pflags &= ~(ATA_PFLAG_SCSI_HOTPLUG | ATA_PFLAG_RECOVERED); in ata_scsi_port_error_handler()
828 ap->pflags &= ~ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
829 wake_up_all(&ap->eh_wait_q); in ata_scsi_port_error_handler()
831 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
844 void ata_port_wait_eh(struct ata_port *ap) in ata_port_wait_eh() argument
850 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
852 while (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS)) { in ata_port_wait_eh()
853 prepare_to_wait(&ap->eh_wait_q, &wait, TASK_UNINTERRUPTIBLE); in ata_port_wait_eh()
854 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
856 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
858 finish_wait(&ap->eh_wait_q, &wait); in ata_port_wait_eh()
860 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
863 if (scsi_host_in_recovery(ap->scsi_host)) { in ata_port_wait_eh()
864 ata_msleep(ap, 10); in ata_port_wait_eh()
870 static int ata_eh_nr_in_flight(struct ata_port *ap) in ata_eh_nr_in_flight() argument
877 if (ata_qc_from_tag(ap, tag)) in ata_eh_nr_in_flight()
885 struct ata_port *ap = (void *)arg; in ata_eh_fastdrain_timerfn() local
889 spin_lock_irqsave(ap->lock, flags); in ata_eh_fastdrain_timerfn()
891 cnt = ata_eh_nr_in_flight(ap); in ata_eh_fastdrain_timerfn()
897 if (cnt == ap->fastdrain_cnt) { in ata_eh_fastdrain_timerfn()
904 struct ata_queued_cmd *qc = ata_qc_from_tag(ap, tag); in ata_eh_fastdrain_timerfn()
909 ata_port_freeze(ap); in ata_eh_fastdrain_timerfn()
912 ap->fastdrain_cnt = cnt; in ata_eh_fastdrain_timerfn()
913 ap->fastdrain_timer.expires = in ata_eh_fastdrain_timerfn()
915 add_timer(&ap->fastdrain_timer); in ata_eh_fastdrain_timerfn()
919 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_fastdrain_timerfn()
934 static void ata_eh_set_pending(struct ata_port *ap, int fastdrain) in ata_eh_set_pending() argument
939 if (ap->pflags & ATA_PFLAG_EH_PENDING) in ata_eh_set_pending()
942 ap->pflags |= ATA_PFLAG_EH_PENDING; in ata_eh_set_pending()
948 cnt = ata_eh_nr_in_flight(ap); in ata_eh_set_pending()
953 ap->fastdrain_cnt = cnt; in ata_eh_set_pending()
954 ap->fastdrain_timer.expires = in ata_eh_set_pending()
956 add_timer(&ap->fastdrain_timer); in ata_eh_set_pending()
971 struct ata_port *ap = qc->ap; in ata_qc_schedule_eh() local
975 WARN_ON(!ap->ops->error_handler); in ata_qc_schedule_eh()
978 ata_eh_set_pending(ap, 1); in ata_qc_schedule_eh()
997 void ata_std_sched_eh(struct ata_port *ap) in ata_std_sched_eh() argument
999 WARN_ON(!ap->ops->error_handler); in ata_std_sched_eh()
1001 if (ap->pflags & ATA_PFLAG_INITIALIZING) in ata_std_sched_eh()
1004 ata_eh_set_pending(ap, 1); in ata_std_sched_eh()
1005 scsi_schedule_eh(ap->scsi_host); in ata_std_sched_eh()
1023 void ata_std_end_eh(struct ata_port *ap) in ata_std_end_eh() argument
1025 struct Scsi_Host *host = ap->scsi_host; in ata_std_end_eh()
1042 void ata_port_schedule_eh(struct ata_port *ap) in ata_port_schedule_eh() argument
1045 ap->ops->sched_eh(ap); in ata_port_schedule_eh()
1048 static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link) in ata_do_link_abort() argument
1052 WARN_ON(!ap->ops->error_handler); in ata_do_link_abort()
1055 ata_eh_set_pending(ap, 0); in ata_do_link_abort()
1058 struct ata_queued_cmd *qc = ata_qc_from_tag(ap, tag); in ata_do_link_abort()
1068 ata_port_schedule_eh(ap); in ata_do_link_abort()
1087 return ata_do_link_abort(link->ap, link); in ata_link_abort()
1102 int ata_port_abort(struct ata_port *ap) in ata_port_abort() argument
1104 return ata_do_link_abort(ap, NULL); in ata_port_abort()
1125 static void __ata_port_freeze(struct ata_port *ap) in __ata_port_freeze() argument
1127 WARN_ON(!ap->ops->error_handler); in __ata_port_freeze()
1129 if (ap->ops->freeze) in __ata_port_freeze()
1130 ap->ops->freeze(ap); in __ata_port_freeze()
1132 ap->pflags |= ATA_PFLAG_FROZEN; in __ata_port_freeze()
1134 DPRINTK("ata%u port frozen\n", ap->print_id); in __ata_port_freeze()
1151 int ata_port_freeze(struct ata_port *ap) in ata_port_freeze() argument
1155 WARN_ON(!ap->ops->error_handler); in ata_port_freeze()
1157 __ata_port_freeze(ap); in ata_port_freeze()
1158 nr_aborted = ata_port_abort(ap); in ata_port_freeze()
1176 int sata_async_notification(struct ata_port *ap) in sata_async_notification() argument
1181 if (!(ap->flags & ATA_FLAG_AN)) in sata_async_notification()
1184 rc = sata_scr_read(&ap->link, SCR_NOTIFICATION, &sntf); in sata_async_notification()
1186 sata_scr_write(&ap->link, SCR_NOTIFICATION, sntf); in sata_async_notification()
1188 if (!sata_pmp_attached(ap) || rc) { in sata_async_notification()
1190 if (!sata_pmp_attached(ap)) { in sata_async_notification()
1195 struct ata_device *dev = ap->link.device; in sata_async_notification()
1207 ata_port_schedule_eh(ap); in sata_async_notification()
1215 ata_for_each_link(link, ap, EDGE) { in sata_async_notification()
1228 ata_port_schedule_eh(ap); in sata_async_notification()
1245 void ata_eh_freeze_port(struct ata_port *ap) in ata_eh_freeze_port() argument
1249 if (!ap->ops->error_handler) in ata_eh_freeze_port()
1252 spin_lock_irqsave(ap->lock, flags); in ata_eh_freeze_port()
1253 __ata_port_freeze(ap); in ata_eh_freeze_port()
1254 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_freeze_port()
1266 void ata_eh_thaw_port(struct ata_port *ap) in ata_eh_thaw_port() argument
1270 if (!ap->ops->error_handler) in ata_eh_thaw_port()
1273 spin_lock_irqsave(ap->lock, flags); in ata_eh_thaw_port()
1275 ap->pflags &= ~ATA_PFLAG_FROZEN; in ata_eh_thaw_port()
1277 if (ap->ops->thaw) in ata_eh_thaw_port()
1278 ap->ops->thaw(ap); in ata_eh_thaw_port()
1280 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_thaw_port()
1282 DPRINTK("ata%u port thawed\n", ap->print_id); in ata_eh_thaw_port()
1292 struct ata_port *ap = qc->ap; in __ata_eh_qc_complete() local
1296 spin_lock_irqsave(ap->lock, flags); in __ata_eh_qc_complete()
1300 spin_unlock_irqrestore(ap->lock, flags); in __ata_eh_qc_complete()
1302 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in __ata_eh_qc_complete()
1352 if (ata_msg_drv(dev->link->ap)) in ata_dev_disable()
1376 struct ata_port *ap = link->ap; in ata_eh_detach_dev() local
1382 spin_lock_irqsave(ap->lock, flags); in ata_eh_detach_dev()
1388 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_detach_dev()
1397 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_detach_dev()
1416 struct ata_port *ap = link->ap; in ata_eh_about_to_do() local
1421 spin_lock_irqsave(ap->lock, flags); in ata_eh_about_to_do()
1428 if (!(ehc->i.flags & ATA_EHI_QUIET) && link != ap->slave_link) in ata_eh_about_to_do()
1429 ap->pflags |= ATA_PFLAG_RECOVERED; in ata_eh_about_to_do()
1431 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_about_to_do()
1508 unsigned long ap_flags = dev->link->ap->flags; in ata_read_log_page()
1571 u8 *buf = dev->link->ap->sector_buf; in ata_eh_read_log_10h()
1658 struct ata_port *ap = dev->link->ap; in atapi_eh_request_sense() local
1678 if (ap->flags & ATA_FLAG_PIO_DMA) { in atapi_eh_request_sense()
1754 struct ata_port *ap = link->ap; in ata_eh_analyze_ncq_error() local
1762 if (ap->pflags & ATA_PFLAG_FROZEN) in ata_eh_analyze_ncq_error()
1771 qc = __ata_qc_from_tag(ap, tag); in ata_eh_analyze_ncq_error()
1796 qc = __ata_qc_from_tag(ap, tag); in ata_eh_analyze_ncq_error()
1846 if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) { in ata_eh_analyze_tf()
2095 (link->ap->cbl != ATA_CBL_SATA || dev->class == ATA_DEV_ATAPI) && in ata_eh_speed_down()
2145 struct ata_port *ap = link->ap; in ata_eh_link_autopsy() local
2180 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); in ata_eh_link_autopsy()
2218 if (ap->pflags & ATA_PFLAG_FROZEN || in ata_eh_link_autopsy()
2236 ap->link.eh_context.i.err_mask |= AC_ERR_TIMEOUT; in ata_eh_link_autopsy()
2263 void ata_eh_autopsy(struct ata_port *ap) in ata_eh_autopsy() argument
2267 ata_for_each_link(link, ap, EDGE) in ata_eh_autopsy()
2274 if (ap->slave_link) { in ata_eh_autopsy()
2275 struct ata_eh_context *mehc = &ap->link.eh_context; in ata_eh_autopsy()
2276 struct ata_eh_context *sehc = &ap->slave_link->eh_context; in ata_eh_autopsy()
2282 ata_eh_link_autopsy(ap->slave_link); in ata_eh_autopsy()
2285 ata_eh_about_to_do(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2289 ata_eh_done(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2295 if (sata_pmp_attached(ap)) in ata_eh_autopsy()
2296 ata_eh_link_autopsy(&ap->link); in ata_eh_autopsy()
2430 struct ata_port *ap = link->ap; in ata_eh_link_report() local
2444 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, 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()
2508 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); in ata_eh_link_report()
2605 void ata_eh_report(struct ata_port *ap) in ata_eh_report() argument
2609 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_report()
2632 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) in ata_eh_followup_srst_needed()
2641 struct ata_port *ap = link->ap; in ata_eh_reset() local
2642 struct ata_link *slave = ap->slave_link; in ata_eh_reset()
2679 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2680 ap->pflags |= ATA_PFLAG_RESETTING; in ata_eh_reset()
2681 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2701 if (ap->ops->set_piomode) in ata_eh_reset()
2702 ap->ops->set_piomode(ap, dev); in ata_eh_reset()
2763 if ((ap->pflags & ATA_PFLAG_FROZEN) && in ata_eh_reset()
2765 ata_eh_thaw_port(ap); in ata_eh_reset()
2776 ata_eh_freeze_port(ap); in ata_eh_reset()
2877 ata_eh_thaw_port(ap); in ata_eh_reset()
2899 spin_lock_irqsave(link->ap->lock, flags); in ata_eh_reset()
2903 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_eh_reset()
2904 spin_unlock_irqrestore(link->ap->lock, flags); in ata_eh_reset()
2906 if (ap->pflags & ATA_PFLAG_FROZEN) in ata_eh_reset()
2907 ata_eh_thaw_port(ap); in ata_eh_reset()
2967 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2968 ap->pflags &= ~ATA_PFLAG_RESETTING; in ata_eh_reset()
2969 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2987 ata_eh_thaw_port(ap); in ata_eh_reset()
2999 ata_eh_release(ap); in ata_eh_reset()
3002 ata_eh_acquire(ap); in ata_eh_reset()
3011 ata_eh_thaw_port(ap); in ata_eh_reset()
3027 static inline void ata_eh_pull_park_action(struct ata_port *ap) in ata_eh_pull_park_action() argument
3059 spin_lock_irqsave(ap->lock, flags); in ata_eh_pull_park_action()
3060 reinit_completion(&ap->park_req_pending); in ata_eh_pull_park_action()
3061 ata_for_each_link(link, ap, EDGE) { in ata_eh_pull_park_action()
3070 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_pull_park_action()
3104 struct ata_port *ap = link->ap; in ata_eh_revalidate_and_attach() local
3146 schedule_work(&(ap->scsi_rescan_task)); in ata_eh_revalidate_and_attach()
3179 ata_eh_thaw_port(ap); in ata_eh_revalidate_and_attach()
3189 if (ap->ops->cable_detect) in ata_eh_revalidate_and_attach()
3190 ap->cbl = ap->ops->cable_detect(ap); in ata_eh_revalidate_and_attach()
3191 ata_force_cbl(ap); in ata_eh_revalidate_and_attach()
3214 spin_lock_irqsave(ap->lock, flags); in ata_eh_revalidate_and_attach()
3215 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_revalidate_and_attach()
3216 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_revalidate_and_attach()
3247 struct ata_port *ap = link->ap; in ata_set_mode() local
3263 if (ap->ops->set_mode) in ata_set_mode()
3264 rc = ap->ops->set_mode(link, r_failed_dev); in ata_set_mode()
3301 u8 *sense_buffer = dev->link->ap->sector_buf; in atapi_eh_clear_ua()
3350 struct ata_port *ap = link->ap; in ata_eh_maybe_retry_flush() local
3360 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_maybe_retry_flush()
3399 if (!(ap->pflags & ATA_PFLAG_FROZEN)) in ata_eh_maybe_retry_flush()
3426 struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL; in ata_eh_set_lpm() local
3430 bool no_dipm = link->ap->flags & ATA_FLAG_NO_DIPM; in ata_eh_set_lpm()
3436 if ((link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm)) in ata_eh_set_lpm()
3474 if (ap) { in ata_eh_set_lpm()
3475 rc = ap->ops->set_lpm(link, policy, hints); in ata_eh_set_lpm()
3476 if (!rc && ap->slave_link) in ata_eh_set_lpm()
3477 rc = ap->ops->set_lpm(ap->slave_link, policy, hints); in ata_eh_set_lpm()
3499 if (ap && ap->slave_link) in ata_eh_set_lpm()
3500 ap->slave_link->lpm_policy = policy; in ata_eh_set_lpm()
3526 if (ap && ap->slave_link) in ata_eh_set_lpm()
3527 ap->slave_link->lpm_policy = old_policy; in ata_eh_set_lpm()
3562 struct ata_port *ap = link->ap; in ata_eh_skip_recovery() local
3575 if ((ap->pflags & ATA_PFLAG_FROZEN) || ata_link_nr_enabled(link)) in ata_eh_skip_recovery()
3627 link->ap->ops->set_lpm(link, ATA_LPM_MAX_POWER, in ata_eh_schedule_probe()
3728 int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_eh_recover() argument
3741 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3747 spin_lock_irqsave(ap->lock, flags); in ata_eh_recover()
3749 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_recover()
3778 if (ap->pflags & ATA_PFLAG_UNLOADING) in ata_eh_recover()
3782 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3794 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3815 ata_eh_pull_park_action(ap); in ata_eh_recover()
3818 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3845 ata_eh_release(ap); in ata_eh_recover()
3846 deadline = wait_for_completion_timeout(&ap->park_req_pending, in ata_eh_recover()
3848 ata_eh_acquire(ap); in ata_eh_recover()
3850 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3863 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_recover()
3866 if (sata_pmp_attached(ap) && ata_is_host_link(link)) in ata_eh_recover()
3915 if (link->lpm_policy != ap->target_lpm_policy) { in ata_eh_recover()
3916 rc = ata_eh_set_lpm(link, ap->target_lpm_policy, &dev); in ata_eh_recover()
3930 if (ap->pflags & ATA_PFLAG_FROZEN) { in ata_eh_recover()
3934 if (sata_pmp_attached(ap)) in ata_eh_recover()
3961 void ata_eh_finish(struct ata_port *ap) in ata_eh_finish() argument
3967 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); in ata_eh_finish()
3993 WARN_ON(ap->nr_active_links); in ata_eh_finish()
3994 ap->nr_active_links = 0; in ata_eh_finish()
4011 void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_do_eh() argument
4018 ata_eh_autopsy(ap); in ata_do_eh()
4019 ata_eh_report(ap); in ata_do_eh()
4021 rc = ata_eh_recover(ap, prereset, softreset, hardreset, postreset, in ata_do_eh()
4024 ata_for_each_dev(dev, &ap->link, ALL) in ata_do_eh()
4028 ata_eh_finish(ap); in ata_do_eh()
4040 void ata_std_error_handler(struct ata_port *ap) in ata_std_error_handler() argument
4042 struct ata_port_operations *ops = ap->ops; in ata_std_error_handler()
4046 if (hardreset == sata_std_hardreset && !sata_scr_valid(&ap->link)) in ata_std_error_handler()
4049 ata_do_eh(ap, ops->prereset, ops->softreset, hardreset, ops->postreset); in ata_std_error_handler()
4062 static void ata_eh_handle_port_suspend(struct ata_port *ap) in ata_eh_handle_port_suspend() argument
4069 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
4070 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_suspend()
4071 ap->pm_mesg.event & PM_EVENT_RESUME) { in ata_eh_handle_port_suspend()
4072 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4075 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4077 WARN_ON(ap->pflags & ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_suspend()
4084 if (PMSG_IS_AUTO(ap->pm_mesg)) { in ata_eh_handle_port_suspend()
4085 ata_for_each_dev(dev, &ap->link, ENABLED) { in ata_eh_handle_port_suspend()
4092 rc = ata_acpi_on_suspend(ap); in ata_eh_handle_port_suspend()
4097 ata_eh_freeze_port(ap); in ata_eh_handle_port_suspend()
4099 if (ap->ops->port_suspend) in ata_eh_handle_port_suspend()
4100 rc = ap->ops->port_suspend(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
4102 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
4105 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
4107 ap->pflags &= ~ATA_PFLAG_PM_PENDING; in ata_eh_handle_port_suspend()
4109 ap->pflags |= ATA_PFLAG_SUSPENDED; in ata_eh_handle_port_suspend()
4110 else if (ap->pflags & ATA_PFLAG_FROZEN) in ata_eh_handle_port_suspend()
4111 ata_port_schedule_eh(ap); in ata_eh_handle_port_suspend()
4113 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
4127 static void ata_eh_handle_port_resume(struct ata_port *ap) in ata_eh_handle_port_resume() argument
4135 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
4136 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_resume()
4137 !(ap->pm_mesg.event & PM_EVENT_RESUME)) { in ata_eh_handle_port_resume()
4138 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
4141 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
4143 WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED)); in ata_eh_handle_port_resume()
4152 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_handle_port_resume()
4156 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_resume()
4158 if (ap->ops->port_resume) in ata_eh_handle_port_resume()
4159 rc = ap->ops->port_resume(ap); in ata_eh_handle_port_resume()
4162 ata_acpi_on_resume(ap); in ata_eh_handle_port_resume()
4165 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
4166 ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_resume()
4167 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()