Lines Matching full:qc

609 	 * completion wins, the qc never reaches EH.  When error  in ata_scsi_cmd_error_handler()
610 * completion wins, the qc has ATA_QCFLAG_EH set. in ata_scsi_cmd_error_handler()
616 * timed out iff its associated qc is active and not failed. in ata_scsi_cmd_error_handler()
634 struct ata_queued_cmd *qc; in ata_scsi_cmd_error_handler() local
644 ata_qc_for_each_raw(ap, qc, i) { in ata_scsi_cmd_error_handler()
645 if (qc->flags & ATA_QCFLAG_ACTIVE && in ata_scsi_cmd_error_handler()
646 qc->scsicmd == scmd) in ata_scsi_cmd_error_handler()
651 /* the scmd has an associated qc */ in ata_scsi_cmd_error_handler()
652 if (!(qc->flags & ATA_QCFLAG_EH)) { in ata_scsi_cmd_error_handler()
655 qc->err_mask |= AC_ERR_TIMEOUT; in ata_scsi_cmd_error_handler()
656 qc->flags |= ATA_QCFLAG_EH; in ata_scsi_cmd_error_handler()
848 struct ata_queued_cmd *qc; in ata_eh_nr_in_flight() local
853 ata_qc_for_each(ap, qc, tag) { in ata_eh_nr_in_flight()
854 if (qc) in ata_eh_nr_in_flight()
876 struct ata_queued_cmd *qc; in ata_eh_fastdrain_timerfn() local
882 ata_qc_for_each(ap, qc, tag) { in ata_eh_fastdrain_timerfn()
883 if (qc) in ata_eh_fastdrain_timerfn()
884 qc->err_mask |= AC_ERR_TIMEOUT; in ata_eh_fastdrain_timerfn()
938 * ata_qc_schedule_eh - schedule qc for error handling
939 * @qc: command to schedule error handling for
941 * Schedule error handling for @qc. EH will kick in as soon as
947 void ata_qc_schedule_eh(struct ata_queued_cmd *qc) in ata_qc_schedule_eh() argument
949 struct ata_port *ap = qc->ap; in ata_qc_schedule_eh()
951 qc->flags |= ATA_QCFLAG_EH; in ata_qc_schedule_eh()
959 blk_abort_request(scsi_cmd_to_rq(qc->scsicmd)); in ata_qc_schedule_eh()
1003 * ata_port_schedule_eh - schedule error handling without a qc
1021 struct ata_queued_cmd *qc; in ata_do_link_abort() local
1028 ata_qc_for_each_with_internal(ap, qc, tag) { in ata_do_link_abort()
1029 if (qc && (!link || qc->dev->link == link)) { in ata_do_link_abort()
1030 qc->flags |= ATA_QCFLAG_EH; in ata_do_link_abort()
1031 ata_qc_complete(qc); in ata_do_link_abort()
1043 * ata_link_abort - abort all qc's on the link
1044 * @link: ATA link to abort qc's for
1046 * Abort all active qc's active on @link and schedule EH.
1052 * Number of aborted qc's.
1061 * ata_port_abort - abort all qc's on the port
1062 * @ap: ATA port to abort qc's for
1064 * Abort all active qc's of @ap and schedule EH.
1070 * Number of aborted qc's.
1177 static void __ata_eh_qc_complete(struct ata_queued_cmd *qc) in __ata_eh_qc_complete() argument
1179 struct ata_port *ap = qc->ap; in __ata_eh_qc_complete()
1180 struct scsi_cmnd *scmd = qc->scsicmd; in __ata_eh_qc_complete()
1184 qc->scsidone = ata_eh_scsidone; in __ata_eh_qc_complete()
1185 __ata_qc_complete(qc); in __ata_eh_qc_complete()
1186 WARN_ON(ata_tag_valid(qc->tag)); in __ata_eh_qc_complete()
1194 * @qc: Command to complete
1199 void ata_eh_qc_complete(struct ata_queued_cmd *qc) in ata_eh_qc_complete() argument
1201 struct scsi_cmnd *scmd = qc->scsicmd; in ata_eh_qc_complete()
1203 __ata_eh_qc_complete(qc); in ata_eh_qc_complete()
1208 * @qc: Command to retry
1215 * due to unrelated failures (qc->err_mask is zero).
1217 void ata_eh_qc_retry(struct ata_queued_cmd *qc) in ata_eh_qc_retry() argument
1219 struct scsi_cmnd *scmd = qc->scsicmd; in ata_eh_qc_retry()
1220 if (!qc->err_mask) in ata_eh_qc_retry()
1222 __ata_eh_qc_complete(qc); in ata_eh_qc_retry()
1417 * ata_eh_decide_disposition - Disposition a qc based on sense data
1418 * @qc: qc to examine
1425 * EH). However, for a QC, we always need to fetch the sense data
1437 * Thus, for QC commands that went via SCSI EH, we need to call
1448 enum scsi_disposition ata_eh_decide_disposition(struct ata_queued_cmd *qc) in ata_eh_decide_disposition() argument
1450 return scsi_check_sense(qc->scsicmd); in ata_eh_decide_disposition()
1455 * @qc: qc to perform REQUEST_SENSE_SENSE_DATA_EXT to
1466 static bool ata_eh_request_sense(struct ata_queued_cmd *qc) in ata_eh_request_sense() argument
1468 struct scsi_cmnd *cmd = qc->scsicmd; in ata_eh_request_sense()
1469 struct ata_device *dev = qc->dev; in ata_eh_request_sense()
1473 if (ata_port_is_frozen(qc->ap)) { in ata_eh_request_sense()
1479 ata_dev_warn(qc->dev, "sense data reporting disabled\n"); in ata_eh_request_sense()
1497 qc->flags |= ATA_QCFLAG_SENSE_VALID; in ata_eh_request_sense()
1550 * the LLD to use DMA for REQUEST_SENSE, but we don't have a qc. in atapi_eh_request_sense()
1616 * ata_eh_analyze_tf - analyze taskfile of a failed qc
1617 * @qc: qc to analyze
1619 * Analyze taskfile of @qc and further determine cause of
1629 static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc) in ata_eh_analyze_tf() argument
1631 const struct ata_taskfile *tf = &qc->result_tf; in ata_eh_analyze_tf()
1636 qc->err_mask |= AC_ERR_HSM; in ata_eh_analyze_tf()
1641 qc->err_mask |= AC_ERR_DEV; in ata_eh_analyze_tf()
1652 switch (qc->dev->class) { in ata_eh_analyze_tf()
1662 if (!(qc->flags & ATA_QCFLAG_SENSE_VALID) && in ata_eh_analyze_tf()
1663 (stat & ATA_SENSE) && ata_eh_request_sense(qc)) in ata_eh_analyze_tf()
1664 set_status_byte(qc->scsicmd, SAM_STAT_CHECK_CONDITION); in ata_eh_analyze_tf()
1666 qc->err_mask |= AC_ERR_ATA_BUS; in ata_eh_analyze_tf()
1668 qc->err_mask |= AC_ERR_MEDIA; in ata_eh_analyze_tf()
1670 qc->err_mask |= AC_ERR_INVALID; in ata_eh_analyze_tf()
1674 if (!ata_port_is_frozen(qc->ap)) { in ata_eh_analyze_tf()
1675 tmp = atapi_eh_request_sense(qc->dev, in ata_eh_analyze_tf()
1676 qc->scsicmd->sense_buffer, in ata_eh_analyze_tf()
1677 qc->result_tf.error >> 4); in ata_eh_analyze_tf()
1679 qc->flags |= ATA_QCFLAG_SENSE_VALID; in ata_eh_analyze_tf()
1681 qc->err_mask |= tmp; in ata_eh_analyze_tf()
1685 if (qc->flags & ATA_QCFLAG_SENSE_VALID) { in ata_eh_analyze_tf()
1686 enum scsi_disposition ret = ata_eh_decide_disposition(qc); in ata_eh_analyze_tf()
1698 qc->flags |= ATA_QCFLAG_RETRY; in ata_eh_analyze_tf()
1699 qc->err_mask |= AC_ERR_OTHER; in ata_eh_analyze_tf()
1701 qc->err_mask |= AC_ERR_HSM; in ata_eh_analyze_tf()
1704 if (qc->err_mask & (AC_ERR_HSM | AC_ERR_TIMEOUT | AC_ERR_ATA_BUS)) in ata_eh_analyze_tf()
1952 * @qc: qc to possibly retry
1959 static inline int ata_eh_worth_retry(struct ata_queued_cmd *qc) in ata_eh_worth_retry() argument
1961 if (qc->err_mask & AC_ERR_MEDIA) in ata_eh_worth_retry()
1963 if (qc->flags & ATA_QCFLAG_IO) in ata_eh_worth_retry()
1965 if (qc->err_mask & AC_ERR_INVALID) in ata_eh_worth_retry()
1967 return qc->err_mask != AC_ERR_DEV; /* retry if not dev error */ in ata_eh_worth_retry()
1972 * @qc: qc to check
1974 * Look at the qc flags anbd its scsi command request flags to determine
1977 static inline bool ata_eh_quiet(struct ata_queued_cmd *qc) in ata_eh_quiet() argument
1979 if (qc->scsicmd && scsi_cmd_to_rq(qc->scsicmd)->rq_flags & RQF_QUIET) in ata_eh_quiet()
1980 qc->flags |= ATA_QCFLAG_QUIET; in ata_eh_quiet()
1981 return qc->flags & ATA_QCFLAG_QUIET; in ata_eh_quiet()
1987 struct ata_queued_cmd *qc; in ata_eh_get_non_ncq_success_sense() local
1989 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_get_non_ncq_success_sense()
1990 if (!qc) in ata_eh_get_non_ncq_success_sense()
1993 if (!(qc->flags & ATA_QCFLAG_EH) || in ata_eh_get_non_ncq_success_sense()
1994 !(qc->flags & ATA_QCFLAG_EH_SUCCESS_CMD) || in ata_eh_get_non_ncq_success_sense()
1995 qc->err_mask) in ata_eh_get_non_ncq_success_sense()
1998 if (!ata_eh_request_sense(qc)) in ata_eh_get_non_ncq_success_sense()
2005 ata_eh_decide_disposition(qc); in ata_eh_get_non_ncq_success_sense()
2015 struct ata_queued_cmd *qc; in ata_eh_get_success_sense() local
2054 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_get_success_sense()
2055 if (!(qc->flags & ATA_QCFLAG_EH) || in ata_eh_get_success_sense()
2056 !(qc->flags & ATA_QCFLAG_EH_SUCCESS_CMD) || in ata_eh_get_success_sense()
2057 qc->err_mask || in ata_eh_get_success_sense()
2058 ata_dev_phys_link(qc->dev) != link) in ata_eh_get_success_sense()
2062 if (qc->flags & ATA_QCFLAG_SENSE_VALID) in ata_eh_get_success_sense()
2066 if (!(qc->result_tf.status & ATA_SENSE)) in ata_eh_get_success_sense()
2070 ata_scsi_set_sense(dev, qc->scsicmd, ABORTED_COMMAND, 0, 0); in ata_eh_get_success_sense()
2071 qc->flags |= ATA_QCFLAG_SENSE_VALID; in ata_eh_get_success_sense()
2091 struct ata_queued_cmd *qc; in ata_eh_link_autopsy() local
2130 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_autopsy()
2131 if (!(qc->flags & ATA_QCFLAG_EH) || in ata_eh_link_autopsy()
2132 qc->flags & ATA_QCFLAG_RETRY || in ata_eh_link_autopsy()
2133 qc->flags & ATA_QCFLAG_EH_SUCCESS_CMD || in ata_eh_link_autopsy()
2134 ata_dev_phys_link(qc->dev) != link) in ata_eh_link_autopsy()
2138 qc->err_mask |= ehc->i.err_mask; in ata_eh_link_autopsy()
2141 ehc->i.action |= ata_eh_analyze_tf(qc); in ata_eh_link_autopsy()
2144 if (qc->err_mask & AC_ERR_ATA_BUS) in ata_eh_link_autopsy()
2145 qc->err_mask &= ~(AC_ERR_DEV | AC_ERR_MEDIA | in ata_eh_link_autopsy()
2149 if (qc->err_mask & ~AC_ERR_OTHER) in ata_eh_link_autopsy()
2150 qc->err_mask &= ~AC_ERR_OTHER; in ata_eh_link_autopsy()
2159 if (qc->flags & ATA_QCFLAG_SENSE_VALID) in ata_eh_link_autopsy()
2160 qc->err_mask &= ~(AC_ERR_DEV | AC_ERR_OTHER); in ata_eh_link_autopsy()
2161 else if (ata_eh_worth_retry(qc)) in ata_eh_link_autopsy()
2162 qc->flags |= ATA_QCFLAG_RETRY; in ata_eh_link_autopsy()
2165 ehc->i.dev = qc->dev; in ata_eh_link_autopsy()
2166 all_err_mask |= qc->err_mask; in ata_eh_link_autopsy()
2167 if (qc->flags & ATA_QCFLAG_IO) in ata_eh_link_autopsy()
2169 trace_ata_eh_link_autopsy_qc(qc); in ata_eh_link_autopsy()
2172 if (ata_eh_quiet(qc)) in ata_eh_link_autopsy()
2397 struct ata_queued_cmd *qc; in ata_eh_link_report() local
2409 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2410 if (!(qc->flags & ATA_QCFLAG_EH) || in ata_eh_link_report()
2411 ata_dev_phys_link(qc->dev) != link || in ata_eh_link_report()
2412 ((qc->flags & ATA_QCFLAG_QUIET) && in ata_eh_link_report()
2413 qc->err_mask == AC_ERR_DEV)) in ata_eh_link_report()
2415 if (qc->flags & ATA_QCFLAG_SENSE_VALID && !qc->err_mask) in ata_eh_link_report()
2471 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_link_report()
2472 struct ata_taskfile *cmd = &qc->tf, *res = &qc->result_tf; in ata_eh_link_report()
2476 if (!(qc->flags & ATA_QCFLAG_EH) || in ata_eh_link_report()
2477 ata_dev_phys_link(qc->dev) != link || !qc->err_mask) in ata_eh_link_report()
2480 if (qc->dma_dir != DMA_NONE) { in ata_eh_link_report()
2488 switch (qc->tf.protocol) { in ata_eh_link_report()
2518 prot_str, qc->nbytes, dma_str[qc->dma_dir]); in ata_eh_link_report()
2521 if (ata_is_atapi(qc->tf.protocol)) { in ata_eh_link_report()
2522 const u8 *cdb = qc->cdb; in ata_eh_link_report()
2523 size_t cdb_len = qc->dev->cdb_len; in ata_eh_link_report()
2525 if (qc->scsicmd) { in ata_eh_link_report()
2526 cdb = qc->scsicmd->cmnd; in ata_eh_link_report()
2527 cdb_len = qc->scsicmd->cmd_len; in ata_eh_link_report()
2532 ata_dev_err(qc->dev, "failed command: %s\n", in ata_eh_link_report()
2535 ata_dev_err(qc->dev, in ata_eh_link_report()
2544 cmd->device, qc->tag, data_buf, cdb_buf, in ata_eh_link_report()
2549 res->device, qc->err_mask, ata_err_string(qc->err_mask), in ata_eh_link_report()
2550 qc->err_mask & AC_ERR_NCQ ? " <F>" : ""); in ata_eh_link_report()
2556 ata_dev_err(qc->dev, "status: { Busy }\n"); in ata_eh_link_report()
2558 ata_dev_err(qc->dev, "status: { %s%s%s%s%s}\n", in ata_eh_link_report()
2569 ata_dev_err(qc->dev, "error: { %s%s%s%s%s}\n", in ata_eh_link_report()
3356 struct ata_queued_cmd *qc; in ata_eh_maybe_retry_flush() local
3365 qc = __ata_qc_from_tag(ap, link->active_tag); in ata_eh_maybe_retry_flush()
3366 if (qc->dev != dev || (qc->tf.command != ATA_CMD_FLUSH_EXT && in ata_eh_maybe_retry_flush()
3367 qc->tf.command != ATA_CMD_FLUSH)) in ata_eh_maybe_retry_flush()
3371 if (qc->err_mask & AC_ERR_DEV) in ata_eh_maybe_retry_flush()
3377 tf.command = qc->tf.command; in ata_eh_maybe_retry_flush()
3382 tf.command, qc->err_mask); in ata_eh_maybe_retry_flush()
3394 qc->scsicmd->allowed = max(qc->scsicmd->allowed, 1); in ata_eh_maybe_retry_flush()
3402 qc->err_mask |= AC_ERR_DEV; in ata_eh_maybe_retry_flush()
3403 qc->result_tf = tf; in ata_eh_maybe_retry_flush()
3979 struct ata_queued_cmd *qc; in ata_eh_finish() local
3983 ata_qc_for_each_raw(ap, qc, tag) { in ata_eh_finish()
3984 if (!(qc->flags & ATA_QCFLAG_EH)) in ata_eh_finish()
3987 if (qc->err_mask) { in ata_eh_finish()
3992 if (qc->flags & ATA_QCFLAG_RETRY) { in ata_eh_finish()
3994 * Since qc->err_mask is set, ata_eh_qc_retry() in ata_eh_finish()
3999 ata_eh_qc_retry(qc); in ata_eh_finish()
4001 ata_eh_qc_complete(qc); in ata_eh_finish()
4004 if (qc->flags & ATA_QCFLAG_SENSE_VALID || in ata_eh_finish()
4005 qc->flags & ATA_QCFLAG_EH_SUCCESS_CMD) { in ata_eh_finish()
4006 ata_eh_qc_complete(qc); in ata_eh_finish()
4009 memset(&qc->result_tf, 0, sizeof(qc->result_tf)); in ata_eh_finish()
4011 * Since qc->err_mask is not set, in ata_eh_finish()
4016 ata_eh_qc_retry(qc); in ata_eh_finish()