]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ata/libata-core.c
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux...
[linux-2.6-omap-h63xx.git] / drivers / ata / libata-core.c
index c4fd4afbf34951c108ec22ab7e63542f16892692..b0b00af90d0e18314782fec05cdd136cbd41eff1 100644 (file)
@@ -61,7 +61,6 @@
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
-#include <asm/semaphore.h>
 #include <asm/byteorder.h>
 #include <linux/cdrom.h>
 
@@ -84,16 +83,6 @@ const struct ata_port_operations sata_port_ops = {
 
        .qc_defer               = ata_std_qc_defer,
        .hardreset              = sata_std_hardreset,
-       .sff_dev_select         = ata_noop_dev_select,
-};
-
-const struct ata_port_operations sata_pmp_port_ops = {
-       .inherits               = &sata_port_ops,
-
-       .pmp_prereset           = sata_pmp_std_prereset,
-       .pmp_hardreset          = sata_pmp_std_hardreset,
-       .pmp_postreset          = sata_pmp_std_postreset,
-       .error_handler          = sata_pmp_error_handler,
 };
 
 static unsigned int ata_dev_init_params(struct ata_device *dev,
@@ -1431,22 +1420,6 @@ static int ata_hpa_resize(struct ata_device *dev)
        return 0;
 }
 
