Commit 258c4e5c authored by Jens Axboe's avatar Jens Axboe Committed by Tejun Heo

libata: convert eh to command iterators

Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 6362f0a2
...@@ -614,8 +614,7 @@ void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, ...@@ -614,8 +614,7 @@ void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap,
list_for_each_entry_safe(scmd, tmp, eh_work_q, eh_entry) { list_for_each_entry_safe(scmd, tmp, eh_work_q, eh_entry) {
struct ata_queued_cmd *qc; struct ata_queued_cmd *qc;
for (i = 0; i < ATA_MAX_QUEUE; i++) { ata_qc_for_each_raw(ap, qc, i) {
qc = __ata_qc_from_tag(ap, i);
if (qc->flags & ATA_QCFLAG_ACTIVE && if (qc->flags & ATA_QCFLAG_ACTIVE &&
qc->scsicmd == scmd) qc->scsicmd == scmd)
break; break;
...@@ -818,14 +817,13 @@ EXPORT_SYMBOL_GPL(ata_port_wait_eh); ...@@ -818,14 +817,13 @@ EXPORT_SYMBOL_GPL(ata_port_wait_eh);
static int ata_eh_nr_in_flight(struct ata_port *ap) static int ata_eh_nr_in_flight(struct ata_port *ap)
{ {
struct ata_queued_cmd *qc;
unsigned int tag; unsigned int tag;
int nr = 0; int nr = 0;
/* count only non-internal commands */ /* count only non-internal commands */
for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { ata_qc_for_each(ap, qc, tag) {
if (ata_tag_internal(tag)) if (qc)
continue;
if (ata_qc_from_tag(ap, tag))
nr++; nr++;
} }
...@@ -847,13 +845,13 @@ void ata_eh_fastdrain_timerfn(struct timer_list *t) ...@@ -847,13 +845,13 @@ void ata_eh_fastdrain_timerfn(struct timer_list *t)
goto out_unlock; goto out_unlock;
if (cnt == ap->fastdrain_cnt) { if (cnt == ap->fastdrain_cnt) {
struct ata_queued_cmd *qc;
unsigned int tag; unsigned int tag;
/* No progress during the last interval, tag all /* No progress during the last interval, tag all
* in-flight qcs as timed out and freeze the port. * in-flight qcs as timed out and freeze the port.
*/ */
for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { ata_qc_for_each(ap, qc, tag) {
struct ata_queued_cmd *qc = ata_qc_from_tag(ap, tag);
if (qc) if (qc)
qc->err_mask |= AC_ERR_TIMEOUT; qc->err_mask |= AC_ERR_TIMEOUT;
} }
...@@ -999,6 +997,7 @@ void ata_port_schedule_eh(struct ata_port *ap) ...@@ -999,6 +997,7 @@ void ata_port_schedule_eh(struct ata_port *ap)
static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link) static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link)
{ {
struct ata_queued_cmd *qc;
int tag, nr_aborted = 0; int tag, nr_aborted = 0;
WARN_ON(!ap->ops->error_handler); WARN_ON(!ap->ops->error_handler);
...@@ -1007,9 +1006,7 @@ static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link) ...@@ -1007,9 +1006,7 @@ static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link)
ata_eh_set_pending(ap, 0); ata_eh_set_pending(ap, 0);
/* include internal tag in iteration */ /* include internal tag in iteration */
for (tag = 0; tag <= ATA_MAX_QUEUE; tag++) { ata_qc_for_each_with_internal(ap, qc, tag) {
struct ata_queued_cmd *qc = ata_qc_from_tag(ap, tag);
if (qc && (!link || qc->dev->link == link)) { if (qc && (!link || qc->dev->link == link)) {
qc->flags |= ATA_QCFLAG_FAILED; qc->flags |= ATA_QCFLAG_FAILED;
ata_qc_complete(qc); ata_qc_complete(qc);
...@@ -1712,9 +1709,7 @@ void ata_eh_analyze_ncq_error(struct ata_link *link) ...@@ -1712,9 +1709,7 @@ void ata_eh_analyze_ncq_error(struct ata_link *link)
return; return;
/* has LLDD analyzed already? */ /* has LLDD analyzed already? */
for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { ata_qc_for_each_raw(ap, qc, tag) {
qc = __ata_qc_from_tag(ap, tag);
if (!(qc->flags & ATA_QCFLAG_FAILED)) if (!(qc->flags & ATA_QCFLAG_FAILED))
continue; continue;
...@@ -2136,6 +2131,7 @@ static void ata_eh_link_autopsy(struct ata_link *link) ...@@ -2136,6 +2131,7 @@ static void ata_eh_link_autopsy(struct ata_link *link)
{ {
struct ata_port *ap = link->ap; struct ata_port *ap = link->ap;
struct ata_eh_context *ehc = &link->eh_context; struct ata_eh_context *ehc = &link->eh_context;
struct ata_queued_cmd *qc;
struct ata_device *dev; struct ata_device *dev;
unsigned int all_err_mask = 0, eflags = 0; unsigned int all_err_mask = 0, eflags = 0;
int tag, nr_failed = 0, nr_quiet = 0; int tag, nr_failed = 0, nr_quiet = 0;
...@@ -2168,9 +2164,7 @@ static void ata_eh_link_autopsy(struct ata_link *link) ...@@ -2168,9 +2164,7 @@ static void ata_eh_link_autopsy(struct ata_link *link)
all_err_mask |= ehc->i.err_mask; all_err_mask |= ehc->i.err_mask;
for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { ata_qc_for_each_raw(ap, qc, tag) {
struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
if (!(qc->flags & ATA_QCFLAG_FAILED) || if (!(qc->flags & ATA_QCFLAG_FAILED) ||
ata_dev_phys_link(qc->dev) != link) ata_dev_phys_link(qc->dev) != link)
continue; continue;
...@@ -2436,6 +2430,7 @@ static void ata_eh_link_report(struct ata_link *link) ...@@ -2436,6 +2430,7 @@ static void ata_eh_link_report(struct ata_link *link)
{ {
struct ata_port *ap = link->ap; struct ata_port *ap = link->ap;
struct ata_eh_context *ehc = &link->eh_context; struct ata_eh_context *ehc = &link->eh_context;
struct ata_queued_cmd *qc;
const char *frozen, *desc; const char *frozen, *desc;
char tries_buf[6] = ""; char tries_buf[6] = "";
int tag, nr_failed = 0; int tag, nr_failed = 0;
...@@ -2447,9 +2442,7 @@ static void ata_eh_link_report(struct ata_link *link) ...@@ -2447,9 +2442,7 @@ static void ata_eh_link_report(struct ata_link *link)
if (ehc->i.desc[0] != '\0') if (ehc->i.desc[0] != '\0')
desc = ehc->i.desc; desc = ehc->i.desc;
for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { ata_qc_for_each_raw(ap, qc, tag) {
struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
if (!(qc->flags & ATA_QCFLAG_FAILED) || if (!(qc->flags & ATA_QCFLAG_FAILED) ||
ata_dev_phys_link(qc->dev) != link || ata_dev_phys_link(qc->dev) != link ||
((qc->flags & ATA_QCFLAG_QUIET) && ((qc->flags & ATA_QCFLAG_QUIET) &&
...@@ -2511,8 +2504,7 @@ static void ata_eh_link_report(struct ata_link *link) ...@@ -2511,8 +2504,7 @@ static void ata_eh_link_report(struct ata_link *link)
ehc->i.serror & SERR_DEV_XCHG ? "DevExch " : ""); ehc->i.serror & SERR_DEV_XCHG ? "DevExch " : "");
#endif #endif
for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { ata_qc_for_each_raw(ap, qc, tag) {
struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
struct ata_taskfile *cmd = &qc->tf, *res = &qc->result_tf; struct ata_taskfile *cmd = &qc->tf, *res = &qc->result_tf;
char data_buf[20] = ""; char data_buf[20] = "";
char cdb_buf[70] = ""; char cdb_buf[70] = "";
...@@ -3992,12 +3984,11 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, ...@@ -3992,12 +3984,11 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
*/ */
void ata_eh_finish(struct ata_port *ap) void ata_eh_finish(struct ata_port *ap)
{ {
struct ata_queued_cmd *qc;
int tag; int tag;
/* retry or finish qcs */ /* retry or finish qcs */
for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { ata_qc_for_each_raw(ap, qc, tag) {
struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
if (!(qc->flags & ATA_QCFLAG_FAILED)) if (!(qc->flags & ATA_QCFLAG_FAILED))
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment