aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libata-core.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2006-05-15 07:58:02 -0400
committerTejun Heo <htejun@gmail.com>2006-05-15 07:58:02 -0400
commit2ab7db1ff1d64a2ba389d0692d532f42a15f1f72 (patch)
treec676e2796896e6856fda6cc6598d5670d06b5c1c /drivers/scsi/libata-core.c
parentdc2b3515868a254b3d653d77844bff93c5d4c095 (diff)
[PATCH] libata-eh-fw: use special reserved tag and qc for internal commands
New EH may issue internal commands to recover from error while failed qc's are still hanging around. To allow such usage, reserve tag ATA_MAX_QUEUE-1 for internal command. This also makes it easy to tell whether a qc is for internal command or not. ata_tag_internal() test implements this test. To avoid breaking existing drivers, ata_exec_internal() uses ATA_TAG_INTERNAL only for drivers which implement ->error_handler. For drivers using old EH, tag 0 is used. Note that this makes ata_tag_internal() test valid only when ->error_handler is implemented. This is okay as drivers on old EH should not and does not have any reason to use ata_tag_internal(). Signed-off-by: Tejun Heo <htejun@gmail.com>
Diffstat (limited to 'drivers/scsi/libata-core.c')
-rw-r--r--drivers/scsi/libata-core.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index de2cd61a264d..966abb5f423e 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -980,15 +980,39 @@ unsigned ata_exec_internal(struct ata_device *dev,
980 struct ata_port *ap = dev->ap; 980 struct ata_port *ap = dev->ap;
981 u8 command = tf->command; 981 u8 command = tf->command;
982 struct ata_queued_cmd *qc; 982 struct ata_queued_cmd *qc;
983 unsigned int tag, preempted_tag;
983 DECLARE_COMPLETION(wait); 984 DECLARE_COMPLETION(wait);
984 unsigned long flags; 985 unsigned long flags;
985 unsigned int err_mask; 986 unsigned int err_mask;
986 987
987 spin_lock_irqsave(&ap->host_set->lock, flags); 988 spin_lock_irqsave(&ap->host_set->lock, flags);
988 989
989 qc = ata_qc_new_init(dev); 990 /* initialize internal qc */
990 BUG_ON(qc == NULL);
991 991
992 /* XXX: Tag 0 is used for drivers with legacy EH as some
993 * drivers choke if any other tag is given. This breaks
994 * ata_tag_internal() test for those drivers. Don't use new
995 * EH stuff without converting to it.
996 */
997 if (ap->ops->error_handler)
998 tag = ATA_TAG_INTERNAL;
999 else
1000 tag = 0;
1001
1002 if (test_and_set_bit(tag, &ap->qactive))
1003 BUG();
1004 qc = ata_qc_from_tag(ap, tag);
1005
1006 qc->tag = tag;
1007 qc->scsicmd = NULL;
1008 qc->ap = ap;
1009 qc->dev = dev;
1010 ata_qc_reinit(qc);
1011
1012 preempted_tag = ap->active_tag;
1013 ap->active_tag = ATA_TAG_POISON;
1014
1015 /* prepare & issue qc */
992 qc->tf = *tf; 1016 qc->tf = *tf;
993 if (cdb) 1017 if (cdb)
994 memcpy(qc->cdb, cdb, ATAPI_CDB_LEN); 1018 memcpy(qc->cdb, cdb, ATAPI_CDB_LEN);
@@ -1035,6 +1059,7 @@ unsigned ata_exec_internal(struct ata_device *dev,
1035 err_mask = qc->err_mask; 1059 err_mask = qc->err_mask;
1036 1060
1037 ata_qc_free(qc); 1061 ata_qc_free(qc);
1062 ap->active_tag = preempted_tag;
1038 1063
1039 /* XXX - Some LLDDs (sata_mv) disable port on command failure. 1064 /* XXX - Some LLDDs (sata_mv) disable port on command failure.
1040 * Until those drivers are fixed, we detect the condition 1065 * Until those drivers are fixed, we detect the condition
@@ -4014,7 +4039,8 @@ static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap)
4014 struct ata_queued_cmd *qc = NULL; 4039 struct ata_queued_cmd *qc = NULL;
4015 unsigned int i; 4040 unsigned int i;
4016 4041
4017 for (i = 0; i < ATA_MAX_QUEUE; i++) 4042 /* the last tag is reserved for internal command. */
4043 for (i = 0; i < ATA_MAX_QUEUE - 1; i++)
4018 if (!test_and_set_bit(i, &ap->qactive)) { 4044 if (!test_and_set_bit(i, &ap->qactive)) {
4019 qc = ata_qc_from_tag(ap, i); 4045 qc = ata_qc_from_tag(ap, i);
4020 break; 4046 break;