Lines Matching defs:link

260 	if (ap->link.eh_info.desc_len)
261 __ata_ehi_push_desc(&ap->link.eh_info, " ");
264 __ata_ehi_pushv_desc(&ap->link.eh_info, fmt, args);
339 struct ata_eh_context *ehc = &dev->link->eh_context;
364 struct ata_eh_context *ehc = &dev->link->eh_context;
435 struct ata_eh_context *ehc = &dev->link->eh_context;
440 static void ata_eh_clear_action(struct ata_link *link, struct ata_device *dev,
447 ata_for_each_dev(tdev, link, ALL)
455 ata_for_each_dev(tdev, link, ALL)
537 qc = ata_qc_from_tag(ap, ap->link.active_tag);
553 struct ata_link *link;
560 ata_for_each_link(link, ap, PMP_FIRST) {
561 sata_scr_write(link, SCR_CONTROL, link->saved_scontrol & 0xff0);
562 ata_for_each_dev(dev, link, ALL)
724 struct ata_link *link;
738 ata_for_each_link(link, ap, HOST_FIRST) {
739 struct ata_eh_context *ehc = &link->eh_context;
742 memset(&link->eh_context, 0, sizeof(link->eh_context));
743 link->eh_context.i = link->eh_info;
744 memset(&link->eh_info, 0, sizeof(link->eh_info));
746 ata_for_each_dev(dev, link, ENABLED) {
793 ata_for_each_link(link, ap, HOST_FIRST)
794 memset(&link->eh_info, 0, sizeof(link->eh_info));
806 WARN_ON(ata_qc_from_tag(ap, ap->link.active_tag) == NULL);
1011 static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link)
1023 if (qc && (!link || qc->dev->link == link)) {
1037 * ata_link_abort - abort all qc's on the link
1038 * @link: ATA link to abort qc's for
1040 * Abort all active qc's active on @link and schedule EH.
1048 int ata_link_abort(struct ata_link *link)
1050 return ata_do_link_abort(link->ap, link);
1147 rc = sata_scr_read(&ap->link, SCR_NOTIFICATION, &sntf);
1149 sata_scr_write(&ap->link, SCR_NOTIFICATION, sntf);
1158 struct ata_device *dev = ap->link.device;
1175 struct ata_link *link;
1178 ata_for_each_link(link, ap, EDGE) {
1179 if (!(sntf & (1 << link->pmp)))
1182 if ((link->device->class == ATA_DEV_ATAPI) &&
1183 (link->device->flags & ATA_DFLAG_AN))
1184 ata_scsi_media_change_notify(link->device);
1315 if (ata_msg_drv(dev->link->ap))
1338 struct ata_link *link = dev->link;
1339 struct ata_port *ap = link->ap;
1340 struct ata_eh_context *ehc = &link->eh_context;
1355 ata_eh_clear_action(link, dev, &link->eh_info, ATA_EH_PERDEV_MASK);
1356 ata_eh_clear_action(link, dev, &link->eh_context.i, ATA_EH_PERDEV_MASK);
1365 * @link: target ATA link
1370 * in @link->eh_info such that eh actions are not unnecessarily
1376 void ata_eh_about_to_do(struct ata_link *link, struct ata_device *dev,
1379 struct ata_port *ap = link->ap;
1380 struct ata_eh_info *ehi = &link->eh_info;
1381 struct ata_eh_context *ehc = &link->eh_context;
1386 ata_eh_clear_action(link, dev, ehi, action);
1391 if (!(ehc->i.flags & ATA_EHI_QUIET) && link != ap->slave_link)
1404 * in @link->eh_context.
1409 void ata_eh_done(struct ata_link *link, struct ata_device *dev,
1412 struct ata_eh_context *ehc = &link->eh_context;
1414 ata_eh_clear_action(link, dev, &ehc->i, action);
1508 u8 *buf = dev->link->ap->sector_buf;
1595 struct ata_port *ap = dev->link->ap;
1631 * @link: ATA link to analyze SError for
1639 static void ata_eh_analyze_serror(struct ata_link *link)
1641 struct ata_eh_context *ehc = &link->eh_context;
1662 * considered as X bit is left at 1 for link plugging.
1664 if (link->lpm_policy > ATA_LPM_MAX_POWER)
1666 else if (!(link->flags & ATA_LFLAG_DISABLED) || ata_is_host_link(link))
1680 * @link: ATA link to analyze NCQ error for
1690 void ata_eh_analyze_ncq_error(struct ata_link *link)
1692 struct ata_port *ap = link->ap;
1693 struct ata_eh_context *ehc = &link->eh_context;
1694 struct ata_device *dev = link->device;
1704 if (!link->sactive || !(ehc->i.err_mask & AC_ERR_DEV))
1722 ata_link_err(link, "failed to read log page 10h (errno=%d)\n",
1727 if (!(link->sactive & (1 << tag))) {
1728 ata_link_err(link, "log page 10h reported inactive tag %d\n",
1976 struct ata_link *link = ata_dev_phys_link(dev);
2000 /* speed down SATA link speed if possible */
2001 if (sata_down_spd_limit(link, 0) == 0) {
2032 (link->ap->cbl != ATA_CBL_SATA || dev->class == ATA_DEV_ATAPI) &&
2051 * @link: host link to perform autopsy on
2053 * Analyze why @link failed and determine which recovery actions
2060 static void ata_eh_link_autopsy(struct ata_link *link)
2062 struct ata_port *ap = link->ap;
2063 struct ata_eh_context *ehc = &link->eh_context;
2076 rc = sata_scr_read(link, SCR_ERROR, &serror);
2079 ata_eh_analyze_serror(link);
2088 ata_eh_analyze_ncq_error(link);
2100 ata_dev_phys_link(qc->dev) != link)
2152 /* propagate timeout to host link */
2153 if ((all_err_mask & AC_ERR_TIMEOUT) && !ata_is_host_link(link))
2154 ap->link.eh_context.i.err_mask |= AC_ERR_TIMEOUT;
2158 if (!dev && ((ata_link_max_devices(link) == 1 &&
2159 ata_dev_enabled(link->device))))
2160 dev = link->device;
2183 struct ata_link *link;
2185 ata_for_each_link(link, ap, EDGE)
2186 ata_eh_link_autopsy(link);
2188 /* Handle the frigging slave link. Autopsy is done similarly
2190 * link and handled from there.
2193 struct ata_eh_context *mehc = &ap->link.eh_context;
2199 /* perform autopsy on the slave link */
2210 /* Autopsy of fanout ports can affect host link autopsy.
2211 * Perform host link autopsy last.
2214 ata_eh_link_autopsy(&ap->link);
2330 * @link: ATA link EH is going on
2337 static void ata_eh_link_report(struct ata_link *link)
2339 struct ata_port *ap = link->ap;
2340 struct ata_eh_context *ehc = &link->eh_context;
2356 ata_dev_phys_link(qc->dev) != link ||
2381 ehc->i.err_mask, link->sactive, ehc->i.serror,
2386 ata_link_err(link, "exception Emask 0x%x "
2388 ehc->i.err_mask, link->sactive, ehc->i.serror,
2391 ata_link_err(link, "%s\n", desc);
2396 ata_link_err(link,
2425 ata_dev_phys_link(qc->dev) != link || !qc->err_mask)
2518 struct ata_link *link;
2520 ata_for_each_link(link, ap, HOST_FIRST)
2521 ata_eh_link_report(link);
2524 static int ata_do_reset(struct ata_link *link, ata_reset_fn_t reset,
2531 ata_for_each_dev(dev, link, ALL)
2534 return reset(link, classes, deadline);
2537 static int ata_eh_followup_srst_needed(struct ata_link *link, int rc)
2539 if ((link->flags & ATA_LFLAG_NO_SRST) || ata_link_offline(link))
2543 if (sata_pmp_supported(link->ap) && ata_is_host_link(link))
2548 int ata_eh_reset(struct ata_link *link, int classify,
2552 struct ata_port *ap = link->ap;
2554 struct ata_eh_context *ehc = &link->eh_context;
2557 unsigned int lflags = link->flags;
2573 if (link->flags & ATA_LFLAG_NO_HRST)
2575 if (link->flags & ATA_LFLAG_NO_SRST)
2592 ata_eh_about_to_do(link, NULL, ATA_EH_RESET);
2594 ata_for_each_dev(dev, link, ALL) {
2633 rc = prereset(link, deadline);
2635 /* If present, do prereset on slave link too. Reset
2651 ata_link_dbg(link, "port disabled--ignoring\n");
2654 ata_for_each_dev(dev, link, ALL)
2659 ata_link_err(link,
2669 ata_for_each_dev(dev, link, ALL)
2672 ata_is_host_link(link))
2683 if (ata_is_host_link(link))
2690 ata_link_info(link, "%s resetting link\n",
2700 rc = ata_do_reset(link, reset, classes, deadline, true);
2702 failed_link = link;
2706 /* hardreset slave link if existent */
2711 ata_link_info(slave, "hard resetting link\n");
2730 ata_eh_followup_srst_needed(link, rc)) {
2734 ata_link_err(link,
2736 failed_link = link;
2741 ata_eh_about_to_do(link, NULL, ATA_EH_RESET);
2742 rc = ata_do_reset(link, reset, classes, deadline, true);
2744 failed_link = link;
2750 ata_link_info(link,
2759 ata_for_each_dev(dev, link, ALL) {
2777 /* record current link speed */
2778 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0)
2779 link->sata_spd = (sstatus >> 4) & 0xf;
2784 if (ata_is_host_link(link))
2788 * is cleared during link resume, clearing SError here is
2792 * link onlineness and classification result later.
2795 postreset(link, classes);
2804 * final recovery action and we cross check link onlineness against
2807 spin_lock_irqsave(link->ap->lock, flags);
2808 memset(&link->eh_info, 0, sizeof(link->eh_info));
2810 memset(&slave->eh_info, 0, sizeof(link->eh_info));
2812 spin_unlock_irqrestore(link->ap->lock, flags);
2822 * link on/offlineness and classification result, those
2826 ata_for_each_dev(dev, link, ALL) {
2829 ata_dev_dbg(dev, "link online but device misclassified\n");
2836 "link offline, clearing class %d to NONE\n",
2841 "link status unknown, clearing UNKNOWN to NONE\n");
2848 ata_link_warn(link,
2849 "link online but %d devices misclassified, retrying\n",
2851 failed_link = link;
2855 ata_link_warn(link,
2856 "link online but %d devices misclassified, "
2861 ata_eh_done(link, NULL, ATA_EH_RESET);
2866 link->lpm_policy = ATA_LPM_UNKNOWN; /* reset LPM state */
2883 if (!ata_is_host_link(link) &&
2884 sata_scr_read(link, SCR_STATUS, &sstatus))
2894 if (ata_is_host_link(link))
2918 if (ata_is_host_link(link))
2924 sata_down_spd_limit(link, 0);
2937 struct ata_link *link;
2969 ata_for_each_link(link, ap, EDGE) {
2970 ata_for_each_dev(dev, link, ALL) {
2971 struct ata_eh_info *ehi = &link->eh_info;
2973 link->eh_context.i.dev_action[dev->devno] |=
2975 ata_eh_clear_action(link, dev, ehi, ATA_EH_PARK);
2983 struct ata_eh_context *ehc = &dev->link->eh_context;
3009 static int ata_eh_revalidate_and_attach(struct ata_link *link,
3012 struct ata_port *ap = link->ap;
3013 struct ata_eh_context *ehc = &link->eh_context;
3025 ata_for_each_dev(dev, link, ALL_REVERSE) {
3040 ata_eh_about_to_do(link, dev, ATA_EH_REVALIDATE);
3046 ata_eh_done(link, dev, ATA_EH_REVALIDATE);
3096 if ((ehc->i.flags & ATA_EHI_DID_RESET) && ata_is_host_link(link)) {
3105 ata_for_each_dev(dev, link, ALL) {
3140 * @link: link on which timings will be programmed
3153 int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)
3155 struct ata_port *ap = link->ap;
3160 ata_for_each_dev(dev, link, ENABLED) {
3172 rc = ap->ops->set_mode(link, r_failed_dev);
3174 rc = ata_do_set_mode(link, r_failed_dev);
3177 ata_for_each_dev(dev, link, ENABLED) {
3178 struct ata_eh_context *ehc = &link->eh_context;
3209 u8 *sense_buffer = dev->link->ap->sector_buf;
3257 struct ata_link *link = dev->link;
3258 struct ata_port *ap = link->ap;
3265 if (!ata_tag_valid(link->active_tag))
3268 qc = __ata_qc_from_tag(ap, link->active_tag);
3316 * @link: link to configure power management
3317 * @policy: the link power management policy
3331 static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
3334 struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL;
3335 struct ata_eh_context *ehc = &link->eh_context;
3337 enum ata_lpm_policy old_policy = link->lpm_policy;
3338 bool no_dipm = link->ap->flags & ATA_FLAG_NO_DIPM;
3343 /* if the link or host doesn't do LPM, noop */
3344 if ((link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm))
3350 * device and link configurations such that the host always
3353 ata_for_each_dev(dev, link, ENABLED) {
3368 /* disable DIPM before changing link config */
3383 rc = ap->ops->set_lpm(link, policy, hints);
3387 rc = sata_pmp_set_lpm(link, policy, hints);
3390 * Attribute link config failure to the first (LPM) enabled
3391 * device on the link.
3395 link->flags |= ATA_LFLAG_NO_LPM;
3406 link->lpm_policy = policy;
3411 ata_for_each_dev(dev, link, ENABLED) {
3430 link->lpm_policy = old_policy;
3436 ata_link_warn(link, "disabling LPM on the link\n");
3437 link->flags |= ATA_LFLAG_NO_LPM;
3444 int ata_link_nr_enabled(struct ata_link *link)
3449 ata_for_each_dev(dev, link, ENABLED)
3454 static int ata_link_nr_vacant(struct ata_link *link)
3459 ata_for_each_dev(dev, link, ALL)
3465 static int ata_eh_skip_recovery(struct ata_link *link)
3467 struct ata_port *ap = link->ap;
3468 struct ata_eh_context *ehc = &link->eh_context;
3472 if (link->flags & ATA_LFLAG_DISABLED)
3480 if ((ap->pflags & ATA_PFLAG_FROZEN) || ata_link_nr_enabled(link))
3489 ata_for_each_dev(dev, link, ALL) {
3514 struct ata_eh_context *ehc = &dev->link->eh_context;
3515 struct ata_link *link = ata_dev_phys_link(dev);
3529 /* the link maybe in a deep sleep, wake it up */
3530 if (link->lpm_policy > ATA_LPM_MAX_POWER) {
3531 if (ata_is_host_link(link))
3532 link->ap->ops->set_lpm(link, ATA_LPM_MAX_POWER,
3535 sata_pmp_set_lpm(link, ATA_LPM_MAX_POWER,
3545 * in the last ATA_EH_PROBE_TRIAL_INTERVAL, link speed is
3548 * This is to work around cases where failed link speed
3556 sata_down_spd_limit(link, 1);
3563 struct ata_eh_context *ehc = &dev->link->eh_context;
3618 * @r_failed_link: out parameter for failed link
3622 * recover each link and hotplug requests are recorded in the
3623 * link's eh_context. This function executes all the operations
3638 struct ata_link *link;
3646 ata_for_each_link(link, ap, EDGE) {
3647 struct ata_eh_context *ehc = &link->eh_context;
3649 /* re-enable link? */
3651 ata_eh_about_to_do(link, NULL, ATA_EH_ENABLE_LINK);
3653 link->flags &= ~ATA_LFLAG_DISABLED;
3655 ata_eh_done(link, NULL, ATA_EH_ENABLE_LINK);
3658 ata_for_each_dev(dev, link, ALL) {
3659 if (link->flags & ATA_LFLAG_NO_RETRY)
3687 ata_for_each_link(link, ap, EDGE) {
3688 struct ata_eh_context *ehc = &link->eh_context;
3691 if (ata_eh_skip_recovery(link))
3694 ata_for_each_dev(dev, link, ALL)
3699 ata_for_each_link(link, ap, EDGE) {
3700 struct ata_eh_context *ehc = &link->eh_context;
3705 rc = ata_eh_reset(link, ata_link_nr_vacant(link),
3708 ata_link_err(link, "reset failed, giving up\n");
3723 ata_for_each_link(link, ap, EDGE) {
3724 ata_for_each_dev(dev, link, ALL) {
3725 struct ata_eh_context *ehc = &link->eh_context;
3754 ata_for_each_link(link, ap, EDGE) {
3755 ata_for_each_dev(dev, link, ALL) {
3756 if (!(link->eh_context.unloaded_mask &
3761 ata_eh_done(link, dev, ATA_EH_PARK);
3767 ata_for_each_link(link, ap, PMP_FIRST) {
3768 struct ata_eh_context *ehc = &link->eh_context;
3770 if (sata_pmp_attached(ap) && ata_is_host_link(link))
3774 rc = ata_eh_revalidate_and_attach(link, &dev);
3779 if (link->device->class == ATA_DEV_PMP) {
3786 rc = ata_set_mode(link, &dev);
3796 ata_for_each_dev(dev, link, ALL) {
3806 ata_for_each_dev(dev, link, ALL) {
3815 /* configure link power saving */
3816 if (link->lpm_policy != ap->target_lpm_policy) {
3817 rc = ata_eh_set_lpm(link, ap->target_lpm_policy, &dev);
3822 /* this link is okay now */
3846 *r_failed_link = link;
3925 ata_for_each_dev(dev, &ap->link, ALL)
3947 if (hardreset == sata_std_hardreset && !sata_scr_valid(&ap->link))
4022 struct ata_link *link;
4045 ata_for_each_link(link, ap, HOST_FIRST)
4046 ata_for_each_dev(dev, link, ALL)