From e58eb583969ff662c8c337e9b3b50ab5ef37e27e Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 24 Jun 2006 20:30:19 +0900 Subject: [PATCH] libata: move ata_do_simple_cmd() below ata_exec_internal() Move ata_do_simple_cmd() below ata_exec_internal() for consistency. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'drivers/scsi/libata-core.c') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 6c66877be2b..bbd6665eb21 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -1131,6 +1131,29 @@ unsigned ata_exec_internal(struct ata_device *dev, return err_mask; } +/* + * Execute a 'simple' command, that only consists of the opcode 'cmd' itself, + * without filling any other registers + */ +static int ata_do_simple_cmd(struct ata_device *dev, u8 cmd) +{ + struct ata_taskfile tf; + int err; + + ata_tf_init(dev, &tf); + + tf.command = cmd; + tf.flags |= ATA_TFLAG_DEVICE; + tf.protocol = ATA_PROT_NODATA; + + err = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); + if (err) + ata_dev_printk(dev, KERN_ERR, "%s: ata command failed: %d\n", + __FUNCTION__, err); + + return err; +} + /** * ata_pio_need_iordy - check if iordy needed * @adev: ATA device @@ -4946,29 +4969,6 @@ int ata_port_offline(struct ata_port *ap) return 0; } -/* - * Execute a 'simple' command, that only consists of the opcode 'cmd' itself, - * without filling any other registers - */ -static int ata_do_simple_cmd(struct ata_device *dev, u8 cmd) -{ - struct ata_taskfile tf; - int err; - - ata_tf_init(dev, &tf); - - tf.command = cmd; - tf.flags |= ATA_TFLAG_DEVICE; - tf.protocol = ATA_PROT_NODATA; - - err = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); - if (err) - ata_dev_printk(dev, KERN_ERR, "%s: ata command failed: %d\n", - __FUNCTION__, err); - - return err; -} - static int ata_flush_cache(struct ata_device *dev) { u8 cmd; -- cgit v1.2.3 From 977e6b9f3a9b17f1c608a9d1e5a7b5c46a5f7d4a Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 24 Jun 2006 20:30:19 +0900 Subject: [PATCH] libata: update ata_do_simple_cmd() * the function has always returned AC_ERR_* masks not -errno but its return type was int. Make return type unsigned int. * don't print error message automatically. it's the caller's responsibility. * add header comment Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 57 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 14 deletions(-) (limited to 'drivers/scsi/libata-core.c') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index bbd6665eb21..4a44e759e45 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -1131,14 +1131,23 @@ unsigned ata_exec_internal(struct ata_device *dev, return err_mask; } -/* - * Execute a 'simple' command, that only consists of the opcode 'cmd' itself, - * without filling any other registers +/** + * ata_do_simple_cmd - execute simple internal command + * @dev: Device to which the command is sent + * @cmd: Opcode to execute + * + * Execute a 'simple' command, that only consists of the opcode + * 'cmd' itself, without filling any other registers + * + * LOCKING: + * Kernel thread context (may sleep). + * + * RETURNS: + * Zero on success, AC_ERR_* mask on failure */ -static int ata_do_simple_cmd(struct ata_device *dev, u8 cmd) +static unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd) { struct ata_taskfile tf; - int err; ata_tf_init(dev, &tf); @@ -1146,12 +1155,7 @@ static int ata_do_simple_cmd(struct ata_device *dev, u8 cmd) tf.flags |= ATA_TFLAG_DEVICE; tf.protocol = ATA_PROT_NODATA; - err = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); - if (err) - ata_dev_printk(dev, KERN_ERR, "%s: ata command failed: %d\n", - __FUNCTION__, err); - - return err; + return ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); } /** @@ -4971,6 +4975,7 @@ int ata_port_offline(struct ata_port *ap) static int ata_flush_cache(struct ata_device *dev) { + unsigned int err_mask; u8 cmd; if (!ata_try_flush_cache(dev)) @@ -4981,17 +4986,41 @@ static int ata_flush_cache(struct ata_device *dev) else cmd = ATA_CMD_FLUSH; - return ata_do_simple_cmd(dev, cmd); + err_mask = ata_do_simple_cmd(dev, cmd); + if (err_mask) { + ata_dev_printk(dev, KERN_ERR, "failed to flush cache\n"); + return -EIO; + } + + return 0; } static int ata_standby_drive(struct ata_device *dev) { - return ata_do_simple_cmd(dev, ATA_CMD_STANDBYNOW1); + unsigned int err_mask; + + err_mask = ata_do_simple_cmd(dev, ATA_CMD_STANDBYNOW1); + if (err_mask) { + ata_dev_printk(dev, KERN_ERR, "failed to standby drive " + "(err_mask=0x%x)\n", err_mask); + return -EIO; + } + + return 0; } static int ata_start_drive(struct ata_device *dev) { - return ata_do_simple_cmd(dev, ATA_CMD_IDLEIMMEDIATE); + unsigned int err_mask; + + err_mask = ata_do_simple_cmd(dev, ATA_CMD_IDLEIMMEDIATE); + if (err_mask) { + ata_dev_printk(dev, KERN_ERR, "failed to start drive " + "(err_mask=0x%x)\n", err_mask); + return -EIO; + } + + return 0; } /** -- cgit v1.2.3 From 77b08fb56a41e84b5e78b14f24d79879235e3337 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 24 Jun 2006 20:30:19 +0900 Subject: [PATCH] libata: make two functions global Make ata_do_simple_cmd() and ata_flush_cache() global. These will be used from libata-eh.c. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/scsi/libata-core.c') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 4a44e759e45..60e80e3a885 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -1145,7 +1145,7 @@ unsigned ata_exec_internal(struct ata_device *dev, * RETURNS: * Zero on success, AC_ERR_* mask on failure */ -static unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd) +unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd) { struct ata_taskfile tf; @@ -4973,7 +4973,7 @@ int ata_port_offline(struct ata_port *ap) return 0; } -static int ata_flush_cache(struct ata_device *dev) +int ata_flush_cache(struct ata_device *dev) { unsigned int err_mask; u8 cmd; -- cgit v1.2.3 From a8601e5f6b77aa4f223058a93bc5f77e1ee45638 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sun, 25 Jun 2006 01:36:52 -0700 Subject: [PATCH] libata reduce timeouts From: Andrew Morton Provide a module parameter to override the default 30-second-per-device SATA probing timeout. Cc: Tejun Heo Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/libata-core.c') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 60e80e3a885..10f15ab95fa 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -88,6 +88,10 @@ int libata_fua = 0; module_param_named(fua, libata_fua, int, 0444); MODULE_PARM_DESC(fua, "FUA support (0=off, 1=on)"); +static int ata_probe_timeout = ATA_TMOUT_INTERNAL / HZ; +module_param(ata_probe_timeout, int, 0444); +MODULE_PARM_DESC(ata_probe_timeout, "Set ATA probing timeout (seconds)"); + MODULE_AUTHOR("Jeff Garzik"); MODULE_DESCRIPTION("Library module for ATA devices"); MODULE_LICENSE("GPL"); @@ -1059,7 +1063,7 @@ unsigned ata_exec_internal(struct ata_device *dev, spin_unlock_irqrestore(ap->lock, flags); - rc = wait_for_completion_timeout(&wait, ATA_TMOUT_INTERNAL); + rc = wait_for_completion_timeout(&wait, ata_probe_timeout); ata_port_flush_task(ap); @@ -5738,6 +5742,7 @@ int ata_pci_device_resume(struct pci_dev *pdev) static int __init ata_init(void) { + ata_probe_timeout *= HZ; ata_wq = create_workqueue("ata"); if (!ata_wq) return -ENOMEM; -- cgit v1.2.3 From 88574551b46ba69b0f145d2775006f2e7dfebc84 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sun, 25 Jun 2006 20:00:35 +0900 Subject: [PATCH] libata: cosmetic updates Cosmetic updates in libata-core.c. * trim trailing whitespaces * break lines which are over 80 column * kill unnecessary braces * make indentation consistent Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 61 ++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 29 deletions(-) (limited to 'drivers/scsi/libata-core.c') diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 10f15ab95fa..47fff7bbf34 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -781,11 +781,9 @@ void ata_std_dev_select (struct ata_port *ap, unsigned int device) void ata_dev_select(struct ata_port *ap, unsigned int device, unsigned int wait, unsigned int can_sleep) { - if (ata_msg_probe(ap)) { + if (ata_msg_probe(ap)) ata_port_printk(ap, KERN_INFO, "ata_dev_select: ENTER, ata%u: " - "device %u, wait %u\n", - ap->id, device, wait); - } + "device %u, wait %u\n", ap->id, device, wait); if (wait) ata_wait_idle(ap); @@ -954,7 +952,8 @@ void ata_port_flush_task(struct ata_port *ap) */ if (!cancel_delayed_work(&ap->port_task)) { if (ata_msg_ctl(ap)) - ata_port_printk(ap, KERN_DEBUG, "%s: flush #2\n", __FUNCTION__); + ata_port_printk(ap, KERN_DEBUG, "%s: flush #2\n", + __FUNCTION__); flush_workqueue(ata_wq); } @@ -1085,7 +1084,7 @@ unsigned ata_exec_internal(struct ata_device *dev, if (ata_msg_warn(ap)) ata_dev_printk(dev, KERN_WARNING, - "qc timeout (cmd 0x%x)\n", command); + "qc timeout (cmd 0x%x)\n", command); } spin_unlock_irqrestore(ap->lock, flags); @@ -1097,9 +1096,9 @@ unsigned ata_exec_internal(struct ata_device *dev, if (qc->flags & ATA_QCFLAG_FAILED && !qc->err_mask) { if (ata_msg_warn(ap)) - ata_dev_printk(dev, KERN_WARNING, + ata_dev_printk(dev, KERN_WARNING, "zero err_mask for failed " - "internal command, assuming AC_ERR_OTHER\n"); + "internal command, assuming AC_ERR_OTHER\n"); qc->err_mask |= AC_ERR_OTHER; } @@ -1224,8 +1223,8 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, int rc; if (ata_msg_ctl(ap)) - ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER, host %u, dev %u\n", - __FUNCTION__, ap->id, dev->devno); + ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER, host %u, dev %u\n", + __FUNCTION__, ap->id, dev->devno); ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */ @@ -1294,9 +1293,9 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, return 0; err_out: - if (ata_msg_warn(ap)) + if (ata_msg_warn(ap)) ata_dev_printk(dev, KERN_WARNING, "failed to IDENTIFY " - "(%s, err_mask=0x%x)\n", reason, err_mask); + "(%s, err_mask=0x%x)\n", reason, err_mask); return rc; } @@ -1349,19 +1348,21 @@ int ata_dev_configure(struct ata_device *dev, int print_info) int i, rc; if (!ata_dev_enabled(dev) && ata_msg_info(ap)) { - ata_dev_printk(dev, KERN_INFO, "%s: ENTER/EXIT (host %u, dev %u) -- nodev\n", - __FUNCTION__, ap->id, dev->devno); + ata_dev_printk(dev, KERN_INFO, + "%s: ENTER/EXIT (host %u, dev %u) -- nodev\n", + __FUNCTION__, ap->id, dev->devno); return 0; } if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER, host %u, dev %u\n", - __FUNCTION__, ap->id, dev->devno); + ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER, host %u, dev %u\n", + __FUNCTION__, ap->id, dev->devno); /* print device capabilities */ if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, "%s: cfg 49:%04x 82:%04x 83:%04x " - "84:%04x 85:%04x 86:%04x 87:%04x 88:%04x\n", + ata_dev_printk(dev, KERN_DEBUG, + "%s: cfg 49:%04x 82:%04x 83:%04x 84:%04x " + "85:%04x 86:%04x 87:%04x 88:%04x\n", __FUNCTION__, id[49], id[82], id[83], id[84], id[85], id[86], id[87], id[88]); @@ -1433,14 +1434,16 @@ int ata_dev_configure(struct ata_device *dev, int print_info) ata_id_major_version(id), ata_mode_string(xfer_mask), (unsigned long long)dev->n_sectors, - dev->cylinders, dev->heads, dev->sectors); + dev->cylinders, dev->heads, + dev->sectors); } if (dev->id[59] & 0x100) { dev->multi_count = dev->id[59] & 0xff; if (ata_msg_info(ap)) - ata_dev_printk(dev, KERN_INFO, "ata%u: dev %u multi count %u\n", - ap->id, dev->devno, dev->multi_count); + ata_dev_printk(dev, KERN_INFO, + "ata%u: dev %u multi count %u\n", + ap->id, dev->devno, dev->multi_count); } dev->cdb_len = 16; @@ -1453,8 +1456,8 @@ int ata_dev_configure(struct ata_device *dev, int print_info) rc = atapi_cdb_len(id); if ((rc < 12) || (rc > ATAPI_CDB_LEN)) { if (ata_msg_warn(ap)) - ata_dev_printk(dev, KERN_WARNING, - "unsupported CDB len\n"); + ata_dev_printk(dev, KERN_WARNING, + "unsupported CDB len\n"); rc = -EINVAL; goto err_out_nosup; } @@ -1497,8 +1500,8 @@ int ata_dev_configure(struct ata_device *dev, int print_info) err_out_nosup: if (ata_msg_probe(ap)) - ata_dev_printk(dev, KERN_DEBUG, - "%s: EXIT, err\n", __FUNCTION__); + ata_dev_printk(dev, KERN_DEBUG, + "%s: EXIT, err\n", __FUNCTION__); return rc; } @@ -3558,7 +3561,7 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words) * Inherited from caller. */ -void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf, +void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf, unsigned int buflen, int write_data) { struct ata_port *ap = adev->ap; @@ -3604,7 +3607,7 @@ void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf, * Inherited from caller. */ -void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf, +void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf, unsigned int buflen, int write_data) { struct ata_port *ap = adev->ap; @@ -3638,7 +3641,7 @@ void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf, * @buflen: buffer length * @write_data: read/write * - * Transfer data from/to the device data register by PIO. Do the + * Transfer data from/to the device data register by PIO. Do the * transfer with interrupts disabled. * * LOCKING: @@ -5245,7 +5248,7 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, ap->msg_enable = 0x00FF; #elif defined(ATA_DEBUG) ap->msg_enable = ATA_MSG_DRV | ATA_MSG_INFO | ATA_MSG_CTL | ATA_MSG_WARN | ATA_MSG_ERR; -#else +#else ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR | ATA_MSG_WARN; #endif -- cgit v1.2.3