aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2008-03-24 23:22:47 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-04-17 15:44:16 -0400
commitf08048e94564d009b19038cfbdd800aa83e79c7f (patch)
tree4afa7e4fff9ec716e9acbe746a464cda5daec063 /drivers/ata
parentb558edddb1c42c70a30cfe494984d4be409f7b2b (diff)
libata: PCI device should be powered up before being accessed
PCI device should be powered up or powered up before its PCI regsiters are accessed. Although PCI configuration register access is allowed in D3hot, PCI device is free to reset its status when transiting from D3hot to D0 causing configuration data to change. Many libata SFF drivers which use ata_pci_init_one() read and update configuration registers before calling ata_pci_init_one() which enables the PCI device. Also, in resume paths, some drivers access registers without resuming the PCI device. This patch adds a call to pcim_enable_device() in init path if register is accessed before calling ata_pci_init_one() and make resume paths first resume PCI devices, access PCI configuration regiters then resume ATA host. While at it... * cmd640 was strange in that it set ->resume even when CONFIG_PM is not. This is by-product of minimal build fix. Updated. * In cs5530, Don't BUG() on reinit failure. Just whine and fail resume. Signed-off-by: Tejun Heo <htejun@gmail.com>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/pata_ali.c14
-rw-r--r--drivers/ata/pata_amd.c16
-rw-r--r--drivers/ata/pata_artop.c5
-rw-r--r--drivers/ata/pata_cmd640.c21
-rw-r--r--drivers/ata/pata_cmd64x.c15
-rw-r--r--drivers/ata/pata_cs5520.c15
-rw-r--r--drivers/ata/pata_cs5530.c18
-rw-r--r--drivers/ata/pata_hpt366.c14
-rw-r--r--drivers/ata/pata_hpt37x.c5
-rw-r--r--drivers/ata/pata_hpt3x2n.c5
-rw-r--r--drivers/ata/pata_it821x.c14
-rw-r--r--drivers/ata/pata_netcell.c5
-rw-r--r--drivers/ata/pata_ns87415.c6
-rw-r--r--drivers/ata/pata_optidma.c5
-rw-r--r--drivers/ata/pata_serverworks.c19
-rw-r--r--drivers/ata/pata_sil680.c13
-rw-r--r--drivers/ata/pata_sis.c6
-rw-r--r--drivers/ata/pata_sl82c105.c5
-rw-r--r--drivers/ata/pata_via.c14
19 files changed, 195 insertions, 20 deletions
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 511a830b6256..3814aebefb2d 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -637,6 +637,11 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
637 const struct ata_port_info *ppi[] = { NULL, NULL }; 637 const struct ata_port_info *ppi[] = { NULL, NULL };
638 u8 tmp; 638 u8 tmp;
639 struct pci_dev *isa_bridge; 639 struct pci_dev *isa_bridge;
640 int rc;
641
642 rc = pcim_enable_device(pdev);
643 if (rc)
644 return rc;
640 645
641 /* 646 /*
642 * The chipset revision selects the driver operations and 647 * The chipset revision selects the driver operations and
@@ -672,8 +677,15 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
672#ifdef CONFIG_PM 677#ifdef CONFIG_PM
673static int ali_reinit_one(struct pci_dev *pdev) 678static int ali_reinit_one(struct pci_dev *pdev)
674{ 679{
680 struct ata_host *host = dev_get_drvdata(&pdev->dev);
681 int rc;
682
683 rc = ata_pci_device_do_resume(pdev);
684 if (rc)
685 return rc;
675 ali_init_chipset(pdev); 686 ali_init_chipset(pdev);
676 return ata_pci_device_resume(pdev); 687 ata_host_resume(host);
688 return 0;
677} 689}
678#endif 690#endif
679 691
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
index 4b8d9b592ca4..5e1bc13a756b 100644
--- a/drivers/ata/pata_amd.c
+++ b/drivers/ata/pata_amd.c
@@ -659,10 +659,15 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
659 static int printed_version; 659 static int printed_version;
660 int type = id->driver_data; 660 int type = id->driver_data;
661 u8 fifo; 661 u8 fifo;
662 int rc;
662 663
663 if (!printed_version++) 664 if (!printed_version++)
664 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); 665 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
665 666
667 rc = pcim_enable_device(pdev);
668 if (rc)
669 return rc;
670
666 pci_read_config_byte(pdev, 0x41, &fifo); 671 pci_read_config_byte(pdev, 0x41, &fifo);
667 672
668 /* Check for AMD7409 without swdma errata and if found adjust type */ 673 /* Check for AMD7409 without swdma errata and if found adjust type */
@@ -706,6 +711,13 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
706#ifdef CONFIG_PM 711#ifdef CONFIG_PM
707static int amd_reinit_one(struct pci_dev *pdev) 712static int amd_reinit_one(struct pci_dev *pdev)
708{ 713{
714 struct ata_host *host = dev_get_drvdata(&pdev->dev);
715 int rc;
716
717 rc = ata_pci_device_do_resume(pdev);
718 if (rc)
719 return rc;
720
709 if (pdev->vendor == PCI_VENDOR_ID_AMD) { 721 if (pdev->vendor == PCI_VENDOR_ID_AMD) {
710 u8 fifo; 722 u8 fifo;
711 pci_read_config_byte(pdev, 0x41, &fifo); 723 pci_read_config_byte(pdev, 0x41, &fifo);
@@ -718,7 +730,9 @@ static int amd_reinit_one(struct pci_dev *pdev)
718 pdev->device == PCI_DEVICE_ID_AMD_COBRA_7401) 730 pdev->device == PCI_DEVICE_ID_AMD_COBRA_7401)
719 ata_pci_clear_simplex(pdev); 731 ata_pci_clear_simplex(pdev);
720 } 732 }
721 return ata_pci_device_resume(pdev); 733
734 ata_host_resume(host);
735 return 0;
722} 736}
723#endif 737#endif
724 738
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c
index d4218310327b..2f8148016971 100644
--- a/drivers/ata/pata_artop.c
+++ b/drivers/ata/pata_artop.c
@@ -446,11 +446,16 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
446 .port_ops = &artop6260_ops, 446 .port_ops = &artop6260_ops,
447 }; 447 };
448 const struct ata_port_info *ppi[] = { NULL, NULL }; 448 const struct ata_port_info *ppi[] = { NULL, NULL };
449 int rc;
449 450
450 if (!printed_version++) 451 if (!printed_version++)
451 dev_printk(KERN_DEBUG, &pdev->dev, 452 dev_printk(KERN_DEBUG, &pdev->dev,
452 "version " DRV_VERSION "\n"); 453 "version " DRV_VERSION "\n");
453 454
455 rc = pcim_enable_device(pdev);
456 if (rc)
457 return rc;
458
454 if (id->driver_data == 0) { /* 6210 variant */ 459 if (id->driver_data == 0) { /* 6210 variant */
455 ppi[0] = &info_6210; 460 ppi[0] = &info_6210;
456 ppi[1] = &ata_dummy_port_info; 461 ppi[1] = &ata_dummy_port_info;
diff --git a/drivers/ata/pata_cmd640.c b/drivers/ata/pata_cmd640.c
index 43d198f90968..0ef1d1ded1f8 100644
--- a/drivers/ata/pata_cmd640.c
+++ b/drivers/ata/pata_cmd640.c
@@ -254,20 +254,31 @@ static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
254 .port_ops = &cmd640_port_ops 254 .port_ops = &cmd640_port_ops
255 }; 255 };
256 const struct ata_port_info *ppi[] = { &info, NULL }; 256 const struct ata_port_info *ppi[] = { &info, NULL };
257 int rc;
258
259 rc = pcim_enable_device(pdev);
260 if (rc)
261 return rc;
257 262
258 cmd640_hardware_init(pdev); 263 cmd640_hardware_init(pdev);
264
259 return ata_pci_init_one(pdev, ppi); 265 return ata_pci_init_one(pdev, ppi);
260} 266}
261 267
268#ifdef CONFIG_PM
262static int cmd640_reinit_one(struct pci_dev *pdev) 269static int cmd640_reinit_one(struct pci_dev *pdev)
263{ 270{
271 struct ata_host *host = dev_get_drvdata(&pdev->dev);
272 int rc;
273
274 rc = ata_pci_device_do_resume(pdev);
275 if (rc)
276 return rc;
264 cmd640_hardware_init(pdev); 277 cmd640_hardware_init(pdev);
265#ifdef CONFIG_PM 278 ata_host_resume(host);
266 return ata_pci_device_resume(pdev);
267#else
268 return 0; 279 return 0;
269#endif
270} 280}
281#endif
271 282
272static const struct pci_device_id cmd640[] = { 283static const struct pci_device_id cmd640[] = {
273 { PCI_VDEVICE(CMD, 0x640), 0 }, 284 { PCI_VDEVICE(CMD, 0x640), 0 },
@@ -281,8 +292,8 @@ static struct pci_driver cmd640_pci_driver = {
281 .remove = ata_pci_remove_one, 292 .remove = ata_pci_remove_one,
282#ifdef CONFIG_PM 293#ifdef CONFIG_PM
283 .suspend = ata_pci_device_suspend, 294 .suspend = ata_pci_device_suspend,
284#endif
285 .resume = cmd640_reinit_one, 295 .resume = cmd640_reinit_one,
296#endif
286}; 297};
287 298
288static int __init cmd640_init(void) 299static int __init cmd640_init(void)
diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c
index 7acbbd9ee469..1c9a8d97f874 100644
--- a/drivers/ata/pata_cmd64x.c
+++ b/drivers/ata/pata_cmd64x.c
@@ -435,6 +435,11 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
435 }; 435 };
436 const struct ata_port_info *ppi[] = { &cmd_info[id->driver_data], NULL }; 436 const struct ata_port_info *ppi[] = { &cmd_info[id->driver_data], NULL };
437 u8 mrdmode; 437 u8 mrdmode;
438 int rc;
439
440 rc = pcim_enable_device(pdev);
441 if (rc)
442 return rc;
438 443
439 pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev); 444 pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev);
440 class_rev &= 0xFF; 445 class_rev &= 0xFF;
@@ -470,7 +475,14 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
470#ifdef CONFIG_PM 475#ifdef CONFIG_PM
471static int cmd64x_reinit_one(struct pci_dev *pdev) 476static int cmd64x_reinit_one(struct pci_dev *pdev)
472{ 477{
478 struct ata_host *host = dev_get_drvdata(&pdev->dev);
473 u8 mrdmode; 479 u8 mrdmode;
480 int rc;
481
482 rc = ata_pci_device_do_resume(pdev);
483 if (rc)
484 return rc;
485
474 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64); 486 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64);
475 pci_read_config_byte(pdev, MRDMODE, &mrdmode); 487 pci_read_config_byte(pdev, MRDMODE, &mrdmode);
476 mrdmode &= ~ 0x30; /* IRQ set up */ 488 mrdmode &= ~ 0x30; /* IRQ set up */
@@ -479,7 +491,8 @@ static int cmd64x_reinit_one(struct pci_dev *pdev)
479#ifdef CONFIG_PPC 491#ifdef CONFIG_PPC
480 pci_write_config_byte(pdev, UDIDETCR0, 0xF0); 492 pci_write_config_byte(pdev, UDIDETCR0, 0xF0);
481#endif 493#endif
482 return ata_pci_device_resume(pdev); 494 ata_host_resume(host);
495 return 0;
483} 496}
484#endif 497#endif
485 498
diff --git a/drivers/ata/pata_cs5520.c b/drivers/ata/pata_cs5520.c
index 7ed279b0a12e..dd6b2355fcdc 100644
--- a/drivers/ata/pata_cs5520.c
+++ b/drivers/ata/pata_cs5520.c
@@ -203,6 +203,10 @@ static int __devinit cs5520_init_one(struct pci_dev *pdev, const struct pci_devi
203 struct ata_ioports *ioaddr; 203 struct ata_ioports *ioaddr;
204 int i, rc; 204 int i, rc;
205 205
206 rc = pcim_enable_device(pdev);
207 if (rc)
208 return rc;
209
206 /* IDE port enable bits */ 210 /* IDE port enable bits */
207 pci_read_config_byte(pdev, 0x60, &pcicfg); 211 pci_read_config_byte(pdev, 0x60, &pcicfg);
208 212
@@ -310,11 +314,20 @@ static int __devinit cs5520_init_one(struct pci_dev *pdev, const struct pci_devi
310 314
311static int cs5520_reinit_one(struct pci_dev *pdev) 315static int cs5520_reinit_one(struct pci_dev *pdev)
312{ 316{
317 struct ata_host *host = dev_get_drvdata(&pdev->dev);
313 u8 pcicfg; 318 u8 pcicfg;
319 int rc;
320
321 rc = ata_pci_device_do_resume(pdev);
322 if (rc)
323 return rc;
324
314 pci_read_config_byte(pdev, 0x60, &pcicfg); 325 pci_read_config_byte(pdev, 0x60, &pcicfg);
315 if ((pcicfg & 0x40) == 0) 326 if ((pcicfg & 0x40) == 0)
316 pci_write_config_byte(pdev, 0x60, pcicfg | 0x40); 327 pci_write_config_byte(pdev, 0x60, pcicfg | 0x40);
317 return ata_pci_device_resume(pdev); 328
329 ata_host_resume(host);
330 return 0;
318} 331}
319 332
320/** 333/**
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c
index e1818fdd9159..f876aeddf1a1 100644
--- a/drivers/ata/pata_cs5530.c
+++ b/drivers/ata/pata_cs5530.c
@@ -349,6 +349,11 @@ static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
349 .port_ops = &cs5530_port_ops 349 .port_ops = &cs5530_port_ops
350 }; 350 };
351 const struct ata_port_info *ppi[] = { &info, NULL }; 351 const struct ata_port_info *ppi[] = { &info, NULL };
352 int rc;
353
354 rc = pcim_enable_device(pdev);
355 if (rc)
356 return rc;
352 357
353 /* Chip initialisation */ 358 /* Chip initialisation */
354 if (cs5530_init_chip()) 359 if (cs5530_init_chip())
@@ -364,10 +369,19 @@ static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
364#ifdef CONFIG_PM 369#ifdef CONFIG_PM
365static int cs5530_reinit_one(struct pci_dev *pdev) 370static int cs5530_reinit_one(struct pci_dev *pdev)
366{ 371{
372 struct ata_host *host = dev_get_drvdata(&pdev->dev);
373 int rc;
374
375 rc = ata_pci_device_do_resume(pdev);
376 if (rc)
377 return rc;
378
367 /* If we fail on resume we are doomed */ 379 /* If we fail on resume we are doomed */
368 if (cs5530_init_chip()) 380 if (cs5530_init_chip())
369 BUG(); 381 return -EIO;
370 return ata_pci_device_resume(pdev); 382
383 ata_host_resume(host);
384 return 0;
371} 385}
372#endif /* CONFIG_PM */ 386#endif /* CONFIG_PM */
373 387
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index a742efa0da2b..a82089048f58 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -402,6 +402,11 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
402 402
403 u32 class_rev; 403 u32 class_rev;
404 u32 reg1; 404 u32 reg1;
405 int rc;
406
407 rc = pcim_enable_device(dev);
408 if (rc)
409 return rc;
405 410
406 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); 411 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
407 class_rev &= 0xFF; 412 class_rev &= 0xFF;
@@ -435,8 +440,15 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
435#ifdef CONFIG_PM 440#ifdef CONFIG_PM
436static int hpt36x_reinit_one(struct pci_dev *dev) 441static int hpt36x_reinit_one(struct pci_dev *dev)
437{ 442{
443 struct ata_host *host = dev_get_drvdata(&dev->dev);
444 int rc;
445
446 rc = ata_pci_device_do_resume(dev);
447 if (rc)
448 return rc;
438 hpt36x_init_chipset(dev); 449 hpt36x_init_chipset(dev);
439 return ata_pci_device_resume(dev); 450 ata_host_resume(host);
451 return 0;
440} 452}
441#endif 453#endif
442 454
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 9a10878b2ad8..2ddcd07a7518 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -966,6 +966,11 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
966 966
967 const struct hpt_chip *chip_table; 967 const struct hpt_chip *chip_table;
968 int clock_slot; 968 int clock_slot;
969 int rc;
970
971 rc = pcim_enable_device(dev);
972 if (rc)
973 return rc;
969 974
970 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); 975 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
971 class_rev &= 0xFF; 976 class_rev &= 0xFF;
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
index 9f1c084f846f..3a517cb9bd3e 100644
--- a/drivers/ata/pata_hpt3x2n.c
+++ b/drivers/ata/pata_hpt3x2n.c
@@ -505,6 +505,11 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
505 unsigned int f_low, f_high; 505 unsigned int f_low, f_high;
506 int adjust; 506 int adjust;
507 unsigned long iobase = pci_resource_start(dev, 4); 507 unsigned long iobase = pci_resource_start(dev, 4);
508 int rc;
509
510 rc = pcim_enable_device(dev);
511 if (rc)
512 return rc;
508 513
509 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); 514 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
510 class_rev &= 0xFF; 515 class_rev &= 0xFF;
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index 257951d03dbb..6bdbb7140dfa 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -759,6 +759,11 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
759 759
760 const struct ata_port_info *ppi[] = { NULL, NULL }; 760 const struct ata_port_info *ppi[] = { NULL, NULL };
761 static char *mode[2] = { "pass through", "smart" }; 761 static char *mode[2] = { "pass through", "smart" };
762 int rc;
763
764 rc = pcim_enable_device(pdev);
765 if (rc)
766 return rc;
762 767
763 /* Force the card into bypass mode if so requested */ 768 /* Force the card into bypass mode if so requested */
764 if (it8212_noraid) { 769 if (it8212_noraid) {
@@ -780,10 +785,17 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
780#ifdef CONFIG_PM 785#ifdef CONFIG_PM
781static int it821x_reinit_one(struct pci_dev *pdev) 786static int it821x_reinit_one(struct pci_dev *pdev)
782{ 787{
788 struct ata_host *host = dev_get_drvdata(&pdev->dev);
789 int rc;
790
791 rc = ata_pci_device_do_resume(pdev);
792 if (rc)
793 return rc;
783 /* Resume - turn raid back off if need be */ 794 /* Resume - turn raid back off if need be */
784 if (it8212_noraid) 795 if (it8212_noraid)
785 it821x_disable_raid(pdev); 796 it821x_disable_raid(pdev);
786 return ata_pci_device_resume(pdev); 797 ata_host_resume(host);
798 return rc;
787} 799}
788#endif 800#endif
789 801
diff --git a/drivers/ata/pata_netcell.c b/drivers/ata/pata_netcell.c
index 25c922abd554..0e4a08e15209 100644
--- a/drivers/ata/pata_netcell.c
+++ b/drivers/ata/pata_netcell.c
@@ -100,11 +100,16 @@ static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *e
100 .port_ops = &netcell_ops, 100 .port_ops = &netcell_ops,
101 }; 101 };
102 const struct ata_port_info *port_info[] = { &info, NULL }; 102 const struct ata_port_info *port_info[] = { &info, NULL };
103 int rc;
103 104
104 if (!printed_version++) 105 if (!printed_version++)
105 dev_printk(KERN_DEBUG, &pdev->dev, 106 dev_printk(KERN_DEBUG, &pdev->dev,
106 "version " DRV_VERSION "\n"); 107 "version " DRV_VERSION "\n");
107 108
109 rc = pcim_enable_device(pdev);
110 if (rc)
111 return rc;
112
108 /* Any chip specific setup/optimisation/messages here */ 113 /* Any chip specific setup/optimisation/messages here */
109 ata_pci_clear_simplex(pdev); 114 ata_pci_clear_simplex(pdev);
110 115
diff --git a/drivers/ata/pata_ns87415.c b/drivers/ata/pata_ns87415.c
index d0e2e50823b1..93eb958cb0c9 100644
--- a/drivers/ata/pata_ns87415.c
+++ b/drivers/ata/pata_ns87415.c
@@ -410,6 +410,7 @@ static int ns87415_init_one (struct pci_dev *pdev, const struct pci_device_id *e
410 .port_ops = &ns87415_pata_ops, 410 .port_ops = &ns87415_pata_ops,
411 }; 411 };
412 const struct ata_port_info *ppi[] = { &info, NULL }; 412 const struct ata_port_info *ppi[] = { &info, NULL };
413 int rc;
413#if defined(CONFIG_SUPERIO) 414#if defined(CONFIG_SUPERIO)
414 static const struct ata_port_info info87560 = { 415 static const struct ata_port_info info87560 = {
415 .sht = &ns87415_sht, 416 .sht = &ns87415_sht,
@@ -425,6 +426,11 @@ static int ns87415_init_one (struct pci_dev *pdev, const struct pci_device_id *e
425 if (!printed_version++) 426 if (!printed_version++)
426 dev_printk(KERN_DEBUG, &pdev->dev, 427 dev_printk(KERN_DEBUG, &pdev->dev,
427 "version " DRV_VERSION "\n"); 428 "version " DRV_VERSION "\n");
429
430 rc = pcim_enable_device(pdev);
431 if (rc)
432 return rc;
433
428 /* Select 512 byte sectors */ 434 /* Select 512 byte sectors */
429 pci_write_config_byte(pdev, 0x55, 0xEE); 435 pci_write_config_byte(pdev, 0x55, 0xEE);
430 /* Select PIO0 8bit clocking */ 436 /* Select PIO0 8bit clocking */
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c
index f9b485a487ae..be8c421dc2aa 100644
--- a/drivers/ata/pata_optidma.c
+++ b/drivers/ata/pata_optidma.c
@@ -497,10 +497,15 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id)
497 }; 497 };
498 const struct ata_port_info *ppi[] = { &info_82c700, NULL }; 498 const struct ata_port_info *ppi[] = { &info_82c700, NULL };
499 static int printed_version; 499 static int printed_version;
500 int rc;
500 501
501 if (!printed_version++) 502 if (!printed_version++)
502 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); 503 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n");
503 504
505 rc = pcim_enable_device(dev);
506 if (rc)
507 return rc;
508
504 /* Fixed location chipset magic */ 509 /* Fixed location chipset magic */
505 inw(0x1F1); 510 inw(0x1F1);
506 inw(0x1F1); 511 inw(0x1F1);
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c
index a589c0fa0dbb..6702df37cfed 100644
--- a/drivers/ata/pata_serverworks.c
+++ b/drivers/ata/pata_serverworks.c
@@ -498,6 +498,11 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
498 } 498 }
499 }; 499 };
500 const struct ata_port_info *ppi[] = { &info[id->driver_data], NULL }; 500 const struct ata_port_info *ppi[] = { &info[id->driver_data], NULL };
501 int rc;
502
503 rc = pcim_enable_device(pdev);
504 if (rc)
505 return rc;
501 506
502 /* Force master latency timer to 64 PCI clocks */ 507 /* Force master latency timer to 64 PCI clocks */
503 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40); 508 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40);
@@ -535,11 +540,17 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
535#ifdef CONFIG_PM 540#ifdef CONFIG_PM
536static int serverworks_reinit_one(struct pci_dev *pdev) 541static int serverworks_reinit_one(struct pci_dev *pdev)
537{ 542{
543 struct ata_host *host = dev_get_drvdata(&pdev->dev);
544 int rc;
545
546 rc = ata_pci_device_do_resume(pdev);
547 if (rc)
548 return rc;
549
538 /* Force master latency timer to 64 PCI clocks */ 550 /* Force master latency timer to 64 PCI clocks */
539 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40); 551 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40);
540 552
541 switch (pdev->device) 553 switch (pdev->device) {
542 {
543 case PCI_DEVICE_ID_SERVERWORKS_OSB4IDE: 554 case PCI_DEVICE_ID_SERVERWORKS_OSB4IDE:
544 serverworks_fixup_osb4(pdev); 555 serverworks_fixup_osb4(pdev);
545 break; 556 break;
@@ -554,7 +565,9 @@ static int serverworks_reinit_one(struct pci_dev *pdev)
554 serverworks_fixup_ht1000(pdev); 565 serverworks_fixup_ht1000(pdev);
555 break; 566 break;
556 } 567 }
557 return ata_pci_device_resume(pdev); 568
569 ata_host_resume(host);
570 return 0;
558} 571}
559#endif 572#endif
560 573
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c
index 7c5b2dd9a1a1..f4dc09718cab 100644
--- a/drivers/ata/pata_sil680.c
+++ b/drivers/ata/pata_sil680.c
@@ -346,6 +346,10 @@ static int __devinit sil680_init_one(struct pci_dev *pdev,
346 if (!printed_version++) 346 if (!printed_version++)
347 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); 347 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
348 348
349 rc = pcim_enable_device(pdev);
350 if (rc)
351 return rc;
352
349 switch (sil680_init_chip(pdev, &try_mmio)) { 353 switch (sil680_init_chip(pdev, &try_mmio)) {
350 case 0: 354 case 0:
351 ppi[0] = &info_slow; 355 ppi[0] = &info_slow;
@@ -406,10 +410,15 @@ use_ioports:
406#ifdef CONFIG_PM 410#ifdef CONFIG_PM
407static int sil680_reinit_one(struct pci_dev *pdev) 411static int sil680_reinit_one(struct pci_dev *pdev)
408{ 412{
409 int try_mmio; 413 struct ata_host *host = dev_get_drvdata(&pdev->dev);
414 int try_mmio, rc;
410 415
416 rc = ata_pci_device_do_resume(pdev);
417 if (rc)
418 return rc;
411 sil680_init_chip(pdev, &try_mmio); 419 sil680_init_chip(pdev, &try_mmio);
412 return ata_pci_device_resume(pdev); 420 ata_host_resume(host);
421 return 0;
413} 422}
414#endif 423#endif
415 424
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index dc7e91562e43..abda90f51247 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -862,6 +862,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
862 struct pci_dev *host = NULL; 862 struct pci_dev *host = NULL;
863 struct sis_chipset *chipset = NULL; 863 struct sis_chipset *chipset = NULL;
864 struct sis_chipset *sets; 864 struct sis_chipset *sets;
865 int rc;
865 866
866 static struct sis_chipset sis_chipsets[] = { 867 static struct sis_chipset sis_chipsets[] = {
867 868
@@ -914,8 +915,11 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
914 dev_printk(KERN_DEBUG, &pdev->dev, 915 dev_printk(KERN_DEBUG, &pdev->dev,
915 "version " DRV_VERSION "\n"); 916 "version " DRV_VERSION "\n");
916 917
917 /* We have to find the bridge first */ 918 rc = pcim_enable_device(pdev);
919 if (rc)
920 return rc;
918 921
922 /* We have to find the bridge first */
919 for (sets = &sis_chipsets[0]; sets->device; sets++) { 923 for (sets = &sis_chipsets[0]; sets->device; sets++) {
920 host = pci_get_device(PCI_VENDOR_ID_SI, sets->device, NULL); 924 host = pci_get_device(PCI_VENDOR_ID_SI, sets->device, NULL);
921 if (host != NULL) { 925 if (host != NULL) {
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c
index 81ef207f8265..6c37181341ea 100644
--- a/drivers/ata/pata_sl82c105.c
+++ b/drivers/ata/pata_sl82c105.c
@@ -344,6 +344,11 @@ static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id
344 NULL }; 344 NULL };
345 u32 val; 345 u32 val;
346 int rev; 346 int rev;
347 int rc;
348
349 rc = pcim_enable_device(dev);
350 if (rc)
351 return rc;
347 352
348 rev = sl82c105_bridge_revision(dev); 353 rev = sl82c105_bridge_revision(dev);
349 354
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index d119a68c388f..24430f70f00e 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -524,10 +524,15 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
524 static int printed_version; 524 static int printed_version;
525 u8 enable; 525 u8 enable;
526 u32 timing; 526 u32 timing;
527 int rc;
527 528
528 if (!printed_version++) 529 if (!printed_version++)
529 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); 530 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
530 531
532 rc = pcim_enable_device(pdev);
533 if (rc)
534 return rc;
535
531 /* To find out how the IDE will behave and what features we 536 /* To find out how the IDE will behave and what features we
532 actually have to look at the bridge not the IDE controller */ 537 actually have to look at the bridge not the IDE controller */
533 for (config = via_isa_bridges; config->id; config++) 538 for (config = via_isa_bridges; config->id; config++)
@@ -615,6 +620,11 @@ static int via_reinit_one(struct pci_dev *pdev)
615 u32 timing; 620 u32 timing;
616 struct ata_host *host = dev_get_drvdata(&pdev->dev); 621 struct ata_host *host = dev_get_drvdata(&pdev->dev);
617 const struct via_isa_bridge *config = host->private_data; 622 const struct via_isa_bridge *config = host->private_data;
623 int rc;
624
625 rc = ata_pci_device_do_resume(pdev);
626 if (rc)
627 return rc;
618 628
619 via_config_fifo(pdev, config->flags); 629 via_config_fifo(pdev, config->flags);
620 630
@@ -630,7 +640,9 @@ static int via_reinit_one(struct pci_dev *pdev)
630 timing &= ~0x80008; 640 timing &= ~0x80008;
631 pci_write_config_dword(pdev, 0x50, timing); 641 pci_write_config_dword(pdev, 0x50, timing);
632 } 642 }
633 return ata_pci_device_resume(pdev); 643
644 ata_host_resume(host);
645 return 0;
634} 646}
635#endif 647#endif
636 648