aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-05-10 15:41:34 -0400
committerJeff Garzik <jgarzik@redhat.com>2010-05-19 13:32:19 -0400
commitc7087652e1890a3feef35b30ee1d4be68e1932cd (patch)
tree04aeca0f44e87a531d7cb5f894b6790391c2c552 /drivers
parent8930ff254a3a80d4477c3391ade07d6dd2a036c7 (diff)
libata-sff: clean up BMDMA initialization
When BMDMA initialization failed or BMDMA was not available for whatever reason, bmdma_addr was left at zero and used as an indication that BMDMA shouldn't be used. This leads to the following problems. p1. For BMDMA drivers which don't use traditional BMDMA register, ata_bmdma_mode_filter() incorrectly inhibits DMA modes. Those drivers either have to inherit from ata_sff_port_ops or clear ->mode_filter explicitly. p2. non-BMDMA drivers call into BMDMA PRD table allocation. It doesn't actually allocate PRD table if bmdma_addr is not initialized but is still confusing. p3. For BMDMA drivers which don't use traditional BMDMA register, some methods might not be invoked as expected (e.g. bmdma_stop from ata_sff_post_internal_cmd()). p4. SFF drivers w/ custom DMA interface implement noop BMDMA ops worrying libata core might call into one of them. These problems are caused by the muddy line between SFF and BMDMA and the assumption that all BMDMA controllers initialize bmdma_addr. This patch fixes p1 and p2 by removing the bmdma_addr assumption and moving prd allocation to BMDMA port start. Later patches will fix the remaining issues. This patch improves BMDMA initialization such that * When BMDMA register initialization fails, falls back to PIO instead of failing. ata_pci_bmdma_init() never fails now. * When ata_pci_bmdma_init() falls back to PIO, it clears ap->mwdma_mask and udma_mask instead of depending on ata_bmdma_mode_filter(). This makes ata_bmdma_mode_filter() unnecessary thus resolving p1. * ata_port_start() which actually is BMDMA specific is moved to ata_bmdma_port_start(). ata_port_start() and ata_sff_port_start() are killed. * ata_sff_port_start32() is moved and renamed to ata_bmdma_port_start32(). Drivers which no longer call into PRD table allocation are... pdc_adma, sata_inic162x, sata_qstor, sata_sx4, pata_cmd640 and all drivers which inherit from ata_sff_port_ops. pata_icside sets ->port_start to ATA_OP_NULL as it doesn't need PRD but is a BMDMA controller and doesn't have custom port_start like other such controllers. Note that with the previous patch which makes all and only BMDMA drivers inherit from ata_bmdma_port_ops, this change doesn't break drivers which need PRD table. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/libata-core.c25
-rw-r--r--drivers/ata/libata-sff.c170
-rw-r--r--drivers/ata/pata_acpi.c4
-rw-r--r--drivers/ata/pata_ali.c2
-rw-r--r--drivers/ata/pata_at91.c1
-rw-r--r--drivers/ata/pata_bf54x.c2
-rw-r--r--drivers/ata/pata_cmd640.c6
-rw-r--r--drivers/ata/pata_hpt366.c2
-rw-r--r--drivers/ata/pata_hpt37x.c4
-rw-r--r--drivers/ata/pata_icside.c2
-rw-r--r--drivers/ata/pata_it821x.c2
-rw-r--r--drivers/ata/pata_macio.c2
-rw-r--r--drivers/ata/pata_pdc2027x.c4
-rw-r--r--drivers/ata/pata_pdc202xx_old.c2
-rw-r--r--drivers/ata/pata_platform.c1
-rw-r--r--drivers/ata/pata_scc.c6
-rw-r--r--drivers/ata/pata_serverworks.c6
-rw-r--r--drivers/ata/pata_via.c4
-rw-r--r--drivers/ata/pdc_adma.c4
-rw-r--r--drivers/ata/sata_inic162x.c5
-rw-r--r--drivers/ata/sata_mv.c2
-rw-r--r--drivers/ata/sata_nv.c6
-rw-r--r--drivers/ata/sata_promise.c3
-rw-r--r--drivers/ata/sata_qstor.c4
-rw-r--r--drivers/ata/sata_sx4.c5
-rw-r--r--drivers/ata/sata_uli.c4
26 files changed, 113 insertions, 165 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 3d8b62f7441c..cc49a0d3089f 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -5506,30 +5506,6 @@ void ata_host_resume(struct ata_host *host)
5506#endif 5506#endif
5507 5507
5508/** 5508/**
5509 * ata_port_start - Set port up for dma.
5510 * @ap: Port to initialize
5511 *
5512 * Called just after data structures for each port are
5513 * initialized. Allocates space for PRD table.
5514 *
5515 * May be used as the port_start() entry in ata_port_operations.
5516 *
5517 * LOCKING:
5518 * Inherited from caller.
5519 */
5520int ata_port_start(struct ata_port *ap)
5521{
5522 struct device *dev = ap->dev;
5523
5524 ap->prd = dmam_alloc_coherent(dev, ATA_PRD_TBL_SZ, &ap->prd_dma,
5525 GFP_KERNEL);
5526 if (!ap->prd)
5527 return -ENOMEM;
5528
5529 return 0;
5530}
5531
5532/**
5533 * ata_dev_init - Initialize an ata_device structure 5509 * ata_dev_init - Initialize an ata_device structure
5534 * @dev: Device structure to initialize 5510 * @dev: Device structure to initialize
5535 * 5511 *
@@ -6757,7 +6733,6 @@ EXPORT_SYMBOL_GPL(ata_xfer_mode2mask);
6757EXPORT_SYMBOL_GPL(ata_xfer_mode2shift); 6733EXPORT_SYMBOL_GPL(ata_xfer_mode2shift);
6758EXPORT_SYMBOL_GPL(ata_mode_string); 6734EXPORT_SYMBOL_GPL(ata_mode_string);
6759EXPORT_SYMBOL_GPL(ata_id_xfermask); 6735EXPORT_SYMBOL_GPL(ata_id_xfermask);
6760EXPORT_SYMBOL_GPL(ata_port_start);
6761EXPORT_SYMBOL_GPL(ata_do_set_mode); 6736EXPORT_SYMBOL_GPL(ata_do_set_mode);
6762EXPORT_SYMBOL_GPL(ata_std_qc_defer); 6737EXPORT_SYMBOL_GPL(ata_std_qc_defer);
6763EXPORT_SYMBOL_GPL(ata_noop_qc_prep); 6738EXPORT_SYMBOL_GPL(ata_noop_qc_prep);
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 6400e8751391..f1c99a3e8b2c 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -66,8 +66,6 @@ const struct ata_port_operations ata_sff_port_ops = {
66 .sff_irq_clear = ata_sff_irq_clear, 66 .sff_irq_clear = ata_sff_irq_clear,
67 67
68 .lost_interrupt = ata_sff_lost_interrupt, 68 .lost_interrupt = ata_sff_lost_interrupt,
69
70 .port_start = ata_sff_port_start,
71}; 69};
72EXPORT_SYMBOL_GPL(ata_sff_port_ops); 70EXPORT_SYMBOL_GPL(ata_sff_port_ops);
73 71
@@ -2444,50 +2442,6 @@ void ata_sff_post_internal_cmd(struct ata_queued_cmd *qc)
2444EXPORT_SYMBOL_GPL(ata_sff_post_internal_cmd); 2442EXPORT_SYMBOL_GPL(ata_sff_post_internal_cmd);
2445 2443
2446/** 2444/**
2447 * ata_sff_port_start - Set port up for dma.
2448 * @ap: Port to initialize
2449 *
2450 * Called just after data structures for each port are
2451 * initialized. Allocates space for PRD table if the device
2452 * is DMA capable SFF.
2453 *
2454 * May be used as the port_start() entry in ata_port_operations.
2455 *
2456 * LOCKING:
2457 * Inherited from caller.
2458 */
2459int ata_sff_port_start(struct ata_port *ap)
2460{
2461 if (ap->ioaddr.bmdma_addr)
2462 return ata_port_start(ap);
2463 return 0;
2464}
2465EXPORT_SYMBOL_GPL(ata_sff_port_start);
2466
2467/**
2468 * ata_sff_port_start32 - Set port up for dma.
2469 * @ap: Port to initialize
2470 *
2471 * Called just after data structures for each port are
2472 * initialized. Allocates space for PRD table if the device
2473 * is DMA capable SFF.
2474 *
2475 * May be used as the port_start() entry in ata_port_operations for
2476 * devices that are capable of 32bit PIO.
2477 *
2478 * LOCKING:
2479 * Inherited from caller.
2480 */
2481int ata_sff_port_start32(struct ata_port *ap)
2482{
2483 ap->pflags |= ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE;
2484 if (ap->ioaddr.bmdma_addr)
2485 return ata_port_start(ap);
2486 return 0;
2487}
2488EXPORT_SYMBOL_GPL(ata_sff_port_start32);
2489
2490/**
2491 * ata_sff_std_ports - initialize ioaddr with standard port offsets. 2445 * ata_sff_std_ports - initialize ioaddr with standard port offsets.
2492 * @ioaddr: IO address structure to be initialized 2446 * @ioaddr: IO address structure to be initialized
2493 * 2447 *
@@ -2646,21 +2600,12 @@ int ata_pci_sff_prepare_host(struct pci_dev *pdev,
2646 goto err_out; 2600 goto err_out;
2647 2601
2648 /* init DMA related stuff */ 2602 /* init DMA related stuff */
2649 rc = ata_pci_bmdma_init(host); 2603 ata_pci_bmdma_init(host);
2650 if (rc)
2651 goto err_bmdma;
2652 2604
2653 devres_remove_group(&pdev->dev, NULL); 2605 devres_remove_group(&pdev->dev, NULL);
2654 *r_host = host; 2606 *r_host = host;
2655 return 0; 2607 return 0;
2656 2608
2657err_bmdma:
2658 /* This is necessary because PCI and iomap resources are
2659 * merged and releasing the top group won't release the
2660 * acquired resources if some of those have been acquired
2661 * before entering this function.
2662 */
2663 pcim_iounmap_regions(pdev, 0xf);
2664err_out: 2609err_out:
2665 devres_release_group(&pdev->dev, NULL); 2610 devres_release_group(&pdev->dev, NULL);
2666 return rc; 2611 return rc;
@@ -2843,12 +2788,12 @@ EXPORT_SYMBOL_GPL(ata_pci_sff_init_one);
2843const struct ata_port_operations ata_bmdma_port_ops = { 2788const struct ata_port_operations ata_bmdma_port_ops = {
2844 .inherits = &ata_sff_port_ops, 2789 .inherits = &ata_sff_port_ops,
2845 2790
2846 .mode_filter = ata_bmdma_mode_filter,
2847
2848 .bmdma_setup = ata_bmdma_setup, 2791 .bmdma_setup = ata_bmdma_setup,
2849 .bmdma_start = ata_bmdma_start, 2792 .bmdma_start = ata_bmdma_start,
2850 .bmdma_stop = ata_bmdma_stop, 2793 .bmdma_stop = ata_bmdma_stop,
2851 .bmdma_status = ata_bmdma_status, 2794 .bmdma_status = ata_bmdma_status,
2795
2796 .port_start = ata_bmdma_port_start,
2852}; 2797};
2853EXPORT_SYMBOL_GPL(ata_bmdma_port_ops); 2798EXPORT_SYMBOL_GPL(ata_bmdma_port_ops);
2854 2799
@@ -2856,22 +2801,10 @@ const struct ata_port_operations ata_bmdma32_port_ops = {
2856 .inherits = &ata_bmdma_port_ops, 2801 .inherits = &ata_bmdma_port_ops,
2857 2802
2858 .sff_data_xfer = ata_sff_data_xfer32, 2803 .sff_data_xfer = ata_sff_data_xfer32,
2859 .port_start = ata_sff_port_start32, 2804 .port_start = ata_bmdma_port_start32,
2860}; 2805};
2861EXPORT_SYMBOL_GPL(ata_bmdma32_port_ops); 2806EXPORT_SYMBOL_GPL(ata_bmdma32_port_ops);
2862 2807
2863unsigned long ata_bmdma_mode_filter(struct ata_device *adev,
2864 unsigned long xfer_mask)
2865{
2866 /* Filter out DMA modes if the device has been configured by
2867 the BIOS as PIO only */
2868
2869 if (adev->link->ap->ioaddr.bmdma_addr == NULL)
2870 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
2871 return xfer_mask;
2872}
2873EXPORT_SYMBOL_GPL(ata_bmdma_mode_filter);
2874
2875/** 2808/**
2876 * ata_bmdma_setup - Set up PCI IDE BMDMA transaction 2809 * ata_bmdma_setup - Set up PCI IDE BMDMA transaction
2877 * @qc: Info associated with this ATA transaction. 2810 * @qc: Info associated with this ATA transaction.
@@ -2976,6 +2909,53 @@ u8 ata_bmdma_status(struct ata_port *ap)
2976} 2909}
2977EXPORT_SYMBOL_GPL(ata_bmdma_status); 2910EXPORT_SYMBOL_GPL(ata_bmdma_status);
2978 2911
2912
2913/**
2914 * ata_bmdma_port_start - Set port up for bmdma.
2915 * @ap: Port to initialize
2916 *
2917 * Called just after data structures for each port are
2918 * initialized. Allocates space for PRD table.
2919 *
2920 * May be used as the port_start() entry in ata_port_operations.
2921 *
2922 * LOCKING:
2923 * Inherited from caller.
2924 */
2925int ata_bmdma_port_start(struct ata_port *ap)
2926{
2927 if (ap->mwdma_mask || ap->udma_mask) {
2928 ap->prd = dmam_alloc_coherent(ap->host->dev, ATA_PRD_TBL_SZ,
2929 &ap->prd_dma, GFP_KERNEL);
2930 if (!ap->prd)
2931 return -ENOMEM;
2932 }
2933
2934 return 0;
2935}
2936EXPORT_SYMBOL_GPL(ata_bmdma_port_start);
2937
2938/**
2939 * ata_bmdma_port_start32 - Set port up for dma.
2940 * @ap: Port to initialize
2941 *
2942 * Called just after data structures for each port are
2943 * initialized. Enables 32bit PIO and allocates space for PRD
2944 * table.
2945 *
2946 * May be used as the port_start() entry in ata_port_operations for
2947 * devices that are capable of 32bit PIO.
2948 *
2949 * LOCKING:
2950 * Inherited from caller.
2951 */
2952int ata_bmdma_port_start32(struct ata_port *ap)
2953{
2954 ap->pflags |= ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE;
2955 return ata_bmdma_port_start(ap);
2956}
2957EXPORT_SYMBOL_GPL(ata_bmdma_port_start32);
2958
2979#ifdef CONFIG_PCI 2959#ifdef CONFIG_PCI
2980 2960
2981/** 2961/**
@@ -3004,6 +2984,19 @@ int ata_pci_bmdma_clear_simplex(struct pci_dev *pdev)
3004} 2984}
3005EXPORT_SYMBOL_GPL(ata_pci_bmdma_clear_simplex); 2985EXPORT_SYMBOL_GPL(ata_pci_bmdma_clear_simplex);
3006 2986
2987static void ata_bmdma_nodma(struct ata_host *host, const char *reason)
2988{
2989 int i;
2990
2991 dev_printk(KERN_ERR, host->dev, "BMDMA: %s, falling back to PIO\n",
2992 reason);
2993
2994 for (i = 0; i < 2; i++) {
2995 host->ports[i]->mwdma_mask = 0;
2996 host->ports[i]->udma_mask = 0;
2997 }
2998}
2999
3007/** 3000/**
3008 * ata_pci_bmdma_init - acquire PCI BMDMA resources and init ATA host 3001 * ata_pci_bmdma_init - acquire PCI BMDMA resources and init ATA host
3009 * @host: target ATA host 3002 * @host: target ATA host
@@ -3012,33 +3005,40 @@ EXPORT_SYMBOL_GPL(ata_pci_bmdma_clear_simplex);
3012 * 3005 *
3013 * LOCKING: 3006 * LOCKING:
3014 * Inherited from calling layer (may sleep). 3007 * Inherited from calling layer (may sleep).
3015 *
3016 * RETURNS:
3017 * 0 on success, -errno otherwise.
3018 */ 3008 */
3019int ata_pci_bmdma_init(struct ata_host *host) 3009void ata_pci_bmdma_init(struct ata_host *host)
3020{ 3010{
3021 struct device *gdev = host->dev; 3011 struct device *gdev = host->dev;
3022 struct pci_dev *pdev = to_pci_dev(gdev); 3012 struct pci_dev *pdev = to_pci_dev(gdev);
3023 int i, rc; 3013 int i, rc;
3024 3014
3025 /* No BAR4 allocation: No DMA */ 3015 /* No BAR4 allocation: No DMA */
3026 if (pci_resource_start(pdev, 4) == 0) 3016 if (pci_resource_start(pdev, 4) == 0) {
3027 return 0; 3017 ata_bmdma_nodma(host, "BAR4 is zero");
3018 return;
3019 }
3028 3020
3029 /* TODO: If we get no DMA mask we should fall back to PIO */ 3021 /*
3022 * Some controllers require BMDMA region to be initialized
3023 * even if DMA is not in use to clear IRQ status via
3024 * ->sff_irq_clear method. Try to initialize bmdma_addr
3025 * regardless of dma masks.
3026 */
3030 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); 3027 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
3031 if (rc) 3028 if (rc)
3032 return rc; 3029 ata_bmdma_nodma(host, "failed to set dma mask");
3033 rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); 3030 if (!rc) {
3034 if (rc) 3031 rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
3035 return rc; 3032 if (rc)
3033 ata_bmdma_nodma(host,
3034 "failed to set consistent dma mask");
3035 }
3036 3036
3037 /* request and iomap DMA region */ 3037 /* request and iomap DMA region */
3038 rc = pcim_iomap_regions(pdev, 1 << 4, dev_driver_string(gdev)); 3038 rc = pcim_iomap_regions(pdev, 1 << 4, dev_driver_string(gdev));
3039 if (rc) { 3039 if (rc) {
3040 dev_printk(KERN_ERR, gdev, "failed to request/iomap BAR4\n"); 3040 ata_bmdma_nodma(host, "failed to request/iomap BAR4");
3041 return -ENOMEM; 3041 return;
3042 } 3042 }
3043 host->iomap = pcim_iomap_table(pdev); 3043 host->iomap = pcim_iomap_table(pdev);
3044 3044
@@ -3057,8 +3057,6 @@ int ata_pci_bmdma_init(struct ata_host *host)
3057 ata_port_desc(ap, "bmdma 0x%llx", 3057 ata_port_desc(ap, "bmdma 0x%llx",
3058 (unsigned long long)pci_resource_start(pdev, 4) + 8 * i); 3058 (unsigned long long)pci_resource_start(pdev, 4) + 8 * i);
3059 } 3059 }
3060
3061 return 0;
3062} 3060}
3063EXPORT_SYMBOL_GPL(ata_pci_bmdma_init); 3061EXPORT_SYMBOL_GPL(ata_pci_bmdma_init);
3064 3062
diff --git a/drivers/ata/pata_acpi.c b/drivers/ata/pata_acpi.c
index 1ea2be0f4b94..1a5a309abccd 100644
--- a/drivers/ata/pata_acpi.c
+++ b/drivers/ata/pata_acpi.c
@@ -101,7 +101,7 @@ static unsigned long pacpi_discover_modes(struct ata_port *ap, struct ata_device
101static unsigned long pacpi_mode_filter(struct ata_device *adev, unsigned long mask) 101static unsigned long pacpi_mode_filter(struct ata_device *adev, unsigned long mask)
102{ 102{
103 struct pata_acpi *acpi = adev->link->ap->private_data; 103 struct pata_acpi *acpi = adev->link->ap->private_data;
104 return ata_bmdma_mode_filter(adev, mask & acpi->mask[adev->devno]); 104 return mask & acpi->mask[adev->devno];
105} 105}
106 106
107/** 107/**
@@ -205,7 +205,7 @@ static int pacpi_port_start(struct ata_port *ap)
205 return -ENOMEM; 205 return -ENOMEM;
206 acpi->mask[0] = pacpi_discover_modes(ap, &ap->link.device[0]); 206 acpi->mask[0] = pacpi_discover_modes(ap, &ap->link.device[0]);
207 acpi->mask[1] = pacpi_discover_modes(ap, &ap->link.device[1]); 207 acpi->mask[1] = pacpi_discover_modes(ap, &ap->link.device[1]);
208 ret = ata_sff_port_start(ap); 208 ret = ata_bmdma_port_start(ap);
209 if (ret < 0) 209 if (ret < 0)
210 return ret; 210 return ret;
211 211
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index dc61b72f751c..f306e10c748d 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -124,7 +124,7 @@ static unsigned long ali_20_filter(struct ata_device *adev, unsigned long mask)
124 ata_id_c_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num)); 124 ata_id_c_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num));
125 if (strstr(model_num, "WDC")) 125 if (strstr(model_num, "WDC"))
126 return mask &= ~ATA_MASK_UDMA; 126 return mask &= ~ATA_MASK_UDMA;
127 return ata_bmdma_mode_filter(adev, mask); 127 return mask;
128} 128}
129 129
130/** 130/**
diff --git a/drivers/ata/pata_at91.c b/drivers/ata/pata_at91.c
index c6a946aa252c..0da0dcc7dd08 100644
--- a/drivers/ata/pata_at91.c
+++ b/drivers/ata/pata_at91.c
@@ -202,7 +202,6 @@ static struct ata_port_operations pata_at91_port_ops = {
202 .sff_data_xfer = pata_at91_data_xfer_noirq, 202 .sff_data_xfer = pata_at91_data_xfer_noirq,
203 .set_piomode = pata_at91_set_piomode, 203 .set_piomode = pata_at91_set_piomode,
204 .cable_detect = ata_cable_40wire, 204 .cable_detect = ata_cable_40wire,
205 .port_start = ATA_OP_NULL,
206}; 205};
207 206
208static int __devinit pata_at91_probe(struct platform_device *pdev) 207static int __devinit pata_at91_probe(struct platform_device *pdev)
diff --git a/drivers/ata/pata_bf54x.c b/drivers/ata/pata_bf54x.c
index 3d94c800e9d1..6422cfd13d0d 100644
--- a/drivers/ata/pata_bf54x.c
+++ b/drivers/ata/pata_bf54x.c
@@ -1450,8 +1450,6 @@ static struct ata_port_operations bfin_pata_ops = {
1450 1450
1451 .port_start = bfin_port_start, 1451 .port_start = bfin_port_start,
1452 .port_stop = bfin_port_stop, 1452 .port_stop = bfin_port_stop,
1453
1454 .mode_filter = ATA_OP_NULL, /* will be removed soon */
1455}; 1453};
1456 1454
1457static struct ata_port_info bfin_port_info[] = { 1455static struct ata_port_info bfin_port_info[] = {
diff --git a/drivers/ata/pata_cmd640.c b/drivers/ata/pata_cmd640.c
index 60ab2d2b1ccd..e5f289f59ca3 100644
--- a/drivers/ata/pata_cmd640.c
+++ b/drivers/ata/pata_cmd640.c
@@ -153,16 +153,12 @@ static int cmd640_port_start(struct ata_port *ap)
153 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 153 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
154 struct cmd640_reg *timing; 154 struct cmd640_reg *timing;
155 155
156 int ret = ata_sff_port_start(ap);
157 if (ret < 0)
158 return ret;
159
160 timing = devm_kzalloc(&pdev->dev, sizeof(struct cmd640_reg), GFP_KERNEL); 156 timing = devm_kzalloc(&pdev->dev, sizeof(struct cmd640_reg), GFP_KERNEL);
161 if (timing == NULL) 157 if (timing == NULL)
162 return -ENOMEM; 158 return -ENOMEM;
163 timing->last = -1; /* Force a load */ 159 timing->last = -1; /* Force a load */
164 ap->private_data = timing; 160 ap->private_data = timing;
165 return ret; 161 return 0;
166} 162}
167 163
168static struct scsi_host_template cmd640_sht = { 164static struct scsi_host_template cmd640_sht = {
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index af49bfb57247..8580eb3cd54d 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -182,7 +182,7 @@ static unsigned long hpt366_filter(struct ata_device *adev, unsigned long mask)
182 } else if (adev->class == ATA_DEV_ATAPI) 182 } else if (adev->class == ATA_DEV_ATAPI)
183 mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); 183 mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
184 184
185 return ata_bmdma_mode_filter(adev, mask); 185 return mask;
186} 186}
187 187
188static int hpt36x_cable_detect(struct ata_port *ap) 188static int hpt36x_cable_detect(struct ata_port *ap)
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 8839307a64cf..98b498b6907c 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -282,7 +282,7 @@ static unsigned long hpt370_filter(struct ata_device *adev, unsigned long mask)
282 if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5)) 282 if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5))
283 mask &= ~(0xE0 << ATA_SHIFT_UDMA); 283 mask &= ~(0xE0 << ATA_SHIFT_UDMA);
284 } 284 }
285 return ata_bmdma_mode_filter(adev, mask); 285 return mask;
286} 286}
287 287
288/** 288/**
@@ -298,7 +298,7 @@ static unsigned long hpt370a_filter(struct ata_device *adev, unsigned long mask)
298 if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5)) 298 if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5))
299 mask &= ~(0xE0 << ATA_SHIFT_UDMA); 299 mask &= ~(0xE0 << ATA_SHIFT_UDMA);
300 } 300 }
301 return ata_bmdma_mode_filter(adev, mask); 301 return mask;
302} 302}
303 303
304/** 304/**
diff --git a/drivers/ata/pata_icside.c b/drivers/ata/pata_icside.c
index 832c8ccd0e80..ee85a9ce0a11 100644
--- a/drivers/ata/pata_icside.c
+++ b/drivers/ata/pata_icside.c
@@ -335,7 +335,7 @@ static struct ata_port_operations pata_icside_port_ops = {
335 .postreset = pata_icside_postreset, 335 .postreset = pata_icside_postreset,
336 .post_internal_cmd = pata_icside_bmdma_stop, 336 .post_internal_cmd = pata_icside_bmdma_stop,
337 337
338 .mode_filter = ATA_OP_NULL, /* will be removed soon */ 338 .port_start = ATA_OP_NULL, /* don't need PRD table */
339}; 339};
340 340
341static void __devinit 341static void __devinit
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index 5cb286fd839e..8d73438f292c 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -739,7 +739,7 @@ static int it821x_port_start(struct ata_port *ap)
739 struct it821x_dev *itdev; 739 struct it821x_dev *itdev;
740 u8 conf; 740 u8 conf;
741 741
742 int ret = ata_sff_port_start(ap); 742 int ret = ata_bmdma_port_start(ap);
743 if (ret < 0) 743 if (ret < 0)
744 return ret; 744 return ret;
745 745
diff --git a/drivers/ata/pata_macio.c b/drivers/ata/pata_macio.c
index 17e4e5d19696..25df50f51c04 100644
--- a/drivers/ata/pata_macio.c
+++ b/drivers/ata/pata_macio.c
@@ -720,6 +720,8 @@ static int pata_macio_port_start(struct ata_port *ap)
720 if (priv->dma_table_cpu == NULL) { 720 if (priv->dma_table_cpu == NULL) {
721 dev_err(priv->dev, "Unable to allocate DMA command list\n"); 721 dev_err(priv->dev, "Unable to allocate DMA command list\n");
722 ap->ioaddr.bmdma_addr = NULL; 722 ap->ioaddr.bmdma_addr = NULL;
723 ap->mwdma_mask = 0;
724 ap->udma_mask = 0;
723 } 725 }
724 return 0; 726 return 0;
725} 727}
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c
index ca5cad0fd80b..09f1f22c0307 100644
--- a/drivers/ata/pata_pdc2027x.c
+++ b/drivers/ata/pata_pdc2027x.c
@@ -265,7 +265,7 @@ static unsigned long pdc2027x_mode_filter(struct ata_device *adev, unsigned long
265 struct ata_device *pair = ata_dev_pair(adev); 265 struct ata_device *pair = ata_dev_pair(adev);
266 266
267 if (adev->class != ATA_DEV_ATA || adev->devno == 0 || pair == NULL) 267 if (adev->class != ATA_DEV_ATA || adev->devno == 0 || pair == NULL)
268 return ata_bmdma_mode_filter(adev, mask); 268 return mask;
269 269
270 /* Check for slave of a Maxtor at UDMA6 */ 270 /* Check for slave of a Maxtor at UDMA6 */
271 ata_id_c_string(pair->id, model_num, ATA_ID_PROD, 271 ata_id_c_string(pair->id, model_num, ATA_ID_PROD,
@@ -274,7 +274,7 @@ static unsigned long pdc2027x_mode_filter(struct ata_device *adev, unsigned long
274 if (strstr(model_num, "Maxtor") == NULL && pair->dma_mode == XFER_UDMA_6) 274 if (strstr(model_num, "Maxtor") == NULL && pair->dma_mode == XFER_UDMA_6)
275 mask &= ~ (1 << (6 + ATA_SHIFT_UDMA)); 275 mask &= ~ (1 << (6 + ATA_SHIFT_UDMA));
276 276
277 return ata_bmdma_mode_filter(adev, mask); 277 return mask;
278} 278}
279 279
280/** 280/**
diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c
index 9ac0897cf8b0..fa1e2f3bc0fd 100644
--- a/drivers/ata/pata_pdc202xx_old.c
+++ b/drivers/ata/pata_pdc202xx_old.c
@@ -249,7 +249,7 @@ static int pdc2026x_port_start(struct ata_port *ap)
249 u8 burst = ioread8(bmdma + 0x1f); 249 u8 burst = ioread8(bmdma + 0x1f);
250 iowrite8(burst | 0x01, bmdma + 0x1f); 250 iowrite8(burst | 0x01, bmdma + 0x1f);
251 } 251 }
252 return ata_sff_port_start(ap); 252 return ata_bmdma_port_start(ap);
253} 253}
254 254
255/** 255/**
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
index 3f6ebc6c665a..50400fa120fe 100644
--- a/drivers/ata/pata_platform.c
+++ b/drivers/ata/pata_platform.c
@@ -53,7 +53,6 @@ static struct ata_port_operations pata_platform_port_ops = {
53 .sff_data_xfer = ata_sff_data_xfer_noirq, 53 .sff_data_xfer = ata_sff_data_xfer_noirq,
54 .cable_detect = ata_cable_unknown, 54 .cable_detect = ata_cable_unknown,
55 .set_mode = pata_platform_set_mode, 55 .set_mode = pata_platform_set_mode,
56 .port_start = ATA_OP_NULL,
57}; 56};
58 57
59static void pata_platform_setup_port(struct ata_ioports *ioaddr, 58static void pata_platform_setup_port(struct ata_ioports *ioaddr,
diff --git a/drivers/ata/pata_scc.c b/drivers/ata/pata_scc.c
index d3988991ca68..70d549e28f0f 100644
--- a/drivers/ata/pata_scc.c
+++ b/drivers/ata/pata_scc.c
@@ -265,7 +265,7 @@ unsigned long scc_mode_filter(struct ata_device *adev, unsigned long mask)
265 printk(KERN_INFO "%s: limit ATAPI UDMA to UDMA4\n", DRV_NAME); 265 printk(KERN_INFO "%s: limit ATAPI UDMA to UDMA4\n", DRV_NAME);
266 mask &= ~(0xE0 << ATA_SHIFT_UDMA); 266 mask &= ~(0xE0 << ATA_SHIFT_UDMA);
267 } 267 }
268 return ata_bmdma_mode_filter(adev, mask); 268 return mask;
269} 269}
270 270
271/** 271/**
@@ -892,7 +892,7 @@ static void scc_irq_clear (struct ata_port *ap)
892 * scc_port_start - Set port up for dma. 892 * scc_port_start - Set port up for dma.
893 * @ap: Port to initialize 893 * @ap: Port to initialize
894 * 894 *
895 * Allocate space for PRD table using ata_port_start(). 895 * Allocate space for PRD table using ata_bmdma_port_start().
896 * Set PRD table address for PTERADD. (PRD Transfer End Read) 896 * Set PRD table address for PTERADD. (PRD Transfer End Read)
897 */ 897 */
898 898
@@ -901,7 +901,7 @@ static int scc_port_start (struct ata_port *ap)
901 void __iomem *mmio = ap->ioaddr.bmdma_addr; 901 void __iomem *mmio = ap->ioaddr.bmdma_addr;
902 int rc; 902 int rc;
903 903
904 rc = ata_port_start(ap); 904 rc = ata_bmdma_port_start(ap);
905 if (rc) 905 if (rc)
906 return rc; 906 return rc;
907 907
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c
index 9524d54035f7..43ea389df2b3 100644
--- a/drivers/ata/pata_serverworks.c
+++ b/drivers/ata/pata_serverworks.c
@@ -198,7 +198,7 @@ static unsigned long serverworks_osb4_filter(struct ata_device *adev, unsigned l
198{ 198{
199 if (adev->class == ATA_DEV_ATA) 199 if (adev->class == ATA_DEV_ATA)
200 mask &= ~ATA_MASK_UDMA; 200 mask &= ~ATA_MASK_UDMA;
201 return ata_bmdma_mode_filter(adev, mask); 201 return mask;
202} 202}
203 203
204 204
@@ -218,7 +218,7 @@ static unsigned long serverworks_csb_filter(struct ata_device *adev, unsigned lo
218 218
219 /* Disk, UDMA */ 219 /* Disk, UDMA */
220 if (adev->class != ATA_DEV_ATA) 220 if (adev->class != ATA_DEV_ATA)
221 return ata_bmdma_mode_filter(adev, mask); 221 return mask;
222 222
223 /* Actually do need to check */ 223 /* Actually do need to check */
224 ata_id_c_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num)); 224 ata_id_c_string(adev->id, model_num, ATA_ID_PROD, sizeof(model_num));
@@ -227,7 +227,7 @@ static unsigned long serverworks_csb_filter(struct ata_device *adev, unsigned lo
227 if (!strcmp(p, model_num)) 227 if (!strcmp(p, model_num))
228 mask &= ~(0xE0 << ATA_SHIFT_UDMA); 228 mask &= ~(0xE0 << ATA_SHIFT_UDMA);
229 } 229 }
230 return ata_bmdma_mode_filter(adev, mask); 230 return mask;
231} 231}
232 232
233/** 233/**
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index 87fb89e407f7..7e3e0a5598b7 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -355,7 +355,7 @@ static unsigned long via_mode_filter(struct ata_device *dev, unsigned long mask)
355 mask &= ~ ATA_MASK_UDMA; 355 mask &= ~ ATA_MASK_UDMA;
356 } 356 }
357 } 357 }
358 return ata_bmdma_mode_filter(dev, mask); 358 return mask;
359} 359}
360 360
361/** 361/**
@@ -424,7 +424,7 @@ static int via_port_start(struct ata_port *ap)
424 struct via_port *vp; 424 struct via_port *vp;
425 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 425 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
426 426
427 int ret = ata_sff_port_start(ap); 427 int ret = ata_bmdma_port_start(ap);
428 if (ret < 0) 428 if (ret < 0)
429 return ret; 429 return ret;
430 430
diff --git a/drivers/ata/pdc_adma.c b/drivers/ata/pdc_adma.c
index ed18d8b42c52..bb4f838655b6 100644
--- a/drivers/ata/pdc_adma.c
+++ b/drivers/ata/pdc_adma.c
@@ -556,11 +556,7 @@ static int adma_port_start(struct ata_port *ap)
556{ 556{
557 struct device *dev = ap->host->dev; 557 struct device *dev = ap->host->dev;
558 struct adma_port_priv *pp; 558 struct adma_port_priv *pp;
559 int rc;
560 559
561 rc = ata_port_start(ap);
562 if (rc)
563 return rc;
564 adma_enter_reg_mode(ap); 560 adma_enter_reg_mode(ap);
565 pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); 561 pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
566 if (!pp) 562 if (!pp)
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index d3e1bab2a7ad..a36149ebf4a2 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -682,7 +682,6 @@ static int inic_port_start(struct ata_port *ap)
682{ 682{
683 struct device *dev = ap->host->dev; 683 struct device *dev = ap->host->dev;
684 struct inic_port_priv *pp; 684 struct inic_port_priv *pp;
685 int rc;
686 685
687 /* alloc and initialize private data */ 686 /* alloc and initialize private data */
688 pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); 687 pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
@@ -691,10 +690,6 @@ static int inic_port_start(struct ata_port *ap)
691 ap->private_data = pp; 690 ap->private_data = pp;
692 691
693 /* Alloc resources */ 692 /* Alloc resources */
694 rc = ata_port_start(ap);
695 if (rc)
696 return rc;
697
698 pp->pkt = dmam_alloc_coherent(dev, sizeof(struct inic_pkt), 693 pp->pkt = dmam_alloc_coherent(dev, sizeof(struct inic_pkt),
699 &pp->pkt_dma, GFP_KERNEL); 694 &pp->pkt_dma, GFP_KERNEL);
700 if (!pp->pkt) 695 if (!pp->pkt)
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index a03371075990..83491861d110 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -717,8 +717,6 @@ static struct ata_port_operations mv6_ops = {
717 717
718 .port_start = mv_port_start, 718 .port_start = mv_port_start,
719 .port_stop = mv_port_stop, 719 .port_stop = mv_port_stop,
720
721 .mode_filter = ATA_OP_NULL, /* will be removed soon */
722}; 720};
723 721
724static struct ata_port_operations mv_iie_ops = { 722static struct ata_port_operations mv_iie_ops = {
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index 20cc510595db..a007b20c1991 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -1156,7 +1156,8 @@ static int nv_adma_port_start(struct ata_port *ap)
1156 if (rc) 1156 if (rc)
1157 return rc; 1157 return rc;
1158 1158
1159 rc = ata_port_start(ap); 1159 /* we might fallback to bmdma, allocate bmdma resources */
1160 rc = ata_bmdma_port_start(ap);
1160 if (rc) 1161 if (rc)
1161 return rc; 1162 return rc;
1162 1163
@@ -1985,7 +1986,8 @@ static int nv_swncq_port_start(struct ata_port *ap)
1985 struct nv_swncq_port_priv *pp; 1986 struct nv_swncq_port_priv *pp;
1986 int rc; 1987 int rc;
1987 1988
1988 rc = ata_port_start(ap); 1989 /* we might fallback to bmdma, allocate bmdma resources */
1990 rc = ata_bmdma_port_start(ap);
1989 if (rc) 1991 if (rc)
1990 return rc; 1992 return rc;
1991 1993
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index 2c029ea12c54..e80628a77669 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -333,7 +333,8 @@ static int pdc_common_port_start(struct ata_port *ap)
333 struct pdc_port_priv *pp; 333 struct pdc_port_priv *pp;
334 int rc; 334 int rc;
335 335
336 rc = ata_port_start(ap); 336 /* we use the same prd table as bmdma, allocate it */
337 rc = ata_bmdma_port_start(ap);
337 if (rc) 338 if (rc)
338 return rc; 339 return rc;
339 340
diff --git a/drivers/ata/sata_qstor.c b/drivers/ata/sata_qstor.c
index febc6e748420..da84ea9e4fb0 100644
--- a/drivers/ata/sata_qstor.c
+++ b/drivers/ata/sata_qstor.c
@@ -504,11 +504,7 @@ static int qs_port_start(struct ata_port *ap)
504 void __iomem *mmio_base = qs_mmio_base(ap->host); 504 void __iomem *mmio_base = qs_mmio_base(ap->host);
505 void __iomem *chan = mmio_base + (ap->port_no * 0x4000); 505 void __iomem *chan = mmio_base + (ap->port_no * 0x4000);
506 u64 addr; 506 u64 addr;
507 int rc;
508 507
509 rc = ata_port_start(ap);
510 if (rc)
511 return rc;
512 pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); 508 pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
513 if (!pp) 509 if (!pp)
514 return -ENOMEM; 510 return -ENOMEM;
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c
index 7e3a25ec93b1..a4e552a325b0 100644
--- a/drivers/ata/sata_sx4.c
+++ b/drivers/ata/sata_sx4.c
@@ -302,11 +302,6 @@ static int pdc_port_start(struct ata_port *ap)
302{ 302{
303 struct device *dev = ap->host->dev; 303 struct device *dev = ap->host->dev;
304 struct pdc_port_priv *pp; 304 struct pdc_port_priv *pp;
305 int rc;
306
307 rc = ata_port_start(ap);
308 if (rc)
309 return rc;
310 305
311 pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); 306 pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
312 if (!pp) 307 if (!pp)
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c
index 011e098590d1..d8dac17dc2c8 100644
--- a/drivers/ata/sata_uli.c
+++ b/drivers/ata/sata_uli.c
@@ -181,9 +181,7 @@ static int uli_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
181 if (rc) 181 if (rc)
182 return rc; 182 return rc;
183 183
184 rc = ata_pci_bmdma_init(host); 184 ata_pci_bmdma_init(host);
185 if (rc)
186 return rc;
187 185
188 iomap = host->iomap; 186 iomap = host->iomap;
189 187