Lines Matching +full:tf +full:- +full:a
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright 2003-2004 Red Hat, Inc. All rights reserved.
6 * Copyright 2003-2004 Jeff Garzik
19 #include "libata-transport.h"
30 * sata_scr_valid - test whether SCRs are accessible
43 struct ata_port *ap = link->ap; in sata_scr_valid()
45 return (ap->flags & ATA_FLAG_SATA) && ap->ops->scr_read; in sata_scr_valid()
50 * sata_scr_read - read SCR register of the specified port
56 * guaranteed to succeed if @link is ap->link, the cable type of
57 * the port is SATA and the port implements ->scr_read.
60 * None if @link is ap->link. Kernel thread context otherwise.
69 return link->ap->ops->scr_read(link, reg, val); in sata_scr_read()
70 return -EOPNOTSUPP; in sata_scr_read()
78 * sata_scr_write - write SCR register of the specified port
84 * guaranteed to succeed if @link is ap->link, the cable type of
85 * the port is SATA and the port implements ->scr_read.
88 * None if @link is ap->link. Kernel thread context otherwise.
97 return link->ap->ops->scr_write(link, reg, val); in sata_scr_write()
98 return -EOPNOTSUPP; in sata_scr_write()
106 * sata_scr_write_flush - write SCR register of the specified port and flush
115 * None if @link is ap->link. Kernel thread context otherwise.
126 rc = link->ap->ops->scr_write(link, reg, val); in sata_scr_write_flush()
128 rc = link->ap->ops->scr_read(link, reg, &val); in sata_scr_write_flush()
131 return -EOPNOTSUPP; in sata_scr_write_flush()
139 * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure
140 * @tf: Taskfile to convert
145 * Converts a standard ATA taskfile to a Serial ATA
146 * FIS structure (Register - Host to Device).
151 void ata_tf_to_fis(const struct ata_taskfile *tf, u8 pmp, int is_cmd, u8 *fis) in ata_tf_to_fis() argument
153 fis[0] = 0x27; /* Register - Host to Device FIS */ in ata_tf_to_fis()
158 fis[2] = tf->command; in ata_tf_to_fis()
159 fis[3] = tf->feature; in ata_tf_to_fis()
161 fis[4] = tf->lbal; in ata_tf_to_fis()
162 fis[5] = tf->lbam; in ata_tf_to_fis()
163 fis[6] = tf->lbah; in ata_tf_to_fis()
164 fis[7] = tf->device; in ata_tf_to_fis()
166 fis[8] = tf->hob_lbal; in ata_tf_to_fis()
167 fis[9] = tf->hob_lbam; in ata_tf_to_fis()
168 fis[10] = tf->hob_lbah; in ata_tf_to_fis()
169 fis[11] = tf->hob_feature; in ata_tf_to_fis()
171 fis[12] = tf->nsect; in ata_tf_to_fis()
172 fis[13] = tf->hob_nsect; in ata_tf_to_fis()
174 fis[15] = tf->ctl; in ata_tf_to_fis()
176 fis[16] = tf->auxiliary & 0xff; in ata_tf_to_fis()
177 fis[17] = (tf->auxiliary >> 8) & 0xff; in ata_tf_to_fis()
178 fis[18] = (tf->auxiliary >> 16) & 0xff; in ata_tf_to_fis()
179 fis[19] = (tf->auxiliary >> 24) & 0xff; in ata_tf_to_fis()
184 * ata_tf_from_fis - Convert SATA FIS to ATA taskfile
186 * @tf: Taskfile to output
188 * Converts a serial ATA FIS structure to a standard ATA taskfile.
194 void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf) in ata_tf_from_fis() argument
196 tf->status = fis[2]; in ata_tf_from_fis()
197 tf->error = fis[3]; in ata_tf_from_fis()
199 tf->lbal = fis[4]; in ata_tf_from_fis()
200 tf->lbam = fis[5]; in ata_tf_from_fis()
201 tf->lbah = fis[6]; in ata_tf_from_fis()
202 tf->device = fis[7]; in ata_tf_from_fis()
204 tf->hob_lbal = fis[8]; in ata_tf_from_fis()
205 tf->hob_lbam = fis[9]; in ata_tf_from_fis()
206 tf->hob_lbah = fis[10]; in ata_tf_from_fis()
208 tf->nsect = fis[12]; in ata_tf_from_fis()
209 tf->hob_nsect = fis[13]; in ata_tf_from_fis()
214 * sata_link_debounce - debounce SATA phy status
233 * 0 on success, -errno on failure.
256 ata_msleep(link->ap, interval); in sata_link_debounce()
276 * -EPIPE to tell upper layer to lower link speed. in sata_link_debounce()
279 return -EPIPE; in sata_link_debounce()
285 * sata_link_resume - resume SATA link
296 * 0 on success, -errno on failure.
322 if (!(link->flags & ATA_LFLAG_NO_DEBOUNCE_DELAY)) in sata_link_resume()
323 ata_msleep(link->ap, 200); in sata_link_resume()
328 } while ((scontrol & 0xf0f) != 0x300 && --tries); in sata_link_resume()
338 ATA_LINK_RESUME_TRIES - tries); in sata_link_resume()
347 return rc != -EINVAL ? rc : 0; in sata_link_resume()
352 * sata_link_scr_lpm - manipulate SControl IPM and SPM fields
367 * 0 on success, -errno otherwise.
372 struct ata_eh_context *ehc = &link->eh_context; in sata_link_scr_lpm()
407 if (link->ap->host->flags & ATA_HOST_NO_PART) in sata_link_scr_lpm()
410 if (link->ap->host->flags & ATA_HOST_NO_SSC) in sata_link_scr_lpm()
413 if (link->ap->host->flags & ATA_HOST_NO_DEVSLP) in sata_link_scr_lpm()
434 ehc->i.serror &= ~SERR_PHYRDY_CHG; in sata_link_scr_lpm()
441 struct ata_link *host_link = &link->ap->link; in __sata_set_spd_needed()
444 limit = link->sata_spd_limit; in __sata_set_spd_needed()
450 if (!ata_is_host_link(link) && host_link->sata_spd) in __sata_set_spd_needed()
451 limit &= (1 << host_link->sata_spd) - 1; in __sata_set_spd_needed()
465 * sata_set_spd_needed - is SATA spd configuration needed
469 * @link->sata_spd_limit. This function is used to determine
490 * sata_set_spd - set SATA spd according to spd limit
521 * sata_down_spd_limit - adjust SATA spd limit downward
529 * If @spd_limit is non-zero, the speed is limited to equal to or
546 return -EOPNOTSUPP; in sata_down_spd_limit()
549 * If not, use cached value in link->sata_spd. in sata_down_spd_limit()
555 spd = link->sata_spd; in sata_down_spd_limit()
557 mask = link->sata_spd_limit; in sata_down_spd_limit()
559 return -EINVAL; in sata_down_spd_limit()
562 bit = fls(mask) - 1; in sata_down_spd_limit()
570 * Otherwise, we should not force 1.5Gbps on a link where we have in sata_down_spd_limit()
575 mask &= (1 << (spd - 1)) - 1; in sata_down_spd_limit()
576 else if (link->sata_spd) in sata_down_spd_limit()
577 return -EINVAL; in sata_down_spd_limit()
581 return -EINVAL; in sata_down_spd_limit()
584 if (mask & ((1 << spd_limit) - 1)) in sata_down_spd_limit()
585 mask &= (1 << spd_limit) - 1; in sata_down_spd_limit()
587 bit = ffs(mask) - 1; in sata_down_spd_limit()
592 link->sata_spd_limit = mask; in sata_down_spd_limit()
601 * sata_link_hardreset - reset link via SATA phy reset
608 * SATA phy-reset @link using DET bits of SControl register.
622 * 0 on success, -errno otherwise.
660 /* Couldn't find anything in SATA I/II specs, but AHCI-1.1 in sata_link_hardreset()
663 ata_msleep(link->ap, 1); in sata_link_hardreset()
673 /* Link is online. From this point, -ENODEV too is an error. */ in sata_link_hardreset()
677 if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) { in sata_link_hardreset()
678 /* If PMP is supported, we have to do follow-up SRST. in sata_link_hardreset()
692 rc = -EAGAIN; in sata_link_hardreset()
700 if (rc && rc != -EAGAIN) { in sata_link_hardreset()
710 * sata_std_hardreset - COMRESET w/o waiting or classification
721 * 0 if link offline, -EAGAIN if link online, -errno on errors.
726 const unsigned int *timing = sata_ehc_deb_timing(&link->eh_context); in sata_std_hardreset()
732 return -EAGAIN; in sata_std_hardreset()
738 * ata_qc_complete_multiple - Complete multiple qcs successfully
742 * Complete in-flight commands. This functions is meant to be
743 * called from low-level driver's interrupt routine to complete
744 * requests normally. ap->qc_active and @qc_active is compared
755 * Number of completed commands on success, -errno otherwise.
759 u64 done_mask, ap_qc_active = ap->qc_active; in ata_qc_complete_multiple()
763 * If the internal tag is set on ap->qc_active, then we care about in ata_qc_complete_multiple()
775 ata_port_err(ap, "illegal qc_active transition (%08llx->%08llx)\n", in ata_qc_complete_multiple()
776 ap->qc_active, qc_active); in ata_qc_complete_multiple()
777 return -EINVAL; in ata_qc_complete_multiple()
780 if (ap->ops->qc_ncq_fill_rtf) in ata_qc_complete_multiple()
781 ap->ops->qc_ncq_fill_rtf(ap, done_mask); in ata_qc_complete_multiple()
800 * ata_slave_link_init - initialize slave link
806 * In libata, a port contains links and a link contains devices.
807 * There is single host link but if a PMP is attached to it,
808 * there can be multiple fan-out links. On SATA, there's usually
809 * a single device connected to a link but PATA and SATA
810 * controllers emulating TF based interface can have two - master
813 * However, there are a few controllers which don't fit into this
814 * abstraction too well - SATA controllers which emulate TF
818 * (e.g. onlineness, link speed) but should be treated like a
826 * handling, separate @ap->slave_link is used. All dirty details
832 * prereset(M) -> prereset(S) -> hardreset(M) -> hardreset(S) ->
833 * softreset(M) -> postreset(M) -> postreset(S)
843 * 0 on success, -errno on failure.
849 WARN_ON(ap->slave_link); in ata_slave_link_init()
850 WARN_ON(ap->flags & ATA_FLAG_PMP); in ata_slave_link_init()
854 return -ENOMEM; in ata_slave_link_init()
857 ap->slave_link = link; in ata_slave_link_init()
863 * sata_lpm_ignore_phy_events - test if PHY event should be ignored
876 unsigned long lpm_timeout = link->last_lpm_change + in sata_lpm_ignore_phy_events()
880 if (link->lpm_policy > ATA_LPM_MAX_POWER) in sata_lpm_ignore_phy_events()
886 if ((link->flags & ATA_LFLAG_CHANGED) && in sata_lpm_ignore_phy_events()
904 * Check if a port supports link power management.
912 if (ap->flags & ATA_FLAG_NO_LPM) in ata_scsi_lpm_supported()
916 ata_for_each_dev(dev, &ap->link, ENABLED) { in ata_scsi_lpm_supported()
917 if (dev->quirks & ATA_QUIRK_NOLPM) in ata_scsi_lpm_supported()
933 spin_lock_irqsave(ap->lock, flags); in ata_scsi_lpm_supported_show()
935 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_lpm_supported_show()
961 return -EINVAL; in ata_scsi_lpm_store()
963 spin_lock_irqsave(ap->lock, flags); in ata_scsi_lpm_store()
966 count = -EOPNOTSUPP; in ata_scsi_lpm_store()
970 ap->target_lpm_policy = policy; in ata_scsi_lpm_store()
973 spin_unlock_irqrestore(ap->lock, flags); in ata_scsi_lpm_store()
983 if (ap->target_lpm_policy >= ARRAY_SIZE(ata_lpm_policy_names)) in ata_scsi_lpm_show()
984 return -EINVAL; in ata_scsi_lpm_show()
987 ata_lpm_policy_names[ap->target_lpm_policy]); in ata_scsi_lpm_show()
994 * ata_ncq_prio_supported - Check if device supports NCQ Priority
997 * @supported: Address of a boolean to store the result
1001 * Context: Any context. Takes and releases @ap->lock.
1004 * * %0 - OK. Status is stored into @supported
1005 * * %-ENODEV - Failed to find the ATA device
1014 spin_lock_irqsave(ap->lock, flags); in ata_ncq_prio_supported()
1017 rc = -ENODEV; in ata_ncq_prio_supported()
1019 *supported = dev->flags & ATA_DFLAG_NCQ_PRIO; in ata_ncq_prio_supported()
1020 spin_unlock_irqrestore(ap->lock, flags); in ata_ncq_prio_supported()
1031 struct ata_port *ap = ata_shost_to_port(sdev->host); in ata_ncq_prio_supported_show()
1046 * ata_ncq_prio_enabled - Check if NCQ Priority is enabled
1049 * @enabled: Address of a boolean to store the result
1053 * Context: Any context. Takes and releases @ap->lock.
1056 * * %0 - OK. Status is stored into @enabled
1057 * * %-ENODEV - Failed to find the ATA device
1066 spin_lock_irqsave(ap->lock, flags); in ata_ncq_prio_enabled()
1069 rc = -ENODEV; in ata_ncq_prio_enabled()
1071 *enabled = dev->flags & ATA_DFLAG_NCQ_PRIO_ENABLED; in ata_ncq_prio_enabled()
1072 spin_unlock_irqrestore(ap->lock, flags); in ata_ncq_prio_enabled()
1083 struct ata_port *ap = ata_shost_to_port(sdev->host); in ata_ncq_prio_enable_show()
1095 * ata_ncq_prio_enable - Enable/disable NCQ Priority
1098 * @enable: true - enable NCQ Priority, false - disable NCQ Priority
1102 * Context: Any context. Takes and releases @ap->lock.
1105 * * %0 - OK. Status is stored into @enabled
1106 * * %-ENODEV - Failed to find the ATA device
1107 * * %-EINVAL - NCQ Priority is not supported or CDL is enabled
1116 spin_lock_irqsave(ap->lock, flags); in ata_ncq_prio_enable()
1120 rc = -ENODEV; in ata_ncq_prio_enable()
1124 if (!(dev->flags & ATA_DFLAG_NCQ_PRIO)) { in ata_ncq_prio_enable()
1125 rc = -EINVAL; in ata_ncq_prio_enable()
1130 if (dev->flags & ATA_DFLAG_CDL_ENABLED) { in ata_ncq_prio_enable()
1133 rc = -EINVAL; in ata_ncq_prio_enable()
1136 dev->flags |= ATA_DFLAG_NCQ_PRIO_ENABLED; in ata_ncq_prio_enable()
1138 dev->flags &= ~ATA_DFLAG_NCQ_PRIO_ENABLED; in ata_ncq_prio_enable()
1142 spin_unlock_irqrestore(ap->lock, flags); in ata_ncq_prio_enable()
1153 struct ata_port *ap = ata_shost_to_port(sdev->host); in ata_ncq_prio_enable_store()
1195 if (ap->ops->em_store && (ap->flags & ATA_FLAG_EM)) in ata_scsi_em_message_store()
1196 return ap->ops->em_store(ap, buf, count); in ata_scsi_em_message_store()
1197 return -EINVAL; in ata_scsi_em_message_store()
1207 if (ap->ops->em_show && (ap->flags & ATA_FLAG_EM)) in ata_scsi_em_message_show()
1208 return ap->ops->em_show(ap, buf); in ata_scsi_em_message_show()
1209 return -EINVAL; in ata_scsi_em_message_show()
1222 return sysfs_emit(buf, "%d\n", ap->em_message_type); in ata_scsi_em_message_type_show()
1233 struct ata_port *ap = ata_shost_to_port(sdev->host); in ata_scsi_activity_show()
1236 if (atadev && ap->ops->sw_activity_show && in ata_scsi_activity_show()
1237 (ap->flags & ATA_FLAG_SW_ACTIVITY)) in ata_scsi_activity_show()
1238 return ap->ops->sw_activity_show(atadev, buf); in ata_scsi_activity_show()
1239 return -EINVAL; in ata_scsi_activity_show()
1247 struct ata_port *ap = ata_shost_to_port(sdev->host); in ata_scsi_activity_store()
1252 if (atadev && ap->ops->sw_activity_store && in ata_scsi_activity_store()
1253 (ap->flags & ATA_FLAG_SW_ACTIVITY)) { in ata_scsi_activity_store()
1257 rc = ap->ops->sw_activity_store(atadev, val); in ata_scsi_activity_store()
1264 return -EINVAL; in ata_scsi_activity_store()
1271 * ata_change_queue_depth - Set a device maximum queue depth
1276 * Helper to set a device maximum queue depth, usable with both libsas
1287 spin_lock_irqsave(ap->lock, flags); in ata_change_queue_depth()
1290 if (!dev || queue_depth < 1 || queue_depth == sdev->queue_depth) { in ata_change_queue_depth()
1291 spin_unlock_irqrestore(ap->lock, flags); in ata_change_queue_depth()
1292 return sdev->queue_depth; in ata_change_queue_depth()
1299 max_queue_depth = min(ATA_MAX_QUEUE, sdev->host->can_queue); in ata_change_queue_depth()
1300 max_queue_depth = min(max_queue_depth, ata_id_queue_depth(dev->id)); in ata_change_queue_depth()
1302 spin_unlock_irqrestore(ap->lock, flags); in ata_change_queue_depth()
1303 return -EINVAL; in ata_change_queue_depth()
1311 dev->flags |= ATA_DFLAG_NCQ_OFF; in ata_change_queue_depth()
1314 dev->flags &= ~ATA_DFLAG_NCQ_OFF; in ata_change_queue_depth()
1317 spin_unlock_irqrestore(ap->lock, flags); in ata_change_queue_depth()
1319 if (queue_depth == sdev->queue_depth) in ata_change_queue_depth()
1320 return sdev->queue_depth; in ata_change_queue_depth()
1327 * ata_scsi_change_queue_depth - SCSI callback for queue depth config
1331 * This is libata standard hostt->change_queue_depth callback.
1343 struct ata_port *ap = ata_shost_to_port(sdev->host); in ata_scsi_change_queue_depth()
1350 * ata_sas_sdev_configure - Default sdev_configure routine for libata
1365 return ata_scsi_dev_config(sdev, lim, ap->link.device); in ata_sas_sdev_configure()
1370 * ata_sas_queuecmd - Issue SCSI cdb to libata-managed device
1383 if (likely(ata_dev_enabled(ap->link.device))) in ata_sas_queuecmd()
1384 rc = __ata_scsi_queuecmd(cmd, ap->link.device); in ata_sas_queuecmd()
1386 cmd->result = (DID_BAD_TARGET << 16); in ata_sas_queuecmd()
1394 * sata_async_notification - SATA async notification handler
1411 if (!(ap->flags & ATA_FLAG_AN)) in sata_async_notification()
1414 rc = sata_scr_read(&ap->link, SCR_NOTIFICATION, &sntf); in sata_async_notification()
1416 sata_scr_write(&ap->link, SCR_NOTIFICATION, sntf); in sata_async_notification()
1425 struct ata_device *dev = ap->link.device; in sata_async_notification()
1427 if ((dev->class == ATA_DEV_ATAPI) && in sata_async_notification()
1428 (dev->flags & ATA_DFLAG_AN)) in sata_async_notification()
1446 if (!(sntf & (1 << link->pmp))) in sata_async_notification()
1449 if ((link->device->class == ATA_DEV_ATAPI) && in sata_async_notification()
1450 (link->device->flags & ATA_DFLAG_AN)) in sata_async_notification()
1451 ata_scsi_media_change_notify(link->device); in sata_async_notification()
1468 * ata_eh_read_log_10h - Read log page 10h for NCQ error details
1471 * @tf: Resulting taskfile registers of the failed command
1480 * 0 on success, -errno otherwise.
1483 int *tag, struct ata_taskfile *tf) in ata_eh_read_log_10h() argument
1485 u8 *buf = dev->sector_buf; in ata_eh_read_log_10h()
1492 return -EIO; in ata_eh_read_log_10h()
1502 return -ENOENT; in ata_eh_read_log_10h()
1506 tf->status = buf[2]; in ata_eh_read_log_10h()
1507 tf->error = buf[3]; in ata_eh_read_log_10h()
1508 tf->lbal = buf[4]; in ata_eh_read_log_10h()
1509 tf->lbam = buf[5]; in ata_eh_read_log_10h()
1510 tf->lbah = buf[6]; in ata_eh_read_log_10h()
1511 tf->device = buf[7]; in ata_eh_read_log_10h()
1512 tf->hob_lbal = buf[8]; in ata_eh_read_log_10h()
1513 tf->hob_lbam = buf[9]; in ata_eh_read_log_10h()
1514 tf->hob_lbah = buf[10]; in ata_eh_read_log_10h()
1515 tf->nsect = buf[12]; in ata_eh_read_log_10h()
1516 tf->hob_nsect = buf[13]; in ata_eh_read_log_10h()
1517 if (ata_id_has_ncq_autosense(dev->id) && (tf->status & ATA_SENSE)) in ata_eh_read_log_10h()
1518 tf->auxiliary = buf[14] << 16 | buf[15] << 8 | buf[16]; in ata_eh_read_log_10h()
1524 * ata_eh_get_ncq_success_sense - Read and process the sense data for
1536 * 0 on success, -errno otherwise.
1540 struct ata_device *dev = link->device; in ata_eh_get_ncq_success_sense()
1541 struct ata_port *ap = dev->link->ap; in ata_eh_get_ncq_success_sense()
1542 u8 *buf = dev->cdl->ncq_sense_log_buf; in ata_eh_get_ncq_success_sense()
1556 return -EIO; in ata_eh_get_ncq_success_sense()
1564 return -EIO; in ata_eh_get_ncq_success_sense()
1572 if (!(qc->flags & ATA_QCFLAG_EH) || in ata_eh_get_ncq_success_sense()
1573 !(qc->flags & ATA_QCFLAG_EH_SUCCESS_CMD) || in ata_eh_get_ncq_success_sense()
1574 qc->err_mask || in ata_eh_get_ncq_success_sense()
1575 ata_dev_phys_link(qc->dev) != link) in ata_eh_get_ncq_success_sense()
1583 qc->result_tf.status &= ~ATA_SENSE; in ata_eh_get_ncq_success_sense()
1593 ret = -EIO; in ata_eh_get_ncq_success_sense()
1597 qc->result_tf.nsect = sense[6]; in ata_eh_get_ncq_success_sense()
1598 qc->result_tf.hob_nsect = sense[7]; in ata_eh_get_ncq_success_sense()
1599 qc->result_tf.lbal = sense[8]; in ata_eh_get_ncq_success_sense()
1600 qc->result_tf.lbam = sense[9]; in ata_eh_get_ncq_success_sense()
1601 qc->result_tf.lbah = sense[10]; in ata_eh_get_ncq_success_sense()
1602 qc->result_tf.hob_lbal = sense[11]; in ata_eh_get_ncq_success_sense()
1603 qc->result_tf.hob_lbam = sense[12]; in ata_eh_get_ncq_success_sense()
1604 qc->result_tf.hob_lbah = sense[13]; in ata_eh_get_ncq_success_sense()
1606 qc->result_tf.auxiliary = get_unaligned_le32(&sense[16]); in ata_eh_get_ncq_success_sense()
1608 /* Set sense without also setting scsicmd->result */ in ata_eh_get_ncq_success_sense()
1609 scsi_build_sense_buffer(dev->flags & ATA_DFLAG_D_SENSE, in ata_eh_get_ncq_success_sense()
1610 qc->scsicmd->sense_buffer, sk, in ata_eh_get_ncq_success_sense()
1612 qc->flags |= ATA_QCFLAG_SENSE_VALID; in ata_eh_get_ncq_success_sense()
1625 * ata_eh_analyze_ncq_error - analyze NCQ error
1629 * error status TF. For NCQ device errors, all LLDDs have to do
1630 * is setting AC_ERR_DEV in ehi->err_mask. This function takes
1638 struct ata_port *ap = link->ap; in ata_eh_analyze_ncq_error()
1639 struct ata_eh_context *ehc = &link->eh_context; in ata_eh_analyze_ncq_error()
1640 struct ata_device *dev = link->device; in ata_eh_analyze_ncq_error()
1642 struct ata_taskfile tf; in ata_eh_analyze_ncq_error() local
1650 if (!link->sactive || !(ehc->i.err_mask & AC_ERR_DEV)) in ata_eh_analyze_ncq_error()
1655 if (!(qc->flags & ATA_QCFLAG_EH)) in ata_eh_analyze_ncq_error()
1658 if (qc->err_mask) in ata_eh_analyze_ncq_error()
1663 memset(&tf, 0, sizeof(tf)); in ata_eh_analyze_ncq_error()
1664 rc = ata_eh_read_log_10h(dev, &tag, &tf); in ata_eh_analyze_ncq_error()
1671 if (!(link->sactive & BIT(tag))) { in ata_eh_analyze_ncq_error()
1679 memcpy(&qc->result_tf, &tf, sizeof(tf)); in ata_eh_analyze_ncq_error()
1680 qc->result_tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_LBA | ATA_TFLAG_LBA48; in ata_eh_analyze_ncq_error()
1681 qc->err_mask |= AC_ERR_DEV | AC_ERR_NCQ; in ata_eh_analyze_ncq_error()
1685 * stored the sense data in qc->result_tf.auxiliary. in ata_eh_analyze_ncq_error()
1687 if (qc->result_tf.auxiliary) { in ata_eh_analyze_ncq_error()
1690 sense_key = (qc->result_tf.auxiliary >> 16) & 0xff; in ata_eh_analyze_ncq_error()
1691 asc = (qc->result_tf.auxiliary >> 8) & 0xff; in ata_eh_analyze_ncq_error()
1692 ascq = qc->result_tf.auxiliary & 0xff; in ata_eh_analyze_ncq_error()
1694 ata_scsi_set_sense(dev, qc->scsicmd, sense_key, asc, in ata_eh_analyze_ncq_error()
1696 qc->flags |= ATA_QCFLAG_SENSE_VALID; in ata_eh_analyze_ncq_error()
1701 if (!(qc->flags & ATA_QCFLAG_EH) || in ata_eh_analyze_ncq_error()
1702 qc->flags & ATA_QCFLAG_EH_SUCCESS_CMD || in ata_eh_analyze_ncq_error()
1703 ata_dev_phys_link(qc->dev) != link) in ata_eh_analyze_ncq_error()
1707 if (qc->err_mask) in ata_eh_analyze_ncq_error()
1716 qc->result_tf.status &= ~ATA_ERR; in ata_eh_analyze_ncq_error()
1717 qc->result_tf.error = 0; in ata_eh_analyze_ncq_error()
1720 * If we get a NCQ error, that means that a single command was in ata_eh_analyze_ncq_error()
1725 qc->flags |= ATA_QCFLAG_RETRY; in ata_eh_analyze_ncq_error()
1728 ehc->i.err_mask &= ~AC_ERR_DEV; in ata_eh_analyze_ncq_error()