diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2012-12-22 18:02:54 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-01-03 07:09:41 -0500 |
commit | 38a9a67a281eeebcd7cccf87f0e371f58ae625e3 (patch) | |
tree | 91f8dd1862d8f46739d01d89299eed82fe3a6545 | |
parent | d2e5f0c16ad60a7208fd371233e63b73c990ece2 (diff) |
ACPI / PCI: Move the _PRT setup and cleanup code to pci-acpi.c
Move the code related to _PRT setup and removal and to power
resources from acpi_pci_bind() and acpi_pci_unbind() to the .setup()
and .cleanup() callbacks in acpi_pci_bus and remove acpi_pci_bind()
and acpi_pci_unbind() that have no purpose any more. Accordingly,
remove the code related to device .bind() and .unbind() operations
from the ACPI PCI root bridge driver.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: Toshi Kani <toshi.kani@hp.com>
-rw-r--r-- | drivers/acpi/Makefile | 2 | ||||
-rw-r--r-- | drivers/acpi/pci_bind.c | 117 | ||||
-rw-r--r-- | drivers/acpi/pci_root.c | 31 | ||||
-rw-r--r-- | drivers/pci/pci-acpi.c | 44 |
4 files changed, 37 insertions, 157 deletions
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 2a4502becd13..4ee2e753306a 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
@@ -37,7 +37,7 @@ acpi-y += resource.o | |||
37 | acpi-y += processor_core.o | 37 | acpi-y += processor_core.o |
38 | acpi-y += ec.o | 38 | acpi-y += ec.o |
39 | acpi-$(CONFIG_ACPI_DOCK) += dock.o | 39 | acpi-$(CONFIG_ACPI_DOCK) += dock.o |
40 | acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o | 40 | acpi-y += pci_root.o pci_link.o pci_irq.o |
41 | acpi-y += acpi_platform.o | 41 | acpi-y += acpi_platform.o |
42 | acpi-y += power.o | 42 | acpi-y += power.o |
43 | acpi-y += event.o | 43 | acpi-y += event.o |
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c deleted file mode 100644 index bbddcc9c894f..000000000000 --- a/drivers/acpi/pci_bind.c +++ /dev/null | |||
@@ -1,117 +0,0 @@ | |||
1 | /* | ||
2 | * pci_bind.c - ACPI PCI Device Binding ($Revision: 2 $) | ||
3 | * | ||
4 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> | ||
5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> | ||
6 | * | ||
7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or (at | ||
12 | * your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
21 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
22 | * | ||
23 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
24 | */ | ||
25 | |||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/types.h> | ||
28 | #include <linux/pci.h> | ||
29 | #include <linux/pci-acpi.h> | ||
30 | #include <linux/acpi.h> | ||
31 | #include <linux/pm_runtime.h> | ||
32 | #include <acpi/acpi_bus.h> | ||
33 | #include <acpi/acpi_drivers.h> | ||
34 | |||
35 | #define _COMPONENT ACPI_PCI_COMPONENT | ||
36 | ACPI_MODULE_NAME("pci_bind"); | ||
37 | |||
38 | static int acpi_pci_unbind(struct acpi_device *device) | ||
39 | { | ||
40 | struct pci_dev *dev; | ||
41 | |||
42 | dev = acpi_get_pci_dev(device->handle); | ||
43 | if (!dev) | ||
44 | goto out; | ||
45 | |||
46 | acpi_power_resource_unregister_device(&dev->dev, device->handle); | ||
47 | |||
48 | if (!dev->subordinate) | ||
49 | goto out; | ||
50 | |||
51 | acpi_pci_irq_del_prt(pci_domain_nr(dev->bus), dev->subordinate->number); | ||
52 | |||
53 | device->ops.bind = NULL; | ||
54 | device->ops.unbind = NULL; | ||
55 | |||
56 | out: | ||
57 | pci_dev_put(dev); | ||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | static int acpi_pci_bind(struct acpi_device *device) | ||
62 | { | ||
63 | acpi_status status; | ||
64 | acpi_handle handle; | ||
65 | unsigned char bus; | ||
66 | struct pci_dev *dev; | ||
67 | |||
68 | dev = acpi_get_pci_dev(device->handle); | ||
69 | if (!dev) | ||
70 | return 0; | ||
71 | |||
72 | acpi_power_resource_register_device(&dev->dev, device->handle); | ||
73 | |||
74 | /* | ||
75 | * Install the 'bind' function to facilitate callbacks for | ||
76 | * children of the P2P bridge. | ||
77 | */ | ||
78 | if (dev->subordinate) { | ||
79 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
80 | "Device %04x:%02x:%02x.%d is a PCI bridge\n", | ||
81 | pci_domain_nr(dev->bus), dev->bus->number, | ||
82 | PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn))); | ||
83 | device->ops.bind = acpi_pci_bind; | ||
84 | device->ops.unbind = acpi_pci_unbind; | ||
85 | } | ||
86 | |||
87 | /* | ||
88 | * Evaluate and parse _PRT, if exists. This code allows parsing of | ||
89 | * _PRT objects within the scope of non-bridge devices. Note that | ||
90 | * _PRTs within the scope of a PCI bridge assume the bridge's | ||
91 | * subordinate bus number. | ||
92 | * | ||
93 | * TBD: Can _PRTs exist within the scope of non-bridge PCI devices? | ||
94 | */ | ||
95 | status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); | ||
96 | if (ACPI_FAILURE(status)) | ||
97 | goto out; | ||
98 | |||
99 | if (dev->subordinate) | ||
100 | bus = dev->subordinate->number; | ||
101 | else | ||
102 | bus = dev->bus->number; | ||
103 | |||
104 | acpi_pci_irq_add_prt(device->handle, pci_domain_nr(dev->bus), bus); | ||
105 | |||
106 | out: | ||
107 | pci_dev_put(dev); | ||
108 | return 0; | ||
109 | } | ||
110 | |||
111 | int acpi_pci_bind_root(struct acpi_device *device) | ||
112 | { | ||
113 | device->ops.bind = acpi_pci_bind; | ||
114 | device->ops.unbind = acpi_pci_unbind; | ||
115 | |||
116 | return 0; | ||
117 | } | ||
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 0e593a203ff8..22a8458b4ec9 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
@@ -186,21 +186,6 @@ static acpi_status try_get_root_bridge_busnr(acpi_handle handle, | |||
186 | return AE_OK; | 186 | return AE_OK; |
187 | } | 187 | } |
188 | 188 | ||
189 | static void acpi_pci_bridge_scan(struct acpi_device *device) | ||
190 | { | ||
191 | int status; | ||
192 | struct acpi_device *child = NULL; | ||
193 | |||
194 | if (device->flags.bus_address) | ||
195 | if (device->parent && device->parent->ops.bind) { | ||
196 | status = device->parent->ops.bind(device); | ||
197 | if (!status) { | ||
198 | list_for_each_entry(child, &device->children, node) | ||
199 | acpi_pci_bridge_scan(child); | ||
200 | } | ||
201 | } | ||
202 | } | ||
203 | |||
204 | static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766"; | 189 | static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766"; |
205 | 190 | ||
206 | static acpi_status acpi_pci_run_osc(acpi_handle handle, | 191 | static acpi_status acpi_pci_run_osc(acpi_handle handle, |
@@ -450,7 +435,6 @@ static int acpi_pci_root_add(struct acpi_device *device) | |||
450 | int result; | 435 | int result; |
451 | struct acpi_pci_root *root; | 436 | struct acpi_pci_root *root; |
452 | acpi_handle handle; | 437 | acpi_handle handle; |
453 | struct acpi_device *child; | ||
454 | struct acpi_pci_driver *driver; | 438 | struct acpi_pci_driver *driver; |
455 | u32 flags, base_flags; | 439 | u32 flags, base_flags; |
456 | bool is_osc_granted = false; | 440 | bool is_osc_granted = false; |
@@ -602,21 +586,6 @@ static int acpi_pci_root_add(struct acpi_device *device) | |||
602 | goto out_del_root; | 586 | goto out_del_root; |
603 | } | 587 | } |
604 | 588 | ||
605 | /* | ||
606 | * Attach ACPI-PCI Context | ||
607 | * ----------------------- | ||
608 | * Thus binding the ACPI and PCI devices. | ||
609 | */ | ||
610 | result = acpi_pci_bind_root(device); | ||
611 | if (result) | ||
612 | goto out_del_root; | ||
613 | |||
614 | /* | ||
615 | * Scan and bind all _ADR-Based Devices | ||
616 | */ | ||
617 | list_for_each_entry(child, &device->children, node) | ||
618 | acpi_pci_bridge_scan(child); | ||
619 | |||
620 | /* ASPM setting */ | 589 | /* ASPM setting */ |
621 | if (is_osc_granted) { | 590 | if (is_osc_granted) { |
622 | if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) | 591 | if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) |
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index b98106c110e7..42736e213f25 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c | |||
@@ -320,12 +320,33 @@ static int acpi_pci_find_root_bridge(struct device *dev, acpi_handle *handle) | |||
320 | return 0; | 320 | return 0; |
321 | } | 321 | } |
322 | 322 | ||
323 | static void acpi_pci_wakeup_setup(struct device *dev) | 323 | static void pci_acpi_setup(struct device *dev) |
324 | { | 324 | { |
325 | struct acpi_device *adev = acpi_dev_pm_get_node(dev); | ||
326 | struct pci_dev *pci_dev = to_pci_dev(dev); | 325 | struct pci_dev *pci_dev = to_pci_dev(dev); |
326 | acpi_handle handle = ACPI_HANDLE(dev); | ||
327 | struct acpi_device *adev; | ||
328 | acpi_status status; | ||
329 | acpi_handle dummy; | ||
327 | 330 | ||
328 | if (!adev || !adev->wakeup.flags.valid) | 331 | /* |
332 | * Evaluate and parse _PRT, if exists. This code allows parsing of | ||
333 | * _PRT objects within the scope of non-bridge devices. Note that | ||
334 | * _PRTs within the scope of a PCI bridge assume the bridge's | ||
335 | * subordinate bus number. | ||
336 | * | ||
337 | * TBD: Can _PRTs exist within the scope of non-bridge PCI devices? | ||
338 | */ | ||
339 | status = acpi_get_handle(handle, METHOD_NAME__PRT, &dummy); | ||
340 | if (ACPI_SUCCESS(status)) { | ||
341 | unsigned char bus; | ||
342 | |||
343 | bus = pci_dev->subordinate ? | ||
344 | pci_dev->subordinate->number : pci_dev->bus->number; | ||
345 | acpi_pci_irq_add_prt(handle, pci_domain_nr(pci_dev->bus), bus); | ||
346 | } | ||
347 | |||
348 | acpi_power_resource_register_device(dev, handle); | ||
349 | if (acpi_bus_get_device(handle, &adev) || !adev->wakeup.flags.valid) | ||
329 | return; | 350 | return; |
330 | 351 | ||
331 | device_set_wakeup_capable(dev, true); | 352 | device_set_wakeup_capable(dev, true); |
@@ -336,23 +357,30 @@ static void acpi_pci_wakeup_setup(struct device *dev) | |||
336 | device_set_run_wake(dev, true); | 357 | device_set_run_wake(dev, true); |
337 | } | 358 | } |
338 | 359 | ||
339 | static void acpi_pci_wakeup_cleanup(struct device *dev) | 360 | static void pci_acpi_cleanup(struct device *dev) |
340 | { | 361 | { |
341 | struct acpi_device *adev = acpi_dev_pm_get_node(dev); | 362 | struct pci_dev *pci_dev = to_pci_dev(dev); |
363 | acpi_handle handle = ACPI_HANDLE(dev); | ||
364 | struct acpi_device *adev; | ||
342 | 365 | ||
343 | if (adev && adev->wakeup.flags.valid) { | 366 | if (!acpi_bus_get_device(handle, &adev) && adev->wakeup.flags.valid) { |
344 | device_set_wakeup_capable(dev, false); | 367 | device_set_wakeup_capable(dev, false); |
345 | device_set_run_wake(dev, false); | 368 | device_set_run_wake(dev, false); |
346 | pci_acpi_remove_pm_notifier(adev); | 369 | pci_acpi_remove_pm_notifier(adev); |
347 | } | 370 | } |
371 | acpi_power_resource_unregister_device(dev, handle); | ||
372 | |||
373 | if (pci_dev->subordinate) | ||
374 | acpi_pci_irq_del_prt(pci_domain_nr(pci_dev->bus), | ||
375 | pci_dev->subordinate->number); | ||
348 | } | 376 | } |
349 | 377 | ||
350 | static struct acpi_bus_type acpi_pci_bus = { | 378 | static struct acpi_bus_type acpi_pci_bus = { |
351 | .bus = &pci_bus_type, | 379 | .bus = &pci_bus_type, |
352 | .find_device = acpi_pci_find_device, | 380 | .find_device = acpi_pci_find_device, |
353 | .find_bridge = acpi_pci_find_root_bridge, | 381 | .find_bridge = acpi_pci_find_root_bridge, |
354 | .setup = acpi_pci_wakeup_setup, | 382 | .setup = pci_acpi_setup, |
355 | .cleanup = acpi_pci_wakeup_cleanup, | 383 | .cleanup = pci_acpi_cleanup, |
356 | }; | 384 | }; |
357 | 385 | ||
358 | static int __init acpi_pci_init(void) | 386 | static int __init acpi_pci_init(void) |