diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/Makefile | 2 | ||||
-rw-r--r-- | drivers/scsi/ahci.c | 8 | ||||
-rw-r--r-- | drivers/scsi/ata_piix.c | 2 | ||||
-rw-r--r-- | drivers/scsi/libata-core.c | 798 | ||||
-rw-r--r-- | drivers/scsi/libata-eh.c | 264 | ||||
-rw-r--r-- | drivers/scsi/libata-scsi.c | 179 | ||||
-rw-r--r-- | drivers/scsi/libata.h | 19 | ||||
-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 | 4 | ||||
-rw-r--r-- | drivers/scsi/sata_sis.c | 2 | ||||
-rw-r--r-- | drivers/scsi/sata_svw.c | 2 | ||||
-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, 810 insertions, 518 deletions
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index e513c3158ad..503f189dab3 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile | |||
@@ -165,7 +165,7 @@ ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \ | |||
165 | CFLAGS_ncr53c8xx.o := $(ncr53c8xx-flags-y) $(ncr53c8xx-flags-m) | 165 | CFLAGS_ncr53c8xx.o := $(ncr53c8xx-flags-y) $(ncr53c8xx-flags-m) |
166 | zalon7xx-objs := zalon.o ncr53c8xx.o | 166 | zalon7xx-objs := zalon.o ncr53c8xx.o |
167 | NCR_Q720_mod-objs := NCR_Q720.o ncr53c8xx.o | 167 | NCR_Q720_mod-objs := NCR_Q720.o ncr53c8xx.o |
168 | libata-objs := libata-core.o libata-scsi.o libata-bmdma.o | 168 | libata-objs := libata-core.o libata-scsi.o libata-bmdma.o libata-eh.o |
169 | oktagon_esp_mod-objs := oktagon_esp.o oktagon_io.o | 169 | oktagon_esp_mod-objs := oktagon_esp.o oktagon_io.o |
170 | 170 | ||
171 | # Files generated that shall be removed upon make clean | 171 | # Files generated that shall be removed upon make clean |
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index b4f8fb1d628..20fc0846e0b 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 { |
@@ -548,6 +548,12 @@ static int ahci_softreset(struct ata_port *ap, int verbose, unsigned int *class) | |||
548 | 548 | ||
549 | DPRINTK("ENTER\n"); | 549 | DPRINTK("ENTER\n"); |
550 | 550 | ||
551 | if (!sata_dev_present(ap)) { | ||
552 | DPRINTK("PHY reports no device\n"); | ||
553 | *class = ATA_DEV_NONE; | ||
554 | return 0; | ||
555 | } | ||
556 | |||
551 | /* prepare for SRST (AHCI-1.1 10.4.1) */ | 557 | /* prepare for SRST (AHCI-1.1 10.4.1) */ |
552 | rc = ahci_stop_engine(ap); | 558 | rc = ahci_stop_engine(ap); |
553 | if (rc) { | 559 | if (rc) { |
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index 6dc88149f9f..62dabf74188 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 bd147207f25..3387fe35c54 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,74 @@ 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 | |||
1390 | dev->class = classes[i]; | 1414 | dev->class = classes[i]; |
1391 | 1415 | ||
1392 | if (!ata_dev_present(dev)) | 1416 | if (!tries[i]) { |
1393 | continue; | 1417 | ata_down_xfermask_limit(ap, dev, 1); |
1394 | 1418 | ata_dev_disable(ap, dev); | |
1395 | WARN_ON(dev->id != NULL); | ||
1396 | if (ata_dev_read_id(ap, dev, &dev->class, 1, &dev->id)) { | ||
1397 | dev->class = ATA_DEV_NONE; | ||
1398 | continue; | ||
1399 | } | 1419 | } |
1400 | 1420 | ||
1401 | if (ata_dev_configure(ap, dev, 1)) { | 1421 | if (!ata_dev_enabled(dev)) |
1402 | ata_dev_disable(ap, dev); | ||
1403 | continue; | 1422 | continue; |
1404 | } | ||
1405 | 1423 | ||
1406 | found = 1; | 1424 | kfree(dev->id); |
1425 | dev->id = NULL; | ||
1426 | rc = ata_dev_read_id(ap, dev, &dev->class, 1, &dev->id); | ||
1427 | if (rc) | ||
1428 | goto fail; | ||
1429 | |||
1430 | rc = ata_dev_configure(ap, dev, 1); | ||
1431 | if (rc) | ||
1432 | goto fail; | ||
1407 | } | 1433 | } |
1408 | 1434 | ||
1409 | if (!found) | 1435 | /* configure transfer mode */ |
1410 | goto err_out_disable; | 1436 | if (ap->ops->set_mode) { |
1437 | /* FIXME: make ->set_mode handle no device case and | ||
1438 | * return error code and failing device on failure as | ||
1439 | * ata_set_mode() does. | ||
1440 | */ | ||
1441 | for (i = 0; i < ATA_MAX_DEVICES; i++) | ||
1442 | if (ata_dev_enabled(&ap->device[i])) { | ||
1443 | ap->ops->set_mode(ap); | ||
1444 | break; | ||
1445 | } | ||
1446 | rc = 0; | ||
1447 | } else { | ||
1448 | rc = ata_set_mode(ap, &dev); | ||
1449 | if (rc) { | ||
1450 | down_xfermask = 1; | ||
1451 | goto fail; | ||
1452 | } | ||
1453 | } | ||
1411 | 1454 | ||
1412 | if (ap->ops->set_mode) | 1455 | for (i = 0; i < ATA_MAX_DEVICES; i++) |
1413 | ap->ops->set_mode(ap); | 1456 | if (ata_dev_enabled(&ap->device[i])) |
1414 | else | 1457 | return 0; |
1415 | ata_set_mode(ap); | ||
1416 | 1458 | ||
1417 | if (ap->flags & ATA_FLAG_PORT_DISABLED) | 1459 | /* no device present, disable port */ |
1418 | goto err_out_disable; | 1460 | ata_port_disable(ap); |
1461 | ap->ops->port_disable(ap); | ||
1462 | return -ENODEV; | ||
1419 | 1463 | ||
1420 | return 0; | 1464 | fail: |
1465 | switch (rc) { | ||
1466 | case -EINVAL: | ||
1467 | case -ENODEV: | ||
1468 | tries[dev->devno] = 0; | ||
1469 | break; | ||
1470 | case -EIO: | ||
1471 | ata_down_sata_spd_limit(ap); | ||
1472 | /* fall through */ | ||
1473 | default: | ||
1474 | tries[dev->devno]--; | ||
1475 | if (down_xfermask && | ||
1476 | ata_down_xfermask_limit(ap, dev, tries[dev->devno] == 1)) | ||
1477 | tries[dev->devno] = 0; | ||
1478 | } | ||
1421 | 1479 | ||
1422 | err_out_disable: | 1480 | goto retry; |
1423 | ap->ops->port_disable(ap); | ||
1424 | return -1; | ||
1425 | } | 1481 | } |
1426 | 1482 | ||
1427 | /** | 1483 | /** |
@@ -1437,7 +1493,7 @@ err_out_disable: | |||
1437 | 1493 | ||
1438 | void ata_port_probe(struct ata_port *ap) | 1494 | void ata_port_probe(struct ata_port *ap) |
1439 | { | 1495 | { |
1440 | ap->flags &= ~ATA_FLAG_PORT_DISABLED; | 1496 | ap->flags &= ~ATA_FLAG_DISABLED; |
1441 | } | 1497 | } |
1442 | 1498 | ||
1443 | /** | 1499 | /** |
@@ -1451,27 +1507,23 @@ void ata_port_probe(struct ata_port *ap) | |||
1451 | */ | 1507 | */ |
1452 | static void sata_print_link_status(struct ata_port *ap) | 1508 | static void sata_print_link_status(struct ata_port *ap) |
1453 | { | 1509 | { |
1454 | u32 sstatus, tmp; | 1510 | u32 sstatus, scontrol, tmp; |
1455 | const char *speed; | ||
1456 | 1511 | ||
1457 | if (!ap->ops->scr_read) | 1512 | if (!ap->ops->scr_read) |
1458 | return; | 1513 | return; |
1459 | 1514 | ||
1460 | sstatus = scr_read(ap, SCR_STATUS); | 1515 | sstatus = scr_read(ap, SCR_STATUS); |
1516 | scontrol = scr_read(ap, SCR_CONTROL); | ||
1461 | 1517 | ||
1462 | if (sata_dev_present(ap)) { | 1518 | if (sata_dev_present(ap)) { |
1463 | tmp = (sstatus >> 4) & 0xf; | 1519 | tmp = (sstatus >> 4) & 0xf; |
1464 | if (tmp & (1 << 0)) | 1520 | printk(KERN_INFO |
1465 | speed = "1.5"; | 1521 | "ata%u: SATA link up %s (SStatus %X SControl %X)\n", |
1466 | else if (tmp & (1 << 1)) | 1522 | 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 { | 1523 | } else { |
1473 | printk(KERN_INFO "ata%u: SATA link down (SStatus %X)\n", | 1524 | printk(KERN_INFO |
1474 | ap->id, sstatus); | 1525 | "ata%u: SATA link down (SStatus %X SControl %X)\n", |
1526 | ap->id, sstatus, scontrol); | ||
1475 | } | 1527 | } |
1476 | } | 1528 | } |
1477 | 1529 | ||
@@ -1518,7 +1570,7 @@ void __sata_phy_reset(struct ata_port *ap) | |||
1518 | else | 1570 | else |
1519 | ata_port_disable(ap); | 1571 | ata_port_disable(ap); |
1520 | 1572 | ||
1521 | if (ap->flags & ATA_FLAG_PORT_DISABLED) | 1573 | if (ap->flags & ATA_FLAG_DISABLED) |
1522 | return; | 1574 | return; |
1523 | 1575 | ||
1524 | if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) { | 1576 | if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) { |
@@ -1543,7 +1595,7 @@ void __sata_phy_reset(struct ata_port *ap) | |||
1543 | void sata_phy_reset(struct ata_port *ap) | 1595 | void sata_phy_reset(struct ata_port *ap) |
1544 | { | 1596 | { |
1545 | __sata_phy_reset(ap); | 1597 | __sata_phy_reset(ap); |
1546 | if (ap->flags & ATA_FLAG_PORT_DISABLED) | 1598 | if (ap->flags & ATA_FLAG_DISABLED) |
1547 | return; | 1599 | return; |
1548 | ata_bus_reset(ap); | 1600 | ata_bus_reset(ap); |
1549 | } | 1601 | } |
@@ -1560,7 +1612,7 @@ void sata_phy_reset(struct ata_port *ap) | |||
1560 | struct ata_device *ata_dev_pair(struct ata_port *ap, struct ata_device *adev) | 1612 | struct ata_device *ata_dev_pair(struct ata_port *ap, struct ata_device *adev) |
1561 | { | 1613 | { |
1562 | struct ata_device *pair = &ap->device[1 - adev->devno]; | 1614 | struct ata_device *pair = &ap->device[1 - adev->devno]; |
1563 | if (!ata_dev_present(pair)) | 1615 | if (!ata_dev_enabled(pair)) |
1564 | return NULL; | 1616 | return NULL; |
1565 | return pair; | 1617 | return pair; |
1566 | } | 1618 | } |
@@ -1582,7 +1634,121 @@ void ata_port_disable(struct ata_port *ap) | |||
1582 | { | 1634 | { |
1583 | ap->device[0].class = ATA_DEV_NONE; | 1635 | ap->device[0].class = ATA_DEV_NONE; |
1584 | ap->device[1].class = ATA_DEV_NONE; | 1636 | ap->device[1].class = ATA_DEV_NONE; |
1585 | ap->flags |= ATA_FLAG_PORT_DISABLED; | 1637 | ap->flags |= ATA_FLAG_DISABLED; |
1638 | } | ||
1639 | |||
1640 | /** | ||
1641 | * ata_down_sata_spd_limit - adjust SATA spd limit downward | ||
1642 | * @ap: Port to adjust SATA spd limit for | ||
1643 | * | ||
1644 | * Adjust SATA spd limit of @ap downward. Note that this | ||
1645 | * function only adjusts the limit. The change must be applied | ||
1646 | * using ata_set_sata_spd(). | ||
1647 | * | ||
1648 | * LOCKING: | ||
1649 | * Inherited from caller. | ||
1650 | * | ||
1651 | * RETURNS: | ||
1652 | * 0 on success, negative errno on failure | ||
1653 | */ | ||
1654 | int ata_down_sata_spd_limit(struct ata_port *ap) | ||
1655 | { | ||
1656 | u32 spd, mask; | ||
1657 | int highbit; | ||
1658 | |||
1659 | if (ap->cbl != ATA_CBL_SATA || !ap->ops->scr_read) | ||
1660 | return -EOPNOTSUPP; | ||
1661 | |||
1662 | mask = ap->sata_spd_limit; | ||
1663 | if (mask <= 1) | ||
1664 | return -EINVAL; | ||
1665 | highbit = fls(mask) - 1; | ||
1666 | mask &= ~(1 << highbit); | ||
1667 | |||
1668 | spd = (scr_read(ap, SCR_STATUS) >> 4) & 0xf; | ||
1669 | if (spd <= 1) | ||
1670 | return -EINVAL; | ||
1671 | spd--; | ||
1672 | mask &= (1 << spd) - 1; | ||
1673 | if (!mask) | ||
1674 | return -EINVAL; | ||
1675 | |||
1676 | ap->sata_spd_limit = mask; | ||
1677 | |||
1678 | printk(KERN_WARNING "ata%u: limiting SATA link speed to %s\n", | ||
1679 | ap->id, sata_spd_string(fls(mask))); | ||
1680 | |||
1681 | return 0; | ||
1682 | } | ||
1683 | |||
1684 | static int __ata_set_sata_spd_needed(struct ata_port *ap, u32 *scontrol) | ||
1685 | { | ||
1686 | u32 spd, limit; | ||
1687 | |||
1688 | if (ap->sata_spd_limit == UINT_MAX) | ||
1689 | limit = 0; | ||
1690 | else | ||
1691 | limit = fls(ap->sata_spd_limit); | ||
1692 | |||
1693 | spd = (*scontrol >> 4) & 0xf; | ||
1694 | *scontrol = (*scontrol & ~0xf0) | ((limit & 0xf) << 4); | ||
1695 | |||
1696 | return spd != limit; | ||
1697 | } | ||
1698 | |||
1699 | /** | ||
1700 | * ata_set_sata_spd_needed - is SATA spd configuration needed | ||
1701 | * @ap: Port in question | ||
1702 | * | ||
1703 | * Test whether the spd limit in SControl matches | ||
1704 | * @ap->sata_spd_limit. This function is used to determine | ||
1705 | * whether hardreset is necessary to apply SATA spd | ||
1706 | * configuration. | ||
1707 | * | ||
1708 | * LOCKING: | ||
1709 | * Inherited from caller. | ||
1710 | * | ||
1711 | * RETURNS: | ||
1712 | * 1 if SATA spd configuration is needed, 0 otherwise. | ||
1713 | */ | ||
1714 | int ata_set_sata_spd_needed(struct ata_port *ap) | ||
1715 | { | ||
1716 | u32 scontrol; | ||
1717 | |||
1718 | if (ap->cbl != ATA_CBL_SATA || !ap->ops->scr_read) | ||
1719 | return 0; | ||
1720 | |||
1721 | scontrol = scr_read(ap, SCR_CONTROL); | ||
1722 | |||
1723 | return __ata_set_sata_spd_needed(ap, &scontrol); | ||
1724 | } | ||
1725 | |||
1726 | /** | ||
1727 | * ata_set_sata_spd - set SATA spd according to spd limit | ||
1728 | * @ap: Port to set SATA spd for | ||
1729 | * | ||
1730 | * Set SATA spd of @ap according to sata_spd_limit. | ||
1731 | * | ||
1732 | * LOCKING: | ||
1733 | * Inherited from caller. | ||
1734 | * | ||
1735 | * RETURNS: | ||
1736 | * 0 if spd doesn't need to be changed, 1 if spd has been | ||
1737 | * changed. -EOPNOTSUPP if SCR registers are inaccessible. | ||
1738 | */ | ||
1739 | static int ata_set_sata_spd(struct ata_port *ap) | ||
1740 | { | ||
1741 | u32 scontrol; | ||
1742 | |||
1743 | if (ap->cbl != ATA_CBL_SATA || !ap->ops->scr_read) | ||
1744 | return -EOPNOTSUPP; | ||
1745 | |||
1746 | scontrol = scr_read(ap, SCR_CONTROL); | ||
1747 | if (!__ata_set_sata_spd_needed(ap, &scontrol)) | ||
1748 | return 0; | ||
1749 | |||
1750 | scr_write(ap, SCR_CONTROL, scontrol); | ||
1751 | return 1; | ||
1586 | } | 1752 | } |
1587 | 1753 | ||
1588 | /* | 1754 | /* |
@@ -1733,11 +1899,62 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed, | |||
1733 | return 0; | 1899 | return 0; |
1734 | } | 1900 | } |
1735 | 1901 | ||
1902 | /** | ||
1903 | * ata_down_xfermask_limit - adjust dev xfer masks downward | ||
1904 | * @ap: Port associated with device @dev | ||
1905 | * @dev: Device to adjust xfer masks | ||
1906 | * @force_pio0: Force PIO0 | ||
1907 | * | ||
1908 | * Adjust xfer masks of @dev downward. Note that this function | ||
1909 | * does not apply the change. Invoking ata_set_mode() afterwards | ||
1910 | * will apply the limit. | ||
1911 | * | ||
1912 | * LOCKING: | ||
1913 | * Inherited from caller. | ||
1914 | * | ||
1915 | * RETURNS: | ||
1916 | * 0 on success, negative errno on failure | ||
1917 | */ | ||
1918 | int ata_down_xfermask_limit(struct ata_port *ap, struct ata_device *dev, | ||
1919 | int force_pio0) | ||
1920 | { | ||
1921 | unsigned long xfer_mask; | ||
1922 | int highbit; | ||
1923 | |||
1924 | xfer_mask = ata_pack_xfermask(dev->pio_mask, dev->mwdma_mask, | ||
1925 | dev->udma_mask); | ||
1926 | |||
1927 | if (!xfer_mask) | ||
1928 | goto fail; | ||
1929 | /* don't gear down to MWDMA from UDMA, go directly to PIO */ | ||
1930 | if (xfer_mask & ATA_MASK_UDMA) | ||
1931 | xfer_mask &= ~ATA_MASK_MWDMA; | ||
1932 | |||
1933 | highbit = fls(xfer_mask) - 1; | ||
1934 | xfer_mask &= ~(1 << highbit); | ||
1935 | if (force_pio0) | ||
1936 | xfer_mask &= 1 << ATA_SHIFT_PIO; | ||
1937 | if (!xfer_mask) | ||
1938 | goto fail; | ||
1939 | |||
1940 | ata_unpack_xfermask(xfer_mask, &dev->pio_mask, &dev->mwdma_mask, | ||
1941 | &dev->udma_mask); | ||
1942 | |||
1943 | printk(KERN_WARNING "ata%u: dev %u limiting speed to %s\n", | ||
1944 | ap->id, dev->devno, ata_mode_string(xfer_mask)); | ||
1945 | |||
1946 | return 0; | ||
1947 | |||
1948 | fail: | ||
1949 | return -EINVAL; | ||
1950 | } | ||
1951 | |||
1736 | static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev) | 1952 | static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev) |
1737 | { | 1953 | { |
1738 | unsigned int err_mask; | 1954 | unsigned int err_mask; |
1739 | int rc; | 1955 | int rc; |
1740 | 1956 | ||
1957 | dev->flags &= ~ATA_DFLAG_PIO; | ||
1741 | if (dev->xfer_shift == ATA_SHIFT_PIO) | 1958 | if (dev->xfer_shift == ATA_SHIFT_PIO) |
1742 | dev->flags |= ATA_DFLAG_PIO; | 1959 | dev->flags |= ATA_DFLAG_PIO; |
1743 | 1960 | ||
@@ -1750,12 +1967,8 @@ static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev) | |||
1750 | } | 1967 | } |
1751 | 1968 | ||
1752 | rc = ata_dev_revalidate(ap, dev, 0); | 1969 | rc = ata_dev_revalidate(ap, dev, 0); |
1753 | if (rc) { | 1970 | if (rc) |
1754 | printk(KERN_ERR | ||
1755 | "ata%u: failed to revalidate after set xfermode\n", | ||
1756 | ap->id); | ||
1757 | return rc; | 1971 | return rc; |
1758 | } | ||
1759 | 1972 | ||
1760 | DPRINTK("xfer_shift=%u, xfer_mode=0x%x\n", | 1973 | DPRINTK("xfer_shift=%u, xfer_mode=0x%x\n", |
1761 | dev->xfer_shift, (int)dev->xfer_mode); | 1974 | dev->xfer_shift, (int)dev->xfer_mode); |
@@ -1766,118 +1979,107 @@ static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev) | |||
1766 | return 0; | 1979 | return 0; |
1767 | } | 1980 | } |
1768 | 1981 | ||
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 | /** | 1982 | /** |
1811 | * ata_set_mode - Program timings and issue SET FEATURES - XFER | 1983 | * ata_set_mode - Program timings and issue SET FEATURES - XFER |
1812 | * @ap: port on which timings will be programmed | 1984 | * @ap: port on which timings will be programmed |
1985 | * @r_failed_dev: out paramter for failed device | ||
1813 | * | 1986 | * |
1814 | * Set ATA device disk transfer mode (PIO3, UDMA6, etc.). | 1987 | * Set ATA device disk transfer mode (PIO3, UDMA6, etc.). If |
1988 | * ata_set_mode() fails, pointer to the failing device is | ||
1989 | * returned in @r_failed_dev. | ||
1815 | * | 1990 | * |
1816 | * LOCKING: | 1991 | * LOCKING: |
1817 | * PCI/etc. bus probe sem. | 1992 | * PCI/etc. bus probe sem. |
1993 | * | ||
1994 | * RETURNS: | ||
1995 | * 0 on success, negative errno otherwise | ||
1818 | */ | 1996 | */ |
1819 | static void ata_set_mode(struct ata_port *ap) | 1997 | int ata_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) |
1820 | { | 1998 | { |
1821 | int i, rc, used_dma = 0; | 1999 | struct ata_device *dev; |
2000 | int i, rc = 0, used_dma = 0, found = 0; | ||
1822 | 2001 | ||
1823 | /* step 1: calculate xfer_mask */ | 2002 | /* step 1: calculate xfer_mask */ |
1824 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 2003 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
1825 | struct ata_device *dev = &ap->device[i]; | ||
1826 | unsigned int pio_mask, dma_mask; | 2004 | unsigned int pio_mask, dma_mask; |
1827 | 2005 | ||
1828 | if (!ata_dev_present(dev)) | 2006 | dev = &ap->device[i]; |
2007 | |||
2008 | if (!ata_dev_enabled(dev)) | ||
1829 | continue; | 2009 | continue; |
1830 | 2010 | ||
1831 | ata_dev_xfermask(ap, dev); | 2011 | ata_dev_xfermask(ap, dev); |
1832 | 2012 | ||
1833 | /* TODO: let LLDD filter dev->*_mask here */ | ||
1834 | |||
1835 | pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0); | 2013 | pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0); |
1836 | dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask); | 2014 | dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask); |
1837 | dev->pio_mode = ata_xfer_mask2mode(pio_mask); | 2015 | dev->pio_mode = ata_xfer_mask2mode(pio_mask); |
1838 | dev->dma_mode = ata_xfer_mask2mode(dma_mask); | 2016 | dev->dma_mode = ata_xfer_mask2mode(dma_mask); |
1839 | 2017 | ||
2018 | found = 1; | ||
1840 | if (dev->dma_mode) | 2019 | if (dev->dma_mode) |
1841 | used_dma = 1; | 2020 | used_dma = 1; |
1842 | } | 2021 | } |
2022 | if (!found) | ||
2023 | goto out; | ||
1843 | 2024 | ||
1844 | /* step 2: always set host PIO timings */ | 2025 | /* step 2: always set host PIO timings */ |
1845 | rc = ata_host_set_pio(ap); | 2026 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
1846 | if (rc) | 2027 | dev = &ap->device[i]; |
1847 | goto err_out; | 2028 | if (!ata_dev_enabled(dev)) |
2029 | continue; | ||
2030 | |||
2031 | if (!dev->pio_mode) { | ||
2032 | printk(KERN_WARNING "ata%u: dev %u no PIO support\n", | ||
2033 | ap->id, dev->devno); | ||
2034 | rc = -EINVAL; | ||
2035 | goto out; | ||
2036 | } | ||
2037 | |||
2038 | dev->xfer_mode = dev->pio_mode; | ||
2039 | dev->xfer_shift = ATA_SHIFT_PIO; | ||
2040 | if (ap->ops->set_piomode) | ||
2041 | ap->ops->set_piomode(ap, dev); | ||
2042 | } | ||
1848 | 2043 | ||
1849 | /* step 3: set host DMA timings */ | 2044 | /* step 3: set host DMA timings */ |
1850 | ata_host_set_dma(ap); | 2045 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
2046 | dev = &ap->device[i]; | ||
2047 | |||
2048 | if (!ata_dev_enabled(dev) || !dev->dma_mode) | ||
2049 | continue; | ||
2050 | |||
2051 | dev->xfer_mode = dev->dma_mode; | ||
2052 | dev->xfer_shift = ata_xfer_mode2shift(dev->dma_mode); | ||
2053 | if (ap->ops->set_dmamode) | ||
2054 | ap->ops->set_dmamode(ap, dev); | ||
2055 | } | ||
1851 | 2056 | ||
1852 | /* step 4: update devices' xfer mode */ | 2057 | /* step 4: update devices' xfer mode */ |
1853 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 2058 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
1854 | struct ata_device *dev = &ap->device[i]; | 2059 | dev = &ap->device[i]; |
1855 | 2060 | ||
1856 | if (!ata_dev_present(dev)) | 2061 | if (!ata_dev_enabled(dev)) |
1857 | continue; | 2062 | continue; |
1858 | 2063 | ||
1859 | if (ata_dev_set_mode(ap, dev)) | 2064 | rc = ata_dev_set_mode(ap, dev); |
1860 | goto err_out; | 2065 | if (rc) |
2066 | goto out; | ||
1861 | } | 2067 | } |
1862 | 2068 | ||
1863 | /* | 2069 | /* Record simplex status. If we selected DMA then the other |
1864 | * Record simplex status. If we selected DMA then the other | 2070 | * host channels are not permitted to do so. |
1865 | * host channels are not permitted to do so. | ||
1866 | */ | 2071 | */ |
1867 | |||
1868 | if (used_dma && (ap->host_set->flags & ATA_HOST_SIMPLEX)) | 2072 | if (used_dma && (ap->host_set->flags & ATA_HOST_SIMPLEX)) |
1869 | ap->host_set->simplex_claimed = 1; | 2073 | ap->host_set->simplex_claimed = 1; |
1870 | 2074 | ||
1871 | /* | 2075 | /* step5: chip specific finalisation */ |
1872 | * Chip specific finalisation | ||
1873 | */ | ||
1874 | if (ap->ops->post_set_mode) | 2076 | if (ap->ops->post_set_mode) |
1875 | ap->ops->post_set_mode(ap); | 2077 | ap->ops->post_set_mode(ap); |
1876 | 2078 | ||
1877 | return; | 2079 | out: |
1878 | 2080 | if (rc) | |
1879 | err_out: | 2081 | *r_failed_dev = dev; |
1880 | ata_port_disable(ap); | 2082 | return rc; |
1881 | } | 2083 | } |
1882 | 2084 | ||
1883 | /** | 2085 | /** |
@@ -2055,7 +2257,7 @@ static unsigned int ata_bus_softreset(struct ata_port *ap, | |||
2055 | * Obtains host_set lock. | 2257 | * Obtains host_set lock. |
2056 | * | 2258 | * |
2057 | * SIDE EFFECTS: | 2259 | * SIDE EFFECTS: |
2058 | * Sets ATA_FLAG_PORT_DISABLED if bus reset fails. | 2260 | * Sets ATA_FLAG_DISABLED if bus reset fails. |
2059 | */ | 2261 | */ |
2060 | 2262 | ||
2061 | void ata_bus_reset(struct ata_port *ap) | 2263 | void ata_bus_reset(struct ata_port *ap) |
@@ -2132,9 +2334,11 @@ err_out: | |||
2132 | static int sata_phy_resume(struct ata_port *ap) | 2334 | static int sata_phy_resume(struct ata_port *ap) |
2133 | { | 2335 | { |
2134 | unsigned long timeout = jiffies + (HZ * 5); | 2336 | unsigned long timeout = jiffies + (HZ * 5); |
2135 | u32 sstatus; | 2337 | u32 scontrol, sstatus; |
2136 | 2338 | ||
2137 | scr_write_flush(ap, SCR_CONTROL, 0x300); | 2339 | scontrol = scr_read(ap, SCR_CONTROL); |
2340 | scontrol = (scontrol & 0x0f0) | 0x300; | ||
2341 | scr_write_flush(ap, SCR_CONTROL, scontrol); | ||
2138 | 2342 | ||
2139 | /* Wait for phy to become ready, if necessary. */ | 2343 | /* Wait for phy to become ready, if necessary. */ |
2140 | do { | 2344 | do { |
@@ -2163,7 +2367,14 @@ static int sata_phy_resume(struct ata_port *ap) | |||
2163 | void ata_std_probeinit(struct ata_port *ap) | 2367 | void ata_std_probeinit(struct ata_port *ap) |
2164 | { | 2368 | { |
2165 | if ((ap->flags & ATA_FLAG_SATA) && ap->ops->scr_read) { | 2369 | if ((ap->flags & ATA_FLAG_SATA) && ap->ops->scr_read) { |
2370 | u32 spd; | ||
2371 | |||
2166 | sata_phy_resume(ap); | 2372 | sata_phy_resume(ap); |
2373 | |||
2374 | spd = (scr_read(ap, SCR_CONTROL) & 0xf0) >> 4; | ||
2375 | if (spd) | ||
2376 | ap->sata_spd_limit &= (1 << spd) - 1; | ||
2377 | |||
2167 | if (sata_dev_present(ap)) | 2378 | if (sata_dev_present(ap)) |
2168 | ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); | 2379 | ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); |
2169 | } | 2380 | } |
@@ -2247,18 +2458,34 @@ int ata_std_softreset(struct ata_port *ap, int verbose, unsigned int *classes) | |||
2247 | */ | 2458 | */ |
2248 | int sata_std_hardreset(struct ata_port *ap, int verbose, unsigned int *class) | 2459 | int sata_std_hardreset(struct ata_port *ap, int verbose, unsigned int *class) |
2249 | { | 2460 | { |
2461 | u32 scontrol; | ||
2462 | |||
2250 | DPRINTK("ENTER\n"); | 2463 | DPRINTK("ENTER\n"); |
2251 | 2464 | ||
2252 | /* Issue phy wake/reset */ | 2465 | if (ata_set_sata_spd_needed(ap)) { |
2253 | scr_write_flush(ap, SCR_CONTROL, 0x301); | 2466 | /* SATA spec says nothing about how to reconfigure |
2467 | * spd. To be on the safe side, turn off phy during | ||
2468 | * reconfiguration. This works for at least ICH7 AHCI | ||
2469 | * and Sil3124. | ||
2470 | */ | ||
2471 | scontrol = scr_read(ap, SCR_CONTROL); | ||
2472 | scontrol = (scontrol & 0x0f0) | 0x302; | ||
2473 | scr_write_flush(ap, SCR_CONTROL, scontrol); | ||
2254 | 2474 | ||
2255 | /* | 2475 | ata_set_sata_spd(ap); |
2256 | * Couldn't find anything in SATA I/II specs, but AHCI-1.1 | 2476 | } |
2477 | |||
2478 | /* issue phy wake/reset */ | ||
2479 | scontrol = scr_read(ap, SCR_CONTROL); | ||
2480 | scontrol = (scontrol & 0x0f0) | 0x301; | ||
2481 | scr_write_flush(ap, SCR_CONTROL, scontrol); | ||
2482 | |||
2483 | /* Couldn't find anything in SATA I/II specs, but AHCI-1.1 | ||
2257 | * 10.4.2 says at least 1 ms. | 2484 | * 10.4.2 says at least 1 ms. |
2258 | */ | 2485 | */ |
2259 | msleep(1); | 2486 | msleep(1); |
2260 | 2487 | ||
2261 | /* Bring phy back */ | 2488 | /* bring phy back */ |
2262 | sata_phy_resume(ap); | 2489 | sata_phy_resume(ap); |
2263 | 2490 | ||
2264 | /* TODO: phy layer with polling, timeouts, etc. */ | 2491 | /* TODO: phy layer with polling, timeouts, etc. */ |
@@ -2365,16 +2592,16 @@ int ata_std_probe_reset(struct ata_port *ap, unsigned int *classes) | |||
2365 | ata_std_postreset, classes); | 2592 | ata_std_postreset, classes); |
2366 | } | 2593 | } |
2367 | 2594 | ||
2368 | static int do_probe_reset(struct ata_port *ap, ata_reset_fn_t reset, | 2595 | int ata_do_reset(struct ata_port *ap, |
2369 | ata_postreset_fn_t postreset, | 2596 | ata_reset_fn_t reset, ata_postreset_fn_t postreset, |
2370 | unsigned int *classes) | 2597 | int verbose, unsigned int *classes) |
2371 | { | 2598 | { |
2372 | int i, rc; | 2599 | int i, rc; |
2373 | 2600 | ||
2374 | for (i = 0; i < ATA_MAX_DEVICES; i++) | 2601 | for (i = 0; i < ATA_MAX_DEVICES; i++) |
2375 | classes[i] = ATA_DEV_UNKNOWN; | 2602 | classes[i] = ATA_DEV_UNKNOWN; |
2376 | 2603 | ||
2377 | rc = reset(ap, 0, classes); | 2604 | rc = reset(ap, verbose, classes); |
2378 | if (rc) | 2605 | if (rc) |
2379 | return rc; | 2606 | return rc; |
2380 | 2607 | ||
@@ -2394,7 +2621,7 @@ static int do_probe_reset(struct ata_port *ap, ata_reset_fn_t reset, | |||
2394 | if (postreset) | 2621 | if (postreset) |
2395 | postreset(ap, classes); | 2622 | postreset(ap, classes); |
2396 | 2623 | ||
2397 | return classes[0] != ATA_DEV_UNKNOWN ? 0 : -ENODEV; | 2624 | return 0; |
2398 | } | 2625 | } |
2399 | 2626 | ||
2400 | /** | 2627 | /** |
@@ -2438,22 +2665,46 @@ int ata_drive_probe_reset(struct ata_port *ap, ata_probeinit_fn_t probeinit, | |||
2438 | if (probeinit) | 2665 | if (probeinit) |
2439 | probeinit(ap); | 2666 | probeinit(ap); |
2440 | 2667 | ||
2441 | if (softreset) { | 2668 | if (softreset && !ata_set_sata_spd_needed(ap)) { |
2442 | rc = do_probe_reset(ap, softreset, postreset, classes); | 2669 | rc = ata_do_reset(ap, softreset, postreset, 0, classes); |
2443 | if (rc == 0) | 2670 | if (rc == 0 && classes[0] != ATA_DEV_UNKNOWN) |
2444 | return 0; | 2671 | goto done; |
2672 | printk(KERN_INFO "ata%u: softreset failed, will try " | ||
2673 | "hardreset in 5 secs\n", ap->id); | ||
2674 | ssleep(5); | ||
2445 | } | 2675 | } |
2446 | 2676 | ||
2447 | if (!hardreset) | 2677 | if (!hardreset) |
2448 | return rc; | 2678 | goto done; |
2449 | 2679 | ||
2450 | rc = do_probe_reset(ap, hardreset, postreset, classes); | 2680 | while (1) { |
2451 | if (rc == 0 || rc != -ENODEV) | 2681 | rc = ata_do_reset(ap, hardreset, postreset, 0, classes); |
2452 | return rc; | 2682 | if (rc == 0) { |
2683 | if (classes[0] != ATA_DEV_UNKNOWN) | ||
2684 | goto done; | ||
2685 | break; | ||
2686 | } | ||
2687 | |||
2688 | if (ata_down_sata_spd_limit(ap)) | ||
2689 | goto done; | ||
2690 | |||
2691 | printk(KERN_INFO "ata%u: hardreset failed, will retry " | ||
2692 | "in 5 secs\n", ap->id); | ||
2693 | ssleep(5); | ||
2694 | } | ||
2695 | |||
2696 | if (softreset) { | ||
2697 | printk(KERN_INFO "ata%u: hardreset succeeded without " | ||
2698 | "classification, will retry softreset in 5 secs\n", | ||
2699 | ap->id); | ||
2700 | ssleep(5); | ||
2453 | 2701 | ||
2454 | if (softreset) | 2702 | rc = ata_do_reset(ap, softreset, postreset, 0, classes); |
2455 | rc = do_probe_reset(ap, softreset, postreset, classes); | 2703 | } |
2456 | 2704 | ||
2705 | done: | ||
2706 | if (rc == 0 && classes[0] == ATA_DEV_UNKNOWN) | ||
2707 | rc = -ENODEV; | ||
2457 | return rc; | 2708 | return rc; |
2458 | } | 2709 | } |
2459 | 2710 | ||
@@ -2537,15 +2788,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, | 2788 | int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, |
2538 | int post_reset) | 2789 | int post_reset) |
2539 | { | 2790 | { |
2540 | unsigned int class; | 2791 | unsigned int class = dev->class; |
2541 | u16 *id; | 2792 | u16 *id = NULL; |
2542 | int rc; | 2793 | int rc; |
2543 | 2794 | ||
2544 | if (!ata_dev_present(dev)) | 2795 | if (!ata_dev_enabled(dev)) { |
2545 | return -ENODEV; | 2796 | rc = -ENODEV; |
2546 | 2797 | goto fail; | |
2547 | class = dev->class; | 2798 | } |
2548 | id = NULL; | ||
2549 | 2799 | ||
2550 | /* allocate & read ID data */ | 2800 | /* allocate & read ID data */ |
2551 | rc = ata_dev_read_id(ap, dev, &class, post_reset, &id); | 2801 | rc = ata_dev_read_id(ap, dev, &class, post_reset, &id); |
@@ -2562,7 +2812,9 @@ int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, | |||
2562 | dev->id = id; | 2812 | dev->id = id; |
2563 | 2813 | ||
2564 | /* configure device according to the new ID */ | 2814 | /* configure device according to the new ID */ |
2565 | return ata_dev_configure(ap, dev, 0); | 2815 | rc = ata_dev_configure(ap, dev, 0); |
2816 | if (rc == 0) | ||
2817 | return 0; | ||
2566 | 2818 | ||
2567 | fail: | 2819 | fail: |
2568 | printk(KERN_ERR "ata%u: dev %u revalidation failed (errno=%d)\n", | 2820 | printk(KERN_ERR "ata%u: dev %u revalidation failed (errno=%d)\n", |
@@ -2664,23 +2916,34 @@ static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev) | |||
2664 | unsigned long xfer_mask; | 2916 | unsigned long xfer_mask; |
2665 | int i; | 2917 | int i; |
2666 | 2918 | ||
2667 | xfer_mask = ata_pack_xfermask(ap->pio_mask, ap->mwdma_mask, | 2919 | xfer_mask = ata_pack_xfermask(ap->pio_mask, |
2668 | ap->udma_mask); | 2920 | ap->mwdma_mask, ap->udma_mask); |
2921 | |||
2922 | /* Apply cable rule here. Don't apply it early because when | ||
2923 | * we handle hot plug the cable type can itself change. | ||
2924 | */ | ||
2925 | if (ap->cbl == ATA_CBL_PATA40) | ||
2926 | xfer_mask &= ~(0xF8 << ATA_SHIFT_UDMA); | ||
2669 | 2927 | ||
2670 | /* FIXME: Use port-wide xfermask for now */ | 2928 | /* FIXME: Use port-wide xfermask for now */ |
2671 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 2929 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
2672 | struct ata_device *d = &ap->device[i]; | 2930 | struct ata_device *d = &ap->device[i]; |
2673 | if (!ata_dev_present(d)) | 2931 | |
2932 | if (ata_dev_absent(d)) | ||
2933 | continue; | ||
2934 | |||
2935 | if (ata_dev_disabled(d)) { | ||
2936 | /* to avoid violating device selection timing */ | ||
2937 | xfer_mask &= ata_pack_xfermask(d->pio_mask, | ||
2938 | UINT_MAX, UINT_MAX); | ||
2674 | continue; | 2939 | continue; |
2675 | xfer_mask &= ata_pack_xfermask(d->pio_mask, d->mwdma_mask, | 2940 | } |
2676 | d->udma_mask); | 2941 | |
2942 | xfer_mask &= ata_pack_xfermask(d->pio_mask, | ||
2943 | d->mwdma_mask, d->udma_mask); | ||
2677 | xfer_mask &= ata_id_xfermask(d->id); | 2944 | xfer_mask &= ata_id_xfermask(d->id); |
2678 | if (ata_dma_blacklisted(d)) | 2945 | if (ata_dma_blacklisted(d)) |
2679 | xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); | 2946 | 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 | } | 2947 | } |
2685 | 2948 | ||
2686 | if (ata_dma_blacklisted(dev)) | 2949 | if (ata_dma_blacklisted(dev)) |
@@ -2691,11 +2954,12 @@ static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev) | |||
2691 | if (hs->simplex_claimed) | 2954 | if (hs->simplex_claimed) |
2692 | xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); | 2955 | xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); |
2693 | } | 2956 | } |
2957 | |||
2694 | if (ap->ops->mode_filter) | 2958 | if (ap->ops->mode_filter) |
2695 | xfer_mask = ap->ops->mode_filter(ap, dev, xfer_mask); | 2959 | xfer_mask = ap->ops->mode_filter(ap, dev, xfer_mask); |
2696 | 2960 | ||
2697 | ata_unpack_xfermask(xfer_mask, &dev->pio_mask, &dev->mwdma_mask, | 2961 | ata_unpack_xfermask(xfer_mask, &dev->pio_mask, |
2698 | &dev->udma_mask); | 2962 | &dev->mwdma_mask, &dev->udma_mask); |
2699 | } | 2963 | } |
2700 | 2964 | ||
2701 | /** | 2965 | /** |
@@ -2729,7 +2993,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_port *ap, | |||
2729 | tf.protocol = ATA_PROT_NODATA; | 2993 | tf.protocol = ATA_PROT_NODATA; |
2730 | tf.nsect = dev->xfer_mode; | 2994 | tf.nsect = dev->xfer_mode; |
2731 | 2995 | ||
2732 | err_mask = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0); | 2996 | err_mask = ata_exec_internal(ap, dev, &tf, NULL, DMA_NONE, NULL, 0); |
2733 | 2997 | ||
2734 | DPRINTK("EXIT, err_mask=%x\n", err_mask); | 2998 | DPRINTK("EXIT, err_mask=%x\n", err_mask); |
2735 | return err_mask; | 2999 | return err_mask; |
@@ -2769,7 +3033,7 @@ static unsigned int ata_dev_init_params(struct ata_port *ap, | |||
2769 | tf.nsect = sectors; | 3033 | tf.nsect = sectors; |
2770 | tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ | 3034 | tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ |
2771 | 3035 | ||
2772 | err_mask = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0); | 3036 | err_mask = ata_exec_internal(ap, dev, &tf, NULL, DMA_NONE, NULL, 0); |
2773 | 3037 | ||
2774 | DPRINTK("EXIT, err_mask=%x\n", err_mask); | 3038 | DPRINTK("EXIT, err_mask=%x\n", err_mask); |
2775 | return err_mask; | 3039 | return err_mask; |
@@ -3157,7 +3421,7 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc) | |||
3157 | 3421 | ||
3158 | /** | 3422 | /** |
3159 | * ata_pio_poll - poll using PIO, depending on current state | 3423 | * ata_pio_poll - poll using PIO, depending on current state |
3160 | * @ap: the target ata_port | 3424 | * @qc: qc in progress |
3161 | * | 3425 | * |
3162 | * LOCKING: | 3426 | * LOCKING: |
3163 | * None. (executing in kernel thread context) | 3427 | * None. (executing in kernel thread context) |
@@ -3165,17 +3429,13 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc) | |||
3165 | * RETURNS: | 3429 | * RETURNS: |
3166 | * timeout value to use | 3430 | * timeout value to use |
3167 | */ | 3431 | */ |
3168 | 3432 | static unsigned long ata_pio_poll(struct ata_queued_cmd *qc) | |
3169 | static unsigned long ata_pio_poll(struct ata_port *ap) | ||
3170 | { | 3433 | { |
3171 | struct ata_queued_cmd *qc; | 3434 | struct ata_port *ap = qc->ap; |
3172 | u8 status; | 3435 | u8 status; |
3173 | unsigned int poll_state = HSM_ST_UNKNOWN; | 3436 | unsigned int poll_state = HSM_ST_UNKNOWN; |
3174 | unsigned int reg_state = HSM_ST_UNKNOWN; | 3437 | unsigned int reg_state = HSM_ST_UNKNOWN; |
3175 | 3438 | ||
3176 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
3177 | WARN_ON(qc == NULL); | ||
3178 | |||
3179 | switch (ap->hsm_task_state) { | 3439 | switch (ap->hsm_task_state) { |
3180 | case HSM_ST: | 3440 | case HSM_ST: |
3181 | case HSM_ST_POLL: | 3441 | case HSM_ST_POLL: |
@@ -3209,7 +3469,7 @@ static unsigned long ata_pio_poll(struct ata_port *ap) | |||
3209 | 3469 | ||
3210 | /** | 3470 | /** |
3211 | * ata_pio_complete - check if drive is busy or idle | 3471 | * ata_pio_complete - check if drive is busy or idle |
3212 | * @ap: the target ata_port | 3472 | * @qc: qc to complete |
3213 | * | 3473 | * |
3214 | * LOCKING: | 3474 | * LOCKING: |
3215 | * None. (executing in kernel thread context) | 3475 | * None. (executing in kernel thread context) |
@@ -3217,10 +3477,9 @@ static unsigned long ata_pio_poll(struct ata_port *ap) | |||
3217 | * RETURNS: | 3477 | * RETURNS: |
3218 | * Non-zero if qc completed, zero otherwise. | 3478 | * Non-zero if qc completed, zero otherwise. |
3219 | */ | 3479 | */ |
3220 | 3480 | static int ata_pio_complete(struct ata_queued_cmd *qc) | |
3221 | static int ata_pio_complete (struct ata_port *ap) | ||
3222 | { | 3481 | { |
3223 | struct ata_queued_cmd *qc; | 3482 | struct ata_port *ap = qc->ap; |
3224 | u8 drv_stat; | 3483 | u8 drv_stat; |
3225 | 3484 | ||
3226 | /* | 3485 | /* |
@@ -3241,9 +3500,6 @@ static int ata_pio_complete (struct ata_port *ap) | |||
3241 | } | 3500 | } |
3242 | } | 3501 | } |
3243 | 3502 | ||
3244 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
3245 | WARN_ON(qc == NULL); | ||
3246 | |||
3247 | drv_stat = ata_wait_idle(ap); | 3503 | drv_stat = ata_wait_idle(ap); |
3248 | if (!ata_ok(drv_stat)) { | 3504 | if (!ata_ok(drv_stat)) { |
3249 | qc->err_mask |= __ac_err_mask(drv_stat); | 3505 | qc->err_mask |= __ac_err_mask(drv_stat); |
@@ -3579,15 +3835,14 @@ err_out: | |||
3579 | 3835 | ||
3580 | /** | 3836 | /** |
3581 | * ata_pio_block - start PIO on a block | 3837 | * ata_pio_block - start PIO on a block |
3582 | * @ap: the target ata_port | 3838 | * @qc: qc to transfer block for |
3583 | * | 3839 | * |
3584 | * LOCKING: | 3840 | * LOCKING: |
3585 | * None. (executing in kernel thread context) | 3841 | * None. (executing in kernel thread context) |
3586 | */ | 3842 | */ |
3587 | 3843 | static void ata_pio_block(struct ata_queued_cmd *qc) | |
3588 | static void ata_pio_block(struct ata_port *ap) | ||
3589 | { | 3844 | { |
3590 | struct ata_queued_cmd *qc; | 3845 | struct ata_port *ap = qc->ap; |
3591 | u8 status; | 3846 | u8 status; |
3592 | 3847 | ||
3593 | /* | 3848 | /* |
@@ -3609,9 +3864,6 @@ static void ata_pio_block(struct ata_port *ap) | |||
3609 | } | 3864 | } |
3610 | } | 3865 | } |
3611 | 3866 | ||
3612 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
3613 | WARN_ON(qc == NULL); | ||
3614 | |||
3615 | /* check error */ | 3867 | /* check error */ |
3616 | if (status & (ATA_ERR | ATA_DF)) { | 3868 | if (status & (ATA_ERR | ATA_DF)) { |
3617 | qc->err_mask |= AC_ERR_DEV; | 3869 | qc->err_mask |= AC_ERR_DEV; |
@@ -3640,15 +3892,13 @@ static void ata_pio_block(struct ata_port *ap) | |||
3640 | } | 3892 | } |
3641 | } | 3893 | } |
3642 | 3894 | ||
3643 | static void ata_pio_error(struct ata_port *ap) | 3895 | static void ata_pio_error(struct ata_queued_cmd *qc) |
3644 | { | 3896 | { |
3645 | struct ata_queued_cmd *qc; | 3897 | struct ata_port *ap = qc->ap; |
3646 | |||
3647 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
3648 | WARN_ON(qc == NULL); | ||
3649 | 3898 | ||
3650 | if (qc->tf.command != ATA_CMD_PACKET) | 3899 | if (qc->tf.command != ATA_CMD_PACKET) |
3651 | printk(KERN_WARNING "ata%u: PIO error\n", ap->id); | 3900 | printk(KERN_WARNING "ata%u: dev %u PIO error\n", |
3901 | ap->id, qc->dev->devno); | ||
3652 | 3902 | ||
3653 | /* make sure qc->err_mask is available to | 3903 | /* make sure qc->err_mask is available to |
3654 | * know what's wrong and recover | 3904 | * know what's wrong and recover |
@@ -3662,7 +3912,8 @@ static void ata_pio_error(struct ata_port *ap) | |||
3662 | 3912 | ||
3663 | static void ata_pio_task(void *_data) | 3913 | static void ata_pio_task(void *_data) |
3664 | { | 3914 | { |
3665 | struct ata_port *ap = _data; | 3915 | struct ata_queued_cmd *qc = _data; |
3916 | struct ata_port *ap = qc->ap; | ||
3666 | unsigned long timeout; | 3917 | unsigned long timeout; |
3667 | int qc_completed; | 3918 | int qc_completed; |
3668 | 3919 | ||
@@ -3675,33 +3926,33 @@ fsm_start: | |||
3675 | return; | 3926 | return; |
3676 | 3927 | ||
3677 | case HSM_ST: | 3928 | case HSM_ST: |
3678 | ata_pio_block(ap); | 3929 | ata_pio_block(qc); |
3679 | break; | 3930 | break; |
3680 | 3931 | ||
3681 | case HSM_ST_LAST: | 3932 | case HSM_ST_LAST: |
3682 | qc_completed = ata_pio_complete(ap); | 3933 | qc_completed = ata_pio_complete(qc); |
3683 | break; | 3934 | break; |
3684 | 3935 | ||
3685 | case HSM_ST_POLL: | 3936 | case HSM_ST_POLL: |
3686 | case HSM_ST_LAST_POLL: | 3937 | case HSM_ST_LAST_POLL: |
3687 | timeout = ata_pio_poll(ap); | 3938 | timeout = ata_pio_poll(qc); |
3688 | break; | 3939 | break; |
3689 | 3940 | ||
3690 | case HSM_ST_TMOUT: | 3941 | case HSM_ST_TMOUT: |
3691 | case HSM_ST_ERR: | 3942 | case HSM_ST_ERR: |
3692 | ata_pio_error(ap); | 3943 | ata_pio_error(qc); |
3693 | return; | 3944 | return; |
3694 | } | 3945 | } |
3695 | 3946 | ||
3696 | if (timeout) | 3947 | if (timeout) |
3697 | ata_port_queue_task(ap, ata_pio_task, ap, timeout); | 3948 | ata_port_queue_task(ap, ata_pio_task, qc, timeout); |
3698 | else if (!qc_completed) | 3949 | else if (!qc_completed) |
3699 | goto fsm_start; | 3950 | goto fsm_start; |
3700 | } | 3951 | } |
3701 | 3952 | ||
3702 | /** | 3953 | /** |
3703 | * atapi_packet_task - Write CDB bytes to hardware | 3954 | * atapi_packet_task - Write CDB bytes to hardware |
3704 | * @_data: Port to which ATAPI device is attached. | 3955 | * @_data: qc in progress |
3705 | * | 3956 | * |
3706 | * When device has indicated its readiness to accept | 3957 | * When device has indicated its readiness to accept |
3707 | * a CDB, this function is called. Send the CDB. | 3958 | * a CDB, this function is called. Send the CDB. |
@@ -3712,17 +3963,12 @@ fsm_start: | |||
3712 | * LOCKING: | 3963 | * LOCKING: |
3713 | * Kernel thread context (may sleep) | 3964 | * Kernel thread context (may sleep) |
3714 | */ | 3965 | */ |
3715 | |||
3716 | static void atapi_packet_task(void *_data) | 3966 | static void atapi_packet_task(void *_data) |
3717 | { | 3967 | { |
3718 | struct ata_port *ap = _data; | 3968 | struct ata_queued_cmd *qc = _data; |
3719 | struct ata_queued_cmd *qc; | 3969 | struct ata_port *ap = qc->ap; |
3720 | u8 status; | 3970 | u8 status; |
3721 | 3971 | ||
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 */ | 3972 | /* sleep-wait for BSY to clear */ |
3727 | DPRINTK("busy wait\n"); | 3973 | DPRINTK("busy wait\n"); |
3728 | if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) { | 3974 | if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) { |
@@ -3762,7 +4008,7 @@ static void atapi_packet_task(void *_data) | |||
3762 | 4008 | ||
3763 | /* PIO commands are handled by polling */ | 4009 | /* PIO commands are handled by polling */ |
3764 | ap->hsm_task_state = HSM_ST; | 4010 | ap->hsm_task_state = HSM_ST; |
3765 | ata_port_queue_task(ap, ata_pio_task, ap, 0); | 4011 | ata_port_queue_task(ap, ata_pio_task, qc, 0); |
3766 | } | 4012 | } |
3767 | 4013 | ||
3768 | return; | 4014 | return; |
@@ -3772,99 +4018,6 @@ err_out: | |||
3772 | } | 4018 | } |
3773 | 4019 | ||
3774 | /** | 4020 | /** |
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 | 4021 | * ata_qc_new - Request an available ATA command, for queueing |
3869 | * @ap: Port associated with device @dev | 4022 | * @ap: Port associated with device @dev |
3870 | * @dev: Device from whom we request an available command structure | 4023 | * @dev: Device from whom we request an available command structure |
@@ -4068,26 +4221,26 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc) | |||
4068 | ata_qc_set_polling(qc); | 4221 | ata_qc_set_polling(qc); |
4069 | ata_tf_to_host(ap, &qc->tf); | 4222 | ata_tf_to_host(ap, &qc->tf); |
4070 | ap->hsm_task_state = HSM_ST; | 4223 | ap->hsm_task_state = HSM_ST; |
4071 | ata_port_queue_task(ap, ata_pio_task, ap, 0); | 4224 | ata_port_queue_task(ap, ata_pio_task, qc, 0); |
4072 | break; | 4225 | break; |
4073 | 4226 | ||
4074 | case ATA_PROT_ATAPI: | 4227 | case ATA_PROT_ATAPI: |
4075 | ata_qc_set_polling(qc); | 4228 | ata_qc_set_polling(qc); |
4076 | ata_tf_to_host(ap, &qc->tf); | 4229 | ata_tf_to_host(ap, &qc->tf); |
4077 | ata_port_queue_task(ap, atapi_packet_task, ap, 0); | 4230 | ata_port_queue_task(ap, atapi_packet_task, qc, 0); |
4078 | break; | 4231 | break; |
4079 | 4232 | ||
4080 | case ATA_PROT_ATAPI_NODATA: | 4233 | case ATA_PROT_ATAPI_NODATA: |
4081 | ap->flags |= ATA_FLAG_NOINTR; | 4234 | ap->flags |= ATA_FLAG_NOINTR; |
4082 | ata_tf_to_host(ap, &qc->tf); | 4235 | ata_tf_to_host(ap, &qc->tf); |
4083 | ata_port_queue_task(ap, atapi_packet_task, ap, 0); | 4236 | ata_port_queue_task(ap, atapi_packet_task, qc, 0); |
4084 | break; | 4237 | break; |
4085 | 4238 | ||
4086 | case ATA_PROT_ATAPI_DMA: | 4239 | case ATA_PROT_ATAPI_DMA: |
4087 | ap->flags |= ATA_FLAG_NOINTR; | 4240 | ap->flags |= ATA_FLAG_NOINTR; |
4088 | ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ | 4241 | ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ |
4089 | ap->ops->bmdma_setup(qc); /* set up bmdma */ | 4242 | ap->ops->bmdma_setup(qc); /* set up bmdma */ |
4090 | ata_port_queue_task(ap, atapi_packet_task, ap, 0); | 4243 | ata_port_queue_task(ap, atapi_packet_task, qc, 0); |
4091 | break; | 4244 | break; |
4092 | 4245 | ||
4093 | default: | 4246 | default: |
@@ -4209,7 +4362,7 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs) | |||
4209 | 4362 | ||
4210 | ap = host_set->ports[i]; | 4363 | ap = host_set->ports[i]; |
4211 | if (ap && | 4364 | if (ap && |
4212 | !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) { | 4365 | !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) { |
4213 | struct ata_queued_cmd *qc; | 4366 | struct ata_queued_cmd *qc; |
4214 | 4367 | ||
4215 | qc = ata_qc_from_tag(ap, ap->active_tag); | 4368 | qc = ata_qc_from_tag(ap, ap->active_tag); |
@@ -4241,7 +4394,7 @@ static int ata_do_simple_cmd(struct ata_port *ap, struct ata_device *dev, | |||
4241 | tf.flags |= ATA_TFLAG_DEVICE; | 4394 | tf.flags |= ATA_TFLAG_DEVICE; |
4242 | tf.protocol = ATA_PROT_NODATA; | 4395 | tf.protocol = ATA_PROT_NODATA; |
4243 | 4396 | ||
4244 | err = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0); | 4397 | err = ata_exec_internal(ap, dev, &tf, NULL, DMA_NONE, NULL, 0); |
4245 | if (err) | 4398 | if (err) |
4246 | printk(KERN_ERR "%s: ata command failed: %d\n", | 4399 | printk(KERN_ERR "%s: ata command failed: %d\n", |
4247 | __FUNCTION__, err); | 4400 | __FUNCTION__, err); |
@@ -4287,10 +4440,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) | 4440 | int ata_device_resume(struct ata_port *ap, struct ata_device *dev) |
4288 | { | 4441 | { |
4289 | if (ap->flags & ATA_FLAG_SUSPENDED) { | 4442 | if (ap->flags & ATA_FLAG_SUSPENDED) { |
4443 | struct ata_device *failed_dev; | ||
4290 | ap->flags &= ~ATA_FLAG_SUSPENDED; | 4444 | ap->flags &= ~ATA_FLAG_SUSPENDED; |
4291 | ata_set_mode(ap); | 4445 | while (ata_set_mode(ap, &failed_dev)) |
4446 | ata_dev_disable(ap, failed_dev); | ||
4292 | } | 4447 | } |
4293 | if (!ata_dev_present(dev)) | 4448 | if (!ata_dev_enabled(dev)) |
4294 | return 0; | 4449 | return 0; |
4295 | if (dev->class == ATA_DEV_ATA) | 4450 | if (dev->class == ATA_DEV_ATA) |
4296 | ata_start_drive(ap, dev); | 4451 | ata_start_drive(ap, dev); |
@@ -4308,7 +4463,7 @@ int ata_device_resume(struct ata_port *ap, struct ata_device *dev) | |||
4308 | */ | 4463 | */ |
4309 | int ata_device_suspend(struct ata_port *ap, struct ata_device *dev, pm_message_t state) | 4464 | int ata_device_suspend(struct ata_port *ap, struct ata_device *dev, pm_message_t state) |
4310 | { | 4465 | { |
4311 | if (!ata_dev_present(dev)) | 4466 | if (!ata_dev_enabled(dev)) |
4312 | return 0; | 4467 | return 0; |
4313 | if (dev->class == ATA_DEV_ATA) | 4468 | if (dev->class == ATA_DEV_ATA) |
4314 | ata_flush_cache(ap, dev); | 4469 | ata_flush_cache(ap, dev); |
@@ -4428,7 +4583,7 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, | |||
4428 | host->unique_id = ata_unique_id++; | 4583 | host->unique_id = ata_unique_id++; |
4429 | host->max_cmd_len = 12; | 4584 | host->max_cmd_len = 12; |
4430 | 4585 | ||
4431 | ap->flags = ATA_FLAG_PORT_DISABLED; | 4586 | ap->flags = ATA_FLAG_DISABLED; |
4432 | ap->id = host->unique_id; | 4587 | ap->id = host->unique_id; |
4433 | ap->host = host; | 4588 | ap->host = host; |
4434 | ap->ctl = ATA_DEVCTL_OBS; | 4589 | ap->ctl = ATA_DEVCTL_OBS; |
@@ -4443,6 +4598,7 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, | |||
4443 | ap->flags |= ent->host_flags; | 4598 | ap->flags |= ent->host_flags; |
4444 | ap->ops = ent->port_ops; | 4599 | ap->ops = ent->port_ops; |
4445 | ap->cbl = ATA_CBL_NONE; | 4600 | ap->cbl = ATA_CBL_NONE; |
4601 | ap->sata_spd_limit = UINT_MAX; | ||
4446 | ap->active_tag = ATA_TAG_POISON; | 4602 | ap->active_tag = ATA_TAG_POISON; |
4447 | ap->last_ctl = 0xFF; | 4603 | ap->last_ctl = 0xFF; |
4448 | 4604 | ||
@@ -4898,7 +5054,6 @@ EXPORT_SYMBOL_GPL(ata_sg_init); | |||
4898 | EXPORT_SYMBOL_GPL(ata_sg_init_one); | 5054 | EXPORT_SYMBOL_GPL(ata_sg_init_one); |
4899 | EXPORT_SYMBOL_GPL(__ata_qc_complete); | 5055 | EXPORT_SYMBOL_GPL(__ata_qc_complete); |
4900 | EXPORT_SYMBOL_GPL(ata_qc_issue_prot); | 5056 | EXPORT_SYMBOL_GPL(ata_qc_issue_prot); |
4901 | EXPORT_SYMBOL_GPL(ata_eng_timeout); | ||
4902 | EXPORT_SYMBOL_GPL(ata_tf_load); | 5057 | EXPORT_SYMBOL_GPL(ata_tf_load); |
4903 | EXPORT_SYMBOL_GPL(ata_tf_read); | 5058 | EXPORT_SYMBOL_GPL(ata_tf_read); |
4904 | EXPORT_SYMBOL_GPL(ata_noop_dev_select); | 5059 | EXPORT_SYMBOL_GPL(ata_noop_dev_select); |
@@ -4944,8 +5099,6 @@ EXPORT_SYMBOL_GPL(ata_host_intr); | |||
4944 | EXPORT_SYMBOL_GPL(ata_id_string); | 5099 | EXPORT_SYMBOL_GPL(ata_id_string); |
4945 | EXPORT_SYMBOL_GPL(ata_id_c_string); | 5100 | EXPORT_SYMBOL_GPL(ata_id_c_string); |
4946 | EXPORT_SYMBOL_GPL(ata_scsi_simulate); | 5101 | EXPORT_SYMBOL_GPL(ata_scsi_simulate); |
4947 | EXPORT_SYMBOL_GPL(ata_eh_qc_complete); | ||
4948 | EXPORT_SYMBOL_GPL(ata_eh_qc_retry); | ||
4949 | 5102 | ||
4950 | EXPORT_SYMBOL_GPL(ata_pio_need_iordy); | 5103 | EXPORT_SYMBOL_GPL(ata_pio_need_iordy); |
4951 | EXPORT_SYMBOL_GPL(ata_timing_compute); | 5104 | EXPORT_SYMBOL_GPL(ata_timing_compute); |
@@ -4967,3 +5120,8 @@ EXPORT_SYMBOL_GPL(ata_device_suspend); | |||
4967 | EXPORT_SYMBOL_GPL(ata_device_resume); | 5120 | EXPORT_SYMBOL_GPL(ata_device_resume); |
4968 | EXPORT_SYMBOL_GPL(ata_scsi_device_suspend); | 5121 | EXPORT_SYMBOL_GPL(ata_scsi_device_suspend); |
4969 | EXPORT_SYMBOL_GPL(ata_scsi_device_resume); | 5122 | EXPORT_SYMBOL_GPL(ata_scsi_device_resume); |
5123 | |||
5124 | EXPORT_SYMBOL_GPL(ata_scsi_error); | ||
5125 | EXPORT_SYMBOL_GPL(ata_eng_timeout); | ||
5126 | EXPORT_SYMBOL_GPL(ata_eh_qc_complete); | ||
5127 | 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 00000000000..e73f5612aea --- /dev/null +++ b/drivers/scsi/libata-eh.c | |||
@@ -0,0 +1,264 @@ | |||
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 = (struct ata_port *) &host->hostdata[0]; | ||
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 | int ata_scsi_error(struct Scsi_Host *host) | ||
101 | { | ||
102 | struct ata_port *ap = (struct ata_port *)&host->hostdata[0]; | ||
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 | return 0; | ||
120 | } | ||
121 | |||
122 | /** | ||
123 | * ata_qc_timeout - Handle timeout of queued command | ||
124 | * @qc: Command that timed out | ||
125 | * | ||
126 | * Some part of the kernel (currently, only the SCSI layer) | ||
127 | * has noticed that the active command on port @ap has not | ||
128 | * completed after a specified length of time. Handle this | ||
129 | * condition by disabling DMA (if necessary) and completing | ||
130 | * transactions, with error if necessary. | ||
131 | * | ||
132 | * This also handles the case of the "lost interrupt", where | ||
133 | * for some reason (possibly hardware bug, possibly driver bug) | ||
134 | * an interrupt was not delivered to the driver, even though the | ||
135 | * transaction completed successfully. | ||
136 | * | ||
137 | * LOCKING: | ||
138 | * Inherited from SCSI layer (none, can sleep) | ||
139 | */ | ||
140 | static void ata_qc_timeout(struct ata_queued_cmd *qc) | ||
141 | { | ||
142 | struct ata_port *ap = qc->ap; | ||
143 | struct ata_host_set *host_set = ap->host_set; | ||
144 | u8 host_stat = 0, drv_stat; | ||
145 | unsigned long flags; | ||
146 | |||
147 | DPRINTK("ENTER\n"); | ||
148 | |||
149 | ap->hsm_task_state = HSM_ST_IDLE; | ||
150 | |||
151 | spin_lock_irqsave(&host_set->lock, flags); | ||
152 | |||
153 | switch (qc->tf.protocol) { | ||
154 | |||
155 | case ATA_PROT_DMA: | ||
156 | case ATA_PROT_ATAPI_DMA: | ||
157 | host_stat = ap->ops->bmdma_status(ap); | ||
158 | |||
159 | /* before we do anything else, clear DMA-Start bit */ | ||
160 | ap->ops->bmdma_stop(qc); | ||
161 | |||
162 | /* fall through */ | ||
163 | |||
164 | default: | ||
165 | ata_altstatus(ap); | ||
166 | drv_stat = ata_chk_status(ap); | ||
167 | |||
168 | /* ack bmdma irq events */ | ||
169 | ap->ops->irq_clear(ap); | ||
170 | |||
171 | printk(KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x host_stat 0x%x\n", | ||
172 | ap->id, qc->tf.command, drv_stat, host_stat); | ||
173 | |||
174 | /* complete taskfile transaction */ | ||
175 | qc->err_mask |= ac_err_mask(drv_stat); | ||
176 | break; | ||
177 | } | ||
178 | |||
179 | spin_unlock_irqrestore(&host_set->lock, flags); | ||
180 | |||
181 | ata_eh_qc_complete(qc); | ||
182 | |||
183 | DPRINTK("EXIT\n"); | ||
184 | } | ||
185 | |||
186 | /** | ||
187 | * ata_eng_timeout - Handle timeout of queued command | ||
188 | * @ap: Port on which timed-out command is active | ||
189 | * | ||
190 | * Some part of the kernel (currently, only the SCSI layer) | ||
191 | * has noticed that the active command on port @ap has not | ||
192 | * completed after a specified length of time. Handle this | ||
193 | * condition by disabling DMA (if necessary) and completing | ||
194 | * transactions, with error if necessary. | ||
195 | * | ||
196 | * This also handles the case of the "lost interrupt", where | ||
197 | * for some reason (possibly hardware bug, possibly driver bug) | ||
198 | * an interrupt was not delivered to the driver, even though the | ||
199 | * transaction completed successfully. | ||
200 | * | ||
201 | * LOCKING: | ||
202 | * Inherited from SCSI layer (none, can sleep) | ||
203 | */ | ||
204 | void ata_eng_timeout(struct ata_port *ap) | ||
205 | { | ||
206 | DPRINTK("ENTER\n"); | ||
207 | |||
208 | ata_qc_timeout(ata_qc_from_tag(ap, ap->active_tag)); | ||
209 | |||
210 | DPRINTK("EXIT\n"); | ||
211 | } | ||
212 | |||
213 | static void ata_eh_scsidone(struct scsi_cmnd *scmd) | ||
214 | { | ||
215 | /* nada */ | ||
216 | } | ||
217 | |||
218 | static void __ata_eh_qc_complete(struct ata_queued_cmd *qc) | ||
219 | { | ||
220 | struct ata_port *ap = qc->ap; | ||
221 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
222 | unsigned long flags; | ||
223 | |||
224 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
225 | qc->scsidone = ata_eh_scsidone; | ||
226 | __ata_qc_complete(qc); | ||
227 | WARN_ON(ata_tag_valid(qc->tag)); | ||
228 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
229 | |||
230 | scsi_eh_finish_cmd(scmd, &ap->eh_done_q); | ||
231 | } | ||
232 | |||
233 | /** | ||
234 | * ata_eh_qc_complete - Complete an active ATA command from EH | ||
235 | * @qc: Command to complete | ||
236 | * | ||
237 | * Indicate to the mid and upper layers that an ATA command has | ||
238 | * completed. To be used from EH. | ||
239 | */ | ||
240 | void ata_eh_qc_complete(struct ata_queued_cmd *qc) | ||
241 | { | ||
242 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
243 | scmd->retries = scmd->allowed; | ||
244 | __ata_eh_qc_complete(qc); | ||
245 | } | ||
246 | |||
247 | /** | ||
248 | * ata_eh_qc_retry - Tell midlayer to retry an ATA command after EH | ||
249 | * @qc: Command to retry | ||
250 | * | ||
251 | * Indicate to the mid and upper layers that an ATA command | ||
252 | * should be retried. To be used from EH. | ||
253 | * | ||
254 | * SCSI midlayer limits the number of retries to scmd->allowed. | ||
255 | * scmd->retries is decremented for commands which get retried | ||
256 | * due to unrelated failures (qc->err_mask is zero). | ||
257 | */ | ||
258 | void ata_eh_qc_retry(struct ata_queued_cmd *qc) | ||
259 | { | ||
260 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
261 | if (!qc->err_mask && scmd->retries) | ||
262 | scmd->retries--; | ||
263 | __ata_eh_qc_complete(qc); | ||
264 | } | ||
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index a0289ec3e28..5ae7613bc15 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 |
@@ -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; |
@@ -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)) { |
@@ -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 bac8cbae06f..652c08e3808 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,25 @@ 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, | ||
60 | ata_reset_fn_t reset, | ||
61 | ata_postreset_fn_t postreset, | ||
62 | int verbose, unsigned int *classes); | ||
49 | extern void ata_qc_free(struct ata_queued_cmd *qc); | 63 | extern void ata_qc_free(struct ata_queued_cmd *qc); |
50 | extern void ata_qc_issue(struct ata_queued_cmd *qc); | 64 | extern void ata_qc_issue(struct ata_queued_cmd *qc); |
51 | extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); | 65 | extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); |
@@ -89,4 +103,7 @@ extern void ata_scsi_rbuf_fill(struct ata_scsi_args *args, | |||
89 | unsigned int (*actor) (struct ata_scsi_args *args, | 103 | unsigned int (*actor) (struct ata_scsi_args *args, |
90 | u8 *rbuf, unsigned int buflen)); | 104 | u8 *rbuf, unsigned int buflen)); |
91 | 105 | ||
106 | /* libata-eh.c */ | ||
107 | extern enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd); | ||
108 | |||
92 | #endif /* __LIBATA_H__ */ | 109 | #endif /* __LIBATA_H__ */ |
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c index 5cda16cfacb..b9a3c566f83 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 b64b077573c..4aabc759fce 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 9f553081b5e..3a70875be8b 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 7eb67a6bdc6..ddbc0c6dd9f 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 886f3447dd4..259c2dec4e2 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 106627299d5..c9333577330 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 f7264fd611c..9aa7493ea14 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 |
@@ -769,7 +769,7 @@ static irqreturn_t sil24_interrupt(int irq, void *dev_instance, struct pt_regs * | |||
769 | for (i = 0; i < host_set->n_ports; i++) | 769 | for (i = 0; i < host_set->n_ports; i++) |
770 | if (status & (1 << i)) { | 770 | if (status & (1 << i)) { |
771 | struct ata_port *ap = host_set->ports[i]; | 771 | struct ata_port *ap = host_set->ports[i]; |
772 | if (ap && !(ap->flags & ATA_FLAG_PORT_DISABLED)) { | 772 | if (ap && !(ap->flags & ATA_FLAG_DISABLED)) { |
773 | sil24_host_intr(host_set->ports[i]); | 773 | sil24_host_intr(host_set->ports[i]); |
774 | handled++; | 774 | handled++; |
775 | } else | 775 | } else |
diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c index 728530df2e0..3097821688d 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 53b0d5c0a61..e15c693e053 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 */ |
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c index 4139ad4b1df..a669d058988 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 38b52bd3fa3..15f81bfc30f 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 9e7ae4e0db3..17aefab5f42 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 8a29ce340b4..9646c393212 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); |