diff options
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/Makefile | 2 | ||||
-rw-r--r-- | drivers/scsi/ahci.c | 52 | ||||
-rw-r--r-- | drivers/scsi/ata_piix.c | 2 | ||||
-rw-r--r-- | drivers/scsi/libata-core.c | 888 | ||||
-rw-r--r-- | drivers/scsi/libata-eh.c | 263 | ||||
-rw-r--r-- | drivers/scsi/libata-scsi.c | 187 | ||||
-rw-r--r-- | drivers/scsi/libata.h | 18 | ||||
-rw-r--r-- | drivers/scsi/pdc_adma.c | 6 | ||||
-rw-r--r-- | drivers/scsi/sata_mv.c | 4 | ||||
-rw-r--r-- | drivers/scsi/sata_nv.c | 4 | ||||
-rw-r--r-- | drivers/scsi/sata_promise.c | 6 | ||||
-rw-r--r-- | drivers/scsi/sata_qstor.c | 6 | ||||
-rw-r--r-- | drivers/scsi/sata_sil.c | 8 | ||||
-rw-r--r-- | drivers/scsi/sata_sil24.c | 249 | ||||
-rw-r--r-- | drivers/scsi/sata_sis.c | 2 | ||||
-rw-r--r-- | drivers/scsi/sata_svw.c | 4 | ||||
-rw-r--r-- | drivers/scsi/sata_sx4.c | 8 | ||||
-rw-r--r-- | drivers/scsi/sata_uli.c | 2 | ||||
-rw-r--r-- | drivers/scsi/sata_via.c | 2 | ||||
-rw-r--r-- | drivers/scsi/sata_vsc.c | 2 |
20 files changed, 1054 insertions, 661 deletions
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index 81803a16f986..669ff6b99c4f 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile | |||
@@ -164,7 +164,7 @@ ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \ | |||
164 | CFLAGS_ncr53c8xx.o := $(ncr53c8xx-flags-y) $(ncr53c8xx-flags-m) | 164 | CFLAGS_ncr53c8xx.o := $(ncr53c8xx-flags-y) $(ncr53c8xx-flags-m) |
165 | zalon7xx-objs := zalon.o ncr53c8xx.o | 165 | zalon7xx-objs := zalon.o ncr53c8xx.o |
166 | NCR_Q720_mod-objs := NCR_Q720.o ncr53c8xx.o | 166 | NCR_Q720_mod-objs := NCR_Q720.o ncr53c8xx.o |
167 | libata-objs := libata-core.o libata-scsi.o libata-bmdma.o | 167 | libata-objs := libata-core.o libata-scsi.o libata-bmdma.o libata-eh.o |
168 | oktagon_esp_mod-objs := oktagon_esp.o oktagon_io.o | 168 | oktagon_esp_mod-objs := oktagon_esp.o oktagon_io.o |
169 | 169 | ||
170 | # Files generated that shall be removed upon make clean | 170 | # Files generated that shall be removed upon make clean |
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index b4f8fb1d628b..1b8429cb3c96 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c | |||
@@ -48,7 +48,7 @@ | |||
48 | #include <asm/io.h> | 48 | #include <asm/io.h> |
49 | 49 | ||
50 | #define DRV_NAME "ahci" | 50 | #define DRV_NAME "ahci" |
51 | #define DRV_VERSION "1.2" | 51 | #define DRV_VERSION "1.3" |
52 | 52 | ||
53 | 53 | ||
54 | enum { | 54 | enum { |
@@ -516,25 +516,7 @@ static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, u32 opts) | |||
516 | pp->cmd_slot[0].tbl_addr_hi = cpu_to_le32((pp->cmd_tbl_dma >> 16) >> 16); | 516 | pp->cmd_slot[0].tbl_addr_hi = cpu_to_le32((pp->cmd_tbl_dma >> 16) >> 16); |
517 | } | 517 | } |
518 | 518 | ||
519 | static int ahci_poll_register(void __iomem *reg, u32 mask, u32 val, | 519 | static int ahci_softreset(struct ata_port *ap, unsigned int *class) |
520 | unsigned long interval_msec, | ||
521 | unsigned long timeout_msec) | ||
522 | { | ||
523 | unsigned long timeout; | ||
524 | u32 tmp; | ||
525 | |||
526 | timeout = jiffies + (timeout_msec * HZ) / 1000; | ||
527 | do { | ||
528 | tmp = readl(reg); | ||
529 | if ((tmp & mask) == val) | ||
530 | return 0; | ||
531 | msleep(interval_msec); | ||
532 | } while (time_before(jiffies, timeout)); | ||
533 | |||
534 | return -1; | ||
535 | } | ||
536 | |||
537 | static int ahci_softreset(struct ata_port *ap, int verbose, unsigned int *class) | ||
538 | { | 520 | { |
539 | struct ahci_host_priv *hpriv = ap->host_set->private_data; | 521 | struct ahci_host_priv *hpriv = ap->host_set->private_data; |
540 | struct ahci_port_priv *pp = ap->private_data; | 522 | struct ahci_port_priv *pp = ap->private_data; |
@@ -543,11 +525,18 @@ static int ahci_softreset(struct ata_port *ap, int verbose, unsigned int *class) | |||
543 | const u32 cmd_fis_len = 5; /* five dwords */ | 525 | const u32 cmd_fis_len = 5; /* five dwords */ |
544 | const char *reason = NULL; | 526 | const char *reason = NULL; |
545 | struct ata_taskfile tf; | 527 | struct ata_taskfile tf; |
528 | u32 tmp; | ||
546 | u8 *fis; | 529 | u8 *fis; |
547 | int rc; | 530 | int rc; |
548 | 531 | ||
549 | DPRINTK("ENTER\n"); | 532 | DPRINTK("ENTER\n"); |
550 | 533 | ||
534 | if (!sata_dev_present(ap)) { | ||
535 | DPRINTK("PHY reports no device\n"); | ||
536 | *class = ATA_DEV_NONE; | ||
537 | return 0; | ||
538 | } | ||
539 | |||
551 | /* prepare for SRST (AHCI-1.1 10.4.1) */ | 540 | /* prepare for SRST (AHCI-1.1 10.4.1) */ |
552 | rc = ahci_stop_engine(ap); | 541 | rc = ahci_stop_engine(ap); |
553 | if (rc) { | 542 | if (rc) { |
@@ -558,8 +547,6 @@ static int ahci_softreset(struct ata_port *ap, int verbose, unsigned int *class) | |||
558 | /* check BUSY/DRQ, perform Command List Override if necessary */ | 547 | /* check BUSY/DRQ, perform Command List Override if necessary */ |
559 | ahci_tf_read(ap, &tf); | 548 | ahci_tf_read(ap, &tf); |
560 | if (tf.command & (ATA_BUSY | ATA_DRQ)) { | 549 | if (tf.command & (ATA_BUSY | ATA_DRQ)) { |
561 | u32 tmp; | ||
562 | |||
563 | if (!(hpriv->cap & HOST_CAP_CLO)) { | 550 | if (!(hpriv->cap & HOST_CAP_CLO)) { |
564 | rc = -EIO; | 551 | rc = -EIO; |
565 | reason = "port busy but no CLO"; | 552 | reason = "port busy but no CLO"; |
@@ -569,10 +556,10 @@ static int ahci_softreset(struct ata_port *ap, int verbose, unsigned int *class) | |||
569 | tmp = readl(port_mmio + PORT_CMD); | 556 | tmp = readl(port_mmio + PORT_CMD); |
570 | tmp |= PORT_CMD_CLO; | 557 | tmp |= PORT_CMD_CLO; |
571 | writel(tmp, port_mmio + PORT_CMD); | 558 | writel(tmp, port_mmio + PORT_CMD); |
572 | readl(port_mmio + PORT_CMD); /* flush */ | ||
573 | 559 | ||
574 | if (ahci_poll_register(port_mmio + PORT_CMD, PORT_CMD_CLO, 0x0, | 560 | tmp = ata_wait_register(port_mmio + PORT_CMD, |
575 | 1, 500)) { | 561 | PORT_CMD_CLO, PORT_CMD_CLO, 1, 500); |
562 | if (tmp & PORT_CMD_CLO) { | ||
576 | rc = -EIO; | 563 | rc = -EIO; |
577 | reason = "CLO failed"; | 564 | reason = "CLO failed"; |
578 | goto fail_restart; | 565 | goto fail_restart; |
@@ -593,9 +580,9 @@ static int ahci_softreset(struct ata_port *ap, int verbose, unsigned int *class) | |||
593 | fis[1] &= ~(1 << 7); /* turn off Command FIS bit */ | 580 | fis[1] &= ~(1 << 7); /* turn off Command FIS bit */ |
594 | 581 | ||
595 | writel(1, port_mmio + PORT_CMD_ISSUE); | 582 | writel(1, port_mmio + PORT_CMD_ISSUE); |
596 | readl(port_mmio + PORT_CMD_ISSUE); /* flush */ | ||
597 | 583 | ||
598 | if (ahci_poll_register(port_mmio + PORT_CMD_ISSUE, 0x1, 0x0, 1, 500)) { | 584 | tmp = ata_wait_register(port_mmio + PORT_CMD_ISSUE, 0x1, 0x1, 1, 500); |
585 | if (tmp & 0x1) { | ||
599 | rc = -EIO; | 586 | rc = -EIO; |
600 | reason = "1st FIS failed"; | 587 | reason = "1st FIS failed"; |
601 | goto fail; | 588 | goto fail; |
@@ -640,22 +627,19 @@ static int ahci_softreset(struct ata_port *ap, int verbose, unsigned int *class) | |||
640 | fail_restart: | 627 | fail_restart: |
641 | ahci_start_engine(ap); | 628 | ahci_start_engine(ap); |
642 | fail: | 629 | fail: |
643 | if (verbose) | 630 | printk(KERN_ERR "ata%u: softreset failed (%s)\n", |
644 | printk(KERN_ERR "ata%u: softreset failed (%s)\n", | 631 | ap->id, reason); |
645 | ap->id, reason); | ||
646 | else | ||
647 | DPRINTK("EXIT, rc=%d reason=\"%s\"\n", rc, reason); | ||
648 | return rc; | 632 | return rc; |
649 | } | 633 | } |
650 | 634 | ||
651 | static int ahci_hardreset(struct ata_port *ap, int verbose, unsigned int *class) | 635 | static int ahci_hardreset(struct ata_port *ap, unsigned int *class) |
652 | { | 636 | { |
653 | int rc; | 637 | int rc; |
654 | 638 | ||
655 | DPRINTK("ENTER\n"); | 639 | DPRINTK("ENTER\n"); |
656 | 640 | ||
657 | ahci_stop_engine(ap); | 641 | ahci_stop_engine(ap); |
658 | rc = sata_std_hardreset(ap, verbose, class); | 642 | rc = sata_std_hardreset(ap, class); |
659 | ahci_start_engine(ap); | 643 | ahci_start_engine(ap); |
660 | 644 | ||
661 | if (rc == 0) | 645 | if (rc == 0) |
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index 6dc88149f9f1..62dabf74188e 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c | |||
@@ -93,7 +93,7 @@ | |||
93 | #include <linux/libata.h> | 93 | #include <linux/libata.h> |
94 | 94 | ||
95 | #define DRV_NAME "ata_piix" | 95 | #define DRV_NAME "ata_piix" |
96 | #define DRV_VERSION "1.05" | 96 | #define DRV_VERSION "1.10" |
97 | 97 | ||
98 | enum { | 98 | enum { |
99 | PIIX_IOCFG = 0x54, /* IDE I/O configuration register */ | 99 | PIIX_IOCFG = 0x54, /* IDE I/O configuration register */ |
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index bd147207f25d..509178c3700c 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -65,7 +65,6 @@ static unsigned int ata_dev_init_params(struct ata_port *ap, | |||
65 | struct ata_device *dev, | 65 | struct ata_device *dev, |
66 | u16 heads, | 66 | u16 heads, |
67 | u16 sectors); | 67 | u16 sectors); |
68 | static void ata_set_mode(struct ata_port *ap); | ||
69 | static unsigned int ata_dev_set_xfermode(struct ata_port *ap, | 68 | static unsigned int ata_dev_set_xfermode(struct ata_port *ap, |
70 | struct ata_device *dev); | 69 | struct ata_device *dev); |
71 | static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev); | 70 | static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev); |
@@ -77,6 +76,10 @@ int atapi_enabled = 1; | |||
77 | module_param(atapi_enabled, int, 0444); | 76 | module_param(atapi_enabled, int, 0444); |
78 | MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)"); | 77 | MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)"); |
79 | 78 | ||
79 | int atapi_dmadir = 0; | ||
80 | module_param(atapi_dmadir, int, 0444); | ||
81 | MODULE_PARM_DESC(atapi_dmadir, "Enable ATAPI DMADIR bridge support (0=off, 1=on)"); | ||
82 | |||
80 | int libata_fua = 0; | 83 | int libata_fua = 0; |
81 | module_param_named(fua, libata_fua, int, 0444); | 84 | module_param_named(fua, libata_fua, int, 0444); |
82 | MODULE_PARM_DESC(fua, "FUA support (0=off, 1=on)"); | 85 | MODULE_PARM_DESC(fua, "FUA support (0=off, 1=on)"); |
@@ -397,9 +400,21 @@ static const char *ata_mode_string(unsigned int xfer_mask) | |||
397 | return "<n/a>"; | 400 | return "<n/a>"; |
398 | } | 401 | } |
399 | 402 | ||
400 | static void ata_dev_disable(struct ata_port *ap, struct ata_device *dev) | 403 | static const char *sata_spd_string(unsigned int spd) |
404 | { | ||
405 | static const char * const spd_str[] = { | ||
406 | "1.5 Gbps", | ||
407 | "3.0 Gbps", | ||
408 | }; | ||
409 | |||
410 | if (spd == 0 || (spd - 1) >= ARRAY_SIZE(spd_str)) | ||
411 | return "<unknown>"; | ||
412 | return spd_str[spd - 1]; | ||
413 | } | ||
414 | |||
415 | void ata_dev_disable(struct ata_port *ap, struct ata_device *dev) | ||
401 | { | 416 | { |
402 | if (ata_dev_present(dev)) { | 417 | if (ata_dev_enabled(dev)) { |
403 | printk(KERN_WARNING "ata%u: dev %u disabled\n", | 418 | printk(KERN_WARNING "ata%u: dev %u disabled\n", |
404 | ap->id, dev->devno); | 419 | ap->id, dev->devno); |
405 | dev->class++; | 420 | dev->class++; |
@@ -949,6 +964,7 @@ void ata_qc_complete_internal(struct ata_queued_cmd *qc) | |||
949 | * @ap: Port to which the command is sent | 964 | * @ap: Port to which the command is sent |
950 | * @dev: Device to which the command is sent | 965 | * @dev: Device to which the command is sent |
951 | * @tf: Taskfile registers for the command and the result | 966 | * @tf: Taskfile registers for the command and the result |
967 | * @cdb: CDB for packet command | ||
952 | * @dma_dir: Data tranfer direction of the command | 968 | * @dma_dir: Data tranfer direction of the command |
953 | * @buf: Data buffer of the command | 969 | * @buf: Data buffer of the command |
954 | * @buflen: Length of data buffer | 970 | * @buflen: Length of data buffer |
@@ -963,10 +979,9 @@ void ata_qc_complete_internal(struct ata_queued_cmd *qc) | |||
963 | * None. Should be called with kernel context, might sleep. | 979 | * None. Should be called with kernel context, might sleep. |
964 | */ | 980 | */ |
965 | 981 | ||
966 | static unsigned | 982 | unsigned ata_exec_internal(struct ata_port *ap, struct ata_device *dev, |
967 | ata_exec_internal(struct ata_port *ap, struct ata_device *dev, | 983 | struct ata_taskfile *tf, const u8 *cdb, |
968 | struct ata_taskfile *tf, | 984 | int dma_dir, void *buf, unsigned int buflen) |
969 | int dma_dir, void *buf, unsigned int buflen) | ||
970 | { | 985 | { |
971 | u8 command = tf->command; | 986 | u8 command = tf->command; |
972 | struct ata_queued_cmd *qc; | 987 | struct ata_queued_cmd *qc; |
@@ -980,6 +995,8 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev, | |||
980 | BUG_ON(qc == NULL); | 995 | BUG_ON(qc == NULL); |
981 | 996 | ||
982 | qc->tf = *tf; | 997 | qc->tf = *tf; |
998 | if (cdb) | ||
999 | memcpy(qc->cdb, cdb, ATAPI_CDB_LEN); | ||
983 | qc->dma_dir = dma_dir; | 1000 | qc->dma_dir = dma_dir; |
984 | if (dma_dir != DMA_NONE) { | 1001 | if (dma_dir != DMA_NONE) { |
985 | ata_sg_init_one(qc, buf, buflen); | 1002 | ata_sg_init_one(qc, buf, buflen); |
@@ -1030,7 +1047,7 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev, | |||
1030 | * | 1047 | * |
1031 | * Kill the following code as soon as those drivers are fixed. | 1048 | * Kill the following code as soon as those drivers are fixed. |
1032 | */ | 1049 | */ |
1033 | if (ap->flags & ATA_FLAG_PORT_DISABLED) { | 1050 | if (ap->flags & ATA_FLAG_DISABLED) { |
1034 | err_mask |= AC_ERR_SYSTEM; | 1051 | err_mask |= AC_ERR_SYSTEM; |
1035 | ata_port_probe(ap); | 1052 | ata_port_probe(ap); |
1036 | } | 1053 | } |
@@ -1129,7 +1146,7 @@ static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev, | |||
1129 | 1146 | ||
1130 | tf.protocol = ATA_PROT_PIO; | 1147 | tf.protocol = ATA_PROT_PIO; |
1131 | 1148 | ||
1132 | err_mask = ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE, | 1149 | err_mask = ata_exec_internal(ap, dev, &tf, NULL, DMA_FROM_DEVICE, |
1133 | id, sizeof(id[0]) * ATA_ID_WORDS); | 1150 | id, sizeof(id[0]) * ATA_ID_WORDS); |
1134 | if (err_mask) { | 1151 | if (err_mask) { |
1135 | rc = -EIO; | 1152 | rc = -EIO; |
@@ -1210,7 +1227,7 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev, | |||
1210 | unsigned int xfer_mask; | 1227 | unsigned int xfer_mask; |
1211 | int i, rc; | 1228 | int i, rc; |
1212 | 1229 | ||
1213 | if (!ata_dev_present(dev)) { | 1230 | if (!ata_dev_enabled(dev)) { |
1214 | DPRINTK("ENTER/EXIT (host %u, dev %u) -- nodev\n", | 1231 | DPRINTK("ENTER/EXIT (host %u, dev %u) -- nodev\n", |
1215 | ap->id, dev->devno); | 1232 | ap->id, dev->devno); |
1216 | return 0; | 1233 | return 0; |
@@ -1226,7 +1243,7 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev, | |||
1226 | id[84], id[85], id[86], id[87], id[88]); | 1243 | id[84], id[85], id[86], id[87], id[88]); |
1227 | 1244 | ||
1228 | /* initialize to-be-configured parameters */ | 1245 | /* initialize to-be-configured parameters */ |
1229 | dev->flags = 0; | 1246 | dev->flags &= ~ATA_DFLAG_CFG_MASK; |
1230 | dev->max_sectors = 0; | 1247 | dev->max_sectors = 0; |
1231 | dev->cdb_len = 0; | 1248 | dev->cdb_len = 0; |
1232 | dev->n_sectors = 0; | 1249 | dev->n_sectors = 0; |
@@ -1349,16 +1366,24 @@ err_out_nosup: | |||
1349 | * PCI/etc. bus probe sem. | 1366 | * PCI/etc. bus probe sem. |
1350 | * | 1367 | * |
1351 | * RETURNS: | 1368 | * RETURNS: |
1352 | * Zero on success, non-zero on error. | 1369 | * Zero on success, negative errno otherwise. |
1353 | */ | 1370 | */ |
1354 | 1371 | ||
1355 | static int ata_bus_probe(struct ata_port *ap) | 1372 | static int ata_bus_probe(struct ata_port *ap) |
1356 | { | 1373 | { |
1357 | unsigned int classes[ATA_MAX_DEVICES]; | 1374 | unsigned int classes[ATA_MAX_DEVICES]; |
1358 | unsigned int i, rc, found = 0; | 1375 | int tries[ATA_MAX_DEVICES]; |
1376 | int i, rc, down_xfermask; | ||
1377 | struct ata_device *dev; | ||
1359 | 1378 | ||
1360 | ata_port_probe(ap); | 1379 | ata_port_probe(ap); |
1361 | 1380 | ||
1381 | for (i = 0; i < ATA_MAX_DEVICES; i++) | ||
1382 | tries[i] = ATA_PROBE_MAX_TRIES; | ||
1383 | |||
1384 | retry: | ||
1385 | down_xfermask = 0; | ||
1386 | |||
1362 | /* reset and determine device classes */ | 1387 | /* reset and determine device classes */ |
1363 | for (i = 0; i < ATA_MAX_DEVICES; i++) | 1388 | for (i = 0; i < ATA_MAX_DEVICES; i++) |
1364 | classes[i] = ATA_DEV_UNKNOWN; | 1389 | classes[i] = ATA_DEV_UNKNOWN; |
@@ -1372,7 +1397,7 @@ static int ata_bus_probe(struct ata_port *ap) | |||
1372 | } else { | 1397 | } else { |
1373 | ap->ops->phy_reset(ap); | 1398 | ap->ops->phy_reset(ap); |
1374 | 1399 | ||
1375 | if (!(ap->flags & ATA_FLAG_PORT_DISABLED)) | 1400 | if (!(ap->flags & ATA_FLAG_DISABLED)) |
1376 | for (i = 0; i < ATA_MAX_DEVICES; i++) | 1401 | for (i = 0; i < ATA_MAX_DEVICES; i++) |
1377 | classes[i] = ap->device[i].class; | 1402 | classes[i] = ap->device[i].class; |
1378 | 1403 | ||
@@ -1385,43 +1410,76 @@ static int ata_bus_probe(struct ata_port *ap) | |||
1385 | 1410 | ||
1386 | /* read IDENTIFY page and configure devices */ | 1411 | /* read IDENTIFY page and configure devices */ |
1387 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 1412 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
1388 | struct ata_device *dev = &ap->device[i]; | 1413 | dev = &ap->device[i]; |
1389 | 1414 | ||
1390 | dev->class = classes[i]; | 1415 | if (tries[i]) |
1416 | dev->class = classes[i]; | ||
1391 | 1417 | ||
1392 | if (!ata_dev_present(dev)) | 1418 | if (!ata_dev_enabled(dev)) |
1393 | continue; | 1419 | continue; |
1394 | 1420 | ||
1395 | WARN_ON(dev->id != NULL); | 1421 | kfree(dev->id); |
1396 | if (ata_dev_read_id(ap, dev, &dev->class, 1, &dev->id)) { | 1422 | dev->id = NULL; |
1397 | dev->class = ATA_DEV_NONE; | 1423 | rc = ata_dev_read_id(ap, dev, &dev->class, 1, &dev->id); |
1398 | continue; | 1424 | if (rc) |
1399 | } | 1425 | goto fail; |
1400 | 1426 | ||
1401 | if (ata_dev_configure(ap, dev, 1)) { | 1427 | rc = ata_dev_configure(ap, dev, 1); |
1402 | ata_dev_disable(ap, dev); | 1428 | if (rc) |
1403 | continue; | 1429 | goto fail; |
1404 | } | 1430 | } |
1405 | 1431 | ||
1406 | found = 1; | 1432 | /* configure transfer mode */ |
1433 | if (ap->ops->set_mode) { | ||
1434 | /* FIXME: make ->set_mode handle no device case and | ||
1435 | * return error code and failing device on failure as | ||
1436 | * ata_set_mode() does. | ||
1437 | */ | ||
1438 | for (i = 0; i < ATA_MAX_DEVICES; i++) | ||
1439 | if (ata_dev_enabled(&ap->device[i])) { | ||
1440 | ap->ops->set_mode(ap); | ||
1441 | break; | ||
1442 | } | ||
1443 | rc = 0; | ||
1444 | } else | ||
1445 | rc = ata_set_mode(ap, &dev); | ||
1446 | |||
1447 | if (rc) { | ||
1448 | down_xfermask = 1; | ||
1449 | goto fail; | ||
1407 | } | 1450 | } |
1408 | 1451 | ||
1409 | if (!found) | 1452 | for (i = 0; i < ATA_MAX_DEVICES; i++) |
1410 | goto err_out_disable; | 1453 | if (ata_dev_enabled(&ap->device[i])) |
1454 | return 0; | ||
1411 | 1455 | ||
1412 | if (ap->ops->set_mode) | 1456 | /* no device present, disable port */ |
1413 | ap->ops->set_mode(ap); | 1457 | ata_port_disable(ap); |
1414 | else | 1458 | ap->ops->port_disable(ap); |
1415 | ata_set_mode(ap); | 1459 | return -ENODEV; |
1416 | 1460 | ||
1417 | if (ap->flags & ATA_FLAG_PORT_DISABLED) | 1461 | fail: |
1418 | goto err_out_disable; | 1462 | switch (rc) { |
1463 | case -EINVAL: | ||
1464 | case -ENODEV: | ||
1465 | tries[dev->devno] = 0; | ||
1466 | break; | ||
1467 | case -EIO: | ||
1468 | ata_down_sata_spd_limit(ap); | ||
1469 | /* fall through */ | ||
1470 | default: | ||
1471 | tries[dev->devno]--; | ||
1472 | if (down_xfermask && | ||
1473 | ata_down_xfermask_limit(ap, dev, tries[dev->devno] == 1)) | ||
1474 | tries[dev->devno] = 0; | ||
1475 | } | ||
1419 | 1476 | ||
1420 | return 0; | 1477 | if (!tries[dev->devno]) { |
1478 | ata_down_xfermask_limit(ap, dev, 1); | ||
1479 | ata_dev_disable(ap, dev); | ||
1480 | } | ||
1421 | 1481 | ||
1422 | err_out_disable: | 1482 | goto retry; |
1423 | ap->ops->port_disable(ap); | ||
1424 | return -1; | ||
1425 | } | 1483 | } |
1426 | 1484 | ||
1427 | /** | 1485 | /** |
@@ -1437,7 +1495,7 @@ err_out_disable: | |||
1437 | 1495 | ||
1438 | void ata_port_probe(struct ata_port *ap) | 1496 | void ata_port_probe(struct ata_port *ap) |
1439 | { | 1497 | { |
1440 | ap->flags &= ~ATA_FLAG_PORT_DISABLED; | 1498 | ap->flags &= ~ATA_FLAG_DISABLED; |
1441 | } | 1499 | } |
1442 | 1500 | ||
1443 | /** | 1501 | /** |
@@ -1451,27 +1509,23 @@ void ata_port_probe(struct ata_port *ap) | |||
1451 | */ | 1509 | */ |
1452 | static void sata_print_link_status(struct ata_port *ap) | 1510 | static void sata_print_link_status(struct ata_port *ap) |
1453 | { | 1511 | { |
1454 | u32 sstatus, tmp; | 1512 | u32 sstatus, scontrol, tmp; |
1455 | const char *speed; | ||
1456 | 1513 | ||
1457 | if (!ap->ops->scr_read) | 1514 | if (!ap->ops->scr_read) |
1458 | return; | 1515 | return; |
1459 | 1516 | ||
1460 | sstatus = scr_read(ap, SCR_STATUS); | 1517 | sstatus = scr_read(ap, SCR_STATUS); |
1518 | scontrol = scr_read(ap, SCR_CONTROL); | ||
1461 | 1519 | ||
1462 | if (sata_dev_present(ap)) { | 1520 | if (sata_dev_present(ap)) { |
1463 | tmp = (sstatus >> 4) & 0xf; | 1521 | tmp = (sstatus >> 4) & 0xf; |
1464 | if (tmp & (1 << 0)) | 1522 | printk(KERN_INFO |
1465 | speed = "1.5"; | 1523 | "ata%u: SATA link up %s (SStatus %X SControl %X)\n", |
1466 | else if (tmp & (1 << 1)) | 1524 | ap->id, sata_spd_string(tmp), sstatus, scontrol); |
1467 | speed = "3.0"; | ||
1468 | else | ||
1469 | speed = "<unknown>"; | ||
1470 | printk(KERN_INFO "ata%u: SATA link up %s Gbps (SStatus %X)\n", | ||
1471 | ap->id, speed, sstatus); | ||
1472 | } else { | 1525 | } else { |
1473 | printk(KERN_INFO "ata%u: SATA link down (SStatus %X)\n", | 1526 | printk(KERN_INFO |
1474 | ap->id, sstatus); | 1527 | "ata%u: SATA link down (SStatus %X SControl %X)\n", |
1528 | ap->id, sstatus, scontrol); | ||
1475 | } | 1529 | } |
1476 | } | 1530 | } |
1477 | 1531 | ||
@@ -1518,7 +1572,7 @@ void __sata_phy_reset(struct ata_port *ap) | |||
1518 | else | 1572 | else |
1519 | ata_port_disable(ap); | 1573 | ata_port_disable(ap); |
1520 | 1574 | ||
1521 | if (ap->flags & ATA_FLAG_PORT_DISABLED) | 1575 | if (ap->flags & ATA_FLAG_DISABLED) |
1522 | return; | 1576 | return; |
1523 | 1577 | ||
1524 | if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) { | 1578 | if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) { |
@@ -1543,7 +1597,7 @@ void __sata_phy_reset(struct ata_port *ap) | |||
1543 | void sata_phy_reset(struct ata_port *ap) | 1597 | void sata_phy_reset(struct ata_port *ap) |
1544 | { | 1598 | { |
1545 | __sata_phy_reset(ap); | 1599 | __sata_phy_reset(ap); |
1546 | if (ap->flags & ATA_FLAG_PORT_DISABLED) | 1600 | if (ap->flags & ATA_FLAG_DISABLED) |
1547 | return; | 1601 | return; |
1548 | ata_bus_reset(ap); | 1602 | ata_bus_reset(ap); |
1549 | } | 1603 | } |
@@ -1560,7 +1614,7 @@ void sata_phy_reset(struct ata_port *ap) | |||
1560 | struct ata_device *ata_dev_pair(struct ata_port *ap, struct ata_device *adev) | 1614 | struct ata_device *ata_dev_pair(struct ata_port *ap, struct ata_device *adev) |
1561 | { | 1615 | { |
1562 | struct ata_device *pair = &ap->device[1 - adev->devno]; | 1616 | struct ata_device *pair = &ap->device[1 - adev->devno]; |
1563 | if (!ata_dev_present(pair)) | 1617 | if (!ata_dev_enabled(pair)) |
1564 | return NULL; | 1618 | return NULL; |
1565 | return pair; | 1619 | return pair; |
1566 | } | 1620 | } |
@@ -1582,7 +1636,121 @@ void ata_port_disable(struct ata_port *ap) | |||
1582 | { | 1636 | { |
1583 | ap->device[0].class = ATA_DEV_NONE; | 1637 | ap->device[0].class = ATA_DEV_NONE; |
1584 | ap->device[1].class = ATA_DEV_NONE; | 1638 | ap->device[1].class = ATA_DEV_NONE; |
1585 | ap->flags |= ATA_FLAG_PORT_DISABLED; | 1639 | ap->flags |= ATA_FLAG_DISABLED; |
1640 | } | ||
1641 | |||
1642 | /** | ||
1643 | * ata_down_sata_spd_limit - adjust SATA spd limit downward | ||
1644 | * @ap: Port to adjust SATA spd limit for | ||
1645 | * | ||
1646 | * Adjust SATA spd limit of @ap downward. Note that this | ||
1647 | * function only adjusts the limit. The change must be applied | ||
1648 | * using ata_set_sata_spd(). | ||
1649 | * | ||
1650 | * LOCKING: | ||
1651 | * Inherited from caller. | ||
1652 | * | ||
1653 | * RETURNS: | ||
1654 | * 0 on success, negative errno on failure | ||
1655 | */ | ||
1656 | int ata_down_sata_spd_limit(struct ata_port *ap) | ||
1657 | { | ||
1658 | u32 spd, mask; | ||
1659 | int highbit; | ||
1660 | |||
1661 | if (ap->cbl != ATA_CBL_SATA || !ap->ops->scr_read) | ||
1662 | return -EOPNOTSUPP; | ||
1663 | |||
1664 | mask = ap->sata_spd_limit; | ||
1665 | if (mask <= 1) | ||
1666 | return -EINVAL; | ||
1667 | highbit = fls(mask) - 1; | ||
1668 | mask &= ~(1 << highbit); | ||
1669 | |||
1670 | spd = (scr_read(ap, SCR_STATUS) >> 4) & 0xf; | ||
1671 | if (spd <= 1) | ||
1672 | return -EINVAL; | ||
1673 | spd--; | ||
1674 | mask &= (1 << spd) - 1; | ||
1675 | if (!mask) | ||
1676 | return -EINVAL; | ||
1677 | |||
1678 | ap->sata_spd_limit = mask; | ||
1679 | |||
1680 | printk(KERN_WARNING "ata%u: limiting SATA link speed to %s\n", | ||
1681 | ap->id, sata_spd_string(fls(mask))); | ||
1682 | |||
1683 | return 0; | ||
1684 | } | ||
1685 | |||
1686 | static int __ata_set_sata_spd_needed(struct ata_port *ap, u32 *scontrol) | ||
1687 | { | ||
1688 | u32 spd, limit; | ||
1689 | |||
1690 | if (ap->sata_spd_limit == UINT_MAX) | ||
1691 | limit = 0; | ||
1692 | else | ||
1693 | limit = fls(ap->sata_spd_limit); | ||
1694 | |||
1695 | spd = (*scontrol >> 4) & 0xf; | ||
1696 | *scontrol = (*scontrol & ~0xf0) | ((limit & 0xf) << 4); | ||
1697 | |||
1698 | return spd != limit; | ||
1699 | } | ||
1700 | |||
1701 | /** | ||
1702 | * ata_set_sata_spd_needed - is SATA spd configuration needed | ||
1703 | * @ap: Port in question | ||
1704 | * | ||
1705 | * Test whether the spd limit in SControl matches | ||
1706 | * @ap->sata_spd_limit. This function is used to determine | ||
1707 | * whether hardreset is necessary to apply SATA spd | ||
1708 | * configuration. | ||
1709 | * | ||
1710 | * LOCKING: | ||
1711 | * Inherited from caller. | ||
1712 | * | ||
1713 | * RETURNS: | ||
1714 | * 1 if SATA spd configuration is needed, 0 otherwise. | ||
1715 | */ | ||
1716 | int ata_set_sata_spd_needed(struct ata_port *ap) | ||
1717 | { | ||
1718 | u32 scontrol; | ||
1719 | |||
1720 | if (ap->cbl != ATA_CBL_SATA || !ap->ops->scr_read) | ||
1721 | return 0; | ||
1722 | |||
1723 | scontrol = scr_read(ap, SCR_CONTROL); | ||
1724 | |||
1725 | return __ata_set_sata_spd_needed(ap, &scontrol); | ||
1726 | } | ||
1727 | |||
1728 | /** | ||
1729 | * ata_set_sata_spd - set SATA spd according to spd limit | ||
1730 | * @ap: Port to set SATA spd for | ||
1731 | * | ||
1732 | * Set SATA spd of @ap according to sata_spd_limit. | ||
1733 | * | ||
1734 | * LOCKING: | ||
1735 | * Inherited from caller. | ||
1736 | * | ||
1737 | * RETURNS: | ||
1738 | * 0 if spd doesn't need to be changed, 1 if spd has been | ||
1739 | * changed. -EOPNOTSUPP if SCR registers are inaccessible. | ||
1740 | */ | ||
1741 | int ata_set_sata_spd(struct ata_port *ap) | ||
1742 | { | ||
1743 | u32 scontrol; | ||
1744 | |||
1745 | if (ap->cbl != ATA_CBL_SATA || !ap->ops->scr_read) | ||
1746 | return -EOPNOTSUPP; | ||
1747 | |||
1748 | scontrol = scr_read(ap, SCR_CONTROL); | ||
1749 | if (!__ata_set_sata_spd_needed(ap, &scontrol)) | ||
1750 | return 0; | ||
1751 | |||
1752 | scr_write(ap, SCR_CONTROL, scontrol); | ||
1753 | return 1; | ||
1586 | } | 1754 | } |
1587 | 1755 | ||
1588 | /* | 1756 | /* |
@@ -1733,11 +1901,62 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed, | |||
1733 | return 0; | 1901 | return 0; |
1734 | } | 1902 | } |
1735 | 1903 | ||
1904 | /** | ||
1905 | * ata_down_xfermask_limit - adjust dev xfer masks downward | ||
1906 | * @ap: Port associated with device @dev | ||
1907 | * @dev: Device to adjust xfer masks | ||
1908 | * @force_pio0: Force PIO0 | ||
1909 | * | ||
1910 | * Adjust xfer masks of @dev downward. Note that this function | ||
1911 | * does not apply the change. Invoking ata_set_mode() afterwards | ||
1912 | * will apply the limit. | ||
1913 | * | ||
1914 | * LOCKING: | ||
1915 | * Inherited from caller. | ||
1916 | * | ||
1917 | * RETURNS: | ||
1918 | * 0 on success, negative errno on failure | ||
1919 | */ | ||
1920 | int ata_down_xfermask_limit(struct ata_port *ap, struct ata_device *dev, | ||
1921 | int force_pio0) | ||
1922 | { | ||
1923 | unsigned long xfer_mask; | ||
1924 | int highbit; | ||
1925 | |||
1926 | xfer_mask = ata_pack_xfermask(dev->pio_mask, dev->mwdma_mask, | ||
1927 | dev->udma_mask); | ||
1928 | |||
1929 | if (!xfer_mask) | ||
1930 | goto fail; | ||
1931 | /* don't gear down to MWDMA from UDMA, go directly to PIO */ | ||
1932 | if (xfer_mask & ATA_MASK_UDMA) | ||
1933 | xfer_mask &= ~ATA_MASK_MWDMA; | ||
1934 | |||
1935 | highbit = fls(xfer_mask) - 1; | ||
1936 | xfer_mask &= ~(1 << highbit); | ||
1937 | if (force_pio0) | ||
1938 | xfer_mask &= 1 << ATA_SHIFT_PIO; | ||
1939 | if (!xfer_mask) | ||
1940 | goto fail; | ||
1941 | |||
1942 | ata_unpack_xfermask(xfer_mask, &dev->pio_mask, &dev->mwdma_mask, | ||
1943 | &dev->udma_mask); | ||
1944 | |||
1945 | printk(KERN_WARNING "ata%u: dev %u limiting speed to %s\n", | ||
1946 | ap->id, dev->devno, ata_mode_string(xfer_mask)); | ||
1947 | |||
1948 | return 0; | ||
1949 | |||
1950 | fail: | ||
1951 | return -EINVAL; | ||
1952 | } | ||
1953 | |||
1736 | static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev) | 1954 | static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev) |
1737 | { | 1955 | { |
1738 | unsigned int err_mask; | 1956 | unsigned int err_mask; |
1739 | int rc; | 1957 | int rc; |
1740 | 1958 | ||
1959 | dev->flags &= ~ATA_DFLAG_PIO; | ||
1741 | if (dev->xfer_shift == ATA_SHIFT_PIO) | 1960 | if (dev->xfer_shift == ATA_SHIFT_PIO) |
1742 | dev->flags |= ATA_DFLAG_PIO; | 1961 | dev->flags |= ATA_DFLAG_PIO; |
1743 | 1962 | ||
@@ -1750,12 +1969,8 @@ static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev) | |||
1750 | } | 1969 | } |
1751 | 1970 | ||
1752 | rc = ata_dev_revalidate(ap, dev, 0); | 1971 | rc = ata_dev_revalidate(ap, dev, 0); |
1753 | if (rc) { | 1972 | if (rc) |
1754 | printk(KERN_ERR | ||
1755 | "ata%u: failed to revalidate after set xfermode\n", | ||
1756 | ap->id); | ||
1757 | return rc; | 1973 | return rc; |
1758 | } | ||
1759 | 1974 | ||
1760 | DPRINTK("xfer_shift=%u, xfer_mode=0x%x\n", | 1975 | DPRINTK("xfer_shift=%u, xfer_mode=0x%x\n", |
1761 | dev->xfer_shift, (int)dev->xfer_mode); | 1976 | dev->xfer_shift, (int)dev->xfer_mode); |
@@ -1766,118 +1981,107 @@ static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev) | |||
1766 | return 0; | 1981 | return 0; |
1767 | } | 1982 | } |
1768 | 1983 | ||
1769 | static int ata_host_set_pio(struct ata_port *ap) | ||
1770 | { | ||
1771 | int i; | ||
1772 | |||
1773 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | ||
1774 | struct ata_device *dev = &ap->device[i]; | ||
1775 | |||
1776 | if (!ata_dev_present(dev)) | ||
1777 | continue; | ||
1778 | |||
1779 | if (!dev->pio_mode) { | ||
1780 | printk(KERN_WARNING "ata%u: no PIO support for device %d.\n", ap->id, i); | ||
1781 | return -1; | ||
1782 | } | ||
1783 | |||
1784 | dev->xfer_mode = dev->pio_mode; | ||
1785 | dev->xfer_shift = ATA_SHIFT_PIO; | ||
1786 | if (ap->ops->set_piomode) | ||
1787 | ap->ops->set_piomode(ap, dev); | ||
1788 | } | ||
1789 | |||
1790 | return 0; | ||
1791 | } | ||
1792 | |||
1793 | static void ata_host_set_dma(struct ata_port *ap) | ||
1794 | { | ||
1795 | int i; | ||
1796 | |||
1797 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | ||
1798 | struct ata_device *dev = &ap->device[i]; | ||
1799 | |||
1800 | if (!ata_dev_present(dev) || !dev->dma_mode) | ||
1801 | continue; | ||
1802 | |||
1803 | dev->xfer_mode = dev->dma_mode; | ||
1804 | dev->xfer_shift = ata_xfer_mode2shift(dev->dma_mode); | ||
1805 | if (ap->ops->set_dmamode) | ||
1806 | ap->ops->set_dmamode(ap, dev); | ||
1807 | } | ||
1808 | } | ||
1809 | |||
1810 | /** | 1984 | /** |
1811 | * ata_set_mode - Program timings and issue SET FEATURES - XFER | 1985 | * ata_set_mode - Program timings and issue SET FEATURES - XFER |
1812 | * @ap: port on which timings will be programmed | 1986 | * @ap: port on which timings will be programmed |
1987 | * @r_failed_dev: out paramter for failed device | ||
1813 | * | 1988 | * |
1814 | * Set ATA device disk transfer mode (PIO3, UDMA6, etc.). | 1989 | * Set ATA device disk transfer mode (PIO3, UDMA6, etc.). If |
1990 | * ata_set_mode() fails, pointer to the failing device is | ||
1991 | * returned in @r_failed_dev. | ||
1815 | * | 1992 | * |
1816 | * LOCKING: | 1993 | * LOCKING: |
1817 | * PCI/etc. bus probe sem. | 1994 | * PCI/etc. bus probe sem. |
1995 | * | ||
1996 | * RETURNS: | ||
1997 | * 0 on success, negative errno otherwise | ||
1818 | */ | 1998 | */ |
1819 | static void ata_set_mode(struct ata_port *ap) | 1999 | int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) |
1820 | { | 2000 | { |
1821 | int i, rc, used_dma = 0; | 2001 | struct ata_device *dev; |
2002 | int i, rc = 0, used_dma = 0, found = 0; | ||
1822 | 2003 | ||
1823 | /* step 1: calculate xfer_mask */ | 2004 | /* step 1: calculate xfer_mask */ |
1824 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 2005 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
1825 | struct ata_device *dev = &ap->device[i]; | ||
1826 | unsigned int pio_mask, dma_mask; | 2006 | unsigned int pio_mask, dma_mask; |
1827 | 2007 | ||
1828 | if (!ata_dev_present(dev)) | 2008 | dev = &ap->device[i]; |
2009 | |||
2010 | if (!ata_dev_enabled(dev)) | ||
1829 | continue; | 2011 | continue; |
1830 | 2012 | ||
1831 | ata_dev_xfermask(ap, dev); | 2013 | ata_dev_xfermask(ap, dev); |
1832 | 2014 | ||
1833 | /* TODO: let LLDD filter dev->*_mask here */ | ||
1834 | |||
1835 | pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0); | 2015 | pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0); |
1836 | dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask); | 2016 | dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask); |
1837 | dev->pio_mode = ata_xfer_mask2mode(pio_mask); | 2017 | dev->pio_mode = ata_xfer_mask2mode(pio_mask); |
1838 | dev->dma_mode = ata_xfer_mask2mode(dma_mask); | 2018 | dev->dma_mode = ata_xfer_mask2mode(dma_mask); |
1839 | 2019 | ||
2020 | found = 1; | ||
1840 | if (dev->dma_mode) | 2021 | if (dev->dma_mode) |
1841 | used_dma = 1; | 2022 | used_dma = 1; |
1842 | } | 2023 | } |
2024 | if (!found) | ||
2025 | goto out; | ||
1843 | 2026 | ||
1844 | /* step 2: always set host PIO timings */ | 2027 | /* step 2: always set host PIO timings */ |
1845 | rc = ata_host_set_pio(ap); | 2028 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
1846 | if (rc) | 2029 | dev = &ap->device[i]; |
1847 | goto err_out; | 2030 | if (!ata_dev_enabled(dev)) |
2031 | continue; | ||
2032 | |||
2033 | if (!dev->pio_mode) { | ||
2034 | printk(KERN_WARNING "ata%u: dev %u no PIO support\n", | ||
2035 | ap->id, dev->devno); | ||
2036 | rc = -EINVAL; | ||
2037 | goto out; | ||
2038 | } | ||
2039 | |||
2040 | dev->xfer_mode = dev->pio_mode; | ||
2041 | dev->xfer_shift = ATA_SHIFT_PIO; | ||
2042 | if (ap->ops->set_piomode) | ||
2043 | ap->ops->set_piomode(ap, dev); | ||
2044 | } | ||
1848 | 2045 | ||
1849 | /* step 3: set host DMA timings */ | 2046 | /* step 3: set host DMA timings */ |
1850 | ata_host_set_dma(ap); | 2047 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
2048 | dev = &ap->device[i]; | ||
2049 | |||
2050 | if (!ata_dev_enabled(dev) || !dev->dma_mode) | ||
2051 | continue; | ||
2052 | |||
2053 | dev->xfer_mode = dev->dma_mode; | ||
2054 | dev->xfer_shift = ata_xfer_mode2shift(dev->dma_mode); | ||
2055 | if (ap->ops->set_dmamode) | ||
2056 | ap->ops->set_dmamode(ap, dev); | ||
2057 | } | ||
1851 | 2058 | ||
1852 | /* step 4: update devices' xfer mode */ | 2059 | /* step 4: update devices' xfer mode */ |
1853 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 2060 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
1854 | struct ata_device *dev = &ap->device[i]; | 2061 | dev = &ap->device[i]; |
1855 | 2062 | ||
1856 | if (!ata_dev_present(dev)) | 2063 | if (!ata_dev_enabled(dev)) |
1857 | continue; | 2064 | continue; |
1858 | 2065 | ||
1859 | if (ata_dev_set_mode(ap, dev)) | 2066 | rc = ata_dev_set_mode(ap, dev); |
1860 | goto err_out; | 2067 | if (rc) |
2068 | goto out; | ||
1861 | } | 2069 | } |
1862 | 2070 | ||
1863 | /* | 2071 | /* Record simplex status. If we selected DMA then the other |
1864 | * Record simplex status. If we selected DMA then the other | 2072 | * host channels are not permitted to do so. |
1865 | * host channels are not permitted to do so. | ||
1866 | */ | 2073 | */ |
1867 | |||
1868 | if (used_dma && (ap->host_set->flags & ATA_HOST_SIMPLEX)) | 2074 | if (used_dma && (ap->host_set->flags & ATA_HOST_SIMPLEX)) |
1869 | ap->host_set->simplex_claimed = 1; | 2075 | ap->host_set->simplex_claimed = 1; |
1870 | 2076 | ||
1871 | /* | 2077 | /* step5: chip specific finalisation */ |
1872 | * Chip specific finalisation | ||
1873 | */ | ||
1874 | if (ap->ops->post_set_mode) | 2078 | if (ap->ops->post_set_mode) |
1875 | ap->ops->post_set_mode(ap); | 2079 | ap->ops->post_set_mode(ap); |
1876 | 2080 | ||
1877 | return; | 2081 | out: |
1878 | 2082 | if (rc) | |
1879 | err_out: | 2083 | *r_failed_dev = dev; |
1880 | ata_port_disable(ap); | 2084 | return rc; |
1881 | } | 2085 | } |
1882 | 2086 | ||
1883 | /** | 2087 | /** |
@@ -2030,8 +2234,10 @@ static unsigned int ata_bus_softreset(struct ata_port *ap, | |||
2030 | * the bus shows 0xFF because the odd clown forgets the D7 | 2234 | * the bus shows 0xFF because the odd clown forgets the D7 |
2031 | * pulldown resistor. | 2235 | * pulldown resistor. |
2032 | */ | 2236 | */ |
2033 | if (ata_check_status(ap) == 0xFF) | 2237 | if (ata_check_status(ap) == 0xFF) { |
2238 | printk(KERN_ERR "ata%u: SRST failed (status 0xFF)\n", ap->id); | ||
2034 | return AC_ERR_OTHER; | 2239 | return AC_ERR_OTHER; |
2240 | } | ||
2035 | 2241 | ||
2036 | ata_bus_post_reset(ap, devmask); | 2242 | ata_bus_post_reset(ap, devmask); |
2037 | 2243 | ||
@@ -2055,7 +2261,7 @@ static unsigned int ata_bus_softreset(struct ata_port *ap, | |||
2055 | * Obtains host_set lock. | 2261 | * Obtains host_set lock. |
2056 | * | 2262 | * |
2057 | * SIDE EFFECTS: | 2263 | * SIDE EFFECTS: |
2058 | * Sets ATA_FLAG_PORT_DISABLED if bus reset fails. | 2264 | * Sets ATA_FLAG_DISABLED if bus reset fails. |
2059 | */ | 2265 | */ |
2060 | 2266 | ||
2061 | void ata_bus_reset(struct ata_port *ap) | 2267 | void ata_bus_reset(struct ata_port *ap) |
@@ -2132,9 +2338,11 @@ err_out: | |||
2132 | static int sata_phy_resume(struct ata_port *ap) | 2338 | static int sata_phy_resume(struct ata_port *ap) |
2133 | { | 2339 | { |
2134 | unsigned long timeout = jiffies + (HZ * 5); | 2340 | unsigned long timeout = jiffies + (HZ * 5); |
2135 | u32 sstatus; | 2341 | u32 scontrol, sstatus; |
2136 | 2342 | ||
2137 | scr_write_flush(ap, SCR_CONTROL, 0x300); | 2343 | scontrol = scr_read(ap, SCR_CONTROL); |
2344 | scontrol = (scontrol & 0x0f0) | 0x300; | ||
2345 | scr_write_flush(ap, SCR_CONTROL, scontrol); | ||
2138 | 2346 | ||
2139 | /* Wait for phy to become ready, if necessary. */ | 2347 | /* Wait for phy to become ready, if necessary. */ |
2140 | do { | 2348 | do { |
@@ -2163,7 +2371,18 @@ static int sata_phy_resume(struct ata_port *ap) | |||
2163 | void ata_std_probeinit(struct ata_port *ap) | 2371 | void ata_std_probeinit(struct ata_port *ap) |
2164 | { | 2372 | { |
2165 | if ((ap->flags & ATA_FLAG_SATA) && ap->ops->scr_read) { | 2373 | if ((ap->flags & ATA_FLAG_SATA) && ap->ops->scr_read) { |
2374 | u32 spd; | ||
2375 | |||
2376 | /* set cable type and resume link */ | ||
2377 | ap->cbl = ATA_CBL_SATA; | ||
2166 | sata_phy_resume(ap); | 2378 | sata_phy_resume(ap); |
2379 | |||
2380 | /* init sata_spd_limit to the current value */ | ||
2381 | spd = (scr_read(ap, SCR_CONTROL) & 0xf0) >> 4; | ||
2382 | if (spd) | ||
2383 | ap->sata_spd_limit &= (1 << spd) - 1; | ||
2384 | |||
2385 | /* wait for device */ | ||
2167 | if (sata_dev_present(ap)) | 2386 | if (sata_dev_present(ap)) |
2168 | ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); | 2387 | ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); |
2169 | } | 2388 | } |
@@ -2172,7 +2391,6 @@ void ata_std_probeinit(struct ata_port *ap) | |||
2172 | /** | 2391 | /** |
2173 | * ata_std_softreset - reset host port via ATA SRST | 2392 | * ata_std_softreset - reset host port via ATA SRST |
2174 | * @ap: port to reset | 2393 | * @ap: port to reset |
2175 | * @verbose: fail verbosely | ||
2176 | * @classes: resulting classes of attached devices | 2394 | * @classes: resulting classes of attached devices |
2177 | * | 2395 | * |
2178 | * Reset host port using ATA SRST. This function is to be used | 2396 | * Reset host port using ATA SRST. This function is to be used |
@@ -2184,7 +2402,7 @@ void ata_std_probeinit(struct ata_port *ap) | |||
2184 | * RETURNS: | 2402 | * RETURNS: |
2185 | * 0 on success, -errno otherwise. | 2403 | * 0 on success, -errno otherwise. |
2186 | */ | 2404 | */ |
2187 | int ata_std_softreset(struct ata_port *ap, int verbose, unsigned int *classes) | 2405 | int ata_std_softreset(struct ata_port *ap, unsigned int *classes) |
2188 | { | 2406 | { |
2189 | unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; | 2407 | unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; |
2190 | unsigned int devmask = 0, err_mask; | 2408 | unsigned int devmask = 0, err_mask; |
@@ -2210,12 +2428,8 @@ int ata_std_softreset(struct ata_port *ap, int verbose, unsigned int *classes) | |||
2210 | DPRINTK("about to softreset, devmask=%x\n", devmask); | 2428 | DPRINTK("about to softreset, devmask=%x\n", devmask); |
2211 | err_mask = ata_bus_softreset(ap, devmask); | 2429 | err_mask = ata_bus_softreset(ap, devmask); |
2212 | if (err_mask) { | 2430 | if (err_mask) { |
2213 | if (verbose) | 2431 | printk(KERN_ERR "ata%u: SRST failed (err_mask=0x%x)\n", |
2214 | printk(KERN_ERR "ata%u: SRST failed (err_mask=0x%x)\n", | 2432 | ap->id, err_mask); |
2215 | ap->id, err_mask); | ||
2216 | else | ||
2217 | DPRINTK("EXIT, softreset failed (err_mask=0x%x)\n", | ||
2218 | err_mask); | ||
2219 | return -EIO; | 2433 | return -EIO; |
2220 | } | 2434 | } |
2221 | 2435 | ||
@@ -2232,7 +2446,6 @@ int ata_std_softreset(struct ata_port *ap, int verbose, unsigned int *classes) | |||
2232 | /** | 2446 | /** |
2233 | * sata_std_hardreset - reset host port via SATA phy reset | 2447 | * sata_std_hardreset - reset host port via SATA phy reset |
2234 | * @ap: port to reset | 2448 | * @ap: port to reset |
2235 | * @verbose: fail verbosely | ||
2236 | * @class: resulting class of attached device | 2449 | * @class: resulting class of attached device |
2237 | * | 2450 | * |
2238 | * SATA phy-reset host port using DET bits of SControl register. | 2451 | * SATA phy-reset host port using DET bits of SControl register. |
@@ -2245,20 +2458,36 @@ int ata_std_softreset(struct ata_port *ap, int verbose, unsigned int *classes) | |||
2245 | * RETURNS: | 2458 | * RETURNS: |
2246 | * 0 on success, -errno otherwise. | 2459 | * 0 on success, -errno otherwise. |
2247 | */ | 2460 | */ |
2248 | int sata_std_hardreset(struct ata_port *ap, int verbose, unsigned int *class) | 2461 | int sata_std_hardreset(struct ata_port *ap, unsigned int *class) |
2249 | { | 2462 | { |
2463 | u32 scontrol; | ||
2464 | |||
2250 | DPRINTK("ENTER\n"); | 2465 | DPRINTK("ENTER\n"); |
2251 | 2466 | ||
2252 | /* Issue phy wake/reset */ | 2467 | if (ata_set_sata_spd_needed(ap)) { |
2253 | scr_write_flush(ap, SCR_CONTROL, 0x301); | 2468 | /* SATA spec says nothing about how to reconfigure |
2469 | * spd. To be on the safe side, turn off phy during | ||
2470 | * reconfiguration. This works for at least ICH7 AHCI | ||
2471 | * and Sil3124. | ||
2472 | */ | ||
2473 | scontrol = scr_read(ap, SCR_CONTROL); | ||
2474 | scontrol = (scontrol & 0x0f0) | 0x302; | ||
2475 | scr_write_flush(ap, SCR_CONTROL, scontrol); | ||
2476 | |||
2477 | ata_set_sata_spd(ap); | ||
2478 | } | ||
2254 | 2479 | ||
2255 | /* | 2480 | /* issue phy wake/reset */ |
2256 | * Couldn't find anything in SATA I/II specs, but AHCI-1.1 | 2481 | scontrol = scr_read(ap, SCR_CONTROL); |
2482 | scontrol = (scontrol & 0x0f0) | 0x301; | ||
2483 | scr_write_flush(ap, SCR_CONTROL, scontrol); | ||
2484 | |||
2485 | /* Couldn't find anything in SATA I/II specs, but AHCI-1.1 | ||
2257 | * 10.4.2 says at least 1 ms. | 2486 | * 10.4.2 says at least 1 ms. |
2258 | */ | 2487 | */ |
2259 | msleep(1); | 2488 | msleep(1); |
2260 | 2489 | ||
2261 | /* Bring phy back */ | 2490 | /* bring phy back */ |
2262 | sata_phy_resume(ap); | 2491 | sata_phy_resume(ap); |
2263 | 2492 | ||
2264 | /* TODO: phy layer with polling, timeouts, etc. */ | 2493 | /* TODO: phy layer with polling, timeouts, etc. */ |
@@ -2269,11 +2498,8 @@ int sata_std_hardreset(struct ata_port *ap, int verbose, unsigned int *class) | |||
2269 | } | 2498 | } |
2270 | 2499 | ||
2271 | if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) { | 2500 | if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) { |
2272 | if (verbose) | 2501 | printk(KERN_ERR |
2273 | printk(KERN_ERR "ata%u: COMRESET failed " | 2502 | "ata%u: COMRESET failed (device not ready)\n", ap->id); |
2274 | "(device not ready)\n", ap->id); | ||
2275 | else | ||
2276 | DPRINTK("EXIT, device not ready\n"); | ||
2277 | return -EIO; | 2503 | return -EIO; |
2278 | } | 2504 | } |
2279 | 2505 | ||
@@ -2304,10 +2530,6 @@ void ata_std_postreset(struct ata_port *ap, unsigned int *classes) | |||
2304 | { | 2530 | { |
2305 | DPRINTK("ENTER\n"); | 2531 | DPRINTK("ENTER\n"); |
2306 | 2532 | ||
2307 | /* set cable type if it isn't already set */ | ||
2308 | if (ap->cbl == ATA_CBL_NONE && ap->flags & ATA_FLAG_SATA) | ||
2309 | ap->cbl = ATA_CBL_SATA; | ||
2310 | |||
2311 | /* print link status */ | 2533 | /* print link status */ |
2312 | if (ap->cbl == ATA_CBL_SATA) | 2534 | if (ap->cbl == ATA_CBL_SATA) |
2313 | sata_print_link_status(ap); | 2535 | sata_print_link_status(ap); |
@@ -2357,7 +2579,7 @@ int ata_std_probe_reset(struct ata_port *ap, unsigned int *classes) | |||
2357 | ata_reset_fn_t hardreset; | 2579 | ata_reset_fn_t hardreset; |
2358 | 2580 | ||
2359 | hardreset = NULL; | 2581 | hardreset = NULL; |
2360 | if (ap->flags & ATA_FLAG_SATA && ap->ops->scr_read) | 2582 | if (ap->cbl == ATA_CBL_SATA && ap->ops->scr_read) |
2361 | hardreset = sata_std_hardreset; | 2583 | hardreset = sata_std_hardreset; |
2362 | 2584 | ||
2363 | return ata_drive_probe_reset(ap, ata_std_probeinit, | 2585 | return ata_drive_probe_reset(ap, ata_std_probeinit, |
@@ -2365,16 +2587,15 @@ int ata_std_probe_reset(struct ata_port *ap, unsigned int *classes) | |||
2365 | ata_std_postreset, classes); | 2587 | ata_std_postreset, classes); |
2366 | } | 2588 | } |
2367 | 2589 | ||
2368 | static int do_probe_reset(struct ata_port *ap, ata_reset_fn_t reset, | 2590 | int ata_do_reset(struct ata_port *ap, ata_reset_fn_t reset, |
2369 | ata_postreset_fn_t postreset, | 2591 | ata_postreset_fn_t postreset, unsigned int *classes) |
2370 | unsigned int *classes) | ||
2371 | { | 2592 | { |
2372 | int i, rc; | 2593 | int i, rc; |
2373 | 2594 | ||
2374 | for (i = 0; i < ATA_MAX_DEVICES; i++) | 2595 | for (i = 0; i < ATA_MAX_DEVICES; i++) |
2375 | classes[i] = ATA_DEV_UNKNOWN; | 2596 | classes[i] = ATA_DEV_UNKNOWN; |
2376 | 2597 | ||
2377 | rc = reset(ap, 0, classes); | 2598 | rc = reset(ap, classes); |
2378 | if (rc) | 2599 | if (rc) |
2379 | return rc; | 2600 | return rc; |
2380 | 2601 | ||
@@ -2394,7 +2615,7 @@ static int do_probe_reset(struct ata_port *ap, ata_reset_fn_t reset, | |||
2394 | if (postreset) | 2615 | if (postreset) |
2395 | postreset(ap, classes); | 2616 | postreset(ap, classes); |
2396 | 2617 | ||
2397 | return classes[0] != ATA_DEV_UNKNOWN ? 0 : -ENODEV; | 2618 | return 0; |
2398 | } | 2619 | } |
2399 | 2620 | ||
2400 | /** | 2621 | /** |
@@ -2418,8 +2639,6 @@ static int do_probe_reset(struct ata_port *ap, ata_reset_fn_t reset, | |||
2418 | * - If classification is supported, fill classes[] with | 2639 | * - If classification is supported, fill classes[] with |
2419 | * recognized class codes. | 2640 | * recognized class codes. |
2420 | * - If classification is not supported, leave classes[] alone. | 2641 | * - If classification is not supported, leave classes[] alone. |
2421 | * - If verbose is non-zero, print error message on failure; | ||
2422 | * otherwise, shut up. | ||
2423 | * | 2642 | * |
2424 | * LOCKING: | 2643 | * LOCKING: |
2425 | * Kernel thread context (may sleep) | 2644 | * Kernel thread context (may sleep) |
@@ -2438,22 +2657,46 @@ int ata_drive_probe_reset(struct ata_port *ap, ata_probeinit_fn_t probeinit, | |||
2438 | if (probeinit) | 2657 | if (probeinit) |
2439 | probeinit(ap); | 2658 | probeinit(ap); |
2440 | 2659 | ||
2441 | if (softreset) { | 2660 | if (softreset && !ata_set_sata_spd_needed(ap)) { |
2442 | rc = do_probe_reset(ap, softreset, postreset, classes); | 2661 | rc = ata_do_reset(ap, softreset, postreset, classes); |
2443 | if (rc == 0) | 2662 | if (rc == 0 && classes[0] != ATA_DEV_UNKNOWN) |
2444 | return 0; | 2663 | goto done; |
2664 | printk(KERN_INFO "ata%u: softreset failed, will try " | ||
2665 | "hardreset in 5 secs\n", ap->id); | ||
2666 | ssleep(5); | ||
2445 | } | 2667 | } |
2446 | 2668 | ||
2447 | if (!hardreset) | 2669 | if (!hardreset) |
2448 | return rc; | 2670 | goto done; |
2449 | 2671 | ||
2450 | rc = do_probe_reset(ap, hardreset, postreset, classes); | 2672 | while (1) { |
2451 | if (rc == 0 || rc != -ENODEV) | 2673 | rc = ata_do_reset(ap, hardreset, postreset, classes); |
2452 | return rc; | 2674 | if (rc == 0) { |
2675 | if (classes[0] != ATA_DEV_UNKNOWN) | ||
2676 | goto done; | ||
2677 | break; | ||
2678 | } | ||
2679 | |||
2680 | if (ata_down_sata_spd_limit(ap)) | ||
2681 | goto done; | ||
2682 | |||
2683 | printk(KERN_INFO "ata%u: hardreset failed, will retry " | ||
2684 | "in 5 secs\n", ap->id); | ||
2685 | ssleep(5); | ||
2686 | } | ||
2687 | |||
2688 | if (softreset) { | ||
2689 | printk(KERN_INFO "ata%u: hardreset succeeded without " | ||
2690 | "classification, will retry softreset in 5 secs\n", | ||
2691 | ap->id); | ||
2692 | ssleep(5); | ||
2453 | 2693 | ||
2454 | if (softreset) | 2694 | rc = ata_do_reset(ap, softreset, postreset, classes); |
2455 | rc = do_probe_reset(ap, softreset, postreset, classes); | 2695 | } |
2456 | 2696 | ||
2697 | done: | ||
2698 | if (rc == 0 && classes[0] == ATA_DEV_UNKNOWN) | ||
2699 | rc = -ENODEV; | ||
2457 | return rc; | 2700 | return rc; |
2458 | } | 2701 | } |
2459 | 2702 | ||
@@ -2537,15 +2780,14 @@ static int ata_dev_same_device(struct ata_port *ap, struct ata_device *dev, | |||
2537 | int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, | 2780 | int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, |
2538 | int post_reset) | 2781 | int post_reset) |
2539 | { | 2782 | { |
2540 | unsigned int class; | 2783 | unsigned int class = dev->class; |
2541 | u16 *id; | 2784 | u16 *id = NULL; |
2542 | int rc; | 2785 | int rc; |
2543 | 2786 | ||
2544 | if (!ata_dev_present(dev)) | 2787 | if (!ata_dev_enabled(dev)) { |
2545 | return -ENODEV; | 2788 | rc = -ENODEV; |
2546 | 2789 | goto fail; | |
2547 | class = dev->class; | 2790 | } |
2548 | id = NULL; | ||
2549 | 2791 | ||
2550 | /* allocate & read ID data */ | 2792 | /* allocate & read ID data */ |
2551 | rc = ata_dev_read_id(ap, dev, &class, post_reset, &id); | 2793 | rc = ata_dev_read_id(ap, dev, &class, post_reset, &id); |
@@ -2562,7 +2804,9 @@ int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, | |||
2562 | dev->id = id; | 2804 | dev->id = id; |
2563 | 2805 | ||
2564 | /* configure device according to the new ID */ | 2806 | /* configure device according to the new ID */ |
2565 | return ata_dev_configure(ap, dev, 0); | 2807 | rc = ata_dev_configure(ap, dev, 0); |
2808 | if (rc == 0) | ||
2809 | return 0; | ||
2566 | 2810 | ||
2567 | fail: | 2811 | fail: |
2568 | printk(KERN_ERR "ata%u: dev %u revalidation failed (errno=%d)\n", | 2812 | printk(KERN_ERR "ata%u: dev %u revalidation failed (errno=%d)\n", |
@@ -2664,23 +2908,34 @@ static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev) | |||
2664 | unsigned long xfer_mask; | 2908 | unsigned long xfer_mask; |
2665 | int i; | 2909 | int i; |
2666 | 2910 | ||
2667 | xfer_mask = ata_pack_xfermask(ap->pio_mask, ap->mwdma_mask, | 2911 | xfer_mask = ata_pack_xfermask(ap->pio_mask, |
2668 | ap->udma_mask); | 2912 | ap->mwdma_mask, ap->udma_mask); |
2913 | |||
2914 | /* Apply cable rule here. Don't apply it early because when | ||
2915 | * we handle hot plug the cable type can itself change. | ||
2916 | */ | ||
2917 | if (ap->cbl == ATA_CBL_PATA40) | ||
2918 | xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA); | ||
2669 | 2919 | ||
2670 | /* FIXME: Use port-wide xfermask for now */ | 2920 | /* FIXME: Use port-wide xfermask for now */ |
2671 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 2921 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
2672 | struct ata_device *d = &ap->device[i]; | 2922 | struct ata_device *d = &ap->device[i]; |
2673 | if (!ata_dev_present(d)) | 2923 | |
2924 | if (ata_dev_absent(d)) | ||
2925 | continue; | ||
2926 | |||
2927 | if (ata_dev_disabled(d)) { | ||
2928 | /* to avoid violating device selection timing */ | ||
2929 | xfer_mask &= ata_pack_xfermask(d->pio_mask, | ||
2930 | UINT_MAX, UINT_MAX); | ||
2674 | continue; | 2931 | continue; |
2675 | xfer_mask &= ata_pack_xfermask(d->pio_mask, d->mwdma_mask, | 2932 | } |
2676 | d->udma_mask); | 2933 | |
2934 | xfer_mask &= ata_pack_xfermask(d->pio_mask, | ||
2935 | d->mwdma_mask, d->udma_mask); | ||
2677 | xfer_mask &= ata_id_xfermask(d->id); | 2936 | xfer_mask &= ata_id_xfermask(d->id); |
2678 | if (ata_dma_blacklisted(d)) | 2937 | if (ata_dma_blacklisted(d)) |
2679 | xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); | 2938 | xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); |
2680 | /* Apply cable rule here. Don't apply it early because when | ||
2681 | we handle hot plug the cable type can itself change */ | ||
2682 | if (ap->cbl == ATA_CBL_PATA40) | ||
2683 | xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA); | ||
2684 | } | 2939 | } |
2685 | 2940 | ||
2686 | if (ata_dma_blacklisted(dev)) | 2941 | if (ata_dma_blacklisted(dev)) |
@@ -2691,11 +2946,12 @@ static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev) | |||
2691 | if (hs->simplex_claimed) | 2946 | if (hs->simplex_claimed) |
2692 | xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); | 2947 | xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); |
2693 | } | 2948 | } |
2949 | |||
2694 | if (ap->ops->mode_filter) | 2950 | if (ap->ops->mode_filter) |
2695 | xfer_mask = ap->ops->mode_filter(ap, dev, xfer_mask); | 2951 | xfer_mask = ap->ops->mode_filter(ap, dev, xfer_mask); |
2696 | 2952 | ||
2697 | ata_unpack_xfermask(xfer_mask, &dev->pio_mask, &dev->mwdma_mask, | 2953 | ata_unpack_xfermask(xfer_mask, &dev->pio_mask, |
2698 | &dev->udma_mask); | 2954 | &dev->mwdma_mask, &dev->udma_mask); |
2699 | } | 2955 | } |
2700 | 2956 | ||
2701 | /** | 2957 | /** |
@@ -2729,7 +2985,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_port *ap, | |||
2729 | tf.protocol = ATA_PROT_NODATA; | 2985 | tf.protocol = ATA_PROT_NODATA; |
2730 | tf.nsect = dev->xfer_mode; | 2986 | tf.nsect = dev->xfer_mode; |
2731 | 2987 | ||
2732 | err_mask = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0); | 2988 | err_mask = ata_exec_internal(ap, dev, &tf, NULL, DMA_NONE, NULL, 0); |
2733 | 2989 | ||
2734 | DPRINTK("EXIT, err_mask=%x\n", err_mask); | 2990 | DPRINTK("EXIT, err_mask=%x\n", err_mask); |
2735 | return err_mask; | 2991 | return err_mask; |
@@ -2769,7 +3025,7 @@ static unsigned int ata_dev_init_params(struct ata_port *ap, | |||
2769 | tf.nsect = sectors; | 3025 | tf.nsect = sectors; |
2770 | tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ | 3026 | tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ |
2771 | 3027 | ||
2772 | err_mask = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0); | 3028 | err_mask = ata_exec_internal(ap, dev, &tf, NULL, DMA_NONE, NULL, 0); |
2773 | 3029 | ||
2774 | DPRINTK("EXIT, err_mask=%x\n", err_mask); | 3030 | DPRINTK("EXIT, err_mask=%x\n", err_mask); |
2775 | return err_mask; | 3031 | return err_mask; |
@@ -3157,7 +3413,7 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc) | |||
3157 | 3413 | ||
3158 | /** | 3414 | /** |
3159 | * ata_pio_poll - poll using PIO, depending on current state | 3415 | * ata_pio_poll - poll using PIO, depending on current state |
3160 | * @ap: the target ata_port | 3416 | * @qc: qc in progress |
3161 | * | 3417 | * |
3162 | * LOCKING: | 3418 | * LOCKING: |
3163 | * None. (executing in kernel thread context) | 3419 | * None. (executing in kernel thread context) |
@@ -3165,17 +3421,13 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc) | |||
3165 | * RETURNS: | 3421 | * RETURNS: |
3166 | * timeout value to use | 3422 | * timeout value to use |
3167 | */ | 3423 | */ |
3168 | 3424 | static unsigned long ata_pio_poll(struct ata_queued_cmd *qc) | |
3169 | static unsigned long ata_pio_poll(struct ata_port *ap) | ||
3170 | { | 3425 | { |
3171 | struct ata_queued_cmd *qc; | 3426 | struct ata_port *ap = qc->ap; |
3172 | u8 status; | 3427 | u8 status; |
3173 | unsigned int poll_state = HSM_ST_UNKNOWN; | 3428 | unsigned int poll_state = HSM_ST_UNKNOWN; |
3174 | unsigned int reg_state = HSM_ST_UNKNOWN; | 3429 | unsigned int reg_state = HSM_ST_UNKNOWN; |
3175 | 3430 | ||
3176 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
3177 | WARN_ON(qc == NULL); | ||
3178 | |||
3179 | switch (ap->hsm_task_state) { | 3431 | switch (ap->hsm_task_state) { |
3180 | case HSM_ST: | 3432 | case HSM_ST: |
3181 | case HSM_ST_POLL: | 3433 | case HSM_ST_POLL: |
@@ -3209,7 +3461,7 @@ static unsigned long ata_pio_poll(struct ata_port *ap) | |||
3209 | 3461 | ||
3210 | /** | 3462 | /** |
3211 | * ata_pio_complete - check if drive is busy or idle | 3463 | * ata_pio_complete - check if drive is busy or idle |
3212 | * @ap: the target ata_port | 3464 | * @qc: qc to complete |
3213 | * | 3465 | * |
3214 | * LOCKING: | 3466 | * LOCKING: |
3215 | * None. (executing in kernel thread context) | 3467 | * None. (executing in kernel thread context) |
@@ -3217,10 +3469,9 @@ static unsigned long ata_pio_poll(struct ata_port *ap) | |||
3217 | * RETURNS: | 3469 | * RETURNS: |
3218 | * Non-zero if qc completed, zero otherwise. | 3470 | * Non-zero if qc completed, zero otherwise. |
3219 | */ | 3471 | */ |
3220 | 3472 | static int ata_pio_complete(struct ata_queued_cmd *qc) | |
3221 | static int ata_pio_complete (struct ata_port *ap) | ||
3222 | { | 3473 | { |
3223 | struct ata_queued_cmd *qc; | 3474 | struct ata_port *ap = qc->ap; |
3224 | u8 drv_stat; | 3475 | u8 drv_stat; |
3225 | 3476 | ||
3226 | /* | 3477 | /* |
@@ -3241,9 +3492,6 @@ static int ata_pio_complete (struct ata_port *ap) | |||
3241 | } | 3492 | } |
3242 | } | 3493 | } |
3243 | 3494 | ||
3244 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
3245 | WARN_ON(qc == NULL); | ||
3246 | |||
3247 | drv_stat = ata_wait_idle(ap); | 3495 | drv_stat = ata_wait_idle(ap); |
3248 | if (!ata_ok(drv_stat)) { | 3496 | if (!ata_ok(drv_stat)) { |
3249 | qc->err_mask |= __ac_err_mask(drv_stat); | 3497 | qc->err_mask |= __ac_err_mask(drv_stat); |
@@ -3579,15 +3827,14 @@ err_out: | |||
3579 | 3827 | ||
3580 | /** | 3828 | /** |
3581 | * ata_pio_block - start PIO on a block | 3829 | * ata_pio_block - start PIO on a block |
3582 | * @ap: the target ata_port | 3830 | * @qc: qc to transfer block for |
3583 | * | 3831 | * |
3584 | * LOCKING: | 3832 | * LOCKING: |
3585 | * None. (executing in kernel thread context) | 3833 | * None. (executing in kernel thread context) |
3586 | */ | 3834 | */ |
3587 | 3835 | static void ata_pio_block(struct ata_queued_cmd *qc) | |
3588 | static void ata_pio_block(struct ata_port *ap) | ||
3589 | { | 3836 | { |
3590 | struct ata_queued_cmd *qc; | 3837 | struct ata_port *ap = qc->ap; |
3591 | u8 status; | 3838 | u8 status; |
3592 | 3839 | ||
3593 | /* | 3840 | /* |
@@ -3609,9 +3856,6 @@ static void ata_pio_block(struct ata_port *ap) | |||
3609 | } | 3856 | } |
3610 | } | 3857 | } |
3611 | 3858 | ||
3612 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
3613 | WARN_ON(qc == NULL); | ||
3614 | |||
3615 | /* check error */ | 3859 | /* check error */ |
3616 | if (status & (ATA_ERR | ATA_DF)) { | 3860 | if (status & (ATA_ERR | ATA_DF)) { |
3617 | qc->err_mask |= AC_ERR_DEV; | 3861 | qc->err_mask |= AC_ERR_DEV; |
@@ -3640,15 +3884,13 @@ static void ata_pio_block(struct ata_port *ap) | |||
3640 | } | 3884 | } |
3641 | } | 3885 | } |
3642 | 3886 | ||
3643 | static void ata_pio_error(struct ata_port *ap) | 3887 | static void ata_pio_error(struct ata_queued_cmd *qc) |
3644 | { | 3888 | { |
3645 | struct ata_queued_cmd *qc; | 3889 | struct ata_port *ap = qc->ap; |
3646 | |||
3647 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
3648 | WARN_ON(qc == NULL); | ||
3649 | 3890 | ||
3650 | if (qc->tf.command != ATA_CMD_PACKET) | 3891 | if (qc->tf.command != ATA_CMD_PACKET) |
3651 | printk(KERN_WARNING "ata%u: PIO error\n", ap->id); | 3892 | printk(KERN_WARNING "ata%u: dev %u PIO error\n", |
3893 | ap->id, qc->dev->devno); | ||
3652 | 3894 | ||
3653 | /* make sure qc->err_mask is available to | 3895 | /* make sure qc->err_mask is available to |
3654 | * know what's wrong and recover | 3896 | * know what's wrong and recover |
@@ -3662,7 +3904,8 @@ static void ata_pio_error(struct ata_port *ap) | |||
3662 | 3904 | ||
3663 | static void ata_pio_task(void *_data) | 3905 | static void ata_pio_task(void *_data) |
3664 | { | 3906 | { |
3665 | struct ata_port *ap = _data; | 3907 | struct ata_queued_cmd *qc = _data; |
3908 | struct ata_port *ap = qc->ap; | ||
3666 | unsigned long timeout; | 3909 | unsigned long timeout; |
3667 | int qc_completed; | 3910 | int qc_completed; |
3668 | 3911 | ||
@@ -3675,33 +3918,33 @@ fsm_start: | |||
3675 | return; | 3918 | return; |
3676 | 3919 | ||
3677 | case HSM_ST: | 3920 | case HSM_ST: |
3678 | ata_pio_block(ap); | 3921 | ata_pio_block(qc); |
3679 | break; | 3922 | break; |
3680 | 3923 | ||
3681 | case HSM_ST_LAST: | 3924 | case HSM_ST_LAST: |
3682 | qc_completed = ata_pio_complete(ap); | 3925 | qc_completed = ata_pio_complete(qc); |
3683 | break; | 3926 | break; |
3684 | 3927 | ||
3685 | case HSM_ST_POLL: | 3928 | case HSM_ST_POLL: |
3686 | case HSM_ST_LAST_POLL: | 3929 | case HSM_ST_LAST_POLL: |
3687 | timeout = ata_pio_poll(ap); | 3930 | timeout = ata_pio_poll(qc); |
3688 | break; | 3931 | break; |
3689 | 3932 | ||
3690 | case HSM_ST_TMOUT: | 3933 | case HSM_ST_TMOUT: |
3691 | case HSM_ST_ERR: | 3934 | case HSM_ST_ERR: |
3692 | ata_pio_error(ap); | 3935 | ata_pio_error(qc); |
3693 | return; | 3936 | return; |
3694 | } | 3937 | } |
3695 | 3938 | ||
3696 | if (timeout) | 3939 | if (timeout) |
3697 | ata_port_queue_task(ap, ata_pio_task, ap, timeout); | 3940 | ata_port_queue_task(ap, ata_pio_task, qc, timeout); |
3698 | else if (!qc_completed) | 3941 | else if (!qc_completed) |
3699 | goto fsm_start; | 3942 | goto fsm_start; |
3700 | } | 3943 | } |
3701 | 3944 | ||
3702 | /** | 3945 | /** |
3703 | * atapi_packet_task - Write CDB bytes to hardware | 3946 | * atapi_packet_task - Write CDB bytes to hardware |
3704 | * @_data: Port to which ATAPI device is attached. | 3947 | * @_data: qc in progress |
3705 | * | 3948 | * |
3706 | * When device has indicated its readiness to accept | 3949 | * When device has indicated its readiness to accept |
3707 | * a CDB, this function is called. Send the CDB. | 3950 | * a CDB, this function is called. Send the CDB. |
@@ -3712,17 +3955,12 @@ fsm_start: | |||
3712 | * LOCKING: | 3955 | * LOCKING: |
3713 | * Kernel thread context (may sleep) | 3956 | * Kernel thread context (may sleep) |
3714 | */ | 3957 | */ |
3715 | |||
3716 | static void atapi_packet_task(void *_data) | 3958 | static void atapi_packet_task(void *_data) |
3717 | { | 3959 | { |
3718 | struct ata_port *ap = _data; | 3960 | struct ata_queued_cmd *qc = _data; |
3719 | struct ata_queued_cmd *qc; | 3961 | struct ata_port *ap = qc->ap; |
3720 | u8 status; | 3962 | u8 status; |
3721 | 3963 | ||
3722 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
3723 | WARN_ON(qc == NULL); | ||
3724 | WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE)); | ||
3725 | |||
3726 | /* sleep-wait for BSY to clear */ | 3964 | /* sleep-wait for BSY to clear */ |
3727 | DPRINTK("busy wait\n"); | 3965 | DPRINTK("busy wait\n"); |
3728 | if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) { | 3966 | if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) { |
@@ -3762,7 +4000,7 @@ static void atapi_packet_task(void *_data) | |||
3762 | 4000 | ||
3763 | /* PIO commands are handled by polling */ | 4001 | /* PIO commands are handled by polling */ |
3764 | ap->hsm_task_state = HSM_ST; | 4002 | ap->hsm_task_state = HSM_ST; |
3765 | ata_port_queue_task(ap, ata_pio_task, ap, 0); | 4003 | ata_port_queue_task(ap, ata_pio_task, qc, 0); |
3766 | } | 4004 | } |
3767 | 4005 | ||
3768 | return; | 4006 | return; |
@@ -3772,99 +4010,6 @@ err_out: | |||
3772 | } | 4010 | } |
3773 | 4011 | ||
3774 | /** | 4012 | /** |
3775 | * ata_qc_timeout - Handle timeout of queued command | ||
3776 | * @qc: Command that timed out | ||
3777 | * | ||
3778 | * Some part of the kernel (currently, only the SCSI layer) | ||
3779 | * has noticed that the active command on port @ap has not | ||
3780 | * completed after a specified length of time. Handle this | ||
3781 | * condition by disabling DMA (if necessary) and completing | ||
3782 | * transactions, with error if necessary. | ||
3783 | * | ||
3784 | * This also handles the case of the "lost interrupt", where | ||
3785 | * for some reason (possibly hardware bug, possibly driver bug) | ||
3786 | * an interrupt was not delivered to the driver, even though the | ||
3787 | * transaction completed successfully. | ||
3788 | * | ||
3789 | * LOCKING: | ||
3790 | * Inherited from SCSI layer (none, can sleep) | ||
3791 | */ | ||
3792 | |||
3793 | static void ata_qc_timeout(struct ata_queued_cmd *qc) | ||
3794 | { | ||
3795 | struct ata_port *ap = qc->ap; | ||
3796 | struct ata_host_set *host_set = ap->host_set; | ||
3797 | u8 host_stat = 0, drv_stat; | ||
3798 | unsigned long flags; | ||
3799 | |||
3800 | DPRINTK("ENTER\n"); | ||
3801 | |||
3802 | ap->hsm_task_state = HSM_ST_IDLE; | ||
3803 | |||
3804 | spin_lock_irqsave(&host_set->lock, flags); | ||
3805 | |||
3806 | switch (qc->tf.protocol) { | ||
3807 | |||
3808 | case ATA_PROT_DMA: | ||
3809 | case ATA_PROT_ATAPI_DMA: | ||
3810 | host_stat = ap->ops->bmdma_status(ap); | ||
3811 | |||
3812 | /* before we do anything else, clear DMA-Start bit */ | ||
3813 | ap->ops->bmdma_stop(qc); | ||
3814 | |||
3815 | /* fall through */ | ||
3816 | |||
3817 | default: | ||
3818 | ata_altstatus(ap); | ||
3819 | drv_stat = ata_chk_status(ap); | ||
3820 | |||
3821 | /* ack bmdma irq events */ | ||
3822 | ap->ops->irq_clear(ap); | ||
3823 | |||
3824 | printk(KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x host_stat 0x%x\n", | ||
3825 | ap->id, qc->tf.command, drv_stat, host_stat); | ||
3826 | |||
3827 | /* complete taskfile transaction */ | ||
3828 | qc->err_mask |= ac_err_mask(drv_stat); | ||
3829 | break; | ||
3830 | } | ||
3831 | |||
3832 | spin_unlock_irqrestore(&host_set->lock, flags); | ||
3833 | |||
3834 | ata_eh_qc_complete(qc); | ||
3835 | |||
3836 | DPRINTK("EXIT\n"); | ||
3837 | } | ||
3838 | |||
3839 | /** | ||
3840 | * ata_eng_timeout - Handle timeout of queued command | ||
3841 | * @ap: Port on which timed-out command is active | ||
3842 | * | ||
3843 | * Some part of the kernel (currently, only the SCSI layer) | ||
3844 | * has noticed that the active command on port @ap has not | ||
3845 | * completed after a specified length of time. Handle this | ||
3846 | * condition by disabling DMA (if necessary) and completing | ||
3847 | * transactions, with error if necessary. | ||
3848 | * | ||
3849 | * This also handles the case of the "lost interrupt", where | ||
3850 | * for some reason (possibly hardware bug, possibly driver bug) | ||
3851 | * an interrupt was not delivered to the driver, even though the | ||
3852 | * transaction completed successfully. | ||
3853 | * | ||
3854 | * LOCKING: | ||
3855 | * Inherited from SCSI layer (none, can sleep) | ||
3856 | */ | ||
3857 | |||
3858 | void ata_eng_timeout(struct ata_port *ap) | ||
3859 | { | ||
3860 | DPRINTK("ENTER\n"); | ||
3861 | |||
3862 | ata_qc_timeout(ata_qc_from_tag(ap, ap->active_tag)); | ||
3863 | |||
3864 | DPRINTK("EXIT\n"); | ||
3865 | } | ||
3866 | |||
3867 | /** | ||
3868 | * ata_qc_new - Request an available ATA command, for queueing | 4013 | * ata_qc_new - Request an available ATA command, for queueing |
3869 | * @ap: Port associated with device @dev | 4014 | * @ap: Port associated with device @dev |
3870 | * @dev: Device from whom we request an available command structure | 4015 | * @dev: Device from whom we request an available command structure |
@@ -4068,26 +4213,26 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc) | |||
4068 | ata_qc_set_polling(qc); | 4213 | ata_qc_set_polling(qc); |
4069 | ata_tf_to_host(ap, &qc->tf); | 4214 | ata_tf_to_host(ap, &qc->tf); |
4070 | ap->hsm_task_state = HSM_ST; | 4215 | ap->hsm_task_state = HSM_ST; |
4071 | ata_port_queue_task(ap, ata_pio_task, ap, 0); | 4216 | ata_port_queue_task(ap, ata_pio_task, qc, 0); |
4072 | break; | 4217 | break; |
4073 | 4218 | ||
4074 | case ATA_PROT_ATAPI: | 4219 | case ATA_PROT_ATAPI: |
4075 | ata_qc_set_polling(qc); | 4220 | ata_qc_set_polling(qc); |
4076 | ata_tf_to_host(ap, &qc->tf); | 4221 | ata_tf_to_host(ap, &qc->tf); |
4077 | ata_port_queue_task(ap, atapi_packet_task, ap, 0); | 4222 | ata_port_queue_task(ap, atapi_packet_task, qc, 0); |
4078 | break; | 4223 | break; |
4079 | 4224 | ||
4080 | case ATA_PROT_ATAPI_NODATA: | 4225 | case ATA_PROT_ATAPI_NODATA: |
4081 | ap->flags |= ATA_FLAG_NOINTR; | 4226 | ap->flags |= ATA_FLAG_NOINTR; |
4082 | ata_tf_to_host(ap, &qc->tf); | 4227 | ata_tf_to_host(ap, &qc->tf); |
4083 | ata_port_queue_task(ap, atapi_packet_task, ap, 0); | 4228 | ata_port_queue_task(ap, atapi_packet_task, qc, 0); |
4084 | break; | 4229 | break; |
4085 | 4230 | ||
4086 | case ATA_PROT_ATAPI_DMA: | 4231 | case ATA_PROT_ATAPI_DMA: |
4087 | ap->flags |= ATA_FLAG_NOINTR; | 4232 | ap->flags |= ATA_FLAG_NOINTR; |
4088 | ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ | 4233 | ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ |
4089 | ap->ops->bmdma_setup(qc); /* set up bmdma */ | 4234 | ap->ops->bmdma_setup(qc); /* set up bmdma */ |
4090 | ata_port_queue_task(ap, atapi_packet_task, ap, 0); | 4235 | ata_port_queue_task(ap, atapi_packet_task, qc, 0); |
4091 | break; | 4236 | break; |
4092 | 4237 | ||
4093 | default: | 4238 | default: |
@@ -4209,7 +4354,7 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs) | |||
4209 | 4354 | ||
4210 | ap = host_set->ports[i]; | 4355 | ap = host_set->ports[i]; |
4211 | if (ap && | 4356 | if (ap && |
4212 | !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) { | 4357 | !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) { |
4213 | struct ata_queued_cmd *qc; | 4358 | struct ata_queued_cmd *qc; |
4214 | 4359 | ||
4215 | qc = ata_qc_from_tag(ap, ap->active_tag); | 4360 | qc = ata_qc_from_tag(ap, ap->active_tag); |
@@ -4241,7 +4386,7 @@ static int ata_do_simple_cmd(struct ata_port *ap, struct ata_device *dev, | |||
4241 | tf.flags |= ATA_TFLAG_DEVICE; | 4386 | tf.flags |= ATA_TFLAG_DEVICE; |
4242 | tf.protocol = ATA_PROT_NODATA; | 4387 | tf.protocol = ATA_PROT_NODATA; |
4243 | 4388 | ||
4244 | err = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0); | 4389 | err = ata_exec_internal(ap, dev, &tf, NULL, DMA_NONE, NULL, 0); |
4245 | if (err) | 4390 | if (err) |
4246 | printk(KERN_ERR "%s: ata command failed: %d\n", | 4391 | printk(KERN_ERR "%s: ata command failed: %d\n", |
4247 | __FUNCTION__, err); | 4392 | __FUNCTION__, err); |
@@ -4287,10 +4432,12 @@ static int ata_start_drive(struct ata_port *ap, struct ata_device *dev) | |||
4287 | int ata_device_resume(struct ata_port *ap, struct ata_device *dev) | 4432 | int ata_device_resume(struct ata_port *ap, struct ata_device *dev) |
4288 | { | 4433 | { |
4289 | if (ap->flags & ATA_FLAG_SUSPENDED) { | 4434 | if (ap->flags & ATA_FLAG_SUSPENDED) { |
4435 | struct ata_device *failed_dev; | ||
4290 | ap->flags &= ~ATA_FLAG_SUSPENDED; | 4436 | ap->flags &= ~ATA_FLAG_SUSPENDED; |
4291 | ata_set_mode(ap); | 4437 | while (ata_set_mode(ap, &failed_dev)) |
4438 | ata_dev_disable(ap, failed_dev); | ||
4292 | } | 4439 | } |
4293 | if (!ata_dev_present(dev)) | 4440 | if (!ata_dev_enabled(dev)) |
4294 | return 0; | 4441 | return 0; |
4295 | if (dev->class == ATA_DEV_ATA) | 4442 | if (dev->class == ATA_DEV_ATA) |
4296 | ata_start_drive(ap, dev); | 4443 | ata_start_drive(ap, dev); |
@@ -4308,7 +4455,7 @@ int ata_device_resume(struct ata_port *ap, struct ata_device *dev) | |||
4308 | */ | 4455 | */ |
4309 | int ata_device_suspend(struct ata_port *ap, struct ata_device *dev, pm_message_t state) | 4456 | int ata_device_suspend(struct ata_port *ap, struct ata_device *dev, pm_message_t state) |
4310 | { | 4457 | { |
4311 | if (!ata_dev_present(dev)) | 4458 | if (!ata_dev_enabled(dev)) |
4312 | return 0; | 4459 | return 0; |
4313 | if (dev->class == ATA_DEV_ATA) | 4460 | if (dev->class == ATA_DEV_ATA) |
4314 | ata_flush_cache(ap, dev); | 4461 | ata_flush_cache(ap, dev); |
@@ -4428,7 +4575,7 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, | |||
4428 | host->unique_id = ata_unique_id++; | 4575 | host->unique_id = ata_unique_id++; |
4429 | host->max_cmd_len = 12; | 4576 | host->max_cmd_len = 12; |
4430 | 4577 | ||
4431 | ap->flags = ATA_FLAG_PORT_DISABLED; | 4578 | ap->flags = ATA_FLAG_DISABLED; |
4432 | ap->id = host->unique_id; | 4579 | ap->id = host->unique_id; |
4433 | ap->host = host; | 4580 | ap->host = host; |
4434 | ap->ctl = ATA_DEVCTL_OBS; | 4581 | ap->ctl = ATA_DEVCTL_OBS; |
@@ -4443,6 +4590,7 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, | |||
4443 | ap->flags |= ent->host_flags; | 4590 | ap->flags |= ent->host_flags; |
4444 | ap->ops = ent->port_ops; | 4591 | ap->ops = ent->port_ops; |
4445 | ap->cbl = ATA_CBL_NONE; | 4592 | ap->cbl = ATA_CBL_NONE; |
4593 | ap->sata_spd_limit = UINT_MAX; | ||
4446 | ap->active_tag = ATA_TAG_POISON; | 4594 | ap->active_tag = ATA_TAG_POISON; |
4447 | ap->last_ctl = 0xFF; | 4595 | ap->last_ctl = 0xFF; |
4448 | 4596 | ||
@@ -4503,7 +4651,7 @@ static struct ata_port * ata_host_add(const struct ata_probe_ent *ent, | |||
4503 | 4651 | ||
4504 | host->transportt = &ata_scsi_transport_template; | 4652 | host->transportt = &ata_scsi_transport_template; |
4505 | 4653 | ||
4506 | ap = (struct ata_port *) &host->hostdata[0]; | 4654 | ap = ata_shost_to_port(host); |
4507 | 4655 | ||
4508 | ata_host_init(ap, host, host_set, ent, port_no); | 4656 | ata_host_init(ap, host, host_set, ent, port_no); |
4509 | 4657 | ||
@@ -4716,7 +4864,7 @@ void ata_host_set_remove(struct ata_host_set *host_set) | |||
4716 | 4864 | ||
4717 | int ata_scsi_release(struct Scsi_Host *host) | 4865 | int ata_scsi_release(struct Scsi_Host *host) |
4718 | { | 4866 | { |
4719 | struct ata_port *ap = (struct ata_port *) &host->hostdata[0]; | 4867 | struct ata_port *ap = ata_shost_to_port(host); |
4720 | int i; | 4868 | int i; |
4721 | 4869 | ||
4722 | DPRINTK("ENTER\n"); | 4870 | DPRINTK("ENTER\n"); |
@@ -4883,6 +5031,52 @@ int ata_ratelimit(void) | |||
4883 | return rc; | 5031 | return rc; |
4884 | } | 5032 | } |
4885 | 5033 | ||
5034 | /** | ||
5035 | * ata_wait_register - wait until register value changes | ||
5036 | * @reg: IO-mapped register | ||
5037 | * @mask: Mask to apply to read register value | ||
5038 | * @val: Wait condition | ||
5039 | * @interval_msec: polling interval in milliseconds | ||
5040 | * @timeout_msec: timeout in milliseconds | ||
5041 | * | ||
5042 | * Waiting for some bits of register to change is a common | ||
5043 | * operation for ATA controllers. This function reads 32bit LE | ||
5044 | * IO-mapped register @reg and tests for the following condition. | ||
5045 | * | ||
5046 | * (*@reg & mask) != val | ||
5047 | * | ||
5048 | * If the condition is met, it returns; otherwise, the process is | ||
5049 | * repeated after @interval_msec until timeout. | ||
5050 | * | ||
5051 | * LOCKING: | ||
5052 | * Kernel thread context (may sleep) | ||
5053 | * | ||
5054 | * RETURNS: | ||
5055 | * The final register value. | ||
5056 | */ | ||
5057 | u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, | ||
5058 | unsigned long interval_msec, | ||
5059 | unsigned long timeout_msec) | ||
5060 | { | ||
5061 | unsigned long timeout; | ||
5062 | u32 tmp; | ||
5063 | |||
5064 | tmp = ioread32(reg); | ||
5065 | |||
5066 | /* Calculate timeout _after_ the first read to make sure | ||
5067 | * preceding writes reach the controller before starting to | ||
5068 | * eat away the timeout. | ||
5069 | */ | ||
5070 | timeout = jiffies + (timeout_msec * HZ) / 1000; | ||
5071 | |||
5072 | while ((tmp & mask) == val && time_before(jiffies, timeout)) { | ||
5073 | msleep(interval_msec); | ||
5074 | tmp = ioread32(reg); | ||
5075 | } | ||
5076 | |||
5077 | return tmp; | ||
5078 | } | ||
5079 | |||
4886 | /* | 5080 | /* |
4887 | * libata is essentially a library of internal helper functions for | 5081 | * libata is essentially a library of internal helper functions for |
4888 | * low-level ATA host controller drivers. As such, the API/ABI is | 5082 | * low-level ATA host controller drivers. As such, the API/ABI is |
@@ -4898,7 +5092,6 @@ EXPORT_SYMBOL_GPL(ata_sg_init); | |||
4898 | EXPORT_SYMBOL_GPL(ata_sg_init_one); | 5092 | EXPORT_SYMBOL_GPL(ata_sg_init_one); |
4899 | EXPORT_SYMBOL_GPL(__ata_qc_complete); | 5093 | EXPORT_SYMBOL_GPL(__ata_qc_complete); |
4900 | EXPORT_SYMBOL_GPL(ata_qc_issue_prot); | 5094 | EXPORT_SYMBOL_GPL(ata_qc_issue_prot); |
4901 | EXPORT_SYMBOL_GPL(ata_eng_timeout); | ||
4902 | EXPORT_SYMBOL_GPL(ata_tf_load); | 5095 | EXPORT_SYMBOL_GPL(ata_tf_load); |
4903 | EXPORT_SYMBOL_GPL(ata_tf_read); | 5096 | EXPORT_SYMBOL_GPL(ata_tf_read); |
4904 | EXPORT_SYMBOL_GPL(ata_noop_dev_select); | 5097 | EXPORT_SYMBOL_GPL(ata_noop_dev_select); |
@@ -4920,6 +5113,7 @@ EXPORT_SYMBOL_GPL(ata_bmdma_irq_clear); | |||
4920 | EXPORT_SYMBOL_GPL(ata_bmdma_status); | 5113 | EXPORT_SYMBOL_GPL(ata_bmdma_status); |
4921 | EXPORT_SYMBOL_GPL(ata_bmdma_stop); | 5114 | EXPORT_SYMBOL_GPL(ata_bmdma_stop); |
4922 | EXPORT_SYMBOL_GPL(ata_port_probe); | 5115 | EXPORT_SYMBOL_GPL(ata_port_probe); |
5116 | EXPORT_SYMBOL_GPL(ata_set_sata_spd); | ||
4923 | EXPORT_SYMBOL_GPL(sata_phy_reset); | 5117 | EXPORT_SYMBOL_GPL(sata_phy_reset); |
4924 | EXPORT_SYMBOL_GPL(__sata_phy_reset); | 5118 | EXPORT_SYMBOL_GPL(__sata_phy_reset); |
4925 | EXPORT_SYMBOL_GPL(ata_bus_reset); | 5119 | EXPORT_SYMBOL_GPL(ata_bus_reset); |
@@ -4934,6 +5128,7 @@ EXPORT_SYMBOL_GPL(ata_dev_classify); | |||
4934 | EXPORT_SYMBOL_GPL(ata_dev_pair); | 5128 | EXPORT_SYMBOL_GPL(ata_dev_pair); |
4935 | EXPORT_SYMBOL_GPL(ata_port_disable); | 5129 | EXPORT_SYMBOL_GPL(ata_port_disable); |
4936 | EXPORT_SYMBOL_GPL(ata_ratelimit); | 5130 | EXPORT_SYMBOL_GPL(ata_ratelimit); |
5131 | EXPORT_SYMBOL_GPL(ata_wait_register); | ||
4937 | EXPORT_SYMBOL_GPL(ata_busy_sleep); | 5132 | EXPORT_SYMBOL_GPL(ata_busy_sleep); |
4938 | EXPORT_SYMBOL_GPL(ata_port_queue_task); | 5133 | EXPORT_SYMBOL_GPL(ata_port_queue_task); |
4939 | EXPORT_SYMBOL_GPL(ata_scsi_ioctl); | 5134 | EXPORT_SYMBOL_GPL(ata_scsi_ioctl); |
@@ -4944,8 +5139,6 @@ EXPORT_SYMBOL_GPL(ata_host_intr); | |||
4944 | EXPORT_SYMBOL_GPL(ata_id_string); | 5139 | EXPORT_SYMBOL_GPL(ata_id_string); |
4945 | EXPORT_SYMBOL_GPL(ata_id_c_string); | 5140 | EXPORT_SYMBOL_GPL(ata_id_c_string); |
4946 | EXPORT_SYMBOL_GPL(ata_scsi_simulate); | 5141 | EXPORT_SYMBOL_GPL(ata_scsi_simulate); |
4947 | EXPORT_SYMBOL_GPL(ata_eh_qc_complete); | ||
4948 | EXPORT_SYMBOL_GPL(ata_eh_qc_retry); | ||
4949 | 5142 | ||
4950 | EXPORT_SYMBOL_GPL(ata_pio_need_iordy); | 5143 | EXPORT_SYMBOL_GPL(ata_pio_need_iordy); |
4951 | EXPORT_SYMBOL_GPL(ata_timing_compute); | 5144 | EXPORT_SYMBOL_GPL(ata_timing_compute); |
@@ -4967,3 +5160,8 @@ EXPORT_SYMBOL_GPL(ata_device_suspend); | |||
4967 | EXPORT_SYMBOL_GPL(ata_device_resume); | 5160 | EXPORT_SYMBOL_GPL(ata_device_resume); |
4968 | EXPORT_SYMBOL_GPL(ata_scsi_device_suspend); | 5161 | EXPORT_SYMBOL_GPL(ata_scsi_device_suspend); |
4969 | EXPORT_SYMBOL_GPL(ata_scsi_device_resume); | 5162 | EXPORT_SYMBOL_GPL(ata_scsi_device_resume); |
5163 | |||
5164 | EXPORT_SYMBOL_GPL(ata_scsi_error); | ||
5165 | EXPORT_SYMBOL_GPL(ata_eng_timeout); | ||
5166 | EXPORT_SYMBOL_GPL(ata_eh_qc_complete); | ||
5167 | EXPORT_SYMBOL_GPL(ata_eh_qc_retry); | ||
diff --git a/drivers/scsi/libata-eh.c b/drivers/scsi/libata-eh.c new file mode 100644 index 000000000000..c31b13fd5307 --- /dev/null +++ b/drivers/scsi/libata-eh.c | |||
@@ -0,0 +1,263 @@ | |||
1 | /* | ||
2 | * libata-eh.c - libata error handling | ||
3 | * | ||
4 | * Maintained by: Jeff Garzik <jgarzik@pobox.com> | ||
5 | * Please ALWAYS copy linux-ide@vger.kernel.org | ||
6 | * on emails. | ||
7 | * | ||
8 | * Copyright 2006 Tejun Heo <htejun@gmail.com> | ||
9 | * | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU General Public License as | ||
13 | * published by the Free Software Foundation; either version 2, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
19 | * General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; see the file COPYING. If not, write to | ||
23 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, | ||
24 | * USA. | ||
25 | * | ||
26 | * | ||
27 | * libata documentation is available via 'make {ps|pdf}docs', | ||
28 | * as Documentation/DocBook/libata.* | ||
29 | * | ||
30 | * Hardware documentation available from http://www.t13.org/ and | ||
31 | * http://www.sata-io.org/ | ||
32 | * | ||
33 | */ | ||
34 | |||
35 | #include <linux/config.h> | ||
36 | #include <linux/kernel.h> | ||
37 | #include <scsi/scsi.h> | ||
38 | #include <scsi/scsi_host.h> | ||
39 | #include <scsi/scsi_eh.h> | ||
40 | #include <scsi/scsi_device.h> | ||
41 | #include <scsi/scsi_cmnd.h> | ||
42 | |||
43 | #include <linux/libata.h> | ||
44 | |||
45 | #include "libata.h" | ||
46 | |||
47 | /** | ||
48 | * ata_scsi_timed_out - SCSI layer time out callback | ||
49 | * @cmd: timed out SCSI command | ||
50 | * | ||
51 | * Handles SCSI layer timeout. We race with normal completion of | ||
52 | * the qc for @cmd. If the qc is already gone, we lose and let | ||
53 | * the scsi command finish (EH_HANDLED). Otherwise, the qc has | ||
54 | * timed out and EH should be invoked. Prevent ata_qc_complete() | ||
55 | * from finishing it by setting EH_SCHEDULED and return | ||
56 | * EH_NOT_HANDLED. | ||
57 | * | ||
58 | * LOCKING: | ||
59 | * Called from timer context | ||
60 | * | ||
61 | * RETURNS: | ||
62 | * EH_HANDLED or EH_NOT_HANDLED | ||
63 | */ | ||
64 | enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd) | ||
65 | { | ||
66 | struct Scsi_Host *host = cmd->device->host; | ||
67 | struct ata_port *ap = ata_shost_to_port(host); | ||
68 | unsigned long flags; | ||
69 | struct ata_queued_cmd *qc; | ||
70 | enum scsi_eh_timer_return ret = EH_HANDLED; | ||
71 | |||
72 | DPRINTK("ENTER\n"); | ||
73 | |||
74 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
75 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
76 | if (qc) { | ||
77 | WARN_ON(qc->scsicmd != cmd); | ||
78 | qc->flags |= ATA_QCFLAG_EH_SCHEDULED; | ||
79 | qc->err_mask |= AC_ERR_TIMEOUT; | ||
80 | ret = EH_NOT_HANDLED; | ||
81 | } | ||
82 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
83 | |||
84 | DPRINTK("EXIT, ret=%d\n", ret); | ||
85 | return ret; | ||
86 | } | ||
87 | |||
88 | /** | ||
89 | * ata_scsi_error - SCSI layer error handler callback | ||
90 | * @host: SCSI host on which error occurred | ||
91 | * | ||
92 | * Handles SCSI-layer-thrown error events. | ||
93 | * | ||
94 | * LOCKING: | ||
95 | * Inherited from SCSI layer (none, can sleep) | ||
96 | * | ||
97 | * RETURNS: | ||
98 | * Zero. | ||
99 | */ | ||
100 | void ata_scsi_error(struct Scsi_Host *host) | ||
101 | { | ||
102 | struct ata_port *ap = ata_shost_to_port(host); | ||
103 | |||
104 | DPRINTK("ENTER\n"); | ||
105 | |||
106 | /* synchronize with IRQ handler and port task */ | ||
107 | spin_unlock_wait(&ap->host_set->lock); | ||
108 | ata_port_flush_task(ap); | ||
109 | |||
110 | WARN_ON(ata_qc_from_tag(ap, ap->active_tag) == NULL); | ||
111 | |||
112 | ap->ops->eng_timeout(ap); | ||
113 | |||
114 | WARN_ON(host->host_failed || !list_empty(&host->eh_cmd_q)); | ||
115 | |||
116 | scsi_eh_flush_done_q(&ap->eh_done_q); | ||
117 | |||
118 | DPRINTK("EXIT\n"); | ||
119 | } | ||
120 | |||
121 | /** | ||
122 | * ata_qc_timeout - Handle timeout of queued command | ||
123 | * @qc: Command that timed out | ||
124 | * | ||
125 | * Some part of the kernel (currently, only the SCSI layer) | ||
126 | * has noticed that the active command on port @ap has not | ||
127 | * completed after a specified length of time. Handle this | ||
128 | * condition by disabling DMA (if necessary) and completing | ||
129 | * transactions, with error if necessary. | ||
130 | * | ||
131 | * This also handles the case of the "lost interrupt", where | ||
132 | * for some reason (possibly hardware bug, possibly driver bug) | ||
133 | * an interrupt was not delivered to the driver, even though the | ||
134 | * transaction completed successfully. | ||
135 | * | ||
136 | * LOCKING: | ||
137 | * Inherited from SCSI layer (none, can sleep) | ||
138 | */ | ||
139 | static void ata_qc_timeout(struct ata_queued_cmd *qc) | ||
140 | { | ||
141 | struct ata_port *ap = qc->ap; | ||
142 | struct ata_host_set *host_set = ap->host_set; | ||
143 | u8 host_stat = 0, drv_stat; | ||
144 | unsigned long flags; | ||
145 | |||
146 | DPRINTK("ENTER\n"); | ||
147 | |||
148 | ap->hsm_task_state = HSM_ST_IDLE; | ||
149 | |||
150 | spin_lock_irqsave(&host_set->lock, flags); | ||
151 | |||
152 | switch (qc->tf.protocol) { | ||
153 | |||
154 | case ATA_PROT_DMA: | ||
155 | case ATA_PROT_ATAPI_DMA: | ||
156 | host_stat = ap->ops->bmdma_status(ap); | ||
157 | |||
158 | /* before we do anything else, clear DMA-Start bit */ | ||
159 | ap->ops->bmdma_stop(qc); | ||
160 | |||
161 | /* fall through */ | ||
162 | |||
163 | default: | ||
164 | ata_altstatus(ap); | ||
165 | drv_stat = ata_chk_status(ap); | ||
166 | |||
167 | /* ack bmdma irq events */ | ||
168 | ap->ops->irq_clear(ap); | ||
169 | |||
170 | printk(KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x host_stat 0x%x\n", | ||
171 | ap->id, qc->tf.command, drv_stat, host_stat); | ||
172 | |||
173 | /* complete taskfile transaction */ | ||
174 | qc->err_mask |= ac_err_mask(drv_stat); | ||
175 | break; | ||
176 | } | ||
177 | |||
178 | spin_unlock_irqrestore(&host_set->lock, flags); | ||
179 | |||
180 | ata_eh_qc_complete(qc); | ||
181 | |||
182 | DPRINTK("EXIT\n"); | ||
183 | } | ||
184 | |||
185 | /** | ||
186 | * ata_eng_timeout - Handle timeout of queued command | ||
187 | * @ap: Port on which timed-out command is active | ||
188 | * | ||
189 | * Some part of the kernel (currently, only the SCSI layer) | ||
190 | * has noticed that the active command on port @ap has not | ||
191 | * completed after a specified length of time. Handle this | ||
192 | * condition by disabling DMA (if necessary) and completing | ||
193 | * transactions, with error if necessary. | ||
194 | * | ||
195 | * This also handles the case of the "lost interrupt", where | ||
196 | * for some reason (possibly hardware bug, possibly driver bug) | ||
197 | * an interrupt was not delivered to the driver, even though the | ||
198 | * transaction completed successfully. | ||
199 | * | ||
200 | * LOCKING: | ||
201 | * Inherited from SCSI layer (none, can sleep) | ||
202 | */ | ||
203 | void ata_eng_timeout(struct ata_port *ap) | ||
204 | { | ||
205 | DPRINTK("ENTER\n"); | ||
206 | |||
207 | ata_qc_timeout(ata_qc_from_tag(ap, ap->active_tag)); | ||
208 | |||
209 | DPRINTK("EXIT\n"); | ||
210 | } | ||
211 | |||
212 | static void ata_eh_scsidone(struct scsi_cmnd *scmd) | ||
213 | { | ||
214 | /* nada */ | ||
215 | } | ||
216 | |||
217 | static void __ata_eh_qc_complete(struct ata_queued_cmd *qc) | ||
218 | { | ||
219 | struct ata_port *ap = qc->ap; | ||
220 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
221 | unsigned long flags; | ||
222 | |||
223 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
224 | qc->scsidone = ata_eh_scsidone; | ||
225 | __ata_qc_complete(qc); | ||
226 | WARN_ON(ata_tag_valid(qc->tag)); | ||
227 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
228 | |||
229 | scsi_eh_finish_cmd(scmd, &ap->eh_done_q); | ||
230 | } | ||
231 | |||
232 | /** | ||
233 | * ata_eh_qc_complete - Complete an active ATA command from EH | ||
234 | * @qc: Command to complete | ||
235 | * | ||
236 | * Indicate to the mid and upper layers that an ATA command has | ||
237 | * completed. To be used from EH. | ||
238 | */ | ||
239 | void ata_eh_qc_complete(struct ata_queued_cmd *qc) | ||
240 | { | ||
241 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
242 | scmd->retries = scmd->allowed; | ||
243 | __ata_eh_qc_complete(qc); | ||
244 | } | ||
245 | |||
246 | /** | ||
247 | * ata_eh_qc_retry - Tell midlayer to retry an ATA command after EH | ||
248 | * @qc: Command to retry | ||
249 | * | ||
250 | * Indicate to the mid and upper layers that an ATA command | ||
251 | * should be retried. To be used from EH. | ||
252 | * | ||
253 | * SCSI midlayer limits the number of retries to scmd->allowed. | ||
254 | * scmd->retries is decremented for commands which get retried | ||
255 | * due to unrelated failures (qc->err_mask is zero). | ||
256 | */ | ||
257 | void ata_eh_qc_retry(struct ata_queued_cmd *qc) | ||
258 | { | ||
259 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
260 | if (!qc->err_mask && scmd->retries) | ||
261 | scmd->retries--; | ||
262 | __ata_eh_qc_complete(qc); | ||
263 | } | ||
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index a0289ec3e283..9871f8272df0 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -53,8 +53,6 @@ | |||
53 | typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd); | 53 | typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd); |
54 | static struct ata_device * | 54 | static struct ata_device * |
55 | ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev); | 55 | ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev); |
56 | static void ata_scsi_error(struct Scsi_Host *host); | ||
57 | enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd); | ||
58 | 56 | ||
59 | #define RW_RECOVERY_MPAGE 0x1 | 57 | #define RW_RECOVERY_MPAGE 0x1 |
60 | #define RW_RECOVERY_MPAGE_LEN 12 | 58 | #define RW_RECOVERY_MPAGE_LEN 12 |
@@ -397,7 +395,7 @@ void ata_dump_status(unsigned id, struct ata_taskfile *tf) | |||
397 | 395 | ||
398 | int ata_scsi_device_resume(struct scsi_device *sdev) | 396 | int ata_scsi_device_resume(struct scsi_device *sdev) |
399 | { | 397 | { |
400 | struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0]; | 398 | struct ata_port *ap = ata_shost_to_port(sdev->host); |
401 | struct ata_device *dev = &ap->device[sdev->id]; | 399 | struct ata_device *dev = &ap->device[sdev->id]; |
402 | 400 | ||
403 | return ata_device_resume(ap, dev); | 401 | return ata_device_resume(ap, dev); |
@@ -405,7 +403,7 @@ int ata_scsi_device_resume(struct scsi_device *sdev) | |||
405 | 403 | ||
406 | int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t state) | 404 | int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t state) |
407 | { | 405 | { |
408 | struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0]; | 406 | struct ata_port *ap = ata_shost_to_port(sdev->host); |
409 | struct ata_device *dev = &ap->device[sdev->id]; | 407 | struct ata_device *dev = &ap->device[sdev->id]; |
410 | 408 | ||
411 | return ata_device_suspend(ap, dev, state); | 409 | return ata_device_suspend(ap, dev, state); |
@@ -548,16 +546,11 @@ void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc) | |||
548 | cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; | 546 | cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; |
549 | 547 | ||
550 | /* | 548 | /* |
551 | * Read the controller registers. | ||
552 | */ | ||
553 | WARN_ON(qc->ap->ops->tf_read == NULL); | ||
554 | qc->ap->ops->tf_read(qc->ap, tf); | ||
555 | |||
556 | /* | ||
557 | * Use ata_to_sense_error() to map status register bits | 549 | * Use ata_to_sense_error() to map status register bits |
558 | * onto sense key, asc & ascq. | 550 | * onto sense key, asc & ascq. |
559 | */ | 551 | */ |
560 | if (tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { | 552 | if (qc->err_mask || |
553 | tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { | ||
561 | ata_to_sense_error(qc->ap->id, tf->command, tf->feature, | 554 | ata_to_sense_error(qc->ap->id, tf->command, tf->feature, |
562 | &sb[1], &sb[2], &sb[3]); | 555 | &sb[1], &sb[2], &sb[3]); |
563 | sb[1] &= 0x0f; | 556 | sb[1] &= 0x0f; |
@@ -623,16 +616,11 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc) | |||
623 | cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; | 616 | cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; |
624 | 617 | ||
625 | /* | 618 | /* |
626 | * Read the controller registers. | ||
627 | */ | ||
628 | WARN_ON(qc->ap->ops->tf_read == NULL); | ||
629 | qc->ap->ops->tf_read(qc->ap, tf); | ||
630 | |||
631 | /* | ||
632 | * Use ata_to_sense_error() to map status register bits | 619 | * Use ata_to_sense_error() to map status register bits |
633 | * onto sense key, asc & ascq. | 620 | * onto sense key, asc & ascq. |
634 | */ | 621 | */ |
635 | if (tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { | 622 | if (qc->err_mask || |
623 | tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { | ||
636 | ata_to_sense_error(qc->ap->id, tf->command, tf->feature, | 624 | ata_to_sense_error(qc->ap->id, tf->command, tf->feature, |
637 | &sb[2], &sb[12], &sb[13]); | 625 | &sb[2], &sb[12], &sb[13]); |
638 | sb[2] &= 0x0f; | 626 | sb[2] &= 0x0f; |
@@ -716,7 +704,7 @@ int ata_scsi_slave_config(struct scsi_device *sdev) | |||
716 | struct ata_port *ap; | 704 | struct ata_port *ap; |
717 | struct ata_device *dev; | 705 | struct ata_device *dev; |
718 | 706 | ||
719 | ap = (struct ata_port *) &sdev->host->hostdata[0]; | 707 | ap = ata_shost_to_port(sdev->host); |
720 | dev = &ap->device[sdev->id]; | 708 | dev = &ap->device[sdev->id]; |
721 | 709 | ||
722 | ata_scsi_dev_config(sdev, dev); | 710 | ata_scsi_dev_config(sdev, dev); |
@@ -726,137 +714,6 @@ int ata_scsi_slave_config(struct scsi_device *sdev) | |||
726 | } | 714 | } |
727 | 715 | ||
728 | /** | 716 | /** |
729 | * ata_scsi_timed_out - SCSI layer time out callback | ||
730 | * @cmd: timed out SCSI command | ||
731 | * | ||
732 | * Handles SCSI layer timeout. We race with normal completion of | ||
733 | * the qc for @cmd. If the qc is already gone, we lose and let | ||
734 | * the scsi command finish (EH_HANDLED). Otherwise, the qc has | ||
735 | * timed out and EH should be invoked. Prevent ata_qc_complete() | ||
736 | * from finishing it by setting EH_SCHEDULED and return | ||
737 | * EH_NOT_HANDLED. | ||
738 | * | ||
739 | * LOCKING: | ||
740 | * Called from timer context | ||
741 | * | ||
742 | * RETURNS: | ||
743 | * EH_HANDLED or EH_NOT_HANDLED | ||
744 | */ | ||
745 | enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd) | ||
746 | { | ||
747 | struct Scsi_Host *host = cmd->device->host; | ||
748 | struct ata_port *ap = (struct ata_port *) &host->hostdata[0]; | ||
749 | unsigned long flags; | ||
750 | struct ata_queued_cmd *qc; | ||
751 | enum scsi_eh_timer_return ret = EH_HANDLED; | ||
752 | |||
753 | DPRINTK("ENTER\n"); | ||
754 | |||
755 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
756 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
757 | if (qc) { | ||
758 | WARN_ON(qc->scsicmd != cmd); | ||
759 | qc->flags |= ATA_QCFLAG_EH_SCHEDULED; | ||
760 | qc->err_mask |= AC_ERR_TIMEOUT; | ||
761 | ret = EH_NOT_HANDLED; | ||
762 | } | ||
763 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
764 | |||
765 | DPRINTK("EXIT, ret=%d\n", ret); | ||
766 | return ret; | ||
767 | } | ||
768 | |||
769 | /** | ||
770 | * ata_scsi_error - SCSI layer error handler callback | ||
771 | * @host: SCSI host on which error occurred | ||
772 | * | ||
773 | * Handles SCSI-layer-thrown error events. | ||
774 | * | ||
775 | * LOCKING: | ||
776 | * Inherited from SCSI layer (none, can sleep) | ||
777 | */ | ||
778 | |||
779 | static void ata_scsi_error(struct Scsi_Host *host) | ||
780 | { | ||
781 | struct ata_port *ap; | ||
782 | unsigned long flags; | ||
783 | |||
784 | DPRINTK("ENTER\n"); | ||
785 | |||
786 | ap = (struct ata_port *) &host->hostdata[0]; | ||
787 | |||
788 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
789 | WARN_ON(ap->flags & ATA_FLAG_IN_EH); | ||
790 | ap->flags |= ATA_FLAG_IN_EH; | ||
791 | WARN_ON(ata_qc_from_tag(ap, ap->active_tag) == NULL); | ||
792 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
793 | |||
794 | ata_port_flush_task(ap); | ||
795 | |||
796 | ap->ops->eng_timeout(ap); | ||
797 | |||
798 | WARN_ON(host->host_failed || !list_empty(&host->eh_cmd_q)); | ||
799 | |||
800 | scsi_eh_flush_done_q(&ap->eh_done_q); | ||
801 | |||
802 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
803 | ap->flags &= ~ATA_FLAG_IN_EH; | ||
804 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
805 | |||
806 | DPRINTK("EXIT\n"); | ||
807 | } | ||
808 | |||
809 | static void ata_eh_scsidone(struct scsi_cmnd *scmd) | ||
810 | { | ||
811 | /* nada */ | ||
812 | } | ||
813 | |||
814 | static void __ata_eh_qc_complete(struct ata_queued_cmd *qc) | ||
815 | { | ||
816 | struct ata_port *ap = qc->ap; | ||
817 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
818 | unsigned long flags; | ||
819 | |||
820 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
821 | qc->scsidone = ata_eh_scsidone; | ||
822 | __ata_qc_complete(qc); | ||
823 | WARN_ON(ata_tag_valid(qc->tag)); | ||
824 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
825 | |||
826 | scsi_eh_finish_cmd(scmd, &ap->eh_done_q); | ||
827 | } | ||
828 | |||
829 | /** | ||
830 | * ata_eh_qc_complete - Complete an active ATA command from EH | ||
831 | * @qc: Command to complete | ||
832 | * | ||
833 | * Indicate to the mid and upper layers that an ATA command has | ||
834 | * completed. To be used from EH. | ||
835 | */ | ||
836 | void ata_eh_qc_complete(struct ata_queued_cmd *qc) | ||
837 | { | ||
838 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
839 | scmd->retries = scmd->allowed; | ||
840 | __ata_eh_qc_complete(qc); | ||
841 | } | ||
842 | |||
843 | /** | ||
844 | * ata_eh_qc_retry - Tell midlayer to retry an ATA command after EH | ||
845 | * @qc: Command to retry | ||
846 | * | ||
847 | * Indicate to the mid and upper layers that an ATA command | ||
848 | * should be retried. To be used from EH. | ||
849 | * | ||
850 | * SCSI midlayer limits the number of retries to scmd->allowed. | ||
851 | * This function might need to adjust scmd->retries for commands | ||
852 | * which get retried due to unrelated NCQ failures. | ||
853 | */ | ||
854 | void ata_eh_qc_retry(struct ata_queued_cmd *qc) | ||
855 | { | ||
856 | __ata_eh_qc_complete(qc); | ||
857 | } | ||
858 | |||
859 | /** | ||
860 | * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command | 717 | * ata_scsi_start_stop_xlat - Translate SCSI START STOP UNIT command |
861 | * @qc: Storage for translated ATA taskfile | 718 | * @qc: Storage for translated ATA taskfile |
862 | * @scsicmd: SCSI command to translate | 719 | * @scsicmd: SCSI command to translate |
@@ -1195,6 +1052,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm | |||
1195 | u64 block; | 1052 | u64 block; |
1196 | u32 n_block; | 1053 | u32 n_block; |
1197 | 1054 | ||
1055 | qc->flags |= ATA_QCFLAG_IO; | ||
1198 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | 1056 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; |
1199 | 1057 | ||
1200 | if (scsicmd[0] == WRITE_10 || scsicmd[0] == WRITE_6 || | 1058 | if (scsicmd[0] == WRITE_10 || scsicmd[0] == WRITE_6 || |
@@ -1341,11 +1199,14 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) | |||
1341 | */ | 1199 | */ |
1342 | if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) && | 1200 | if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) && |
1343 | ((cdb[2] & 0x20) || need_sense)) { | 1201 | ((cdb[2] & 0x20) || need_sense)) { |
1202 | qc->ap->ops->tf_read(qc->ap, &qc->tf); | ||
1344 | ata_gen_ata_desc_sense(qc); | 1203 | ata_gen_ata_desc_sense(qc); |
1345 | } else { | 1204 | } else { |
1346 | if (!need_sense) { | 1205 | if (!need_sense) { |
1347 | cmd->result = SAM_STAT_GOOD; | 1206 | cmd->result = SAM_STAT_GOOD; |
1348 | } else { | 1207 | } else { |
1208 | qc->ap->ops->tf_read(qc->ap, &qc->tf); | ||
1209 | |||
1349 | /* TODO: decide which descriptor format to use | 1210 | /* TODO: decide which descriptor format to use |
1350 | * for 48b LBA devices and call that here | 1211 | * for 48b LBA devices and call that here |
1351 | * instead of the fixed desc, which is only | 1212 | * instead of the fixed desc, which is only |
@@ -2137,13 +1998,15 @@ void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8 | |||
2137 | 1998 | ||
2138 | static void atapi_sense_complete(struct ata_queued_cmd *qc) | 1999 | static void atapi_sense_complete(struct ata_queued_cmd *qc) |
2139 | { | 2000 | { |
2140 | if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) | 2001 | if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) { |
2141 | /* FIXME: not quite right; we don't want the | 2002 | /* FIXME: not quite right; we don't want the |
2142 | * translation of taskfile registers into | 2003 | * translation of taskfile registers into |
2143 | * a sense descriptors, since that's only | 2004 | * a sense descriptors, since that's only |
2144 | * correct for ATA, not ATAPI | 2005 | * correct for ATA, not ATAPI |
2145 | */ | 2006 | */ |
2007 | qc->ap->ops->tf_read(qc->ap, &qc->tf); | ||
2146 | ata_gen_ata_desc_sense(qc); | 2008 | ata_gen_ata_desc_sense(qc); |
2009 | } | ||
2147 | 2010 | ||
2148 | qc->scsidone(qc->scsicmd); | 2011 | qc->scsidone(qc->scsicmd); |
2149 | ata_qc_free(qc); | 2012 | ata_qc_free(qc); |
@@ -2211,17 +2074,15 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc) | |||
2211 | cmd->result = SAM_STAT_CHECK_CONDITION; | 2074 | cmd->result = SAM_STAT_CHECK_CONDITION; |
2212 | atapi_request_sense(qc); | 2075 | atapi_request_sense(qc); |
2213 | return; | 2076 | return; |
2214 | } | 2077 | } else if (unlikely(err_mask)) { |
2215 | |||
2216 | else if (unlikely(err_mask)) | ||
2217 | /* FIXME: not quite right; we don't want the | 2078 | /* FIXME: not quite right; we don't want the |
2218 | * translation of taskfile registers into | 2079 | * translation of taskfile registers into |
2219 | * a sense descriptors, since that's only | 2080 | * a sense descriptors, since that's only |
2220 | * correct for ATA, not ATAPI | 2081 | * correct for ATA, not ATAPI |
2221 | */ | 2082 | */ |
2083 | qc->ap->ops->tf_read(qc->ap, &qc->tf); | ||
2222 | ata_gen_ata_desc_sense(qc); | 2084 | ata_gen_ata_desc_sense(qc); |
2223 | 2085 | } else { | |
2224 | else { | ||
2225 | u8 *scsicmd = cmd->cmnd; | 2086 | u8 *scsicmd = cmd->cmnd; |
2226 | 2087 | ||
2227 | if ((scsicmd[0] == INQUIRY) && ((scsicmd[1] & 0x03) == 0)) { | 2088 | if ((scsicmd[0] == INQUIRY) && ((scsicmd[1] & 0x03) == 0)) { |
@@ -2303,11 +2164,9 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd) | |||
2303 | qc->tf.protocol = ATA_PROT_ATAPI_DMA; | 2164 | qc->tf.protocol = ATA_PROT_ATAPI_DMA; |
2304 | qc->tf.feature |= ATAPI_PKT_DMA; | 2165 | qc->tf.feature |= ATAPI_PKT_DMA; |
2305 | 2166 | ||
2306 | #ifdef ATAPI_ENABLE_DMADIR | 2167 | if (atapi_dmadir && (cmd->sc_data_direction != DMA_TO_DEVICE)) |
2307 | /* some SATA bridges need us to indicate data xfer direction */ | 2168 | /* some SATA bridges need us to indicate data xfer direction */ |
2308 | if (cmd->sc_data_direction != DMA_TO_DEVICE) | ||
2309 | qc->tf.feature |= ATAPI_DMADIR; | 2169 | qc->tf.feature |= ATAPI_DMADIR; |
2310 | #endif | ||
2311 | } | 2170 | } |
2312 | 2171 | ||
2313 | qc->nbytes = cmd->bufflen; | 2172 | qc->nbytes = cmd->bufflen; |
@@ -2347,7 +2206,7 @@ ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev) | |||
2347 | (scsidev->lun != 0))) | 2206 | (scsidev->lun != 0))) |
2348 | return NULL; | 2207 | return NULL; |
2349 | 2208 | ||
2350 | if (unlikely(!ata_dev_present(dev))) | 2209 | if (unlikely(!ata_dev_enabled(dev))) |
2351 | return NULL; | 2210 | return NULL; |
2352 | 2211 | ||
2353 | if (!atapi_enabled || (ap->flags & ATA_FLAG_NO_ATAPI)) { | 2212 | if (!atapi_enabled || (ap->flags & ATA_FLAG_NO_ATAPI)) { |
@@ -2619,7 +2478,7 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) | |||
2619 | struct scsi_device *scsidev = cmd->device; | 2478 | struct scsi_device *scsidev = cmd->device; |
2620 | struct Scsi_Host *shost = scsidev->host; | 2479 | struct Scsi_Host *shost = scsidev->host; |
2621 | 2480 | ||
2622 | ap = (struct ata_port *) &shost->hostdata[0]; | 2481 | ap = ata_shost_to_port(shost); |
2623 | 2482 | ||
2624 | spin_unlock(shost->host_lock); | 2483 | spin_unlock(shost->host_lock); |
2625 | spin_lock(&ap->host_set->lock); | 2484 | spin_lock(&ap->host_set->lock); |
@@ -2735,13 +2594,13 @@ void ata_scsi_scan_host(struct ata_port *ap) | |||
2735 | struct ata_device *dev; | 2594 | struct ata_device *dev; |
2736 | unsigned int i; | 2595 | unsigned int i; |
2737 | 2596 | ||
2738 | if (ap->flags & ATA_FLAG_PORT_DISABLED) | 2597 | if (ap->flags & ATA_FLAG_DISABLED) |
2739 | return; | 2598 | return; |
2740 | 2599 | ||
2741 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 2600 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
2742 | dev = &ap->device[i]; | 2601 | dev = &ap->device[i]; |
2743 | 2602 | ||
2744 | if (ata_dev_present(dev)) | 2603 | if (ata_dev_enabled(dev)) |
2745 | scsi_scan_target(&ap->host->shost_gendev, 0, i, 0, 0); | 2604 | scsi_scan_target(&ap->host->shost_gendev, 0, i, 0, 0); |
2746 | } | 2605 | } |
2747 | } | 2606 | } |
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h index bac8cbae06fe..3f8b0a863781 100644 --- a/drivers/scsi/libata.h +++ b/drivers/scsi/libata.h | |||
@@ -29,7 +29,7 @@ | |||
29 | #define __LIBATA_H__ | 29 | #define __LIBATA_H__ |
30 | 30 | ||
31 | #define DRV_NAME "libata" | 31 | #define DRV_NAME "libata" |
32 | #define DRV_VERSION "1.20" /* must be exactly four chars */ | 32 | #define DRV_VERSION "1.30" /* must be exactly four chars */ |
33 | 33 | ||
34 | struct ata_scsi_args { | 34 | struct ata_scsi_args { |
35 | struct ata_port *ap; | 35 | struct ata_port *ap; |
@@ -41,11 +41,23 @@ struct ata_scsi_args { | |||
41 | 41 | ||
42 | /* libata-core.c */ | 42 | /* libata-core.c */ |
43 | extern int atapi_enabled; | 43 | extern int atapi_enabled; |
44 | extern int atapi_dmadir; | ||
44 | extern int libata_fua; | 45 | extern int libata_fua; |
45 | extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, | 46 | extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, |
46 | struct ata_device *dev); | 47 | struct ata_device *dev); |
47 | extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc); | 48 | extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc); |
49 | extern void ata_dev_disable(struct ata_port *ap, struct ata_device *dev); | ||
48 | extern void ata_port_flush_task(struct ata_port *ap); | 50 | extern void ata_port_flush_task(struct ata_port *ap); |
51 | extern unsigned ata_exec_internal(struct ata_port *ap, struct ata_device *dev, | ||
52 | struct ata_taskfile *tf, const u8 *cdb, | ||
53 | int dma_dir, void *buf, unsigned int buflen); | ||
54 | extern int ata_down_sata_spd_limit(struct ata_port *ap); | ||
55 | extern int ata_set_sata_spd_needed(struct ata_port *ap); | ||
56 | extern int ata_down_xfermask_limit(struct ata_port *ap, struct ata_device *dev, | ||
57 | int force_pio0); | ||
58 | extern int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev); | ||
59 | extern int ata_do_reset(struct ata_port *ap, ata_reset_fn_t reset, | ||
60 | ata_postreset_fn_t postreset, unsigned int *classes); | ||
49 | extern void ata_qc_free(struct ata_queued_cmd *qc); | 61 | extern void ata_qc_free(struct ata_queued_cmd *qc); |
50 | extern void ata_qc_issue(struct ata_queued_cmd *qc); | 62 | extern void ata_qc_issue(struct ata_queued_cmd *qc); |
51 | extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); | 63 | extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); |
@@ -89,4 +101,8 @@ extern void ata_scsi_rbuf_fill(struct ata_scsi_args *args, | |||
89 | unsigned int (*actor) (struct ata_scsi_args *args, | 101 | unsigned int (*actor) (struct ata_scsi_args *args, |
90 | u8 *rbuf, unsigned int buflen)); | 102 | u8 *rbuf, unsigned int buflen)); |
91 | 103 | ||
104 | /* libata-eh.c */ | ||
105 | extern enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd); | ||
106 | extern void ata_scsi_error(struct Scsi_Host *host); | ||
107 | |||
92 | #endif /* __LIBATA_H__ */ | 108 | #endif /* __LIBATA_H__ */ |
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c index 5cda16cfacb0..b9a3c566f833 100644 --- a/drivers/scsi/pdc_adma.c +++ b/drivers/scsi/pdc_adma.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/libata.h> | 46 | #include <linux/libata.h> |
47 | 47 | ||
48 | #define DRV_NAME "pdc_adma" | 48 | #define DRV_NAME "pdc_adma" |
49 | #define DRV_VERSION "0.03" | 49 | #define DRV_VERSION "0.04" |
50 | 50 | ||
51 | /* macro to calculate base address for ATA regs */ | 51 | /* macro to calculate base address for ATA regs */ |
52 | #define ADMA_ATA_REGS(base,port_no) ((base) + ((port_no) * 0x40)) | 52 | #define ADMA_ATA_REGS(base,port_no) ((base) + ((port_no) * 0x40)) |
@@ -455,7 +455,7 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set) | |||
455 | continue; | 455 | continue; |
456 | handled = 1; | 456 | handled = 1; |
457 | adma_enter_reg_mode(ap); | 457 | adma_enter_reg_mode(ap); |
458 | if (ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR)) | 458 | if (ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR)) |
459 | continue; | 459 | continue; |
460 | pp = ap->private_data; | 460 | pp = ap->private_data; |
461 | if (!pp || pp->state != adma_state_pkt) | 461 | if (!pp || pp->state != adma_state_pkt) |
@@ -480,7 +480,7 @@ static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set) | |||
480 | for (port_no = 0; port_no < host_set->n_ports; ++port_no) { | 480 | for (port_no = 0; port_no < host_set->n_ports; ++port_no) { |
481 | struct ata_port *ap; | 481 | struct ata_port *ap; |
482 | ap = host_set->ports[port_no]; | 482 | ap = host_set->ports[port_no]; |
483 | if (ap && (!(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR)))) { | 483 | if (ap && (!(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR)))) { |
484 | struct ata_queued_cmd *qc; | 484 | struct ata_queued_cmd *qc; |
485 | struct adma_port_priv *pp = ap->private_data; | 485 | struct adma_port_priv *pp = ap->private_data; |
486 | if (!pp || pp->state != adma_state_mmio) | 486 | if (!pp || pp->state != adma_state_mmio) |
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c index d5fdcb9a8842..181917ac0426 100644 --- a/drivers/scsi/sata_mv.c +++ b/drivers/scsi/sata_mv.c | |||
@@ -1396,7 +1396,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, | |||
1396 | } | 1396 | } |
1397 | } | 1397 | } |
1398 | 1398 | ||
1399 | if (ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR)) | 1399 | if (ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR)) |
1400 | continue; | 1400 | continue; |
1401 | 1401 | ||
1402 | err_mask = ac_err_mask(ata_status); | 1402 | err_mask = ac_err_mask(ata_status); |
@@ -1990,7 +1990,7 @@ comreset_retry: | |||
1990 | tf.nsect = readb((void __iomem *) ap->ioaddr.nsect_addr); | 1990 | tf.nsect = readb((void __iomem *) ap->ioaddr.nsect_addr); |
1991 | 1991 | ||
1992 | dev->class = ata_dev_classify(&tf); | 1992 | dev->class = ata_dev_classify(&tf); |
1993 | if (!ata_dev_present(dev)) { | 1993 | if (!ata_dev_enabled(dev)) { |
1994 | VPRINTK("Port disabled post-sig: No device present.\n"); | 1994 | VPRINTK("Port disabled post-sig: No device present.\n"); |
1995 | ata_port_disable(ap); | 1995 | ata_port_disable(ap); |
1996 | } | 1996 | } |
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c index 9f553081b5e8..3a70875be8ba 100644 --- a/drivers/scsi/sata_nv.c +++ b/drivers/scsi/sata_nv.c | |||
@@ -44,7 +44,7 @@ | |||
44 | #include <linux/libata.h> | 44 | #include <linux/libata.h> |
45 | 45 | ||
46 | #define DRV_NAME "sata_nv" | 46 | #define DRV_NAME "sata_nv" |
47 | #define DRV_VERSION "0.8" | 47 | #define DRV_VERSION "0.9" |
48 | 48 | ||
49 | enum { | 49 | enum { |
50 | NV_PORTS = 2, | 50 | NV_PORTS = 2, |
@@ -279,7 +279,7 @@ static irqreturn_t nv_interrupt (int irq, void *dev_instance, | |||
279 | 279 | ||
280 | ap = host_set->ports[i]; | 280 | ap = host_set->ports[i]; |
281 | if (ap && | 281 | if (ap && |
282 | !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) { | 282 | !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) { |
283 | struct ata_queued_cmd *qc; | 283 | struct ata_queued_cmd *qc; |
284 | 284 | ||
285 | qc = ata_qc_from_tag(ap, ap->active_tag); | 285 | qc = ata_qc_from_tag(ap, ap->active_tag); |
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c index 7eb67a6bdc64..ddbc0c6dd9fe 100644 --- a/drivers/scsi/sata_promise.c +++ b/drivers/scsi/sata_promise.c | |||
@@ -533,7 +533,7 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *r | |||
533 | ap = host_set->ports[i]; | 533 | ap = host_set->ports[i]; |
534 | tmp = mask & (1 << (i + 1)); | 534 | tmp = mask & (1 << (i + 1)); |
535 | if (tmp && ap && | 535 | if (tmp && ap && |
536 | !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) { | 536 | !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) { |
537 | struct ata_queued_cmd *qc; | 537 | struct ata_queued_cmd *qc; |
538 | 538 | ||
539 | qc = ata_qc_from_tag(ap, ap->active_tag); | 539 | qc = ata_qc_from_tag(ap, ap->active_tag); |
@@ -676,10 +676,6 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
676 | if (!printed_version++) | 676 | if (!printed_version++) |
677 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 677 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
678 | 678 | ||
679 | /* | ||
680 | * If this driver happens to only be useful on Apple's K2, then | ||
681 | * we should check that here as it has a normal Serverworks ID | ||
682 | */ | ||
683 | rc = pci_enable_device(pdev); | 679 | rc = pci_enable_device(pdev); |
684 | if (rc) | 680 | if (rc) |
685 | return rc; | 681 | return rc; |
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c index 886f3447dd48..259c2dec4e21 100644 --- a/drivers/scsi/sata_qstor.c +++ b/drivers/scsi/sata_qstor.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #include <linux/libata.h> | 41 | #include <linux/libata.h> |
42 | 42 | ||
43 | #define DRV_NAME "sata_qstor" | 43 | #define DRV_NAME "sata_qstor" |
44 | #define DRV_VERSION "0.05" | 44 | #define DRV_VERSION "0.06" |
45 | 45 | ||
46 | enum { | 46 | enum { |
47 | QS_PORTS = 4, | 47 | QS_PORTS = 4, |
@@ -395,7 +395,7 @@ static inline unsigned int qs_intr_pkt(struct ata_host_set *host_set) | |||
395 | sff1, sff0, port_no, sHST, sDST); | 395 | sff1, sff0, port_no, sHST, sDST); |
396 | handled = 1; | 396 | handled = 1; |
397 | if (ap && !(ap->flags & | 397 | if (ap && !(ap->flags & |
398 | (ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) { | 398 | (ATA_FLAG_DISABLED|ATA_FLAG_NOINTR))) { |
399 | struct ata_queued_cmd *qc; | 399 | struct ata_queued_cmd *qc; |
400 | struct qs_port_priv *pp = ap->private_data; | 400 | struct qs_port_priv *pp = ap->private_data; |
401 | if (!pp || pp->state != qs_state_pkt) | 401 | if (!pp || pp->state != qs_state_pkt) |
@@ -428,7 +428,7 @@ static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set) | |||
428 | struct ata_port *ap; | 428 | struct ata_port *ap; |
429 | ap = host_set->ports[port_no]; | 429 | ap = host_set->ports[port_no]; |
430 | if (ap && | 430 | if (ap && |
431 | !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) { | 431 | !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) { |
432 | struct ata_queued_cmd *qc; | 432 | struct ata_queued_cmd *qc; |
433 | struct qs_port_priv *pp = ap->private_data; | 433 | struct qs_port_priv *pp = ap->private_data; |
434 | if (!pp || pp->state != qs_state_mmio) | 434 | if (!pp || pp->state != qs_state_mmio) |
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c index 106627299d55..c9333577330e 100644 --- a/drivers/scsi/sata_sil.c +++ b/drivers/scsi/sata_sil.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/libata.h> | 46 | #include <linux/libata.h> |
47 | 47 | ||
48 | #define DRV_NAME "sata_sil" | 48 | #define DRV_NAME "sata_sil" |
49 | #define DRV_VERSION "0.9" | 49 | #define DRV_VERSION "1.0" |
50 | 50 | ||
51 | enum { | 51 | enum { |
52 | /* | 52 | /* |
@@ -263,7 +263,7 @@ static void sil_post_set_mode (struct ata_port *ap) | |||
263 | 263 | ||
264 | for (i = 0; i < 2; i++) { | 264 | for (i = 0; i < 2; i++) { |
265 | dev = &ap->device[i]; | 265 | dev = &ap->device[i]; |
266 | if (!ata_dev_present(dev)) | 266 | if (!ata_dev_enabled(dev)) |
267 | dev_mode[i] = 0; /* PIO0/1/2 */ | 267 | dev_mode[i] = 0; /* PIO0/1/2 */ |
268 | else if (dev->flags & ATA_DFLAG_PIO) | 268 | else if (dev->flags & ATA_DFLAG_PIO) |
269 | dev_mode[i] = 1; /* PIO3/4 */ | 269 | dev_mode[i] = 1; /* PIO3/4 */ |
@@ -390,10 +390,6 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
390 | if (!printed_version++) | 390 | if (!printed_version++) |
391 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 391 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
392 | 392 | ||
393 | /* | ||
394 | * If this driver happens to only be useful on Apple's K2, then | ||
395 | * we should check that here as it has a normal Serverworks ID | ||
396 | */ | ||
397 | rc = pci_enable_device(pdev); | 393 | rc = pci_enable_device(pdev); |
398 | if (rc) | 394 | if (rc) |
399 | return rc; | 395 | return rc; |
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c index f7264fd611c2..e9fd869140c5 100644 --- a/drivers/scsi/sata_sil24.c +++ b/drivers/scsi/sata_sil24.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <asm/io.h> | 31 | #include <asm/io.h> |
32 | 32 | ||
33 | #define DRV_NAME "sata_sil24" | 33 | #define DRV_NAME "sata_sil24" |
34 | #define DRV_VERSION "0.23" | 34 | #define DRV_VERSION "0.24" |
35 | 35 | ||
36 | /* | 36 | /* |
37 | * Port request block (PRB) 32 bytes | 37 | * Port request block (PRB) 32 bytes |
@@ -86,6 +86,13 @@ enum { | |||
86 | /* HOST_SLOT_STAT bits */ | 86 | /* HOST_SLOT_STAT bits */ |
87 | HOST_SSTAT_ATTN = (1 << 31), | 87 | HOST_SSTAT_ATTN = (1 << 31), |
88 | 88 | ||
89 | /* HOST_CTRL bits */ | ||
90 | HOST_CTRL_M66EN = (1 << 16), /* M66EN PCI bus signal */ | ||
91 | HOST_CTRL_TRDY = (1 << 17), /* latched PCI TRDY */ | ||
92 | HOST_CTRL_STOP = (1 << 18), /* latched PCI STOP */ | ||
93 | HOST_CTRL_DEVSEL = (1 << 19), /* latched PCI DEVSEL */ | ||
94 | HOST_CTRL_REQ64 = (1 << 20), /* latched PCI REQ64 */ | ||
95 | |||
89 | /* | 96 | /* |
90 | * Port registers | 97 | * Port registers |
91 | * (8192 bytes @ +0x0000, +0x2000, +0x4000 and +0x6000 @ BAR2) | 98 | * (8192 bytes @ +0x0000, +0x2000, +0x4000 and +0x6000 @ BAR2) |
@@ -142,8 +149,12 @@ enum { | |||
142 | PORT_IRQ_PWR_CHG = (1 << 3), /* power management change */ | 149 | PORT_IRQ_PWR_CHG = (1 << 3), /* power management change */ |
143 | PORT_IRQ_PHYRDY_CHG = (1 << 4), /* PHY ready change */ | 150 | PORT_IRQ_PHYRDY_CHG = (1 << 4), /* PHY ready change */ |
144 | PORT_IRQ_COMWAKE = (1 << 5), /* COMWAKE received */ | 151 | PORT_IRQ_COMWAKE = (1 << 5), /* COMWAKE received */ |
145 | PORT_IRQ_UNK_FIS = (1 << 6), /* Unknown FIS received */ | 152 | PORT_IRQ_UNK_FIS = (1 << 6), /* unknown FIS received */ |
146 | PORT_IRQ_SDB_FIS = (1 << 11), /* SDB FIS received */ | 153 | PORT_IRQ_DEV_XCHG = (1 << 7), /* device exchanged */ |
154 | PORT_IRQ_8B10B = (1 << 8), /* 8b/10b decode error threshold */ | ||
155 | PORT_IRQ_CRC = (1 << 9), /* CRC error threshold */ | ||
156 | PORT_IRQ_HANDSHAKE = (1 << 10), /* handshake error threshold */ | ||
157 | PORT_IRQ_SDB_NOTIFY = (1 << 11), /* SDB notify received */ | ||
147 | 158 | ||
148 | /* bits[27:16] are unmasked (raw) */ | 159 | /* bits[27:16] are unmasked (raw) */ |
149 | PORT_IRQ_RAW_SHIFT = 16, | 160 | PORT_IRQ_RAW_SHIFT = 16, |
@@ -174,7 +185,7 @@ enum { | |||
174 | PORT_CERR_CMD_PCIPERR = 27, /* ctrl[15:13] 110 - PCI parity err while fetching PRB */ | 185 | PORT_CERR_CMD_PCIPERR = 27, /* ctrl[15:13] 110 - PCI parity err while fetching PRB */ |
175 | PORT_CERR_XFR_UNDEF = 32, /* PSD ecode 00 - undefined */ | 186 | PORT_CERR_XFR_UNDEF = 32, /* PSD ecode 00 - undefined */ |
176 | PORT_CERR_XFR_TGTABRT = 33, /* PSD ecode 01 - target abort */ | 187 | PORT_CERR_XFR_TGTABRT = 33, /* PSD ecode 01 - target abort */ |
177 | PORT_CERR_XFR_MSGABRT = 34, /* PSD ecode 10 - master abort */ | 188 | PORT_CERR_XFR_MSTABRT = 34, /* PSD ecode 10 - master abort */ |
178 | PORT_CERR_XFR_PCIPERR = 35, /* PSD ecode 11 - PCI prity err during transfer */ | 189 | PORT_CERR_XFR_PCIPERR = 35, /* PSD ecode 11 - PCI prity err during transfer */ |
179 | PORT_CERR_SENDSERVICE = 36, /* FIS received while sending service */ | 190 | PORT_CERR_SENDSERVICE = 36, /* FIS received while sending service */ |
180 | 191 | ||
@@ -207,6 +218,11 @@ enum { | |||
207 | BID_SIL3132 = 1, | 218 | BID_SIL3132 = 1, |
208 | BID_SIL3131 = 2, | 219 | BID_SIL3131 = 2, |
209 | 220 | ||
221 | /* host flags */ | ||
222 | SIL24_COMMON_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | ||
223 | ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA, | ||
224 | SIL24_FLAG_PCIX_IRQ_WOC = (1 << 24), /* IRQ loss errata on PCI-X */ | ||
225 | |||
210 | IRQ_STAT_4PORTS = 0xf, | 226 | IRQ_STAT_4PORTS = 0xf, |
211 | }; | 227 | }; |
212 | 228 | ||
@@ -333,9 +349,8 @@ static struct ata_port_info sil24_port_info[] = { | |||
333 | /* sil_3124 */ | 349 | /* sil_3124 */ |
334 | { | 350 | { |
335 | .sht = &sil24_sht, | 351 | .sht = &sil24_sht, |
336 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 352 | .host_flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(4) | |
337 | ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | | 353 | SIL24_FLAG_PCIX_IRQ_WOC, |
338 | SIL24_NPORTS2FLAG(4), | ||
339 | .pio_mask = 0x1f, /* pio0-4 */ | 354 | .pio_mask = 0x1f, /* pio0-4 */ |
340 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 355 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
341 | .udma_mask = 0x3f, /* udma0-5 */ | 356 | .udma_mask = 0x3f, /* udma0-5 */ |
@@ -344,9 +359,7 @@ static struct ata_port_info sil24_port_info[] = { | |||
344 | /* sil_3132 */ | 359 | /* sil_3132 */ |
345 | { | 360 | { |
346 | .sht = &sil24_sht, | 361 | .sht = &sil24_sht, |
347 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 362 | .host_flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(2), |
348 | ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | | ||
349 | SIL24_NPORTS2FLAG(2), | ||
350 | .pio_mask = 0x1f, /* pio0-4 */ | 363 | .pio_mask = 0x1f, /* pio0-4 */ |
351 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 364 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
352 | .udma_mask = 0x3f, /* udma0-5 */ | 365 | .udma_mask = 0x3f, /* udma0-5 */ |
@@ -355,9 +368,7 @@ static struct ata_port_info sil24_port_info[] = { | |||
355 | /* sil_3131/sil_3531 */ | 368 | /* sil_3131/sil_3531 */ |
356 | { | 369 | { |
357 | .sht = &sil24_sht, | 370 | .sht = &sil24_sht, |
358 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 371 | .host_flags = SIL24_COMMON_FLAGS | SIL24_NPORTS2FLAG(1), |
359 | ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | | ||
360 | SIL24_NPORTS2FLAG(1), | ||
361 | .pio_mask = 0x1f, /* pio0-4 */ | 372 | .pio_mask = 0x1f, /* pio0-4 */ |
362 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 373 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
363 | .udma_mask = 0x3f, /* udma0-5 */ | 374 | .udma_mask = 0x3f, /* udma0-5 */ |
@@ -426,15 +437,30 @@ static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf) | |||
426 | *tf = pp->tf; | 437 | *tf = pp->tf; |
427 | } | 438 | } |
428 | 439 | ||
429 | static int sil24_softreset(struct ata_port *ap, int verbose, | 440 | static int sil24_init_port(struct ata_port *ap) |
430 | unsigned int *class) | 441 | { |
442 | void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; | ||
443 | u32 tmp; | ||
444 | |||
445 | writel(PORT_CS_INIT, port + PORT_CTRL_STAT); | ||
446 | ata_wait_register(port + PORT_CTRL_STAT, | ||
447 | PORT_CS_INIT, PORT_CS_INIT, 10, 100); | ||
448 | tmp = ata_wait_register(port + PORT_CTRL_STAT, | ||
449 | PORT_CS_RDY, 0, 10, 100); | ||
450 | |||
451 | if ((tmp & (PORT_CS_INIT | PORT_CS_RDY)) != PORT_CS_RDY) | ||
452 | return -EIO; | ||
453 | return 0; | ||
454 | } | ||
455 | |||
456 | static int sil24_softreset(struct ata_port *ap, unsigned int *class) | ||
431 | { | 457 | { |
432 | void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; | 458 | void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; |
433 | struct sil24_port_priv *pp = ap->private_data; | 459 | struct sil24_port_priv *pp = ap->private_data; |
434 | struct sil24_prb *prb = &pp->cmd_block[0].ata.prb; | 460 | struct sil24_prb *prb = &pp->cmd_block[0].ata.prb; |
435 | dma_addr_t paddr = pp->cmd_block_dma; | 461 | dma_addr_t paddr = pp->cmd_block_dma; |
436 | unsigned long timeout = jiffies + ATA_TMOUT_BOOT * HZ; | 462 | u32 mask, irq_enable, irq_stat; |
437 | u32 irq_enable, irq_stat; | 463 | const char *reason; |
438 | 464 | ||
439 | DPRINTK("ENTER\n"); | 465 | DPRINTK("ENTER\n"); |
440 | 466 | ||
@@ -448,34 +474,35 @@ static int sil24_softreset(struct ata_port *ap, int verbose, | |||
448 | irq_enable = readl(port + PORT_IRQ_ENABLE_SET); | 474 | irq_enable = readl(port + PORT_IRQ_ENABLE_SET); |
449 | writel(irq_enable, port + PORT_IRQ_ENABLE_CLR); | 475 | writel(irq_enable, port + PORT_IRQ_ENABLE_CLR); |
450 | 476 | ||
451 | /* | 477 | /* put the port into known state */ |
452 | * XXX: Not sure whether the following sleep is needed or not. | 478 | if (sil24_init_port(ap)) { |
453 | * The original driver had it. So.... | 479 | reason ="port not ready"; |
454 | */ | 480 | goto err; |
455 | msleep(10); | 481 | } |
456 | 482 | ||
457 | prb->ctrl = PRB_CTRL_SRST; | 483 | /* do SRST */ |
484 | prb->ctrl = cpu_to_le16(PRB_CTRL_SRST); | ||
458 | prb->fis[1] = 0; /* no PM yet */ | 485 | prb->fis[1] = 0; /* no PM yet */ |
459 | 486 | ||
460 | writel((u32)paddr, port + PORT_CMD_ACTIVATE); | 487 | writel((u32)paddr, port + PORT_CMD_ACTIVATE); |
488 | writel((u64)paddr >> 32, port + PORT_CMD_ACTIVATE + 4); | ||
461 | 489 | ||
462 | do { | 490 | mask = (PORT_IRQ_COMPLETE | PORT_IRQ_ERROR) << PORT_IRQ_RAW_SHIFT; |
463 | irq_stat = readl(port + PORT_IRQ_STAT); | 491 | irq_stat = ata_wait_register(port + PORT_IRQ_STAT, mask, 0x0, |
464 | writel(irq_stat, port + PORT_IRQ_STAT); /* clear irq */ | 492 | 100, ATA_TMOUT_BOOT / HZ * 1000); |
465 | |||
466 | irq_stat >>= PORT_IRQ_RAW_SHIFT; | ||
467 | if (irq_stat & (PORT_IRQ_COMPLETE | PORT_IRQ_ERROR)) | ||
468 | break; | ||
469 | 493 | ||
470 | msleep(100); | 494 | writel(irq_stat, port + PORT_IRQ_STAT); /* clear IRQs */ |
471 | } while (time_before(jiffies, timeout)); | 495 | irq_stat >>= PORT_IRQ_RAW_SHIFT; |
472 | 496 | ||
473 | /* restore IRQs */ | 497 | /* restore IRQs */ |
474 | writel(irq_enable, port + PORT_IRQ_ENABLE_SET); | 498 | writel(irq_enable, port + PORT_IRQ_ENABLE_SET); |
475 | 499 | ||
476 | if (!(irq_stat & PORT_IRQ_COMPLETE)) { | 500 | if (!(irq_stat & PORT_IRQ_COMPLETE)) { |
477 | DPRINTK("EXIT, srst failed\n"); | 501 | if (irq_stat & PORT_IRQ_ERROR) |
478 | return -EIO; | 502 | reason = "SRST command error"; |
503 | else | ||
504 | reason = "timeout"; | ||
505 | goto err; | ||
479 | } | 506 | } |
480 | 507 | ||
481 | sil24_update_tf(ap); | 508 | sil24_update_tf(ap); |
@@ -487,15 +514,55 @@ static int sil24_softreset(struct ata_port *ap, int verbose, | |||
487 | out: | 514 | out: |
488 | DPRINTK("EXIT, class=%u\n", *class); | 515 | DPRINTK("EXIT, class=%u\n", *class); |
489 | return 0; | 516 | return 0; |
517 | |||
518 | err: | ||
519 | printk(KERN_ERR "ata%u: softreset failed (%s)\n", ap->id, reason); | ||
520 | return -EIO; | ||
490 | } | 521 | } |
491 | 522 | ||
492 | static int sil24_hardreset(struct ata_port *ap, int verbose, | 523 | static int sil24_hardreset(struct ata_port *ap, unsigned int *class) |
493 | unsigned int *class) | ||
494 | { | 524 | { |
495 | unsigned int dummy_class; | 525 | void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; |
526 | const char *reason; | ||
527 | int tout_msec; | ||
528 | u32 tmp; | ||
529 | |||
530 | /* sil24 does the right thing(tm) without any protection */ | ||
531 | ata_set_sata_spd(ap); | ||
532 | |||
533 | tout_msec = 100; | ||
534 | if (sata_dev_present(ap)) | ||
535 | tout_msec = 5000; | ||
496 | 536 | ||
497 | /* sil24 doesn't report device signature after hard reset */ | 537 | writel(PORT_CS_DEV_RST, port + PORT_CTRL_STAT); |
498 | return sata_std_hardreset(ap, verbose, &dummy_class); | 538 | tmp = ata_wait_register(port + PORT_CTRL_STAT, |
539 | PORT_CS_DEV_RST, PORT_CS_DEV_RST, 10, tout_msec); | ||
540 | |||
541 | /* SStatus oscillates between zero and valid status for short | ||
542 | * duration after DEV_RST, give it time to settle. | ||
543 | */ | ||
544 | msleep(100); | ||
545 | |||
546 | if (tmp & PORT_CS_DEV_RST) { | ||
547 | if (!sata_dev_present(ap)) | ||
548 | return 0; | ||
549 | reason = "link not ready"; | ||
550 | goto err; | ||
551 | } | ||
552 | |||
553 | if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) { | ||
554 | reason = "device not ready"; | ||
555 | goto err; | ||
556 | } | ||
557 | |||
558 | /* sil24 doesn't report device class code after hardreset, | ||
559 | * leave *class alone. | ||
560 | */ | ||
561 | return 0; | ||
562 | |||
563 | err: | ||
564 | printk(KERN_ERR "ata%u: hardreset failed (%s)\n", ap->id, reason); | ||
565 | return -EIO; | ||
499 | } | 566 | } |
500 | 567 | ||
501 | static int sil24_probe_reset(struct ata_port *ap, unsigned int *classes) | 568 | static int sil24_probe_reset(struct ata_port *ap, unsigned int *classes) |
@@ -531,6 +598,7 @@ static void sil24_qc_prep(struct ata_queued_cmd *qc) | |||
531 | union sil24_cmd_block *cb = pp->cmd_block + qc->tag; | 598 | union sil24_cmd_block *cb = pp->cmd_block + qc->tag; |
532 | struct sil24_prb *prb; | 599 | struct sil24_prb *prb; |
533 | struct sil24_sge *sge; | 600 | struct sil24_sge *sge; |
601 | u16 ctrl = 0; | ||
534 | 602 | ||
535 | switch (qc->tf.protocol) { | 603 | switch (qc->tf.protocol) { |
536 | case ATA_PROT_PIO: | 604 | case ATA_PROT_PIO: |
@@ -538,7 +606,6 @@ static void sil24_qc_prep(struct ata_queued_cmd *qc) | |||
538 | case ATA_PROT_NODATA: | 606 | case ATA_PROT_NODATA: |
539 | prb = &cb->ata.prb; | 607 | prb = &cb->ata.prb; |
540 | sge = cb->ata.sge; | 608 | sge = cb->ata.sge; |
541 | prb->ctrl = 0; | ||
542 | break; | 609 | break; |
543 | 610 | ||
544 | case ATA_PROT_ATAPI: | 611 | case ATA_PROT_ATAPI: |
@@ -551,12 +618,10 @@ static void sil24_qc_prep(struct ata_queued_cmd *qc) | |||
551 | 618 | ||
552 | if (qc->tf.protocol != ATA_PROT_ATAPI_NODATA) { | 619 | if (qc->tf.protocol != ATA_PROT_ATAPI_NODATA) { |
553 | if (qc->tf.flags & ATA_TFLAG_WRITE) | 620 | if (qc->tf.flags & ATA_TFLAG_WRITE) |
554 | prb->ctrl = PRB_CTRL_PACKET_WRITE; | 621 | ctrl = PRB_CTRL_PACKET_WRITE; |
555 | else | 622 | else |
556 | prb->ctrl = PRB_CTRL_PACKET_READ; | 623 | ctrl = PRB_CTRL_PACKET_READ; |
557 | } else | 624 | } |
558 | prb->ctrl = 0; | ||
559 | |||
560 | break; | 625 | break; |
561 | 626 | ||
562 | default: | 627 | default: |
@@ -565,6 +630,7 @@ static void sil24_qc_prep(struct ata_queued_cmd *qc) | |||
565 | BUG(); | 630 | BUG(); |
566 | } | 631 | } |
567 | 632 | ||
633 | prb->ctrl = cpu_to_le16(ctrl); | ||
568 | ata_tf_to_fis(&qc->tf, prb->fis, 0); | 634 | ata_tf_to_fis(&qc->tf, prb->fis, 0); |
569 | 635 | ||
570 | if (qc->flags & ATA_QCFLAG_DMAMAP) | 636 | if (qc->flags & ATA_QCFLAG_DMAMAP) |
@@ -579,6 +645,8 @@ static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc) | |||
579 | dma_addr_t paddr = pp->cmd_block_dma + qc->tag * sizeof(*pp->cmd_block); | 645 | dma_addr_t paddr = pp->cmd_block_dma + qc->tag * sizeof(*pp->cmd_block); |
580 | 646 | ||
581 | writel((u32)paddr, port + PORT_CMD_ACTIVATE); | 647 | writel((u32)paddr, port + PORT_CMD_ACTIVATE); |
648 | writel((u64)paddr >> 32, port + PORT_CMD_ACTIVATE + 4); | ||
649 | |||
582 | return 0; | 650 | return 0; |
583 | } | 651 | } |
584 | 652 | ||
@@ -727,6 +795,10 @@ static inline void sil24_host_intr(struct ata_port *ap) | |||
727 | slot_stat = readl(port + PORT_SLOT_STAT); | 795 | slot_stat = readl(port + PORT_SLOT_STAT); |
728 | if (!(slot_stat & HOST_SSTAT_ATTN)) { | 796 | if (!(slot_stat & HOST_SSTAT_ATTN)) { |
729 | struct sil24_port_priv *pp = ap->private_data; | 797 | struct sil24_port_priv *pp = ap->private_data; |
798 | |||
799 | if (ap->flags & SIL24_FLAG_PCIX_IRQ_WOC) | ||
800 | writel(PORT_IRQ_COMPLETE, port + PORT_IRQ_STAT); | ||
801 | |||
730 | /* | 802 | /* |
731 | * !HOST_SSAT_ATTN guarantees successful completion, | 803 | * !HOST_SSAT_ATTN guarantees successful completion, |
732 | * so reading back tf registers is unnecessary for | 804 | * so reading back tf registers is unnecessary for |
@@ -769,7 +841,7 @@ static irqreturn_t sil24_interrupt(int irq, void *dev_instance, struct pt_regs * | |||
769 | for (i = 0; i < host_set->n_ports; i++) | 841 | for (i = 0; i < host_set->n_ports; i++) |
770 | if (status & (1 << i)) { | 842 | if (status & (1 << i)) { |
771 | struct ata_port *ap = host_set->ports[i]; | 843 | struct ata_port *ap = host_set->ports[i]; |
772 | if (ap && !(ap->flags & ATA_FLAG_PORT_DISABLED)) { | 844 | if (ap && !(ap->flags & ATA_FLAG_DISABLED)) { |
773 | sil24_host_intr(host_set->ports[i]); | 845 | sil24_host_intr(host_set->ports[i]); |
774 | handled++; | 846 | handled++; |
775 | } else | 847 | } else |
@@ -858,6 +930,7 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
858 | void __iomem *host_base = NULL; | 930 | void __iomem *host_base = NULL; |
859 | void __iomem *port_base = NULL; | 931 | void __iomem *port_base = NULL; |
860 | int i, rc; | 932 | int i, rc; |
933 | u32 tmp; | ||
861 | 934 | ||
862 | if (!printed_version++) | 935 | if (!printed_version++) |
863 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 936 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
@@ -910,35 +983,51 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
910 | /* | 983 | /* |
911 | * Configure the device | 984 | * Configure the device |
912 | */ | 985 | */ |
913 | /* | 986 | if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) { |
914 | * FIXME: This device is certainly 64-bit capable. We just | 987 | rc = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK); |
915 | * don't know how to use it. After fixing 32bit activation in | 988 | if (rc) { |
916 | * this function, enable 64bit masks here. | 989 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); |
917 | */ | 990 | if (rc) { |
918 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | 991 | dev_printk(KERN_ERR, &pdev->dev, |
919 | if (rc) { | 992 | "64-bit DMA enable failed\n"); |
920 | dev_printk(KERN_ERR, &pdev->dev, | 993 | goto out_free; |
921 | "32-bit DMA enable failed\n"); | 994 | } |
922 | goto out_free; | 995 | } |
923 | } | 996 | } else { |
924 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | 997 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); |
925 | if (rc) { | 998 | if (rc) { |
926 | dev_printk(KERN_ERR, &pdev->dev, | 999 | dev_printk(KERN_ERR, &pdev->dev, |
927 | "32-bit consistent DMA enable failed\n"); | 1000 | "32-bit DMA enable failed\n"); |
928 | goto out_free; | 1001 | goto out_free; |
1002 | } | ||
1003 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | ||
1004 | if (rc) { | ||
1005 | dev_printk(KERN_ERR, &pdev->dev, | ||
1006 | "32-bit consistent DMA enable failed\n"); | ||
1007 | goto out_free; | ||
1008 | } | ||
929 | } | 1009 | } |
930 | 1010 | ||
931 | /* GPIO off */ | 1011 | /* GPIO off */ |
932 | writel(0, host_base + HOST_FLASH_CMD); | 1012 | writel(0, host_base + HOST_FLASH_CMD); |
933 | 1013 | ||
934 | /* Mask interrupts during initialization */ | 1014 | /* Apply workaround for completion IRQ loss on PCI-X errata */ |
1015 | if (probe_ent->host_flags & SIL24_FLAG_PCIX_IRQ_WOC) { | ||
1016 | tmp = readl(host_base + HOST_CTRL); | ||
1017 | if (tmp & (HOST_CTRL_TRDY | HOST_CTRL_STOP | HOST_CTRL_DEVSEL)) | ||
1018 | dev_printk(KERN_INFO, &pdev->dev, | ||
1019 | "Applying completion IRQ loss on PCI-X " | ||
1020 | "errata fix\n"); | ||
1021 | else | ||
1022 | probe_ent->host_flags &= ~SIL24_FLAG_PCIX_IRQ_WOC; | ||
1023 | } | ||
1024 | |||
1025 | /* clear global reset & mask interrupts during initialization */ | ||
935 | writel(0, host_base + HOST_CTRL); | 1026 | writel(0, host_base + HOST_CTRL); |
936 | 1027 | ||
937 | for (i = 0; i < probe_ent->n_ports; i++) { | 1028 | for (i = 0; i < probe_ent->n_ports; i++) { |
938 | void __iomem *port = port_base + i * PORT_REGS_SIZE; | 1029 | void __iomem *port = port_base + i * PORT_REGS_SIZE; |
939 | unsigned long portu = (unsigned long)port; | 1030 | unsigned long portu = (unsigned long)port; |
940 | u32 tmp; | ||
941 | int cnt; | ||
942 | 1031 | ||
943 | probe_ent->port[i].cmd_addr = portu + PORT_PRB; | 1032 | probe_ent->port[i].cmd_addr = portu + PORT_PRB; |
944 | probe_ent->port[i].scr_addr = portu + PORT_SCONTROL; | 1033 | probe_ent->port[i].scr_addr = portu + PORT_SCONTROL; |
@@ -952,18 +1041,20 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
952 | tmp = readl(port + PORT_CTRL_STAT); | 1041 | tmp = readl(port + PORT_CTRL_STAT); |
953 | if (tmp & PORT_CS_PORT_RST) { | 1042 | if (tmp & PORT_CS_PORT_RST) { |
954 | writel(PORT_CS_PORT_RST, port + PORT_CTRL_CLR); | 1043 | writel(PORT_CS_PORT_RST, port + PORT_CTRL_CLR); |
955 | readl(port + PORT_CTRL_STAT); /* sync */ | 1044 | tmp = ata_wait_register(port + PORT_CTRL_STAT, |
956 | for (cnt = 0; cnt < 10; cnt++) { | 1045 | PORT_CS_PORT_RST, |
957 | msleep(10); | 1046 | PORT_CS_PORT_RST, 10, 100); |
958 | tmp = readl(port + PORT_CTRL_STAT); | ||
959 | if (!(tmp & PORT_CS_PORT_RST)) | ||
960 | break; | ||
961 | } | ||
962 | if (tmp & PORT_CS_PORT_RST) | 1047 | if (tmp & PORT_CS_PORT_RST) |
963 | dev_printk(KERN_ERR, &pdev->dev, | 1048 | dev_printk(KERN_ERR, &pdev->dev, |
964 | "failed to clear port RST\n"); | 1049 | "failed to clear port RST\n"); |
965 | } | 1050 | } |
966 | 1051 | ||
1052 | /* Configure IRQ WoC */ | ||
1053 | if (probe_ent->host_flags & SIL24_FLAG_PCIX_IRQ_WOC) | ||
1054 | writel(PORT_CS_IRQ_WOC, port + PORT_CTRL_STAT); | ||
1055 | else | ||
1056 | writel(PORT_CS_IRQ_WOC, port + PORT_CTRL_CLR); | ||
1057 | |||
967 | /* Zero error counters. */ | 1058 | /* Zero error counters. */ |
968 | writel(0x8000, port + PORT_DECODE_ERR_THRESH); | 1059 | writel(0x8000, port + PORT_DECODE_ERR_THRESH); |
969 | writel(0x8000, port + PORT_CRC_ERR_THRESH); | 1060 | writel(0x8000, port + PORT_CRC_ERR_THRESH); |
@@ -972,14 +1063,13 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
972 | writel(0x0000, port + PORT_CRC_ERR_CNT); | 1063 | writel(0x0000, port + PORT_CRC_ERR_CNT); |
973 | writel(0x0000, port + PORT_HSHK_ERR_CNT); | 1064 | writel(0x0000, port + PORT_HSHK_ERR_CNT); |
974 | 1065 | ||
975 | /* FIXME: 32bit activation? */ | 1066 | /* Always use 64bit activation */ |
976 | writel(0, port + PORT_ACTIVATE_UPPER_ADDR); | 1067 | writel(PORT_CS_32BIT_ACTV, port + PORT_CTRL_CLR); |
977 | writel(PORT_CS_32BIT_ACTV, port + PORT_CTRL_STAT); | ||
978 | 1068 | ||
979 | /* Configure interrupts */ | 1069 | /* Configure interrupts */ |
980 | writel(0xffff, port + PORT_IRQ_ENABLE_CLR); | 1070 | writel(0xffff, port + PORT_IRQ_ENABLE_CLR); |
981 | writel(PORT_IRQ_COMPLETE | PORT_IRQ_ERROR | PORT_IRQ_SDB_FIS, | 1071 | writel(PORT_IRQ_COMPLETE | PORT_IRQ_ERROR | |
982 | port + PORT_IRQ_ENABLE_SET); | 1072 | PORT_IRQ_SDB_NOTIFY, port + PORT_IRQ_ENABLE_SET); |
983 | 1073 | ||
984 | /* Clear interrupts */ | 1074 | /* Clear interrupts */ |
985 | writel(0x0fff0fff, port + PORT_IRQ_STAT); | 1075 | writel(0x0fff0fff, port + PORT_IRQ_STAT); |
@@ -987,11 +1077,6 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
987 | 1077 | ||
988 | /* Clear port multiplier enable and resume bits */ | 1078 | /* Clear port multiplier enable and resume bits */ |
989 | writel(PORT_CS_PM_EN | PORT_CS_RESUME, port + PORT_CTRL_CLR); | 1079 | writel(PORT_CS_PM_EN | PORT_CS_RESUME, port + PORT_CTRL_CLR); |
990 | |||
991 | /* Reset itself */ | ||
992 | if (__sil24_reset_controller(port)) | ||
993 | dev_printk(KERN_ERR, &pdev->dev, | ||
994 | "failed to reset controller\n"); | ||
995 | } | 1080 | } |
996 | 1081 | ||
997 | /* Turn on interrupts */ | 1082 | /* Turn on interrupts */ |
diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c index 728530df2e07..3097821688dc 100644 --- a/drivers/scsi/sata_sis.c +++ b/drivers/scsi/sata_sis.c | |||
@@ -43,7 +43,7 @@ | |||
43 | #include <linux/libata.h> | 43 | #include <linux/libata.h> |
44 | 44 | ||
45 | #define DRV_NAME "sata_sis" | 45 | #define DRV_NAME "sata_sis" |
46 | #define DRV_VERSION "0.5" | 46 | #define DRV_VERSION "0.6" |
47 | 47 | ||
48 | enum { | 48 | enum { |
49 | sis_180 = 0, | 49 | sis_180 = 0, |
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c index 53b0d5c0a61f..d5eb5375e265 100644 --- a/drivers/scsi/sata_svw.c +++ b/drivers/scsi/sata_svw.c | |||
@@ -54,7 +54,7 @@ | |||
54 | #endif /* CONFIG_PPC_OF */ | 54 | #endif /* CONFIG_PPC_OF */ |
55 | 55 | ||
56 | #define DRV_NAME "sata_svw" | 56 | #define DRV_NAME "sata_svw" |
57 | #define DRV_VERSION "1.07" | 57 | #define DRV_VERSION "1.8" |
58 | 58 | ||
59 | enum { | 59 | enum { |
60 | /* Taskfile registers offsets */ | 60 | /* Taskfile registers offsets */ |
@@ -257,7 +257,7 @@ static int k2_sata_proc_info(struct Scsi_Host *shost, char *page, char **start, | |||
257 | int len, index; | 257 | int len, index; |
258 | 258 | ||
259 | /* Find the ata_port */ | 259 | /* Find the ata_port */ |
260 | ap = (struct ata_port *) &shost->hostdata[0]; | 260 | ap = ata_shost_to_port(shost); |
261 | if (ap == NULL) | 261 | if (ap == NULL) |
262 | return 0; | 262 | return 0; |
263 | 263 | ||
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c index 4139ad4b1df0..a669d0589889 100644 --- a/drivers/scsi/sata_sx4.c +++ b/drivers/scsi/sata_sx4.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include "sata_promise.h" | 46 | #include "sata_promise.h" |
47 | 47 | ||
48 | #define DRV_NAME "sata_sx4" | 48 | #define DRV_NAME "sata_sx4" |
49 | #define DRV_VERSION "0.8" | 49 | #define DRV_VERSION "0.9" |
50 | 50 | ||
51 | 51 | ||
52 | enum { | 52 | enum { |
@@ -833,7 +833,7 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re | |||
833 | tmp = mask & (1 << i); | 833 | tmp = mask & (1 << i); |
834 | VPRINTK("seq %u, port_no %u, ap %p, tmp %x\n", i, port_no, ap, tmp); | 834 | VPRINTK("seq %u, port_no %u, ap %p, tmp %x\n", i, port_no, ap, tmp); |
835 | if (tmp && ap && | 835 | if (tmp && ap && |
836 | !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) { | 836 | !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) { |
837 | struct ata_queued_cmd *qc; | 837 | struct ata_queued_cmd *qc; |
838 | 838 | ||
839 | qc = ata_qc_from_tag(ap, ap->active_tag); | 839 | qc = ata_qc_from_tag(ap, ap->active_tag); |
@@ -1375,10 +1375,6 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id * | |||
1375 | if (!printed_version++) | 1375 | if (!printed_version++) |
1376 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 1376 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
1377 | 1377 | ||
1378 | /* | ||
1379 | * If this driver happens to only be useful on Apple's K2, then | ||
1380 | * we should check that here as it has a normal Serverworks ID | ||
1381 | */ | ||
1382 | rc = pci_enable_device(pdev); | 1378 | rc = pci_enable_device(pdev); |
1383 | if (rc) | 1379 | if (rc) |
1384 | return rc; | 1380 | return rc; |
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c index 38b52bd3fa3f..15f81bfc30f0 100644 --- a/drivers/scsi/sata_uli.c +++ b/drivers/scsi/sata_uli.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <linux/libata.h> | 37 | #include <linux/libata.h> |
38 | 38 | ||
39 | #define DRV_NAME "sata_uli" | 39 | #define DRV_NAME "sata_uli" |
40 | #define DRV_VERSION "0.5" | 40 | #define DRV_VERSION "0.6" |
41 | 41 | ||
42 | enum { | 42 | enum { |
43 | uli_5289 = 0, | 43 | uli_5289 = 0, |
diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c index 9e7ae4e0db32..17aefab5f42f 100644 --- a/drivers/scsi/sata_via.c +++ b/drivers/scsi/sata_via.c | |||
@@ -47,7 +47,7 @@ | |||
47 | #include <asm/io.h> | 47 | #include <asm/io.h> |
48 | 48 | ||
49 | #define DRV_NAME "sata_via" | 49 | #define DRV_NAME "sata_via" |
50 | #define DRV_VERSION "1.1" | 50 | #define DRV_VERSION "1.2" |
51 | 51 | ||
52 | enum board_ids_enum { | 52 | enum board_ids_enum { |
53 | vt6420, | 53 | vt6420, |
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c index 8a29ce340b47..9646c3932129 100644 --- a/drivers/scsi/sata_vsc.c +++ b/drivers/scsi/sata_vsc.c | |||
@@ -222,7 +222,7 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance, | |||
222 | ap = host_set->ports[i]; | 222 | ap = host_set->ports[i]; |
223 | 223 | ||
224 | if (ap && !(ap->flags & | 224 | if (ap && !(ap->flags & |
225 | (ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) { | 225 | (ATA_FLAG_DISABLED|ATA_FLAG_NOINTR))) { |
226 | struct ata_queued_cmd *qc; | 226 | struct ata_queued_cmd *qc; |
227 | 227 | ||
228 | qc = ata_qc_from_tag(ap, ap->active_tag); | 228 | qc = ata_qc_from_tag(ap, ap->active_tag); |