aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_via.c
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/pata_via.c
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/pata_via.c')
-rw-r--r--drivers/ata/pata_via.c14
1 files changed, 13 insertions, 1 deletions
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