diff options
author | Jens Axboe <axboe@kernel.dk> | 2018-06-19 12:12:49 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2018-06-19 12:30:27 -0400 |
commit | 258c4e5c65b21bdbe9735f49ea584b3059c810e4 (patch) | |
tree | 56e41dd8774388837e4ab03b449da0815b1243a8 /drivers/ata/libata-eh.c | |
parent | 6362f0a290023bafd7f991089e81dd9278f154b8 (diff) |
libata: convert eh to command iterators
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'drivers/ata/libata-eh.c')
-rw-r--r-- | drivers/ata/libata-eh.c | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index d5412145d76d..01306c018398 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -614,8 +614,7 @@ void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, | |||
614 | list_for_each_entry_safe(scmd, tmp, eh_work_q, eh_entry) { | 614 | list_for_each_entry_safe(scmd, tmp, eh_work_q, eh_entry) { |
615 | struct ata_queued_cmd *qc; | 615 | struct ata_queued_cmd *qc; |
616 | 616 | ||
617 | for (i = 0; i < ATA_MAX_QUEUE; i++) { | 617 | ata_qc_for_each_raw(ap, qc, i) { |
618 | qc = __ata_qc_from_tag(ap, i); | ||
619 | if (qc->flags & ATA_QCFLAG_ACTIVE && | 618 | if (qc->flags & ATA_QCFLAG_ACTIVE && |
620 | qc->scsicmd == scmd) | 619 | qc->scsicmd == scmd) |
621 | break; | 620 | break; |
@@ -818,14 +817,13 @@ EXPORT_SYMBOL_GPL(ata_port_wait_eh); | |||
818 | 817 | ||
819 | static int ata_eh_nr_in_flight(struct ata_port *ap) | 818 | static int ata_eh_nr_in_flight(struct ata_port *ap) |
820 | { | 819 | { |
820 | struct ata_queued_cmd *qc; | ||
821 | unsigned int tag; | 821 | unsigned int tag; |
822 | int nr = 0; | 822 | int nr = 0; |
823 | 823 | ||
824 | /* count only non-internal commands */ | 824 | /* count only non-internal commands */ |
825 | for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { | 825 | ata_qc_for_each(ap, qc, tag) { |
826 | if (ata_tag_internal(tag)) | 826 | if (qc) |
827 | continue; | ||
828 | if (ata_qc_from_tag(ap, tag)) | ||
829 | nr++; | 827 | nr++; |
830 | } | 828 | } |
831 | 829 | ||
@@ -847,13 +845,13 @@ void ata_eh_fastdrain_timerfn(struct timer_list *t) | |||
847 | goto out_unlock; | 845 | goto out_unlock; |
848 | 846 | ||
849 | if (cnt == ap->fastdrain_cnt) { | 847 | if (cnt == ap->fastdrain_cnt) { |
848 | struct ata_queued_cmd *qc; | ||
850 | unsigned int tag; | 849 | unsigned int tag; |
851 | 850 | ||
852 | /* No progress during the last interval, tag all | 851 | /* No progress during the last interval, tag all |
853 | * in-flight qcs as timed out and freeze the port. | 852 | * in-flight qcs as timed out and freeze the port. |
854 | */ | 853 | */ |
855 | for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { | 854 | ata_qc_for_each(ap, qc, tag) { |
856 | struct ata_queued_cmd *qc = ata_qc_from_tag(ap, tag); | ||
857 | if (qc) | 855 | if (qc) |
858 | qc->err_mask |= AC_ERR_TIMEOUT; | 856 | qc->err_mask |= AC_ERR_TIMEOUT; |
859 | } | 857 | } |
@@ -999,6 +997,7 @@ void ata_port_schedule_eh(struct ata_port *ap) | |||
999 | 997 | ||
1000 | static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link) | 998 | static int ata_do_link_abort(struct ata_port *ap, struct ata_link *link) |
1001 | { | 999 | { |
1000 | struct ata_queued_cmd *qc; | ||
1002 | int tag, nr_aborted = 0; | 1001 | int tag, nr_aborted = 0; |
1003 | 1002 | ||
1004 | WARN_ON(!ap->ops->error_handler); | 1003 | 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 | ata_eh_set_pending(ap, 0); | 1006 | ata_eh_set_pending(ap, 0); |
1008 | 1007 | ||
1009 | /* include internal tag in iteration */ | 1008 | /* include internal tag in iteration */ |
1010 | for (tag = 0; tag <= ATA_MAX_QUEUE; tag++) { | 1009 | ata_qc_for_each_with_internal(ap, qc, tag) { |
1011 | struct ata_queued_cmd *qc = ata_qc_from_tag(ap, tag); | ||
1012 | |||
1013 | if (qc && (!link || qc->dev->link == link)) { | 1010 | if (qc && (!link || qc->dev->link == link)) { |
1014 | qc->flags |= ATA_QCFLAG_FAILED; | 1011 | qc->flags |= ATA_QCFLAG_FAILED; |
1015 | ata_qc_complete(qc); | 1012 | ata_qc_complete(qc); |
@@ -1712,9 +1709,7 @@ void ata_eh_analyze_ncq_error(struct ata_link *link) | |||
1712 | return; | 1709 | return; |
1713 | 1710 | ||
1714 | /* has LLDD analyzed already? */ | 1711 | /* has LLDD analyzed already? */ |
1715 | for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { | 1712 | ata_qc_for_each_raw(ap, qc, tag) { |
1716 | qc = __ata_qc_from_tag(ap, tag); | ||
1717 | |||
1718 | if (!(qc->flags & ATA_QCFLAG_FAILED)) | 1713 | if (!(qc->flags & ATA_QCFLAG_FAILED)) |
1719 | continue; | 1714 | continue; |
1720 | 1715 | ||
@@ -2136,6 +2131,7 @@ static void ata_eh_link_autopsy(struct ata_link *link) | |||
2136 | { | 2131 | { |
2137 | struct ata_port *ap = link->ap; | 2132 | struct ata_port *ap = link->ap; |
2138 | struct ata_eh_context *ehc = &link->eh_context; | 2133 | struct ata_eh_context *ehc = &link->eh_context; |
2134 | struct ata_queued_cmd *qc; | ||
2139 | struct ata_device *dev; | 2135 | struct ata_device *dev; |
2140 | unsigned int all_err_mask = 0, eflags = 0; | 2136 | unsigned int all_err_mask = 0, eflags = 0; |
2141 | int tag, nr_failed = 0, nr_quiet = 0; | 2137 | int tag, nr_failed = 0, nr_quiet = 0; |
@@ -2168,9 +2164,7 @@ static void ata_eh_link_autopsy(struct ata_link *link) | |||
2168 | 2164 | ||
2169 | all_err_mask |= ehc->i.err_mask; | 2165 | all_err_mask |= ehc->i.err_mask; |
2170 | 2166 | ||
2171 | for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { | 2167 | ata_qc_for_each_raw(ap, qc, tag) { |
2172 | struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); | ||
2173 | |||
2174 | if (!(qc->flags & ATA_QCFLAG_FAILED) || | 2168 | if (!(qc->flags & ATA_QCFLAG_FAILED) || |
2175 | ata_dev_phys_link(qc->dev) != link) | 2169 | ata_dev_phys_link(qc->dev) != link) |
2176 | continue; | 2170 | continue; |
@@ -2436,6 +2430,7 @@ static void ata_eh_link_report(struct ata_link *link) | |||
2436 | { | 2430 | { |
2437 | struct ata_port *ap = link->ap; | 2431 | struct ata_port *ap = link->ap; |
2438 | struct ata_eh_context *ehc = &link->eh_context; | 2432 | struct ata_eh_context *ehc = &link->eh_context; |
2433 | struct ata_queued_cmd *qc; | ||
2439 | const char *frozen, *desc; | 2434 | const char *frozen, *desc; |
2440 | char tries_buf[6] = ""; | 2435 | char tries_buf[6] = ""; |
2441 | int tag, nr_failed = 0; | 2436 | int tag, nr_failed = 0; |
@@ -2447,9 +2442,7 @@ static void ata_eh_link_report(struct ata_link *link) | |||
2447 | if (ehc->i.desc[0] != '\0') | 2442 | if (ehc->i.desc[0] != '\0') |
2448 | desc = ehc->i.desc; | 2443 | desc = ehc->i.desc; |
2449 | 2444 | ||
2450 | for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { | 2445 | ata_qc_for_each_raw(ap, qc, tag) { |
2451 | struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); | ||
2452 | |||
2453 | if (!(qc->flags & ATA_QCFLAG_FAILED) || | 2446 | if (!(qc->flags & ATA_QCFLAG_FAILED) || |
2454 | ata_dev_phys_link(qc->dev) != link || | 2447 | ata_dev_phys_link(qc->dev) != link || |
2455 | ((qc->flags & ATA_QCFLAG_QUIET) && | 2448 | ((qc->flags & ATA_QCFLAG_QUIET) && |
@@ -2511,8 +2504,7 @@ static void ata_eh_link_report(struct ata_link *link) | |||
2511 | ehc->i.serror & SERR_DEV_XCHG ? "DevExch " : ""); | 2504 | ehc->i.serror & SERR_DEV_XCHG ? "DevExch " : ""); |
2512 | #endif | 2505 | #endif |
2513 | 2506 | ||
2514 | for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { | 2507 | ata_qc_for_each_raw(ap, qc, tag) { |
2515 | struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); | ||
2516 | struct ata_taskfile *cmd = &qc->tf, *res = &qc->result_tf; | 2508 | struct ata_taskfile *cmd = &qc->tf, *res = &qc->result_tf; |
2517 | char data_buf[20] = ""; | 2509 | char data_buf[20] = ""; |
2518 | char cdb_buf[70] = ""; | 2510 | char cdb_buf[70] = ""; |
@@ -3992,12 +3984,11 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
3992 | */ | 3984 | */ |
3993 | void ata_eh_finish(struct ata_port *ap) | 3985 | void ata_eh_finish(struct ata_port *ap) |
3994 | { | 3986 | { |
3987 | struct ata_queued_cmd *qc; | ||
3995 | int tag; | 3988 | int tag; |
3996 | 3989 | ||
3997 | /* retry or finish qcs */ | 3990 | /* retry or finish qcs */ |
3998 | for (tag = 0; tag < ATA_MAX_QUEUE; tag++) { | 3991 | ata_qc_for_each_raw(ap, qc, tag) { |
3999 | struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); | ||
4000 | |||
4001 | if (!(qc->flags & ATA_QCFLAG_FAILED)) | 3992 | if (!(qc->flags & ATA_QCFLAG_FAILED)) |
4002 | continue; | 3993 | continue; |
4003 | 3994 | ||