Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild
[pandora-kernel.git] / drivers / scsi / libata-core.c
index 89c3fbe..1c960ac 100644 (file)
@@ -32,7 +32,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -88,6 +87,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");
@@ -418,7 +421,7 @@ static const char *sata_spd_string(unsigned int spd)
 
 void ata_dev_disable(struct ata_device *dev)
 {
-       if (ata_dev_enabled(dev)) {
+       if (ata_dev_enabled(dev) && ata_msg_drv(dev->ap)) {
                ata_dev_printk(dev, KERN_WARNING, "disabled\n");
                dev->class++;
        }
@@ -777,8 +780,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)
 {
-       VPRINTK("ENTER, ata%u: device %u, wait %u\n",
-               ap->id, device, wait);
+       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);
 
        if (wait)
                ata_wait_idle(ap);
@@ -933,9 +937,9 @@ void ata_port_flush_task(struct ata_port *ap)
 
        DPRINTK("ENTER\n");
 
-       spin_lock_irqsave(&ap->host_set->lock, flags);
+       spin_lock_irqsave(ap->lock, flags);
        ap->flags |= ATA_FLAG_FLUSH_PORT_TASK;
-       spin_unlock_irqrestore(&ap->host_set->lock, flags);
+       spin_unlock_irqrestore(ap->lock, flags);
 
        DPRINTK("flush #1\n");
        flush_workqueue(ata_wq);
@@ -946,15 +950,18 @@ void ata_port_flush_task(struct ata_port *ap)
         * Cancel and flush.
         */
        if (!cancel_delayed_work(&ap->port_task)) {
-               DPRINTK("flush #2\n");
+               if (ata_msg_ctl(ap))
+                       ata_port_printk(ap, KERN_DEBUG, "%s: flush #2\n",
+                                       __FUNCTION__);
                flush_workqueue(ata_wq);
        }
 
-       spin_lock_irqsave(&ap->host_set->lock, flags);
+       spin_lock_irqsave(ap->lock, flags);
        ap->flags &= ~ATA_FLAG_FLUSH_PORT_TASK;
-       spin_unlock_irqrestore(&ap->host_set->lock, flags);
+       spin_unlock_irqrestore(ap->lock, flags);
 
-       DPRINTK("EXIT\n");
+       if (ata_msg_ctl(ap))
+               ata_port_printk(ap, KERN_DEBUG, "%s: EXIT\n", __FUNCTION__);
 }
 
 void ata_qc_complete_internal(struct ata_queued_cmd *qc)
