[PATCH] libata basic detection and errata for PATA->SATA bridges
authorBrad Campbell <brad@wasp.net.au>
Thu, 12 May 2005 19:07:47 +0000 (15:07 -0400)
committerJeff Garzik <jgarzik@pobox.com>
Thu, 12 May 2005 19:07:47 +0000 (15:07 -0400)
This patch works around an issue with WD drives (and possibly others)
over SiL PATA->SATA Bridges on SATA controllers locking up with
transfers > 200 sectors.

Signed-off-by: Brad Campbell <brad@wasp.net.au>
drivers/scsi/libata-core.c
include/linux/ata.h
include/linux/libata.h

index 0b5d3a5b7edab5ce17889a0e698805ce346b4d1a..8b5a3f00083d8d58ccfbe377a3e5bb6738efe00c 100644 (file)
@@ -1186,6 +1186,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
@@ -1208,8 +1239,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);
                }
        }
 
@@ -4014,6 +4044,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
index f178894edd04f954a4f650661175b5fe009011c6..ca5fcadf998194cd663ff0414bc7435896749e84 100644 (file)
@@ -224,6 +224,7 @@ struct ata_taskfile {
 };
 
 #define ata_id_is_ata(id)      (((id)[0] & (1 << 15)) == 0)
+#define ata_id_is_sata(id)     ((id)[93] == 0)
 #define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6))
 #define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5))
 #define ata_id_has_flush(id) ((id)[83] & (1 << 12))
index 505160ab472b0198ec5393380ce7c21b2fad85d1..d33e70361a7d83a3d966ce8bf0b6fd8f68702669 100644 (file)
@@ -420,6 +420,7 @@ extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
 extern unsigned int ata_dev_classify(struct ata_taskfile *tf);
 extern void ata_dev_id_string(u16 *id, unsigned char *s,
                              unsigned int ofs, unsigned int len);
+extern void ata_dev_config(struct ata_port *ap, unsigned int i);
 extern void ata_bmdma_setup (struct ata_queued_cmd *qc);
 extern void ata_bmdma_start (struct ata_queued_cmd *qc);
 extern void ata_bmdma_stop(struct ata_port *ap);