• Home
  • Raw
  • Download

Lines Matching full:ap

153 static void __ata_port_freeze(struct ata_port *ap);
155 static void ata_eh_handle_port_suspend(struct ata_port *ap);
156 static void ata_eh_handle_port_resume(struct ata_port *ap);
158 static void ata_eh_handle_port_suspend(struct ata_port *ap) in ata_eh_handle_port_suspend() argument
161 static void ata_eh_handle_port_resume(struct ata_port *ap) in ata_eh_handle_port_resume() argument
235 * @ap: target ATA port
246 void ata_port_desc(struct ata_port *ap, const char *fmt, ...) in ata_port_desc() argument
250 WARN_ON(!(ap->pflags & ATA_PFLAG_INITIALIZING)); in ata_port_desc()
252 if (ap->link.eh_info.desc_len) in ata_port_desc()
253 __ata_ehi_push_desc(&ap->link.eh_info, " "); in ata_port_desc()
256 __ata_ehi_pushv_desc(&ap->link.eh_info, fmt, args); in ata_port_desc()
264 * @ap: target ATA port
277 void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset, in ata_port_pbar_desc() argument
280 struct pci_dev *pdev = to_pci_dev(ap->host->dev); in ata_port_pbar_desc()
293 ata_port_desc(ap, "%s %s%llu@0x%llx", name, type, len, start); in ata_port_pbar_desc()
295 ata_port_desc(ap, "%s 0x%llx", name, in ata_port_pbar_desc()
460 * @ap: ATA port to acquire EH ownership for
462 * Acquire EH ownership for @ap. This is the basic exclusion
469 void ata_eh_acquire(struct ata_port *ap) in ata_eh_acquire() argument
471 mutex_lock(&ap->host->eh_mutex); in ata_eh_acquire()
472 WARN_ON_ONCE(ap->host->eh_owner); in ata_eh_acquire()
473 ap->host->eh_owner = current; in ata_eh_acquire()
478 * @ap: ATA port to release EH ownership for
480 * Release EH ownership for @ap if the caller. The caller must
486 void ata_eh_release(struct ata_port *ap) in ata_eh_release() argument
488 WARN_ON_ONCE(ap->host->eh_owner != current); in ata_eh_release()
489 ap->host->eh_owner = NULL; in ata_eh_release()
490 mutex_unlock(&ap->host->eh_mutex); in ata_eh_release()
493 static void ata_eh_unload(struct ata_port *ap) in ata_eh_unload() argument
502 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_unload()
509 spin_lock_irqsave(ap->lock, flags); in ata_eh_unload()
511 ata_port_freeze(ap); /* won't be thawed */ in ata_eh_unload()
512 ap->pflags &= ~ATA_PFLAG_EH_PENDING; /* clear pending from freeze */ in ata_eh_unload()
513 ap->pflags |= ATA_PFLAG_UNLOADED; in ata_eh_unload()
515 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_unload()
532 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()
557 * @ap: ATA port within the host
561 * ap->eh_done_q. This function is the first part of the libata error
564 void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, in ata_scsi_cmd_error_handler() argument
571 ata_sff_flush_pio_task(ap); in ata_scsi_cmd_error_handler()
587 spin_lock_irqsave(ap->lock, flags); in ata_scsi_cmd_error_handler()
588 if (ap->ops->error_handler) { in ata_scsi_cmd_error_handler()
592 /* This must occur under the ap->lock as we don't want in ata_scsi_cmd_error_handler()
601 if (ap->ops->lost_interrupt) in ata_scsi_cmd_error_handler()
602 ap->ops->lost_interrupt(ap); in ata_scsi_cmd_error_handler()
607 ata_qc_for_each_raw(ap, qc, i) { in ata_scsi_cmd_error_handler()
627 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in ata_scsi_cmd_error_handler()
638 __ata_port_freeze(ap); in ata_scsi_cmd_error_handler()
642 ap->eh_tries = ATA_EH_MAX_TRIES; in ata_scsi_cmd_error_handler()
644 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_cmd_error_handler()
652 * @ap: the ATA port
654 * Handle the recovery of the port @ap after all the commands
657 void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap) in ata_scsi_port_error_handler() argument
662 if (ap->ops->error_handler) { in ata_scsi_port_error_handler()
666 ata_eh_acquire(ap); in ata_scsi_port_error_handler()
669 del_timer_sync(&ap->fastdrain_timer); in ata_scsi_port_error_handler()
672 ata_eh_handle_port_resume(ap); in ata_scsi_port_error_handler()
675 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
677 ata_for_each_link(link, ap, HOST_FIRST) { in ata_scsi_port_error_handler()
694 ap->pflags |= ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
695 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
696 ap->excl_link = NULL; /* don't maintain exclusion over EH */ in ata_scsi_port_error_handler()
698 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
701 if (!(ap->pflags & (ATA_PFLAG_UNLOADING | ATA_PFLAG_SUSPENDED))) in ata_scsi_port_error_handler()
702 ap->ops->error_handler(ap); in ata_scsi_port_error_handler()
705 if ((ap->pflags & ATA_PFLAG_UNLOADING) && in ata_scsi_port_error_handler()
706 !(ap->pflags & ATA_PFLAG_UNLOADED)) in ata_scsi_port_error_handler()
707 ata_eh_unload(ap); in ata_scsi_port_error_handler()
708 ata_eh_finish(ap); in ata_scsi_port_error_handler()
712 ata_eh_handle_port_suspend(ap); in ata_scsi_port_error_handler()
718 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
720 if (ap->pflags & ATA_PFLAG_EH_PENDING) { in ata_scsi_port_error_handler()
721 if (--ap->eh_tries) { in ata_scsi_port_error_handler()
722 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
725 ata_port_err(ap, in ata_scsi_port_error_handler()
728 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_scsi_port_error_handler()
732 ata_for_each_link(link, ap, HOST_FIRST) in ata_scsi_port_error_handler()
736 * ap->lock such that if exception occurs after this in ata_scsi_port_error_handler()
740 ap->ops->end_eh(ap); in ata_scsi_port_error_handler()
742 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
743 ata_eh_release(ap); in ata_scsi_port_error_handler()
745 WARN_ON(ata_qc_from_tag(ap, ap->link.active_tag) == NULL); in ata_scsi_port_error_handler()
746 ap->ops->eng_timeout(ap); in ata_scsi_port_error_handler()
749 scsi_eh_flush_done_q(&ap->eh_done_q); in ata_scsi_port_error_handler()
752 spin_lock_irqsave(ap->lock, flags); in ata_scsi_port_error_handler()
754 if (ap->pflags & ATA_PFLAG_LOADING) in ata_scsi_port_error_handler()
755 ap->pflags &= ~ATA_PFLAG_LOADING; in ata_scsi_port_error_handler()
756 else if ((ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) && in ata_scsi_port_error_handler()
757 !(ap->flags & ATA_FLAG_SAS_HOST)) in ata_scsi_port_error_handler()
758 schedule_delayed_work(&ap->hotplug_task, 0); in ata_scsi_port_error_handler()
760 if (ap->pflags & ATA_PFLAG_RECOVERED) in ata_scsi_port_error_handler()
761 ata_port_info(ap, "EH complete\n"); in ata_scsi_port_error_handler()
763 ap->pflags &= ~(ATA_PFLAG_SCSI_HOTPLUG | ATA_PFLAG_RECOVERED); in ata_scsi_port_error_handler()
766 ap->pflags &= ~ATA_PFLAG_EH_IN_PROGRESS; in ata_scsi_port_error_handler()
767 wake_up_all(&ap->eh_wait_q); in ata_scsi_port_error_handler()
769 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_port_error_handler()
775 * @ap: Port to wait EH for
782 void ata_port_wait_eh(struct ata_port *ap) in ata_port_wait_eh() argument
788 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
790 while (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS)) { in ata_port_wait_eh()
791 prepare_to_wait(&ap->eh_wait_q, &wait, TASK_UNINTERRUPTIBLE); in ata_port_wait_eh()
792 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
794 spin_lock_irqsave(ap->lock, flags); in ata_port_wait_eh()
796 finish_wait(&ap->eh_wait_q, &wait); in ata_port_wait_eh()
798 spin_unlock_irqrestore(ap->lock, flags); in ata_port_wait_eh()
801 if (scsi_host_in_recovery(ap->scsi_host)) { in ata_port_wait_eh()
802 ata_msleep(ap, 10); in ata_port_wait_eh()
808 static int ata_eh_nr_in_flight(struct ata_port *ap) in ata_eh_nr_in_flight() argument
815 ata_qc_for_each(ap, qc, tag) { in ata_eh_nr_in_flight()
825 struct ata_port *ap = from_timer(ap, t, fastdrain_timer); in ata_eh_fastdrain_timerfn() local
829 spin_lock_irqsave(ap->lock, flags); in ata_eh_fastdrain_timerfn()
831 cnt = ata_eh_nr_in_flight(ap); in ata_eh_fastdrain_timerfn()
837 if (cnt == ap->fastdrain_cnt) { in ata_eh_fastdrain_timerfn()
844 ata_qc_for_each(ap, qc, tag) { in ata_eh_fastdrain_timerfn()
849 ata_port_freeze(ap); in ata_eh_fastdrain_timerfn()
852 ap->fastdrain_cnt = cnt; in ata_eh_fastdrain_timerfn()
853 ap->fastdrain_timer.expires = in ata_eh_fastdrain_timerfn()
855 add_timer(&ap->fastdrain_timer); in ata_eh_fastdrain_timerfn()
859 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_fastdrain_timerfn()
864 * @ap: target ATA port
874 static void ata_eh_set_pending(struct ata_port *ap, int fastdrain) in ata_eh_set_pending() argument
879 if (ap->pflags & ATA_PFLAG_EH_PENDING) in ata_eh_set_pending()
882 ap->pflags |= ATA_PFLAG_EH_PENDING; in ata_eh_set_pending()
888 cnt = ata_eh_nr_in_flight(ap); in ata_eh_set_pending()
893 ap->fastdrain_cnt = cnt; in ata_eh_set_pending()
894 ap->fastdrain_timer.expires = in ata_eh_set_pending()
896 add_timer(&ap->fastdrain_timer); in ata_eh_set_pending()
911 struct ata_port *ap = qc->ap; in ata_qc_schedule_eh() local
913 WARN_ON(!ap->ops->error_handler); in ata_qc_schedule_eh()
916 ata_eh_set_pending(ap, 1); in ata_qc_schedule_eh()
928 * @ap: ATA port to schedule EH for
933 void ata_std_sched_eh(struct ata_port *ap) in ata_std_sched_eh() argument
935 WARN_ON(!ap->ops->error_handler); in ata_std_sched_eh()
937 if (ap->pflags & ATA_PFLAG_INITIALIZING) in ata_std_sched_eh()
940 ata_eh_set_pending(ap, 1); in ata_std_sched_eh()
941 scsi_schedule_eh(ap->scsi_host); in ata_std_sched_eh()
949 * @ap: ATA port to end EH for
952 * shost, so host fields can be directly manipulated under ap->lock, in
959 void ata_std_end_eh(struct ata_port *ap) in ata_std_end_eh() argument
961 struct Scsi_Host *host = ap->scsi_host; in ata_std_end_eh()
970 * @ap: ATA port to schedule EH for
972 * Schedule error handling for @ap. EH will kick in as soon as
978 void ata_port_schedule_eh(struct ata_port *ap) in ata_port_schedule_eh() argument
981 ap->ops->sched_eh(ap); in ata_port_schedule_eh()
985 static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link) in ata_do_link_abort() argument
990 WARN_ON(!ap->ops->error_handler); in ata_do_link_abort()
993 ata_eh_set_pending(ap, 0); in ata_do_link_abort()
996 ata_qc_for_each_with_internal(ap, qc, tag) { in ata_do_link_abort()
1005 ata_port_schedule_eh(ap); in ata_do_link_abort()
1024 return ata_do_link_abort(link->ap, link); in ata_link_abort()
1030 * @ap: ATA port to abort qc's for
1032 * Abort all active qc's of @ap and schedule EH.
1040 int ata_port_abort(struct ata_port *ap) in ata_port_abort() argument
1042 return ata_do_link_abort(ap, NULL); in ata_port_abort()
1048 * @ap: ATA port to freeze
1055 * ap->ops->freeze() callback can be used for freezing the port
1064 static void __ata_port_freeze(struct ata_port *ap) in __ata_port_freeze() argument
1066 WARN_ON(!ap->ops->error_handler); in __ata_port_freeze()
1068 if (ap->ops->freeze) in __ata_port_freeze()
1069 ap->ops->freeze(ap); in __ata_port_freeze()
1071 ap->pflags |= ATA_PFLAG_FROZEN; in __ata_port_freeze()
1073 DPRINTK("ata%u port frozen\n", ap->print_id); in __ata_port_freeze()
1078 * @ap: ATA port to freeze
1080 * Abort and freeze @ap. The freeze operation must be called
1090 int ata_port_freeze(struct ata_port *ap) in ata_port_freeze() argument
1094 WARN_ON(!ap->ops->error_handler); in ata_port_freeze()
1096 __ata_port_freeze(ap); in ata_port_freeze()
1097 nr_aborted = ata_port_abort(ap); in ata_port_freeze()
1105 * @ap: ATA port to freeze
1107 * Freeze @ap.
1112 void ata_eh_freeze_port(struct ata_port *ap) in ata_eh_freeze_port() argument
1116 if (!ap->ops->error_handler) in ata_eh_freeze_port()
1119 spin_lock_irqsave(ap->lock, flags); in ata_eh_freeze_port()
1120 __ata_port_freeze(ap); in ata_eh_freeze_port()
1121 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_freeze_port()
1127 * @ap: ATA port to thaw
1129 * Thaw frozen port @ap.
1134 void ata_eh_thaw_port(struct ata_port *ap) in ata_eh_thaw_port() argument
1138 if (!ap->ops->error_handler) in ata_eh_thaw_port()
1141 spin_lock_irqsave(ap->lock, flags); in ata_eh_thaw_port()
1143 ap->pflags &= ~ATA_PFLAG_FROZEN; in ata_eh_thaw_port()
1145 if (ap->ops->thaw) in ata_eh_thaw_port()
1146 ap->ops->thaw(ap); in ata_eh_thaw_port()
1148 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_thaw_port()
1150 DPRINTK("ata%u port thawed\n", ap->print_id); in ata_eh_thaw_port()
1160 struct ata_port *ap = qc->ap; in __ata_eh_qc_complete() local
1164 spin_lock_irqsave(ap->lock, flags); in __ata_eh_qc_complete()
1168 spin_unlock_irqrestore(ap->lock, flags); in __ata_eh_qc_complete()
1170 scsi_eh_finish_cmd(scmd, &ap->eh_done_q); in __ata_eh_qc_complete()
1220 if (ata_msg_drv(dev->link->ap)) in ata_dev_disable()
1245 struct ata_port *ap = link->ap; in ata_eh_detach_dev() local
1251 spin_lock_irqsave(ap->lock, flags); in ata_eh_detach_dev()
1257 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_detach_dev()
1266 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_detach_dev()
1285 struct ata_port *ap = link->ap; in ata_eh_about_to_do() local
1290 spin_lock_irqsave(ap->lock, flags); in ata_eh_about_to_do()
1297 if (!(ehc->i.flags & ATA_EHI_QUIET) && link != ap->slave_link) in ata_eh_about_to_do()
1298 ap->pflags |= ATA_PFLAG_RECOVERED; in ata_eh_about_to_do()
1300 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_about_to_do()
1411 if (qc->ap->pflags & ATA_PFLAG_FROZEN) { in ata_eh_request_sense()
1463 struct ata_port *ap = dev->link->ap; in atapi_eh_request_sense() local
1483 if (ap->flags & ATA_FLAG_PIO_DMA) { in atapi_eh_request_sense()
1598 if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) { in ata_eh_analyze_tf()
1858 (link->ap->cbl != ATA_CBL_SATA || dev->class == ATA_DEV_ATAPI) && in ata_eh_speed_down()
1923 struct ata_port *ap = link->ap; in ata_eh_link_autopsy() local
1958 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_autopsy()
2008 if (ap->pflags & ATA_PFLAG_FROZEN || in ata_eh_link_autopsy()
2026 ap->link.eh_context.i.err_mask |= AC_ERR_TIMEOUT; in ata_eh_link_autopsy()
2045 * @ap: host port to perform autopsy on
2047 * Analyze all links of @ap and determine why they failed and
2053 void ata_eh_autopsy(struct ata_port *ap) in ata_eh_autopsy() argument
2057 ata_for_each_link(link, ap, EDGE) in ata_eh_autopsy()
2064 if (ap->slave_link) { in ata_eh_autopsy()
2065 struct ata_eh_context *mehc = &ap->link.eh_context; in ata_eh_autopsy()
2066 struct ata_eh_context *sehc = &ap->slave_link->eh_context; in ata_eh_autopsy()
2072 ata_eh_link_autopsy(ap->slave_link); in ata_eh_autopsy()
2075 ata_eh_about_to_do(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2079 ata_eh_done(ap->slave_link, NULL, ATA_EH_ALL_ACTIONS); in ata_eh_autopsy()
2085 if (sata_pmp_attached(ap)) in ata_eh_autopsy()
2086 ata_eh_link_autopsy(&ap->link); in ata_eh_autopsy()
2222 struct ata_port *ap = link->ap; in ata_eh_link_report() local
2236 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2252 if (ap->pflags & ATA_PFLAG_FROZEN) in ata_eh_link_report()
2255 if (ap->eh_tries < ATA_EH_MAX_TRIES) in ata_eh_link_report()
2257 ap->eh_tries); in ata_eh_link_report()
2298 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2411 * @ap: ATA port to report EH about
2418 void ata_eh_report(struct ata_port *ap) in ata_eh_report() argument
2422 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_report()
2445 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) in ata_eh_followup_srst_needed()
2454 struct ata_port *ap = link->ap; in ata_eh_reset() local
2455 struct ata_link *slave = ap->slave_link; in ata_eh_reset()
2492 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2493 ap->pflags |= ATA_PFLAG_RESETTING; in ata_eh_reset()
2494 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2514 if (ap->ops->set_piomode) in ata_eh_reset()
2515 ap->ops->set_piomode(ap, dev); in ata_eh_reset()
2576 if ((ap->pflags & ATA_PFLAG_FROZEN) && in ata_eh_reset()
2578 ata_eh_thaw_port(ap); in ata_eh_reset()
2589 ata_eh_freeze_port(ap); in ata_eh_reset()
2690 ata_eh_thaw_port(ap); in ata_eh_reset()
2712 spin_lock_irqsave(link->ap->lock, flags); in ata_eh_reset()
2716 ap->pflags &= ~ATA_PFLAG_EH_PENDING; in ata_eh_reset()
2717 spin_unlock_irqrestore(link->ap->lock, flags); in ata_eh_reset()
2719 if (ap->pflags & ATA_PFLAG_FROZEN) in ata_eh_reset()
2720 ata_eh_thaw_port(ap); in ata_eh_reset()
2780 spin_lock_irqsave(ap->lock, flags); in ata_eh_reset()
2781 ap->pflags &= ~ATA_PFLAG_RESETTING; in ata_eh_reset()
2782 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_reset()
2800 ata_eh_thaw_port(ap); in ata_eh_reset()
2812 ata_eh_release(ap); in ata_eh_reset()
2815 ata_eh_acquire(ap); in ata_eh_reset()
2824 ata_eh_thaw_port(ap); in ata_eh_reset()
2840 static inline void ata_eh_pull_park_action(struct ata_port *ap) in ata_eh_pull_park_action() argument
2858 * Additionally, all write accesses to &ap->park_req_pending in ata_eh_pull_park_action()
2863 * *all* devices on port ap have been pulled into the in ata_eh_pull_park_action()
2868 * ap and we have to cycle over the do {} while () loop in in ata_eh_pull_park_action()
2872 spin_lock_irqsave(ap->lock, flags); in ata_eh_pull_park_action()
2873 reinit_completion(&ap->park_req_pending); in ata_eh_pull_park_action()
2874 ata_for_each_link(link, ap, EDGE) { in ata_eh_pull_park_action()
2883 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_pull_park_action()
2917 struct ata_port *ap = link->ap; in ata_eh_revalidate_and_attach() local
2959 schedule_work(&(ap->scsi_rescan_task)); in ata_eh_revalidate_and_attach()
2992 ata_eh_thaw_port(ap); in ata_eh_revalidate_and_attach()
3002 if (ap->ops->cable_detect) in ata_eh_revalidate_and_attach()
3003 ap->cbl = ap->ops->cable_detect(ap); in ata_eh_revalidate_and_attach()
3004 ata_force_cbl(ap); in ata_eh_revalidate_and_attach()
3027 spin_lock_irqsave(ap->lock, flags); in ata_eh_revalidate_and_attach()
3028 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; in ata_eh_revalidate_and_attach()
3029 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_revalidate_and_attach()
3060 struct ata_port *ap = link->ap; in ata_set_mode() local
3076 if (ap->ops->set_mode) in ata_set_mode()
3077 rc = ap->ops->set_mode(link, r_failed_dev); in ata_set_mode()
3114 u8 *sense_buffer = dev->link->ap->sector_buf; in atapi_eh_clear_ua()
3163 struct ata_port *ap = link->ap; in ata_eh_maybe_retry_flush() local
3173 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_maybe_retry_flush()
3212 if (!(ap->pflags & ATA_PFLAG_FROZEN)) in ata_eh_maybe_retry_flush()
3239 struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL; in ata_eh_set_lpm() local
3243 bool no_dipm = link->ap->flags & ATA_FLAG_NO_DIPM; in ata_eh_set_lpm()
3250 (link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm)) in ata_eh_set_lpm()
3288 if (ap) { in ata_eh_set_lpm()
3289 rc = ap->ops->set_lpm(link, policy, hints); in ata_eh_set_lpm()
3290 if (!rc && ap->slave_link) in ata_eh_set_lpm()
3291 rc = ap->ops->set_lpm(ap->slave_link, policy, hints); in ata_eh_set_lpm()
3313 if (ap && ap->slave_link) in ata_eh_set_lpm()
3314 ap->slave_link->lpm_policy = policy; in ata_eh_set_lpm()
3340 if (ap && ap->slave_link) in ata_eh_set_lpm()
3341 ap->slave_link->lpm_policy = old_policy; in ata_eh_set_lpm()
3376 struct ata_port *ap = link->ap; in ata_eh_skip_recovery() local
3389 if ((ap->pflags & ATA_PFLAG_FROZEN) || ata_link_nr_enabled(link)) in ata_eh_skip_recovery()
3441 link->ap->ops->set_lpm(link, ATA_LPM_MAX_POWER, in ata_eh_schedule_probe()
3524 * @ap: host port to recover
3544 int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_eh_recover() argument
3557 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3563 spin_lock_irqsave(ap->lock, flags); in ata_eh_recover()
3565 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_recover()
3594 if (ap->pflags & ATA_PFLAG_UNLOADING) in ata_eh_recover()
3598 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3610 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3629 * ap->park_req_pending in ata_eh_recover()
3631 ata_eh_pull_park_action(ap); in ata_eh_recover()
3634 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3661 ata_eh_release(ap); in ata_eh_recover()
3662 deadline = wait_for_completion_timeout(&ap->park_req_pending, in ata_eh_recover()
3664 ata_eh_acquire(ap); in ata_eh_recover()
3666 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3679 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_recover()
3682 if (sata_pmp_attached(ap) && ata_is_host_link(link)) in ata_eh_recover()
3731 if (link->lpm_policy != ap->target_lpm_policy) { in ata_eh_recover()
3732 rc = ata_eh_set_lpm(link, ap->target_lpm_policy, &dev); in ata_eh_recover()
3746 if (ap->pflags & ATA_PFLAG_FROZEN) { in ata_eh_recover()
3750 if (sata_pmp_attached(ap)) in ata_eh_recover()
3769 * @ap: host port to finish EH for
3777 void ata_eh_finish(struct ata_port *ap) in ata_eh_finish() argument
3783 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_finish()
3808 WARN_ON(ap->nr_active_links); in ata_eh_finish()
3809 ap->nr_active_links = 0; in ata_eh_finish()
3814 * @ap: host port to handle error for
3826 void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, in ata_do_eh() argument
3833 ata_eh_autopsy(ap); in ata_do_eh()
3834 ata_eh_report(ap); in ata_do_eh()
3836 rc = ata_eh_recover(ap, prereset, softreset, hardreset, postreset, in ata_do_eh()
3839 ata_for_each_dev(dev, &ap->link, ALL) in ata_do_eh()
3843 ata_eh_finish(ap); in ata_do_eh()
3848 * @ap: host port to handle error for
3855 void ata_std_error_handler(struct ata_port *ap) in ata_std_error_handler() argument
3857 struct ata_port_operations *ops = ap->ops; in ata_std_error_handler()
3861 if (hardreset == sata_std_hardreset && !sata_scr_valid(&ap->link)) in ata_std_error_handler()
3864 ata_do_eh(ap, ops->prereset, ops->softreset, hardreset, ops->postreset); in ata_std_error_handler()
3871 * @ap: port to suspend
3873 * Suspend @ap.
3878 static void ata_eh_handle_port_suspend(struct ata_port *ap) in ata_eh_handle_port_suspend() argument
3885 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
3886 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_suspend()
3887 ap->pm_mesg.event & PM_EVENT_RESUME) { in ata_eh_handle_port_suspend()
3888 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
3891 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
3893 WARN_ON(ap->pflags & ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_suspend()
3900 if (PMSG_IS_AUTO(ap->pm_mesg)) { in ata_eh_handle_port_suspend()
3901 ata_for_each_dev(dev, &ap->link, ENABLED) { in ata_eh_handle_port_suspend()
3908 rc = ata_acpi_on_suspend(ap); in ata_eh_handle_port_suspend()
3913 ata_eh_freeze_port(ap); in ata_eh_handle_port_suspend()
3915 if (ap->ops->port_suspend) in ata_eh_handle_port_suspend()
3916 rc = ap->ops->port_suspend(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
3918 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_suspend()
3921 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_suspend()
3923 ap->pflags &= ~ATA_PFLAG_PM_PENDING; in ata_eh_handle_port_suspend()
3925 ap->pflags |= ATA_PFLAG_SUSPENDED; in ata_eh_handle_port_suspend()
3926 else if (ap->pflags & ATA_PFLAG_FROZEN) in ata_eh_handle_port_suspend()
3927 ata_port_schedule_eh(ap); in ata_eh_handle_port_suspend()
3929 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_suspend()
3936 * @ap: port to resume
3938 * Resume @ap.
3943 static void ata_eh_handle_port_resume(struct ata_port *ap) in ata_eh_handle_port_resume() argument
3950 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
3951 if (!(ap->pflags & ATA_PFLAG_PM_PENDING) || in ata_eh_handle_port_resume()
3952 !(ap->pm_mesg.event & PM_EVENT_RESUME)) { in ata_eh_handle_port_resume()
3953 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
3956 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()
3958 WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED)); in ata_eh_handle_port_resume()
3967 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_handle_port_resume()
3971 ata_acpi_set_state(ap, ap->pm_mesg); in ata_eh_handle_port_resume()
3973 if (ap->ops->port_resume) in ata_eh_handle_port_resume()
3974 ap->ops->port_resume(ap); in ata_eh_handle_port_resume()
3977 ata_acpi_on_resume(ap); in ata_eh_handle_port_resume()
3980 spin_lock_irqsave(ap->lock, flags); in ata_eh_handle_port_resume()
3981 ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); in ata_eh_handle_port_resume()
3982 spin_unlock_irqrestore(ap->lock, flags); in ata_eh_handle_port_resume()