diff -ur linux-3.13.2/drivers/ata/libata-core.c linux-3.13.2-patched/drivers/ata/libata-core.c --- linux-3.13.2/drivers/ata/libata-core.c 2014-02-16 10:54:49.723896755 -0500 +++ linux-3.13.2-patched/drivers/ata/libata-core.c 2014-02-16 10:49:07.933893744 -0500 @@ -1047,48 +1047,18 @@ */ unsigned int ata_dev_classify(const struct ata_taskfile *tf) { - /* Apple's open source Darwin code hints that some devices only - * put a proper signature into the LBA mid/high registers, - * So, we only check those. It's sufficient for uniqueness. - * - * ATA/ATAPI-7 (d1532v1r1: Feb. 19, 2003) specified separate - * signatures for ATA and ATAPI devices attached on SerialATA, - * 0x3c/0xc3 and 0x69/0x96 respectively. However, SerialATA - * spec has never mentioned about using different signatures - * for ATA/ATAPI devices. Then, Serial ATA II: Port - * Multiplier specification began to use 0x69/0x96 to identify - * port multpliers and 0x3c/0xc3 to identify SEMB device. - * ATA/ATAPI-7 dropped descriptions about 0x3c/0xc3 and - * 0x69/0x96 shortly and described them as reserved for - * SerialATA. - * - * We follow the current spec and consider that 0x69/0x96 - * identifies a port multiplier and 0x3c/0xc3 a SEMB device. - * Unfortunately, WDC WD1600JS-62MHB5 (a hard drive) reports - * SEMB signature. This is worked around in - * ata_dev_read_id(). - */ - if ((tf->lbam == 0) && (tf->lbah == 0)) { - DPRINTK("found ATA device by sig\n"); + // The "signatures" from VESA IDE are unhelpful. + switch (tf->command) { + case 82: // VESA IDE master + case 80: // ISA IDE master + printk(KERN_INFO "ata: ATA device, sig 0x%02x/0x%02x\n", tf->lbam, tf->lbah); return ATA_DEV_ATA; - } - - if ((tf->lbam == 0x14) && (tf->lbah == 0xeb)) { - DPRINTK("found ATAPI device by sig\n"); + case 0: // ISA IDE slave + printk(KERN_INFO "ata: ATAPI device, sig 0x%02x/0x%02x\n", tf->lbam, tf->lbah); return ATA_DEV_ATAPI; } - - if ((tf->lbam == 0x69) && (tf->lbah == 0x96)) { - DPRINTK("found PMP device by sig\n"); - return ATA_DEV_PMP; - } - - if ((tf->lbam == 0x3c) && (tf->lbah == 0xc3)) { - DPRINTK("found SEMB device by sig (could be ATA device)\n"); - return ATA_DEV_SEMB; - } - - DPRINTK("unknown device\n"); + // case 2: VESA IDE slave. + printk(KERN_INFO "ata: non-existent device, sig 0x%02x/0x%02x\n", tf->lbam, tf->lbah); return ATA_DEV_UNKNOWN; } @@ -1199,115 +1169,6 @@ } /** - * ata_read_native_max_address - Read native max address - * @dev: target device - * @max_sectors: out parameter for the result native max address - * - * Perform an LBA48 or LBA28 native size query upon the device in - * question. - * - * RETURNS: - * 0 on success, -EACCES if command is aborted by the drive. - * -EIO on other errors. - */ -static int ata_read_native_max_address(struct ata_device *dev, u64 *max_sectors) -{ - unsigned int err_mask; - struct ata_taskfile tf; - int lba48 = ata_id_has_lba48(dev->id); - - ata_tf_init(dev, &tf); - - /* always clear all address registers */ - tf.flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR; - - if (lba48) { - tf.command = ATA_CMD_READ_NATIVE_MAX_EXT; - tf.flags |= ATA_TFLAG_LBA48; - } else - tf.command = ATA_CMD_READ_NATIVE_MAX; - - tf.protocol |= ATA_PROT_NODATA; - tf.device |= ATA_LBA; - - err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); - if (err_mask) { - ata_dev_warn(dev, - "failed to read native max address (err_mask=0x%x)\n", - err_mask); - if (err_mask == AC_ERR_DEV && (tf.feature & ATA_ABORTED)) - return -EACCES; - return -EIO; - } - - if (lba48) - *max_sectors = ata_tf_to_lba48(&tf) + 1; - else - *max_sectors = ata_tf_to_lba(&tf) + 1; - if (dev->horkage & ATA_HORKAGE_HPA_SIZE) - (*max_sectors)--; - return 0; -} - -/** - * ata_set_max_sectors - Set max sectors - * @dev: target device - * @new_sectors: new max sectors value to set for the device - * - * Set max sectors of @dev to @new_sectors. - * - * RETURNS: - * 0 on success, -EACCES if command is aborted or denied (due to - * previous non-volatile SET_MAX) by the drive. -EIO on other - * errors. - */ -static int ata_set_max_sectors(struct ata_device *dev, u64 new_sectors) -{ - unsigned int err_mask; - struct ata_taskfile tf; - int lba48 = ata_id_has_lba48(dev->id); - - new_sectors--; - - ata_tf_init(dev, &tf); - - tf.flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR; - - if (lba48) { - tf.command = ATA_CMD_SET_MAX_EXT; - tf.flags |= ATA_TFLAG_LBA48; - - tf.hob_lbal = (new_sectors >> 24) & 0xff; - tf.hob_lbam = (new_sectors >> 32) & 0xff; - tf.hob_lbah = (new_sectors >> 40) & 0xff; - } else { - tf.command = ATA_CMD_SET_MAX; - - tf.device |= (new_sectors >> 24) & 0xf; - } - - tf.protocol |= ATA_PROT_NODATA; - tf.device |= ATA_LBA; - - tf.lbal = (new_sectors >> 0) & 0xff; - tf.lbam = (new_sectors >> 8) & 0xff; - tf.lbah = (new_sectors >> 16) & 0xff; - - err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); - if (err_mask) { - ata_dev_warn(dev, - "failed to set max address (err_mask=0x%x)\n", - err_mask); - if (err_mask == AC_ERR_DEV && - (tf.feature & (ATA_ABORTED | ATA_IDNF))) - return -EACCES; - return -EIO; - } - - return 0; -} - -/** * ata_hpa_resize - Resize a device with an HPA set * @dev: Device to resize * @@ -1320,87 +1181,7 @@ */ static int ata_hpa_resize(struct ata_device *dev) { - struct ata_eh_context *ehc = &dev->link->eh_context; - int print_info = ehc->i.flags & ATA_EHI_PRINTINFO; - bool unlock_hpa = ata_ignore_hpa || dev->flags & ATA_DFLAG_UNLOCK_HPA; - u64 sectors = ata_id_n_sectors(dev->id); - u64 native_sectors; - int rc; - - /* do we need to do it? */ - if (dev->class != ATA_DEV_ATA || - !ata_id_has_lba(dev->id) || !ata_id_hpa_enabled(dev->id) || - (dev->horkage & ATA_HORKAGE_BROKEN_HPA)) - return 0; - - /* read native max address */ - rc = ata_read_native_max_address(dev, &native_sectors); - if (rc) { - /* If device aborted the command or HPA isn't going to - * be unlocked, skip HPA resizing. - */ - if (rc == -EACCES || !unlock_hpa) { - ata_dev_warn(dev, - "HPA support seems broken, skipping HPA handling\n"); - dev->horkage |= ATA_HORKAGE_BROKEN_HPA; - - /* we can continue if device aborted the command */ - if (rc == -EACCES) - rc = 0; - } - - return rc; - } - dev->n_native_sectors = native_sectors; - - /* nothing to do? */ - if (native_sectors <= sectors || !unlock_hpa) { - if (!print_info || native_sectors == sectors) - return 0; - - if (native_sectors > sectors) - ata_dev_info(dev, - "HPA detected: current %llu, native %llu\n", - (unsigned long long)sectors, - (unsigned long long)native_sectors); - else if (native_sectors < sectors) - ata_dev_warn(dev, - "native sectors (%llu) is smaller than sectors (%llu)\n", - (unsigned long long)native_sectors, - (unsigned long long)sectors); - return 0; - } - - /* let's unlock HPA */ - rc = ata_set_max_sectors(dev, native_sectors); - if (rc == -EACCES) { - /* if device aborted the command, skip HPA resizing */ - ata_dev_warn(dev, - "device aborted resize (%llu -> %llu), skipping HPA handling\n", - (unsigned long long)sectors, - (unsigned long long)native_sectors); - dev->horkage |= ATA_HORKAGE_BROKEN_HPA; - return 0; - } else if (rc) - return rc; - - /* re-read IDENTIFY data */ - rc = ata_dev_reread_id(dev, 0); - if (rc) { - ata_dev_err(dev, - "failed to re-read IDENTIFY data after HPA resizing\n"); - return rc; - } - - if (print_info) { - u64 new_sectors = ata_id_n_sectors(dev->id); - ata_dev_info(dev, - "HPA unlocked: %llu -> %llu, native %llu\n", - (unsigned long long)sectors, - (unsigned long long)new_sectors, - (unsigned long long)native_sectors); - } - + dev->horkage |= ATA_HORKAGE_BROKEN_HPA; return 0; } diff -ur linux-3.13.2/drivers/ata/pata_legacy.c linux-3.13.2-patched/drivers/ata/pata_legacy.c --- linux-3.13.2/drivers/ata/pata_legacy.c 2014-01-19 21:40:07.000000000 -0500 +++ linux-3.13.2-patched/drivers/ata/pata_legacy.c 2014-02-10 19:59:15.901948540 -0500 @@ -868,67 +868,6 @@ static __init int probe_chip_type(struct legacy_probe *probe) { - int mask = 1 << probe->slot; - - if (winbond && (probe->port == 0x1F0 || probe->port == 0x170)) { - u8 reg = winbond_readcfg(winbond, 0x81); - reg |= 0x80; /* jumpered mode off */ - winbond_writecfg(winbond, 0x81, reg); - reg = winbond_readcfg(winbond, 0x83); - reg |= 0xF0; /* local control */ - winbond_writecfg(winbond, 0x83, reg); - reg = winbond_readcfg(winbond, 0x85); - reg |= 0xF0; /* programmable timing */ - winbond_writecfg(winbond, 0x85, reg); - - reg = winbond_readcfg(winbond, 0x81); - - if (reg & mask) - return W83759A; - } - if (probe->port == 0x1F0) { - unsigned long flags; - local_irq_save(flags); - /* Probes */ - outb(inb(0x1F2) | 0x80, 0x1F2); - inb(0x1F5); - inb(0x1F2); - inb(0x3F6); - inb(0x3F6); - inb(0x1F2); - inb(0x1F2); - - if ((inb(0x1F2) & 0x80) == 0) { - /* PDC20230c or 20630 ? */ - printk(KERN_INFO "PDC20230-C/20630 VLB ATA controller" - " detected.\n"); - udelay(100); - inb(0x1F5); - local_irq_restore(flags); - return PDC20230; - } else { - outb(0x55, 0x1F2); - inb(0x1F2); - inb(0x1F2); - if (inb(0x1F2) == 0x00) - printk(KERN_INFO "PDC20230-B VLB ATA " - "controller detected.\n"); - local_irq_restore(flags); - return BIOS; - } - local_irq_restore(flags); - } - - if (ht6560a & mask) - return HT6560A; - if (ht6560b & mask) - return HT6560B; - if (opti82c611a & mask) - return OPTI611A; - if (opti82c46x & mask) - return OPTI46X; - if (autospeed & mask) - return SNOOP; return BIOS; } @@ -1217,14 +1156,6 @@ if (secondary == 0 || all) legacy_probe_add(0x170, 15, UNKNOWN, 0); - if (probe_all || !pci_present) { - /* ISA/VLB extra ports */ - legacy_probe_add(0x1E8, 11, UNKNOWN, 0); - legacy_probe_add(0x168, 10, UNKNOWN, 0); - legacy_probe_add(0x1E0, 8, UNKNOWN, 0); - legacy_probe_add(0x160, 12, UNKNOWN, 0); - } - if (opti82c46x) probe_opti_vlb(); if (qdi)