@@ -994,16 +1001,16 @@ unsigned ata_exec_internal(struct ata_device *dev,
        struct ata_queued_cmd *qc;
        unsigned int tag, preempted_tag;
        u32 preempted_sactive, preempted_qc_active;
-       DECLARE_COMPLETION(wait);
+       DECLARE_COMPLETION_ONSTACK(wait);
        unsigned long flags;
        unsigned int err_mask;
        int rc;
 
-       spin_lock_irqsave(&ap->host_set->lock, flags);
+       spin_lock_irqsave(ap->lock, flags);
 
        /* no internal command while frozen */
        if (ap->flags & ATA_FLAG_FROZEN) {
-               spin_unlock_irqrestore(&ap->host_set->lock, flags);
+               spin_unlock_irqrestore(ap->lock, flags);
                return AC_ERR_SYSTEM;
        }
 
@@ -1052,14 +1059,14 @@ unsigned ata_exec_internal(struct ata_device *dev,
 
        ata_qc_issue(qc);
 
-       spin_unlock_irqrestore(&ap->host_set->lock, flags);
+       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);
 
        if (!rc) {
-               spin_lock_irqsave(&ap->host_set->lock, flags);
+               spin_lock_irqsave(ap->lock, flags);
 
                /* We're racing with irq here.  If we lose, the
                 * following test prevents us from completing the qc
@@ -1074,11 +1081,12 @@ unsigned ata_exec_internal(struct ata_device *dev,
                        else
                                ata_qc_complete(qc);
 
-                       ata_dev_printk(dev, KERN_WARNING,
-                                      "qc timeout (cmd 0x%x)\n", command);
+                       if (ata_msg_warn(ap))
+                               ata_dev_printk(dev, KERN_WARNING,
+                                       "qc timeout (cmd 0x%x)\n", command);
                }
 
-               spin_unlock_irqrestore(&ap->host_set->lock, flags);
+               spin_unlock_irqrestore(ap->lock, flags);
        }
 
        /* do post_internal_cmd */
@@ -1086,13 +1094,15 @@ unsigned ata_exec_internal(struct ata_device *dev,
                ap->ops->post_internal_cmd(qc);
 
        if (qc->flags & ATA_QCFLAG_FAILED && !qc->err_mask) {
-               ata_dev_printk(dev, KERN_WARNING, "zero err_mask for failed "
-                              "internal command, assuming AC_ERR_OTHER\n");
+               if (ata_msg_warn(ap))
+                       ata_dev_printk(dev, KERN_WARNING,
+                               "zero err_mask for failed "
+                               "internal command, assuming AC_ERR_OTHER\n");
                qc->err_mask |= AC_ERR_OTHER;
        }
 
        /* finish up */
-       spin_lock_irqsave(&ap->host_set->lock, flags);
+       spin_lock_irqsave(ap->lock, flags);
 
        *tf = qc->result_tf;
        err_mask = qc->err_mask;
@@ -1118,11 +1128,38 @@ unsigned ata_exec_internal(struct ata_device *dev,
                ata_port_probe(ap);
        }
 
-       spin_unlock_irqrestore(&ap->host_set->lock, flags);
+       spin_unlock_irqrestore(ap->lock, flags);
 
        return err_mask;
 }
 
+/**
+ *     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
+ */
+unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd)
+{
+       struct ata_taskfile tf;
+
+       ata_tf_init(dev, &tf);
+
+       tf.command = cmd;
+       tf.flags |= ATA_TFLAG_DEVICE;
+       tf.protocol = ATA_PROT_NODATA;
+
+       return ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0);
+}
+
 /**
  *     ata_pio_need_iordy      -       check if iordy needed
  *     @adev: ATA device
@@ -1184,7 +1221,9 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
        const char *reason;
        int rc;
 
-       DPRINTK("ENTER, host %u, dev %u\n", ap->id, dev->devno);
+       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_select(ap, dev->devno, 1, 1); /* select device 0/1 */
 
@@ -1253,8 +1292,9 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
        return 0;
 
  err_out:
-       ata_dev_printk(dev, KERN_WARNING, "failed to IDENTIFY "
-                      "(%s, err_mask=0x%x)\n", reason, err_mask);
+       if (ata_msg_warn(ap))
+               ata_dev_printk(dev, KERN_WARNING, "failed to IDENTIFY "
+                              "(%s, err_mask=0x%x)\n", reason, err_mask);
        return rc;
 }
 
@@ -1306,18 +1346,23 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
        unsigned int xfer_mask;
        int i, rc;
 
-       if (!ata_dev_enabled(dev)) {
-               DPRINTK("ENTER/EXIT (host %u, dev %u) -- nodev\n",
-                       ap->id, dev->devno);
+       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);
                return 0;
        }
 
-       DPRINTK("ENTER, host %u, dev %u\n", ap->id, dev->devno);
+       if (ata_msg_probe(ap))
+               ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER, host %u, dev %u\n",
+                              __FUNCTION__, ap->id, dev->devno);
 
        /* print device capabilities */
-       if (print_info)
-               ata_dev_printk(dev, KERN_DEBUG, "cfg 49:%04x 82:%04x 83:%04x "
-                              "84:%04x 85:%04x 86:%04x 87:%04x 88:%04x\n",
+       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",
+                              __FUNCTION__,
                               id[49], id[82], id[83], id[84],
                               id[85], id[86], id[87], id[88]);
 
