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()
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()
1701 static void ata_eh_analyze_serror(struct ata_link *link) in ata_eh_analyze_serror() argument
1703 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_analyze_serror()
1726 if (link->lpm_policy > ATA_LPM_MAX_POWER) in ata_eh_analyze_serror()
1728 else if (!(link->flags & ATA_LFLAG_DISABLED) || ata_is_host_link(link)) in ata_eh_analyze_serror()
1752 void ata_eh_analyze_ncq_error(struct ata_link *link) in ata_eh_analyze_ncq_error() argument
1754 struct ata_port *ap = link->ap; in ata_eh_analyze_ncq_error()
1755 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_analyze_ncq_error()
1756 struct ata_device *dev = link->device; in ata_eh_analyze_ncq_error()
1766 if (!link->sactive || !(ehc->i.err_mask & AC_ERR_DEV)) in ata_eh_analyze_ncq_error()
1784 ata_link_err(link, "failed to read log page 10h (errno=%d)\n", in ata_eh_analyze_ncq_error()
1789 if (!(link->sactive & (1 << tag))) { in ata_eh_analyze_ncq_error()
1790 ata_link_err(link, "log page 10h reported inactive tag %d\n", in ata_eh_analyze_ncq_error()
2039 struct ata_link *link = ata_dev_phys_link(dev); in ata_eh_speed_down() local
2064 if (sata_down_spd_limit(link, 0) == 0) { in ata_eh_speed_down()
2095 (link->ap->cbl != ATA_CBL_SATA || dev->class == ATA_DEV_ATAPI) && in ata_eh_speed_down()
2143 static void ata_eh_link_autopsy(struct ata_link *link) in ata_eh_link_autopsy() argument
2145 struct ata_port *ap = link->ap; in ata_eh_link_autopsy()
2146 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_link_autopsy()
2159 rc = sata_scr_read(link, SCR_ERROR, &serror); in ata_eh_link_autopsy()
2162 ata_eh_analyze_serror(link); in ata_eh_link_autopsy()
2171 ata_eh_analyze_ncq_error(link); in ata_eh_link_autopsy()
2183 ata_dev_phys_link(qc->dev) != link) in ata_eh_link_autopsy()
2235 if ((all_err_mask & AC_ERR_TIMEOUT) && !ata_is_host_link(link)) in ata_eh_link_autopsy()
2236 ap->link.eh_context.i.err_mask |= AC_ERR_TIMEOUT; in ata_eh_link_autopsy()
2240 if (!dev && ((ata_link_max_devices(link) == 1 && in ata_eh_link_autopsy()
2241 ata_dev_enabled(link->device)))) in ata_eh_link_autopsy()
2242 dev = link->device; in ata_eh_link_autopsy()
2265 struct ata_link *link; in ata_eh_autopsy() local
2267 ata_for_each_link(link, ap, EDGE) in ata_eh_autopsy()
2268 ata_eh_link_autopsy(link); in ata_eh_autopsy()
2275 struct ata_eh_context *mehc = &ap->link.eh_context; in ata_eh_autopsy()
2296 ata_eh_link_autopsy(&ap->link); in ata_eh_autopsy()
2428 static void ata_eh_link_report(struct ata_link *link) in ata_eh_link_report() argument
2430 struct ata_port *ap = link->ap; in ata_eh_link_report()
2431 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_link_report()
2447 ata_dev_phys_link(qc->dev) != link || in ata_eh_link_report()
2471 ehc->i.err_mask, link->sactive, ehc->i.serror, in ata_eh_link_report()
2476 ata_link_err(link, "exception Emask 0x%x " in ata_eh_link_report()
2478 ehc->i.err_mask, link->sactive, ehc->i.serror, in ata_eh_link_report()
2481 ata_link_err(link, "%s\n", desc); in ata_eh_link_report()
2486 ata_link_err(link, in ata_eh_link_report()
2514 ata_dev_phys_link(qc->dev) != link || !qc->err_mask) in ata_eh_link_report()
2607 struct ata_link *link; in ata_eh_report() local
2609 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_report()
2610 ata_eh_link_report(link); in ata_eh_report()
2613 static int ata_do_reset(struct ata_link *link, ata_reset_fn_t reset, in ata_do_reset() argument
2620 ata_for_each_dev(dev, link, ALL) in ata_do_reset()
2623 return reset(link, classes, deadline); in ata_do_reset()
2626 static int ata_eh_followup_srst_needed(struct ata_link *link, int rc) in ata_eh_followup_srst_needed() argument
2628 if ((link->flags & ATA_LFLAG_NO_SRST) || ata_link_offline(link)) in ata_eh_followup_srst_needed()
2632 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) in ata_eh_followup_srst_needed()
2637 int ata_eh_reset(struct ata_link *link, int classify, in ata_eh_reset() argument
2641 struct ata_port *ap = link->ap; in ata_eh_reset()
2643 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_reset()
2646 unsigned int lflags = link->flags; in ata_eh_reset()
2662 if (link->flags & ATA_LFLAG_RST_ONCE) in ata_eh_reset()
2664 if (link->flags & ATA_LFLAG_NO_HRST) in ata_eh_reset()
2666 if (link->flags & ATA_LFLAG_NO_SRST) in ata_eh_reset()
2683 ata_eh_about_to_do(link, NULL, ATA_EH_RESET); in ata_eh_reset()
2685 ata_for_each_dev(dev, link, ALL) { in ata_eh_reset()
2725 rc = prereset(link, deadline); in ata_eh_reset()
2743 ata_link_dbg(link, "port disabled--ignoring\n"); in ata_eh_reset()
2746 ata_for_each_dev(dev, link, ALL) in ata_eh_reset()
2751 ata_link_err(link, in ata_eh_reset()
2761 ata_for_each_dev(dev, link, ALL) in ata_eh_reset()
2764 ata_is_host_link(link)) in ata_eh_reset()
2775 if (ata_is_host_link(link)) in ata_eh_reset()
2782 ata_link_info(link, "%s resetting link\n", in ata_eh_reset()
2792 rc = ata_do_reset(link, reset, classes, deadline, true); in ata_eh_reset()
2794 failed_link = link; in ata_eh_reset()
2822 ata_eh_followup_srst_needed(link, rc)) { in ata_eh_reset()
2826 ata_link_err(link, in ata_eh_reset()
2828 failed_link = link; in ata_eh_reset()
2833 ata_eh_about_to_do(link, NULL, ATA_EH_RESET); in ata_eh_reset()
2834 rc = ata_do_reset(link, reset, classes, deadline, true); in ata_eh_reset()
2836 failed_link = link; in ata_eh_reset()
2842 ata_link_info(link, in ata_eh_reset()
2851 ata_for_each_dev(dev, link, ALL) { in ata_eh_reset()
2870 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0) in ata_eh_reset()
2871 link->sata_spd = (sstatus >> 4) & 0xf; in ata_eh_reset()
2876 if (ata_is_host_link(link)) in ata_eh_reset()
2887 postreset(link, classes); in ata_eh_reset()
2899 spin_lock_irqsave(link->ap->lock, flags); in ata_eh_reset()
2900 memset(&link->eh_info, 0, sizeof(link->eh_info)); in ata_eh_reset()
2902 memset(&slave->eh_info, 0, sizeof(link->eh_info)); in ata_eh_reset()
2904 spin_unlock_irqrestore(link->ap->lock, flags); in ata_eh_reset()
2918 ata_for_each_dev(dev, link, ALL) { in ata_eh_reset()
2940 ata_link_warn(link, in ata_eh_reset()
2943 failed_link = link; in ata_eh_reset()
2947 ata_link_warn(link, in ata_eh_reset()
2953 ata_eh_done(link, NULL, ATA_EH_RESET); in ata_eh_reset()
2958 link->lpm_policy = ATA_LPM_UNKNOWN; /* reset LPM state */ in ata_eh_reset()
2975 if (!ata_is_host_link(link) && in ata_eh_reset()
2976 sata_scr_read(link, SCR_STATUS, &sstatus)) in ata_eh_reset()
2986 if (ata_is_host_link(link)) in ata_eh_reset()
3010 if (ata_is_host_link(link)) in ata_eh_reset()
3016 sata_down_spd_limit(link, 0); in ata_eh_reset()
3029 struct ata_link *link; in ata_eh_pull_park_action() local
3061 ata_for_each_link(link, ap, EDGE) { in ata_eh_pull_park_action()
3062 ata_for_each_dev(dev, link, ALL) { in ata_eh_pull_park_action()
3063 struct ata_eh_info *ehi = &link->eh_info; in ata_eh_pull_park_action()
3065 link->eh_context.i.dev_action[dev->devno] |= in ata_eh_pull_park_action()
3067 ata_eh_clear_action(link, dev, ehi, ATA_EH_PARK); in ata_eh_pull_park_action()
3075 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_eh_park_issue_cmd()
3101 static int ata_eh_revalidate_and_attach(struct ata_link *link, in ata_eh_revalidate_and_attach() argument
3104 struct ata_port *ap = link->ap; in ata_eh_revalidate_and_attach()
3105 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_revalidate_and_attach()
3117 ata_for_each_dev(dev, link, ALL_REVERSE) { in ata_eh_revalidate_and_attach()
3132 ata_eh_about_to_do(link, dev, ATA_EH_REVALIDATE); in ata_eh_revalidate_and_attach()
3138 ata_eh_done(link, dev, ATA_EH_REVALIDATE); in ata_eh_revalidate_and_attach()
3188 if ((ehc->i.flags & ATA_EHI_DID_RESET) && ata_is_host_link(link)) { in ata_eh_revalidate_and_attach()
3197 ata_for_each_dev(dev, link, ALL) { in ata_eh_revalidate_and_attach()
3245 int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev) in ata_set_mode() argument
3247 struct ata_port *ap = link->ap; in ata_set_mode()
3252 ata_for_each_dev(dev, link, ENABLED) { in ata_set_mode()
3264 rc = ap->ops->set_mode(link, r_failed_dev); in ata_set_mode()
3266 rc = ata_do_set_mode(link, r_failed_dev); in ata_set_mode()
3269 ata_for_each_dev(dev, link, ENABLED) { in ata_set_mode()
3270 struct ata_eh_context *ehc = &link->eh_context; in ata_set_mode()
3301 u8 *sense_buffer = dev->link->ap->sector_buf; in atapi_eh_clear_ua()
3349 struct ata_link *link = dev->link; in ata_eh_maybe_retry_flush() local
3350 struct ata_port *ap = link->ap; in ata_eh_maybe_retry_flush()
3357 if (!ata_tag_valid(link->active_tag)) in ata_eh_maybe_retry_flush()
3360 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_maybe_retry_flush()
3423 static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy, in ata_eh_set_lpm() argument
3426 struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL; in ata_eh_set_lpm()
3427 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_set_lpm()
3429 enum ata_lpm_policy old_policy = link->lpm_policy; in ata_eh_set_lpm()
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()
3445 ata_for_each_dev(dev, link, ENABLED) { in ata_eh_set_lpm()
3475 rc = ap->ops->set_lpm(link, policy, hints); in ata_eh_set_lpm()
3479 rc = sata_pmp_set_lpm(link, policy, hints); in ata_eh_set_lpm()
3487 link->flags |= ATA_LFLAG_NO_LPM; in ata_eh_set_lpm()
3498 link->lpm_policy = policy; in ata_eh_set_lpm()
3503 ata_for_each_dev(dev, link, ENABLED) { in ata_eh_set_lpm()
3518 link->last_lpm_change = jiffies; in ata_eh_set_lpm()
3519 link->flags |= ATA_LFLAG_CHANGED; in ata_eh_set_lpm()
3525 link->lpm_policy = old_policy; in ata_eh_set_lpm()
3531 ata_link_warn(link, "disabling LPM on the link\n"); in ata_eh_set_lpm()
3532 link->flags |= ATA_LFLAG_NO_LPM; in ata_eh_set_lpm()
3539 int ata_link_nr_enabled(struct ata_link *link) in ata_link_nr_enabled() argument
3544 ata_for_each_dev(dev, link, ENABLED) in ata_link_nr_enabled()
3549 static int ata_link_nr_vacant(struct ata_link *link) in ata_link_nr_vacant() argument
3554 ata_for_each_dev(dev, link, ALL) in ata_link_nr_vacant()
3560 static int ata_eh_skip_recovery(struct ata_link *link) in ata_eh_skip_recovery() argument
3562 struct ata_port *ap = link->ap; in ata_eh_skip_recovery()
3563 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_skip_recovery()
3567 if (link->flags & ATA_LFLAG_DISABLED) in ata_eh_skip_recovery()
3575 if ((ap->pflags & ATA_PFLAG_FROZEN) || ata_link_nr_enabled(link)) in ata_eh_skip_recovery()
3584 ata_for_each_dev(dev, link, ALL) { in ata_eh_skip_recovery()
3609 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_eh_schedule_probe()
3610 struct ata_link *link = ata_dev_phys_link(dev); in ata_eh_schedule_probe() local
3625 if (link->lpm_policy > ATA_LPM_MAX_POWER) { in ata_eh_schedule_probe()
3626 if (ata_is_host_link(link)) in ata_eh_schedule_probe()
3627 link->ap->ops->set_lpm(link, ATA_LPM_MAX_POWER, in ata_eh_schedule_probe()
3630 sata_pmp_set_lpm(link, ATA_LPM_MAX_POWER, in ata_eh_schedule_probe()
3651 sata_down_spd_limit(link, 1); in ata_eh_schedule_probe()
3658 struct ata_eh_context *ehc = &dev->link->eh_context; in ata_eh_handle_dev_fail()
3733 struct ata_link *link; in ata_eh_recover() local
3741 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3742 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3746 ata_eh_about_to_do(link, NULL, ATA_EH_ENABLE_LINK); in ata_eh_recover()
3748 link->flags &= ~ATA_LFLAG_DISABLED; in ata_eh_recover()
3750 ata_eh_done(link, NULL, ATA_EH_ENABLE_LINK); in ata_eh_recover()
3753 ata_for_each_dev(dev, link, ALL) { in ata_eh_recover()
3754 if (link->flags & ATA_LFLAG_NO_RETRY) in ata_eh_recover()
3782 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3783 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3786 if (ata_eh_skip_recovery(link)) in ata_eh_recover()
3789 ata_for_each_dev(dev, link, ALL) in ata_eh_recover()
3794 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3795 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3800 rc = ata_eh_reset(link, ata_link_nr_vacant(link), in ata_eh_recover()
3803 ata_link_err(link, "reset failed, giving up\n"); in ata_eh_recover()
3818 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3819 ata_for_each_dev(dev, link, ALL) { in ata_eh_recover()
3820 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3850 ata_for_each_link(link, ap, EDGE) { in ata_eh_recover()
3851 ata_for_each_dev(dev, link, ALL) { in ata_eh_recover()
3852 if (!(link->eh_context.unloaded_mask & in ata_eh_recover()
3857 ata_eh_done(link, dev, ATA_EH_PARK); in ata_eh_recover()
3863 ata_for_each_link(link, ap, PMP_FIRST) { in ata_eh_recover()
3864 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_recover()
3866 if (sata_pmp_attached(ap) && ata_is_host_link(link)) in ata_eh_recover()
3870 rc = ata_eh_revalidate_and_attach(link, &dev); in ata_eh_recover()
3875 if (link->device->class == ATA_DEV_PMP) { in ata_eh_recover()
3882 rc = ata_set_mode(link, &dev); in ata_eh_recover()
3892 ata_for_each_dev(dev, link, ALL) { in ata_eh_recover()
3904 ata_for_each_dev(dev, link, ALL) { 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()
3945 *r_failed_link = link; in ata_eh_recover()
4024 ata_for_each_dev(dev, &ap->link, ALL) in ata_do_eh()
4046 if (hardreset == sata_std_hardreset && !sata_scr_valid(&ap->link)) in ata_std_error_handler()
4085 ata_for_each_dev(dev, &ap->link, ENABLED) { in ata_eh_handle_port_suspend()
4129 struct ata_link *link; in ata_eh_handle_port_resume() local
4152 ata_for_each_link(link, ap, HOST_FIRST) in ata_eh_handle_port_resume()
4153 ata_for_each_dev(dev, link, ALL) in ata_eh_handle_port_resume()