diff options
Diffstat (limited to 'drivers/pci/pcie')
-rw-r--r-- | drivers/pci/pcie/aer/aer_inject.c | 2 | ||||
-rw-r--r-- | drivers/pci/pcie/aer/aerdrv.c | 24 | ||||
-rw-r--r-- | drivers/pci/pcie/aer/aerdrv_acpi.c | 2 | ||||
-rw-r--r-- | drivers/pci/pcie/aer/aerdrv_core.c | 53 | ||||
-rw-r--r-- | drivers/pci/pcie/aspm.c | 119 | ||||
-rw-r--r-- | drivers/pci/pcie/pme.c | 29 | ||||
-rw-r--r-- | drivers/pci/pcie/portdrv_bus.c | 2 | ||||
-rw-r--r-- | drivers/pci/pcie/portdrv_core.c | 34 | ||||
-rw-r--r-- | drivers/pci/pcie/portdrv_pci.c | 17 |
9 files changed, 104 insertions, 178 deletions
diff --git a/drivers/pci/pcie/aer/aer_inject.c b/drivers/pci/pcie/aer/aer_inject.c index 52229863e9fe..4e24cb8a94ae 100644 --- a/drivers/pci/pcie/aer/aer_inject.c +++ b/drivers/pci/pcie/aer/aer_inject.c | |||
@@ -288,7 +288,7 @@ static struct pci_dev *pcie_find_root_port(struct pci_dev *dev) | |||
288 | while (1) { | 288 | while (1) { |
289 | if (!pci_is_pcie(dev)) | 289 | if (!pci_is_pcie(dev)) |
290 | break; | 290 | break; |
291 | if (dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) | 291 | if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) |
292 | return dev; | 292 | return dev; |
293 | if (!dev->bus->self) | 293 | if (!dev->bus->self) |
294 | break; | 294 | break; |
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c index 7131644e3ae6..030cf12d5468 100644 --- a/drivers/pci/pcie/aer/aerdrv.c +++ b/drivers/pci/pcie/aer/aerdrv.c | |||
@@ -81,10 +81,11 @@ bool pci_aer_available(void) | |||
81 | static int set_device_error_reporting(struct pci_dev *dev, void *data) | 81 | static int set_device_error_reporting(struct pci_dev *dev, void *data) |
82 | { | 82 | { |
83 | bool enable = *((bool *)data); | 83 | bool enable = *((bool *)data); |
84 | int type = pci_pcie_type(dev); | ||
84 | 85 | ||
85 | if ((dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) || | 86 | if ((type == PCI_EXP_TYPE_ROOT_PORT) || |
86 | (dev->pcie_type == PCI_EXP_TYPE_UPSTREAM) || | 87 | (type == PCI_EXP_TYPE_UPSTREAM) || |
87 | (dev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM)) { | 88 | (type == PCI_EXP_TYPE_DOWNSTREAM)) { |
88 | if (enable) | 89 | if (enable) |
89 | pci_enable_pcie_error_reporting(dev); | 90 | pci_enable_pcie_error_reporting(dev); |
90 | else | 91 | else |
@@ -121,19 +122,17 @@ static void set_downstream_devices_error_reporting(struct pci_dev *dev, | |||
121 | static void aer_enable_rootport(struct aer_rpc *rpc) | 122 | static void aer_enable_rootport(struct aer_rpc *rpc) |
122 | { | 123 | { |
123 | struct pci_dev *pdev = rpc->rpd->port; | 124 | struct pci_dev *pdev = rpc->rpd->port; |
124 | int pos, aer_pos; | 125 | int aer_pos; |
125 | u16 reg16; | 126 | u16 reg16; |
126 | u32 reg32; | 127 | u32 reg32; |
127 | 128 | ||
128 | pos = pci_pcie_cap(pdev); | ||
129 | /* Clear PCIe Capability's Device Status */ | 129 | /* Clear PCIe Capability's Device Status */ |
130 | pci_read_config_word(pdev, pos+PCI_EXP_DEVSTA, ®16); | 130 | pcie_capability_read_word(pdev, PCI_EXP_DEVSTA, ®16); |
131 | pci_write_config_word(pdev, pos+PCI_EXP_DEVSTA, reg16); | 131 | pcie_capability_write_word(pdev, PCI_EXP_DEVSTA, reg16); |
132 | 132 | ||
133 | /* Disable system error generation in response to error messages */ | 133 | /* Disable system error generation in response to error messages */ |
134 | pci_read_config_word(pdev, pos + PCI_EXP_RTCTL, ®16); | 134 | pcie_capability_clear_word(pdev, PCI_EXP_RTCTL, |
135 | reg16 &= ~(SYSTEM_ERROR_INTR_ON_MESG_MASK); | 135 | SYSTEM_ERROR_INTR_ON_MESG_MASK); |
136 | pci_write_config_word(pdev, pos + PCI_EXP_RTCTL, reg16); | ||
137 | 136 | ||
138 | aer_pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR); | 137 | aer_pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR); |
139 | /* Clear error status */ | 138 | /* Clear error status */ |
@@ -395,9 +394,8 @@ static void aer_error_resume(struct pci_dev *dev) | |||
395 | u16 reg16; | 394 | u16 reg16; |
396 | 395 | ||
397 | /* Clean up Root device status */ | 396 | /* Clean up Root device status */ |
398 | pos = pci_pcie_cap(dev); | 397 | pcie_capability_read_word(dev, PCI_EXP_DEVSTA, ®16); |
399 | pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, ®16); | 398 | pcie_capability_write_word(dev, PCI_EXP_DEVSTA, reg16); |
400 | pci_write_config_word(dev, pos + PCI_EXP_DEVSTA, reg16); | ||
401 | 399 | ||
402 | /* Clean AER Root Error Status */ | 400 | /* Clean AER Root Error Status */ |
403 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); | 401 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); |
diff --git a/drivers/pci/pcie/aer/aerdrv_acpi.c b/drivers/pci/pcie/aer/aerdrv_acpi.c index 124f20ff11b2..5194a7d41730 100644 --- a/drivers/pci/pcie/aer/aerdrv_acpi.c +++ b/drivers/pci/pcie/aer/aerdrv_acpi.c | |||
@@ -60,7 +60,7 @@ static int aer_hest_parse(struct acpi_hest_header *hest_hdr, void *data) | |||
60 | p = (struct acpi_hest_aer_common *)(hest_hdr + 1); | 60 | p = (struct acpi_hest_aer_common *)(hest_hdr + 1); |
61 | if (p->flags & ACPI_HEST_GLOBAL) { | 61 | if (p->flags & ACPI_HEST_GLOBAL) { |
62 | if ((pci_is_pcie(info->pci_dev) && | 62 | if ((pci_is_pcie(info->pci_dev) && |
63 | info->pci_dev->pcie_type == pcie_type) || bridge) | 63 | pci_pcie_type(info->pci_dev) == pcie_type) || bridge) |
64 | ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST); | 64 | ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST); |
65 | } else | 65 | } else |
66 | if (hest_match_pci(p, info->pci_dev)) | 66 | if (hest_match_pci(p, info->pci_dev)) |
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c index dc901771d34b..cd46d74ec806 100644 --- a/drivers/pci/pcie/aer/aerdrv_core.c +++ b/drivers/pci/pcie/aer/aerdrv_core.c | |||
@@ -32,53 +32,28 @@ static bool nosourceid; | |||
32 | module_param(forceload, bool, 0); | 32 | module_param(forceload, bool, 0); |
33 | module_param(nosourceid, bool, 0); | 33 | module_param(nosourceid, bool, 0); |
34 | 34 | ||
35 | #define PCI_EXP_AER_FLAGS (PCI_EXP_DEVCTL_CERE | PCI_EXP_DEVCTL_NFERE | \ | ||
36 | PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE) | ||
37 | |||
35 | int pci_enable_pcie_error_reporting(struct pci_dev *dev) | 38 | int pci_enable_pcie_error_reporting(struct pci_dev *dev) |
36 | { | 39 | { |
37 | u16 reg16 = 0; | ||
38 | int pos; | ||
39 | |||
40 | if (pcie_aer_get_firmware_first(dev)) | 40 | if (pcie_aer_get_firmware_first(dev)) |
41 | return -EIO; | 41 | return -EIO; |
42 | 42 | ||
43 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); | 43 | if (!pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR)) |
44 | if (!pos) | ||
45 | return -EIO; | ||
46 | |||
47 | pos = pci_pcie_cap(dev); | ||
48 | if (!pos) | ||
49 | return -EIO; | 44 | return -EIO; |
50 | 45 | ||
51 | pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, ®16); | 46 | return pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_AER_FLAGS); |
52 | reg16 |= (PCI_EXP_DEVCTL_CERE | | ||
53 | PCI_EXP_DEVCTL_NFERE | | ||
54 | PCI_EXP_DEVCTL_FERE | | ||
55 | PCI_EXP_DEVCTL_URRE); | ||
56 | pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, reg16); | ||
57 | |||
58 | return 0; | ||
59 | } | 47 | } |
60 | EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting); | 48 | EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting); |
61 | 49 | ||
62 | int pci_disable_pcie_error_reporting(struct pci_dev *dev) | 50 | int pci_disable_pcie_error_reporting(struct pci_dev *dev) |
63 | { | 51 | { |
64 | u16 reg16 = 0; | ||
65 | int pos; | ||
66 | |||
67 | if (pcie_aer_get_firmware_first(dev)) | 52 | if (pcie_aer_get_firmware_first(dev)) |
68 | return -EIO; | 53 | return -EIO; |
69 | 54 | ||
70 | pos = pci_pcie_cap(dev); | 55 | return pcie_capability_clear_word(dev, PCI_EXP_DEVCTL, |
71 | if (!pos) | 56 | PCI_EXP_AER_FLAGS); |
72 | return -EIO; | ||
73 | |||
74 | pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, ®16); | ||
75 | reg16 &= ~(PCI_EXP_DEVCTL_CERE | | ||
76 | PCI_EXP_DEVCTL_NFERE | | ||
77 | PCI_EXP_DEVCTL_FERE | | ||
78 | PCI_EXP_DEVCTL_URRE); | ||
79 | pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, reg16); | ||
80 | |||
81 | return 0; | ||
82 | } | 57 | } |
83 | EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting); | 58 | EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting); |
84 | 59 | ||
@@ -151,18 +126,12 @@ static bool is_error_source(struct pci_dev *dev, struct aer_err_info *e_info) | |||
151 | */ | 126 | */ |
152 | if (atomic_read(&dev->enable_cnt) == 0) | 127 | if (atomic_read(&dev->enable_cnt) == 0) |
153 | return false; | 128 | return false; |
154 | pos = pci_pcie_cap(dev); | ||
155 | if (!pos) | ||
156 | return false; | ||
157 | 129 | ||
158 | /* Check if AER is enabled */ | 130 | /* Check if AER is enabled */ |
159 | pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, ®16); | 131 | pcie_capability_read_word(dev, PCI_EXP_DEVCTL, ®16); |
160 | if (!(reg16 & ( | 132 | if (!(reg16 & PCI_EXP_AER_FLAGS)) |
161 | PCI_EXP_DEVCTL_CERE | | ||
162 | PCI_EXP_DEVCTL_NFERE | | ||
163 | PCI_EXP_DEVCTL_FERE | | ||
164 | PCI_EXP_DEVCTL_URRE))) | ||
165 | return false; | 133 | return false; |
134 | |||
166 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); | 135 | pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); |
167 | if (!pos) | 136 | if (!pos) |
168 | return false; | 137 | return false; |
@@ -465,7 +434,7 @@ static pci_ers_result_t reset_link(struct pci_dev *dev) | |||
465 | 434 | ||
466 | if (driver && driver->reset_link) { | 435 | if (driver && driver->reset_link) { |
467 | status = driver->reset_link(udev); | 436 | status = driver->reset_link(udev); |
468 | } else if (udev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM) { | 437 | } else if (pci_pcie_type(udev) == PCI_EXP_TYPE_DOWNSTREAM) { |
469 | status = default_downstream_reset_link(udev); | 438 | status = default_downstream_reset_link(udev); |
470 | } else { | 439 | } else { |
471 | dev_printk(KERN_DEBUG, &dev->dev, | 440 | dev_printk(KERN_DEBUG, &dev->dev, |
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index b500840a143b..213753b283a6 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c | |||
@@ -125,21 +125,16 @@ static int policy_to_clkpm_state(struct pcie_link_state *link) | |||
125 | 125 | ||
126 | static void pcie_set_clkpm_nocheck(struct pcie_link_state *link, int enable) | 126 | static void pcie_set_clkpm_nocheck(struct pcie_link_state *link, int enable) |
127 | { | 127 | { |
128 | int pos; | ||
129 | u16 reg16; | ||
130 | struct pci_dev *child; | 128 | struct pci_dev *child; |
131 | struct pci_bus *linkbus = link->pdev->subordinate; | 129 | struct pci_bus *linkbus = link->pdev->subordinate; |
132 | 130 | ||
133 | list_for_each_entry(child, &linkbus->devices, bus_list) { | 131 | list_for_each_entry(child, &linkbus->devices, bus_list) { |
134 | pos = pci_pcie_cap(child); | ||
135 | if (!pos) | ||
136 | return; | ||
137 | pci_read_config_word(child, pos + PCI_EXP_LNKCTL, ®16); | ||
138 | if (enable) | 132 | if (enable) |
139 | reg16 |= PCI_EXP_LNKCTL_CLKREQ_EN; | 133 | pcie_capability_set_word(child, PCI_EXP_LNKCTL, |
134 | PCI_EXP_LNKCTL_CLKREQ_EN); | ||
140 | else | 135 | else |
141 | reg16 &= ~PCI_EXP_LNKCTL_CLKREQ_EN; | 136 | pcie_capability_clear_word(child, PCI_EXP_LNKCTL, |
142 | pci_write_config_word(child, pos + PCI_EXP_LNKCTL, reg16); | 137 | PCI_EXP_LNKCTL_CLKREQ_EN); |
143 | } | 138 | } |
144 | link->clkpm_enabled = !!enable; | 139 | link->clkpm_enabled = !!enable; |
145 | } | 140 | } |
@@ -157,7 +152,7 @@ static void pcie_set_clkpm(struct pcie_link_state *link, int enable) | |||
157 | 152 | ||
158 | static void pcie_clkpm_cap_init(struct pcie_link_state *link, int blacklist) | 153 | static void pcie_clkpm_cap_init(struct pcie_link_state *link, int blacklist) |
159 | { | 154 | { |
160 | int pos, capable = 1, enabled = 1; | 155 | int capable = 1, enabled = 1; |
161 | u32 reg32; | 156 | u32 reg32; |
162 | u16 reg16; | 157 | u16 reg16; |
163 | struct pci_dev *child; | 158 | struct pci_dev *child; |
@@ -165,16 +160,13 @@ static void pcie_clkpm_cap_init(struct pcie_link_state *link, int blacklist) | |||
165 | 160 | ||
166 | /* All functions should have the same cap and state, take the worst */ | 161 | /* All functions should have the same cap and state, take the worst */ |
167 | list_for_each_entry(child, &linkbus->devices, bus_list) { | 162 | list_for_each_entry(child, &linkbus->devices, bus_list) { |
168 | pos = pci_pcie_cap(child); | 163 | pcie_capability_read_dword(child, PCI_EXP_LNKCAP, ®32); |
169 | if (!pos) | ||
170 | return; | ||
171 | pci_read_config_dword(child, pos + PCI_EXP_LNKCAP, ®32); | ||
172 | if (!(reg32 & PCI_EXP_LNKCAP_CLKPM)) { | 164 | if (!(reg32 & PCI_EXP_LNKCAP_CLKPM)) { |
173 | capable = 0; | 165 | capable = 0; |
174 | enabled = 0; | 166 | enabled = 0; |
175 | break; | 167 | break; |
176 | } | 168 | } |
177 | pci_read_config_word(child, pos + PCI_EXP_LNKCTL, ®16); | 169 | pcie_capability_read_word(child, PCI_EXP_LNKCTL, ®16); |
178 | if (!(reg16 & PCI_EXP_LNKCTL_CLKREQ_EN)) | 170 | if (!(reg16 & PCI_EXP_LNKCTL_CLKREQ_EN)) |
179 | enabled = 0; | 171 | enabled = 0; |
180 | } | 172 | } |
@@ -190,7 +182,7 @@ static void pcie_clkpm_cap_init(struct pcie_link_state *link, int blacklist) | |||
190 | */ | 182 | */ |
191 | static void pcie_aspm_configure_common_clock(struct pcie_link_state *link) | 183 | static void pcie_aspm_configure_common_clock(struct pcie_link_state *link) |
192 | { | 184 | { |
193 | int ppos, cpos, same_clock = 1; | 185 | int same_clock = 1; |
194 | u16 reg16, parent_reg, child_reg[8]; | 186 | u16 reg16, parent_reg, child_reg[8]; |
195 | unsigned long start_jiffies; | 187 | unsigned long start_jiffies; |
196 | struct pci_dev *child, *parent = link->pdev; | 188 | struct pci_dev *child, *parent = link->pdev; |
@@ -203,46 +195,43 @@ static void pcie_aspm_configure_common_clock(struct pcie_link_state *link) | |||
203 | BUG_ON(!pci_is_pcie(child)); | 195 | BUG_ON(!pci_is_pcie(child)); |
204 | 196 | ||
205 | /* Check downstream component if bit Slot Clock Configuration is 1 */ | 197 | /* Check downstream component if bit Slot Clock Configuration is 1 */ |
206 | cpos = pci_pcie_cap(child); | 198 | pcie_capability_read_word(child, PCI_EXP_LNKSTA, ®16); |
207 | pci_read_config_word(child, cpos + PCI_EXP_LNKSTA, ®16); | ||
208 | if (!(reg16 & PCI_EXP_LNKSTA_SLC)) | 199 | if (!(reg16 & PCI_EXP_LNKSTA_SLC)) |
209 | same_clock = 0; | 200 | same_clock = 0; |
210 | 201 | ||
211 | /* Check upstream component if bit Slot Clock Configuration is 1 */ | 202 | /* Check upstream component if bit Slot Clock Configuration is 1 */ |
212 | ppos = pci_pcie_cap(parent); | 203 | pcie_capability_read_word(parent, PCI_EXP_LNKSTA, ®16); |
213 | pci_read_config_word(parent, ppos + PCI_EXP_LNKSTA, ®16); | ||
214 | if (!(reg16 & PCI_EXP_LNKSTA_SLC)) | 204 | if (!(reg16 & PCI_EXP_LNKSTA_SLC)) |
215 | same_clock = 0; | 205 | same_clock = 0; |
216 | 206 | ||
217 | /* Configure downstream component, all functions */ | 207 | /* Configure downstream component, all functions */ |
218 | list_for_each_entry(child, &linkbus->devices, bus_list) { | 208 | list_for_each_entry(child, &linkbus->devices, bus_list) { |
219 | cpos = pci_pcie_cap(child); | 209 | pcie_capability_read_word(child, PCI_EXP_LNKCTL, ®16); |
220 | pci_read_config_word(child, cpos + PCI_EXP_LNKCTL, ®16); | ||
221 | child_reg[PCI_FUNC(child->devfn)] = reg16; | 210 | child_reg[PCI_FUNC(child->devfn)] = reg16; |
222 | if (same_clock) | 211 | if (same_clock) |
223 | reg16 |= PCI_EXP_LNKCTL_CCC; | 212 | reg16 |= PCI_EXP_LNKCTL_CCC; |
224 | else | 213 | else |
225 | reg16 &= ~PCI_EXP_LNKCTL_CCC; | 214 | reg16 &= ~PCI_EXP_LNKCTL_CCC; |
226 | pci_write_config_word(child, cpos + PCI_EXP_LNKCTL, reg16); | 215 | pcie_capability_write_word(child, PCI_EXP_LNKCTL, reg16); |
227 | } | 216 | } |
228 | 217 | ||
229 | /* Configure upstream component */ | 218 | /* Configure upstream component */ |
230 | pci_read_config_word(parent, ppos + PCI_EXP_LNKCTL, ®16); | 219 | pcie_capability_read_word(parent, PCI_EXP_LNKCTL, ®16); |
231 | parent_reg = reg16; | 220 | parent_reg = reg16; |
232 | if (same_clock) | 221 | if (same_clock) |
233 | reg16 |= PCI_EXP_LNKCTL_CCC; | 222 | reg16 |= PCI_EXP_LNKCTL_CCC; |
234 | else | 223 | else |
235 | reg16 &= ~PCI_EXP_LNKCTL_CCC; | 224 | reg16 &= ~PCI_EXP_LNKCTL_CCC; |
236 | pci_write_config_word(parent, ppos + PCI_EXP_LNKCTL, reg16); | 225 | pcie_capability_write_word(parent, PCI_EXP_LNKCTL, reg16); |
237 | 226 | ||
238 | /* Retrain link */ | 227 | /* Retrain link */ |
239 | reg16 |= PCI_EXP_LNKCTL_RL; | 228 | reg16 |= PCI_EXP_LNKCTL_RL; |
240 | pci_write_config_word(parent, ppos + PCI_EXP_LNKCTL, reg16); | 229 | pcie_capability_write_word(parent, PCI_EXP_LNKCTL, reg16); |
241 | 230 | ||
242 | /* Wait for link training end. Break out after waiting for timeout */ | 231 | /* Wait for link training end. Break out after waiting for timeout */ |
243 | start_jiffies = jiffies; | 232 | start_jiffies = jiffies; |
244 | for (;;) { | 233 | for (;;) { |
245 | pci_read_config_word(parent, ppos + PCI_EXP_LNKSTA, ®16); | 234 | pcie_capability_read_word(parent, PCI_EXP_LNKSTA, ®16); |
246 | if (!(reg16 & PCI_EXP_LNKSTA_LT)) | 235 | if (!(reg16 & PCI_EXP_LNKSTA_LT)) |
247 | break; | 236 | break; |
248 | if (time_after(jiffies, start_jiffies + LINK_RETRAIN_TIMEOUT)) | 237 | if (time_after(jiffies, start_jiffies + LINK_RETRAIN_TIMEOUT)) |
@@ -255,12 +244,10 @@ static void pcie_aspm_configure_common_clock(struct pcie_link_state *link) | |||
255 | /* Training failed. Restore common clock configurations */ | 244 | /* Training failed. Restore common clock configurations */ |
256 | dev_printk(KERN_ERR, &parent->dev, | 245 | dev_printk(KERN_ERR, &parent->dev, |
257 | "ASPM: Could not configure common clock\n"); | 246 | "ASPM: Could not configure common clock\n"); |
258 | list_for_each_entry(child, &linkbus->devices, bus_list) { | 247 | list_for_each_entry(child, &linkbus->devices, bus_list) |
259 | cpos = pci_pcie_cap(child); | 248 | pcie_capability_write_word(child, PCI_EXP_LNKCTL, |
260 | pci_write_config_word(child, cpos + PCI_EXP_LNKCTL, | 249 | child_reg[PCI_FUNC(child->devfn)]); |
261 | child_reg[PCI_FUNC(child->devfn)]); | 250 | pcie_capability_write_word(parent, PCI_EXP_LNKCTL, parent_reg); |
262 | } | ||
263 | pci_write_config_word(parent, ppos + PCI_EXP_LNKCTL, parent_reg); | ||
264 | } | 251 | } |
265 | 252 | ||
266 | /* Convert L0s latency encoding to ns */ | 253 | /* Convert L0s latency encoding to ns */ |
@@ -305,16 +292,14 @@ struct aspm_register_info { | |||
305 | static void pcie_get_aspm_reg(struct pci_dev *pdev, | 292 | static void pcie_get_aspm_reg(struct pci_dev *pdev, |
306 | struct aspm_register_info *info) | 293 | struct aspm_register_info *info) |
307 | { | 294 | { |
308 | int pos; | ||
309 | u16 reg16; | 295 | u16 reg16; |
310 | u32 reg32; | 296 | u32 reg32; |
311 | 297 | ||
312 | pos = pci_pcie_cap(pdev); | 298 | pcie_capability_read_dword(pdev, PCI_EXP_LNKCAP, ®32); |
313 | pci_read_config_dword(pdev, pos + PCI_EXP_LNKCAP, ®32); | ||
314 | info->support = (reg32 & PCI_EXP_LNKCAP_ASPMS) >> 10; | 299 | info->support = (reg32 & PCI_EXP_LNKCAP_ASPMS) >> 10; |
315 | info->latency_encoding_l0s = (reg32 & PCI_EXP_LNKCAP_L0SEL) >> 12; | 300 | info->latency_encoding_l0s = (reg32 & PCI_EXP_LNKCAP_L0SEL) >> 12; |
316 | info->latency_encoding_l1 = (reg32 & PCI_EXP_LNKCAP_L1EL) >> 15; | 301 | info->latency_encoding_l1 = (reg32 & PCI_EXP_LNKCAP_L1EL) >> 15; |
317 | pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, ®16); | 302 | pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, ®16); |
318 | info->enabled = reg16 & PCI_EXP_LNKCTL_ASPMC; | 303 | info->enabled = reg16 & PCI_EXP_LNKCTL_ASPMC; |
319 | } | 304 | } |
320 | 305 | ||
@@ -412,7 +397,7 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) | |||
412 | * do ASPM for now. | 397 | * do ASPM for now. |
413 | */ | 398 | */ |
414 | list_for_each_entry(child, &linkbus->devices, bus_list) { | 399 | list_for_each_entry(child, &linkbus->devices, bus_list) { |
415 | if (child->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) { | 400 | if (pci_pcie_type(child) == PCI_EXP_TYPE_PCI_BRIDGE) { |
416 | link->aspm_disable = ASPM_STATE_ALL; | 401 | link->aspm_disable = ASPM_STATE_ALL; |
417 | break; | 402 | break; |
418 | } | 403 | } |
@@ -420,17 +405,15 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) | |||
420 | 405 | ||
421 | /* Get and check endpoint acceptable latencies */ | 406 | /* Get and check endpoint acceptable latencies */ |
422 | list_for_each_entry(child, &linkbus->devices, bus_list) { | 407 | list_for_each_entry(child, &linkbus->devices, bus_list) { |
423 | int pos; | ||
424 | u32 reg32, encoding; | 408 | u32 reg32, encoding; |
425 | struct aspm_latency *acceptable = | 409 | struct aspm_latency *acceptable = |
426 | &link->acceptable[PCI_FUNC(child->devfn)]; | 410 | &link->acceptable[PCI_FUNC(child->devfn)]; |
427 | 411 | ||
428 | if (child->pcie_type != PCI_EXP_TYPE_ENDPOINT && | 412 | if (pci_pcie_type(child) != PCI_EXP_TYPE_ENDPOINT && |
429 | child->pcie_type != PCI_EXP_TYPE_LEG_END) | 413 | pci_pcie_type(child) != PCI_EXP_TYPE_LEG_END) |
430 | continue; | 414 | continue; |
431 | 415 | ||
432 | pos = pci_pcie_cap(child); | 416 | pcie_capability_read_dword(child, PCI_EXP_DEVCAP, ®32); |
433 | pci_read_config_dword(child, pos + PCI_EXP_DEVCAP, ®32); | ||
434 | /* Calculate endpoint L0s acceptable latency */ | 417 | /* Calculate endpoint L0s acceptable latency */ |
435 | encoding = (reg32 & PCI_EXP_DEVCAP_L0S) >> 6; | 418 | encoding = (reg32 & PCI_EXP_DEVCAP_L0S) >> 6; |
436 | acceptable->l0s = calc_l0s_acceptable(encoding); | 419 | acceptable->l0s = calc_l0s_acceptable(encoding); |
@@ -444,13 +427,7 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) | |||
444 | 427 | ||
445 | static void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val) | 428 | static void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val) |
446 | { | 429 | { |
447 | u16 reg16; | 430 | pcie_capability_clear_and_set_word(pdev, PCI_EXP_LNKCTL, 0x3, val); |
448 | int pos = pci_pcie_cap(pdev); | ||
449 | |||
450 | pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, ®16); | ||
451 | reg16 &= ~0x3; | ||
452 | reg16 |= val; | ||
453 | pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16); | ||
454 | } | 431 | } |
455 | 432 | ||
456 | static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state) | 433 | static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state) |
@@ -505,7 +482,6 @@ static void free_link_state(struct pcie_link_state *link) | |||
505 | static int pcie_aspm_sanity_check(struct pci_dev *pdev) | 482 | static int pcie_aspm_sanity_check(struct pci_dev *pdev) |
506 | { | 483 | { |
507 | struct pci_dev *child; | 484 | struct pci_dev *child; |
508 | int pos; | ||
509 | u32 reg32; | 485 | u32 reg32; |
510 | 486 | ||
511 | /* | 487 | /* |
@@ -513,8 +489,7 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev) | |||
513 | * very strange. Disable ASPM for the whole slot | 489 | * very strange. Disable ASPM for the whole slot |
514 | */ | 490 | */ |
515 | list_for_each_entry(child, &pdev->subordinate->devices, bus_list) { | 491 | list_for_each_entry(child, &pdev->subordinate->devices, bus_list) { |
516 | pos = pci_pcie_cap(child); | 492 | if (!pci_is_pcie(child)) |
517 | if (!pos) | ||
518 | return -EINVAL; | 493 | return -EINVAL; |
519 | 494 | ||
520 | /* | 495 | /* |
@@ -530,7 +505,7 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev) | |||
530 | * Disable ASPM for pre-1.1 PCIe device, we follow MS to use | 505 | * Disable ASPM for pre-1.1 PCIe device, we follow MS to use |
531 | * RBER bit to determine if a function is 1.1 version device | 506 | * RBER bit to determine if a function is 1.1 version device |
532 | */ | 507 | */ |
533 | pci_read_config_dword(child, pos + PCI_EXP_DEVCAP, ®32); | 508 | pcie_capability_read_dword(child, PCI_EXP_DEVCAP, ®32); |
534 | if (!(reg32 & PCI_EXP_DEVCAP_RBER) && !aspm_force) { | 509 | if (!(reg32 & PCI_EXP_DEVCAP_RBER) && !aspm_force) { |
535 | dev_printk(KERN_INFO, &child->dev, "disabling ASPM" | 510 | dev_printk(KERN_INFO, &child->dev, "disabling ASPM" |
536 | " on pre-1.1 PCIe device. You can enable it" | 511 | " on pre-1.1 PCIe device. You can enable it" |
@@ -552,7 +527,7 @@ static struct pcie_link_state *alloc_pcie_link_state(struct pci_dev *pdev) | |||
552 | INIT_LIST_HEAD(&link->children); | 527 | INIT_LIST_HEAD(&link->children); |
553 | INIT_LIST_HEAD(&link->link); | 528 | INIT_LIST_HEAD(&link->link); |
554 | link->pdev = pdev; | 529 | link->pdev = pdev; |
555 | if (pdev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM) { | 530 | if (pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM) { |
556 | struct pcie_link_state *parent; | 531 | struct pcie_link_state *parent; |
557 | parent = pdev->bus->parent->self->link_state; | 532 | parent = pdev->bus->parent->self->link_state; |
558 | if (!parent) { | 533 | if (!parent) { |
@@ -585,12 +560,12 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev) | |||
585 | 560 | ||
586 | if (!pci_is_pcie(pdev) || pdev->link_state) | 561 | if (!pci_is_pcie(pdev) || pdev->link_state) |
587 | return; | 562 | return; |
588 | if (pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT && | 563 | if (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT && |
589 | pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) | 564 | pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM) |
590 | return; | 565 | return; |
591 | 566 | ||
592 | /* VIA has a strange chipset, root port is under a bridge */ | 567 | /* VIA has a strange chipset, root port is under a bridge */ |
593 | if (pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT && | 568 | if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT && |
594 | pdev->bus->self) | 569 | pdev->bus->self) |
595 | return; | 570 | return; |
596 | 571 | ||
@@ -647,8 +622,8 @@ static void pcie_update_aspm_capable(struct pcie_link_state *root) | |||
647 | if (link->root != root) | 622 | if (link->root != root) |
648 | continue; | 623 | continue; |
649 | list_for_each_entry(child, &linkbus->devices, bus_list) { | 624 | list_for_each_entry(child, &linkbus->devices, bus_list) { |
650 | if ((child->pcie_type != PCI_EXP_TYPE_ENDPOINT) && | 625 | if ((pci_pcie_type(child) != PCI_EXP_TYPE_ENDPOINT) && |
651 | (child->pcie_type != PCI_EXP_TYPE_LEG_END)) | 626 | (pci_pcie_type(child) != PCI_EXP_TYPE_LEG_END)) |
652 | continue; | 627 | continue; |
653 | pcie_aspm_check_latency(child); | 628 | pcie_aspm_check_latency(child); |
654 | } | 629 | } |
@@ -663,8 +638,8 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev) | |||
663 | 638 | ||
664 | if (!pci_is_pcie(pdev) || !parent || !parent->link_state) | 639 | if (!pci_is_pcie(pdev) || !parent || !parent->link_state) |
665 | return; | 640 | return; |
666 | if ((parent->pcie_type != PCI_EXP_TYPE_ROOT_PORT) && | 641 | if ((pci_pcie_type(parent) != PCI_EXP_TYPE_ROOT_PORT) && |
667 | (parent->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)) | 642 | (pci_pcie_type(parent) != PCI_EXP_TYPE_DOWNSTREAM)) |
668 | return; | 643 | return; |
669 | 644 | ||
670 | down_read(&pci_bus_sem); | 645 | down_read(&pci_bus_sem); |
@@ -704,8 +679,8 @@ void pcie_aspm_pm_state_change(struct pci_dev *pdev) | |||
704 | 679 | ||
705 | if (aspm_disabled || !pci_is_pcie(pdev) || !link) | 680 | if (aspm_disabled || !pci_is_pcie(pdev) || !link) |
706 | return; | 681 | return; |
707 | if ((pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) && | 682 | if ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) && |
708 | (pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)) | 683 | (pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM)) |
709 | return; | 684 | return; |
710 | /* | 685 | /* |
711 | * Devices changed PM state, we should recheck if latency | 686 | * Devices changed PM state, we should recheck if latency |
@@ -729,8 +704,8 @@ void pcie_aspm_powersave_config_link(struct pci_dev *pdev) | |||
729 | if (aspm_policy != POLICY_POWERSAVE) | 704 | if (aspm_policy != POLICY_POWERSAVE) |
730 | return; | 705 | return; |
731 | 706 | ||
732 | if ((pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) && | 707 | if ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) && |
733 | (pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)) | 708 | (pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM)) |
734 | return; | 709 | return; |
735 | 710 | ||
736 | down_read(&pci_bus_sem); | 711 | down_read(&pci_bus_sem); |
@@ -757,8 +732,8 @@ static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem, | |||
757 | if (!pci_is_pcie(pdev)) | 732 | if (!pci_is_pcie(pdev)) |
758 | return; | 733 | return; |
759 | 734 | ||
760 | if (pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT || | 735 | if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT || |
761 | pdev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM) | 736 | pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM) |
762 | parent = pdev; | 737 | parent = pdev; |
763 | if (!parent || !parent->link_state) | 738 | if (!parent || !parent->link_state) |
764 | return; | 739 | return; |
@@ -933,8 +908,8 @@ void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev) | |||
933 | struct pcie_link_state *link_state = pdev->link_state; | 908 | struct pcie_link_state *link_state = pdev->link_state; |
934 | 909 | ||
935 | if (!pci_is_pcie(pdev) || | 910 | if (!pci_is_pcie(pdev) || |
936 | (pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT && | 911 | (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT && |
937 | pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) || !link_state) | 912 | pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM) || !link_state) |
938 | return; | 913 | return; |
939 | 914 | ||
940 | if (link_state->aspm_support) | 915 | if (link_state->aspm_support) |
@@ -950,8 +925,8 @@ void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev) | |||
950 | struct pcie_link_state *link_state = pdev->link_state; | 925 | struct pcie_link_state *link_state = pdev->link_state; |
951 | 926 | ||
952 | if (!pci_is_pcie(pdev) || | 927 | if (!pci_is_pcie(pdev) || |
953 | (pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT && | 928 | (pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT && |
954 | pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) || !link_state) | 929 | pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM) || !link_state) |
955 | return; | 930 | return; |
956 | 931 | ||
957 | if (link_state->aspm_support) | 932 | if (link_state->aspm_support) |
diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c index 001f1b78f39c..9ca0dc9ffd84 100644 --- a/drivers/pci/pcie/pme.c +++ b/drivers/pci/pcie/pme.c | |||
@@ -57,17 +57,12 @@ struct pcie_pme_service_data { | |||
57 | */ | 57 | */ |
58 | void pcie_pme_interrupt_enable(struct pci_dev *dev, bool enable) | 58 | void pcie_pme_interrupt_enable(struct pci_dev *dev, bool enable) |
59 | { | 59 | { |
60 | int rtctl_pos; | ||
61 | u16 rtctl; | ||
62 | |||
63 | rtctl_pos = pci_pcie_cap(dev) + PCI_EXP_RTCTL; | ||
64 | |||
65 | pci_read_config_word(dev, rtctl_pos, &rtctl); | ||
66 | if (enable) | 60 | if (enable) |
67 | rtctl |= PCI_EXP_RTCTL_PMEIE; | 61 | pcie_capability_set_word(dev, PCI_EXP_RTCTL, |
62 | PCI_EXP_RTCTL_PMEIE); | ||
68 | else | 63 | else |
69 | rtctl &= ~PCI_EXP_RTCTL_PMEIE; | 64 | pcie_capability_clear_word(dev, PCI_EXP_RTCTL, |
70 | pci_write_config_word(dev, rtctl_pos, rtctl); | 65 | PCI_EXP_RTCTL_PMEIE); |
71 | } | 66 | } |
72 | 67 | ||
73 | /** | 68 | /** |
@@ -120,7 +115,7 @@ static bool pcie_pme_from_pci_bridge(struct pci_bus *bus, u8 devfn) | |||
120 | if (!dev) | 115 | if (!dev) |
121 | return false; | 116 | return false; |
122 | 117 | ||
123 | if (pci_is_pcie(dev) && dev->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) { | 118 | if (pci_is_pcie(dev) && pci_pcie_type(dev) == PCI_EXP_TYPE_PCI_BRIDGE) { |
124 | down_read(&pci_bus_sem); | 119 | down_read(&pci_bus_sem); |
125 | if (pcie_pme_walk_bus(bus)) | 120 | if (pcie_pme_walk_bus(bus)) |
126 | found = true; | 121 | found = true; |
@@ -226,18 +221,15 @@ static void pcie_pme_work_fn(struct work_struct *work) | |||
226 | struct pcie_pme_service_data *data = | 221 | struct pcie_pme_service_data *data = |
227 | container_of(work, struct pcie_pme_service_data, work); | 222 | container_of(work, struct pcie_pme_service_data, work); |
228 | struct pci_dev *port = data->srv->port; | 223 | struct pci_dev *port = data->srv->port; |
229 | int rtsta_pos; | ||
230 | u32 rtsta; | 224 | u32 rtsta; |
231 | 225 | ||
232 | rtsta_pos = pci_pcie_cap(port) + PCI_EXP_RTSTA; | ||
233 | |||
234 | spin_lock_irq(&data->lock); | 226 | spin_lock_irq(&data->lock); |
235 | 227 | ||
236 | for (;;) { | 228 | for (;;) { |
237 | if (data->noirq) | 229 | if (data->noirq) |
238 | break; | 230 | break; |
239 | 231 | ||
240 | pci_read_config_dword(port, rtsta_pos, &rtsta); | 232 | pcie_capability_read_dword(port, PCI_EXP_RTSTA, &rtsta); |
241 | if (rtsta & PCI_EXP_RTSTA_PME) { | 233 | if (rtsta & PCI_EXP_RTSTA_PME) { |
242 | /* | 234 | /* |
243 | * Clear PME status of the port. If there are other | 235 | * Clear PME status of the port. If there are other |
@@ -276,17 +268,14 @@ static irqreturn_t pcie_pme_irq(int irq, void *context) | |||
276 | { | 268 | { |
277 | struct pci_dev *port; | 269 | struct pci_dev *port; |
278 | struct pcie_pme_service_data *data; | 270 | struct pcie_pme_service_data *data; |
279 | int rtsta_pos; | ||
280 | u32 rtsta; | 271 | u32 rtsta; |
281 | unsigned long flags; | 272 | unsigned long flags; |
282 | 273 | ||
283 | port = ((struct pcie_device *)context)->port; | 274 | port = ((struct pcie_device *)context)->port; |
284 | data = get_service_data((struct pcie_device *)context); | 275 | data = get_service_data((struct pcie_device *)context); |
285 | 276 | ||
286 | rtsta_pos = pci_pcie_cap(port) + PCI_EXP_RTSTA; | ||
287 | |||
288 | spin_lock_irqsave(&data->lock, flags); | 277 | spin_lock_irqsave(&data->lock, flags); |
289 | pci_read_config_dword(port, rtsta_pos, &rtsta); | 278 | pcie_capability_read_dword(port, PCI_EXP_RTSTA, &rtsta); |
290 | 279 | ||
291 | if (!(rtsta & PCI_EXP_RTSTA_PME)) { | 280 | if (!(rtsta & PCI_EXP_RTSTA_PME)) { |
292 | spin_unlock_irqrestore(&data->lock, flags); | 281 | spin_unlock_irqrestore(&data->lock, flags); |
@@ -335,13 +324,13 @@ static void pcie_pme_mark_devices(struct pci_dev *port) | |||
335 | struct pci_dev *dev; | 324 | struct pci_dev *dev; |
336 | 325 | ||
337 | /* Check if this is a root port event collector. */ | 326 | /* Check if this is a root port event collector. */ |
338 | if (port->pcie_type != PCI_EXP_TYPE_RC_EC || !bus) | 327 | if (pci_pcie_type(port) != PCI_EXP_TYPE_RC_EC || !bus) |
339 | return; | 328 | return; |
340 | 329 | ||
341 | down_read(&pci_bus_sem); | 330 | down_read(&pci_bus_sem); |
342 | list_for_each_entry(dev, &bus->devices, bus_list) | 331 | list_for_each_entry(dev, &bus->devices, bus_list) |
343 | if (pci_is_pcie(dev) | 332 | if (pci_is_pcie(dev) |
344 | && dev->pcie_type == PCI_EXP_TYPE_RC_END) | 333 | && pci_pcie_type(dev) == PCI_EXP_TYPE_RC_END) |
345 | pcie_pme_set_native(dev, NULL); | 334 | pcie_pme_set_native(dev, NULL); |
346 | up_read(&pci_bus_sem); | 335 | up_read(&pci_bus_sem); |
347 | } | 336 | } |
diff --git a/drivers/pci/pcie/portdrv_bus.c b/drivers/pci/pcie/portdrv_bus.c index 18bf90f748f6..67be55a7f260 100644 --- a/drivers/pci/pcie/portdrv_bus.c +++ b/drivers/pci/pcie/portdrv_bus.c | |||
@@ -38,7 +38,7 @@ static int pcie_port_bus_match(struct device *dev, struct device_driver *drv) | |||
38 | return 0; | 38 | return 0; |
39 | 39 | ||
40 | if ((driver->port_type != PCIE_ANY_PORT) && | 40 | if ((driver->port_type != PCIE_ANY_PORT) && |
41 | (driver->port_type != pciedev->port->pcie_type)) | 41 | (driver->port_type != pci_pcie_type(pciedev->port))) |
42 | return 0; | 42 | return 0; |
43 | 43 | ||
44 | return 1; | 44 | return 1; |
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index 75915b30ad19..d03a7a39b2d8 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c | |||
@@ -200,10 +200,13 @@ static int init_service_irqs(struct pci_dev *dev, int *irqs, int mask) | |||
200 | { | 200 | { |
201 | int i, irq = -1; | 201 | int i, irq = -1; |
202 | 202 | ||
203 | /* We have to use INTx if MSI cannot be used for PCIe PME or pciehp. */ | 203 | /* |
204 | * If MSI cannot be used for PCIe PME or hotplug, we have to use | ||
205 | * INTx or other interrupts, e.g. system shared interrupt. | ||
206 | */ | ||
204 | if (((mask & PCIE_PORT_SERVICE_PME) && pcie_pme_no_msi()) || | 207 | if (((mask & PCIE_PORT_SERVICE_PME) && pcie_pme_no_msi()) || |
205 | ((mask & PCIE_PORT_SERVICE_HP) && pciehp_no_msi())) { | 208 | ((mask & PCIE_PORT_SERVICE_HP) && pciehp_no_msi())) { |
206 | if (dev->pin) | 209 | if (dev->irq) |
207 | irq = dev->irq; | 210 | irq = dev->irq; |
208 | goto no_msi; | 211 | goto no_msi; |
209 | } | 212 | } |
@@ -212,8 +215,12 @@ static int init_service_irqs(struct pci_dev *dev, int *irqs, int mask) | |||
212 | if (!pcie_port_enable_msix(dev, irqs, mask)) | 215 | if (!pcie_port_enable_msix(dev, irqs, mask)) |
213 | return 0; | 216 | return 0; |
214 | 217 | ||
215 | /* We're not going to use MSI-X, so try MSI and fall back to INTx */ | 218 | /* |
216 | if (!pci_enable_msi(dev) || dev->pin) | 219 | * We're not going to use MSI-X, so try MSI and fall back to INTx. |
220 | * If neither MSI/MSI-X nor INTx available, try other interrupt. On | ||
221 | * some platforms, root port doesn't support MSI/MSI-X/INTx in RC mode. | ||
222 | */ | ||
223 | if (!pci_enable_msi(dev) || dev->irq) | ||
217 | irq = dev->irq; | 224 | irq = dev->irq; |
218 | 225 | ||
219 | no_msi: | 226 | no_msi: |
@@ -246,8 +253,7 @@ static void cleanup_service_irqs(struct pci_dev *dev) | |||
246 | */ | 253 | */ |
247 | static int get_port_device_capability(struct pci_dev *dev) | 254 | static int get_port_device_capability(struct pci_dev *dev) |
248 | { | 255 | { |
249 | int services = 0, pos; | 256 | int services = 0; |
250 | u16 reg16; | ||
251 | u32 reg32; | 257 | u32 reg32; |
252 | int cap_mask = 0; | 258 | int cap_mask = 0; |
253 | int err; | 259 | int err; |
@@ -265,11 +271,9 @@ static int get_port_device_capability(struct pci_dev *dev) | |||
265 | return 0; | 271 | return 0; |
266 | } | 272 | } |
267 | 273 | ||
268 | pos = pci_pcie_cap(dev); | ||
269 | pci_read_config_word(dev, pos + PCI_EXP_FLAGS, ®16); | ||
270 | /* Hot-Plug Capable */ | 274 | /* Hot-Plug Capable */ |
271 | if ((cap_mask & PCIE_PORT_SERVICE_HP) && (reg16 & PCI_EXP_FLAGS_SLOT)) { | 275 | if (cap_mask & PCIE_PORT_SERVICE_HP) { |
272 | pci_read_config_dword(dev, pos + PCI_EXP_SLTCAP, ®32); | 276 | pcie_capability_read_dword(dev, PCI_EXP_SLTCAP, ®32); |
273 | if (reg32 & PCI_EXP_SLTCAP_HPC) { | 277 | if (reg32 & PCI_EXP_SLTCAP_HPC) { |
274 | services |= PCIE_PORT_SERVICE_HP; | 278 | services |= PCIE_PORT_SERVICE_HP; |
275 | /* | 279 | /* |
@@ -277,10 +281,8 @@ static int get_port_device_capability(struct pci_dev *dev) | |||
277 | * enabled by the BIOS and the hot-plug service driver | 281 | * enabled by the BIOS and the hot-plug service driver |
278 | * is not loaded. | 282 | * is not loaded. |
279 | */ | 283 | */ |
280 | pos += PCI_EXP_SLTCTL; | 284 | pcie_capability_clear_word(dev, PCI_EXP_SLTCTL, |
281 | pci_read_config_word(dev, pos, ®16); | 285 | PCI_EXP_SLTCTL_CCIE | PCI_EXP_SLTCTL_HPIE); |
282 | reg16 &= ~(PCI_EXP_SLTCTL_CCIE | PCI_EXP_SLTCTL_HPIE); | ||
283 | pci_write_config_word(dev, pos, reg16); | ||
284 | } | 286 | } |
285 | } | 287 | } |
286 | /* AER capable */ | 288 | /* AER capable */ |
@@ -298,7 +300,7 @@ static int get_port_device_capability(struct pci_dev *dev) | |||
298 | services |= PCIE_PORT_SERVICE_VC; | 300 | services |= PCIE_PORT_SERVICE_VC; |
299 | /* Root ports are capable of generating PME too */ | 301 | /* Root ports are capable of generating PME too */ |
300 | if ((cap_mask & PCIE_PORT_SERVICE_PME) | 302 | if ((cap_mask & PCIE_PORT_SERVICE_PME) |
301 | && dev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) { | 303 | && pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) { |
302 | services |= PCIE_PORT_SERVICE_PME; | 304 | services |= PCIE_PORT_SERVICE_PME; |
303 | /* | 305 | /* |
304 | * Disable PME interrupt on this port in case it's been enabled | 306 | * Disable PME interrupt on this port in case it's been enabled |
@@ -336,7 +338,7 @@ static int pcie_device_init(struct pci_dev *pdev, int service, int irq) | |||
336 | device->release = release_pcie_device; /* callback to free pcie dev */ | 338 | device->release = release_pcie_device; /* callback to free pcie dev */ |
337 | dev_set_name(device, "%s:pcie%02x", | 339 | dev_set_name(device, "%s:pcie%02x", |
338 | pci_name(pdev), | 340 | pci_name(pdev), |
339 | get_descriptor_id(pdev->pcie_type, service)); | 341 | get_descriptor_id(pci_pcie_type(pdev), service)); |
340 | device->parent = &pdev->dev; | 342 | device->parent = &pdev->dev; |
341 | device_enable_async_suspend(device); | 343 | device_enable_async_suspend(device); |
342 | 344 | ||
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index 943443510089..ca10911ee0df 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c | |||
@@ -64,14 +64,7 @@ __setup("pcie_ports=", pcie_port_setup); | |||
64 | */ | 64 | */ |
65 | void pcie_clear_root_pme_status(struct pci_dev *dev) | 65 | void pcie_clear_root_pme_status(struct pci_dev *dev) |
66 | { | 66 | { |
67 | int rtsta_pos; | 67 | pcie_capability_set_dword(dev, PCI_EXP_RTSTA, PCI_EXP_RTSTA_PME); |
68 | u32 rtsta; | ||
69 | |||
70 | rtsta_pos = pci_pcie_cap(dev) + PCI_EXP_RTSTA; | ||
71 | |||
72 | pci_read_config_dword(dev, rtsta_pos, &rtsta); | ||
73 | rtsta |= PCI_EXP_RTSTA_PME; | ||
74 | pci_write_config_dword(dev, rtsta_pos, rtsta); | ||
75 | } | 68 | } |
76 | 69 | ||
77 | static int pcie_portdrv_restore_config(struct pci_dev *dev) | 70 | static int pcie_portdrv_restore_config(struct pci_dev *dev) |
@@ -95,7 +88,7 @@ static int pcie_port_resume_noirq(struct device *dev) | |||
95 | * which breaks ACPI-based runtime wakeup on PCI Express, so clear those | 88 | * which breaks ACPI-based runtime wakeup on PCI Express, so clear those |
96 | * bits now just in case (shouldn't hurt). | 89 | * bits now just in case (shouldn't hurt). |
97 | */ | 90 | */ |
98 | if(pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) | 91 | if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT) |
99 | pcie_clear_root_pme_status(pdev); | 92 | pcie_clear_root_pme_status(pdev); |
100 | return 0; | 93 | return 0; |
101 | } | 94 | } |
@@ -186,9 +179,9 @@ static int __devinit pcie_portdrv_probe(struct pci_dev *dev, | |||
186 | int status; | 179 | int status; |
187 | 180 | ||
188 | if (!pci_is_pcie(dev) || | 181 | if (!pci_is_pcie(dev) || |
189 | ((dev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) && | 182 | ((pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) && |
190 | (dev->pcie_type != PCI_EXP_TYPE_UPSTREAM) && | 183 | (pci_pcie_type(dev) != PCI_EXP_TYPE_UPSTREAM) && |
191 | (dev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM))) | 184 | (pci_pcie_type(dev) != PCI_EXP_TYPE_DOWNSTREAM))) |
192 | return -ENODEV; | 185 | return -ENODEV; |
193 | 186 | ||
194 | if (!dev->irq && dev->pin) { | 187 | if (!dev->irq && dev->pin) { |