diff options
author | Tejun Heo <htejun@gmail.com> | 2007-10-09 02:05:44 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-10-12 14:55:47 -0400 |
commit | 2b789108fc1dcba22050a7e6e29ae5ebaea427dd (patch) | |
tree | 1c241e249c388d956ad9771efacfd827a24ec41e /drivers/ata | |
parent | 5f226c6bf78edab023ed1ea679531731d9df92a6 (diff) |
libata: add @timeout to ata_exec_internal[_sg]()
Add @timeout argument to ata_exec_internal[_sg](). If 0, default
timeout ata_probe_timeout is used.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata')
-rw-r--r-- | drivers/ata/libata-acpi.c | 2 | ||||
-rw-r--r-- | drivers/ata/libata-core.c | 32 | ||||
-rw-r--r-- | drivers/ata/libata-eh.c | 4 | ||||
-rw-r--r-- | drivers/ata/libata.h | 5 |
4 files changed, 26 insertions, 17 deletions
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index f862e07d92f2..3f7533589041 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c | |||
@@ -478,7 +478,7 @@ static int taskfile_load_raw(struct ata_device *dev, | |||
478 | tf.lbal, tf.lbam, tf.lbah, tf.device); | 478 | tf.lbal, tf.lbam, tf.lbah, tf.device); |
479 | 479 | ||
480 | rtf = tf; | 480 | rtf = tf; |
481 | err_mask = ata_exec_internal(dev, &rtf, NULL, DMA_NONE, NULL, 0); | 481 | err_mask = ata_exec_internal(dev, &rtf, NULL, DMA_NONE, NULL, 0, 0); |
482 | if (err_mask) { | 482 | if (err_mask) { |
483 | ata_dev_printk(dev, KERN_ERR, | 483 | ata_dev_printk(dev, KERN_ERR, |
484 | "ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x failed " | 484 | "ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x failed " |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index db760e2dc30b..59ebc5d5100a 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -926,7 +926,7 @@ static int ata_read_native_max_address(struct ata_device *dev, u64 *max_sectors) | |||
926 | tf.protocol |= ATA_PROT_NODATA; | 926 | tf.protocol |= ATA_PROT_NODATA; |
927 | tf.device |= ATA_LBA; | 927 | tf.device |= ATA_LBA; |
928 | 928 | ||
929 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); | 929 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); |
930 | if (err_mask) { | 930 | if (err_mask) { |
931 | ata_dev_printk(dev, KERN_WARNING, "failed to read native " | 931 | ata_dev_printk(dev, KERN_WARNING, "failed to read native " |
932 | "max address (err_mask=0x%x)\n", err_mask); | 932 | "max address (err_mask=0x%x)\n", err_mask); |
@@ -988,7 +988,7 @@ static int ata_set_max_sectors(struct ata_device *dev, u64 new_sectors) | |||
988 | tf.lbam = (new_sectors >> 8) & 0xff; | 988 | tf.lbam = (new_sectors >> 8) & 0xff; |
989 | tf.lbah = (new_sectors >> 16) & 0xff; | 989 | tf.lbah = (new_sectors >> 16) & 0xff; |
990 | 990 | ||
991 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); | 991 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); |
992 | if (err_mask) { | 992 | if (err_mask) { |
993 | ata_dev_printk(dev, KERN_WARNING, "failed to set " | 993 | ata_dev_printk(dev, KERN_WARNING, "failed to set " |
994 | "max address (err_mask=0x%x)\n", err_mask); | 994 | "max address (err_mask=0x%x)\n", err_mask); |
@@ -1394,6 +1394,7 @@ static void ata_qc_complete_internal(struct ata_queued_cmd *qc) | |||
1394 | * @dma_dir: Data tranfer direction of the command | 1394 | * @dma_dir: Data tranfer direction of the command |
1395 | * @sg: sg list for the data buffer of the command | 1395 | * @sg: sg list for the data buffer of the command |
1396 | * @n_elem: Number of sg entries | 1396 | * @n_elem: Number of sg entries |
1397 | * @timeout: Timeout in msecs (0 for default) | ||
1397 | * | 1398 | * |
1398 | * Executes libata internal command with timeout. @tf contains | 1399 | * Executes libata internal command with timeout. @tf contains |
1399 | * command on entry and result on return. Timeout and error | 1400 | * command on entry and result on return. Timeout and error |
@@ -1410,7 +1411,7 @@ static void ata_qc_complete_internal(struct ata_queued_cmd *qc) | |||
1410 | unsigned ata_exec_internal_sg(struct ata_device *dev, | 1411 | unsigned ata_exec_internal_sg(struct ata_device *dev, |
1411 | struct ata_taskfile *tf, const u8 *cdb, | 1412 | struct ata_taskfile *tf, const u8 *cdb, |
1412 | int dma_dir, struct scatterlist *sg, | 1413 | int dma_dir, struct scatterlist *sg, |
1413 | unsigned int n_elem) | 1414 | unsigned int n_elem, unsigned long timeout) |
1414 | { | 1415 | { |
1415 | struct ata_link *link = dev->link; | 1416 | struct ata_link *link = dev->link; |
1416 | struct ata_port *ap = link->ap; | 1417 | struct ata_port *ap = link->ap; |
@@ -1486,7 +1487,10 @@ unsigned ata_exec_internal_sg(struct ata_device *dev, | |||
1486 | 1487 | ||
1487 | spin_unlock_irqrestore(ap->lock, flags); | 1488 | spin_unlock_irqrestore(ap->lock, flags); |
1488 | 1489 | ||
1489 | rc = wait_for_completion_timeout(&wait, ata_probe_timeout); | 1490 | if (!timeout) |
1491 | timeout = ata_probe_timeout * 1000 / HZ; | ||
1492 | |||
1493 | rc = wait_for_completion_timeout(&wait, msecs_to_jiffies(timeout)); | ||
1490 | 1494 | ||
1491 | ata_port_flush_task(ap); | 1495 | ata_port_flush_task(ap); |
1492 | 1496 | ||
@@ -1571,6 +1575,7 @@ unsigned ata_exec_internal_sg(struct ata_device *dev, | |||
1571 | * @dma_dir: Data tranfer direction of the command | 1575 | * @dma_dir: Data tranfer direction of the command |
1572 | * @buf: Data buffer of the command | 1576 | * @buf: Data buffer of the command |
1573 | * @buflen: Length of data buffer | 1577 | * @buflen: Length of data buffer |
1578 | * @timeout: Timeout in msecs (0 for default) | ||
1574 | * | 1579 | * |
1575 | * Wrapper around ata_exec_internal_sg() which takes simple | 1580 | * Wrapper around ata_exec_internal_sg() which takes simple |
1576 | * buffer instead of sg list. | 1581 | * buffer instead of sg list. |
@@ -1583,7 +1588,8 @@ unsigned ata_exec_internal_sg(struct ata_device *dev, | |||
1583 | */ | 1588 | */ |
1584 | unsigned ata_exec_internal(struct ata_device *dev, | 1589 | unsigned ata_exec_internal(struct ata_device *dev, |
1585 | struct ata_taskfile *tf, const u8 *cdb, | 1590 | struct ata_taskfile *tf, const u8 *cdb, |
1586 | int dma_dir, void *buf, unsigned int buflen) | 1591 | int dma_dir, void *buf, unsigned int buflen, |
1592 | unsigned long timeout) | ||
1587 | { | 1593 | { |
1588 | struct scatterlist *psg = NULL, sg; | 1594 | struct scatterlist *psg = NULL, sg; |
1589 | unsigned int n_elem = 0; | 1595 | unsigned int n_elem = 0; |
@@ -1595,7 +1601,8 @@ unsigned ata_exec_internal(struct ata_device *dev, | |||
1595 | n_elem++; | 1601 | n_elem++; |
1596 | } | 1602 | } |
1597 | 1603 | ||
1598 | return ata_exec_internal_sg(dev, tf, cdb, dma_dir, psg, n_elem); | 1604 | return ata_exec_internal_sg(dev, tf, cdb, dma_dir, psg, n_elem, |
1605 | timeout); | ||
1599 | } | 1606 | } |
1600 | 1607 | ||
1601 | /** | 1608 | /** |
@@ -1622,7 +1629,7 @@ unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd) | |||
1622 | tf.flags |= ATA_TFLAG_DEVICE; | 1629 | tf.flags |= ATA_TFLAG_DEVICE; |
1623 | tf.protocol = ATA_PROT_NODATA; | 1630 | tf.protocol = ATA_PROT_NODATA; |
1624 | 1631 | ||
1625 | return ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); | 1632 | return ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); |
1626 | } | 1633 | } |
1627 | 1634 | ||
1628 | /** | 1635 | /** |
@@ -1737,7 +1744,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1737 | tf.flags |= ATA_TFLAG_POLLING; | 1744 | tf.flags |= ATA_TFLAG_POLLING; |
1738 | 1745 | ||
1739 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, | 1746 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, |
1740 | id, sizeof(id[0]) * ATA_ID_WORDS); | 1747 | id, sizeof(id[0]) * ATA_ID_WORDS, 0); |
1741 | if (err_mask) { | 1748 | if (err_mask) { |
1742 | if (err_mask & AC_ERR_NODEV_HINT) { | 1749 | if (err_mask & AC_ERR_NODEV_HINT) { |
1743 | DPRINTK("ata%u.%d: NODEV after polling detection\n", | 1750 | DPRINTK("ata%u.%d: NODEV after polling detection\n", |
@@ -1796,7 +1803,8 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1796 | tf.feature = SETFEATURES_SPINUP; | 1803 | tf.feature = SETFEATURES_SPINUP; |
1797 | tf.protocol = ATA_PROT_NODATA; | 1804 | tf.protocol = ATA_PROT_NODATA; |
1798 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | 1805 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; |
1799 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); | 1806 | err_mask = ata_exec_internal(dev, &tf, NULL, |
1807 | DMA_NONE, NULL, 0, 0); | ||
1800 | if (err_mask && id[2] != 0x738c) { | 1808 | if (err_mask && id[2] != 0x738c) { |
1801 | rc = -EIO; | 1809 | rc = -EIO; |
1802 | reason = "SPINUP failed"; | 1810 | reason = "SPINUP failed"; |
@@ -4157,7 +4165,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev) | |||
4157 | tf.protocol = ATA_PROT_NODATA; | 4165 | tf.protocol = ATA_PROT_NODATA; |
4158 | tf.nsect = dev->xfer_mode; | 4166 | tf.nsect = dev->xfer_mode; |
4159 | 4167 | ||
4160 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); | 4168 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); |
4161 | 4169 | ||
4162 | DPRINTK("EXIT, err_mask=%x\n", err_mask); | 4170 | DPRINTK("EXIT, err_mask=%x\n", err_mask); |
4163 | return err_mask; | 4171 | return err_mask; |
@@ -4193,7 +4201,7 @@ static unsigned int ata_dev_set_AN(struct ata_device *dev, u8 enable) | |||
4193 | tf.protocol = ATA_PROT_NODATA; | 4201 | tf.protocol = ATA_PROT_NODATA; |
4194 | tf.nsect = SATA_AN; | 4202 | tf.nsect = SATA_AN; |
4195 | 4203 | ||
4196 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); | 4204 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); |
4197 | 4205 | ||
4198 | DPRINTK("EXIT, err_mask=%x\n", err_mask); | 4206 | DPRINTK("EXIT, err_mask=%x\n", err_mask); |
4199 | return err_mask; | 4207 | return err_mask; |
@@ -4231,7 +4239,7 @@ static unsigned int ata_dev_init_params(struct ata_device *dev, | |||
4231 | tf.nsect = sectors; | 4239 | tf.nsect = sectors; |
4232 | tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ | 4240 | tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ |
4233 | 4241 | ||
4234 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); | 4242 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); |
4235 | /* A clean abort indicates an original or just out of spec drive | 4243 | /* A clean abort indicates an original or just out of spec drive |
4236 | and we should continue as we issue the setup based on the | 4244 | and we should continue as we issue the setup based on the |
4237 | drive reported working geometry */ | 4245 | drive reported working geometry */ |
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 8aa61403303f..c0e9a42e6ae7 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -1249,7 +1249,7 @@ static unsigned int ata_read_log_page(struct ata_device *dev, | |||
1249 | tf.protocol = ATA_PROT_PIO; | 1249 | tf.protocol = ATA_PROT_PIO; |
1250 | 1250 | ||
1251 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, | 1251 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, |
1252 | buf, sectors * ATA_SECT_SIZE); | 1252 | buf, sectors * ATA_SECT_SIZE, 0); |
1253 | 1253 | ||
1254 | DPRINTK("EXIT, err_mask=%x\n", err_mask); | 1254 | DPRINTK("EXIT, err_mask=%x\n", err_mask); |
1255 | return err_mask; | 1255 | return err_mask; |
@@ -1363,7 +1363,7 @@ static unsigned int atapi_eh_request_sense(struct ata_queued_cmd *qc) | |||
1363 | } | 1363 | } |
1364 | 1364 | ||
1365 | return ata_exec_internal(dev, &tf, cdb, DMA_FROM_DEVICE, | 1365 | return ata_exec_internal(dev, &tf, cdb, DMA_FROM_DEVICE, |
1366 | sense_buf, SCSI_SENSE_BUFFERSIZE); | 1366 | sense_buf, SCSI_SENSE_BUFFERSIZE, 0); |
1367 | } | 1367 | } |
1368 | 1368 | ||
1369 | /** | 1369 | /** |
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index f8bd955c5ba7..90df58a3edc9 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h | |||
@@ -69,11 +69,12 @@ extern void ata_dev_disable(struct ata_device *dev); | |||
69 | extern void ata_port_flush_task(struct ata_port *ap); | 69 | extern void ata_port_flush_task(struct ata_port *ap); |
70 | extern unsigned ata_exec_internal(struct ata_device *dev, | 70 | extern unsigned ata_exec_internal(struct ata_device *dev, |
71 | struct ata_taskfile *tf, const u8 *cdb, | 71 | struct ata_taskfile *tf, const u8 *cdb, |
72 | int dma_dir, void *buf, unsigned int buflen); | 72 | int dma_dir, void *buf, unsigned int buflen, |
73 | unsigned long timeout); | ||
73 | extern unsigned ata_exec_internal_sg(struct ata_device *dev, | 74 | extern unsigned ata_exec_internal_sg(struct ata_device *dev, |
74 | struct ata_taskfile *tf, const u8 *cdb, | 75 | struct ata_taskfile *tf, const u8 *cdb, |
75 | int dma_dir, struct scatterlist *sg, | 76 | int dma_dir, struct scatterlist *sg, |
76 | unsigned int n_elem); | 77 | unsigned int n_elem, unsigned long timeout); |
77 | extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd); | 78 | extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd); |
78 | extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | 79 | extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, |
79 | unsigned int flags, u16 *id); | 80 | unsigned int flags, u16 *id); |