diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-27 22:07:21 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-27 22:07:21 -0400 |
commit | 03529d9f66b7995c67ddceb8f83258df3c9915da (patch) | |
tree | c16b506ebbb5644849f094c23976680906d64c1f /drivers/scsi/libata-core.c | |
parent | 11bcab9071ac204b1ca2bb0514ad1641bc4c280b (diff) | |
parent | 2154cfa6ba560401d25f6cc083fe3fb996cbb571 (diff) |
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev
* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev:
[PATCH] ata_piix: add ICH6/7/8 to Kconfig
[PATCH] sata_sil: disable hotplug interrupts on two ATI IXPs
[PATCH] libata: cosmetic updates
[PATCH] ata: add some NVIDIA chipset IDs
[PATCH] libata reduce timeouts
[PATCH] libata: implement ata_port_max_devices()
[PATCH] libata: make two functions global
[PATCH] libata: update ata_do_simple_cmd()
[PATCH] libata: move ata_do_simple_cmd() below ata_exec_internal()
[PATCH] libata: clear EH action on device detach
[PATCH] libata: implement and use ata_deh_dev_action()
[PATCH] libata: move ata_eh_clear_action() upward
[PATCH] libata.h needs scatterlist.h
[libata] sata_vsc: partially revert a PCI ID-related commit
[libata] Bump versions
Diffstat (limited to 'drivers/scsi/libata-core.c')
-rw-r--r-- | drivers/scsi/libata-core.c | 151 |
1 files changed, 94 insertions, 57 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 855ce9a9d948..d1c1c30d123f 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -88,6 +88,10 @@ int libata_fua = 0; | |||
88 | module_param_named(fua, libata_fua, int, 0444); | 88 | module_param_named(fua, libata_fua, int, 0444); |
89 | MODULE_PARM_DESC(fua, "FUA support (0=off, 1=on)"); | 89 | MODULE_PARM_DESC(fua, "FUA support (0=off, 1=on)"); |
90 | 90 | ||
91 | static int ata_probe_timeout = ATA_TMOUT_INTERNAL / HZ; | ||
92 | module_param(ata_probe_timeout, int, 0444); | ||
93 | MODULE_PARM_DESC(ata_probe_timeout, "Set ATA probing timeout (seconds)"); | ||
94 | |||
91 | MODULE_AUTHOR("Jeff Garzik"); | 95 | MODULE_AUTHOR("Jeff Garzik"); |
92 | MODULE_DESCRIPTION("Library module for ATA devices"); | 96 | MODULE_DESCRIPTION("Library module for ATA devices"); |
93 | MODULE_LICENSE("GPL"); | 97 | MODULE_LICENSE("GPL"); |
@@ -777,11 +781,9 @@ void ata_std_dev_select (struct ata_port *ap, unsigned int device) | |||
777 | void ata_dev_select(struct ata_port *ap, unsigned int device, | 781 | void ata_dev_select(struct ata_port *ap, unsigned int device, |
778 | unsigned int wait, unsigned int can_sleep) | 782 | unsigned int wait, unsigned int can_sleep) |
779 | { | 783 | { |
780 | if (ata_msg_probe(ap)) { | 784 | if (ata_msg_probe(ap)) |
781 | ata_port_printk(ap, KERN_INFO, "ata_dev_select: ENTER, ata%u: " | 785 | ata_port_printk(ap, KERN_INFO, "ata_dev_select: ENTER, ata%u: " |
782 | "device %u, wait %u\n", | 786 | "device %u, wait %u\n", ap->id, device, wait); |
783 | ap->id, device, wait); | ||
784 | } | ||
785 | 787 | ||
786 | if (wait) | 788 | if (wait) |
787 | ata_wait_idle(ap); | 789 | ata_wait_idle(ap); |
@@ -950,7 +952,8 @@ void ata_port_flush_task(struct ata_port *ap) | |||
950 | */ | 952 | */ |
951 | if (!cancel_delayed_work(&ap->port_task)) { | 953 | if (!cancel_delayed_work(&ap->port_task)) { |
952 | if (ata_msg_ctl(ap)) | 954 | if (ata_msg_ctl(ap)) |
953 | ata_port_printk(ap, KERN_DEBUG, "%s: flush #2\n", __FUNCTION__); | 955 | ata_port_printk(ap, KERN_DEBUG, "%s: flush #2\n", |
956 | __FUNCTION__); | ||
954 | flush_workqueue(ata_wq); | 957 | flush_workqueue(ata_wq); |
955 | } | 958 | } |
956 | 959 | ||
@@ -1059,7 +1062,7 @@ unsigned ata_exec_internal(struct ata_device *dev, | |||
1059 | 1062 | ||
1060 | spin_unlock_irqrestore(ap->lock, flags); | 1063 | spin_unlock_irqrestore(ap->lock, flags); |
1061 | 1064 | ||
1062 | rc = wait_for_completion_timeout(&wait, ATA_TMOUT_INTERNAL); | 1065 | rc = wait_for_completion_timeout(&wait, ata_probe_timeout); |
1063 | 1066 | ||
1064 | ata_port_flush_task(ap); | 1067 | ata_port_flush_task(ap); |
1065 | 1068 | ||
@@ -1081,7 +1084,7 @@ unsigned ata_exec_internal(struct ata_device *dev, | |||
1081 | 1084 | ||
1082 | if (ata_msg_warn(ap)) | 1085 | if (ata_msg_warn(ap)) |
1083 | ata_dev_printk(dev, KERN_WARNING, | 1086 | ata_dev_printk(dev, KERN_WARNING, |
1084 | "qc timeout (cmd 0x%x)\n", command); | 1087 | "qc timeout (cmd 0x%x)\n", command); |
1085 | } | 1088 | } |
1086 | 1089 | ||
1087 | spin_unlock_irqrestore(ap->lock, flags); | 1090 | spin_unlock_irqrestore(ap->lock, flags); |
@@ -1093,9 +1096,9 @@ unsigned ata_exec_internal(struct ata_device *dev, | |||
1093 | 1096 | ||
1094 | if (qc->flags & ATA_QCFLAG_FAILED && !qc->err_mask) { | 1097 | if (qc->flags & ATA_QCFLAG_FAILED && !qc->err_mask) { |
1095 | if (ata_msg_warn(ap)) | 1098 | if (ata_msg_warn(ap)) |
1096 | ata_dev_printk(dev, KERN_WARNING, | 1099 | ata_dev_printk(dev, KERN_WARNING, |
1097 | "zero err_mask for failed " | 1100 | "zero err_mask for failed " |
1098 | "internal command, assuming AC_ERR_OTHER\n"); | 1101 | "internal command, assuming AC_ERR_OTHER\n"); |
1099 | qc->err_mask |= AC_ERR_OTHER; | 1102 | qc->err_mask |= AC_ERR_OTHER; |
1100 | } | 1103 | } |
1101 | 1104 | ||
@@ -1132,6 +1135,33 @@ unsigned ata_exec_internal(struct ata_device *dev, | |||
1132 | } | 1135 | } |
1133 | 1136 | ||
1134 | /** | 1137 | /** |
1138 | * ata_do_simple_cmd - execute simple internal command | ||
1139 | * @dev: Device to which the command is sent | ||
1140 | * @cmd: Opcode to execute | ||
1141 | * | ||
1142 | * Execute a 'simple' command, that only consists of the opcode | ||
1143 | * 'cmd' itself, without filling any other registers | ||
1144 | * | ||
1145 | * LOCKING: | ||
1146 | * Kernel thread context (may sleep). | ||
1147 | * | ||
1148 | * RETURNS: | ||
1149 | * Zero on success, AC_ERR_* mask on failure | ||
1150 | */ | ||
1151 | unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd) | ||
1152 | { | ||
1153 | struct ata_taskfile tf; | ||
1154 | |||
1155 | ata_tf_init(dev, &tf); | ||
1156 | |||
1157 | tf.command = cmd; | ||
1158 | tf.flags |= ATA_TFLAG_DEVICE; | ||
1159 | tf.protocol = ATA_PROT_NODATA; | ||
1160 | |||
1161 | return ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); | ||
1162 | } | ||
1163 | |||
1164 | /** | ||
1135 | * ata_pio_need_iordy - check if iordy needed | 1165 | * ata_pio_need_iordy - check if iordy needed |
1136 | * @adev: ATA device | 1166 | * @adev: ATA device |
1137 | * | 1167 | * |
@@ -1193,8 +1223,8 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1193 | int rc; | 1223 | int rc; |
1194 | 1224 | ||
1195 | if (ata_msg_ctl(ap)) | 1225 | if (ata_msg_ctl(ap)) |
1196 | ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER, host %u, dev %u\n", | 1226 | ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER, host %u, dev %u\n", |
1197 | __FUNCTION__, ap->id, dev->devno); | 1227 | __FUNCTION__, ap->id, dev->devno); |
1198 | 1228 | ||
1199 | ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */ | 1229 | ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */ |
1200 | 1230 | ||
@@ -1263,9 +1293,9 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1263 | return 0; | 1293 | return 0; |
1264 | 1294 | ||
1265 | err_out: | 1295 | err_out: |
1266 | if (ata_msg_warn(ap)) | 1296 | if (ata_msg_warn(ap)) |
1267 | ata_dev_printk(dev, KERN_WARNING, "failed to IDENTIFY " | 1297 | ata_dev_printk(dev, KERN_WARNING, "failed to IDENTIFY " |
1268 | "(%s, err_mask=0x%x)\n", reason, err_mask); | 1298 | "(%s, err_mask=0x%x)\n", reason, err_mask); |
1269 | return rc; | 1299 | return rc; |
1270 | } | 1300 | } |
1271 | 1301 | ||
@@ -1318,19 +1348,21 @@ int ata_dev_configure(struct ata_device *dev, int print_info) | |||
1318 | int i, rc; | 1348 | int i, rc; |
1319 | 1349 | ||
1320 | if (!ata_dev_enabled(dev) && ata_msg_info(ap)) { | 1350 | if (!ata_dev_enabled(dev) && ata_msg_info(ap)) { |
1321 | ata_dev_printk(dev, KERN_INFO, "%s: ENTER/EXIT (host %u, dev %u) -- nodev\n", | 1351 | ata_dev_printk(dev, KERN_INFO, |
1322 | __FUNCTION__, ap->id, dev->devno); | 1352 | "%s: ENTER/EXIT (host %u, dev %u) -- nodev\n", |
1353 | __FUNCTION__, ap->id, dev->devno); | ||
1323 | return 0; | 1354 | return 0; |
1324 | } | 1355 | } |
1325 | 1356 | ||
1326 | if (ata_msg_probe(ap)) | 1357 | if (ata_msg_probe(ap)) |
1327 | ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER, host %u, dev %u\n", | 1358 | ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER, host %u, dev %u\n", |
1328 | __FUNCTION__, ap->id, dev->devno); | 1359 | __FUNCTION__, ap->id, dev->devno); |
1329 | 1360 | ||
1330 | /* print device capabilities */ | 1361 | /* print device capabilities */ |
1331 | if (ata_msg_probe(ap)) | 1362 | if (ata_msg_probe(ap)) |
1332 | ata_dev_printk(dev, KERN_DEBUG, "%s: cfg 49:%04x 82:%04x 83:%04x " | 1363 | ata_dev_printk(dev, KERN_DEBUG, |
1333 | "84:%04x 85:%04x 86:%04x 87:%04x 88:%04x\n", | 1364 | "%s: cfg 49:%04x 82:%04x 83:%04x 84:%04x " |
1365 | "85:%04x 86:%04x 87:%04x 88:%04x\n", | ||
1334 | __FUNCTION__, | 1366 | __FUNCTION__, |
1335 | id[49], id[82], id[83], id[84], | 1367 | id[49], id[82], id[83], id[84], |
1336 | id[85], id[86], id[87], id[88]); | 1368 | id[85], id[86], id[87], id[88]); |
@@ -1402,14 +1434,16 @@ int ata_dev_configure(struct ata_device *dev, int print_info) | |||
1402 | ata_id_major_version(id), | 1434 | ata_id_major_version(id), |
1403 | ata_mode_string(xfer_mask), | 1435 | ata_mode_string(xfer_mask), |
1404 | (unsigned long long)dev->n_sectors, | 1436 | (unsigned long long)dev->n_sectors, |
1405 | dev->cylinders, dev->heads, dev->sectors); | 1437 | dev->cylinders, dev->heads, |
1438 | dev->sectors); | ||
1406 | } | 1439 | } |
1407 | 1440 | ||
1408 | if (dev->id[59] & 0x100) { | 1441 | if (dev->id[59] & 0x100) { |
1409 | dev->multi_count = dev->id[59] & 0xff; | 1442 | dev->multi_count = dev->id[59] & 0xff; |
1410 | if (ata_msg_info(ap)) | 1443 | if (ata_msg_info(ap)) |
1411 | ata_dev_printk(dev, KERN_INFO, "ata%u: dev %u multi count %u\n", | 1444 | ata_dev_printk(dev, KERN_INFO, |
1412 | ap->id, dev->devno, dev->multi_count); | 1445 | "ata%u: dev %u multi count %u\n", |
1446 | ap->id, dev->devno, dev->multi_count); | ||
1413 | } | 1447 | } |
1414 | 1448 | ||
1415 | dev->cdb_len = 16; | 1449 | dev->cdb_len = 16; |
@@ -1422,8 +1456,8 @@ int ata_dev_configure(struct ata_device *dev, int print_info) | |||
1422 | rc = atapi_cdb_len(id); | 1456 | rc = atapi_cdb_len(id); |
1423 | if ((rc < 12) || (rc > ATAPI_CDB_LEN)) { | 1457 | if ((rc < 12) || (rc > ATAPI_CDB_LEN)) { |
1424 | if (ata_msg_warn(ap)) | 1458 | if (ata_msg_warn(ap)) |
1425 | ata_dev_printk(dev, KERN_WARNING, | 1459 | ata_dev_printk(dev, KERN_WARNING, |
1426 | "unsupported CDB len\n"); | 1460 | "unsupported CDB len\n"); |
1427 | rc = -EINVAL; | 1461 | rc = -EINVAL; |
1428 | goto err_out_nosup; | 1462 | goto err_out_nosup; |
1429 | } | 1463 | } |
@@ -1466,8 +1500,8 @@ int ata_dev_configure(struct ata_device *dev, int print_info) | |||
1466 | 1500 | ||
1467 | err_out_nosup: | 1501 | err_out_nosup: |
1468 | if (ata_msg_probe(ap)) | 1502 | if (ata_msg_probe(ap)) |
1469 | ata_dev_printk(dev, KERN_DEBUG, | 1503 | ata_dev_printk(dev, KERN_DEBUG, |
1470 | "%s: EXIT, err\n", __FUNCTION__); | 1504 | "%s: EXIT, err\n", __FUNCTION__); |
1471 | return rc; | 1505 | return rc; |
1472 | } | 1506 | } |
1473 | 1507 | ||
@@ -3527,7 +3561,7 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words) | |||
3527 | * Inherited from caller. | 3561 | * Inherited from caller. |
3528 | */ | 3562 | */ |
3529 | 3563 | ||
3530 | void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf, | 3564 | void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf, |
3531 | unsigned int buflen, int write_data) | 3565 | unsigned int buflen, int write_data) |
3532 | { | 3566 | { |
3533 | struct ata_port *ap = adev->ap; | 3567 | struct ata_port *ap = adev->ap; |
@@ -3573,7 +3607,7 @@ void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf, | |||
3573 | * Inherited from caller. | 3607 | * Inherited from caller. |
3574 | */ | 3608 | */ |
3575 | 3609 | ||
3576 | void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf, | 3610 | void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf, |
3577 | unsigned int buflen, int write_data) | 3611 | unsigned int buflen, int write_data) |
3578 | { | 3612 | { |
3579 | struct ata_port *ap = adev->ap; | 3613 | struct ata_port *ap = adev->ap; |
@@ -3607,7 +3641,7 @@ void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf, | |||
3607 | * @buflen: buffer length | 3641 | * @buflen: buffer length |
3608 | * @write_data: read/write | 3642 | * @write_data: read/write |
3609 | * | 3643 | * |
3610 | * Transfer data from/to the device data register by PIO. Do the | 3644 | * Transfer data from/to the device data register by PIO. Do the |
3611 | * transfer with interrupts disabled. | 3645 | * transfer with interrupts disabled. |
3612 | * | 3646 | * |
3613 | * LOCKING: | 3647 | * LOCKING: |
@@ -4946,31 +4980,9 @@ int ata_port_offline(struct ata_port *ap) | |||
4946 | return 0; | 4980 | return 0; |
4947 | } | 4981 | } |
4948 | 4982 | ||
4949 | /* | 4983 | int ata_flush_cache(struct ata_device *dev) |
4950 | * Execute a 'simple' command, that only consists of the opcode 'cmd' itself, | ||
4951 | * without filling any other registers | ||
4952 | */ | ||
4953 | static int ata_do_simple_cmd(struct ata_device *dev, u8 cmd) | ||
4954 | { | ||
4955 | struct ata_taskfile tf; | ||
4956 | int err; | ||
4957 | |||
4958 | ata_tf_init(dev, &tf); | ||
4959 | |||
4960 | tf.command = cmd; | ||
4961 | tf.flags |= ATA_TFLAG_DEVICE; | ||
4962 | tf.protocol = ATA_PROT_NODATA; | ||
4963 | |||
4964 | err = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); | ||
4965 | if (err) | ||
4966 | ata_dev_printk(dev, KERN_ERR, "%s: ata command failed: %d\n", | ||
4967 | __FUNCTION__, err); | ||
4968 | |||
4969 | return err; | ||
4970 | } | ||
4971 | |||
4972 | static int ata_flush_cache(struct ata_device *dev) | ||
4973 | { | 4984 | { |
4985 | unsigned int err_mask; | ||
4974 | u8 cmd; | 4986 | u8 cmd; |
4975 | 4987 | ||
4976 | if (!ata_try_flush_cache(dev)) | 4988 | if (!ata_try_flush_cache(dev)) |
@@ -4981,17 +4993,41 @@ static int ata_flush_cache(struct ata_device *dev) | |||
4981 | else | 4993 | else |
4982 | cmd = ATA_CMD_FLUSH; | 4994 | cmd = ATA_CMD_FLUSH; |
4983 | 4995 | ||
4984 | return ata_do_simple_cmd(dev, cmd); | 4996 | err_mask = ata_do_simple_cmd(dev, cmd); |
4997 | if (err_mask) { | ||
4998 | ata_dev_printk(dev, KERN_ERR, "failed to flush cache\n"); | ||
4999 | return -EIO; | ||
5000 | } | ||
5001 | |||
5002 | return 0; | ||
4985 | } | 5003 | } |
4986 | 5004 | ||
4987 | static int ata_standby_drive(struct ata_device *dev) | 5005 | static int ata_standby_drive(struct ata_device *dev) |
4988 | { | 5006 | { |
4989 | return ata_do_simple_cmd(dev, ATA_CMD_STANDBYNOW1); | 5007 | unsigned int err_mask; |
5008 | |||
5009 | err_mask = ata_do_simple_cmd(dev, ATA_CMD_STANDBYNOW1); | ||
5010 | if (err_mask) { | ||
5011 | ata_dev_printk(dev, KERN_ERR, "failed to standby drive " | ||
5012 | "(err_mask=0x%x)\n", err_mask); | ||
5013 | return -EIO; | ||
5014 | } | ||
5015 | |||
5016 | return 0; | ||
4990 | } | 5017 | } |
4991 | 5018 | ||
4992 | static int ata_start_drive(struct ata_device *dev) | 5019 | static int ata_start_drive(struct ata_device *dev) |
4993 | { | 5020 | { |
4994 | return ata_do_simple_cmd(dev, ATA_CMD_IDLEIMMEDIATE); | 5021 | unsigned int err_mask; |
5022 | |||
5023 | err_mask = ata_do_simple_cmd(dev, ATA_CMD_IDLEIMMEDIATE); | ||
5024 | if (err_mask) { | ||
5025 | ata_dev_printk(dev, KERN_ERR, "failed to start drive " | ||
5026 | "(err_mask=0x%x)\n", err_mask); | ||
5027 | return -EIO; | ||
5028 | } | ||
5029 | |||
5030 | return 0; | ||
4995 | } | 5031 | } |
4996 | 5032 | ||
4997 | /** | 5033 | /** |
@@ -5212,7 +5248,7 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, | |||
5212 | ap->msg_enable = 0x00FF; | 5248 | ap->msg_enable = 0x00FF; |
5213 | #elif defined(ATA_DEBUG) | 5249 | #elif defined(ATA_DEBUG) |
5214 | ap->msg_enable = ATA_MSG_DRV | ATA_MSG_INFO | ATA_MSG_CTL | ATA_MSG_WARN | ATA_MSG_ERR; | 5250 | ap->msg_enable = ATA_MSG_DRV | ATA_MSG_INFO | ATA_MSG_CTL | ATA_MSG_WARN | ATA_MSG_ERR; |
5215 | #else | 5251 | #else |
5216 | ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR | ATA_MSG_WARN; | 5252 | ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR | ATA_MSG_WARN; |
5217 | #endif | 5253 | #endif |
5218 | 5254 | ||
@@ -5709,6 +5745,7 @@ int ata_pci_device_resume(struct pci_dev *pdev) | |||
5709 | 5745 | ||
5710 | static int __init ata_init(void) | 5746 | static int __init ata_init(void) |
5711 | { | 5747 | { |
5748 | ata_probe_timeout *= HZ; | ||
5712 | ata_wq = create_workqueue("ata"); | 5749 | ata_wq = create_workqueue("ata"); |
5713 | if (!ata_wq) | 5750 | if (!ata_wq) |
5714 | return -ENOMEM; | 5751 | return -ENOMEM; |