aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pcie
diff options
context:
space:
mode:
authorlong <tlnguyen@snoqualmie.dp.intel.com>2005-06-22 12:09:54 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-07-01 16:35:51 -0400
commit5823d100ae260d022b4dd5ec9cc0b85f0bf0d646 (patch)
tree20cb85773cb51eed009a8b0f4646ebc4db7c293a /drivers/pci/pcie
parenta00db371624e2e3718e5ab7d73bf364681098106 (diff)
[PATCH] PCI: acpi tg3 ethernet not coming back properly after S3 suspendon DellM70
This patch, is based on kernel 2.6.12, provides a fix for PCIe port bus driver suspend/resume. Signed-off-by: T. Long Nguyen <tom.l.nguyen@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/pcie')
-rw-r--r--drivers/pci/pcie/portdrv.h5
-rw-r--r--drivers/pci/pcie/portdrv_core.c8
-rw-r--r--drivers/pci/pcie/portdrv_pci.c79
3 files changed, 91 insertions, 1 deletions
diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h
index 537b372dc340..a63bd8f72601 100644
--- a/drivers/pci/pcie/portdrv.h
+++ b/drivers/pci/pcie/portdrv.h
@@ -27,6 +27,11 @@
27 27
28#define get_descriptor_id(type, service) (((type - 4) << 4) | service) 28#define get_descriptor_id(type, service) (((type - 4) << 4) | service)
29 29
30struct pcie_port_device_ext {
31 int interrupt_mode; /* [0:INTx | 1:MSI | 2:MSI-X] */
32 unsigned int saved_msi_config_space[5];
33};
34
30extern struct bus_type pcie_port_bus_type; 35extern struct bus_type pcie_port_bus_type;
31extern int pcie_port_device_probe(struct pci_dev *dev); 36extern int pcie_port_device_probe(struct pci_dev *dev);
32extern int pcie_port_device_register(struct pci_dev *dev); 37extern int pcie_port_device_register(struct pci_dev *dev);
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index f5c5f10a3d2f..4db69982876e 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -275,10 +275,17 @@ int pcie_port_device_probe(struct pci_dev *dev)
275 275
276int pcie_port_device_register(struct pci_dev *dev) 276int pcie_port_device_register(struct pci_dev *dev)
277{ 277{
278 struct pcie_port_device_ext *p_ext;
278 int status, type, capabilities, irq_mode, i; 279 int status, type, capabilities, irq_mode, i;
279 int vectors[PCIE_PORT_DEVICE_MAXSERVICES]; 280 int vectors[PCIE_PORT_DEVICE_MAXSERVICES];
280 u16 reg16; 281 u16 reg16;
281 282
283 /* Allocate port device extension */
284 if (!(p_ext = kmalloc(sizeof(struct pcie_port_device_ext), GFP_KERNEL)))
285 return -ENOMEM;
286
287 pci_set_drvdata(dev, p_ext);
288
282 /* Get port type */ 289 /* Get port type */
283 pci_read_config_word(dev, 290 pci_read_config_word(dev,
284 pci_find_capability(dev, PCI_CAP_ID_EXP) + 291 pci_find_capability(dev, PCI_CAP_ID_EXP) +
@@ -288,6 +295,7 @@ int pcie_port_device_register(struct pci_dev *dev)
288 /* Now get port services */ 295 /* Now get port services */
289 capabilities = get_port_device_capability(dev); 296 capabilities = get_port_device_capability(dev);
290 irq_mode = assign_interrupt_mode(dev, vectors, capabilities); 297 irq_mode = assign_interrupt_mode(dev, vectors, capabilities);
298 p_ext->interrupt_mode = irq_mode;
291 299
292 /* Allocate child services if any */ 300 /* Allocate child services if any */
293 for (i = 0; i < PCIE_PORT_DEVICE_MAXSERVICES; i++) { 301 for (i = 0; i < PCIE_PORT_DEVICE_MAXSERVICES; i++) {
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index e9095ee508e3..30bac7ed7c16 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -29,6 +29,78 @@ MODULE_LICENSE("GPL");
29/* global data */ 29/* global data */
30static const char device_name[] = "pcieport-driver"; 30static const char device_name[] = "pcieport-driver";
31 31
32static void pci_save_msi_state(struct pci_dev *dev)
33{
34 struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev);
35 int i = 0, pos;
36 u16 control;
37
38 if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSI)) <= 0)
39 return;
40
41 pci_read_config_dword(dev, pos, &p_ext->saved_msi_config_space[i++]);
42 control = p_ext->saved_msi_config_space[0] >> 16;
43 pci_read_config_dword(dev, pos + PCI_MSI_ADDRESS_LO,
44 &p_ext->saved_msi_config_space[i++]);
45 if (control & PCI_MSI_FLAGS_64BIT) {
46 pci_read_config_dword(dev, pos + PCI_MSI_ADDRESS_HI,
47 &p_ext->saved_msi_config_space[i++]);
48 pci_read_config_dword(dev, pos + PCI_MSI_DATA_64,
49 &p_ext->saved_msi_config_space[i++]);
50 } else
51 pci_read_config_dword(dev, pos + PCI_MSI_DATA_32,
52 &p_ext->saved_msi_config_space[i++]);
53 if (control & PCI_MSI_FLAGS_MASKBIT)
54 pci_read_config_dword(dev, pos + PCI_MSI_MASK_BIT,
55 &p_ext->saved_msi_config_space[i++]);
56}
57
58static void pci_restore_msi_state(struct pci_dev *dev)
59{
60 struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev);
61 int i = 0, pos;
62 u16 control;
63
64 if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSI)) <= 0)
65 return;
66
67 control = p_ext->saved_msi_config_space[i++] >> 16;
68 pci_write_config_word(dev, pos + PCI_MSI_FLAGS, control);
69 pci_write_config_dword(dev, pos + PCI_MSI_ADDRESS_LO,
70 p_ext->saved_msi_config_space[i++]);
71 if (control & PCI_MSI_FLAGS_64BIT) {
72 pci_write_config_dword(dev, pos + PCI_MSI_ADDRESS_HI,
73 p_ext->saved_msi_config_space[i++]);
74 pci_write_config_dword(dev, pos + PCI_MSI_DATA_64,
75 p_ext->saved_msi_config_space[i++]);
76 } else
77 pci_write_config_dword(dev, pos + PCI_MSI_DATA_32,
78 p_ext->saved_msi_config_space[i++]);
79 if (control & PCI_MSI_FLAGS_MASKBIT)
80 pci_write_config_dword(dev, pos + PCI_MSI_MASK_BIT,
81 p_ext->saved_msi_config_space[i++]);
82}
83
84static void pcie_portdrv_save_config(struct pci_dev *dev)
85{
86 struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev);
87
88 pci_save_state(dev);
89 if (p_ext->interrupt_mode == PCIE_PORT_MSI_MODE)
90 pci_save_msi_state(dev);
91}
92
93static void pcie_portdrv_restore_config(struct pci_dev *dev)
94{
95 struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev);
96
97 pci_restore_state(dev);
98 if (p_ext->interrupt_mode == PCIE_PORT_MSI_MODE)
99 pci_restore_msi_state(dev);
100 pci_enable_device(dev);
101 pci_set_master(dev);
102}
103
32/* 104/*
33 * pcie_portdrv_probe - Probe PCI-Express port devices 105 * pcie_portdrv_probe - Probe PCI-Express port devices
34 * @dev: PCI-Express port device being probed 106 * @dev: PCI-Express port device being probed
@@ -64,16 +136,21 @@ static int __devinit pcie_portdrv_probe (struct pci_dev *dev,
64static void pcie_portdrv_remove (struct pci_dev *dev) 136static void pcie_portdrv_remove (struct pci_dev *dev)
65{ 137{
66 pcie_port_device_remove(dev); 138 pcie_port_device_remove(dev);
139 kfree(pci_get_drvdata(dev));
67} 140}
68 141
69#ifdef CONFIG_PM 142#ifdef CONFIG_PM
70static int pcie_portdrv_suspend (struct pci_dev *dev, pm_message_t state) 143static int pcie_portdrv_suspend (struct pci_dev *dev, pm_message_t state)
71{ 144{
72 return pcie_port_device_suspend(dev, state); 145 int ret = pcie_port_device_suspend(dev, state);
146
147 pcie_portdrv_save_config(dev);
148 return ret;
73} 149}
74 150
75static int pcie_portdrv_resume (struct pci_dev *dev) 151static int pcie_portdrv_resume (struct pci_dev *dev)
76{ 152{
153 pcie_portdrv_restore_config(dev);
77 return pcie_port_device_resume(dev); 154 return pcie_port_device_resume(dev);
78} 155}
79#endif 156#endif