Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev

* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev: (54 commits)
Revert "pata_sis: Implement MWDMA for the UDMA 133 capable chips"
libata: Clarify ata_set_lba_range_entries function
libata: Report zeroed read after TRIM and max discard size
pata_hpt3x2n: fix overclocked MWDMA0 timing
pata_it8213: MWDMA0 is unsupported
[libata] MWDMA0 is unsupported on PIIX-like PATA controllers
pata_via: clear UDMA transfer mode bit for PIO and MWDMA
pata_sis: Power Management fix
pata_rz1000: Power Management fix
pata_radisys: fix UDMA handling
pata_ns87415: Power Management fix
pata_marvell: fix marvell_pre_reset() documentation
pata_legacy: add pointers to QDI65x0 documentation
pata_legacy: fix access to control register for QDI6580
pata_legacy: fix QDI6580DP support
pata_it8213: fix it8213_pre_reset() documentation
pata_it8213: fix wrong MWDMA timings being programmed
pata_it8213: fix PIO2 underclocking
pata_it8213: fix wrong PIO timings being programmed
pata_it8213: fix UDMA handling
...

+845 -273
+25 -16
drivers/ata/Kconfig
··· 3 3 # 4 4 5 5 menuconfig ATA 6 - tristate "Serial ATA (prod) and Parallel ATA (experimental) drivers" 6 + tristate "Serial ATA and Parallel ATA drivers" 7 7 depends on HAS_IOMEM 8 8 depends on BLOCK 9 9 depends on !(M32R || M68K) || BROKEN ··· 374 374 If unsure, say N. 375 375 376 376 config PATA_HPT37X 377 - tristate "HPT 370/370A/371/372/374/302 PATA support (Experimental)" 378 - depends on PCI && EXPERIMENTAL 377 + tristate "HPT 370/370A/371/372/374/302 PATA support" 378 + depends on PCI 379 379 help 380 380 This option enables support for the majority of the later HPT 381 381 PATA controllers via the new ATA layer. ··· 383 383 If unsure, say N. 384 384 385 385 config PATA_HPT3X2N 386 - tristate "HPT 372N/302N PATA support (Experimental)" 387 - depends on PCI && EXPERIMENTAL 386 + tristate "HPT 372N/302N PATA support" 387 + depends on PCI 388 388 help 389 389 This option enables support for the N variant HPT PATA 390 390 controllers via the new ATA layer ··· 401 401 If unsure, say N. 402 402 403 403 config PATA_HPT3X3_DMA 404 - bool "HPT 343/363 DMA support (Experimental)" 404 + bool "HPT 343/363 DMA support" 405 405 depends on PATA_HPT3X3 406 406 help 407 407 This option enables DMA support for the HPT343/363 ··· 510 510 If unsure, say N. 511 511 512 512 config PATA_NINJA32 513 - tristate "Ninja32/Delkin Cardbus ATA support (Experimental)" 514 - depends on PCI && EXPERIMENTAL 513 + tristate "Ninja32/Delkin Cardbus ATA support" 514 + depends on PCI 515 515 help 516 516 This option enables support for the Ninja32, Delkin and 517 517 possibly other brands of Cardbus ATA adapter ··· 570 570 help 571 571 This option enables support for PCMCIA ATA interfaces, including 572 572 compact flash card adapters via the new ATA layer. 573 + 574 + If unsure, say N. 575 + 576 + config PATA_PDC2027X 577 + tristate "Promise PATA 2027x support" 578 + depends on PCI 579 + help 580 + This option enables support for Promise PATA pdc20268 to pdc20277 host adapters. 573 581 574 582 If unsure, say N. 575 583 ··· 651 643 652 644 If unsure, say N. 653 645 654 - config PATA_PDC2027X 655 - tristate "Promise PATA 2027x support" 656 - depends on PCI 657 - help 658 - This option enables support for Promise PATA pdc20268 to pdc20277 host adapters. 659 - 660 - If unsure, say N. 661 - 662 646 config PATA_SIL680 663 647 tristate "CMD / Silicon Image 680 PATA support" 664 648 depends on PCI ··· 664 664 depends on PCI 665 665 help 666 666 This option enables support for SiS PATA controllers 667 + 668 + If unsure, say N. 669 + 670 + config PATA_TOSHIBA 671 + tristate "Toshiba Piccolo support (Experimental)" 672 + depends on PCI && EXPERIMENTAL 673 + help 674 + Support for the Toshiba Piccolo controllers. Currently only the 675 + primary channel is supported by this driver. 667 676 668 677 If unsure, say N. 669 678
+1
drivers/ata/Makefile
··· 63 63 obj-$(CONFIG_PATA_SC1200) += pata_sc1200.o 64 64 obj-$(CONFIG_PATA_SERVERWORKS) += pata_serverworks.o 65 65 obj-$(CONFIG_PATA_SIL680) += pata_sil680.o 66 + obj-$(CONFIG_PATA_TOSHIBA) += pata_piccolo.o 66 67 obj-$(CONFIG_PATA_VIA) += pata_via.o 67 68 obj-$(CONFIG_PATA_WINBOND) += pata_sl82c105.o 68 69 obj-$(CONFIG_PATA_WINBOND_VLB) += pata_winbond.o
+26 -2
drivers/ata/ahci.c
··· 113 113 board_ahci_mcp65 = 6, 114 114 board_ahci_nopmp = 7, 115 115 board_ahci_yesncq = 8, 116 + board_ahci_nosntf = 9, 116 117 117 118 /* global controller registers */ 118 119 HOST_CAP = 0x00, /* host capabilities */ ··· 236 235 AHCI_HFLAG_NO_SUSPEND = (1 << 10), /* don't suspend */ 237 236 AHCI_HFLAG_SRST_TOUT_IS_OFFLINE = (1 << 11), /* treat SRST timeout as 238 237 link offline */ 238 + AHCI_HFLAG_NO_SNTF = (1 << 12), /* no sntf */ 239 239 240 240 /* ap->flags bits */ 241 241 ··· 510 508 .udma_mask = ATA_UDMA6, 511 509 .port_ops = &ahci_ops, 512 510 }, 513 - /* board_ahci_yesncq */ 511 + [board_ahci_yesncq] = 514 512 { 515 513 AHCI_HFLAGS (AHCI_HFLAG_YES_NCQ), 514 + .flags = AHCI_FLAG_COMMON, 515 + .pio_mask = ATA_PIO4, 516 + .udma_mask = ATA_UDMA6, 517 + .port_ops = &ahci_ops, 518 + }, 519 + [board_ahci_nosntf] = 520 + { 521 + AHCI_HFLAGS (AHCI_HFLAG_NO_SNTF), 516 522 .flags = AHCI_FLAG_COMMON, 517 523 .pio_mask = ATA_PIO4, 518 524 .udma_mask = ATA_UDMA6, ··· 541 531 { PCI_VDEVICE(INTEL, 0x2683), board_ahci }, /* ESB2 */ 542 532 { PCI_VDEVICE(INTEL, 0x27c6), board_ahci }, /* ICH7-M DH */ 543 533 { PCI_VDEVICE(INTEL, 0x2821), board_ahci }, /* ICH8 */ 544 - { PCI_VDEVICE(INTEL, 0x2822), board_ahci }, /* ICH8 */ 534 + { PCI_VDEVICE(INTEL, 0x2822), board_ahci_nosntf }, /* ICH8 */ 545 535 { PCI_VDEVICE(INTEL, 0x2824), board_ahci }, /* ICH8 */ 546 536 { PCI_VDEVICE(INTEL, 0x2829), board_ahci }, /* ICH8M */ 547 537 { PCI_VDEVICE(INTEL, 0x282a), board_ahci }, /* ICH8M */ ··· 857 847 dev_printk(KERN_INFO, &pdev->dev, 858 848 "controller can't do PMP, turning off CAP_PMP\n"); 859 849 cap &= ~HOST_CAP_PMP; 850 + } 851 + 852 + if ((cap & HOST_CAP_SNTF) && (hpriv->flags & AHCI_HFLAG_NO_SNTF)) { 853 + dev_printk(KERN_INFO, &pdev->dev, 854 + "controller can't do SNTF, turning off CAP_SNTF\n"); 855 + cap &= ~HOST_CAP_SNTF; 860 856 } 861 857 862 858 if (pdev->vendor == PCI_VENDOR_ID_JMICRON && pdev->device == 0x2361 && ··· 3003 2987 AHCI stays out of the way */ 3004 2988 if (pdev->vendor == PCI_VENDOR_ID_MARVELL && !marvell_enable) 3005 2989 return -ENODEV; 2990 + 2991 + /* Promise's PDC42819 is a SAS/SATA controller that has an AHCI mode. 2992 + * At the moment, we can only use the AHCI mode. Let the users know 2993 + * that for SAS drives they're out of luck. 2994 + */ 2995 + if (pdev->vendor == PCI_VENDOR_ID_PROMISE) 2996 + dev_printk(KERN_INFO, &pdev->dev, "PDC42819 " 2997 + "can only drive SATA devices with this driver\n"); 3006 2998 3007 2999 /* acquire resources */ 3008 3000 rc = pcim_enable_device(pdev);
+4 -1
drivers/ata/ata_generic.c
··· 168 168 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C561), }, 169 169 { PCI_DEVICE(PCI_VENDOR_ID_OPTI, PCI_DEVICE_ID_OPTI_82C558), }, 170 170 { PCI_DEVICE(PCI_VENDOR_ID_CENATEK,PCI_DEVICE_ID_CENATEK_IDE), }, 171 - { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO), }, 171 + #if !defined(CONFIG_PATA_TOSHIBA) && !defined(CONFIG_PATA_TOSHIBA_MODULE) 172 172 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), }, 173 173 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), }, 174 + { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_3), }, 175 + { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_5), }, 176 + #endif 174 177 /* Must come last. If you add entries adjust this table appropriately */ 175 178 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xFFFFFF00UL, 1}, 176 179 { 0, },
+3 -3
drivers/ata/ata_piix.c
··· 869 869 (timings[pio][1] << 8); 870 870 } 871 871 872 - if (ap->udma_mask) { 872 + if (ap->udma_mask) 873 873 udma_enable &= ~(1 << devid); 874 - pci_write_config_word(dev, master_port, master_data); 875 - } 874 + 875 + pci_write_config_word(dev, master_port, master_data); 876 876 } 877 877 /* Don't scribble on 0x48 if the controller does not support UDMA */ 878 878 if (ap->udma_mask)
+9 -6
drivers/ata/libata-acpi.c
··· 807 807 * EH context. 808 808 * 809 809 * RETURNS: 810 - * 0 on success, -errno on failure. 810 + * 0 on success, -ENOENT if _SDD doesn't exist, -errno on failure. 811 811 */ 812 812 static int ata_acpi_push_id(struct ata_device *dev) 813 813 { 814 814 struct ata_port *ap = dev->link->ap; 815 - int err; 816 815 acpi_status status; 817 816 struct acpi_object_list input; 818 817 union acpi_object in_params[1]; ··· 834 835 status = acpi_evaluate_object(dev->acpi_handle, "_SDD", &input, NULL); 835 836 swap_buf_le16(dev->id, ATA_ID_WORDS); 836 837 837 - err = ACPI_FAILURE(status) ? -EIO : 0; 838 - if (err < 0) 838 + if (status == AE_NOT_FOUND) 839 + return -ENOENT; 840 + 841 + if (ACPI_FAILURE(status)) { 839 842 ata_dev_printk(dev, KERN_WARNING, 840 843 "ACPI _SDD failed (AE 0x%x)\n", status); 844 + return -EIO; 845 + } 841 846 842 - return err; 847 + return 0; 843 848 } 844 849 845 850 /** ··· 974 971 /* do _SDD if SATA */ 975 972 if (acpi_sata) { 976 973 rc = ata_acpi_push_id(dev); 977 - if (rc) 974 + if (rc && rc != -ENOENT) 978 975 goto acpi_err; 979 976 } 980 977
+7
drivers/ata/libata-core.c
··· 6616 6616 { 6617 6617 ata_parse_force_param(); 6618 6618 6619 + /* 6620 + * FIXME: In UP case, there is only one workqueue thread and if you 6621 + * have more than one PIO device, latency is bloody awful, with 6622 + * occasional multi-second "hiccups" as one PIO device waits for 6623 + * another. It's an ugly wart that users DO occasionally complain 6624 + * about; luckily most users have at most one PIO polled device. 6625 + */ 6619 6626 ata_wq = create_workqueue("ata"); 6620 6627 if (!ata_wq) 6621 6628 goto free_force_tbl;
+94
drivers/ata/libata-eh.c
··· 110 110 ULONG_MAX, 111 111 }; 112 112 113 + static const unsigned long ata_eh_flush_timeouts[] = { 114 + 15000, /* be generous with flush */ 115 + 15000, /* ditto */ 116 + 30000, /* and even more generous */ 117 + ULONG_MAX, 118 + }; 119 + 113 120 static const unsigned long ata_eh_other_timeouts[] = { 114 121 5000, /* same rationale as identify timeout */ 115 122 10000, /* ditto */ ··· 154 147 .timeouts = ata_eh_other_timeouts, }, 155 148 { .commands = CMDS(ATA_CMD_INIT_DEV_PARAMS), 156 149 .timeouts = ata_eh_other_timeouts, }, 150 + { .commands = CMDS(ATA_CMD_FLUSH, ATA_CMD_FLUSH_EXT), 151 + .timeouts = ata_eh_flush_timeouts }, 157 152 }; 158 153 #undef CMDS 159 154 ··· 3121 3112 return 0; 3122 3113 } 3123 3114 3115 + /** 3116 + * ata_eh_maybe_retry_flush - Retry FLUSH if necessary 3117 + * @dev: ATA device which may need FLUSH retry 3118 + * 3119 + * If @dev failed FLUSH, it needs to be reported upper layer 3120 + * immediately as it means that @dev failed to remap and already 3121 + * lost at least a sector and further FLUSH retrials won't make 3122 + * any difference to the lost sector. However, if FLUSH failed 3123 + * for other reasons, for example transmission error, FLUSH needs 3124 + * to be retried. 3125 + * 3126 + * This function determines whether FLUSH failure retry is 3127 + * necessary and performs it if so. 3128 + * 3129 + * RETURNS: 3130 + * 0 if EH can continue, -errno if EH needs to be repeated. 3131 + */ 3132 + static int ata_eh_maybe_retry_flush(struct ata_device *dev) 3133 + { 3134 + struct ata_link *link = dev->link; 3135 + struct ata_port *ap = link->ap; 3136 + struct ata_queued_cmd *qc; 3137 + struct ata_taskfile tf; 3138 + unsigned int err_mask; 3139 + int rc = 0; 3140 + 3141 + /* did flush fail for this device? */ 3142 + if (!ata_tag_valid(link->active_tag)) 3143 + return 0; 3144 + 3145 + qc = __ata_qc_from_tag(ap, link->active_tag); 3146 + if (qc->dev != dev || (qc->tf.command != ATA_CMD_FLUSH_EXT && 3147 + qc->tf.command != ATA_CMD_FLUSH)) 3148 + return 0; 3149 + 3150 + /* if the device failed it, it should be reported to upper layers */ 3151 + if (qc->err_mask & AC_ERR_DEV) 3152 + return 0; 3153 + 3154 + /* flush failed for some other reason, give it another shot */ 3155 + ata_tf_init(dev, &tf); 3156 + 3157 + tf.command = qc->tf.command; 3158 + tf.flags |= ATA_TFLAG_DEVICE; 3159 + tf.protocol = ATA_PROT_NODATA; 3160 + 3161 + ata_dev_printk(dev, KERN_WARNING, "retrying FLUSH 0x%x Emask 0x%x\n", 3162 + tf.command, qc->err_mask); 3163 + 3164 + err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); 3165 + if (!err_mask) { 3166 + /* 3167 + * FLUSH is complete but there's no way to 3168 + * successfully complete a failed command from EH. 3169 + * Making sure retry is allowed at least once and 3170 + * retrying it should do the trick - whatever was in 3171 + * the cache is already on the platter and this won't 3172 + * cause infinite loop. 3173 + */ 3174 + qc->scsicmd->allowed = max(qc->scsicmd->allowed, 1); 3175 + } else { 3176 + ata_dev_printk(dev, KERN_WARNING, "FLUSH failed Emask 0x%x\n", 3177 + err_mask); 3178 + rc = -EIO; 3179 + 3180 + /* if device failed it, report it to upper layers */ 3181 + if (err_mask & AC_ERR_DEV) { 3182 + qc->err_mask |= AC_ERR_DEV; 3183 + qc->result_tf = tf; 3184 + if (!(ap->pflags & ATA_PFLAG_FROZEN)) 3185 + rc = 0; 3186 + } 3187 + } 3188 + return rc; 3189 + } 3190 + 3124 3191 static int ata_link_nr_enabled(struct ata_link *link) 3125 3192 { 3126 3193 struct ata_device *dev; ··· 3538 3453 if (rc) 3539 3454 goto dev_fail; 3540 3455 } 3456 + } 3457 + 3458 + /* retry flush if necessary */ 3459 + ata_for_each_dev(dev, link, ALL) { 3460 + if (dev->class != ATA_DEV_ATA) 3461 + continue; 3462 + rc = ata_eh_maybe_retry_flush(dev); 3463 + if (rc) 3464 + goto dev_fail; 3541 3465 } 3542 3466 3543 3467 /* configure link power saving */
+105 -2
drivers/ata/libata-scsi.c
··· 47 47 #include <linux/hdreg.h> 48 48 #include <linux/uaccess.h> 49 49 #include <linux/suspend.h> 50 + #include <asm/unaligned.h> 50 51 51 52 #include "libata.h" 52 53 ··· 155 154 */ 156 155 for (i = 1; i < ARRAY_SIZE(link_pm_policy); i++) { 157 156 const int len = strlen(link_pm_policy[i].name); 158 - if (strncmp(link_pm_policy[i].name, buf, len) == 0 && 159 - buf[len] == '\n') { 157 + if (strncmp(link_pm_policy[i].name, buf, len) == 0) { 160 158 policy = link_pm_policy[i].value; 161 159 break; 162 160 } ··· 1964 1964 0x80, /* page 0x80, unit serial no page */ 1965 1965 0x83, /* page 0x83, device ident page */ 1966 1966 0x89, /* page 0x89, ata info page */ 1967 + 0xb0, /* page 0xb0, block limits page */ 1967 1968 0xb1, /* page 0xb1, block device characteristics page */ 1968 1969 }; 1969 1970 ··· 2083 2082 rbuf[56] = ATA_CMD_ID_ATA; 2084 2083 2085 2084 memcpy(&rbuf[60], &args->id[0], 512); 2085 + return 0; 2086 + } 2087 + 2088 + static unsigned int ata_scsiop_inq_b0(struct ata_scsi_args *args, u8 *rbuf) 2089 + { 2090 + u32 min_io_sectors; 2091 + 2092 + rbuf[1] = 0xb0; 2093 + rbuf[3] = 0x3c; /* required VPD size with unmap support */ 2094 + 2095 + /* 2096 + * Optimal transfer length granularity. 2097 + * 2098 + * This is always one physical block, but for disks with a smaller 2099 + * logical than physical sector size we need to figure out what the 2100 + * latter is. 2101 + */ 2102 + if (ata_id_has_large_logical_sectors(args->id)) 2103 + min_io_sectors = ata_id_logical_per_physical_sectors(args->id); 2104 + else 2105 + min_io_sectors = 1; 2106 + put_unaligned_be16(min_io_sectors, &rbuf[6]); 2107 + 2108 + /* 2109 + * Optimal unmap granularity. 2110 + * 2111 + * The ATA spec doesn't even know about a granularity or alignment 2112 + * for the TRIM command. We can leave away most of the unmap related 2113 + * VPD page entries, but we have specifify a granularity to signal 2114 + * that we support some form of unmap - in thise case via WRITE SAME 2115 + * with the unmap bit set. 2116 + */ 2117 + if (ata_id_has_trim(args->id)) { 2118 + put_unaligned_be32(65535 * 512 / 8, &rbuf[20]); 2119 + put_unaligned_be32(1, &rbuf[28]); 2120 + } 2121 + 2086 2122 return 0; 2087 2123 } 2088 2124 ··· 2412 2374 rbuf[13] = log_per_phys; 2413 2375 rbuf[14] = (lowest_aligned >> 8) & 0x3f; 2414 2376 rbuf[15] = lowest_aligned; 2377 + 2378 + if (ata_id_has_trim(args->id)) { 2379 + rbuf[14] |= 0x80; /* TPE */ 2380 + 2381 + if (ata_id_has_zero_after_trim(args->id)) 2382 + rbuf[14] |= 0x40; /* TPRZ */ 2383 + } 2415 2384 } 2416 2385 2417 2386 return 0; ··· 2941 2896 return 1; 2942 2897 } 2943 2898 2899 + static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc) 2900 + { 2901 + struct ata_taskfile *tf = &qc->tf; 2902 + struct scsi_cmnd *scmd = qc->scsicmd; 2903 + struct ata_device *dev = qc->dev; 2904 + const u8 *cdb = scmd->cmnd; 2905 + u64 block; 2906 + u32 n_block; 2907 + u32 size; 2908 + void *buf; 2909 + 2910 + /* we may not issue DMA commands if no DMA mode is set */ 2911 + if (unlikely(!dev->dma_mode)) 2912 + goto invalid_fld; 2913 + 2914 + if (unlikely(scmd->cmd_len < 16)) 2915 + goto invalid_fld; 2916 + scsi_16_lba_len(cdb, &block, &n_block); 2917 + 2918 + /* for now we only support WRITE SAME with the unmap bit set */ 2919 + if (unlikely(!(cdb[1] & 0x8))) 2920 + goto invalid_fld; 2921 + 2922 + /* 2923 + * WRITE SAME always has a sector sized buffer as payload, this 2924 + * should never be a multiple entry S/G list. 2925 + */ 2926 + if (!scsi_sg_count(scmd)) 2927 + goto invalid_fld; 2928 + 2929 + buf = page_address(sg_page(scsi_sglist(scmd))); 2930 + size = ata_set_lba_range_entries(buf, 512, block, n_block); 2931 + 2932 + tf->protocol = ATA_PROT_DMA; 2933 + tf->hob_feature = 0; 2934 + tf->feature = ATA_DSM_TRIM; 2935 + tf->hob_nsect = (size / 512) >> 8; 2936 + tf->nsect = size / 512; 2937 + tf->command = ATA_CMD_DSM; 2938 + tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48 | 2939 + ATA_TFLAG_WRITE; 2940 + 2941 + ata_qc_set_pc_nbytes(qc); 2942 + 2943 + return 0; 2944 + 2945 + invalid_fld: 2946 + ata_scsi_set_sense(scmd, ILLEGAL_REQUEST, 0x24, 0x00); 2947 + /* "Invalid field in cdb" */ 2948 + return 1; 2949 + } 2950 + 2944 2951 /** 2945 2952 * ata_get_xlat_func - check if SCSI to ATA translation is possible 2946 2953 * @dev: ATA device ··· 3016 2919 case WRITE_10: 3017 2920 case WRITE_16: 3018 2921 return ata_scsi_rw_xlat; 2922 + 2923 + case 0x93 /*WRITE_SAME_16*/: 2924 + return ata_scsi_write_same_xlat; 3019 2925 3020 2926 case SYNCHRONIZE_CACHE: 3021 2927 if (ata_try_flush_cache(dev)) ··· 3208 3108 break; 3209 3109 case 0x89: 3210 3110 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_89); 3111 + break; 3112 + case 0xb0: 3113 + ata_scsi_rbuf_fill(&args, ata_scsiop_inq_b0); 3211 3114 break; 3212 3115 case 0xb1: 3213 3116 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_b1);
+1 -1
drivers/ata/libata-sff.c
··· 2384 2384 ap->hsm_task_state = HSM_ST_IDLE; 2385 2385 2386 2386 if (ap->ioaddr.bmdma_addr) 2387 - ata_bmdma_stop(qc); 2387 + ap->ops->bmdma_stop(qc); 2388 2388 2389 2389 spin_unlock_irqrestore(ap->lock, flags); 2390 2390 }
+3 -1
drivers/ata/pata_ali.c
··· 453 453 /* Clear CD-ROM DMA write bit */ 454 454 tmp &= 0x7F; 455 455 /* Cable and UDMA */ 456 - pci_write_config_byte(pdev, 0x4B, tmp | 0x09); 456 + if (pdev->revision >= 0xc2) 457 + tmp |= 0x01; 458 + pci_write_config_byte(pdev, 0x4B, tmp | 0x08); 457 459 /* 458 460 * CD_ROM DMA on (0x53 bit 0). Enable this even if we want 459 461 * to use PIO. 0x53 bit 1 (rev 20 only) - enable FIFO control
+110 -15
drivers/ata/pata_cmd64x.c
··· 31 31 #include <linux/libata.h> 32 32 33 33 #define DRV_NAME "pata_cmd64x" 34 - #define DRV_VERSION "0.2.5" 34 + #define DRV_VERSION "0.3.1" 35 35 36 36 /* 37 37 * CMD64x specific registers definition. ··· 254 254 } 255 255 256 256 /** 257 - * cmd646r1_dma_stop - DMA stop callback 257 + * cmd64x_bmdma_stop - DMA stop callback 258 258 * @qc: Command in progress 259 259 * 260 - * Stub for now while investigating the r1 quirk in the old driver. 260 + * Track the completion of live DMA commands and clear the 261 + * host->private_data DMA tracking flag as we do. 261 262 */ 262 263 263 - static void cmd646r1_bmdma_stop(struct ata_queued_cmd *qc) 264 + static void cmd64x_bmdma_stop(struct ata_queued_cmd *qc) 264 265 { 266 + struct ata_port *ap = qc->ap; 265 267 ata_bmdma_stop(qc); 268 + WARN_ON(ap->host->private_data != ap); 269 + ap->host->private_data = NULL; 266 270 } 267 271 272 + /** 273 + * cmd64x_qc_defer - Defer logic for chip limits 274 + * @qc: queued command 275 + * 276 + * Decide whether we can issue the command. Called under the host lock. 277 + */ 278 + 279 + static int cmd64x_qc_defer(struct ata_queued_cmd *qc) 280 + { 281 + struct ata_host *host = qc->ap->host; 282 + struct ata_port *alt = host->ports[1 ^ qc->ap->port_no]; 283 + int rc; 284 + int dma = 0; 285 + 286 + /* Apply the ATA rules first */ 287 + rc = ata_std_qc_defer(qc); 288 + if (rc) 289 + return rc; 290 + 291 + if (qc->tf.protocol == ATAPI_PROT_DMA || 292 + qc->tf.protocol == ATA_PROT_DMA) 293 + dma = 1; 294 + 295 + /* If the other port is not live then issue the command */ 296 + if (alt == NULL || !alt->qc_active) { 297 + if (dma) 298 + host->private_data = qc->ap; 299 + return 0; 300 + } 301 + /* If there is a live DMA command then wait */ 302 + if (host->private_data != NULL) 303 + return ATA_DEFER_PORT; 304 + if (dma) 305 + /* Cannot overlap our DMA command */ 306 + return ATA_DEFER_PORT; 307 + return 0; 308 + } 309 + 310 + /** 311 + * cmd64x_interrupt - ATA host interrupt handler 312 + * @irq: irq line (unused) 313 + * @dev_instance: pointer to our ata_host information structure 314 + * 315 + * Our interrupt handler for PCI IDE devices. Calls 316 + * ata_sff_host_intr() for each port that is flagging an IRQ. We cannot 317 + * use the defaults as we need to avoid touching status/altstatus during 318 + * a DMA. 319 + * 320 + * LOCKING: 321 + * Obtains host lock during operation. 322 + * 323 + * RETURNS: 324 + * IRQ_NONE or IRQ_HANDLED. 325 + */ 326 + irqreturn_t cmd64x_interrupt(int irq, void *dev_instance) 327 + { 328 + struct ata_host *host = dev_instance; 329 + struct pci_dev *pdev = to_pci_dev(host->dev); 330 + unsigned int i; 331 + unsigned int handled = 0; 332 + unsigned long flags; 333 + static const u8 irq_reg[2] = { CFR, ARTTIM23 }; 334 + static const u8 irq_mask[2] = { 1 << 2, 1 << 4 }; 335 + 336 + /* TODO: make _irqsave conditional on x86 PCI IDE legacy mode */ 337 + spin_lock_irqsave(&host->lock, flags); 338 + 339 + for (i = 0; i < host->n_ports; i++) { 340 + struct ata_port *ap; 341 + u8 reg; 342 + 343 + pci_read_config_byte(pdev, irq_reg[i], &reg); 344 + ap = host->ports[i]; 345 + if (ap && (reg & irq_mask[i]) && 346 + !(ap->flags & ATA_FLAG_DISABLED)) { 347 + struct ata_queued_cmd *qc; 348 + 349 + qc = ata_qc_from_tag(ap, ap->link.active_tag); 350 + if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) && 351 + (qc->flags & ATA_QCFLAG_ACTIVE)) 352 + handled |= ata_sff_host_intr(ap, qc); 353 + } 354 + } 355 + 356 + spin_unlock_irqrestore(&host->lock, flags); 357 + 358 + return IRQ_RETVAL(handled); 359 + } 268 360 static struct scsi_host_template cmd64x_sht = { 269 361 ATA_BMDMA_SHT(DRV_NAME), 270 362 }; ··· 365 273 .inherits = &ata_bmdma_port_ops, 366 274 .set_piomode = cmd64x_set_piomode, 367 275 .set_dmamode = cmd64x_set_dmamode, 276 + .bmdma_stop = cmd64x_bmdma_stop, 277 + .qc_defer = cmd64x_qc_defer, 368 278 }; 369 279 370 280 static struct ata_port_operations cmd64x_port_ops = { ··· 376 282 377 283 static struct ata_port_operations cmd646r1_port_ops = { 378 284 .inherits = &cmd64x_base_ops, 379 - .bmdma_stop = cmd646r1_bmdma_stop, 380 285 .cable_detect = ata_cable_40wire, 381 286 }; 382 287 ··· 383 290 .inherits = &cmd64x_base_ops, 384 291 .bmdma_stop = cmd648_bmdma_stop, 385 292 .cable_detect = cmd648_cable_detect, 293 + .qc_defer = ata_std_qc_defer 386 294 }; 387 295 388 296 static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 389 297 { 390 - u32 class_rev; 391 - 392 298 static const struct ata_port_info cmd_info[6] = { 393 299 { /* CMD 643 - no UDMA */ 394 300 .flags = ATA_FLAG_SLAVE_POSS, ··· 432 340 const struct ata_port_info *ppi[] = { &cmd_info[id->driver_data], NULL }; 433 341 u8 mrdmode; 434 342 int rc; 343 + struct ata_host *host; 435 344 436 345 rc = pcim_enable_device(pdev); 437 346 if (rc) 438 347 return rc; 439 - 440 - pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev); 441 - class_rev &= 0xFF; 442 348 443 349 if (id->driver_data == 0) /* 643 */ 444 350 ata_pci_bmdma_clear_simplex(pdev); 445 351 446 352 if (pdev->device == PCI_DEVICE_ID_CMD_646) { 447 353 /* Does UDMA work ? */ 448 - if (class_rev > 4) 354 + if (pdev->revision > 4) 449 355 ppi[0] = &cmd_info[2]; 450 356 /* Early rev with other problems ? */ 451 - else if (class_rev == 1) 357 + else if (pdev->revision == 1) 452 358 ppi[0] = &cmd_info[3]; 453 359 } 360 + 454 361 455 362 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64); 456 363 pci_read_config_byte(pdev, MRDMODE, &mrdmode); ··· 457 366 mrdmode |= 0x02; /* Memory read line enable */ 458 367 pci_write_config_byte(pdev, MRDMODE, mrdmode); 459 368 460 - /* Force PIO 0 here.. */ 461 - 462 369 /* PPC specific fixup copied from old driver */ 463 370 #ifdef CONFIG_PPC 464 371 pci_write_config_byte(pdev, UDIDETCR0, 0xF0); 465 372 #endif 373 + rc = ata_pci_sff_prepare_host(pdev, ppi, &host); 374 + if (rc) 375 + return rc; 376 + /* We use this pointer to track the AP which has DMA running */ 377 + host->private_data = NULL; 466 378 467 - return ata_pci_sff_init_one(pdev, ppi, &cmd64x_sht, NULL); 379 + pci_set_master(pdev); 380 + return ata_pci_sff_activate_host(host, cmd64x_interrupt, &cmd64x_sht); 468 381 } 469 382 470 383 #ifdef CONFIG_PM
+1 -38
drivers/ata/pata_cs5520.c
··· 90 90 } 91 91 92 92 /** 93 - * cs5520_enable_dma - turn on DMA bits 94 - * 95 - * Turn on the DMA bits for this disk. Needed because the BIOS probably 96 - * has not done the work for us. Belongs in the core SATA code. 97 - */ 98 - 99 - static void cs5520_enable_dma(struct ata_port *ap, struct ata_device *adev) 100 - { 101 - /* Set the DMA enable/disable flag */ 102 - u8 reg = ioread8(ap->ioaddr.bmdma_addr + 0x02); 103 - reg |= 1<<(adev->devno + 5); 104 - iowrite8(reg, ap->ioaddr.bmdma_addr + 0x02); 105 - } 106 - 107 - /** 108 - * cs5520_set_dmamode - program DMA timings 109 - * @ap: ATA port 110 - * @adev: ATA device 111 - * 112 - * Program the DMA mode timings for the controller according to the pio 113 - * clocking table. Note that this device sets the DMA timings to PIO 114 - * mode values. This may seem bizarre but the 5520 architecture talks 115 - * PIO mode to the disk and DMA mode to the controller so the underlying 116 - * transfers are PIO timed. 117 - */ 118 - 119 - static void cs5520_set_dmamode(struct ata_port *ap, struct ata_device *adev) 120 - { 121 - static const int dma_xlate[3] = { XFER_PIO_0, XFER_PIO_3, XFER_PIO_4 }; 122 - cs5520_set_timings(ap, adev, dma_xlate[adev->dma_mode]); 123 - cs5520_enable_dma(ap, adev); 124 - } 125 - 126 - /** 127 93 * cs5520_set_piomode - program PIO timings 128 94 * @ap: ATA port 129 95 * @adev: ATA device 130 96 * 131 97 * Program the PIO mode timings for the controller according to the pio 132 - * clocking table. We know pio_mode will equal dma_mode because of the 133 - * CS5520 architecture. At least once we turned DMA on and wrote a 134 - * mode setter. 98 + * clocking table. 135 99 */ 136 100 137 101 static void cs5520_set_piomode(struct ata_port *ap, struct ata_device *adev) ··· 113 149 .qc_prep = ata_sff_dumb_qc_prep, 114 150 .cable_detect = ata_cable_40wire, 115 151 .set_piomode = cs5520_set_piomode, 116 - .set_dmamode = cs5520_set_dmamode, 117 152 }; 118 153 119 154 static int __devinit cs5520_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
+1 -1
drivers/ata/pata_cs5536.c
··· 224 224 }; 225 225 226 226 static struct ata_port_operations cs5536_port_ops = { 227 - .inherits = &ata_bmdma_port_ops, 227 + .inherits = &ata_bmdma32_port_ops, 228 228 .cable_detect = cs5536_cable_detect, 229 229 .set_piomode = cs5536_set_piomode, 230 230 .set_dmamode = cs5536_set_dmamode,
+5 -4
drivers/ata/pata_efar.c
··· 2 2 * pata_efar.c - EFAR PIIX clone controller driver 3 3 * 4 4 * (C) 2005 Red Hat 5 + * (C) 2009 Bartlomiej Zolnierkiewicz 5 6 * 6 7 * Some parts based on ata_piix.c by Jeff Garzik and others. 7 8 * ··· 119 118 int shift = 4 * ap->port_no; 120 119 u8 slave_data; 121 120 122 - idetm_data &= 0xCC0F; 121 + idetm_data &= 0xFF0F; 123 122 idetm_data |= (control << 4); 124 123 125 124 /* Slave timing in separate register */ 126 125 pci_read_config_byte(dev, 0x44, &slave_data); 127 - slave_data &= 0x0F << shift; 126 + slave_data &= ap->port_no ? 0x0F : 0xF0; 128 127 slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << shift; 129 128 pci_write_config_byte(dev, 0x44, slave_data); 130 129 } ··· 201 200 master_data &= 0xFF4F; /* Mask out IORDY|TIME1|DMAONLY */ 202 201 master_data |= control << 4; 203 202 pci_read_config_byte(dev, 0x44, &slave_data); 204 - slave_data &= (0x0F + 0xE1 * ap->port_no); 203 + slave_data &= ap->port_no ? 0x0F : 0xF0; 205 204 /* Load the matching timing */ 206 205 slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << (ap->port_no ? 4 : 0); 207 206 pci_write_config_byte(dev, 0x44, slave_data); ··· 252 251 static const struct ata_port_info info = { 253 252 .flags = ATA_FLAG_SLAVE_POSS, 254 253 .pio_mask = ATA_PIO4, 255 - .mwdma_mask = ATA_MWDMA2, 254 + .mwdma_mask = ATA_MWDMA12_ONLY, 256 255 .udma_mask = ATA_UDMA4, 257 256 .port_ops = &efar_ops, 258 257 };
+16 -22
drivers/ata/pata_hpt366.c
··· 27 27 #include <linux/libata.h> 28 28 29 29 #define DRV_NAME "pata_hpt366" 30 - #define DRV_VERSION "0.6.2" 30 + #define DRV_VERSION "0.6.7" 31 31 32 32 struct hpt_clock { 33 33 u8 xfer_mode; ··· 36 36 37 37 /* key for bus clock timings 38 38 * bit 39 - * 0:3 data_high_time. inactive time of DIOW_/DIOR_ for PIO and MW 40 - * DMA. cycles = value + 1 41 - * 4:8 data_low_time. active time of DIOW_/DIOR_ for PIO and MW 42 - * DMA. cycles = value + 1 43 - * 9:12 cmd_high_time. inactive time of DIOW_/DIOR_ during task file 39 + * 0:3 data_high_time. Inactive time of DIOW_/DIOR_ for PIO and MW DMA. 40 + * cycles = value + 1 41 + * 4:7 data_low_time. Active time of DIOW_/DIOR_ for PIO and MW DMA. 42 + * cycles = value + 1 43 + * 8:11 cmd_high_time. Inactive time of DIOW_/DIOR_ during task file 44 44 * register access. 45 - * 13:17 cmd_low_time. active time of DIOW_/DIOR_ during task file 45 + * 12:15 cmd_low_time. Active time of DIOW_/DIOR_ during task file 46 46 * register access. 47 - * 18:21 udma_cycle_time. clock freq and clock cycles for UDMA xfer. 48 - * during task file register access. 49 - * 22:24 pre_high_time. time to initialize 1st cycle for PIO and MW DMA 50 - * xfer. 51 - * 25:27 cmd_pre_high_time. time to initialize 1st PIO cycle for task 47 + * 16:18 udma_cycle_time. Clock cycles for UDMA xfer? 48 + * 19:21 pre_high_time. Time to initialize 1st cycle for PIO and MW DMA xfer. 49 + * 22:24 cmd_pre_high_time. Time to initialize 1st PIO cycle for task file 52 50 * register access. 53 - * 28 UDMA enable 54 - * 29 DMA enable 55 - * 30 PIO_MST enable. if set, the chip is in bus master mode during 56 - * PIO. 51 + * 28 UDMA enable. 52 + * 29 DMA enable. 53 + * 30 PIO_MST enable. If set, the chip is in bus master mode during 54 + * PIO xfer. 57 55 * 31 FIFO enable. 58 56 */ 59 57 ··· 342 344 const struct ata_port_info *ppi[] = { &info_hpt366, NULL }; 343 345 344 346 void *hpriv = NULL; 345 - u32 class_rev; 346 347 u32 reg1; 347 348 int rc; 348 349 ··· 349 352 if (rc) 350 353 return rc; 351 354 352 - pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); 353 - class_rev &= 0xFF; 354 - 355 355 /* May be a later chip in disguise. Check */ 356 356 /* Newer chips are not in the HPT36x driver. Ignore them */ 357 - if (class_rev > 2) 358 - return -ENODEV; 357 + if (dev->revision > 2) 358 + return -ENODEV; 359 359 360 360 hpt36x_init_chipset(dev); 361 361
+71 -66
drivers/ata/pata_hpt37x.c
··· 24 24 #include <linux/libata.h> 25 25 26 26 #define DRV_NAME "pata_hpt37x" 27 - #define DRV_VERSION "0.6.12" 27 + #define DRV_VERSION "0.6.14" 28 28 29 29 struct hpt_clock { 30 30 u8 xfer_speed; ··· 303 303 } 304 304 305 305 /** 306 - * hpt37x_pre_reset - reset the hpt37x bus 307 - * @link: ATA link to reset 308 - * @deadline: deadline jiffies for the operation 306 + * hpt37x_cable_detect - Detect the cable type 307 + * @ap: ATA port to detect on 309 308 * 310 - * Perform the initial reset handling for the 370/372 and 374 func 0 309 + * Return the cable type attached to this port 311 310 */ 312 311 313 - static int hpt37x_pre_reset(struct ata_link *link, unsigned long deadline) 312 + static int hpt37x_cable_detect(struct ata_port *ap) 314 313 { 315 - u8 scr2, ata66; 316 - struct ata_port *ap = link->ap; 317 314 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 318 - static const struct pci_bits hpt37x_enable_bits[] = { 319 - { 0x50, 1, 0x04, 0x04 }, 320 - { 0x54, 1, 0x04, 0x04 } 321 - }; 322 - if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no])) 323 - return -ENOENT; 315 + u8 scr2, ata66; 324 316 325 317 pci_read_config_byte(pdev, 0x5B, &scr2); 326 318 pci_write_config_byte(pdev, 0x5B, scr2 & ~0x01); 319 + 320 + udelay(10); /* debounce */ 321 + 327 322 /* Cable register now active */ 328 323 pci_read_config_byte(pdev, 0x5A, &ata66); 329 324 /* Restore state */ 330 325 pci_write_config_byte(pdev, 0x5B, scr2); 331 326 332 327 if (ata66 & (2 >> ap->port_no)) 333 - ap->cbl = ATA_CBL_PATA40; 328 + return ATA_CBL_PATA40; 334 329 else 335 - ap->cbl = ATA_CBL_PATA80; 336 - 337 - /* Reset the state machine */ 338 - pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); 339 - udelay(100); 340 - 341 - return ata_sff_prereset(link, deadline); 330 + return ATA_CBL_PATA80; 342 331 } 343 332 344 - static int hpt374_fn1_pre_reset(struct ata_link *link, unsigned long deadline) 333 + /** 334 + * hpt374_fn1_cable_detect - Detect the cable type 335 + * @ap: ATA port to detect on 336 + * 337 + * Return the cable type attached to this port 338 + */ 339 + 340 + static int hpt374_fn1_cable_detect(struct ata_port *ap) 345 341 { 346 - static const struct pci_bits hpt37x_enable_bits[] = { 347 - { 0x50, 1, 0x04, 0x04 }, 348 - { 0x54, 1, 0x04, 0x04 } 349 - }; 350 - u16 mcr3; 351 - u8 ata66; 352 - struct ata_port *ap = link->ap; 353 342 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 354 343 unsigned int mcrbase = 0x50 + 4 * ap->port_no; 355 - 356 - if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no])) 357 - return -ENOENT; 344 + u16 mcr3; 345 + u8 ata66; 358 346 359 347 /* Do the extra channel work */ 360 348 pci_read_config_word(pdev, mcrbase + 2, &mcr3); 361 - /* Set bit 15 of 0x52 to enable TCBLID as input 362 - */ 349 + /* Set bit 15 of 0x52 to enable TCBLID as input */ 363 350 pci_write_config_word(pdev, mcrbase + 2, mcr3 | 0x8000); 364 351 pci_read_config_byte(pdev, 0x5A, &ata66); 365 352 /* Reset TCBLID/FCBLID to output */ 366 353 pci_write_config_word(pdev, mcrbase + 2, mcr3); 367 354 368 355 if (ata66 & (2 >> ap->port_no)) 369 - ap->cbl = ATA_CBL_PATA40; 356 + return ATA_CBL_PATA40; 370 357 else 371 - ap->cbl = ATA_CBL_PATA80; 358 + return ATA_CBL_PATA80; 359 + } 360 + 361 + /** 362 + * hpt37x_pre_reset - reset the hpt37x bus 363 + * @link: ATA link to reset 364 + * @deadline: deadline jiffies for the operation 365 + * 366 + * Perform the initial reset handling for the HPT37x. 367 + */ 368 + 369 + static int hpt37x_pre_reset(struct ata_link *link, unsigned long deadline) 370 + { 371 + struct ata_port *ap = link->ap; 372 + struct pci_dev *pdev = to_pci_dev(ap->host->dev); 373 + static const struct pci_bits hpt37x_enable_bits[] = { 374 + { 0x50, 1, 0x04, 0x04 }, 375 + { 0x54, 1, 0x04, 0x04 } 376 + }; 377 + if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no])) 378 + return -ENOENT; 372 379 373 380 /* Reset the state machine */ 374 381 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); ··· 411 404 412 405 pci_read_config_dword(pdev, addr1, &reg); 413 406 mode = hpt37x_find_mode(ap, adev->pio_mode); 414 - mode &= ~0x8000000; /* No FIFO in PIO */ 415 - mode &= ~0x30070000; /* Leave config bits alone */ 416 - reg &= 0x30070000; /* Strip timing bits */ 407 + mode &= 0xCFC3FFFF; /* Leave DMA bits alone */ 408 + reg &= ~0xCFC3FFFF; /* Strip timing bits */ 417 409 pci_write_config_dword(pdev, addr1, reg | mode); 418 410 } 419 411 ··· 429 423 { 430 424 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 431 425 u32 addr1, addr2; 432 - u32 reg; 433 - u32 mode; 426 + u32 reg, mode, mask; 434 427 u8 fast; 435 428 436 429 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no); ··· 441 436 fast |= 0x01; 442 437 pci_write_config_byte(pdev, addr2, fast); 443 438 439 + mask = adev->dma_mode < XFER_UDMA_0 ? 0x31C001FF : 0x303C0000; 440 + 444 441 pci_read_config_dword(pdev, addr1, &reg); 445 442 mode = hpt37x_find_mode(ap, adev->dma_mode); 446 - mode |= 0x8000000; /* FIFO in MWDMA or UDMA */ 447 - mode &= ~0xC0000000; /* Leave config bits alone */ 448 - reg &= 0xC0000000; /* Strip timing bits */ 443 + mode &= mask; 444 + reg &= ~mask; 449 445 pci_write_config_dword(pdev, addr1, reg | mode); 450 446 } 451 447 ··· 514 508 mode = hpt37x_find_mode(ap, adev->pio_mode); 515 509 516 510 printk("Find mode for %d reports %X\n", adev->pio_mode, mode); 517 - mode &= ~0x80000000; /* No FIFO in PIO */ 518 - mode &= ~0x30070000; /* Leave config bits alone */ 519 - reg &= 0x30070000; /* Strip timing bits */ 511 + mode &= 0xCFC3FFFF; /* Leave DMA bits alone */ 512 + reg &= ~0xCFC3FFFF; /* Strip timing bits */ 520 513 pci_write_config_dword(pdev, addr1, reg | mode); 521 514 } 522 515 ··· 532 527 { 533 528 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 534 529 u32 addr1, addr2; 535 - u32 reg; 536 - u32 mode; 530 + u32 reg, mode, mask; 537 531 u8 fast; 538 532 539 533 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no); ··· 543 539 fast &= ~0x07; 544 540 pci_write_config_byte(pdev, addr2, fast); 545 541 542 + mask = adev->dma_mode < XFER_UDMA_0 ? 0x31C001FF : 0x303C0000; 543 + 546 544 pci_read_config_dword(pdev, addr1, &reg); 547 545 mode = hpt37x_find_mode(ap, adev->dma_mode); 548 546 printk("Find mode for DMA %d reports %X\n", adev->dma_mode, mode); 549 - mode &= ~0xC0000000; /* Leave config bits alone */ 550 - mode |= 0x80000000; /* FIFO in MWDMA or UDMA */ 551 - reg &= 0xC0000000; /* Strip timing bits */ 547 + mode &= mask; 548 + reg &= ~mask; 552 549 pci_write_config_dword(pdev, addr1, reg | mode); 553 550 } 554 551 ··· 589 584 .bmdma_stop = hpt370_bmdma_stop, 590 585 591 586 .mode_filter = hpt370_filter, 587 + .cable_detect = hpt37x_cable_detect, 592 588 .set_piomode = hpt370_set_piomode, 593 589 .set_dmamode = hpt370_set_dmamode, 594 590 .prereset = hpt37x_pre_reset, ··· 614 608 615 609 .bmdma_stop = hpt37x_bmdma_stop, 616 610 611 + .cable_detect = hpt37x_cable_detect, 617 612 .set_piomode = hpt372_set_piomode, 618 613 .set_dmamode = hpt372_set_dmamode, 619 614 .prereset = hpt37x_pre_reset, ··· 627 620 628 621 static struct ata_port_operations hpt374_fn1_port_ops = { 629 622 .inherits = &hpt372_port_ops, 630 - .prereset = hpt374_fn1_pre_reset, 623 + .cable_detect = hpt374_fn1_cable_detect, 624 + .prereset = hpt37x_pre_reset, 631 625 }; 632 626 633 627 /** ··· 799 791 static const int MHz[4] = { 33, 40, 50, 66 }; 800 792 void *private_data = NULL; 801 793 const struct ata_port_info *ppi[] = { NULL, NULL }; 802 - 794 + u8 rev = dev->revision; 803 795 u8 irqmask; 804 - u32 class_rev; 805 796 u8 mcr1; 806 797 u32 freq; 807 798 int prefer_dpll = 1; ··· 815 808 if (rc) 816 809 return rc; 817 810 818 - pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); 819 - class_rev &= 0xFF; 820 - 821 811 if (dev->device == PCI_DEVICE_ID_TTI_HPT366) { 822 812 /* May be a later chip in disguise. Check */ 823 813 /* Older chips are in the HPT366 driver. Ignore them */ 824 - if (class_rev < 3) 814 + if (rev < 3) 825 815 return -ENODEV; 826 816 /* N series chips have their own driver. Ignore */ 827 - if (class_rev == 6) 817 + if (rev == 6) 828 818 return -ENODEV; 829 819 830 - switch(class_rev) { 820 + switch(rev) { 831 821 case 3: 832 822 ppi[0] = &info_hpt370; 833 823 chip_table = &hpt370; ··· 840 836 chip_table = &hpt372; 841 837 break; 842 838 default: 843 - printk(KERN_ERR "pata_hpt37x: Unknown HPT366 subtype please report (%d).\n", class_rev); 839 + printk(KERN_ERR "pata_hpt37x: Unknown HPT366 " 840 + "subtype, please report (%d).\n", rev); 844 841 return -ENODEV; 845 842 } 846 843 } else { 847 844 switch(dev->device) { 848 845 case PCI_DEVICE_ID_TTI_HPT372: 849 846 /* 372N if rev >= 2*/ 850 - if (class_rev >= 2) 847 + if (rev >= 2) 851 848 return -ENODEV; 852 849 ppi[0] = &info_hpt372; 853 850 chip_table = &hpt372a; 854 851 break; 855 852 case PCI_DEVICE_ID_TTI_HPT302: 856 853 /* 302N if rev > 1 */ 857 - if (class_rev > 1) 854 + if (rev > 1) 858 855 return -ENODEV; 859 856 ppi[0] = &info_hpt372; 860 857 /* Check this */ 861 858 chip_table = &hpt302; 862 859 break; 863 860 case PCI_DEVICE_ID_TTI_HPT371: 864 - if (class_rev > 1) 861 + if (rev > 1) 865 862 return -ENODEV; 866 863 ppi[0] = &info_hpt372; 867 864 chip_table = &hpt371;
+18 -22
drivers/ata/pata_hpt3x2n.c
··· 25 25 #include <linux/libata.h> 26 26 27 27 #define DRV_NAME "pata_hpt3x2n" 28 - #define DRV_VERSION "0.3.4" 28 + #define DRV_VERSION "0.3.7" 29 29 30 30 enum { 31 31 HPT_PCI_FAST = (1 << 31), ··· 80 80 81 81 { XFER_MW_DMA_2, 0x2c829c62 }, 82 82 { XFER_MW_DMA_1, 0x2c829c66 }, 83 - { XFER_MW_DMA_0, 0x2c829d2c }, 83 + { XFER_MW_DMA_0, 0x2c829d2e }, 84 84 85 85 { XFER_PIO_4, 0x0c829c62 }, 86 86 { XFER_PIO_3, 0x0c829c84 }, 87 87 { XFER_PIO_2, 0x0c829ca6 }, 88 88 { XFER_PIO_1, 0x0d029d26 }, 89 89 { XFER_PIO_0, 0x0d029d5e }, 90 - { 0, 0x0d029d5e } 91 90 }; 92 91 93 92 /** ··· 127 128 128 129 pci_read_config_byte(pdev, 0x5B, &scr2); 129 130 pci_write_config_byte(pdev, 0x5B, scr2 & ~0x01); 131 + 132 + udelay(10); /* debounce */ 133 + 130 134 /* Cable register now active */ 131 135 pci_read_config_byte(pdev, 0x5A, &ata66); 132 136 /* Restore state */ 133 137 pci_write_config_byte(pdev, 0x5B, scr2); 134 138 135 - if (ata66 & (1 << ap->port_no)) 139 + if (ata66 & (2 >> ap->port_no)) 136 140 return ATA_CBL_PATA40; 137 141 else 138 142 return ATA_CBL_PATA80; ··· 187 185 188 186 pci_read_config_dword(pdev, addr1, &reg); 189 187 mode = hpt3x2n_find_mode(ap, adev->pio_mode); 190 - mode &= ~0x8000000; /* No FIFO in PIO */ 191 - mode &= ~0x30070000; /* Leave config bits alone */ 192 - reg &= 0x30070000; /* Strip timing bits */ 188 + mode &= 0xCFC3FFFF; /* Leave DMA bits alone */ 189 + reg &= ~0xCFC3FFFF; /* Strip timing bits */ 193 190 pci_write_config_dword(pdev, addr1, reg | mode); 194 191 } 195 192 ··· 205 204 { 206 205 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 207 206 u32 addr1, addr2; 208 - u32 reg; 209 - u32 mode; 207 + u32 reg, mode, mask; 210 208 u8 fast; 211 209 212 210 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no); ··· 216 216 fast &= ~0x07; 217 217 pci_write_config_byte(pdev, addr2, fast); 218 218 219 + mask = adev->dma_mode < XFER_UDMA_0 ? 0x31C001FF : 0x303C0000; 220 + 219 221 pci_read_config_dword(pdev, addr1, &reg); 220 222 mode = hpt3x2n_find_mode(ap, adev->dma_mode); 221 - mode |= 0x8000000; /* FIFO in MWDMA or UDMA */ 222 - mode &= ~0xC0000000; /* Leave config bits alone */ 223 - reg &= 0xC0000000; /* Strip timing bits */ 223 + mode &= mask; 224 + reg &= ~mask; 224 225 pci_write_config_dword(pdev, addr1, reg | mode); 225 226 } 226 227 ··· 448 447 .port_ops = &hpt3x2n_port_ops 449 448 }; 450 449 const struct ata_port_info *ppi[] = { &info, NULL }; 451 - 450 + u8 rev = dev->revision; 452 451 u8 irqmask; 453 - u32 class_rev; 454 - 455 452 unsigned int pci_mhz; 456 453 unsigned int f_low, f_high; 457 454 int adjust; ··· 461 462 if (rc) 462 463 return rc; 463 464 464 - pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); 465 - class_rev &= 0xFF; 466 - 467 465 switch(dev->device) { 468 466 case PCI_DEVICE_ID_TTI_HPT366: 469 - if (class_rev < 6) 467 + if (rev < 6) 470 468 return -ENODEV; 471 469 break; 472 470 case PCI_DEVICE_ID_TTI_HPT371: 473 - if (class_rev < 2) 471 + if (rev < 2) 474 472 return -ENODEV; 475 473 /* 371N if rev > 1 */ 476 474 break; 477 475 case PCI_DEVICE_ID_TTI_HPT372: 478 476 /* 372N if rev >= 2*/ 479 - if (class_rev < 2) 477 + if (rev < 2) 480 478 return -ENODEV; 481 479 break; 482 480 case PCI_DEVICE_ID_TTI_HPT302: 483 - if (class_rev < 2) 481 + if (rev < 2) 484 482 return -ENODEV; 485 483 break; 486 484 case PCI_DEVICE_ID_TTI_HPT372N:
+10 -1
drivers/ata/pata_hpt3x3.c
··· 255 255 #ifdef CONFIG_PM 256 256 static int hpt3x3_reinit_one(struct pci_dev *dev) 257 257 { 258 + struct ata_host *host = dev_get_drvdata(&dev->dev); 259 + int rc; 260 + 261 + rc = ata_pci_device_do_resume(dev); 262 + if (rc) 263 + return rc; 264 + 258 265 hpt3x3_init_chipset(dev); 259 - return ata_pci_device_resume(dev); 266 + 267 + ata_host_resume(host); 268 + return 0; 260 269 } 261 270 #endif 262 271
+13 -14
drivers/ata/pata_it8213.c
··· 22 22 #define DRV_VERSION "0.0.3" 23 23 24 24 /** 25 - * it8213_pre_reset - check for 40/80 pin 25 + * it8213_pre_reset - probe begin 26 26 * @link: link 27 27 * @deadline: deadline jiffies for the operation 28 28 * ··· 92 92 { 2, 1 }, 93 93 { 2, 3 }, }; 94 94 95 - if (pio > 2) 96 - control |= 1; /* TIME1 enable */ 95 + if (pio > 1) 96 + control |= 1; /* TIME */ 97 97 if (ata_pio_need_iordy(adev)) /* PIO 3/4 require IORDY */ 98 - control |= 2; /* IORDY enable */ 98 + control |= 2; /* IE */ 99 99 /* Bit 2 is set for ATAPI on the IT8213 - reverse of ICH/PIIX */ 100 100 if (adev->class != ATA_DEV_ATA) 101 - control |= 4; 101 + control |= 4; /* PPE */ 102 102 103 103 pci_read_config_word(dev, idetm_port, &idetm_data); 104 104 105 - /* Enable PPE, IE and TIME as appropriate */ 106 - 105 + /* Set PPE, IE, and TIME as appropriate */ 107 106 if (adev->devno == 0) { 108 107 idetm_data &= 0xCCF0; 109 108 idetm_data |= control; ··· 111 112 } else { 112 113 u8 slave_data; 113 114 114 - idetm_data &= 0xCC0F; 115 + idetm_data &= 0xFF0F; 115 116 idetm_data |= (control << 4); 116 117 117 118 /* Slave timing in separate register */ 118 119 pci_read_config_byte(dev, 0x44, &slave_data); 119 120 slave_data &= 0xF0; 120 - slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << 4; 121 + slave_data |= (timings[pio][0] << 2) | timings[pio][1]; 121 122 pci_write_config_byte(dev, 0x44, slave_data); 122 123 } 123 124 124 - idetm_data |= 0x4000; /* Ensure SITRE is enabled */ 125 + idetm_data |= 0x4000; /* Ensure SITRE is set */ 125 126 pci_write_config_word(dev, idetm_port, idetm_data); 126 127 } 127 128 ··· 172 173 173 174 udma_enable |= (1 << devid); 174 175 175 - /* Load the UDMA mode number */ 176 + /* Load the UDMA cycle time */ 176 177 pci_read_config_word(dev, 0x4A, &udma_timing); 177 178 udma_timing &= ~(3 << (4 * devid)); 178 - udma_timing |= (udma & 3) << (4 * devid); 179 + udma_timing |= u_speed << (4 * devid); 179 180 pci_write_config_word(dev, 0x4A, udma_timing); 180 181 181 182 /* Load the clock selection */ ··· 210 211 master_data &= 0xFF4F; /* Mask out IORDY|TIME1|DMAONLY */ 211 212 master_data |= control << 4; 212 213 pci_read_config_byte(dev, 0x44, &slave_data); 213 - slave_data &= (0x0F + 0xE1 * ap->port_no); 214 + slave_data &= 0xF0; 214 215 /* Load the matching timing */ 215 216 slave_data |= ((timings[pio][0] << 2) | timings[pio][1]) << (ap->port_no ? 4 : 0); 216 217 pci_write_config_byte(dev, 0x44, slave_data); ··· 262 263 static const struct ata_port_info info = { 263 264 .flags = ATA_FLAG_SLAVE_POSS, 264 265 .pio_mask = ATA_PIO4, 265 - .mwdma_mask = ATA_MWDMA2, 266 + .mwdma_mask = ATA_MWDMA12_ONLY, 266 267 .udma_mask = ATA_UDMA4, /* FIXME: want UDMA 100? */ 267 268 .port_ops = &it8213_ops, 268 269 };
+1 -1
drivers/ata/pata_it821x.c
··· 955 955 static const struct pci_device_id it821x[] = { 956 956 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8211), }, 957 957 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8212), }, 958 - { PCI_VDEVICE(RDC, 0x1010), }, 958 + { PCI_VDEVICE(RDC, PCI_DEVICE_ID_RDC_D1010), }, 959 959 960 960 { }, 961 961 };
+11 -3
drivers/ata/pata_legacy.c
··· 25 25 * http://www.ryston.cz/petr/vlb/pdc20230b.html 26 26 * http://www.ryston.cz/petr/vlb/pdc20230c.html 27 27 * http://www.ryston.cz/petr/vlb/pdc20630.html 28 + * QDI65x0: 29 + * http://www.ryston.cz/petr/vlb/qd6500.html 30 + * http://www.ryston.cz/petr/vlb/qd6580.html 31 + * 32 + * QDI65x0 probe code based on drivers/ide/legacy/qd65xx.c 33 + * Rewritten from the work of Colten Edwards <pje120@cs.usask.ca> by 34 + * Samuel Thibault <samuel.thibault@ens-lyon.org> 28 35 * 29 36 * Unsupported but docs exist: 30 37 * Appian/Adaptec AIC25VL01/Cirrus Logic PD7220 ··· 42 35 * the MPIIX where the tuning is PCI side but the IDE is "ISA side". 43 36 * 44 37 * Specific support is included for the ht6560a/ht6560b/opti82c611a/ 45 - * opti82c465mv/promise 20230c/20630/winbond83759A 38 + * opti82c465mv/promise 20230c/20630/qdi65x0/winbond83759A 46 39 * 47 40 * Use the autospeed and pio_mask options with: 48 41 * Appian ADI/2 aka CLPD7220 or AIC25VL01. ··· 679 672 outb(timing, ld_qdi->timing + 2 * ap->port_no); 680 673 /* Clear the FIFO */ 681 674 if (adev->class != ATA_DEV_ATA) 682 - outb(0x5F, ld_qdi->timing + 3); 675 + outb(0x5F, (ld_qdi->timing & 0xFFF0) + 3); 683 676 } 684 677 685 678 /** ··· 714 707 outb(timing, ld_qdi->timing + 2 * adev->devno); 715 708 /* Clear the FIFO */ 716 709 if (adev->class != ATA_DEV_ATA) 717 - outb(0x5F, ld_qdi->timing + 3); 710 + outb(0x5F, (ld_qdi->timing & 0xFFF0) + 3); 718 711 } 719 712 720 713 /** ··· 794 787 static struct ata_port_operations qdi6580dp_port_ops = { 795 788 .inherits = &legacy_base_port_ops, 796 789 .set_piomode = qdi6580dp_set_piomode, 790 + .qc_issue = qdi_qc_issue, 797 791 .sff_data_xfer = vlb32_data_xfer, 798 792 }; 799 793
+1 -1
drivers/ata/pata_marvell.c
··· 58 58 } 59 59 60 60 /** 61 - * marvell_pre_reset - check for 40/80 pin 61 + * marvell_pre_reset - probe begin 62 62 * @link: link 63 63 * @deadline: deadline jiffies for the operation 64 64 *
+27 -5
drivers/ata/pata_ns87415.c
··· 325 325 ATA_BMDMA_SHT(DRV_NAME), 326 326 }; 327 327 328 + static void ns87415_fixup(struct pci_dev *pdev) 329 + { 330 + /* Select 512 byte sectors */ 331 + pci_write_config_byte(pdev, 0x55, 0xEE); 332 + /* Select PIO0 8bit clocking */ 333 + pci_write_config_byte(pdev, 0x54, 0xB7); 334 + } 328 335 329 336 /** 330 337 * ns87415_init_one - Register 87415 ATA PCI device with kernel services ··· 378 371 if (rc) 379 372 return rc; 380 373 381 - /* Select 512 byte sectors */ 382 - pci_write_config_byte(pdev, 0x55, 0xEE); 383 - /* Select PIO0 8bit clocking */ 384 - pci_write_config_byte(pdev, 0x54, 0xB7); 374 + ns87415_fixup(pdev); 375 + 385 376 return ata_pci_sff_init_one(pdev, ppi, &ns87415_sht, NULL); 386 377 } 387 378 ··· 389 384 { } /* terminate list */ 390 385 }; 391 386 387 + #ifdef CONFIG_PM 388 + static int ns87415_reinit_one(struct pci_dev *pdev) 389 + { 390 + struct ata_host *host = dev_get_drvdata(&pdev->dev); 391 + int rc; 392 + 393 + rc = ata_pci_device_do_resume(pdev); 394 + if (rc) 395 + return rc; 396 + 397 + ns87415_fixup(pdev); 398 + 399 + ata_host_resume(host); 400 + return 0; 401 + } 402 + #endif 403 + 392 404 static struct pci_driver ns87415_pci_driver = { 393 405 .name = DRV_NAME, 394 406 .id_table = ns87415_pci_tbl, ··· 413 391 .remove = ata_pci_remove_one, 414 392 #ifdef CONFIG_PM 415 393 .suspend = ata_pci_device_suspend, 416 - .resume = ata_pci_device_resume, 394 + .resume = ns87415_reinit_one, 417 395 #endif 418 396 }; 419 397
+1 -1
drivers/ata/pata_oldpiix.c
··· 239 239 static const struct ata_port_info info = { 240 240 .flags = ATA_FLAG_SLAVE_POSS, 241 241 .pio_mask = ATA_PIO4, 242 - .mwdma_mask = ATA_MWDMA2, 242 + .mwdma_mask = ATA_MWDMA12_ONLY, 243 243 .port_ops = &oldpiix_pata_ops, 244 244 }; 245 245 const struct ata_port_info *ppi[] = { &info, NULL };
+140
drivers/ata/pata_piccolo.c
··· 1 + /* 2 + * pata_piccolo.c - Toshiba Piccolo PATA/SATA controller driver. 3 + * 4 + * This is basically an update to ata_generic.c to add Toshiba Piccolo support 5 + * then split out to keep ata_generic "clean". 6 + * 7 + * Copyright 2005 Red Hat Inc, all rights reserved. 8 + * 9 + * Elements from ide/pci/generic.c 10 + * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org> 11 + * Portions (C) Copyright 2002 Red Hat Inc <alan@redhat.com> 12 + * 13 + * May be copied or modified under the terms of the GNU General Public License 14 + * 15 + * The timing data tables/programming info are courtesy of the NetBSD driver 16 + */ 17 + 18 + #include <linux/kernel.h> 19 + #include <linux/module.h> 20 + #include <linux/pci.h> 21 + #include <linux/init.h> 22 + #include <linux/blkdev.h> 23 + #include <linux/delay.h> 24 + #include <scsi/scsi_host.h> 25 + #include <linux/libata.h> 26 + 27 + #define DRV_NAME "pata_piccolo" 28 + #define DRV_VERSION "0.0.1" 29 + 30 + 31 + 32 + static void tosh_set_piomode(struct ata_port *ap, struct ata_device *adev) 33 + { 34 + static const u16 pio[6] = { /* For reg 0x50 low word & E088 */ 35 + 0x0566, 0x0433, 0x0311, 0x0201, 0x0200, 0x0100 36 + }; 37 + struct pci_dev *pdev = to_pci_dev(ap->host->dev); 38 + u16 conf; 39 + pci_read_config_word(pdev, 0x50, &conf); 40 + conf &= 0xE088; 41 + conf |= pio[adev->pio_mode - XFER_PIO_0]; 42 + pci_write_config_word(pdev, 0x50, conf); 43 + } 44 + 45 + static void tosh_set_dmamode(struct ata_port *ap, struct ata_device *adev) 46 + { 47 + struct pci_dev *pdev = to_pci_dev(ap->host->dev); 48 + u32 conf; 49 + pci_read_config_dword(pdev, 0x5C, &conf); 50 + conf &= 0x78FFE088; /* Keep the other bits */ 51 + if (adev->dma_mode >= XFER_UDMA_0) { 52 + int udma = adev->dma_mode - XFER_UDMA_0; 53 + conf |= 0x80000000; 54 + conf |= (udma + 2) << 28; 55 + conf |= (2 - udma) * 0x111; /* spread into three nibbles */ 56 + } else { 57 + static const u32 mwdma[4] = { 58 + 0x0655, 0x0200, 0x0200, 0x0100 59 + }; 60 + conf |= mwdma[adev->dma_mode - XFER_MW_DMA_0]; 61 + } 62 + pci_write_config_dword(pdev, 0x5C, conf); 63 + } 64 + 65 + 66 + static struct scsi_host_template tosh_sht = { 67 + ATA_BMDMA_SHT(DRV_NAME), 68 + }; 69 + 70 + static struct ata_port_operations tosh_port_ops = { 71 + .inherits = &ata_bmdma_port_ops, 72 + .cable_detect = ata_cable_unknown, 73 + .set_piomode = tosh_set_piomode, 74 + .set_dmamode = tosh_set_dmamode 75 + }; 76 + 77 + /** 78 + * ata_tosh_init - attach generic IDE 79 + * @dev: PCI device found 80 + * @id: match entry 81 + * 82 + * Called each time a matching IDE interface is found. We check if the 83 + * interface is one we wish to claim and if so we perform any chip 84 + * specific hacks then let the ATA layer do the heavy lifting. 85 + */ 86 + 87 + static int ata_tosh_init_one(struct pci_dev *dev, const struct pci_device_id *id) 88 + { 89 + static const struct ata_port_info info = { 90 + .flags = ATA_FLAG_SLAVE_POSS, 91 + .pio_mask = ATA_PIO5, 92 + .mwdma_mask = ATA_MWDMA2, 93 + .udma_mask = ATA_UDMA2, 94 + .port_ops = &tosh_port_ops 95 + }; 96 + const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; 97 + /* Just one port for the moment */ 98 + return ata_pci_sff_init_one(dev, ppi, &tosh_sht, NULL); 99 + } 100 + 101 + static struct pci_device_id ata_tosh[] = { 102 + { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), }, 103 + { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), }, 104 + { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_3), }, 105 + { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_5), }, 106 + { 0, }, 107 + }; 108 + 109 + static struct pci_driver ata_tosh_pci_driver = { 110 + .name = DRV_NAME, 111 + .id_table = ata_tosh, 112 + .probe = ata_tosh_init_one, 113 + .remove = ata_pci_remove_one, 114 + #ifdef CONFIG_PM 115 + .suspend = ata_pci_device_suspend, 116 + .resume = ata_pci_device_resume, 117 + #endif 118 + }; 119 + 120 + static int __init ata_tosh_init(void) 121 + { 122 + return pci_register_driver(&ata_tosh_pci_driver); 123 + } 124 + 125 + 126 + static void __exit ata_tosh_exit(void) 127 + { 128 + pci_unregister_driver(&ata_tosh_pci_driver); 129 + } 130 + 131 + 132 + MODULE_AUTHOR("Alan Cox"); 133 + MODULE_DESCRIPTION("Low level driver for Toshiba Piccolo ATA"); 134 + MODULE_LICENSE("GPL"); 135 + MODULE_DEVICE_TABLE(pci, ata_tosh); 136 + MODULE_VERSION(DRV_VERSION); 137 + 138 + module_init(ata_tosh_init); 139 + module_exit(ata_tosh_exit); 140 +
+2 -2
drivers/ata/pata_radisys.c
··· 139 139 pci_read_config_byte(dev, 0x4A, &udma_mode); 140 140 141 141 if (adev->xfer_mode == XFER_UDMA_2) 142 - udma_mode &= ~ (1 << adev->devno); 142 + udma_mode &= ~(2 << (adev->devno * 4)); 143 143 else /* UDMA 4 */ 144 - udma_mode |= (1 << adev->devno); 144 + udma_mode |= (2 << (adev->devno * 4)); 145 145 146 146 pci_write_config_byte(dev, 0x4A, udma_mode); 147 147
+1 -1
drivers/ata/pata_rdc.c
··· 284 284 285 285 .flags = ATA_FLAG_SLAVE_POSS, 286 286 .pio_mask = ATA_PIO4, 287 - .mwdma_mask = ATA_MWDMA2, 287 + .mwdma_mask = ATA_MWDMA12_ONLY, 288 288 .udma_mask = ATA_UDMA5, 289 289 .port_ops = &rdc_pata_ops, 290 290 };
+10 -1
drivers/ata/pata_rz1000.c
··· 105 105 #ifdef CONFIG_PM 106 106 static int rz1000_reinit_one(struct pci_dev *pdev) 107 107 { 108 + struct ata_host *host = dev_get_drvdata(&pdev->dev); 109 + int rc; 110 + 111 + rc = ata_pci_device_do_resume(pdev); 112 + if (rc) 113 + return rc; 114 + 108 115 /* If this fails on resume (which is a "cant happen" case), we 109 116 must stop as any progress risks data loss */ 110 117 if (rz1000_fifo_disable(pdev)) 111 118 panic("rz1000 fifo"); 112 - return ata_pci_device_resume(pdev); 119 + 120 + ata_host_resume(host); 121 + return 0; 113 122 } 114 123 #endif 115 124
+2 -4
drivers/ata/pata_sil680.c
··· 212 212 213 213 static u8 sil680_init_chip(struct pci_dev *pdev, int *try_mmio) 214 214 { 215 - u32 class_rev = 0; 216 215 u8 tmpbyte = 0; 217 216 218 - pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev); 219 - class_rev &= 0xff; 220 217 /* FIXME: double check */ 221 - pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, (class_rev) ? 1 : 255); 218 + pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 219 + pdev->revision ? 1 : 255); 222 220 223 221 pci_write_config_byte(pdev, 0x80, 0x00); 224 222 pci_write_config_byte(pdev, 0x84, 0x00);
+19 -2
drivers/ata/pata_sis.c
··· 2 2 * pata_sis.c - SiS ATA driver 3 3 * 4 4 * (C) 2005 Red Hat 5 - * (C) 2007 Bartlomiej Zolnierkiewicz 5 + * (C) 2007,2009 Bartlomiej Zolnierkiewicz 6 6 * 7 7 * Based upon linux/drivers/ide/pci/sis5513.c 8 8 * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org> ··· 829 829 return ata_pci_sff_init_one(pdev, ppi, &sis_sht, chipset); 830 830 } 831 831 832 + #ifdef CONFIG_PM 833 + static int sis_reinit_one(struct pci_dev *pdev) 834 + { 835 + struct ata_host *host = dev_get_drvdata(&pdev->dev); 836 + int rc; 837 + 838 + rc = ata_pci_device_do_resume(pdev); 839 + if (rc) 840 + return rc; 841 + 842 + sis_fixup(pdev, host->private_data); 843 + 844 + ata_host_resume(host); 845 + return 0; 846 + } 847 + #endif 848 + 832 849 static const struct pci_device_id sis_pci_tbl[] = { 833 850 { PCI_VDEVICE(SI, 0x5513), }, /* SiS 5513 */ 834 851 { PCI_VDEVICE(SI, 0x5518), }, /* SiS 5518 */ ··· 861 844 .remove = ata_pci_remove_one, 862 845 #ifdef CONFIG_PM 863 846 .suspend = ata_pci_device_suspend, 864 - .resume = ata_pci_device_resume, 847 + .resume = sis_reinit_one, 865 848 #endif 866 849 }; 867 850
+45 -13
drivers/ata/pata_via.c
··· 303 303 } 304 304 305 305 /* Set UDMA unless device is not UDMA capable */ 306 - if (udma_type && t.udma) { 307 - u8 cable80_status; 306 + if (udma_type) { 307 + u8 udma_etc; 308 308 309 - /* Get 80-wire cable detection bit */ 310 - pci_read_config_byte(pdev, 0x50 + offset, &cable80_status); 311 - cable80_status &= 0x10; 309 + pci_read_config_byte(pdev, 0x50 + offset, &udma_etc); 312 310 313 - pci_write_config_byte(pdev, 0x50 + offset, ut | cable80_status); 311 + /* clear transfer mode bit */ 312 + udma_etc &= ~0x20; 313 + 314 + if (t.udma) { 315 + /* preserve 80-wire cable detection bit */ 316 + udma_etc &= 0x10; 317 + udma_etc |= ut; 318 + } 319 + 320 + pci_write_config_byte(pdev, 0x50 + offset, udma_etc); 314 321 } 315 322 } 316 323 ··· 341 334 static u8 udma[5] = { 0, 33, 66, 100, 133 }; 342 335 343 336 via_do_set_mode(ap, adev, adev->dma_mode, tclock[mode], set_ast, udma[mode]); 337 + } 338 + 339 + /** 340 + * via_mode_filter - filter buggy device/mode pairs 341 + * @dev: ATA device 342 + * @mask: Mode bitmask 343 + * 344 + * We need to apply some minimal filtering for old controllers and at least 345 + * one breed of Transcend SSD. Return the updated mask. 346 + */ 347 + 348 + static unsigned long via_mode_filter(struct ata_device *dev, unsigned long mask) 349 + { 350 + struct ata_host *host = dev->link->ap->host; 351 + const struct via_isa_bridge *config = host->private_data; 352 + unsigned char model_num[ATA_ID_PROD_LEN + 1]; 353 + 354 + if (config->id == PCI_DEVICE_ID_VIA_82C586_0) { 355 + ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num)); 356 + if (strcmp(model_num, "TS64GSSD25-M") == 0) { 357 + ata_dev_printk(dev, KERN_WARNING, 358 + "disabling UDMA mode due to reported lockups with this device.\n"); 359 + mask &= ~ ATA_MASK_UDMA; 360 + } 361 + } 362 + return ata_bmdma_mode_filter(dev, mask); 344 363 } 345 364 346 365 /** ··· 460 427 .prereset = via_pre_reset, 461 428 .sff_tf_load = via_tf_load, 462 429 .port_start = via_port_start, 430 + .mode_filter = via_mode_filter, 463 431 }; 464 432 465 433 static struct ata_port_operations via_port_ops_noirq = { ··· 560 526 .port_ops = &via_port_ops 561 527 }; 562 528 const struct ata_port_info *ppi[] = { NULL, NULL }; 563 - struct pci_dev *isa = NULL; 529 + struct pci_dev *isa; 564 530 const struct via_isa_bridge *config; 565 531 static int printed_version; 566 532 u8 enable; ··· 585 551 if ((isa = pci_get_device(PCI_VENDOR_ID_VIA + 586 552 !!(config->flags & VIA_BAD_ID), 587 553 config->id, NULL))) { 588 - 589 - if (isa->revision >= config->rev_min && 590 - isa->revision <= config->rev_max) 591 - break; 554 + u8 rev = isa->revision; 592 555 pci_dev_put(isa); 593 - } 594 556 595 - pci_dev_put(isa); 557 + if (rev >= config->rev_min && rev <= config->rev_max) 558 + break; 559 + } 596 560 597 561 if (!(config->flags & VIA_NO_ENABLES)) { 598 562 /* 0x40 low bits indicate enabled channels */
+10 -8
drivers/ata/sata_fsl.c
··· 34 34 35 35 SATA_FSL_HOST_FLAGS = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 36 36 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | 37 - ATA_FLAG_PMP | ATA_FLAG_NCQ), 37 + ATA_FLAG_PMP | ATA_FLAG_NCQ | ATA_FLAG_AN), 38 38 39 39 SATA_FSL_MAX_CMDS = SATA_FSL_QUEUE_DEPTH, 40 40 SATA_FSL_CMD_HDR_SIZE = 16, /* 4 DWORDS */ ··· 132 132 INT_ON_SINGL_DEVICE_ERR = (1 << 1), 133 133 INT_ON_CMD_COMPLETE = 1, 134 134 135 - INT_ON_ERROR = INT_ON_FATAL_ERR | 135 + INT_ON_ERROR = INT_ON_FATAL_ERR | INT_ON_SNOTIFY_UPDATE | 136 136 INT_ON_PHYRDY_CHG | INT_ON_SINGL_DEVICE_ERR, 137 137 138 138 /* ··· 153 153 IE_ON_CMD_COMPLETE = 1, 154 154 155 155 DEFAULT_PORT_IRQ_ENABLE_MASK = IE_ON_FATAL_ERR | IE_ON_PHYRDY_CHG | 156 - IE_ON_SIGNATURE_UPDATE | 156 + IE_ON_SIGNATURE_UPDATE | IE_ON_SNOTIFY_UPDATE | 157 157 IE_ON_SINGL_DEVICE_ERR | IE_ON_CMD_COMPLETE, 158 158 159 159 EXT_INDIRECT_SEG_PRD_FLAG = (1 << 31), ··· 992 992 */ 993 993 994 994 sata_fsl_scr_read(&ap->link, SCR_ERROR, &SError); 995 - if (unlikely(SError & 0xFFFF0000)) { 995 + if (unlikely(SError & 0xFFFF0000)) 996 996 sata_fsl_scr_write(&ap->link, SCR_ERROR, SError); 997 - } 998 997 999 998 DPRINTK("error_intr,hStat=0x%x,CE=0x%x,DE =0x%x,SErr=0x%x\n", 1000 999 hstatus, cereg, ioread32(hcr_base + DE), SError); ··· 1005 1006 1006 1007 freeze = 1; 1007 1008 } 1009 + 1010 + /* Handle SDB FIS receive & notify update */ 1011 + if (hstatus & INT_ON_SNOTIFY_UPDATE) 1012 + sata_async_notification(ap); 1008 1013 1009 1014 /* Handle PHYRDY change notification */ 1010 1015 if (hstatus & INT_ON_PHYRDY_CHG) { ··· 1073 1070 } 1074 1071 1075 1072 /* record error info */ 1076 - if (qc) { 1073 + if (qc) 1077 1074 qc->err_mask |= err_mask; 1078 - } else 1075 + else 1079 1076 ehi->err_mask |= err_mask; 1080 1077 1081 1078 ehi->action |= action; ··· 1106 1103 if (unlikely(SError & 0xFFFF0000)) { 1107 1104 DPRINTK("serror @host_intr : 0x%x\n", SError); 1108 1105 sata_fsl_error_intr(ap); 1109 - 1110 1106 } 1111 1107 1112 1108 if (unlikely(hstatus & INT_ON_ERROR)) {
+1 -1
drivers/ata/sata_mv.c
··· 2217 2217 int err = 0; 2218 2218 2219 2219 ata_tf_to_fis(&qc->tf, link->pmp, 1, (void *)fis); 2220 - err = mv_send_fis(ap, fis, sizeof(fis) / sizeof(fis[0])); 2220 + err = mv_send_fis(ap, fis, ARRAY_SIZE(fis)); 2221 2221 if (err) 2222 2222 return err; 2223 2223
+9
drivers/ata/sata_sil24.c
··· 417 417 #endif 418 418 }; 419 419 420 + static int sata_sil24_msi; /* Disable MSI */ 421 + module_param_named(msi, sata_sil24_msi, bool, S_IRUGO); 422 + MODULE_PARM_DESC(msi, "Enable MSI (Default: false)"); 423 + 420 424 /* 421 425 * Use bits 30-31 of port_flags to encode available port numbers. 422 426 * Current maxium is 4. ··· 1343 1339 pcie_set_readrq(pdev, 4096); 1344 1340 1345 1341 sil24_init_controller(host); 1342 + 1343 + if (sata_sil24_msi && !pci_enable_msi(pdev)) { 1344 + dev_printk(KERN_INFO, &pdev->dev, "Using MSI\n"); 1345 + pci_intx(pdev, 0); 1346 + } 1346 1347 1347 1348 pci_set_master(pdev); 1348 1349 return ata_host_activate(host, pdev->irq, sil24_interrupt, IRQF_SHARED,
+2 -1
drivers/ide/ide-pci-generic.c
··· 162 162 #ifdef CONFIG_BLK_DEV_IDE_SATA 163 163 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8237_SATA), 5 }, 164 164 #endif 165 - { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO), 4 }, 166 165 { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), 4 }, 167 166 { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), 4 }, 167 + { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_3), 4 }, 168 + { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_5), 4 }, 168 169 { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), 6 }, 169 170 /* 170 171 * Must come last. If you add entries adjust
+34 -10
include/linux/ata.h
··· 75 75 ATA_ID_EIDE_DMA_TIME = 66, 76 76 ATA_ID_EIDE_PIO = 67, 77 77 ATA_ID_EIDE_PIO_IORDY = 68, 78 + ATA_ID_ADDITIONAL_SUPP = 69, 78 79 ATA_ID_QUEUE_DEPTH = 75, 79 80 ATA_ID_MAJOR_VER = 80, 80 81 ATA_ID_COMMAND_SET_1 = 82, ··· 88 87 ATA_ID_HW_CONFIG = 93, 89 88 ATA_ID_SPG = 98, 90 89 ATA_ID_LBA_CAPACITY_2 = 100, 90 + ATA_ID_SECTOR_SIZE = 106, 91 91 ATA_ID_LAST_LUN = 126, 92 92 ATA_ID_DLF = 128, 93 93 ATA_ID_CSFO = 129, ··· 640 638 return (id[ATA_ID_CFS_ENABLE_2] & 0x2400) == 0x2400; 641 639 } 642 640 641 + static inline int ata_id_has_large_logical_sectors(const u16 *id) 642 + { 643 + if ((id[ATA_ID_SECTOR_SIZE] & 0xc000) != 0x4000) 644 + return 0; 645 + return id[ATA_ID_SECTOR_SIZE] & (1 << 13); 646 + } 647 + 648 + static inline u8 ata_id_logical_per_physical_sectors(const u16 *id) 649 + { 650 + return id[ATA_ID_SECTOR_SIZE] & 0xf; 651 + } 652 + 643 653 static inline int ata_id_has_lba48(const u16 *id) 644 654 { 645 655 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) ··· 817 803 return 0; 818 804 } 819 805 806 + static inline int ata_id_has_zero_after_trim(const u16 *id) 807 + { 808 + /* DSM supported, deterministic read, and read zero after trim set */ 809 + if (ata_id_has_trim(id) && 810 + (id[ATA_ID_ADDITIONAL_SUPP] & 0x4020) == 0x4020) 811 + return 1; 812 + 813 + return 0; 814 + } 815 + 820 816 static inline int ata_id_current_chs_valid(const u16 *id) 821 817 { 822 818 /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command ··· 982 958 } 983 959 984 960 /* 985 - * Write up to 'max' LBA Range Entries to the buffer that will cover the 986 - * extent from sector to sector + count. This is used for TRIM and for 987 - * ADD LBA(S) TO NV CACHE PINNED SET. 961 + * Write LBA Range Entries to the buffer that will cover the extent from 962 + * sector to sector + count. This is used for TRIM and for ADD LBA(S) 963 + * TO NV CACHE PINNED SET. 988 964 */ 989 - static inline unsigned ata_set_lba_range_entries(void *_buffer, unsigned max, 990 - u64 sector, unsigned long count) 965 + static inline unsigned ata_set_lba_range_entries(void *_buffer, 966 + unsigned buf_size, u64 sector, unsigned long count) 991 967 { 992 968 __le64 *buffer = _buffer; 993 - unsigned i = 0; 969 + unsigned i = 0, used_bytes; 994 970 995 - while (i < max) { 971 + while (i < buf_size / 8 ) { /* 6-byte LBA + 2-byte range per entry */ 996 972 u64 entry = sector | 997 973 ((u64)(count > 0xffff ? 0xffff : count) << 48); 998 974 buffer[i++] = __cpu_to_le64(entry); ··· 1002 978 sector += 0xffff; 1003 979 } 1004 980 1005 - max = ALIGN(i * 8, 512); 1006 - memset(buffer + i, 0, max - i * 8); 1007 - return max; 981 + used_bytes = ALIGN(i * 8, 512); 982 + memset(buffer + i, 0, used_bytes - i * 8); 983 + return used_bytes; 1008 984 } 1009 985 1010 986 static inline int is_multi_taskfile(struct ata_taskfile *tf)
+2 -1
include/linux/libata.h
··· 365 365 /* This should match the actual table size of 366 366 * ata_eh_cmd_timeout_table in libata-eh.c. 367 367 */ 368 - ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 5, 368 + ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 6, 369 369 370 370 /* Horkage types. May be set by libata or controller on drives 371 371 (some horkage may be drive/controller pair dependant */ ··· 595 595 unsigned int horkage; /* List of broken features */ 596 596 unsigned long flags; /* ATA_DFLAG_xxx */ 597 597 struct scsi_device *sdev; /* attached SCSI device */ 598 + void *private_data; 598 599 #ifdef CONFIG_ATA_ACPI 599 600 acpi_handle acpi_handle; 600 601 union acpi_object *gtf_cache;
+4 -3
include/linux/pci_ids.h
··· 1496 1496 #define PCI_DEVICE_ID_SBE_WANXL400 0x0104 1497 1497 1498 1498 #define PCI_VENDOR_ID_TOSHIBA 0x1179 1499 - #define PCI_DEVICE_ID_TOSHIBA_PICCOLO 0x0102 1500 - #define PCI_DEVICE_ID_TOSHIBA_PICCOLO_1 0x0103 1501 - #define PCI_DEVICE_ID_TOSHIBA_PICCOLO_2 0x0105 1499 + #define PCI_DEVICE_ID_TOSHIBA_PICCOLO_1 0x0101 1500 + #define PCI_DEVICE_ID_TOSHIBA_PICCOLO_2 0x0102 1501 + #define PCI_DEVICE_ID_TOSHIBA_PICCOLO_3 0x0103 1502 + #define PCI_DEVICE_ID_TOSHIBA_PICCOLO_5 0x0105 1502 1503 #define PCI_DEVICE_ID_TOSHIBA_TOPIC95 0x060a 1503 1504 #define PCI_DEVICE_ID_TOSHIBA_TOPIC97 0x060f 1504 1505 #define PCI_DEVICE_ID_TOSHIBA_TOPIC100 0x0617