@@ -1337,7 +1382,8 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
        /* find max transfer mode; for printk only */
        xfer_mask = ata_id_xfermask(id);
 
-       ata_dump_id(id);
+       if (ata_msg_probe(ap))
+               ata_dump_id(id);
 
        /* ATA-specific feature tests */
        if (dev->class == ATA_DEV_ATA) {
@@ -1358,7 +1404,7 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
                        ata_dev_config_ncq(dev, ncq_desc, sizeof(ncq_desc));
 
                        /* print device info to dmesg */
-                       if (print_info)
+                       if (ata_msg_info(ap))
                                ata_dev_printk(dev, KERN_INFO, "ATA-%d, "
                                        "max %s, %Lu sectors: %s %s\n",
                                        ata_id_major_version(id),
@@ -1381,19 +1427,22 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
                        }
 
                        /* print device info to dmesg */
-                       if (print_info)
+                       if (ata_msg_info(ap))
                                ata_dev_printk(dev, KERN_INFO, "ATA-%d, "
                                        "max %s, %Lu sectors: CHS %u/%u/%u\n",
                                        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;
-                       DPRINTK("ata%u: dev %u multi count %u\n",
-                               ap->id, dev->devno, dev->multi_count);
+                       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);
                }
 
                dev->cdb_len = 16;
@@ -1405,8 +1454,9 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
 
                rc = atapi_cdb_len(id);
                if ((rc < 12) || (rc > ATAPI_CDB_LEN)) {
-                       ata_dev_printk(dev, KERN_WARNING,
-                                      "unsupported CDB len\n");
+                       if (ata_msg_warn(ap))
+                               ata_dev_printk(dev, KERN_WARNING,
+                                              "unsupported CDB len\n");
                        rc = -EINVAL;
                        goto err_out_nosup;
                }
@@ -1418,7 +1468,7 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
                }
 
                /* print device info to dmesg */
-               if (print_info)
+               if (ata_msg_info(ap))
                        ata_dev_printk(dev, KERN_INFO, "ATAPI, max %s%s\n",
                                       ata_mode_string(xfer_mask),
                                       cdb_intr_string);
@@ -1432,7 +1482,7 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
 
        /* limit bridge transfers to udma5, 200 sectors */
        if (ata_dev_knobble(dev)) {
-               if (print_info)
+               if (ata_msg_info(ap))
                        ata_dev_printk(dev, KERN_INFO,
                                       "applying bridge limits\n");
                dev->udma_mask &= ATA_UDMA5;
@@ -1442,11 +1492,15 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
        if (ap->ops->dev_config)
                ap->ops->dev_config(ap, dev);
 
-       DPRINTK("EXIT, drv_stat = 0x%x\n", ata_chk_status(ap));
+       if (ata_msg_probe(ap))
+               ata_dev_printk(dev, KERN_DEBUG, "%s: EXIT, drv_stat = 0x%x\n",
+                       __FUNCTION__, ata_chk_status(ap));
        return 0;
 
 err_out_nosup:
-       DPRINTK("EXIT, err\n");
+       if (ata_msg_probe(ap))
+               ata_dev_printk(dev, KERN_DEBUG,
+                              "%s: EXIT, err\n", __FUNCTION__);
        return rc;
 }
 
@@ -2943,6 +2997,14 @@ static int ata_dma_blacklisted(const struct ata_device *dev)
        unsigned int nlen, rlen;
        int i;
 
