Lines Matching refs:link
260 if (ap->link.eh_info.desc_len) in ata_port_desc()
261 __ata_ehi_push_desc(&ap->link.eh_info, " "); in ata_port_desc()
264 __ata_ehi_pushv_desc(&ap->link.eh_info, fmt, args); in ata_port_desc()
339 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_internal_cmd_timeout()
364 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_internal_cmd_timed_out()
435 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_eh_dev_action()
440 static void ata_eh_clear_action(struct ata_link *link, struct ata_device *dev, in ata_eh_clear_action() argument
447 ata_for_each_dev(tdev, link, ALL) in ata_eh_clear_action()
455 ata_for_each_dev(tdev, link, ALL) in ata_eh_clear_action()
537 qc = ata_qc_from_tag(ap, ap->link.active_tag); in ata_scsi_timed_out()
553 struct ata_link *link; in ata_eh_unload() local
560 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_unload()
561 sata_scr_write(link, SCR_CONTROL, link->saved_scontrol & 0xff0); in ata_eh_unload()
562 ata_for_each_dev(dev, link, ALL) in ata_eh_unload()
724 struct ata_link *link; in ata_scsi_port_error_handler() local
738 ata_for_each_link(link, ap, HOST_FIRST) { in ata_scsi_port_error_handler()
739 struct ata_eh_context *ehc = &link->eh_context; in ata_scsi_port_error_handler()
742 memset(&link->eh_context, 0, sizeof(link->eh_context)); in ata_scsi_port_error_handler()
743 link->eh_context.i = link->eh_info; in ata_scsi_port_error_handler()
744 memset(&link->eh_info, 0, sizeof(link->eh_info)); in ata_scsi_port_error_handler()
746 ata_for_each_dev(dev, link, ENABLED) { in ata_scsi_port_error_handler()
793 ata_for_each_link(link, ap, HOST_FIRST) in ata_scsi_port_error_handler()
794 memset(&link->eh_info, 0, sizeof(link->eh_info)); in ata_scsi_port_error_handler()
806 WARN_ON(ata_qc_from_tag(ap, ap->link.active_tag) == NULL); in ata_scsi_port_error_handler()
1046 static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link) in ata_do_link_abort() argument
1058 if (qc && (!link || qc->dev->link == link)) { in ata_do_link_abort()
1083 int ata_link_abort(struct ata_link *link) in ata_link_abort() argument
1085 return ata_do_link_abort(link->ap, link); in ata_link_abort()
1182 rc = sata_scr_read(&ap->link, SCR_NOTIFICATION, &sntf); in sata_async_notification()
1184 sata_scr_write(&ap->link, SCR_NOTIFICATION, sntf); in sata_async_notification()
1193 struct ata_device *dev = ap->link.device; in sata_async_notification()
1210 struct ata_link *link; in sata_async_notification() local
1213 ata_for_each_link(link, ap, EDGE) { in sata_async_notification()
1214 if (!(sntf & (1 << link->pmp))) in sata_async_notification()
1217 if ((link->device->class == ATA_DEV_ATAPI) && in sata_async_notification()
1218 (link->device->flags & ATA_DFLAG_AN)) in sata_async_notification()
1219 ata_scsi_media_change_notify(link->device); in sata_async_notification()
1350 if (ata_msg_drv(dev->link->ap)) in ata_dev_disable()
1373 struct ata_link *link = dev->link; in ata_eh_detach_dev() local
1374 struct ata_port *ap = link->ap; in ata_eh_detach_dev()
1375 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_detach_dev()
1390 ata_eh_clear_action(link, dev, &link->eh_info, ATA_EH_PERDEV_MASK); in ata_eh_detach_dev()
1391 ata_eh_clear_action(link, dev, &link->eh_context.i, ATA_EH_PERDEV_MASK); in ata_eh_detach_dev()
1411 void ata_eh_about_to_do(struct ata_link *link, struct ata_device *dev, in ata_eh_about_to_do() argument
1414 struct ata_port *ap = link->ap; in ata_eh_about_to_do()
1415 struct ata_eh_info *ehi = &link->eh_info; in ata_eh_about_to_do()
1416 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_about_to_do()
1421 ata_eh_clear_action(link, dev, ehi, action); in ata_eh_about_to_do()
1426 if (!(ehc->i.flags & ATA_EHI_QUIET) && link != ap->slave_link) in ata_eh_about_to_do()
1444 void ata_eh_done(struct ata_link *link, struct ata_device *dev, in ata_eh_done() argument
1447 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_done()
1449 ata_eh_clear_action(link, dev, &ehc->i, action); in ata_eh_done()
1545 u8 *buf = dev->link->ap->sector_buf; in ata_eh_read_log_10h()
1632 struct ata_port *ap = dev->link->ap; in atapi_eh_request_sense()
1676 static void ata_eh_analyze_serror(struct ata_link *link) in ata_eh_analyze_serror() argument
1678 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_analyze_serror()
1701 if (link->lpm_policy > ATA_LPM_MAX_POWER) in ata_eh_analyze_serror()
1703 else if (!(link->flags & ATA_LFLAG_DISABLED) || ata_is_host_link(link)) in ata_eh_analyze_serror()
1727 void ata_eh_analyze_ncq_error(struct ata_link *link) in ata_eh_analyze_ncq_error() argument
1729 struct ata_port *ap = link->ap; in ata_eh_analyze_ncq_error()
1730 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_analyze_ncq_error()
1731 struct ata_device *dev = link->device; in ata_eh_analyze_ncq_error()
1741 if (!link->sactive || !(ehc->i.err_mask & AC_ERR_DEV)) in ata_eh_analyze_ncq_error()
1759 ata_link_err(link, "failed to read log page 10h (errno=%d)\n", in ata_eh_analyze_ncq_error()
1764 if (!(link->sactive & (1 << tag))) { in ata_eh_analyze_ncq_error()
1765 ata_link_err(link, "log page 10h reported inactive tag %d\n", in ata_eh_analyze_ncq_error()
2013 struct ata_link *link = ata_dev_phys_link(dev); in ata_eh_speed_down() local
2038 if (sata_down_spd_limit(link, 0) == 0) { in ata_eh_speed_down()
2069 (link->ap->cbl != ATA_CBL_SATA || dev->class == ATA_DEV_ATAPI) && in ata_eh_speed_down()
2117 static void ata_eh_link_autopsy(struct ata_link *link) in ata_eh_link_autopsy() argument
2119 struct ata_port *ap = link->ap; in ata_eh_link_autopsy()
2120 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_link_autopsy()
2133 rc = sata_scr_read(link, SCR_ERROR, &serror); in ata_eh_link_autopsy()
2136 ata_eh_analyze_serror(link); in ata_eh_link_autopsy()
2145 ata_eh_analyze_ncq_error(link); in ata_eh_link_autopsy()
2157 ata_dev_phys_link(qc->dev) != link) in ata_eh_link_autopsy()
2208 if ((all_err_mask & AC_ERR_TIMEOUT) && !ata_is_host_link(link)) in ata_eh_link_autopsy()
2209 ap->link.eh_context.i.err_mask |= AC_ERR_TIMEOUT; in ata_eh_link_autopsy()
2213 if (!dev && ((ata_link_max_devices(link) == 1 && in ata_eh_link_autopsy()
2214 ata_dev_enabled(link->device)))) in ata_eh_link_autopsy()
2215 dev = link->device; in ata_eh_link_autopsy()
2238 struct ata_link *link; in ata_eh_autopsy() local
2240 ata_for_each_link(link, ap, EDGE) in ata_eh_autopsy()
2241 ata_eh_link_autopsy(link); in ata_eh_autopsy()
2248 struct ata_eh_context *mehc = &ap->link.eh_context; in ata_eh_autopsy()
2269 ata_eh_link_autopsy(&ap->link); in ata_eh_autopsy()
2392 static void ata_eh_link_report(struct ata_link *link) in ata_eh_link_report() argument
2394 struct ata_port *ap = link->ap; in ata_eh_link_report()
2395 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_link_report()
2411 ata_dev_phys_link(qc->dev) != link || in ata_eh_link_report()
2436 ehc->i.err_mask, link->sactive, ehc->i.serror, in ata_eh_link_report()
2441 ata_link_err(link, "exception Emask 0x%x " in ata_eh_link_report()
2443 ehc->i.err_mask, link->sactive, ehc->i.serror, in ata_eh_link_report()
2446 ata_link_err(link, "%s\n", desc); in ata_eh_link_report()
2451 ata_link_err(link, in ata_eh_link_report()
2480 ata_dev_phys_link(qc->dev) != link || !qc->err_mask) in ata_eh_link_report()
2573 struct ata_link *link; in ata_eh_report() local
2575 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_report()
2576 ata_eh_link_report(link); in ata_eh_report()
2579 static int ata_do_reset(struct ata_link *link, ata_reset_fn_t reset, in ata_do_reset() argument
2586 ata_for_each_dev(dev, link, ALL) in ata_do_reset()
2589 return reset(link, classes, deadline); in ata_do_reset()
2592 static int ata_eh_followup_srst_needed(struct ata_link *link, int rc) in ata_eh_followup_srst_needed() argument
2594 if ((link->flags & ATA_LFLAG_NO_SRST) || ata_link_offline(link)) in ata_eh_followup_srst_needed()
2598 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) in ata_eh_followup_srst_needed()
2603 int ata_eh_reset(struct ata_link *link, int classify, in ata_eh_reset() argument
2607 struct ata_port *ap = link->ap; in ata_eh_reset()
2609 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_reset()
2612 unsigned int lflags = link->flags; in ata_eh_reset()
2628 if (link->flags & ATA_LFLAG_RST_ONCE) in ata_eh_reset()
2630 if (link->flags & ATA_LFLAG_NO_HRST) in ata_eh_reset()
2632 if (link->flags & ATA_LFLAG_NO_SRST) in ata_eh_reset()
2649 ata_eh_about_to_do(link, NULL, ATA_EH_RESET); in ata_eh_reset()
2651 ata_for_each_dev(dev, link, ALL) { in ata_eh_reset()
2691 rc = prereset(link, deadline); in ata_eh_reset()
2709 ata_link_dbg(link, "port disabled--ignoring\n"); in ata_eh_reset()
2712 ata_for_each_dev(dev, link, ALL) in ata_eh_reset()
2717 ata_link_err(link, in ata_eh_reset()
2727 ata_for_each_dev(dev, link, ALL) in ata_eh_reset()
2730 ata_is_host_link(link)) in ata_eh_reset()
2741 if (ata_is_host_link(link)) in ata_eh_reset()
2748 ata_link_info(link, "%s resetting link\n", in ata_eh_reset()
2758 rc = ata_do_reset(link, reset, classes, deadline, true); in ata_eh_reset()
2760 failed_link = link; in ata_eh_reset()
2788 ata_eh_followup_srst_needed(link, rc)) { in ata_eh_reset()
2792 ata_link_err(link, in ata_eh_reset()
2794 failed_link = link; in ata_eh_reset()
2799 ata_eh_about_to_do(link, NULL, ATA_EH_RESET); in ata_eh_reset()
2800 rc = ata_do_reset(link, reset, classes, deadline, true); in ata_eh_reset()
2802 failed_link = link; in ata_eh_reset()
2808 ata_link_info(link, in ata_eh_reset()
2817 ata_for_each_dev(dev, link, ALL) { in ata_eh_reset()
2836 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0) in ata_eh_reset()
2837 link->sata_spd = (sstatus >> 4) & 0xf; in ata_eh_reset()
2842 if (ata_is_host_link(link)) in ata_eh_reset()
2853 postreset(link, classes); in ata_eh_reset()
2865 spin_lock_irqsave(link->ap->lock, flags); in ata_eh_reset()
2866 memset(&link->eh_info, 0, sizeof(link->eh_info)); in ata_eh_reset()
2868 memset(&slave->eh_info, 0, sizeof(link->eh_info)); in ata_eh_reset()
2870 spin_unlock_irqrestore(link->ap->lock, flags); in ata_eh_reset()
2884 ata_for_each_dev(dev, link, ALL) { in ata_eh_reset()
2906 ata_link_warn(link, in ata_eh_reset()
2909 failed_link = link; in ata_eh_reset()
2913 ata_link_warn(link, in ata_eh_reset()
2919 ata_eh_done(link, NULL, ATA_EH_RESET); in ata_eh_reset()
2924 link->lpm_policy = ATA_LPM_UNKNOWN; /* reset LPM state */ in ata_eh_reset()
2941 if (!ata_is_host_link(link) && in ata_eh_reset()
2942 sata_scr_read(link, SCR_STATUS, &sstatus)) in ata_eh_reset()
2952 if (ata_is_host_link(link)) in ata_eh_reset()
2976 if (ata_is_host_link(link)) in ata_eh_reset()
2982 sata_down_spd_limit(link, 0); in ata_eh_reset()
2995 struct ata_link *link; in ata_eh_pull_park_action() local
3027 ata_for_each_link(link, ap, EDGE) { in ata_eh_pull_park_action()
3028 ata_for_each_dev(dev, link, ALL) { in ata_eh_pull_park_action()
3029 struct ata_eh_info *ehi = &link->eh_info; in ata_eh_pull_park_action()
3031 link->eh_context.i.dev_action[dev->devno] |= in ata_eh_pull_park_action()
3033 ata_eh_clear_action(link, dev, ehi, ATA_EH_PARK); in ata_eh_pull_park_action()
3041 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_eh_park_issue_cmd()
3067 static int ata_eh_revalidate_and_attach(struct ata_link *link, in ata_eh_revalidate_and_attach() argument
3070 struct ata_port *ap = link->ap; in ata_eh_revalidate_and_attach()
3071 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_revalidate_and_attach()
3083 ata_for_each_dev(dev, link, ALL_REVERSE) { in ata_eh_revalidate_and_attach()
3098 ata_eh_about_to_do(link, dev, ATA_EH_REVALIDATE); in ata_eh_revalidate_and_attach()
3104 ata_eh_done(link, dev, ATA_EH_REVALIDATE); in ata_eh_revalidate_and_attach()
3154 if ((ehc->i.flags & ATA_EHI_DID_RESET) && ata_is_host_link(link)) { in ata_eh_revalidate_and_attach()
3163 ata_for_each_dev(dev, link, ALL) { in ata_eh_revalidate_and_attach()
3211 int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev) in ata_set_mode() argument
3213 struct ata_port *ap = link->ap; in ata_set_mode()
3218 ata_for_each_dev(dev, link, ENABLED) { in ata_set_mode()
3230 rc = ap->ops->set_mode(link, r_failed_dev); in ata_set_mode()
3232 rc = ata_do_set_mode(link, r_failed_dev); in ata_set_mode()
3235 ata_for_each_dev(dev, link, ENABLED) { in ata_set_mode()
3236 struct ata_eh_context *ehc = &link->eh_context; in ata_set_mode()
3267 u8 *sense_buffer = dev->link->ap->sector_buf; in atapi_eh_clear_ua()
3315 struct ata_link *link = dev->link; in ata_eh_maybe_retry_flush() local
3316 struct ata_port *ap = link->ap; in ata_eh_maybe_retry_flush()
3323 if (!ata_tag_valid(link->active_tag)) in ata_eh_maybe_retry_flush()
3326 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_maybe_retry_flush()
3389 static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy, in ata_eh_set_lpm() argument
3392 struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL; in ata_eh_set_lpm()
3393 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_set_lpm()
3395 enum ata_lpm_policy old_policy = link->lpm_policy; in ata_eh_set_lpm()
3396 bool no_dipm = link->ap->flags & ATA_FLAG_NO_DIPM; in ata_eh_set_lpm()
3402 if ((link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm)) in ata_eh_set_lpm()
3411 ata_for_each_dev(dev, link, ENABLED) { in ata_eh_set_lpm()
3441 rc = ap->ops->set_lpm(link, policy, hints); in ata_eh_set_lpm()
3445 rc = sata_pmp_set_lpm(link, policy, hints); in ata_eh_set_lpm()
3453 link->flags |= ATA_LFLAG_NO_LPM; in ata_eh_set_lpm()
3464 link->lpm_policy = policy; in ata_eh_set_lpm()
3469 ata_for_each_dev(dev, link, ENABLED) { in ata_eh_set_lpm()
3488 link->lpm_policy = old_policy; in ata_eh_set_lpm()
3494 ata_link_warn(link, "disabling LPM on the link\n"); in ata_eh_set_lpm()
3495 link->flags |= ATA_LFLAG_NO_LPM; in ata_eh_set_lpm()
3502 int ata_link_nr_enabled(struct ata_link *link) in ata_link_nr_enabled() argument
3507 ata_for_each_dev(dev, link, ENABLED) in ata_link_nr_enabled()
3512 static int ata_link_nr_vacant(struct ata_link *link) in ata_link_nr_vacant() argument
3517 ata_for_each_dev(dev, link, ALL) in ata_link_nr_vacant()
3523 static int ata_eh_skip_recovery(struct ata_link *link) in ata_eh_skip_recovery() argument
3525 struct ata_port *ap = link->ap; in ata_eh_skip_recovery()
3526 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_skip_recovery()
3530 if (link->flags & ATA_LFLAG_DISABLED) in ata_eh_skip_recovery()
3538 if ((ap->pflags & ATA_PFLAG_FROZEN) || ata_link_nr_enabled(link)) in ata_eh_skip_recovery()
3547 ata_for_each_dev(dev, link, ALL) { in ata_eh_skip_recovery()
3572 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_eh_schedule_probe()
3573 struct ata_link *link = ata_dev_phys_link(dev); in ata_eh_schedule_probe() local
3588 if (link->lpm_policy > ATA_LPM_MAX_POWER) { in ata_eh_schedule_probe()
3589 if (ata_is_host_link(link)) in ata_eh_schedule_probe()
3590 link->ap->ops->set_lpm(link, ATA_LPM_MAX_POWER, in ata_eh_schedule_probe()
3593 sata_pmp_set_lpm(link, ATA_LPM_MAX_POWER, in ata_eh_schedule_probe()
3614 sata_down_spd_limit(link, 1); in ata_eh_schedule_probe()
3621 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_eh_handle_dev_fail()
3696 struct ata_link *link; in ata_eh_recover() local
3704 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3705 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3709 ata_eh_about_to_do(link, NULL, ATA_EH_ENABLE_LINK); in ata_eh_recover()
3711 link->flags &= ~ATA_LFLAG_DISABLED; in ata_eh_recover()
3713 ata_eh_done(link, NULL, ATA_EH_ENABLE_LINK); in ata_eh_recover()
3716 ata_for_each_dev(dev, link, ALL) { in ata_eh_recover()
3717 if (link->flags & ATA_LFLAG_NO_RETRY) in ata_eh_recover()
3745 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3746 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3749 if (ata_eh_skip_recovery(link)) in ata_eh_recover()
3752 ata_for_each_dev(dev, link, ALL) in ata_eh_recover()
3757 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3758 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3763 rc = ata_eh_reset(link, ata_link_nr_vacant(link), in ata_eh_recover()
3766 ata_link_err(link, "reset failed, giving up\n"); in ata_eh_recover()
3781 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3782 ata_for_each_dev(dev, link, ALL) { in ata_eh_recover()
3783 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3812 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3813 ata_for_each_dev(dev, link, ALL) { in ata_eh_recover()
3814 if (!(link->eh_context.unloaded_mask & in ata_eh_recover()
3819 ata_eh_done(link, dev, ATA_EH_PARK); in ata_eh_recover()
3825 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_recover()
3826 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3828 if (sata_pmp_attached(ap) && ata_is_host_link(link)) in ata_eh_recover()
3832 rc = ata_eh_revalidate_and_attach(link, &dev); in ata_eh_recover()
3837 if (link->device->class == ATA_DEV_PMP) { in ata_eh_recover()
3844 rc = ata_set_mode(link, &dev); in ata_eh_recover()
3854 ata_for_each_dev(dev, link, ALL) { in ata_eh_recover()
3866 ata_for_each_dev(dev, link, ALL) { in ata_eh_recover()
3876 if (link->lpm_policy != ap->target_lpm_policy) { in ata_eh_recover()
3877 rc = ata_eh_set_lpm(link, ap->target_lpm_policy, &dev); in ata_eh_recover()
3906 *r_failed_link = link; in ata_eh_recover()
3985 ata_for_each_dev(dev, &ap->link, ALL) in ata_do_eh()
4007 if (hardreset == sata_std_hardreset && !sata_scr_valid(&ap->link)) in ata_std_error_handler()
4046 ata_for_each_dev(dev, &ap->link, ENABLED) { in ata_eh_handle_port_suspend()
4095 struct ata_link *link; in ata_eh_handle_port_resume() local
4118 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_handle_port_resume()
4119 ata_for_each_dev(dev, link, ALL) in ata_eh_handle_port_resume()