aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/host/pci-mvebu.c5
-rw-r--r--drivers/pci/pci-acpi.c21
-rw-r--r--drivers/pci/pci-driver.c38
-rw-r--r--drivers/pci/pci-label.c129
-rw-r--r--drivers/pci/pci.c8
-rw-r--r--drivers/pci/quirks.c4
-rw-r--r--drivers/pci/remove.c4
7 files changed, 95 insertions, 114 deletions
diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index c269e430c760..2aa7b77c7c88 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -447,6 +447,11 @@ static int mvebu_sw_pci_bridge_read(struct mvebu_pcie_port *port,
447 *value = 0; 447 *value = 0;
448 break; 448 break;
449 449
450 case PCI_INTERRUPT_LINE:
451 /* LINE PIN MIN_GNT MAX_LAT */
452 *value = 0;
453 break;
454
450 default: 455 default:
451 *value = 0xffffffff; 456 *value = 0xffffffff;
452 return PCIBIOS_BAD_REGISTER_NUMBER; 457 return PCIBIOS_BAD_REGISTER_NUMBER;
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index ce31eb0cdca7..733a8222b13f 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -325,29 +325,32 @@ static struct acpi_device *acpi_pci_find_companion(struct device *dev)
325static void pci_acpi_setup(struct device *dev) 325static void pci_acpi_setup(struct device *dev)
326{ 326{
327 struct pci_dev *pci_dev = to_pci_dev(dev); 327 struct pci_dev *pci_dev = to_pci_dev(dev);
328 acpi_handle handle = ACPI_HANDLE(dev); 328 struct acpi_device *adev = ACPI_COMPANION(dev);
329 struct acpi_device *adev;
330 329
331 if (acpi_bus_get_device(handle, &adev) || !adev->wakeup.flags.valid) 330 if (!adev)
331 return;
332
333 pci_acpi_add_pm_notifier(adev, pci_dev);
334 if (!adev->wakeup.flags.valid)
332 return; 335 return;
333 336
334 device_set_wakeup_capable(dev, true); 337 device_set_wakeup_capable(dev, true);
335 acpi_pci_sleep_wake(pci_dev, false); 338 acpi_pci_sleep_wake(pci_dev, false);
336
337 pci_acpi_add_pm_notifier(adev, pci_dev);
338 if (adev->wakeup.flags.run_wake) 339 if (adev->wakeup.flags.run_wake)
339 device_set_run_wake(dev, true); 340 device_set_run_wake(dev, true);
340} 341}
341 342
342static void pci_acpi_cleanup(struct device *dev) 343static void pci_acpi_cleanup(struct device *dev)
343{ 344{
344 acpi_handle handle = ACPI_HANDLE(dev); 345 struct acpi_device *adev = ACPI_COMPANION(dev);
345 struct acpi_device *adev; 346
347 if (!adev)
348 return;
346 349
347 if (!acpi_bus_get_device(handle, &adev) && adev->wakeup.flags.valid) { 350 pci_acpi_remove_pm_notifier(adev);
351 if (adev->wakeup.flags.valid) {
348 device_set_wakeup_capable(dev, false); 352 device_set_wakeup_capable(dev, false);
349 device_set_run_wake(dev, false); 353 device_set_run_wake(dev, false);
350 pci_acpi_remove_pm_notifier(adev);
351 } 354 }
352} 355}
353 356
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 9042fdbd7244..25f0bc659164 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -19,6 +19,7 @@
19#include <linux/cpu.h> 19#include <linux/cpu.h>
20#include <linux/pm_runtime.h> 20#include <linux/pm_runtime.h>
21#include <linux/suspend.h> 21#include <linux/suspend.h>
22#include <linux/kexec.h>
22#include "pci.h" 23#include "pci.h"
23 24
24struct pci_dynid { 25struct pci_dynid {
@@ -288,12 +289,27 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
288 int error, node; 289 int error, node;
289 struct drv_dev_and_id ddi = { drv, dev, id }; 290 struct drv_dev_and_id ddi = { drv, dev, id };
290 291
291 /* Execute driver initialization on node where the device's 292 /*
292 bus is attached to. This way the driver likely allocates 293 * Execute driver initialization on node where the device is
293 its local memory on the right node without any need to 294 * attached. This way the driver likely allocates its local memory
294 change it. */ 295 * on the right node.
296 */
295 node = dev_to_node(&dev->dev); 297 node = dev_to_node(&dev->dev);
296 if (node >= 0) { 298
299 /*
300 * On NUMA systems, we are likely to call a PF probe function using
301 * work_on_cpu(). If that probe calls pci_enable_sriov() (which
302 * adds the VF devices via pci_bus_add_device()), we may re-enter
303 * this function to call the VF probe function. Calling
304 * work_on_cpu() again will cause a lockdep warning. Since VFs are
305 * always on the same node as the PF, we can work around this by
306 * avoiding work_on_cpu() when we're already on the correct node.
307 *
308 * Preemption is enabled, so it's theoretically unsafe to use
309 * numa_node_id(), but even if we run the probe function on the
310 * wrong node, it should be functionally correct.
311 */
312 if (node >= 0 && node != numa_node_id()) {
297 int cpu; 313 int cpu;
298 314
299 get_online_cpus(); 315 get_online_cpus();
@@ -305,6 +321,7 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
305 put_online_cpus(); 321 put_online_cpus();
306 } else 322 } else
307 error = local_pci_probe(&ddi); 323 error = local_pci_probe(&ddi);
324
308 return error; 325 return error;
309} 326}
310 327
@@ -399,12 +416,17 @@ static void pci_device_shutdown(struct device *dev)
399 pci_msi_shutdown(pci_dev); 416 pci_msi_shutdown(pci_dev);
400 pci_msix_shutdown(pci_dev); 417 pci_msix_shutdown(pci_dev);
401 418
419#ifdef CONFIG_KEXEC
402 /* 420 /*
403 * Turn off Bus Master bit on the device to tell it to not 421 * If this is a kexec reboot, turn off Bus Master bit on the
404 * continue to do DMA. Don't touch devices in D3cold or unknown states. 422 * device to tell it to not continue to do DMA. Don't touch
423 * devices in D3cold or unknown states.
424 * If it is not a kexec reboot, firmware will hit the PCI
425 * devices with big hammer and stop their DMA any way.
405 */ 426 */
406 if (pci_dev->current_state <= PCI_D3hot) 427 if (kexec_in_progress && (pci_dev->current_state <= PCI_D3hot))
407 pci_clear_master(pci_dev); 428 pci_clear_master(pci_dev);
429#endif
408} 430}
409 431
410#ifdef CONFIG_PM 432#ifdef CONFIG_PM
diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c
index dbafcc8ef673..d2d1ceccad4b 100644
--- a/drivers/pci/pci-label.c
+++ b/drivers/pci/pci-label.c
@@ -186,7 +186,6 @@ static const char device_label_dsm_uuid[] = {
186}; 186};
187 187
188enum acpi_attr_enum { 188enum acpi_attr_enum {
189 ACPI_ATTR_NONE = 0,
190 ACPI_ATTR_LABEL_SHOW, 189 ACPI_ATTR_LABEL_SHOW,
191 ACPI_ATTR_INDEX_SHOW, 190 ACPI_ATTR_INDEX_SHOW,
192}; 191};
@@ -194,84 +193,61 @@ enum acpi_attr_enum {
194static void dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf) 193static void dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf)
195{ 194{
196 int len; 195 int len;
197 len = utf16s_to_utf8s((const wchar_t *)obj-> 196 len = utf16s_to_utf8s((const wchar_t *)obj->string.pointer,
198 package.elements[1].string.pointer, 197 obj->string.length,
199 obj->package.elements[1].string.length,
200 UTF16_LITTLE_ENDIAN, 198 UTF16_LITTLE_ENDIAN,
201 buf, PAGE_SIZE); 199 buf, PAGE_SIZE);
202 buf[len] = '\n'; 200 buf[len] = '\n';
203} 201}
204 202
205static int 203static int
206dsm_get_label(acpi_handle handle, int func, 204dsm_get_label(struct device *dev, char *buf, enum acpi_attr_enum attr)
207 struct acpi_buffer *output,
208 char *buf, enum acpi_attr_enum attribute)
209{ 205{
210 struct acpi_object_list input; 206 acpi_handle handle;
211 union acpi_object params[4]; 207 union acpi_object *obj, *tmp;
212 union acpi_object *obj; 208 int len = -1;
213 int len = 0; 209
214 210 handle = ACPI_HANDLE(dev);
215 int err; 211 if (!handle)
216
217 input.count = 4;
218 input.pointer = params;
219 params[0].type = ACPI_TYPE_BUFFER;
220 params[0].buffer.length = sizeof(device_label_dsm_uuid);
221 params[0].buffer.pointer = (char *)device_label_dsm_uuid;
222 params[1].type = ACPI_TYPE_INTEGER;
223 params[1].integer.value = 0x02;
224 params[2].type = ACPI_TYPE_INTEGER;
225 params[2].integer.value = func;
226 params[3].type = ACPI_TYPE_PACKAGE;
227 params[3].package.count = 0;
228 params[3].package.elements = NULL;
229
230 err = acpi_evaluate_object(handle, "_DSM", &input, output);
231 if (err)
232 return -1; 212 return -1;
233 213
234 obj = (union acpi_object *)output->pointer; 214 obj = acpi_evaluate_dsm(handle, device_label_dsm_uuid, 0x2,
235 215 DEVICE_LABEL_DSM, NULL);
236 switch (obj->type) { 216 if (!obj)
237 case ACPI_TYPE_PACKAGE: 217 return -1;
238 if (obj->package.count != 2) 218
239 break; 219 tmp = obj->package.elements;
240 len = obj->package.elements[0].integer.value; 220 if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 2 &&
241 if (buf) { 221 tmp[0].type == ACPI_TYPE_INTEGER &&
242 if (attribute == ACPI_ATTR_INDEX_SHOW) 222 tmp[1].type == ACPI_TYPE_STRING) {
243 scnprintf(buf, PAGE_SIZE, "%llu\n", 223 /*
244 obj->package.elements[0].integer.value); 224 * The second string element is optional even when
245 else if (attribute == ACPI_ATTR_LABEL_SHOW) 225 * this _DSM is implemented; when not implemented,
246 dsm_label_utf16s_to_utf8s(obj, buf); 226 * this entry must return a null string.
247 kfree(output->pointer); 227 */
248 return strlen(buf); 228 if (attr == ACPI_ATTR_INDEX_SHOW)
249 } 229 scnprintf(buf, PAGE_SIZE, "%llu\n", tmp->integer.value);
250 kfree(output->pointer); 230 else if (attr == ACPI_ATTR_LABEL_SHOW)
251 return len; 231 dsm_label_utf16s_to_utf8s(tmp + 1, buf);
252 break; 232 len = strlen(buf) > 0 ? strlen(buf) : -1;
253 default:
254 kfree(output->pointer);
255 } 233 }
256 return -1; 234
235 ACPI_FREE(obj);
236
237 return len;
257} 238}
258 239
259static bool 240static bool
260device_has_dsm(struct device *dev) 241device_has_dsm(struct device *dev)
261{ 242{
262 acpi_handle handle; 243 acpi_handle handle;
263 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
264 244
265 handle = ACPI_HANDLE(dev); 245 handle = ACPI_HANDLE(dev);
266
267 if (!handle) 246 if (!handle)
268 return FALSE; 247 return false;
269 248
270 if (dsm_get_label(handle, DEVICE_LABEL_DSM, &output, NULL, 249 return !!acpi_check_dsm(handle, device_label_dsm_uuid, 0x2,
271 ACPI_ATTR_NONE) > 0) 250 1 << DEVICE_LABEL_DSM);
272 return TRUE;
273
274 return FALSE;
275} 251}
276 252
277static umode_t 253static umode_t
@@ -290,44 +266,13 @@ acpi_index_string_exist(struct kobject *kobj, struct attribute *attr, int n)
290static ssize_t 266static ssize_t
291acpilabel_show(struct device *dev, struct device_attribute *attr, char *buf) 267acpilabel_show(struct device *dev, struct device_attribute *attr, char *buf)
292{ 268{
293 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL}; 269 return dsm_get_label(dev, buf, ACPI_ATTR_LABEL_SHOW);
294 acpi_handle handle;
295 int length;
296
297 handle = ACPI_HANDLE(dev);
298
299 if (!handle)
300 return -1;
301
302 length = dsm_get_label(handle, DEVICE_LABEL_DSM,
303 &output, buf, ACPI_ATTR_LABEL_SHOW);
304
305 if (length < 1)
306 return -1;
307
308 return length;
309} 270}
310 271
311static ssize_t 272static ssize_t
312acpiindex_show(struct device *dev, struct device_attribute *attr, char *buf) 273acpiindex_show(struct device *dev, struct device_attribute *attr, char *buf)
313{ 274{
314 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL}; 275 return dsm_get_label(dev, buf, ACPI_ATTR_INDEX_SHOW);
315 acpi_handle handle;
316 int length;
317
318 handle = ACPI_HANDLE(dev);
319
320 if (!handle)
321 return -1;
322
323 length = dsm_get_label(handle, DEVICE_LABEL_DSM,
324 &output, buf, ACPI_ATTR_INDEX_SHOW);
325
326 if (length < 0)
327 return -1;
328
329 return length;
330
331} 276}
332 277
333static struct device_attribute acpi_attr_label = { 278static struct device_attribute acpi_attr_label = {
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 33120d156668..07369f32e8bb 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4165,6 +4165,14 @@ int pci_set_vga_state(struct pci_dev *dev, bool decode,
4165 return 0; 4165 return 0;
4166} 4166}
4167 4167
4168bool pci_device_is_present(struct pci_dev *pdev)
4169{
4170 u32 v;
4171
4172 return pci_bus_read_dev_vendor_id(pdev->bus, pdev->devfn, &v, 0);
4173}
4174EXPORT_SYMBOL_GPL(pci_device_is_present);
4175
4168#define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE 4176#define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE
4169static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0}; 4177static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0};
4170static DEFINE_SPINLOCK(resource_alignment_lock); 4178static DEFINE_SPINLOCK(resource_alignment_lock);
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index b3b1b9aa8863..3a02717473ad 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -9,10 +9,6 @@
9 * 9 *
10 * Init/reset quirks for USB host controllers should be in the 10 * Init/reset quirks for USB host controllers should be in the
11 * USB quirks file, where their drivers can access reuse it. 11 * USB quirks file, where their drivers can access reuse it.
12 *
13 * The bridge optimization stuff has been removed. If you really
14 * have a silly BIOS which is unable to set your host bridge right,
15 * use the PowerTweak utility (see http://powertweak.sourceforge.net).
16 */ 12 */
17 13
18#include <linux/types.h> 14#include <linux/types.h>
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index 1576851028db..cc9337a71529 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -24,7 +24,7 @@ static void pci_stop_dev(struct pci_dev *dev)
24 if (dev->is_added) { 24 if (dev->is_added) {
25 pci_proc_detach_device(dev); 25 pci_proc_detach_device(dev);
26 pci_remove_sysfs_dev_files(dev); 26 pci_remove_sysfs_dev_files(dev);
27 device_del(&dev->dev); 27 device_release_driver(&dev->dev);
28 dev->is_added = 0; 28 dev->is_added = 0;
29 } 29 }
30 30
@@ -34,6 +34,8 @@ static void pci_stop_dev(struct pci_dev *dev)
34 34
35static void pci_destroy_dev(struct pci_dev *dev) 35static void pci_destroy_dev(struct pci_dev *dev)
36{ 36{
37 device_del(&dev->dev);
38
37 down_write(&pci_bus_sem); 39 down_write(&pci_bus_sem);
38 list_del(&dev->bus_list); 40 list_del(&dev->bus_list);
39 up_write(&pci_bus_sem); 41 up_write(&pci_bus_sem);