+       /* We don't support polling DMA.
+        * DMA blacklist those ATAPI devices with CDB-intr (and use PIO)
+        * if the LLDD handles only interrupts in the HSM_ST_LAST state.
+        */
+       if ((dev->ap->flags & ATA_FLAG_PIO_POLLING) &&
+           (dev->flags & ATA_DFLAG_CDB_INTR))
+               return 1;
+
        ata_id_string(dev->id, model_num, ATA_ID_PROD_OFS,
                          sizeof(model_num));
        ata_id_string(dev->id, model_rev, ATA_ID_FW_REV_OFS,
@@ -3235,15 +3297,6 @@ int ata_check_atapi_dma(struct ata_queued_cmd *qc)
        if (ap->ops->check_atapi_dma)
                rc = ap->ops->check_atapi_dma(qc);
 
-       /* We don't support polling DMA.
-        * Use PIO if the LLDD handles only interrupts in
-        * the HSM_ST_LAST state and the ATAPI device
-        * generates CDB interrupts.
-        */
-       if ((ap->flags & ATA_FLAG_PIO_POLLING) &&
-           (qc->dev->flags & ATA_DFLAG_CDB_INTR))
-               rc = 1;
-
        return rc;
 }
 /**
@@ -3507,7 +3560,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;
@@ -3553,7 +3606,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;
@@ -3587,7 +3640,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:
@@ -3913,7 +3966,7 @@ static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
 
        if (ap->ops->error_handler) {
                if (in_wq) {
-                       spin_lock_irqsave(&ap->host_set->lock, flags);
+                       spin_lock_irqsave(ap->lock, flags);
 
                        /* EH might have kicked in while host_set lock
                         * is released.
@@ -3927,7 +3980,7 @@ static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
                                        ata_port_freeze(ap);
                        }
 
-                       spin_unlock_irqrestore(&ap->host_set->lock, flags);
+                       spin_unlock_irqrestore(ap->lock, flags);
                } else {
                        if (likely(!(qc->err_mask & AC_ERR_HSM)))
                                ata_qc_complete(qc);
@@ -3936,10 +3989,10 @@ static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
                }
        } else {
                if (in_wq) {
-                       spin_lock_irqsave(&ap->host_set->lock, flags);
+                       spin_lock_irqsave(ap->lock, flags);
                        ata_irq_on(ap);
                        ata_qc_complete(qc);
-                       spin_unlock_irqrestore(&ap->host_set->lock, flags);
+                       spin_unlock_irqrestore(ap->lock, flags);
                } else
                        ata_qc_complete(qc);
        }
@@ -4019,7 +4072,7 @@ fsm_start:
                 * hsm_task_state is changed. Hence, the following locking.
                 */
                if (in_wq)
-                       spin_lock_irqsave(&ap->host_set->lock, flags);
+                       spin_lock_irqsave(ap->lock, flags);
 
                if (qc->tf.protocol == ATA_PROT_PIO) {
                        /* PIO data out protocol.
@@ -4038,7 +4091,7 @@ fsm_start:
                        atapi_send_cdb(ap, qc);
 
                if (in_wq)
-                       spin_unlock_irqrestore(&ap->host_set->lock, flags);
+                       spin_unlock_irqrestore(ap->lock, flags);
 
                /* if polling, ata_pio_task() handles the rest.
                 * otherwise, interrupt handler takes over from here.
@@ -4551,7 +4604,7 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
                        break;
                case ATA_PROT_ATAPI_DMA:
                        if (qc->dev->flags & ATA_DFLAG_CDB_INTR)
-                               /* see ata_check_atapi_dma() */
+                               /* see ata_dma_blacklisted() */
                                BUG();
                        break;
                default:
@@ -4926,31 +4979,9 @@ 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)
+int ata_flush_cache(struct ata_device *dev)
 {
+       unsigned int err_mask;
        u8 cmd;
 
        if (!ata_try_flush_cache(dev))
@@ -4961,17 +4992,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;
 }
 
 /**
@@ -4990,6 +5045,7 @@ int ata_device_resume(struct ata_device *dev)
        if (ap->flags & ATA_FLAG_SUSPENDED) {
                struct ata_device *failed_dev;
 
+               ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT);
                ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 200000);
 
                ap->flags &= ~ATA_FLAG_SUSPENDED;
@@ -5130,9 +5186,9 @@ void ata_dev_init(struct ata_device *dev)
         * requests which occur asynchronously.  Synchronize using
         * host_set lock.
         */