-/**
- *     ata_noop_dev_select - Select device 0/1 on ATA bus
- *     @ap: ATA channel to manipulate
- *     @device: ATA device (numbered from zero) to select
- *
- *     This function performs no actual function.
- *
- *     May be used as the dev_select() entry in ata_port_operations.
- *
- *     LOCKING:
- *     caller.
- */
-void ata_noop_dev_select(struct ata_port *ap, unsigned int device)
-{
-}
-
 /**
  *     ata_dump_id - IDENTIFY DEVICE info debugging output
  *     @id: IDENTIFY DEVICE page to dump
@@ -2304,7 +2277,7 @@ int ata_dev_configure(struct ata_device *dev)
                 * changed notifications and ATAPI ANs.
                 */
                if ((ap->flags & ATA_FLAG_AN) && ata_id_has_atapi_AN(id) &&
-                   (!ap->nr_pmp_links ||
+                   (!sata_pmp_attached(ap) ||
                     sata_scr_read(&ap->link, SCR_NOTIFICATION, &sntf) == 0)) {
                        unsigned int err_mask;
 
@@ -3158,16 +3131,21 @@ static int ata_dev_set_mode(struct ata_device *dev)
        if (rc)
                return rc;
 
-       /* Old CFA may refuse this command, which is just fine */
-       if (dev->xfer_shift == ATA_SHIFT_PIO && ata_id_is_cfa(dev->id))
-               ign_dev_err = 1;
-
-       /* Some very old devices and some bad newer ones fail any kind of
-          SET_XFERMODE request but support PIO0-2 timings and no IORDY */
-       if (dev->xfer_shift == ATA_SHIFT_PIO && !ata_id_has_iordy(dev->id) &&
-                       dev->pio_mode <= XFER_PIO_2)
-               ign_dev_err = 1;
-
+       if (dev->xfer_shift == ATA_SHIFT_PIO) {
+               /* Old CFA may refuse this command, which is just fine */
+               if (ata_id_is_cfa(dev->id))
+                       ign_dev_err = 1;
+               /* Catch several broken garbage emulations plus some pre
+                  ATA devices */
+               if (ata_id_major_version(dev->id) == 0 &&
+                                       dev->pio_mode <= XFER_PIO_2)
+                       ign_dev_err = 1;
+               /* Some very old devices and some bad newer ones fail
+                  any kind of SET_XFERMODE request but support PIO0-2
+                  timings and no IORDY */
+               if (!ata_id_has_iordy(dev->id) && dev->pio_mode <= XFER_PIO_2)
+                       ign_dev_err = 1;
+       }
        /* Early MWDMA devices do DMA but don't allow DMA mode setting.
           Don't fail an MWDMA0 set IFF the device indicates it is in MWDMA0 */
        if (dev->xfer_shift == ATA_SHIFT_MWDMA &&
@@ -3493,7 +3471,7 @@ int sata_link_debounce(struct ata_link *link, const unsigned long *params,
 int sata_link_resume(struct ata_link *link, const unsigned long *params,
                     unsigned long deadline)
 {
-       u32 scontrol;
+       u32 scontrol, serror;
        int rc;
 
        if ((rc = sata_scr_read(link, SCR_CONTROL, &scontrol)))
@@ -3509,7 +3487,25 @@ int sata_link_resume(struct ata_link *link, const unsigned long *params,
         */
        msleep(200);
 
-       return sata_link_debounce(link, params, deadline);
+       if ((rc = sata_link_debounce(link, params, deadline)))
+               return rc;
+
+       /* Clear SError.  PMP and some host PHYs require this to
+        * operate and clearing should be done before checking PHY
+        * online status to avoid race condition (hotplugging between
+        * link resume and status check).
+        */
+       if (!(rc = sata_scr_read(link, SCR_ERROR, &serror)))
+               rc = sata_scr_write(link, SCR_ERROR, serror);
+       if (rc == 0 || rc == -EINVAL) {
+               unsigned long flags;
+
+               spin_lock_irqsave(link->ap->lock, flags);
+               link->eh_info.serror = 0;
+               spin_unlock_irqrestore(link->ap->lock, flags);
+               rc = 0;
+       }
+       return rc;
 }
 
 /**
@@ -3549,6 +3545,10 @@ int ata_std_prereset(struct ata_link *link, unsigned long deadline)
                                        "link for reset (errno=%d)\n", rc);
        }
 
+       /* no point in trying softreset on offline link */
+       if (ata_link_offline(link))
+               ehc->i.action &= ~ATA_EH_SOFTRESET;
+
        return 0;
 }
 
@@ -3631,7 +3631,7 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing,
        if (online)
                *online = true;
 
-       if ((link->ap->flags & ATA_FLAG_PMP) && ata_is_host_link(link)) {
+       if (sata_pmp_supported(link->ap) && ata_is_host_link(link)) {
                /* If PMP is supported, we have to do follow-up SRST.
                 * Some PMPs don't send D2H Reg FIS after hardreset if
                 * the first port is empty.  Wait only for
@@ -3683,7 +3683,6 @@ int sata_std_hardreset(struct ata_link *link, unsigned int *class,
 
        /* do hardreset */
        rc = sata_link_hardreset(link, timing, deadline, &online, NULL);
-       *class = ATA_DEV_NONE;
        return online ? -EAGAIN : rc;
 }
 
@@ -3701,18 +3700,11 @@ int sata_std_hardreset(struct ata_link *link, unsigned int *class,
  */
 void ata_std_postreset(struct ata_link *link, unsigned int *classes)
 {
-       u32 serror;
-
        DPRINTK("ENTER\n");
 
        /* print link status */
        sata_print_link_status(link);
 
-       /* clear SError */
-       if (sata_scr_read(link, SCR_ERROR, &serror) == 0)
-               sata_scr_write(link, SCR_ERROR, serror);
-       link->eh_info.serror = 0;
-
        DPRINTK("EXIT\n");
 }
 
@@ -4045,6 +4037,10 @@ static int cable_is_40wire(struct ata_port *ap)
        /* If the controller thinks we are 80 wire, we are */
        if (ap->cbl == ATA_CBL_PATA80 || ap->cbl == ATA_CBL_SATA)
                return 0;
+       /* If the system is known to be 40 wire short cable (eg laptop),
+          then we allow 80 wire modes even if the drive isn't sure */
+       if (ap->cbl == ATA_CBL_PATA40_SHORT)
+               return 0;
        /* If the controller doesn't know we scan
 
           - Note: We look for all 40 wire detects at this point.
@@ -4552,7 +4548,7 @@ static void fill_result_tf(struct ata_queued_cmd *qc)
        struct ata_port *ap = qc->ap;
 
        qc->result_tf.flags = qc->tf.flags;
-       ap->ops->sff_tf_read(ap, &qc->result_tf);
+       ap->ops->qc_fill_rtf(qc);
 }
 
 static void ata_verify_xfer(struct ata_queued_cmd *qc)
@@ -4662,7 +4658,6 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
  *     ata_qc_complete_multiple - Complete multiple qcs successfully
  *     @ap: port in question
  *     @qc_active: new qc_active mask
- *     @finish_qc: LLDD callback invoked before completing a qc
  *
  *     Complete in-flight commands.  This functions is meant to be
  *     called from low-level driver's interrupt routine to complete
@@ -4675,8 +4670,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
  *     RETURNS:
  *     Number of completed commands on success, -errno otherwise.
  */
-int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active,
-                            void (*finish_qc)(struct ata_queued_cmd *))
+int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active)
 {
        int nr_done = 0;
        u32 done_mask;
@@ -4697,8 +4691,6 @@ int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active,
                        continue;
 
                if ((qc = ata_qc_from_tag(ap, i))) {
-                       if (finish_qc)
-                               finish_qc(qc);
                        ata_qc_complete(qc);
                        nr_done++;
                }
@@ -5206,7 +5198,9 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
        ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR | ATA_MSG_WARN;
 #endif
 
+#ifdef CONFIG_ATA_SFF
        INIT_DELAYED_WORK(&ap->port_task, ata_pio_task);
+#endif
        INIT_DELAYED_WORK(&ap->hotplug_task, ata_scsi_hotplug);
        INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan);
        INIT_LIST_HEAD(&ap->eh_done_q);
@@ -6170,33 +6164,20 @@ u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
 /*
  * Dummy port_ops
  */
-static void ata_dummy_noret(struct ata_port *ap)       { }
-static int ata_dummy_ret0(struct ata_port *ap)         { return 0; }
-static void ata_dummy_qc_noret(struct ata_queued_cmd *qc) { }
-
-static u8 ata_dummy_check_status(struct ata_port *ap)
+static unsigned int ata_dummy_qc_issue(struct ata_queued_cmd *qc)
 {
-       return ATA_DRDY;
+       return AC_ERR_SYSTEM;
 }
 
-static unsigned int ata_dummy_qc_issue(struct ata_queued_cmd *qc)
+static void ata_dummy_error_handler(struct ata_port *ap)
 {
-       return AC_ERR_SYSTEM;
+       /* truly dummy */
 }
 
 struct ata_port_operations ata_dummy_port_ops = {
-       .sff_check_status       = ata_dummy_check_status,
-       .sff_check_altstatus    = ata_dummy_check_status,
-       .sff_dev_select         = ata_noop_dev_select,
        .qc_prep                = ata_noop_qc_prep,
        .qc_issue               = ata_dummy_qc_issue,
-       .freeze                 = ata_dummy_noret,
-       .thaw                   = ata_dummy_noret,
-       .error_handler          = ata_dummy_noret,
-       .post_internal_cmd      = ata_dummy_qc_noret,
-       .sff_irq_clear          = ata_dummy_noret,
-       .port_start             = ata_dummy_ret0,
-       .port_stop              = ata_dummy_noret,
+       .error_handler          = ata_dummy_error_handler,
 };
 
 const struct ata_port_info ata_dummy_port_info = {
@@ -6214,7 +6195,6 @@ EXPORT_SYMBOL_GPL(sata_deb_timing_hotplug);
 EXPORT_SYMBOL_GPL(sata_deb_timing_long);
 EXPORT_SYMBOL_GPL(ata_base_port_ops);
 EXPORT_SYMBOL_GPL(sata_port_ops);
-EXPORT_SYMBOL_GPL(sata_pmp_port_ops);
 EXPORT_SYMBOL_GPL(ata_dummy_port_ops);
 EXPORT_SYMBOL_GPL(ata_dummy_port_info);
 EXPORT_SYMBOL_GPL(ata_std_bios_param);
@@ -6228,7 +6208,6 @@ EXPORT_SYMBOL_GPL(ata_host_detach);
 EXPORT_SYMBOL_GPL(ata_sg_init);
 EXPORT_SYMBOL_GPL(ata_qc_complete);
 EXPORT_SYMBOL_GPL(ata_qc_complete_multiple);
-EXPORT_SYMBOL_GPL(ata_noop_dev_select);
 EXPORT_SYMBOL_GPL(sata_print_link_status);
 EXPORT_SYMBOL_GPL(atapi_cmd_type);
 EXPORT_SYMBOL_GPL(ata_tf_to_fis);
@@ -6295,12 +6274,6 @@ EXPORT_SYMBOL_GPL(ata_pci_device_resume);
 #endif /* CONFIG_PM */
 #endif /* CONFIG_PCI */
 
-EXPORT_SYMBOL_GPL(sata_pmp_qc_defer_cmd_switch);
-EXPORT_SYMBOL_GPL(sata_pmp_std_prereset);
-EXPORT_SYMBOL_GPL(sata_pmp_std_hardreset);
-EXPORT_SYMBOL_GPL(sata_pmp_std_postreset);
-EXPORT_SYMBOL_GPL(sata_pmp_error_handler);
-
 EXPORT_SYMBOL_GPL(__ata_ehi_push_desc);
 EXPORT_SYMBOL_GPL(ata_ehi_push_desc);
 EXPORT_SYMBOL_GPL(ata_ehi_clear_desc);