Lines Matching refs:link

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()
341 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_internal_cmd_timeout()
366 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_internal_cmd_timed_out()
437 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_eh_dev_action()
442 static void ata_eh_clear_action(struct ata_link *link, struct ata_device *dev, in ata_eh_clear_action() argument
449 ata_for_each_dev(tdev, link, ALL) in ata_eh_clear_action()
457 ata_for_each_dev(tdev, link, ALL) in ata_eh_clear_action()
539 qc = ata_qc_from_tag(ap, ap->link.active_tag); in ata_scsi_timed_out()
555 struct ata_link *link; in ata_eh_unload() local
562 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_unload()
563 sata_scr_write(link, SCR_CONTROL, link->saved_scontrol & 0xff0); in ata_eh_unload()
564 ata_for_each_dev(dev, link, ALL) in ata_eh_unload()
726 struct ata_link *link; in ata_scsi_port_error_handler() local
740 ata_for_each_link(link, ap, HOST_FIRST) { in ata_scsi_port_error_handler()
741 struct ata_eh_context *ehc = &link->eh_context; in ata_scsi_port_error_handler()
744 memset(&link->eh_context, 0, sizeof(link->eh_context)); in ata_scsi_port_error_handler()
745 link->eh_context.i = link->eh_info; in ata_scsi_port_error_handler()
746 memset(&link->eh_info, 0, sizeof(link->eh_info)); in ata_scsi_port_error_handler()
748 ata_for_each_dev(dev, link, ENABLED) { in ata_scsi_port_error_handler()
795 ata_for_each_link(link, ap, HOST_FIRST) in ata_scsi_port_error_handler()
796 memset(&link->eh_info, 0, sizeof(link->eh_info)); 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()
1048 static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link) in ata_do_link_abort() argument
1060 if (qc && (!link || qc->dev->link == link)) { in ata_do_link_abort()
1085 int ata_link_abort(struct ata_link *link) in ata_link_abort() argument
1087 return ata_do_link_abort(link->ap, link); in ata_link_abort()
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()
1195 struct ata_device *dev = ap->link.device; in sata_async_notification()
1212 struct ata_link *link; in sata_async_notification() local
1215 ata_for_each_link(link, ap, EDGE) { in sata_async_notification()
1216 if (!(sntf & (1 << link->pmp))) in sata_async_notification()
1219 if ((link->device->class == ATA_DEV_ATAPI) && in sata_async_notification()
1220 (link->device->flags & ATA_DFLAG_AN)) in sata_async_notification()
1221 ata_scsi_media_change_notify(link->device); in sata_async_notification()
1352 if (ata_msg_drv(dev->link->ap)) in ata_dev_disable()
1375 struct ata_link *link = dev->link; in ata_eh_detach_dev() local
1376 struct ata_port *ap = link->ap; in ata_eh_detach_dev()
1377 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_detach_dev()
1392 ata_eh_clear_action(link, dev, &link->eh_info, ATA_EH_PERDEV_MASK); in ata_eh_detach_dev()
1393 ata_eh_clear_action(link, dev, &link->eh_context.i, ATA_EH_PERDEV_MASK); in ata_eh_detach_dev()
1413 void ata_eh_about_to_do(struct ata_link *link, struct ata_device *dev, in ata_eh_about_to_do() argument
1416 struct ata_port *ap = link->ap; in ata_eh_about_to_do()
1417 struct ata_eh_info *ehi = &link->eh_info; in ata_eh_about_to_do()
1418 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_about_to_do()
1423 ata_eh_clear_action(link, dev, ehi, action); in ata_eh_about_to_do()
1428 if (!(ehc->i.flags & ATA_EHI_QUIET) && link != ap->slave_link) in ata_eh_about_to_do()
1446 void ata_eh_done(struct ata_link *link, struct ata_device *dev, in ata_eh_done() argument
1449 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_done()
1451 ata_eh_clear_action(link, dev, &ehc->i, action); in ata_eh_done()
1563 u8 *buf = dev->link->ap->sector_buf; in ata_eh_read_log_10h()
1650 struct ata_port *ap = dev->link->ap; in atapi_eh_request_sense()
1693 static void ata_eh_analyze_serror(struct ata_link *link) in ata_eh_analyze_serror() argument
1695 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_analyze_serror()
1718 if (link->lpm_policy > ATA_LPM_MAX_POWER) in ata_eh_analyze_serror()
1720 else if (!(link->flags & ATA_LFLAG_DISABLED) || ata_is_host_link(link)) in ata_eh_analyze_serror()
1744 void ata_eh_analyze_ncq_error(struct ata_link *link) in ata_eh_analyze_ncq_error() argument
1746 struct ata_port *ap = link->ap; in ata_eh_analyze_ncq_error()
1747 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_analyze_ncq_error()
1748 struct ata_device *dev = link->device; in ata_eh_analyze_ncq_error()
1758 if (!link->sactive || !(ehc->i.err_mask & AC_ERR_DEV)) in ata_eh_analyze_ncq_error()
1776 ata_link_err(link, "failed to read log page 10h (errno=%d)\n", in ata_eh_analyze_ncq_error()
1781 if (!(link->sactive & (1 << tag))) { in ata_eh_analyze_ncq_error()
1782 ata_link_err(link, "log page 10h reported inactive tag %d\n", in ata_eh_analyze_ncq_error()
2031 struct ata_link *link = ata_dev_phys_link(dev); in ata_eh_speed_down() local
2056 if (sata_down_spd_limit(link, 0) == 0) { in ata_eh_speed_down()
2087 (link->ap->cbl != ATA_CBL_SATA || dev->class == ATA_DEV_ATAPI) && in ata_eh_speed_down()
2135 static void ata_eh_link_autopsy(struct ata_link *link) in ata_eh_link_autopsy() argument
2137 struct ata_port *ap = link->ap; in ata_eh_link_autopsy()
2138 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_link_autopsy()
2151 rc = sata_scr_read(link, SCR_ERROR, &serror); in ata_eh_link_autopsy()
2154 ata_eh_analyze_serror(link); in ata_eh_link_autopsy()
2163 ata_eh_analyze_ncq_error(link); in ata_eh_link_autopsy()
2175 ata_dev_phys_link(qc->dev) != link) in ata_eh_link_autopsy()
2227 if ((all_err_mask & AC_ERR_TIMEOUT) && !ata_is_host_link(link)) in ata_eh_link_autopsy()
2228 ap->link.eh_context.i.err_mask |= AC_ERR_TIMEOUT; in ata_eh_link_autopsy()
2232 if (!dev && ((ata_link_max_devices(link) == 1 && in ata_eh_link_autopsy()
2233 ata_dev_enabled(link->device)))) in ata_eh_link_autopsy()
2234 dev = link->device; in ata_eh_link_autopsy()
2257 struct ata_link *link; in ata_eh_autopsy() local
2259 ata_for_each_link(link, ap, EDGE) in ata_eh_autopsy()
2260 ata_eh_link_autopsy(link); in ata_eh_autopsy()
2267 struct ata_eh_context *mehc = &ap->link.eh_context; in ata_eh_autopsy()
2288 ata_eh_link_autopsy(&ap->link); in ata_eh_autopsy()
2420 static void ata_eh_link_report(struct ata_link *link) in ata_eh_link_report() argument
2422 struct ata_port *ap = link->ap; in ata_eh_link_report()
2423 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_link_report()
2439 ata_dev_phys_link(qc->dev) != link || in ata_eh_link_report()
2463 ehc->i.err_mask, link->sactive, ehc->i.serror, in ata_eh_link_report()
2468 ata_link_err(link, "exception Emask 0x%x " in ata_eh_link_report()
2470 ehc->i.err_mask, link->sactive, ehc->i.serror, in ata_eh_link_report()
2473 ata_link_err(link, "%s\n", desc); in ata_eh_link_report()
2478 ata_link_err(link, in ata_eh_link_report()
2506 ata_dev_phys_link(qc->dev) != link || !qc->err_mask) in ata_eh_link_report()
2599 struct ata_link *link; in ata_eh_report() local
2601 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_report()
2602 ata_eh_link_report(link); in ata_eh_report()
2605 static int ata_do_reset(struct ata_link *link, ata_reset_fn_t reset, in ata_do_reset() argument
2612 ata_for_each_dev(dev, link, ALL) in ata_do_reset()
2615 return reset(link, classes, deadline); in ata_do_reset()
2618 static int ata_eh_followup_srst_needed(struct ata_link *link, int rc) in ata_eh_followup_srst_needed() argument
2620 if ((link->flags & ATA_LFLAG_NO_SRST) || ata_link_offline(link)) in ata_eh_followup_srst_needed()
2624 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) in ata_eh_followup_srst_needed()
2629 int ata_eh_reset(struct ata_link *link, int classify, in ata_eh_reset() argument
2633 struct ata_port *ap = link->ap; in ata_eh_reset()
2635 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_reset()
2638 unsigned int lflags = link->flags; in ata_eh_reset()
2654 if (link->flags & ATA_LFLAG_RST_ONCE) in ata_eh_reset()
2656 if (link->flags & ATA_LFLAG_NO_HRST) in ata_eh_reset()
2658 if (link->flags & ATA_LFLAG_NO_SRST) in ata_eh_reset()
2675 ata_eh_about_to_do(link, NULL, ATA_EH_RESET); in ata_eh_reset()
2677 ata_for_each_dev(dev, link, ALL) { in ata_eh_reset()
2717 rc = prereset(link, deadline); in ata_eh_reset()
2735 ata_link_dbg(link, "port disabled--ignoring\n"); in ata_eh_reset()
2738 ata_for_each_dev(dev, link, ALL) in ata_eh_reset()
2743 ata_link_err(link, in ata_eh_reset()
2753 ata_for_each_dev(dev, link, ALL) in ata_eh_reset()
2756 ata_is_host_link(link)) in ata_eh_reset()
2767 if (ata_is_host_link(link)) in ata_eh_reset()
2774 ata_link_info(link, "%s resetting link\n", in ata_eh_reset()
2784 rc = ata_do_reset(link, reset, classes, deadline, true); in ata_eh_reset()
2786 failed_link = link; in ata_eh_reset()
2814 ata_eh_followup_srst_needed(link, rc)) { in ata_eh_reset()
2818 ata_link_err(link, in ata_eh_reset()
2820 failed_link = link; in ata_eh_reset()
2825 ata_eh_about_to_do(link, NULL, ATA_EH_RESET); in ata_eh_reset()
2826 rc = ata_do_reset(link, reset, classes, deadline, true); in ata_eh_reset()
2828 failed_link = link; in ata_eh_reset()
2834 ata_link_info(link, in ata_eh_reset()
2843 ata_for_each_dev(dev, link, ALL) { in ata_eh_reset()
2862 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0) in ata_eh_reset()
2863 link->sata_spd = (sstatus >> 4) & 0xf; in ata_eh_reset()
2868 if (ata_is_host_link(link)) in ata_eh_reset()
2879 postreset(link, classes); in ata_eh_reset()
2891 spin_lock_irqsave(link->ap->lock, flags); in ata_eh_reset()
2892 memset(&link->eh_info, 0, sizeof(link->eh_info)); in ata_eh_reset()
2894 memset(&slave->eh_info, 0, sizeof(link->eh_info)); in ata_eh_reset()
2896 spin_unlock_irqrestore(link->ap->lock, flags); in ata_eh_reset()
2910 ata_for_each_dev(dev, link, ALL) { in ata_eh_reset()
2932 ata_link_warn(link, in ata_eh_reset()
2935 failed_link = link; in ata_eh_reset()
2939 ata_link_warn(link, in ata_eh_reset()
2945 ata_eh_done(link, NULL, ATA_EH_RESET); in ata_eh_reset()
2950 link->lpm_policy = ATA_LPM_UNKNOWN; /* reset LPM state */ in ata_eh_reset()
2967 if (!ata_is_host_link(link) && in ata_eh_reset()
2968 sata_scr_read(link, SCR_STATUS, &sstatus)) in ata_eh_reset()
2978 if (ata_is_host_link(link)) in ata_eh_reset()
3002 if (ata_is_host_link(link)) in ata_eh_reset()
3008 sata_down_spd_limit(link, 0); in ata_eh_reset()
3021 struct ata_link *link; in ata_eh_pull_park_action() local
3053 ata_for_each_link(link, ap, EDGE) { in ata_eh_pull_park_action()
3054 ata_for_each_dev(dev, link, ALL) { in ata_eh_pull_park_action()
3055 struct ata_eh_info *ehi = &link->eh_info; in ata_eh_pull_park_action()
3057 link->eh_context.i.dev_action[dev->devno] |= in ata_eh_pull_park_action()
3059 ata_eh_clear_action(link, dev, ehi, ATA_EH_PARK); in ata_eh_pull_park_action()
3067 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_eh_park_issue_cmd()
3093 static int ata_eh_revalidate_and_attach(struct ata_link *link, in ata_eh_revalidate_and_attach() argument
3096 struct ata_port *ap = link->ap; in ata_eh_revalidate_and_attach()
3097 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_revalidate_and_attach()
3109 ata_for_each_dev(dev, link, ALL_REVERSE) { in ata_eh_revalidate_and_attach()
3124 ata_eh_about_to_do(link, dev, ATA_EH_REVALIDATE); in ata_eh_revalidate_and_attach()
3130 ata_eh_done(link, dev, ATA_EH_REVALIDATE); in ata_eh_revalidate_and_attach()
3180 if ((ehc->i.flags & ATA_EHI_DID_RESET) && ata_is_host_link(link)) { in ata_eh_revalidate_and_attach()
3189 ata_for_each_dev(dev, link, ALL) { in ata_eh_revalidate_and_attach()
3237 int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev) in ata_set_mode() argument
3239 struct ata_port *ap = link->ap; in ata_set_mode()
3244 ata_for_each_dev(dev, link, ENABLED) { in ata_set_mode()
3256 rc = ap->ops->set_mode(link, r_failed_dev); in ata_set_mode()
3258 rc = ata_do_set_mode(link, r_failed_dev); in ata_set_mode()
3261 ata_for_each_dev(dev, link, ENABLED) { in ata_set_mode()
3262 struct ata_eh_context *ehc = &link->eh_context; in ata_set_mode()
3293 u8 *sense_buffer = dev->link->ap->sector_buf; in atapi_eh_clear_ua()
3341 struct ata_link *link = dev->link; in ata_eh_maybe_retry_flush() local
3342 struct ata_port *ap = link->ap; in ata_eh_maybe_retry_flush()
3349 if (!ata_tag_valid(link->active_tag)) in ata_eh_maybe_retry_flush()
3352 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_maybe_retry_flush()
3415 static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy, in ata_eh_set_lpm() argument
3418 struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL; in ata_eh_set_lpm()
3419 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_set_lpm()
3421 enum ata_lpm_policy old_policy = link->lpm_policy; in ata_eh_set_lpm()
3422 bool no_dipm = link->ap->flags & ATA_FLAG_NO_DIPM; in ata_eh_set_lpm()
3428 if ((link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm)) in ata_eh_set_lpm()
3437 ata_for_each_dev(dev, link, ENABLED) { in ata_eh_set_lpm()
3467 rc = ap->ops->set_lpm(link, policy, hints); in ata_eh_set_lpm()
3471 rc = sata_pmp_set_lpm(link, policy, hints); in ata_eh_set_lpm()
3479 link->flags |= ATA_LFLAG_NO_LPM; in ata_eh_set_lpm()
3490 link->lpm_policy = policy; in ata_eh_set_lpm()
3495 ata_for_each_dev(dev, link, ENABLED) { in ata_eh_set_lpm()
3510 link->last_lpm_change = jiffies; in ata_eh_set_lpm()
3511 link->flags |= ATA_LFLAG_CHANGED; in ata_eh_set_lpm()
3517 link->lpm_policy = old_policy; in ata_eh_set_lpm()
3523 ata_link_warn(link, "disabling LPM on the link\n"); in ata_eh_set_lpm()
3524 link->flags |= ATA_LFLAG_NO_LPM; in ata_eh_set_lpm()
3531 int ata_link_nr_enabled(struct ata_link *link) in ata_link_nr_enabled() argument
3536 ata_for_each_dev(dev, link, ENABLED) in ata_link_nr_enabled()
3541 static int ata_link_nr_vacant(struct ata_link *link) in ata_link_nr_vacant() argument
3546 ata_for_each_dev(dev, link, ALL) in ata_link_nr_vacant()
3552 static int ata_eh_skip_recovery(struct ata_link *link) in ata_eh_skip_recovery() argument
3554 struct ata_port *ap = link->ap; in ata_eh_skip_recovery()
3555 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_skip_recovery()
3559 if (link->flags & ATA_LFLAG_DISABLED) in ata_eh_skip_recovery()
3567 if ((ap->pflags & ATA_PFLAG_FROZEN) || ata_link_nr_enabled(link)) in ata_eh_skip_recovery()
3576 ata_for_each_dev(dev, link, ALL) { in ata_eh_skip_recovery()
3601 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_eh_schedule_probe()
3602 struct ata_link *link = ata_dev_phys_link(dev); in ata_eh_schedule_probe() local
3617 if (link->lpm_policy > ATA_LPM_MAX_POWER) { in ata_eh_schedule_probe()
3618 if (ata_is_host_link(link)) in ata_eh_schedule_probe()
3619 link->ap->ops->set_lpm(link, ATA_LPM_MAX_POWER, in ata_eh_schedule_probe()
3622 sata_pmp_set_lpm(link, ATA_LPM_MAX_POWER, in ata_eh_schedule_probe()
3643 sata_down_spd_limit(link, 1); in ata_eh_schedule_probe()
3650 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_eh_handle_dev_fail()
3725 struct ata_link *link; in ata_eh_recover() local
3733 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3734 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3738 ata_eh_about_to_do(link, NULL, ATA_EH_ENABLE_LINK); in ata_eh_recover()
3740 link->flags &= ~ATA_LFLAG_DISABLED; in ata_eh_recover()
3742 ata_eh_done(link, NULL, ATA_EH_ENABLE_LINK); in ata_eh_recover()
3745 ata_for_each_dev(dev, link, ALL) { in ata_eh_recover()
3746 if (link->flags & ATA_LFLAG_NO_RETRY) in ata_eh_recover()
3774 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3775 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3778 if (ata_eh_skip_recovery(link)) in ata_eh_recover()
3781 ata_for_each_dev(dev, link, ALL) in ata_eh_recover()
3786 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3787 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3792 rc = ata_eh_reset(link, ata_link_nr_vacant(link), in ata_eh_recover()
3795 ata_link_err(link, "reset failed, giving up\n"); in ata_eh_recover()
3810 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3811 ata_for_each_dev(dev, link, ALL) { in ata_eh_recover()
3812 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3842 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3843 ata_for_each_dev(dev, link, ALL) { in ata_eh_recover()
3844 if (!(link->eh_context.unloaded_mask & in ata_eh_recover()
3849 ata_eh_done(link, dev, ATA_EH_PARK); in ata_eh_recover()
3855 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_recover()
3856 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3858 if (sata_pmp_attached(ap) && ata_is_host_link(link)) in ata_eh_recover()
3862 rc = ata_eh_revalidate_and_attach(link, &dev); in ata_eh_recover()
3867 if (link->device->class == ATA_DEV_PMP) { in ata_eh_recover()
3874 rc = ata_set_mode(link, &dev); in ata_eh_recover()
3884 ata_for_each_dev(dev, link, ALL) { in ata_eh_recover()
3896 ata_for_each_dev(dev, link, ALL) { in ata_eh_recover()
3907 if (link->lpm_policy != ap->target_lpm_policy) { in ata_eh_recover()
3908 rc = ata_eh_set_lpm(link, ap->target_lpm_policy, &dev); in ata_eh_recover()
3937 *r_failed_link = link; in ata_eh_recover()
4016 ata_for_each_dev(dev, &ap->link, ALL) in ata_do_eh()
4038 if (hardreset == sata_std_hardreset && !sata_scr_valid(&ap->link)) in ata_std_error_handler()
4077 ata_for_each_dev(dev, &ap->link, ENABLED) { in ata_eh_handle_port_suspend()
4121 struct ata_link *link; in ata_eh_handle_port_resume() local
4144 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_handle_port_resume()
4145 ata_for_each_dev(dev, link, ALL) in ata_eh_handle_port_resume()