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>
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index d119a68..24430f7 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -524,10 +524,15 @@
static int printed_version;
u8 enable;
u32 timing;
+ int rc;
if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
+ rc = pcim_enable_device(pdev);
+ if (rc)
+ return rc;
+
/* To find out how the IDE will behave and what features we
actually have to look at the bridge not the IDE controller */
for (config = via_isa_bridges; config->id; config++)
@@ -615,6 +620,11 @@
u32 timing;
struct ata_host *host = dev_get_drvdata(&pdev->dev);
const struct via_isa_bridge *config = host->private_data;
+ int rc;
+
+ rc = ata_pci_device_do_resume(pdev);
+ if (rc)
+ return rc;
via_config_fifo(pdev, config->flags);
@@ -630,7 +640,9 @@
timing &= ~0x80008;
pci_write_config_dword(pdev, 0x50, timing);
}
- return ata_pci_device_resume(pdev);
+
+ ata_host_resume(host);
+ return 0;
}
#endif