]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/libata-core.c
[PATCH] MMC: Fix divdi3 reference in mmci.c
[linux-2.6-omap-h63xx.git] / drivers / scsi / libata-core.c
index a5d7c33a434da803b33516d64a3c58a3e0b4e5d3..cb535fa185b93453ca535bf8a28fe2366a904a06 100644 (file)
@@ -1295,6 +1295,37 @@ err_out:
        DPRINTK("EXIT, err\n");
 }
 
+
+static inline u8 ata_dev_knobble(struct ata_port *ap)
+{
+       return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(ap->device->id)));
+}
+
+/**
+ *     ata_dev_config - Run device specific handlers and check for
+ *                      SATA->PATA bridges
+ *     @ap: Bus 
+ *     @i:  Device
+ *
+ *     LOCKING:
+ */
+void ata_dev_config(struct ata_port *ap, unsigned int i)
+{
+       /* limit bridge transfers to udma5, 200 sectors */
+       if (ata_dev_knobble(ap)) {
+               printk(KERN_INFO "ata%u(%u): applying bridge limits\n",
+                       ap->id, ap->device->devno);
+               ap->udma_mask &= ATA_UDMA5;
+               ap->host->max_sectors = ATA_MAX_SECTORS;
+               ap->host->hostt->max_sectors = ATA_MAX_SECTORS;
+               ap->device->flags |= ATA_DFLAG_LOCK_SECTORS;
+       }
+
+       if (ap->ops->dev_config)
+               ap->ops->dev_config(ap, &ap->device[i]);
+}
+
 /**
  *     ata_bus_probe - Reset and probe ATA bus
  *     @ap: Bus to probe
@@ -1322,8 +1353,7 @@ static int ata_bus_probe(struct ata_port *ap)
                ata_dev_identify(ap, i);
                if (ata_dev_present(&ap->device[i])) {
                        found = 1;
-                       if (ap->ops->dev_config)
-                               ap->ops->dev_config(ap, &ap->device[i]);
+                       ata_dev_config(ap,i);
                }
        }
 
@@ -1378,7 +1408,9 @@ void __sata_phy_reset(struct ata_port *ap)
        if (ap->flags & ATA_FLAG_SATA_RESET) {
                /* issue phy wake/reset */
                scr_write_flush(ap, SCR_CONTROL, 0x301);
-               udelay(400);                    /* FIXME: a guess */
+               /* Couldn't find anything in SATA I/II specs, but
+                * AHCI-1.1 10.4.2 says at least 1 ms. */
+               mdelay(1);
        }
        scr_write_flush(ap, SCR_CONTROL, 0x300); /* phy wake/clear reset */
 
@@ -1890,6 +1922,7 @@ static const char * ata_dma_blacklist [] = {
        "HITACHI CDR-8335",
        "HITACHI CDR-8435",
        "Toshiba CD-ROM XM-6202B",
+       "TOSHIBA CD-ROM XM-1702BC",
        "CD-532E-A",
        "E-IDE CD-ROM CR-840",
        "CD-ROM Drive/F5A",
@@ -1897,7 +1930,6 @@ static const char * ata_dma_blacklist [] = {
        "SAMSUNG CD-ROM SC-148C",
        "SAMSUNG CD-ROM SC",
        "SanDisk SDP3B-64",
-       "SAMSUNG CD-ROM SN-124",
        "ATAPI CD-ROM DRIVE 40X MAXIMUM",
        "_NEC DV5800A",
 };
@@ -2577,7 +2609,6 @@ static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes)
 next_sg:
        sg = &qc->sg[qc->cursg];
 
-next_page:
        page = sg->page;
        offset = sg->offset + qc->cursg_ofs;
 
@@ -2585,6 +2616,7 @@ next_page:
        page = nth_page(page, (offset >> PAGE_SHIFT));
        offset %= PAGE_SIZE;
 
+       /* don't overrun current sg */
        count = min(sg->length - qc->cursg_ofs, bytes);
 
        /* don't cross page boundaries */
@@ -2609,8 +2641,6 @@ next_page:
        kunmap(page);
 
        if (bytes) {
-               if (qc->cursg_ofs < sg->length)
-                       goto next_page;
                goto next_sg;
        }
 }
@@ -3666,6 +3696,13 @@ void ata_port_stop (struct ata_port *ap)
        dma_free_coherent(dev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma);
 }
 
+void ata_host_stop (struct ata_host_set *host_set)
+{
+       if (host_set->mmio_base)
+               iounmap(host_set->mmio_base);
+}
+
+
 /**
  *     ata_host_remove - Unregister SCSI host structure with upper layers
  *     @ap: Port to unregister
@@ -4271,10 +4308,6 @@ void ata_pci_remove_one (struct pci_dev *pdev)
        }
 
        free_irq(host_set->irq, host_set);
-       if (host_set->ops->host_stop)
-               host_set->ops->host_stop(host_set);
-       if (host_set->mmio_base)
-               iounmap(host_set->mmio_base);
 
        for (i = 0; i < host_set->n_ports; i++) {
                ap = host_set->ports[i];
@@ -4293,6 +4326,9 @@ void ata_pci_remove_one (struct pci_dev *pdev)
                scsi_host_put(ap->host);
        }
 
+       if (host_set->ops->host_stop)
+               host_set->ops->host_stop(host_set);
+
        kfree(host_set);
 
        pci_release_regions(pdev);
@@ -4381,6 +4417,7 @@ EXPORT_SYMBOL_GPL(ata_chk_err);
 EXPORT_SYMBOL_GPL(ata_exec_command);
 EXPORT_SYMBOL_GPL(ata_port_start);
 EXPORT_SYMBOL_GPL(ata_port_stop);
+EXPORT_SYMBOL_GPL(ata_host_stop);
 EXPORT_SYMBOL_GPL(ata_interrupt);
 EXPORT_SYMBOL_GPL(ata_qc_prep);
 EXPORT_SYMBOL_GPL(ata_bmdma_setup);
@@ -4401,6 +4438,7 @@ EXPORT_SYMBOL_GPL(ata_scsi_release);
 EXPORT_SYMBOL_GPL(ata_host_intr);
 EXPORT_SYMBOL_GPL(ata_dev_classify);
 EXPORT_SYMBOL_GPL(ata_dev_id_string);
+EXPORT_SYMBOL_GPL(ata_dev_config);
 EXPORT_SYMBOL_GPL(ata_scsi_simulate);
 
 #ifdef CONFIG_PCI