-       spin_lock_irqsave(&ap->host_set->lock, flags);
+       spin_lock_irqsave(ap->lock, flags);
        dev->flags &= ~ATA_DFLAG_INIT_MASK;
-       spin_unlock_irqrestore(&ap->host_set->lock, flags);
+       spin_unlock_irqrestore(ap->lock, flags);
 
        memset((void *)dev + ATA_DEVICE_CLEAR_OFFSET, 0,
               sizeof(*dev) - ATA_DEVICE_CLEAR_OFFSET);
@@ -5167,6 +5223,7 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
        host->unique_id = ata_unique_id++;
        host->max_cmd_len = 12;
 
+       ap->lock = &host_set->lock;
        ap->flags = ATA_FLAG_DISABLED;
        ap->id = host->unique_id;
        ap->host = host;
@@ -5190,8 +5247,8 @@ 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 
-       ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR;
+#else
+       ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR | ATA_MSG_WARN;
 #endif
 
        INIT_WORK(&ap->port_task, NULL, NULL);
@@ -5388,7 +5445,7 @@ int ata_device_add(const struct ata_probe_ent *ent)
                        ata_port_probe(ap);
 
                        /* kick EH for boot probing */
-                       spin_lock_irqsave(&ap->host_set->lock, flags);
+                       spin_lock_irqsave(ap->lock, flags);
 
                        ap->eh_info.probe_mask = (1 << ATA_MAX_DEVICES) - 1;
                        ap->eh_info.action |= ATA_EH_SOFTRESET;
@@ -5396,7 +5453,7 @@ int ata_device_add(const struct ata_probe_ent *ent)
                        ap->flags |= ATA_FLAG_LOADING;
                        ata_port_schedule_eh(ap);
 
-                       spin_unlock_irqrestore(&ap->host_set->lock, flags);
+                       spin_unlock_irqrestore(ap->lock, flags);
 
                        /* wait for EH to finish */
                        ata_port_wait_eh(ap);
@@ -5460,29 +5517,29 @@ void ata_port_detach(struct ata_port *ap)
                return;
 
        /* tell EH we're leaving & flush EH */
-       spin_lock_irqsave(&ap->host_set->lock, flags);
+       spin_lock_irqsave(ap->lock, flags);
        ap->flags |= ATA_FLAG_UNLOADING;
-       spin_unlock_irqrestore(&ap->host_set->lock, flags);
+       spin_unlock_irqrestore(ap->lock, flags);
 
        ata_port_wait_eh(ap);
 
        /* EH is now guaranteed to see UNLOADING, so no new device
         * will be attached.  Disable all existing devices.
         */
-       spin_lock_irqsave(&ap->host_set->lock, flags);
+       spin_lock_irqsave(ap->lock, flags);
 
        for (i = 0; i < ATA_MAX_DEVICES; i++)
                ata_dev_disable(&ap->device[i]);
 
-       spin_unlock_irqrestore(&ap->host_set->lock, flags);
+       spin_unlock_irqrestore(ap->lock, flags);
 
        /* Final freeze & EH.  All in-flight commands are aborted.  EH
         * will be skipped and retrials will be terminated with bad
         * target.
         */
-       spin_lock_irqsave(&ap->host_set->lock, flags);
+       spin_lock_irqsave(ap->lock, flags);
        ata_port_freeze(ap);    /* won't be thawed */
-       spin_unlock_irqrestore(&ap->host_set->lock, flags);
+       spin_unlock_irqrestore(ap->lock, flags);
 
        ata_port_wait_eh(ap);
 
@@ -5687,6 +5744,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;
@@ -5711,7 +5769,7 @@ module_init(ata_init);
 module_exit(ata_exit);
 
 static unsigned long ratelimit_time;
-static spinlock_t ata_ratelimit_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(ata_ratelimit_lock);
 
 int ata_ratelimit(void)
 {