diff options
279 files changed, 6877 insertions, 3419 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-acpi b/Documentation/ABI/testing/sysfs-bus-acpi new file mode 100644 index 000000000000..7fa9cbc75344 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-acpi | |||
@@ -0,0 +1,58 @@ | |||
1 | What: /sys/bus/acpi/devices/.../path | ||
2 | Date: December 2006 | ||
3 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> | ||
4 | Description: | ||
5 | This attribute indicates the full path of ACPI namespace | ||
6 | object associated with the device object. For example, | ||
7 | \_SB_.PCI0. | ||
8 | This file is not present for device objects representing | ||
9 | fixed ACPI hardware features (like power and sleep | ||
10 | buttons). | ||
11 | |||
12 | What: /sys/bus/acpi/devices/.../modalias | ||
13 | Date: July 2007 | ||
14 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> | ||
15 | Description: | ||
16 | This attribute indicates the PNP IDs of the device object. | ||
17 | That is acpi:HHHHHHHH:[CCCCCCC:]. Where each HHHHHHHH or | ||
18 | CCCCCCCC contains device object's PNPID (_HID or _CID). | ||
19 | |||
20 | What: /sys/bus/acpi/devices/.../hid | ||
21 | Date: April 2005 | ||
22 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> | ||
23 | Description: | ||
24 | This attribute indicates the hardware ID (_HID) of the | ||
25 | device object. For example, PNP0103. | ||
26 | This file is present for device objects having the _HID | ||
27 | control method. | ||
28 | |||
29 | What: /sys/bus/acpi/devices/.../description | ||
30 | Date: October 2012 | ||
31 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> | ||
32 | Description: | ||
33 | This attribute contains the output of the device object's | ||
34 | _STR control method, if present. | ||
35 | |||
36 | What: /sys/bus/acpi/devices/.../adr | ||
37 | Date: October 2012 | ||
38 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> | ||
39 | Description: | ||
40 | This attribute contains the output of the device object's | ||
41 | _ADR control method, which is present for ACPI device | ||
42 | objects representing devices having standard enumeration | ||
43 | algorithms, such as PCI. | ||
44 | |||
45 | What: /sys/bus/acpi/devices/.../uid | ||
46 | Date: October 2012 | ||
47 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> | ||
48 | Description: | ||
49 | This attribute contains the output of the device object's | ||
50 | _UID control method, if present. | ||
51 | |||
52 | What: /sys/bus/acpi/devices/.../eject | ||
53 | Date: December 2006 | ||
54 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> | ||
55 | Description: | ||
56 | Writing 1 to this attribute will trigger hot removal of | ||
57 | this device object. This file exists for every device | ||
58 | object that has _EJ0 method. | ||
diff --git a/Documentation/ABI/testing/sysfs-class-devfreq b/Documentation/ABI/testing/sysfs-class-devfreq index 0ba6ea2f89d9..ee39acacf6f8 100644 --- a/Documentation/ABI/testing/sysfs-class-devfreq +++ b/Documentation/ABI/testing/sysfs-class-devfreq | |||
@@ -78,3 +78,23 @@ Contact: Nishanth Menon <nm@ti.com> | |||
78 | Description: | 78 | Description: |
79 | The /sys/class/devfreq/.../available_governors shows | 79 | The /sys/class/devfreq/.../available_governors shows |
80 | currently available governors in the system. | 80 | currently available governors in the system. |
81 | |||
82 | What: /sys/class/devfreq/.../min_freq | ||
83 | Date: January 2013 | ||
84 | Contact: MyungJoo Ham <myungjoo.ham@samsung.com> | ||
85 | Description: | ||
86 | The /sys/class/devfreq/.../min_freq shows and stores | ||
87 | the minimum frequency requested by users. It is 0 if | ||
88 | the user does not care. min_freq overrides the | ||
89 | frequency requested by governors. | ||
90 | |||
91 | What: /sys/class/devfreq/.../max_freq | ||
92 | Date: January 2013 | ||
93 | Contact: MyungJoo Ham <myungjoo.ham@samsung.com> | ||
94 | Description: | ||
95 | The /sys/class/devfreq/.../max_freq shows and stores | ||
96 | the maximum frequency requested by users. It is 0 if | ||
97 | the user does not care. max_freq overrides the | ||
98 | frequency requested by governors and min_freq. | ||
99 | The max_freq overrides min_freq because max_freq may be | ||
100 | used to throttle devices to avoid overheating. | ||
diff --git a/Documentation/ABI/testing/sysfs-devices-online b/Documentation/ABI/testing/sysfs-devices-online new file mode 100644 index 000000000000..f990026c0740 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-devices-online | |||
@@ -0,0 +1,20 @@ | |||
1 | What: /sys/devices/.../online | ||
2 | Date: April 2013 | ||
3 | Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
4 | Description: | ||
5 | The /sys/devices/.../online attribute is only present for | ||
6 | devices whose bus types provide .online() and .offline() | ||
7 | callbacks. The number read from it (0 or 1) reflects the value | ||
8 | of the device's 'offline' field. If that number is 1 and '0' | ||
9 | (or 'n', or 'N') is written to this file, the device bus type's | ||
10 | .offline() callback is executed for the device and (if | ||
11 | successful) its 'offline' field is updated accordingly. In | ||
12 | turn, if that number is 0 and '1' (or 'y', or 'Y') is written to | ||
13 | this file, the device bus type's .online() callback is executed | ||
14 | for the device and (if successful) its 'offline' field is | ||
15 | updated as appropriate. | ||
16 | |||
17 | After a successful execution of the bus type's .offline() | ||
18 | callback the device cannot be used for any purpose until either | ||
19 | it is removed (i.e. device_del() is called for it), or its bus | ||
20 | type's .online() is exeucted successfully. | ||
diff --git a/Documentation/ABI/testing/sysfs-devices-sun b/Documentation/ABI/testing/sysfs-devices-sun index 86be9848a77e..625ce4b63758 100644 --- a/Documentation/ABI/testing/sysfs-devices-sun +++ b/Documentation/ABI/testing/sysfs-devices-sun | |||
@@ -1,4 +1,4 @@ | |||
1 | Whatt: /sys/devices/.../sun | 1 | What: /sys/devices/.../sun |
2 | Date: October 2012 | 2 | Date: October 2012 |
3 | Contact: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com> | 3 | Contact: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com> |
4 | Description: | 4 | Description: |
diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu index 2447698aed41..468e4d48f884 100644 --- a/Documentation/ABI/testing/sysfs-devices-system-cpu +++ b/Documentation/ABI/testing/sysfs-devices-system-cpu | |||
@@ -144,6 +144,21 @@ Description: Discover and change clock speed of CPUs | |||
144 | to learn how to control the knobs. | 144 | to learn how to control the knobs. |
145 | 145 | ||
146 | 146 | ||
147 | What: /sys/devices/system/cpu/cpu#/cpufreq/freqdomain_cpus | ||
148 | Date: June 2013 | ||
149 | Contact: cpufreq@vger.kernel.org | ||
150 | Description: Discover CPUs in the same CPU frequency coordination domain | ||
151 | |||
152 | freqdomain_cpus is the list of CPUs (online+offline) that share | ||
153 | the same clock/freq domain (possibly at the hardware level). | ||
154 | That information may be hidden from the cpufreq core and the | ||
155 | value of related_cpus may be different from freqdomain_cpus. This | ||
156 | attribute is useful for user space DVFS controllers to get better | ||
157 | power/performance results for platforms using acpi-cpufreq. | ||
158 | |||
159 | This file is only present if the acpi-cpufreq driver is in use. | ||
160 | |||
161 | |||
147 | What: /sys/devices/system/cpu/cpu*/cache/index3/cache_disable_{0,1} | 162 | What: /sys/devices/system/cpu/cpu*/cache/index3/cache_disable_{0,1} |
148 | Date: August 2008 | 163 | Date: August 2008 |
149 | KernelVersion: 2.6.27 | 164 | KernelVersion: 2.6.27 |
diff --git a/Documentation/ABI/testing/sysfs-firmware-acpi b/Documentation/ABI/testing/sysfs-firmware-acpi index ce9bee98b43b..b4436cca97a8 100644 --- a/Documentation/ABI/testing/sysfs-firmware-acpi +++ b/Documentation/ABI/testing/sysfs-firmware-acpi | |||
@@ -44,6 +44,16 @@ Description: | |||
44 | or 0 (unset). Attempts to write any other values to it will | 44 | or 0 (unset). Attempts to write any other values to it will |
45 | cause -EINVAL to be returned. | 45 | cause -EINVAL to be returned. |
46 | 46 | ||
47 | What: /sys/firmware/acpi/hotplug/force_remove | ||
48 | Date: May 2013 | ||
49 | Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
50 | Description: | ||
51 | The number in this file (0 or 1) determines whether (1) or not | ||
52 | (0) the ACPI subsystem will allow devices to be hot-removed even | ||
53 | if they cannot be put offline gracefully (from the kernel's | ||
54 | viewpoint). That number can be changed by writing a boolean | ||
55 | value to this file. | ||
56 | |||
47 | What: /sys/firmware/acpi/interrupts/ | 57 | What: /sys/firmware/acpi/interrupts/ |
48 | Date: February 2008 | 58 | Date: February 2008 |
49 | Contact: Len Brown <lenb@kernel.org> | 59 | Contact: Len Brown <lenb@kernel.org> |
diff --git a/Documentation/acpi/namespace.txt b/Documentation/acpi/namespace.txt new file mode 100644 index 000000000000..260f6a3661fa --- /dev/null +++ b/Documentation/acpi/namespace.txt | |||
@@ -0,0 +1,395 @@ | |||
1 | ACPI Device Tree - Representation of ACPI Namespace | ||
2 | |||
3 | Copyright (C) 2013, Intel Corporation | ||
4 | Author: Lv Zheng <lv.zheng@intel.com> | ||
5 | |||
6 | |||
7 | Abstract: | ||
8 | |||
9 | The Linux ACPI subsystem converts ACPI namespace objects into a Linux | ||
10 | device tree under the /sys/devices/LNXSYSTEM:00 and updates it upon | ||
11 | receiving ACPI hotplug notification events. For each device object in this | ||
12 | hierarchy there is a corresponding symbolic link in the | ||
13 | /sys/bus/acpi/devices. | ||
14 | This document illustrates the structure of the ACPI device tree. | ||
15 | |||
16 | |||
17 | Credit: | ||
18 | |||
19 | Thanks for the help from Zhang Rui <rui.zhang@intel.com> and Rafael J. | ||
20 | Wysocki <rafael.j.wysocki@intel.com>. | ||
21 | |||
22 | |||
23 | 1. ACPI Definition Blocks | ||
24 | |||
25 | The ACPI firmware sets up RSDP (Root System Description Pointer) in the | ||
26 | system memory address space pointing to the XSDT (Extended System | ||
27 | Description Table). The XSDT always points to the FADT (Fixed ACPI | ||
28 | Description Table) using its first entry, the data within the FADT | ||
29 | includes various fixed-length entries that describe fixed ACPI features | ||
30 | of the hardware. The FADT contains a pointer to the DSDT | ||
31 | (Differentiated System Descripition Table). The XSDT also contains | ||
32 | entries pointing to possibly multiple SSDTs (Secondary System | ||
33 | Description Table). | ||
34 | |||
35 | The DSDT and SSDT data is organized in data structures called definition | ||
36 | blocks that contain definitions of various objects, including ACPI | ||
37 | control methods, encoded in AML (ACPI Machine Language). The data block | ||
38 | of the DSDT along with the contents of SSDTs represents a hierarchical | ||
39 | data structure called the ACPI namespace whose topology reflects the | ||
40 | structure of the underlying hardware platform. | ||
41 | |||
42 | The relationships between ACPI System Definition Tables described above | ||
43 | are illustrated in the following diagram. | ||
44 | |||
45 | +---------+ +-------+ +--------+ +------------------------+ | ||
46 | | RSDP | +->| XSDT | +->| FADT | | +-------------------+ | | ||
47 | +---------+ | +-------+ | +--------+ +-|->| DSDT | | | ||
48 | | Pointer | | | Entry |-+ | ...... | | | +-------------------+ | | ||
49 | +---------+ | +-------+ | X_DSDT |--+ | | Definition Blocks | | | ||
50 | | Pointer |-+ | ..... | | ...... | | +-------------------+ | | ||
51 | +---------+ +-------+ +--------+ | +-------------------+ | | ||
52 | | Entry |------------------|->| SSDT | | | ||
53 | +- - - -+ | +-------------------| | | ||
54 | | Entry | - - - - - - - -+ | | Definition Blocks | | | ||
55 | +- - - -+ | | +-------------------+ | | ||
56 | | | +- - - - - - - - - -+ | | ||
57 | +-|->| SSDT | | | ||
58 | | +-------------------+ | | ||
59 | | | Definition Blocks | | | ||
60 | | +- - - - - - - - - -+ | | ||
61 | +------------------------+ | ||
62 | | | ||
63 | OSPM Loading | | ||
64 | \|/ | ||
65 | +----------------+ | ||
66 | | ACPI Namespace | | ||
67 | +----------------+ | ||
68 | |||
69 | Figure 1. ACPI Definition Blocks | ||
70 | |||
71 | NOTE: RSDP can also contain a pointer to the RSDT (Root System | ||
72 | Description Table). Platforms provide RSDT to enable | ||
73 | compatibility with ACPI 1.0 operating systems. The OS is expected | ||
74 | to use XSDT, if present. | ||
75 | |||
76 | |||
77 | 2. Example ACPI Namespace | ||
78 | |||
79 | All definition blocks are loaded into a single namespace. The namespace | ||
80 | is a hierarchy of objects identified by names and paths. | ||
81 | The following naming conventions apply to object names in the ACPI | ||
82 | namespace: | ||
83 | 1. All names are 32 bits long. | ||
84 | 2. The first byte of a name must be one of 'A' - 'Z', '_'. | ||
85 | 3. Each of the remaining bytes of a name must be one of 'A' - 'Z', '0' | ||
86 | - '9', '_'. | ||
87 | 4. Names starting with '_' are reserved by the ACPI specification. | ||
88 | 5. The '\' symbol represents the root of the namespace (i.e. names | ||
89 | prepended with '\' are relative to the namespace root). | ||
90 | 6. The '^' symbol represents the parent of the current namespace node | ||
91 | (i.e. names prepended with '^' are relative to the parent of the | ||
92 | current namespace node). | ||
93 | |||
94 | The figure below shows an example ACPI namespace. | ||
95 | |||
96 | +------+ | ||
97 | | \ | Root | ||
98 | +------+ | ||
99 | | | ||
100 | | +------+ | ||
101 | +-| _PR | Scope(_PR): the processor namespace | ||
102 | | +------+ | ||
103 | | | | ||
104 | | | +------+ | ||
105 | | +-| CPU0 | Processor(CPU0): the first processor | ||
106 | | +------+ | ||
107 | | | ||
108 | | +------+ | ||
109 | +-| _SB | Scope(_SB): the system bus namespace | ||
110 | | +------+ | ||
111 | | | | ||
112 | | | +------+ | ||
113 | | +-| LID0 | Device(LID0); the lid device | ||
114 | | | +------+ | ||
115 | | | | | ||
116 | | | | +------+ | ||
117 | | | +-| _HID | Name(_HID, "PNP0C0D"): the hardware ID | ||
118 | | | | +------+ | ||
119 | | | | | ||
120 | | | | +------+ | ||
121 | | | +-| _STA | Method(_STA): the status control method | ||
122 | | | +------+ | ||
123 | | | | ||
124 | | | +------+ | ||
125 | | +-| PCI0 | Device(PCI0); the PCI root bridge | ||
126 | | +------+ | ||
127 | | | | ||
128 | | | +------+ | ||
129 | | +-| _HID | Name(_HID, "PNP0A08"): the hardware ID | ||
130 | | | +------+ | ||
131 | | | | ||
132 | | | +------+ | ||
133 | | +-| _CID | Name(_CID, "PNP0A03"): the compatible ID | ||
134 | | | +------+ | ||
135 | | | | ||
136 | | | +------+ | ||
137 | | +-| RP03 | Scope(RP03): the PCI0 power scope | ||
138 | | | +------+ | ||
139 | | | | | ||
140 | | | | +------+ | ||
141 | | | +-| PXP3 | PowerResource(PXP3): the PCI0 power resource | ||
142 | | | +------+ | ||
143 | | | | ||
144 | | | +------+ | ||
145 | | +-| GFX0 | Device(GFX0): the graphics adapter | ||
146 | | +------+ | ||
147 | | | | ||
148 | | | +------+ | ||
149 | | +-| _ADR | Name(_ADR, 0x00020000): the PCI bus address | ||
150 | | | +------+ | ||
151 | | | | ||
152 | | | +------+ | ||
153 | | +-| DD01 | Device(DD01): the LCD output device | ||
154 | | +------+ | ||
155 | | | | ||
156 | | | +------+ | ||
157 | | +-| _BCL | Method(_BCL): the backlight control method | ||
158 | | +------+ | ||
159 | | | ||
160 | | +------+ | ||
161 | +-| _TZ | Scope(_TZ): the thermal zone namespace | ||
162 | | +------+ | ||
163 | | | | ||
164 | | | +------+ | ||
165 | | +-| FN00 | PowerResource(FN00): the FAN0 power resource | ||
166 | | | +------+ | ||
167 | | | | ||
168 | | | +------+ | ||
169 | | +-| FAN0 | Device(FAN0): the FAN0 cooling device | ||
170 | | | +------+ | ||
171 | | | | | ||
172 | | | | +------+ | ||
173 | | | +-| _HID | Name(_HID, "PNP0A0B"): the hardware ID | ||
174 | | | +------+ | ||
175 | | | | ||
176 | | | +------+ | ||
177 | | +-| TZ00 | ThermalZone(TZ00); the FAN thermal zone | ||
178 | | +------+ | ||
179 | | | ||
180 | | +------+ | ||
181 | +-| _GPE | Scope(_GPE): the GPE namespace | ||
182 | +------+ | ||
183 | |||
184 | Figure 2. Example ACPI Namespace | ||
185 | |||
186 | |||
187 | 3. Linux ACPI Device Objects | ||
188 | |||
189 | The Linux kernel's core ACPI subsystem creates struct acpi_device | ||
190 | objects for ACPI namespace objects representing devices, power resources | ||
191 | processors, thermal zones. Those objects are exported to user space via | ||
192 | sysfs as directories in the subtree under /sys/devices/LNXSYSTM:00. The | ||
193 | format of their names is <bus_id:instance>, where 'bus_id' refers to the | ||
194 | ACPI namespace representation of the given object and 'instance' is used | ||
195 | for distinguishing different object of the same 'bus_id' (it is | ||
196 | two-digit decimal representation of an unsigned integer). | ||
197 | |||
198 | The value of 'bus_id' depends on the type of the object whose name it is | ||
199 | part of as listed in the table below. | ||
200 | |||
201 | +---+-----------------+-------+----------+ | ||
202 | | | Object/Feature | Table | bus_id | | ||
203 | +---+-----------------+-------+----------+ | ||
204 | | N | Root | xSDT | LNXSYSTM | | ||
205 | +---+-----------------+-------+----------+ | ||
206 | | N | Device | xSDT | _HID | | ||
207 | +---+-----------------+-------+----------+ | ||
208 | | N | Processor | xSDT | LNXCPU | | ||
209 | +---+-----------------+-------+----------+ | ||
210 | | N | ThermalZone | xSDT | LNXTHERM | | ||
211 | +---+-----------------+-------+----------+ | ||
212 | | N | PowerResource | xSDT | LNXPOWER | | ||
213 | +---+-----------------+-------+----------+ | ||
214 | | N | Other Devices | xSDT | device | | ||
215 | +---+-----------------+-------+----------+ | ||
216 | | F | PWR_BUTTON | FADT | LNXPWRBN | | ||
217 | +---+-----------------+-------+----------+ | ||
218 | | F | SLP_BUTTON | FADT | LNXSLPBN | | ||
219 | +---+-----------------+-------+----------+ | ||
220 | | M | Video Extension | xSDT | LNXVIDEO | | ||
221 | +---+-----------------+-------+----------+ | ||
222 | | M | ATA Controller | xSDT | LNXIOBAY | | ||
223 | +---+-----------------+-------+----------+ | ||
224 | | M | Docking Station | xSDT | LNXDOCK | | ||
225 | +---+-----------------+-------+----------+ | ||
226 | |||
227 | Table 1. ACPI Namespace Objects Mapping | ||
228 | |||
229 | The following rules apply when creating struct acpi_device objects on | ||
230 | the basis of the contents of ACPI System Description Tables (as | ||
231 | indicated by the letter in the first column and the notation in the | ||
232 | second column of the table above): | ||
233 | N: | ||
234 | The object's source is an ACPI namespace node (as indicated by the | ||
235 | named object's type in the second column). In that case the object's | ||
236 | directory in sysfs will contain the 'path' attribute whose value is | ||
237 | the full path to the node from the namespace root. | ||
238 | struct acpi_device objects are created for the ACPI namespace nodes | ||
239 | whose _STA control methods return PRESENT or FUNCTIONING. The power | ||
240 | resource nodes or nodes without _STA are assumed to be both PRESENT | ||
241 | and FUNCTIONING. | ||
242 | F: | ||
243 | The struct acpi_device object is created for a fixed hardware | ||
244 | feature (as indicated by the fixed feature flag's name in the second | ||
245 | column), so its sysfs directory will not contain the 'path' | ||
246 | attribute. | ||
247 | M: | ||
248 | The struct acpi_device object is created for an ACPI namespace node | ||
249 | with specific control methods (as indicated by the ACPI defined | ||
250 | device's type in the second column). The 'path' attribute containing | ||
251 | its namespace path will be present in its sysfs directory. For | ||
252 | example, if the _BCL method is present for an ACPI namespace node, a | ||
253 | struct acpi_device object with LNXVIDEO 'bus_id' will be created for | ||
254 | it. | ||
255 | |||
256 | The third column of the above table indicates which ACPI System | ||
257 | Description Tables contain information used for the creation of the | ||
258 | struct acpi_device objects represented by the given row (xSDT means DSDT | ||
259 | or SSDT). | ||
260 | |||
261 | The forth column of the above table indicates the 'bus_id' generation | ||
262 | rule of the struct acpi_device object: | ||
263 | _HID: | ||
264 | _HID in the last column of the table means that the object's bus_id | ||
265 | is derived from the _HID/_CID identification objects present under | ||
266 | the corresponding ACPI namespace node. The object's sysfs directory | ||
267 | will then contain the 'hid' and 'modalias' attributes that can be | ||
268 | used to retrieve the _HID and _CIDs of that object. | ||
269 | LNXxxxxx: | ||
270 | The 'modalias' attribute is also present for struct acpi_device | ||
271 | objects having bus_id of the "LNXxxxxx" form (pseudo devices), in | ||
272 | which cases it contains the bus_id string itself. | ||
273 | device: | ||
274 | 'device' in the last column of the table indicates that the object's | ||
275 | bus_id cannot be determined from _HID/_CID of the corresponding | ||
276 | ACPI namespace node, although that object represents a device (for | ||
277 | example, it may be a PCI device with _ADR defined and without _HID | ||
278 | or _CID). In that case the string 'device' will be used as the | ||
279 | object's bus_id. | ||
280 | |||
281 | |||
282 | 4. Linux ACPI Physical Device Glue | ||
283 | |||
284 | ACPI device (i.e. struct acpi_device) objects may be linked to other | ||
285 | objects in the Linux' device hierarchy that represent "physical" devices | ||
286 | (for example, devices on the PCI bus). If that happens, it means that | ||
287 | the ACPI device object is a "companion" of a device otherwise | ||
288 | represented in a different way and is used (1) to provide configuration | ||
289 | information on that device which cannot be obtained by other means and | ||
290 | (2) to do specific things to the device with the help of its ACPI | ||
291 | control methods. One ACPI device object may be linked this way to | ||
292 | multiple "physical" devices. | ||
293 | |||
294 | If an ACPI device object is linked to a "physical" device, its sysfs | ||
295 | directory contains the "physical_node" symbolic link to the sysfs | ||
296 | directory of the target device object. In turn, the target device's | ||
297 | sysfs directory will then contain the "firmware_node" symbolic link to | ||
298 | the sysfs directory of the companion ACPI device object. | ||
299 | The linking mechanism relies on device identification provided by the | ||
300 | ACPI namespace. For example, if there's an ACPI namespace object | ||
301 | representing a PCI device (i.e. a device object under an ACPI namespace | ||
302 | object representing a PCI bridge) whose _ADR returns 0x00020000 and the | ||
303 | bus number of the parent PCI bridge is 0, the sysfs directory | ||
304 | representing the struct acpi_device object created for that ACPI | ||
305 | namespace object will contain the 'physical_node' symbolic link to the | ||
306 | /sys/devices/pci0000:00/0000:00:02:0/ sysfs directory of the | ||
307 | corresponding PCI device. | ||
308 | |||
309 | The linking mechanism is generally bus-specific. The core of its | ||
310 | implementation is located in the drivers/acpi/glue.c file, but there are | ||
311 | complementary parts depending on the bus types in question located | ||
312 | elsewhere. For example, the PCI-specific part of it is located in | ||
313 | drivers/pci/pci-acpi.c. | ||
314 | |||
315 | |||
316 | 5. Example Linux ACPI Device Tree | ||
317 | |||
318 | The sysfs hierarchy of struct acpi_device objects corresponding to the | ||
319 | example ACPI namespace illustrated in Figure 2 with the addition of | ||
320 | fixed PWR_BUTTON/SLP_BUTTON devices is shown below. | ||
321 | |||
322 | +--------------+---+-----------------+ | ||
323 | | LNXSYSTEM:00 | \ | acpi:LNXSYSTEM: | | ||
324 | +--------------+---+-----------------+ | ||
325 | | | ||
326 | | +-------------+-----+----------------+ | ||
327 | +-| LNXPWRBN:00 | N/A | acpi:LNXPWRBN: | | ||
328 | | +-------------+-----+----------------+ | ||
329 | | | ||
330 | | +-------------+-----+----------------+ | ||
331 | +-| LNXSLPBN:00 | N/A | acpi:LNXSLPBN: | | ||
332 | | +-------------+-----+----------------+ | ||
333 | | | ||
334 | | +-----------+------------+--------------+ | ||
335 | +-| LNXCPU:00 | \_PR_.CPU0 | acpi:LNXCPU: | | ||
336 | | +-----------+------------+--------------+ | ||
337 | | | ||
338 | | +-------------+-------+----------------+ | ||
339 | +-| LNXSYBUS:00 | \_SB_ | acpi:LNXSYBUS: | | ||
340 | | +-------------+-------+----------------+ | ||
341 | | | | ||
342 | | | +- - - - - - - +- - - - - - +- - - - - - - -+ | ||
343 | | +-| * PNP0C0D:00 | \_SB_.LID0 | acpi:PNP0C0D: | | ||
344 | | | +- - - - - - - +- - - - - - +- - - - - - - -+ | ||
345 | | | | ||
346 | | | +------------+------------+-----------------------+ | ||
347 | | +-| PNP0A08:00 | \_SB_.PCI0 | acpi:PNP0A08:PNP0A03: | | ||
348 | | +------------+------------+-----------------------+ | ||
349 | | | | ||
350 | | | +-----------+-----------------+-----+ | ||
351 | | +-| device:00 | \_SB_.PCI0.RP03 | N/A | | ||
352 | | | +-----------+-----------------+-----+ | ||
353 | | | | | ||
354 | | | | +-------------+----------------------+----------------+ | ||
355 | | | +-| LNXPOWER:00 | \_SB_.PCI0.RP03.PXP3 | acpi:LNXPOWER: | | ||
356 | | | +-------------+----------------------+----------------+ | ||
357 | | | | ||
358 | | | +-------------+-----------------+----------------+ | ||
359 | | +-| LNXVIDEO:00 | \_SB_.PCI0.GFX0 | acpi:LNXVIDEO: | | ||
360 | | +-------------+-----------------+----------------+ | ||
361 | | | | ||
362 | | | +-----------+-----------------+-----+ | ||
363 | | +-| device:01 | \_SB_.PCI0.DD01 | N/A | | ||
364 | | +-----------+-----------------+-----+ | ||
365 | | | ||
366 | | +-------------+-------+----------------+ | ||
367 | +-| LNXSYBUS:01 | \_TZ_ | acpi:LNXSYBUS: | | ||
368 | +-------------+-------+----------------+ | ||
369 | | | ||
370 | | +-------------+------------+----------------+ | ||
371 | +-| LNXPOWER:0a | \_TZ_.FN00 | acpi:LNXPOWER: | | ||
372 | | +-------------+------------+----------------+ | ||
373 | | | ||
374 | | +------------+------------+---------------+ | ||
375 | +-| PNP0C0B:00 | \_TZ_.FAN0 | acpi:PNP0C0B: | | ||
376 | | +------------+------------+---------------+ | ||
377 | | | ||
378 | | +-------------+------------+----------------+ | ||
379 | +-| LNXTHERM:00 | \_TZ_.TZ00 | acpi:LNXTHERM: | | ||
380 | +-------------+------------+----------------+ | ||
381 | |||
382 | Figure 3. Example Linux ACPI Device Tree | ||
383 | |||
384 | NOTE: Each node is represented as "object/path/modalias", where: | ||
385 | 1. 'object' is the name of the object's directory in sysfs. | ||
386 | 2. 'path' is the ACPI namespace path of the corresponding | ||
387 | ACPI namespace object, as returned by the object's 'path' | ||
388 | sysfs attribute. | ||
389 | 3. 'modalias' is the value of the object's 'modalias' sysfs | ||
390 | attribute (as described earlier in this document). | ||
391 | NOTE: N/A indicates the device object does not have the 'path' or the | ||
392 | 'modalias' attribute. | ||
393 | NOTE: The PNP0C0D device listed above is highlighted (marked by "*") | ||
394 | to indicate it will be created only when its _STA methods return | ||
395 | PRESENT or FUNCTIONING. | ||
diff --git a/Documentation/acpi/video_extension.txt b/Documentation/acpi/video_extension.txt new file mode 100644 index 000000000000..78b32ac02466 --- /dev/null +++ b/Documentation/acpi/video_extension.txt | |||
@@ -0,0 +1,106 @@ | |||
1 | ACPI video extensions | ||
2 | ~~~~~~~~~~~~~~~~~~~~~ | ||
3 | |||
4 | This driver implement the ACPI Extensions For Display Adapters for | ||
5 | integrated graphics devices on motherboard, as specified in ACPI 2.0 | ||
6 | Specification, Appendix B, allowing to perform some basic control like | ||
7 | defining the video POST device, retrieving EDID information or to | ||
8 | setup a video output, etc. Note that this is an ref. implementation | ||
9 | only. It may or may not work for your integrated video device. | ||
10 | |||
11 | The ACPI video driver does 3 things regarding backlight control: | ||
12 | |||
13 | 1 Export a sysfs interface for user space to control backlight level | ||
14 | |||
15 | If the ACPI table has a video device, and acpi_backlight=vendor kernel | ||
16 | command line is not present, the driver will register a backlight device | ||
17 | and set the required backlight operation structure for it for the sysfs | ||
18 | interface control. For every registered class device, there will be a | ||
19 | directory named acpi_videoX under /sys/class/backlight. | ||
20 | |||
21 | The backlight sysfs interface has a standard definition here: | ||
22 | Documentation/ABI/stable/sysfs-class-backlight. | ||
23 | |||
24 | And what ACPI video driver does is: | ||
25 | actual_brightness: on read, control method _BQC will be evaluated to | ||
26 | get the brightness level the firmware thinks it is at; | ||
27 | bl_power: not implemented, will set the current brightness instead; | ||
28 | brightness: on write, control method _BCM will run to set the requested | ||
29 | brightness level; | ||
30 | max_brightness: Derived from the _BCL package(see below); | ||
31 | type: firmware | ||
32 | |||
33 | Note that ACPI video backlight driver will always use index for | ||
34 | brightness, actual_brightness and max_brightness. So if we have | ||
35 | the following _BCL package: | ||
36 | |||
37 | Method (_BCL, 0, NotSerialized) | ||
38 | { | ||
39 | Return (Package (0x0C) | ||
40 | { | ||
41 | 0x64, | ||
42 | 0x32, | ||
43 | 0x0A, | ||
44 | 0x14, | ||
45 | 0x1E, | ||
46 | 0x28, | ||
47 | 0x32, | ||
48 | 0x3C, | ||
49 | 0x46, | ||
50 | 0x50, | ||
51 | 0x5A, | ||
52 | 0x64 | ||
53 | }) | ||
54 | } | ||
55 | |||
56 | The first two levels are for when laptop are on AC or on battery and are | ||
57 | not used by Linux currently. The remaining 10 levels are supported levels | ||
58 | that we can choose from. The applicable index values are from 0 (that | ||
59 | corresponds to the 0x0A brightness value) to 9 (that corresponds to the | ||
60 | 0x64 brightness value) inclusive. Each of those index values is regarded | ||
61 | as a "brightness level" indicator. Thus from the user space perspective | ||
62 | the range of available brightness levels is from 0 to 9 (max_brightness) | ||
63 | inclusive. | ||
64 | |||
65 | 2 Notify user space about hotkey event | ||
66 | |||
67 | There are generally two cases for hotkey event reporting: | ||
68 | i) For some laptops, when user presses the hotkey, a scancode will be | ||
69 | generated and sent to user space through the input device created by | ||
70 | the keyboard driver as a key type input event, with proper remap, the | ||
71 | following key code will appear to user space: | ||
72 | |||
73 | EV_KEY, KEY_BRIGHTNESSUP | ||
74 | EV_KEY, KEY_BRIGHTNESSDOWN | ||
75 | etc. | ||
76 | |||
77 | For this case, ACPI video driver does not need to do anything(actually, | ||
78 | it doesn't even know this happened). | ||
79 | |||
80 | ii) For some laptops, the press of the hotkey will not generate the | ||
81 | scancode, instead, firmware will notify the video device ACPI node | ||
82 | about the event. The event value is defined in the ACPI spec. ACPI | ||
83 | video driver will generate an key type input event according to the | ||
84 | notify value it received and send the event to user space through the | ||
85 | input device it created: | ||
86 | |||
87 | event keycode | ||
88 | 0x86 KEY_BRIGHTNESSUP | ||
89 | 0x87 KEY_BRIGHTNESSDOWN | ||
90 | etc. | ||
91 | |||
92 | so this would lead to the same effect as case i) now. | ||
93 | |||
94 | Once user space tool receives this event, it can modify the backlight | ||
95 | level through the sysfs interface. | ||
96 | |||
97 | 3 Change backlight level in the kernel | ||
98 | |||
99 | This works for machines covered by case ii) in Section 2. Once the driver | ||
100 | received a notification, it will set the backlight level accordingly. This does | ||
101 | not affect the sending of event to user space, they are always sent to user | ||
102 | space regardless of whether or not the video module controls the backlight level | ||
103 | directly. This behaviour can be controlled through the brightness_switch_enabled | ||
104 | module parameter as documented in kernel-parameters.txt. It is recommended to | ||
105 | disable this behaviour once a GUI environment starts up and wants to have full | ||
106 | control of the backlight level. | ||
diff --git a/Documentation/cpu-freq/cpu-drivers.txt b/Documentation/cpu-freq/cpu-drivers.txt index a3585eac83b6..19fa98e07bf7 100644 --- a/Documentation/cpu-freq/cpu-drivers.txt +++ b/Documentation/cpu-freq/cpu-drivers.txt | |||
@@ -186,7 +186,7 @@ As most cpufreq processors only allow for being set to a few specific | |||
186 | frequencies, a "frequency table" with some functions might assist in | 186 | frequencies, a "frequency table" with some functions might assist in |
187 | some work of the processor driver. Such a "frequency table" consists | 187 | some work of the processor driver. Such a "frequency table" consists |
188 | of an array of struct cpufreq_frequency_table entries, with any value in | 188 | of an array of struct cpufreq_frequency_table entries, with any value in |
189 | "index" you want to use, and the corresponding frequency in | 189 | "driver_data" you want to use, and the corresponding frequency in |
190 | "frequency". At the end of the table, you need to add a | 190 | "frequency". At the end of the table, you need to add a |
191 | cpufreq_frequency_table entry with frequency set to CPUFREQ_TABLE_END. And | 191 | cpufreq_frequency_table entry with frequency set to CPUFREQ_TABLE_END. And |
192 | if you want to skip one entry in the table, set the frequency to | 192 | if you want to skip one entry in the table, set the frequency to |
@@ -214,10 +214,4 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | |||
214 | is the corresponding frequency table helper for the ->target | 214 | is the corresponding frequency table helper for the ->target |
215 | stage. Just pass the values to this function, and the unsigned int | 215 | stage. Just pass the values to this function, and the unsigned int |
216 | index returns the number of the frequency table entry which contains | 216 | index returns the number of the frequency table entry which contains |
217 | the frequency the CPU shall be set to. PLEASE NOTE: This is not the | 217 | the frequency the CPU shall be set to. |
218 | "index" which is in this cpufreq_table_entry.index, but instead | ||
219 | cpufreq_table[index]. So, the new frequency is | ||
220 | cpufreq_table[index].frequency, and the value you stored into the | ||
221 | frequency table "index" field is | ||
222 | cpufreq_table[index].index. | ||
223 | |||
diff --git a/Documentation/cpu-hotplug.txt b/Documentation/cpu-hotplug.txt index 0efd1b905b9d..edd4b4df3932 100644 --- a/Documentation/cpu-hotplug.txt +++ b/Documentation/cpu-hotplug.txt | |||
@@ -370,8 +370,10 @@ A: There is no clear spec defined way from ACPI that can give us that | |||
370 | CPUs in MADT as hotpluggable CPUS. In the case there are no disabled CPUS | 370 | CPUs in MADT as hotpluggable CPUS. In the case there are no disabled CPUS |
371 | we assume 1/2 the number of CPUs currently present can be hotplugged. | 371 | we assume 1/2 the number of CPUs currently present can be hotplugged. |
372 | 372 | ||
373 | Caveat: Today's ACPI MADT can only provide 256 entries since the apicid field | 373 | Caveat: ACPI MADT can only provide 256 entries in systems with only ACPI 2.0c |
374 | in MADT is only 8 bits. | 374 | or earlier ACPI version supported, because the apicid field in MADT is only |
375 | 8 bits. From ACPI 3.0, this limitation was removed since the apicid field | ||
376 | was extended to 32 bits with x2APIC introduced. | ||
375 | 377 | ||
376 | User Space Notification | 378 | User Space Notification |
377 | 379 | ||
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 3c80382a84dd..ef8bd35814cf 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
@@ -3231,6 +3231,15 @@ bytes respectively. Such letter suffixes can also be entirely omitted. | |||
3231 | video= [FB] Frame buffer configuration | 3231 | video= [FB] Frame buffer configuration |
3232 | See Documentation/fb/modedb.txt. | 3232 | See Documentation/fb/modedb.txt. |
3233 | 3233 | ||
3234 | video.brightness_switch_enabled= [0,1] | ||
3235 | If set to 1, on receiving an ACPI notify event | ||
3236 | generated by hotkey, video driver will adjust brightness | ||
3237 | level and then send out the event to user space through | ||
3238 | the allocated input device; If set to 0, video driver | ||
3239 | will only send out the event without touching backlight | ||
3240 | brightness level. | ||
3241 | default: 1 | ||
3242 | |||
3234 | virtio_mmio.device= | 3243 | virtio_mmio.device= |
3235 | [VMMIO] Memory mapped virtio (platform) device. | 3244 | [VMMIO] Memory mapped virtio (platform) device. |
3236 | 3245 | ||
diff --git a/Documentation/power/pm_qos_interface.txt b/Documentation/power/pm_qos_interface.txt index 79a2a58425ee..483632087788 100644 --- a/Documentation/power/pm_qos_interface.txt +++ b/Documentation/power/pm_qos_interface.txt | |||
@@ -7,7 +7,7 @@ one of the parameters. | |||
7 | Two different PM QoS frameworks are available: | 7 | Two different PM QoS frameworks are available: |
8 | 1. PM QoS classes for cpu_dma_latency, network_latency, network_throughput. | 8 | 1. PM QoS classes for cpu_dma_latency, network_latency, network_throughput. |
9 | 2. the per-device PM QoS framework provides the API to manage the per-device latency | 9 | 2. the per-device PM QoS framework provides the API to manage the per-device latency |
10 | constraints. | 10 | constraints and PM QoS flags. |
11 | 11 | ||
12 | Each parameters have defined units: | 12 | Each parameters have defined units: |
13 | * latency: usec | 13 | * latency: usec |
@@ -86,13 +86,17 @@ To remove the user mode request for a target value simply close the device | |||
86 | node. | 86 | node. |
87 | 87 | ||
88 | 88 | ||
89 | 2. PM QoS per-device latency framework | 89 | 2. PM QoS per-device latency and flags framework |
90 | |||
91 | For each device, there are two lists of PM QoS requests. One is maintained | ||
92 | along with the aggregated target of latency value and the other is for PM QoS | ||
93 | flags. Values are updated in response to changes of the request list. | ||
94 | |||
95 | Target latency value is simply the minimum of the request values held in the | ||
96 | parameter list elements. The PM QoS flags aggregate value is a gather (bitwise | ||
97 | OR) of all list elements' values. Two device PM QoS flags are defined currently: | ||
98 | PM_QOS_FLAG_NO_POWER_OFF and PM_QOS_FLAG_REMOTE_WAKEUP. | ||
90 | 99 | ||
91 | For each device a list of performance requests is maintained along with | ||
92 | an aggregated target value. The aggregated target value is updated with | ||
93 | changes to the request list or elements of the list. Typically the | ||
94 | aggregated target value is simply the max or min of the request values held | ||
95 | in the parameter list elements. | ||
96 | Note: the aggregated target value is implemented as an atomic variable so that | 100 | Note: the aggregated target value is implemented as an atomic variable so that |
97 | reading the aggregated value does not require any locking mechanism. | 101 | reading the aggregated value does not require any locking mechanism. |
98 | 102 | ||
@@ -119,6 +123,38 @@ the request. | |||
119 | s32 dev_pm_qos_read_value(device): | 123 | s32 dev_pm_qos_read_value(device): |
120 | Returns the aggregated value for a given device's constraints list. | 124 | Returns the aggregated value for a given device's constraints list. |
121 | 125 | ||
126 | enum pm_qos_flags_status dev_pm_qos_flags(device, mask) | ||
127 | Check PM QoS flags of the given device against the given mask of flags. | ||
128 | The meaning of the return values is as follows: | ||
129 | PM_QOS_FLAGS_ALL: All flags from the mask are set | ||
130 | PM_QOS_FLAGS_SOME: Some flags from the mask are set | ||
131 | PM_QOS_FLAGS_NONE: No flags from the mask are set | ||
132 | PM_QOS_FLAGS_UNDEFINED: The device's PM QoS structure has not been | ||
133 | initialized or the list of requests is empty. | ||
134 | |||
135 | int dev_pm_qos_add_ancestor_request(dev, handle, value) | ||
136 | Add a PM QoS request for the first direct ancestor of the given device whose | ||
137 | power.ignore_children flag is unset. | ||
138 | |||
139 | int dev_pm_qos_expose_latency_limit(device, value) | ||
140 | Add a request to the device's PM QoS list of latency constraints and create | ||
141 | a sysfs attribute pm_qos_resume_latency_us under the device's power directory | ||
142 | allowing user space to manipulate that request. | ||
143 | |||
144 | void dev_pm_qos_hide_latency_limit(device) | ||
145 | Drop the request added by dev_pm_qos_expose_latency_limit() from the device's | ||
146 | PM QoS list of latency constraints and remove sysfs attribute pm_qos_resume_latency_us | ||
147 | from the device's power directory. | ||
148 | |||
149 | int dev_pm_qos_expose_flags(device, value) | ||
150 | Add a request to the device's PM QoS list of flags and create sysfs attributes | ||
151 | pm_qos_no_power_off and pm_qos_remote_wakeup under the device's power directory | ||
152 | allowing user space to change these flags' value. | ||
153 | |||
154 | void dev_pm_qos_hide_flags(device) | ||
155 | Drop the request added by dev_pm_qos_expose_flags() from the device's PM QoS list | ||
156 | of flags and remove sysfs attributes pm_qos_no_power_off and pm_qos_remote_wakeup | ||
157 | under the device's power directory. | ||
122 | 158 | ||
123 | Notification mechanisms: | 159 | Notification mechanisms: |
124 | The per-device PM QoS framework has 2 different and distinct notification trees: | 160 | The per-device PM QoS framework has 2 different and distinct notification trees: |
diff --git a/Documentation/power/runtime_pm.txt b/Documentation/power/runtime_pm.txt index 6c9f5d9aa115..71d8fe4e75d3 100644 --- a/Documentation/power/runtime_pm.txt +++ b/Documentation/power/runtime_pm.txt | |||
@@ -144,8 +144,12 @@ The action performed by the idle callback is totally dependent on the subsystem | |||
144 | (or driver) in question, but the expected and recommended action is to check | 144 | (or driver) in question, but the expected and recommended action is to check |
145 | if the device can be suspended (i.e. if all of the conditions necessary for | 145 | if the device can be suspended (i.e. if all of the conditions necessary for |
146 | suspending the device are satisfied) and to queue up a suspend request for the | 146 | suspending the device are satisfied) and to queue up a suspend request for the |
147 | device in that case. The value returned by this callback is ignored by the PM | 147 | device in that case. If there is no idle callback, or if the callback returns |
148 | core. | 148 | 0, then the PM core will attempt to carry out a runtime suspend of the device; |
149 | in essence, it will call pm_runtime_suspend() directly. To prevent this (for | ||
150 | example, if the callback routine has started a delayed suspend), the routine | ||
151 | should return a non-zero value. Negative error return codes are ignored by the | ||
152 | PM core. | ||
149 | 153 | ||
150 | The helper functions provided by the PM core, described in Section 4, guarantee | 154 | The helper functions provided by the PM core, described in Section 4, guarantee |
151 | that the following constraints are met with respect to runtime PM callbacks for | 155 | that the following constraints are met with respect to runtime PM callbacks for |
@@ -301,9 +305,10 @@ drivers/base/power/runtime.c and include/linux/pm_runtime.h: | |||
301 | removing the device from device hierarchy | 305 | removing the device from device hierarchy |
302 | 306 | ||
303 | int pm_runtime_idle(struct device *dev); | 307 | int pm_runtime_idle(struct device *dev); |
304 | - execute the subsystem-level idle callback for the device; returns 0 on | 308 | - execute the subsystem-level idle callback for the device; returns an |
305 | success or error code on failure, where -EINPROGRESS means that | 309 | error code on failure, where -EINPROGRESS means that ->runtime_idle() is |
306 | ->runtime_idle() is already being executed | 310 | already being executed; if there is no callback or the callback returns 0 |
311 | then run pm_runtime_suspend(dev) and return its result | ||
307 | 312 | ||
308 | int pm_runtime_suspend(struct device *dev); | 313 | int pm_runtime_suspend(struct device *dev); |
309 | - execute the subsystem-level suspend callback for the device; returns 0 on | 314 | - execute the subsystem-level suspend callback for the device; returns 0 on |
@@ -660,11 +665,6 @@ Subsystems may wish to conserve code space by using the set of generic power | |||
660 | management callbacks provided by the PM core, defined in | 665 | management callbacks provided by the PM core, defined in |
661 | driver/base/power/generic_ops.c: | 666 | driver/base/power/generic_ops.c: |
662 | 667 | ||
663 | int pm_generic_runtime_idle(struct device *dev); | ||
664 | - invoke the ->runtime_idle() callback provided by the driver of this | ||
665 | device, if defined, and call pm_runtime_suspend() for this device if the | ||
666 | return value is 0 or the callback is not defined | ||
667 | |||
668 | int pm_generic_runtime_suspend(struct device *dev); | 668 | int pm_generic_runtime_suspend(struct device *dev); |
669 | - invoke the ->runtime_suspend() callback provided by the driver of this | 669 | - invoke the ->runtime_suspend() callback provided by the driver of this |
670 | device and return its result, or return -EINVAL if not defined | 670 | device and return its result, or return -EINVAL if not defined |
diff --git a/Documentation/power/video_extension.txt b/Documentation/power/video_extension.txt deleted file mode 100644 index b2f9b1598ac2..000000000000 --- a/Documentation/power/video_extension.txt +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | ACPI video extensions | ||
2 | ~~~~~~~~~~~~~~~~~~~~~ | ||
3 | |||
4 | This driver implement the ACPI Extensions For Display Adapters for | ||
5 | integrated graphics devices on motherboard, as specified in ACPI 2.0 | ||
6 | Specification, Appendix B, allowing to perform some basic control like | ||
7 | defining the video POST device, retrieving EDID information or to | ||
8 | setup a video output, etc. Note that this is an ref. implementation | ||
9 | only. It may or may not work for your integrated video device. | ||
10 | |||
11 | Interfaces exposed to userland through /proc/acpi/video: | ||
12 | |||
13 | VGA/info : display the supported video bus device capability like Video ROM, CRT/LCD/TV. | ||
14 | VGA/ROM : Used to get a copy of the display devices' ROM data (up to 4k). | ||
15 | VGA/POST_info : Used to determine what options are implemented. | ||
16 | VGA/POST : Used to get/set POST device. | ||
17 | VGA/DOS : Used to get/set ownership of output switching: | ||
18 | Please refer ACPI spec B.4.1 _DOS | ||
19 | VGA/CRT : CRT output | ||
20 | VGA/LCD : LCD output | ||
21 | VGA/TVO : TV output | ||
22 | VGA/*/brightness : Used to get/set brightness of output device | ||
23 | |||
24 | Notify event through /proc/acpi/event: | ||
25 | |||
26 | #define ACPI_VIDEO_NOTIFY_SWITCH 0x80 | ||
27 | #define ACPI_VIDEO_NOTIFY_PROBE 0x81 | ||
28 | #define ACPI_VIDEO_NOTIFY_CYCLE 0x82 | ||
29 | #define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83 | ||
30 | #define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84 | ||
31 | |||
32 | #define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x82 | ||
33 | #define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x83 | ||
34 | #define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x84 | ||
35 | #define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x85 | ||
36 | #define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x86 | ||
37 | |||
diff --git a/Documentation/trace/events-power.txt b/Documentation/trace/events-power.txt index e1498ff8cf94..3bd33b8dc7c4 100644 --- a/Documentation/trace/events-power.txt +++ b/Documentation/trace/events-power.txt | |||
@@ -63,3 +63,34 @@ power_domain_target "%s state=%lu cpu_id=%lu" | |||
63 | The first parameter gives the power domain name (e.g. "mpu_pwrdm"). | 63 | The first parameter gives the power domain name (e.g. "mpu_pwrdm"). |
64 | The second parameter is the power domain target state. | 64 | The second parameter is the power domain target state. |
65 | 65 | ||
66 | 4. PM QoS events | ||
67 | ================ | ||
68 | The PM QoS events are used for QoS add/update/remove request and for | ||
69 | target/flags update. | ||
70 | |||
71 | pm_qos_add_request "pm_qos_class=%s value=%d" | ||
72 | pm_qos_update_request "pm_qos_class=%s value=%d" | ||
73 | pm_qos_remove_request "pm_qos_class=%s value=%d" | ||
74 | pm_qos_update_request_timeout "pm_qos_class=%s value=%d, timeout_us=%ld" | ||
75 | |||
76 | The first parameter gives the QoS class name (e.g. "CPU_DMA_LATENCY"). | ||
77 | The second parameter is value to be added/updated/removed. | ||
78 | The third parameter is timeout value in usec. | ||
79 | |||
80 | pm_qos_update_target "action=%s prev_value=%d curr_value=%d" | ||
81 | pm_qos_update_flags "action=%s prev_value=0x%x curr_value=0x%x" | ||
82 | |||
83 | The first parameter gives the QoS action name (e.g. "ADD_REQ"). | ||
84 | The second parameter is the previous QoS value. | ||
85 | The third parameter is the current QoS value to update. | ||
86 | |||
87 | And, there are also events used for device PM QoS add/update/remove request. | ||
88 | |||
89 | dev_pm_qos_add_request "device=%s type=%s new_value=%d" | ||
90 | dev_pm_qos_update_request "device=%s type=%s new_value=%d" | ||
91 | dev_pm_qos_remove_request "device=%s type=%s new_value=%d" | ||
92 | |||
93 | The first parameter gives the device name which tries to add/update/remove | ||
94 | QoS requests. | ||
95 | The second parameter gives the request type (e.g. "DEV_PM_QOS_LATENCY"). | ||
96 | The third parameter is value to be added/updated/removed. | ||
diff --git a/MAINTAINERS b/MAINTAINERS index 85c1402e8a12..6d9578131c31 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -242,6 +242,8 @@ F: drivers/acpi/ | |||
242 | F: drivers/pnp/pnpacpi/ | 242 | F: drivers/pnp/pnpacpi/ |
243 | F: include/linux/acpi.h | 243 | F: include/linux/acpi.h |
244 | F: include/acpi/ | 244 | F: include/acpi/ |
245 | F: Documentation/acpi | ||
246 | F: Documentation/ABI/testing/sysfs-bus-acpi | ||
245 | 247 | ||
246 | ACPI FAN DRIVER | 248 | ACPI FAN DRIVER |
247 | M: Zhang Rui <rui.zhang@intel.com> | 249 | M: Zhang Rui <rui.zhang@intel.com> |
@@ -1320,6 +1322,7 @@ W: http://wiki.xilinx.com | |||
1320 | T: git git://git.xilinx.com/linux-xlnx.git | 1322 | T: git git://git.xilinx.com/linux-xlnx.git |
1321 | S: Supported | 1323 | S: Supported |
1322 | F: arch/arm/mach-zynq/ | 1324 | F: arch/arm/mach-zynq/ |
1325 | F: drivers/cpuidle/cpuidle-zynq.c | ||
1323 | 1326 | ||
1324 | ARM64 PORT (AARCH64 ARCHITECTURE) | 1327 | ARM64 PORT (AARCH64 ARCHITECTURE) |
1325 | M: Catalin Marinas <catalin.marinas@arm.com> | 1328 | M: Catalin Marinas <catalin.marinas@arm.com> |
@@ -2227,7 +2230,8 @@ M: Viresh Kumar <viresh.kumar@linaro.org> | |||
2227 | L: cpufreq@vger.kernel.org | 2230 | L: cpufreq@vger.kernel.org |
2228 | L: linux-pm@vger.kernel.org | 2231 | L: linux-pm@vger.kernel.org |
2229 | S: Maintained | 2232 | S: Maintained |
2230 | T: git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git | 2233 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git |
2234 | T: git git://git.linaro.org/people/vireshk/linux.git (For ARM Updates) | ||
2231 | F: drivers/cpufreq/ | 2235 | F: drivers/cpufreq/ |
2232 | F: include/linux/cpufreq.h | 2236 | F: include/linux/cpufreq.h |
2233 | 2237 | ||
@@ -2528,7 +2532,7 @@ F: drivers/usb/dwc3/ | |||
2528 | DEVICE FREQUENCY (DEVFREQ) | 2532 | DEVICE FREQUENCY (DEVFREQ) |
2529 | M: MyungJoo Ham <myungjoo.ham@samsung.com> | 2533 | M: MyungJoo Ham <myungjoo.ham@samsung.com> |
2530 | M: Kyungmin Park <kyungmin.park@samsung.com> | 2534 | M: Kyungmin Park <kyungmin.park@samsung.com> |
2531 | L: linux-kernel@vger.kernel.org | 2535 | L: linux-pm@vger.kernel.org |
2532 | S: Maintained | 2536 | S: Maintained |
2533 | F: drivers/devfreq/ | 2537 | F: drivers/devfreq/ |
2534 | 2538 | ||
diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig index a075b3e0c5c7..e026b19b23ea 100644 --- a/arch/arm/mach-davinci/Kconfig +++ b/arch/arm/mach-davinci/Kconfig | |||
@@ -40,6 +40,7 @@ config ARCH_DAVINCI_DA850 | |||
40 | bool "DA850/OMAP-L138/AM18x based system" | 40 | bool "DA850/OMAP-L138/AM18x based system" |
41 | select ARCH_DAVINCI_DA8XX | 41 | select ARCH_DAVINCI_DA8XX |
42 | select ARCH_HAS_CPUFREQ | 42 | select ARCH_HAS_CPUFREQ |
43 | select CPU_FREQ_TABLE | ||
43 | select CP_INTC | 44 | select CP_INTC |
44 | 45 | ||
45 | config ARCH_DAVINCI_DA8XX | 46 | config ARCH_DAVINCI_DA8XX |
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c index 4d6933848abf..a0d4f6038b60 100644 --- a/arch/arm/mach-davinci/da850.c +++ b/arch/arm/mach-davinci/da850.c | |||
@@ -1004,7 +1004,7 @@ static const struct da850_opp da850_opp_96 = { | |||
1004 | 1004 | ||
1005 | #define OPP(freq) \ | 1005 | #define OPP(freq) \ |
1006 | { \ | 1006 | { \ |
1007 | .index = (unsigned int) &da850_opp_##freq, \ | 1007 | .driver_data = (unsigned int) &da850_opp_##freq, \ |
1008 | .frequency = freq * 1000, \ | 1008 | .frequency = freq * 1000, \ |
1009 | } | 1009 | } |
1010 | 1010 | ||
@@ -1016,7 +1016,7 @@ static struct cpufreq_frequency_table da850_freq_table[] = { | |||
1016 | OPP(200), | 1016 | OPP(200), |
1017 | OPP(96), | 1017 | OPP(96), |
1018 | { | 1018 | { |
1019 | .index = 0, | 1019 | .driver_data = 0, |
1020 | .frequency = CPUFREQ_TABLE_END, | 1020 | .frequency = CPUFREQ_TABLE_END, |
1021 | }, | 1021 | }, |
1022 | }; | 1022 | }; |
@@ -1044,7 +1044,7 @@ static int da850_set_voltage(unsigned int index) | |||
1044 | if (!cvdd) | 1044 | if (!cvdd) |
1045 | return -ENODEV; | 1045 | return -ENODEV; |
1046 | 1046 | ||
1047 | opp = (struct da850_opp *) cpufreq_info.freq_table[index].index; | 1047 | opp = (struct da850_opp *) cpufreq_info.freq_table[index].driver_data; |
1048 | 1048 | ||
1049 | return regulator_set_voltage(cvdd, opp->cvdd_min, opp->cvdd_max); | 1049 | return regulator_set_voltage(cvdd, opp->cvdd_min, opp->cvdd_max); |
1050 | } | 1050 | } |
@@ -1125,7 +1125,7 @@ static int da850_set_pll0rate(struct clk *clk, unsigned long index) | |||
1125 | struct pll_data *pll = clk->pll_data; | 1125 | struct pll_data *pll = clk->pll_data; |
1126 | int ret; | 1126 | int ret; |
1127 | 1127 | ||
1128 | opp = (struct da850_opp *) cpufreq_info.freq_table[index].index; | 1128 | opp = (struct da850_opp *) cpufreq_info.freq_table[index].driver_data; |
1129 | prediv = opp->prediv; | 1129 | prediv = opp->prediv; |
1130 | mult = opp->mult; | 1130 | mult = opp->mult; |
1131 | postdiv = opp->postdiv; | 1131 | postdiv = opp->postdiv; |
diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c index 68be532f8688..5cc92874be7e 100644 --- a/arch/arm/mach-omap2/omap_device.c +++ b/arch/arm/mach-omap2/omap_device.c | |||
@@ -588,11 +588,6 @@ static int _od_runtime_suspend(struct device *dev) | |||
588 | return ret; | 588 | return ret; |
589 | } | 589 | } |
590 | 590 | ||
591 | static int _od_runtime_idle(struct device *dev) | ||
592 | { | ||
593 | return pm_generic_runtime_idle(dev); | ||
594 | } | ||
595 | |||
596 | static int _od_runtime_resume(struct device *dev) | 591 | static int _od_runtime_resume(struct device *dev) |
597 | { | 592 | { |
598 | struct platform_device *pdev = to_platform_device(dev); | 593 | struct platform_device *pdev = to_platform_device(dev); |
@@ -648,7 +643,7 @@ static int _od_resume_noirq(struct device *dev) | |||
648 | struct dev_pm_domain omap_device_pm_domain = { | 643 | struct dev_pm_domain omap_device_pm_domain = { |
649 | .ops = { | 644 | .ops = { |
650 | SET_RUNTIME_PM_OPS(_od_runtime_suspend, _od_runtime_resume, | 645 | SET_RUNTIME_PM_OPS(_od_runtime_suspend, _od_runtime_resume, |
651 | _od_runtime_idle) | 646 | NULL) |
652 | USE_PLATFORM_PM_SLEEP_OPS | 647 | USE_PLATFORM_PM_SLEEP_OPS |
653 | .suspend_noirq = _od_suspend_noirq, | 648 | .suspend_noirq = _od_suspend_noirq, |
654 | .resume_noirq = _od_resume_noirq, | 649 | .resume_noirq = _od_resume_noirq, |
diff --git a/arch/arm/mach-omap2/smartreflex-class3.c b/arch/arm/mach-omap2/smartreflex-class3.c index aee3c8940a30..7a42e1960c3b 100644 --- a/arch/arm/mach-omap2/smartreflex-class3.c +++ b/arch/arm/mach-omap2/smartreflex-class3.c | |||
@@ -26,14 +26,14 @@ static int sr_class3_enable(struct omap_sr *sr) | |||
26 | } | 26 | } |
27 | 27 | ||
28 | omap_vp_enable(sr->voltdm); | 28 | omap_vp_enable(sr->voltdm); |
29 | return sr_enable(sr->voltdm, volt); | 29 | return sr_enable(sr, volt); |
30 | } | 30 | } |
31 | 31 | ||
32 | static int sr_class3_disable(struct omap_sr *sr, int is_volt_reset) | 32 | static int sr_class3_disable(struct omap_sr *sr, int is_volt_reset) |
33 | { | 33 | { |
34 | sr_disable_errgen(sr->voltdm); | 34 | sr_disable_errgen(sr); |
35 | omap_vp_disable(sr->voltdm); | 35 | omap_vp_disable(sr->voltdm); |
36 | sr_disable(sr->voltdm); | 36 | sr_disable(sr); |
37 | if (is_volt_reset) | 37 | if (is_volt_reset) |
38 | voltdm_reset(sr->voltdm); | 38 | voltdm_reset(sr->voltdm); |
39 | 39 | ||
@@ -42,7 +42,7 @@ static int sr_class3_disable(struct omap_sr *sr, int is_volt_reset) | |||
42 | 42 | ||
43 | static int sr_class3_configure(struct omap_sr *sr) | 43 | static int sr_class3_configure(struct omap_sr *sr) |
44 | { | 44 | { |
45 | return sr_configure_errgen(sr->voltdm); | 45 | return sr_configure_errgen(sr); |
46 | } | 46 | } |
47 | 47 | ||
48 | /* SR class3 structure */ | 48 | /* SR class3 structure */ |
diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig index 96100dbf5a2e..a8427115ee07 100644 --- a/arch/arm/mach-pxa/Kconfig +++ b/arch/arm/mach-pxa/Kconfig | |||
@@ -615,12 +615,14 @@ endmenu | |||
615 | config PXA25x | 615 | config PXA25x |
616 | bool | 616 | bool |
617 | select CPU_XSCALE | 617 | select CPU_XSCALE |
618 | select CPU_FREQ_TABLE if CPU_FREQ | ||
618 | help | 619 | help |
619 | Select code specific to PXA21x/25x/26x variants | 620 | Select code specific to PXA21x/25x/26x variants |
620 | 621 | ||
621 | config PXA27x | 622 | config PXA27x |
622 | bool | 623 | bool |
623 | select CPU_XSCALE | 624 | select CPU_XSCALE |
625 | select CPU_FREQ_TABLE if CPU_FREQ | ||
624 | help | 626 | help |
625 | Select code specific to PXA27x variants | 627 | Select code specific to PXA27x variants |
626 | 628 | ||
@@ -633,6 +635,7 @@ config CPU_PXA26x | |||
633 | config PXA3xx | 635 | config PXA3xx |
634 | bool | 636 | bool |
635 | select CPU_XSC3 | 637 | select CPU_XSC3 |
638 | select CPU_FREQ_TABLE if CPU_FREQ | ||
636 | help | 639 | help |
637 | Select code specific to PXA3xx variants | 640 | Select code specific to PXA3xx variants |
638 | 641 | ||
diff --git a/arch/arm/mach-s3c24xx/cpufreq-utils.c b/arch/arm/mach-s3c24xx/cpufreq-utils.c index ddd8280e3875..2a0aa5684e72 100644 --- a/arch/arm/mach-s3c24xx/cpufreq-utils.c +++ b/arch/arm/mach-s3c24xx/cpufreq-utils.c | |||
@@ -60,5 +60,5 @@ void s3c2410_cpufreq_setrefresh(struct s3c_cpufreq_config *cfg) | |||
60 | */ | 60 | */ |
61 | void s3c2410_set_fvco(struct s3c_cpufreq_config *cfg) | 61 | void s3c2410_set_fvco(struct s3c_cpufreq_config *cfg) |
62 | { | 62 | { |
63 | __raw_writel(cfg->pll.index, S3C2410_MPLLCON); | 63 | __raw_writel(cfg->pll.driver_data, S3C2410_MPLLCON); |
64 | } | 64 | } |
diff --git a/arch/arm/mach-s3c24xx/pll-s3c2410.c b/arch/arm/mach-s3c24xx/pll-s3c2410.c index dcf3420a3271..5e37d368594b 100644 --- a/arch/arm/mach-s3c24xx/pll-s3c2410.c +++ b/arch/arm/mach-s3c24xx/pll-s3c2410.c | |||
@@ -33,36 +33,36 @@ | |||
33 | #include <plat/cpu-freq-core.h> | 33 | #include <plat/cpu-freq-core.h> |
34 | 34 | ||
35 | static struct cpufreq_frequency_table pll_vals_12MHz[] = { | 35 | static struct cpufreq_frequency_table pll_vals_12MHz[] = { |
36 | { .frequency = 34000000, .index = PLLVAL(82, 2, 3), }, | 36 | { .frequency = 34000000, .driver_data = PLLVAL(82, 2, 3), }, |
37 | { .frequency = 45000000, .index = PLLVAL(82, 1, 3), }, | 37 | { .frequency = 45000000, .driver_data = PLLVAL(82, 1, 3), }, |
38 | { .frequency = 51000000, .index = PLLVAL(161, 3, 3), }, | 38 | { .frequency = 51000000, .driver_data = PLLVAL(161, 3, 3), }, |
39 | { .frequency = 48000000, .index = PLLVAL(120, 2, 3), }, | 39 | { .frequency = 48000000, .driver_data = PLLVAL(120, 2, 3), }, |
40 | { .frequency = 56000000, .index = PLLVAL(142, 2, 3), }, | 40 | { .frequency = 56000000, .driver_data = PLLVAL(142, 2, 3), }, |
41 | { .frequency = 68000000, .index = PLLVAL(82, 2, 2), }, | 41 | { .frequency = 68000000, .driver_data = PLLVAL(82, 2, 2), }, |
42 | { .frequency = 79000000, .index = PLLVAL(71, 1, 2), }, | 42 | { .frequency = 79000000, .driver_data = PLLVAL(71, 1, 2), }, |
43 | { .frequency = 85000000, .index = PLLVAL(105, 2, 2), }, | 43 | { .frequency = 85000000, .driver_data = PLLVAL(105, 2, 2), }, |
44 | { .frequency = 90000000, .index = PLLVAL(112, 2, 2), }, | 44 | { .frequency = 90000000, .driver_data = PLLVAL(112, 2, 2), }, |
45 | { .frequency = 101000000, .index = PLLVAL(127, 2, 2), }, | 45 | { .frequency = 101000000, .driver_data = PLLVAL(127, 2, 2), }, |
46 | { .frequency = 113000000, .index = PLLVAL(105, 1, 2), }, | 46 | { .frequency = 113000000, .driver_data = PLLVAL(105, 1, 2), }, |
47 | { .frequency = 118000000, .index = PLLVAL(150, 2, 2), }, | 47 | { .frequency = 118000000, .driver_data = PLLVAL(150, 2, 2), }, |
48 | { .frequency = 124000000, .index = PLLVAL(116, 1, 2), }, | 48 | { .frequency = 124000000, .driver_data = PLLVAL(116, 1, 2), }, |
49 | { .frequency = 135000000, .index = PLLVAL(82, 2, 1), }, | 49 | { .frequency = 135000000, .driver_data = PLLVAL(82, 2, 1), }, |
50 | { .frequency = 147000000, .index = PLLVAL(90, 2, 1), }, | 50 | { .frequency = 147000000, .driver_data = PLLVAL(90, 2, 1), }, |
51 | { .frequency = 152000000, .index = PLLVAL(68, 1, 1), }, | 51 | { .frequency = 152000000, .driver_data = PLLVAL(68, 1, 1), }, |
52 | { .frequency = 158000000, .index = PLLVAL(71, 1, 1), }, | 52 | { .frequency = 158000000, .driver_data = PLLVAL(71, 1, 1), }, |
53 | { .frequency = 170000000, .index = PLLVAL(77, 1, 1), }, | 53 | { .frequency = 170000000, .driver_data = PLLVAL(77, 1, 1), }, |
54 | { .frequency = 180000000, .index = PLLVAL(82, 1, 1), }, | 54 | { .frequency = 180000000, .driver_data = PLLVAL(82, 1, 1), }, |
55 | { .frequency = 186000000, .index = PLLVAL(85, 1, 1), }, | 55 | { .frequency = 186000000, .driver_data = PLLVAL(85, 1, 1), }, |
56 | { .frequency = 192000000, .index = PLLVAL(88, 1, 1), }, | 56 | { .frequency = 192000000, .driver_data = PLLVAL(88, 1, 1), }, |
57 | { .frequency = 203000000, .index = PLLVAL(161, 3, 1), }, | 57 | { .frequency = 203000000, .driver_data = PLLVAL(161, 3, 1), }, |
58 | 58 | ||
59 | /* 2410A extras */ | 59 | /* 2410A extras */ |
60 | 60 | ||
61 | { .frequency = 210000000, .index = PLLVAL(132, 2, 1), }, | 61 | { .frequency = 210000000, .driver_data = PLLVAL(132, 2, 1), }, |
62 | { .frequency = 226000000, .index = PLLVAL(105, 1, 1), }, | 62 | { .frequency = 226000000, .driver_data = PLLVAL(105, 1, 1), }, |
63 | { .frequency = 266000000, .index = PLLVAL(125, 1, 1), }, | 63 | { .frequency = 266000000, .driver_data = PLLVAL(125, 1, 1), }, |
64 | { .frequency = 268000000, .index = PLLVAL(126, 1, 1), }, | 64 | { .frequency = 268000000, .driver_data = PLLVAL(126, 1, 1), }, |
65 | { .frequency = 270000000, .index = PLLVAL(127, 1, 1), }, | 65 | { .frequency = 270000000, .driver_data = PLLVAL(127, 1, 1), }, |
66 | }; | 66 | }; |
67 | 67 | ||
68 | static int s3c2410_plls_add(struct device *dev, struct subsys_interface *sif) | 68 | static int s3c2410_plls_add(struct device *dev, struct subsys_interface *sif) |
diff --git a/arch/arm/mach-s3c24xx/pll-s3c2440-12000000.c b/arch/arm/mach-s3c24xx/pll-s3c2440-12000000.c index 673781758319..a19460e6e7b0 100644 --- a/arch/arm/mach-s3c24xx/pll-s3c2440-12000000.c +++ b/arch/arm/mach-s3c24xx/pll-s3c2440-12000000.c | |||
@@ -21,33 +21,33 @@ | |||
21 | #include <plat/cpu-freq-core.h> | 21 | #include <plat/cpu-freq-core.h> |
22 | 22 | ||
23 | static struct cpufreq_frequency_table s3c2440_plls_12[] __initdata = { | 23 | static struct cpufreq_frequency_table s3c2440_plls_12[] __initdata = { |
24 | { .frequency = 75000000, .index = PLLVAL(0x75, 3, 3), }, /* FVco 600.000000 */ | 24 | { .frequency = 75000000, .driver_data = PLLVAL(0x75, 3, 3), }, /* FVco 600.000000 */ |
25 | { .frequency = 80000000, .index = PLLVAL(0x98, 4, 3), }, /* FVco 640.000000 */ | 25 | { .frequency = 80000000, .driver_data = PLLVAL(0x98, 4, 3), }, /* FVco 640.000000 */ |
26 | { .frequency = 90000000, .index = PLLVAL(0x70, 2, 3), }, /* FVco 720.000000 */ | 26 | { .frequency = 90000000, .driver_data = PLLVAL(0x70, 2, 3), }, /* FVco 720.000000 */ |
27 | { .frequency = 100000000, .index = PLLVAL(0x5c, 1, 3), }, /* FVco 800.000000 */ | 27 | { .frequency = 100000000, .driver_data = PLLVAL(0x5c, 1, 3), }, /* FVco 800.000000 */ |
28 | { .frequency = 110000000, .index = PLLVAL(0x66, 1, 3), }, /* FVco 880.000000 */ | 28 | { .frequency = 110000000, .driver_data = PLLVAL(0x66, 1, 3), }, /* FVco 880.000000 */ |
29 | { .frequency = 120000000, .index = PLLVAL(0x70, 1, 3), }, /* FVco 960.000000 */ | 29 | { .frequency = 120000000, .driver_data = PLLVAL(0x70, 1, 3), }, /* FVco 960.000000 */ |
30 | { .frequency = 150000000, .index = PLLVAL(0x75, 3, 2), }, /* FVco 600.000000 */ | 30 | { .frequency = 150000000, .driver_data = PLLVAL(0x75, 3, 2), }, /* FVco 600.000000 */ |
31 | { .frequency = 160000000, .index = PLLVAL(0x98, 4, 2), }, /* FVco 640.000000 */ | 31 | { .frequency = 160000000, .driver_data = PLLVAL(0x98, 4, 2), }, /* FVco 640.000000 */ |
32 | { .frequency = 170000000, .index = PLLVAL(0x4d, 1, 2), }, /* FVco 680.000000 */ | 32 | { .frequency = 170000000, .driver_data = PLLVAL(0x4d, 1, 2), }, /* FVco 680.000000 */ |
33 | { .frequency = 180000000, .index = PLLVAL(0x70, 2, 2), }, /* FVco 720.000000 */ | 33 | { .frequency = 180000000, .driver_data = PLLVAL(0x70, 2, 2), }, /* FVco 720.000000 */ |
34 | { .frequency = 190000000, .index = PLLVAL(0x57, 1, 2), }, /* FVco 760.000000 */ | 34 | { .frequency = 190000000, .driver_data = PLLVAL(0x57, 1, 2), }, /* FVco 760.000000 */ |
35 | { .frequency = 200000000, .index = PLLVAL(0x5c, 1, 2), }, /* FVco 800.000000 */ | 35 | { .frequency = 200000000, .driver_data = PLLVAL(0x5c, 1, 2), }, /* FVco 800.000000 */ |
36 | { .frequency = 210000000, .index = PLLVAL(0x84, 2, 2), }, /* FVco 840.000000 */ | 36 | { .frequency = 210000000, .driver_data = PLLVAL(0x84, 2, 2), }, /* FVco 840.000000 */ |
37 | { .frequency = 220000000, .index = PLLVAL(0x66, 1, 2), }, /* FVco 880.000000 */ | 37 | { .frequency = 220000000, .driver_data = PLLVAL(0x66, 1, 2), }, /* FVco 880.000000 */ |
38 | { .frequency = 230000000, .index = PLLVAL(0x6b, 1, 2), }, /* FVco 920.000000 */ | 38 | { .frequency = 230000000, .driver_data = PLLVAL(0x6b, 1, 2), }, /* FVco 920.000000 */ |
39 | { .frequency = 240000000, .index = PLLVAL(0x70, 1, 2), }, /* FVco 960.000000 */ | 39 | { .frequency = 240000000, .driver_data = PLLVAL(0x70, 1, 2), }, /* FVco 960.000000 */ |
40 | { .frequency = 300000000, .index = PLLVAL(0x75, 3, 1), }, /* FVco 600.000000 */ | 40 | { .frequency = 300000000, .driver_data = PLLVAL(0x75, 3, 1), }, /* FVco 600.000000 */ |
41 | { .frequency = 310000000, .index = PLLVAL(0x93, 4, 1), }, /* FVco 620.000000 */ | 41 | { .frequency = 310000000, .driver_data = PLLVAL(0x93, 4, 1), }, /* FVco 620.000000 */ |
42 | { .frequency = 320000000, .index = PLLVAL(0x98, 4, 1), }, /* FVco 640.000000 */ | 42 | { .frequency = 320000000, .driver_data = PLLVAL(0x98, 4, 1), }, /* FVco 640.000000 */ |
43 | { .frequency = 330000000, .index = PLLVAL(0x66, 2, 1), }, /* FVco 660.000000 */ | 43 | { .frequency = 330000000, .driver_data = PLLVAL(0x66, 2, 1), }, /* FVco 660.000000 */ |
44 | { .frequency = 340000000, .index = PLLVAL(0x4d, 1, 1), }, /* FVco 680.000000 */ | 44 | { .frequency = 340000000, .driver_data = PLLVAL(0x4d, 1, 1), }, /* FVco 680.000000 */ |
45 | { .frequency = 350000000, .index = PLLVAL(0xa7, 4, 1), }, /* FVco 700.000000 */ | 45 | { .frequency = 350000000, .driver_data = PLLVAL(0xa7, 4, 1), }, /* FVco 700.000000 */ |
46 | { .frequency = 360000000, .index = PLLVAL(0x70, 2, 1), }, /* FVco 720.000000 */ | 46 | { .frequency = 360000000, .driver_data = PLLVAL(0x70, 2, 1), }, /* FVco 720.000000 */ |
47 | { .frequency = 370000000, .index = PLLVAL(0xb1, 4, 1), }, /* FVco 740.000000 */ | 47 | { .frequency = 370000000, .driver_data = PLLVAL(0xb1, 4, 1), }, /* FVco 740.000000 */ |
48 | { .frequency = 380000000, .index = PLLVAL(0x57, 1, 1), }, /* FVco 760.000000 */ | 48 | { .frequency = 380000000, .driver_data = PLLVAL(0x57, 1, 1), }, /* FVco 760.000000 */ |
49 | { .frequency = 390000000, .index = PLLVAL(0x7a, 2, 1), }, /* FVco 780.000000 */ | 49 | { .frequency = 390000000, .driver_data = PLLVAL(0x7a, 2, 1), }, /* FVco 780.000000 */ |
50 | { .frequency = 400000000, .index = PLLVAL(0x5c, 1, 1), }, /* FVco 800.000000 */ | 50 | { .frequency = 400000000, .driver_data = PLLVAL(0x5c, 1, 1), }, /* FVco 800.000000 */ |
51 | }; | 51 | }; |
52 | 52 | ||
53 | static int s3c2440_plls12_add(struct device *dev, struct subsys_interface *sif) | 53 | static int s3c2440_plls12_add(struct device *dev, struct subsys_interface *sif) |
diff --git a/arch/arm/mach-s3c24xx/pll-s3c2440-16934400.c b/arch/arm/mach-s3c24xx/pll-s3c2440-16934400.c index debfa106289b..1191b2905625 100644 --- a/arch/arm/mach-s3c24xx/pll-s3c2440-16934400.c +++ b/arch/arm/mach-s3c24xx/pll-s3c2440-16934400.c | |||
@@ -21,61 +21,61 @@ | |||
21 | #include <plat/cpu-freq-core.h> | 21 | #include <plat/cpu-freq-core.h> |
22 | 22 | ||
23 | static struct cpufreq_frequency_table s3c2440_plls_169344[] __initdata = { | 23 | static struct cpufreq_frequency_table s3c2440_plls_169344[] __initdata = { |
24 | { .frequency = 78019200, .index = PLLVAL(121, 5, 3), }, /* FVco 624.153600 */ | 24 | { .frequency = 78019200, .driver_data = PLLVAL(121, 5, 3), }, /* FVco 624.153600 */ |
25 | { .frequency = 84067200, .index = PLLVAL(131, 5, 3), }, /* FVco 672.537600 */ | 25 | { .frequency = 84067200, .driver_data = PLLVAL(131, 5, 3), }, /* FVco 672.537600 */ |
26 | { .frequency = 90115200, .index = PLLVAL(141, 5, 3), }, /* FVco 720.921600 */ | 26 | { .frequency = 90115200, .driver_data = PLLVAL(141, 5, 3), }, /* FVco 720.921600 */ |
27 | { .frequency = 96163200, .index = PLLVAL(151, 5, 3), }, /* FVco 769.305600 */ | 27 | { .frequency = 96163200, .driver_data = PLLVAL(151, 5, 3), }, /* FVco 769.305600 */ |
28 | { .frequency = 102135600, .index = PLLVAL(185, 6, 3), }, /* FVco 817.084800 */ | 28 | { .frequency = 102135600, .driver_data = PLLVAL(185, 6, 3), }, /* FVco 817.084800 */ |
29 | { .frequency = 108259200, .index = PLLVAL(171, 5, 3), }, /* FVco 866.073600 */ | 29 | { .frequency = 108259200, .driver_data = PLLVAL(171, 5, 3), }, /* FVco 866.073600 */ |
30 | { .frequency = 114307200, .index = PLLVAL(127, 3, 3), }, /* FVco 914.457600 */ | 30 | { .frequency = 114307200, .driver_data = PLLVAL(127, 3, 3), }, /* FVco 914.457600 */ |
31 | { .frequency = 120234240, .index = PLLVAL(134, 3, 3), }, /* FVco 961.873920 */ | 31 | { .frequency = 120234240, .driver_data = PLLVAL(134, 3, 3), }, /* FVco 961.873920 */ |
32 | { .frequency = 126161280, .index = PLLVAL(141, 3, 3), }, /* FVco 1009.290240 */ | 32 | { .frequency = 126161280, .driver_data = PLLVAL(141, 3, 3), }, /* FVco 1009.290240 */ |
33 | { .frequency = 132088320, .index = PLLVAL(148, 3, 3), }, /* FVco 1056.706560 */ | 33 | { .frequency = 132088320, .driver_data = PLLVAL(148, 3, 3), }, /* FVco 1056.706560 */ |
34 | { .frequency = 138015360, .index = PLLVAL(155, 3, 3), }, /* FVco 1104.122880 */ | 34 | { .frequency = 138015360, .driver_data = PLLVAL(155, 3, 3), }, /* FVco 1104.122880 */ |
35 | { .frequency = 144789120, .index = PLLVAL(163, 3, 3), }, /* FVco 1158.312960 */ | 35 | { .frequency = 144789120, .driver_data = PLLVAL(163, 3, 3), }, /* FVco 1158.312960 */ |
36 | { .frequency = 150100363, .index = PLLVAL(187, 9, 2), }, /* FVco 600.401454 */ | 36 | { .frequency = 150100363, .driver_data = PLLVAL(187, 9, 2), }, /* FVco 600.401454 */ |
37 | { .frequency = 156038400, .index = PLLVAL(121, 5, 2), }, /* FVco 624.153600 */ | 37 | { .frequency = 156038400, .driver_data = PLLVAL(121, 5, 2), }, /* FVco 624.153600 */ |
38 | { .frequency = 162086400, .index = PLLVAL(126, 5, 2), }, /* FVco 648.345600 */ | 38 | { .frequency = 162086400, .driver_data = PLLVAL(126, 5, 2), }, /* FVco 648.345600 */ |
39 | { .frequency = 168134400, .index = PLLVAL(131, 5, 2), }, /* FVco 672.537600 */ | 39 | { .frequency = 168134400, .driver_data = PLLVAL(131, 5, 2), }, /* FVco 672.537600 */ |
40 | { .frequency = 174048000, .index = PLLVAL(177, 7, 2), }, /* FVco 696.192000 */ | 40 | { .frequency = 174048000, .driver_data = PLLVAL(177, 7, 2), }, /* FVco 696.192000 */ |
41 | { .frequency = 180230400, .index = PLLVAL(141, 5, 2), }, /* FVco 720.921600 */ | 41 | { .frequency = 180230400, .driver_data = PLLVAL(141, 5, 2), }, /* FVco 720.921600 */ |
42 | { .frequency = 186278400, .index = PLLVAL(124, 4, 2), }, /* FVco 745.113600 */ | 42 | { .frequency = 186278400, .driver_data = PLLVAL(124, 4, 2), }, /* FVco 745.113600 */ |
43 | { .frequency = 192326400, .index = PLLVAL(151, 5, 2), }, /* FVco 769.305600 */ | 43 | { .frequency = 192326400, .driver_data = PLLVAL(151, 5, 2), }, /* FVco 769.305600 */ |
44 | { .frequency = 198132480, .index = PLLVAL(109, 3, 2), }, /* FVco 792.529920 */ | 44 | { .frequency = 198132480, .driver_data = PLLVAL(109, 3, 2), }, /* FVco 792.529920 */ |
45 | { .frequency = 204271200, .index = PLLVAL(185, 6, 2), }, /* FVco 817.084800 */ | 45 | { .frequency = 204271200, .driver_data = PLLVAL(185, 6, 2), }, /* FVco 817.084800 */ |
46 | { .frequency = 210268800, .index = PLLVAL(141, 4, 2), }, /* FVco 841.075200 */ | 46 | { .frequency = 210268800, .driver_data = PLLVAL(141, 4, 2), }, /* FVco 841.075200 */ |
47 | { .frequency = 216518400, .index = PLLVAL(171, 5, 2), }, /* FVco 866.073600 */ | 47 | { .frequency = 216518400, .driver_data = PLLVAL(171, 5, 2), }, /* FVco 866.073600 */ |
48 | { .frequency = 222264000, .index = PLLVAL(97, 2, 2), }, /* FVco 889.056000 */ | 48 | { .frequency = 222264000, .driver_data = PLLVAL(97, 2, 2), }, /* FVco 889.056000 */ |
49 | { .frequency = 228614400, .index = PLLVAL(127, 3, 2), }, /* FVco 914.457600 */ | 49 | { .frequency = 228614400, .driver_data = PLLVAL(127, 3, 2), }, /* FVco 914.457600 */ |
50 | { .frequency = 234259200, .index = PLLVAL(158, 4, 2), }, /* FVco 937.036800 */ | 50 | { .frequency = 234259200, .driver_data = PLLVAL(158, 4, 2), }, /* FVco 937.036800 */ |
51 | { .frequency = 240468480, .index = PLLVAL(134, 3, 2), }, /* FVco 961.873920 */ | 51 | { .frequency = 240468480, .driver_data = PLLVAL(134, 3, 2), }, /* FVco 961.873920 */ |
52 | { .frequency = 246960000, .index = PLLVAL(167, 4, 2), }, /* FVco 987.840000 */ | 52 | { .frequency = 246960000, .driver_data = PLLVAL(167, 4, 2), }, /* FVco 987.840000 */ |
53 | { .frequency = 252322560, .index = PLLVAL(141, 3, 2), }, /* FVco 1009.290240 */ | 53 | { .frequency = 252322560, .driver_data = PLLVAL(141, 3, 2), }, /* FVco 1009.290240 */ |
54 | { .frequency = 258249600, .index = PLLVAL(114, 2, 2), }, /* FVco 1032.998400 */ | 54 | { .frequency = 258249600, .driver_data = PLLVAL(114, 2, 2), }, /* FVco 1032.998400 */ |
55 | { .frequency = 264176640, .index = PLLVAL(148, 3, 2), }, /* FVco 1056.706560 */ | 55 | { .frequency = 264176640, .driver_data = PLLVAL(148, 3, 2), }, /* FVco 1056.706560 */ |
56 | { .frequency = 270950400, .index = PLLVAL(120, 2, 2), }, /* FVco 1083.801600 */ | 56 | { .frequency = 270950400, .driver_data = PLLVAL(120, 2, 2), }, /* FVco 1083.801600 */ |
57 | { .frequency = 276030720, .index = PLLVAL(155, 3, 2), }, /* FVco 1104.122880 */ | 57 | { .frequency = 276030720, .driver_data = PLLVAL(155, 3, 2), }, /* FVco 1104.122880 */ |
58 | { .frequency = 282240000, .index = PLLVAL(92, 1, 2), }, /* FVco 1128.960000 */ | 58 | { .frequency = 282240000, .driver_data = PLLVAL(92, 1, 2), }, /* FVco 1128.960000 */ |
59 | { .frequency = 289578240, .index = PLLVAL(163, 3, 2), }, /* FVco 1158.312960 */ | 59 | { .frequency = 289578240, .driver_data = PLLVAL(163, 3, 2), }, /* FVco 1158.312960 */ |
60 | { .frequency = 294235200, .index = PLLVAL(131, 2, 2), }, /* FVco 1176.940800 */ | 60 | { .frequency = 294235200, .driver_data = PLLVAL(131, 2, 2), }, /* FVco 1176.940800 */ |
61 | { .frequency = 300200727, .index = PLLVAL(187, 9, 1), }, /* FVco 600.401454 */ | 61 | { .frequency = 300200727, .driver_data = PLLVAL(187, 9, 1), }, /* FVco 600.401454 */ |
62 | { .frequency = 306358690, .index = PLLVAL(191, 9, 1), }, /* FVco 612.717380 */ | 62 | { .frequency = 306358690, .driver_data = PLLVAL(191, 9, 1), }, /* FVco 612.717380 */ |
63 | { .frequency = 312076800, .index = PLLVAL(121, 5, 1), }, /* FVco 624.153600 */ | 63 | { .frequency = 312076800, .driver_data = PLLVAL(121, 5, 1), }, /* FVco 624.153600 */ |
64 | { .frequency = 318366720, .index = PLLVAL(86, 3, 1), }, /* FVco 636.733440 */ | 64 | { .frequency = 318366720, .driver_data = PLLVAL(86, 3, 1), }, /* FVco 636.733440 */ |
65 | { .frequency = 324172800, .index = PLLVAL(126, 5, 1), }, /* FVco 648.345600 */ | 65 | { .frequency = 324172800, .driver_data = PLLVAL(126, 5, 1), }, /* FVco 648.345600 */ |
66 | { .frequency = 330220800, .index = PLLVAL(109, 4, 1), }, /* FVco 660.441600 */ | 66 | { .frequency = 330220800, .driver_data = PLLVAL(109, 4, 1), }, /* FVco 660.441600 */ |
67 | { .frequency = 336268800, .index = PLLVAL(131, 5, 1), }, /* FVco 672.537600 */ | 67 | { .frequency = 336268800, .driver_data = PLLVAL(131, 5, 1), }, /* FVco 672.537600 */ |
68 | { .frequency = 342074880, .index = PLLVAL(93, 3, 1), }, /* FVco 684.149760 */ | 68 | { .frequency = 342074880, .driver_data = PLLVAL(93, 3, 1), }, /* FVco 684.149760 */ |
69 | { .frequency = 348096000, .index = PLLVAL(177, 7, 1), }, /* FVco 696.192000 */ | 69 | { .frequency = 348096000, .driver_data = PLLVAL(177, 7, 1), }, /* FVco 696.192000 */ |
70 | { .frequency = 355622400, .index = PLLVAL(118, 4, 1), }, /* FVco 711.244800 */ | 70 | { .frequency = 355622400, .driver_data = PLLVAL(118, 4, 1), }, /* FVco 711.244800 */ |
71 | { .frequency = 360460800, .index = PLLVAL(141, 5, 1), }, /* FVco 720.921600 */ | 71 | { .frequency = 360460800, .driver_data = PLLVAL(141, 5, 1), }, /* FVco 720.921600 */ |
72 | { .frequency = 366206400, .index = PLLVAL(165, 6, 1), }, /* FVco 732.412800 */ | 72 | { .frequency = 366206400, .driver_data = PLLVAL(165, 6, 1), }, /* FVco 732.412800 */ |
73 | { .frequency = 372556800, .index = PLLVAL(124, 4, 1), }, /* FVco 745.113600 */ | 73 | { .frequency = 372556800, .driver_data = PLLVAL(124, 4, 1), }, /* FVco 745.113600 */ |
74 | { .frequency = 378201600, .index = PLLVAL(126, 4, 1), }, /* FVco 756.403200 */ | 74 | { .frequency = 378201600, .driver_data = PLLVAL(126, 4, 1), }, /* FVco 756.403200 */ |
75 | { .frequency = 384652800, .index = PLLVAL(151, 5, 1), }, /* FVco 769.305600 */ | 75 | { .frequency = 384652800, .driver_data = PLLVAL(151, 5, 1), }, /* FVco 769.305600 */ |
76 | { .frequency = 391608000, .index = PLLVAL(177, 6, 1), }, /* FVco 783.216000 */ | 76 | { .frequency = 391608000, .driver_data = PLLVAL(177, 6, 1), }, /* FVco 783.216000 */ |
77 | { .frequency = 396264960, .index = PLLVAL(109, 3, 1), }, /* FVco 792.529920 */ | 77 | { .frequency = 396264960, .driver_data = PLLVAL(109, 3, 1), }, /* FVco 792.529920 */ |
78 | { .frequency = 402192000, .index = PLLVAL(87, 2, 1), }, /* FVco 804.384000 */ | 78 | { .frequency = 402192000, .driver_data = PLLVAL(87, 2, 1), }, /* FVco 804.384000 */ |
79 | }; | 79 | }; |
80 | 80 | ||
81 | static int s3c2440_plls169344_add(struct device *dev, | 81 | static int s3c2440_plls169344_add(struct device *dev, |
diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c index 7e105932c09d..5390c6bbbc02 100644 --- a/arch/arm/mach-shmobile/clock-sh7372.c +++ b/arch/arm/mach-shmobile/clock-sh7372.c | |||
@@ -142,15 +142,15 @@ static void pllc2_table_rebuild(struct clk *clk) | |||
142 | /* Initialise PLLC2 frequency table */ | 142 | /* Initialise PLLC2 frequency table */ |
143 | for (i = 0; i < ARRAY_SIZE(pllc2_freq_table) - 2; i++) { | 143 | for (i = 0; i < ARRAY_SIZE(pllc2_freq_table) - 2; i++) { |
144 | pllc2_freq_table[i].frequency = clk->parent->rate * (i + 20) * 2; | 144 | pllc2_freq_table[i].frequency = clk->parent->rate * (i + 20) * 2; |
145 | pllc2_freq_table[i].index = i; | 145 | pllc2_freq_table[i].driver_data = i; |
146 | } | 146 | } |
147 | 147 | ||
148 | /* This is a special entry - switching PLL off makes it a repeater */ | 148 | /* This is a special entry - switching PLL off makes it a repeater */ |
149 | pllc2_freq_table[i].frequency = clk->parent->rate; | 149 | pllc2_freq_table[i].frequency = clk->parent->rate; |
150 | pllc2_freq_table[i].index = i; | 150 | pllc2_freq_table[i].driver_data = i; |
151 | 151 | ||
152 | pllc2_freq_table[++i].frequency = CPUFREQ_TABLE_END; | 152 | pllc2_freq_table[++i].frequency = CPUFREQ_TABLE_END; |
153 | pllc2_freq_table[i].index = i; | 153 | pllc2_freq_table[i].driver_data = i; |
154 | } | 154 | } |
155 | 155 | ||
156 | static unsigned long pllc2_recalc(struct clk *clk) | 156 | static unsigned long pllc2_recalc(struct clk *clk) |
diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig index 65c5ae6fa386..ef3a8da49b2d 100644 --- a/arch/arm/mach-tegra/Kconfig +++ b/arch/arm/mach-tegra/Kconfig | |||
@@ -28,7 +28,6 @@ config ARCH_TEGRA_2x_SOC | |||
28 | select ARM_ERRATA_754327 if SMP | 28 | select ARM_ERRATA_754327 if SMP |
29 | select ARM_ERRATA_764369 if SMP | 29 | select ARM_ERRATA_764369 if SMP |
30 | select ARM_GIC | 30 | select ARM_GIC |
31 | select CPU_FREQ_TABLE if CPU_FREQ | ||
32 | select CPU_V7 | 31 | select CPU_V7 |
33 | select PINCTRL | 32 | select PINCTRL |
34 | select PINCTRL_TEGRA20 | 33 | select PINCTRL_TEGRA20 |
@@ -46,7 +45,6 @@ config ARCH_TEGRA_3x_SOC | |||
46 | select ARM_ERRATA_754322 | 45 | select ARM_ERRATA_754322 |
47 | select ARM_ERRATA_764369 if SMP | 46 | select ARM_ERRATA_764369 if SMP |
48 | select ARM_GIC | 47 | select ARM_GIC |
49 | select CPU_FREQ_TABLE if CPU_FREQ | ||
50 | select CPU_V7 | 48 | select CPU_V7 |
51 | select PINCTRL | 49 | select PINCTRL |
52 | select PINCTRL_TEGRA30 | 50 | select PINCTRL_TEGRA30 |
@@ -63,7 +61,6 @@ config ARCH_TEGRA_114_SOC | |||
63 | select HAVE_ARM_ARCH_TIMER | 61 | select HAVE_ARM_ARCH_TIMER |
64 | select ARM_GIC | 62 | select ARM_GIC |
65 | select ARM_L1_CACHE_SHIFT_6 | 63 | select ARM_L1_CACHE_SHIFT_6 |
66 | select CPU_FREQ_TABLE if CPU_FREQ | ||
67 | select CPU_V7 | 64 | select CPU_V7 |
68 | select PINCTRL | 65 | select PINCTRL |
69 | select PINCTRL_TEGRA114 | 66 | select PINCTRL_TEGRA114 |
diff --git a/arch/arm/plat-samsung/include/plat/cpu-freq-core.h b/arch/arm/plat-samsung/include/plat/cpu-freq-core.h index d7e17150028a..7231c8e4975e 100644 --- a/arch/arm/plat-samsung/include/plat/cpu-freq-core.h +++ b/arch/arm/plat-samsung/include/plat/cpu-freq-core.h | |||
@@ -285,7 +285,7 @@ static inline int s3c_cpufreq_addfreq(struct cpufreq_frequency_table *table, | |||
285 | s3c_freq_dbg("%s: { %d = %u kHz }\n", | 285 | s3c_freq_dbg("%s: { %d = %u kHz }\n", |
286 | __func__, index, freq); | 286 | __func__, index, freq); |
287 | 287 | ||
288 | table[index].index = index; | 288 | table[index].driver_data = index; |
289 | table[index].frequency = freq; | 289 | table[index].frequency = freq; |
290 | } | 290 | } |
291 | 291 | ||
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig index 9f3c54360e78..3201ddb8da6a 100644 --- a/arch/cris/Kconfig +++ b/arch/cris/Kconfig | |||
@@ -134,11 +134,13 @@ config SVINTO_SIM | |||
134 | 134 | ||
135 | config ETRAXFS | 135 | config ETRAXFS |
136 | bool "ETRAX-FS-V32" | 136 | bool "ETRAX-FS-V32" |
137 | select CPU_FREQ_TABLE if CPU_FREQ | ||
137 | help | 138 | help |
138 | Support CRIS V32. | 139 | Support CRIS V32. |
139 | 140 | ||
140 | config CRIS_MACH_ARTPEC3 | 141 | config CRIS_MACH_ARTPEC3 |
141 | bool "ARTPEC-3" | 142 | bool "ARTPEC-3" |
143 | select CPU_FREQ_TABLE if CPU_FREQ | ||
142 | help | 144 | help |
143 | Support Axis ARTPEC-3. | 145 | Support Axis ARTPEC-3. |
144 | 146 | ||
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c index bcda5b2d121a..d43daf192b21 100644 --- a/arch/ia64/hp/common/sba_iommu.c +++ b/arch/ia64/hp/common/sba_iommu.c | |||
@@ -2042,7 +2042,8 @@ sba_map_ioc_to_node(struct ioc *ioc, acpi_handle handle) | |||
2042 | #endif | 2042 | #endif |
2043 | 2043 | ||
2044 | static int __init | 2044 | static int __init |
2045 | acpi_sba_ioc_add(struct acpi_device *device) | 2045 | acpi_sba_ioc_add(struct acpi_device *device, |
2046 | const struct acpi_device_id *not_used) | ||
2046 | { | 2047 | { |
2047 | struct ioc *ioc; | 2048 | struct ioc *ioc; |
2048 | acpi_status status; | 2049 | acpi_status status; |
@@ -2090,14 +2091,18 @@ static const struct acpi_device_id hp_ioc_iommu_device_ids[] = { | |||
2090 | {"HWP0004", 0}, | 2091 | {"HWP0004", 0}, |
2091 | {"", 0}, | 2092 | {"", 0}, |
2092 | }; | 2093 | }; |
2093 | static struct acpi_driver acpi_sba_ioc_driver = { | 2094 | static struct acpi_scan_handler acpi_sba_ioc_handler = { |
2094 | .name = "IOC IOMMU Driver", | 2095 | .ids = hp_ioc_iommu_device_ids, |
2095 | .ids = hp_ioc_iommu_device_ids, | 2096 | .attach = acpi_sba_ioc_add, |
2096 | .ops = { | ||
2097 | .add = acpi_sba_ioc_add, | ||
2098 | }, | ||
2099 | }; | 2097 | }; |
2100 | 2098 | ||
2099 | static int __init acpi_sba_ioc_init_acpi(void) | ||
2100 | { | ||
2101 | return acpi_scan_add_handler(&acpi_sba_ioc_handler); | ||
2102 | } | ||
2103 | /* This has to run before acpi_scan_init(). */ | ||
2104 | arch_initcall(acpi_sba_ioc_init_acpi); | ||
2105 | |||
2101 | extern struct dma_map_ops swiotlb_dma_ops; | 2106 | extern struct dma_map_ops swiotlb_dma_ops; |
2102 | 2107 | ||
2103 | static int __init | 2108 | static int __init |
@@ -2122,7 +2127,10 @@ sba_init(void) | |||
2122 | } | 2127 | } |
2123 | #endif | 2128 | #endif |
2124 | 2129 | ||
2125 | acpi_bus_register_driver(&acpi_sba_ioc_driver); | 2130 | /* |
2131 | * ioc_list should be populated by the acpi_sba_ioc_handler's .attach() | ||
2132 | * routine, but that only happens if acpi_scan_init() has already run. | ||
2133 | */ | ||
2126 | if (!ioc_list) { | 2134 | if (!ioc_list) { |
2127 | #ifdef CONFIG_IA64_GENERIC | 2135 | #ifdef CONFIG_IA64_GENERIC |
2128 | /* | 2136 | /* |
diff --git a/arch/mips/loongson/lemote-2f/clock.c b/arch/mips/loongson/lemote-2f/clock.c index bc739d4bab2e..4dc2f5fa3f67 100644 --- a/arch/mips/loongson/lemote-2f/clock.c +++ b/arch/mips/loongson/lemote-2f/clock.c | |||
@@ -121,7 +121,8 @@ int clk_set_rate(struct clk *clk, unsigned long rate) | |||
121 | clk->rate = rate; | 121 | clk->rate = rate; |
122 | 122 | ||
123 | regval = LOONGSON_CHIPCFG0; | 123 | regval = LOONGSON_CHIPCFG0; |
124 | regval = (regval & ~0x7) | (loongson2_clockmod_table[i].index - 1); | 124 | regval = (regval & ~0x7) | |
125 | (loongson2_clockmod_table[i].driver_data - 1); | ||
125 | LOONGSON_CHIPCFG0 = regval; | 126 | LOONGSON_CHIPCFG0 = regval; |
126 | 127 | ||
127 | return ret; | 128 | return ret; |
diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig index b62aab3e22ec..e17cdfc5ba40 100644 --- a/arch/powerpc/platforms/Kconfig +++ b/arch/powerpc/platforms/Kconfig | |||
@@ -193,37 +193,6 @@ config PPC_IO_WORKAROUNDS | |||
193 | 193 | ||
194 | source "drivers/cpufreq/Kconfig" | 194 | source "drivers/cpufreq/Kconfig" |
195 | 195 | ||
196 | menu "CPU Frequency drivers" | ||
197 | depends on CPU_FREQ | ||
198 | |||
199 | config CPU_FREQ_PMAC | ||
200 | bool "Support for Apple PowerBooks" | ||
201 | depends on ADB_PMU && PPC32 | ||
202 | select CPU_FREQ_TABLE | ||
203 | help | ||
204 | This adds support for frequency switching on Apple PowerBooks, | ||
205 | this currently includes some models of iBook & Titanium | ||
206 | PowerBook. | ||
207 | |||
208 | config CPU_FREQ_PMAC64 | ||
209 | bool "Support for some Apple G5s" | ||
210 | depends on PPC_PMAC && PPC64 | ||
211 | select CPU_FREQ_TABLE | ||
212 | help | ||
213 | This adds support for frequency switching on Apple iMac G5, | ||
214 | and some of the more recent desktop G5 machines as well. | ||
215 | |||
216 | config PPC_PASEMI_CPUFREQ | ||
217 | bool "Support for PA Semi PWRficient" | ||
218 | depends on PPC_PASEMI | ||
219 | default y | ||
220 | select CPU_FREQ_TABLE | ||
221 | help | ||
222 | This adds the support for frequency switching on PA Semi | ||
223 | PWRficient processors. | ||
224 | |||
225 | endmenu | ||
226 | |||
227 | menu "CPUIdle driver" | 196 | menu "CPUIdle driver" |
228 | 197 | ||
229 | source "drivers/cpuidle/Kconfig" | 198 | source "drivers/cpuidle/Kconfig" |
diff --git a/arch/powerpc/platforms/pasemi/Makefile b/arch/powerpc/platforms/pasemi/Makefile index ce6d789e0741..8e8d4cae5ebe 100644 --- a/arch/powerpc/platforms/pasemi/Makefile +++ b/arch/powerpc/platforms/pasemi/Makefile | |||
@@ -1,3 +1,2 @@ | |||
1 | obj-y += setup.o pci.o time.o idle.o powersave.o iommu.o dma_lib.o misc.o | 1 | obj-y += setup.o pci.o time.o idle.o powersave.o iommu.o dma_lib.o misc.o |
2 | obj-$(CONFIG_PPC_PASEMI_MDIO) += gpio_mdio.o | 2 | obj-$(CONFIG_PPC_PASEMI_MDIO) += gpio_mdio.o |
3 | obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += cpufreq.o | ||
diff --git a/arch/powerpc/platforms/powermac/Makefile b/arch/powerpc/platforms/powermac/Makefile index ea47df66fee5..52c6ce1cc985 100644 --- a/arch/powerpc/platforms/powermac/Makefile +++ b/arch/powerpc/platforms/powermac/Makefile | |||
@@ -9,8 +9,6 @@ obj-y += pic.o setup.o time.o feature.o pci.o \ | |||
9 | sleep.o low_i2c.o cache.o pfunc_core.o \ | 9 | sleep.o low_i2c.o cache.o pfunc_core.o \ |
10 | pfunc_base.o udbg_scc.o udbg_adb.o | 10 | pfunc_base.o udbg_scc.o udbg_adb.o |
11 | obj-$(CONFIG_PMAC_BACKLIGHT) += backlight.o | 11 | obj-$(CONFIG_PMAC_BACKLIGHT) += backlight.o |
12 | obj-$(CONFIG_CPU_FREQ_PMAC) += cpufreq_32.o | ||
13 | obj-$(CONFIG_CPU_FREQ_PMAC64) += cpufreq_64.o | ||
14 | # CONFIG_NVRAM is an arch. independent tristate symbol, for pmac32 we really | 12 | # CONFIG_NVRAM is an arch. independent tristate symbol, for pmac32 we really |
15 | # need this to be a bool. Cheat here and pretend CONFIG_NVRAM=m is really | 13 | # need this to be a bool. Cheat here and pretend CONFIG_NVRAM=m is really |
16 | # CONFIG_NVRAM=y | 14 | # CONFIG_NVRAM=y |
diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h index b31bf97775fc..2dfac58f3b11 100644 --- a/arch/x86/include/asm/acpi.h +++ b/arch/x86/include/asm/acpi.h | |||
@@ -111,7 +111,7 @@ static inline void acpi_disable_pci(void) | |||
111 | } | 111 | } |
112 | 112 | ||
113 | /* Low-level suspend routine. */ | 113 | /* Low-level suspend routine. */ |
114 | extern int acpi_suspend_lowlevel(void); | 114 | extern int (*acpi_suspend_lowlevel)(void); |
115 | 115 | ||
116 | /* Physical address to resume after wakeup */ | 116 | /* Physical address to resume after wakeup */ |
117 | #define acpi_wakeup_address ((unsigned long)(real_mode_header->wakeup_start)) | 117 | #define acpi_wakeup_address ((unsigned long)(real_mode_header->wakeup_start)) |
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index 230c8ea878e5..d81a972dd506 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <asm/mpspec.h> | 44 | #include <asm/mpspec.h> |
45 | #include <asm/smp.h> | 45 | #include <asm/smp.h> |
46 | 46 | ||
47 | #include "sleep.h" /* To include x86_acpi_suspend_lowlevel */ | ||
47 | static int __initdata acpi_force = 0; | 48 | static int __initdata acpi_force = 0; |
48 | u32 acpi_rsdt_forced; | 49 | u32 acpi_rsdt_forced; |
49 | int acpi_disabled; | 50 | int acpi_disabled; |
@@ -559,6 +560,12 @@ static int acpi_register_gsi_ioapic(struct device *dev, u32 gsi, | |||
559 | int (*__acpi_register_gsi)(struct device *dev, u32 gsi, | 560 | int (*__acpi_register_gsi)(struct device *dev, u32 gsi, |
560 | int trigger, int polarity) = acpi_register_gsi_pic; | 561 | int trigger, int polarity) = acpi_register_gsi_pic; |
561 | 562 | ||
563 | #ifdef CONFIG_ACPI_SLEEP | ||
564 | int (*acpi_suspend_lowlevel)(void) = x86_acpi_suspend_lowlevel; | ||
565 | #else | ||
566 | int (*acpi_suspend_lowlevel)(void); | ||
567 | #endif | ||
568 | |||
562 | /* | 569 | /* |
563 | * success: return IRQ number (>=0) | 570 | * success: return IRQ number (>=0) |
564 | * failure: return < 0 | 571 | * failure: return < 0 |
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c index b44577bc9744..2a34aaf3c8f1 100644 --- a/arch/x86/kernel/acpi/sleep.c +++ b/arch/x86/kernel/acpi/sleep.c | |||
@@ -26,12 +26,12 @@ static char temp_stack[4096]; | |||
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * acpi_suspend_lowlevel - save kernel state | 29 | * x86_acpi_suspend_lowlevel - save kernel state |
30 | * | 30 | * |
31 | * Create an identity mapped page table and copy the wakeup routine to | 31 | * Create an identity mapped page table and copy the wakeup routine to |
32 | * low memory. | 32 | * low memory. |
33 | */ | 33 | */ |
34 | int acpi_suspend_lowlevel(void) | 34 | int x86_acpi_suspend_lowlevel(void) |
35 | { | 35 | { |
36 | struct wakeup_header *header = | 36 | struct wakeup_header *header = |
37 | (struct wakeup_header *) __va(real_mode_header->wakeup_header); | 37 | (struct wakeup_header *) __va(real_mode_header->wakeup_header); |
diff --git a/arch/x86/kernel/acpi/sleep.h b/arch/x86/kernel/acpi/sleep.h index 67f59f8c6956..c9c2c982d5e4 100644 --- a/arch/x86/kernel/acpi/sleep.h +++ b/arch/x86/kernel/acpi/sleep.h | |||
@@ -15,3 +15,5 @@ extern unsigned long acpi_copy_wakeup_routine(unsigned long); | |||
15 | extern void wakeup_long64(void); | 15 | extern void wakeup_long64(void); |
16 | 16 | ||
17 | extern void do_suspend_lowlevel(void); | 17 | extern void do_suspend_lowlevel(void); |
18 | |||
19 | extern int x86_acpi_suspend_lowlevel(void); | ||
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 536562c626a2..81dbeb83bb45 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
@@ -34,6 +34,7 @@ acpi-$(CONFIG_ACPI_SLEEP) += proc.o | |||
34 | acpi-y += bus.o glue.o | 34 | acpi-y += bus.o glue.o |
35 | acpi-y += scan.o | 35 | acpi-y += scan.o |
36 | acpi-y += resource.o | 36 | acpi-y += resource.o |
37 | acpi-y += acpi_processor.o | ||
37 | acpi-y += processor_core.o | 38 | acpi-y += processor_core.o |
38 | acpi-y += ec.o | 39 | acpi-y += ec.o |
39 | acpi-$(CONFIG_ACPI_DOCK) += dock.o | 40 | acpi-$(CONFIG_ACPI_DOCK) += dock.o |
@@ -43,6 +44,7 @@ acpi-y += acpi_platform.o | |||
43 | acpi-y += power.o | 44 | acpi-y += power.o |
44 | acpi-y += event.o | 45 | acpi-y += event.o |
45 | acpi-y += sysfs.o | 46 | acpi-y += sysfs.o |
47 | acpi-$(CONFIG_X86) += acpi_cmos_rtc.o | ||
46 | acpi-$(CONFIG_DEBUG_FS) += debugfs.o | 48 | acpi-$(CONFIG_DEBUG_FS) += debugfs.o |
47 | acpi-$(CONFIG_ACPI_NUMA) += numa.o | 49 | acpi-$(CONFIG_ACPI_NUMA) += numa.o |
48 | acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o | 50 | acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o |
diff --git a/drivers/acpi/acpi_cmos_rtc.c b/drivers/acpi/acpi_cmos_rtc.c new file mode 100644 index 000000000000..84190ed89c04 --- /dev/null +++ b/drivers/acpi/acpi_cmos_rtc.c | |||
@@ -0,0 +1,92 @@ | |||
1 | /* | ||
2 | * ACPI support for CMOS RTC Address Space access | ||
3 | * | ||
4 | * Copyright (C) 2013, Intel Corporation | ||
5 | * Authors: Lan Tianyu <tianyu.lan@intel.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/acpi.h> | ||
13 | #include <linux/device.h> | ||
14 | #include <linux/err.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <asm-generic/rtc.h> | ||
18 | |||
19 | #include "internal.h" | ||
20 | |||
21 | #define PREFIX "ACPI: " | ||
22 | |||
23 | ACPI_MODULE_NAME("cmos rtc"); | ||
24 | |||
25 | static const struct acpi_device_id acpi_cmos_rtc_ids[] = { | ||
26 | { "PNP0B00" }, | ||
27 | { "PNP0B01" }, | ||
28 | { "PNP0B02" }, | ||
29 | {} | ||
30 | }; | ||
31 | |||
32 | static acpi_status | ||
33 | acpi_cmos_rtc_space_handler(u32 function, acpi_physical_address address, | ||
34 | u32 bits, u64 *value64, | ||
35 | void *handler_context, void *region_context) | ||
36 | { | ||
37 | int i; | ||
38 | u8 *value = (u8 *)&value64; | ||
39 | |||
40 | if (address > 0xff || !value64) | ||
41 | return AE_BAD_PARAMETER; | ||
42 | |||
43 | if (function != ACPI_WRITE && function != ACPI_READ) | ||
44 | return AE_BAD_PARAMETER; | ||
45 | |||
46 | spin_lock_irq(&rtc_lock); | ||
47 | |||
48 | for (i = 0; i < DIV_ROUND_UP(bits, 8); ++i, ++address, ++value) | ||
49 | if (function == ACPI_READ) | ||
50 | *value = CMOS_READ(address); | ||
51 | else | ||
52 | CMOS_WRITE(*value, address); | ||
53 | |||
54 | spin_unlock_irq(&rtc_lock); | ||
55 | |||
56 | return AE_OK; | ||
57 | } | ||
58 | |||
59 | static int acpi_install_cmos_rtc_space_handler(struct acpi_device *adev, | ||
60 | const struct acpi_device_id *id) | ||
61 | { | ||
62 | acpi_status status; | ||
63 | |||
64 | status = acpi_install_address_space_handler(adev->handle, | ||
65 | ACPI_ADR_SPACE_CMOS, | ||
66 | &acpi_cmos_rtc_space_handler, | ||
67 | NULL, NULL); | ||
68 | if (ACPI_FAILURE(status)) { | ||
69 | pr_err(PREFIX "Error installing CMOS-RTC region handler\n"); | ||
70 | return -ENODEV; | ||
71 | } | ||
72 | |||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | static void acpi_remove_cmos_rtc_space_handler(struct acpi_device *adev) | ||
77 | { | ||
78 | if (ACPI_FAILURE(acpi_remove_address_space_handler(adev->handle, | ||
79 | ACPI_ADR_SPACE_CMOS, &acpi_cmos_rtc_space_handler))) | ||
80 | pr_err(PREFIX "Error removing CMOS-RTC region handler\n"); | ||
81 | } | ||
82 | |||
83 | static struct acpi_scan_handler cmos_rtc_handler = { | ||
84 | .ids = acpi_cmos_rtc_ids, | ||
85 | .attach = acpi_install_cmos_rtc_space_handler, | ||
86 | .detach = acpi_remove_cmos_rtc_space_handler, | ||
87 | }; | ||
88 | |||
89 | void __init acpi_cmos_rtc_init(void) | ||
90 | { | ||
91 | acpi_scan_add_handler(&cmos_rtc_handler); | ||
92 | } | ||
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index cab13f2fc28e..6a382188fa20 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c | |||
@@ -32,12 +32,26 @@ ACPI_MODULE_NAME("acpi_lpss"); | |||
32 | #define LPSS_GENERAL_LTR_MODE_SW BIT(2) | 32 | #define LPSS_GENERAL_LTR_MODE_SW BIT(2) |
33 | #define LPSS_SW_LTR 0x10 | 33 | #define LPSS_SW_LTR 0x10 |
34 | #define LPSS_AUTO_LTR 0x14 | 34 | #define LPSS_AUTO_LTR 0x14 |
35 | #define LPSS_TX_INT 0x20 | ||
36 | #define LPSS_TX_INT_MASK BIT(1) | ||
37 | |||
38 | struct lpss_shared_clock { | ||
39 | const char *name; | ||
40 | unsigned long rate; | ||
41 | struct clk *clk; | ||
42 | }; | ||
43 | |||
44 | struct lpss_private_data; | ||
35 | 45 | ||
36 | struct lpss_device_desc { | 46 | struct lpss_device_desc { |
37 | bool clk_required; | 47 | bool clk_required; |
38 | const char *clkdev_name; | 48 | const char *clkdev_name; |
39 | bool ltr_required; | 49 | bool ltr_required; |
40 | unsigned int prv_offset; | 50 | unsigned int prv_offset; |
51 | size_t prv_size_override; | ||
52 | bool clk_gate; | ||
53 | struct lpss_shared_clock *shared_clock; | ||
54 | void (*setup)(struct lpss_private_data *pdata); | ||
41 | }; | 55 | }; |
42 | 56 | ||
43 | static struct lpss_device_desc lpss_dma_desc = { | 57 | static struct lpss_device_desc lpss_dma_desc = { |
@@ -52,17 +66,76 @@ struct lpss_private_data { | |||
52 | const struct lpss_device_desc *dev_desc; | 66 | const struct lpss_device_desc *dev_desc; |
53 | }; | 67 | }; |
54 | 68 | ||
69 | static void lpss_uart_setup(struct lpss_private_data *pdata) | ||
70 | { | ||
71 | unsigned int tx_int_offset = pdata->dev_desc->prv_offset + LPSS_TX_INT; | ||
72 | u32 reg; | ||
73 | |||
74 | reg = readl(pdata->mmio_base + tx_int_offset); | ||
75 | writel(reg | LPSS_TX_INT_MASK, pdata->mmio_base + tx_int_offset); | ||
76 | } | ||
77 | |||
55 | static struct lpss_device_desc lpt_dev_desc = { | 78 | static struct lpss_device_desc lpt_dev_desc = { |
56 | .clk_required = true, | 79 | .clk_required = true, |
57 | .prv_offset = 0x800, | 80 | .prv_offset = 0x800, |
58 | .ltr_required = true, | 81 | .ltr_required = true, |
82 | .clk_gate = true, | ||
83 | }; | ||
84 | |||
85 | static struct lpss_device_desc lpt_uart_dev_desc = { | ||
86 | .clk_required = true, | ||
87 | .prv_offset = 0x800, | ||
88 | .ltr_required = true, | ||
89 | .clk_gate = true, | ||
90 | .setup = lpss_uart_setup, | ||
59 | }; | 91 | }; |
60 | 92 | ||
61 | static struct lpss_device_desc lpt_sdio_dev_desc = { | 93 | static struct lpss_device_desc lpt_sdio_dev_desc = { |
62 | .prv_offset = 0x1000, | 94 | .prv_offset = 0x1000, |
95 | .prv_size_override = 0x1018, | ||
63 | .ltr_required = true, | 96 | .ltr_required = true, |
64 | }; | 97 | }; |
65 | 98 | ||
99 | static struct lpss_shared_clock uart_clock = { | ||
100 | .name = "uart_clk", | ||
101 | .rate = 44236800, | ||
102 | }; | ||
103 | |||
104 | static struct lpss_device_desc byt_uart_dev_desc = { | ||
105 | .clk_required = true, | ||
106 | .prv_offset = 0x800, | ||
107 | .clk_gate = true, | ||
108 | .shared_clock = &uart_clock, | ||
109 | .setup = lpss_uart_setup, | ||
110 | }; | ||
111 | |||
112 | static struct lpss_shared_clock spi_clock = { | ||
113 | .name = "spi_clk", | ||
114 | .rate = 50000000, | ||
115 | }; | ||
116 | |||
117 | static struct lpss_device_desc byt_spi_dev_desc = { | ||
118 | .clk_required = true, | ||
119 | .prv_offset = 0x400, | ||
120 | .clk_gate = true, | ||
121 | .shared_clock = &spi_clock, | ||
122 | }; | ||
123 | |||
124 | static struct lpss_device_desc byt_sdio_dev_desc = { | ||
125 | .clk_required = true, | ||
126 | }; | ||
127 | |||
128 | static struct lpss_shared_clock i2c_clock = { | ||
129 | .name = "i2c_clk", | ||
130 | .rate = 100000000, | ||
131 | }; | ||
132 | |||
133 | static struct lpss_device_desc byt_i2c_dev_desc = { | ||
134 | .clk_required = true, | ||
135 | .prv_offset = 0x800, | ||
136 | .shared_clock = &i2c_clock, | ||
137 | }; | ||
138 | |||
66 | static const struct acpi_device_id acpi_lpss_device_ids[] = { | 139 | static const struct acpi_device_id acpi_lpss_device_ids[] = { |
67 | /* Generic LPSS devices */ | 140 | /* Generic LPSS devices */ |
68 | { "INTL9C60", (unsigned long)&lpss_dma_desc }, | 141 | { "INTL9C60", (unsigned long)&lpss_dma_desc }, |
@@ -72,11 +145,18 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = { | |||
72 | { "INT33C1", (unsigned long)&lpt_dev_desc }, | 145 | { "INT33C1", (unsigned long)&lpt_dev_desc }, |
73 | { "INT33C2", (unsigned long)&lpt_dev_desc }, | 146 | { "INT33C2", (unsigned long)&lpt_dev_desc }, |
74 | { "INT33C3", (unsigned long)&lpt_dev_desc }, | 147 | { "INT33C3", (unsigned long)&lpt_dev_desc }, |
75 | { "INT33C4", (unsigned long)&lpt_dev_desc }, | 148 | { "INT33C4", (unsigned long)&lpt_uart_dev_desc }, |
76 | { "INT33C5", (unsigned long)&lpt_dev_desc }, | 149 | { "INT33C5", (unsigned long)&lpt_uart_dev_desc }, |
77 | { "INT33C6", (unsigned long)&lpt_sdio_dev_desc }, | 150 | { "INT33C6", (unsigned long)&lpt_sdio_dev_desc }, |
78 | { "INT33C7", }, | 151 | { "INT33C7", }, |
79 | 152 | ||
153 | /* BayTrail LPSS devices */ | ||
154 | { "80860F0A", (unsigned long)&byt_uart_dev_desc }, | ||
155 | { "80860F0E", (unsigned long)&byt_spi_dev_desc }, | ||
156 | { "80860F14", (unsigned long)&byt_sdio_dev_desc }, | ||
157 | { "80860F41", (unsigned long)&byt_i2c_dev_desc }, | ||
158 | { "INT33B2", }, | ||
159 | |||
80 | { } | 160 | { } |
81 | }; | 161 | }; |
82 | 162 | ||
@@ -98,7 +178,10 @@ static int register_device_clock(struct acpi_device *adev, | |||
98 | struct lpss_private_data *pdata) | 178 | struct lpss_private_data *pdata) |
99 | { | 179 | { |
100 | const struct lpss_device_desc *dev_desc = pdata->dev_desc; | 180 | const struct lpss_device_desc *dev_desc = pdata->dev_desc; |
181 | struct lpss_shared_clock *shared_clock = dev_desc->shared_clock; | ||
182 | struct clk *clk = ERR_PTR(-ENODEV); | ||
101 | struct lpss_clk_data *clk_data; | 183 | struct lpss_clk_data *clk_data; |
184 | const char *parent; | ||
102 | 185 | ||
103 | if (!lpss_clk_dev) | 186 | if (!lpss_clk_dev) |
104 | lpt_register_clock_device(); | 187 | lpt_register_clock_device(); |
@@ -117,14 +200,30 @@ static int register_device_clock(struct acpi_device *adev, | |||
117 | || pdata->mmio_size < dev_desc->prv_offset + LPSS_CLK_SIZE) | 200 | || pdata->mmio_size < dev_desc->prv_offset + LPSS_CLK_SIZE) |
118 | return -ENODATA; | 201 | return -ENODATA; |
119 | 202 | ||
120 | pdata->clk = clk_register_gate(NULL, dev_name(&adev->dev), | 203 | parent = clk_data->name; |
121 | clk_data->name, 0, | 204 | |
122 | pdata->mmio_base + dev_desc->prv_offset, | 205 | if (shared_clock) { |
123 | 0, 0, NULL); | 206 | clk = shared_clock->clk; |
124 | if (IS_ERR(pdata->clk)) | 207 | if (!clk) { |
125 | return PTR_ERR(pdata->clk); | 208 | clk = clk_register_fixed_rate(NULL, shared_clock->name, |
209 | "lpss_clk", 0, | ||
210 | shared_clock->rate); | ||
211 | shared_clock->clk = clk; | ||
212 | } | ||
213 | parent = shared_clock->name; | ||
214 | } | ||
215 | |||
216 | if (dev_desc->clk_gate) { | ||
217 | clk = clk_register_gate(NULL, dev_name(&adev->dev), parent, 0, | ||
218 | pdata->mmio_base + dev_desc->prv_offset, | ||
219 | 0, 0, NULL); | ||
220 | pdata->clk = clk; | ||
221 | } | ||
126 | 222 | ||
127 | clk_register_clkdev(pdata->clk, NULL, dev_name(&adev->dev)); | 223 | if (IS_ERR(clk)) |
224 | return PTR_ERR(clk); | ||
225 | |||
226 | clk_register_clkdev(clk, NULL, dev_name(&adev->dev)); | ||
128 | return 0; | 227 | return 0; |
129 | } | 228 | } |
130 | 229 | ||
@@ -152,7 +251,10 @@ static int acpi_lpss_create_device(struct acpi_device *adev, | |||
152 | 251 | ||
153 | list_for_each_entry(rentry, &resource_list, node) | 252 | list_for_each_entry(rentry, &resource_list, node) |
154 | if (resource_type(&rentry->res) == IORESOURCE_MEM) { | 253 | if (resource_type(&rentry->res) == IORESOURCE_MEM) { |
155 | pdata->mmio_size = resource_size(&rentry->res); | 254 | if (dev_desc->prv_size_override) |
255 | pdata->mmio_size = dev_desc->prv_size_override; | ||
256 | else | ||
257 | pdata->mmio_size = resource_size(&rentry->res); | ||
156 | pdata->mmio_base = ioremap(rentry->res.start, | 258 | pdata->mmio_base = ioremap(rentry->res.start, |
157 | pdata->mmio_size); | 259 | pdata->mmio_size); |
158 | pdata->dev_desc = dev_desc; | 260 | pdata->dev_desc = dev_desc; |
@@ -182,6 +284,9 @@ static int acpi_lpss_create_device(struct acpi_device *adev, | |||
182 | goto err_out; | 284 | goto err_out; |
183 | } | 285 | } |
184 | 286 | ||
287 | if (dev_desc->setup) | ||
288 | dev_desc->setup(pdata); | ||
289 | |||
185 | adev->driver_data = pdata; | 290 | adev->driver_data = pdata; |
186 | ret = acpi_create_platform_device(adev, id); | 291 | ret = acpi_create_platform_device(adev, id); |
187 | if (ret > 0) | 292 | if (ret > 0) |
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index 5e6301e94920..c711d1144044 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c | |||
@@ -28,6 +28,7 @@ | |||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <linux/acpi.h> | 30 | #include <linux/acpi.h> |
31 | #include <linux/memory.h> | ||
31 | #include <linux/memory_hotplug.h> | 32 | #include <linux/memory_hotplug.h> |
32 | 33 | ||
33 | #include "internal.h" | 34 | #include "internal.h" |
@@ -166,13 +167,50 @@ static int acpi_memory_check_device(struct acpi_memory_device *mem_device) | |||
166 | return 0; | 167 | return 0; |
167 | } | 168 | } |
168 | 169 | ||
170 | static unsigned long acpi_meminfo_start_pfn(struct acpi_memory_info *info) | ||
171 | { | ||
172 | return PFN_DOWN(info->start_addr); | ||
173 | } | ||
174 | |||
175 | static unsigned long acpi_meminfo_end_pfn(struct acpi_memory_info *info) | ||
176 | { | ||
177 | return PFN_UP(info->start_addr + info->length-1); | ||
178 | } | ||
179 | |||
180 | static int acpi_bind_memblk(struct memory_block *mem, void *arg) | ||
181 | { | ||
182 | return acpi_bind_one(&mem->dev, (acpi_handle)arg); | ||
183 | } | ||
184 | |||
185 | static int acpi_bind_memory_blocks(struct acpi_memory_info *info, | ||
186 | acpi_handle handle) | ||
187 | { | ||
188 | return walk_memory_range(acpi_meminfo_start_pfn(info), | ||
189 | acpi_meminfo_end_pfn(info), (void *)handle, | ||
190 | acpi_bind_memblk); | ||
191 | } | ||
192 | |||
193 | static int acpi_unbind_memblk(struct memory_block *mem, void *arg) | ||
194 | { | ||
195 | acpi_unbind_one(&mem->dev); | ||
196 | return 0; | ||
197 | } | ||
198 | |||
199 | static void acpi_unbind_memory_blocks(struct acpi_memory_info *info, | ||
200 | acpi_handle handle) | ||
201 | { | ||
202 | walk_memory_range(acpi_meminfo_start_pfn(info), | ||
203 | acpi_meminfo_end_pfn(info), NULL, acpi_unbind_memblk); | ||
204 | } | ||
205 | |||
169 | static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) | 206 | static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) |
170 | { | 207 | { |
208 | acpi_handle handle = mem_device->device->handle; | ||
171 | int result, num_enabled = 0; | 209 | int result, num_enabled = 0; |
172 | struct acpi_memory_info *info; | 210 | struct acpi_memory_info *info; |
173 | int node; | 211 | int node; |
174 | 212 | ||
175 | node = acpi_get_node(mem_device->device->handle); | 213 | node = acpi_get_node(handle); |
176 | /* | 214 | /* |
177 | * Tell the VM there is more memory here... | 215 | * Tell the VM there is more memory here... |
178 | * Note: Assume that this function returns zero on success | 216 | * Note: Assume that this function returns zero on success |
@@ -203,6 +241,12 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) | |||
203 | if (result && result != -EEXIST) | 241 | if (result && result != -EEXIST) |
204 | continue; | 242 | continue; |
205 | 243 | ||
244 | result = acpi_bind_memory_blocks(info, handle); | ||
245 | if (result) { | ||
246 | acpi_unbind_memory_blocks(info, handle); | ||
247 | return -ENODEV; | ||
248 | } | ||
249 | |||
206 | info->enabled = 1; | 250 | info->enabled = 1; |
207 | 251 | ||
208 | /* | 252 | /* |
@@ -227,12 +271,11 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) | |||
227 | return 0; | 271 | return 0; |
228 | } | 272 | } |
229 | 273 | ||
230 | static int acpi_memory_remove_memory(struct acpi_memory_device *mem_device) | 274 | static void acpi_memory_remove_memory(struct acpi_memory_device *mem_device) |
231 | { | 275 | { |
232 | int result = 0, nid; | 276 | acpi_handle handle = mem_device->device->handle; |
233 | struct acpi_memory_info *info, *n; | 277 | struct acpi_memory_info *info, *n; |
234 | 278 | int nid = acpi_get_node(handle); | |
235 | nid = acpi_get_node(mem_device->device->handle); | ||
236 | 279 | ||
237 | list_for_each_entry_safe(info, n, &mem_device->res_list, list) { | 280 | list_for_each_entry_safe(info, n, &mem_device->res_list, list) { |
238 | if (!info->enabled) | 281 | if (!info->enabled) |
@@ -240,15 +283,12 @@ static int acpi_memory_remove_memory(struct acpi_memory_device *mem_device) | |||
240 | 283 | ||
241 | if (nid < 0) | 284 | if (nid < 0) |
242 | nid = memory_add_physaddr_to_nid(info->start_addr); | 285 | nid = memory_add_physaddr_to_nid(info->start_addr); |
243 | result = remove_memory(nid, info->start_addr, info->length); | ||
244 | if (result) | ||
245 | return result; | ||
246 | 286 | ||
287 | acpi_unbind_memory_blocks(info, handle); | ||
288 | remove_memory(nid, info->start_addr, info->length); | ||
247 | list_del(&info->list); | 289 | list_del(&info->list); |
248 | kfree(info); | 290 | kfree(info); |
249 | } | 291 | } |
250 | |||
251 | return result; | ||
252 | } | 292 | } |
253 | 293 | ||
254 | static void acpi_memory_device_free(struct acpi_memory_device *mem_device) | 294 | static void acpi_memory_device_free(struct acpi_memory_device *mem_device) |
@@ -300,7 +340,7 @@ static int acpi_memory_device_add(struct acpi_device *device, | |||
300 | if (result) { | 340 | if (result) { |
301 | dev_err(&device->dev, "acpi_memory_enable_device() error\n"); | 341 | dev_err(&device->dev, "acpi_memory_enable_device() error\n"); |
302 | acpi_memory_device_free(mem_device); | 342 | acpi_memory_device_free(mem_device); |
303 | return -ENODEV; | 343 | return result; |
304 | } | 344 | } |
305 | 345 | ||
306 | dev_dbg(&device->dev, "Memory device configured by ACPI\n"); | 346 | dev_dbg(&device->dev, "Memory device configured by ACPI\n"); |
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c new file mode 100644 index 000000000000..e9b01e35ac37 --- /dev/null +++ b/drivers/acpi/acpi_processor.c | |||
@@ -0,0 +1,494 @@ | |||
1 | /* | ||
2 | * acpi_processor.c - ACPI processor enumeration support | ||
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 | * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de> | ||
7 | * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | ||
8 | * Copyright (C) 2013, Intel Corporation | ||
9 | * Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify it | ||
12 | * under the terms of the GNU General Public License version 2 as published | ||
13 | * by the Free Software Foundation. | ||
14 | */ | ||
15 | |||
16 | #include <linux/acpi.h> | ||
17 | #include <linux/device.h> | ||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/pci.h> | ||
21 | |||
22 | #include <acpi/processor.h> | ||
23 | |||
24 | #include <asm/cpu.h> | ||
25 | |||
26 | #include "internal.h" | ||
27 | |||
28 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | ||
29 | |||
30 | ACPI_MODULE_NAME("processor"); | ||
31 | |||
32 | DEFINE_PER_CPU(struct acpi_processor *, processors); | ||
33 | EXPORT_PER_CPU_SYMBOL(processors); | ||
34 | |||
35 | /* -------------------------------------------------------------------------- | ||
36 | Errata Handling | ||
37 | -------------------------------------------------------------------------- */ | ||
38 | |||
39 | struct acpi_processor_errata errata __read_mostly; | ||
40 | EXPORT_SYMBOL_GPL(errata); | ||
41 | |||
42 | static int acpi_processor_errata_piix4(struct pci_dev *dev) | ||
43 | { | ||
44 | u8 value1 = 0; | ||
45 | u8 value2 = 0; | ||
46 | |||
47 | |||
48 | if (!dev) | ||
49 | return -EINVAL; | ||
50 | |||
51 | /* | ||
52 | * Note that 'dev' references the PIIX4 ACPI Controller. | ||
53 | */ | ||
54 | |||
55 | switch (dev->revision) { | ||
56 | case 0: | ||
57 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 A-step\n")); | ||
58 | break; | ||
59 | case 1: | ||
60 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 B-step\n")); | ||
61 | break; | ||
62 | case 2: | ||
63 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4E\n")); | ||
64 | break; | ||
65 | case 3: | ||
66 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4M\n")); | ||
67 | break; | ||
68 | default: | ||
69 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unknown PIIX4\n")); | ||
70 | break; | ||
71 | } | ||
72 | |||
73 | switch (dev->revision) { | ||
74 | |||
75 | case 0: /* PIIX4 A-step */ | ||
76 | case 1: /* PIIX4 B-step */ | ||
77 | /* | ||
78 | * See specification changes #13 ("Manual Throttle Duty Cycle") | ||
79 | * and #14 ("Enabling and Disabling Manual Throttle"), plus | ||
80 | * erratum #5 ("STPCLK# Deassertion Time") from the January | ||
81 | * 2002 PIIX4 specification update. Applies to only older | ||
82 | * PIIX4 models. | ||
83 | */ | ||
84 | errata.piix4.throttle = 1; | ||
85 | |||
86 | case 2: /* PIIX4E */ | ||
87 | case 3: /* PIIX4M */ | ||
88 | /* | ||
89 | * See erratum #18 ("C3 Power State/BMIDE and Type-F DMA | ||
90 | * Livelock") from the January 2002 PIIX4 specification update. | ||
91 | * Applies to all PIIX4 models. | ||
92 | */ | ||
93 | |||
94 | /* | ||
95 | * BM-IDE | ||
96 | * ------ | ||
97 | * Find the PIIX4 IDE Controller and get the Bus Master IDE | ||
98 | * Status register address. We'll use this later to read | ||
99 | * each IDE controller's DMA status to make sure we catch all | ||
100 | * DMA activity. | ||
101 | */ | ||
102 | dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, | ||
103 | PCI_DEVICE_ID_INTEL_82371AB, | ||
104 | PCI_ANY_ID, PCI_ANY_ID, NULL); | ||
105 | if (dev) { | ||
106 | errata.piix4.bmisx = pci_resource_start(dev, 4); | ||
107 | pci_dev_put(dev); | ||
108 | } | ||
109 | |||
110 | /* | ||
111 | * Type-F DMA | ||
112 | * ---------- | ||
113 | * Find the PIIX4 ISA Controller and read the Motherboard | ||
114 | * DMA controller's status to see if Type-F (Fast) DMA mode | ||
115 | * is enabled (bit 7) on either channel. Note that we'll | ||
116 | * disable C3 support if this is enabled, as some legacy | ||
117 | * devices won't operate well if fast DMA is disabled. | ||
118 | */ | ||
119 | dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, | ||
120 | PCI_DEVICE_ID_INTEL_82371AB_0, | ||
121 | PCI_ANY_ID, PCI_ANY_ID, NULL); | ||
122 | if (dev) { | ||
123 | pci_read_config_byte(dev, 0x76, &value1); | ||
124 | pci_read_config_byte(dev, 0x77, &value2); | ||
125 | if ((value1 & 0x80) || (value2 & 0x80)) | ||
126 | errata.piix4.fdma = 1; | ||
127 | pci_dev_put(dev); | ||
128 | } | ||
129 | |||
130 | break; | ||
131 | } | ||
132 | |||
133 | if (errata.piix4.bmisx) | ||
134 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
135 | "Bus master activity detection (BM-IDE) erratum enabled\n")); | ||
136 | if (errata.piix4.fdma) | ||
137 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
138 | "Type-F DMA livelock erratum (C3 disabled)\n")); | ||
139 | |||
140 | return 0; | ||
141 | } | ||
142 | |||
143 | static int acpi_processor_errata(struct acpi_processor *pr) | ||
144 | { | ||
145 | int result = 0; | ||
146 | struct pci_dev *dev = NULL; | ||
147 | |||
148 | |||
149 | if (!pr) | ||
150 | return -EINVAL; | ||
151 | |||
152 | /* | ||
153 | * PIIX4 | ||
154 | */ | ||
155 | dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, | ||
156 | PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID, | ||
157 | PCI_ANY_ID, NULL); | ||
158 | if (dev) { | ||
159 | result = acpi_processor_errata_piix4(dev); | ||
160 | pci_dev_put(dev); | ||
161 | } | ||
162 | |||
163 | return result; | ||
164 | } | ||
165 | |||
166 | /* -------------------------------------------------------------------------- | ||
167 | Initialization | ||
168 | -------------------------------------------------------------------------- */ | ||
169 | |||
170 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | ||
171 | static int acpi_processor_hotadd_init(struct acpi_processor *pr) | ||
172 | { | ||
173 | unsigned long long sta; | ||
174 | acpi_status status; | ||
175 | int ret; | ||
176 | |||
177 | status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta); | ||
178 | if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT)) | ||
179 | return -ENODEV; | ||
180 | |||
181 | ret = acpi_map_lsapic(pr->handle, &pr->id); | ||
182 | if (ret) | ||
183 | return ret; | ||
184 | |||
185 | ret = arch_register_cpu(pr->id); | ||
186 | if (ret) { | ||
187 | acpi_unmap_lsapic(pr->id); | ||
188 | return ret; | ||
189 | } | ||
190 | |||
191 | /* | ||
192 | * CPU got hot-added, but cpu_data is not initialized yet. Set a flag | ||
193 | * to delay cpu_idle/throttling initialization and do it when the CPU | ||
194 | * gets online for the first time. | ||
195 | */ | ||
196 | pr_info("CPU%d has been hot-added\n", pr->id); | ||
197 | pr->flags.need_hotplug_init = 1; | ||
198 | return 0; | ||
199 | } | ||
200 | #else | ||
201 | static inline int acpi_processor_hotadd_init(struct acpi_processor *pr) | ||
202 | { | ||
203 | return -ENODEV; | ||
204 | } | ||
205 | #endif /* CONFIG_ACPI_HOTPLUG_CPU */ | ||
206 | |||
207 | static int acpi_processor_get_info(struct acpi_device *device) | ||
208 | { | ||
209 | union acpi_object object = { 0 }; | ||
210 | struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; | ||
211 | struct acpi_processor *pr = acpi_driver_data(device); | ||
212 | int cpu_index, device_declaration = 0; | ||
213 | acpi_status status = AE_OK; | ||
214 | static int cpu0_initialized; | ||
215 | |||
216 | if (num_online_cpus() > 1) | ||
217 | errata.smp = TRUE; | ||
218 | |||
219 | acpi_processor_errata(pr); | ||
220 | |||
221 | /* | ||
222 | * Check to see if we have bus mastering arbitration control. This | ||
223 | * is required for proper C3 usage (to maintain cache coherency). | ||
224 | */ | ||
225 | if (acpi_gbl_FADT.pm2_control_block && acpi_gbl_FADT.pm2_control_length) { | ||
226 | pr->flags.bm_control = 1; | ||
227 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
228 | "Bus mastering arbitration control present\n")); | ||
229 | } else | ||
230 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
231 | "No bus mastering arbitration control\n")); | ||
232 | |||
233 | if (!strcmp(acpi_device_hid(device), ACPI_PROCESSOR_OBJECT_HID)) { | ||
234 | /* Declared with "Processor" statement; match ProcessorID */ | ||
235 | status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); | ||
236 | if (ACPI_FAILURE(status)) { | ||
237 | dev_err(&device->dev, | ||
238 | "Failed to evaluate processor object (0x%x)\n", | ||
239 | status); | ||
240 | return -ENODEV; | ||
241 | } | ||
242 | |||
243 | /* | ||
244 | * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP. | ||
245 | * >>> 'acpi_get_processor_id(acpi_id, &id)' in | ||
246 | * arch/xxx/acpi.c | ||
247 | */ | ||
248 | pr->acpi_id = object.processor.proc_id; | ||
249 | } else { | ||
250 | /* | ||
251 | * Declared with "Device" statement; match _UID. | ||
252 | * Note that we don't handle string _UIDs yet. | ||
253 | */ | ||
254 | unsigned long long value; | ||
255 | status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID, | ||
256 | NULL, &value); | ||
257 | if (ACPI_FAILURE(status)) { | ||
258 | dev_err(&device->dev, | ||
259 | "Failed to evaluate processor _UID (0x%x)\n", | ||
260 | status); | ||
261 | return -ENODEV; | ||
262 | } | ||
263 | device_declaration = 1; | ||
264 | pr->acpi_id = value; | ||
265 | } | ||
266 | cpu_index = acpi_get_cpuid(pr->handle, device_declaration, pr->acpi_id); | ||
267 | |||
268 | /* Handle UP system running SMP kernel, with no LAPIC in MADT */ | ||
269 | if (!cpu0_initialized && (cpu_index == -1) && | ||
270 | (num_online_cpus() == 1)) { | ||
271 | cpu_index = 0; | ||
272 | } | ||
273 | |||
274 | cpu0_initialized = 1; | ||
275 | |||
276 | pr->id = cpu_index; | ||
277 | |||
278 | /* | ||
279 | * Extra Processor objects may be enumerated on MP systems with | ||
280 | * less than the max # of CPUs. They should be ignored _iff | ||
281 | * they are physically not present. | ||
282 | */ | ||
283 | if (pr->id == -1) { | ||
284 | int ret = acpi_processor_hotadd_init(pr); | ||
285 | if (ret) | ||
286 | return ret; | ||
287 | } | ||
288 | /* | ||
289 | * On some boxes several processors use the same processor bus id. | ||
290 | * But they are located in different scope. For example: | ||
291 | * \_SB.SCK0.CPU0 | ||
292 | * \_SB.SCK1.CPU0 | ||
293 | * Rename the processor device bus id. And the new bus id will be | ||
294 | * generated as the following format: | ||
295 | * CPU+CPU ID. | ||
296 | */ | ||
297 | sprintf(acpi_device_bid(device), "CPU%X", pr->id); | ||
298 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id, | ||
299 | pr->acpi_id)); | ||
300 | |||
301 | if (!object.processor.pblk_address) | ||
302 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n")); | ||
303 | else if (object.processor.pblk_length != 6) | ||
304 | dev_err(&device->dev, "Invalid PBLK length [%d]\n", | ||
305 | object.processor.pblk_length); | ||
306 | else { | ||
307 | pr->throttling.address = object.processor.pblk_address; | ||
308 | pr->throttling.duty_offset = acpi_gbl_FADT.duty_offset; | ||
309 | pr->throttling.duty_width = acpi_gbl_FADT.duty_width; | ||
310 | |||
311 | pr->pblk = object.processor.pblk_address; | ||
312 | |||
313 | /* | ||
314 | * We don't care about error returns - we just try to mark | ||
315 | * these reserved so that nobody else is confused into thinking | ||
316 | * that this region might be unused.. | ||
317 | * | ||
318 | * (In particular, allocating the IO range for Cardbus) | ||
319 | */ | ||
320 | request_region(pr->throttling.address, 6, "ACPI CPU throttle"); | ||
321 | } | ||
322 | |||
323 | /* | ||
324 | * If ACPI describes a slot number for this CPU, we can use it to | ||
325 | * ensure we get the right value in the "physical id" field | ||
326 | * of /proc/cpuinfo | ||
327 | */ | ||
328 | status = acpi_evaluate_object(pr->handle, "_SUN", NULL, &buffer); | ||
329 | if (ACPI_SUCCESS(status)) | ||
330 | arch_fix_phys_package_id(pr->id, object.integer.value); | ||
331 | |||
332 | return 0; | ||
333 | } | ||
334 | |||
335 | /* | ||
336 | * Do not put anything in here which needs the core to be online. | ||
337 | * For example MSR access or setting up things which check for cpuinfo_x86 | ||
338 | * (cpu_data(cpu)) values, like CPU feature flags, family, model, etc. | ||
339 | * Such things have to be put in and set up by the processor driver's .probe(). | ||
340 | */ | ||
341 | static DEFINE_PER_CPU(void *, processor_device_array); | ||
342 | |||
343 | static int __cpuinit acpi_processor_add(struct acpi_device *device, | ||
344 | const struct acpi_device_id *id) | ||
345 | { | ||
346 | struct acpi_processor *pr; | ||
347 | struct device *dev; | ||
348 | int result = 0; | ||
349 | |||
350 | pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL); | ||
351 | if (!pr) | ||
352 | return -ENOMEM; | ||
353 | |||
354 | if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) { | ||
355 | result = -ENOMEM; | ||
356 | goto err_free_pr; | ||
357 | } | ||
358 | |||
359 | pr->handle = device->handle; | ||
360 | strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); | ||
361 | strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); | ||
362 | device->driver_data = pr; | ||
363 | |||
364 | result = acpi_processor_get_info(device); | ||
365 | if (result) /* Processor is not physically present or unavailable */ | ||
366 | return 0; | ||
367 | |||
368 | #ifdef CONFIG_SMP | ||
369 | if (pr->id >= setup_max_cpus && pr->id != 0) | ||
370 | return 0; | ||
371 | #endif | ||
372 | |||
373 | BUG_ON(pr->id >= nr_cpu_ids); | ||
374 | |||
375 | /* | ||
376 | * Buggy BIOS check. | ||
377 | * ACPI id of processors can be reported wrongly by the BIOS. | ||
378 | * Don't trust it blindly | ||
379 | */ | ||
380 | if (per_cpu(processor_device_array, pr->id) != NULL && | ||
381 | per_cpu(processor_device_array, pr->id) != device) { | ||
382 | dev_warn(&device->dev, | ||
383 | "BIOS reported wrong ACPI id %d for the processor\n", | ||
384 | pr->id); | ||
385 | /* Give up, but do not abort the namespace scan. */ | ||
386 | goto err; | ||
387 | } | ||
388 | /* | ||
389 | * processor_device_array is not cleared on errors to allow buggy BIOS | ||
390 | * checks. | ||
391 | */ | ||
392 | per_cpu(processor_device_array, pr->id) = device; | ||
393 | per_cpu(processors, pr->id) = pr; | ||
394 | |||
395 | dev = get_cpu_device(pr->id); | ||
396 | if (!dev) { | ||
397 | result = -ENODEV; | ||
398 | goto err; | ||
399 | } | ||
400 | |||
401 | result = acpi_bind_one(dev, pr->handle); | ||
402 | if (result) | ||
403 | goto err; | ||
404 | |||
405 | pr->dev = dev; | ||
406 | dev->offline = pr->flags.need_hotplug_init; | ||
407 | |||
408 | /* Trigger the processor driver's .probe() if present. */ | ||
409 | if (device_attach(dev) >= 0) | ||
410 | return 1; | ||
411 | |||
412 | dev_err(dev, "Processor driver could not be attached\n"); | ||
413 | acpi_unbind_one(dev); | ||
414 | |||
415 | err: | ||
416 | free_cpumask_var(pr->throttling.shared_cpu_map); | ||
417 | device->driver_data = NULL; | ||
418 | per_cpu(processors, pr->id) = NULL; | ||
419 | err_free_pr: | ||
420 | kfree(pr); | ||
421 | return result; | ||
422 | } | ||
423 | |||
424 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | ||
425 | /* -------------------------------------------------------------------------- | ||
426 | Removal | ||
427 | -------------------------------------------------------------------------- */ | ||
428 | |||
429 | static void acpi_processor_remove(struct acpi_device *device) | ||
430 | { | ||
431 | struct acpi_processor *pr; | ||
432 | |||
433 | if (!device || !acpi_driver_data(device)) | ||
434 | return; | ||
435 | |||
436 | pr = acpi_driver_data(device); | ||
437 | if (pr->id >= nr_cpu_ids) | ||
438 | goto out; | ||
439 | |||
440 | /* | ||
441 | * The only reason why we ever get here is CPU hot-removal. The CPU is | ||
442 | * already offline and the ACPI device removal locking prevents it from | ||
443 | * being put back online at this point. | ||
444 | * | ||
445 | * Unbind the driver from the processor device and detach it from the | ||
446 | * ACPI companion object. | ||
447 | */ | ||
448 | device_release_driver(pr->dev); | ||
449 | acpi_unbind_one(pr->dev); | ||
450 | |||
451 | /* Clean up. */ | ||
452 | per_cpu(processor_device_array, pr->id) = NULL; | ||
453 | per_cpu(processors, pr->id) = NULL; | ||
454 | try_offline_node(cpu_to_node(pr->id)); | ||
455 | |||
456 | /* Remove the CPU. */ | ||
457 | get_online_cpus(); | ||
458 | arch_unregister_cpu(pr->id); | ||
459 | acpi_unmap_lsapic(pr->id); | ||
460 | put_online_cpus(); | ||
461 | |||
462 | out: | ||
463 | free_cpumask_var(pr->throttling.shared_cpu_map); | ||
464 | kfree(pr); | ||
465 | } | ||
466 | #endif /* CONFIG_ACPI_HOTPLUG_CPU */ | ||
467 | |||
468 | /* | ||
469 | * The following ACPI IDs are known to be suitable for representing as | ||
470 | * processor devices. | ||
471 | */ | ||
472 | static const struct acpi_device_id processor_device_ids[] = { | ||
473 | |||
474 | { ACPI_PROCESSOR_OBJECT_HID, }, | ||
475 | { ACPI_PROCESSOR_DEVICE_HID, }, | ||
476 | |||
477 | { } | ||
478 | }; | ||
479 | |||
480 | static struct acpi_scan_handler __refdata processor_handler = { | ||
481 | .ids = processor_device_ids, | ||
482 | .attach = acpi_processor_add, | ||
483 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | ||
484 | .detach = acpi_processor_remove, | ||
485 | #endif | ||
486 | .hotplug = { | ||
487 | .enabled = true, | ||
488 | }, | ||
489 | }; | ||
490 | |||
491 | void __init acpi_processor_init(void) | ||
492 | { | ||
493 | acpi_scan_add_handler_with_hotplug(&processor_handler, "processor"); | ||
494 | } | ||
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile index 7ddf29eca9f5..438304086ff1 100644 --- a/drivers/acpi/acpica/Makefile +++ b/drivers/acpi/acpica/Makefile | |||
@@ -83,6 +83,7 @@ acpi-$(ACPI_FUTURE_USAGE) += hwtimer.o | |||
83 | acpi-y += \ | 83 | acpi-y += \ |
84 | nsaccess.o \ | 84 | nsaccess.o \ |
85 | nsalloc.o \ | 85 | nsalloc.o \ |
86 | nsarguments.o \ | ||
86 | nsconvert.o \ | 87 | nsconvert.o \ |
87 | nsdump.o \ | 88 | nsdump.o \ |
88 | nseval.o \ | 89 | nseval.o \ |
@@ -137,6 +138,7 @@ acpi-y += \ | |||
137 | tbfadt.o \ | 138 | tbfadt.o \ |
138 | tbfind.o \ | 139 | tbfind.o \ |
139 | tbinstal.o \ | 140 | tbinstal.o \ |
141 | tbprint.o \ | ||
140 | tbutils.o \ | 142 | tbutils.o \ |
141 | tbxface.o \ | 143 | tbxface.o \ |
142 | tbxfload.o \ | 144 | tbxfload.o \ |
@@ -145,11 +147,13 @@ acpi-y += \ | |||
145 | acpi-y += \ | 147 | acpi-y += \ |
146 | utaddress.o \ | 148 | utaddress.o \ |
147 | utalloc.o \ | 149 | utalloc.o \ |
150 | utbuffer.o \ | ||
148 | utcopy.o \ | 151 | utcopy.o \ |
149 | utexcep.o \ | 152 | utexcep.o \ |
150 | utdebug.o \ | 153 | utdebug.o \ |
151 | utdecode.o \ | 154 | utdecode.o \ |
152 | utdelete.o \ | 155 | utdelete.o \ |
156 | uterror.o \ | ||
153 | uteval.o \ | 157 | uteval.o \ |
154 | utglobal.o \ | 158 | utglobal.o \ |
155 | utids.o \ | 159 | utids.o \ |
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h index 07160928ca25..b8d38117a20c 100644 --- a/drivers/acpi/acpica/acglobal.h +++ b/drivers/acpi/acpica/acglobal.h | |||
@@ -132,6 +132,12 @@ u8 ACPI_INIT_GLOBAL(acpi_gbl_truncate_io_addresses, FALSE); | |||
132 | */ | 132 | */ |
133 | u8 ACPI_INIT_GLOBAL(acpi_gbl_disable_auto_repair, FALSE); | 133 | u8 ACPI_INIT_GLOBAL(acpi_gbl_disable_auto_repair, FALSE); |
134 | 134 | ||
135 | /* | ||
136 | * Optionally do not load any SSDTs from the RSDT/XSDT during initialization. | ||
137 | * This can be useful for debugging ACPI problems on some machines. | ||
138 | */ | ||
139 | u8 ACPI_INIT_GLOBAL(acpi_gbl_disable_ssdt_table_load, FALSE); | ||
140 | |||
135 | /* acpi_gbl_FADT is a local copy of the FADT, converted to a common format. */ | 141 | /* acpi_gbl_FADT is a local copy of the FADT, converted to a common format. */ |
136 | 142 | ||
137 | struct acpi_table_fadt acpi_gbl_FADT; | 143 | struct acpi_table_fadt acpi_gbl_FADT; |
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h index d5bfbd331bfd..dfed26545ba2 100644 --- a/drivers/acpi/acpica/aclocal.h +++ b/drivers/acpi/acpica/aclocal.h | |||
@@ -362,23 +362,6 @@ union acpi_predefined_info { | |||
362 | 362 | ||
363 | #pragma pack() | 363 | #pragma pack() |
364 | 364 | ||
365 | /* Data block used during object validation */ | ||
366 | |||
367 | struct acpi_predefined_data { | ||
368 | char *pathname; | ||
369 | const union acpi_predefined_info *predefined; | ||
370 | union acpi_operand_object *parent_package; | ||
371 | struct acpi_namespace_node *node; | ||
372 | u32 flags; | ||
373 | u32 return_btype; | ||
374 | u8 node_flags; | ||
375 | }; | ||
376 | |||
377 | /* Defines for Flags field above */ | ||
378 | |||
379 | #define ACPI_OBJECT_REPAIRED 1 | ||
380 | #define ACPI_OBJECT_WRAPPED 2 | ||
381 | |||
382 | /* Return object auto-repair info */ | 365 | /* Return object auto-repair info */ |
383 | 366 | ||
384 | typedef acpi_status(*acpi_object_converter) (union acpi_operand_object | 367 | typedef acpi_status(*acpi_object_converter) (union acpi_operand_object |
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h index 53666bd9193d..530a2f8c1252 100644 --- a/drivers/acpi/acpica/acmacros.h +++ b/drivers/acpi/acpica/acmacros.h | |||
@@ -374,10 +374,11 @@ | |||
374 | * the plist contains a set of parens to allow variable-length lists. | 374 | * the plist contains a set of parens to allow variable-length lists. |
375 | * These macros are used for both the debug and non-debug versions of the code. | 375 | * These macros are used for both the debug and non-debug versions of the code. |
376 | */ | 376 | */ |
377 | #define ACPI_ERROR_NAMESPACE(s, e) acpi_ut_namespace_error (AE_INFO, s, e); | 377 | #define ACPI_ERROR_NAMESPACE(s, e) acpi_ut_namespace_error (AE_INFO, s, e); |
378 | #define ACPI_ERROR_METHOD(s, n, p, e) acpi_ut_method_error (AE_INFO, s, n, p, e); | 378 | #define ACPI_ERROR_METHOD(s, n, p, e) acpi_ut_method_error (AE_INFO, s, n, p, e); |
379 | #define ACPI_WARN_PREDEFINED(plist) acpi_ut_predefined_warning plist | 379 | #define ACPI_WARN_PREDEFINED(plist) acpi_ut_predefined_warning plist |
380 | #define ACPI_INFO_PREDEFINED(plist) acpi_ut_predefined_info plist | 380 | #define ACPI_INFO_PREDEFINED(plist) acpi_ut_predefined_info plist |
381 | #define ACPI_BIOS_ERROR_PREDEFINED(plist) acpi_ut_predefined_bios_error plist | ||
381 | 382 | ||
382 | #else | 383 | #else |
383 | 384 | ||
@@ -387,6 +388,7 @@ | |||
387 | #define ACPI_ERROR_METHOD(s, n, p, e) | 388 | #define ACPI_ERROR_METHOD(s, n, p, e) |
388 | #define ACPI_WARN_PREDEFINED(plist) | 389 | #define ACPI_WARN_PREDEFINED(plist) |
389 | #define ACPI_INFO_PREDEFINED(plist) | 390 | #define ACPI_INFO_PREDEFINED(plist) |
391 | #define ACPI_BIOS_ERROR_PREDEFINED(plist) | ||
390 | 392 | ||
391 | #endif /* ACPI_NO_ERROR_MESSAGES */ | 393 | #endif /* ACPI_NO_ERROR_MESSAGES */ |
392 | 394 | ||
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h index d2e491876bc0..b83dc32a5ae0 100644 --- a/drivers/acpi/acpica/acnamesp.h +++ b/drivers/acpi/acpica/acnamesp.h | |||
@@ -223,22 +223,33 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info); | |||
223 | void acpi_ns_exec_module_code_list(void); | 223 | void acpi_ns_exec_module_code_list(void); |
224 | 224 | ||
225 | /* | 225 | /* |
226 | * nspredef - Support for predefined/reserved names | 226 | * nsarguments - Argument count/type checking for predefined/reserved names |
227 | */ | 227 | */ |
228 | acpi_status | 228 | void |
229 | acpi_ns_check_predefined_names(struct acpi_namespace_node *node, | 229 | acpi_ns_check_argument_count(char *pathname, |
230 | u32 user_param_count, | 230 | struct acpi_namespace_node *node, |
231 | acpi_status return_status, | 231 | u32 user_param_count, |
232 | union acpi_operand_object **return_object); | 232 | const union acpi_predefined_info *info); |
233 | 233 | ||
234 | void | 234 | void |
235 | acpi_ns_check_parameter_count(char *pathname, | 235 | acpi_ns_check_acpi_compliance(char *pathname, |
236 | struct acpi_namespace_node *node, | 236 | struct acpi_namespace_node *node, |
237 | u32 user_param_count, | 237 | const union acpi_predefined_info *predefined); |
238 | const union acpi_predefined_info *info); | 238 | |
239 | void acpi_ns_check_argument_types(struct acpi_evaluate_info *info); | ||
240 | |||
241 | /* | ||
242 | * nspredef - Return value checking for predefined/reserved names | ||
243 | */ | ||
244 | acpi_status | ||
245 | acpi_ns_check_return_value(struct acpi_namespace_node *node, | ||
246 | struct acpi_evaluate_info *info, | ||
247 | u32 user_param_count, | ||
248 | acpi_status return_status, | ||
249 | union acpi_operand_object **return_object); | ||
239 | 250 | ||
240 | acpi_status | 251 | acpi_status |
241 | acpi_ns_check_object_type(struct acpi_predefined_data *data, | 252 | acpi_ns_check_object_type(struct acpi_evaluate_info *info, |
242 | union acpi_operand_object **return_object_ptr, | 253 | union acpi_operand_object **return_object_ptr, |
243 | u32 expected_btypes, u32 package_index); | 254 | u32 expected_btypes, u32 package_index); |
244 | 255 | ||
@@ -246,7 +257,7 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data, | |||
246 | * nsprepkg - Validation of predefined name packages | 257 | * nsprepkg - Validation of predefined name packages |
247 | */ | 258 | */ |
248 | acpi_status | 259 | acpi_status |
249 | acpi_ns_check_package(struct acpi_predefined_data *data, | 260 | acpi_ns_check_package(struct acpi_evaluate_info *info, |
250 | union acpi_operand_object **return_object_ptr); | 261 | union acpi_operand_object **return_object_ptr); |
251 | 262 | ||
252 | /* | 263 | /* |
@@ -308,24 +319,24 @@ acpi_ns_get_attached_data(struct acpi_namespace_node *node, | |||
308 | * predefined methods/objects | 319 | * predefined methods/objects |
309 | */ | 320 | */ |
310 | acpi_status | 321 | acpi_status |
311 | acpi_ns_simple_repair(struct acpi_predefined_data *data, | 322 | acpi_ns_simple_repair(struct acpi_evaluate_info *info, |
312 | u32 expected_btypes, | 323 | u32 expected_btypes, |
313 | u32 package_index, | 324 | u32 package_index, |
314 | union acpi_operand_object **return_object_ptr); | 325 | union acpi_operand_object **return_object_ptr); |
315 | 326 | ||
316 | acpi_status | 327 | acpi_status |
317 | acpi_ns_wrap_with_package(struct acpi_predefined_data *data, | 328 | acpi_ns_wrap_with_package(struct acpi_evaluate_info *info, |
318 | union acpi_operand_object *original_object, | 329 | union acpi_operand_object *original_object, |
319 | union acpi_operand_object **obj_desc_ptr); | 330 | union acpi_operand_object **obj_desc_ptr); |
320 | 331 | ||
321 | acpi_status | 332 | acpi_status |
322 | acpi_ns_repair_null_element(struct acpi_predefined_data *data, | 333 | acpi_ns_repair_null_element(struct acpi_evaluate_info *info, |
323 | u32 expected_btypes, | 334 | u32 expected_btypes, |
324 | u32 package_index, | 335 | u32 package_index, |
325 | union acpi_operand_object **return_object_ptr); | 336 | union acpi_operand_object **return_object_ptr); |
326 | 337 | ||
327 | void | 338 | void |
328 | acpi_ns_remove_null_elements(struct acpi_predefined_data *data, | 339 | acpi_ns_remove_null_elements(struct acpi_evaluate_info *info, |
329 | u8 package_type, | 340 | u8 package_type, |
330 | union acpi_operand_object *obj_desc); | 341 | union acpi_operand_object *obj_desc); |
331 | 342 | ||
@@ -334,7 +345,7 @@ acpi_ns_remove_null_elements(struct acpi_predefined_data *data, | |||
334 | * predefined methods/objects | 345 | * predefined methods/objects |
335 | */ | 346 | */ |
336 | acpi_status | 347 | acpi_status |
337 | acpi_ns_complex_repairs(struct acpi_predefined_data *data, | 348 | acpi_ns_complex_repairs(struct acpi_evaluate_info *info, |
338 | struct acpi_namespace_node *node, | 349 | struct acpi_namespace_node *node, |
339 | acpi_status validate_status, | 350 | acpi_status validate_status, |
340 | union acpi_operand_object **return_object_ptr); | 351 | union acpi_operand_object **return_object_ptr); |
diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h index b22b70944fd6..f600aded7261 100644 --- a/drivers/acpi/acpica/acpredef.h +++ b/drivers/acpi/acpica/acpredef.h | |||
@@ -128,8 +128,8 @@ enum acpi_return_package_types { | |||
128 | #define ARG_COUNT_IS_MINIMUM 0x8000 | 128 | #define ARG_COUNT_IS_MINIMUM 0x8000 |
129 | #define METHOD_MAX_ARG_TYPE ACPI_TYPE_PACKAGE | 129 | #define METHOD_MAX_ARG_TYPE ACPI_TYPE_PACKAGE |
130 | 130 | ||
131 | #define METHOD_GET_COUNT(arg_list) (arg_list & METHOD_ARG_MASK) | 131 | #define METHOD_GET_ARG_COUNT(arg_list) ((arg_list) & METHOD_ARG_MASK) |
132 | #define METHOD_GET_NEXT_ARG(arg_list) (arg_list >> METHOD_ARG_BIT_WIDTH) | 132 | #define METHOD_GET_NEXT_TYPE(arg_list) (((arg_list) >>= METHOD_ARG_BIT_WIDTH) & METHOD_ARG_MASK) |
133 | 133 | ||
134 | /* Macros used to build the predefined info table */ | 134 | /* Macros used to build the predefined info table */ |
135 | 135 | ||
diff --git a/drivers/acpi/acpica/acstruct.h b/drivers/acpi/acpica/acstruct.h index 7896d85876ca..fc83c0a5ca70 100644 --- a/drivers/acpi/acpica/acstruct.h +++ b/drivers/acpi/acpica/acstruct.h | |||
@@ -178,25 +178,41 @@ union acpi_aml_operands { | |||
178 | }; | 178 | }; |
179 | 179 | ||
180 | /* | 180 | /* |
181 | * Structure used to pass object evaluation parameters. | 181 | * Structure used to pass object evaluation information and parameters. |
182 | * Purpose is to reduce CPU stack use. | 182 | * Purpose is to reduce CPU stack use. |
183 | */ | 183 | */ |
184 | struct acpi_evaluate_info { | 184 | struct acpi_evaluate_info { |
185 | struct acpi_namespace_node *prefix_node; | 185 | /* The first 3 elements are passed by the caller to acpi_ns_evaluate */ |
186 | char *pathname; | 186 | |
187 | union acpi_operand_object *obj_desc; | 187 | struct acpi_namespace_node *prefix_node; /* Input: starting node */ |
188 | union acpi_operand_object **parameters; | 188 | char *relative_pathname; /* Input: path relative to prefix_node */ |
189 | struct acpi_namespace_node *resolved_node; | 189 | union acpi_operand_object **parameters; /* Input: argument list */ |
190 | union acpi_operand_object *return_object; | 190 | |
191 | u8 param_count; | 191 | struct acpi_namespace_node *node; /* Resolved node (prefix_node:relative_pathname) */ |
192 | u8 pass_number; | 192 | union acpi_operand_object *obj_desc; /* Object attached to the resolved node */ |
193 | u8 return_object_type; | 193 | char *full_pathname; /* Full pathname of the resolved node */ |
194 | u8 flags; | 194 | |
195 | const union acpi_predefined_info *predefined; /* Used if Node is a predefined name */ | ||
196 | union acpi_operand_object *return_object; /* Object returned from the evaluation */ | ||
197 | union acpi_operand_object *parent_package; /* Used if return object is a Package */ | ||
198 | |||
199 | u32 return_flags; /* Used for return value analysis */ | ||
200 | u32 return_btype; /* Bitmapped type of the returned object */ | ||
201 | u16 param_count; /* Count of the input argument list */ | ||
202 | u8 pass_number; /* Parser pass number */ | ||
203 | u8 return_object_type; /* Object type of the returned object */ | ||
204 | u8 node_flags; /* Same as Node->Flags */ | ||
205 | u8 flags; /* General flags */ | ||
195 | }; | 206 | }; |
196 | 207 | ||
197 | /* Values for Flags above */ | 208 | /* Values for Flags above */ |
198 | 209 | ||
199 | #define ACPI_IGNORE_RETURN_VALUE 1 | 210 | #define ACPI_IGNORE_RETURN_VALUE 1 |
211 | |||
212 | /* Defines for return_flags field above */ | ||
213 | |||
214 | #define ACPI_OBJECT_REPAIRED 1 | ||
215 | #define ACPI_OBJECT_WRAPPED 2 | ||
200 | 216 | ||
201 | /* Info used by acpi_ns_initialize_devices */ | 217 | /* Info used by acpi_ns_initialize_devices */ |
202 | 218 | ||
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h index 202f4f12d3e2..3c76edea6803 100644 --- a/drivers/acpi/acpica/acutils.h +++ b/drivers/acpi/acpica/acutils.h | |||
@@ -87,6 +87,48 @@ extern const char *acpi_gbl_fc_decode[]; | |||
87 | extern const char *acpi_gbl_pt_decode[]; | 87 | extern const char *acpi_gbl_pt_decode[]; |
88 | #endif | 88 | #endif |
89 | 89 | ||
90 | /* | ||
91 | * For the iASL compiler case, the output is redirected to stderr so that | ||
92 | * any of the various ACPI errors and warnings do not appear in the output | ||
93 | * files, for either the compiler or disassembler portions of the tool. | ||
94 | */ | ||
95 | #ifdef ACPI_ASL_COMPILER | ||
96 | |||
97 | #include <stdio.h> | ||
98 | extern FILE *acpi_gbl_output_file; | ||
99 | |||
100 | #define ACPI_MSG_REDIRECT_BEGIN \ | ||
101 | FILE *output_file = acpi_gbl_output_file; \ | ||
102 | acpi_os_redirect_output (stderr); | ||
103 | |||
104 | #define ACPI_MSG_REDIRECT_END \ | ||
105 | acpi_os_redirect_output (output_file); | ||
106 | |||
107 | #else | ||
108 | /* | ||
109 | * non-iASL case - no redirection, nothing to do | ||
110 | */ | ||
111 | #define ACPI_MSG_REDIRECT_BEGIN | ||
112 | #define ACPI_MSG_REDIRECT_END | ||
113 | #endif | ||
114 | |||
115 | /* | ||
116 | * Common error message prefixes | ||
117 | */ | ||
118 | #define ACPI_MSG_ERROR "ACPI Error: " | ||
119 | #define ACPI_MSG_EXCEPTION "ACPI Exception: " | ||
120 | #define ACPI_MSG_WARNING "ACPI Warning: " | ||
121 | #define ACPI_MSG_INFO "ACPI: " | ||
122 | |||
123 | #define ACPI_MSG_BIOS_ERROR "ACPI BIOS Error (bug): " | ||
124 | #define ACPI_MSG_BIOS_WARNING "ACPI BIOS Warning (bug): " | ||
125 | |||
126 | /* | ||
127 | * Common message suffix | ||
128 | */ | ||
129 | #define ACPI_MSG_SUFFIX \ | ||
130 | acpi_os_printf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, module_name, line_number) | ||
131 | |||
90 | /* Types for Resource descriptor entries */ | 132 | /* Types for Resource descriptor entries */ |
91 | 133 | ||
92 | #define ACPI_INVALID_RESOURCE 0 | 134 | #define ACPI_INVALID_RESOURCE 0 |
@@ -578,7 +620,7 @@ void acpi_ut_print_string(char *string, u8 max_length); | |||
578 | 620 | ||
579 | void ut_convert_backslashes(char *pathname); | 621 | void ut_convert_backslashes(char *pathname); |
580 | 622 | ||
581 | u8 acpi_ut_valid_acpi_name(u32 name); | 623 | u8 acpi_ut_valid_acpi_name(char *name); |
582 | 624 | ||
583 | u8 acpi_ut_valid_acpi_char(char character, u32 position); | 625 | u8 acpi_ut_valid_acpi_char(char character, u32 position); |
584 | 626 | ||
@@ -670,6 +712,12 @@ acpi_ut_predefined_info(const char *module_name, | |||
670 | u32 line_number, | 712 | u32 line_number, |
671 | char *pathname, u8 node_flags, const char *format, ...); | 713 | char *pathname, u8 node_flags, const char *format, ...); |
672 | 714 | ||
715 | void ACPI_INTERNAL_VAR_XFACE | ||
716 | acpi_ut_predefined_bios_error(const char *module_name, | ||
717 | u32 line_number, | ||
718 | char *pathname, | ||
719 | u8 node_flags, const char *format, ...); | ||
720 | |||
673 | void | 721 | void |
674 | acpi_ut_namespace_error(const char *module_name, | 722 | acpi_ut_namespace_error(const char *module_name, |
675 | u32 line_number, | 723 | u32 line_number, |
diff --git a/drivers/acpi/acpica/dscontrol.c b/drivers/acpi/acpica/dscontrol.c index 7ea0f162f11c..eb56b66444b5 100644 --- a/drivers/acpi/acpica/dscontrol.c +++ b/drivers/acpi/acpica/dscontrol.c | |||
@@ -78,7 +78,6 @@ acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state, | |||
78 | 78 | ||
79 | switch (op->common.aml_opcode) { | 79 | switch (op->common.aml_opcode) { |
80 | case AML_WHILE_OP: | 80 | case AML_WHILE_OP: |
81 | |||
82 | /* | 81 | /* |
83 | * If this is an additional iteration of a while loop, continue. | 82 | * If this is an additional iteration of a while loop, continue. |
84 | * There is no need to allocate a new control state. | 83 | * There is no need to allocate a new control state. |
@@ -99,7 +98,6 @@ acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state, | |||
99 | /*lint -fallthrough */ | 98 | /*lint -fallthrough */ |
100 | 99 | ||
101 | case AML_IF_OP: | 100 | case AML_IF_OP: |
102 | |||
103 | /* | 101 | /* |
104 | * IF/WHILE: Create a new control state to manage these | 102 | * IF/WHILE: Create a new control state to manage these |
105 | * constructs. We need to manage these as a stack, in order | 103 | * constructs. We need to manage these as a stack, in order |
@@ -142,6 +140,7 @@ acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state, | |||
142 | break; | 140 | break; |
143 | 141 | ||
144 | default: | 142 | default: |
143 | |||
145 | break; | 144 | break; |
146 | } | 145 | } |
147 | 146 | ||
@@ -344,6 +343,7 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state, | |||
344 | case AML_NOOP_OP: | 343 | case AML_NOOP_OP: |
345 | 344 | ||
346 | /* Just do nothing! */ | 345 | /* Just do nothing! */ |
346 | |||
347 | break; | 347 | break; |
348 | 348 | ||
349 | case AML_BREAK_POINT_OP: | 349 | case AML_BREAK_POINT_OP: |
diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c index feadeed1012d..d4bfe7b7f90a 100644 --- a/drivers/acpi/acpica/dsfield.c +++ b/drivers/acpi/acpica/dsfield.c | |||
@@ -563,21 +563,25 @@ acpi_ds_init_field_objects(union acpi_parse_object *op, | |||
563 | */ | 563 | */ |
564 | switch (walk_state->opcode) { | 564 | switch (walk_state->opcode) { |
565 | case AML_FIELD_OP: | 565 | case AML_FIELD_OP: |
566 | |||
566 | arg = acpi_ps_get_arg(op, 2); | 567 | arg = acpi_ps_get_arg(op, 2); |
567 | type = ACPI_TYPE_LOCAL_REGION_FIELD; | 568 | type = ACPI_TYPE_LOCAL_REGION_FIELD; |
568 | break; | 569 | break; |
569 | 570 | ||
570 | case AML_BANK_FIELD_OP: | 571 | case AML_BANK_FIELD_OP: |
572 | |||
571 | arg = acpi_ps_get_arg(op, 4); | 573 | arg = acpi_ps_get_arg(op, 4); |
572 | type = ACPI_TYPE_LOCAL_BANK_FIELD; | 574 | type = ACPI_TYPE_LOCAL_BANK_FIELD; |
573 | break; | 575 | break; |
574 | 576 | ||
575 | case AML_INDEX_FIELD_OP: | 577 | case AML_INDEX_FIELD_OP: |
578 | |||
576 | arg = acpi_ps_get_arg(op, 3); | 579 | arg = acpi_ps_get_arg(op, 3); |
577 | type = ACPI_TYPE_LOCAL_INDEX_FIELD; | 580 | type = ACPI_TYPE_LOCAL_INDEX_FIELD; |
578 | break; | 581 | break; |
579 | 582 | ||
580 | default: | 583 | default: |
584 | |||
581 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 585 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
582 | } | 586 | } |
583 | 587 | ||
diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c index bc8e63f7784b..14424200d246 100644 --- a/drivers/acpi/acpica/dsinit.c +++ b/drivers/acpi/acpica/dsinit.c | |||
@@ -127,6 +127,7 @@ acpi_ds_init_one_object(acpi_handle obj_handle, | |||
127 | break; | 127 | break; |
128 | 128 | ||
129 | default: | 129 | default: |
130 | |||
130 | break; | 131 | break; |
131 | } | 132 | } |
132 | 133 | ||
diff --git a/drivers/acpi/acpica/dsmthdat.c b/drivers/acpi/acpica/dsmthdat.c index 3da80460ce38..c4b0b3657237 100644 --- a/drivers/acpi/acpica/dsmthdat.c +++ b/drivers/acpi/acpica/dsmthdat.c | |||
@@ -285,6 +285,7 @@ acpi_ds_method_data_get_node(u8 type, | |||
285 | break; | 285 | break; |
286 | 286 | ||
287 | default: | 287 | default: |
288 | |||
288 | ACPI_ERROR((AE_INFO, "Type %u is invalid", type)); | 289 | ACPI_ERROR((AE_INFO, "Type %u is invalid", type)); |
289 | return_ACPI_STATUS(AE_TYPE); | 290 | return_ACPI_STATUS(AE_TYPE); |
290 | } | 291 | } |
@@ -428,7 +429,6 @@ acpi_ds_method_data_get_value(u8 type, | |||
428 | return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG); | 429 | return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG); |
429 | 430 | ||
430 | case ACPI_REFCLASS_LOCAL: | 431 | case ACPI_REFCLASS_LOCAL: |
431 | |||
432 | /* | 432 | /* |
433 | * No error message for this case, will be trapped again later to | 433 | * No error message for this case, will be trapped again later to |
434 | * detect and ignore cases of Store(local_x,local_x) | 434 | * detect and ignore cases of Store(local_x,local_x) |
diff --git a/drivers/acpi/acpica/dsobject.c b/drivers/acpi/acpica/dsobject.c index e20e9f84eee8..63f0d220ca3d 100644 --- a/drivers/acpi/acpica/dsobject.c +++ b/drivers/acpi/acpica/dsobject.c | |||
@@ -648,7 +648,6 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, | |||
648 | 648 | ||
649 | switch (obj_desc->common.type) { | 649 | switch (obj_desc->common.type) { |
650 | case ACPI_TYPE_BUFFER: | 650 | case ACPI_TYPE_BUFFER: |
651 | |||
652 | /* | 651 | /* |
653 | * Defer evaluation of Buffer term_arg operand | 652 | * Defer evaluation of Buffer term_arg operand |
654 | */ | 653 | */ |
@@ -660,7 +659,6 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, | |||
660 | break; | 659 | break; |
661 | 660 | ||
662 | case ACPI_TYPE_PACKAGE: | 661 | case ACPI_TYPE_PACKAGE: |
663 | |||
664 | /* | 662 | /* |
665 | * Defer evaluation of Package term_arg operand | 663 | * Defer evaluation of Package term_arg operand |
666 | */ | 664 | */ |
@@ -741,6 +739,7 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state, | |||
741 | break; | 739 | break; |
742 | 740 | ||
743 | default: | 741 | default: |
742 | |||
744 | ACPI_ERROR((AE_INFO, "Unknown Integer type 0x%X", | 743 | ACPI_ERROR((AE_INFO, "Unknown Integer type 0x%X", |
745 | op_info->type)); | 744 | op_info->type)); |
746 | status = AE_AML_OPERAND_TYPE; | 745 | status = AE_AML_OPERAND_TYPE; |
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c index ee6367b8eaf7..1fc1ff114f26 100644 --- a/drivers/acpi/acpica/dsopcode.c +++ b/drivers/acpi/acpica/dsopcode.c | |||
@@ -636,6 +636,7 @@ acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state, | |||
636 | break; | 636 | break; |
637 | 637 | ||
638 | default: | 638 | default: |
639 | |||
639 | return_ACPI_STATUS(AE_AML_BAD_OPCODE); | 640 | return_ACPI_STATUS(AE_AML_BAD_OPCODE); |
640 | } | 641 | } |
641 | 642 | ||
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c index 99778997c35a..c666fc014987 100644 --- a/drivers/acpi/acpica/dsutils.c +++ b/drivers/acpi/acpica/dsutils.c | |||
@@ -240,7 +240,6 @@ acpi_ds_is_result_used(union acpi_parse_object * op, | |||
240 | 240 | ||
241 | case AML_IF_OP: | 241 | case AML_IF_OP: |
242 | case AML_WHILE_OP: | 242 | case AML_WHILE_OP: |
243 | |||
244 | /* | 243 | /* |
245 | * If we are executing the predicate AND this is the predicate op, | 244 | * If we are executing the predicate AND this is the predicate op, |
246 | * we will use the return value | 245 | * we will use the return value |
@@ -254,7 +253,9 @@ acpi_ds_is_result_used(union acpi_parse_object * op, | |||
254 | break; | 253 | break; |
255 | 254 | ||
256 | default: | 255 | default: |
256 | |||
257 | /* Ignore other control opcodes */ | 257 | /* Ignore other control opcodes */ |
258 | |||
258 | break; | 259 | break; |
259 | } | 260 | } |
260 | 261 | ||
@@ -263,7 +264,6 @@ acpi_ds_is_result_used(union acpi_parse_object * op, | |||
263 | goto result_not_used; | 264 | goto result_not_used; |
264 | 265 | ||
265 | case AML_CLASS_CREATE: | 266 | case AML_CLASS_CREATE: |
266 | |||
267 | /* | 267 | /* |
268 | * These opcodes allow term_arg(s) as operands and therefore | 268 | * These opcodes allow term_arg(s) as operands and therefore |
269 | * the operands can be method calls. The result is used. | 269 | * the operands can be method calls. The result is used. |
@@ -292,7 +292,6 @@ acpi_ds_is_result_used(union acpi_parse_object * op, | |||
292 | goto result_not_used; | 292 | goto result_not_used; |
293 | 293 | ||
294 | default: | 294 | default: |
295 | |||
296 | /* | 295 | /* |
297 | * In all other cases. the parent will actually use the return | 296 | * In all other cases. the parent will actually use the return |
298 | * object, so keep it. | 297 | * object, so keep it. |
diff --git a/drivers/acpi/acpica/dswexec.c b/drivers/acpi/acpica/dswexec.c index e2199a947470..151d924817e1 100644 --- a/drivers/acpi/acpica/dswexec.c +++ b/drivers/acpi/acpica/dswexec.c | |||
@@ -327,6 +327,7 @@ acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state, | |||
327 | break; | 327 | break; |
328 | 328 | ||
329 | default: | 329 | default: |
330 | |||
330 | break; | 331 | break; |
331 | } | 332 | } |
332 | 333 | ||
@@ -488,7 +489,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) | |||
488 | break; | 489 | break; |
489 | 490 | ||
490 | case AML_TYPE_METHOD_CALL: | 491 | case AML_TYPE_METHOD_CALL: |
491 | |||
492 | /* | 492 | /* |
493 | * If the method is referenced from within a package | 493 | * If the method is referenced from within a package |
494 | * declaration, it is not a invocation of the method, just | 494 | * declaration, it is not a invocation of the method, just |
@@ -582,7 +582,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state) | |||
582 | 582 | ||
583 | switch (op->common.parent->common.aml_opcode) { | 583 | switch (op->common.parent->common.aml_opcode) { |
584 | case AML_NAME_OP: | 584 | case AML_NAME_OP: |
585 | |||
586 | /* | 585 | /* |
587 | * Put the Node on the object stack (Contains the ACPI Name | 586 | * Put the Node on the object stack (Contains the ACPI Name |
588 | * of this object) | 587 | * of this object) |
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c index 6e17c0e24e63..95e681a36f9c 100644 --- a/drivers/acpi/acpica/dswload.c +++ b/drivers/acpi/acpica/dswload.c | |||
@@ -74,6 +74,7 @@ acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number) | |||
74 | 74 | ||
75 | switch (pass_number) { | 75 | switch (pass_number) { |
76 | case 1: | 76 | case 1: |
77 | |||
77 | walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | | 78 | walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | |
78 | ACPI_PARSE_DELETE_TREE; | 79 | ACPI_PARSE_DELETE_TREE; |
79 | walk_state->descending_callback = acpi_ds_load1_begin_op; | 80 | walk_state->descending_callback = acpi_ds_load1_begin_op; |
@@ -81,6 +82,7 @@ acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number) | |||
81 | break; | 82 | break; |
82 | 83 | ||
83 | case 2: | 84 | case 2: |
85 | |||
84 | walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | | 86 | walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | |
85 | ACPI_PARSE_DELETE_TREE; | 87 | ACPI_PARSE_DELETE_TREE; |
86 | walk_state->descending_callback = acpi_ds_load2_begin_op; | 88 | walk_state->descending_callback = acpi_ds_load2_begin_op; |
@@ -88,6 +90,7 @@ acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number) | |||
88 | break; | 90 | break; |
89 | 91 | ||
90 | case 3: | 92 | case 3: |
93 | |||
91 | #ifndef ACPI_NO_METHOD_EXECUTION | 94 | #ifndef ACPI_NO_METHOD_EXECUTION |
92 | walk_state->parse_flags |= ACPI_PARSE_EXECUTE | | 95 | walk_state->parse_flags |= ACPI_PARSE_EXECUTE | |
93 | ACPI_PARSE_DELETE_TREE; | 96 | ACPI_PARSE_DELETE_TREE; |
@@ -97,6 +100,7 @@ acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number) | |||
97 | break; | 100 | break; |
98 | 101 | ||
99 | default: | 102 | default: |
103 | |||
100 | return (AE_BAD_PARAMETER); | 104 | return (AE_BAD_PARAMETER); |
101 | } | 105 | } |
102 | 106 | ||
@@ -161,7 +165,6 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, | |||
161 | 165 | ||
162 | switch (walk_state->opcode) { | 166 | switch (walk_state->opcode) { |
163 | case AML_SCOPE_OP: | 167 | case AML_SCOPE_OP: |
164 | |||
165 | /* | 168 | /* |
166 | * The target name of the Scope() operator must exist at this point so | 169 | * The target name of the Scope() operator must exist at this point so |
167 | * that we can actually open the scope to enter new names underneath it. | 170 | * that we can actually open the scope to enter new names underneath it. |
@@ -210,7 +213,6 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, | |||
210 | case ACPI_TYPE_INTEGER: | 213 | case ACPI_TYPE_INTEGER: |
211 | case ACPI_TYPE_STRING: | 214 | case ACPI_TYPE_STRING: |
212 | case ACPI_TYPE_BUFFER: | 215 | case ACPI_TYPE_BUFFER: |
213 | |||
214 | /* | 216 | /* |
215 | * These types we will allow, but we will change the type. | 217 | * These types we will allow, but we will change the type. |
216 | * This enables some existing code of the form: | 218 | * This enables some existing code of the form: |
@@ -232,7 +234,6 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state, | |||
232 | break; | 234 | break; |
233 | 235 | ||
234 | case ACPI_TYPE_METHOD: | 236 | case ACPI_TYPE_METHOD: |
235 | |||
236 | /* | 237 | /* |
237 | * Allow scope change to root during execution of module-level | 238 | * Allow scope change to root during execution of module-level |
238 | * code. Root is typed METHOD during this time. | 239 | * code. Root is typed METHOD during this time. |
diff --git a/drivers/acpi/acpica/dswload2.c b/drivers/acpi/acpica/dswload2.c index 4407ff2377d5..b1f8f4725c23 100644 --- a/drivers/acpi/acpica/dswload2.c +++ b/drivers/acpi/acpica/dswload2.c | |||
@@ -509,6 +509,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) | |||
509 | break; | 509 | break; |
510 | 510 | ||
511 | default: | 511 | default: |
512 | |||
512 | /* All NAMED_FIELD opcodes must be handled above */ | 513 | /* All NAMED_FIELD opcodes must be handled above */ |
513 | break; | 514 | break; |
514 | } | 515 | } |
@@ -548,6 +549,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) | |||
548 | break; | 549 | break; |
549 | 550 | ||
550 | default: | 551 | default: |
552 | |||
551 | /* Unknown opcode */ | 553 | /* Unknown opcode */ |
552 | 554 | ||
553 | status = AE_OK; | 555 | status = AE_OK; |
@@ -674,6 +676,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) | |||
674 | #endif /* ACPI_NO_METHOD_EXECUTION */ | 676 | #endif /* ACPI_NO_METHOD_EXECUTION */ |
675 | 677 | ||
676 | default: | 678 | default: |
679 | |||
677 | /* All NAMED_COMPLEX opcodes must be handled above */ | 680 | /* All NAMED_COMPLEX opcodes must be handled above */ |
678 | break; | 681 | break; |
679 | } | 682 | } |
@@ -721,6 +724,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state) | |||
721 | break; | 724 | break; |
722 | 725 | ||
723 | default: | 726 | default: |
727 | |||
724 | break; | 728 | break; |
725 | } | 729 | } |
726 | 730 | ||
diff --git a/drivers/acpi/acpica/evglock.c b/drivers/acpi/acpica/evglock.c index a621481c6cf2..fdb0a76e40a3 100644 --- a/drivers/acpi/acpica/evglock.c +++ b/drivers/acpi/acpica/evglock.c | |||
@@ -128,6 +128,7 @@ acpi_status acpi_ev_remove_global_lock_handler(void) | |||
128 | status = acpi_remove_fixed_event_handler(ACPI_EVENT_GLOBAL, | 128 | status = acpi_remove_fixed_event_handler(ACPI_EVENT_GLOBAL, |
129 | acpi_ev_global_lock_handler); | 129 | acpi_ev_global_lock_handler); |
130 | 130 | ||
131 | acpi_os_delete_lock(acpi_gbl_global_lock_pending_lock); | ||
131 | return_ACPI_STATUS(status); | 132 | return_ACPI_STATUS(status); |
132 | } | 133 | } |
133 | 134 | ||
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c index a493b528f8f9..c8a1f7d5931f 100644 --- a/drivers/acpi/acpica/evgpe.c +++ b/drivers/acpi/acpica/evgpe.c | |||
@@ -529,7 +529,6 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context) | |||
529 | 529 | ||
530 | switch (local_gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) { | 530 | switch (local_gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) { |
531 | case ACPI_GPE_DISPATCH_NOTIFY: | 531 | case ACPI_GPE_DISPATCH_NOTIFY: |
532 | |||
533 | /* | 532 | /* |
534 | * Implicit notify. | 533 | * Implicit notify. |
535 | * Dispatch a DEVICE_WAKE notify to the appropriate handler. | 534 | * Dispatch a DEVICE_WAKE notify to the appropriate handler. |
@@ -579,11 +578,11 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context) | |||
579 | (local_gpe_event_info->dispatch. | 578 | (local_gpe_event_info->dispatch. |
580 | method_node))); | 579 | method_node))); |
581 | } | 580 | } |
582 | |||
583 | break; | 581 | break; |
584 | 582 | ||
585 | default: | 583 | default: |
586 | return_VOID; /* Should never happen */ | 584 | |
585 | return_VOID; /* Should never happen */ | ||
587 | } | 586 | } |
588 | 587 | ||
589 | /* Defer enabling of GPE until all notify handlers are done */ | 588 | /* Defer enabling of GPE until all notify handlers are done */ |
@@ -755,7 +754,6 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, | |||
755 | 754 | ||
756 | case ACPI_GPE_DISPATCH_METHOD: | 755 | case ACPI_GPE_DISPATCH_METHOD: |
757 | case ACPI_GPE_DISPATCH_NOTIFY: | 756 | case ACPI_GPE_DISPATCH_NOTIFY: |
758 | |||
759 | /* | 757 | /* |
760 | * Execute the method associated with the GPE | 758 | * Execute the method associated with the GPE |
761 | * NOTE: Level-triggered GPEs are cleared after the method completes. | 759 | * NOTE: Level-triggered GPEs are cleared after the method completes. |
@@ -771,7 +769,6 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, | |||
771 | break; | 769 | break; |
772 | 770 | ||
773 | default: | 771 | default: |
774 | |||
775 | /* | 772 | /* |
776 | * No handler or method to run! | 773 | * No handler or method to run! |
777 | * 03/2010: This case should no longer be possible. We will not allow | 774 | * 03/2010: This case should no longer be possible. We will not allow |
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c index a2d688bbac02..c1aa1eda26c3 100644 --- a/drivers/acpi/acpica/evgpeblk.c +++ b/drivers/acpi/acpica/evgpeblk.c | |||
@@ -382,6 +382,8 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, | |||
382 | 382 | ||
383 | status = acpi_ev_install_gpe_block(gpe_block, interrupt_number); | 383 | status = acpi_ev_install_gpe_block(gpe_block, interrupt_number); |
384 | if (ACPI_FAILURE(status)) { | 384 | if (ACPI_FAILURE(status)) { |
385 | ACPI_FREE(gpe_block->register_info); | ||
386 | ACPI_FREE(gpe_block->event_info); | ||
385 | ACPI_FREE(gpe_block); | 387 | ACPI_FREE(gpe_block); |
386 | return_ACPI_STATUS(status); | 388 | return_ACPI_STATUS(status); |
387 | } | 389 | } |
diff --git a/drivers/acpi/acpica/evgpeinit.c b/drivers/acpi/acpica/evgpeinit.c index 72b8f6b3f4ca..9037f17c9608 100644 --- a/drivers/acpi/acpica/evgpeinit.c +++ b/drivers/acpi/acpica/evgpeinit.c | |||
@@ -363,14 +363,17 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle, | |||
363 | */ | 363 | */ |
364 | switch (name[1]) { | 364 | switch (name[1]) { |
365 | case 'L': | 365 | case 'L': |
366 | |||
366 | type = ACPI_GPE_LEVEL_TRIGGERED; | 367 | type = ACPI_GPE_LEVEL_TRIGGERED; |
367 | break; | 368 | break; |
368 | 369 | ||
369 | case 'E': | 370 | case 'E': |
371 | |||
370 | type = ACPI_GPE_EDGE_TRIGGERED; | 372 | type = ACPI_GPE_EDGE_TRIGGERED; |
371 | break; | 373 | break; |
372 | 374 | ||
373 | default: | 375 | default: |
376 | |||
374 | /* Unknown method type, just ignore it */ | 377 | /* Unknown method type, just ignore it */ |
375 | 378 | ||
376 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, | 379 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, |
diff --git a/drivers/acpi/acpica/evhandler.c b/drivers/acpi/acpica/evhandler.c index d4f83112c2e2..068af96134b8 100644 --- a/drivers/acpi/acpica/evhandler.c +++ b/drivers/acpi/acpica/evhandler.c | |||
@@ -354,36 +354,43 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node, | |||
354 | 354 | ||
355 | switch (space_id) { | 355 | switch (space_id) { |
356 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: | 356 | case ACPI_ADR_SPACE_SYSTEM_MEMORY: |
357 | |||
357 | handler = acpi_ex_system_memory_space_handler; | 358 | handler = acpi_ex_system_memory_space_handler; |
358 | setup = acpi_ev_system_memory_region_setup; | 359 | setup = acpi_ev_system_memory_region_setup; |
359 | break; | 360 | break; |
360 | 361 | ||
361 | case ACPI_ADR_SPACE_SYSTEM_IO: | 362 | case ACPI_ADR_SPACE_SYSTEM_IO: |
363 | |||
362 | handler = acpi_ex_system_io_space_handler; | 364 | handler = acpi_ex_system_io_space_handler; |
363 | setup = acpi_ev_io_space_region_setup; | 365 | setup = acpi_ev_io_space_region_setup; |
364 | break; | 366 | break; |
365 | 367 | ||
366 | case ACPI_ADR_SPACE_PCI_CONFIG: | 368 | case ACPI_ADR_SPACE_PCI_CONFIG: |
369 | |||
367 | handler = acpi_ex_pci_config_space_handler; | 370 | handler = acpi_ex_pci_config_space_handler; |
368 | setup = acpi_ev_pci_config_region_setup; | 371 | setup = acpi_ev_pci_config_region_setup; |
369 | break; | 372 | break; |
370 | 373 | ||
371 | case ACPI_ADR_SPACE_CMOS: | 374 | case ACPI_ADR_SPACE_CMOS: |
375 | |||
372 | handler = acpi_ex_cmos_space_handler; | 376 | handler = acpi_ex_cmos_space_handler; |
373 | setup = acpi_ev_cmos_region_setup; | 377 | setup = acpi_ev_cmos_region_setup; |
374 | break; | 378 | break; |
375 | 379 | ||
376 | case ACPI_ADR_SPACE_PCI_BAR_TARGET: | 380 | case ACPI_ADR_SPACE_PCI_BAR_TARGET: |
381 | |||
377 | handler = acpi_ex_pci_bar_space_handler; | 382 | handler = acpi_ex_pci_bar_space_handler; |
378 | setup = acpi_ev_pci_bar_region_setup; | 383 | setup = acpi_ev_pci_bar_region_setup; |
379 | break; | 384 | break; |
380 | 385 | ||
381 | case ACPI_ADR_SPACE_DATA_TABLE: | 386 | case ACPI_ADR_SPACE_DATA_TABLE: |
387 | |||
382 | handler = acpi_ex_data_table_space_handler; | 388 | handler = acpi_ex_data_table_space_handler; |
383 | setup = NULL; | 389 | setup = NULL; |
384 | break; | 390 | break; |
385 | 391 | ||
386 | default: | 392 | default: |
393 | |||
387 | status = AE_BAD_PARAMETER; | 394 | status = AE_BAD_PARAMETER; |
388 | goto unlock_and_exit; | 395 | goto unlock_and_exit; |
389 | } | 396 | } |
diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c index c986b2336b81..1b111ef74903 100644 --- a/drivers/acpi/acpica/evmisc.c +++ b/drivers/acpi/acpica/evmisc.c | |||
@@ -78,6 +78,7 @@ u8 acpi_ev_is_notify_object(struct acpi_namespace_node *node) | |||
78 | return (TRUE); | 78 | return (TRUE); |
79 | 79 | ||
80 | default: | 80 | default: |
81 | |||
81 | return (FALSE); | 82 | return (FALSE); |
82 | } | 83 | } |
83 | } | 84 | } |
@@ -275,6 +276,8 @@ void acpi_ev_terminate(void) | |||
275 | ACPI_ERROR((AE_INFO, | 276 | ACPI_ERROR((AE_INFO, |
276 | "Could not remove Global Lock handler")); | 277 | "Could not remove Global Lock handler")); |
277 | } | 278 | } |
279 | |||
280 | acpi_gbl_events_initialized = FALSE; | ||
278 | } | 281 | } |
279 | 282 | ||
280 | /* Deallocate all handler objects installed within GPE info structs */ | 283 | /* Deallocate all handler objects installed within GPE info structs */ |
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c index 6555e350fc1f..cea14d6fc76c 100644 --- a/drivers/acpi/acpica/evregion.c +++ b/drivers/acpi/acpica/evregion.c | |||
@@ -54,7 +54,8 @@ extern u8 acpi_gbl_default_address_spaces[]; | |||
54 | 54 | ||
55 | /* Local prototypes */ | 55 | /* Local prototypes */ |
56 | 56 | ||
57 | static void acpi_ev_orphan_ec_reg_method(void); | 57 | static void |
58 | acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node *ec_device_node); | ||
58 | 59 | ||
59 | static acpi_status | 60 | static acpi_status |
60 | acpi_ev_reg_run(acpi_handle obj_handle, | 61 | acpi_ev_reg_run(acpi_handle obj_handle, |
@@ -532,7 +533,7 @@ acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function) | |||
532 | } | 533 | } |
533 | 534 | ||
534 | info->prefix_node = region_obj2->extra.method_REG; | 535 | info->prefix_node = region_obj2->extra.method_REG; |
535 | info->pathname = NULL; | 536 | info->relative_pathname = NULL; |
536 | info->parameters = args; | 537 | info->parameters = args; |
537 | info->flags = ACPI_IGNORE_RETURN_VALUE; | 538 | info->flags = ACPI_IGNORE_RETURN_VALUE; |
538 | 539 | ||
@@ -612,7 +613,7 @@ acpi_ev_execute_reg_methods(struct acpi_namespace_node *node, | |||
612 | /* Special case for EC: handle "orphan" _REG methods with no region */ | 613 | /* Special case for EC: handle "orphan" _REG methods with no region */ |
613 | 614 | ||
614 | if (space_id == ACPI_ADR_SPACE_EC) { | 615 | if (space_id == ACPI_ADR_SPACE_EC) { |
615 | acpi_ev_orphan_ec_reg_method(); | 616 | acpi_ev_orphan_ec_reg_method(node); |
616 | } | 617 | } |
617 | 618 | ||
618 | return_ACPI_STATUS(status); | 619 | return_ACPI_STATUS(status); |
@@ -681,7 +682,7 @@ acpi_ev_reg_run(acpi_handle obj_handle, | |||
681 | * | 682 | * |
682 | * FUNCTION: acpi_ev_orphan_ec_reg_method | 683 | * FUNCTION: acpi_ev_orphan_ec_reg_method |
683 | * | 684 | * |
684 | * PARAMETERS: None | 685 | * PARAMETERS: ec_device_node - Namespace node for an EC device |
685 | * | 686 | * |
686 | * RETURN: None | 687 | * RETURN: None |
687 | * | 688 | * |
@@ -693,37 +694,27 @@ acpi_ev_reg_run(acpi_handle obj_handle, | |||
693 | * detected by providing a _REG method object underneath the | 694 | * detected by providing a _REG method object underneath the |
694 | * Embedded Controller device." | 695 | * Embedded Controller device." |
695 | * | 696 | * |
696 | * To quickly access the EC device, we use the EC_ID that appears | 697 | * To quickly access the EC device, we use the ec_device_node used |
697 | * within the ECDT. Otherwise, we would need to perform a time- | 698 | * during EC handler installation. Otherwise, we would need to |
698 | * consuming namespace walk, executing _HID methods to find the | 699 | * perform a time consuming namespace walk, executing _HID |
699 | * EC device. | 700 | * methods to find the EC device. |
701 | * | ||
702 | * MUTEX: Assumes the namespace is locked | ||
700 | * | 703 | * |
701 | ******************************************************************************/ | 704 | ******************************************************************************/ |
702 | 705 | ||
703 | static void acpi_ev_orphan_ec_reg_method(void) | 706 | static void |
707 | acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node *ec_device_node) | ||
704 | { | 708 | { |
705 | struct acpi_table_ecdt *table; | 709 | acpi_handle reg_method; |
710 | struct acpi_namespace_node *next_node; | ||
706 | acpi_status status; | 711 | acpi_status status; |
707 | struct acpi_object_list args; | 712 | struct acpi_object_list args; |
708 | union acpi_object objects[2]; | 713 | union acpi_object objects[2]; |
709 | struct acpi_namespace_node *ec_device_node; | ||
710 | struct acpi_namespace_node *reg_method; | ||
711 | struct acpi_namespace_node *next_node; | ||
712 | 714 | ||
713 | ACPI_FUNCTION_TRACE(ev_orphan_ec_reg_method); | 715 | ACPI_FUNCTION_TRACE(ev_orphan_ec_reg_method); |
714 | 716 | ||
715 | /* Get the ECDT (if present in system) */ | 717 | if (!ec_device_node) { |
716 | |||
717 | status = acpi_get_table(ACPI_SIG_ECDT, 0, | ||
718 | ACPI_CAST_INDIRECT_PTR(struct acpi_table_header, | ||
719 | &table)); | ||
720 | if (ACPI_FAILURE(status)) { | ||
721 | return_VOID; | ||
722 | } | ||
723 | |||
724 | /* We need a valid EC_ID string */ | ||
725 | |||
726 | if (!(*table->id)) { | ||
727 | return_VOID; | 718 | return_VOID; |
728 | } | 719 | } |
729 | 720 | ||
@@ -731,22 +722,11 @@ static void acpi_ev_orphan_ec_reg_method(void) | |||
731 | 722 | ||
732 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | 723 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
733 | 724 | ||
734 | /* Get a handle to the EC device referenced in the ECDT */ | ||
735 | |||
736 | status = acpi_get_handle(NULL, | ||
737 | ACPI_CAST_PTR(char, table->id), | ||
738 | ACPI_CAST_PTR(acpi_handle, &ec_device_node)); | ||
739 | if (ACPI_FAILURE(status)) { | ||
740 | goto exit; | ||
741 | } | ||
742 | |||
743 | /* Get a handle to a _REG method immediately under the EC device */ | 725 | /* Get a handle to a _REG method immediately under the EC device */ |
744 | 726 | ||
745 | status = acpi_get_handle(ec_device_node, | 727 | status = acpi_get_handle(ec_device_node, METHOD_NAME__REG, ®_method); |
746 | METHOD_NAME__REG, ACPI_CAST_PTR(acpi_handle, | ||
747 | ®_method)); | ||
748 | if (ACPI_FAILURE(status)) { | 728 | if (ACPI_FAILURE(status)) { |
749 | goto exit; | 729 | goto exit; /* There is no _REG method present */ |
750 | } | 730 | } |
751 | 731 | ||
752 | /* | 732 | /* |
@@ -754,19 +734,20 @@ static void acpi_ev_orphan_ec_reg_method(void) | |||
754 | * this scope with the Embedded Controller space ID. Otherwise, it | 734 | * this scope with the Embedded Controller space ID. Otherwise, it |
755 | * will already have been executed. Note, this allows for Regions | 735 | * will already have been executed. Note, this allows for Regions |
756 | * with other space IDs to be present; but the code below will then | 736 | * with other space IDs to be present; but the code below will then |
757 | * execute the _REG method with the EC space ID argument. | 737 | * execute the _REG method with the embedded_control space_ID argument. |
758 | */ | 738 | */ |
759 | next_node = acpi_ns_get_next_node(ec_device_node, NULL); | 739 | next_node = acpi_ns_get_next_node(ec_device_node, NULL); |
760 | while (next_node) { | 740 | while (next_node) { |
761 | if ((next_node->type == ACPI_TYPE_REGION) && | 741 | if ((next_node->type == ACPI_TYPE_REGION) && |
762 | (next_node->object) && | 742 | (next_node->object) && |
763 | (next_node->object->region.space_id == ACPI_ADR_SPACE_EC)) { | 743 | (next_node->object->region.space_id == ACPI_ADR_SPACE_EC)) { |
764 | goto exit; /* Do not execute _REG */ | 744 | goto exit; /* Do not execute the _REG */ |
765 | } | 745 | } |
746 | |||
766 | next_node = acpi_ns_get_next_node(ec_device_node, next_node); | 747 | next_node = acpi_ns_get_next_node(ec_device_node, next_node); |
767 | } | 748 | } |
768 | 749 | ||
769 | /* Evaluate the _REG(EC,Connect) method */ | 750 | /* Evaluate the _REG(embedded_control,Connect) method */ |
770 | 751 | ||
771 | args.count = 2; | 752 | args.count = 2; |
772 | args.pointer = objects; | 753 | args.pointer = objects; |
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c index 3bb616794b3b..8354c4f7f10c 100644 --- a/drivers/acpi/acpica/evrgnini.c +++ b/drivers/acpi/acpica/evrgnini.c | |||
@@ -596,7 +596,9 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj, | |||
596 | break; | 596 | break; |
597 | 597 | ||
598 | default: | 598 | default: |
599 | |||
599 | /* Ignore other objects */ | 600 | /* Ignore other objects */ |
601 | |||
600 | break; | 602 | break; |
601 | } | 603 | } |
602 | 604 | ||
diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c index aff4cc261211..7662f1a42ff6 100644 --- a/drivers/acpi/acpica/evxfgpe.c +++ b/drivers/acpi/acpica/evxfgpe.c | |||
@@ -366,16 +366,19 @@ acpi_set_gpe_wake_mask(acpi_handle gpe_device, u32 gpe_number, u8 action) | |||
366 | 366 | ||
367 | switch (action) { | 367 | switch (action) { |
368 | case ACPI_GPE_ENABLE: | 368 | case ACPI_GPE_ENABLE: |
369 | |||
369 | ACPI_SET_BIT(gpe_register_info->enable_for_wake, | 370 | ACPI_SET_BIT(gpe_register_info->enable_for_wake, |
370 | (u8)register_bit); | 371 | (u8)register_bit); |
371 | break; | 372 | break; |
372 | 373 | ||
373 | case ACPI_GPE_DISABLE: | 374 | case ACPI_GPE_DISABLE: |
375 | |||
374 | ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake, | 376 | ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake, |
375 | (u8)register_bit); | 377 | (u8)register_bit); |
376 | break; | 378 | break; |
377 | 379 | ||
378 | default: | 380 | default: |
381 | |||
379 | ACPI_ERROR((AE_INFO, "%u, Invalid action", action)); | 382 | ACPI_ERROR((AE_INFO, "%u, Invalid action", action)); |
380 | status = AE_BAD_PARAMETER; | 383 | status = AE_BAD_PARAMETER; |
381 | break; | 384 | break; |
diff --git a/drivers/acpi/acpica/evxfregn.c b/drivers/acpi/acpica/evxfregn.c index 96c9e5f355ae..80cecf838591 100644 --- a/drivers/acpi/acpica/evxfregn.c +++ b/drivers/acpi/acpica/evxfregn.c | |||
@@ -139,6 +139,7 @@ acpi_install_address_space_handler(acpi_handle device, | |||
139 | break; | 139 | break; |
140 | 140 | ||
141 | default: | 141 | default: |
142 | |||
142 | break; | 143 | break; |
143 | } | 144 | } |
144 | 145 | ||
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c index d93b70be60ad..06d216c8d43a 100644 --- a/drivers/acpi/acpica/exconfig.c +++ b/drivers/acpi/acpica/exconfig.c | |||
@@ -480,6 +480,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc, | |||
480 | break; | 480 | break; |
481 | 481 | ||
482 | default: | 482 | default: |
483 | |||
483 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); | 484 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
484 | } | 485 | } |
485 | 486 | ||
@@ -588,7 +589,7 @@ acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle) | |||
588 | (ACPI_GET_DESCRIPTOR_TYPE(ddb_handle) != ACPI_DESC_TYPE_OPERAND) || | 589 | (ACPI_GET_DESCRIPTOR_TYPE(ddb_handle) != ACPI_DESC_TYPE_OPERAND) || |
589 | (ddb_handle->common.type != ACPI_TYPE_LOCAL_REFERENCE) || | 590 | (ddb_handle->common.type != ACPI_TYPE_LOCAL_REFERENCE) || |
590 | (!(ddb_handle->common.flags & AOPOBJ_DATA_VALID))) { | 591 | (!(ddb_handle->common.flags & AOPOBJ_DATA_VALID))) { |
591 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 592 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
592 | } | 593 | } |
593 | 594 | ||
594 | /* Get the table index from the ddb_handle */ | 595 | /* Get the table index from the ddb_handle */ |
diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c index d2b9613bbf01..69e4a8cc9b71 100644 --- a/drivers/acpi/acpica/exconvrt.c +++ b/drivers/acpi/acpica/exconvrt.c | |||
@@ -99,6 +99,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc, | |||
99 | break; | 99 | break; |
100 | 100 | ||
101 | default: | 101 | default: |
102 | |||
102 | return_ACPI_STATUS(AE_TYPE); | 103 | return_ACPI_STATUS(AE_TYPE); |
103 | } | 104 | } |
104 | 105 | ||
@@ -117,7 +118,6 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc, | |||
117 | 118 | ||
118 | switch (obj_desc->common.type) { | 119 | switch (obj_desc->common.type) { |
119 | case ACPI_TYPE_STRING: | 120 | case ACPI_TYPE_STRING: |
120 | |||
121 | /* | 121 | /* |
122 | * Convert string to an integer - for most cases, the string must be | 122 | * Convert string to an integer - for most cases, the string must be |
123 | * hexadecimal as per the ACPI specification. The only exception (as | 123 | * hexadecimal as per the ACPI specification. The only exception (as |
@@ -161,6 +161,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc, | |||
161 | default: | 161 | default: |
162 | 162 | ||
163 | /* No other types can get here */ | 163 | /* No other types can get here */ |
164 | |||
164 | break; | 165 | break; |
165 | } | 166 | } |
166 | 167 | ||
@@ -213,7 +214,6 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc, | |||
213 | return_ACPI_STATUS(AE_OK); | 214 | return_ACPI_STATUS(AE_OK); |
214 | 215 | ||
215 | case ACPI_TYPE_INTEGER: | 216 | case ACPI_TYPE_INTEGER: |
216 | |||
217 | /* | 217 | /* |
218 | * Create a new Buffer object. | 218 | * Create a new Buffer object. |
219 | * Need enough space for one integer | 219 | * Need enough space for one integer |
@@ -233,7 +233,6 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc, | |||
233 | break; | 233 | break; |
234 | 234 | ||
235 | case ACPI_TYPE_STRING: | 235 | case ACPI_TYPE_STRING: |
236 | |||
237 | /* | 236 | /* |
238 | * Create a new Buffer object | 237 | * Create a new Buffer object |
239 | * Size will be the string length | 238 | * Size will be the string length |
@@ -258,6 +257,7 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc, | |||
258 | break; | 257 | break; |
259 | 258 | ||
260 | default: | 259 | default: |
260 | |||
261 | return_ACPI_STATUS(AE_TYPE); | 261 | return_ACPI_STATUS(AE_TYPE); |
262 | } | 262 | } |
263 | 263 | ||
@@ -304,15 +304,18 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width) | |||
304 | 304 | ||
305 | switch (data_width) { | 305 | switch (data_width) { |
306 | case 1: | 306 | case 1: |
307 | |||
307 | decimal_length = ACPI_MAX8_DECIMAL_DIGITS; | 308 | decimal_length = ACPI_MAX8_DECIMAL_DIGITS; |
308 | break; | 309 | break; |
309 | 310 | ||
310 | case 4: | 311 | case 4: |
312 | |||
311 | decimal_length = ACPI_MAX32_DECIMAL_DIGITS; | 313 | decimal_length = ACPI_MAX32_DECIMAL_DIGITS; |
312 | break; | 314 | break; |
313 | 315 | ||
314 | case 8: | 316 | case 8: |
315 | default: | 317 | default: |
318 | |||
316 | decimal_length = ACPI_MAX64_DECIMAL_DIGITS; | 319 | decimal_length = ACPI_MAX64_DECIMAL_DIGITS; |
317 | break; | 320 | break; |
318 | } | 321 | } |
@@ -546,6 +549,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, | |||
546 | break; | 549 | break; |
547 | 550 | ||
548 | default: | 551 | default: |
552 | |||
549 | return_ACPI_STATUS(AE_TYPE); | 553 | return_ACPI_STATUS(AE_TYPE); |
550 | } | 554 | } |
551 | 555 | ||
@@ -599,6 +603,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type, | |||
599 | break; | 603 | break; |
600 | 604 | ||
601 | default: | 605 | default: |
606 | |||
602 | /* No conversion allowed for these types */ | 607 | /* No conversion allowed for these types */ |
603 | 608 | ||
604 | if (destination_type != source_desc->common.type) { | 609 | if (destination_type != source_desc->common.type) { |
@@ -649,6 +654,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type, | |||
649 | break; | 654 | break; |
650 | 655 | ||
651 | default: | 656 | default: |
657 | |||
652 | ACPI_ERROR((AE_INFO, | 658 | ACPI_ERROR((AE_INFO, |
653 | "Bad destination type during conversion: 0x%X", | 659 | "Bad destination type during conversion: 0x%X", |
654 | destination_type)); | 660 | destination_type)); |
@@ -664,6 +670,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type, | |||
664 | break; | 670 | break; |
665 | 671 | ||
666 | default: | 672 | default: |
673 | |||
667 | ACPI_ERROR((AE_INFO, | 674 | ACPI_ERROR((AE_INFO, |
668 | "Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s", | 675 | "Unknown Target type ID 0x%X AmlOpcode 0x%X DestType %s", |
669 | GET_CURRENT_ARG_TYPE(walk_state->op_info-> | 676 | GET_CURRENT_ARG_TYPE(walk_state->op_info-> |
diff --git a/drivers/acpi/acpica/excreate.c b/drivers/acpi/acpica/excreate.c index 26a13f67977e..269e81d86ef4 100644 --- a/drivers/acpi/acpica/excreate.c +++ b/drivers/acpi/acpica/excreate.c | |||
@@ -103,7 +103,6 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state) | |||
103 | case ACPI_TYPE_BUFFER: | 103 | case ACPI_TYPE_BUFFER: |
104 | case ACPI_TYPE_PACKAGE: | 104 | case ACPI_TYPE_PACKAGE: |
105 | case ACPI_TYPE_BUFFER_FIELD: | 105 | case ACPI_TYPE_BUFFER_FIELD: |
106 | |||
107 | /* | 106 | /* |
108 | * These types open a new scope, so we need the NS node in order to access | 107 | * These types open a new scope, so we need the NS node in order to access |
109 | * any children. | 108 | * any children. |
@@ -113,7 +112,6 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state) | |||
113 | case ACPI_TYPE_PROCESSOR: | 112 | case ACPI_TYPE_PROCESSOR: |
114 | case ACPI_TYPE_THERMAL: | 113 | case ACPI_TYPE_THERMAL: |
115 | case ACPI_TYPE_LOCAL_SCOPE: | 114 | case ACPI_TYPE_LOCAL_SCOPE: |
116 | |||
117 | /* | 115 | /* |
118 | * The new alias has the type ALIAS and points to the original | 116 | * The new alias has the type ALIAS and points to the original |
119 | * NS node, not the object itself. | 117 | * NS node, not the object itself. |
@@ -124,7 +122,6 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state) | |||
124 | break; | 122 | break; |
125 | 123 | ||
126 | case ACPI_TYPE_METHOD: | 124 | case ACPI_TYPE_METHOD: |
127 | |||
128 | /* | 125 | /* |
129 | * Control method aliases need to be differentiated | 126 | * Control method aliases need to be differentiated |
130 | */ | 127 | */ |
diff --git a/drivers/acpi/acpica/exdebug.c b/drivers/acpi/acpica/exdebug.c index 7eb853cd279f..81c72a4ecd82 100644 --- a/drivers/acpi/acpica/exdebug.c +++ b/drivers/acpi/acpica/exdebug.c | |||
@@ -193,6 +193,7 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc, | |||
193 | return_VOID; | 193 | return_VOID; |
194 | 194 | ||
195 | default: | 195 | default: |
196 | |||
196 | break; | 197 | break; |
197 | } | 198 | } |
198 | 199 | ||
@@ -226,6 +227,7 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc, | |||
226 | break; | 227 | break; |
227 | 228 | ||
228 | default: | 229 | default: |
230 | |||
229 | acpi_ex_do_debug_object((source_desc-> | 231 | acpi_ex_do_debug_object((source_desc-> |
230 | reference. | 232 | reference. |
231 | node)->object, | 233 | node)->object, |
diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c index e5a3c249f7fa..c740f24e3101 100644 --- a/drivers/acpi/acpica/exdump.c +++ b/drivers/acpi/acpica/exdump.c | |||
@@ -357,6 +357,7 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc, | |||
357 | 357 | ||
358 | switch (info->opcode) { | 358 | switch (info->opcode) { |
359 | case ACPI_EXD_INIT: | 359 | case ACPI_EXD_INIT: |
360 | |||
360 | break; | 361 | break; |
361 | 362 | ||
362 | case ACPI_EXD_TYPE: | 363 | case ACPI_EXD_TYPE: |
@@ -718,6 +719,7 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth) | |||
718 | break; | 719 | break; |
719 | 720 | ||
720 | default: | 721 | default: |
722 | |||
721 | /* Unknown Type */ | 723 | /* Unknown Type */ |
722 | 724 | ||
723 | acpi_os_printf("Unknown Type %X\n", obj_desc->common.type); | 725 | acpi_os_printf("Unknown Type %X\n", obj_desc->common.type); |
diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c index 7d4bae71e8c6..c2a65aaf29af 100644 --- a/drivers/acpi/acpica/exfield.c +++ b/drivers/acpi/acpica/exfield.c | |||
@@ -331,21 +331,25 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc, | |||
331 | 331 | ||
332 | switch (source_desc->common.type) { | 332 | switch (source_desc->common.type) { |
333 | case ACPI_TYPE_INTEGER: | 333 | case ACPI_TYPE_INTEGER: |
334 | |||
334 | buffer = &source_desc->integer.value; | 335 | buffer = &source_desc->integer.value; |
335 | length = sizeof(source_desc->integer.value); | 336 | length = sizeof(source_desc->integer.value); |
336 | break; | 337 | break; |
337 | 338 | ||
338 | case ACPI_TYPE_BUFFER: | 339 | case ACPI_TYPE_BUFFER: |
340 | |||
339 | buffer = source_desc->buffer.pointer; | 341 | buffer = source_desc->buffer.pointer; |
340 | length = source_desc->buffer.length; | 342 | length = source_desc->buffer.length; |
341 | break; | 343 | break; |
342 | 344 | ||
343 | case ACPI_TYPE_STRING: | 345 | case ACPI_TYPE_STRING: |
346 | |||
344 | buffer = source_desc->string.pointer; | 347 | buffer = source_desc->string.pointer; |
345 | length = source_desc->string.length; | 348 | length = source_desc->string.length; |
346 | break; | 349 | break; |
347 | 350 | ||
348 | default: | 351 | default: |
352 | |||
349 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); | 353 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
350 | } | 354 | } |
351 | 355 | ||
diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c index c84ee956fa4c..7e0afe72487e 100644 --- a/drivers/acpi/acpica/exfldio.c +++ b/drivers/acpi/acpica/exfldio.c | |||
@@ -446,7 +446,6 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc, | |||
446 | break; | 446 | break; |
447 | 447 | ||
448 | case ACPI_TYPE_LOCAL_BANK_FIELD: | 448 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
449 | |||
450 | /* | 449 | /* |
451 | * Ensure that the bank_value is not beyond the capacity of | 450 | * Ensure that the bank_value is not beyond the capacity of |
452 | * the register | 451 | * the register |
@@ -488,7 +487,6 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc, | |||
488 | break; | 487 | break; |
489 | 488 | ||
490 | case ACPI_TYPE_LOCAL_INDEX_FIELD: | 489 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
491 | |||
492 | /* | 490 | /* |
493 | * Ensure that the index_value is not beyond the capacity of | 491 | * Ensure that the index_value is not beyond the capacity of |
494 | * the register | 492 | * the register |
diff --git a/drivers/acpi/acpica/exmisc.c b/drivers/acpi/acpica/exmisc.c index 72a2a13b6d36..00bf29877574 100644 --- a/drivers/acpi/acpica/exmisc.c +++ b/drivers/acpi/acpica/exmisc.c | |||
@@ -105,7 +105,6 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc, | |||
105 | break; | 105 | break; |
106 | 106 | ||
107 | case ACPI_DESC_TYPE_NAMED: | 107 | case ACPI_DESC_TYPE_NAMED: |
108 | |||
109 | /* | 108 | /* |
110 | * A named reference that has already been resolved to a Node | 109 | * A named reference that has already been resolved to a Node |
111 | */ | 110 | */ |
@@ -261,20 +260,24 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0, | |||
261 | */ | 260 | */ |
262 | switch (operand0->common.type) { | 261 | switch (operand0->common.type) { |
263 | case ACPI_TYPE_INTEGER: | 262 | case ACPI_TYPE_INTEGER: |
263 | |||
264 | status = | 264 | status = |
265 | acpi_ex_convert_to_integer(operand1, &local_operand1, 16); | 265 | acpi_ex_convert_to_integer(operand1, &local_operand1, 16); |
266 | break; | 266 | break; |
267 | 267 | ||
268 | case ACPI_TYPE_STRING: | 268 | case ACPI_TYPE_STRING: |
269 | |||
269 | status = acpi_ex_convert_to_string(operand1, &local_operand1, | 270 | status = acpi_ex_convert_to_string(operand1, &local_operand1, |
270 | ACPI_IMPLICIT_CONVERT_HEX); | 271 | ACPI_IMPLICIT_CONVERT_HEX); |
271 | break; | 272 | break; |
272 | 273 | ||
273 | case ACPI_TYPE_BUFFER: | 274 | case ACPI_TYPE_BUFFER: |
275 | |||
274 | status = acpi_ex_convert_to_buffer(operand1, &local_operand1); | 276 | status = acpi_ex_convert_to_buffer(operand1, &local_operand1); |
275 | break; | 277 | break; |
276 | 278 | ||
277 | default: | 279 | default: |
280 | |||
278 | ACPI_ERROR((AE_INFO, "Invalid object type: 0x%X", | 281 | ACPI_ERROR((AE_INFO, "Invalid object type: 0x%X", |
279 | operand0->common.type)); | 282 | operand0->common.type)); |
280 | status = AE_AML_INTERNAL; | 283 | status = AE_AML_INTERNAL; |
@@ -519,6 +522,7 @@ acpi_ex_do_logical_numeric_op(u16 opcode, | |||
519 | break; | 522 | break; |
520 | 523 | ||
521 | default: | 524 | default: |
525 | |||
522 | status = AE_AML_INTERNAL; | 526 | status = AE_AML_INTERNAL; |
523 | break; | 527 | break; |
524 | } | 528 | } |
@@ -580,20 +584,24 @@ acpi_ex_do_logical_op(u16 opcode, | |||
580 | */ | 584 | */ |
581 | switch (operand0->common.type) { | 585 | switch (operand0->common.type) { |
582 | case ACPI_TYPE_INTEGER: | 586 | case ACPI_TYPE_INTEGER: |
587 | |||
583 | status = | 588 | status = |
584 | acpi_ex_convert_to_integer(operand1, &local_operand1, 16); | 589 | acpi_ex_convert_to_integer(operand1, &local_operand1, 16); |
585 | break; | 590 | break; |
586 | 591 | ||
587 | case ACPI_TYPE_STRING: | 592 | case ACPI_TYPE_STRING: |
593 | |||
588 | status = acpi_ex_convert_to_string(operand1, &local_operand1, | 594 | status = acpi_ex_convert_to_string(operand1, &local_operand1, |
589 | ACPI_IMPLICIT_CONVERT_HEX); | 595 | ACPI_IMPLICIT_CONVERT_HEX); |
590 | break; | 596 | break; |
591 | 597 | ||
592 | case ACPI_TYPE_BUFFER: | 598 | case ACPI_TYPE_BUFFER: |
599 | |||
593 | status = acpi_ex_convert_to_buffer(operand1, &local_operand1); | 600 | status = acpi_ex_convert_to_buffer(operand1, &local_operand1); |
594 | break; | 601 | break; |
595 | 602 | ||
596 | default: | 603 | default: |
604 | |||
597 | status = AE_AML_INTERNAL; | 605 | status = AE_AML_INTERNAL; |
598 | break; | 606 | break; |
599 | } | 607 | } |
@@ -636,6 +644,7 @@ acpi_ex_do_logical_op(u16 opcode, | |||
636 | break; | 644 | break; |
637 | 645 | ||
638 | default: | 646 | default: |
647 | |||
639 | status = AE_AML_INTERNAL; | 648 | status = AE_AML_INTERNAL; |
640 | break; | 649 | break; |
641 | } | 650 | } |
@@ -703,6 +712,7 @@ acpi_ex_do_logical_op(u16 opcode, | |||
703 | break; | 712 | break; |
704 | 713 | ||
705 | default: | 714 | default: |
715 | |||
706 | status = AE_AML_INTERNAL; | 716 | status = AE_AML_INTERNAL; |
707 | break; | 717 | break; |
708 | } | 718 | } |
diff --git a/drivers/acpi/acpica/exoparg1.c b/drivers/acpi/acpica/exoparg1.c index b60c877f5906..814b4a3d656a 100644 --- a/drivers/acpi/acpica/exoparg1.c +++ b/drivers/acpi/acpica/exoparg1.c | |||
@@ -327,7 +327,6 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state) | |||
327 | break; | 327 | break; |
328 | 328 | ||
329 | case AML_FROM_BCD_OP: /* from_bcd (BCDValue, Result) */ | 329 | case AML_FROM_BCD_OP: /* from_bcd (BCDValue, Result) */ |
330 | |||
331 | /* | 330 | /* |
332 | * The 64-bit ACPI integer can hold 16 4-bit BCD characters | 331 | * The 64-bit ACPI integer can hold 16 4-bit BCD characters |
333 | * (if table is 32-bit, integer can hold 8 BCD characters) | 332 | * (if table is 32-bit, integer can hold 8 BCD characters) |
@@ -407,7 +406,6 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state) | |||
407 | break; | 406 | break; |
408 | 407 | ||
409 | case AML_COND_REF_OF_OP: /* cond_ref_of (source_object, Result) */ | 408 | case AML_COND_REF_OF_OP: /* cond_ref_of (source_object, Result) */ |
410 | |||
411 | /* | 409 | /* |
412 | * This op is a little strange because the internal return value is | 410 | * This op is a little strange because the internal return value is |
413 | * different than the return value stored in the result descriptor | 411 | * different than the return value stored in the result descriptor |
@@ -442,13 +440,14 @@ acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state) | |||
442 | goto cleanup; | 440 | goto cleanup; |
443 | 441 | ||
444 | default: | 442 | default: |
443 | |||
445 | /* No other opcodes get here */ | 444 | /* No other opcodes get here */ |
445 | |||
446 | break; | 446 | break; |
447 | } | 447 | } |
448 | break; | 448 | break; |
449 | 449 | ||
450 | case AML_STORE_OP: /* Store (Source, Target) */ | 450 | case AML_STORE_OP: /* Store (Source, Target) */ |
451 | |||
452 | /* | 451 | /* |
453 | * A store operand is typically a number, string, buffer or lvalue | 452 | * A store operand is typically a number, string, buffer or lvalue |
454 | * Be careful about deleting the source object, | 453 | * Be careful about deleting the source object, |
@@ -615,7 +614,6 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
615 | 614 | ||
616 | case AML_DECREMENT_OP: /* Decrement (Operand) */ | 615 | case AML_DECREMENT_OP: /* Decrement (Operand) */ |
617 | case AML_INCREMENT_OP: /* Increment (Operand) */ | 616 | case AML_INCREMENT_OP: /* Increment (Operand) */ |
618 | |||
619 | /* | 617 | /* |
620 | * Create a new integer. Can't just get the base integer and | 618 | * Create a new integer. Can't just get the base integer and |
621 | * increment it because it may be an Arg or Field. | 619 | * increment it because it may be an Arg or Field. |
@@ -682,7 +680,6 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
682 | break; | 680 | break; |
683 | 681 | ||
684 | case AML_TYPE_OP: /* object_type (source_object) */ | 682 | case AML_TYPE_OP: /* object_type (source_object) */ |
685 | |||
686 | /* | 683 | /* |
687 | * Note: The operand is not resolved at this point because we want to | 684 | * Note: The operand is not resolved at this point because we want to |
688 | * get the associated object, not its value. For example, we don't | 685 | * get the associated object, not its value. For example, we don't |
@@ -709,7 +706,6 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
709 | break; | 706 | break; |
710 | 707 | ||
711 | case AML_SIZE_OF_OP: /* size_of (source_object) */ | 708 | case AML_SIZE_OF_OP: /* size_of (source_object) */ |
712 | |||
713 | /* | 709 | /* |
714 | * Note: The operand is not resolved at this point because we want to | 710 | * Note: The operand is not resolved at this point because we want to |
715 | * get the associated object, not its value. | 711 | * get the associated object, not its value. |
@@ -735,10 +731,12 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
735 | */ | 731 | */ |
736 | switch (type) { | 732 | switch (type) { |
737 | case ACPI_TYPE_INTEGER: | 733 | case ACPI_TYPE_INTEGER: |
734 | |||
738 | value = acpi_gbl_integer_byte_width; | 735 | value = acpi_gbl_integer_byte_width; |
739 | break; | 736 | break; |
740 | 737 | ||
741 | case ACPI_TYPE_STRING: | 738 | case ACPI_TYPE_STRING: |
739 | |||
742 | value = temp_desc->string.length; | 740 | value = temp_desc->string.length; |
743 | break; | 741 | break; |
744 | 742 | ||
@@ -759,6 +757,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
759 | break; | 757 | break; |
760 | 758 | ||
761 | default: | 759 | default: |
760 | |||
762 | ACPI_ERROR((AE_INFO, | 761 | ACPI_ERROR((AE_INFO, |
763 | "Operand must be Buffer/Integer/String/Package - found type %s", | 762 | "Operand must be Buffer/Integer/String/Package - found type %s", |
764 | acpi_ut_get_type_name(type))); | 763 | acpi_ut_get_type_name(type))); |
@@ -860,9 +859,11 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
860 | break; | 859 | break; |
861 | 860 | ||
862 | case ACPI_TYPE_STRING: | 861 | case ACPI_TYPE_STRING: |
862 | |||
863 | break; | 863 | break; |
864 | 864 | ||
865 | default: | 865 | default: |
866 | |||
866 | status = AE_AML_OPERAND_TYPE; | 867 | status = AE_AML_OPERAND_TYPE; |
867 | goto cleanup; | 868 | goto cleanup; |
868 | } | 869 | } |
@@ -923,7 +924,6 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
923 | */ | 924 | */ |
924 | switch (operand[0]->reference.class) { | 925 | switch (operand[0]->reference.class) { |
925 | case ACPI_REFCLASS_INDEX: | 926 | case ACPI_REFCLASS_INDEX: |
926 | |||
927 | /* | 927 | /* |
928 | * The target type for the Index operator must be | 928 | * The target type for the Index operator must be |
929 | * either a Buffer or a Package | 929 | * either a Buffer or a Package |
@@ -956,7 +956,6 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
956 | break; | 956 | break; |
957 | 957 | ||
958 | case ACPI_TYPE_PACKAGE: | 958 | case ACPI_TYPE_PACKAGE: |
959 | |||
960 | /* | 959 | /* |
961 | * Return the referenced element of the package. We must | 960 | * Return the referenced element of the package. We must |
962 | * add another reference to the referenced object, however. | 961 | * add another reference to the referenced object, however. |
@@ -999,6 +998,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state) | |||
999 | break; | 998 | break; |
1000 | 999 | ||
1001 | default: | 1000 | default: |
1001 | |||
1002 | ACPI_ERROR((AE_INFO, | 1002 | ACPI_ERROR((AE_INFO, |
1003 | "Unknown class in reference(%p) - 0x%2.2X", | 1003 | "Unknown class in reference(%p) - 0x%2.2X", |
1004 | operand[0], | 1004 | operand[0], |
diff --git a/drivers/acpi/acpica/exoparg2.c b/drivers/acpi/acpica/exoparg2.c index b0838a4ea53e..d5088f7030c7 100644 --- a/drivers/acpi/acpica/exoparg2.c +++ b/drivers/acpi/acpica/exoparg2.c | |||
@@ -304,7 +304,6 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) | |||
304 | break; | 304 | break; |
305 | 305 | ||
306 | case AML_TO_STRING_OP: /* to_string (Buffer, Length, Result) (ACPI 2.0) */ | 306 | case AML_TO_STRING_OP: /* to_string (Buffer, Length, Result) (ACPI 2.0) */ |
307 | |||
308 | /* | 307 | /* |
309 | * Input object is guaranteed to be a buffer at this point (it may have | 308 | * Input object is guaranteed to be a buffer at this point (it may have |
310 | * been converted.) Copy the raw buffer data to a new object of | 309 | * been converted.) Copy the raw buffer data to a new object of |
diff --git a/drivers/acpi/acpica/exoparg3.c b/drivers/acpi/acpica/exoparg3.c index 2d7491f3126e..37656f12f204 100644 --- a/drivers/acpi/acpica/exoparg3.c +++ b/drivers/acpi/acpica/exoparg3.c | |||
@@ -155,7 +155,6 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state) | |||
155 | 155 | ||
156 | switch (walk_state->opcode) { | 156 | switch (walk_state->opcode) { |
157 | case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ | 157 | case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ |
158 | |||
159 | /* | 158 | /* |
160 | * Create the return object. The Source operand is guaranteed to be | 159 | * Create the return object. The Source operand is guaranteed to be |
161 | * either a String or a Buffer, so just use its type. | 160 | * either a String or a Buffer, so just use its type. |
diff --git a/drivers/acpi/acpica/exoparg6.c b/drivers/acpi/acpica/exoparg6.c index b76b97002dff..879b6cd8319c 100644 --- a/drivers/acpi/acpica/exoparg6.c +++ b/drivers/acpi/acpica/exoparg6.c | |||
@@ -119,7 +119,6 @@ acpi_ex_do_match(u32 match_op, | |||
119 | break; | 119 | break; |
120 | 120 | ||
121 | case MATCH_MEQ: | 121 | case MATCH_MEQ: |
122 | |||
123 | /* | 122 | /* |
124 | * True if equal: (P[i] == M) | 123 | * True if equal: (P[i] == M) |
125 | * Change to: (M == P[i]) | 124 | * Change to: (M == P[i]) |
@@ -133,7 +132,6 @@ acpi_ex_do_match(u32 match_op, | |||
133 | break; | 132 | break; |
134 | 133 | ||
135 | case MATCH_MLE: | 134 | case MATCH_MLE: |
136 | |||
137 | /* | 135 | /* |
138 | * True if less than or equal: (P[i] <= M) (P[i] not_greater than M) | 136 | * True if less than or equal: (P[i] <= M) (P[i] not_greater than M) |
139 | * Change to: (M >= P[i]) (M not_less than P[i]) | 137 | * Change to: (M >= P[i]) (M not_less than P[i]) |
@@ -148,7 +146,6 @@ acpi_ex_do_match(u32 match_op, | |||
148 | break; | 146 | break; |
149 | 147 | ||
150 | case MATCH_MLT: | 148 | case MATCH_MLT: |
151 | |||
152 | /* | 149 | /* |
153 | * True if less than: (P[i] < M) | 150 | * True if less than: (P[i] < M) |
154 | * Change to: (M > P[i]) | 151 | * Change to: (M > P[i]) |
@@ -162,7 +159,6 @@ acpi_ex_do_match(u32 match_op, | |||
162 | break; | 159 | break; |
163 | 160 | ||
164 | case MATCH_MGE: | 161 | case MATCH_MGE: |
165 | |||
166 | /* | 162 | /* |
167 | * True if greater than or equal: (P[i] >= M) (P[i] not_less than M) | 163 | * True if greater than or equal: (P[i] >= M) (P[i] not_less than M) |
168 | * Change to: (M <= P[i]) (M not_greater than P[i]) | 164 | * Change to: (M <= P[i]) (M not_greater than P[i]) |
@@ -177,7 +173,6 @@ acpi_ex_do_match(u32 match_op, | |||
177 | break; | 173 | break; |
178 | 174 | ||
179 | case MATCH_MGT: | 175 | case MATCH_MGT: |
180 | |||
181 | /* | 176 | /* |
182 | * True if greater than: (P[i] > M) | 177 | * True if greater than: (P[i] > M) |
183 | * Change to: (M < P[i]) | 178 | * Change to: (M < P[i]) |
diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c index 6b728aef2dca..5a588611ab48 100644 --- a/drivers/acpi/acpica/exprep.c +++ b/drivers/acpi/acpica/exprep.c | |||
@@ -253,26 +253,31 @@ acpi_ex_decode_field_access(union acpi_operand_object *obj_desc, | |||
253 | 253 | ||
254 | case AML_FIELD_ACCESS_BYTE: | 254 | case AML_FIELD_ACCESS_BYTE: |
255 | case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */ | 255 | case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */ |
256 | |||
256 | byte_alignment = 1; | 257 | byte_alignment = 1; |
257 | bit_length = 8; | 258 | bit_length = 8; |
258 | break; | 259 | break; |
259 | 260 | ||
260 | case AML_FIELD_ACCESS_WORD: | 261 | case AML_FIELD_ACCESS_WORD: |
262 | |||
261 | byte_alignment = 2; | 263 | byte_alignment = 2; |
262 | bit_length = 16; | 264 | bit_length = 16; |
263 | break; | 265 | break; |
264 | 266 | ||
265 | case AML_FIELD_ACCESS_DWORD: | 267 | case AML_FIELD_ACCESS_DWORD: |
268 | |||
266 | byte_alignment = 4; | 269 | byte_alignment = 4; |
267 | bit_length = 32; | 270 | bit_length = 32; |
268 | break; | 271 | break; |
269 | 272 | ||
270 | case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */ | 273 | case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */ |
274 | |||
271 | byte_alignment = 8; | 275 | byte_alignment = 8; |
272 | bit_length = 64; | 276 | bit_length = 64; |
273 | break; | 277 | break; |
274 | 278 | ||
275 | default: | 279 | default: |
280 | |||
276 | /* Invalid field access type */ | 281 | /* Invalid field access type */ |
277 | 282 | ||
278 | ACPI_ERROR((AE_INFO, "Unknown field access type 0x%X", access)); | 283 | ACPI_ERROR((AE_INFO, "Unknown field access type 0x%X", access)); |
@@ -598,7 +603,9 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info) | |||
598 | break; | 603 | break; |
599 | 604 | ||
600 | default: | 605 | default: |
606 | |||
601 | /* No other types should get here */ | 607 | /* No other types should get here */ |
608 | |||
602 | break; | 609 | break; |
603 | } | 610 | } |
604 | 611 | ||
diff --git a/drivers/acpi/acpica/exregion.c b/drivers/acpi/acpica/exregion.c index 182abaf045e1..303429bb4d5d 100644 --- a/drivers/acpi/acpica/exregion.c +++ b/drivers/acpi/acpica/exregion.c | |||
@@ -88,22 +88,27 @@ acpi_ex_system_memory_space_handler(u32 function, | |||
88 | 88 | ||
89 | switch (bit_width) { | 89 | switch (bit_width) { |
90 | case 8: | 90 | case 8: |
91 | |||
91 | length = 1; | 92 | length = 1; |
92 | break; | 93 | break; |
93 | 94 | ||
94 | case 16: | 95 | case 16: |
96 | |||
95 | length = 2; | 97 | length = 2; |
96 | break; | 98 | break; |
97 | 99 | ||
98 | case 32: | 100 | case 32: |
101 | |||
99 | length = 4; | 102 | length = 4; |
100 | break; | 103 | break; |
101 | 104 | ||
102 | case 64: | 105 | case 64: |
106 | |||
103 | length = 8; | 107 | length = 8; |
104 | break; | 108 | break; |
105 | 109 | ||
106 | default: | 110 | default: |
111 | |||
107 | ACPI_ERROR((AE_INFO, "Invalid SystemMemory width %u", | 112 | ACPI_ERROR((AE_INFO, "Invalid SystemMemory width %u", |
108 | bit_width)); | 113 | bit_width)); |
109 | return_ACPI_STATUS(AE_AML_OPERAND_VALUE); | 114 | return_ACPI_STATUS(AE_AML_OPERAND_VALUE); |
@@ -214,23 +219,29 @@ acpi_ex_system_memory_space_handler(u32 function, | |||
214 | *value = 0; | 219 | *value = 0; |
215 | switch (bit_width) { | 220 | switch (bit_width) { |
216 | case 8: | 221 | case 8: |
217 | *value = (u64) ACPI_GET8(logical_addr_ptr); | 222 | |
223 | *value = (u64)ACPI_GET8(logical_addr_ptr); | ||
218 | break; | 224 | break; |
219 | 225 | ||
220 | case 16: | 226 | case 16: |
221 | *value = (u64) ACPI_GET16(logical_addr_ptr); | 227 | |
228 | *value = (u64)ACPI_GET16(logical_addr_ptr); | ||
222 | break; | 229 | break; |
223 | 230 | ||
224 | case 32: | 231 | case 32: |
225 | *value = (u64) ACPI_GET32(logical_addr_ptr); | 232 | |
233 | *value = (u64)ACPI_GET32(logical_addr_ptr); | ||
226 | break; | 234 | break; |
227 | 235 | ||
228 | case 64: | 236 | case 64: |
229 | *value = (u64) ACPI_GET64(logical_addr_ptr); | 237 | |
238 | *value = (u64)ACPI_GET64(logical_addr_ptr); | ||
230 | break; | 239 | break; |
231 | 240 | ||
232 | default: | 241 | default: |
242 | |||
233 | /* bit_width was already validated */ | 243 | /* bit_width was already validated */ |
244 | |||
234 | break; | 245 | break; |
235 | } | 246 | } |
236 | break; | 247 | break; |
@@ -239,28 +250,35 @@ acpi_ex_system_memory_space_handler(u32 function, | |||
239 | 250 | ||
240 | switch (bit_width) { | 251 | switch (bit_width) { |
241 | case 8: | 252 | case 8: |
253 | |||
242 | ACPI_SET8(logical_addr_ptr, *value); | 254 | ACPI_SET8(logical_addr_ptr, *value); |
243 | break; | 255 | break; |
244 | 256 | ||
245 | case 16: | 257 | case 16: |
258 | |||
246 | ACPI_SET16(logical_addr_ptr, *value); | 259 | ACPI_SET16(logical_addr_ptr, *value); |
247 | break; | 260 | break; |
248 | 261 | ||
249 | case 32: | 262 | case 32: |
263 | |||
250 | ACPI_SET32(logical_addr_ptr, *value); | 264 | ACPI_SET32(logical_addr_ptr, *value); |
251 | break; | 265 | break; |
252 | 266 | ||
253 | case 64: | 267 | case 64: |
268 | |||
254 | ACPI_SET64(logical_addr_ptr, *value); | 269 | ACPI_SET64(logical_addr_ptr, *value); |
255 | break; | 270 | break; |
256 | 271 | ||
257 | default: | 272 | default: |
273 | |||
258 | /* bit_width was already validated */ | 274 | /* bit_width was already validated */ |
275 | |||
259 | break; | 276 | break; |
260 | } | 277 | } |
261 | break; | 278 | break; |
262 | 279 | ||
263 | default: | 280 | default: |
281 | |||
264 | status = AE_BAD_PARAMETER; | 282 | status = AE_BAD_PARAMETER; |
265 | break; | 283 | break; |
266 | } | 284 | } |
@@ -320,6 +338,7 @@ acpi_ex_system_io_space_handler(u32 function, | |||
320 | break; | 338 | break; |
321 | 339 | ||
322 | default: | 340 | default: |
341 | |||
323 | status = AE_BAD_PARAMETER; | 342 | status = AE_BAD_PARAMETER; |
324 | break; | 343 | break; |
325 | } | 344 | } |
diff --git a/drivers/acpi/acpica/exresnte.c b/drivers/acpi/acpica/exresnte.c index 8565b6bd12bb..acd34f599313 100644 --- a/drivers/acpi/acpica/exresnte.c +++ b/drivers/acpi/acpica/exresnte.c | |||
@@ -248,6 +248,7 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, | |||
248 | break; | 248 | break; |
249 | 249 | ||
250 | default: | 250 | default: |
251 | |||
251 | /* No named references are allowed here */ | 252 | /* No named references are allowed here */ |
252 | 253 | ||
253 | ACPI_ERROR((AE_INFO, | 254 | ACPI_ERROR((AE_INFO, |
diff --git a/drivers/acpi/acpica/exresolv.c b/drivers/acpi/acpica/exresolv.c index e4f9dfbb2a13..ac04278ad28f 100644 --- a/drivers/acpi/acpica/exresolv.c +++ b/drivers/acpi/acpica/exresolv.c | |||
@@ -156,7 +156,6 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, | |||
156 | switch (ref_type) { | 156 | switch (ref_type) { |
157 | case ACPI_REFCLASS_LOCAL: | 157 | case ACPI_REFCLASS_LOCAL: |
158 | case ACPI_REFCLASS_ARG: | 158 | case ACPI_REFCLASS_ARG: |
159 | |||
160 | /* | 159 | /* |
161 | * Get the local from the method's state info | 160 | * Get the local from the method's state info |
162 | * Note: this increments the local's object reference count | 161 | * Note: this increments the local's object reference count |
@@ -309,6 +308,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr, | |||
309 | break; | 308 | break; |
310 | 309 | ||
311 | default: | 310 | default: |
311 | |||
312 | break; | 312 | break; |
313 | } | 313 | } |
314 | 314 | ||
@@ -348,10 +348,12 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, | |||
348 | 348 | ||
349 | switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) { | 349 | switch (ACPI_GET_DESCRIPTOR_TYPE(obj_desc)) { |
350 | case ACPI_DESC_TYPE_OPERAND: | 350 | case ACPI_DESC_TYPE_OPERAND: |
351 | |||
351 | type = obj_desc->common.type; | 352 | type = obj_desc->common.type; |
352 | break; | 353 | break; |
353 | 354 | ||
354 | case ACPI_DESC_TYPE_NAMED: | 355 | case ACPI_DESC_TYPE_NAMED: |
356 | |||
355 | type = ((struct acpi_namespace_node *)obj_desc)->type; | 357 | type = ((struct acpi_namespace_node *)obj_desc)->type; |
356 | obj_desc = | 358 | obj_desc = |
357 | acpi_ns_get_attached_object((struct acpi_namespace_node *) | 359 | acpi_ns_get_attached_object((struct acpi_namespace_node *) |
@@ -538,7 +540,9 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state, | |||
538 | break; | 540 | break; |
539 | 541 | ||
540 | default: | 542 | default: |
543 | |||
541 | /* No change to Type required */ | 544 | /* No change to Type required */ |
545 | |||
542 | break; | 546 | break; |
543 | } | 547 | } |
544 | 548 | ||
diff --git a/drivers/acpi/acpica/exresop.c b/drivers/acpi/acpica/exresop.c index 9fb9f5e9a4da..00e5af7129c1 100644 --- a/drivers/acpi/acpica/exresop.c +++ b/drivers/acpi/acpica/exresop.c | |||
@@ -307,7 +307,6 @@ acpi_ex_resolve_operands(u16 opcode, | |||
307 | case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ | 307 | case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ |
308 | case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ | 308 | case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ |
309 | case ARGI_SIMPLE_TARGET: /* Name, Local, or arg - no implicit conversion */ | 309 | case ARGI_SIMPLE_TARGET: /* Name, Local, or arg - no implicit conversion */ |
310 | |||
311 | /* | 310 | /* |
312 | * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE | 311 | * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE |
313 | * A Namespace Node is OK as-is | 312 | * A Namespace Node is OK as-is |
@@ -326,7 +325,6 @@ acpi_ex_resolve_operands(u16 opcode, | |||
326 | goto next_operand; | 325 | goto next_operand; |
327 | 326 | ||
328 | case ARGI_DATAREFOBJ: /* Store operator only */ | 327 | case ARGI_DATAREFOBJ: /* Store operator only */ |
329 | |||
330 | /* | 328 | /* |
331 | * We don't want to resolve index_op reference objects during | 329 | * We don't want to resolve index_op reference objects during |
332 | * a store because this would be an implicit de_ref_of operation. | 330 | * a store because this would be an implicit de_ref_of operation. |
@@ -343,7 +341,9 @@ acpi_ex_resolve_operands(u16 opcode, | |||
343 | break; | 341 | break; |
344 | 342 | ||
345 | default: | 343 | default: |
344 | |||
346 | /* All cases covered above */ | 345 | /* All cases covered above */ |
346 | |||
347 | break; | 347 | break; |
348 | } | 348 | } |
349 | 349 | ||
@@ -433,7 +433,6 @@ acpi_ex_resolve_operands(u16 opcode, | |||
433 | goto next_operand; | 433 | goto next_operand; |
434 | 434 | ||
435 | case ARGI_BUFFER: | 435 | case ARGI_BUFFER: |
436 | |||
437 | /* | 436 | /* |
438 | * Need an operand of type ACPI_TYPE_BUFFER, | 437 | * Need an operand of type ACPI_TYPE_BUFFER, |
439 | * But we can implicitly convert from a STRING or INTEGER | 438 | * But we can implicitly convert from a STRING or INTEGER |
@@ -459,7 +458,6 @@ acpi_ex_resolve_operands(u16 opcode, | |||
459 | goto next_operand; | 458 | goto next_operand; |
460 | 459 | ||
461 | case ARGI_STRING: | 460 | case ARGI_STRING: |
462 | |||
463 | /* | 461 | /* |
464 | * Need an operand of type ACPI_TYPE_STRING, | 462 | * Need an operand of type ACPI_TYPE_STRING, |
465 | * But we can implicitly convert from a BUFFER or INTEGER | 463 | * But we can implicitly convert from a BUFFER or INTEGER |
@@ -562,6 +560,7 @@ acpi_ex_resolve_operands(u16 opcode, | |||
562 | break; | 560 | break; |
563 | 561 | ||
564 | default: | 562 | default: |
563 | |||
565 | ACPI_ERROR((AE_INFO, | 564 | ACPI_ERROR((AE_INFO, |
566 | "Needed [Buffer/String/Package/Reference], found [%s] %p", | 565 | "Needed [Buffer/String/Package/Reference], found [%s] %p", |
567 | acpi_ut_get_object_type_name | 566 | acpi_ut_get_object_type_name |
@@ -584,6 +583,7 @@ acpi_ex_resolve_operands(u16 opcode, | |||
584 | break; | 583 | break; |
585 | 584 | ||
586 | default: | 585 | default: |
586 | |||
587 | ACPI_ERROR((AE_INFO, | 587 | ACPI_ERROR((AE_INFO, |
588 | "Needed [Buffer/String/Package], found [%s] %p", | 588 | "Needed [Buffer/String/Package], found [%s] %p", |
589 | acpi_ut_get_object_type_name | 589 | acpi_ut_get_object_type_name |
@@ -605,6 +605,7 @@ acpi_ex_resolve_operands(u16 opcode, | |||
605 | break; | 605 | break; |
606 | 606 | ||
607 | default: | 607 | default: |
608 | |||
608 | ACPI_ERROR((AE_INFO, | 609 | ACPI_ERROR((AE_INFO, |
609 | "Needed [Region/Buffer], found [%s] %p", | 610 | "Needed [Region/Buffer], found [%s] %p", |
610 | acpi_ut_get_object_type_name | 611 | acpi_ut_get_object_type_name |
diff --git a/drivers/acpi/acpica/exstore.c b/drivers/acpi/acpica/exstore.c index 93c6049c2d75..2bdba6f7d762 100644 --- a/drivers/acpi/acpica/exstore.c +++ b/drivers/acpi/acpica/exstore.c | |||
@@ -114,6 +114,7 @@ acpi_ex_store(union acpi_operand_object *source_desc, | |||
114 | 114 | ||
115 | switch (dest_desc->common.type) { | 115 | switch (dest_desc->common.type) { |
116 | case ACPI_TYPE_LOCAL_REFERENCE: | 116 | case ACPI_TYPE_LOCAL_REFERENCE: |
117 | |||
117 | break; | 118 | break; |
118 | 119 | ||
119 | case ACPI_TYPE_INTEGER: | 120 | case ACPI_TYPE_INTEGER: |
@@ -178,7 +179,6 @@ acpi_ex_store(union acpi_operand_object *source_desc, | |||
178 | break; | 179 | break; |
179 | 180 | ||
180 | case ACPI_REFCLASS_DEBUG: | 181 | case ACPI_REFCLASS_DEBUG: |
181 | |||
182 | /* | 182 | /* |
183 | * Storing to the Debug object causes the value stored to be | 183 | * Storing to the Debug object causes the value stored to be |
184 | * displayed and otherwise has no effect -- see ACPI Specification | 184 | * displayed and otherwise has no effect -- see ACPI Specification |
@@ -291,7 +291,6 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc, | |||
291 | break; | 291 | break; |
292 | 292 | ||
293 | case ACPI_TYPE_BUFFER_FIELD: | 293 | case ACPI_TYPE_BUFFER_FIELD: |
294 | |||
295 | /* | 294 | /* |
296 | * Store into a Buffer or String (not actually a real buffer_field) | 295 | * Store into a Buffer or String (not actually a real buffer_field) |
297 | * at a location defined by an Index. | 296 | * at a location defined by an Index. |
@@ -447,7 +446,6 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc, | |||
447 | case ACPI_TYPE_INTEGER: | 446 | case ACPI_TYPE_INTEGER: |
448 | case ACPI_TYPE_STRING: | 447 | case ACPI_TYPE_STRING: |
449 | case ACPI_TYPE_BUFFER: | 448 | case ACPI_TYPE_BUFFER: |
450 | |||
451 | /* | 449 | /* |
452 | * These target types are all of type Integer/String/Buffer, and | 450 | * These target types are all of type Integer/String/Buffer, and |
453 | * therefore support implicit conversion before the store. | 451 | * therefore support implicit conversion before the store. |
diff --git a/drivers/acpi/acpica/exstoren.c b/drivers/acpi/acpica/exstoren.c index 1cefe777068e..20d809d90c5b 100644 --- a/drivers/acpi/acpica/exstoren.c +++ b/drivers/acpi/acpica/exstoren.c | |||
@@ -85,11 +85,9 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr, | |||
85 | * These cases all require only Integers or values that | 85 | * These cases all require only Integers or values that |
86 | * can be converted to Integers (Strings or Buffers) | 86 | * can be converted to Integers (Strings or Buffers) |
87 | */ | 87 | */ |
88 | |||
89 | case ACPI_TYPE_INTEGER: | 88 | case ACPI_TYPE_INTEGER: |
90 | case ACPI_TYPE_STRING: | 89 | case ACPI_TYPE_STRING: |
91 | case ACPI_TYPE_BUFFER: | 90 | case ACPI_TYPE_BUFFER: |
92 | |||
93 | /* | 91 | /* |
94 | * Stores into a Field/Region or into a Integer/Buffer/String | 92 | * Stores into a Field/Region or into a Integer/Buffer/String |
95 | * are all essentially the same. This case handles the | 93 | * are all essentially the same. This case handles the |
@@ -133,7 +131,6 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr, | |||
133 | 131 | ||
134 | case ACPI_TYPE_LOCAL_ALIAS: | 132 | case ACPI_TYPE_LOCAL_ALIAS: |
135 | case ACPI_TYPE_LOCAL_METHOD_ALIAS: | 133 | case ACPI_TYPE_LOCAL_METHOD_ALIAS: |
136 | |||
137 | /* | 134 | /* |
138 | * All aliases should have been resolved earlier, during the | 135 | * All aliases should have been resolved earlier, during the |
139 | * operand resolution phase. | 136 | * operand resolution phase. |
@@ -144,7 +141,6 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr, | |||
144 | 141 | ||
145 | case ACPI_TYPE_PACKAGE: | 142 | case ACPI_TYPE_PACKAGE: |
146 | default: | 143 | default: |
147 | |||
148 | /* | 144 | /* |
149 | * All other types than Alias and the various Fields come here, | 145 | * All other types than Alias and the various Fields come here, |
150 | * including the untyped case - ACPI_TYPE_ANY. | 146 | * including the untyped case - ACPI_TYPE_ANY. |
diff --git a/drivers/acpi/acpica/hwacpi.c b/drivers/acpi/acpica/hwacpi.c index 579c3a53ac87..3d36df828f52 100644 --- a/drivers/acpi/acpica/hwacpi.c +++ b/drivers/acpi/acpica/hwacpi.c | |||
@@ -108,7 +108,6 @@ acpi_status acpi_hw_set_mode(u32 mode) | |||
108 | break; | 108 | break; |
109 | 109 | ||
110 | case ACPI_SYS_MODE_LEGACY: | 110 | case ACPI_SYS_MODE_LEGACY: |
111 | |||
112 | /* | 111 | /* |
113 | * BIOS should clear all fixed status bits and restore fixed event | 112 | * BIOS should clear all fixed status bits and restore fixed event |
114 | * enable bits to default | 113 | * enable bits to default |
@@ -120,6 +119,7 @@ acpi_status acpi_hw_set_mode(u32 mode) | |||
120 | break; | 119 | break; |
121 | 120 | ||
122 | default: | 121 | default: |
122 | |||
123 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 123 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
124 | } | 124 | } |
125 | 125 | ||
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c index 20d02e93c990..96540506058f 100644 --- a/drivers/acpi/acpica/hwgpe.c +++ b/drivers/acpi/acpica/hwgpe.c | |||
@@ -127,14 +127,17 @@ acpi_hw_low_set_gpe(struct acpi_gpe_event_info *gpe_event_info, u32 action) | |||
127 | /*lint -fallthrough */ | 127 | /*lint -fallthrough */ |
128 | 128 | ||
129 | case ACPI_GPE_ENABLE: | 129 | case ACPI_GPE_ENABLE: |
130 | |||
130 | ACPI_SET_BIT(enable_mask, register_bit); | 131 | ACPI_SET_BIT(enable_mask, register_bit); |
131 | break; | 132 | break; |
132 | 133 | ||
133 | case ACPI_GPE_DISABLE: | 134 | case ACPI_GPE_DISABLE: |
135 | |||
134 | ACPI_CLEAR_BIT(enable_mask, register_bit); | 136 | ACPI_CLEAR_BIT(enable_mask, register_bit); |
135 | break; | 137 | break; |
136 | 138 | ||
137 | default: | 139 | default: |
140 | |||
138 | ACPI_ERROR((AE_INFO, "Invalid GPE Action, %u", action)); | 141 | ACPI_ERROR((AE_INFO, "Invalid GPE Action, %u", action)); |
139 | return (AE_BAD_PARAMETER); | 142 | return (AE_BAD_PARAMETER); |
140 | } | 143 | } |
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c index 083d6551f0e2..8d2e866be15f 100644 --- a/drivers/acpi/acpica/hwregs.c +++ b/drivers/acpi/acpica/hwregs.c | |||
@@ -419,6 +419,7 @@ acpi_status acpi_hw_register_read(u32 register_id, u32 *return_value) | |||
419 | break; | 419 | break; |
420 | 420 | ||
421 | default: | 421 | default: |
422 | |||
422 | ACPI_ERROR((AE_INFO, "Unknown Register ID: 0x%X", register_id)); | 423 | ACPI_ERROR((AE_INFO, "Unknown Register ID: 0x%X", register_id)); |
423 | status = AE_BAD_PARAMETER; | 424 | status = AE_BAD_PARAMETER; |
424 | break; | 425 | break; |
@@ -491,7 +492,6 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) | |||
491 | break; | 492 | break; |
492 | 493 | ||
493 | case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */ | 494 | case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */ |
494 | |||
495 | /* | 495 | /* |
496 | * Perform a read first to preserve certain bits (per ACPI spec) | 496 | * Perform a read first to preserve certain bits (per ACPI spec) |
497 | * Note: This includes SCI_EN, we never want to change this bit | 497 | * Note: This includes SCI_EN, we never want to change this bit |
@@ -520,7 +520,6 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) | |||
520 | break; | 520 | break; |
521 | 521 | ||
522 | case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ | 522 | case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ |
523 | |||
524 | /* | 523 | /* |
525 | * For control registers, all reserved bits must be preserved, | 524 | * For control registers, all reserved bits must be preserved, |
526 | * as per the ACPI spec. | 525 | * as per the ACPI spec. |
@@ -555,6 +554,7 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) | |||
555 | break; | 554 | break; |
556 | 555 | ||
557 | default: | 556 | default: |
557 | |||
558 | ACPI_ERROR((AE_INFO, "Unknown Register ID: 0x%X", register_id)); | 558 | ACPI_ERROR((AE_INFO, "Unknown Register ID: 0x%X", register_id)); |
559 | status = AE_BAD_PARAMETER; | 559 | status = AE_BAD_PARAMETER; |
560 | break; | 560 | break; |
diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c index 04c2e16f2c0a..5ee7a814cd92 100644 --- a/drivers/acpi/acpica/hwxface.c +++ b/drivers/acpi/acpica/hwxface.c | |||
@@ -495,7 +495,7 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b) | |||
495 | * Evaluate the \_Sx namespace object containing the register values | 495 | * Evaluate the \_Sx namespace object containing the register values |
496 | * for this state | 496 | * for this state |
497 | */ | 497 | */ |
498 | info->pathname = | 498 | info->relative_pathname = |
499 | ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]); | 499 | ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]); |
500 | status = acpi_ns_evaluate(info); | 500 | status = acpi_ns_evaluate(info); |
501 | if (ACPI_FAILURE(status)) { | 501 | if (ACPI_FAILURE(status)) { |
@@ -506,7 +506,7 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b) | |||
506 | 506 | ||
507 | if (!info->return_object) { | 507 | if (!info->return_object) { |
508 | ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]", | 508 | ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]", |
509 | info->pathname)); | 509 | info->relative_pathname)); |
510 | status = AE_AML_NO_RETURN_VALUE; | 510 | status = AE_AML_NO_RETURN_VALUE; |
511 | goto cleanup; | 511 | goto cleanup; |
512 | } | 512 | } |
@@ -528,10 +528,12 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b) | |||
528 | elements = info->return_object->package.elements; | 528 | elements = info->return_object->package.elements; |
529 | switch (info->return_object->package.count) { | 529 | switch (info->return_object->package.count) { |
530 | case 0: | 530 | case 0: |
531 | |||
531 | status = AE_AML_PACKAGE_LIMIT; | 532 | status = AE_AML_PACKAGE_LIMIT; |
532 | break; | 533 | break; |
533 | 534 | ||
534 | case 1: | 535 | case 1: |
536 | |||
535 | if (elements[0]->common.type != ACPI_TYPE_INTEGER) { | 537 | if (elements[0]->common.type != ACPI_TYPE_INTEGER) { |
536 | status = AE_AML_OPERAND_TYPE; | 538 | status = AE_AML_OPERAND_TYPE; |
537 | break; | 539 | break; |
@@ -545,6 +547,7 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b) | |||
545 | 547 | ||
546 | case 2: | 548 | case 2: |
547 | default: | 549 | default: |
550 | |||
548 | if ((elements[0]->common.type != ACPI_TYPE_INTEGER) || | 551 | if ((elements[0]->common.type != ACPI_TYPE_INTEGER) || |
549 | (elements[1]->common.type != ACPI_TYPE_INTEGER)) { | 552 | (elements[1]->common.type != ACPI_TYPE_INTEGER)) { |
550 | status = AE_AML_OPERAND_TYPE; | 553 | status = AE_AML_OPERAND_TYPE; |
@@ -565,7 +568,7 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b) | |||
565 | if (ACPI_FAILURE(status)) { | 568 | if (ACPI_FAILURE(status)) { |
566 | ACPI_EXCEPTION((AE_INFO, status, | 569 | ACPI_EXCEPTION((AE_INFO, status, |
567 | "While evaluating Sleep State [%s]", | 570 | "While evaluating Sleep State [%s]", |
568 | info->pathname)); | 571 | info->relative_pathname)); |
569 | } | 572 | } |
570 | 573 | ||
571 | ACPI_FREE(info); | 574 | ACPI_FREE(info); |
diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c index 35eebdac0f9d..f2e669db8b65 100644 --- a/drivers/acpi/acpica/hwxfsleep.c +++ b/drivers/acpi/acpica/hwxfsleep.c | |||
@@ -240,12 +240,14 @@ static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id) | |||
240 | &acpi_sleep_dispatch[function_id]; | 240 | &acpi_sleep_dispatch[function_id]; |
241 | 241 | ||
242 | #if (!ACPI_REDUCED_HARDWARE) | 242 | #if (!ACPI_REDUCED_HARDWARE) |
243 | |||
244 | /* | 243 | /* |
245 | * If the Hardware Reduced flag is set (from the FADT), we must | 244 | * If the Hardware Reduced flag is set (from the FADT), we must |
246 | * use the extended sleep registers | 245 | * use the extended sleep registers (FADT). Note: As per the ACPI |
246 | * specification, these extended registers are to be used for HW-reduced | ||
247 | * platforms only. They are not general-purpose replacements for the | ||
248 | * legacy PM register sleep support. | ||
247 | */ | 249 | */ |
248 | if (acpi_gbl_reduced_hardware || acpi_gbl_FADT.sleep_control.address) { | 250 | if (acpi_gbl_reduced_hardware) { |
249 | status = sleep_functions->extended_function(sleep_state); | 251 | status = sleep_functions->extended_function(sleep_state); |
250 | } else { | 252 | } else { |
251 | /* Legacy sleep */ | 253 | /* Legacy sleep */ |
@@ -314,20 +316,24 @@ acpi_status acpi_enter_sleep_state_prep(u8 sleep_state) | |||
314 | 316 | ||
315 | switch (sleep_state) { | 317 | switch (sleep_state) { |
316 | case ACPI_STATE_S0: | 318 | case ACPI_STATE_S0: |
319 | |||
317 | sst_value = ACPI_SST_WORKING; | 320 | sst_value = ACPI_SST_WORKING; |
318 | break; | 321 | break; |
319 | 322 | ||
320 | case ACPI_STATE_S1: | 323 | case ACPI_STATE_S1: |
321 | case ACPI_STATE_S2: | 324 | case ACPI_STATE_S2: |
322 | case ACPI_STATE_S3: | 325 | case ACPI_STATE_S3: |
326 | |||
323 | sst_value = ACPI_SST_SLEEPING; | 327 | sst_value = ACPI_SST_SLEEPING; |
324 | break; | 328 | break; |
325 | 329 | ||
326 | case ACPI_STATE_S4: | 330 | case ACPI_STATE_S4: |
331 | |||
327 | sst_value = ACPI_SST_SLEEP_CONTEXT; | 332 | sst_value = ACPI_SST_SLEEP_CONTEXT; |
328 | break; | 333 | break; |
329 | 334 | ||
330 | default: | 335 | default: |
336 | |||
331 | sst_value = ACPI_SST_INDICATOR_OFF; /* Default is off */ | 337 | sst_value = ACPI_SST_INDICATOR_OFF; /* Default is off */ |
332 | break; | 338 | break; |
333 | } | 339 | } |
diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c index 8769cf83b044..c5316e5bd4ab 100644 --- a/drivers/acpi/acpica/nsaccess.c +++ b/drivers/acpi/acpica/nsaccess.c | |||
@@ -151,6 +151,7 @@ acpi_status acpi_ns_root_initialize(void) | |||
151 | */ | 151 | */ |
152 | switch (init_val->type) { | 152 | switch (init_val->type) { |
153 | case ACPI_TYPE_METHOD: | 153 | case ACPI_TYPE_METHOD: |
154 | |||
154 | obj_desc->method.param_count = | 155 | obj_desc->method.param_count = |
155 | (u8) ACPI_TO_INTEGER(val); | 156 | (u8) ACPI_TO_INTEGER(val); |
156 | obj_desc->common.flags |= AOPOBJ_DATA_VALID; | 157 | obj_desc->common.flags |= AOPOBJ_DATA_VALID; |
diff --git a/drivers/acpi/acpica/nsarguments.c b/drivers/acpi/acpica/nsarguments.c new file mode 100644 index 000000000000..74b24c82707e --- /dev/null +++ b/drivers/acpi/acpica/nsarguments.c | |||
@@ -0,0 +1,294 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: nsarguments - Validation of args for ACPI predefined methods | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2013, Intel Corp. | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions, and the following disclaimer, | ||
16 | * without modification. | ||
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
18 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
19 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
20 | * including a substantially similar Disclaimer requirement for further | ||
21 | * binary redistribution. | ||
22 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
23 | * of any contributors may be used to endorse or promote products derived | ||
24 | * from this software without specific prior written permission. | ||
25 | * | ||
26 | * Alternatively, this software may be distributed under the terms of the | ||
27 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
28 | * Software Foundation. | ||
29 | * | ||
30 | * NO WARRANTY | ||
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
41 | * POSSIBILITY OF SUCH DAMAGES. | ||
42 | */ | ||
43 | |||
44 | #include <acpi/acpi.h> | ||
45 | #include "accommon.h" | ||
46 | #include "acnamesp.h" | ||
47 | #include "acpredef.h" | ||
48 | |||
49 | #define _COMPONENT ACPI_NAMESPACE | ||
50 | ACPI_MODULE_NAME("nsarguments") | ||
51 | |||
52 | /******************************************************************************* | ||
53 | * | ||
54 | * FUNCTION: acpi_ns_check_argument_types | ||
55 | * | ||
56 | * PARAMETERS: info - Method execution information block | ||
57 | * | ||
58 | * RETURN: None | ||
59 | * | ||
60 | * DESCRIPTION: Check the incoming argument count and all argument types | ||
61 | * against the argument type list for a predefined name. | ||
62 | * | ||
63 | ******************************************************************************/ | ||
64 | void acpi_ns_check_argument_types(struct acpi_evaluate_info *info) | ||
65 | { | ||
66 | u16 arg_type_list; | ||
67 | u8 arg_count; | ||
68 | u8 arg_type; | ||
69 | u8 user_arg_type; | ||
70 | u32 i; | ||
71 | |||
72 | /* If not a predefined name, cannot typecheck args */ | ||
73 | |||
74 | if (!info->predefined) { | ||
75 | return; | ||
76 | } | ||
77 | |||
78 | arg_type_list = info->predefined->info.argument_list; | ||
79 | arg_count = METHOD_GET_ARG_COUNT(arg_type_list); | ||
80 | |||
81 | /* Typecheck all arguments */ | ||
82 | |||
83 | for (i = 0; ((i < arg_count) && (i < info->param_count)); i++) { | ||
84 | arg_type = METHOD_GET_NEXT_TYPE(arg_type_list); | ||
85 | user_arg_type = info->parameters[i]->common.type; | ||
86 | |||
87 | if (user_arg_type != arg_type) { | ||
88 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, | ||
89 | ACPI_WARN_ALWAYS, | ||
90 | "Argument #%u type mismatch - " | ||
91 | "Found [%s], ACPI requires [%s]", | ||
92 | (i + 1), | ||
93 | acpi_ut_get_type_name | ||
94 | (user_arg_type), | ||
95 | acpi_ut_get_type_name(arg_type))); | ||
96 | } | ||
97 | } | ||
98 | } | ||
99 | |||
100 | /******************************************************************************* | ||
101 | * | ||
102 | * FUNCTION: acpi_ns_check_acpi_compliance | ||
103 | * | ||
104 | * PARAMETERS: pathname - Full pathname to the node (for error msgs) | ||
105 | * node - Namespace node for the method/object | ||
106 | * predefined - Pointer to entry in predefined name table | ||
107 | * | ||
108 | * RETURN: None | ||
109 | * | ||
110 | * DESCRIPTION: Check that the declared parameter count (in ASL/AML) for a | ||
111 | * predefined name is what is expected (matches what is defined in | ||
112 | * the ACPI specification for this predefined name.) | ||
113 | * | ||
114 | ******************************************************************************/ | ||
115 | |||
116 | void | ||
117 | acpi_ns_check_acpi_compliance(char *pathname, | ||
118 | struct acpi_namespace_node *node, | ||
119 | const union acpi_predefined_info *predefined) | ||
120 | { | ||
121 | u32 aml_param_count; | ||
122 | u32 required_param_count; | ||
123 | |||
124 | if (!predefined) { | ||
125 | return; | ||
126 | } | ||
127 | |||
128 | /* Get the ACPI-required arg count from the predefined info table */ | ||
129 | |||
130 | required_param_count = | ||
131 | METHOD_GET_ARG_COUNT(predefined->info.argument_list); | ||
132 | |||
133 | /* | ||
134 | * If this object is not a control method, we can check if the ACPI | ||
135 | * spec requires that it be a method. | ||
136 | */ | ||
137 | if (node->type != ACPI_TYPE_METHOD) { | ||
138 | if (required_param_count > 0) { | ||
139 | |||
140 | /* Object requires args, must be implemented as a method */ | ||
141 | |||
142 | ACPI_BIOS_ERROR_PREDEFINED((AE_INFO, pathname, | ||
143 | ACPI_WARN_ALWAYS, | ||
144 | "Object (%s) must be a control method with %u arguments", | ||
145 | acpi_ut_get_type_name(node-> | ||
146 | type), | ||
147 | required_param_count)); | ||
148 | } else if (!required_param_count | ||
149 | && !predefined->info.expected_btypes) { | ||
150 | |||
151 | /* Object requires no args and no return value, must be a method */ | ||
152 | |||
153 | ACPI_BIOS_ERROR_PREDEFINED((AE_INFO, pathname, | ||
154 | ACPI_WARN_ALWAYS, | ||
155 | "Object (%s) must be a control method " | ||
156 | "with no arguments and no return value", | ||
157 | acpi_ut_get_type_name(node-> | ||
158 | type))); | ||
159 | } | ||
160 | |||
161 | return; | ||
162 | } | ||
163 | |||
164 | /* | ||
165 | * This is a control method. | ||
166 | * Check that the ASL/AML-defined parameter count for this method | ||
167 | * matches the ACPI-required parameter count | ||
168 | * | ||
169 | * Some methods are allowed to have a "minimum" number of args (_SCP) | ||
170 | * because their definition in ACPI has changed over time. | ||
171 | * | ||
172 | * Note: These are BIOS errors in the declaration of the object | ||
173 | */ | ||
174 | aml_param_count = node->object->method.param_count; | ||
175 | |||
176 | if (aml_param_count < required_param_count) { | ||
177 | ACPI_BIOS_ERROR_PREDEFINED((AE_INFO, pathname, ACPI_WARN_ALWAYS, | ||
178 | "Insufficient arguments - " | ||
179 | "ASL declared %u, ACPI requires %u", | ||
180 | aml_param_count, | ||
181 | required_param_count)); | ||
182 | } else if ((aml_param_count > required_param_count) | ||
183 | && !(predefined->info. | ||
184 | argument_list & ARG_COUNT_IS_MINIMUM)) { | ||
185 | ACPI_BIOS_ERROR_PREDEFINED((AE_INFO, pathname, ACPI_WARN_ALWAYS, | ||
186 | "Excess arguments - " | ||
187 | "ASL declared %u, ACPI requires %u", | ||
188 | aml_param_count, | ||
189 | required_param_count)); | ||
190 | } | ||
191 | } | ||
192 | |||
193 | /******************************************************************************* | ||
194 | * | ||
195 | * FUNCTION: acpi_ns_check_argument_count | ||
196 | * | ||
197 | * PARAMETERS: pathname - Full pathname to the node (for error msgs) | ||
198 | * node - Namespace node for the method/object | ||
199 | * user_param_count - Number of args passed in by the caller | ||
200 | * predefined - Pointer to entry in predefined name table | ||
201 | * | ||
202 | * RETURN: None | ||
203 | * | ||
204 | * DESCRIPTION: Check that incoming argument count matches the declared | ||
205 | * parameter count (in the ASL/AML) for an object. | ||
206 | * | ||
207 | ******************************************************************************/ | ||
208 | |||
209 | void | ||
210 | acpi_ns_check_argument_count(char *pathname, | ||
211 | struct acpi_namespace_node *node, | ||
212 | u32 user_param_count, | ||
213 | const union acpi_predefined_info *predefined) | ||
214 | { | ||
215 | u32 aml_param_count; | ||
216 | u32 required_param_count; | ||
217 | |||
218 | if (!predefined) { | ||
219 | /* | ||
220 | * Not a predefined name. Check the incoming user argument count | ||
221 | * against the count that is specified in the method/object. | ||
222 | */ | ||
223 | if (node->type != ACPI_TYPE_METHOD) { | ||
224 | if (user_param_count) { | ||
225 | ACPI_INFO_PREDEFINED((AE_INFO, pathname, | ||
226 | ACPI_WARN_ALWAYS, | ||
227 | "%u arguments were passed to a non-method ACPI object (%s)", | ||
228 | user_param_count, | ||
229 | acpi_ut_get_type_name | ||
230 | (node->type))); | ||
231 | } | ||
232 | |||
233 | return; | ||
234 | } | ||
235 | |||
236 | /* | ||
237 | * This is a control method. Check the parameter count. | ||
238 | * We can only check the incoming argument count against the | ||
239 | * argument count declared for the method in the ASL/AML. | ||
240 | * | ||
241 | * Emit a message if too few or too many arguments have been passed | ||
242 | * by the caller. | ||
243 | * | ||
244 | * Note: Too many arguments will not cause the method to | ||
245 | * fail. However, the method will fail if there are too few | ||
246 | * arguments and the method attempts to use one of the missing ones. | ||
247 | */ | ||
248 | aml_param_count = node->object->method.param_count; | ||
249 | |||
250 | if (user_param_count < aml_param_count) { | ||
251 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, | ||
252 | ACPI_WARN_ALWAYS, | ||
253 | "Insufficient arguments - " | ||
254 | "Caller passed %u, method requires %u", | ||
255 | user_param_count, | ||
256 | aml_param_count)); | ||
257 | } else if (user_param_count > aml_param_count) { | ||
258 | ACPI_INFO_PREDEFINED((AE_INFO, pathname, | ||
259 | ACPI_WARN_ALWAYS, | ||
260 | "Excess arguments - " | ||
261 | "Caller passed %u, method requires %u", | ||
262 | user_param_count, | ||
263 | aml_param_count)); | ||
264 | } | ||
265 | |||
266 | return; | ||
267 | } | ||
268 | |||
269 | /* | ||
270 | * This is a predefined name. Validate the user-supplied parameter | ||
271 | * count against the ACPI specification. We don't validate against | ||
272 | * the method itself because what is important here is that the | ||
273 | * caller is in conformance with the spec. (The arg count for the | ||
274 | * method was checked against the ACPI spec earlier.) | ||
275 | * | ||
276 | * Some methods are allowed to have a "minimum" number of args (_SCP) | ||
277 | * because their definition in ACPI has changed over time. | ||
278 | */ | ||
279 | required_param_count = | ||
280 | METHOD_GET_ARG_COUNT(predefined->info.argument_list); | ||
281 | |||
282 | if (user_param_count < required_param_count) { | ||
283 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, ACPI_WARN_ALWAYS, | ||
284 | "Insufficient arguments - " | ||
285 | "Caller passed %u, ACPI requires %u", | ||
286 | user_param_count, required_param_count)); | ||
287 | } else if ((user_param_count > required_param_count) && | ||
288 | !(predefined->info.argument_list & ARG_COUNT_IS_MINIMUM)) { | ||
289 | ACPI_INFO_PREDEFINED((AE_INFO, pathname, ACPI_WARN_ALWAYS, | ||
290 | "Excess arguments - " | ||
291 | "Caller passed %u, ACPI requires %u", | ||
292 | user_param_count, required_param_count)); | ||
293 | } | ||
294 | } | ||
diff --git a/drivers/acpi/acpica/nsconvert.c b/drivers/acpi/acpica/nsconvert.c index 8f79a9d2d50e..acd2964c2690 100644 --- a/drivers/acpi/acpica/nsconvert.c +++ b/drivers/acpi/acpica/nsconvert.c | |||
@@ -103,6 +103,7 @@ acpi_ns_convert_to_integer(union acpi_operand_object *original_object, | |||
103 | break; | 103 | break; |
104 | 104 | ||
105 | default: | 105 | default: |
106 | |||
106 | return (AE_AML_OPERAND_TYPE); | 107 | return (AE_AML_OPERAND_TYPE); |
107 | } | 108 | } |
108 | 109 | ||
@@ -191,6 +192,7 @@ acpi_ns_convert_to_string(union acpi_operand_object *original_object, | |||
191 | break; | 192 | break; |
192 | 193 | ||
193 | default: | 194 | default: |
195 | |||
194 | return (AE_AML_OPERAND_TYPE); | 196 | return (AE_AML_OPERAND_TYPE); |
195 | } | 197 | } |
196 | 198 | ||
@@ -294,6 +296,7 @@ acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, | |||
294 | break; | 296 | break; |
295 | 297 | ||
296 | default: | 298 | default: |
299 | |||
297 | return (AE_AML_OPERAND_TYPE); | 300 | return (AE_AML_OPERAND_TYPE); |
298 | } | 301 | } |
299 | 302 | ||
diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c index ce6e97326205..7418c77fde8c 100644 --- a/drivers/acpi/acpica/nsdump.c +++ b/drivers/acpi/acpica/nsdump.c | |||
@@ -244,10 +244,12 @@ acpi_ns_dump_one_object(acpi_handle obj_handle, | |||
244 | case ACPI_TYPE_BUFFER: | 244 | case ACPI_TYPE_BUFFER: |
245 | case ACPI_TYPE_STRING: | 245 | case ACPI_TYPE_STRING: |
246 | case ACPI_TYPE_METHOD: | 246 | case ACPI_TYPE_METHOD: |
247 | |||
247 | acpi_os_printf("<No attached object>"); | 248 | acpi_os_printf("<No attached object>"); |
248 | break; | 249 | break; |
249 | 250 | ||
250 | default: | 251 | default: |
252 | |||
251 | break; | 253 | break; |
252 | } | 254 | } |
253 | 255 | ||
@@ -433,6 +435,7 @@ acpi_ns_dump_one_object(acpi_handle obj_handle, | |||
433 | break; | 435 | break; |
434 | 436 | ||
435 | default: | 437 | default: |
438 | |||
436 | break; | 439 | break; |
437 | } | 440 | } |
438 | break; | 441 | break; |
@@ -567,32 +570,39 @@ acpi_ns_dump_one_object(acpi_handle obj_handle, | |||
567 | goto cleanup; | 570 | goto cleanup; |
568 | 571 | ||
569 | case ACPI_TYPE_BUFFER_FIELD: | 572 | case ACPI_TYPE_BUFFER_FIELD: |
573 | |||
570 | obj_desc = | 574 | obj_desc = |
571 | (union acpi_operand_object *)obj_desc->buffer_field. | 575 | (union acpi_operand_object *)obj_desc->buffer_field. |
572 | buffer_obj; | 576 | buffer_obj; |
573 | break; | 577 | break; |
574 | 578 | ||
575 | case ACPI_TYPE_PACKAGE: | 579 | case ACPI_TYPE_PACKAGE: |
580 | |||
576 | obj_desc = (void *)obj_desc->package.elements; | 581 | obj_desc = (void *)obj_desc->package.elements; |
577 | break; | 582 | break; |
578 | 583 | ||
579 | case ACPI_TYPE_METHOD: | 584 | case ACPI_TYPE_METHOD: |
585 | |||
580 | obj_desc = (void *)obj_desc->method.aml_start; | 586 | obj_desc = (void *)obj_desc->method.aml_start; |
581 | break; | 587 | break; |
582 | 588 | ||
583 | case ACPI_TYPE_LOCAL_REGION_FIELD: | 589 | case ACPI_TYPE_LOCAL_REGION_FIELD: |
590 | |||
584 | obj_desc = (void *)obj_desc->field.region_obj; | 591 | obj_desc = (void *)obj_desc->field.region_obj; |
585 | break; | 592 | break; |
586 | 593 | ||
587 | case ACPI_TYPE_LOCAL_BANK_FIELD: | 594 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
595 | |||
588 | obj_desc = (void *)obj_desc->bank_field.region_obj; | 596 | obj_desc = (void *)obj_desc->bank_field.region_obj; |
589 | break; | 597 | break; |
590 | 598 | ||
591 | case ACPI_TYPE_LOCAL_INDEX_FIELD: | 599 | case ACPI_TYPE_LOCAL_INDEX_FIELD: |
600 | |||
592 | obj_desc = (void *)obj_desc->index_field.index_obj; | 601 | obj_desc = (void *)obj_desc->index_field.index_obj; |
593 | break; | 602 | break; |
594 | 603 | ||
595 | default: | 604 | default: |
605 | |||
596 | goto cleanup; | 606 | goto cleanup; |
597 | } | 607 | } |
598 | 608 | ||
diff --git a/drivers/acpi/acpica/nseval.c b/drivers/acpi/acpica/nseval.c index b61db69d5675..18108bc2e51c 100644 --- a/drivers/acpi/acpica/nseval.c +++ b/drivers/acpi/acpica/nseval.c | |||
@@ -61,7 +61,7 @@ acpi_ns_exec_module_code(union acpi_operand_object *method_obj, | |||
61 | * | 61 | * |
62 | * PARAMETERS: info - Evaluation info block, contains: | 62 | * PARAMETERS: info - Evaluation info block, contains: |
63 | * prefix_node - Prefix or Method/Object Node to execute | 63 | * prefix_node - Prefix or Method/Object Node to execute |
64 | * pathname - Name of method to execute, If NULL, the | 64 | * relative_path - Name of method to execute, If NULL, the |
65 | * Node is the object to execute | 65 | * Node is the object to execute |
66 | * parameters - List of parameters to pass to the method, | 66 | * parameters - List of parameters to pass to the method, |
67 | * terminated by NULL. Params itself may be | 67 | * terminated by NULL. Params itself may be |
@@ -82,10 +82,9 @@ acpi_ns_exec_module_code(union acpi_operand_object *method_obj, | |||
82 | * | 82 | * |
83 | ******************************************************************************/ | 83 | ******************************************************************************/ |
84 | 84 | ||
85 | acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) | 85 | acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info) |
86 | { | 86 | { |
87 | acpi_status status; | 87 | acpi_status status; |
88 | struct acpi_namespace_node *node; | ||
89 | 88 | ||
90 | ACPI_FUNCTION_TRACE(ns_evaluate); | 89 | ACPI_FUNCTION_TRACE(ns_evaluate); |
91 | 90 | ||
@@ -93,83 +92,138 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) | |||
93 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 92 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
94 | } | 93 | } |
95 | 94 | ||
96 | /* Initialize the return value to an invalid object */ | 95 | if (!info->node) { |
97 | |||
98 | info->return_object = NULL; | ||
99 | info->param_count = 0; | ||
100 | |||
101 | if (!info->resolved_node) { | ||
102 | /* | 96 | /* |
103 | * Get the actual namespace node for the target object if we need to. | 97 | * Get the actual namespace node for the target object if we |
104 | * Handles these cases: | 98 | * need to. Handles these cases: |
105 | * | 99 | * |
106 | * 1) Null node, Pathname (absolute path) | 100 | * 1) Null node, valid pathname from root (absolute path) |
107 | * 2) Node, Pathname (path relative to Node) | 101 | * 2) Node and valid pathname (path relative to Node) |
108 | * 3) Node, Null Pathname | 102 | * 3) Node, Null pathname |
109 | */ | 103 | */ |
110 | status = acpi_ns_get_node(info->prefix_node, info->pathname, | 104 | status = |
111 | ACPI_NS_NO_UPSEARCH, | 105 | acpi_ns_get_node(info->prefix_node, info->relative_pathname, |
112 | &info->resolved_node); | 106 | ACPI_NS_NO_UPSEARCH, &info->node); |
113 | if (ACPI_FAILURE(status)) { | 107 | if (ACPI_FAILURE(status)) { |
114 | return_ACPI_STATUS(status); | 108 | return_ACPI_STATUS(status); |
115 | } | 109 | } |
116 | } | 110 | } |
117 | 111 | ||
118 | /* | 112 | /* |
119 | * For a method alias, we must grab the actual method node so that proper | 113 | * For a method alias, we must grab the actual method node so that |
120 | * scoping context will be established before execution. | 114 | * proper scoping context will be established before execution. |
121 | */ | 115 | */ |
122 | if (acpi_ns_get_type(info->resolved_node) == | 116 | if (acpi_ns_get_type(info->node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) { |
123 | ACPI_TYPE_LOCAL_METHOD_ALIAS) { | 117 | info->node = |
124 | info->resolved_node = | ||
125 | ACPI_CAST_PTR(struct acpi_namespace_node, | 118 | ACPI_CAST_PTR(struct acpi_namespace_node, |
126 | info->resolved_node->object); | 119 | info->node->object); |
120 | } | ||
121 | |||
122 | /* Complete the info block initialization */ | ||
123 | |||
124 | info->return_object = NULL; | ||
125 | info->node_flags = info->node->flags; | ||
126 | info->obj_desc = acpi_ns_get_attached_object(info->node); | ||
127 | |||
128 | ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%s [%p] Value %p\n", | ||
129 | info->relative_pathname, info->node, | ||
130 | acpi_ns_get_attached_object(info->node))); | ||
131 | |||
132 | /* Get info if we have a predefined name (_HID, etc.) */ | ||
133 | |||
134 | info->predefined = | ||
135 | acpi_ut_match_predefined_method(info->node->name.ascii); | ||
136 | |||
137 | /* Get the full pathname to the object, for use in warning messages */ | ||
138 | |||
139 | info->full_pathname = acpi_ns_get_external_pathname(info->node); | ||
140 | if (!info->full_pathname) { | ||
141 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
127 | } | 142 | } |
128 | 143 | ||
129 | ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "%s [%p] Value %p\n", info->pathname, | 144 | /* Count the number of arguments being passed in */ |
130 | info->resolved_node, | 145 | |
131 | acpi_ns_get_attached_object(info->resolved_node))); | 146 | info->param_count = 0; |
147 | if (info->parameters) { | ||
148 | while (info->parameters[info->param_count]) { | ||
149 | info->param_count++; | ||
150 | } | ||
151 | |||
152 | /* Warn on impossible argument count */ | ||
153 | |||
154 | if (info->param_count > ACPI_METHOD_NUM_ARGS) { | ||
155 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, | ||
156 | ACPI_WARN_ALWAYS, | ||
157 | "Excess arguments (%u) - using only %u", | ||
158 | info->param_count, | ||
159 | ACPI_METHOD_NUM_ARGS)); | ||
160 | |||
161 | info->param_count = ACPI_METHOD_NUM_ARGS; | ||
162 | } | ||
163 | } | ||
164 | |||
165 | /* | ||
166 | * For predefined names: Check that the declared argument count | ||
167 | * matches the ACPI spec -- otherwise this is a BIOS error. | ||
168 | */ | ||
169 | acpi_ns_check_acpi_compliance(info->full_pathname, info->node, | ||
170 | info->predefined); | ||
171 | |||
172 | /* | ||
173 | * For all names: Check that the incoming argument count for | ||
174 | * this method/object matches the actual ASL/AML definition. | ||
175 | */ | ||
176 | acpi_ns_check_argument_count(info->full_pathname, info->node, | ||
177 | info->param_count, info->predefined); | ||
132 | 178 | ||
133 | node = info->resolved_node; | 179 | /* For predefined names: Typecheck all incoming arguments */ |
180 | |||
181 | acpi_ns_check_argument_types(info); | ||
134 | 182 | ||
135 | /* | 183 | /* |
136 | * Two major cases here: | 184 | * Three major evaluation cases: |
137 | * | 185 | * |
138 | * 1) The object is a control method -- execute it | 186 | * 1) Object types that cannot be evaluated by definition |
139 | * 2) The object is not a method -- just return it's current value | 187 | * 2) The object is a control method -- execute it |
188 | * 3) The object is not a method -- just return it's current value | ||
140 | */ | 189 | */ |
141 | if (acpi_ns_get_type(info->resolved_node) == ACPI_TYPE_METHOD) { | 190 | switch (acpi_ns_get_type(info->node)) { |
191 | case ACPI_TYPE_DEVICE: | ||
192 | case ACPI_TYPE_EVENT: | ||
193 | case ACPI_TYPE_MUTEX: | ||
194 | case ACPI_TYPE_REGION: | ||
195 | case ACPI_TYPE_THERMAL: | ||
196 | case ACPI_TYPE_LOCAL_SCOPE: | ||
197 | /* | ||
198 | * 1) Disallow evaluation of certain object types. For these, | ||
199 | * object evaluation is undefined and not supported. | ||
200 | */ | ||
201 | ACPI_ERROR((AE_INFO, | ||
202 | "%s: Evaluation of object type [%s] is not supported", | ||
203 | info->full_pathname, | ||
204 | acpi_ut_get_type_name(info->node->type))); | ||
205 | |||
206 | status = AE_TYPE; | ||
207 | goto cleanup; | ||
208 | |||
209 | case ACPI_TYPE_METHOD: | ||
142 | /* | 210 | /* |
143 | * 1) Object is a control method - execute it | 211 | * 2) Object is a control method - execute it |
144 | */ | 212 | */ |
145 | 213 | ||
146 | /* Verify that there is a method object associated with this node */ | 214 | /* Verify that there is a method object associated with this node */ |
147 | 215 | ||
148 | info->obj_desc = | ||
149 | acpi_ns_get_attached_object(info->resolved_node); | ||
150 | if (!info->obj_desc) { | 216 | if (!info->obj_desc) { |
151 | ACPI_ERROR((AE_INFO, | 217 | ACPI_ERROR((AE_INFO, |
152 | "Control method has no attached sub-object")); | 218 | "%s: Method has no attached sub-object", |
153 | return_ACPI_STATUS(AE_NULL_OBJECT); | 219 | info->full_pathname)); |
220 | status = AE_NULL_OBJECT; | ||
221 | goto cleanup; | ||
154 | } | 222 | } |
155 | 223 | ||
156 | /* Count the number of arguments being passed to the method */ | ||
157 | |||
158 | if (info->parameters) { | ||
159 | while (info->parameters[info->param_count]) { | ||
160 | if (info->param_count > ACPI_METHOD_MAX_ARG) { | ||
161 | return_ACPI_STATUS(AE_LIMIT); | ||
162 | } | ||
163 | info->param_count++; | ||
164 | } | ||
165 | } | ||
166 | |||
167 | |||
168 | ACPI_DUMP_PATHNAME(info->resolved_node, "ACPI: Execute Method", | ||
169 | ACPI_LV_INFO, _COMPONENT); | ||
170 | |||
171 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 224 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
172 | "Method at AML address %p Length %X\n", | 225 | "**** Execute method [%s] at AML address %p length %X\n", |
226 | info->full_pathname, | ||
173 | info->obj_desc->method.aml_start + 1, | 227 | info->obj_desc->method.aml_start + 1, |
174 | info->obj_desc->method.aml_length - 1)); | 228 | info->obj_desc->method.aml_length - 1)); |
175 | 229 | ||
@@ -184,81 +238,61 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) | |||
184 | acpi_ex_enter_interpreter(); | 238 | acpi_ex_enter_interpreter(); |
185 | status = acpi_ps_execute_method(info); | 239 | status = acpi_ps_execute_method(info); |
186 | acpi_ex_exit_interpreter(); | 240 | acpi_ex_exit_interpreter(); |
187 | } else { | 241 | break; |
242 | |||
243 | default: | ||
188 | /* | 244 | /* |
189 | * 2) Object is not a method, return its current value | 245 | * 3) All other non-method objects -- get the current object value |
190 | * | ||
191 | * Disallow certain object types. For these, "evaluation" is undefined. | ||
192 | */ | 246 | */ |
193 | switch (info->resolved_node->type) { | ||
194 | case ACPI_TYPE_DEVICE: | ||
195 | case ACPI_TYPE_EVENT: | ||
196 | case ACPI_TYPE_MUTEX: | ||
197 | case ACPI_TYPE_REGION: | ||
198 | case ACPI_TYPE_THERMAL: | ||
199 | case ACPI_TYPE_LOCAL_SCOPE: | ||
200 | |||
201 | ACPI_ERROR((AE_INFO, | ||
202 | "[%4.4s] Evaluation of object type [%s] is not supported", | ||
203 | info->resolved_node->name.ascii, | ||
204 | acpi_ut_get_type_name(info->resolved_node-> | ||
205 | type))); | ||
206 | |||
207 | return_ACPI_STATUS(AE_TYPE); | ||
208 | |||
209 | default: | ||
210 | break; | ||
211 | } | ||
212 | 247 | ||
213 | /* | 248 | /* |
214 | * Objects require additional resolution steps (e.g., the Node may be | 249 | * Some objects require additional resolution steps (e.g., the Node |
215 | * a field that must be read, etc.) -- we can't just grab the object | 250 | * may be a field that must be read, etc.) -- we can't just grab |
216 | * out of the node. | 251 | * the object out of the node. |
217 | * | 252 | * |
218 | * Use resolve_node_to_value() to get the associated value. | 253 | * Use resolve_node_to_value() to get the associated value. |
219 | * | 254 | * |
220 | * NOTE: we can get away with passing in NULL for a walk state because | 255 | * NOTE: we can get away with passing in NULL for a walk state because |
221 | * resolved_node is guaranteed to not be a reference to either a method | 256 | * the Node is guaranteed to not be a reference to either a method |
222 | * local or a method argument (because this interface is never called | 257 | * local or a method argument (because this interface is never called |
223 | * from a running method.) | 258 | * from a running method.) |
224 | * | 259 | * |
225 | * Even though we do not directly invoke the interpreter for object | 260 | * Even though we do not directly invoke the interpreter for object |
226 | * resolution, we must lock it because we could access an opregion. | 261 | * resolution, we must lock it because we could access an op_region. |
227 | * The opregion access code assumes that the interpreter is locked. | 262 | * The op_region access code assumes that the interpreter is locked. |
228 | */ | 263 | */ |
229 | acpi_ex_enter_interpreter(); | 264 | acpi_ex_enter_interpreter(); |
230 | 265 | ||
231 | /* Function has a strange interface */ | 266 | /* TBD: resolve_node_to_value has a strange interface, fix */ |
267 | |||
268 | info->return_object = | ||
269 | ACPI_CAST_PTR(union acpi_operand_object, info->node); | ||
232 | 270 | ||
233 | status = | 271 | status = |
234 | acpi_ex_resolve_node_to_value(&info->resolved_node, NULL); | 272 | acpi_ex_resolve_node_to_value(ACPI_CAST_INDIRECT_PTR |
273 | (struct acpi_namespace_node, | ||
274 | &info->return_object), NULL); | ||
235 | acpi_ex_exit_interpreter(); | 275 | acpi_ex_exit_interpreter(); |
236 | 276 | ||
237 | /* | 277 | if (ACPI_FAILURE(status)) { |
238 | * If acpi_ex_resolve_node_to_value() succeeded, the return value was placed | 278 | goto cleanup; |
239 | * in resolved_node. | ||
240 | */ | ||
241 | if (ACPI_SUCCESS(status)) { | ||
242 | status = AE_CTRL_RETURN_VALUE; | ||
243 | info->return_object = | ||
244 | ACPI_CAST_PTR(union acpi_operand_object, | ||
245 | info->resolved_node); | ||
246 | |||
247 | ACPI_DEBUG_PRINT((ACPI_DB_NAMES, | ||
248 | "Returning object %p [%s]\n", | ||
249 | info->return_object, | ||
250 | acpi_ut_get_object_type_name(info-> | ||
251 | return_object))); | ||
252 | } | 279 | } |
280 | |||
281 | ACPI_DEBUG_PRINT((ACPI_DB_NAMES, "Returned object %p [%s]\n", | ||
282 | info->return_object, | ||
283 | acpi_ut_get_object_type_name(info-> | ||
284 | return_object))); | ||
285 | |||
286 | status = AE_CTRL_RETURN_VALUE; /* Always has a "return value" */ | ||
287 | break; | ||
253 | } | 288 | } |
254 | 289 | ||
255 | /* | 290 | /* |
256 | * Check input argument count against the ASL-defined count for a method. | 291 | * For predefined names, check the return value against the ACPI |
257 | * Also check predefined names: argument count and return value against | 292 | * specification. Some incorrect return value types are repaired. |
258 | * the ACPI specification. Some incorrect return value types are repaired. | ||
259 | */ | 293 | */ |
260 | (void)acpi_ns_check_predefined_names(node, info->param_count, | 294 | (void)acpi_ns_check_return_value(info->node, info, info->param_count, |
261 | status, &info->return_object); | 295 | status, &info->return_object); |
262 | 296 | ||
263 | /* Check if there is a return value that must be dealt with */ | 297 | /* Check if there is a return value that must be dealt with */ |
264 | 298 | ||
@@ -278,12 +312,15 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) | |||
278 | 312 | ||
279 | ACPI_DEBUG_PRINT((ACPI_DB_NAMES, | 313 | ACPI_DEBUG_PRINT((ACPI_DB_NAMES, |
280 | "*** Completed evaluation of object %s ***\n", | 314 | "*** Completed evaluation of object %s ***\n", |
281 | info->pathname)); | 315 | info->relative_pathname)); |
282 | 316 | ||
317 | cleanup: | ||
283 | /* | 318 | /* |
284 | * Namespace was unlocked by the handling acpi_ns* function, so we | 319 | * Namespace was unlocked by the handling acpi_ns* function, so we |
285 | * just return | 320 | * just free the pathname and return |
286 | */ | 321 | */ |
322 | ACPI_FREE(info->full_pathname); | ||
323 | info->full_pathname = NULL; | ||
287 | return_ACPI_STATUS(status); | 324 | return_ACPI_STATUS(status); |
288 | } | 325 | } |
289 | 326 | ||
diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c index 46f0f83417a1..dd2ceae3f717 100644 --- a/drivers/acpi/acpica/nsinit.c +++ b/drivers/acpi/acpica/nsinit.c | |||
@@ -176,7 +176,7 @@ acpi_status acpi_ns_initialize_devices(void) | |||
176 | * part of the ACPI specification. | 176 | * part of the ACPI specification. |
177 | */ | 177 | */ |
178 | info.evaluate_info->prefix_node = acpi_gbl_root_node; | 178 | info.evaluate_info->prefix_node = acpi_gbl_root_node; |
179 | info.evaluate_info->pathname = METHOD_NAME__INI; | 179 | info.evaluate_info->relative_pathname = METHOD_NAME__INI; |
180 | info.evaluate_info->parameters = NULL; | 180 | info.evaluate_info->parameters = NULL; |
181 | info.evaluate_info->flags = ACPI_IGNORE_RETURN_VALUE; | 181 | info.evaluate_info->flags = ACPI_IGNORE_RETURN_VALUE; |
182 | 182 | ||
@@ -266,28 +266,34 @@ acpi_ns_init_one_object(acpi_handle obj_handle, | |||
266 | 266 | ||
267 | switch (type) { | 267 | switch (type) { |
268 | case ACPI_TYPE_REGION: | 268 | case ACPI_TYPE_REGION: |
269 | |||
269 | info->op_region_count++; | 270 | info->op_region_count++; |
270 | break; | 271 | break; |
271 | 272 | ||
272 | case ACPI_TYPE_BUFFER_FIELD: | 273 | case ACPI_TYPE_BUFFER_FIELD: |
274 | |||
273 | info->field_count++; | 275 | info->field_count++; |
274 | break; | 276 | break; |
275 | 277 | ||
276 | case ACPI_TYPE_LOCAL_BANK_FIELD: | 278 | case ACPI_TYPE_LOCAL_BANK_FIELD: |
279 | |||
277 | info->field_count++; | 280 | info->field_count++; |
278 | break; | 281 | break; |
279 | 282 | ||
280 | case ACPI_TYPE_BUFFER: | 283 | case ACPI_TYPE_BUFFER: |
284 | |||
281 | info->buffer_count++; | 285 | info->buffer_count++; |
282 | break; | 286 | break; |
283 | 287 | ||
284 | case ACPI_TYPE_PACKAGE: | 288 | case ACPI_TYPE_PACKAGE: |
289 | |||
285 | info->package_count++; | 290 | info->package_count++; |
286 | break; | 291 | break; |
287 | 292 | ||
288 | default: | 293 | default: |
289 | 294 | ||
290 | /* No init required, just exit now */ | 295 | /* No init required, just exit now */ |
296 | |||
291 | return (AE_OK); | 297 | return (AE_OK); |
292 | } | 298 | } |
293 | 299 | ||
@@ -337,7 +343,9 @@ acpi_ns_init_one_object(acpi_handle obj_handle, | |||
337 | break; | 343 | break; |
338 | 344 | ||
339 | default: | 345 | default: |
346 | |||
340 | /* No other types can get here */ | 347 | /* No other types can get here */ |
348 | |||
341 | break; | 349 | break; |
342 | } | 350 | } |
343 | 351 | ||
@@ -416,6 +424,7 @@ acpi_ns_find_ini_methods(acpi_handle obj_handle, | |||
416 | break; | 424 | break; |
417 | 425 | ||
418 | default: | 426 | default: |
427 | |||
419 | break; | 428 | break; |
420 | } | 429 | } |
421 | 430 | ||
@@ -560,7 +569,7 @@ acpi_ns_init_one_device(acpi_handle obj_handle, | |||
560 | 569 | ||
561 | ACPI_MEMSET(info, 0, sizeof(struct acpi_evaluate_info)); | 570 | ACPI_MEMSET(info, 0, sizeof(struct acpi_evaluate_info)); |
562 | info->prefix_node = device_node; | 571 | info->prefix_node = device_node; |
563 | info->pathname = METHOD_NAME__INI; | 572 | info->relative_pathname = METHOD_NAME__INI; |
564 | info->parameters = NULL; | 573 | info->parameters = NULL; |
565 | info->flags = ACPI_IGNORE_RETURN_VALUE; | 574 | info->flags = ACPI_IGNORE_RETURN_VALUE; |
566 | 575 | ||
@@ -574,8 +583,7 @@ acpi_ns_init_one_device(acpi_handle obj_handle, | |||
574 | 583 | ||
575 | /* Ignore error and move on to next device */ | 584 | /* Ignore error and move on to next device */ |
576 | 585 | ||
577 | char *scope_name = | 586 | char *scope_name = acpi_ns_get_external_pathname(info->node); |
578 | acpi_ns_get_external_pathname(info->resolved_node); | ||
579 | 587 | ||
580 | ACPI_EXCEPTION((AE_INFO, status, "during %s._INI execution", | 588 | ACPI_EXCEPTION((AE_INFO, status, "during %s._INI execution", |
581 | scope_name)); | 589 | scope_name)); |
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c index 8a52916148cb..24b71a01bf93 100644 --- a/drivers/acpi/acpica/nspredef.c +++ b/drivers/acpi/acpica/nspredef.c | |||
@@ -61,28 +61,29 @@ ACPI_MODULE_NAME("nspredef") | |||
61 | * There are several areas that are validated: | 61 | * There are several areas that are validated: |
62 | * | 62 | * |
63 | * 1) The number of input arguments as defined by the method/object in the | 63 | * 1) The number of input arguments as defined by the method/object in the |
64 | * ASL is validated against the ACPI specification. | 64 | * ASL is validated against the ACPI specification. |
65 | * 2) The type of the return object (if any) is validated against the ACPI | 65 | * 2) The type of the return object (if any) is validated against the ACPI |
66 | * specification. | 66 | * specification. |
67 | * 3) For returned package objects, the count of package elements is | 67 | * 3) For returned package objects, the count of package elements is |
68 | * validated, as well as the type of each package element. Nested | 68 | * validated, as well as the type of each package element. Nested |
69 | * packages are supported. | 69 | * packages are supported. |
70 | * | 70 | * |
71 | * For any problems found, a warning message is issued. | 71 | * For any problems found, a warning message is issued. |
72 | * | 72 | * |
73 | ******************************************************************************/ | 73 | ******************************************************************************/ |
74 | /* Local prototypes */ | 74 | /* Local prototypes */ |
75 | static acpi_status | 75 | static acpi_status |
76 | acpi_ns_check_reference(struct acpi_predefined_data *data, | 76 | acpi_ns_check_reference(struct acpi_evaluate_info *info, |
77 | union acpi_operand_object *return_object); | 77 | union acpi_operand_object *return_object); |
78 | 78 | ||
79 | static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object); | 79 | static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object); |
80 | 80 | ||
81 | /******************************************************************************* | 81 | /******************************************************************************* |
82 | * | 82 | * |
83 | * FUNCTION: acpi_ns_check_predefined_names | 83 | * FUNCTION: acpi_ns_check_return_value |
84 | * | 84 | * |
85 | * PARAMETERS: node - Namespace node for the method/object | 85 | * PARAMETERS: node - Namespace node for the method/object |
86 | * info - Method execution information block | ||
86 | * user_param_count - Number of parameters actually passed | 87 | * user_param_count - Number of parameters actually passed |
87 | * return_status - Status from the object evaluation | 88 | * return_status - Status from the object evaluation |
88 | * return_object_ptr - Pointer to the object returned from the | 89 | * return_object_ptr - Pointer to the object returned from the |
@@ -90,44 +91,25 @@ static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object); | |||
90 | * | 91 | * |
91 | * RETURN: Status | 92 | * RETURN: Status |
92 | * | 93 | * |
93 | * DESCRIPTION: Check an ACPI name for a match in the predefined name list. | 94 | * DESCRIPTION: Check the value returned from a predefined name. |
94 | * | 95 | * |
95 | ******************************************************************************/ | 96 | ******************************************************************************/ |
96 | 97 | ||
97 | acpi_status | 98 | acpi_status |
98 | acpi_ns_check_predefined_names(struct acpi_namespace_node *node, | 99 | acpi_ns_check_return_value(struct acpi_namespace_node *node, |
99 | u32 user_param_count, | 100 | struct acpi_evaluate_info *info, |
100 | acpi_status return_status, | 101 | u32 user_param_count, |
101 | union acpi_operand_object **return_object_ptr) | 102 | acpi_status return_status, |
103 | union acpi_operand_object **return_object_ptr) | ||
102 | { | 104 | { |
103 | acpi_status status = AE_OK; | 105 | acpi_status status; |
104 | const union acpi_predefined_info *predefined; | 106 | const union acpi_predefined_info *predefined; |
105 | char *pathname; | ||
106 | struct acpi_predefined_data *data; | ||
107 | |||
108 | /* Match the name for this method/object against the predefined list */ | ||
109 | |||
110 | predefined = acpi_ut_match_predefined_method(node->name.ascii); | ||
111 | |||
112 | /* Get the full pathname to the object, for use in warning messages */ | ||
113 | |||
114 | pathname = acpi_ns_get_external_pathname(node); | ||
115 | if (!pathname) { | ||
116 | return (AE_OK); /* Could not get pathname, ignore */ | ||
117 | } | ||
118 | |||
119 | /* | ||
120 | * Check that the parameter count for this method matches the ASL | ||
121 | * definition. For predefined names, ensure that both the caller and | ||
122 | * the method itself are in accordance with the ACPI specification. | ||
123 | */ | ||
124 | acpi_ns_check_parameter_count(pathname, node, user_param_count, | ||
125 | predefined); | ||
126 | 107 | ||
127 | /* If not a predefined name, we cannot validate the return object */ | 108 | /* If not a predefined name, we cannot validate the return object */ |
128 | 109 | ||
110 | predefined = info->predefined; | ||
129 | if (!predefined) { | 111 | if (!predefined) { |
130 | goto cleanup; | 112 | return (AE_OK); |
131 | } | 113 | } |
132 | 114 | ||
133 | /* | 115 | /* |
@@ -135,7 +117,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node, | |||
135 | * validate the return object | 117 | * validate the return object |
136 | */ | 118 | */ |
137 | if ((return_status != AE_OK) && (return_status != AE_CTRL_RETURN_VALUE)) { | 119 | if ((return_status != AE_OK) && (return_status != AE_CTRL_RETURN_VALUE)) { |
138 | goto cleanup; | 120 | return (AE_OK); |
139 | } | 121 | } |
140 | 122 | ||
141 | /* | 123 | /* |
@@ -154,25 +136,14 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node, | |||
154 | if (acpi_gbl_disable_auto_repair || | 136 | if (acpi_gbl_disable_auto_repair || |
155 | (!predefined->info.expected_btypes) || | 137 | (!predefined->info.expected_btypes) || |
156 | (predefined->info.expected_btypes == ACPI_RTYPE_ALL)) { | 138 | (predefined->info.expected_btypes == ACPI_RTYPE_ALL)) { |
157 | goto cleanup; | 139 | return (AE_OK); |
158 | } | ||
159 | |||
160 | /* Create the parameter data block for object validation */ | ||
161 | |||
162 | data = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_predefined_data)); | ||
163 | if (!data) { | ||
164 | goto cleanup; | ||
165 | } | 140 | } |
166 | data->predefined = predefined; | ||
167 | data->node = node; | ||
168 | data->node_flags = node->flags; | ||
169 | data->pathname = pathname; | ||
170 | 141 | ||
171 | /* | 142 | /* |
172 | * Check that the type of the main return object is what is expected | 143 | * Check that the type of the main return object is what is expected |
173 | * for this predefined name | 144 | * for this predefined name |
174 | */ | 145 | */ |
175 | status = acpi_ns_check_object_type(data, return_object_ptr, | 146 | status = acpi_ns_check_object_type(info, return_object_ptr, |
176 | predefined->info.expected_btypes, | 147 | predefined->info.expected_btypes, |
177 | ACPI_NOT_PACKAGE_ELEMENT); | 148 | ACPI_NOT_PACKAGE_ELEMENT); |
178 | if (ACPI_FAILURE(status)) { | 149 | if (ACPI_FAILURE(status)) { |
@@ -184,10 +155,16 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node, | |||
184 | * Note: Package may have been newly created by call above. | 155 | * Note: Package may have been newly created by call above. |
185 | */ | 156 | */ |
186 | if ((*return_object_ptr)->common.type == ACPI_TYPE_PACKAGE) { | 157 | if ((*return_object_ptr)->common.type == ACPI_TYPE_PACKAGE) { |
187 | data->parent_package = *return_object_ptr; | 158 | info->parent_package = *return_object_ptr; |
188 | status = acpi_ns_check_package(data, return_object_ptr); | 159 | status = acpi_ns_check_package(info, return_object_ptr); |
189 | if (ACPI_FAILURE(status)) { | 160 | if (ACPI_FAILURE(status)) { |
190 | goto exit; | 161 | |
162 | /* We might be able to fix some errors */ | ||
163 | |||
164 | if ((status != AE_AML_OPERAND_TYPE) && | ||
165 | (status != AE_AML_OPERAND_VALUE)) { | ||
166 | goto exit; | ||
167 | } | ||
191 | } | 168 | } |
192 | } | 169 | } |
193 | 170 | ||
@@ -199,7 +176,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node, | |||
199 | * performed on a per-name basis, i.e., the code is specific to | 176 | * performed on a per-name basis, i.e., the code is specific to |
200 | * particular predefined names. | 177 | * particular predefined names. |
201 | */ | 178 | */ |
202 | status = acpi_ns_complex_repairs(data, node, status, return_object_ptr); | 179 | status = acpi_ns_complex_repairs(info, node, status, return_object_ptr); |
203 | 180 | ||
204 | exit: | 181 | exit: |
205 | /* | 182 | /* |
@@ -207,112 +184,18 @@ exit: | |||
207 | * or more objects, mark the parent node to suppress further warning | 184 | * or more objects, mark the parent node to suppress further warning |
208 | * messages during the next evaluation of the same method/object. | 185 | * messages during the next evaluation of the same method/object. |
209 | */ | 186 | */ |
210 | if (ACPI_FAILURE(status) || (data->flags & ACPI_OBJECT_REPAIRED)) { | 187 | if (ACPI_FAILURE(status) || (info->return_flags & ACPI_OBJECT_REPAIRED)) { |
211 | node->flags |= ANOBJ_EVALUATED; | 188 | node->flags |= ANOBJ_EVALUATED; |
212 | } | 189 | } |
213 | ACPI_FREE(data); | ||
214 | 190 | ||
215 | cleanup: | ||
216 | ACPI_FREE(pathname); | ||
217 | return (status); | 191 | return (status); |
218 | } | 192 | } |
219 | 193 | ||
220 | /******************************************************************************* | 194 | /******************************************************************************* |
221 | * | 195 | * |
222 | * FUNCTION: acpi_ns_check_parameter_count | ||
223 | * | ||
224 | * PARAMETERS: pathname - Full pathname to the node (for error msgs) | ||
225 | * node - Namespace node for the method/object | ||
226 | * user_param_count - Number of args passed in by the caller | ||
227 | * predefined - Pointer to entry in predefined name table | ||
228 | * | ||
229 | * RETURN: None | ||
230 | * | ||
231 | * DESCRIPTION: Check that the declared (in ASL/AML) parameter count for a | ||
232 | * predefined name is what is expected (i.e., what is defined in | ||
233 | * the ACPI specification for this predefined name.) | ||
234 | * | ||
235 | ******************************************************************************/ | ||
236 | |||
237 | void | ||
238 | acpi_ns_check_parameter_count(char *pathname, | ||
239 | struct acpi_namespace_node *node, | ||
240 | u32 user_param_count, | ||
241 | const union acpi_predefined_info *predefined) | ||
242 | { | ||
243 | u32 param_count; | ||
244 | u32 required_params_current; | ||
245 | u32 required_params_old; | ||
246 | |||
247 | /* Methods have 0-7 parameters. All other types have zero. */ | ||
248 | |||
249 | param_count = 0; | ||
250 | if (node->type == ACPI_TYPE_METHOD) { | ||
251 | param_count = node->object->method.param_count; | ||
252 | } | ||
253 | |||
254 | if (!predefined) { | ||
255 | /* | ||
256 | * Check the parameter count for non-predefined methods/objects. | ||
257 | * | ||
258 | * Warning if too few or too many arguments have been passed by the | ||
259 | * caller. An incorrect number of arguments may not cause the method | ||
260 | * to fail. However, the method will fail if there are too few | ||
261 | * arguments and the method attempts to use one of the missing ones. | ||
262 | */ | ||
263 | if (user_param_count < param_count) { | ||
264 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, | ||
265 | ACPI_WARN_ALWAYS, | ||
266 | "Insufficient arguments - needs %u, found %u", | ||
267 | param_count, user_param_count)); | ||
268 | } else if (user_param_count > param_count) { | ||
269 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, | ||
270 | ACPI_WARN_ALWAYS, | ||
271 | "Excess arguments - needs %u, found %u", | ||
272 | param_count, user_param_count)); | ||
273 | } | ||
274 | return; | ||
275 | } | ||
276 | |||
277 | /* | ||
278 | * Validate the user-supplied parameter count. | ||
279 | * Allow two different legal argument counts (_SCP, etc.) | ||
280 | */ | ||
281 | required_params_current = | ||
282 | predefined->info.argument_list & METHOD_ARG_MASK; | ||
283 | required_params_old = | ||
284 | predefined->info.argument_list >> METHOD_ARG_BIT_WIDTH; | ||
285 | |||
286 | if (user_param_count != ACPI_UINT32_MAX) { | ||
287 | if ((user_param_count != required_params_current) && | ||
288 | (user_param_count != required_params_old)) { | ||
289 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, | ||
290 | ACPI_WARN_ALWAYS, | ||
291 | "Parameter count mismatch - " | ||
292 | "caller passed %u, ACPI requires %u", | ||
293 | user_param_count, | ||
294 | required_params_current)); | ||
295 | } | ||
296 | } | ||
297 | |||
298 | /* | ||
299 | * Check that the ASL-defined parameter count is what is expected for | ||
300 | * this predefined name (parameter count as defined by the ACPI | ||
301 | * specification) | ||
302 | */ | ||
303 | if ((param_count != required_params_current) && | ||
304 | (param_count != required_params_old)) { | ||
305 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, node->flags, | ||
306 | "Parameter count mismatch - ASL declared %u, ACPI requires %u", | ||
307 | param_count, required_params_current)); | ||
308 | } | ||
309 | } | ||
310 | |||
311 | /******************************************************************************* | ||
312 | * | ||
313 | * FUNCTION: acpi_ns_check_object_type | 196 | * FUNCTION: acpi_ns_check_object_type |
314 | * | 197 | * |
315 | * PARAMETERS: data - Pointer to validation data structure | 198 | * PARAMETERS: info - Method execution information block |
316 | * return_object_ptr - Pointer to the object returned from the | 199 | * return_object_ptr - Pointer to the object returned from the |
317 | * evaluation of a method or object | 200 | * evaluation of a method or object |
318 | * expected_btypes - Bitmap of expected return type(s) | 201 | * expected_btypes - Bitmap of expected return type(s) |
@@ -328,7 +211,7 @@ acpi_ns_check_parameter_count(char *pathname, | |||
328 | ******************************************************************************/ | 211 | ******************************************************************************/ |
329 | 212 | ||
330 | acpi_status | 213 | acpi_status |
331 | acpi_ns_check_object_type(struct acpi_predefined_data *data, | 214 | acpi_ns_check_object_type(struct acpi_evaluate_info *info, |
332 | union acpi_operand_object **return_object_ptr, | 215 | union acpi_operand_object **return_object_ptr, |
333 | u32 expected_btypes, u32 package_index) | 216 | u32 expected_btypes, u32 package_index) |
334 | { | 217 | { |
@@ -340,7 +223,8 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data, | |||
340 | 223 | ||
341 | if (return_object && | 224 | if (return_object && |
342 | ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) { | 225 | ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) { |
343 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 226 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, |
227 | info->node_flags, | ||
344 | "Invalid return type - Found a Namespace node [%4.4s] type %s", | 228 | "Invalid return type - Found a Namespace node [%4.4s] type %s", |
345 | return_object->node.name.ascii, | 229 | return_object->node.name.ascii, |
346 | acpi_ut_get_type_name(return_object->node. | 230 | acpi_ut_get_type_name(return_object->node. |
@@ -356,8 +240,8 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data, | |||
356 | * from all of the predefined names (including elements of returned | 240 | * from all of the predefined names (including elements of returned |
357 | * packages) | 241 | * packages) |
358 | */ | 242 | */ |
359 | data->return_btype = acpi_ns_get_bitmapped_type(return_object); | 243 | info->return_btype = acpi_ns_get_bitmapped_type(return_object); |
360 | if (data->return_btype == ACPI_RTYPE_ANY) { | 244 | if (info->return_btype == ACPI_RTYPE_ANY) { |
361 | 245 | ||
362 | /* Not one of the supported objects, must be incorrect */ | 246 | /* Not one of the supported objects, must be incorrect */ |
363 | goto type_error_exit; | 247 | goto type_error_exit; |
@@ -365,16 +249,18 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data, | |||
365 | 249 | ||
366 | /* For reference objects, check that the reference type is correct */ | 250 | /* For reference objects, check that the reference type is correct */ |
367 | 251 | ||
368 | if ((data->return_btype & expected_btypes) == ACPI_RTYPE_REFERENCE) { | 252 | if ((info->return_btype & expected_btypes) == ACPI_RTYPE_REFERENCE) { |
369 | status = acpi_ns_check_reference(data, return_object); | 253 | status = acpi_ns_check_reference(info, return_object); |
370 | return (status); | 254 | return (status); |
371 | } | 255 | } |
372 | 256 | ||
373 | /* Attempt simple repair of the returned object if necessary */ | 257 | /* Attempt simple repair of the returned object if necessary */ |
374 | 258 | ||
375 | status = acpi_ns_simple_repair(data, expected_btypes, | 259 | status = acpi_ns_simple_repair(info, expected_btypes, |
376 | package_index, return_object_ptr); | 260 | package_index, return_object_ptr); |
377 | return (status); | 261 | if (ACPI_SUCCESS(status)) { |
262 | return (AE_OK); /* Successful repair */ | ||
263 | } | ||
378 | 264 | ||
379 | type_error_exit: | 265 | type_error_exit: |
380 | 266 | ||
@@ -383,12 +269,14 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data, | |||
383 | acpi_ut_get_expected_return_types(type_buffer, expected_btypes); | 269 | acpi_ut_get_expected_return_types(type_buffer, expected_btypes); |
384 | 270 | ||
385 | if (package_index == ACPI_NOT_PACKAGE_ELEMENT) { | 271 | if (package_index == ACPI_NOT_PACKAGE_ELEMENT) { |
386 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 272 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, |
273 | info->node_flags, | ||
387 | "Return type mismatch - found %s, expected %s", | 274 | "Return type mismatch - found %s, expected %s", |
388 | acpi_ut_get_object_type_name | 275 | acpi_ut_get_object_type_name |
389 | (return_object), type_buffer)); | 276 | (return_object), type_buffer)); |
390 | } else { | 277 | } else { |
391 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 278 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, |
279 | info->node_flags, | ||
392 | "Return Package type mismatch at index %u - " | 280 | "Return Package type mismatch at index %u - " |
393 | "found %s, expected %s", package_index, | 281 | "found %s, expected %s", package_index, |
394 | acpi_ut_get_object_type_name | 282 | acpi_ut_get_object_type_name |
@@ -402,7 +290,7 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data, | |||
402 | * | 290 | * |
403 | * FUNCTION: acpi_ns_check_reference | 291 | * FUNCTION: acpi_ns_check_reference |
404 | * | 292 | * |
405 | * PARAMETERS: data - Pointer to validation data structure | 293 | * PARAMETERS: info - Method execution information block |
406 | * return_object - Object returned from the evaluation of a | 294 | * return_object - Object returned from the evaluation of a |
407 | * method or object | 295 | * method or object |
408 | * | 296 | * |
@@ -415,7 +303,7 @@ acpi_ns_check_object_type(struct acpi_predefined_data *data, | |||
415 | ******************************************************************************/ | 303 | ******************************************************************************/ |
416 | 304 | ||
417 | static acpi_status | 305 | static acpi_status |
418 | acpi_ns_check_reference(struct acpi_predefined_data *data, | 306 | acpi_ns_check_reference(struct acpi_evaluate_info *info, |
419 | union acpi_operand_object *return_object) | 307 | union acpi_operand_object *return_object) |
420 | { | 308 | { |
421 | 309 | ||
@@ -428,7 +316,7 @@ acpi_ns_check_reference(struct acpi_predefined_data *data, | |||
428 | return (AE_OK); | 316 | return (AE_OK); |
429 | } | 317 | } |
430 | 318 | ||
431 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 319 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, info->node_flags, |
432 | "Return type mismatch - unexpected reference object type [%s] %2.2X", | 320 | "Return type mismatch - unexpected reference object type [%s] %2.2X", |
433 | acpi_ut_get_reference_name(return_object), | 321 | acpi_ut_get_reference_name(return_object), |
434 | return_object->reference.class)); | 322 | return_object->reference.class)); |
@@ -462,26 +350,32 @@ static u32 acpi_ns_get_bitmapped_type(union acpi_operand_object *return_object) | |||
462 | 350 | ||
463 | switch (return_object->common.type) { | 351 | switch (return_object->common.type) { |
464 | case ACPI_TYPE_INTEGER: | 352 | case ACPI_TYPE_INTEGER: |
353 | |||
465 | return_btype = ACPI_RTYPE_INTEGER; | 354 | return_btype = ACPI_RTYPE_INTEGER; |
466 | break; | 355 | break; |
467 | 356 | ||
468 | case ACPI_TYPE_BUFFER: | 357 | case ACPI_TYPE_BUFFER: |
358 | |||
469 | return_btype = ACPI_RTYPE_BUFFER; | 359 | return_btype = ACPI_RTYPE_BUFFER; |
470 | break; | 360 | break; |
471 | 361 | ||
472 | case ACPI_TYPE_STRING: | 362 | case ACPI_TYPE_STRING: |
363 | |||
473 | return_btype = ACPI_RTYPE_STRING; | 364 | return_btype = ACPI_RTYPE_STRING; |
474 | break; | 365 | break; |
475 | 366 | ||
476 | case ACPI_TYPE_PACKAGE: | 367 | case ACPI_TYPE_PACKAGE: |
368 | |||
477 | return_btype = ACPI_RTYPE_PACKAGE; | 369 | return_btype = ACPI_RTYPE_PACKAGE; |
478 | break; | 370 | break; |
479 | 371 | ||
480 | case ACPI_TYPE_LOCAL_REFERENCE: | 372 | case ACPI_TYPE_LOCAL_REFERENCE: |
373 | |||
481 | return_btype = ACPI_RTYPE_REFERENCE; | 374 | return_btype = ACPI_RTYPE_REFERENCE; |
482 | break; | 375 | break; |
483 | 376 | ||
484 | default: | 377 | default: |
378 | |||
485 | /* Not one of the supported objects, must be incorrect */ | 379 | /* Not one of the supported objects, must be incorrect */ |
486 | 380 | ||
487 | return_btype = ACPI_RTYPE_ANY; | 381 | return_btype = ACPI_RTYPE_ANY; |
diff --git a/drivers/acpi/acpica/nsprepkg.c b/drivers/acpi/acpica/nsprepkg.c index 77cdd539de16..6d55cef7916c 100644 --- a/drivers/acpi/acpica/nsprepkg.c +++ b/drivers/acpi/acpica/nsprepkg.c | |||
@@ -51,12 +51,12 @@ ACPI_MODULE_NAME("nsprepkg") | |||
51 | 51 | ||
52 | /* Local prototypes */ | 52 | /* Local prototypes */ |
53 | static acpi_status | 53 | static acpi_status |
54 | acpi_ns_check_package_list(struct acpi_predefined_data *data, | 54 | acpi_ns_check_package_list(struct acpi_evaluate_info *info, |
55 | const union acpi_predefined_info *package, | 55 | const union acpi_predefined_info *package, |
56 | union acpi_operand_object **elements, u32 count); | 56 | union acpi_operand_object **elements, u32 count); |
57 | 57 | ||
58 | static acpi_status | 58 | static acpi_status |
59 | acpi_ns_check_package_elements(struct acpi_predefined_data *data, | 59 | acpi_ns_check_package_elements(struct acpi_evaluate_info *info, |
60 | union acpi_operand_object **elements, | 60 | union acpi_operand_object **elements, |
61 | u8 type1, | 61 | u8 type1, |
62 | u32 count1, | 62 | u32 count1, |
@@ -66,7 +66,7 @@ acpi_ns_check_package_elements(struct acpi_predefined_data *data, | |||
66 | * | 66 | * |
67 | * FUNCTION: acpi_ns_check_package | 67 | * FUNCTION: acpi_ns_check_package |
68 | * | 68 | * |
69 | * PARAMETERS: data - Pointer to validation data structure | 69 | * PARAMETERS: info - Method execution information block |
70 | * return_object_ptr - Pointer to the object returned from the | 70 | * return_object_ptr - Pointer to the object returned from the |
71 | * evaluation of a method or object | 71 | * evaluation of a method or object |
72 | * | 72 | * |
@@ -78,7 +78,7 @@ acpi_ns_check_package_elements(struct acpi_predefined_data *data, | |||
78 | ******************************************************************************/ | 78 | ******************************************************************************/ |
79 | 79 | ||
80 | acpi_status | 80 | acpi_status |
81 | acpi_ns_check_package(struct acpi_predefined_data *data, | 81 | acpi_ns_check_package(struct acpi_evaluate_info *info, |
82 | union acpi_operand_object **return_object_ptr) | 82 | union acpi_operand_object **return_object_ptr) |
83 | { | 83 | { |
84 | union acpi_operand_object *return_object = *return_object_ptr; | 84 | union acpi_operand_object *return_object = *return_object_ptr; |
@@ -93,18 +93,18 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
93 | 93 | ||
94 | /* The package info for this name is in the next table entry */ | 94 | /* The package info for this name is in the next table entry */ |
95 | 95 | ||
96 | package = data->predefined + 1; | 96 | package = info->predefined + 1; |
97 | 97 | ||
98 | ACPI_DEBUG_PRINT((ACPI_DB_NAMES, | 98 | ACPI_DEBUG_PRINT((ACPI_DB_NAMES, |
99 | "%s Validating return Package of Type %X, Count %X\n", | 99 | "%s Validating return Package of Type %X, Count %X\n", |
100 | data->pathname, package->ret_info.type, | 100 | info->full_pathname, package->ret_info.type, |
101 | return_object->package.count)); | 101 | return_object->package.count)); |
102 | 102 | ||
103 | /* | 103 | /* |
104 | * For variable-length Packages, we can safely remove all embedded | 104 | * For variable-length Packages, we can safely remove all embedded |
105 | * and trailing NULL package elements | 105 | * and trailing NULL package elements |
106 | */ | 106 | */ |
107 | acpi_ns_remove_null_elements(data, package->ret_info.type, | 107 | acpi_ns_remove_null_elements(info, package->ret_info.type, |
108 | return_object); | 108 | return_object); |
109 | 109 | ||
110 | /* Extract package count and elements array */ | 110 | /* Extract package count and elements array */ |
@@ -121,7 +121,8 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
121 | return (AE_OK); | 121 | return (AE_OK); |
122 | } | 122 | } |
123 | 123 | ||
124 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 124 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, |
125 | info->node_flags, | ||
125 | "Return Package has no elements (empty)")); | 126 | "Return Package has no elements (empty)")); |
126 | 127 | ||
127 | return (AE_AML_OPERAND_VALUE); | 128 | return (AE_AML_OPERAND_VALUE); |
@@ -135,7 +136,6 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
135 | */ | 136 | */ |
136 | switch (package->ret_info.type) { | 137 | switch (package->ret_info.type) { |
137 | case ACPI_PTYPE1_FIXED: | 138 | case ACPI_PTYPE1_FIXED: |
138 | |||
139 | /* | 139 | /* |
140 | * The package count is fixed and there are no sub-packages | 140 | * The package count is fixed and there are no sub-packages |
141 | * | 141 | * |
@@ -150,13 +150,13 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
150 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | 150 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, |
151 | "%s: Return Package is larger than needed - " | 151 | "%s: Return Package is larger than needed - " |
152 | "found %u, expected %u\n", | 152 | "found %u, expected %u\n", |
153 | data->pathname, count, | 153 | info->full_pathname, count, |
154 | expected_count)); | 154 | expected_count)); |
155 | } | 155 | } |
156 | 156 | ||
157 | /* Validate all elements of the returned package */ | 157 | /* Validate all elements of the returned package */ |
158 | 158 | ||
159 | status = acpi_ns_check_package_elements(data, elements, | 159 | status = acpi_ns_check_package_elements(info, elements, |
160 | package->ret_info. | 160 | package->ret_info. |
161 | object_type1, | 161 | object_type1, |
162 | package->ret_info. | 162 | package->ret_info. |
@@ -168,13 +168,12 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
168 | break; | 168 | break; |
169 | 169 | ||
170 | case ACPI_PTYPE1_VAR: | 170 | case ACPI_PTYPE1_VAR: |
171 | |||
172 | /* | 171 | /* |
173 | * The package count is variable, there are no sub-packages, and all | 172 | * The package count is variable, there are no sub-packages, and all |
174 | * elements must be of the same type | 173 | * elements must be of the same type |
175 | */ | 174 | */ |
176 | for (i = 0; i < count; i++) { | 175 | for (i = 0; i < count; i++) { |
177 | status = acpi_ns_check_object_type(data, elements, | 176 | status = acpi_ns_check_object_type(info, elements, |
178 | package->ret_info. | 177 | package->ret_info. |
179 | object_type1, i); | 178 | object_type1, i); |
180 | if (ACPI_FAILURE(status)) { | 179 | if (ACPI_FAILURE(status)) { |
@@ -185,7 +184,6 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
185 | break; | 184 | break; |
186 | 185 | ||
187 | case ACPI_PTYPE1_OPTION: | 186 | case ACPI_PTYPE1_OPTION: |
188 | |||
189 | /* | 187 | /* |
190 | * The package count is variable, there are no sub-packages. There are | 188 | * The package count is variable, there are no sub-packages. There are |
191 | * a fixed number of required elements, and a variable number of | 189 | * a fixed number of required elements, and a variable number of |
@@ -206,7 +204,7 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
206 | /* These are the required package elements (0, 1, or 2) */ | 204 | /* These are the required package elements (0, 1, or 2) */ |
207 | 205 | ||
208 | status = | 206 | status = |
209 | acpi_ns_check_object_type(data, elements, | 207 | acpi_ns_check_object_type(info, elements, |
210 | package-> | 208 | package-> |
211 | ret_info3. | 209 | ret_info3. |
212 | object_type[i], | 210 | object_type[i], |
@@ -218,7 +216,7 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
218 | /* These are the optional package elements */ | 216 | /* These are the optional package elements */ |
219 | 217 | ||
220 | status = | 218 | status = |
221 | acpi_ns_check_object_type(data, elements, | 219 | acpi_ns_check_object_type(info, elements, |
222 | package-> | 220 | package-> |
223 | ret_info3. | 221 | ret_info3. |
224 | tail_object_type, | 222 | tail_object_type, |
@@ -235,7 +233,7 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
235 | 233 | ||
236 | /* First element is the (Integer) revision */ | 234 | /* First element is the (Integer) revision */ |
237 | 235 | ||
238 | status = acpi_ns_check_object_type(data, elements, | 236 | status = acpi_ns_check_object_type(info, elements, |
239 | ACPI_RTYPE_INTEGER, 0); | 237 | ACPI_RTYPE_INTEGER, 0); |
240 | if (ACPI_FAILURE(status)) { | 238 | if (ACPI_FAILURE(status)) { |
241 | return (status); | 239 | return (status); |
@@ -247,14 +245,14 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
247 | /* Examine the sub-packages */ | 245 | /* Examine the sub-packages */ |
248 | 246 | ||
249 | status = | 247 | status = |
250 | acpi_ns_check_package_list(data, package, elements, count); | 248 | acpi_ns_check_package_list(info, package, elements, count); |
251 | break; | 249 | break; |
252 | 250 | ||
253 | case ACPI_PTYPE2_PKG_COUNT: | 251 | case ACPI_PTYPE2_PKG_COUNT: |
254 | 252 | ||
255 | /* First element is the (Integer) count of sub-packages to follow */ | 253 | /* First element is the (Integer) count of sub-packages to follow */ |
256 | 254 | ||
257 | status = acpi_ns_check_object_type(data, elements, | 255 | status = acpi_ns_check_object_type(info, elements, |
258 | ACPI_RTYPE_INTEGER, 0); | 256 | ACPI_RTYPE_INTEGER, 0); |
259 | if (ACPI_FAILURE(status)) { | 257 | if (ACPI_FAILURE(status)) { |
260 | return (status); | 258 | return (status); |
@@ -275,7 +273,7 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
275 | /* Examine the sub-packages */ | 273 | /* Examine the sub-packages */ |
276 | 274 | ||
277 | status = | 275 | status = |
278 | acpi_ns_check_package_list(data, package, elements, count); | 276 | acpi_ns_check_package_list(info, package, elements, count); |
279 | break; | 277 | break; |
280 | 278 | ||
281 | case ACPI_PTYPE2: | 279 | case ACPI_PTYPE2: |
@@ -283,7 +281,6 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
283 | case ACPI_PTYPE2_MIN: | 281 | case ACPI_PTYPE2_MIN: |
284 | case ACPI_PTYPE2_COUNT: | 282 | case ACPI_PTYPE2_COUNT: |
285 | case ACPI_PTYPE2_FIX_VAR: | 283 | case ACPI_PTYPE2_FIX_VAR: |
286 | |||
287 | /* | 284 | /* |
288 | * These types all return a single Package that consists of a | 285 | * These types all return a single Package that consists of a |
289 | * variable number of sub-Packages. | 286 | * variable number of sub-Packages. |
@@ -300,7 +297,7 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
300 | /* Create the new outer package and populate it */ | 297 | /* Create the new outer package and populate it */ |
301 | 298 | ||
302 | status = | 299 | status = |
303 | acpi_ns_wrap_with_package(data, return_object, | 300 | acpi_ns_wrap_with_package(info, return_object, |
304 | return_object_ptr); | 301 | return_object_ptr); |
305 | if (ACPI_FAILURE(status)) { | 302 | if (ACPI_FAILURE(status)) { |
306 | return (status); | 303 | return (status); |
@@ -316,14 +313,15 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
316 | /* Examine the sub-packages */ | 313 | /* Examine the sub-packages */ |
317 | 314 | ||
318 | status = | 315 | status = |
319 | acpi_ns_check_package_list(data, package, elements, count); | 316 | acpi_ns_check_package_list(info, package, elements, count); |
320 | break; | 317 | break; |
321 | 318 | ||
322 | default: | 319 | default: |
323 | 320 | ||
324 | /* Should not get here if predefined info table is correct */ | 321 | /* Should not get here if predefined info table is correct */ |
325 | 322 | ||
326 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 323 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, |
324 | info->node_flags, | ||
327 | "Invalid internal return type in table entry: %X", | 325 | "Invalid internal return type in table entry: %X", |
328 | package->ret_info.type)); | 326 | package->ret_info.type)); |
329 | 327 | ||
@@ -336,7 +334,7 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
336 | 334 | ||
337 | /* Error exit for the case with an incorrect package count */ | 335 | /* Error exit for the case with an incorrect package count */ |
338 | 336 | ||
339 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 337 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, info->node_flags, |
340 | "Return Package is too small - found %u elements, expected %u", | 338 | "Return Package is too small - found %u elements, expected %u", |
341 | count, expected_count)); | 339 | count, expected_count)); |
342 | 340 | ||
@@ -347,7 +345,7 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
347 | * | 345 | * |
348 | * FUNCTION: acpi_ns_check_package_list | 346 | * FUNCTION: acpi_ns_check_package_list |
349 | * | 347 | * |
350 | * PARAMETERS: data - Pointer to validation data structure | 348 | * PARAMETERS: info - Method execution information block |
351 | * package - Pointer to package-specific info for method | 349 | * package - Pointer to package-specific info for method |
352 | * elements - Element list of parent package. All elements | 350 | * elements - Element list of parent package. All elements |
353 | * of this list should be of type Package. | 351 | * of this list should be of type Package. |
@@ -360,7 +358,7 @@ acpi_ns_check_package(struct acpi_predefined_data *data, | |||
360 | ******************************************************************************/ | 358 | ******************************************************************************/ |
361 | 359 | ||
362 | static acpi_status | 360 | static acpi_status |
363 | acpi_ns_check_package_list(struct acpi_predefined_data *data, | 361 | acpi_ns_check_package_list(struct acpi_evaluate_info *info, |
364 | const union acpi_predefined_info *package, | 362 | const union acpi_predefined_info *package, |
365 | union acpi_operand_object **elements, u32 count) | 363 | union acpi_operand_object **elements, u32 count) |
366 | { | 364 | { |
@@ -381,11 +379,11 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data, | |||
381 | for (i = 0; i < count; i++) { | 379 | for (i = 0; i < count; i++) { |
382 | sub_package = *elements; | 380 | sub_package = *elements; |
383 | sub_elements = sub_package->package.elements; | 381 | sub_elements = sub_package->package.elements; |
384 | data->parent_package = sub_package; | 382 | info->parent_package = sub_package; |
385 | 383 | ||
386 | /* Each sub-object must be of type Package */ | 384 | /* Each sub-object must be of type Package */ |
387 | 385 | ||
388 | status = acpi_ns_check_object_type(data, &sub_package, | 386 | status = acpi_ns_check_object_type(info, &sub_package, |
389 | ACPI_RTYPE_PACKAGE, i); | 387 | ACPI_RTYPE_PACKAGE, i); |
390 | if (ACPI_FAILURE(status)) { | 388 | if (ACPI_FAILURE(status)) { |
391 | return (status); | 389 | return (status); |
@@ -393,7 +391,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data, | |||
393 | 391 | ||
394 | /* Examine the different types of expected sub-packages */ | 392 | /* Examine the different types of expected sub-packages */ |
395 | 393 | ||
396 | data->parent_package = sub_package; | 394 | info->parent_package = sub_package; |
397 | switch (package->ret_info.type) { | 395 | switch (package->ret_info.type) { |
398 | case ACPI_PTYPE2: | 396 | case ACPI_PTYPE2: |
399 | case ACPI_PTYPE2_PKG_COUNT: | 397 | case ACPI_PTYPE2_PKG_COUNT: |
@@ -408,7 +406,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data, | |||
408 | } | 406 | } |
409 | 407 | ||
410 | status = | 408 | status = |
411 | acpi_ns_check_package_elements(data, sub_elements, | 409 | acpi_ns_check_package_elements(info, sub_elements, |
412 | package->ret_info. | 410 | package->ret_info. |
413 | object_type1, | 411 | object_type1, |
414 | package->ret_info. | 412 | package->ret_info. |
@@ -434,7 +432,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data, | |||
434 | } | 432 | } |
435 | 433 | ||
436 | status = | 434 | status = |
437 | acpi_ns_check_package_elements(data, sub_elements, | 435 | acpi_ns_check_package_elements(info, sub_elements, |
438 | package->ret_info. | 436 | package->ret_info. |
439 | object_type1, | 437 | object_type1, |
440 | package->ret_info. | 438 | package->ret_info. |
@@ -463,7 +461,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data, | |||
463 | 461 | ||
464 | for (j = 0; j < expected_count; j++) { | 462 | for (j = 0; j < expected_count; j++) { |
465 | status = | 463 | status = |
466 | acpi_ns_check_object_type(data, | 464 | acpi_ns_check_object_type(info, |
467 | &sub_elements[j], | 465 | &sub_elements[j], |
468 | package-> | 466 | package-> |
469 | ret_info2. | 467 | ret_info2. |
@@ -487,7 +485,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data, | |||
487 | /* Check the type of each sub-package element */ | 485 | /* Check the type of each sub-package element */ |
488 | 486 | ||
489 | status = | 487 | status = |
490 | acpi_ns_check_package_elements(data, sub_elements, | 488 | acpi_ns_check_package_elements(info, sub_elements, |
491 | package->ret_info. | 489 | package->ret_info. |
492 | object_type1, | 490 | object_type1, |
493 | sub_package->package. | 491 | sub_package->package. |
@@ -498,12 +496,11 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data, | |||
498 | break; | 496 | break; |
499 | 497 | ||
500 | case ACPI_PTYPE2_COUNT: | 498 | case ACPI_PTYPE2_COUNT: |
501 | |||
502 | /* | 499 | /* |
503 | * First element is the (Integer) count of elements, including | 500 | * First element is the (Integer) count of elements, including |
504 | * the count field (the ACPI name is num_elements) | 501 | * the count field (the ACPI name is num_elements) |
505 | */ | 502 | */ |
506 | status = acpi_ns_check_object_type(data, sub_elements, | 503 | status = acpi_ns_check_object_type(info, sub_elements, |
507 | ACPI_RTYPE_INTEGER, | 504 | ACPI_RTYPE_INTEGER, |
508 | 0); | 505 | 0); |
509 | if (ACPI_FAILURE(status)) { | 506 | if (ACPI_FAILURE(status)) { |
@@ -537,7 +534,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data, | |||
537 | /* Check the type of each sub-package element */ | 534 | /* Check the type of each sub-package element */ |
538 | 535 | ||
539 | status = | 536 | status = |
540 | acpi_ns_check_package_elements(data, | 537 | acpi_ns_check_package_elements(info, |
541 | (sub_elements + 1), | 538 | (sub_elements + 1), |
542 | package->ret_info. | 539 | package->ret_info. |
543 | object_type1, | 540 | object_type1, |
@@ -562,7 +559,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data, | |||
562 | 559 | ||
563 | /* The sub-package count was smaller than required */ | 560 | /* The sub-package count was smaller than required */ |
564 | 561 | ||
565 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 562 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, info->node_flags, |
566 | "Return Sub-Package[%u] is too small - found %u elements, expected %u", | 563 | "Return Sub-Package[%u] is too small - found %u elements, expected %u", |
567 | i, sub_package->package.count, expected_count)); | 564 | i, sub_package->package.count, expected_count)); |
568 | 565 | ||
@@ -573,7 +570,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data, | |||
573 | * | 570 | * |
574 | * FUNCTION: acpi_ns_check_package_elements | 571 | * FUNCTION: acpi_ns_check_package_elements |
575 | * | 572 | * |
576 | * PARAMETERS: data - Pointer to validation data structure | 573 | * PARAMETERS: info - Method execution information block |
577 | * elements - Pointer to the package elements array | 574 | * elements - Pointer to the package elements array |
578 | * type1 - Object type for first group | 575 | * type1 - Object type for first group |
579 | * count1 - Count for first group | 576 | * count1 - Count for first group |
@@ -589,7 +586,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data, | |||
589 | ******************************************************************************/ | 586 | ******************************************************************************/ |
590 | 587 | ||
591 | static acpi_status | 588 | static acpi_status |
592 | acpi_ns_check_package_elements(struct acpi_predefined_data *data, | 589 | acpi_ns_check_package_elements(struct acpi_evaluate_info *info, |
593 | union acpi_operand_object **elements, | 590 | union acpi_operand_object **elements, |
594 | u8 type1, | 591 | u8 type1, |
595 | u32 count1, | 592 | u32 count1, |
@@ -605,7 +602,7 @@ acpi_ns_check_package_elements(struct acpi_predefined_data *data, | |||
605 | * The second group can have a count of zero. | 602 | * The second group can have a count of zero. |
606 | */ | 603 | */ |
607 | for (i = 0; i < count1; i++) { | 604 | for (i = 0; i < count1; i++) { |
608 | status = acpi_ns_check_object_type(data, this_element, | 605 | status = acpi_ns_check_object_type(info, this_element, |
609 | type1, i + start_index); | 606 | type1, i + start_index); |
610 | if (ACPI_FAILURE(status)) { | 607 | if (ACPI_FAILURE(status)) { |
611 | return (status); | 608 | return (status); |
@@ -614,7 +611,7 @@ acpi_ns_check_package_elements(struct acpi_predefined_data *data, | |||
614 | } | 611 | } |
615 | 612 | ||
616 | for (i = 0; i < count2; i++) { | 613 | for (i = 0; i < count2; i++) { |
617 | status = acpi_ns_check_object_type(data, this_element, | 614 | status = acpi_ns_check_object_type(info, this_element, |
618 | type2, | 615 | type2, |
619 | (i + count1 + start_index)); | 616 | (i + count1 + start_index)); |
620 | if (ACPI_FAILURE(status)) { | 617 | if (ACPI_FAILURE(status)) { |
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c index 18f02e4ece01..f8e71ea60319 100644 --- a/drivers/acpi/acpica/nsrepair.c +++ b/drivers/acpi/acpica/nsrepair.c | |||
@@ -130,7 +130,7 @@ static const struct acpi_simple_repair_info acpi_object_repair_info[] = { | |||
130 | * | 130 | * |
131 | * FUNCTION: acpi_ns_simple_repair | 131 | * FUNCTION: acpi_ns_simple_repair |
132 | * | 132 | * |
133 | * PARAMETERS: data - Pointer to validation data structure | 133 | * PARAMETERS: info - Method execution information block |
134 | * expected_btypes - Object types expected | 134 | * expected_btypes - Object types expected |
135 | * package_index - Index of object within parent package (if | 135 | * package_index - Index of object within parent package (if |
136 | * applicable - ACPI_NOT_PACKAGE_ELEMENT | 136 | * applicable - ACPI_NOT_PACKAGE_ELEMENT |
@@ -146,7 +146,7 @@ static const struct acpi_simple_repair_info acpi_object_repair_info[] = { | |||
146 | ******************************************************************************/ | 146 | ******************************************************************************/ |
147 | 147 | ||
148 | acpi_status | 148 | acpi_status |
149 | acpi_ns_simple_repair(struct acpi_predefined_data *data, | 149 | acpi_ns_simple_repair(struct acpi_evaluate_info *info, |
150 | u32 expected_btypes, | 150 | u32 expected_btypes, |
151 | u32 package_index, | 151 | u32 package_index, |
152 | union acpi_operand_object **return_object_ptr) | 152 | union acpi_operand_object **return_object_ptr) |
@@ -162,12 +162,12 @@ acpi_ns_simple_repair(struct acpi_predefined_data *data, | |||
162 | * Special repairs for certain names that are in the repair table. | 162 | * Special repairs for certain names that are in the repair table. |
163 | * Check if this name is in the list of repairable names. | 163 | * Check if this name is in the list of repairable names. |
164 | */ | 164 | */ |
165 | predefined = acpi_ns_match_simple_repair(data->node, | 165 | predefined = acpi_ns_match_simple_repair(info->node, |
166 | data->return_btype, | 166 | info->return_btype, |
167 | package_index); | 167 | package_index); |
168 | if (predefined) { | 168 | if (predefined) { |
169 | if (!return_object) { | 169 | if (!return_object) { |
170 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, | 170 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, |
171 | ACPI_WARN_ALWAYS, | 171 | ACPI_WARN_ALWAYS, |
172 | "Missing expected return value")); | 172 | "Missing expected return value")); |
173 | } | 173 | } |
@@ -191,7 +191,7 @@ acpi_ns_simple_repair(struct acpi_predefined_data *data, | |||
191 | * Do not perform simple object repair unless the return type is not | 191 | * Do not perform simple object repair unless the return type is not |
192 | * expected. | 192 | * expected. |
193 | */ | 193 | */ |
194 | if (data->return_btype & expected_btypes) { | 194 | if (info->return_btype & expected_btypes) { |
195 | return (AE_OK); | 195 | return (AE_OK); |
196 | } | 196 | } |
197 | 197 | ||
@@ -211,7 +211,7 @@ acpi_ns_simple_repair(struct acpi_predefined_data *data, | |||
211 | */ | 211 | */ |
212 | if (!return_object) { | 212 | if (!return_object) { |
213 | if (expected_btypes && (!(expected_btypes & ACPI_RTYPE_NONE))) { | 213 | if (expected_btypes && (!(expected_btypes & ACPI_RTYPE_NONE))) { |
214 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, | 214 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, |
215 | ACPI_WARN_ALWAYS, | 215 | ACPI_WARN_ALWAYS, |
216 | "Missing expected return value")); | 216 | "Missing expected return value")); |
217 | 217 | ||
@@ -247,14 +247,14 @@ acpi_ns_simple_repair(struct acpi_predefined_data *data, | |||
247 | * for correct contents (expected object type or types). | 247 | * for correct contents (expected object type or types). |
248 | */ | 248 | */ |
249 | status = | 249 | status = |
250 | acpi_ns_wrap_with_package(data, return_object, &new_object); | 250 | acpi_ns_wrap_with_package(info, return_object, &new_object); |
251 | if (ACPI_SUCCESS(status)) { | 251 | if (ACPI_SUCCESS(status)) { |
252 | /* | 252 | /* |
253 | * The original object just had its reference count | 253 | * The original object just had its reference count |
254 | * incremented for being inserted into the new package. | 254 | * incremented for being inserted into the new package. |
255 | */ | 255 | */ |
256 | *return_object_ptr = new_object; /* New Package object */ | 256 | *return_object_ptr = new_object; /* New Package object */ |
257 | data->flags |= ACPI_OBJECT_REPAIRED; | 257 | info->return_flags |= ACPI_OBJECT_REPAIRED; |
258 | return (AE_OK); | 258 | return (AE_OK); |
259 | } | 259 | } |
260 | } | 260 | } |
@@ -277,7 +277,7 @@ acpi_ns_simple_repair(struct acpi_predefined_data *data, | |||
277 | * package object as part of the repair, we don't need to | 277 | * package object as part of the repair, we don't need to |
278 | * change the reference count. | 278 | * change the reference count. |
279 | */ | 279 | */ |
280 | if (!(data->flags & ACPI_OBJECT_WRAPPED)) { | 280 | if (!(info->return_flags & ACPI_OBJECT_WRAPPED)) { |
281 | new_object->common.reference_count = | 281 | new_object->common.reference_count = |
282 | return_object->common.reference_count; | 282 | return_object->common.reference_count; |
283 | 283 | ||
@@ -288,14 +288,14 @@ acpi_ns_simple_repair(struct acpi_predefined_data *data, | |||
288 | 288 | ||
289 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | 289 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, |
290 | "%s: Converted %s to expected %s at Package index %u\n", | 290 | "%s: Converted %s to expected %s at Package index %u\n", |
291 | data->pathname, | 291 | info->full_pathname, |
292 | acpi_ut_get_object_type_name(return_object), | 292 | acpi_ut_get_object_type_name(return_object), |
293 | acpi_ut_get_object_type_name(new_object), | 293 | acpi_ut_get_object_type_name(new_object), |
294 | package_index)); | 294 | package_index)); |
295 | } else { | 295 | } else { |
296 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | 296 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, |
297 | "%s: Converted %s to expected %s\n", | 297 | "%s: Converted %s to expected %s\n", |
298 | data->pathname, | 298 | info->full_pathname, |
299 | acpi_ut_get_object_type_name(return_object), | 299 | acpi_ut_get_object_type_name(return_object), |
300 | acpi_ut_get_object_type_name(new_object))); | 300 | acpi_ut_get_object_type_name(new_object))); |
301 | } | 301 | } |
@@ -304,7 +304,7 @@ acpi_ns_simple_repair(struct acpi_predefined_data *data, | |||
304 | 304 | ||
305 | acpi_ut_remove_reference(return_object); | 305 | acpi_ut_remove_reference(return_object); |
306 | *return_object_ptr = new_object; | 306 | *return_object_ptr = new_object; |
307 | data->flags |= ACPI_OBJECT_REPAIRED; | 307 | info->return_flags |= ACPI_OBJECT_REPAIRED; |
308 | return (AE_OK); | 308 | return (AE_OK); |
309 | } | 309 | } |
310 | 310 | ||
@@ -359,7 +359,7 @@ static const struct acpi_simple_repair_info *acpi_ns_match_simple_repair(struct | |||
359 | * | 359 | * |
360 | * FUNCTION: acpi_ns_repair_null_element | 360 | * FUNCTION: acpi_ns_repair_null_element |
361 | * | 361 | * |
362 | * PARAMETERS: data - Pointer to validation data structure | 362 | * PARAMETERS: info - Method execution information block |
363 | * expected_btypes - Object types expected | 363 | * expected_btypes - Object types expected |
364 | * package_index - Index of object within parent package (if | 364 | * package_index - Index of object within parent package (if |
365 | * applicable - ACPI_NOT_PACKAGE_ELEMENT | 365 | * applicable - ACPI_NOT_PACKAGE_ELEMENT |
@@ -374,7 +374,7 @@ static const struct acpi_simple_repair_info *acpi_ns_match_simple_repair(struct | |||
374 | ******************************************************************************/ | 374 | ******************************************************************************/ |
375 | 375 | ||
376 | acpi_status | 376 | acpi_status |
377 | acpi_ns_repair_null_element(struct acpi_predefined_data *data, | 377 | acpi_ns_repair_null_element(struct acpi_evaluate_info * info, |
378 | u32 expected_btypes, | 378 | u32 expected_btypes, |
379 | u32 package_index, | 379 | u32 package_index, |
380 | union acpi_operand_object **return_object_ptr) | 380 | union acpi_operand_object **return_object_ptr) |
@@ -424,16 +424,16 @@ acpi_ns_repair_null_element(struct acpi_predefined_data *data, | |||
424 | /* Set the reference count according to the parent Package object */ | 424 | /* Set the reference count according to the parent Package object */ |
425 | 425 | ||
426 | new_object->common.reference_count = | 426 | new_object->common.reference_count = |
427 | data->parent_package->common.reference_count; | 427 | info->parent_package->common.reference_count; |
428 | 428 | ||
429 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | 429 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, |
430 | "%s: Converted NULL package element to expected %s at index %u\n", | 430 | "%s: Converted NULL package element to expected %s at index %u\n", |
431 | data->pathname, | 431 | info->full_pathname, |
432 | acpi_ut_get_object_type_name(new_object), | 432 | acpi_ut_get_object_type_name(new_object), |
433 | package_index)); | 433 | package_index)); |
434 | 434 | ||
435 | *return_object_ptr = new_object; | 435 | *return_object_ptr = new_object; |
436 | data->flags |= ACPI_OBJECT_REPAIRED; | 436 | info->return_flags |= ACPI_OBJECT_REPAIRED; |
437 | return (AE_OK); | 437 | return (AE_OK); |
438 | } | 438 | } |
439 | 439 | ||
@@ -441,7 +441,7 @@ acpi_ns_repair_null_element(struct acpi_predefined_data *data, | |||
441 | * | 441 | * |
442 | * FUNCTION: acpi_ns_remove_null_elements | 442 | * FUNCTION: acpi_ns_remove_null_elements |
443 | * | 443 | * |
444 | * PARAMETERS: data - Pointer to validation data structure | 444 | * PARAMETERS: info - Method execution information block |
445 | * package_type - An acpi_return_package_types value | 445 | * package_type - An acpi_return_package_types value |
446 | * obj_desc - A Package object | 446 | * obj_desc - A Package object |
447 | * | 447 | * |
@@ -454,7 +454,7 @@ acpi_ns_repair_null_element(struct acpi_predefined_data *data, | |||
454 | *****************************************************************************/ | 454 | *****************************************************************************/ |
455 | 455 | ||
456 | void | 456 | void |
457 | acpi_ns_remove_null_elements(struct acpi_predefined_data *data, | 457 | acpi_ns_remove_null_elements(struct acpi_evaluate_info *info, |
458 | u8 package_type, | 458 | u8 package_type, |
459 | union acpi_operand_object *obj_desc) | 459 | union acpi_operand_object *obj_desc) |
460 | { | 460 | { |
@@ -480,6 +480,7 @@ acpi_ns_remove_null_elements(struct acpi_predefined_data *data, | |||
480 | case ACPI_PTYPE2_MIN: | 480 | case ACPI_PTYPE2_MIN: |
481 | case ACPI_PTYPE2_REV_FIXED: | 481 | case ACPI_PTYPE2_REV_FIXED: |
482 | case ACPI_PTYPE2_FIX_VAR: | 482 | case ACPI_PTYPE2_FIX_VAR: |
483 | |||
483 | break; | 484 | break; |
484 | 485 | ||
485 | default: | 486 | default: |
@@ -511,7 +512,7 @@ acpi_ns_remove_null_elements(struct acpi_predefined_data *data, | |||
511 | if (new_count < count) { | 512 | if (new_count < count) { |
512 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | 513 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, |
513 | "%s: Found and removed %u NULL elements\n", | 514 | "%s: Found and removed %u NULL elements\n", |
514 | data->pathname, (count - new_count))); | 515 | info->full_pathname, (count - new_count))); |
515 | 516 | ||
516 | /* NULL terminate list and update the package count */ | 517 | /* NULL terminate list and update the package count */ |
517 | 518 | ||
@@ -524,7 +525,7 @@ acpi_ns_remove_null_elements(struct acpi_predefined_data *data, | |||
524 | * | 525 | * |
525 | * FUNCTION: acpi_ns_wrap_with_package | 526 | * FUNCTION: acpi_ns_wrap_with_package |
526 | * | 527 | * |
527 | * PARAMETERS: data - Pointer to validation data structure | 528 | * PARAMETERS: info - Method execution information block |
528 | * original_object - Pointer to the object to repair. | 529 | * original_object - Pointer to the object to repair. |
529 | * obj_desc_ptr - The new package object is returned here | 530 | * obj_desc_ptr - The new package object is returned here |
530 | * | 531 | * |
@@ -545,7 +546,7 @@ acpi_ns_remove_null_elements(struct acpi_predefined_data *data, | |||
545 | ******************************************************************************/ | 546 | ******************************************************************************/ |
546 | 547 | ||
547 | acpi_status | 548 | acpi_status |
548 | acpi_ns_wrap_with_package(struct acpi_predefined_data *data, | 549 | acpi_ns_wrap_with_package(struct acpi_evaluate_info *info, |
549 | union acpi_operand_object *original_object, | 550 | union acpi_operand_object *original_object, |
550 | union acpi_operand_object **obj_desc_ptr) | 551 | union acpi_operand_object **obj_desc_ptr) |
551 | { | 552 | { |
@@ -566,12 +567,12 @@ acpi_ns_wrap_with_package(struct acpi_predefined_data *data, | |||
566 | 567 | ||
567 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | 568 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, |
568 | "%s: Wrapped %s with expected Package object\n", | 569 | "%s: Wrapped %s with expected Package object\n", |
569 | data->pathname, | 570 | info->full_pathname, |
570 | acpi_ut_get_object_type_name(original_object))); | 571 | acpi_ut_get_object_type_name(original_object))); |
571 | 572 | ||
572 | /* Return the new object in the object pointer */ | 573 | /* Return the new object in the object pointer */ |
573 | 574 | ||
574 | *obj_desc_ptr = pkg_obj_desc; | 575 | *obj_desc_ptr = pkg_obj_desc; |
575 | data->flags |= ACPI_OBJECT_REPAIRED | ACPI_OBJECT_WRAPPED; | 576 | info->return_flags |= ACPI_OBJECT_REPAIRED | ACPI_OBJECT_WRAPPED; |
576 | return (AE_OK); | 577 | return (AE_OK); |
577 | } | 578 | } |
diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c index 149e9b9c2c1b..c84603ee83ae 100644 --- a/drivers/acpi/acpica/nsrepair2.c +++ b/drivers/acpi/acpica/nsrepair2.c | |||
@@ -54,7 +54,7 @@ ACPI_MODULE_NAME("nsrepair2") | |||
54 | * be repaired on a per-name basis. | 54 | * be repaired on a per-name basis. |
55 | */ | 55 | */ |
56 | typedef | 56 | typedef |
57 | acpi_status(*acpi_repair_function) (struct acpi_predefined_data *data, | 57 | acpi_status(*acpi_repair_function) (struct acpi_evaluate_info * info, |
58 | union acpi_operand_object | 58 | union acpi_operand_object |
59 | **return_object_ptr); | 59 | **return_object_ptr); |
60 | 60 | ||
@@ -71,45 +71,57 @@ static const struct acpi_repair_info *acpi_ns_match_complex_repair(struct | |||
71 | *node); | 71 | *node); |
72 | 72 | ||
73 | static acpi_status | 73 | static acpi_status |
74 | acpi_ns_repair_ALR(struct acpi_predefined_data *data, | 74 | acpi_ns_repair_ALR(struct acpi_evaluate_info *info, |
75 | union acpi_operand_object **return_object_ptr); | 75 | union acpi_operand_object **return_object_ptr); |
76 | 76 | ||
77 | static acpi_status | 77 | static acpi_status |
78 | acpi_ns_repair_CID(struct acpi_predefined_data *data, | 78 | acpi_ns_repair_CID(struct acpi_evaluate_info *info, |
79 | union acpi_operand_object **return_object_ptr); | 79 | union acpi_operand_object **return_object_ptr); |
80 | 80 | ||
81 | static acpi_status | 81 | static acpi_status |
82 | acpi_ns_repair_FDE(struct acpi_predefined_data *data, | 82 | acpi_ns_repair_CST(struct acpi_evaluate_info *info, |
83 | union acpi_operand_object **return_object_ptr); | 83 | union acpi_operand_object **return_object_ptr); |
84 | 84 | ||
85 | static acpi_status | 85 | static acpi_status |
86 | acpi_ns_repair_HID(struct acpi_predefined_data *data, | 86 | acpi_ns_repair_FDE(struct acpi_evaluate_info *info, |
87 | union acpi_operand_object **return_object_ptr); | 87 | union acpi_operand_object **return_object_ptr); |
88 | 88 | ||
89 | static acpi_status | 89 | static acpi_status |
90 | acpi_ns_repair_PSS(struct acpi_predefined_data *data, | 90 | acpi_ns_repair_HID(struct acpi_evaluate_info *info, |
91 | union acpi_operand_object **return_object_ptr); | 91 | union acpi_operand_object **return_object_ptr); |
92 | 92 | ||
93 | static acpi_status | 93 | static acpi_status |
94 | acpi_ns_repair_TSS(struct acpi_predefined_data *data, | 94 | acpi_ns_repair_PRT(struct acpi_evaluate_info *info, |
95 | union acpi_operand_object **return_object_ptr); | 95 | union acpi_operand_object **return_object_ptr); |
96 | 96 | ||
97 | static acpi_status | 97 | static acpi_status |
98 | acpi_ns_check_sorted_list(struct acpi_predefined_data *data, | 98 | acpi_ns_repair_PSS(struct acpi_evaluate_info *info, |
99 | union acpi_operand_object **return_object_ptr); | ||
100 | |||
101 | static acpi_status | ||
102 | acpi_ns_repair_TSS(struct acpi_evaluate_info *info, | ||
103 | union acpi_operand_object **return_object_ptr); | ||
104 | |||
105 | static acpi_status | ||
106 | acpi_ns_check_sorted_list(struct acpi_evaluate_info *info, | ||
99 | union acpi_operand_object *return_object, | 107 | union acpi_operand_object *return_object, |
108 | u32 start_index, | ||
100 | u32 expected_count, | 109 | u32 expected_count, |
101 | u32 sort_index, | 110 | u32 sort_index, |
102 | u8 sort_direction, char *sort_key_name); | 111 | u8 sort_direction, char *sort_key_name); |
103 | 112 | ||
104 | static void | ||
105 | acpi_ns_sort_list(union acpi_operand_object **elements, | ||
106 | u32 count, u32 index, u8 sort_direction); | ||
107 | |||
108 | /* Values for sort_direction above */ | 113 | /* Values for sort_direction above */ |
109 | 114 | ||
110 | #define ACPI_SORT_ASCENDING 0 | 115 | #define ACPI_SORT_ASCENDING 0 |
111 | #define ACPI_SORT_DESCENDING 1 | 116 | #define ACPI_SORT_DESCENDING 1 |
112 | 117 | ||
118 | static void | ||
119 | acpi_ns_remove_element(union acpi_operand_object *obj_desc, u32 index); | ||
120 | |||
121 | static void | ||
122 | acpi_ns_sort_list(union acpi_operand_object **elements, | ||
123 | u32 count, u32 index, u8 sort_direction); | ||
124 | |||
113 | /* | 125 | /* |
114 | * This table contains the names of the predefined methods for which we can | 126 | * This table contains the names of the predefined methods for which we can |
115 | * perform more complex repairs. | 127 | * perform more complex repairs. |
@@ -118,9 +130,11 @@ acpi_ns_sort_list(union acpi_operand_object **elements, | |||
118 | * | 130 | * |
119 | * _ALR: Sort the list ascending by ambient_illuminance | 131 | * _ALR: Sort the list ascending by ambient_illuminance |
120 | * _CID: Strings: uppercase all, remove any leading asterisk | 132 | * _CID: Strings: uppercase all, remove any leading asterisk |
133 | * _CST: Sort the list ascending by C state type | ||
121 | * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs | 134 | * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs |
122 | * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs | 135 | * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs |
123 | * _HID: Strings: uppercase all, remove any leading asterisk | 136 | * _HID: Strings: uppercase all, remove any leading asterisk |
137 | * _PRT: Fix reversed source_name and source_index | ||
124 | * _PSS: Sort the list descending by Power | 138 | * _PSS: Sort the list descending by Power |
125 | * _TSS: Sort the list descending by Power | 139 | * _TSS: Sort the list descending by Power |
126 | * | 140 | * |
@@ -134,9 +148,11 @@ acpi_ns_sort_list(union acpi_operand_object **elements, | |||
134 | static const struct acpi_repair_info acpi_ns_repairable_names[] = { | 148 | static const struct acpi_repair_info acpi_ns_repairable_names[] = { |
135 | {"_ALR", acpi_ns_repair_ALR}, | 149 | {"_ALR", acpi_ns_repair_ALR}, |
136 | {"_CID", acpi_ns_repair_CID}, | 150 | {"_CID", acpi_ns_repair_CID}, |
151 | {"_CST", acpi_ns_repair_CST}, | ||
137 | {"_FDE", acpi_ns_repair_FDE}, | 152 | {"_FDE", acpi_ns_repair_FDE}, |
138 | {"_GTM", acpi_ns_repair_FDE}, /* _GTM has same repair as _FDE */ | 153 | {"_GTM", acpi_ns_repair_FDE}, /* _GTM has same repair as _FDE */ |
139 | {"_HID", acpi_ns_repair_HID}, | 154 | {"_HID", acpi_ns_repair_HID}, |
155 | {"_PRT", acpi_ns_repair_PRT}, | ||
140 | {"_PSS", acpi_ns_repair_PSS}, | 156 | {"_PSS", acpi_ns_repair_PSS}, |
141 | {"_TSS", acpi_ns_repair_TSS}, | 157 | {"_TSS", acpi_ns_repair_TSS}, |
142 | {{0, 0, 0, 0}, NULL} /* Table terminator */ | 158 | {{0, 0, 0, 0}, NULL} /* Table terminator */ |
@@ -150,7 +166,7 @@ static const struct acpi_repair_info acpi_ns_repairable_names[] = { | |||
150 | * | 166 | * |
151 | * FUNCTION: acpi_ns_complex_repairs | 167 | * FUNCTION: acpi_ns_complex_repairs |
152 | * | 168 | * |
153 | * PARAMETERS: data - Pointer to validation data structure | 169 | * PARAMETERS: info - Method execution information block |
154 | * node - Namespace node for the method/object | 170 | * node - Namespace node for the method/object |
155 | * validate_status - Original status of earlier validation | 171 | * validate_status - Original status of earlier validation |
156 | * return_object_ptr - Pointer to the object returned from the | 172 | * return_object_ptr - Pointer to the object returned from the |
@@ -165,7 +181,7 @@ static const struct acpi_repair_info acpi_ns_repairable_names[] = { | |||
165 | *****************************************************************************/ | 181 | *****************************************************************************/ |
166 | 182 | ||
167 | acpi_status | 183 | acpi_status |
168 | acpi_ns_complex_repairs(struct acpi_predefined_data *data, | 184 | acpi_ns_complex_repairs(struct acpi_evaluate_info *info, |
169 | struct acpi_namespace_node *node, | 185 | struct acpi_namespace_node *node, |
170 | acpi_status validate_status, | 186 | acpi_status validate_status, |
171 | union acpi_operand_object **return_object_ptr) | 187 | union acpi_operand_object **return_object_ptr) |
@@ -180,7 +196,7 @@ acpi_ns_complex_repairs(struct acpi_predefined_data *data, | |||
180 | return (validate_status); | 196 | return (validate_status); |
181 | } | 197 | } |
182 | 198 | ||
183 | status = predefined->repair_function(data, return_object_ptr); | 199 | status = predefined->repair_function(info, return_object_ptr); |
184 | return (status); | 200 | return (status); |
185 | } | 201 | } |
186 | 202 | ||
@@ -219,7 +235,7 @@ static const struct acpi_repair_info *acpi_ns_match_complex_repair(struct | |||
219 | * | 235 | * |
220 | * FUNCTION: acpi_ns_repair_ALR | 236 | * FUNCTION: acpi_ns_repair_ALR |
221 | * | 237 | * |
222 | * PARAMETERS: data - Pointer to validation data structure | 238 | * PARAMETERS: info - Method execution information block |
223 | * return_object_ptr - Pointer to the object returned from the | 239 | * return_object_ptr - Pointer to the object returned from the |
224 | * evaluation of a method or object | 240 | * evaluation of a method or object |
225 | * | 241 | * |
@@ -231,13 +247,13 @@ static const struct acpi_repair_info *acpi_ns_match_complex_repair(struct | |||
231 | *****************************************************************************/ | 247 | *****************************************************************************/ |
232 | 248 | ||
233 | static acpi_status | 249 | static acpi_status |
234 | acpi_ns_repair_ALR(struct acpi_predefined_data *data, | 250 | acpi_ns_repair_ALR(struct acpi_evaluate_info *info, |
235 | union acpi_operand_object **return_object_ptr) | 251 | union acpi_operand_object **return_object_ptr) |
236 | { | 252 | { |
237 | union acpi_operand_object *return_object = *return_object_ptr; | 253 | union acpi_operand_object *return_object = *return_object_ptr; |
238 | acpi_status status; | 254 | acpi_status status; |
239 | 255 | ||
240 | status = acpi_ns_check_sorted_list(data, return_object, 2, 1, | 256 | status = acpi_ns_check_sorted_list(info, return_object, 0, 2, 1, |
241 | ACPI_SORT_ASCENDING, | 257 | ACPI_SORT_ASCENDING, |
242 | "AmbientIlluminance"); | 258 | "AmbientIlluminance"); |
243 | 259 | ||
@@ -248,7 +264,7 @@ acpi_ns_repair_ALR(struct acpi_predefined_data *data, | |||
248 | * | 264 | * |
249 | * FUNCTION: acpi_ns_repair_FDE | 265 | * FUNCTION: acpi_ns_repair_FDE |
250 | * | 266 | * |
251 | * PARAMETERS: data - Pointer to validation data structure | 267 | * PARAMETERS: info - Method execution information block |
252 | * return_object_ptr - Pointer to the object returned from the | 268 | * return_object_ptr - Pointer to the object returned from the |
253 | * evaluation of a method or object | 269 | * evaluation of a method or object |
254 | * | 270 | * |
@@ -262,7 +278,7 @@ acpi_ns_repair_ALR(struct acpi_predefined_data *data, | |||
262 | *****************************************************************************/ | 278 | *****************************************************************************/ |
263 | 279 | ||
264 | static acpi_status | 280 | static acpi_status |
265 | acpi_ns_repair_FDE(struct acpi_predefined_data *data, | 281 | acpi_ns_repair_FDE(struct acpi_evaluate_info *info, |
266 | union acpi_operand_object **return_object_ptr) | 282 | union acpi_operand_object **return_object_ptr) |
267 | { | 283 | { |
268 | union acpi_operand_object *return_object = *return_object_ptr; | 284 | union acpi_operand_object *return_object = *return_object_ptr; |
@@ -285,8 +301,8 @@ acpi_ns_repair_FDE(struct acpi_predefined_data *data, | |||
285 | /* We can only repair if we have exactly 5 BYTEs */ | 301 | /* We can only repair if we have exactly 5 BYTEs */ |
286 | 302 | ||
287 | if (return_object->buffer.length != ACPI_FDE_BYTE_BUFFER_SIZE) { | 303 | if (return_object->buffer.length != ACPI_FDE_BYTE_BUFFER_SIZE) { |
288 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, | 304 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, |
289 | data->node_flags, | 305 | info->node_flags, |
290 | "Incorrect return buffer length %u, expected %u", | 306 | "Incorrect return buffer length %u, expected %u", |
291 | return_object->buffer.length, | 307 | return_object->buffer.length, |
292 | ACPI_FDE_DWORD_BUFFER_SIZE)); | 308 | ACPI_FDE_DWORD_BUFFER_SIZE)); |
@@ -316,10 +332,11 @@ acpi_ns_repair_FDE(struct acpi_predefined_data *data, | |||
316 | 332 | ||
317 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | 333 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, |
318 | "%s Expanded Byte Buffer to expected DWord Buffer\n", | 334 | "%s Expanded Byte Buffer to expected DWord Buffer\n", |
319 | data->pathname)); | 335 | info->full_pathname)); |
320 | break; | 336 | break; |
321 | 337 | ||
322 | default: | 338 | default: |
339 | |||
323 | return (AE_AML_OPERAND_TYPE); | 340 | return (AE_AML_OPERAND_TYPE); |
324 | } | 341 | } |
325 | 342 | ||
@@ -328,7 +345,7 @@ acpi_ns_repair_FDE(struct acpi_predefined_data *data, | |||
328 | acpi_ut_remove_reference(return_object); | 345 | acpi_ut_remove_reference(return_object); |
329 | *return_object_ptr = buffer_object; | 346 | *return_object_ptr = buffer_object; |
330 | 347 | ||
331 | data->flags |= ACPI_OBJECT_REPAIRED; | 348 | info->return_flags |= ACPI_OBJECT_REPAIRED; |
332 | return (AE_OK); | 349 | return (AE_OK); |
333 | } | 350 | } |
334 | 351 | ||
@@ -336,7 +353,7 @@ acpi_ns_repair_FDE(struct acpi_predefined_data *data, | |||
336 | * | 353 | * |
337 | * FUNCTION: acpi_ns_repair_CID | 354 | * FUNCTION: acpi_ns_repair_CID |
338 | * | 355 | * |
339 | * PARAMETERS: data - Pointer to validation data structure | 356 | * PARAMETERS: info - Method execution information block |
340 | * return_object_ptr - Pointer to the object returned from the | 357 | * return_object_ptr - Pointer to the object returned from the |
341 | * evaluation of a method or object | 358 | * evaluation of a method or object |
342 | * | 359 | * |
@@ -349,7 +366,7 @@ acpi_ns_repair_FDE(struct acpi_predefined_data *data, | |||
349 | *****************************************************************************/ | 366 | *****************************************************************************/ |
350 | 367 | ||
351 | static acpi_status | 368 | static acpi_status |
352 | acpi_ns_repair_CID(struct acpi_predefined_data *data, | 369 | acpi_ns_repair_CID(struct acpi_evaluate_info *info, |
353 | union acpi_operand_object **return_object_ptr) | 370 | union acpi_operand_object **return_object_ptr) |
354 | { | 371 | { |
355 | acpi_status status; | 372 | acpi_status status; |
@@ -362,7 +379,7 @@ acpi_ns_repair_CID(struct acpi_predefined_data *data, | |||
362 | /* Check for _CID as a simple string */ | 379 | /* Check for _CID as a simple string */ |
363 | 380 | ||
364 | if (return_object->common.type == ACPI_TYPE_STRING) { | 381 | if (return_object->common.type == ACPI_TYPE_STRING) { |
365 | status = acpi_ns_repair_HID(data, return_object_ptr); | 382 | status = acpi_ns_repair_HID(info, return_object_ptr); |
366 | return (status); | 383 | return (status); |
367 | } | 384 | } |
368 | 385 | ||
@@ -379,7 +396,7 @@ acpi_ns_repair_CID(struct acpi_predefined_data *data, | |||
379 | original_element = *element_ptr; | 396 | original_element = *element_ptr; |
380 | original_ref_count = original_element->common.reference_count; | 397 | original_ref_count = original_element->common.reference_count; |
381 | 398 | ||
382 | status = acpi_ns_repair_HID(data, element_ptr); | 399 | status = acpi_ns_repair_HID(info, element_ptr); |
383 | if (ACPI_FAILURE(status)) { | 400 | if (ACPI_FAILURE(status)) { |
384 | return (status); | 401 | return (status); |
385 | } | 402 | } |
@@ -404,9 +421,95 @@ acpi_ns_repair_CID(struct acpi_predefined_data *data, | |||
404 | 421 | ||
405 | /****************************************************************************** | 422 | /****************************************************************************** |
406 | * | 423 | * |
424 | * FUNCTION: acpi_ns_repair_CST | ||
425 | * | ||
426 | * PARAMETERS: info - Method execution information block | ||
427 | * return_object_ptr - Pointer to the object returned from the | ||
428 | * evaluation of a method or object | ||
429 | * | ||
430 | * RETURN: Status. AE_OK if object is OK or was repaired successfully | ||
431 | * | ||
432 | * DESCRIPTION: Repair for the _CST object: | ||
433 | * 1. Sort the list ascending by C state type | ||
434 | * 2. Ensure type cannot be zero | ||
435 | * 3. A sub-package count of zero means _CST is meaningless | ||
436 | * 4. Count must match the number of C state sub-packages | ||
437 | * | ||
438 | *****************************************************************************/ | ||
439 | |||
440 | static acpi_status | ||
441 | acpi_ns_repair_CST(struct acpi_evaluate_info *info, | ||
442 | union acpi_operand_object **return_object_ptr) | ||
443 | { | ||
444 | union acpi_operand_object *return_object = *return_object_ptr; | ||
445 | union acpi_operand_object **outer_elements; | ||
446 | u32 outer_element_count; | ||
447 | union acpi_operand_object *obj_desc; | ||
448 | acpi_status status; | ||
449 | u8 removing; | ||
450 | u32 i; | ||
451 | |||
452 | ACPI_FUNCTION_NAME(ns_repair_CST); | ||
453 | |||
454 | /* | ||
455 | * Check if the C-state type values are proportional. | ||
456 | */ | ||
457 | outer_element_count = return_object->package.count - 1; | ||
458 | i = 0; | ||
459 | while (i < outer_element_count) { | ||
460 | outer_elements = &return_object->package.elements[i + 1]; | ||
461 | removing = FALSE; | ||
462 | |||
463 | if ((*outer_elements)->package.count == 0) { | ||
464 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, | ||
465 | info->node_flags, | ||
466 | "SubPackage[%u] - removing entry due to zero count", | ||
467 | i)); | ||
468 | removing = TRUE; | ||
469 | goto remove_element; | ||
470 | } | ||
471 | |||
472 | obj_desc = (*outer_elements)->package.elements[1]; /* Index1 = Type */ | ||
473 | if ((u32)obj_desc->integer.value == 0) { | ||
474 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, | ||
475 | info->node_flags, | ||
476 | "SubPackage[%u] - removing entry due to invalid Type(0)", | ||
477 | i)); | ||
478 | removing = TRUE; | ||
479 | } | ||
480 | |||
481 | remove_element: | ||
482 | if (removing) { | ||
483 | acpi_ns_remove_element(return_object, i + 1); | ||
484 | outer_element_count--; | ||
485 | } else { | ||
486 | i++; | ||
487 | } | ||
488 | } | ||
489 | |||
490 | /* Update top-level package count, Type "Integer" checked elsewhere */ | ||
491 | |||
492 | obj_desc = return_object->package.elements[0]; | ||
493 | obj_desc->integer.value = outer_element_count; | ||
494 | |||
495 | /* | ||
496 | * Entries (subpackages) in the _CST Package must be sorted by the | ||
497 | * C-state type, in ascending order. | ||
498 | */ | ||
499 | status = acpi_ns_check_sorted_list(info, return_object, 1, 4, 1, | ||
500 | ACPI_SORT_ASCENDING, "C-State Type"); | ||
501 | if (ACPI_FAILURE(status)) { | ||
502 | return (status); | ||
503 | } | ||
504 | |||
505 | return (AE_OK); | ||
506 | } | ||
507 | |||
508 | /****************************************************************************** | ||
509 | * | ||
407 | * FUNCTION: acpi_ns_repair_HID | 510 | * FUNCTION: acpi_ns_repair_HID |
408 | * | 511 | * |
409 | * PARAMETERS: data - Pointer to validation data structure | 512 | * PARAMETERS: info - Method execution information block |
410 | * return_object_ptr - Pointer to the object returned from the | 513 | * return_object_ptr - Pointer to the object returned from the |
411 | * evaluation of a method or object | 514 | * evaluation of a method or object |
412 | * | 515 | * |
@@ -418,7 +521,7 @@ acpi_ns_repair_CID(struct acpi_predefined_data *data, | |||
418 | *****************************************************************************/ | 521 | *****************************************************************************/ |
419 | 522 | ||
420 | static acpi_status | 523 | static acpi_status |
421 | acpi_ns_repair_HID(struct acpi_predefined_data *data, | 524 | acpi_ns_repair_HID(struct acpi_evaluate_info *info, |
422 | union acpi_operand_object **return_object_ptr) | 525 | union acpi_operand_object **return_object_ptr) |
423 | { | 526 | { |
424 | union acpi_operand_object *return_object = *return_object_ptr; | 527 | union acpi_operand_object *return_object = *return_object_ptr; |
@@ -435,12 +538,13 @@ acpi_ns_repair_HID(struct acpi_predefined_data *data, | |||
435 | } | 538 | } |
436 | 539 | ||
437 | if (return_object->string.length == 0) { | 540 | if (return_object->string.length == 0) { |
438 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags, | 541 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, |
542 | info->node_flags, | ||
439 | "Invalid zero-length _HID or _CID string")); | 543 | "Invalid zero-length _HID or _CID string")); |
440 | 544 | ||
441 | /* Return AE_OK anyway, let driver handle it */ | 545 | /* Return AE_OK anyway, let driver handle it */ |
442 | 546 | ||
443 | data->flags |= ACPI_OBJECT_REPAIRED; | 547 | info->return_flags |= ACPI_OBJECT_REPAIRED; |
444 | return (AE_OK); | 548 | return (AE_OK); |
445 | } | 549 | } |
446 | 550 | ||
@@ -464,7 +568,7 @@ acpi_ns_repair_HID(struct acpi_predefined_data *data, | |||
464 | 568 | ||
465 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | 569 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, |
466 | "%s: Removed invalid leading asterisk\n", | 570 | "%s: Removed invalid leading asterisk\n", |
467 | data->pathname)); | 571 | info->full_pathname)); |
468 | } | 572 | } |
469 | 573 | ||
470 | /* | 574 | /* |
@@ -486,53 +590,69 @@ acpi_ns_repair_HID(struct acpi_predefined_data *data, | |||
486 | 590 | ||
487 | /****************************************************************************** | 591 | /****************************************************************************** |
488 | * | 592 | * |
489 | * FUNCTION: acpi_ns_repair_TSS | 593 | * FUNCTION: acpi_ns_repair_PRT |
490 | * | 594 | * |
491 | * PARAMETERS: data - Pointer to validation data structure | 595 | * PARAMETERS: info - Method execution information block |
492 | * return_object_ptr - Pointer to the object returned from the | 596 | * return_object_ptr - Pointer to the object returned from the |
493 | * evaluation of a method or object | 597 | * evaluation of a method or object |
494 | * | 598 | * |
495 | * RETURN: Status. AE_OK if object is OK or was repaired successfully | 599 | * RETURN: Status. AE_OK if object is OK or was repaired successfully |
496 | * | 600 | * |
497 | * DESCRIPTION: Repair for the _TSS object. If necessary, sort the object list | 601 | * DESCRIPTION: Repair for the _PRT object. If necessary, fix reversed |
498 | * descending by the power dissipation values. | 602 | * source_name and source_index field, a common BIOS bug. |
499 | * | 603 | * |
500 | *****************************************************************************/ | 604 | *****************************************************************************/ |
501 | 605 | ||
502 | static acpi_status | 606 | static acpi_status |
503 | acpi_ns_repair_TSS(struct acpi_predefined_data *data, | 607 | acpi_ns_repair_PRT(struct acpi_evaluate_info *info, |
504 | union acpi_operand_object **return_object_ptr) | 608 | union acpi_operand_object **return_object_ptr) |
505 | { | 609 | { |
506 | union acpi_operand_object *return_object = *return_object_ptr; | 610 | union acpi_operand_object *package_object = *return_object_ptr; |
507 | acpi_status status; | 611 | union acpi_operand_object **top_object_list; |
508 | struct acpi_namespace_node *node; | 612 | union acpi_operand_object **sub_object_list; |
613 | union acpi_operand_object *obj_desc; | ||
614 | u32 element_count; | ||
615 | u32 index; | ||
509 | 616 | ||
510 | /* | 617 | /* Each element in the _PRT package is a subpackage */ |
511 | * We can only sort the _TSS return package if there is no _PSS in the | ||
512 | * same scope. This is because if _PSS is present, the ACPI specification | ||
513 | * dictates that the _TSS Power Dissipation field is to be ignored, and | ||
514 | * therefore some BIOSs leave garbage values in the _TSS Power field(s). | ||
515 | * In this case, it is best to just return the _TSS package as-is. | ||
516 | * (May, 2011) | ||
517 | */ | ||
518 | status = | ||
519 | acpi_ns_get_node(data->node, "^_PSS", ACPI_NS_NO_UPSEARCH, &node); | ||
520 | if (ACPI_SUCCESS(status)) { | ||
521 | return (AE_OK); | ||
522 | } | ||
523 | 618 | ||
524 | status = acpi_ns_check_sorted_list(data, return_object, 5, 1, | 619 | top_object_list = package_object->package.elements; |
525 | ACPI_SORT_DESCENDING, | 620 | element_count = package_object->package.count; |
526 | "PowerDissipation"); | ||
527 | 621 | ||
528 | return (status); | 622 | for (index = 0; index < element_count; index++) { |
623 | sub_object_list = (*top_object_list)->package.elements; | ||
624 | |||
625 | /* | ||
626 | * If the BIOS has erroneously reversed the _PRT source_name (index 2) | ||
627 | * and the source_index (index 3), fix it. _PRT is important enough to | ||
628 | * workaround this BIOS error. This also provides compatibility with | ||
629 | * other ACPI implementations. | ||
630 | */ | ||
631 | obj_desc = sub_object_list[3]; | ||
632 | if (!obj_desc || (obj_desc->common.type != ACPI_TYPE_INTEGER)) { | ||
633 | sub_object_list[3] = sub_object_list[2]; | ||
634 | sub_object_list[2] = obj_desc; | ||
635 | info->return_flags |= ACPI_OBJECT_REPAIRED; | ||
636 | |||
637 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, | ||
638 | info->node_flags, | ||
639 | "PRT[%X]: Fixed reversed SourceName and SourceIndex", | ||
640 | index)); | ||
641 | } | ||
642 | |||
643 | /* Point to the next union acpi_operand_object in the top level package */ | ||
644 | |||
645 | top_object_list++; | ||
646 | } | ||
647 | |||
648 | return (AE_OK); | ||
529 | } | 649 | } |
530 | 650 | ||
531 | /****************************************************************************** | 651 | /****************************************************************************** |
532 | * | 652 | * |
533 | * FUNCTION: acpi_ns_repair_PSS | 653 | * FUNCTION: acpi_ns_repair_PSS |
534 | * | 654 | * |
535 | * PARAMETERS: data - Pointer to validation data structure | 655 | * PARAMETERS: info - Method execution information block |
536 | * return_object_ptr - Pointer to the object returned from the | 656 | * return_object_ptr - Pointer to the object returned from the |
537 | * evaluation of a method or object | 657 | * evaluation of a method or object |
538 | * | 658 | * |
@@ -546,7 +666,7 @@ acpi_ns_repair_TSS(struct acpi_predefined_data *data, | |||
546 | *****************************************************************************/ | 666 | *****************************************************************************/ |
547 | 667 | ||
548 | static acpi_status | 668 | static acpi_status |
549 | acpi_ns_repair_PSS(struct acpi_predefined_data *data, | 669 | acpi_ns_repair_PSS(struct acpi_evaluate_info *info, |
550 | union acpi_operand_object **return_object_ptr) | 670 | union acpi_operand_object **return_object_ptr) |
551 | { | 671 | { |
552 | union acpi_operand_object *return_object = *return_object_ptr; | 672 | union acpi_operand_object *return_object = *return_object_ptr; |
@@ -564,7 +684,7 @@ acpi_ns_repair_PSS(struct acpi_predefined_data *data, | |||
564 | * incorrectly sorted, sort it. We sort by cpu_frequency, since this | 684 | * incorrectly sorted, sort it. We sort by cpu_frequency, since this |
565 | * should be proportional to the power. | 685 | * should be proportional to the power. |
566 | */ | 686 | */ |
567 | status = acpi_ns_check_sorted_list(data, return_object, 6, 0, | 687 | status = acpi_ns_check_sorted_list(info, return_object, 0, 6, 0, |
568 | ACPI_SORT_DESCENDING, | 688 | ACPI_SORT_DESCENDING, |
569 | "CpuFrequency"); | 689 | "CpuFrequency"); |
570 | if (ACPI_FAILURE(status)) { | 690 | if (ACPI_FAILURE(status)) { |
@@ -584,8 +704,8 @@ acpi_ns_repair_PSS(struct acpi_predefined_data *data, | |||
584 | obj_desc = elements[1]; /* Index1 = power_dissipation */ | 704 | obj_desc = elements[1]; /* Index1 = power_dissipation */ |
585 | 705 | ||
586 | if ((u32) obj_desc->integer.value > previous_value) { | 706 | if ((u32) obj_desc->integer.value > previous_value) { |
587 | ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, | 707 | ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, |
588 | data->node_flags, | 708 | info->node_flags, |
589 | "SubPackage[%u,%u] - suspicious power dissipation values", | 709 | "SubPackage[%u,%u] - suspicious power dissipation values", |
590 | i - 1, i)); | 710 | i - 1, i)); |
591 | } | 711 | } |
@@ -599,10 +719,55 @@ acpi_ns_repair_PSS(struct acpi_predefined_data *data, | |||
599 | 719 | ||
600 | /****************************************************************************** | 720 | /****************************************************************************** |
601 | * | 721 | * |
722 | * FUNCTION: acpi_ns_repair_TSS | ||
723 | * | ||
724 | * PARAMETERS: info - Method execution information block | ||
725 | * return_object_ptr - Pointer to the object returned from the | ||
726 | * evaluation of a method or object | ||
727 | * | ||
728 | * RETURN: Status. AE_OK if object is OK or was repaired successfully | ||
729 | * | ||
730 | * DESCRIPTION: Repair for the _TSS object. If necessary, sort the object list | ||
731 | * descending by the power dissipation values. | ||
732 | * | ||
733 | *****************************************************************************/ | ||
734 | |||
735 | static acpi_status | ||
736 | acpi_ns_repair_TSS(struct acpi_evaluate_info *info, | ||
737 | union acpi_operand_object **return_object_ptr) | ||
738 | { | ||
739 | union acpi_operand_object *return_object = *return_object_ptr; | ||
740 | acpi_status status; | ||
741 | struct acpi_namespace_node *node; | ||
742 | |||
743 | /* | ||
744 | * We can only sort the _TSS return package if there is no _PSS in the | ||
745 | * same scope. This is because if _PSS is present, the ACPI specification | ||
746 | * dictates that the _TSS Power Dissipation field is to be ignored, and | ||
747 | * therefore some BIOSs leave garbage values in the _TSS Power field(s). | ||
748 | * In this case, it is best to just return the _TSS package as-is. | ||
749 | * (May, 2011) | ||
750 | */ | ||
751 | status = acpi_ns_get_node(info->node, "^_PSS", | ||
752 | ACPI_NS_NO_UPSEARCH, &node); | ||
753 | if (ACPI_SUCCESS(status)) { | ||
754 | return (AE_OK); | ||
755 | } | ||
756 | |||
757 | status = acpi_ns_check_sorted_list(info, return_object, 0, 5, 1, | ||
758 | ACPI_SORT_DESCENDING, | ||
759 | "PowerDissipation"); | ||
760 | |||
761 | return (status); | ||
762 | } | ||
763 | |||
764 | /****************************************************************************** | ||
765 | * | ||
602 | * FUNCTION: acpi_ns_check_sorted_list | 766 | * FUNCTION: acpi_ns_check_sorted_list |
603 | * | 767 | * |
604 | * PARAMETERS: data - Pointer to validation data structure | 768 | * PARAMETERS: info - Method execution information block |
605 | * return_object - Pointer to the top-level returned object | 769 | * return_object - Pointer to the top-level returned object |
770 | * start_index - Index of the first sub-package | ||
606 | * expected_count - Minimum length of each sub-package | 771 | * expected_count - Minimum length of each sub-package |
607 | * sort_index - Sub-package entry to sort on | 772 | * sort_index - Sub-package entry to sort on |
608 | * sort_direction - Ascending or descending | 773 | * sort_direction - Ascending or descending |
@@ -617,8 +782,9 @@ acpi_ns_repair_PSS(struct acpi_predefined_data *data, | |||
617 | *****************************************************************************/ | 782 | *****************************************************************************/ |
618 | 783 | ||
619 | static acpi_status | 784 | static acpi_status |
620 | acpi_ns_check_sorted_list(struct acpi_predefined_data *data, | 785 | acpi_ns_check_sorted_list(struct acpi_evaluate_info *info, |
621 | union acpi_operand_object *return_object, | 786 | union acpi_operand_object *return_object, |
787 | u32 start_index, | ||
622 | u32 expected_count, | 788 | u32 expected_count, |
623 | u32 sort_index, | 789 | u32 sort_index, |
624 | u8 sort_direction, char *sort_key_name) | 790 | u8 sort_direction, char *sort_key_name) |
@@ -643,12 +809,14 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data, | |||
643 | * Any NULL elements should have been removed by earlier call | 809 | * Any NULL elements should have been removed by earlier call |
644 | * to acpi_ns_remove_null_elements. | 810 | * to acpi_ns_remove_null_elements. |
645 | */ | 811 | */ |
646 | outer_elements = return_object->package.elements; | ||
647 | outer_element_count = return_object->package.count; | 812 | outer_element_count = return_object->package.count; |
648 | if (!outer_element_count) { | 813 | if (!outer_element_count || start_index >= outer_element_count) { |
649 | return (AE_AML_PACKAGE_LIMIT); | 814 | return (AE_AML_PACKAGE_LIMIT); |
650 | } | 815 | } |
651 | 816 | ||
817 | outer_elements = &return_object->package.elements[start_index]; | ||
818 | outer_element_count -= start_index; | ||
819 | |||
652 | previous_value = 0; | 820 | previous_value = 0; |
653 | if (sort_direction == ACPI_SORT_DESCENDING) { | 821 | if (sort_direction == ACPI_SORT_DESCENDING) { |
654 | previous_value = ACPI_UINT32_MAX; | 822 | previous_value = ACPI_UINT32_MAX; |
@@ -685,15 +853,16 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data, | |||
685 | (obj_desc->integer.value < previous_value)) || | 853 | (obj_desc->integer.value < previous_value)) || |
686 | ((sort_direction == ACPI_SORT_DESCENDING) && | 854 | ((sort_direction == ACPI_SORT_DESCENDING) && |
687 | (obj_desc->integer.value > previous_value))) { | 855 | (obj_desc->integer.value > previous_value))) { |
688 | acpi_ns_sort_list(return_object->package.elements, | 856 | acpi_ns_sort_list(&return_object->package. |
857 | elements[start_index], | ||
689 | outer_element_count, sort_index, | 858 | outer_element_count, sort_index, |
690 | sort_direction); | 859 | sort_direction); |
691 | 860 | ||
692 | data->flags |= ACPI_OBJECT_REPAIRED; | 861 | info->return_flags |= ACPI_OBJECT_REPAIRED; |
693 | 862 | ||
694 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, | 863 | ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, |
695 | "%s: Repaired unsorted list - now sorted by %s\n", | 864 | "%s: Repaired unsorted list - now sorted by %s\n", |
696 | data->pathname, sort_key_name)); | 865 | info->full_pathname, sort_key_name)); |
697 | return (AE_OK); | 866 | return (AE_OK); |
698 | } | 867 | } |
699 | 868 | ||
@@ -752,3 +921,52 @@ acpi_ns_sort_list(union acpi_operand_object **elements, | |||
752 | } | 921 | } |
753 | } | 922 | } |
754 | } | 923 | } |
924 | |||
925 | /****************************************************************************** | ||
926 | * | ||
927 | * FUNCTION: acpi_ns_remove_element | ||
928 | * | ||
929 | * PARAMETERS: obj_desc - Package object element list | ||
930 | * index - Index of element to remove | ||
931 | * | ||
932 | * RETURN: None | ||
933 | * | ||
934 | * DESCRIPTION: Remove the requested element of a package and delete it. | ||
935 | * | ||
936 | *****************************************************************************/ | ||
937 | |||
938 | static void | ||
939 | acpi_ns_remove_element(union acpi_operand_object *obj_desc, u32 index) | ||
940 | { | ||
941 | union acpi_operand_object **source; | ||
942 | union acpi_operand_object **dest; | ||
943 | u32 count; | ||
944 | u32 new_count; | ||
945 | u32 i; | ||
946 | |||
947 | ACPI_FUNCTION_NAME(ns_remove_element); | ||
948 | |||
949 | count = obj_desc->package.count; | ||
950 | new_count = count - 1; | ||
951 | |||
952 | source = obj_desc->package.elements; | ||
953 | dest = source; | ||
954 | |||
955 | /* Examine all elements of the package object, remove matched index */ | ||
956 | |||
957 | for (i = 0; i < count; i++) { | ||
958 | if (i == index) { | ||
959 | acpi_ut_remove_reference(*source); /* Remove one ref for being in pkg */ | ||
960 | acpi_ut_remove_reference(*source); | ||
961 | } else { | ||
962 | *dest = *source; | ||
963 | dest++; | ||
964 | } | ||
965 | source++; | ||
966 | } | ||
967 | |||
968 | /* NULL terminate list and update the package count */ | ||
969 | |||
970 | *dest = NULL; | ||
971 | obj_desc->package.count = new_count; | ||
972 | } | ||
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c index 2808586fad30..08c0b5beec88 100644 --- a/drivers/acpi/acpica/nsutils.c +++ b/drivers/acpi/acpica/nsutils.c | |||
@@ -419,10 +419,12 @@ acpi_ns_externalize_name(u32 internal_name_length, | |||
419 | 419 | ||
420 | switch (internal_name[0]) { | 420 | switch (internal_name[0]) { |
421 | case AML_ROOT_PREFIX: | 421 | case AML_ROOT_PREFIX: |
422 | |||
422 | prefix_length = 1; | 423 | prefix_length = 1; |
423 | break; | 424 | break; |
424 | 425 | ||
425 | case AML_PARENT_PREFIX: | 426 | case AML_PARENT_PREFIX: |
427 | |||
426 | for (i = 0; i < internal_name_length; i++) { | 428 | for (i = 0; i < internal_name_length; i++) { |
427 | if (ACPI_IS_PARENT_PREFIX(internal_name[i])) { | 429 | if (ACPI_IS_PARENT_PREFIX(internal_name[i])) { |
428 | prefix_length = i + 1; | 430 | prefix_length = i + 1; |
@@ -438,6 +440,7 @@ acpi_ns_externalize_name(u32 internal_name_length, | |||
438 | break; | 440 | break; |
439 | 441 | ||
440 | default: | 442 | default: |
443 | |||
441 | break; | 444 | break; |
442 | } | 445 | } |
443 | 446 | ||
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c index fc69949151bb..f553cfdb71dd 100644 --- a/drivers/acpi/acpica/nsxfeval.c +++ b/drivers/acpi/acpica/nsxfeval.c | |||
@@ -187,8 +187,6 @@ acpi_evaluate_object(acpi_handle handle, | |||
187 | return_ACPI_STATUS(AE_NO_MEMORY); | 187 | return_ACPI_STATUS(AE_NO_MEMORY); |
188 | } | 188 | } |
189 | 189 | ||
190 | info->pathname = pathname; | ||
191 | |||
192 | /* Convert and validate the device handle */ | 190 | /* Convert and validate the device handle */ |
193 | 191 | ||
194 | info->prefix_node = acpi_ns_validate_handle(handle); | 192 | info->prefix_node = acpi_ns_validate_handle(handle); |
@@ -198,17 +196,64 @@ acpi_evaluate_object(acpi_handle handle, | |||
198 | } | 196 | } |
199 | 197 | ||
200 | /* | 198 | /* |
201 | * If there are parameters to be passed to a control method, the external | 199 | * Get the actual namespace node for the target object. |
202 | * objects must all be converted to internal objects | 200 | * Handles these cases: |
201 | * | ||
202 | * 1) Null node, valid pathname from root (absolute path) | ||
203 | * 2) Node and valid pathname (path relative to Node) | ||
204 | * 3) Node, Null pathname | ||
205 | */ | ||
206 | if ((pathname) && (ACPI_IS_ROOT_PREFIX(pathname[0]))) { | ||
207 | |||
208 | /* The path is fully qualified, just evaluate by name */ | ||
209 | |||
210 | info->prefix_node = NULL; | ||
211 | } else if (!handle) { | ||
212 | /* | ||
213 | * A handle is optional iff a fully qualified pathname is specified. | ||
214 | * Since we've already handled fully qualified names above, this is | ||
215 | * an error. | ||
216 | */ | ||
217 | if (!pathname) { | ||
218 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
219 | "Both Handle and Pathname are NULL")); | ||
220 | } else { | ||
221 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
222 | "Null Handle with relative pathname [%s]", | ||
223 | pathname)); | ||
224 | } | ||
225 | |||
226 | status = AE_BAD_PARAMETER; | ||
227 | goto cleanup; | ||
228 | } | ||
229 | |||
230 | info->relative_pathname = pathname; | ||
231 | |||
232 | /* | ||
233 | * Convert all external objects passed as arguments to the | ||
234 | * internal version(s). | ||
203 | */ | 235 | */ |
204 | if (external_params && external_params->count) { | 236 | if (external_params && external_params->count) { |
237 | info->param_count = (u16)external_params->count; | ||
238 | |||
239 | /* Warn on impossible argument count */ | ||
240 | |||
241 | if (info->param_count > ACPI_METHOD_NUM_ARGS) { | ||
242 | ACPI_WARN_PREDEFINED((AE_INFO, pathname, | ||
243 | ACPI_WARN_ALWAYS, | ||
244 | "Excess arguments (%u) - using only %u", | ||
245 | info->param_count, | ||
246 | ACPI_METHOD_NUM_ARGS)); | ||
247 | |||
248 | info->param_count = ACPI_METHOD_NUM_ARGS; | ||
249 | } | ||
250 | |||
205 | /* | 251 | /* |
206 | * Allocate a new parameter block for the internal objects | 252 | * Allocate a new parameter block for the internal objects |
207 | * Add 1 to count to allow for null terminated internal list | 253 | * Add 1 to count to allow for null terminated internal list |
208 | */ | 254 | */ |
209 | info->parameters = ACPI_ALLOCATE_ZEROED(((acpi_size) | 255 | info->parameters = ACPI_ALLOCATE_ZEROED(((acpi_size) info-> |
210 | external_params-> | 256 | param_count + |
211 | count + | ||
212 | 1) * sizeof(void *)); | 257 | 1) * sizeof(void *)); |
213 | if (!info->parameters) { | 258 | if (!info->parameters) { |
214 | status = AE_NO_MEMORY; | 259 | status = AE_NO_MEMORY; |
@@ -217,7 +262,7 @@ acpi_evaluate_object(acpi_handle handle, | |||
217 | 262 | ||
218 | /* Convert each external object in the list to an internal object */ | 263 | /* Convert each external object in the list to an internal object */ |
219 | 264 | ||
220 | for (i = 0; i < external_params->count; i++) { | 265 | for (i = 0; i < info->param_count; i++) { |
221 | status = | 266 | status = |
222 | acpi_ut_copy_eobject_to_iobject(&external_params-> | 267 | acpi_ut_copy_eobject_to_iobject(&external_params-> |
223 | pointer[i], | 268 | pointer[i], |
@@ -227,43 +272,96 @@ acpi_evaluate_object(acpi_handle handle, | |||
227 | goto cleanup; | 272 | goto cleanup; |
228 | } | 273 | } |
229 | } | 274 | } |
230 | info->parameters[external_params->count] = NULL; | 275 | |
276 | info->parameters[info->param_count] = NULL; | ||
231 | } | 277 | } |
232 | 278 | ||
279 | #if 0 | ||
280 | |||
233 | /* | 281 | /* |
234 | * Three major cases: | 282 | * Begin incoming argument count analysis. Check for too few args |
235 | * 1) Fully qualified pathname | 283 | * and too many args. |
236 | * 2) No handle, not fully qualified pathname (error) | ||
237 | * 3) Valid handle | ||
238 | */ | 284 | */ |
239 | if ((pathname) && (ACPI_IS_ROOT_PREFIX(pathname[0]))) { | ||
240 | 285 | ||
241 | /* The path is fully qualified, just evaluate by name */ | 286 | switch (acpi_ns_get_type(info->node)) { |
287 | case ACPI_TYPE_METHOD: | ||
288 | |||
289 | /* Check incoming argument count against the method definition */ | ||
290 | |||
291 | if (info->obj_desc->method.param_count > info->param_count) { | ||
292 | ACPI_ERROR((AE_INFO, | ||
293 | "Insufficient arguments (%u) - %u are required", | ||
294 | info->param_count, | ||
295 | info->obj_desc->method.param_count)); | ||
296 | |||
297 | status = AE_MISSING_ARGUMENTS; | ||
298 | goto cleanup; | ||
299 | } | ||
300 | |||
301 | else if (info->obj_desc->method.param_count < info->param_count) { | ||
302 | ACPI_WARNING((AE_INFO, | ||
303 | "Excess arguments (%u) - only %u are required", | ||
304 | info->param_count, | ||
305 | info->obj_desc->method.param_count)); | ||
306 | |||
307 | /* Just pass the required number of arguments */ | ||
308 | |||
309 | info->param_count = info->obj_desc->method.param_count; | ||
310 | } | ||
242 | 311 | ||
243 | info->prefix_node = NULL; | ||
244 | status = acpi_ns_evaluate(info); | ||
245 | } else if (!handle) { | ||
246 | /* | 312 | /* |
247 | * A handle is optional iff a fully qualified pathname is specified. | 313 | * Any incoming external objects to be passed as arguments to the |
248 | * Since we've already handled fully qualified names above, this is | 314 | * method must be converted to internal objects |
249 | * an error | ||
250 | */ | 315 | */ |
251 | if (!pathname) { | 316 | if (info->param_count) { |
252 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 317 | /* |
253 | "Both Handle and Pathname are NULL")); | 318 | * Allocate a new parameter block for the internal objects |
254 | } else { | 319 | * Add 1 to count to allow for null terminated internal list |
255 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 320 | */ |
256 | "Null Handle with relative pathname [%s]", | 321 | info->parameters = ACPI_ALLOCATE_ZEROED(((acpi_size) |
257 | pathname)); | 322 | info-> |
323 | param_count + | ||
324 | 1) * | ||
325 | sizeof(void *)); | ||
326 | if (!info->parameters) { | ||
327 | status = AE_NO_MEMORY; | ||
328 | goto cleanup; | ||
329 | } | ||
330 | |||
331 | /* Convert each external object in the list to an internal object */ | ||
332 | |||
333 | for (i = 0; i < info->param_count; i++) { | ||
334 | status = | ||
335 | acpi_ut_copy_eobject_to_iobject | ||
336 | (&external_params->pointer[i], | ||
337 | &info->parameters[i]); | ||
338 | if (ACPI_FAILURE(status)) { | ||
339 | goto cleanup; | ||
340 | } | ||
341 | } | ||
342 | |||
343 | info->parameters[info->param_count] = NULL; | ||
258 | } | 344 | } |
345 | break; | ||
259 | 346 | ||
260 | status = AE_BAD_PARAMETER; | 347 | default: |
261 | } else { | 348 | |
262 | /* We have a namespace a node and a possible relative path */ | 349 | /* Warn if arguments passed to an object that is not a method */ |
263 | 350 | ||
264 | status = acpi_ns_evaluate(info); | 351 | if (info->param_count) { |
352 | ACPI_WARNING((AE_INFO, | ||
353 | "%u arguments were passed to a non-method ACPI object", | ||
354 | info->param_count)); | ||
355 | } | ||
356 | break; | ||
265 | } | 357 | } |
266 | 358 | ||
359 | #endif | ||
360 | |||
361 | /* Now we can evaluate the object */ | ||
362 | |||
363 | status = acpi_ns_evaluate(info); | ||
364 | |||
267 | /* | 365 | /* |
268 | * If we are expecting a return value, and all went well above, | 366 | * If we are expecting a return value, and all went well above, |
269 | * copy the return value to an external object. | 367 | * copy the return value to an external object. |
@@ -413,6 +511,7 @@ static void acpi_ns_resolve_references(struct acpi_evaluate_info *info) | |||
413 | break; | 511 | break; |
414 | 512 | ||
415 | default: | 513 | default: |
514 | |||
416 | return; | 515 | return; |
417 | } | 516 | } |
418 | 517 | ||
diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c index 9f25a3d4e992..91a5a69db80c 100644 --- a/drivers/acpi/acpica/psargs.c +++ b/drivers/acpi/acpica/psargs.c | |||
@@ -629,24 +629,28 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state | |||
629 | 629 | ||
630 | switch (opcode) { | 630 | switch (opcode) { |
631 | case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ | 631 | case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ |
632 | |||
632 | buffer_length = | 633 | buffer_length = |
633 | ACPI_GET8(parser_state->aml); | 634 | ACPI_GET8(parser_state->aml); |
634 | parser_state->aml += 1; | 635 | parser_state->aml += 1; |
635 | break; | 636 | break; |
636 | 637 | ||
637 | case AML_WORD_OP: /* AML_WORDDATA_ARG */ | 638 | case AML_WORD_OP: /* AML_WORDDATA_ARG */ |
639 | |||
638 | buffer_length = | 640 | buffer_length = |
639 | ACPI_GET16(parser_state->aml); | 641 | ACPI_GET16(parser_state->aml); |
640 | parser_state->aml += 2; | 642 | parser_state->aml += 2; |
641 | break; | 643 | break; |
642 | 644 | ||
643 | case AML_DWORD_OP: /* AML_DWORDATA_ARG */ | 645 | case AML_DWORD_OP: /* AML_DWORDATA_ARG */ |
646 | |||
644 | buffer_length = | 647 | buffer_length = |
645 | ACPI_GET32(parser_state->aml); | 648 | ACPI_GET32(parser_state->aml); |
646 | parser_state->aml += 4; | 649 | parser_state->aml += 4; |
647 | break; | 650 | break; |
648 | 651 | ||
649 | default: | 652 | default: |
653 | |||
650 | buffer_length = 0; | 654 | buffer_length = 0; |
651 | break; | 655 | break; |
652 | } | 656 | } |
diff --git a/drivers/acpi/acpica/psloop.c b/drivers/acpi/acpica/psloop.c index 63c455447481..065b44ae538f 100644 --- a/drivers/acpi/acpica/psloop.c +++ b/drivers/acpi/acpica/psloop.c | |||
@@ -164,7 +164,6 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state, | |||
164 | case AML_IF_OP: | 164 | case AML_IF_OP: |
165 | case AML_ELSE_OP: | 165 | case AML_ELSE_OP: |
166 | case AML_WHILE_OP: | 166 | case AML_WHILE_OP: |
167 | |||
168 | /* | 167 | /* |
169 | * Currently supported module-level opcodes are: | 168 | * Currently supported module-level opcodes are: |
170 | * IF/ELSE/WHILE. These appear to be the most common, | 169 | * IF/ELSE/WHILE. These appear to be the most common, |
@@ -289,6 +288,7 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state, | |||
289 | default: | 288 | default: |
290 | 289 | ||
291 | /* No action for all other opcodes */ | 290 | /* No action for all other opcodes */ |
291 | |||
292 | break; | 292 | break; |
293 | } | 293 | } |
294 | 294 | ||
diff --git a/drivers/acpi/acpica/psobject.c b/drivers/acpi/acpica/psobject.c index 12c4028002b1..95dc608a66a8 100644 --- a/drivers/acpi/acpica/psobject.c +++ b/drivers/acpi/acpica/psobject.c | |||
@@ -402,6 +402,7 @@ acpi_ps_complete_op(struct acpi_walk_state *walk_state, | |||
402 | 402 | ||
403 | switch (status) { | 403 | switch (status) { |
404 | case AE_OK: | 404 | case AE_OK: |
405 | |||
405 | break; | 406 | break; |
406 | 407 | ||
407 | case AE_CTRL_TRANSFER: | 408 | case AE_CTRL_TRANSFER: |
diff --git a/drivers/acpi/acpica/psparse.c b/drivers/acpi/acpica/psparse.c index abc4c48b2edd..86198a9139b5 100644 --- a/drivers/acpi/acpica/psparse.c +++ b/drivers/acpi/acpica/psparse.c | |||
@@ -176,10 +176,10 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state, | |||
176 | 176 | ||
177 | switch (parent_info->class) { | 177 | switch (parent_info->class) { |
178 | case AML_CLASS_CONTROL: | 178 | case AML_CLASS_CONTROL: |
179 | |||
179 | break; | 180 | break; |
180 | 181 | ||
181 | case AML_CLASS_CREATE: | 182 | case AML_CLASS_CREATE: |
182 | |||
183 | /* | 183 | /* |
184 | * These opcodes contain term_arg operands. The current | 184 | * These opcodes contain term_arg operands. The current |
185 | * op must be replaced by a placeholder return op | 185 | * op must be replaced by a placeholder return op |
@@ -192,7 +192,6 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state, | |||
192 | break; | 192 | break; |
193 | 193 | ||
194 | case AML_CLASS_NAMED_OBJECT: | 194 | case AML_CLASS_NAMED_OBJECT: |
195 | |||
196 | /* | 195 | /* |
197 | * These opcodes contain term_arg operands. The current | 196 | * These opcodes contain term_arg operands. The current |
198 | * op must be replaced by a placeholder return op | 197 | * op must be replaced by a placeholder return op |
diff --git a/drivers/acpi/acpica/pstree.c b/drivers/acpi/acpica/pstree.c index c1934bf04f0a..877dc0de8df3 100644 --- a/drivers/acpi/acpica/pstree.c +++ b/drivers/acpi/acpica/pstree.c | |||
@@ -308,7 +308,9 @@ union acpi_parse_object *acpi_ps_get_child(union acpi_parse_object *op) | |||
308 | break; | 308 | break; |
309 | 309 | ||
310 | default: | 310 | default: |
311 | |||
311 | /* All others have no children */ | 312 | /* All others have no children */ |
313 | |||
312 | break; | 314 | break; |
313 | } | 315 | } |
314 | 316 | ||
diff --git a/drivers/acpi/acpica/psxface.c b/drivers/acpi/acpica/psxface.c index f68254268965..11b99ab20bb3 100644 --- a/drivers/acpi/acpica/psxface.c +++ b/drivers/acpi/acpica/psxface.c | |||
@@ -125,7 +125,7 @@ static void acpi_ps_start_trace(struct acpi_evaluate_info *info) | |||
125 | } | 125 | } |
126 | 126 | ||
127 | if ((!acpi_gbl_trace_method_name) || | 127 | if ((!acpi_gbl_trace_method_name) || |
128 | (acpi_gbl_trace_method_name != info->resolved_node->name.integer)) { | 128 | (acpi_gbl_trace_method_name != info->node->name.integer)) { |
129 | goto exit; | 129 | goto exit; |
130 | } | 130 | } |
131 | 131 | ||
@@ -170,7 +170,7 @@ static void acpi_ps_stop_trace(struct acpi_evaluate_info *info) | |||
170 | } | 170 | } |
171 | 171 | ||
172 | if ((!acpi_gbl_trace_method_name) || | 172 | if ((!acpi_gbl_trace_method_name) || |
173 | (acpi_gbl_trace_method_name != info->resolved_node->name.integer)) { | 173 | (acpi_gbl_trace_method_name != info->node->name.integer)) { |
174 | goto exit; | 174 | goto exit; |
175 | } | 175 | } |
176 | 176 | ||
@@ -226,15 +226,14 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info) | |||
226 | 226 | ||
227 | /* Validate the Info and method Node */ | 227 | /* Validate the Info and method Node */ |
228 | 228 | ||
229 | if (!info || !info->resolved_node) { | 229 | if (!info || !info->node) { |
230 | return_ACPI_STATUS(AE_NULL_ENTRY); | 230 | return_ACPI_STATUS(AE_NULL_ENTRY); |
231 | } | 231 | } |
232 | 232 | ||
233 | /* Init for new method, wait on concurrency semaphore */ | 233 | /* Init for new method, wait on concurrency semaphore */ |
234 | 234 | ||
235 | status = | 235 | status = |
236 | acpi_ds_begin_method_execution(info->resolved_node, info->obj_desc, | 236 | acpi_ds_begin_method_execution(info->node, info->obj_desc, NULL); |
237 | NULL); | ||
238 | if (ACPI_FAILURE(status)) { | 237 | if (ACPI_FAILURE(status)) { |
239 | return_ACPI_STATUS(status); | 238 | return_ACPI_STATUS(status); |
240 | } | 239 | } |
@@ -253,8 +252,7 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info) | |||
253 | */ | 252 | */ |
254 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, | 253 | ACPI_DEBUG_PRINT((ACPI_DB_PARSE, |
255 | "**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n", | 254 | "**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n", |
256 | info->resolved_node->name.ascii, info->resolved_node, | 255 | info->node->name.ascii, info->node, info->obj_desc)); |
257 | info->obj_desc)); | ||
258 | 256 | ||
259 | /* Create and init a Root Node */ | 257 | /* Create and init a Root Node */ |
260 | 258 | ||
@@ -275,7 +273,7 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info) | |||
275 | goto cleanup; | 273 | goto cleanup; |
276 | } | 274 | } |
277 | 275 | ||
278 | status = acpi_ds_init_aml_walk(walk_state, op, info->resolved_node, | 276 | status = acpi_ds_init_aml_walk(walk_state, op, info->node, |
279 | info->obj_desc->method.aml_start, | 277 | info->obj_desc->method.aml_start, |
280 | info->obj_desc->method.aml_length, info, | 278 | info->obj_desc->method.aml_length, info, |
281 | info->pass_number); | 279 | info->pass_number); |
diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c index 72077fa1eea5..b62a0f4f4f9b 100644 --- a/drivers/acpi/acpica/rscalc.c +++ b/drivers/acpi/acpica/rscalc.c | |||
@@ -352,6 +352,7 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) | |||
352 | break; | 352 | break; |
353 | 353 | ||
354 | default: | 354 | default: |
355 | |||
355 | break; | 356 | break; |
356 | } | 357 | } |
357 | 358 | ||
@@ -539,6 +540,7 @@ acpi_rs_get_list_length(u8 * aml_buffer, | |||
539 | break; | 540 | break; |
540 | 541 | ||
541 | default: | 542 | default: |
543 | |||
542 | break; | 544 | break; |
543 | } | 545 | } |
544 | 546 | ||
@@ -650,8 +652,9 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object, | |||
650 | 652 | ||
651 | name_found = FALSE; | 653 | name_found = FALSE; |
652 | 654 | ||
653 | for (table_index = 0; table_index < 4 && !name_found; | 655 | for (table_index = 0; |
654 | table_index++) { | 656 | table_index < package_element->package.count |
657 | && !name_found; table_index++) { | ||
655 | if (*sub_object_list && /* Null object allowed */ | 658 | if (*sub_object_list && /* Null object allowed */ |
656 | ((ACPI_TYPE_STRING == | 659 | ((ACPI_TYPE_STRING == |
657 | (*sub_object_list)->common.type) || | 660 | (*sub_object_list)->common.type) || |
diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c index f8b55b426c9d..65f3e1c5b598 100644 --- a/drivers/acpi/acpica/rscreate.c +++ b/drivers/acpi/acpica/rscreate.c | |||
@@ -273,17 +273,6 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
273 | */ | 273 | */ |
274 | user_prt->length = (sizeof(struct acpi_pci_routing_table) - 4); | 274 | user_prt->length = (sizeof(struct acpi_pci_routing_table) - 4); |
275 | 275 | ||
276 | /* Each element of the top-level package must also be a package */ | ||
277 | |||
278 | if ((*top_object_list)->common.type != ACPI_TYPE_PACKAGE) { | ||
279 | ACPI_ERROR((AE_INFO, | ||
280 | "(PRT[%u]) Need sub-package, found %s", | ||
281 | index, | ||
282 | acpi_ut_get_object_type_name | ||
283 | (*top_object_list))); | ||
284 | return_ACPI_STATUS(AE_AML_OPERAND_TYPE); | ||
285 | } | ||
286 | |||
287 | /* Each sub-package must be of length 4 */ | 276 | /* Each sub-package must be of length 4 */ |
288 | 277 | ||
289 | if ((*top_object_list)->package.count != 4) { | 278 | if ((*top_object_list)->package.count != 4) { |
@@ -327,22 +316,6 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object, | |||
327 | user_prt->pin = (u32) obj_desc->integer.value; | 316 | user_prt->pin = (u32) obj_desc->integer.value; |
328 | 317 | ||
329 | /* | 318 | /* |
330 | * If the BIOS has erroneously reversed the _PRT source_name (index 2) | ||
331 | * and the source_index (index 3), fix it. _PRT is important enough to | ||
332 | * workaround this BIOS error. This also provides compatibility with | ||
333 | * other ACPI implementations. | ||
334 | */ | ||
335 | obj_desc = sub_object_list[3]; | ||
336 | if (!obj_desc || (obj_desc->common.type != ACPI_TYPE_INTEGER)) { | ||
337 | sub_object_list[3] = sub_object_list[2]; | ||
338 | sub_object_list[2] = obj_desc; | ||
339 | |||
340 | ACPI_WARNING((AE_INFO, | ||
341 | "(PRT[%X].Source) SourceName and SourceIndex are reversed, fixed", | ||
342 | index)); | ||
343 | } | ||
344 | |||
345 | /* | ||
346 | * 3) Third subobject: Dereference the PRT.source_name | 319 | * 3) Third subobject: Dereference the PRT.source_name |
347 | * The name may be unresolved (slack mode), so allow a null object | 320 | * The name may be unresolved (slack mode), so allow a null object |
348 | */ | 321 | */ |
diff --git a/drivers/acpi/acpica/rsdump.c b/drivers/acpi/acpica/rsdump.c index b5fc0db2e87b..8a2d4986b0aa 100644 --- a/drivers/acpi/acpica/rsdump.c +++ b/drivers/acpi/acpica/rsdump.c | |||
@@ -120,17 +120,20 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) | |||
120 | /* Strings */ | 120 | /* Strings */ |
121 | 121 | ||
122 | case ACPI_RSD_LITERAL: | 122 | case ACPI_RSD_LITERAL: |
123 | |||
123 | acpi_rs_out_string(name, | 124 | acpi_rs_out_string(name, |
124 | ACPI_CAST_PTR(char, table->pointer)); | 125 | ACPI_CAST_PTR(char, table->pointer)); |
125 | break; | 126 | break; |
126 | 127 | ||
127 | case ACPI_RSD_STRING: | 128 | case ACPI_RSD_STRING: |
129 | |||
128 | acpi_rs_out_string(name, ACPI_CAST_PTR(char, target)); | 130 | acpi_rs_out_string(name, ACPI_CAST_PTR(char, target)); |
129 | break; | 131 | break; |
130 | 132 | ||
131 | /* Data items, 8/16/32/64 bit */ | 133 | /* Data items, 8/16/32/64 bit */ |
132 | 134 | ||
133 | case ACPI_RSD_UINT8: | 135 | case ACPI_RSD_UINT8: |
136 | |||
134 | if (table->pointer) { | 137 | if (table->pointer) { |
135 | acpi_rs_out_string(name, ACPI_CAST_PTR(char, | 138 | acpi_rs_out_string(name, ACPI_CAST_PTR(char, |
136 | table-> | 139 | table-> |
@@ -142,20 +145,24 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) | |||
142 | break; | 145 | break; |
143 | 146 | ||
144 | case ACPI_RSD_UINT16: | 147 | case ACPI_RSD_UINT16: |
148 | |||
145 | acpi_rs_out_integer16(name, ACPI_GET16(target)); | 149 | acpi_rs_out_integer16(name, ACPI_GET16(target)); |
146 | break; | 150 | break; |
147 | 151 | ||
148 | case ACPI_RSD_UINT32: | 152 | case ACPI_RSD_UINT32: |
153 | |||
149 | acpi_rs_out_integer32(name, ACPI_GET32(target)); | 154 | acpi_rs_out_integer32(name, ACPI_GET32(target)); |
150 | break; | 155 | break; |
151 | 156 | ||
152 | case ACPI_RSD_UINT64: | 157 | case ACPI_RSD_UINT64: |
158 | |||
153 | acpi_rs_out_integer64(name, ACPI_GET64(target)); | 159 | acpi_rs_out_integer64(name, ACPI_GET64(target)); |
154 | break; | 160 | break; |
155 | 161 | ||
156 | /* Flags: 1-bit and 2-bit flags supported */ | 162 | /* Flags: 1-bit and 2-bit flags supported */ |
157 | 163 | ||
158 | case ACPI_RSD_1BITFLAG: | 164 | case ACPI_RSD_1BITFLAG: |
165 | |||
159 | acpi_rs_out_string(name, ACPI_CAST_PTR(char, | 166 | acpi_rs_out_string(name, ACPI_CAST_PTR(char, |
160 | table-> | 167 | table-> |
161 | pointer[*target & | 168 | pointer[*target & |
@@ -163,6 +170,7 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) | |||
163 | break; | 170 | break; |
164 | 171 | ||
165 | case ACPI_RSD_2BITFLAG: | 172 | case ACPI_RSD_2BITFLAG: |
173 | |||
166 | acpi_rs_out_string(name, ACPI_CAST_PTR(char, | 174 | acpi_rs_out_string(name, ACPI_CAST_PTR(char, |
167 | table-> | 175 | table-> |
168 | pointer[*target & | 176 | pointer[*target & |
@@ -170,6 +178,7 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) | |||
170 | break; | 178 | break; |
171 | 179 | ||
172 | case ACPI_RSD_3BITFLAG: | 180 | case ACPI_RSD_3BITFLAG: |
181 | |||
173 | acpi_rs_out_string(name, ACPI_CAST_PTR(char, | 182 | acpi_rs_out_string(name, ACPI_CAST_PTR(char, |
174 | table-> | 183 | table-> |
175 | pointer[*target & | 184 | pointer[*target & |
@@ -258,6 +267,7 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table) | |||
258 | break; | 267 | break; |
259 | 268 | ||
260 | default: | 269 | default: |
270 | |||
261 | acpi_os_printf("**** Invalid table opcode [%X] ****\n", | 271 | acpi_os_printf("**** Invalid table opcode [%X] ****\n", |
262 | table->opcode); | 272 | table->opcode); |
263 | return; | 273 | return; |
diff --git a/drivers/acpi/acpica/rsmisc.c b/drivers/acpi/acpica/rsmisc.c index d5bf05a96096..80d12994e0d0 100644 --- a/drivers/acpi/acpica/rsmisc.c +++ b/drivers/acpi/acpica/rsmisc.c | |||
@@ -194,7 +194,6 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, | |||
194 | break; | 194 | break; |
195 | 195 | ||
196 | case ACPI_RSC_COUNT_GPIO_RES: | 196 | case ACPI_RSC_COUNT_GPIO_RES: |
197 | |||
198 | /* | 197 | /* |
199 | * Vendor data is optional (length/offset may both be zero) | 198 | * Vendor data is optional (length/offset may both be zero) |
200 | * Examine vendor data length field first | 199 | * Examine vendor data length field first |
@@ -410,12 +409,14 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource, | |||
410 | */ | 409 | */ |
411 | switch (info->resource_offset) { | 410 | switch (info->resource_offset) { |
412 | case ACPI_RSC_COMPARE_AML_LENGTH: | 411 | case ACPI_RSC_COMPARE_AML_LENGTH: |
412 | |||
413 | if (aml_resource_length != info->value) { | 413 | if (aml_resource_length != info->value) { |
414 | goto exit; | 414 | goto exit; |
415 | } | 415 | } |
416 | break; | 416 | break; |
417 | 417 | ||
418 | case ACPI_RSC_COMPARE_VALUE: | 418 | case ACPI_RSC_COMPARE_VALUE: |
419 | |||
419 | if (ACPI_GET8(source) != info->value) { | 420 | if (ACPI_GET8(source) != info->value) { |
420 | goto exit; | 421 | goto exit; |
421 | } | 422 | } |
diff --git a/drivers/acpi/acpica/rsutils.c b/drivers/acpi/acpica/rsutils.c index a44953c6f75d..480b6b40c5ea 100644 --- a/drivers/acpi/acpica/rsutils.c +++ b/drivers/acpi/acpica/rsutils.c | |||
@@ -147,6 +147,7 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) | |||
147 | case ACPI_RSC_MOVE_GPIO_RES: | 147 | case ACPI_RSC_MOVE_GPIO_RES: |
148 | case ACPI_RSC_MOVE_SERIAL_VEN: | 148 | case ACPI_RSC_MOVE_SERIAL_VEN: |
149 | case ACPI_RSC_MOVE_SERIAL_RES: | 149 | case ACPI_RSC_MOVE_SERIAL_RES: |
150 | |||
150 | ACPI_MEMCPY(destination, source, item_count); | 151 | ACPI_MEMCPY(destination, source, item_count); |
151 | return; | 152 | return; |
152 | 153 | ||
@@ -157,21 +158,25 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type) | |||
157 | */ | 158 | */ |
158 | case ACPI_RSC_MOVE16: | 159 | case ACPI_RSC_MOVE16: |
159 | case ACPI_RSC_MOVE_GPIO_PIN: | 160 | case ACPI_RSC_MOVE_GPIO_PIN: |
161 | |||
160 | ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i], | 162 | ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i], |
161 | &ACPI_CAST_PTR(u16, source)[i]); | 163 | &ACPI_CAST_PTR(u16, source)[i]); |
162 | break; | 164 | break; |
163 | 165 | ||
164 | case ACPI_RSC_MOVE32: | 166 | case ACPI_RSC_MOVE32: |
167 | |||
165 | ACPI_MOVE_32_TO_32(&ACPI_CAST_PTR(u32, destination)[i], | 168 | ACPI_MOVE_32_TO_32(&ACPI_CAST_PTR(u32, destination)[i], |
166 | &ACPI_CAST_PTR(u32, source)[i]); | 169 | &ACPI_CAST_PTR(u32, source)[i]); |
167 | break; | 170 | break; |
168 | 171 | ||
169 | case ACPI_RSC_MOVE64: | 172 | case ACPI_RSC_MOVE64: |
173 | |||
170 | ACPI_MOVE_64_TO_64(&ACPI_CAST_PTR(u64, destination)[i], | 174 | ACPI_MOVE_64_TO_64(&ACPI_CAST_PTR(u64, destination)[i], |
171 | &ACPI_CAST_PTR(u64, source)[i]); | 175 | &ACPI_CAST_PTR(u64, source)[i]); |
172 | break; | 176 | break; |
173 | 177 | ||
174 | default: | 178 | default: |
179 | |||
175 | return; | 180 | return; |
176 | } | 181 | } |
177 | } | 182 | } |
@@ -736,7 +741,7 @@ acpi_rs_set_srs_method_data(struct acpi_namespace_node *node, | |||
736 | } | 741 | } |
737 | 742 | ||
738 | info->prefix_node = node; | 743 | info->prefix_node = node; |
739 | info->pathname = METHOD_NAME__SRS; | 744 | info->relative_pathname = METHOD_NAME__SRS; |
740 | info->parameters = args; | 745 | info->parameters = args; |
741 | info->flags = ACPI_IGNORE_RETURN_VALUE; | 746 | info->flags = ACPI_IGNORE_RETURN_VALUE; |
742 | 747 | ||
diff --git a/drivers/acpi/acpica/rsxface.c b/drivers/acpi/acpica/rsxface.c index c0e5d2d3ce67..94e3517554f9 100644 --- a/drivers/acpi/acpica/rsxface.c +++ b/drivers/acpi/acpica/rsxface.c | |||
@@ -402,6 +402,7 @@ acpi_resource_to_address64(struct acpi_resource *resource, | |||
402 | break; | 402 | break; |
403 | 403 | ||
404 | default: | 404 | default: |
405 | |||
405 | return (AE_BAD_PARAMETER); | 406 | return (AE_BAD_PARAMETER); |
406 | } | 407 | } |
407 | 408 | ||
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c index e57cd38004e3..42a13c0d7015 100644 --- a/drivers/acpi/acpica/tbinstal.c +++ b/drivers/acpi/acpica/tbinstal.c | |||
@@ -141,8 +141,7 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) | |||
141 | ACPI_BIOS_ERROR((AE_INFO, | 141 | ACPI_BIOS_ERROR((AE_INFO, |
142 | "Table has invalid signature [%4.4s] (0x%8.8X), " | 142 | "Table has invalid signature [%4.4s] (0x%8.8X), " |
143 | "must be SSDT or OEMx", | 143 | "must be SSDT or OEMx", |
144 | acpi_ut_valid_acpi_name(*(u32 *)table_desc-> | 144 | acpi_ut_valid_acpi_name(table_desc->pointer-> |
145 | pointer-> | ||
146 | signature) ? | 145 | signature) ? |
147 | table_desc->pointer->signature : "????", | 146 | table_desc->pointer->signature : "????", |
148 | *(u32 *)table_desc->pointer->signature)); | 147 | *(u32 *)table_desc->pointer->signature)); |
@@ -471,15 +470,19 @@ void acpi_tb_delete_table(struct acpi_table_desc *table_desc) | |||
471 | } | 470 | } |
472 | switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) { | 471 | switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) { |
473 | case ACPI_TABLE_ORIGIN_MAPPED: | 472 | case ACPI_TABLE_ORIGIN_MAPPED: |
473 | |||
474 | acpi_os_unmap_memory(table_desc->pointer, table_desc->length); | 474 | acpi_os_unmap_memory(table_desc->pointer, table_desc->length); |
475 | break; | 475 | break; |
476 | |||
476 | case ACPI_TABLE_ORIGIN_ALLOCATED: | 477 | case ACPI_TABLE_ORIGIN_ALLOCATED: |
478 | |||
477 | ACPI_FREE(table_desc->pointer); | 479 | ACPI_FREE(table_desc->pointer); |
478 | break; | 480 | break; |
479 | 481 | ||
480 | /* Not mapped or allocated, there is nothing we can do */ | 482 | /* Not mapped or allocated, there is nothing we can do */ |
481 | 483 | ||
482 | default: | 484 | default: |
485 | |||
483 | return; | 486 | return; |
484 | } | 487 | } |
485 | 488 | ||
diff --git a/drivers/acpi/acpica/tbprint.c b/drivers/acpi/acpica/tbprint.c new file mode 100644 index 000000000000..dc963f823d2c --- /dev/null +++ b/drivers/acpi/acpica/tbprint.c | |||
@@ -0,0 +1,237 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: tbprint - Table output utilities | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2013, Intel Corp. | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions, and the following disclaimer, | ||
16 | * without modification. | ||
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
18 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
19 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
20 | * including a substantially similar Disclaimer requirement for further | ||
21 | * binary redistribution. | ||
22 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
23 | * of any contributors may be used to endorse or promote products derived | ||
24 | * from this software without specific prior written permission. | ||
25 | * | ||
26 | * Alternatively, this software may be distributed under the terms of the | ||
27 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
28 | * Software Foundation. | ||
29 | * | ||
30 | * NO WARRANTY | ||
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
41 | * POSSIBILITY OF SUCH DAMAGES. | ||
42 | */ | ||
43 | |||
44 | #include <acpi/acpi.h> | ||
45 | #include "accommon.h" | ||
46 | #include "actables.h" | ||
47 | |||
48 | #define _COMPONENT ACPI_TABLES | ||
49 | ACPI_MODULE_NAME("tbprint") | ||
50 | |||
51 | /* Local prototypes */ | ||
52 | static void acpi_tb_fix_string(char *string, acpi_size length); | ||
53 | |||
54 | static void | ||
55 | acpi_tb_cleanup_table_header(struct acpi_table_header *out_header, | ||
56 | struct acpi_table_header *header); | ||
57 | |||
58 | /******************************************************************************* | ||
59 | * | ||
60 | * FUNCTION: acpi_tb_fix_string | ||
61 | * | ||
62 | * PARAMETERS: string - String to be repaired | ||
63 | * length - Maximum length | ||
64 | * | ||
65 | * RETURN: None | ||
66 | * | ||
67 | * DESCRIPTION: Replace every non-printable or non-ascii byte in the string | ||
68 | * with a question mark '?'. | ||
69 | * | ||
70 | ******************************************************************************/ | ||
71 | |||
72 | static void acpi_tb_fix_string(char *string, acpi_size length) | ||
73 | { | ||
74 | |||
75 | while (length && *string) { | ||
76 | if (!ACPI_IS_PRINT(*string)) { | ||
77 | *string = '?'; | ||
78 | } | ||
79 | string++; | ||
80 | length--; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | /******************************************************************************* | ||
85 | * | ||
86 | * FUNCTION: acpi_tb_cleanup_table_header | ||
87 | * | ||
88 | * PARAMETERS: out_header - Where the cleaned header is returned | ||
89 | * header - Input ACPI table header | ||
90 | * | ||
91 | * RETURN: Returns the cleaned header in out_header | ||
92 | * | ||
93 | * DESCRIPTION: Copy the table header and ensure that all "string" fields in | ||
94 | * the header consist of printable characters. | ||
95 | * | ||
96 | ******************************************************************************/ | ||
97 | |||
98 | static void | ||
99 | acpi_tb_cleanup_table_header(struct acpi_table_header *out_header, | ||
100 | struct acpi_table_header *header) | ||
101 | { | ||
102 | |||
103 | ACPI_MEMCPY(out_header, header, sizeof(struct acpi_table_header)); | ||
104 | |||
105 | acpi_tb_fix_string(out_header->signature, ACPI_NAME_SIZE); | ||
106 | acpi_tb_fix_string(out_header->oem_id, ACPI_OEM_ID_SIZE); | ||
107 | acpi_tb_fix_string(out_header->oem_table_id, ACPI_OEM_TABLE_ID_SIZE); | ||
108 | acpi_tb_fix_string(out_header->asl_compiler_id, ACPI_NAME_SIZE); | ||
109 | } | ||
110 | |||
111 | /******************************************************************************* | ||
112 | * | ||
113 | * FUNCTION: acpi_tb_print_table_header | ||
114 | * | ||
115 | * PARAMETERS: address - Table physical address | ||
116 | * header - Table header | ||
117 | * | ||
118 | * RETURN: None | ||
119 | * | ||
120 | * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP. | ||
121 | * | ||
122 | ******************************************************************************/ | ||
123 | |||
124 | void | ||
125 | acpi_tb_print_table_header(acpi_physical_address address, | ||
126 | struct acpi_table_header *header) | ||
127 | { | ||
128 | struct acpi_table_header local_header; | ||
129 | |||
130 | /* | ||
131 | * The reason that the Address is cast to a void pointer is so that we | ||
132 | * can use %p which will work properly on both 32-bit and 64-bit hosts. | ||
133 | */ | ||
134 | if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) { | ||
135 | |||
136 | /* FACS only has signature and length fields */ | ||
137 | |||
138 | ACPI_INFO((AE_INFO, "%4.4s %p %05X", | ||
139 | header->signature, ACPI_CAST_PTR(void, address), | ||
140 | header->length)); | ||
141 | } else if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_RSDP)) { | ||
142 | |||
143 | /* RSDP has no common fields */ | ||
144 | |||
145 | ACPI_MEMCPY(local_header.oem_id, | ||
146 | ACPI_CAST_PTR(struct acpi_table_rsdp, | ||
147 | header)->oem_id, ACPI_OEM_ID_SIZE); | ||
148 | acpi_tb_fix_string(local_header.oem_id, ACPI_OEM_ID_SIZE); | ||
149 | |||
150 | ACPI_INFO((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)", | ||
151 | ACPI_CAST_PTR(void, address), | ||
152 | (ACPI_CAST_PTR(struct acpi_table_rsdp, header)-> | ||
153 | revision > | ||
154 | 0) ? ACPI_CAST_PTR(struct acpi_table_rsdp, | ||
155 | header)->length : 20, | ||
156 | ACPI_CAST_PTR(struct acpi_table_rsdp, | ||
157 | header)->revision, | ||
158 | local_header.oem_id)); | ||
159 | } else { | ||
160 | /* Standard ACPI table with full common header */ | ||
161 | |||
162 | acpi_tb_cleanup_table_header(&local_header, header); | ||
163 | |||
164 | ACPI_INFO((AE_INFO, | ||
165 | "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)", | ||
166 | local_header.signature, ACPI_CAST_PTR(void, address), | ||
167 | local_header.length, local_header.revision, | ||
168 | local_header.oem_id, local_header.oem_table_id, | ||
169 | local_header.oem_revision, | ||
170 | local_header.asl_compiler_id, | ||
171 | local_header.asl_compiler_revision)); | ||
172 | } | ||
173 | } | ||
174 | |||
175 | /******************************************************************************* | ||
176 | * | ||
177 | * FUNCTION: acpi_tb_validate_checksum | ||
178 | * | ||
179 | * PARAMETERS: table - ACPI table to verify | ||
180 | * length - Length of entire table | ||
181 | * | ||
182 | * RETURN: Status | ||
183 | * | ||
184 | * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns | ||
185 | * exception on bad checksum. | ||
186 | * | ||
187 | ******************************************************************************/ | ||
188 | |||
189 | acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length) | ||
190 | { | ||
191 | u8 checksum; | ||
192 | |||
193 | /* Compute the checksum on the table */ | ||
194 | |||
195 | checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), length); | ||
196 | |||
197 | /* Checksum ok? (should be zero) */ | ||
198 | |||
199 | if (checksum) { | ||
200 | ACPI_BIOS_WARNING((AE_INFO, | ||
201 | "Incorrect checksum in table [%4.4s] - 0x%2.2X, " | ||
202 | "should be 0x%2.2X", | ||
203 | table->signature, table->checksum, | ||
204 | (u8)(table->checksum - checksum))); | ||
205 | |||
206 | #if (ACPI_CHECKSUM_ABORT) | ||
207 | return (AE_BAD_CHECKSUM); | ||
208 | #endif | ||
209 | } | ||
210 | |||
211 | return (AE_OK); | ||
212 | } | ||
213 | |||
214 | /******************************************************************************* | ||
215 | * | ||
216 | * FUNCTION: acpi_tb_checksum | ||
217 | * | ||
218 | * PARAMETERS: buffer - Pointer to memory region to be checked | ||
219 | * length - Length of this memory region | ||
220 | * | ||
221 | * RETURN: Checksum (u8) | ||
222 | * | ||
223 | * DESCRIPTION: Calculates circular checksum of memory region. | ||
224 | * | ||
225 | ******************************************************************************/ | ||
226 | |||
227 | u8 acpi_tb_checksum(u8 *buffer, u32 length) | ||
228 | { | ||
229 | u8 sum = 0; | ||
230 | u8 *end = buffer + length; | ||
231 | |||
232 | while (buffer < end) { | ||
233 | sum = (u8)(sum + *(buffer++)); | ||
234 | } | ||
235 | |||
236 | return (sum); | ||
237 | } | ||
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c index ce3d5db39a9c..bffdfc7b8322 100644 --- a/drivers/acpi/acpica/tbutils.c +++ b/drivers/acpi/acpica/tbutils.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | * |
3 | * Module Name: tbutils - table utilities | 3 | * Module Name: tbutils - ACPI Table utilities |
4 | * | 4 | * |
5 | *****************************************************************************/ | 5 | *****************************************************************************/ |
6 | 6 | ||
@@ -49,12 +49,6 @@ | |||
49 | ACPI_MODULE_NAME("tbutils") | 49 | ACPI_MODULE_NAME("tbutils") |
50 | 50 | ||
51 | /* Local prototypes */ | 51 | /* Local prototypes */ |
52 | static void acpi_tb_fix_string(char *string, acpi_size length); | ||
53 | |||
54 | static void | ||
55 | acpi_tb_cleanup_table_header(struct acpi_table_header *out_header, | ||
56 | struct acpi_table_header *header); | ||
57 | |||
58 | static acpi_physical_address | 52 | static acpi_physical_address |
59 | acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size); | 53 | acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size); |
60 | 54 | ||
@@ -176,189 +170,6 @@ u8 acpi_tb_tables_loaded(void) | |||
176 | 170 | ||
177 | /******************************************************************************* | 171 | /******************************************************************************* |
178 | * | 172 | * |
179 | * FUNCTION: acpi_tb_fix_string | ||
180 | * | ||
181 | * PARAMETERS: string - String to be repaired | ||
182 | * length - Maximum length | ||
183 | * | ||
184 | * RETURN: None | ||
185 | * | ||
186 | * DESCRIPTION: Replace every non-printable or non-ascii byte in the string | ||
187 | * with a question mark '?'. | ||
188 | * | ||
189 | ******************************************************************************/ | ||
190 | |||
191 | static void acpi_tb_fix_string(char *string, acpi_size length) | ||
192 | { | ||
193 | |||
194 | while (length && *string) { | ||
195 | if (!ACPI_IS_PRINT(*string)) { | ||
196 | *string = '?'; | ||
197 | } | ||
198 | string++; | ||
199 | length--; | ||
200 | } | ||
201 | } | ||
202 | |||
203 | /******************************************************************************* | ||
204 | * | ||
205 | * FUNCTION: acpi_tb_cleanup_table_header | ||
206 | * | ||
207 | * PARAMETERS: out_header - Where the cleaned header is returned | ||
208 | * header - Input ACPI table header | ||
209 | * | ||
210 | * RETURN: Returns the cleaned header in out_header | ||
211 | * | ||
212 | * DESCRIPTION: Copy the table header and ensure that all "string" fields in | ||
213 | * the header consist of printable characters. | ||
214 | * | ||
215 | ******************************************************************************/ | ||
216 | |||
217 | static void | ||
218 | acpi_tb_cleanup_table_header(struct acpi_table_header *out_header, | ||
219 | struct acpi_table_header *header) | ||
220 | { | ||
221 | |||
222 | ACPI_MEMCPY(out_header, header, sizeof(struct acpi_table_header)); | ||
223 | |||
224 | acpi_tb_fix_string(out_header->signature, ACPI_NAME_SIZE); | ||
225 | acpi_tb_fix_string(out_header->oem_id, ACPI_OEM_ID_SIZE); | ||
226 | acpi_tb_fix_string(out_header->oem_table_id, ACPI_OEM_TABLE_ID_SIZE); | ||
227 | acpi_tb_fix_string(out_header->asl_compiler_id, ACPI_NAME_SIZE); | ||
228 | } | ||
229 | |||
230 | /******************************************************************************* | ||
231 | * | ||
232 | * FUNCTION: acpi_tb_print_table_header | ||
233 | * | ||
234 | * PARAMETERS: address - Table physical address | ||
235 | * header - Table header | ||
236 | * | ||
237 | * RETURN: None | ||
238 | * | ||
239 | * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP. | ||
240 | * | ||
241 | ******************************************************************************/ | ||
242 | |||
243 | void | ||
244 | acpi_tb_print_table_header(acpi_physical_address address, | ||
245 | struct acpi_table_header *header) | ||
246 | { | ||
247 | struct acpi_table_header local_header; | ||
248 | |||
249 | /* | ||
250 | * The reason that the Address is cast to a void pointer is so that we | ||
251 | * can use %p which will work properly on both 32-bit and 64-bit hosts. | ||
252 | */ | ||
253 | if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) { | ||
254 | |||
255 | /* FACS only has signature and length fields */ | ||
256 | |||
257 | ACPI_INFO((AE_INFO, "%4.4s %p %05X", | ||
258 | header->signature, ACPI_CAST_PTR(void, address), | ||
259 | header->length)); | ||
260 | } else if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_RSDP)) { | ||
261 | |||
262 | /* RSDP has no common fields */ | ||
263 | |||
264 | ACPI_MEMCPY(local_header.oem_id, | ||
265 | ACPI_CAST_PTR(struct acpi_table_rsdp, | ||
266 | header)->oem_id, ACPI_OEM_ID_SIZE); | ||
267 | acpi_tb_fix_string(local_header.oem_id, ACPI_OEM_ID_SIZE); | ||
268 | |||
269 | ACPI_INFO((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)", | ||
270 | ACPI_CAST_PTR (void, address), | ||
271 | (ACPI_CAST_PTR(struct acpi_table_rsdp, header)-> | ||
272 | revision > | ||
273 | 0) ? ACPI_CAST_PTR(struct acpi_table_rsdp, | ||
274 | header)->length : 20, | ||
275 | ACPI_CAST_PTR(struct acpi_table_rsdp, | ||
276 | header)->revision, | ||
277 | local_header.oem_id)); | ||
278 | } else { | ||
279 | /* Standard ACPI table with full common header */ | ||
280 | |||
281 | acpi_tb_cleanup_table_header(&local_header, header); | ||
282 | |||
283 | ACPI_INFO((AE_INFO, | ||
284 | "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)", | ||
285 | local_header.signature, ACPI_CAST_PTR(void, address), | ||
286 | local_header.length, local_header.revision, | ||
287 | local_header.oem_id, local_header.oem_table_id, | ||
288 | local_header.oem_revision, | ||
289 | local_header.asl_compiler_id, | ||
290 | local_header.asl_compiler_revision)); | ||
291 | |||
292 | } | ||
293 | } | ||
294 | |||
295 | /******************************************************************************* | ||
296 | * | ||
297 | * FUNCTION: acpi_tb_validate_checksum | ||
298 | * | ||
299 | * PARAMETERS: table - ACPI table to verify | ||
300 | * length - Length of entire table | ||
301 | * | ||
302 | * RETURN: Status | ||
303 | * | ||
304 | * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns | ||
305 | * exception on bad checksum. | ||
306 | * | ||
307 | ******************************************************************************/ | ||
308 | |||
309 | acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length) | ||
310 | { | ||
311 | u8 checksum; | ||
312 | |||
313 | /* Compute the checksum on the table */ | ||
314 | |||
315 | checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), length); | ||
316 | |||
317 | /* Checksum ok? (should be zero) */ | ||
318 | |||
319 | if (checksum) { | ||
320 | ACPI_BIOS_WARNING((AE_INFO, | ||
321 | "Incorrect checksum in table [%4.4s] - 0x%2.2X, " | ||
322 | "should be 0x%2.2X", | ||
323 | table->signature, table->checksum, | ||
324 | (u8)(table->checksum - checksum))); | ||
325 | |||
326 | #if (ACPI_CHECKSUM_ABORT) | ||
327 | |||
328 | return (AE_BAD_CHECKSUM); | ||
329 | #endif | ||
330 | } | ||
331 | |||
332 | return (AE_OK); | ||
333 | } | ||
334 | |||
335 | /******************************************************************************* | ||
336 | * | ||
337 | * FUNCTION: acpi_tb_checksum | ||
338 | * | ||
339 | * PARAMETERS: buffer - Pointer to memory region to be checked | ||
340 | * length - Length of this memory region | ||
341 | * | ||
342 | * RETURN: Checksum (u8) | ||
343 | * | ||
344 | * DESCRIPTION: Calculates circular checksum of memory region. | ||
345 | * | ||
346 | ******************************************************************************/ | ||
347 | |||
348 | u8 acpi_tb_checksum(u8 *buffer, u32 length) | ||
349 | { | ||
350 | u8 sum = 0; | ||
351 | u8 *end = buffer + length; | ||
352 | |||
353 | while (buffer < end) { | ||
354 | sum = (u8) (sum + *(buffer++)); | ||
355 | } | ||
356 | |||
357 | return (sum); | ||
358 | } | ||
359 | |||
360 | /******************************************************************************* | ||
361 | * | ||
362 | * FUNCTION: acpi_tb_check_dsdt_header | 173 | * FUNCTION: acpi_tb_check_dsdt_header |
363 | * | 174 | * |
364 | * PARAMETERS: None | 175 | * PARAMETERS: None |
diff --git a/drivers/acpi/acpica/tbxfload.c b/drivers/acpi/acpica/tbxfload.c index 67e046ec8f0a..0ba9e328d5d7 100644 --- a/drivers/acpi/acpica/tbxfload.c +++ b/drivers/acpi/acpica/tbxfload.c | |||
@@ -53,8 +53,6 @@ ACPI_MODULE_NAME("tbxfload") | |||
53 | /* Local prototypes */ | 53 | /* Local prototypes */ |
54 | static acpi_status acpi_tb_load_namespace(void); | 54 | static acpi_status acpi_tb_load_namespace(void); |
55 | 55 | ||
56 | static int no_auto_ssdt; | ||
57 | |||
58 | /******************************************************************************* | 56 | /******************************************************************************* |
59 | * | 57 | * |
60 | * FUNCTION: acpi_load_tables | 58 | * FUNCTION: acpi_load_tables |
@@ -180,8 +178,16 @@ static acpi_status acpi_tb_load_namespace(void) | |||
180 | continue; | 178 | continue; |
181 | } | 179 | } |
182 | 180 | ||
183 | if (no_auto_ssdt) { | 181 | /* |
184 | printk(KERN_WARNING "ACPI: SSDT ignored due to \"acpi_no_auto_ssdt\"\n"); | 182 | * Optionally do not load any SSDTs from the RSDT/XSDT. This can |
183 | * be useful for debugging ACPI problems on some machines. | ||
184 | */ | ||
185 | if (acpi_gbl_disable_ssdt_table_load) { | ||
186 | ACPI_INFO((AE_INFO, "Ignoring %4.4s at %p", | ||
187 | acpi_gbl_root_table_list.tables[i].signature. | ||
188 | ascii, ACPI_CAST_PTR(void, | ||
189 | acpi_gbl_root_table_list. | ||
190 | tables[i].address))); | ||
185 | continue; | 191 | continue; |
186 | } | 192 | } |
187 | 193 | ||
@@ -376,14 +382,3 @@ acpi_status acpi_unload_parent_table(acpi_handle object) | |||
376 | } | 382 | } |
377 | 383 | ||
378 | ACPI_EXPORT_SYMBOL(acpi_unload_parent_table) | 384 | ACPI_EXPORT_SYMBOL(acpi_unload_parent_table) |
379 | |||
380 | static int __init acpi_no_auto_ssdt_setup(char *s) { | ||
381 | |||
382 | printk(KERN_NOTICE "ACPI: SSDT auto-load disabled\n"); | ||
383 | |||
384 | no_auto_ssdt = 1; | ||
385 | |||
386 | return 1; | ||
387 | } | ||
388 | |||
389 | __setup("acpi_no_auto_ssdt", acpi_no_auto_ssdt_setup); | ||
diff --git a/drivers/acpi/acpica/utbuffer.c b/drivers/acpi/acpica/utbuffer.c new file mode 100644 index 000000000000..11fde93be120 --- /dev/null +++ b/drivers/acpi/acpica/utbuffer.c | |||
@@ -0,0 +1,201 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: utbuffer - Buffer dump routines | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2013, Intel Corp. | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions, and the following disclaimer, | ||
16 | * without modification. | ||
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
18 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
19 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
20 | * including a substantially similar Disclaimer requirement for further | ||
21 | * binary redistribution. | ||
22 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
23 | * of any contributors may be used to endorse or promote products derived | ||
24 | * from this software without specific prior written permission. | ||
25 | * | ||
26 | * Alternatively, this software may be distributed under the terms of the | ||
27 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
28 | * Software Foundation. | ||
29 | * | ||
30 | * NO WARRANTY | ||
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
41 | * POSSIBILITY OF SUCH DAMAGES. | ||
42 | */ | ||
43 | |||
44 | #include <acpi/acpi.h> | ||
45 | #include "accommon.h" | ||
46 | |||
47 | #define _COMPONENT ACPI_UTILITIES | ||
48 | ACPI_MODULE_NAME("utbuffer") | ||
49 | |||
50 | /******************************************************************************* | ||
51 | * | ||
52 | * FUNCTION: acpi_ut_dump_buffer | ||
53 | * | ||
54 | * PARAMETERS: buffer - Buffer to dump | ||
55 | * count - Amount to dump, in bytes | ||
56 | * display - BYTE, WORD, DWORD, or QWORD display: | ||
57 | * DB_BYTE_DISPLAY | ||
58 | * DB_WORD_DISPLAY | ||
59 | * DB_DWORD_DISPLAY | ||
60 | * DB_QWORD_DISPLAY | ||
61 | * base_offset - Beginning buffer offset (display only) | ||
62 | * | ||
63 | * RETURN: None | ||
64 | * | ||
65 | * DESCRIPTION: Generic dump buffer in both hex and ascii. | ||
66 | * | ||
67 | ******************************************************************************/ | ||
68 | void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 base_offset) | ||
69 | { | ||
70 | u32 i = 0; | ||
71 | u32 j; | ||
72 | u32 temp32; | ||
73 | u8 buf_char; | ||
74 | |||
75 | if (!buffer) { | ||
76 | acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n"); | ||
77 | return; | ||
78 | } | ||
79 | |||
80 | if ((count < 4) || (count & 0x01)) { | ||
81 | display = DB_BYTE_DISPLAY; | ||
82 | } | ||
83 | |||
84 | /* Nasty little dump buffer routine! */ | ||
85 | |||
86 | while (i < count) { | ||
87 | |||
88 | /* Print current offset */ | ||
89 | |||
90 | acpi_os_printf("%6.4X: ", (base_offset + i)); | ||
91 | |||
92 | /* Print 16 hex chars */ | ||
93 | |||
94 | for (j = 0; j < 16;) { | ||
95 | if (i + j >= count) { | ||
96 | |||
97 | /* Dump fill spaces */ | ||
98 | |||
99 | acpi_os_printf("%*s", ((display * 2) + 1), " "); | ||
100 | j += display; | ||
101 | continue; | ||
102 | } | ||
103 | |||
104 | switch (display) { | ||
105 | case DB_BYTE_DISPLAY: | ||
106 | default: /* Default is BYTE display */ | ||
107 | |||
108 | acpi_os_printf("%02X ", | ||
109 | buffer[(acpi_size) i + j]); | ||
110 | break; | ||
111 | |||
112 | case DB_WORD_DISPLAY: | ||
113 | |||
114 | ACPI_MOVE_16_TO_32(&temp32, | ||
115 | &buffer[(acpi_size) i + j]); | ||
116 | acpi_os_printf("%04X ", temp32); | ||
117 | break; | ||
118 | |||
119 | case DB_DWORD_DISPLAY: | ||
120 | |||
121 | ACPI_MOVE_32_TO_32(&temp32, | ||
122 | &buffer[(acpi_size) i + j]); | ||
123 | acpi_os_printf("%08X ", temp32); | ||
124 | break; | ||
125 | |||
126 | case DB_QWORD_DISPLAY: | ||
127 | |||
128 | ACPI_MOVE_32_TO_32(&temp32, | ||
129 | &buffer[(acpi_size) i + j]); | ||
130 | acpi_os_printf("%08X", temp32); | ||
131 | |||
132 | ACPI_MOVE_32_TO_32(&temp32, | ||
133 | &buffer[(acpi_size) i + j + | ||
134 | 4]); | ||
135 | acpi_os_printf("%08X ", temp32); | ||
136 | break; | ||
137 | } | ||
138 | |||
139 | j += display; | ||
140 | } | ||
141 | |||
142 | /* | ||
143 | * Print the ASCII equivalent characters but watch out for the bad | ||
144 | * unprintable ones (printable chars are 0x20 through 0x7E) | ||
145 | */ | ||
146 | acpi_os_printf(" "); | ||
147 | for (j = 0; j < 16; j++) { | ||
148 | if (i + j >= count) { | ||
149 | acpi_os_printf("\n"); | ||
150 | return; | ||
151 | } | ||
152 | |||
153 | buf_char = buffer[(acpi_size) i + j]; | ||
154 | if (ACPI_IS_PRINT(buf_char)) { | ||
155 | acpi_os_printf("%c", buf_char); | ||
156 | } else { | ||
157 | acpi_os_printf("."); | ||
158 | } | ||
159 | } | ||
160 | |||
161 | /* Done with that line. */ | ||
162 | |||
163 | acpi_os_printf("\n"); | ||
164 | i += 16; | ||
165 | } | ||
166 | |||
167 | return; | ||
168 | } | ||
169 | |||
170 | /******************************************************************************* | ||
171 | * | ||
172 | * FUNCTION: acpi_ut_debug_dump_buffer | ||
173 | * | ||
174 | * PARAMETERS: buffer - Buffer to dump | ||
175 | * count - Amount to dump, in bytes | ||
176 | * display - BYTE, WORD, DWORD, or QWORD display: | ||
177 | * DB_BYTE_DISPLAY | ||
178 | * DB_WORD_DISPLAY | ||
179 | * DB_DWORD_DISPLAY | ||
180 | * DB_QWORD_DISPLAY | ||
181 | * component_ID - Caller's component ID | ||
182 | * | ||
183 | * RETURN: None | ||
184 | * | ||
185 | * DESCRIPTION: Generic dump buffer in both hex and ascii. | ||
186 | * | ||
187 | ******************************************************************************/ | ||
188 | |||
189 | void | ||
190 | acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id) | ||
191 | { | ||
192 | |||
193 | /* Only dump the buffer if tracing is enabled */ | ||
194 | |||
195 | if (!((ACPI_LV_TABLES & acpi_dbg_level) && | ||
196 | (component_id & acpi_dbg_layer))) { | ||
197 | return; | ||
198 | } | ||
199 | |||
200 | acpi_ut_dump_buffer(buffer, count, display, 0); | ||
201 | } | ||
diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c index e4c9291fc0a3..1731c27c36a6 100644 --- a/drivers/acpi/acpica/utcopy.c +++ b/drivers/acpi/acpica/utcopy.c | |||
@@ -178,7 +178,6 @@ acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object, | |||
178 | 178 | ||
179 | switch (internal_object->reference.class) { | 179 | switch (internal_object->reference.class) { |
180 | case ACPI_REFCLASS_NAME: | 180 | case ACPI_REFCLASS_NAME: |
181 | |||
182 | /* | 181 | /* |
183 | * For namepath, return the object handle ("reference") | 182 | * For namepath, return the object handle ("reference") |
184 | * We are referring to the namespace node | 183 | * We are referring to the namespace node |
@@ -264,7 +263,6 @@ acpi_ut_copy_ielement_to_eelement(u8 object_type, | |||
264 | 263 | ||
265 | switch (object_type) { | 264 | switch (object_type) { |
266 | case ACPI_COPY_TYPE_SIMPLE: | 265 | case ACPI_COPY_TYPE_SIMPLE: |
267 | |||
268 | /* | 266 | /* |
269 | * This is a simple or null object | 267 | * This is a simple or null object |
270 | */ | 268 | */ |
@@ -278,7 +276,6 @@ acpi_ut_copy_ielement_to_eelement(u8 object_type, | |||
278 | break; | 276 | break; |
279 | 277 | ||
280 | case ACPI_COPY_TYPE_PACKAGE: | 278 | case ACPI_COPY_TYPE_PACKAGE: |
281 | |||
282 | /* | 279 | /* |
283 | * Build the package object | 280 | * Build the package object |
284 | */ | 281 | */ |
@@ -304,6 +301,7 @@ acpi_ut_copy_ielement_to_eelement(u8 object_type, | |||
304 | break; | 301 | break; |
305 | 302 | ||
306 | default: | 303 | default: |
304 | |||
307 | return (AE_BAD_PARAMETER); | 305 | return (AE_BAD_PARAMETER); |
308 | } | 306 | } |
309 | 307 | ||
@@ -481,6 +479,7 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object, | |||
481 | return_ACPI_STATUS(AE_OK); | 479 | return_ACPI_STATUS(AE_OK); |
482 | 480 | ||
483 | default: | 481 | default: |
482 | |||
484 | /* All other types are not supported */ | 483 | /* All other types are not supported */ |
485 | 484 | ||
486 | ACPI_ERROR((AE_INFO, | 485 | ACPI_ERROR((AE_INFO, |
@@ -544,7 +543,9 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object, | |||
544 | break; | 543 | break; |
545 | 544 | ||
546 | default: | 545 | default: |
546 | |||
547 | /* Other types can't get here */ | 547 | /* Other types can't get here */ |
548 | |||
548 | break; | 549 | break; |
549 | } | 550 | } |
550 | 551 | ||
@@ -800,7 +801,9 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc, | |||
800 | break; | 801 | break; |
801 | 802 | ||
802 | default: | 803 | default: |
804 | |||
803 | /* Nothing to do for other simple objects */ | 805 | /* Nothing to do for other simple objects */ |
806 | |||
804 | break; | 807 | break; |
805 | } | 808 | } |
806 | 809 | ||
@@ -868,7 +871,6 @@ acpi_ut_copy_ielement_to_ielement(u8 object_type, | |||
868 | break; | 871 | break; |
869 | 872 | ||
870 | case ACPI_COPY_TYPE_PACKAGE: | 873 | case ACPI_COPY_TYPE_PACKAGE: |
871 | |||
872 | /* | 874 | /* |
873 | * This object is a package - go down another nesting level | 875 | * This object is a package - go down another nesting level |
874 | * Create and build the package object | 876 | * Create and build the package object |
@@ -891,6 +893,7 @@ acpi_ut_copy_ielement_to_ielement(u8 object_type, | |||
891 | break; | 893 | break; |
892 | 894 | ||
893 | default: | 895 | default: |
896 | |||
894 | return (AE_BAD_PARAMETER); | 897 | return (AE_BAD_PARAMETER); |
895 | } | 898 | } |
896 | 899 | ||
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c index c57d9cc07ba9..5796e11a0671 100644 --- a/drivers/acpi/acpica/utdebug.c +++ b/drivers/acpi/acpica/utdebug.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | * |
3 | * Module Name: utdebug - Debug print routines | 3 | * Module Name: utdebug - Debug print/trace routines |
4 | * | 4 | * |
5 | *****************************************************************************/ | 5 | *****************************************************************************/ |
6 | 6 | ||
@@ -543,149 +543,3 @@ acpi_ut_ptr_exit(u32 line_number, | |||
543 | } | 543 | } |
544 | 544 | ||
545 | #endif | 545 | #endif |
546 | |||
547 | /******************************************************************************* | ||
548 | * | ||
549 | * FUNCTION: acpi_ut_dump_buffer | ||
550 | * | ||
551 | * PARAMETERS: buffer - Buffer to dump | ||
552 | * count - Amount to dump, in bytes | ||
553 | * display - BYTE, WORD, DWORD, or QWORD display | ||
554 | * offset - Beginning buffer offset (display only) | ||
555 | * | ||
556 | * RETURN: None | ||
557 | * | ||
558 | * DESCRIPTION: Generic dump buffer in both hex and ascii. | ||
559 | * | ||
560 | ******************************************************************************/ | ||
561 | |||
562 | void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 base_offset) | ||
563 | { | ||
564 | u32 i = 0; | ||
565 | u32 j; | ||
566 | u32 temp32; | ||
567 | u8 buf_char; | ||
568 | |||
569 | if (!buffer) { | ||
570 | acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n"); | ||
571 | return; | ||
572 | } | ||
573 | |||
574 | if ((count < 4) || (count & 0x01)) { | ||
575 | display = DB_BYTE_DISPLAY; | ||
576 | } | ||
577 | |||
578 | /* Nasty little dump buffer routine! */ | ||
579 | |||
580 | while (i < count) { | ||
581 | |||
582 | /* Print current offset */ | ||
583 | |||
584 | acpi_os_printf("%6.4X: ", (base_offset + i)); | ||
585 | |||
586 | /* Print 16 hex chars */ | ||
587 | |||
588 | for (j = 0; j < 16;) { | ||
589 | if (i + j >= count) { | ||
590 | |||
591 | /* Dump fill spaces */ | ||
592 | |||
593 | acpi_os_printf("%*s", ((display * 2) + 1), " "); | ||
594 | j += display; | ||
595 | continue; | ||
596 | } | ||
597 | |||
598 | switch (display) { | ||
599 | case DB_BYTE_DISPLAY: | ||
600 | default: /* Default is BYTE display */ | ||
601 | |||
602 | acpi_os_printf("%02X ", | ||
603 | buffer[(acpi_size) i + j]); | ||
604 | break; | ||
605 | |||
606 | case DB_WORD_DISPLAY: | ||
607 | |||
608 | ACPI_MOVE_16_TO_32(&temp32, | ||
609 | &buffer[(acpi_size) i + j]); | ||
610 | acpi_os_printf("%04X ", temp32); | ||
611 | break; | ||
612 | |||
613 | case DB_DWORD_DISPLAY: | ||
614 | |||
615 | ACPI_MOVE_32_TO_32(&temp32, | ||
616 | &buffer[(acpi_size) i + j]); | ||
617 | acpi_os_printf("%08X ", temp32); | ||
618 | break; | ||
619 | |||
620 | case DB_QWORD_DISPLAY: | ||
621 | |||
622 | ACPI_MOVE_32_TO_32(&temp32, | ||
623 | &buffer[(acpi_size) i + j]); | ||
624 | acpi_os_printf("%08X", temp32); | ||
625 | |||
626 | ACPI_MOVE_32_TO_32(&temp32, | ||
627 | &buffer[(acpi_size) i + j + | ||
628 | 4]); | ||
629 | acpi_os_printf("%08X ", temp32); | ||
630 | break; | ||
631 | } | ||
632 | |||
633 | j += display; | ||
634 | } | ||
635 | |||
636 | /* | ||
637 | * Print the ASCII equivalent characters but watch out for the bad | ||
638 | * unprintable ones (printable chars are 0x20 through 0x7E) | ||
639 | */ | ||
640 | acpi_os_printf(" "); | ||
641 | for (j = 0; j < 16; j++) { | ||
642 | if (i + j >= count) { | ||
643 | acpi_os_printf("\n"); | ||
644 | return; | ||
645 | } | ||
646 | |||
647 | buf_char = buffer[(acpi_size) i + j]; | ||
648 | if (ACPI_IS_PRINT(buf_char)) { | ||
649 | acpi_os_printf("%c", buf_char); | ||
650 | } else { | ||
651 | acpi_os_printf("."); | ||
652 | } | ||
653 | } | ||
654 | |||
655 | /* Done with that line. */ | ||
656 | |||
657 | acpi_os_printf("\n"); | ||
658 | i += 16; | ||
659 | } | ||
660 | |||
661 | return; | ||
662 | } | ||
663 | |||
664 | /******************************************************************************* | ||
665 | * | ||
666 | * FUNCTION: acpi_ut_debug_dump_buffer | ||
667 | * | ||
668 | * PARAMETERS: buffer - Buffer to dump | ||
669 | * count - Amount to dump, in bytes | ||
670 | * display - BYTE, WORD, DWORD, or QWORD display | ||
671 | * component_ID - Caller's component ID | ||
672 | * | ||
673 | * RETURN: None | ||
674 | * | ||
675 | * DESCRIPTION: Generic dump buffer in both hex and ascii. | ||
676 | * | ||
677 | ******************************************************************************/ | ||
678 | |||
679 | void | ||
680 | acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id) | ||
681 | { | ||
682 | |||
683 | /* Only dump the buffer if tracing is enabled */ | ||
684 | |||
685 | if (!((ACPI_LV_TABLES & acpi_dbg_level) && | ||
686 | (component_id & acpi_dbg_layer))) { | ||
687 | return; | ||
688 | } | ||
689 | |||
690 | acpi_ut_dump_buffer(buffer, count, display, 0); | ||
691 | } | ||
diff --git a/drivers/acpi/acpica/utdelete.c b/drivers/acpi/acpica/utdelete.c index 29b930250b6f..d6b33f29d327 100644 --- a/drivers/acpi/acpica/utdelete.c +++ b/drivers/acpi/acpica/utdelete.c | |||
@@ -303,6 +303,7 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object) | |||
303 | break; | 303 | break; |
304 | 304 | ||
305 | default: | 305 | default: |
306 | |||
306 | break; | 307 | break; |
307 | } | 308 | } |
308 | 309 | ||
@@ -508,7 +509,6 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) | |||
508 | case ACPI_TYPE_PROCESSOR: | 509 | case ACPI_TYPE_PROCESSOR: |
509 | case ACPI_TYPE_POWER: | 510 | case ACPI_TYPE_POWER: |
510 | case ACPI_TYPE_THERMAL: | 511 | case ACPI_TYPE_THERMAL: |
511 | |||
512 | /* | 512 | /* |
513 | * Update the notify objects for these types (if present) | 513 | * Update the notify objects for these types (if present) |
514 | * Two lists, system and device notify handlers. | 514 | * Two lists, system and device notify handlers. |
@@ -623,6 +623,7 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action) | |||
623 | 623 | ||
624 | case ACPI_TYPE_REGION: | 624 | case ACPI_TYPE_REGION: |
625 | default: | 625 | default: |
626 | |||
626 | break; /* No subobjects for all other types */ | 627 | break; /* No subobjects for all other types */ |
627 | } | 628 | } |
628 | 629 | ||
diff --git a/drivers/acpi/acpica/uterror.c b/drivers/acpi/acpica/uterror.c new file mode 100644 index 000000000000..154fdcaa5830 --- /dev/null +++ b/drivers/acpi/acpica/uterror.c | |||
@@ -0,0 +1,289 @@ | |||
1 | /******************************************************************************* | ||
2 | * | ||
3 | * Module Name: uterror - Various internal error/warning output functions | ||
4 | * | ||
5 | ******************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2013, Intel Corp. | ||
9 | * All rights reserved. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions, and the following disclaimer, | ||
16 | * without modification. | ||
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
18 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
19 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
20 | * including a substantially similar Disclaimer requirement for further | ||
21 | * binary redistribution. | ||
22 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
23 | * of any contributors may be used to endorse or promote products derived | ||
24 | * from this software without specific prior written permission. | ||
25 | * | ||
26 | * Alternatively, this software may be distributed under the terms of the | ||
27 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
28 | * Software Foundation. | ||
29 | * | ||
30 | * NO WARRANTY | ||
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
41 | * POSSIBILITY OF SUCH DAMAGES. | ||
42 | */ | ||
43 | |||
44 | #include <acpi/acpi.h> | ||
45 | #include "accommon.h" | ||
46 | #include "acnamesp.h" | ||
47 | |||
48 | #define _COMPONENT ACPI_UTILITIES | ||
49 | ACPI_MODULE_NAME("uterror") | ||
50 | |||
51 | /* | ||
52 | * This module contains internal error functions that may | ||
53 | * be configured out. | ||
54 | */ | ||
55 | #if !defined (ACPI_NO_ERROR_MESSAGES) | ||
56 | /******************************************************************************* | ||
57 | * | ||
58 | * FUNCTION: acpi_ut_predefined_warning | ||
59 | * | ||
60 | * PARAMETERS: module_name - Caller's module name (for error output) | ||
61 | * line_number - Caller's line number (for error output) | ||
62 | * pathname - Full pathname to the node | ||
63 | * node_flags - From Namespace node for the method/object | ||
64 | * format - Printf format string + additional args | ||
65 | * | ||
66 | * RETURN: None | ||
67 | * | ||
68 | * DESCRIPTION: Warnings for the predefined validation module. Messages are | ||
69 | * only emitted the first time a problem with a particular | ||
70 | * method/object is detected. This prevents a flood of error | ||
71 | * messages for methods that are repeatedly evaluated. | ||
72 | * | ||
73 | ******************************************************************************/ | ||
74 | void ACPI_INTERNAL_VAR_XFACE | ||
75 | acpi_ut_predefined_warning(const char *module_name, | ||
76 | u32 line_number, | ||
77 | char *pathname, | ||
78 | u8 node_flags, const char *format, ...) | ||
79 | { | ||
80 | va_list arg_list; | ||
81 | |||
82 | /* | ||
83 | * Warning messages for this method/object will be disabled after the | ||
84 | * first time a validation fails or an object is successfully repaired. | ||
85 | */ | ||
86 | if (node_flags & ANOBJ_EVALUATED) { | ||
87 | return; | ||
88 | } | ||
89 | |||
90 | acpi_os_printf(ACPI_MSG_WARNING "%s: ", pathname); | ||
91 | |||
92 | va_start(arg_list, format); | ||
93 | acpi_os_vprintf(format, arg_list); | ||
94 | ACPI_MSG_SUFFIX; | ||
95 | va_end(arg_list); | ||
96 | } | ||
97 | |||
98 | /******************************************************************************* | ||
99 | * | ||
100 | * FUNCTION: acpi_ut_predefined_info | ||
101 | * | ||
102 | * PARAMETERS: module_name - Caller's module name (for error output) | ||
103 | * line_number - Caller's line number (for error output) | ||
104 | * pathname - Full pathname to the node | ||
105 | * node_flags - From Namespace node for the method/object | ||
106 | * format - Printf format string + additional args | ||
107 | * | ||
108 | * RETURN: None | ||
109 | * | ||
110 | * DESCRIPTION: Info messages for the predefined validation module. Messages | ||
111 | * are only emitted the first time a problem with a particular | ||
112 | * method/object is detected. This prevents a flood of | ||
113 | * messages for methods that are repeatedly evaluated. | ||
114 | * | ||
115 | ******************************************************************************/ | ||
116 | |||
117 | void ACPI_INTERNAL_VAR_XFACE | ||
118 | acpi_ut_predefined_info(const char *module_name, | ||
119 | u32 line_number, | ||
120 | char *pathname, u8 node_flags, const char *format, ...) | ||
121 | { | ||
122 | va_list arg_list; | ||
123 | |||
124 | /* | ||
125 | * Warning messages for this method/object will be disabled after the | ||
126 | * first time a validation fails or an object is successfully repaired. | ||
127 | */ | ||
128 | if (node_flags & ANOBJ_EVALUATED) { | ||
129 | return; | ||
130 | } | ||
131 | |||
132 | acpi_os_printf(ACPI_MSG_INFO "%s: ", pathname); | ||
133 | |||
134 | va_start(arg_list, format); | ||
135 | acpi_os_vprintf(format, arg_list); | ||
136 | ACPI_MSG_SUFFIX; | ||
137 | va_end(arg_list); | ||
138 | } | ||
139 | |||
140 | /******************************************************************************* | ||
141 | * | ||
142 | * FUNCTION: acpi_ut_predefined_bios_error | ||
143 | * | ||
144 | * PARAMETERS: module_name - Caller's module name (for error output) | ||
145 | * line_number - Caller's line number (for error output) | ||
146 | * pathname - Full pathname to the node | ||
147 | * node_flags - From Namespace node for the method/object | ||
148 | * format - Printf format string + additional args | ||
149 | * | ||
150 | * RETURN: None | ||
151 | * | ||
152 | * DESCRIPTION: BIOS error message for predefined names. Messages | ||
153 | * are only emitted the first time a problem with a particular | ||
154 | * method/object is detected. This prevents a flood of | ||
155 | * messages for methods that are repeatedly evaluated. | ||
156 | * | ||
157 | ******************************************************************************/ | ||
158 | |||
159 | void ACPI_INTERNAL_VAR_XFACE | ||
160 | acpi_ut_predefined_bios_error(const char *module_name, | ||
161 | u32 line_number, | ||
162 | char *pathname, | ||
163 | u8 node_flags, const char *format, ...) | ||
164 | { | ||
165 | va_list arg_list; | ||
166 | |||
167 | /* | ||
168 | * Warning messages for this method/object will be disabled after the | ||
169 | * first time a validation fails or an object is successfully repaired. | ||
170 | */ | ||
171 | if (node_flags & ANOBJ_EVALUATED) { | ||
172 | return; | ||
173 | } | ||
174 | |||
175 | acpi_os_printf(ACPI_MSG_BIOS_ERROR "%s: ", pathname); | ||
176 | |||
177 | va_start(arg_list, format); | ||
178 | acpi_os_vprintf(format, arg_list); | ||
179 | ACPI_MSG_SUFFIX; | ||
180 | va_end(arg_list); | ||
181 | } | ||
182 | |||
183 | /******************************************************************************* | ||
184 | * | ||
185 | * FUNCTION: acpi_ut_namespace_error | ||
186 | * | ||
187 | * PARAMETERS: module_name - Caller's module name (for error output) | ||
188 | * line_number - Caller's line number (for error output) | ||
189 | * internal_name - Name or path of the namespace node | ||
190 | * lookup_status - Exception code from NS lookup | ||
191 | * | ||
192 | * RETURN: None | ||
193 | * | ||
194 | * DESCRIPTION: Print error message with the full pathname for the NS node. | ||
195 | * | ||
196 | ******************************************************************************/ | ||
197 | |||
198 | void | ||
199 | acpi_ut_namespace_error(const char *module_name, | ||
200 | u32 line_number, | ||
201 | const char *internal_name, acpi_status lookup_status) | ||
202 | { | ||
203 | acpi_status status; | ||
204 | u32 bad_name; | ||
205 | char *name = NULL; | ||
206 | |||
207 | ACPI_MSG_REDIRECT_BEGIN; | ||
208 | acpi_os_printf(ACPI_MSG_ERROR); | ||
209 | |||
210 | if (lookup_status == AE_BAD_CHARACTER) { | ||
211 | |||
212 | /* There is a non-ascii character in the name */ | ||
213 | |||
214 | ACPI_MOVE_32_TO_32(&bad_name, | ||
215 | ACPI_CAST_PTR(u32, internal_name)); | ||
216 | acpi_os_printf("[0x%.8X] (NON-ASCII)", bad_name); | ||
217 | } else { | ||
218 | /* Convert path to external format */ | ||
219 | |||
220 | status = acpi_ns_externalize_name(ACPI_UINT32_MAX, | ||
221 | internal_name, NULL, &name); | ||
222 | |||
223 | /* Print target name */ | ||
224 | |||
225 | if (ACPI_SUCCESS(status)) { | ||
226 | acpi_os_printf("[%s]", name); | ||
227 | } else { | ||
228 | acpi_os_printf("[COULD NOT EXTERNALIZE NAME]"); | ||
229 | } | ||
230 | |||
231 | if (name) { | ||
232 | ACPI_FREE(name); | ||
233 | } | ||
234 | } | ||
235 | |||
236 | acpi_os_printf(" Namespace lookup failure, %s", | ||
237 | acpi_format_exception(lookup_status)); | ||
238 | |||
239 | ACPI_MSG_SUFFIX; | ||
240 | ACPI_MSG_REDIRECT_END; | ||
241 | } | ||
242 | |||
243 | /******************************************************************************* | ||
244 | * | ||
245 | * FUNCTION: acpi_ut_method_error | ||
246 | * | ||
247 | * PARAMETERS: module_name - Caller's module name (for error output) | ||
248 | * line_number - Caller's line number (for error output) | ||
249 | * message - Error message to use on failure | ||
250 | * prefix_node - Prefix relative to the path | ||
251 | * path - Path to the node (optional) | ||
252 | * method_status - Execution status | ||
253 | * | ||
254 | * RETURN: None | ||
255 | * | ||
256 | * DESCRIPTION: Print error message with the full pathname for the method. | ||
257 | * | ||
258 | ******************************************************************************/ | ||
259 | |||
260 | void | ||
261 | acpi_ut_method_error(const char *module_name, | ||
262 | u32 line_number, | ||
263 | const char *message, | ||
264 | struct acpi_namespace_node *prefix_node, | ||
265 | const char *path, acpi_status method_status) | ||
266 | { | ||
267 | acpi_status status; | ||
268 | struct acpi_namespace_node *node = prefix_node; | ||
269 | |||
270 | ACPI_MSG_REDIRECT_BEGIN; | ||
271 | acpi_os_printf(ACPI_MSG_ERROR); | ||
272 | |||
273 | if (path) { | ||
274 | status = | ||
275 | acpi_ns_get_node(prefix_node, path, ACPI_NS_NO_UPSEARCH, | ||
276 | &node); | ||
277 | if (ACPI_FAILURE(status)) { | ||
278 | acpi_os_printf("[Could not get node by pathname]"); | ||
279 | } | ||
280 | } | ||
281 | |||
282 | acpi_ns_print_node_pathname(node, message); | ||
283 | acpi_os_printf(", %s", acpi_format_exception(method_status)); | ||
284 | |||
285 | ACPI_MSG_SUFFIX; | ||
286 | ACPI_MSG_REDIRECT_END; | ||
287 | } | ||
288 | |||
289 | #endif /* ACPI_NO_ERROR_MESSAGES */ | ||
diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c index c3f3a7e7bdc7..ee83adb97b1e 100644 --- a/drivers/acpi/acpica/uteval.c +++ b/drivers/acpi/acpica/uteval.c | |||
@@ -68,7 +68,7 @@ ACPI_MODULE_NAME("uteval") | |||
68 | ******************************************************************************/ | 68 | ******************************************************************************/ |
69 | 69 | ||
70 | acpi_status | 70 | acpi_status |
71 | acpi_ut_evaluate_object(struct acpi_namespace_node * prefix_node, | 71 | acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, |
72 | char *path, | 72 | char *path, |
73 | u32 expected_return_btypes, | 73 | u32 expected_return_btypes, |
74 | union acpi_operand_object **return_desc) | 74 | union acpi_operand_object **return_desc) |
@@ -87,7 +87,7 @@ acpi_ut_evaluate_object(struct acpi_namespace_node * prefix_node, | |||
87 | } | 87 | } |
88 | 88 | ||
89 | info->prefix_node = prefix_node; | 89 | info->prefix_node = prefix_node; |
90 | info->pathname = path; | 90 | info->relative_pathname = path; |
91 | 91 | ||
92 | /* Evaluate the object/method */ | 92 | /* Evaluate the object/method */ |
93 | 93 | ||
@@ -123,22 +123,27 @@ acpi_ut_evaluate_object(struct acpi_namespace_node * prefix_node, | |||
123 | 123 | ||
124 | switch ((info->return_object)->common.type) { | 124 | switch ((info->return_object)->common.type) { |
125 | case ACPI_TYPE_INTEGER: | 125 | case ACPI_TYPE_INTEGER: |
126 | |||
126 | return_btype = ACPI_BTYPE_INTEGER; | 127 | return_btype = ACPI_BTYPE_INTEGER; |
127 | break; | 128 | break; |
128 | 129 | ||
129 | case ACPI_TYPE_BUFFER: | 130 | case ACPI_TYPE_BUFFER: |
131 | |||
130 | return_btype = ACPI_BTYPE_BUFFER; | 132 | return_btype = ACPI_BTYPE_BUFFER; |
131 | break; | 133 | break; |
132 | 134 | ||
133 | case ACPI_TYPE_STRING: | 135 | case ACPI_TYPE_STRING: |
136 | |||
134 | return_btype = ACPI_BTYPE_STRING; | 137 | return_btype = ACPI_BTYPE_STRING; |
135 | break; | 138 | break; |
136 | 139 | ||
137 | case ACPI_TYPE_PACKAGE: | 140 | case ACPI_TYPE_PACKAGE: |
141 | |||
138 | return_btype = ACPI_BTYPE_PACKAGE; | 142 | return_btype = ACPI_BTYPE_PACKAGE; |
139 | break; | 143 | break; |
140 | 144 | ||
141 | default: | 145 | default: |
146 | |||
142 | return_btype = 0; | 147 | return_btype = 0; |
143 | break; | 148 | break; |
144 | } | 149 | } |
diff --git a/drivers/acpi/acpica/utexcep.c b/drivers/acpi/acpica/utexcep.c index b543a144941a..ff6d9e8aa842 100644 --- a/drivers/acpi/acpica/utexcep.c +++ b/drivers/acpi/acpica/utexcep.c | |||
@@ -146,6 +146,7 @@ const struct acpi_exception_info *acpi_ut_validate_exception(acpi_status status) | |||
146 | break; | 146 | break; |
147 | 147 | ||
148 | default: | 148 | default: |
149 | |||
149 | break; | 150 | break; |
150 | } | 151 | } |
151 | 152 | ||
diff --git a/drivers/acpi/acpica/utids.c b/drivers/acpi/acpica/utids.c index 43a170a74a61..fa69071db418 100644 --- a/drivers/acpi/acpica/utids.c +++ b/drivers/acpi/acpica/utids.c | |||
@@ -341,14 +341,17 @@ acpi_ut_execute_CID(struct acpi_namespace_node *device_node, | |||
341 | 341 | ||
342 | switch (cid_objects[i]->common.type) { | 342 | switch (cid_objects[i]->common.type) { |
343 | case ACPI_TYPE_INTEGER: | 343 | case ACPI_TYPE_INTEGER: |
344 | |||
344 | string_area_size += ACPI_EISAID_STRING_SIZE; | 345 | string_area_size += ACPI_EISAID_STRING_SIZE; |
345 | break; | 346 | break; |
346 | 347 | ||
347 | case ACPI_TYPE_STRING: | 348 | case ACPI_TYPE_STRING: |
349 | |||
348 | string_area_size += cid_objects[i]->string.length + 1; | 350 | string_area_size += cid_objects[i]->string.length + 1; |
349 | break; | 351 | break; |
350 | 352 | ||
351 | default: | 353 | default: |
354 | |||
352 | status = AE_TYPE; | 355 | status = AE_TYPE; |
353 | goto cleanup; | 356 | goto cleanup; |
354 | } | 357 | } |
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c index 785fdd07ae56..02f9101b65e4 100644 --- a/drivers/acpi/acpica/utmisc.c +++ b/drivers/acpi/acpica/utmisc.c | |||
@@ -382,10 +382,12 @@ acpi_ut_display_init_pathname(u8 type, | |||
382 | 382 | ||
383 | switch (type) { | 383 | switch (type) { |
384 | case ACPI_TYPE_METHOD: | 384 | case ACPI_TYPE_METHOD: |
385 | |||
385 | acpi_os_printf("Executing "); | 386 | acpi_os_printf("Executing "); |
386 | break; | 387 | break; |
387 | 388 | ||
388 | default: | 389 | default: |
390 | |||
389 | acpi_os_printf("Initializing "); | 391 | acpi_os_printf("Initializing "); |
390 | break; | 392 | break; |
391 | } | 393 | } |
diff --git a/drivers/acpi/acpica/utobject.c b/drivers/acpi/acpica/utobject.c index 1099f5c069f8..aa61f66ee861 100644 --- a/drivers/acpi/acpica/utobject.c +++ b/drivers/acpi/acpica/utobject.c | |||
@@ -129,6 +129,7 @@ union acpi_operand_object *acpi_ut_create_internal_object_dbg(const char | |||
129 | break; | 129 | break; |
130 | 130 | ||
131 | default: | 131 | default: |
132 | |||
132 | /* All others have no secondary object */ | 133 | /* All others have no secondary object */ |
133 | break; | 134 | break; |
134 | } | 135 | } |
@@ -353,6 +354,7 @@ u8 acpi_ut_valid_internal_object(void *object) | |||
353 | return (TRUE); | 354 | return (TRUE); |
354 | 355 | ||
355 | default: | 356 | default: |
357 | |||
356 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, | 358 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
357 | "%p is not not an ACPI operand obj [%s]\n", | 359 | "%p is not not an ACPI operand obj [%s]\n", |
358 | object, acpi_ut_get_descriptor_name(object))); | 360 | object, acpi_ut_get_descriptor_name(object))); |
@@ -509,7 +511,6 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, | |||
509 | 511 | ||
510 | switch (internal_object->reference.class) { | 512 | switch (internal_object->reference.class) { |
511 | case ACPI_REFCLASS_NAME: | 513 | case ACPI_REFCLASS_NAME: |
512 | |||
513 | /* | 514 | /* |
514 | * Get the actual length of the full pathname to this object. | 515 | * Get the actual length of the full pathname to this object. |
515 | * The reference will be converted to the pathname to the object | 516 | * The reference will be converted to the pathname to the object |
@@ -525,7 +526,6 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object, | |||
525 | break; | 526 | break; |
526 | 527 | ||
527 | default: | 528 | default: |
528 | |||
529 | /* | 529 | /* |
530 | * No other reference opcodes are supported. | 530 | * No other reference opcodes are supported. |
531 | * Notably, Locals and Args are not supported, but this may be | 531 | * Notably, Locals and Args are not supported, but this may be |
@@ -585,7 +585,6 @@ acpi_ut_get_element_length(u8 object_type, | |||
585 | 585 | ||
586 | switch (object_type) { | 586 | switch (object_type) { |
587 | case ACPI_COPY_TYPE_SIMPLE: | 587 | case ACPI_COPY_TYPE_SIMPLE: |
588 | |||
589 | /* | 588 | /* |
590 | * Simple object - just get the size (Null object/entry is handled | 589 | * Simple object - just get the size (Null object/entry is handled |
591 | * here also) and sum it into the running package length | 590 | * here also) and sum it into the running package length |
diff --git a/drivers/acpi/acpica/utpredef.c b/drivers/acpi/acpica/utpredef.c index 29459479148f..2b1ce4cd3207 100644 --- a/drivers/acpi/acpica/utpredef.c +++ b/drivers/acpi/acpica/utpredef.c | |||
@@ -147,6 +147,11 @@ void acpi_ut_get_expected_return_types(char *buffer, u32 expected_btypes) | |||
147 | u32 i; | 147 | u32 i; |
148 | u32 j; | 148 | u32 j; |
149 | 149 | ||
150 | if (!expected_btypes) { | ||
151 | ACPI_STRCPY(buffer, "NONE"); | ||
152 | return; | ||
153 | } | ||
154 | |||
150 | j = 1; | 155 | j = 1; |
151 | buffer[0] = 0; | 156 | buffer[0] = 0; |
152 | this_rtype = ACPI_RTYPE_INTEGER; | 157 | this_rtype = ACPI_RTYPE_INTEGER; |
@@ -328,9 +333,7 @@ static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types) | |||
328 | 333 | ||
329 | /* First field in the types list is the count of args to follow */ | 334 | /* First field in the types list is the count of args to follow */ |
330 | 335 | ||
331 | arg_count = (argument_types & METHOD_ARG_MASK); | 336 | arg_count = METHOD_GET_ARG_COUNT(argument_types); |
332 | argument_types >>= METHOD_ARG_BIT_WIDTH; | ||
333 | |||
334 | if (arg_count > METHOD_PREDEF_ARGS_MAX) { | 337 | if (arg_count > METHOD_PREDEF_ARGS_MAX) { |
335 | printf("**** Invalid argument count (%u) " | 338 | printf("**** Invalid argument count (%u) " |
336 | "in predefined info structure\n", arg_count); | 339 | "in predefined info structure\n", arg_count); |
@@ -340,7 +343,8 @@ static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types) | |||
340 | /* Get each argument from the list, convert to ascii, store to buffer */ | 343 | /* Get each argument from the list, convert to ascii, store to buffer */ |
341 | 344 | ||
342 | for (i = 0; i < arg_count; i++) { | 345 | for (i = 0; i < arg_count; i++) { |
343 | this_argument_type = (argument_types & METHOD_ARG_MASK); | 346 | this_argument_type = METHOD_GET_NEXT_TYPE(argument_types); |
347 | |||
344 | if (!this_argument_type | 348 | if (!this_argument_type |
345 | || (this_argument_type > METHOD_MAX_ARG_TYPE)) { | 349 | || (this_argument_type > METHOD_MAX_ARG_TYPE)) { |
346 | printf("**** Invalid argument type (%u) " | 350 | printf("**** Invalid argument type (%u) " |
@@ -351,10 +355,6 @@ static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types) | |||
351 | 355 | ||
352 | strcat(buffer, | 356 | strcat(buffer, |
353 | ut_external_type_names[this_argument_type] + sub_index); | 357 | ut_external_type_names[this_argument_type] + sub_index); |
354 | |||
355 | /* Shift to next argument type field */ | ||
356 | |||
357 | argument_types >>= METHOD_ARG_BIT_WIDTH; | ||
358 | sub_index = 0; | 358 | sub_index = 0; |
359 | } | 359 | } |
360 | 360 | ||
diff --git a/drivers/acpi/acpica/utstring.c b/drivers/acpi/acpica/utstring.c index b3e36a81aa4d..c53759b76a3f 100644 --- a/drivers/acpi/acpica/utstring.c +++ b/drivers/acpi/acpica/utstring.c | |||
@@ -186,10 +186,13 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) | |||
186 | switch (base) { | 186 | switch (base) { |
187 | case ACPI_ANY_BASE: | 187 | case ACPI_ANY_BASE: |
188 | case 16: | 188 | case 16: |
189 | |||
189 | break; | 190 | break; |
190 | 191 | ||
191 | default: | 192 | default: |
193 | |||
192 | /* Invalid Base */ | 194 | /* Invalid Base */ |
195 | |||
193 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 196 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
194 | } | 197 | } |
195 | 198 | ||
@@ -355,36 +358,44 @@ void acpi_ut_print_string(char *string, u8 max_length) | |||
355 | 358 | ||
356 | switch (string[i]) { | 359 | switch (string[i]) { |
357 | case 0x07: | 360 | case 0x07: |
361 | |||
358 | acpi_os_printf("\\a"); /* BELL */ | 362 | acpi_os_printf("\\a"); /* BELL */ |
359 | break; | 363 | break; |
360 | 364 | ||
361 | case 0x08: | 365 | case 0x08: |
366 | |||
362 | acpi_os_printf("\\b"); /* BACKSPACE */ | 367 | acpi_os_printf("\\b"); /* BACKSPACE */ |
363 | break; | 368 | break; |
364 | 369 | ||
365 | case 0x0C: | 370 | case 0x0C: |
371 | |||
366 | acpi_os_printf("\\f"); /* FORMFEED */ | 372 | acpi_os_printf("\\f"); /* FORMFEED */ |
367 | break; | 373 | break; |
368 | 374 | ||
369 | case 0x0A: | 375 | case 0x0A: |
376 | |||
370 | acpi_os_printf("\\n"); /* LINEFEED */ | 377 | acpi_os_printf("\\n"); /* LINEFEED */ |
371 | break; | 378 | break; |
372 | 379 | ||
373 | case 0x0D: | 380 | case 0x0D: |
381 | |||
374 | acpi_os_printf("\\r"); /* CARRIAGE RETURN */ | 382 | acpi_os_printf("\\r"); /* CARRIAGE RETURN */ |
375 | break; | 383 | break; |
376 | 384 | ||
377 | case 0x09: | 385 | case 0x09: |
386 | |||
378 | acpi_os_printf("\\t"); /* HORIZONTAL TAB */ | 387 | acpi_os_printf("\\t"); /* HORIZONTAL TAB */ |
379 | break; | 388 | break; |
380 | 389 | ||
381 | case 0x0B: | 390 | case 0x0B: |
391 | |||
382 | acpi_os_printf("\\v"); /* VERTICAL TAB */ | 392 | acpi_os_printf("\\v"); /* VERTICAL TAB */ |
383 | break; | 393 | break; |
384 | 394 | ||
385 | case '\'': /* Single Quote */ | 395 | case '\'': /* Single Quote */ |
386 | case '\"': /* Double Quote */ | 396 | case '\"': /* Double Quote */ |
387 | case '\\': /* Backslash */ | 397 | case '\\': /* Backslash */ |
398 | |||
388 | acpi_os_printf("\\%c", (int)string[i]); | 399 | acpi_os_printf("\\%c", (int)string[i]); |
389 | break; | 400 | break; |
390 | 401 | ||
@@ -451,7 +462,8 @@ u8 acpi_ut_valid_acpi_char(char character, u32 position) | |||
451 | * | 462 | * |
452 | * FUNCTION: acpi_ut_valid_acpi_name | 463 | * FUNCTION: acpi_ut_valid_acpi_name |
453 | * | 464 | * |
454 | * PARAMETERS: name - The name to be examined | 465 | * PARAMETERS: name - The name to be examined. Does not have to |
466 | * be NULL terminated string. | ||
455 | * | 467 | * |
456 | * RETURN: TRUE if the name is valid, FALSE otherwise | 468 | * RETURN: TRUE if the name is valid, FALSE otherwise |
457 | * | 469 | * |
@@ -462,15 +474,14 @@ u8 acpi_ut_valid_acpi_char(char character, u32 position) | |||
462 | * | 474 | * |
463 | ******************************************************************************/ | 475 | ******************************************************************************/ |
464 | 476 | ||
465 | u8 acpi_ut_valid_acpi_name(u32 name) | 477 | u8 acpi_ut_valid_acpi_name(char *name) |
466 | { | 478 | { |
467 | u32 i; | 479 | u32 i; |
468 | 480 | ||
469 | ACPI_FUNCTION_ENTRY(); | 481 | ACPI_FUNCTION_ENTRY(); |
470 | 482 | ||
471 | for (i = 0; i < ACPI_NAME_SIZE; i++) { | 483 | for (i = 0; i < ACPI_NAME_SIZE; i++) { |
472 | if (!acpi_ut_valid_acpi_char | 484 | if (!acpi_ut_valid_acpi_char(name[i], i)) { |
473 | ((ACPI_CAST_PTR(char, &name))[i], i)) { | ||
474 | return (FALSE); | 485 | return (FALSE); |
475 | } | 486 | } |
476 | } | 487 | } |
diff --git a/drivers/acpi/acpica/uttrack.c b/drivers/acpi/acpica/uttrack.c index 62774c7b76a8..160f13f4aab5 100644 --- a/drivers/acpi/acpica/uttrack.c +++ b/drivers/acpi/acpica/uttrack.c | |||
@@ -603,6 +603,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module) | |||
603 | switch (ACPI_GET_DESCRIPTOR_TYPE | 603 | switch (ACPI_GET_DESCRIPTOR_TYPE |
604 | (descriptor)) { | 604 | (descriptor)) { |
605 | case ACPI_DESC_TYPE_OPERAND: | 605 | case ACPI_DESC_TYPE_OPERAND: |
606 | |||
606 | if (element->size == | 607 | if (element->size == |
607 | sizeof(union | 608 | sizeof(union |
608 | acpi_operand_object)) | 609 | acpi_operand_object)) |
@@ -613,6 +614,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module) | |||
613 | break; | 614 | break; |
614 | 615 | ||
615 | case ACPI_DESC_TYPE_PARSER: | 616 | case ACPI_DESC_TYPE_PARSER: |
617 | |||
616 | if (element->size == | 618 | if (element->size == |
617 | sizeof(union | 619 | sizeof(union |
618 | acpi_parse_object)) { | 620 | acpi_parse_object)) { |
@@ -622,6 +624,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module) | |||
622 | break; | 624 | break; |
623 | 625 | ||
624 | case ACPI_DESC_TYPE_NAMED: | 626 | case ACPI_DESC_TYPE_NAMED: |
627 | |||
625 | if (element->size == | 628 | if (element->size == |
626 | sizeof(struct | 629 | sizeof(struct |
627 | acpi_namespace_node)) | 630 | acpi_namespace_node)) |
@@ -632,6 +635,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module) | |||
632 | break; | 635 | break; |
633 | 636 | ||
634 | default: | 637 | default: |
638 | |||
635 | break; | 639 | break; |
636 | } | 640 | } |
637 | 641 | ||
@@ -639,6 +643,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module) | |||
639 | 643 | ||
640 | switch (descriptor_type) { | 644 | switch (descriptor_type) { |
641 | case ACPI_DESC_TYPE_OPERAND: | 645 | case ACPI_DESC_TYPE_OPERAND: |
646 | |||
642 | acpi_os_printf | 647 | acpi_os_printf |
643 | ("%12.12s RefCount 0x%04X\n", | 648 | ("%12.12s RefCount 0x%04X\n", |
644 | acpi_ut_get_type_name | 649 | acpi_ut_get_type_name |
@@ -649,6 +654,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module) | |||
649 | break; | 654 | break; |
650 | 655 | ||
651 | case ACPI_DESC_TYPE_PARSER: | 656 | case ACPI_DESC_TYPE_PARSER: |
657 | |||
652 | acpi_os_printf | 658 | acpi_os_printf |
653 | ("AmlOpcode 0x%04hX\n", | 659 | ("AmlOpcode 0x%04hX\n", |
654 | descriptor->op.asl. | 660 | descriptor->op.asl. |
@@ -656,6 +662,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module) | |||
656 | break; | 662 | break; |
657 | 663 | ||
658 | case ACPI_DESC_TYPE_NAMED: | 664 | case ACPI_DESC_TYPE_NAMED: |
665 | |||
659 | acpi_os_printf("%4.4s\n", | 666 | acpi_os_printf("%4.4s\n", |
660 | acpi_ut_get_node_name | 667 | acpi_ut_get_node_name |
661 | (&descriptor-> | 668 | (&descriptor-> |
@@ -663,6 +670,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module) | |||
663 | break; | 670 | break; |
664 | 671 | ||
665 | default: | 672 | default: |
673 | |||
666 | acpi_os_printf("\n"); | 674 | acpi_os_printf("\n"); |
667 | break; | 675 | break; |
668 | } | 676 | } |
diff --git a/drivers/acpi/acpica/utxferror.c b/drivers/acpi/acpica/utxferror.c index 976b6c734fce..e966a2e47b76 100644 --- a/drivers/acpi/acpica/utxferror.c +++ b/drivers/acpi/acpica/utxferror.c | |||
@@ -44,7 +44,6 @@ | |||
44 | #include <linux/export.h> | 44 | #include <linux/export.h> |
45 | #include <acpi/acpi.h> | 45 | #include <acpi/acpi.h> |
46 | #include "accommon.h" | 46 | #include "accommon.h" |
47 | #include "acnamesp.h" | ||
48 | 47 | ||
49 | #define _COMPONENT ACPI_UTILITIES | 48 | #define _COMPONENT ACPI_UTILITIES |
50 | ACPI_MODULE_NAME("utxferror") | 49 | ACPI_MODULE_NAME("utxferror") |
@@ -52,43 +51,7 @@ ACPI_MODULE_NAME("utxferror") | |||
52 | /* | 51 | /* |
53 | * This module is used for the in-kernel ACPICA as well as the ACPICA | 52 | * This module is used for the in-kernel ACPICA as well as the ACPICA |
54 | * tools/applications. | 53 | * tools/applications. |
55 | * | ||
56 | * For the iASL compiler case, the output is redirected to stderr so that | ||
57 | * any of the various ACPI errors and warnings do not appear in the output | ||
58 | * files, for either the compiler or disassembler portions of the tool. | ||
59 | */ | 54 | */ |
60 | #ifdef ACPI_ASL_COMPILER | ||
61 | #include <stdio.h> | ||
62 | extern FILE *acpi_gbl_output_file; | ||
63 | |||
64 | #define ACPI_MSG_REDIRECT_BEGIN \ | ||
65 | FILE *output_file = acpi_gbl_output_file; \ | ||
66 | acpi_os_redirect_output (stderr); | ||
67 | |||
68 | #define ACPI_MSG_REDIRECT_END \ | ||
69 | acpi_os_redirect_output (output_file); | ||
70 | |||
71 | #else | ||
72 | /* | ||
73 | * non-iASL case - no redirection, nothing to do | ||
74 | */ | ||
75 | #define ACPI_MSG_REDIRECT_BEGIN | ||
76 | #define ACPI_MSG_REDIRECT_END | ||
77 | #endif | ||
78 | /* | ||
79 | * Common message prefixes | ||
80 | */ | ||
81 | #define ACPI_MSG_ERROR "ACPI Error: " | ||
82 | #define ACPI_MSG_EXCEPTION "ACPI Exception: " | ||
83 | #define ACPI_MSG_WARNING "ACPI Warning: " | ||
84 | #define ACPI_MSG_INFO "ACPI: " | ||
85 | #define ACPI_MSG_BIOS_ERROR "ACPI BIOS Bug: Error: " | ||
86 | #define ACPI_MSG_BIOS_WARNING "ACPI BIOS Bug: Warning: " | ||
87 | /* | ||
88 | * Common message suffix | ||
89 | */ | ||
90 | #define ACPI_MSG_SUFFIX \ | ||
91 | acpi_os_printf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, module_name, line_number) | ||
92 | /******************************************************************************* | 55 | /******************************************************************************* |
93 | * | 56 | * |
94 | * FUNCTION: acpi_error | 57 | * FUNCTION: acpi_error |
@@ -285,200 +248,3 @@ acpi_bios_warning(const char *module_name, | |||
285 | } | 248 | } |
286 | 249 | ||
287 | ACPI_EXPORT_SYMBOL(acpi_bios_warning) | 250 | ACPI_EXPORT_SYMBOL(acpi_bios_warning) |
288 | |||
289 | /* | ||
290 | * The remainder of this module contains internal error functions that may | ||
291 | * be configured out. | ||
292 | */ | ||
293 | #if !defined (ACPI_NO_ERROR_MESSAGES) && !defined (ACPI_BIN_APP) | ||
294 | /******************************************************************************* | ||
295 | * | ||
296 | * FUNCTION: acpi_ut_predefined_warning | ||
297 | * | ||
298 | * PARAMETERS: module_name - Caller's module name (for error output) | ||
299 | * line_number - Caller's line number (for error output) | ||
300 | * pathname - Full pathname to the node | ||
301 | * node_flags - From Namespace node for the method/object | ||
302 | * format - Printf format string + additional args | ||
303 | * | ||
304 | * RETURN: None | ||
305 | * | ||
306 | * DESCRIPTION: Warnings for the predefined validation module. Messages are | ||
307 | * only emitted the first time a problem with a particular | ||
308 | * method/object is detected. This prevents a flood of error | ||
309 | * messages for methods that are repeatedly evaluated. | ||
310 | * | ||
311 | ******************************************************************************/ | ||
312 | void ACPI_INTERNAL_VAR_XFACE | ||
313 | acpi_ut_predefined_warning(const char *module_name, | ||
314 | u32 line_number, | ||
315 | char *pathname, | ||
316 | u8 node_flags, const char *format, ...) | ||
317 | { | ||
318 | va_list arg_list; | ||
319 | |||
320 | /* | ||
321 | * Warning messages for this method/object will be disabled after the | ||
322 | * first time a validation fails or an object is successfully repaired. | ||
323 | */ | ||
324 | if (node_flags & ANOBJ_EVALUATED) { | ||
325 | return; | ||
326 | } | ||
327 | |||
328 | acpi_os_printf(ACPI_MSG_WARNING "For %s: ", pathname); | ||
329 | |||
330 | va_start(arg_list, format); | ||
331 | acpi_os_vprintf(format, arg_list); | ||
332 | ACPI_MSG_SUFFIX; | ||
333 | va_end(arg_list); | ||
334 | } | ||
335 | |||
336 | /******************************************************************************* | ||
337 | * | ||
338 | * FUNCTION: acpi_ut_predefined_info | ||
339 | * | ||
340 | * PARAMETERS: module_name - Caller's module name (for error output) | ||
341 | * line_number - Caller's line number (for error output) | ||
342 | * pathname - Full pathname to the node | ||
343 | * node_flags - From Namespace node for the method/object | ||
344 | * format - Printf format string + additional args | ||
345 | * | ||
346 | * RETURN: None | ||
347 | * | ||
348 | * DESCRIPTION: Info messages for the predefined validation module. Messages | ||
349 | * are only emitted the first time a problem with a particular | ||
350 | * method/object is detected. This prevents a flood of | ||
351 | * messages for methods that are repeatedly evaluated. | ||
352 | * | ||
353 | ******************************************************************************/ | ||
354 | |||
355 | void ACPI_INTERNAL_VAR_XFACE | ||
356 | acpi_ut_predefined_info(const char *module_name, | ||
357 | u32 line_number, | ||
358 | char *pathname, u8 node_flags, const char *format, ...) | ||
359 | { | ||
360 | va_list arg_list; | ||
361 | |||
362 | /* | ||
363 | * Warning messages for this method/object will be disabled after the | ||
364 | * first time a validation fails or an object is successfully repaired. | ||
365 | */ | ||
366 | if (node_flags & ANOBJ_EVALUATED) { | ||
367 | return; | ||
368 | } | ||
369 | |||
370 | acpi_os_printf(ACPI_MSG_INFO "For %s: ", pathname); | ||
371 | |||
372 | va_start(arg_list, format); | ||
373 | acpi_os_vprintf(format, arg_list); | ||
374 | ACPI_MSG_SUFFIX; | ||
375 | va_end(arg_list); | ||
376 | } | ||
377 | |||
378 | /******************************************************************************* | ||
379 | * | ||
380 | * FUNCTION: acpi_ut_namespace_error | ||
381 | * | ||
382 | * PARAMETERS: module_name - Caller's module name (for error output) | ||
383 | * line_number - Caller's line number (for error output) | ||
384 | * internal_name - Name or path of the namespace node | ||
385 | * lookup_status - Exception code from NS lookup | ||
386 | * | ||
387 | * RETURN: None | ||
388 | * | ||
389 | * DESCRIPTION: Print error message with the full pathname for the NS node. | ||
390 | * | ||
391 | ******************************************************************************/ | ||
392 | |||
393 | void | ||
394 | acpi_ut_namespace_error(const char *module_name, | ||
395 | u32 line_number, | ||
396 | const char *internal_name, acpi_status lookup_status) | ||
397 | { | ||
398 | acpi_status status; | ||
399 | u32 bad_name; | ||
400 | char *name = NULL; | ||
401 | |||
402 | ACPI_MSG_REDIRECT_BEGIN; | ||
403 | acpi_os_printf(ACPI_MSG_ERROR); | ||
404 | |||
405 | if (lookup_status == AE_BAD_CHARACTER) { | ||
406 | |||
407 | /* There is a non-ascii character in the name */ | ||
408 | |||
409 | ACPI_MOVE_32_TO_32(&bad_name, | ||
410 | ACPI_CAST_PTR(u32, internal_name)); | ||
411 | acpi_os_printf("[0x%.8X] (NON-ASCII)", bad_name); | ||
412 | } else { | ||
413 | /* Convert path to external format */ | ||
414 | |||
415 | status = acpi_ns_externalize_name(ACPI_UINT32_MAX, | ||
416 | internal_name, NULL, &name); | ||
417 | |||
418 | /* Print target name */ | ||
419 | |||
420 | if (ACPI_SUCCESS(status)) { | ||
421 | acpi_os_printf("[%s]", name); | ||
422 | } else { | ||
423 | acpi_os_printf("[COULD NOT EXTERNALIZE NAME]"); | ||
424 | } | ||
425 | |||
426 | if (name) { | ||
427 | ACPI_FREE(name); | ||
428 | } | ||
429 | } | ||
430 | |||
431 | acpi_os_printf(" Namespace lookup failure, %s", | ||
432 | acpi_format_exception(lookup_status)); | ||
433 | |||
434 | ACPI_MSG_SUFFIX; | ||
435 | ACPI_MSG_REDIRECT_END; | ||
436 | } | ||
437 | |||
438 | /******************************************************************************* | ||
439 | * | ||
440 | * FUNCTION: acpi_ut_method_error | ||
441 | * | ||
442 | * PARAMETERS: module_name - Caller's module name (for error output) | ||
443 | * line_number - Caller's line number (for error output) | ||
444 | * message - Error message to use on failure | ||
445 | * prefix_node - Prefix relative to the path | ||
446 | * path - Path to the node (optional) | ||
447 | * method_status - Execution status | ||
448 | * | ||
449 | * RETURN: None | ||
450 | * | ||
451 | * DESCRIPTION: Print error message with the full pathname for the method. | ||
452 | * | ||
453 | ******************************************************************************/ | ||
454 | |||
455 | void | ||
456 | acpi_ut_method_error(const char *module_name, | ||
457 | u32 line_number, | ||
458 | const char *message, | ||
459 | struct acpi_namespace_node *prefix_node, | ||
460 | const char *path, acpi_status method_status) | ||
461 | { | ||
462 | acpi_status status; | ||
463 | struct acpi_namespace_node *node = prefix_node; | ||
464 | |||
465 | ACPI_MSG_REDIRECT_BEGIN; | ||
466 | acpi_os_printf(ACPI_MSG_ERROR); | ||
467 | |||
468 | if (path) { | ||
469 | status = | ||
470 | acpi_ns_get_node(prefix_node, path, ACPI_NS_NO_UPSEARCH, | ||
471 | &node); | ||
472 | if (ACPI_FAILURE(status)) { | ||
473 | acpi_os_printf("[Could not get node by pathname]"); | ||
474 | } | ||
475 | } | ||
476 | |||
477 | acpi_ns_print_node_pathname(node, message); | ||
478 | acpi_os_printf(", %s", acpi_format_exception(method_status)); | ||
479 | |||
480 | ACPI_MSG_SUFFIX; | ||
481 | ACPI_MSG_REDIRECT_END; | ||
482 | } | ||
483 | |||
484 | #endif /* ACPI_NO_ERROR_MESSAGES */ | ||
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index e7100459ac4a..082b4dd252a8 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -425,7 +425,7 @@ static int acpi_battery_get_info(struct acpi_battery *battery) | |||
425 | { | 425 | { |
426 | int result = -EFAULT; | 426 | int result = -EFAULT; |
427 | acpi_status status = 0; | 427 | acpi_status status = 0; |
428 | char *name = test_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags)? | 428 | char *name = test_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags) ? |
429 | "_BIX" : "_BIF"; | 429 | "_BIX" : "_BIF"; |
430 | 430 | ||
431 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 431 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
@@ -661,11 +661,11 @@ static void find_battery(const struct dmi_header *dm, void *private) | |||
661 | static void acpi_battery_quirks(struct acpi_battery *battery) | 661 | static void acpi_battery_quirks(struct acpi_battery *battery) |
662 | { | 662 | { |
663 | if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)) | 663 | if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)) |
664 | return ; | 664 | return; |
665 | 665 | ||
666 | if (battery->full_charge_capacity == 100 && | 666 | if (battery->full_charge_capacity == 100 && |
667 | battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN && | 667 | battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN && |
668 | battery->capacity_now >=0 && battery->capacity_now <= 100) { | 668 | battery->capacity_now >= 0 && battery->capacity_now <= 100) { |
669 | set_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags); | 669 | set_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags); |
670 | battery->full_charge_capacity = battery->design_capacity; | 670 | battery->full_charge_capacity = battery->design_capacity; |
671 | battery->capacity_now = (battery->capacity_now * | 671 | battery->capacity_now = (battery->capacity_now * |
@@ -673,7 +673,7 @@ static void acpi_battery_quirks(struct acpi_battery *battery) | |||
673 | } | 673 | } |
674 | 674 | ||
675 | if (test_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH, &battery->flags)) | 675 | if (test_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH, &battery->flags)) |
676 | return ; | 676 | return; |
677 | 677 | ||
678 | if (battery->power_unit && dmi_name_in_vendors("LENOVO")) { | 678 | if (battery->power_unit && dmi_name_in_vendors("LENOVO")) { |
679 | const char *s; | 679 | const char *s; |
@@ -761,7 +761,7 @@ static int acpi_battery_print_info(struct seq_file *seq, int result) | |||
761 | goto end; | 761 | goto end; |
762 | 762 | ||
763 | seq_printf(seq, "present: %s\n", | 763 | seq_printf(seq, "present: %s\n", |
764 | acpi_battery_present(battery)?"yes":"no"); | 764 | acpi_battery_present(battery) ? "yes" : "no"); |
765 | if (!acpi_battery_present(battery)) | 765 | if (!acpi_battery_present(battery)) |
766 | goto end; | 766 | goto end; |
767 | if (battery->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN) | 767 | if (battery->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN) |
@@ -817,12 +817,12 @@ static int acpi_battery_print_state(struct seq_file *seq, int result) | |||
817 | goto end; | 817 | goto end; |
818 | 818 | ||
819 | seq_printf(seq, "present: %s\n", | 819 | seq_printf(seq, "present: %s\n", |
820 | acpi_battery_present(battery)?"yes":"no"); | 820 | acpi_battery_present(battery) ? "yes" : "no"); |
821 | if (!acpi_battery_present(battery)) | 821 | if (!acpi_battery_present(battery)) |
822 | goto end; | 822 | goto end; |
823 | 823 | ||
824 | seq_printf(seq, "capacity state: %s\n", | 824 | seq_printf(seq, "capacity state: %s\n", |
825 | (battery->state & 0x04)?"critical":"ok"); | 825 | (battery->state & 0x04) ? "critical" : "ok"); |
826 | if ((battery->state & 0x01) && (battery->state & 0x02)) | 826 | if ((battery->state & 0x01) && (battery->state & 0x02)) |
827 | seq_printf(seq, | 827 | seq_printf(seq, |
828 | "charging state: charging/discharging\n"); | 828 | "charging state: charging/discharging\n"); |
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 292de3cab9cc..a5bb33bab448 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -91,8 +91,7 @@ static struct dmi_system_id dsdt_dmi_table[] __initdata = { | |||
91 | 91 | ||
92 | int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) | 92 | int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) |
93 | { | 93 | { |
94 | acpi_status status = AE_OK; | 94 | acpi_status status; |
95 | |||
96 | 95 | ||
97 | if (!device) | 96 | if (!device) |
98 | return -EINVAL; | 97 | return -EINVAL; |
@@ -162,7 +161,7 @@ EXPORT_SYMBOL(acpi_bus_private_data_handler); | |||
162 | 161 | ||
163 | int acpi_bus_get_private_data(acpi_handle handle, void **data) | 162 | int acpi_bus_get_private_data(acpi_handle handle, void **data) |
164 | { | 163 | { |
165 | acpi_status status = AE_OK; | 164 | acpi_status status; |
166 | 165 | ||
167 | if (!*data) | 166 | if (!*data) |
168 | return -EINVAL; | 167 | return -EINVAL; |
@@ -361,7 +360,7 @@ extern int event_is_open; | |||
361 | int acpi_bus_generate_proc_event4(const char *device_class, const char *bus_id, u8 type, int data) | 360 | int acpi_bus_generate_proc_event4(const char *device_class, const char *bus_id, u8 type, int data) |
362 | { | 361 | { |
363 | struct acpi_bus_event *event; | 362 | struct acpi_bus_event *event; |
364 | unsigned long flags = 0; | 363 | unsigned long flags; |
365 | 364 | ||
366 | /* drop event on the floor if no one's listening */ | 365 | /* drop event on the floor if no one's listening */ |
367 | if (!event_is_open) | 366 | if (!event_is_open) |
@@ -400,7 +399,7 @@ EXPORT_SYMBOL(acpi_bus_generate_proc_event); | |||
400 | 399 | ||
401 | int acpi_bus_receive_event(struct acpi_bus_event *event) | 400 | int acpi_bus_receive_event(struct acpi_bus_event *event) |
402 | { | 401 | { |
403 | unsigned long flags = 0; | 402 | unsigned long flags; |
404 | struct acpi_bus_event *entry = NULL; | 403 | struct acpi_bus_event *entry = NULL; |
405 | 404 | ||
406 | DECLARE_WAITQUEUE(wait, current); | 405 | DECLARE_WAITQUEUE(wait, current); |
@@ -593,7 +592,7 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data) | |||
593 | 592 | ||
594 | static int __init acpi_bus_init_irq(void) | 593 | static int __init acpi_bus_init_irq(void) |
595 | { | 594 | { |
596 | acpi_status status = AE_OK; | 595 | acpi_status status; |
597 | union acpi_object arg = { ACPI_TYPE_INTEGER }; | 596 | union acpi_object arg = { ACPI_TYPE_INTEGER }; |
598 | struct acpi_object_list arg_list = { 1, &arg }; | 597 | struct acpi_object_list arg_list = { 1, &arg }; |
599 | char *message = NULL; | 598 | char *message = NULL; |
@@ -640,7 +639,7 @@ u8 acpi_gbl_permanent_mmap; | |||
640 | 639 | ||
641 | void __init acpi_early_init(void) | 640 | void __init acpi_early_init(void) |
642 | { | 641 | { |
643 | acpi_status status = AE_OK; | 642 | acpi_status status; |
644 | 643 | ||
645 | if (acpi_disabled) | 644 | if (acpi_disabled) |
646 | return; | 645 | return; |
@@ -714,8 +713,8 @@ void __init acpi_early_init(void) | |||
714 | 713 | ||
715 | static int __init acpi_bus_init(void) | 714 | static int __init acpi_bus_init(void) |
716 | { | 715 | { |
717 | int result = 0; | 716 | int result; |
718 | acpi_status status = AE_OK; | 717 | acpi_status status; |
719 | extern acpi_status acpi_os_initialize1(void); | 718 | extern acpi_status acpi_os_initialize1(void); |
720 | 719 | ||
721 | acpi_os_initialize1(); | 720 | acpi_os_initialize1(); |
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 31c217a42839..e9e8bb24785b 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c | |||
@@ -419,62 +419,73 @@ bool acpi_bus_can_wakeup(acpi_handle handle) | |||
419 | EXPORT_SYMBOL(acpi_bus_can_wakeup); | 419 | EXPORT_SYMBOL(acpi_bus_can_wakeup); |
420 | 420 | ||
421 | /** | 421 | /** |
422 | * acpi_device_power_state - Get preferred power state of ACPI device. | 422 | * acpi_dev_pm_get_state - Get preferred power state of ACPI device. |
423 | * @dev: Device whose preferred target power state to return. | 423 | * @dev: Device whose preferred target power state to return. |
424 | * @adev: ACPI device node corresponding to @dev. | 424 | * @adev: ACPI device node corresponding to @dev. |
425 | * @target_state: System state to match the resultant device state. | 425 | * @target_state: System state to match the resultant device state. |
426 | * @d_max_in: Deepest low-power state to take into consideration. | 426 | * @d_min_p: Location to store the highest power state available to the device. |
427 | * @d_min_p: Location to store the upper limit of the allowed states range. | 427 | * @d_max_p: Location to store the lowest power state available to the device. |
428 | * Return value: Preferred power state of the device on success, -ENODEV | ||
429 | * (if there's no 'struct acpi_device' for @dev) or -EINVAL on failure | ||
430 | * | 428 | * |
431 | * Find the lowest power (highest number) ACPI device power state that the | 429 | * Find the lowest power (highest number) and highest power (lowest number) ACPI |
432 | * device can be in while the system is in the state represented by | 430 | * device power states that the device can be in while the system is in the |
433 | * @target_state. If @d_min_p is set, the highest power (lowest number) device | 431 | * state represented by @target_state. Store the integer numbers representing |
434 | * power state that @dev can be in for the given system sleep state is stored | 432 | * those stats in the memory locations pointed to by @d_max_p and @d_min_p, |
435 | * at the location pointed to by it. | 433 | * respectively. |
436 | * | 434 | * |
437 | * Callers must ensure that @dev and @adev are valid pointers and that @adev | 435 | * Callers must ensure that @dev and @adev are valid pointers and that @adev |
438 | * actually corresponds to @dev before using this function. | 436 | * actually corresponds to @dev before using this function. |
437 | * | ||
438 | * Returns 0 on success or -ENODATA when one of the ACPI methods fails or | ||
439 | * returns a value that doesn't make sense. The memory locations pointed to by | ||
440 | * @d_max_p and @d_min_p are only modified on success. | ||
439 | */ | 441 | */ |
440 | int acpi_device_power_state(struct device *dev, struct acpi_device *adev, | 442 | static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev, |
441 | u32 target_state, int d_max_in, int *d_min_p) | 443 | u32 target_state, int *d_min_p, int *d_max_p) |
442 | { | 444 | { |
443 | char acpi_method[] = "_SxD"; | 445 | char method[] = { '_', 'S', '0' + target_state, 'D', '\0' }; |
444 | unsigned long long d_min, d_max; | 446 | acpi_handle handle = adev->handle; |
447 | unsigned long long ret; | ||
448 | int d_min, d_max; | ||
445 | bool wakeup = false; | 449 | bool wakeup = false; |
450 | acpi_status status; | ||
446 | 451 | ||
447 | if (d_max_in < ACPI_STATE_D0 || d_max_in > ACPI_STATE_D3) | ||
448 | return -EINVAL; | ||
449 | |||
450 | if (d_max_in > ACPI_STATE_D3_HOT) { | ||
451 | enum pm_qos_flags_status stat; | ||
452 | |||
453 | stat = dev_pm_qos_flags(dev, PM_QOS_FLAG_NO_POWER_OFF); | ||
454 | if (stat == PM_QOS_FLAGS_ALL) | ||
455 | d_max_in = ACPI_STATE_D3_HOT; | ||
456 | } | ||
457 | |||
458 | acpi_method[2] = '0' + target_state; | ||
459 | /* | 452 | /* |
460 | * If the sleep state is S0, the lowest limit from ACPI is D3, | 453 | * If the system state is S0, the lowest power state the device can be |
461 | * but if the device has _S0W, we will use the value from _S0W | 454 | * in is D3cold, unless the device has _S0W and is supposed to signal |
462 | * as the lowest limit from ACPI. Finally, we will constrain | 455 | * wakeup, in which case the return value of _S0W has to be used as the |
463 | * the lowest limit with the specified one. | 456 | * lowest power state available to the device. |
464 | */ | 457 | */ |
465 | d_min = ACPI_STATE_D0; | 458 | d_min = ACPI_STATE_D0; |
466 | d_max = ACPI_STATE_D3; | 459 | d_max = ACPI_STATE_D3_COLD; |
467 | 460 | ||
468 | /* | 461 | /* |
469 | * If present, _SxD methods return the minimum D-state (highest power | 462 | * If present, _SxD methods return the minimum D-state (highest power |
470 | * state) we can use for the corresponding S-states. Otherwise, the | 463 | * state) we can use for the corresponding S-states. Otherwise, the |
471 | * minimum D-state is D0 (ACPI 3.x). | 464 | * minimum D-state is D0 (ACPI 3.x). |
472 | * | ||
473 | * NOTE: We rely on acpi_evaluate_integer() not clobbering the integer | ||
474 | * provided -- that's our fault recovery, we ignore retval. | ||
475 | */ | 465 | */ |
476 | if (target_state > ACPI_STATE_S0) { | 466 | if (target_state > ACPI_STATE_S0) { |
477 | acpi_evaluate_integer(adev->handle, acpi_method, NULL, &d_min); | 467 | /* |
468 | * We rely on acpi_evaluate_integer() not clobbering the integer | ||
469 | * provided if AE_NOT_FOUND is returned. | ||
470 | */ | ||
471 | ret = d_min; | ||
472 | status = acpi_evaluate_integer(handle, method, NULL, &ret); | ||
473 | if ((ACPI_FAILURE(status) && status != AE_NOT_FOUND) | ||
474 | || ret > ACPI_STATE_D3_COLD) | ||
475 | return -ENODATA; | ||
476 | |||
477 | /* | ||
478 | * We need to handle legacy systems where D3hot and D3cold are | ||
479 | * the same and 3 is returned in both cases, so fall back to | ||
480 | * D3cold if D3hot is not a valid state. | ||
481 | */ | ||
482 | if (!adev->power.states[ret].flags.valid) { | ||
483 | if (ret == ACPI_STATE_D3_HOT) | ||
484 | ret = ACPI_STATE_D3_COLD; | ||
485 | else | ||
486 | return -ENODATA; | ||
487 | } | ||
488 | d_min = ret; | ||
478 | wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid | 489 | wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid |
479 | && adev->wakeup.sleep_state >= target_state; | 490 | && adev->wakeup.sleep_state >= target_state; |
480 | } else if (dev_pm_qos_flags(dev, PM_QOS_FLAG_REMOTE_WAKEUP) != | 491 | } else if (dev_pm_qos_flags(dev, PM_QOS_FLAG_REMOTE_WAKEUP) != |
@@ -490,38 +501,30 @@ int acpi_device_power_state(struct device *dev, struct acpi_device *adev, | |||
490 | * can wake the system. _S0W may be valid, too. | 501 | * can wake the system. _S0W may be valid, too. |
491 | */ | 502 | */ |
492 | if (wakeup) { | 503 | if (wakeup) { |
493 | acpi_status status; | 504 | method[3] = 'W'; |
494 | 505 | status = acpi_evaluate_integer(handle, method, NULL, &ret); | |
495 | acpi_method[3] = 'W'; | 506 | if (status == AE_NOT_FOUND) { |
496 | status = acpi_evaluate_integer(adev->handle, acpi_method, NULL, | 507 | if (target_state > ACPI_STATE_S0) |
497 | &d_max); | ||
498 | if (ACPI_FAILURE(status)) { | ||
499 | if (target_state != ACPI_STATE_S0 || | ||
500 | status != AE_NOT_FOUND) | ||
501 | d_max = d_min; | 508 | d_max = d_min; |
502 | } else if (d_max < d_min) { | 509 | } else if (ACPI_SUCCESS(status) && ret <= ACPI_STATE_D3_COLD) { |
503 | /* Warn the user of the broken DSDT */ | 510 | /* Fall back to D3cold if ret is not a valid state. */ |
504 | printk(KERN_WARNING "ACPI: Wrong value from %s\n", | 511 | if (!adev->power.states[ret].flags.valid) |
505 | acpi_method); | 512 | ret = ACPI_STATE_D3_COLD; |
506 | /* Sanitize it */ | 513 | |
507 | d_min = d_max; | 514 | d_max = ret > d_min ? ret : d_min; |
515 | } else { | ||
516 | return -ENODATA; | ||
508 | } | 517 | } |
509 | } | 518 | } |
510 | 519 | ||
511 | if (d_max_in < d_min) | ||
512 | return -EINVAL; | ||
513 | if (d_min_p) | 520 | if (d_min_p) |
514 | *d_min_p = d_min; | 521 | *d_min_p = d_min; |
515 | /* constrain d_max with specified lowest limit (max number) */ | 522 | |
516 | if (d_max > d_max_in) { | 523 | if (d_max_p) |
517 | for (d_max = d_max_in; d_max > d_min; d_max--) { | 524 | *d_max_p = d_max; |
518 | if (adev->power.states[d_max].flags.valid) | 525 | |
519 | break; | 526 | return 0; |
520 | } | ||
521 | } | ||
522 | return d_max; | ||
523 | } | 527 | } |
524 | EXPORT_SYMBOL_GPL(acpi_device_power_state); | ||
525 | 528 | ||
526 | /** | 529 | /** |
527 | * acpi_pm_device_sleep_state - Get preferred power state of ACPI device. | 530 | * acpi_pm_device_sleep_state - Get preferred power state of ACPI device. |
@@ -529,7 +532,8 @@ EXPORT_SYMBOL_GPL(acpi_device_power_state); | |||
529 | * @d_min_p: Location to store the upper limit of the allowed states range. | 532 | * @d_min_p: Location to store the upper limit of the allowed states range. |
530 | * @d_max_in: Deepest low-power state to take into consideration. | 533 | * @d_max_in: Deepest low-power state to take into consideration. |
531 | * Return value: Preferred power state of the device on success, -ENODEV | 534 | * Return value: Preferred power state of the device on success, -ENODEV |
532 | * (if there's no 'struct acpi_device' for @dev) or -EINVAL on failure | 535 | * if there's no 'struct acpi_device' for @dev, -EINVAL if @d_max_in is |
536 | * incorrect, or -ENODATA on ACPI method failure. | ||
533 | * | 537 | * |
534 | * The caller must ensure that @dev is valid before using this function. | 538 | * The caller must ensure that @dev is valid before using this function. |
535 | */ | 539 | */ |
@@ -537,14 +541,43 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in) | |||
537 | { | 541 | { |
538 | acpi_handle handle = DEVICE_ACPI_HANDLE(dev); | 542 | acpi_handle handle = DEVICE_ACPI_HANDLE(dev); |
539 | struct acpi_device *adev; | 543 | struct acpi_device *adev; |
544 | int ret, d_min, d_max; | ||
545 | |||
546 | if (d_max_in < ACPI_STATE_D0 || d_max_in > ACPI_STATE_D3_COLD) | ||
547 | return -EINVAL; | ||
548 | |||
549 | if (d_max_in > ACPI_STATE_D3_HOT) { | ||
550 | enum pm_qos_flags_status stat; | ||
551 | |||
552 | stat = dev_pm_qos_flags(dev, PM_QOS_FLAG_NO_POWER_OFF); | ||
553 | if (stat == PM_QOS_FLAGS_ALL) | ||
554 | d_max_in = ACPI_STATE_D3_HOT; | ||
555 | } | ||
540 | 556 | ||
541 | if (!handle || acpi_bus_get_device(handle, &adev)) { | 557 | if (!handle || acpi_bus_get_device(handle, &adev)) { |
542 | dev_dbg(dev, "ACPI handle without context in %s!\n", __func__); | 558 | dev_dbg(dev, "ACPI handle without context in %s!\n", __func__); |
543 | return -ENODEV; | 559 | return -ENODEV; |
544 | } | 560 | } |
545 | 561 | ||
546 | return acpi_device_power_state(dev, adev, acpi_target_system_state(), | 562 | ret = acpi_dev_pm_get_state(dev, adev, acpi_target_system_state(), |
547 | d_max_in, d_min_p); | 563 | &d_min, &d_max); |
564 | if (ret) | ||
565 | return ret; | ||
566 | |||
567 | if (d_max_in < d_min) | ||
568 | return -EINVAL; | ||
569 | |||
570 | if (d_max > d_max_in) { | ||
571 | for (d_max = d_max_in; d_max > d_min; d_max--) { | ||
572 | if (adev->power.states[d_max].flags.valid) | ||
573 | break; | ||
574 | } | ||
575 | } | ||
576 | |||
577 | if (d_min_p) | ||
578 | *d_min_p = d_min; | ||
579 | |||
580 | return d_max; | ||
548 | } | 581 | } |
549 | EXPORT_SYMBOL(acpi_pm_device_sleep_state); | 582 | EXPORT_SYMBOL(acpi_pm_device_sleep_state); |
550 | 583 | ||
@@ -695,17 +728,13 @@ struct acpi_device *acpi_dev_pm_get_node(struct device *dev) | |||
695 | static int acpi_dev_pm_low_power(struct device *dev, struct acpi_device *adev, | 728 | static int acpi_dev_pm_low_power(struct device *dev, struct acpi_device *adev, |
696 | u32 system_state) | 729 | u32 system_state) |
697 | { | 730 | { |
698 | int power_state; | 731 | int ret, state; |
699 | 732 | ||
700 | if (!acpi_device_power_manageable(adev)) | 733 | if (!acpi_device_power_manageable(adev)) |
701 | return 0; | 734 | return 0; |
702 | 735 | ||
703 | power_state = acpi_device_power_state(dev, adev, system_state, | 736 | ret = acpi_dev_pm_get_state(dev, adev, system_state, NULL, &state); |
704 | ACPI_STATE_D3, NULL); | 737 | return ret ? ret : acpi_device_set_power(adev, state); |
705 | if (power_state < ACPI_STATE_D0 || power_state > ACPI_STATE_D3) | ||
706 | return -EIO; | ||
707 | |||
708 | return acpi_device_set_power(adev, power_state); | ||
709 | } | 738 | } |
710 | 739 | ||
711 | /** | 740 | /** |
@@ -908,7 +937,6 @@ static struct dev_pm_domain acpi_general_pm_domain = { | |||
908 | #ifdef CONFIG_PM_RUNTIME | 937 | #ifdef CONFIG_PM_RUNTIME |
909 | .runtime_suspend = acpi_subsys_runtime_suspend, | 938 | .runtime_suspend = acpi_subsys_runtime_suspend, |
910 | .runtime_resume = acpi_subsys_runtime_resume, | 939 | .runtime_resume = acpi_subsys_runtime_resume, |
911 | .runtime_idle = pm_generic_runtime_idle, | ||
912 | #endif | 940 | #endif |
913 | #ifdef CONFIG_PM_SLEEP | 941 | #ifdef CONFIG_PM_SLEEP |
914 | .prepare = acpi_subsys_prepare, | 942 | .prepare = acpi_subsys_prepare, |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index edc00818c803..80403c1a89f8 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -983,6 +983,10 @@ static struct dmi_system_id __initdata ec_dmi_table[] = { | |||
983 | ec_enlarge_storm_threshold, "CLEVO hardware", { | 983 | ec_enlarge_storm_threshold, "CLEVO hardware", { |
984 | DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."), | 984 | DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."), |
985 | DMI_MATCH(DMI_PRODUCT_NAME, "M720T/M730T"),}, NULL}, | 985 | DMI_MATCH(DMI_PRODUCT_NAME, "M720T/M730T"),}, NULL}, |
986 | { | ||
987 | ec_skip_dsdt_scan, "HP Folio 13", { | ||
988 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | ||
989 | DMI_MATCH(DMI_PRODUCT_NAME, "HP Folio 13"),}, NULL}, | ||
986 | {}, | 990 | {}, |
987 | }; | 991 | }; |
988 | 992 | ||
diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c index 7586544fddb4..4e7b798900f2 100644 --- a/drivers/acpi/ec_sys.c +++ b/drivers/acpi/ec_sys.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/acpi.h> | 12 | #include <linux/acpi.h> |
13 | #include <linux/debugfs.h> | 13 | #include <linux/debugfs.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/uaccess.h> | ||
15 | #include "internal.h" | 16 | #include "internal.h" |
16 | 17 | ||
17 | MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>"); | 18 | MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>"); |
@@ -34,7 +35,6 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf, | |||
34 | * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private; | 35 | * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private; |
35 | */ | 36 | */ |
36 | unsigned int size = EC_SPACE_SIZE; | 37 | unsigned int size = EC_SPACE_SIZE; |
37 | u8 *data = (u8 *) buf; | ||
38 | loff_t init_off = *off; | 38 | loff_t init_off = *off; |
39 | int err = 0; | 39 | int err = 0; |
40 | 40 | ||
@@ -47,9 +47,15 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf, | |||
47 | size = count; | 47 | size = count; |
48 | 48 | ||
49 | while (size) { | 49 | while (size) { |
50 | err = ec_read(*off, &data[*off - init_off]); | 50 | u8 byte_read; |
51 | err = ec_read(*off, &byte_read); | ||
51 | if (err) | 52 | if (err) |
52 | return err; | 53 | return err; |
54 | if (put_user(byte_read, buf + *off - init_off)) { | ||
55 | if (*off - init_off) | ||
56 | return *off - init_off; /* partial read */ | ||
57 | return -EFAULT; | ||
58 | } | ||
53 | *off += 1; | 59 | *off += 1; |
54 | size--; | 60 | size--; |
55 | } | 61 | } |
@@ -65,7 +71,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf, | |||
65 | 71 | ||
66 | unsigned int size = count; | 72 | unsigned int size = count; |
67 | loff_t init_off = *off; | 73 | loff_t init_off = *off; |
68 | u8 *data = (u8 *) buf; | ||
69 | int err = 0; | 74 | int err = 0; |
70 | 75 | ||
71 | if (*off >= EC_SPACE_SIZE) | 76 | if (*off >= EC_SPACE_SIZE) |
@@ -76,7 +81,12 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf, | |||
76 | } | 81 | } |
77 | 82 | ||
78 | while (size) { | 83 | while (size) { |
79 | u8 byte_write = data[*off - init_off]; | 84 | u8 byte_write; |
85 | if (get_user(byte_write, buf + *off - init_off)) { | ||
86 | if (*off - init_off) | ||
87 | return *off - init_off; /* partial write */ | ||
88 | return -EFAULT; | ||
89 | } | ||
80 | err = ec_write(*off, byte_write); | 90 | err = ec_write(*off, byte_write); |
81 | if (err) | 91 | if (err) |
82 | return err; | 92 | return err; |
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 40a84cc6740c..f68095756fb7 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c | |||
@@ -81,13 +81,15 @@ static struct acpi_bus_type *acpi_get_bus_type(struct device *dev) | |||
81 | static acpi_status do_acpi_find_child(acpi_handle handle, u32 lvl_not_used, | 81 | static acpi_status do_acpi_find_child(acpi_handle handle, u32 lvl_not_used, |
82 | void *addr_p, void **ret_p) | 82 | void *addr_p, void **ret_p) |
83 | { | 83 | { |
84 | unsigned long long addr; | 84 | unsigned long long addr, sta; |
85 | acpi_status status; | 85 | acpi_status status; |
86 | 86 | ||
87 | status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &addr); | 87 | status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &addr); |
88 | if (ACPI_SUCCESS(status) && addr == *((u64 *)addr_p)) { | 88 | if (ACPI_SUCCESS(status) && addr == *((u64 *)addr_p)) { |
89 | *ret_p = handle; | 89 | *ret_p = handle; |
90 | return AE_CTRL_TERMINATE; | 90 | status = acpi_bus_get_status_handle(handle, &sta); |
91 | if (ACPI_SUCCESS(status) && (sta & ACPI_STA_DEVICE_ENABLED)) | ||
92 | return AE_CTRL_TERMINATE; | ||
91 | } | 93 | } |
92 | return AE_OK; | 94 | return AE_OK; |
93 | } | 95 | } |
@@ -105,7 +107,7 @@ acpi_handle acpi_get_child(acpi_handle parent, u64 address) | |||
105 | } | 107 | } |
106 | EXPORT_SYMBOL(acpi_get_child); | 108 | EXPORT_SYMBOL(acpi_get_child); |
107 | 109 | ||
108 | static int acpi_bind_one(struct device *dev, acpi_handle handle) | 110 | int acpi_bind_one(struct device *dev, acpi_handle handle) |
109 | { | 111 | { |
110 | struct acpi_device *acpi_dev; | 112 | struct acpi_device *acpi_dev; |
111 | acpi_status status; | 113 | acpi_status status; |
@@ -188,8 +190,9 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle) | |||
188 | kfree(physical_node); | 190 | kfree(physical_node); |
189 | goto err; | 191 | goto err; |
190 | } | 192 | } |
193 | EXPORT_SYMBOL_GPL(acpi_bind_one); | ||
191 | 194 | ||
192 | static int acpi_unbind_one(struct device *dev) | 195 | int acpi_unbind_one(struct device *dev) |
193 | { | 196 | { |
194 | struct acpi_device_physical_node *entry; | 197 | struct acpi_device_physical_node *entry; |
195 | struct acpi_device *acpi_dev; | 198 | struct acpi_device *acpi_dev; |
@@ -238,6 +241,7 @@ err: | |||
238 | dev_err(dev, "Oops, 'acpi_handle' corrupt\n"); | 241 | dev_err(dev, "Oops, 'acpi_handle' corrupt\n"); |
239 | return -EINVAL; | 242 | return -EINVAL; |
240 | } | 243 | } |
244 | EXPORT_SYMBOL_GPL(acpi_unbind_one); | ||
241 | 245 | ||
242 | static int acpi_platform_notify(struct device *dev) | 246 | static int acpi_platform_notify(struct device *dev) |
243 | { | 247 | { |
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index c610a76d92c4..3a50a34fe176 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h | |||
@@ -33,6 +33,7 @@ static inline void acpi_pci_slot_init(void) { } | |||
33 | void acpi_pci_root_init(void); | 33 | void acpi_pci_root_init(void); |
34 | void acpi_pci_link_init(void); | 34 | void acpi_pci_link_init(void); |
35 | void acpi_pci_root_hp_init(void); | 35 | void acpi_pci_root_hp_init(void); |
36 | void acpi_processor_init(void); | ||
36 | void acpi_platform_init(void); | 37 | void acpi_platform_init(void); |
37 | int acpi_sysfs_init(void); | 38 | int acpi_sysfs_init(void); |
38 | #ifdef CONFIG_ACPI_CONTAINER | 39 | #ifdef CONFIG_ACPI_CONTAINER |
@@ -50,6 +51,13 @@ void acpi_memory_hotplug_init(void); | |||
50 | #else | 51 | #else |
51 | static inline void acpi_memory_hotplug_init(void) {} | 52 | static inline void acpi_memory_hotplug_init(void) {} |
52 | #endif | 53 | #endif |
54 | #ifdef CONFIG_X86 | ||
55 | void acpi_cmos_rtc_init(void); | ||
56 | #else | ||
57 | static inline void acpi_cmos_rtc_init(void) {} | ||
58 | #endif | ||
59 | |||
60 | extern bool acpi_force_hot_remove; | ||
53 | 61 | ||
54 | void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug, | 62 | void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug, |
55 | const char *name); | 63 | const char *name); |
@@ -81,6 +89,8 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, | |||
81 | int type, unsigned long long sta); | 89 | int type, unsigned long long sta); |
82 | void acpi_device_add_finalize(struct acpi_device *device); | 90 | void acpi_device_add_finalize(struct acpi_device *device); |
83 | void acpi_free_pnp_ids(struct acpi_device_pnp *pnp); | 91 | void acpi_free_pnp_ids(struct acpi_device_pnp *pnp); |
92 | int acpi_bind_one(struct device *dev, acpi_handle handle); | ||
93 | int acpi_unbind_one(struct device *dev); | ||
84 | 94 | ||
85 | /* -------------------------------------------------------------------------- | 95 | /* -------------------------------------------------------------------------- |
86 | Power Resource | 96 | Power Resource |
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index e72186340fec..6ab2c3505520 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
@@ -835,19 +835,9 @@ void acpi_os_stall(u32 us) | |||
835 | */ | 835 | */ |
836 | u64 acpi_os_get_timer(void) | 836 | u64 acpi_os_get_timer(void) |
837 | { | 837 | { |
838 | static u64 t; | 838 | u64 time_ns = ktime_to_ns(ktime_get()); |
839 | 839 | do_div(time_ns, 100); | |
840 | #ifdef CONFIG_HPET | 840 | return time_ns; |
841 | /* TBD: use HPET if available */ | ||
842 | #endif | ||
843 | |||
844 | #ifdef CONFIG_X86_PM_TIMER | ||
845 | /* TBD: default to PM timer if HPET was not available */ | ||
846 | #endif | ||
847 | if (!t) | ||
848 | printk(KERN_ERR PREFIX "acpi_os_get_timer() TBD\n"); | ||
849 | |||
850 | return ++t; | ||
851 | } | 841 | } |
852 | 842 | ||
853 | acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width) | 843 | acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width) |
@@ -1715,6 +1705,17 @@ acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object) | |||
1715 | } | 1705 | } |
1716 | #endif | 1706 | #endif |
1717 | 1707 | ||
1708 | static int __init acpi_no_auto_ssdt_setup(char *s) | ||
1709 | { | ||
1710 | printk(KERN_NOTICE PREFIX "SSDT auto-load disabled\n"); | ||
1711 | |||
1712 | acpi_gbl_disable_ssdt_table_load = TRUE; | ||
1713 | |||
1714 | return 1; | ||
1715 | } | ||
1716 | |||
1717 | __setup("acpi_no_auto_ssdt", acpi_no_auto_ssdt_setup); | ||
1718 | |||
1718 | acpi_status __init acpi_os_initialize(void) | 1719 | acpi_status __init acpi_os_initialize(void) |
1719 | { | 1720 | { |
1720 | acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1a_event_block); | 1721 | acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1a_event_block); |
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c index c266cdc11784..823be116619e 100644 --- a/drivers/acpi/processor_driver.c +++ b/drivers/acpi/processor_driver.c | |||
@@ -1,11 +1,13 @@ | |||
1 | /* | 1 | /* |
2 | * acpi_processor.c - ACPI Processor Driver ($Revision: 71 $) | 2 | * processor_driver.c - ACPI Processor Driver |
3 | * | 3 | * |
4 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> | 4 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> |
5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> | 5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> |
6 | * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de> | 6 | * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de> |
7 | * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | 7 | * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> |
8 | * - Added processor hotplug support | 8 | * - Added processor hotplug support |
9 | * Copyright (C) 2013, Intel Corporation | ||
10 | * Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
9 | * | 11 | * |
10 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 12 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
11 | * | 13 | * |
@@ -24,55 +26,26 @@ | |||
24 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | 26 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
25 | * | 27 | * |
26 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 28 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
27 | * TBD: | ||
28 | * 1. Make # power states dynamic. | ||
29 | * 2. Support duty_cycle values that span bit 4. | ||
30 | * 3. Optimize by having scheduler determine business instead of | ||
31 | * having us try to calculate it here. | ||
32 | * 4. Need C1 timing -- must modify kernel (IRQ handler) to get this. | ||
33 | */ | 29 | */ |
34 | 30 | ||
35 | #include <linux/kernel.h> | 31 | #include <linux/kernel.h> |
36 | #include <linux/module.h> | 32 | #include <linux/module.h> |
37 | #include <linux/init.h> | 33 | #include <linux/init.h> |
38 | #include <linux/types.h> | ||
39 | #include <linux/pci.h> | ||
40 | #include <linux/pm.h> | ||
41 | #include <linux/cpufreq.h> | 34 | #include <linux/cpufreq.h> |
42 | #include <linux/cpu.h> | 35 | #include <linux/cpu.h> |
43 | #include <linux/dmi.h> | ||
44 | #include <linux/moduleparam.h> | ||
45 | #include <linux/cpuidle.h> | 36 | #include <linux/cpuidle.h> |
46 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
47 | #include <linux/acpi.h> | 38 | #include <linux/acpi.h> |
48 | #include <linux/memory_hotplug.h> | 39 | |
49 | |||
50 | #include <asm/io.h> | ||
51 | #include <asm/cpu.h> | ||
52 | #include <asm/delay.h> | ||
53 | #include <asm/uaccess.h> | ||
54 | #include <asm/processor.h> | ||
55 | #include <asm/smp.h> | ||
56 | #include <asm/acpi.h> | ||
57 | |||
58 | #include <acpi/acpi_bus.h> | ||
59 | #include <acpi/acpi_drivers.h> | ||
60 | #include <acpi/processor.h> | 40 | #include <acpi/processor.h> |
61 | 41 | ||
42 | #include "internal.h" | ||
43 | |||
62 | #define PREFIX "ACPI: " | 44 | #define PREFIX "ACPI: " |
63 | 45 | ||
64 | #define ACPI_PROCESSOR_CLASS "processor" | ||
65 | #define ACPI_PROCESSOR_DEVICE_NAME "Processor" | ||
66 | #define ACPI_PROCESSOR_FILE_INFO "info" | ||
67 | #define ACPI_PROCESSOR_FILE_THROTTLING "throttling" | ||
68 | #define ACPI_PROCESSOR_FILE_LIMIT "limit" | ||
69 | #define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80 | 46 | #define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80 |
70 | #define ACPI_PROCESSOR_NOTIFY_POWER 0x81 | 47 | #define ACPI_PROCESSOR_NOTIFY_POWER 0x81 |
71 | #define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82 | 48 | #define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82 |
72 | #define ACPI_PROCESSOR_DEVICE_HID "ACPI0007" | ||
73 | |||
74 | #define ACPI_PROCESSOR_LIMIT_USER 0 | ||
75 | #define ACPI_PROCESSOR_LIMIT_THERMAL 1 | ||
76 | 49 | ||
77 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | 50 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
78 | ACPI_MODULE_NAME("processor_driver"); | 51 | ACPI_MODULE_NAME("processor_driver"); |
@@ -81,12 +54,8 @@ MODULE_AUTHOR("Paul Diefenbaugh"); | |||
81 | MODULE_DESCRIPTION("ACPI Processor Driver"); | 54 | MODULE_DESCRIPTION("ACPI Processor Driver"); |
82 | MODULE_LICENSE("GPL"); | 55 | MODULE_LICENSE("GPL"); |
83 | 56 | ||
84 | static int acpi_processor_add(struct acpi_device *device); | 57 | static int acpi_processor_start(struct device *dev); |
85 | static int acpi_processor_remove(struct acpi_device *device); | 58 | static int acpi_processor_stop(struct device *dev); |
86 | static void acpi_processor_notify(struct acpi_device *device, u32 event); | ||
87 | static acpi_status acpi_processor_hotadd_init(struct acpi_processor *pr); | ||
88 | static int acpi_processor_handle_eject(struct acpi_processor *pr); | ||
89 | static int acpi_processor_start(struct acpi_processor *pr); | ||
90 | 59 | ||
91 | static const struct acpi_device_id processor_device_ids[] = { | 60 | static const struct acpi_device_id processor_device_ids[] = { |
92 | {ACPI_PROCESSOR_OBJECT_HID, 0}, | 61 | {ACPI_PROCESSOR_OBJECT_HID, 0}, |
@@ -95,295 +64,24 @@ static const struct acpi_device_id processor_device_ids[] = { | |||
95 | }; | 64 | }; |
96 | MODULE_DEVICE_TABLE(acpi, processor_device_ids); | 65 | MODULE_DEVICE_TABLE(acpi, processor_device_ids); |
97 | 66 | ||
98 | static struct acpi_driver acpi_processor_driver = { | 67 | static struct device_driver acpi_processor_driver = { |
99 | .name = "processor", | 68 | .name = "processor", |
100 | .class = ACPI_PROCESSOR_CLASS, | 69 | .bus = &cpu_subsys, |
101 | .ids = processor_device_ids, | 70 | .acpi_match_table = processor_device_ids, |
102 | .ops = { | 71 | .probe = acpi_processor_start, |
103 | .add = acpi_processor_add, | 72 | .remove = acpi_processor_stop, |
104 | .remove = acpi_processor_remove, | ||
105 | .notify = acpi_processor_notify, | ||
106 | }, | ||
107 | }; | 73 | }; |
108 | 74 | ||
109 | #define INSTALL_NOTIFY_HANDLER 1 | 75 | static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) |
110 | #define UNINSTALL_NOTIFY_HANDLER 2 | ||
111 | |||
112 | DEFINE_PER_CPU(struct acpi_processor *, processors); | ||
113 | EXPORT_PER_CPU_SYMBOL(processors); | ||
114 | |||
115 | struct acpi_processor_errata errata __read_mostly; | ||
116 | |||
117 | /* -------------------------------------------------------------------------- | ||
118 | Errata Handling | ||
119 | -------------------------------------------------------------------------- */ | ||
120 | |||
121 | static int acpi_processor_errata_piix4(struct pci_dev *dev) | ||
122 | { | ||
123 | u8 value1 = 0; | ||
124 | u8 value2 = 0; | ||
125 | |||
126 | |||
127 | if (!dev) | ||
128 | return -EINVAL; | ||
129 | |||
130 | /* | ||
131 | * Note that 'dev' references the PIIX4 ACPI Controller. | ||
132 | */ | ||
133 | |||
134 | switch (dev->revision) { | ||
135 | case 0: | ||
136 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 A-step\n")); | ||
137 | break; | ||
138 | case 1: | ||
139 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4 B-step\n")); | ||
140 | break; | ||
141 | case 2: | ||
142 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4E\n")); | ||
143 | break; | ||
144 | case 3: | ||
145 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found PIIX4M\n")); | ||
146 | break; | ||
147 | default: | ||
148 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unknown PIIX4\n")); | ||
149 | break; | ||
150 | } | ||
151 | |||
152 | switch (dev->revision) { | ||
153 | |||
154 | case 0: /* PIIX4 A-step */ | ||
155 | case 1: /* PIIX4 B-step */ | ||
156 | /* | ||
157 | * See specification changes #13 ("Manual Throttle Duty Cycle") | ||
158 | * and #14 ("Enabling and Disabling Manual Throttle"), plus | ||
159 | * erratum #5 ("STPCLK# Deassertion Time") from the January | ||
160 | * 2002 PIIX4 specification update. Applies to only older | ||
161 | * PIIX4 models. | ||
162 | */ | ||
163 | errata.piix4.throttle = 1; | ||
164 | |||
165 | case 2: /* PIIX4E */ | ||
166 | case 3: /* PIIX4M */ | ||
167 | /* | ||
168 | * See erratum #18 ("C3 Power State/BMIDE and Type-F DMA | ||
169 | * Livelock") from the January 2002 PIIX4 specification update. | ||
170 | * Applies to all PIIX4 models. | ||
171 | */ | ||
172 | |||
173 | /* | ||
174 | * BM-IDE | ||
175 | * ------ | ||
176 | * Find the PIIX4 IDE Controller and get the Bus Master IDE | ||
177 | * Status register address. We'll use this later to read | ||
178 | * each IDE controller's DMA status to make sure we catch all | ||
179 | * DMA activity. | ||
180 | */ | ||
181 | dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, | ||
182 | PCI_DEVICE_ID_INTEL_82371AB, | ||
183 | PCI_ANY_ID, PCI_ANY_ID, NULL); | ||
184 | if (dev) { | ||
185 | errata.piix4.bmisx = pci_resource_start(dev, 4); | ||
186 | pci_dev_put(dev); | ||
187 | } | ||
188 | |||
189 | /* | ||
190 | * Type-F DMA | ||
191 | * ---------- | ||
192 | * Find the PIIX4 ISA Controller and read the Motherboard | ||
193 | * DMA controller's status to see if Type-F (Fast) DMA mode | ||
194 | * is enabled (bit 7) on either channel. Note that we'll | ||
195 | * disable C3 support if this is enabled, as some legacy | ||
196 | * devices won't operate well if fast DMA is disabled. | ||
197 | */ | ||
198 | dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, | ||
199 | PCI_DEVICE_ID_INTEL_82371AB_0, | ||
200 | PCI_ANY_ID, PCI_ANY_ID, NULL); | ||
201 | if (dev) { | ||
202 | pci_read_config_byte(dev, 0x76, &value1); | ||
203 | pci_read_config_byte(dev, 0x77, &value2); | ||
204 | if ((value1 & 0x80) || (value2 & 0x80)) | ||
205 | errata.piix4.fdma = 1; | ||
206 | pci_dev_put(dev); | ||
207 | } | ||
208 | |||
209 | break; | ||
210 | } | ||
211 | |||
212 | if (errata.piix4.bmisx) | ||
213 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
214 | "Bus master activity detection (BM-IDE) erratum enabled\n")); | ||
215 | if (errata.piix4.fdma) | ||
216 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
217 | "Type-F DMA livelock erratum (C3 disabled)\n")); | ||
218 | |||
219 | return 0; | ||
220 | } | ||
221 | |||
222 | static int acpi_processor_errata(struct acpi_processor *pr) | ||
223 | { | 76 | { |
224 | int result = 0; | 77 | struct acpi_device *device = data; |
225 | struct pci_dev *dev = NULL; | ||
226 | |||
227 | |||
228 | if (!pr) | ||
229 | return -EINVAL; | ||
230 | |||
231 | /* | ||
232 | * PIIX4 | ||
233 | */ | ||
234 | dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, | ||
235 | PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID, | ||
236 | PCI_ANY_ID, NULL); | ||
237 | if (dev) { | ||
238 | result = acpi_processor_errata_piix4(dev); | ||
239 | pci_dev_put(dev); | ||
240 | } | ||
241 | |||
242 | return result; | ||
243 | } | ||
244 | |||
245 | /* -------------------------------------------------------------------------- | ||
246 | Driver Interface | ||
247 | -------------------------------------------------------------------------- */ | ||
248 | |||
249 | static int acpi_processor_get_info(struct acpi_device *device) | ||
250 | { | ||
251 | acpi_status status = 0; | ||
252 | union acpi_object object = { 0 }; | ||
253 | struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; | ||
254 | struct acpi_processor *pr; | 78 | struct acpi_processor *pr; |
255 | int cpu_index, device_declaration = 0; | ||
256 | static int cpu0_initialized; | ||
257 | |||
258 | pr = acpi_driver_data(device); | ||
259 | if (!pr) | ||
260 | return -EINVAL; | ||
261 | |||
262 | if (num_online_cpus() > 1) | ||
263 | errata.smp = TRUE; | ||
264 | |||
265 | acpi_processor_errata(pr); | ||
266 | |||
267 | /* | ||
268 | * Check to see if we have bus mastering arbitration control. This | ||
269 | * is required for proper C3 usage (to maintain cache coherency). | ||
270 | */ | ||
271 | if (acpi_gbl_FADT.pm2_control_block && acpi_gbl_FADT.pm2_control_length) { | ||
272 | pr->flags.bm_control = 1; | ||
273 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
274 | "Bus mastering arbitration control present\n")); | ||
275 | } else | ||
276 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
277 | "No bus mastering arbitration control\n")); | ||
278 | |||
279 | if (!strcmp(acpi_device_hid(device), ACPI_PROCESSOR_OBJECT_HID)) { | ||
280 | /* Declared with "Processor" statement; match ProcessorID */ | ||
281 | status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); | ||
282 | if (ACPI_FAILURE(status)) { | ||
283 | dev_err(&device->dev, | ||
284 | "Failed to evaluate processor object (0x%x)\n", | ||
285 | status); | ||
286 | return -ENODEV; | ||
287 | } | ||
288 | |||
289 | /* | ||
290 | * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP. | ||
291 | * >>> 'acpi_get_processor_id(acpi_id, &id)' in | ||
292 | * arch/xxx/acpi.c | ||
293 | */ | ||
294 | pr->acpi_id = object.processor.proc_id; | ||
295 | } else { | ||
296 | /* | ||
297 | * Declared with "Device" statement; match _UID. | ||
298 | * Note that we don't handle string _UIDs yet. | ||
299 | */ | ||
300 | unsigned long long value; | ||
301 | status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID, | ||
302 | NULL, &value); | ||
303 | if (ACPI_FAILURE(status)) { | ||
304 | dev_err(&device->dev, | ||
305 | "Failed to evaluate processor _UID (0x%x)\n", | ||
306 | status); | ||
307 | return -ENODEV; | ||
308 | } | ||
309 | device_declaration = 1; | ||
310 | pr->acpi_id = value; | ||
311 | } | ||
312 | cpu_index = acpi_get_cpuid(pr->handle, device_declaration, pr->acpi_id); | ||
313 | |||
314 | /* Handle UP system running SMP kernel, with no LAPIC in MADT */ | ||
315 | if (!cpu0_initialized && (cpu_index == -1) && | ||
316 | (num_online_cpus() == 1)) { | ||
317 | cpu_index = 0; | ||
318 | } | ||
319 | |||
320 | cpu0_initialized = 1; | ||
321 | |||
322 | pr->id = cpu_index; | ||
323 | |||
324 | /* | ||
325 | * Extra Processor objects may be enumerated on MP systems with | ||
326 | * less than the max # of CPUs. They should be ignored _iff | ||
327 | * they are physically not present. | ||
328 | */ | ||
329 | if (pr->id == -1) { | ||
330 | if (ACPI_FAILURE(acpi_processor_hotadd_init(pr))) | ||
331 | return -ENODEV; | ||
332 | } | ||
333 | /* | ||
334 | * On some boxes several processors use the same processor bus id. | ||
335 | * But they are located in different scope. For example: | ||
336 | * \_SB.SCK0.CPU0 | ||
337 | * \_SB.SCK1.CPU0 | ||
338 | * Rename the processor device bus id. And the new bus id will be | ||
339 | * generated as the following format: | ||
340 | * CPU+CPU ID. | ||
341 | */ | ||
342 | sprintf(acpi_device_bid(device), "CPU%X", pr->id); | ||
343 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id, | ||
344 | pr->acpi_id)); | ||
345 | |||
346 | if (!object.processor.pblk_address) | ||
347 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n")); | ||
348 | else if (object.processor.pblk_length != 6) | ||
349 | dev_err(&device->dev, "Invalid PBLK length [%d]\n", | ||
350 | object.processor.pblk_length); | ||
351 | else { | ||
352 | pr->throttling.address = object.processor.pblk_address; | ||
353 | pr->throttling.duty_offset = acpi_gbl_FADT.duty_offset; | ||
354 | pr->throttling.duty_width = acpi_gbl_FADT.duty_width; | ||
355 | |||
356 | pr->pblk = object.processor.pblk_address; | ||
357 | |||
358 | /* | ||
359 | * We don't care about error returns - we just try to mark | ||
360 | * these reserved so that nobody else is confused into thinking | ||
361 | * that this region might be unused.. | ||
362 | * | ||
363 | * (In particular, allocating the IO range for Cardbus) | ||
364 | */ | ||
365 | request_region(pr->throttling.address, 6, "ACPI CPU throttle"); | ||
366 | } | ||
367 | |||
368 | /* | ||
369 | * If ACPI describes a slot number for this CPU, we can use it | ||
370 | * ensure we get the right value in the "physical id" field | ||
371 | * of /proc/cpuinfo | ||
372 | */ | ||
373 | status = acpi_evaluate_object(pr->handle, "_SUN", NULL, &buffer); | ||
374 | if (ACPI_SUCCESS(status)) | ||
375 | arch_fix_phys_package_id(pr->id, object.integer.value); | ||
376 | |||
377 | return 0; | ||
378 | } | ||
379 | |||
380 | static DEFINE_PER_CPU(void *, processor_device_array); | ||
381 | |||
382 | static void acpi_processor_notify(struct acpi_device *device, u32 event) | ||
383 | { | ||
384 | struct acpi_processor *pr = acpi_driver_data(device); | ||
385 | int saved; | 79 | int saved; |
386 | 80 | ||
81 | if (device->handle != handle) | ||
82 | return; | ||
83 | |||
84 | pr = acpi_driver_data(device); | ||
387 | if (!pr) | 85 | if (!pr) |
388 | return; | 86 | return; |
389 | 87 | ||
@@ -420,55 +118,62 @@ static void acpi_processor_notify(struct acpi_device *device, u32 event) | |||
420 | return; | 118 | return; |
421 | } | 119 | } |
422 | 120 | ||
423 | static int acpi_cpu_soft_notify(struct notifier_block *nfb, | 121 | static __cpuinit int __acpi_processor_start(struct acpi_device *device); |
424 | unsigned long action, void *hcpu) | 122 | |
123 | static int __cpuinit acpi_cpu_soft_notify(struct notifier_block *nfb, | ||
124 | unsigned long action, void *hcpu) | ||
425 | { | 125 | { |
426 | unsigned int cpu = (unsigned long)hcpu; | 126 | unsigned int cpu = (unsigned long)hcpu; |
427 | struct acpi_processor *pr = per_cpu(processors, cpu); | 127 | struct acpi_processor *pr = per_cpu(processors, cpu); |
128 | struct acpi_device *device; | ||
129 | |||
130 | if (!pr || acpi_bus_get_device(pr->handle, &device)) | ||
131 | return NOTIFY_DONE; | ||
428 | 132 | ||
429 | if (action == CPU_ONLINE && pr) { | 133 | if (action == CPU_ONLINE) { |
430 | /* CPU got physically hotplugged and onlined the first time: | 134 | /* |
431 | * Initialize missing things | 135 | * CPU got physically hotplugged and onlined for the first time: |
136 | * Initialize missing things. | ||
432 | */ | 137 | */ |
433 | if (pr->flags.need_hotplug_init) { | 138 | if (pr->flags.need_hotplug_init) { |
139 | int ret; | ||
140 | |||
434 | pr_info("Will online and init hotplugged CPU: %d\n", | 141 | pr_info("Will online and init hotplugged CPU: %d\n", |
435 | pr->id); | 142 | pr->id); |
436 | WARN(acpi_processor_start(pr), "Failed to start CPU:" | ||
437 | " %d\n", pr->id); | ||
438 | pr->flags.need_hotplug_init = 0; | 143 | pr->flags.need_hotplug_init = 0; |
439 | /* Normal CPU soft online event */ | 144 | ret = __acpi_processor_start(device); |
145 | WARN(ret, "Failed to start CPU: %d\n", pr->id); | ||
440 | } else { | 146 | } else { |
147 | /* Normal CPU soft online event. */ | ||
441 | acpi_processor_ppc_has_changed(pr, 0); | 148 | acpi_processor_ppc_has_changed(pr, 0); |
442 | acpi_processor_hotplug(pr); | 149 | acpi_processor_hotplug(pr); |
443 | acpi_processor_reevaluate_tstate(pr, action); | 150 | acpi_processor_reevaluate_tstate(pr, action); |
444 | acpi_processor_tstate_has_changed(pr); | 151 | acpi_processor_tstate_has_changed(pr); |
445 | } | 152 | } |
446 | } | 153 | } else if (action == CPU_DEAD) { |
447 | if (action == CPU_DEAD && pr) { | 154 | /* Invalidate flag.throttling after the CPU is offline. */ |
448 | /* invalidate the flag.throttling after one CPU is offline */ | ||
449 | acpi_processor_reevaluate_tstate(pr, action); | 155 | acpi_processor_reevaluate_tstate(pr, action); |
450 | } | 156 | } |
451 | return NOTIFY_OK; | 157 | return NOTIFY_OK; |
452 | } | 158 | } |
453 | 159 | ||
454 | static struct notifier_block acpi_cpu_notifier = | 160 | static struct notifier_block __refdata acpi_cpu_notifier = |
455 | { | 161 | { |
456 | .notifier_call = acpi_cpu_soft_notify, | 162 | .notifier_call = acpi_cpu_soft_notify, |
457 | }; | 163 | }; |
458 | 164 | ||
459 | /* | 165 | static __cpuinit int __acpi_processor_start(struct acpi_device *device) |
460 | * acpi_processor_start() is called by the cpu_hotplug_notifier func: | ||
461 | * acpi_cpu_soft_notify(). Getting it __cpuinit{data} is difficult, the | ||
462 | * root cause seem to be that acpi_processor_uninstall_hotplug_notify() | ||
463 | * is in the module_exit (__exit) func. Allowing acpi_processor_start() | ||
464 | * to not be in __cpuinit section, but being called from __cpuinit funcs | ||
465 | * via __ref looks like the right thing to do here. | ||
466 | */ | ||
467 | static __ref int acpi_processor_start(struct acpi_processor *pr) | ||
468 | { | 166 | { |
469 | struct acpi_device *device = per_cpu(processor_device_array, pr->id); | 167 | struct acpi_processor *pr = acpi_driver_data(device); |
168 | acpi_status status; | ||
470 | int result = 0; | 169 | int result = 0; |
471 | 170 | ||
171 | if (!pr) | ||
172 | return -ENODEV; | ||
173 | |||
174 | if (pr->flags.need_hotplug_init) | ||
175 | return 0; | ||
176 | |||
472 | #ifdef CONFIG_CPU_FREQ | 177 | #ifdef CONFIG_CPU_FREQ |
473 | acpi_processor_ppc_has_changed(pr, 0); | 178 | acpi_processor_ppc_has_changed(pr, 0); |
474 | acpi_processor_load_module(pr); | 179 | acpi_processor_load_module(pr); |
@@ -506,462 +211,95 @@ static __ref int acpi_processor_start(struct acpi_processor *pr) | |||
506 | goto err_remove_sysfs_thermal; | 211 | goto err_remove_sysfs_thermal; |
507 | } | 212 | } |
508 | 213 | ||
509 | return 0; | 214 | status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, |
215 | acpi_processor_notify, device); | ||
216 | if (ACPI_SUCCESS(status)) | ||
217 | return 0; | ||
510 | 218 | ||
511 | err_remove_sysfs_thermal: | 219 | sysfs_remove_link(&pr->cdev->device.kobj, "device"); |
220 | err_remove_sysfs_thermal: | ||
512 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); | 221 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); |
513 | err_thermal_unregister: | 222 | err_thermal_unregister: |
514 | thermal_cooling_device_unregister(pr->cdev); | 223 | thermal_cooling_device_unregister(pr->cdev); |
515 | err_power_exit: | 224 | err_power_exit: |
516 | acpi_processor_power_exit(pr); | 225 | acpi_processor_power_exit(pr); |
517 | |||
518 | return result; | 226 | return result; |
519 | } | 227 | } |
520 | 228 | ||
521 | /* | 229 | static int __cpuinit acpi_processor_start(struct device *dev) |
522 | * Do not put anything in here which needs the core to be online. | ||
523 | * For example MSR access or setting up things which check for cpuinfo_x86 | ||
524 | * (cpu_data(cpu)) values, like CPU feature flags, family, model, etc. | ||
525 | * Such things have to be put in and set up above in acpi_processor_start() | ||
526 | */ | ||
527 | static int __cpuinit acpi_processor_add(struct acpi_device *device) | ||
528 | { | 230 | { |
529 | struct acpi_processor *pr = NULL; | 231 | struct acpi_device *device; |
530 | int result = 0; | ||
531 | struct device *dev; | ||
532 | |||
533 | pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL); | ||
534 | if (!pr) | ||
535 | return -ENOMEM; | ||
536 | |||
537 | if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) { | ||
538 | result = -ENOMEM; | ||
539 | goto err_free_pr; | ||
540 | } | ||
541 | |||
542 | pr->handle = device->handle; | ||
543 | strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); | ||
544 | strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); | ||
545 | device->driver_data = pr; | ||
546 | |||
547 | result = acpi_processor_get_info(device); | ||
548 | if (result) { | ||
549 | /* Processor is physically not present */ | ||
550 | return 0; | ||
551 | } | ||
552 | 232 | ||
553 | #ifdef CONFIG_SMP | 233 | if (acpi_bus_get_device(ACPI_HANDLE(dev), &device)) |
554 | if (pr->id >= setup_max_cpus && pr->id != 0) | 234 | return -ENODEV; |
555 | return 0; | ||
556 | #endif | ||
557 | |||
558 | BUG_ON(pr->id >= nr_cpu_ids); | ||
559 | |||
560 | /* | ||
561 | * Buggy BIOS check | ||
562 | * ACPI id of processors can be reported wrongly by the BIOS. | ||
563 | * Don't trust it blindly | ||
564 | */ | ||
565 | if (per_cpu(processor_device_array, pr->id) != NULL && | ||
566 | per_cpu(processor_device_array, pr->id) != device) { | ||
567 | dev_warn(&device->dev, | ||
568 | "BIOS reported wrong ACPI id %d for the processor\n", | ||
569 | pr->id); | ||
570 | result = -ENODEV; | ||
571 | goto err_free_cpumask; | ||
572 | } | ||
573 | per_cpu(processor_device_array, pr->id) = device; | ||
574 | 235 | ||
575 | per_cpu(processors, pr->id) = pr; | 236 | return __acpi_processor_start(device); |
576 | |||
577 | dev = get_cpu_device(pr->id); | ||
578 | if (sysfs_create_link(&device->dev.kobj, &dev->kobj, "sysdev")) { | ||
579 | result = -EFAULT; | ||
580 | goto err_clear_processor; | ||
581 | } | ||
582 | |||
583 | /* | ||
584 | * Do not start hotplugged CPUs now, but when they | ||
585 | * are onlined the first time | ||
586 | */ | ||
587 | if (pr->flags.need_hotplug_init) | ||
588 | return 0; | ||
589 | |||
590 | result = acpi_processor_start(pr); | ||
591 | if (result) | ||
592 | goto err_remove_sysfs; | ||
593 | |||
594 | return 0; | ||
595 | |||
596 | err_remove_sysfs: | ||
597 | sysfs_remove_link(&device->dev.kobj, "sysdev"); | ||
598 | err_clear_processor: | ||
599 | /* | ||
600 | * processor_device_array is not cleared to allow checks for buggy BIOS | ||
601 | */ | ||
602 | per_cpu(processors, pr->id) = NULL; | ||
603 | err_free_cpumask: | ||
604 | free_cpumask_var(pr->throttling.shared_cpu_map); | ||
605 | err_free_pr: | ||
606 | kfree(pr); | ||
607 | return result; | ||
608 | } | 237 | } |
609 | 238 | ||
610 | static int acpi_processor_remove(struct acpi_device *device) | 239 | static int acpi_processor_stop(struct device *dev) |
611 | { | 240 | { |
612 | struct acpi_processor *pr = NULL; | 241 | struct acpi_device *device; |
242 | struct acpi_processor *pr; | ||
613 | 243 | ||
244 | if (acpi_bus_get_device(ACPI_HANDLE(dev), &device)) | ||
245 | return 0; | ||
614 | 246 | ||
615 | if (!device || !acpi_driver_data(device)) | 247 | acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, |
616 | return -EINVAL; | 248 | acpi_processor_notify); |
617 | 249 | ||
618 | pr = acpi_driver_data(device); | 250 | pr = acpi_driver_data(device); |
619 | 251 | if (!pr) | |
620 | if (pr->id >= nr_cpu_ids) | 252 | return 0; |
621 | goto free; | ||
622 | |||
623 | if (device->removal_type == ACPI_BUS_REMOVAL_EJECT) { | ||
624 | if (acpi_processor_handle_eject(pr)) | ||
625 | return -EINVAL; | ||
626 | } | ||
627 | 253 | ||
628 | acpi_processor_power_exit(pr); | 254 | acpi_processor_power_exit(pr); |
629 | 255 | ||
630 | sysfs_remove_link(&device->dev.kobj, "sysdev"); | ||
631 | |||
632 | if (pr->cdev) { | 256 | if (pr->cdev) { |
633 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); | 257 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); |
634 | sysfs_remove_link(&pr->cdev->device.kobj, "device"); | 258 | sysfs_remove_link(&pr->cdev->device.kobj, "device"); |
635 | thermal_cooling_device_unregister(pr->cdev); | 259 | thermal_cooling_device_unregister(pr->cdev); |
636 | pr->cdev = NULL; | 260 | pr->cdev = NULL; |
637 | } | 261 | } |
638 | |||
639 | per_cpu(processors, pr->id) = NULL; | ||
640 | per_cpu(processor_device_array, pr->id) = NULL; | ||
641 | try_offline_node(cpu_to_node(pr->id)); | ||
642 | |||
643 | free: | ||
644 | free_cpumask_var(pr->throttling.shared_cpu_map); | ||
645 | kfree(pr); | ||
646 | |||
647 | return 0; | 262 | return 0; |
648 | } | 263 | } |
649 | 264 | ||
650 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | ||
651 | /**************************************************************************** | ||
652 | * Acpi processor hotplug support * | ||
653 | ****************************************************************************/ | ||
654 | |||
655 | static int is_processor_present(acpi_handle handle) | ||
656 | { | ||
657 | acpi_status status; | ||
658 | unsigned long long sta = 0; | ||
659 | |||
660 | |||
661 | status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); | ||
662 | |||
663 | if (ACPI_SUCCESS(status) && (sta & ACPI_STA_DEVICE_PRESENT)) | ||
664 | return 1; | ||
665 | |||
666 | /* | ||
667 | * _STA is mandatory for a processor that supports hot plug | ||
668 | */ | ||
669 | if (status == AE_NOT_FOUND) | ||
670 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
671 | "Processor does not support hot plug\n")); | ||
672 | else | ||
673 | ACPI_EXCEPTION((AE_INFO, status, | ||
674 | "Processor Device is not present")); | ||
675 | return 0; | ||
676 | } | ||
677 | |||
678 | static void acpi_processor_hotplug_notify(acpi_handle handle, | ||
679 | u32 event, void *data) | ||
680 | { | ||
681 | struct acpi_device *device = NULL; | ||
682 | struct acpi_eject_event *ej_event = NULL; | ||
683 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ | ||
684 | acpi_status status; | ||
685 | int result; | ||
686 | |||
687 | acpi_scan_lock_acquire(); | ||
688 | |||
689 | switch (event) { | ||
690 | case ACPI_NOTIFY_BUS_CHECK: | ||
691 | case ACPI_NOTIFY_DEVICE_CHECK: | ||
692 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
693 | "Processor driver received %s event\n", | ||
694 | (event == ACPI_NOTIFY_BUS_CHECK) ? | ||
695 | "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK")); | ||
696 | |||
697 | if (!is_processor_present(handle)) | ||
698 | break; | ||
699 | |||
700 | if (!acpi_bus_get_device(handle, &device)) | ||
701 | break; | ||
702 | |||
703 | result = acpi_bus_scan(handle); | ||
704 | if (result) { | ||
705 | acpi_handle_err(handle, "Unable to add the device\n"); | ||
706 | break; | ||
707 | } | ||
708 | result = acpi_bus_get_device(handle, &device); | ||
709 | if (result) { | ||
710 | acpi_handle_err(handle, "Missing device object\n"); | ||
711 | break; | ||
712 | } | ||
713 | ost_code = ACPI_OST_SC_SUCCESS; | ||
714 | break; | ||
715 | |||
716 | case ACPI_NOTIFY_EJECT_REQUEST: | ||
717 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
718 | "received ACPI_NOTIFY_EJECT_REQUEST\n")); | ||
719 | |||
720 | if (acpi_bus_get_device(handle, &device)) { | ||
721 | acpi_handle_err(handle, | ||
722 | "Device don't exist, dropping EJECT\n"); | ||
723 | break; | ||
724 | } | ||
725 | if (!acpi_driver_data(device)) { | ||
726 | acpi_handle_err(handle, | ||
727 | "Driver data is NULL, dropping EJECT\n"); | ||
728 | break; | ||
729 | } | ||
730 | |||
731 | ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL); | ||
732 | if (!ej_event) { | ||
733 | acpi_handle_err(handle, "No memory, dropping EJECT\n"); | ||
734 | break; | ||
735 | } | ||
736 | |||
737 | get_device(&device->dev); | ||
738 | ej_event->device = device; | ||
739 | ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; | ||
740 | /* The eject is carried out asynchronously. */ | ||
741 | status = acpi_os_hotplug_execute(acpi_bus_hot_remove_device, | ||
742 | ej_event); | ||
743 | if (ACPI_FAILURE(status)) { | ||
744 | put_device(&device->dev); | ||
745 | kfree(ej_event); | ||
746 | break; | ||
747 | } | ||
748 | goto out; | ||
749 | |||
750 | default: | ||
751 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
752 | "Unsupported event [0x%x]\n", event)); | ||
753 | |||
754 | /* non-hotplug event; possibly handled by other handler */ | ||
755 | goto out; | ||
756 | } | ||
757 | |||
758 | /* Inform firmware that the hotplug operation has completed */ | ||
759 | (void) acpi_evaluate_hotplug_ost(handle, event, ost_code, NULL); | ||
760 | |||
761 | out: | ||
762 | acpi_scan_lock_release(); | ||
763 | } | ||
764 | |||
765 | static acpi_status is_processor_device(acpi_handle handle) | ||
766 | { | ||
767 | struct acpi_device_info *info; | ||
768 | char *hid; | ||
769 | acpi_status status; | ||
770 | |||
771 | status = acpi_get_object_info(handle, &info); | ||
772 | if (ACPI_FAILURE(status)) | ||
773 | return status; | ||
774 | |||
775 | if (info->type == ACPI_TYPE_PROCESSOR) { | ||
776 | kfree(info); | ||
777 | return AE_OK; /* found a processor object */ | ||
778 | } | ||
779 | |||
780 | if (!(info->valid & ACPI_VALID_HID)) { | ||
781 | kfree(info); | ||
782 | return AE_ERROR; | ||
783 | } | ||
784 | |||
785 | hid = info->hardware_id.string; | ||
786 | if ((hid == NULL) || strcmp(hid, ACPI_PROCESSOR_DEVICE_HID)) { | ||
787 | kfree(info); | ||
788 | return AE_ERROR; | ||
789 | } | ||
790 | |||
791 | kfree(info); | ||
792 | return AE_OK; /* found a processor device object */ | ||
793 | } | ||
794 | |||
795 | static acpi_status | ||
796 | processor_walk_namespace_cb(acpi_handle handle, | ||
797 | u32 lvl, void *context, void **rv) | ||
798 | { | ||
799 | acpi_status status; | ||
800 | int *action = context; | ||
801 | |||
802 | status = is_processor_device(handle); | ||
803 | if (ACPI_FAILURE(status)) | ||
804 | return AE_OK; /* not a processor; continue to walk */ | ||
805 | |||
806 | switch (*action) { | ||
807 | case INSTALL_NOTIFY_HANDLER: | ||
808 | acpi_install_notify_handler(handle, | ||
809 | ACPI_SYSTEM_NOTIFY, | ||
810 | acpi_processor_hotplug_notify, | ||
811 | NULL); | ||
812 | break; | ||
813 | case UNINSTALL_NOTIFY_HANDLER: | ||
814 | acpi_remove_notify_handler(handle, | ||
815 | ACPI_SYSTEM_NOTIFY, | ||
816 | acpi_processor_hotplug_notify); | ||
817 | break; | ||
818 | default: | ||
819 | break; | ||
820 | } | ||
821 | |||
822 | /* found a processor; skip walking underneath */ | ||
823 | return AE_CTRL_DEPTH; | ||
824 | } | ||
825 | |||
826 | static acpi_status acpi_processor_hotadd_init(struct acpi_processor *pr) | ||
827 | { | ||
828 | acpi_handle handle = pr->handle; | ||
829 | |||
830 | if (!is_processor_present(handle)) { | ||
831 | return AE_ERROR; | ||
832 | } | ||
833 | |||
834 | if (acpi_map_lsapic(handle, &pr->id)) | ||
835 | return AE_ERROR; | ||
836 | |||
837 | if (arch_register_cpu(pr->id)) { | ||
838 | acpi_unmap_lsapic(pr->id); | ||
839 | return AE_ERROR; | ||
840 | } | ||
841 | |||
842 | /* CPU got hot-plugged, but cpu_data is not initialized yet | ||
843 | * Set flag to delay cpu_idle/throttling initialization | ||
844 | * in: | ||
845 | * acpi_processor_add() | ||
846 | * acpi_processor_get_info() | ||
847 | * and do it when the CPU gets online the first time | ||
848 | * TBD: Cleanup above functions and try to do this more elegant. | ||
849 | */ | ||
850 | pr_info("CPU %d got hotplugged\n", pr->id); | ||
851 | pr->flags.need_hotplug_init = 1; | ||
852 | |||
853 | return AE_OK; | ||
854 | } | ||
855 | |||
856 | static int acpi_processor_handle_eject(struct acpi_processor *pr) | ||
857 | { | ||
858 | if (cpu_online(pr->id)) | ||
859 | cpu_down(pr->id); | ||
860 | |||
861 | get_online_cpus(); | ||
862 | /* | ||
863 | * The cpu might become online again at this point. So we check whether | ||
864 | * the cpu has been onlined or not. If the cpu became online, it means | ||
865 | * that someone wants to use the cpu. So acpi_processor_handle_eject() | ||
866 | * returns -EAGAIN. | ||
867 | */ | ||
868 | if (unlikely(cpu_online(pr->id))) { | ||
869 | put_online_cpus(); | ||
870 | pr_warn("Failed to remove CPU %d, because other task " | ||
871 | "brought the CPU back online\n", pr->id); | ||
872 | return -EAGAIN; | ||
873 | } | ||
874 | arch_unregister_cpu(pr->id); | ||
875 | acpi_unmap_lsapic(pr->id); | ||
876 | put_online_cpus(); | ||
877 | return (0); | ||
878 | } | ||
879 | #else | ||
880 | static acpi_status acpi_processor_hotadd_init(struct acpi_processor *pr) | ||
881 | { | ||
882 | return AE_ERROR; | ||
883 | } | ||
884 | static int acpi_processor_handle_eject(struct acpi_processor *pr) | ||
885 | { | ||
886 | return (-EINVAL); | ||
887 | } | ||
888 | #endif | ||
889 | |||
890 | static | ||
891 | void acpi_processor_install_hotplug_notify(void) | ||
892 | { | ||
893 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | ||
894 | int action = INSTALL_NOTIFY_HANDLER; | ||
895 | acpi_walk_namespace(ACPI_TYPE_ANY, | ||
896 | ACPI_ROOT_OBJECT, | ||
897 | ACPI_UINT32_MAX, | ||
898 | processor_walk_namespace_cb, NULL, &action, NULL); | ||
899 | #endif | ||
900 | register_hotcpu_notifier(&acpi_cpu_notifier); | ||
901 | } | ||
902 | |||
903 | static | ||
904 | void acpi_processor_uninstall_hotplug_notify(void) | ||
905 | { | ||
906 | #ifdef CONFIG_ACPI_HOTPLUG_CPU | ||
907 | int action = UNINSTALL_NOTIFY_HANDLER; | ||
908 | acpi_walk_namespace(ACPI_TYPE_ANY, | ||
909 | ACPI_ROOT_OBJECT, | ||
910 | ACPI_UINT32_MAX, | ||
911 | processor_walk_namespace_cb, NULL, &action, NULL); | ||
912 | #endif | ||
913 | unregister_hotcpu_notifier(&acpi_cpu_notifier); | ||
914 | } | ||
915 | |||
916 | /* | 265 | /* |
917 | * We keep the driver loaded even when ACPI is not running. | 266 | * We keep the driver loaded even when ACPI is not running. |
918 | * This is needed for the powernow-k8 driver, that works even without | 267 | * This is needed for the powernow-k8 driver, that works even without |
919 | * ACPI, but needs symbols from this driver | 268 | * ACPI, but needs symbols from this driver |
920 | */ | 269 | */ |
921 | 270 | ||
922 | static int __init acpi_processor_init(void) | 271 | static int __init acpi_processor_driver_init(void) |
923 | { | 272 | { |
924 | int result = 0; | 273 | int result = 0; |
925 | 274 | ||
926 | if (acpi_disabled) | 275 | if (acpi_disabled) |
927 | return 0; | 276 | return 0; |
928 | 277 | ||
929 | result = acpi_bus_register_driver(&acpi_processor_driver); | 278 | result = driver_register(&acpi_processor_driver); |
930 | if (result < 0) | 279 | if (result < 0) |
931 | return result; | 280 | return result; |
932 | 281 | ||
933 | acpi_processor_syscore_init(); | 282 | acpi_processor_syscore_init(); |
934 | 283 | register_hotcpu_notifier(&acpi_cpu_notifier); | |
935 | acpi_processor_install_hotplug_notify(); | ||
936 | |||
937 | acpi_thermal_cpufreq_init(); | 284 | acpi_thermal_cpufreq_init(); |
938 | |||
939 | acpi_processor_ppc_init(); | 285 | acpi_processor_ppc_init(); |
940 | |||
941 | acpi_processor_throttling_init(); | 286 | acpi_processor_throttling_init(); |
942 | |||
943 | return 0; | 287 | return 0; |
944 | } | 288 | } |
945 | 289 | ||
946 | static void __exit acpi_processor_exit(void) | 290 | static void __exit acpi_processor_driver_exit(void) |
947 | { | 291 | { |
948 | if (acpi_disabled) | 292 | if (acpi_disabled) |
949 | return; | 293 | return; |
950 | 294 | ||
951 | acpi_processor_ppc_exit(); | 295 | acpi_processor_ppc_exit(); |
952 | |||
953 | acpi_thermal_cpufreq_exit(); | 296 | acpi_thermal_cpufreq_exit(); |
954 | 297 | unregister_hotcpu_notifier(&acpi_cpu_notifier); | |
955 | acpi_processor_uninstall_hotplug_notify(); | ||
956 | |||
957 | acpi_processor_syscore_exit(); | 298 | acpi_processor_syscore_exit(); |
958 | 299 | driver_unregister(&acpi_processor_driver); | |
959 | acpi_bus_unregister_driver(&acpi_processor_driver); | ||
960 | |||
961 | return; | ||
962 | } | 300 | } |
963 | 301 | ||
964 | module_init(acpi_processor_init); | 302 | module_init(acpi_processor_driver_init); |
965 | module_exit(acpi_processor_exit); | 303 | module_exit(acpi_processor_driver_exit); |
966 | 304 | ||
967 | MODULE_ALIAS("processor"); | 305 | MODULE_ALIAS("processor"); |
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index eb133c77aadb..0461ccc92c54 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -214,13 +214,13 @@ static void lapic_timer_state_broadcast(struct acpi_processor *pr, | |||
214 | #ifdef CONFIG_PM_SLEEP | 214 | #ifdef CONFIG_PM_SLEEP |
215 | static u32 saved_bm_rld; | 215 | static u32 saved_bm_rld; |
216 | 216 | ||
217 | int acpi_processor_suspend(void) | 217 | static int acpi_processor_suspend(void) |
218 | { | 218 | { |
219 | acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &saved_bm_rld); | 219 | acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &saved_bm_rld); |
220 | return 0; | 220 | return 0; |
221 | } | 221 | } |
222 | 222 | ||
223 | void acpi_processor_resume(void) | 223 | static void acpi_processor_resume(void) |
224 | { | 224 | { |
225 | u32 resumed_bm_rld; | 225 | u32 resumed_bm_rld; |
226 | 226 | ||
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index e854582f29a6..1e9732d809bf 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c | |||
@@ -639,7 +639,7 @@ end: | |||
639 | int acpi_processor_preregister_performance( | 639 | int acpi_processor_preregister_performance( |
640 | struct acpi_processor_performance __percpu *performance) | 640 | struct acpi_processor_performance __percpu *performance) |
641 | { | 641 | { |
642 | int count, count_target; | 642 | int count_target; |
643 | int retval = 0; | 643 | int retval = 0; |
644 | unsigned int i, j; | 644 | unsigned int i, j; |
645 | cpumask_var_t covered_cpus; | 645 | cpumask_var_t covered_cpus; |
@@ -711,7 +711,6 @@ int acpi_processor_preregister_performance( | |||
711 | 711 | ||
712 | /* Validate the Domain info */ | 712 | /* Validate the Domain info */ |
713 | count_target = pdomain->num_processors; | 713 | count_target = pdomain->num_processors; |
714 | count = 1; | ||
715 | if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL) | 714 | if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL) |
716 | pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL; | 715 | pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL; |
717 | else if (pdomain->coord_type == DOMAIN_COORD_TYPE_HW_ALL) | 716 | else if (pdomain->coord_type == DOMAIN_COORD_TYPE_HW_ALL) |
@@ -745,7 +744,6 @@ int acpi_processor_preregister_performance( | |||
745 | 744 | ||
746 | cpumask_set_cpu(j, covered_cpus); | 745 | cpumask_set_cpu(j, covered_cpus); |
747 | cpumask_set_cpu(j, pr->performance->shared_cpu_map); | 746 | cpumask_set_cpu(j, pr->performance->shared_cpu_map); |
748 | count++; | ||
749 | } | 747 | } |
750 | 748 | ||
751 | for_each_possible_cpu(j) { | 749 | for_each_possible_cpu(j) { |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 27da63061e11..dfe76f17cfc4 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -27,6 +27,12 @@ extern struct acpi_device *acpi_root; | |||
27 | 27 | ||
28 | #define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent) | 28 | #define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent) |
29 | 29 | ||
30 | /* | ||
31 | * If set, devices will be hot-removed even if they cannot be put offline | ||
32 | * gracefully (from the kernel's standpoint). | ||
33 | */ | ||
34 | bool acpi_force_hot_remove; | ||
35 | |||
30 | static const char *dummy_hid = "device"; | 36 | static const char *dummy_hid = "device"; |
31 | 37 | ||
32 | static LIST_HEAD(acpi_device_list); | 38 | static LIST_HEAD(acpi_device_list); |
@@ -120,12 +126,78 @@ acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, cha | |||
120 | } | 126 | } |
121 | static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); | 127 | static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); |
122 | 128 | ||
129 | static acpi_status acpi_bus_offline_companions(acpi_handle handle, u32 lvl, | ||
130 | void *data, void **ret_p) | ||
131 | { | ||
132 | struct acpi_device *device = NULL; | ||
133 | struct acpi_device_physical_node *pn; | ||
134 | bool second_pass = (bool)data; | ||
135 | acpi_status status = AE_OK; | ||
136 | |||
137 | if (acpi_bus_get_device(handle, &device)) | ||
138 | return AE_OK; | ||
139 | |||
140 | mutex_lock(&device->physical_node_lock); | ||
141 | |||
142 | list_for_each_entry(pn, &device->physical_node_list, node) { | ||
143 | int ret; | ||
144 | |||
145 | if (second_pass) { | ||
146 | /* Skip devices offlined by the first pass. */ | ||
147 | if (pn->put_online) | ||
148 | continue; | ||
149 | } else { | ||
150 | pn->put_online = false; | ||
151 | } | ||
152 | ret = device_offline(pn->dev); | ||
153 | if (acpi_force_hot_remove) | ||
154 | continue; | ||
155 | |||
156 | if (ret >= 0) { | ||
157 | pn->put_online = !ret; | ||
158 | } else { | ||
159 | *ret_p = pn->dev; | ||
160 | if (second_pass) { | ||
161 | status = AE_ERROR; | ||
162 | break; | ||
163 | } | ||
164 | } | ||
165 | } | ||
166 | |||
167 | mutex_unlock(&device->physical_node_lock); | ||
168 | |||
169 | return status; | ||
170 | } | ||
171 | |||
172 | static acpi_status acpi_bus_online_companions(acpi_handle handle, u32 lvl, | ||
173 | void *data, void **ret_p) | ||
174 | { | ||
175 | struct acpi_device *device = NULL; | ||
176 | struct acpi_device_physical_node *pn; | ||
177 | |||
178 | if (acpi_bus_get_device(handle, &device)) | ||
179 | return AE_OK; | ||
180 | |||
181 | mutex_lock(&device->physical_node_lock); | ||
182 | |||
183 | list_for_each_entry(pn, &device->physical_node_list, node) | ||
184 | if (pn->put_online) { | ||
185 | device_online(pn->dev); | ||
186 | pn->put_online = false; | ||
187 | } | ||
188 | |||
189 | mutex_unlock(&device->physical_node_lock); | ||
190 | |||
191 | return AE_OK; | ||
192 | } | ||
193 | |||
123 | static int acpi_scan_hot_remove(struct acpi_device *device) | 194 | static int acpi_scan_hot_remove(struct acpi_device *device) |
124 | { | 195 | { |
125 | acpi_handle handle = device->handle; | 196 | acpi_handle handle = device->handle; |
126 | acpi_handle not_used; | 197 | acpi_handle not_used; |
127 | struct acpi_object_list arg_list; | 198 | struct acpi_object_list arg_list; |
128 | union acpi_object arg; | 199 | union acpi_object arg; |
200 | struct device *errdev; | ||
129 | acpi_status status; | 201 | acpi_status status; |
130 | unsigned long long sta; | 202 | unsigned long long sta; |
131 | 203 | ||
@@ -136,10 +208,53 @@ static int acpi_scan_hot_remove(struct acpi_device *device) | |||
136 | return -EINVAL; | 208 | return -EINVAL; |
137 | } | 209 | } |
138 | 210 | ||
211 | lock_device_hotplug(); | ||
212 | |||
213 | /* | ||
214 | * Carry out two passes here and ignore errors in the first pass, | ||
215 | * because if the devices in question are memory blocks and | ||
216 | * CONFIG_MEMCG is set, one of the blocks may hold data structures | ||
217 | * that the other blocks depend on, but it is not known in advance which | ||
218 | * block holds them. | ||
219 | * | ||
220 | * If the first pass is successful, the second one isn't needed, though. | ||
221 | */ | ||
222 | errdev = NULL; | ||
223 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, | ||
224 | NULL, acpi_bus_offline_companions, | ||
225 | (void *)false, (void **)&errdev); | ||
226 | acpi_bus_offline_companions(handle, 0, (void *)false, (void **)&errdev); | ||
227 | if (errdev) { | ||
228 | errdev = NULL; | ||
229 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, | ||
230 | NULL, acpi_bus_offline_companions, | ||
231 | (void *)true , (void **)&errdev); | ||
232 | if (!errdev || acpi_force_hot_remove) | ||
233 | acpi_bus_offline_companions(handle, 0, (void *)true, | ||
234 | (void **)&errdev); | ||
235 | |||
236 | if (errdev && !acpi_force_hot_remove) { | ||
237 | dev_warn(errdev, "Offline failed.\n"); | ||
238 | acpi_bus_online_companions(handle, 0, NULL, NULL); | ||
239 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, | ||
240 | ACPI_UINT32_MAX, | ||
241 | acpi_bus_online_companions, NULL, | ||
242 | NULL, NULL); | ||
243 | |||
244 | unlock_device_hotplug(); | ||
245 | |||
246 | put_device(&device->dev); | ||
247 | return -EBUSY; | ||
248 | } | ||
249 | } | ||
250 | |||
139 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 251 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
140 | "Hot-removing device %s...\n", dev_name(&device->dev))); | 252 | "Hot-removing device %s...\n", dev_name(&device->dev))); |
141 | 253 | ||
142 | acpi_bus_trim(device); | 254 | acpi_bus_trim(device); |
255 | |||
256 | unlock_device_hotplug(); | ||
257 | |||
143 | /* Device node has been unregistered. */ | 258 | /* Device node has been unregistered. */ |
144 | put_device(&device->dev); | 259 | put_device(&device->dev); |
145 | device = NULL; | 260 | device = NULL; |
@@ -236,6 +351,7 @@ static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source) | |||
236 | int error; | 351 | int error; |
237 | 352 | ||
238 | mutex_lock(&acpi_scan_lock); | 353 | mutex_lock(&acpi_scan_lock); |
354 | lock_device_hotplug(); | ||
239 | 355 | ||
240 | acpi_bus_get_device(handle, &device); | 356 | acpi_bus_get_device(handle, &device); |
241 | if (device) { | 357 | if (device) { |
@@ -259,6 +375,7 @@ static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source) | |||
259 | kobject_uevent(&device->dev.kobj, KOBJ_ONLINE); | 375 | kobject_uevent(&device->dev.kobj, KOBJ_ONLINE); |
260 | 376 | ||
261 | out: | 377 | out: |
378 | unlock_device_hotplug(); | ||
262 | acpi_evaluate_hotplug_ost(handle, ost_source, ost_code, NULL); | 379 | acpi_evaluate_hotplug_ost(handle, ost_source, ost_code, NULL); |
263 | mutex_unlock(&acpi_scan_lock); | 380 | mutex_unlock(&acpi_scan_lock); |
264 | } | 381 | } |
@@ -816,32 +933,43 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device) | |||
816 | acpi_device_notify); | 933 | acpi_device_notify); |
817 | } | 934 | } |
818 | 935 | ||
819 | static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *); | 936 | static int acpi_device_probe(struct device *dev) |
820 | static int acpi_device_probe(struct device * dev) | ||
821 | { | 937 | { |
822 | struct acpi_device *acpi_dev = to_acpi_device(dev); | 938 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
823 | struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver); | 939 | struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver); |
824 | int ret; | 940 | int ret; |
825 | 941 | ||
826 | ret = acpi_bus_driver_init(acpi_dev, acpi_drv); | 942 | if (acpi_dev->handler) |
827 | if (!ret) { | 943 | return -EINVAL; |
828 | if (acpi_drv->ops.notify) { | ||
829 | ret = acpi_device_install_notify_handler(acpi_dev); | ||
830 | if (ret) { | ||
831 | if (acpi_drv->ops.remove) | ||
832 | acpi_drv->ops.remove(acpi_dev); | ||
833 | acpi_dev->driver = NULL; | ||
834 | acpi_dev->driver_data = NULL; | ||
835 | return ret; | ||
836 | } | ||
837 | } | ||
838 | 944 | ||
839 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 945 | if (!acpi_drv->ops.add) |
840 | "Found driver [%s] for device [%s]\n", | 946 | return -ENOSYS; |
841 | acpi_drv->name, acpi_dev->pnp.bus_id)); | 947 | |
842 | get_device(dev); | 948 | ret = acpi_drv->ops.add(acpi_dev); |
949 | if (ret) | ||
950 | return ret; | ||
951 | |||
952 | acpi_dev->driver = acpi_drv; | ||
953 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
954 | "Driver [%s] successfully bound to device [%s]\n", | ||
955 | acpi_drv->name, acpi_dev->pnp.bus_id)); | ||
956 | |||
957 | if (acpi_drv->ops.notify) { | ||
958 | ret = acpi_device_install_notify_handler(acpi_dev); | ||
959 | if (ret) { | ||
960 | if (acpi_drv->ops.remove) | ||
961 | acpi_drv->ops.remove(acpi_dev); | ||
962 | |||
963 | acpi_dev->driver = NULL; | ||
964 | acpi_dev->driver_data = NULL; | ||
965 | return ret; | ||
966 | } | ||
843 | } | 967 | } |
844 | return ret; | 968 | |
969 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n", | ||
970 | acpi_drv->name, acpi_dev->pnp.bus_id)); | ||
971 | get_device(dev); | ||
972 | return 0; | ||
845 | } | 973 | } |
846 | 974 | ||
847 | static int acpi_device_remove(struct device * dev) | 975 | static int acpi_device_remove(struct device * dev) |
@@ -952,7 +1080,6 @@ int acpi_device_add(struct acpi_device *device, | |||
952 | printk(KERN_ERR PREFIX "Error creating sysfs interface for device %s\n", | 1080 | printk(KERN_ERR PREFIX "Error creating sysfs interface for device %s\n", |
953 | dev_name(&device->dev)); | 1081 | dev_name(&device->dev)); |
954 | 1082 | ||
955 | device->removal_type = ACPI_BUS_REMOVAL_NORMAL; | ||
956 | return 0; | 1083 | return 0; |
957 | 1084 | ||
958 | err: | 1085 | err: |
@@ -998,41 +1125,6 @@ static void acpi_device_unregister(struct acpi_device *device) | |||
998 | Driver Management | 1125 | Driver Management |
999 | -------------------------------------------------------------------------- */ | 1126 | -------------------------------------------------------------------------- */ |
1000 | /** | 1127 | /** |
1001 | * acpi_bus_driver_init - add a device to a driver | ||
1002 | * @device: the device to add and initialize | ||
1003 | * @driver: driver for the device | ||
1004 | * | ||
1005 | * Used to initialize a device via its device driver. Called whenever a | ||
1006 | * driver is bound to a device. Invokes the driver's add() ops. | ||
1007 | */ | ||
1008 | static int | ||
1009 | acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver) | ||
1010 | { | ||
1011 | int result = 0; | ||
1012 | |||
1013 | if (!device || !driver) | ||
1014 | return -EINVAL; | ||
1015 | |||
1016 | if (!driver->ops.add) | ||
1017 | return -ENOSYS; | ||
1018 | |||
1019 | result = driver->ops.add(device); | ||
1020 | if (result) | ||
1021 | return result; | ||
1022 | |||
1023 | device->driver = driver; | ||
1024 | |||
1025 | /* | ||
1026 | * TBD - Configuration Management: Assign resources to device based | ||
1027 | * upon possible configuration and currently allocated resources. | ||
1028 | */ | ||
1029 | |||
1030 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
1031 | "Driver successfully bound to device\n")); | ||
1032 | return 0; | ||
1033 | } | ||
1034 | |||
1035 | /** | ||
1036 | * acpi_bus_register_driver - register a driver with the ACPI bus | 1128 | * acpi_bus_register_driver - register a driver with the ACPI bus |
1037 | * @driver: driver being registered | 1129 | * @driver: driver being registered |
1038 | * | 1130 | * |
@@ -1939,7 +2031,6 @@ static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used, | |||
1939 | if (!acpi_bus_get_device(handle, &device)) { | 2031 | if (!acpi_bus_get_device(handle, &device)) { |
1940 | struct acpi_scan_handler *dev_handler = device->handler; | 2032 | struct acpi_scan_handler *dev_handler = device->handler; |
1941 | 2033 | ||
1942 | device->removal_type = ACPI_BUS_REMOVAL_EJECT; | ||
1943 | if (dev_handler) { | 2034 | if (dev_handler) { |
1944 | if (dev_handler->detach) | 2035 | if (dev_handler->detach) |
1945 | dev_handler->detach(device); | 2036 | dev_handler->detach(device); |
@@ -2038,8 +2129,10 @@ int __init acpi_scan_init(void) | |||
2038 | 2129 | ||
2039 | acpi_pci_root_init(); | 2130 | acpi_pci_root_init(); |
2040 | acpi_pci_link_init(); | 2131 | acpi_pci_link_init(); |
2132 | acpi_processor_init(); | ||
2041 | acpi_platform_init(); | 2133 | acpi_platform_init(); |
2042 | acpi_lpss_init(); | 2134 | acpi_lpss_init(); |
2135 | acpi_cmos_rtc_init(); | ||
2043 | acpi_container_init(); | 2136 | acpi_container_init(); |
2044 | acpi_memory_hotplug_init(); | 2137 | acpi_memory_hotplug_init(); |
2045 | acpi_dock_init(); | 2138 | acpi_dock_init(); |
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 9c1a435d10e6..187ab61889e6 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c | |||
@@ -494,6 +494,8 @@ static int acpi_suspend_enter(suspend_state_t pm_state) | |||
494 | break; | 494 | break; |
495 | 495 | ||
496 | case ACPI_STATE_S3: | 496 | case ACPI_STATE_S3: |
497 | if (!acpi_suspend_lowlevel) | ||
498 | return -ENOSYS; | ||
497 | error = acpi_suspend_lowlevel(); | 499 | error = acpi_suspend_lowlevel(); |
498 | if (error) | 500 | if (error) |
499 | return error; | 501 | return error; |
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index fcae5fa2e1b3..5c5d1624fa2c 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c | |||
@@ -780,6 +780,33 @@ void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug, | |||
780 | pr_err(PREFIX "Unable to add hotplug profile '%s'\n", name); | 780 | pr_err(PREFIX "Unable to add hotplug profile '%s'\n", name); |
781 | } | 781 | } |
782 | 782 | ||
783 | static ssize_t force_remove_show(struct kobject *kobj, | ||
784 | struct kobj_attribute *attr, char *buf) | ||
785 | { | ||
786 | return sprintf(buf, "%d\n", !!acpi_force_hot_remove); | ||
787 | } | ||
788 | |||
789 | static ssize_t force_remove_store(struct kobject *kobj, | ||
790 | struct kobj_attribute *attr, | ||
791 | const char *buf, size_t size) | ||
792 | { | ||
793 | bool val; | ||
794 | int ret; | ||
795 | |||
796 | ret = strtobool(buf, &val); | ||
797 | if (ret < 0) | ||
798 | return ret; | ||
799 | |||
800 | lock_device_hotplug(); | ||
801 | acpi_force_hot_remove = val; | ||
802 | unlock_device_hotplug(); | ||
803 | return size; | ||
804 | } | ||
805 | |||
806 | static const struct kobj_attribute force_remove_attr = | ||
807 | __ATTR(force_remove, S_IRUGO | S_IWUSR, force_remove_show, | ||
808 | force_remove_store); | ||
809 | |||
783 | int __init acpi_sysfs_init(void) | 810 | int __init acpi_sysfs_init(void) |
784 | { | 811 | { |
785 | int result; | 812 | int result; |
@@ -789,6 +816,10 @@ int __init acpi_sysfs_init(void) | |||
789 | return result; | 816 | return result; |
790 | 817 | ||
791 | hotplug_kobj = kobject_create_and_add("hotplug", acpi_kobj); | 818 | hotplug_kobj = kobject_create_and_add("hotplug", acpi_kobj); |
819 | result = sysfs_create_file(hotplug_kobj, &force_remove_attr.attr); | ||
820 | if (result) | ||
821 | return result; | ||
822 | |||
792 | result = sysfs_create_file(acpi_kobj, &pm_profile_attr.attr); | 823 | result = sysfs_create_file(acpi_kobj, &pm_profile_attr.attr); |
793 | return result; | 824 | return result; |
794 | } | 825 | } |
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 440eadf2d32c..5d7075d25700 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -1722,9 +1722,6 @@ static int acpi_video_bus_add(struct acpi_device *device) | |||
1722 | int error; | 1722 | int error; |
1723 | acpi_status status; | 1723 | acpi_status status; |
1724 | 1724 | ||
1725 | if (device->handler) | ||
1726 | return -EINVAL; | ||
1727 | |||
1728 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, | 1725 | status = acpi_walk_namespace(ACPI_TYPE_DEVICE, |
1729 | device->parent->handle, 1, | 1726 | device->parent->handle, 1, |
1730 | acpi_video_bus_match, NULL, | 1727 | acpi_video_bus_match, NULL, |
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index cdbad3a454a0..c6707278a6bb 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c | |||
@@ -284,7 +284,7 @@ static const struct dev_pm_ops amba_pm = { | |||
284 | SET_RUNTIME_PM_OPS( | 284 | SET_RUNTIME_PM_OPS( |
285 | amba_pm_runtime_suspend, | 285 | amba_pm_runtime_suspend, |
286 | amba_pm_runtime_resume, | 286 | amba_pm_runtime_resume, |
287 | pm_generic_runtime_idle | 287 | NULL |
288 | ) | 288 | ) |
289 | }; | 289 | }; |
290 | 290 | ||
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index adf002a3c584..6e458a40a93b 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -5436,7 +5436,7 @@ static int ata_port_runtime_idle(struct device *dev) | |||
5436 | return -EBUSY; | 5436 | return -EBUSY; |
5437 | } | 5437 | } |
5438 | 5438 | ||
5439 | return pm_runtime_suspend(dev); | 5439 | return 0; |
5440 | } | 5440 | } |
5441 | 5441 | ||
5442 | static int ata_port_runtime_suspend(struct device *dev) | 5442 | static int ata_port_runtime_suspend(struct device *dev) |
diff --git a/drivers/base/core.c b/drivers/base/core.c index 6fdc53d46fa0..dc3ea237f086 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -403,6 +403,36 @@ static ssize_t store_uevent(struct device *dev, struct device_attribute *attr, | |||
403 | static struct device_attribute uevent_attr = | 403 | static struct device_attribute uevent_attr = |
404 | __ATTR(uevent, S_IRUGO | S_IWUSR, show_uevent, store_uevent); | 404 | __ATTR(uevent, S_IRUGO | S_IWUSR, show_uevent, store_uevent); |
405 | 405 | ||
406 | static ssize_t show_online(struct device *dev, struct device_attribute *attr, | ||
407 | char *buf) | ||
408 | { | ||
409 | bool val; | ||
410 | |||
411 | lock_device_hotplug(); | ||
412 | val = !dev->offline; | ||
413 | unlock_device_hotplug(); | ||
414 | return sprintf(buf, "%u\n", val); | ||
415 | } | ||
416 | |||
417 | static ssize_t store_online(struct device *dev, struct device_attribute *attr, | ||
418 | const char *buf, size_t count) | ||
419 | { | ||
420 | bool val; | ||
421 | int ret; | ||
422 | |||
423 | ret = strtobool(buf, &val); | ||
424 | if (ret < 0) | ||
425 | return ret; | ||
426 | |||
427 | lock_device_hotplug(); | ||
428 | ret = val ? device_online(dev) : device_offline(dev); | ||
429 | unlock_device_hotplug(); | ||
430 | return ret < 0 ? ret : count; | ||
431 | } | ||
432 | |||
433 | static struct device_attribute online_attr = | ||
434 | __ATTR(online, S_IRUGO | S_IWUSR, show_online, store_online); | ||
435 | |||
406 | static int device_add_attributes(struct device *dev, | 436 | static int device_add_attributes(struct device *dev, |
407 | struct device_attribute *attrs) | 437 | struct device_attribute *attrs) |
408 | { | 438 | { |
@@ -516,6 +546,12 @@ static int device_add_attrs(struct device *dev) | |||
516 | if (error) | 546 | if (error) |
517 | goto err_remove_type_groups; | 547 | goto err_remove_type_groups; |
518 | 548 | ||
549 | if (device_supports_offline(dev) && !dev->offline_disabled) { | ||
550 | error = device_create_file(dev, &online_attr); | ||
551 | if (error) | ||
552 | goto err_remove_type_groups; | ||
553 | } | ||
554 | |||
519 | return 0; | 555 | return 0; |
520 | 556 | ||
521 | err_remove_type_groups: | 557 | err_remove_type_groups: |
@@ -536,6 +572,7 @@ static void device_remove_attrs(struct device *dev) | |||
536 | struct class *class = dev->class; | 572 | struct class *class = dev->class; |
537 | const struct device_type *type = dev->type; | 573 | const struct device_type *type = dev->type; |
538 | 574 | ||
575 | device_remove_file(dev, &online_attr); | ||
539 | device_remove_groups(dev, dev->groups); | 576 | device_remove_groups(dev, dev->groups); |
540 | 577 | ||
541 | if (type) | 578 | if (type) |
@@ -1435,6 +1472,99 @@ EXPORT_SYMBOL_GPL(put_device); | |||
1435 | EXPORT_SYMBOL_GPL(device_create_file); | 1472 | EXPORT_SYMBOL_GPL(device_create_file); |
1436 | EXPORT_SYMBOL_GPL(device_remove_file); | 1473 | EXPORT_SYMBOL_GPL(device_remove_file); |
1437 | 1474 | ||
1475 | static DEFINE_MUTEX(device_hotplug_lock); | ||
1476 | |||
1477 | void lock_device_hotplug(void) | ||
1478 | { | ||
1479 | mutex_lock(&device_hotplug_lock); | ||
1480 | } | ||
1481 | |||
1482 | void unlock_device_hotplug(void) | ||
1483 | { | ||
1484 | mutex_unlock(&device_hotplug_lock); | ||
1485 | } | ||
1486 | |||
1487 | static int device_check_offline(struct device *dev, void *not_used) | ||
1488 | { | ||
1489 | int ret; | ||
1490 | |||
1491 | ret = device_for_each_child(dev, NULL, device_check_offline); | ||
1492 | if (ret) | ||
1493 | return ret; | ||
1494 | |||
1495 | return device_supports_offline(dev) && !dev->offline ? -EBUSY : 0; | ||
1496 | } | ||
1497 | |||
1498 | /** | ||
1499 | * device_offline - Prepare the device for hot-removal. | ||
1500 | * @dev: Device to be put offline. | ||
1501 | * | ||
1502 | * Execute the device bus type's .offline() callback, if present, to prepare | ||
1503 | * the device for a subsequent hot-removal. If that succeeds, the device must | ||
1504 | * not be used until either it is removed or its bus type's .online() callback | ||
1505 | * is executed. | ||
1506 | * | ||
1507 | * Call under device_hotplug_lock. | ||
1508 | */ | ||
1509 | int device_offline(struct device *dev) | ||
1510 | { | ||
1511 | int ret; | ||
1512 | |||
1513 | if (dev->offline_disabled) | ||
1514 | return -EPERM; | ||
1515 | |||
1516 | ret = device_for_each_child(dev, NULL, device_check_offline); | ||
1517 | if (ret) | ||
1518 | return ret; | ||
1519 | |||
1520 | device_lock(dev); | ||
1521 | if (device_supports_offline(dev)) { | ||
1522 | if (dev->offline) { | ||
1523 | ret = 1; | ||
1524 | } else { | ||
1525 | ret = dev->bus->offline(dev); | ||
1526 | if (!ret) { | ||
1527 | kobject_uevent(&dev->kobj, KOBJ_OFFLINE); | ||
1528 | dev->offline = true; | ||
1529 | } | ||
1530 | } | ||
1531 | } | ||
1532 | device_unlock(dev); | ||
1533 | |||
1534 | return ret; | ||
1535 | } | ||
1536 | |||
1537 | /** | ||
1538 | * device_online - Put the device back online after successful device_offline(). | ||
1539 | * @dev: Device to be put back online. | ||
1540 | * | ||
1541 | * If device_offline() has been successfully executed for @dev, but the device | ||
1542 | * has not been removed subsequently, execute its bus type's .online() callback | ||
1543 | * to indicate that the device can be used again. | ||
1544 | * | ||
1545 | * Call under device_hotplug_lock. | ||
1546 | */ | ||
1547 | int device_online(struct device *dev) | ||
1548 | { | ||
1549 | int ret = 0; | ||
1550 | |||
1551 | device_lock(dev); | ||
1552 | if (device_supports_offline(dev)) { | ||
1553 | if (dev->offline) { | ||
1554 | ret = dev->bus->online(dev); | ||
1555 | if (!ret) { | ||
1556 | kobject_uevent(&dev->kobj, KOBJ_ONLINE); | ||
1557 | dev->offline = false; | ||
1558 | } | ||
1559 | } else { | ||
1560 | ret = 1; | ||
1561 | } | ||
1562 | } | ||
1563 | device_unlock(dev); | ||
1564 | |||
1565 | return ret; | ||
1566 | } | ||
1567 | |||
1438 | struct root_device { | 1568 | struct root_device { |
1439 | struct device dev; | 1569 | struct device dev; |
1440 | struct module *owner; | 1570 | struct module *owner; |
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index c377673320ed..a16d20e389f0 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c | |||
@@ -13,17 +13,21 @@ | |||
13 | #include <linux/gfp.h> | 13 | #include <linux/gfp.h> |
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/percpu.h> | 15 | #include <linux/percpu.h> |
16 | #include <linux/acpi.h> | ||
16 | 17 | ||
17 | #include "base.h" | 18 | #include "base.h" |
18 | 19 | ||
19 | struct bus_type cpu_subsys = { | ||
20 | .name = "cpu", | ||
21 | .dev_name = "cpu", | ||
22 | }; | ||
23 | EXPORT_SYMBOL_GPL(cpu_subsys); | ||
24 | |||
25 | static DEFINE_PER_CPU(struct device *, cpu_sys_devices); | 20 | static DEFINE_PER_CPU(struct device *, cpu_sys_devices); |
26 | 21 | ||
22 | static int cpu_subsys_match(struct device *dev, struct device_driver *drv) | ||
23 | { | ||
24 | /* ACPI style match is the only one that may succeed. */ | ||
25 | if (acpi_driver_match_device(dev, drv)) | ||
26 | return 1; | ||
27 | |||
28 | return 0; | ||
29 | } | ||
30 | |||
27 | #ifdef CONFIG_HOTPLUG_CPU | 31 | #ifdef CONFIG_HOTPLUG_CPU |
28 | static void change_cpu_under_node(struct cpu *cpu, | 32 | static void change_cpu_under_node(struct cpu *cpu, |
29 | unsigned int from_nid, unsigned int to_nid) | 33 | unsigned int from_nid, unsigned int to_nid) |
@@ -34,65 +38,38 @@ static void change_cpu_under_node(struct cpu *cpu, | |||
34 | cpu->node_id = to_nid; | 38 | cpu->node_id = to_nid; |
35 | } | 39 | } |
36 | 40 | ||
37 | static ssize_t show_online(struct device *dev, | 41 | static int __ref cpu_subsys_online(struct device *dev) |
38 | struct device_attribute *attr, | ||
39 | char *buf) | ||
40 | { | 42 | { |
41 | struct cpu *cpu = container_of(dev, struct cpu, dev); | 43 | struct cpu *cpu = container_of(dev, struct cpu, dev); |
44 | int cpuid = dev->id; | ||
45 | int from_nid, to_nid; | ||
46 | int ret; | ||
47 | |||
48 | cpu_hotplug_driver_lock(); | ||
42 | 49 | ||
43 | return sprintf(buf, "%u\n", !!cpu_online(cpu->dev.id)); | 50 | from_nid = cpu_to_node(cpuid); |
51 | ret = cpu_up(cpuid); | ||
52 | /* | ||
53 | * When hot adding memory to memoryless node and enabling a cpu | ||
54 | * on the node, node number of the cpu may internally change. | ||
55 | */ | ||
56 | to_nid = cpu_to_node(cpuid); | ||
57 | if (from_nid != to_nid) | ||
58 | change_cpu_under_node(cpu, from_nid, to_nid); | ||
59 | |||
60 | cpu_hotplug_driver_unlock(); | ||
61 | return ret; | ||
44 | } | 62 | } |
45 | 63 | ||
46 | static ssize_t __ref store_online(struct device *dev, | 64 | static int cpu_subsys_offline(struct device *dev) |
47 | struct device_attribute *attr, | ||
48 | const char *buf, size_t count) | ||
49 | { | 65 | { |
50 | struct cpu *cpu = container_of(dev, struct cpu, dev); | 66 | int ret; |
51 | int cpuid = cpu->dev.id; | ||
52 | int from_nid, to_nid; | ||
53 | ssize_t ret; | ||
54 | 67 | ||
55 | cpu_hotplug_driver_lock(); | 68 | cpu_hotplug_driver_lock(); |
56 | switch (buf[0]) { | 69 | ret = cpu_down(dev->id); |
57 | case '0': | ||
58 | ret = cpu_down(cpuid); | ||
59 | if (!ret) | ||
60 | kobject_uevent(&dev->kobj, KOBJ_OFFLINE); | ||
61 | break; | ||
62 | case '1': | ||
63 | from_nid = cpu_to_node(cpuid); | ||
64 | ret = cpu_up(cpuid); | ||
65 | |||
66 | /* | ||
67 | * When hot adding memory to memoryless node and enabling a cpu | ||
68 | * on the node, node number of the cpu may internally change. | ||
69 | */ | ||
70 | to_nid = cpu_to_node(cpuid); | ||
71 | if (from_nid != to_nid) | ||
72 | change_cpu_under_node(cpu, from_nid, to_nid); | ||
73 | |||
74 | if (!ret) | ||
75 | kobject_uevent(&dev->kobj, KOBJ_ONLINE); | ||
76 | break; | ||
77 | default: | ||
78 | ret = -EINVAL; | ||
79 | } | ||
80 | cpu_hotplug_driver_unlock(); | 70 | cpu_hotplug_driver_unlock(); |
81 | |||
82 | if (ret >= 0) | ||
83 | ret = count; | ||
84 | return ret; | 71 | return ret; |
85 | } | 72 | } |
86 | static DEVICE_ATTR(online, 0644, show_online, store_online); | ||
87 | |||
88 | static struct attribute *hotplug_cpu_attrs[] = { | ||
89 | &dev_attr_online.attr, | ||
90 | NULL | ||
91 | }; | ||
92 | |||
93 | static struct attribute_group hotplug_cpu_attr_group = { | ||
94 | .attrs = hotplug_cpu_attrs, | ||
95 | }; | ||
96 | 73 | ||
97 | void unregister_cpu(struct cpu *cpu) | 74 | void unregister_cpu(struct cpu *cpu) |
98 | { | 75 | { |
@@ -127,6 +104,17 @@ static DEVICE_ATTR(release, S_IWUSR, NULL, cpu_release_store); | |||
127 | #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ | 104 | #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ |
128 | #endif /* CONFIG_HOTPLUG_CPU */ | 105 | #endif /* CONFIG_HOTPLUG_CPU */ |
129 | 106 | ||
107 | struct bus_type cpu_subsys = { | ||
108 | .name = "cpu", | ||
109 | .dev_name = "cpu", | ||
110 | .match = cpu_subsys_match, | ||
111 | #ifdef CONFIG_HOTPLUG_CPU | ||
112 | .online = cpu_subsys_online, | ||
113 | .offline = cpu_subsys_offline, | ||
114 | #endif | ||
115 | }; | ||
116 | EXPORT_SYMBOL_GPL(cpu_subsys); | ||
117 | |||
130 | #ifdef CONFIG_KEXEC | 118 | #ifdef CONFIG_KEXEC |
131 | #include <linux/kexec.h> | 119 | #include <linux/kexec.h> |
132 | 120 | ||
@@ -185,9 +173,6 @@ static const struct attribute_group *hotplugable_cpu_attr_groups[] = { | |||
185 | #ifdef CONFIG_KEXEC | 173 | #ifdef CONFIG_KEXEC |
186 | &crash_note_cpu_attr_group, | 174 | &crash_note_cpu_attr_group, |
187 | #endif | 175 | #endif |
188 | #ifdef CONFIG_HOTPLUG_CPU | ||
189 | &hotplug_cpu_attr_group, | ||
190 | #endif | ||
191 | NULL | 176 | NULL |
192 | }; | 177 | }; |
193 | 178 | ||
@@ -302,6 +287,8 @@ int __cpuinit register_cpu(struct cpu *cpu, int num) | |||
302 | cpu->dev.id = num; | 287 | cpu->dev.id = num; |
303 | cpu->dev.bus = &cpu_subsys; | 288 | cpu->dev.bus = &cpu_subsys; |
304 | cpu->dev.release = cpu_device_release; | 289 | cpu->dev.release = cpu_device_release; |
290 | cpu->dev.offline_disabled = !cpu->hotpluggable; | ||
291 | cpu->dev.offline = !cpu_online(num); | ||
305 | #ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE | 292 | #ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE |
306 | cpu->dev.bus->uevent = arch_cpu_uevent; | 293 | cpu->dev.bus->uevent = arch_cpu_uevent; |
307 | #endif | 294 | #endif |
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index e315051cfeeb..2b7813ec6d02 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
@@ -37,9 +37,14 @@ static inline int base_memory_block_id(int section_nr) | |||
37 | return section_nr / sections_per_block; | 37 | return section_nr / sections_per_block; |
38 | } | 38 | } |
39 | 39 | ||
40 | static int memory_subsys_online(struct device *dev); | ||
41 | static int memory_subsys_offline(struct device *dev); | ||
42 | |||
40 | static struct bus_type memory_subsys = { | 43 | static struct bus_type memory_subsys = { |
41 | .name = MEMORY_CLASS_NAME, | 44 | .name = MEMORY_CLASS_NAME, |
42 | .dev_name = MEMORY_CLASS_NAME, | 45 | .dev_name = MEMORY_CLASS_NAME, |
46 | .online = memory_subsys_online, | ||
47 | .offline = memory_subsys_offline, | ||
43 | }; | 48 | }; |
44 | 49 | ||
45 | static BLOCKING_NOTIFIER_HEAD(memory_chain); | 50 | static BLOCKING_NOTIFIER_HEAD(memory_chain); |
@@ -262,33 +267,64 @@ static int __memory_block_change_state(struct memory_block *mem, | |||
262 | { | 267 | { |
263 | int ret = 0; | 268 | int ret = 0; |
264 | 269 | ||
265 | if (mem->state != from_state_req) { | 270 | if (mem->state != from_state_req) |
266 | ret = -EINVAL; | 271 | return -EINVAL; |
267 | goto out; | ||
268 | } | ||
269 | 272 | ||
270 | if (to_state == MEM_OFFLINE) | 273 | if (to_state == MEM_OFFLINE) |
271 | mem->state = MEM_GOING_OFFLINE; | 274 | mem->state = MEM_GOING_OFFLINE; |
272 | 275 | ||
273 | ret = memory_block_action(mem->start_section_nr, to_state, online_type); | 276 | ret = memory_block_action(mem->start_section_nr, to_state, online_type); |
277 | mem->state = ret ? from_state_req : to_state; | ||
278 | return ret; | ||
279 | } | ||
274 | 280 | ||
275 | if (ret) { | 281 | static int memory_subsys_online(struct device *dev) |
276 | mem->state = from_state_req; | 282 | { |
277 | goto out; | 283 | struct memory_block *mem = container_of(dev, struct memory_block, dev); |
278 | } | 284 | int ret; |
279 | 285 | ||
280 | mem->state = to_state; | 286 | mutex_lock(&mem->state_mutex); |
281 | switch (mem->state) { | 287 | |
282 | case MEM_OFFLINE: | 288 | ret = mem->state == MEM_ONLINE ? 0 : |
283 | kobject_uevent(&mem->dev.kobj, KOBJ_OFFLINE); | 289 | __memory_block_change_state(mem, MEM_ONLINE, MEM_OFFLINE, |
284 | break; | 290 | ONLINE_KEEP); |
285 | case MEM_ONLINE: | 291 | |
286 | kobject_uevent(&mem->dev.kobj, KOBJ_ONLINE); | 292 | mutex_unlock(&mem->state_mutex); |
287 | break; | 293 | return ret; |
288 | default: | 294 | } |
289 | break; | 295 | |
296 | static int memory_subsys_offline(struct device *dev) | ||
297 | { | ||
298 | struct memory_block *mem = container_of(dev, struct memory_block, dev); | ||
299 | int ret; | ||
300 | |||
301 | mutex_lock(&mem->state_mutex); | ||
302 | |||
303 | ret = mem->state == MEM_OFFLINE ? 0 : | ||
304 | __memory_block_change_state(mem, MEM_OFFLINE, MEM_ONLINE, -1); | ||
305 | |||
306 | mutex_unlock(&mem->state_mutex); | ||
307 | return ret; | ||
308 | } | ||
309 | |||
310 | static int __memory_block_change_state_uevent(struct memory_block *mem, | ||
311 | unsigned long to_state, unsigned long from_state_req, | ||
312 | int online_type) | ||
313 | { | ||
314 | int ret = __memory_block_change_state(mem, to_state, from_state_req, | ||
315 | online_type); | ||
316 | if (!ret) { | ||
317 | switch (mem->state) { | ||
318 | case MEM_OFFLINE: | ||
319 | kobject_uevent(&mem->dev.kobj, KOBJ_OFFLINE); | ||
320 | break; | ||
321 | case MEM_ONLINE: | ||
322 | kobject_uevent(&mem->dev.kobj, KOBJ_ONLINE); | ||
323 | break; | ||
324 | default: | ||
325 | break; | ||
326 | } | ||
290 | } | 327 | } |
291 | out: | ||
292 | return ret; | 328 | return ret; |
293 | } | 329 | } |
294 | 330 | ||
@@ -299,8 +335,8 @@ static int memory_block_change_state(struct memory_block *mem, | |||
299 | int ret; | 335 | int ret; |
300 | 336 | ||
301 | mutex_lock(&mem->state_mutex); | 337 | mutex_lock(&mem->state_mutex); |
302 | ret = __memory_block_change_state(mem, to_state, from_state_req, | 338 | ret = __memory_block_change_state_uevent(mem, to_state, from_state_req, |
303 | online_type); | 339 | online_type); |
304 | mutex_unlock(&mem->state_mutex); | 340 | mutex_unlock(&mem->state_mutex); |
305 | 341 | ||
306 | return ret; | 342 | return ret; |
@@ -310,22 +346,34 @@ store_mem_state(struct device *dev, | |||
310 | struct device_attribute *attr, const char *buf, size_t count) | 346 | struct device_attribute *attr, const char *buf, size_t count) |
311 | { | 347 | { |
312 | struct memory_block *mem; | 348 | struct memory_block *mem; |
349 | bool offline; | ||
313 | int ret = -EINVAL; | 350 | int ret = -EINVAL; |
314 | 351 | ||
315 | mem = container_of(dev, struct memory_block, dev); | 352 | mem = container_of(dev, struct memory_block, dev); |
316 | 353 | ||
317 | if (!strncmp(buf, "online_kernel", min_t(int, count, 13))) | 354 | lock_device_hotplug(); |
355 | |||
356 | if (!strncmp(buf, "online_kernel", min_t(int, count, 13))) { | ||
357 | offline = false; | ||
318 | ret = memory_block_change_state(mem, MEM_ONLINE, | 358 | ret = memory_block_change_state(mem, MEM_ONLINE, |
319 | MEM_OFFLINE, ONLINE_KERNEL); | 359 | MEM_OFFLINE, ONLINE_KERNEL); |
320 | else if (!strncmp(buf, "online_movable", min_t(int, count, 14))) | 360 | } else if (!strncmp(buf, "online_movable", min_t(int, count, 14))) { |
361 | offline = false; | ||
321 | ret = memory_block_change_state(mem, MEM_ONLINE, | 362 | ret = memory_block_change_state(mem, MEM_ONLINE, |
322 | MEM_OFFLINE, ONLINE_MOVABLE); | 363 | MEM_OFFLINE, ONLINE_MOVABLE); |
323 | else if (!strncmp(buf, "online", min_t(int, count, 6))) | 364 | } else if (!strncmp(buf, "online", min_t(int, count, 6))) { |
365 | offline = false; | ||
324 | ret = memory_block_change_state(mem, MEM_ONLINE, | 366 | ret = memory_block_change_state(mem, MEM_ONLINE, |
325 | MEM_OFFLINE, ONLINE_KEEP); | 367 | MEM_OFFLINE, ONLINE_KEEP); |
326 | else if(!strncmp(buf, "offline", min_t(int, count, 7))) | 368 | } else if(!strncmp(buf, "offline", min_t(int, count, 7))) { |
369 | offline = true; | ||
327 | ret = memory_block_change_state(mem, MEM_OFFLINE, | 370 | ret = memory_block_change_state(mem, MEM_OFFLINE, |
328 | MEM_ONLINE, -1); | 371 | MEM_ONLINE, -1); |
372 | } | ||
373 | if (!ret) | ||
374 | dev->offline = offline; | ||
375 | |||
376 | unlock_device_hotplug(); | ||
329 | 377 | ||
330 | if (ret) | 378 | if (ret) |
331 | return ret; | 379 | return ret; |
@@ -523,6 +571,7 @@ int register_memory(struct memory_block *memory) | |||
523 | memory->dev.id = memory->start_section_nr / sections_per_block; | 571 | memory->dev.id = memory->start_section_nr / sections_per_block; |
524 | memory->dev.release = memory_block_release; | 572 | memory->dev.release = memory_block_release; |
525 | memory->dev.groups = memory_memblk_attr_groups; | 573 | memory->dev.groups = memory_memblk_attr_groups; |
574 | memory->dev.offline = memory->state == MEM_OFFLINE; | ||
526 | 575 | ||
527 | error = device_register(&memory->dev); | 576 | error = device_register(&memory->dev); |
528 | return error; | 577 | return error; |
@@ -646,21 +695,6 @@ int unregister_memory_section(struct mem_section *section) | |||
646 | } | 695 | } |
647 | #endif /* CONFIG_MEMORY_HOTREMOVE */ | 696 | #endif /* CONFIG_MEMORY_HOTREMOVE */ |
648 | 697 | ||
649 | /* | ||
650 | * offline one memory block. If the memory block has been offlined, do nothing. | ||
651 | */ | ||
652 | int offline_memory_block(struct memory_block *mem) | ||
653 | { | ||
654 | int ret = 0; | ||
655 | |||
656 | mutex_lock(&mem->state_mutex); | ||
657 | if (mem->state != MEM_OFFLINE) | ||
658 | ret = __memory_block_change_state(mem, MEM_OFFLINE, MEM_ONLINE, -1); | ||
659 | mutex_unlock(&mem->state_mutex); | ||
660 | |||
661 | return ret; | ||
662 | } | ||
663 | |||
664 | /* return true if the memory block is offlined, otherwise, return false */ | 698 | /* return true if the memory block is offlined, otherwise, return false */ |
665 | bool is_memblock_offlined(struct memory_block *mem) | 699 | bool is_memblock_offlined(struct memory_block *mem) |
666 | { | 700 | { |
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index ed75cf6ef9c9..6eaa7ab9e4bc 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -890,7 +890,6 @@ int platform_pm_restore(struct device *dev) | |||
890 | static const struct dev_pm_ops platform_dev_pm_ops = { | 890 | static const struct dev_pm_ops platform_dev_pm_ops = { |
891 | .runtime_suspend = pm_generic_runtime_suspend, | 891 | .runtime_suspend = pm_generic_runtime_suspend, |
892 | .runtime_resume = pm_generic_runtime_resume, | 892 | .runtime_resume = pm_generic_runtime_resume, |
893 | .runtime_idle = pm_generic_runtime_idle, | ||
894 | USE_PLATFORM_PM_SLEEP_OPS | 893 | USE_PLATFORM_PM_SLEEP_OPS |
895 | }; | 894 | }; |
896 | 895 | ||
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 7072404c8b6d..bfb8955c406c 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c | |||
@@ -2143,7 +2143,6 @@ void pm_genpd_init(struct generic_pm_domain *genpd, | |||
2143 | genpd->max_off_time_changed = true; | 2143 | genpd->max_off_time_changed = true; |
2144 | genpd->domain.ops.runtime_suspend = pm_genpd_runtime_suspend; | 2144 | genpd->domain.ops.runtime_suspend = pm_genpd_runtime_suspend; |
2145 | genpd->domain.ops.runtime_resume = pm_genpd_runtime_resume; | 2145 | genpd->domain.ops.runtime_resume = pm_genpd_runtime_resume; |
2146 | genpd->domain.ops.runtime_idle = pm_generic_runtime_idle; | ||
2147 | genpd->domain.ops.prepare = pm_genpd_prepare; | 2146 | genpd->domain.ops.prepare = pm_genpd_prepare; |
2148 | genpd->domain.ops.suspend = pm_genpd_suspend; | 2147 | genpd->domain.ops.suspend = pm_genpd_suspend; |
2149 | genpd->domain.ops.suspend_late = pm_genpd_suspend_late; | 2148 | genpd->domain.ops.suspend_late = pm_genpd_suspend_late; |
diff --git a/drivers/base/power/generic_ops.c b/drivers/base/power/generic_ops.c index bfd898b8988e..5ee030a864f9 100644 --- a/drivers/base/power/generic_ops.c +++ b/drivers/base/power/generic_ops.c | |||
@@ -12,29 +12,6 @@ | |||
12 | 12 | ||
13 | #ifdef CONFIG_PM_RUNTIME | 13 | #ifdef CONFIG_PM_RUNTIME |
14 | /** | 14 | /** |
15 | * pm_generic_runtime_idle - Generic runtime idle callback for subsystems. | ||
16 | * @dev: Device to handle. | ||
17 | * | ||
18 | * If PM operations are defined for the @dev's driver and they include | ||
19 | * ->runtime_idle(), execute it and return its error code, if nonzero. | ||
20 | * Otherwise, execute pm_runtime_suspend() for the device and return 0. | ||
21 | */ | ||
22 | int pm_generic_runtime_idle(struct device *dev) | ||
23 | { | ||
24 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; | ||
25 | |||
26 | if (pm && pm->runtime_idle) { | ||
27 | int ret = pm->runtime_idle(dev); | ||
28 | if (ret) | ||
29 | return ret; | ||
30 | } | ||
31 | |||
32 | pm_runtime_suspend(dev); | ||
33 | return 0; | ||
34 | } | ||
35 | EXPORT_SYMBOL_GPL(pm_generic_runtime_idle); | ||
36 | |||
37 | /** | ||
38 | * pm_generic_runtime_suspend - Generic runtime suspend callback for subsystems. | 15 | * pm_generic_runtime_suspend - Generic runtime suspend callback for subsystems. |
39 | * @dev: Device to suspend. | 16 | * @dev: Device to suspend. |
40 | * | 17 | * |
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index f0077cb8e249..c8ec186303db 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c | |||
@@ -648,14 +648,14 @@ int opp_init_cpufreq_table(struct device *dev, | |||
648 | 648 | ||
649 | list_for_each_entry(opp, &dev_opp->opp_list, node) { | 649 | list_for_each_entry(opp, &dev_opp->opp_list, node) { |
650 | if (opp->available) { | 650 | if (opp->available) { |
651 | freq_table[i].index = i; | 651 | freq_table[i].driver_data = i; |
652 | freq_table[i].frequency = opp->rate / 1000; | 652 | freq_table[i].frequency = opp->rate / 1000; |
653 | i++; | 653 | i++; |
654 | } | 654 | } |
655 | } | 655 | } |
656 | mutex_unlock(&dev_opp_list_lock); | 656 | mutex_unlock(&dev_opp_list_lock); |
657 | 657 | ||
658 | freq_table[i].index = i; | 658 | freq_table[i].driver_data = i; |
659 | freq_table[i].frequency = CPUFREQ_TABLE_END; | 659 | freq_table[i].frequency = CPUFREQ_TABLE_END; |
660 | 660 | ||
661 | *table = &freq_table[0]; | 661 | *table = &freq_table[0]; |
diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c index 71671c42ef45..5c1361a9e5dd 100644 --- a/drivers/base/power/qos.c +++ b/drivers/base/power/qos.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/export.h> | 42 | #include <linux/export.h> |
43 | #include <linux/pm_runtime.h> | 43 | #include <linux/pm_runtime.h> |
44 | #include <linux/err.h> | 44 | #include <linux/err.h> |
45 | #include <trace/events/power.h> | ||
45 | 46 | ||
46 | #include "power.h" | 47 | #include "power.h" |
47 | 48 | ||
@@ -305,6 +306,7 @@ int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req, | |||
305 | else if (!dev->power.qos) | 306 | else if (!dev->power.qos) |
306 | ret = dev_pm_qos_constraints_allocate(dev); | 307 | ret = dev_pm_qos_constraints_allocate(dev); |
307 | 308 | ||
309 | trace_dev_pm_qos_add_request(dev_name(dev), type, value); | ||
308 | if (!ret) { | 310 | if (!ret) { |
309 | req->dev = dev; | 311 | req->dev = dev; |
310 | req->type = type; | 312 | req->type = type; |
@@ -349,6 +351,8 @@ static int __dev_pm_qos_update_request(struct dev_pm_qos_request *req, | |||
349 | return -EINVAL; | 351 | return -EINVAL; |
350 | } | 352 | } |
351 | 353 | ||
354 | trace_dev_pm_qos_update_request(dev_name(req->dev), req->type, | ||
355 | new_value); | ||
352 | if (curr_value != new_value) | 356 | if (curr_value != new_value) |
353 | ret = apply_constraint(req, PM_QOS_UPDATE_REQ, new_value); | 357 | ret = apply_constraint(req, PM_QOS_UPDATE_REQ, new_value); |
354 | 358 | ||
@@ -398,6 +402,8 @@ static int __dev_pm_qos_remove_request(struct dev_pm_qos_request *req) | |||
398 | if (IS_ERR_OR_NULL(req->dev->power.qos)) | 402 | if (IS_ERR_OR_NULL(req->dev->power.qos)) |
399 | return -ENODEV; | 403 | return -ENODEV; |
400 | 404 | ||
405 | trace_dev_pm_qos_remove_request(dev_name(req->dev), req->type, | ||
406 | PM_QOS_DEFAULT_VALUE); | ||
401 | ret = apply_constraint(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE); | 407 | ret = apply_constraint(req, PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE); |
402 | memset(req, 0, sizeof(*req)); | 408 | memset(req, 0, sizeof(*req)); |
403 | return ret; | 409 | return ret; |
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index ef13ad08afb2..268a35097578 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c | |||
@@ -293,11 +293,8 @@ static int rpm_idle(struct device *dev, int rpmflags) | |||
293 | /* Pending requests need to be canceled. */ | 293 | /* Pending requests need to be canceled. */ |
294 | dev->power.request = RPM_REQ_NONE; | 294 | dev->power.request = RPM_REQ_NONE; |
295 | 295 | ||
296 | if (dev->power.no_callbacks) { | 296 | if (dev->power.no_callbacks) |
297 | /* Assume ->runtime_idle() callback would have suspended. */ | ||
298 | retval = rpm_suspend(dev, rpmflags); | ||
299 | goto out; | 297 | goto out; |
300 | } | ||
301 | 298 | ||
302 | /* Carry out an asynchronous or a synchronous idle notification. */ | 299 | /* Carry out an asynchronous or a synchronous idle notification. */ |
303 | if (rpmflags & RPM_ASYNC) { | 300 | if (rpmflags & RPM_ASYNC) { |
@@ -306,7 +303,8 @@ static int rpm_idle(struct device *dev, int rpmflags) | |||
306 | dev->power.request_pending = true; | 303 | dev->power.request_pending = true; |
307 | queue_work(pm_wq, &dev->power.work); | 304 | queue_work(pm_wq, &dev->power.work); |
308 | } | 305 | } |
309 | goto out; | 306 | trace_rpm_return_int(dev, _THIS_IP_, 0); |
307 | return 0; | ||
310 | } | 308 | } |
311 | 309 | ||
312 | dev->power.idle_notification = true; | 310 | dev->power.idle_notification = true; |
@@ -326,14 +324,14 @@ static int rpm_idle(struct device *dev, int rpmflags) | |||
326 | callback = dev->driver->pm->runtime_idle; | 324 | callback = dev->driver->pm->runtime_idle; |
327 | 325 | ||
328 | if (callback) | 326 | if (callback) |
329 | __rpm_callback(callback, dev); | 327 | retval = __rpm_callback(callback, dev); |
330 | 328 | ||
331 | dev->power.idle_notification = false; | 329 | dev->power.idle_notification = false; |
332 | wake_up_all(&dev->power.wait_queue); | 330 | wake_up_all(&dev->power.wait_queue); |
333 | 331 | ||
334 | out: | 332 | out: |
335 | trace_rpm_return_int(dev, _THIS_IP_, retval); | 333 | trace_rpm_return_int(dev, _THIS_IP_, retval); |
336 | return retval; | 334 | return retval ? retval : rpm_suspend(dev, rpmflags); |
337 | } | 335 | } |
338 | 336 | ||
339 | /** | 337 | /** |
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index 79715e7fa43e..2d56f4113ae7 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c | |||
@@ -659,7 +659,7 @@ void pm_wakeup_event(struct device *dev, unsigned int msec) | |||
659 | } | 659 | } |
660 | EXPORT_SYMBOL_GPL(pm_wakeup_event); | 660 | EXPORT_SYMBOL_GPL(pm_wakeup_event); |
661 | 661 | ||
662 | static void print_active_wakeup_sources(void) | 662 | void pm_print_active_wakeup_sources(void) |
663 | { | 663 | { |
664 | struct wakeup_source *ws; | 664 | struct wakeup_source *ws; |
665 | int active = 0; | 665 | int active = 0; |
@@ -683,6 +683,7 @@ static void print_active_wakeup_sources(void) | |||
683 | last_activity_ws->name); | 683 | last_activity_ws->name); |
684 | rcu_read_unlock(); | 684 | rcu_read_unlock(); |
685 | } | 685 | } |
686 | EXPORT_SYMBOL_GPL(pm_print_active_wakeup_sources); | ||
686 | 687 | ||
687 | /** | 688 | /** |
688 | * pm_wakeup_pending - Check if power transition in progress should be aborted. | 689 | * pm_wakeup_pending - Check if power transition in progress should be aborted. |
@@ -707,8 +708,10 @@ bool pm_wakeup_pending(void) | |||
707 | } | 708 | } |
708 | spin_unlock_irqrestore(&events_lock, flags); | 709 | spin_unlock_irqrestore(&events_lock, flags); |
709 | 710 | ||
710 | if (ret) | 711 | if (ret) { |
711 | print_active_wakeup_sources(); | 712 | pr_info("PM: Wakeup pending, aborting suspend\n"); |
713 | pm_print_active_wakeup_sources(); | ||
714 | } | ||
712 | 715 | ||
713 | return ret; | 716 | return ret; |
714 | } | 717 | } |
diff --git a/drivers/clk/x86/clk-lpt.c b/drivers/clk/x86/clk-lpt.c index 4f45eee9e33b..812f83f8b0c6 100644 --- a/drivers/clk/x86/clk-lpt.c +++ b/drivers/clk/x86/clk-lpt.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Intel Lynxpoint LPSS clocks. | 2 | * Intel Low Power Subsystem clocks. |
3 | * | 3 | * |
4 | * Copyright (C) 2013, Intel Corporation | 4 | * Copyright (C) 2013, Intel Corporation |
5 | * Authors: Mika Westerberg <mika.westerberg@linux.intel.com> | 5 | * Authors: Mika Westerberg <mika.westerberg@linux.intel.com> |
@@ -18,8 +18,6 @@ | |||
18 | #include <linux/platform_data/clk-lpss.h> | 18 | #include <linux/platform_data/clk-lpss.h> |
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | 20 | ||
21 | #define PRV_CLOCK_PARAMS 0x800 | ||
22 | |||
23 | static int lpt_clk_probe(struct platform_device *pdev) | 21 | static int lpt_clk_probe(struct platform_device *pdev) |
24 | { | 22 | { |
25 | struct lpss_clk_data *drvdata; | 23 | struct lpss_clk_data *drvdata; |
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm index a92440896868..de4d5d93c3fd 100644 --- a/drivers/cpufreq/Kconfig.arm +++ b/drivers/cpufreq/Kconfig.arm | |||
@@ -5,6 +5,7 @@ | |||
5 | config ARM_BIG_LITTLE_CPUFREQ | 5 | config ARM_BIG_LITTLE_CPUFREQ |
6 | tristate "Generic ARM big LITTLE CPUfreq driver" | 6 | tristate "Generic ARM big LITTLE CPUfreq driver" |
7 | depends on ARM_CPU_TOPOLOGY && PM_OPP && HAVE_CLK | 7 | depends on ARM_CPU_TOPOLOGY && PM_OPP && HAVE_CLK |
8 | select CPU_FREQ_TABLE | ||
8 | help | 9 | help |
9 | This enables the Generic CPUfreq driver for ARM big.LITTLE platforms. | 10 | This enables the Generic CPUfreq driver for ARM big.LITTLE platforms. |
10 | 11 | ||
@@ -18,6 +19,7 @@ config ARM_DT_BL_CPUFREQ | |||
18 | config ARM_EXYNOS_CPUFREQ | 19 | config ARM_EXYNOS_CPUFREQ |
19 | bool "SAMSUNG EXYNOS SoCs" | 20 | bool "SAMSUNG EXYNOS SoCs" |
20 | depends on ARCH_EXYNOS | 21 | depends on ARCH_EXYNOS |
22 | select CPU_FREQ_TABLE | ||
21 | default y | 23 | default y |
22 | help | 24 | help |
23 | This adds the CPUFreq driver common part for Samsung | 25 | This adds the CPUFreq driver common part for Samsung |
@@ -46,6 +48,7 @@ config ARM_EXYNOS5250_CPUFREQ | |||
46 | config ARM_EXYNOS5440_CPUFREQ | 48 | config ARM_EXYNOS5440_CPUFREQ |
47 | def_bool SOC_EXYNOS5440 | 49 | def_bool SOC_EXYNOS5440 |
48 | depends on HAVE_CLK && PM_OPP && OF | 50 | depends on HAVE_CLK && PM_OPP && OF |
51 | select CPU_FREQ_TABLE | ||
49 | help | 52 | help |
50 | This adds the CPUFreq driver for Samsung EXYNOS5440 | 53 | This adds the CPUFreq driver for Samsung EXYNOS5440 |
51 | SoC. The nature of exynos5440 clock controller is | 54 | SoC. The nature of exynos5440 clock controller is |
@@ -55,7 +58,6 @@ config ARM_EXYNOS5440_CPUFREQ | |||
55 | config ARM_HIGHBANK_CPUFREQ | 58 | config ARM_HIGHBANK_CPUFREQ |
56 | tristate "Calxeda Highbank-based" | 59 | tristate "Calxeda Highbank-based" |
57 | depends on ARCH_HIGHBANK | 60 | depends on ARCH_HIGHBANK |
58 | select CPU_FREQ_TABLE | ||
59 | select GENERIC_CPUFREQ_CPU0 | 61 | select GENERIC_CPUFREQ_CPU0 |
60 | select PM_OPP | 62 | select PM_OPP |
61 | select REGULATOR | 63 | select REGULATOR |
@@ -71,6 +73,7 @@ config ARM_IMX6Q_CPUFREQ | |||
71 | tristate "Freescale i.MX6Q cpufreq support" | 73 | tristate "Freescale i.MX6Q cpufreq support" |
72 | depends on SOC_IMX6Q | 74 | depends on SOC_IMX6Q |
73 | depends on REGULATOR_ANATOP | 75 | depends on REGULATOR_ANATOP |
76 | select CPU_FREQ_TABLE | ||
74 | help | 77 | help |
75 | This adds cpufreq driver support for Freescale i.MX6Q SOC. | 78 | This adds cpufreq driver support for Freescale i.MX6Q SOC. |
76 | 79 | ||
@@ -86,6 +89,7 @@ config ARM_INTEGRATOR | |||
86 | 89 | ||
87 | config ARM_KIRKWOOD_CPUFREQ | 90 | config ARM_KIRKWOOD_CPUFREQ |
88 | def_bool ARCH_KIRKWOOD && OF | 91 | def_bool ARCH_KIRKWOOD && OF |
92 | select CPU_FREQ_TABLE | ||
89 | help | 93 | help |
90 | This adds the CPUFreq driver for Marvell Kirkwood | 94 | This adds the CPUFreq driver for Marvell Kirkwood |
91 | SoCs. | 95 | SoCs. |
@@ -149,6 +153,7 @@ config ARM_S3C2412_CPUFREQ | |||
149 | config ARM_S3C2416_CPUFREQ | 153 | config ARM_S3C2416_CPUFREQ |
150 | bool "S3C2416 CPU Frequency scaling support" | 154 | bool "S3C2416 CPU Frequency scaling support" |
151 | depends on CPU_S3C2416 | 155 | depends on CPU_S3C2416 |
156 | select CPU_FREQ_TABLE | ||
152 | help | 157 | help |
153 | This adds the CPUFreq driver for the Samsung S3C2416 and | 158 | This adds the CPUFreq driver for the Samsung S3C2416 and |
154 | S3C2450 SoC. The S3C2416 supports changing the rate of the | 159 | S3C2450 SoC. The S3C2416 supports changing the rate of the |
@@ -179,6 +184,7 @@ config ARM_S3C2440_CPUFREQ | |||
179 | config ARM_S3C64XX_CPUFREQ | 184 | config ARM_S3C64XX_CPUFREQ |
180 | bool "Samsung S3C64XX" | 185 | bool "Samsung S3C64XX" |
181 | depends on CPU_S3C6410 | 186 | depends on CPU_S3C6410 |
187 | select CPU_FREQ_TABLE | ||
182 | default y | 188 | default y |
183 | help | 189 | help |
184 | This adds the CPUFreq driver for Samsung S3C6410 SoC. | 190 | This adds the CPUFreq driver for Samsung S3C6410 SoC. |
@@ -205,6 +211,15 @@ config ARM_SA1110_CPUFREQ | |||
205 | config ARM_SPEAR_CPUFREQ | 211 | config ARM_SPEAR_CPUFREQ |
206 | bool "SPEAr CPUFreq support" | 212 | bool "SPEAr CPUFreq support" |
207 | depends on PLAT_SPEAR | 213 | depends on PLAT_SPEAR |
214 | select CPU_FREQ_TABLE | ||
208 | default y | 215 | default y |
209 | help | 216 | help |
210 | This adds the CPUFreq driver support for SPEAr SOCs. | 217 | This adds the CPUFreq driver support for SPEAr SOCs. |
218 | |||
219 | config ARM_TEGRA_CPUFREQ | ||
220 | bool "TEGRA CPUFreq support" | ||
221 | depends on ARCH_TEGRA | ||
222 | select CPU_FREQ_TABLE | ||
223 | default y | ||
224 | help | ||
225 | This adds the CPUFreq driver support for TEGRA SOCs. | ||
diff --git a/drivers/cpufreq/Kconfig.powerpc b/drivers/cpufreq/Kconfig.powerpc index 9c926ca0d718..25ca9db62e09 100644 --- a/drivers/cpufreq/Kconfig.powerpc +++ b/drivers/cpufreq/Kconfig.powerpc | |||
@@ -1,6 +1,7 @@ | |||
1 | config CPU_FREQ_CBE | 1 | config CPU_FREQ_CBE |
2 | tristate "CBE frequency scaling" | 2 | tristate "CBE frequency scaling" |
3 | depends on CBE_RAS && PPC_CELL | 3 | depends on CBE_RAS && PPC_CELL |
4 | select CPU_FREQ_TABLE | ||
4 | default m | 5 | default m |
5 | help | 6 | help |
6 | This adds the cpufreq driver for Cell BE processors. | 7 | This adds the cpufreq driver for Cell BE processors. |
@@ -23,3 +24,39 @@ config CPU_FREQ_MAPLE | |||
23 | help | 24 | help |
24 | This adds support for frequency switching on Maple 970FX | 25 | This adds support for frequency switching on Maple 970FX |
25 | Evaluation Board and compatible boards (IBM JS2x blades). | 26 | Evaluation Board and compatible boards (IBM JS2x blades). |
27 | |||
28 | config PPC_CORENET_CPUFREQ | ||
29 | tristate "CPU frequency scaling driver for Freescale E500MC SoCs" | ||
30 | depends on PPC_E500MC && OF && COMMON_CLK | ||
31 | select CPU_FREQ_TABLE | ||
32 | select CLK_PPC_CORENET | ||
33 | help | ||
34 | This adds the CPUFreq driver support for Freescale e500mc, | ||
35 | e5500 and e6500 series SoCs which are capable of changing | ||
36 | the CPU's frequency dynamically. | ||
37 | |||
38 | config CPU_FREQ_PMAC | ||
39 | bool "Support for Apple PowerBooks" | ||
40 | depends on ADB_PMU && PPC32 | ||
41 | select CPU_FREQ_TABLE | ||
42 | help | ||
43 | This adds support for frequency switching on Apple PowerBooks, | ||
44 | this currently includes some models of iBook & Titanium | ||
45 | PowerBook. | ||
46 | |||
47 | config CPU_FREQ_PMAC64 | ||
48 | bool "Support for some Apple G5s" | ||
49 | depends on PPC_PMAC && PPC64 | ||
50 | select CPU_FREQ_TABLE | ||
51 | help | ||
52 | This adds support for frequency switching on Apple iMac G5, | ||
53 | and some of the more recent desktop G5 machines as well. | ||
54 | |||
55 | config PPC_PASEMI_CPUFREQ | ||
56 | bool "Support for PA Semi PWRficient" | ||
57 | depends on PPC_PASEMI | ||
58 | select CPU_FREQ_TABLE | ||
59 | default y | ||
60 | help | ||
61 | This adds the support for frequency switching on PA Semi | ||
62 | PWRficient processors. | ||
diff --git a/drivers/cpufreq/Kconfig.x86 b/drivers/cpufreq/Kconfig.x86 index 6bd63d63d356..e2b6eabef221 100644 --- a/drivers/cpufreq/Kconfig.x86 +++ b/drivers/cpufreq/Kconfig.x86 | |||
@@ -132,6 +132,7 @@ config X86_POWERNOW_K8 | |||
132 | config X86_AMD_FREQ_SENSITIVITY | 132 | config X86_AMD_FREQ_SENSITIVITY |
133 | tristate "AMD frequency sensitivity feedback powersave bias" | 133 | tristate "AMD frequency sensitivity feedback powersave bias" |
134 | depends on CPU_FREQ_GOV_ONDEMAND && X86_ACPI_CPUFREQ && CPU_SUP_AMD | 134 | depends on CPU_FREQ_GOV_ONDEMAND && X86_ACPI_CPUFREQ && CPU_SUP_AMD |
135 | select CPU_FREQ_TABLE | ||
135 | help | 136 | help |
136 | This adds AMD-specific powersave bias function to the ondemand | 137 | This adds AMD-specific powersave bias function to the ondemand |
137 | governor, which allows it to make more power-conscious frequency | 138 | governor, which allows it to make more power-conscious frequency |
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index 6ad0b913ca17..d345b5a7aa71 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile | |||
@@ -76,7 +76,7 @@ obj-$(CONFIG_ARM_S5PV210_CPUFREQ) += s5pv210-cpufreq.o | |||
76 | obj-$(CONFIG_ARM_SA1100_CPUFREQ) += sa1100-cpufreq.o | 76 | obj-$(CONFIG_ARM_SA1100_CPUFREQ) += sa1100-cpufreq.o |
77 | obj-$(CONFIG_ARM_SA1110_CPUFREQ) += sa1110-cpufreq.o | 77 | obj-$(CONFIG_ARM_SA1110_CPUFREQ) += sa1110-cpufreq.o |
78 | obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o | 78 | obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o |
79 | obj-$(CONFIG_ARCH_TEGRA) += tegra-cpufreq.o | 79 | obj-$(CONFIG_ARM_TEGRA_CPUFREQ) += tegra-cpufreq.o |
80 | 80 | ||
81 | ################################################################################## | 81 | ################################################################################## |
82 | # PowerPC platform drivers | 82 | # PowerPC platform drivers |
@@ -84,11 +84,15 @@ obj-$(CONFIG_CPU_FREQ_CBE) += ppc-cbe-cpufreq.o | |||
84 | ppc-cbe-cpufreq-y += ppc_cbe_cpufreq_pervasive.o ppc_cbe_cpufreq.o | 84 | ppc-cbe-cpufreq-y += ppc_cbe_cpufreq_pervasive.o ppc_cbe_cpufreq.o |
85 | obj-$(CONFIG_CPU_FREQ_CBE_PMI) += ppc_cbe_cpufreq_pmi.o | 85 | obj-$(CONFIG_CPU_FREQ_CBE_PMI) += ppc_cbe_cpufreq_pmi.o |
86 | obj-$(CONFIG_CPU_FREQ_MAPLE) += maple-cpufreq.o | 86 | obj-$(CONFIG_CPU_FREQ_MAPLE) += maple-cpufreq.o |
87 | obj-$(CONFIG_PPC_CORENET_CPUFREQ) += ppc-corenet-cpufreq.o | ||
88 | obj-$(CONFIG_CPU_FREQ_PMAC) += pmac32-cpufreq.o | ||
89 | obj-$(CONFIG_CPU_FREQ_PMAC64) += pmac64-cpufreq.o | ||
90 | obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += pasemi-cpufreq.o | ||
87 | 91 | ||
88 | ################################################################################## | 92 | ################################################################################## |
89 | # Other platform drivers | 93 | # Other platform drivers |
90 | obj-$(CONFIG_AVR32_AT32AP_CPUFREQ) += at32ap-cpufreq.o | 94 | obj-$(CONFIG_AVR32_AT32AP_CPUFREQ) += at32ap-cpufreq.o |
91 | obj-$(CONFIG_BLACKFIN) += blackfin-cpufreq.o | 95 | obj-$(CONFIG_BFIN_CPU_FREQ) += blackfin-cpufreq.o |
92 | obj-$(CONFIG_CRIS_MACH_ARTPEC3) += cris-artpec3-cpufreq.o | 96 | obj-$(CONFIG_CRIS_MACH_ARTPEC3) += cris-artpec3-cpufreq.o |
93 | obj-$(CONFIG_ETRAXFS) += cris-etraxfs-cpufreq.o | 97 | obj-$(CONFIG_ETRAXFS) += cris-etraxfs-cpufreq.o |
94 | obj-$(CONFIG_IA64_ACPI_CPUFREQ) += ia64-acpi-cpufreq.o | 98 | obj-$(CONFIG_IA64_ACPI_CPUFREQ) += ia64-acpi-cpufreq.o |
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index edc089e9d0c4..39264020b88a 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c | |||
@@ -70,6 +70,7 @@ struct acpi_cpufreq_data { | |||
70 | struct cpufreq_frequency_table *freq_table; | 70 | struct cpufreq_frequency_table *freq_table; |
71 | unsigned int resume; | 71 | unsigned int resume; |
72 | unsigned int cpu_feature; | 72 | unsigned int cpu_feature; |
73 | cpumask_var_t freqdomain_cpus; | ||
73 | }; | 74 | }; |
74 | 75 | ||
75 | static DEFINE_PER_CPU(struct acpi_cpufreq_data *, acfreq_data); | 76 | static DEFINE_PER_CPU(struct acpi_cpufreq_data *, acfreq_data); |
@@ -176,6 +177,15 @@ static struct global_attr global_boost = __ATTR(boost, 0644, | |||
176 | show_global_boost, | 177 | show_global_boost, |
177 | store_global_boost); | 178 | store_global_boost); |
178 | 179 | ||
180 | static ssize_t show_freqdomain_cpus(struct cpufreq_policy *policy, char *buf) | ||
181 | { | ||
182 | struct acpi_cpufreq_data *data = per_cpu(acfreq_data, policy->cpu); | ||
183 | |||
184 | return cpufreq_show_cpus(data->freqdomain_cpus, buf); | ||
185 | } | ||
186 | |||
187 | cpufreq_freq_attr_ro(freqdomain_cpus); | ||
188 | |||
179 | #ifdef CONFIG_X86_ACPI_CPUFREQ_CPB | 189 | #ifdef CONFIG_X86_ACPI_CPUFREQ_CPB |
180 | static ssize_t store_cpb(struct cpufreq_policy *policy, const char *buf, | 190 | static ssize_t store_cpb(struct cpufreq_policy *policy, const char *buf, |
181 | size_t count) | 191 | size_t count) |
@@ -232,7 +242,7 @@ static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data) | |||
232 | perf = data->acpi_data; | 242 | perf = data->acpi_data; |
233 | 243 | ||
234 | for (i = 0; data->freq_table[i].frequency != CPUFREQ_TABLE_END; i++) { | 244 | for (i = 0; data->freq_table[i].frequency != CPUFREQ_TABLE_END; i++) { |
235 | if (msr == perf->states[data->freq_table[i].index].status) | 245 | if (msr == perf->states[data->freq_table[i].driver_data].status) |
236 | return data->freq_table[i].frequency; | 246 | return data->freq_table[i].frequency; |
237 | } | 247 | } |
238 | return data->freq_table[0].frequency; | 248 | return data->freq_table[0].frequency; |
@@ -442,7 +452,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
442 | goto out; | 452 | goto out; |
443 | } | 453 | } |
444 | 454 | ||
445 | next_perf_state = data->freq_table[next_state].index; | 455 | next_perf_state = data->freq_table[next_state].driver_data; |
446 | if (perf->state == next_perf_state) { | 456 | if (perf->state == next_perf_state) { |
447 | if (unlikely(data->resume)) { | 457 | if (unlikely(data->resume)) { |
448 | pr_debug("Called after resume, resetting to P%d\n", | 458 | pr_debug("Called after resume, resetting to P%d\n", |
@@ -494,12 +504,14 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
494 | pr_debug("acpi_cpufreq_target failed (%d)\n", | 504 | pr_debug("acpi_cpufreq_target failed (%d)\n", |
495 | policy->cpu); | 505 | policy->cpu); |
496 | result = -EAGAIN; | 506 | result = -EAGAIN; |
497 | goto out; | 507 | freqs.new = freqs.old; |
498 | } | 508 | } |
499 | } | 509 | } |
500 | 510 | ||
501 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 511 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
502 | perf->state = next_perf_state; | 512 | |
513 | if (!result) | ||
514 | perf->state = next_perf_state; | ||
503 | 515 | ||
504 | out: | 516 | out: |
505 | return result; | 517 | return result; |
@@ -702,6 +714,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
702 | if (!data) | 714 | if (!data) |
703 | return -ENOMEM; | 715 | return -ENOMEM; |
704 | 716 | ||
717 | if (!zalloc_cpumask_var(&data->freqdomain_cpus, GFP_KERNEL)) { | ||
718 | result = -ENOMEM; | ||
719 | goto err_free; | ||
720 | } | ||
721 | |||
705 | data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu); | 722 | data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu); |
706 | per_cpu(acfreq_data, cpu) = data; | 723 | per_cpu(acfreq_data, cpu) = data; |
707 | 724 | ||
@@ -710,7 +727,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
710 | 727 | ||
711 | result = acpi_processor_register_performance(data->acpi_data, cpu); | 728 | result = acpi_processor_register_performance(data->acpi_data, cpu); |
712 | if (result) | 729 | if (result) |
713 | goto err_free; | 730 | goto err_free_mask; |
714 | 731 | ||
715 | perf = data->acpi_data; | 732 | perf = data->acpi_data; |
716 | policy->shared_type = perf->shared_type; | 733 | policy->shared_type = perf->shared_type; |
@@ -723,6 +740,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
723 | policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) { | 740 | policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) { |
724 | cpumask_copy(policy->cpus, perf->shared_cpu_map); | 741 | cpumask_copy(policy->cpus, perf->shared_cpu_map); |
725 | } | 742 | } |
743 | cpumask_copy(data->freqdomain_cpus, perf->shared_cpu_map); | ||
726 | 744 | ||
727 | #ifdef CONFIG_SMP | 745 | #ifdef CONFIG_SMP |
728 | dmi_check_system(sw_any_bug_dmi_table); | 746 | dmi_check_system(sw_any_bug_dmi_table); |
@@ -734,6 +752,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
734 | if (check_amd_hwpstate_cpu(cpu) && !acpi_pstate_strict) { | 752 | if (check_amd_hwpstate_cpu(cpu) && !acpi_pstate_strict) { |
735 | cpumask_clear(policy->cpus); | 753 | cpumask_clear(policy->cpus); |
736 | cpumask_set_cpu(cpu, policy->cpus); | 754 | cpumask_set_cpu(cpu, policy->cpus); |
755 | cpumask_copy(data->freqdomain_cpus, cpu_sibling_mask(cpu)); | ||
737 | policy->shared_type = CPUFREQ_SHARED_TYPE_HW; | 756 | policy->shared_type = CPUFREQ_SHARED_TYPE_HW; |
738 | pr_info_once(PFX "overriding BIOS provided _PSD data\n"); | 757 | pr_info_once(PFX "overriding BIOS provided _PSD data\n"); |
739 | } | 758 | } |
@@ -811,7 +830,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
811 | data->freq_table[valid_states-1].frequency / 1000) | 830 | data->freq_table[valid_states-1].frequency / 1000) |
812 | continue; | 831 | continue; |
813 | 832 | ||
814 | data->freq_table[valid_states].index = i; | 833 | data->freq_table[valid_states].driver_data = i; |
815 | data->freq_table[valid_states].frequency = | 834 | data->freq_table[valid_states].frequency = |
816 | perf->states[i].core_frequency * 1000; | 835 | perf->states[i].core_frequency * 1000; |
817 | valid_states++; | 836 | valid_states++; |
@@ -868,6 +887,8 @@ err_freqfree: | |||
868 | kfree(data->freq_table); | 887 | kfree(data->freq_table); |
869 | err_unreg: | 888 | err_unreg: |
870 | acpi_processor_unregister_performance(perf, cpu); | 889 | acpi_processor_unregister_performance(perf, cpu); |
890 | err_free_mask: | ||
891 | free_cpumask_var(data->freqdomain_cpus); | ||
871 | err_free: | 892 | err_free: |
872 | kfree(data); | 893 | kfree(data); |
873 | per_cpu(acfreq_data, cpu) = NULL; | 894 | per_cpu(acfreq_data, cpu) = NULL; |
@@ -886,6 +907,7 @@ static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy) | |||
886 | per_cpu(acfreq_data, policy->cpu) = NULL; | 907 | per_cpu(acfreq_data, policy->cpu) = NULL; |
887 | acpi_processor_unregister_performance(data->acpi_data, | 908 | acpi_processor_unregister_performance(data->acpi_data, |
888 | policy->cpu); | 909 | policy->cpu); |
910 | free_cpumask_var(data->freqdomain_cpus); | ||
889 | kfree(data->freq_table); | 911 | kfree(data->freq_table); |
890 | kfree(data); | 912 | kfree(data); |
891 | } | 913 | } |
@@ -906,6 +928,7 @@ static int acpi_cpufreq_resume(struct cpufreq_policy *policy) | |||
906 | 928 | ||
907 | static struct freq_attr *acpi_cpufreq_attr[] = { | 929 | static struct freq_attr *acpi_cpufreq_attr[] = { |
908 | &cpufreq_freq_attr_scaling_available_freqs, | 930 | &cpufreq_freq_attr_scaling_available_freqs, |
931 | &freqdomain_cpus, | ||
909 | NULL, /* this is a placeholder for cpb, do not remove */ | 932 | NULL, /* this is a placeholder for cpb, do not remove */ |
910 | NULL, | 933 | NULL, |
911 | }; | 934 | }; |
@@ -947,7 +970,7 @@ static void __init acpi_cpufreq_boost_init(void) | |||
947 | /* We create the boost file in any case, though for systems without | 970 | /* We create the boost file in any case, though for systems without |
948 | * hardware support it will be read-only and hardwired to return 0. | 971 | * hardware support it will be read-only and hardwired to return 0. |
949 | */ | 972 | */ |
950 | if (sysfs_create_file(cpufreq_global_kobject, &(global_boost.attr))) | 973 | if (cpufreq_sysfs_create_file(&(global_boost.attr))) |
951 | pr_warn(PFX "could not register global boost sysfs file\n"); | 974 | pr_warn(PFX "could not register global boost sysfs file\n"); |
952 | else | 975 | else |
953 | pr_debug("registered global boost sysfs file\n"); | 976 | pr_debug("registered global boost sysfs file\n"); |
@@ -955,7 +978,7 @@ static void __init acpi_cpufreq_boost_init(void) | |||
955 | 978 | ||
956 | static void __exit acpi_cpufreq_boost_exit(void) | 979 | static void __exit acpi_cpufreq_boost_exit(void) |
957 | { | 980 | { |
958 | sysfs_remove_file(cpufreq_global_kobject, &(global_boost.attr)); | 981 | cpufreq_sysfs_remove_file(&(global_boost.attr)); |
959 | 982 | ||
960 | if (msrs) { | 983 | if (msrs) { |
961 | unregister_cpu_notifier(&boost_nb); | 984 | unregister_cpu_notifier(&boost_nb); |
@@ -1034,4 +1057,11 @@ static const struct x86_cpu_id acpi_cpufreq_ids[] = { | |||
1034 | }; | 1057 | }; |
1035 | MODULE_DEVICE_TABLE(x86cpu, acpi_cpufreq_ids); | 1058 | MODULE_DEVICE_TABLE(x86cpu, acpi_cpufreq_ids); |
1036 | 1059 | ||
1060 | static const struct acpi_device_id processor_device_ids[] = { | ||
1061 | {ACPI_PROCESSOR_OBJECT_HID, }, | ||
1062 | {ACPI_PROCESSOR_DEVICE_HID, }, | ||
1063 | {}, | ||
1064 | }; | ||
1065 | MODULE_DEVICE_TABLE(acpi, processor_device_ids); | ||
1066 | |||
1037 | MODULE_ALIAS("acpi"); | 1067 | MODULE_ALIAS("acpi"); |
diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c index 5d7f53fcd6f5..3549f0784af1 100644 --- a/drivers/cpufreq/arm_big_little.c +++ b/drivers/cpufreq/arm_big_little.c | |||
@@ -84,11 +84,9 @@ static int bL_cpufreq_set_target(struct cpufreq_policy *policy, | |||
84 | ret = clk_set_rate(clk[cur_cluster], freqs.new * 1000); | 84 | ret = clk_set_rate(clk[cur_cluster], freqs.new * 1000); |
85 | if (ret) { | 85 | if (ret) { |
86 | pr_err("clk_set_rate failed: %d\n", ret); | 86 | pr_err("clk_set_rate failed: %d\n", ret); |
87 | return ret; | 87 | freqs.new = freqs.old; |
88 | } | 88 | } |
89 | 89 | ||
90 | policy->cur = freqs.new; | ||
91 | |||
92 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 90 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
93 | 91 | ||
94 | return ret; | 92 | return ret; |
diff --git a/drivers/cpufreq/blackfin-cpufreq.c b/drivers/cpufreq/blackfin-cpufreq.c index 995511e80bef..9cdbbd278a80 100644 --- a/drivers/cpufreq/blackfin-cpufreq.c +++ b/drivers/cpufreq/blackfin-cpufreq.c | |||
@@ -20,23 +20,23 @@ | |||
20 | 20 | ||
21 | 21 | ||
22 | /* this is the table of CCLK frequencies, in Hz */ | 22 | /* this is the table of CCLK frequencies, in Hz */ |
23 | /* .index is the entry in the auxiliary dpm_state_table[] */ | 23 | /* .driver_data is the entry in the auxiliary dpm_state_table[] */ |
24 | static struct cpufreq_frequency_table bfin_freq_table[] = { | 24 | static struct cpufreq_frequency_table bfin_freq_table[] = { |
25 | { | 25 | { |
26 | .frequency = CPUFREQ_TABLE_END, | 26 | .frequency = CPUFREQ_TABLE_END, |
27 | .index = 0, | 27 | .driver_data = 0, |
28 | }, | 28 | }, |
29 | { | 29 | { |
30 | .frequency = CPUFREQ_TABLE_END, | 30 | .frequency = CPUFREQ_TABLE_END, |
31 | .index = 1, | 31 | .driver_data = 1, |
32 | }, | 32 | }, |
33 | { | 33 | { |
34 | .frequency = CPUFREQ_TABLE_END, | 34 | .frequency = CPUFREQ_TABLE_END, |
35 | .index = 2, | 35 | .driver_data = 2, |
36 | }, | 36 | }, |
37 | { | 37 | { |
38 | .frequency = CPUFREQ_TABLE_END, | 38 | .frequency = CPUFREQ_TABLE_END, |
39 | .index = 0, | 39 | .driver_data = 0, |
40 | }, | 40 | }, |
41 | }; | 41 | }; |
42 | 42 | ||
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 2d53f47d1747..6a015ada5285 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -3,6 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2001 Russell King | 4 | * Copyright (C) 2001 Russell King |
5 | * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> | 5 | * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> |
6 | * (C) 2013 Viresh Kumar <viresh.kumar@linaro.org> | ||
6 | * | 7 | * |
7 | * Oct 2005 - Ashok Raj <ashok.raj@intel.com> | 8 | * Oct 2005 - Ashok Raj <ashok.raj@intel.com> |
8 | * Added handling for CPU hotplug | 9 | * Added handling for CPU hotplug |
@@ -12,12 +13,13 @@ | |||
12 | * This program is free software; you can redistribute it and/or modify | 13 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License version 2 as | 14 | * it under the terms of the GNU General Public License version 2 as |
14 | * published by the Free Software Foundation. | 15 | * published by the Free Software Foundation. |
15 | * | ||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 18 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
19 | 19 | ||
20 | #include <asm/cputime.h> | ||
20 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/kernel_stat.h> | ||
21 | #include <linux/module.h> | 23 | #include <linux/module.h> |
22 | #include <linux/init.h> | 24 | #include <linux/init.h> |
23 | #include <linux/notifier.h> | 25 | #include <linux/notifier.h> |
@@ -25,6 +27,7 @@ | |||
25 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
26 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
27 | #include <linux/spinlock.h> | 29 | #include <linux/spinlock.h> |
30 | #include <linux/tick.h> | ||
28 | #include <linux/device.h> | 31 | #include <linux/device.h> |
29 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
30 | #include <linux/cpu.h> | 33 | #include <linux/cpu.h> |
@@ -41,11 +44,13 @@ | |||
41 | */ | 44 | */ |
42 | static struct cpufreq_driver *cpufreq_driver; | 45 | static struct cpufreq_driver *cpufreq_driver; |
43 | static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data); | 46 | static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data); |
47 | static DEFINE_RWLOCK(cpufreq_driver_lock); | ||
48 | static DEFINE_MUTEX(cpufreq_governor_lock); | ||
49 | |||
44 | #ifdef CONFIG_HOTPLUG_CPU | 50 | #ifdef CONFIG_HOTPLUG_CPU |
45 | /* This one keeps track of the previously set governor of a removed CPU */ | 51 | /* This one keeps track of the previously set governor of a removed CPU */ |
46 | static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); | 52 | static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); |
47 | #endif | 53 | #endif |
48 | static DEFINE_RWLOCK(cpufreq_driver_lock); | ||
49 | 54 | ||
50 | /* | 55 | /* |
51 | * cpu_policy_rwsem is a per CPU reader-writer semaphore designed to cure | 56 | * cpu_policy_rwsem is a per CPU reader-writer semaphore designed to cure |
@@ -132,6 +137,51 @@ bool have_governor_per_policy(void) | |||
132 | { | 137 | { |
133 | return cpufreq_driver->have_governor_per_policy; | 138 | return cpufreq_driver->have_governor_per_policy; |
134 | } | 139 | } |
140 | EXPORT_SYMBOL_GPL(have_governor_per_policy); | ||
141 | |||
142 | struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy) | ||
143 | { | ||
144 | if (have_governor_per_policy()) | ||
145 | return &policy->kobj; | ||
146 | else | ||
147 | return cpufreq_global_kobject; | ||
148 | } | ||
149 | EXPORT_SYMBOL_GPL(get_governor_parent_kobj); | ||
150 | |||
151 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) | ||
152 | { | ||
153 | u64 idle_time; | ||
154 | u64 cur_wall_time; | ||
155 | u64 busy_time; | ||
156 | |||
157 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); | ||
158 | |||
159 | busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER]; | ||
160 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM]; | ||
161 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ]; | ||
162 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ]; | ||
163 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL]; | ||
164 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE]; | ||
165 | |||
166 | idle_time = cur_wall_time - busy_time; | ||
167 | if (wall) | ||
168 | *wall = cputime_to_usecs(cur_wall_time); | ||
169 | |||
170 | return cputime_to_usecs(idle_time); | ||
171 | } | ||
172 | |||
173 | u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy) | ||
174 | { | ||
175 | u64 idle_time = get_cpu_idle_time_us(cpu, io_busy ? wall : NULL); | ||
176 | |||
177 | if (idle_time == -1ULL) | ||
178 | return get_cpu_idle_time_jiffy(cpu, wall); | ||
179 | else if (!io_busy) | ||
180 | idle_time += get_cpu_iowait_time_us(cpu, wall); | ||
181 | |||
182 | return idle_time; | ||
183 | } | ||
184 | EXPORT_SYMBOL_GPL(get_cpu_idle_time); | ||
135 | 185 | ||
136 | static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs) | 186 | static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs) |
137 | { | 187 | { |
@@ -150,7 +200,6 @@ static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs) | |||
150 | if (!try_module_get(cpufreq_driver->owner)) | 200 | if (!try_module_get(cpufreq_driver->owner)) |
151 | goto err_out_unlock; | 201 | goto err_out_unlock; |
152 | 202 | ||
153 | |||
154 | /* get the CPU */ | 203 | /* get the CPU */ |
155 | data = per_cpu(cpufreq_cpu_data, cpu); | 204 | data = per_cpu(cpufreq_cpu_data, cpu); |
156 | 205 | ||
@@ -220,7 +269,7 @@ static void cpufreq_cpu_put_sysfs(struct cpufreq_policy *data) | |||
220 | */ | 269 | */ |
221 | #ifndef CONFIG_SMP | 270 | #ifndef CONFIG_SMP |
222 | static unsigned long l_p_j_ref; | 271 | static unsigned long l_p_j_ref; |
223 | static unsigned int l_p_j_ref_freq; | 272 | static unsigned int l_p_j_ref_freq; |
224 | 273 | ||
225 | static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) | 274 | static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) |
226 | { | 275 | { |
@@ -233,7 +282,7 @@ static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) | |||
233 | pr_debug("saving %lu as reference value for loops_per_jiffy; " | 282 | pr_debug("saving %lu as reference value for loops_per_jiffy; " |
234 | "freq is %u kHz\n", l_p_j_ref, l_p_j_ref_freq); | 283 | "freq is %u kHz\n", l_p_j_ref, l_p_j_ref_freq); |
235 | } | 284 | } |
236 | if ((val == CPUFREQ_POSTCHANGE && ci->old != ci->new) || | 285 | if ((val == CPUFREQ_POSTCHANGE && ci->old != ci->new) || |
237 | (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) { | 286 | (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) { |
238 | loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, | 287 | loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, |
239 | ci->new); | 288 | ci->new); |
@@ -248,8 +297,7 @@ static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) | |||
248 | } | 297 | } |
249 | #endif | 298 | #endif |
250 | 299 | ||
251 | 300 | static void __cpufreq_notify_transition(struct cpufreq_policy *policy, | |
252 | void __cpufreq_notify_transition(struct cpufreq_policy *policy, | ||
253 | struct cpufreq_freqs *freqs, unsigned int state) | 301 | struct cpufreq_freqs *freqs, unsigned int state) |
254 | { | 302 | { |
255 | BUG_ON(irqs_disabled()); | 303 | BUG_ON(irqs_disabled()); |
@@ -264,6 +312,12 @@ void __cpufreq_notify_transition(struct cpufreq_policy *policy, | |||
264 | switch (state) { | 312 | switch (state) { |
265 | 313 | ||
266 | case CPUFREQ_PRECHANGE: | 314 | case CPUFREQ_PRECHANGE: |
315 | if (WARN(policy->transition_ongoing, | ||
316 | "In middle of another frequency transition\n")) | ||
317 | return; | ||
318 | |||
319 | policy->transition_ongoing = true; | ||
320 | |||
267 | /* detect if the driver reported a value as "old frequency" | 321 | /* detect if the driver reported a value as "old frequency" |
268 | * which is not equal to what the cpufreq core thinks is | 322 | * which is not equal to what the cpufreq core thinks is |
269 | * "old frequency". | 323 | * "old frequency". |
@@ -283,6 +337,12 @@ void __cpufreq_notify_transition(struct cpufreq_policy *policy, | |||
283 | break; | 337 | break; |
284 | 338 | ||
285 | case CPUFREQ_POSTCHANGE: | 339 | case CPUFREQ_POSTCHANGE: |
340 | if (WARN(!policy->transition_ongoing, | ||
341 | "No frequency transition in progress\n")) | ||
342 | return; | ||
343 | |||
344 | policy->transition_ongoing = false; | ||
345 | |||
286 | adjust_jiffies(CPUFREQ_POSTCHANGE, freqs); | 346 | adjust_jiffies(CPUFREQ_POSTCHANGE, freqs); |
287 | pr_debug("FREQ: %lu - CPU: %lu", (unsigned long)freqs->new, | 347 | pr_debug("FREQ: %lu - CPU: %lu", (unsigned long)freqs->new, |
288 | (unsigned long)freqs->cpu); | 348 | (unsigned long)freqs->cpu); |
@@ -294,6 +354,7 @@ void __cpufreq_notify_transition(struct cpufreq_policy *policy, | |||
294 | break; | 354 | break; |
295 | } | 355 | } |
296 | } | 356 | } |
357 | |||
297 | /** | 358 | /** |
298 | * cpufreq_notify_transition - call notifier chain and adjust_jiffies | 359 | * cpufreq_notify_transition - call notifier chain and adjust_jiffies |
299 | * on frequency transition. | 360 | * on frequency transition. |
@@ -311,7 +372,6 @@ void cpufreq_notify_transition(struct cpufreq_policy *policy, | |||
311 | EXPORT_SYMBOL_GPL(cpufreq_notify_transition); | 372 | EXPORT_SYMBOL_GPL(cpufreq_notify_transition); |
312 | 373 | ||
313 | 374 | ||
314 | |||
315 | /********************************************************************* | 375 | /********************************************************************* |
316 | * SYSFS INTERFACE * | 376 | * SYSFS INTERFACE * |
317 | *********************************************************************/ | 377 | *********************************************************************/ |
@@ -376,7 +436,6 @@ out: | |||
376 | return err; | 436 | return err; |
377 | } | 437 | } |
378 | 438 | ||
379 | |||
380 | /** | 439 | /** |
381 | * cpufreq_per_cpu_attr_read() / show_##file_name() - | 440 | * cpufreq_per_cpu_attr_read() / show_##file_name() - |
382 | * print out cpufreq information | 441 | * print out cpufreq information |
@@ -441,7 +500,6 @@ static ssize_t show_cpuinfo_cur_freq(struct cpufreq_policy *policy, | |||
441 | return sprintf(buf, "%u\n", cur_freq); | 500 | return sprintf(buf, "%u\n", cur_freq); |
442 | } | 501 | } |
443 | 502 | ||
444 | |||
445 | /** | 503 | /** |
446 | * show_scaling_governor - show the current policy for the specified CPU | 504 | * show_scaling_governor - show the current policy for the specified CPU |
447 | */ | 505 | */ |
@@ -457,7 +515,6 @@ static ssize_t show_scaling_governor(struct cpufreq_policy *policy, char *buf) | |||
457 | return -EINVAL; | 515 | return -EINVAL; |
458 | } | 516 | } |
459 | 517 | ||
460 | |||
461 | /** | 518 | /** |
462 | * store_scaling_governor - store policy for the specified CPU | 519 | * store_scaling_governor - store policy for the specified CPU |
463 | */ | 520 | */ |
@@ -480,8 +537,10 @@ static ssize_t store_scaling_governor(struct cpufreq_policy *policy, | |||
480 | &new_policy.governor)) | 537 | &new_policy.governor)) |
481 | return -EINVAL; | 538 | return -EINVAL; |
482 | 539 | ||
483 | /* Do not use cpufreq_set_policy here or the user_policy.max | 540 | /* |
484 | will be wrongly overridden */ | 541 | * Do not use cpufreq_set_policy here or the user_policy.max |
542 | * will be wrongly overridden | ||
543 | */ | ||
485 | ret = __cpufreq_set_policy(policy, &new_policy); | 544 | ret = __cpufreq_set_policy(policy, &new_policy); |
486 | 545 | ||
487 | policy->user_policy.policy = policy->policy; | 546 | policy->user_policy.policy = policy->policy; |
@@ -526,7 +585,7 @@ out: | |||
526 | return i; | 585 | return i; |
527 | } | 586 | } |
528 | 587 | ||
529 | static ssize_t show_cpus(const struct cpumask *mask, char *buf) | 588 | ssize_t cpufreq_show_cpus(const struct cpumask *mask, char *buf) |
530 | { | 589 | { |
531 | ssize_t i = 0; | 590 | ssize_t i = 0; |
532 | unsigned int cpu; | 591 | unsigned int cpu; |
@@ -541,6 +600,7 @@ static ssize_t show_cpus(const struct cpumask *mask, char *buf) | |||
541 | i += sprintf(&buf[i], "\n"); | 600 | i += sprintf(&buf[i], "\n"); |
542 | return i; | 601 | return i; |
543 | } | 602 | } |
603 | EXPORT_SYMBOL_GPL(cpufreq_show_cpus); | ||
544 | 604 | ||
545 | /** | 605 | /** |
546 | * show_related_cpus - show the CPUs affected by each transition even if | 606 | * show_related_cpus - show the CPUs affected by each transition even if |
@@ -548,7 +608,7 @@ static ssize_t show_cpus(const struct cpumask *mask, char *buf) | |||
548 | */ | 608 | */ |
549 | static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf) | 609 | static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf) |
550 | { | 610 | { |
551 | return show_cpus(policy->related_cpus, buf); | 611 | return cpufreq_show_cpus(policy->related_cpus, buf); |
552 | } | 612 | } |
553 | 613 | ||
554 | /** | 614 | /** |
@@ -556,7 +616,7 @@ static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf) | |||
556 | */ | 616 | */ |
557 | static ssize_t show_affected_cpus(struct cpufreq_policy *policy, char *buf) | 617 | static ssize_t show_affected_cpus(struct cpufreq_policy *policy, char *buf) |
558 | { | 618 | { |
559 | return show_cpus(policy->cpus, buf); | 619 | return cpufreq_show_cpus(policy->cpus, buf); |
560 | } | 620 | } |
561 | 621 | ||
562 | static ssize_t store_scaling_setspeed(struct cpufreq_policy *policy, | 622 | static ssize_t store_scaling_setspeed(struct cpufreq_policy *policy, |
@@ -630,9 +690,6 @@ static struct attribute *default_attrs[] = { | |||
630 | NULL | 690 | NULL |
631 | }; | 691 | }; |
632 | 692 | ||
633 | struct kobject *cpufreq_global_kobject; | ||
634 | EXPORT_SYMBOL(cpufreq_global_kobject); | ||
635 | |||
636 | #define to_policy(k) container_of(k, struct cpufreq_policy, kobj) | 693 | #define to_policy(k) container_of(k, struct cpufreq_policy, kobj) |
637 | #define to_attr(a) container_of(a, struct freq_attr, attr) | 694 | #define to_attr(a) container_of(a, struct freq_attr, attr) |
638 | 695 | ||
@@ -703,6 +760,49 @@ static struct kobj_type ktype_cpufreq = { | |||
703 | .release = cpufreq_sysfs_release, | 760 | .release = cpufreq_sysfs_release, |
704 | }; | 761 | }; |
705 | 762 | ||
763 | struct kobject *cpufreq_global_kobject; | ||
764 | EXPORT_SYMBOL(cpufreq_global_kobject); | ||
765 | |||
766 | static int cpufreq_global_kobject_usage; | ||
767 | |||
768 | int cpufreq_get_global_kobject(void) | ||
769 | { | ||
770 | if (!cpufreq_global_kobject_usage++) | ||
771 | return kobject_add(cpufreq_global_kobject, | ||
772 | &cpu_subsys.dev_root->kobj, "%s", "cpufreq"); | ||
773 | |||
774 | return 0; | ||
775 | } | ||
776 | EXPORT_SYMBOL(cpufreq_get_global_kobject); | ||
777 | |||
778 | void cpufreq_put_global_kobject(void) | ||
779 | { | ||
780 | if (!--cpufreq_global_kobject_usage) | ||
781 | kobject_del(cpufreq_global_kobject); | ||
782 | } | ||
783 | EXPORT_SYMBOL(cpufreq_put_global_kobject); | ||
784 | |||
785 | int cpufreq_sysfs_create_file(const struct attribute *attr) | ||
786 | { | ||
787 | int ret = cpufreq_get_global_kobject(); | ||
788 | |||
789 | if (!ret) { | ||
790 | ret = sysfs_create_file(cpufreq_global_kobject, attr); | ||
791 | if (ret) | ||
792 | cpufreq_put_global_kobject(); | ||
793 | } | ||
794 | |||
795 | return ret; | ||
796 | } | ||
797 | EXPORT_SYMBOL(cpufreq_sysfs_create_file); | ||
798 | |||
799 | void cpufreq_sysfs_remove_file(const struct attribute *attr) | ||
800 | { | ||
801 | sysfs_remove_file(cpufreq_global_kobject, attr); | ||
802 | cpufreq_put_global_kobject(); | ||
803 | } | ||
804 | EXPORT_SYMBOL(cpufreq_sysfs_remove_file); | ||
805 | |||
706 | /* symlink affected CPUs */ | 806 | /* symlink affected CPUs */ |
707 | static int cpufreq_add_dev_symlink(unsigned int cpu, | 807 | static int cpufreq_add_dev_symlink(unsigned int cpu, |
708 | struct cpufreq_policy *policy) | 808 | struct cpufreq_policy *policy) |
@@ -1005,7 +1105,8 @@ static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu) | |||
1005 | * Caller should already have policy_rwsem in write mode for this CPU. | 1105 | * Caller should already have policy_rwsem in write mode for this CPU. |
1006 | * This routine frees the rwsem before returning. | 1106 | * This routine frees the rwsem before returning. |
1007 | */ | 1107 | */ |
1008 | static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) | 1108 | static int __cpufreq_remove_dev(struct device *dev, |
1109 | struct subsys_interface *sif) | ||
1009 | { | 1110 | { |
1010 | unsigned int cpu = dev->id, ret, cpus; | 1111 | unsigned int cpu = dev->id, ret, cpus; |
1011 | unsigned long flags; | 1112 | unsigned long flags; |
@@ -1112,7 +1213,6 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif | |||
1112 | return 0; | 1213 | return 0; |
1113 | } | 1214 | } |
1114 | 1215 | ||
1115 | |||
1116 | static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) | 1216 | static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) |
1117 | { | 1217 | { |
1118 | unsigned int cpu = dev->id; | 1218 | unsigned int cpu = dev->id; |
@@ -1125,7 +1225,6 @@ static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) | |||
1125 | return retval; | 1225 | return retval; |
1126 | } | 1226 | } |
1127 | 1227 | ||
1128 | |||
1129 | static void handle_update(struct work_struct *work) | 1228 | static void handle_update(struct work_struct *work) |
1130 | { | 1229 | { |
1131 | struct cpufreq_policy *policy = | 1230 | struct cpufreq_policy *policy = |
@@ -1136,7 +1235,8 @@ static void handle_update(struct work_struct *work) | |||
1136 | } | 1235 | } |
1137 | 1236 | ||
1138 | /** | 1237 | /** |
1139 | * cpufreq_out_of_sync - If actual and saved CPU frequency differs, we're in deep trouble. | 1238 | * cpufreq_out_of_sync - If actual and saved CPU frequency differs, we're |
1239 | * in deep trouble. | ||
1140 | * @cpu: cpu number | 1240 | * @cpu: cpu number |
1141 | * @old_freq: CPU frequency the kernel thinks the CPU runs at | 1241 | * @old_freq: CPU frequency the kernel thinks the CPU runs at |
1142 | * @new_freq: CPU frequency the CPU actually runs at | 1242 | * @new_freq: CPU frequency the CPU actually runs at |
@@ -1151,7 +1251,6 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, | |||
1151 | struct cpufreq_freqs freqs; | 1251 | struct cpufreq_freqs freqs; |
1152 | unsigned long flags; | 1252 | unsigned long flags; |
1153 | 1253 | ||
1154 | |||
1155 | pr_debug("Warning: CPU frequency out of sync: cpufreq and timing " | 1254 | pr_debug("Warning: CPU frequency out of sync: cpufreq and timing " |
1156 | "core thinks of %u, is %u kHz.\n", old_freq, new_freq); | 1255 | "core thinks of %u, is %u kHz.\n", old_freq, new_freq); |
1157 | 1256 | ||
@@ -1166,7 +1265,6 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, | |||
1166 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 1265 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
1167 | } | 1266 | } |
1168 | 1267 | ||
1169 | |||
1170 | /** | 1268 | /** |
1171 | * cpufreq_quick_get - get the CPU frequency (in kHz) from policy->cur | 1269 | * cpufreq_quick_get - get the CPU frequency (in kHz) from policy->cur |
1172 | * @cpu: CPU number | 1270 | * @cpu: CPU number |
@@ -1212,7 +1310,6 @@ unsigned int cpufreq_quick_get_max(unsigned int cpu) | |||
1212 | } | 1310 | } |
1213 | EXPORT_SYMBOL(cpufreq_quick_get_max); | 1311 | EXPORT_SYMBOL(cpufreq_quick_get_max); |
1214 | 1312 | ||
1215 | |||
1216 | static unsigned int __cpufreq_get(unsigned int cpu) | 1313 | static unsigned int __cpufreq_get(unsigned int cpu) |
1217 | { | 1314 | { |
1218 | struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); | 1315 | struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); |
@@ -1271,7 +1368,6 @@ static struct subsys_interface cpufreq_interface = { | |||
1271 | .remove_dev = cpufreq_remove_dev, | 1368 | .remove_dev = cpufreq_remove_dev, |
1272 | }; | 1369 | }; |
1273 | 1370 | ||
1274 | |||
1275 | /** | 1371 | /** |
1276 | * cpufreq_bp_suspend - Prepare the boot CPU for system suspend. | 1372 | * cpufreq_bp_suspend - Prepare the boot CPU for system suspend. |
1277 | * | 1373 | * |
@@ -1408,11 +1504,10 @@ int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list) | |||
1408 | } | 1504 | } |
1409 | EXPORT_SYMBOL(cpufreq_register_notifier); | 1505 | EXPORT_SYMBOL(cpufreq_register_notifier); |
1410 | 1506 | ||
1411 | |||
1412 | /** | 1507 | /** |
1413 | * cpufreq_unregister_notifier - unregister a driver with cpufreq | 1508 | * cpufreq_unregister_notifier - unregister a driver with cpufreq |
1414 | * @nb: notifier block to be unregistered | 1509 | * @nb: notifier block to be unregistered |
1415 | * @list: CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER | 1510 | * @list: CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER |
1416 | * | 1511 | * |
1417 | * Remove a driver from the CPU frequency notifier list. | 1512 | * Remove a driver from the CPU frequency notifier list. |
1418 | * | 1513 | * |
@@ -1448,7 +1543,6 @@ EXPORT_SYMBOL(cpufreq_unregister_notifier); | |||
1448 | * GOVERNORS * | 1543 | * GOVERNORS * |
1449 | *********************************************************************/ | 1544 | *********************************************************************/ |
1450 | 1545 | ||
1451 | |||
1452 | int __cpufreq_driver_target(struct cpufreq_policy *policy, | 1546 | int __cpufreq_driver_target(struct cpufreq_policy *policy, |
1453 | unsigned int target_freq, | 1547 | unsigned int target_freq, |
1454 | unsigned int relation) | 1548 | unsigned int relation) |
@@ -1458,6 +1552,8 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, | |||
1458 | 1552 | ||
1459 | if (cpufreq_disabled()) | 1553 | if (cpufreq_disabled()) |
1460 | return -ENODEV; | 1554 | return -ENODEV; |
1555 | if (policy->transition_ongoing) | ||
1556 | return -EBUSY; | ||
1461 | 1557 | ||
1462 | /* Make sure that target_freq is within supported range */ | 1558 | /* Make sure that target_freq is within supported range */ |
1463 | if (target_freq > policy->max) | 1559 | if (target_freq > policy->max) |
@@ -1484,10 +1580,6 @@ int cpufreq_driver_target(struct cpufreq_policy *policy, | |||
1484 | { | 1580 | { |
1485 | int ret = -EINVAL; | 1581 | int ret = -EINVAL; |
1486 | 1582 | ||
1487 | policy = cpufreq_cpu_get(policy->cpu); | ||
1488 | if (!policy) | ||
1489 | goto no_policy; | ||
1490 | |||
1491 | if (unlikely(lock_policy_rwsem_write(policy->cpu))) | 1583 | if (unlikely(lock_policy_rwsem_write(policy->cpu))) |
1492 | goto fail; | 1584 | goto fail; |
1493 | 1585 | ||
@@ -1496,30 +1588,19 @@ int cpufreq_driver_target(struct cpufreq_policy *policy, | |||
1496 | unlock_policy_rwsem_write(policy->cpu); | 1588 | unlock_policy_rwsem_write(policy->cpu); |
1497 | 1589 | ||
1498 | fail: | 1590 | fail: |
1499 | cpufreq_cpu_put(policy); | ||
1500 | no_policy: | ||
1501 | return ret; | 1591 | return ret; |
1502 | } | 1592 | } |
1503 | EXPORT_SYMBOL_GPL(cpufreq_driver_target); | 1593 | EXPORT_SYMBOL_GPL(cpufreq_driver_target); |
1504 | 1594 | ||
1505 | int __cpufreq_driver_getavg(struct cpufreq_policy *policy, unsigned int cpu) | 1595 | int __cpufreq_driver_getavg(struct cpufreq_policy *policy, unsigned int cpu) |
1506 | { | 1596 | { |
1507 | int ret = 0; | ||
1508 | |||
1509 | if (cpufreq_disabled()) | 1597 | if (cpufreq_disabled()) |
1510 | return ret; | 1598 | return 0; |
1511 | 1599 | ||
1512 | if (!cpufreq_driver->getavg) | 1600 | if (!cpufreq_driver->getavg) |
1513 | return 0; | 1601 | return 0; |
1514 | 1602 | ||
1515 | policy = cpufreq_cpu_get(policy->cpu); | 1603 | return cpufreq_driver->getavg(policy, cpu); |
1516 | if (!policy) | ||
1517 | return -EINVAL; | ||
1518 | |||
1519 | ret = cpufreq_driver->getavg(policy, cpu); | ||
1520 | |||
1521 | cpufreq_cpu_put(policy); | ||
1522 | return ret; | ||
1523 | } | 1604 | } |
1524 | EXPORT_SYMBOL_GPL(__cpufreq_driver_getavg); | 1605 | EXPORT_SYMBOL_GPL(__cpufreq_driver_getavg); |
1525 | 1606 | ||
@@ -1562,6 +1643,21 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, | |||
1562 | 1643 | ||
1563 | pr_debug("__cpufreq_governor for CPU %u, event %u\n", | 1644 | pr_debug("__cpufreq_governor for CPU %u, event %u\n", |
1564 | policy->cpu, event); | 1645 | policy->cpu, event); |
1646 | |||
1647 | mutex_lock(&cpufreq_governor_lock); | ||
1648 | if ((!policy->governor_enabled && (event == CPUFREQ_GOV_STOP)) || | ||
1649 | (policy->governor_enabled && (event == CPUFREQ_GOV_START))) { | ||
1650 | mutex_unlock(&cpufreq_governor_lock); | ||
1651 | return -EBUSY; | ||
1652 | } | ||
1653 | |||
1654 | if (event == CPUFREQ_GOV_STOP) | ||
1655 | policy->governor_enabled = false; | ||
1656 | else if (event == CPUFREQ_GOV_START) | ||
1657 | policy->governor_enabled = true; | ||
1658 | |||
1659 | mutex_unlock(&cpufreq_governor_lock); | ||
1660 | |||
1565 | ret = policy->governor->governor(policy, event); | 1661 | ret = policy->governor->governor(policy, event); |
1566 | 1662 | ||
1567 | if (!ret) { | 1663 | if (!ret) { |
@@ -1569,6 +1665,14 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, | |||
1569 | policy->governor->initialized++; | 1665 | policy->governor->initialized++; |
1570 | else if (event == CPUFREQ_GOV_POLICY_EXIT) | 1666 | else if (event == CPUFREQ_GOV_POLICY_EXIT) |
1571 | policy->governor->initialized--; | 1667 | policy->governor->initialized--; |
1668 | } else { | ||
1669 | /* Restore original values */ | ||
1670 | mutex_lock(&cpufreq_governor_lock); | ||
1671 | if (event == CPUFREQ_GOV_STOP) | ||
1672 | policy->governor_enabled = true; | ||
1673 | else if (event == CPUFREQ_GOV_START) | ||
1674 | policy->governor_enabled = false; | ||
1675 | mutex_unlock(&cpufreq_governor_lock); | ||
1572 | } | 1676 | } |
1573 | 1677 | ||
1574 | /* we keep one module reference alive for | 1678 | /* we keep one module reference alive for |
@@ -1581,7 +1685,6 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, | |||
1581 | return ret; | 1685 | return ret; |
1582 | } | 1686 | } |
1583 | 1687 | ||
1584 | |||
1585 | int cpufreq_register_governor(struct cpufreq_governor *governor) | 1688 | int cpufreq_register_governor(struct cpufreq_governor *governor) |
1586 | { | 1689 | { |
1587 | int err; | 1690 | int err; |
@@ -1606,7 +1709,6 @@ int cpufreq_register_governor(struct cpufreq_governor *governor) | |||
1606 | } | 1709 | } |
1607 | EXPORT_SYMBOL_GPL(cpufreq_register_governor); | 1710 | EXPORT_SYMBOL_GPL(cpufreq_register_governor); |
1608 | 1711 | ||
1609 | |||
1610 | void cpufreq_unregister_governor(struct cpufreq_governor *governor) | 1712 | void cpufreq_unregister_governor(struct cpufreq_governor *governor) |
1611 | { | 1713 | { |
1612 | #ifdef CONFIG_HOTPLUG_CPU | 1714 | #ifdef CONFIG_HOTPLUG_CPU |
@@ -1636,7 +1738,6 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor) | |||
1636 | EXPORT_SYMBOL_GPL(cpufreq_unregister_governor); | 1738 | EXPORT_SYMBOL_GPL(cpufreq_unregister_governor); |
1637 | 1739 | ||
1638 | 1740 | ||
1639 | |||
1640 | /********************************************************************* | 1741 | /********************************************************************* |
1641 | * POLICY INTERFACE * | 1742 | * POLICY INTERFACE * |
1642 | *********************************************************************/ | 1743 | *********************************************************************/ |
@@ -1665,7 +1766,6 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu) | |||
1665 | } | 1766 | } |
1666 | EXPORT_SYMBOL(cpufreq_get_policy); | 1767 | EXPORT_SYMBOL(cpufreq_get_policy); |
1667 | 1768 | ||
1668 | |||
1669 | /* | 1769 | /* |
1670 | * data : current policy. | 1770 | * data : current policy. |
1671 | * policy : policy to be set. | 1771 | * policy : policy to be set. |
@@ -1699,8 +1799,10 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data, | |||
1699 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | 1799 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, |
1700 | CPUFREQ_INCOMPATIBLE, policy); | 1800 | CPUFREQ_INCOMPATIBLE, policy); |
1701 | 1801 | ||
1702 | /* verify the cpu speed can be set within this limit, | 1802 | /* |
1703 | which might be different to the first one */ | 1803 | * verify the cpu speed can be set within this limit, which might be |
1804 | * different to the first one | ||
1805 | */ | ||
1704 | ret = cpufreq_driver->verify(policy); | 1806 | ret = cpufreq_driver->verify(policy); |
1705 | if (ret) | 1807 | if (ret) |
1706 | goto error_out; | 1808 | goto error_out; |
@@ -1802,8 +1904,10 @@ int cpufreq_update_policy(unsigned int cpu) | |||
1802 | policy.policy = data->user_policy.policy; | 1904 | policy.policy = data->user_policy.policy; |
1803 | policy.governor = data->user_policy.governor; | 1905 | policy.governor = data->user_policy.governor; |
1804 | 1906 | ||
1805 | /* BIOS might change freq behind our back | 1907 | /* |
1806 | -> ask driver for current freq and notify governors about a change */ | 1908 | * BIOS might change freq behind our back |
1909 | * -> ask driver for current freq and notify governors about a change | ||
1910 | */ | ||
1807 | if (cpufreq_driver->get) { | 1911 | if (cpufreq_driver->get) { |
1808 | policy.cur = cpufreq_driver->get(cpu); | 1912 | policy.cur = cpufreq_driver->get(cpu); |
1809 | if (!data->cur) { | 1913 | if (!data->cur) { |
@@ -1852,7 +1956,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb, | |||
1852 | } | 1956 | } |
1853 | 1957 | ||
1854 | static struct notifier_block __refdata cpufreq_cpu_notifier = { | 1958 | static struct notifier_block __refdata cpufreq_cpu_notifier = { |
1855 | .notifier_call = cpufreq_cpu_callback, | 1959 | .notifier_call = cpufreq_cpu_callback, |
1856 | }; | 1960 | }; |
1857 | 1961 | ||
1858 | /********************************************************************* | 1962 | /********************************************************************* |
@@ -1864,7 +1968,7 @@ static struct notifier_block __refdata cpufreq_cpu_notifier = { | |||
1864 | * @driver_data: A struct cpufreq_driver containing the values# | 1968 | * @driver_data: A struct cpufreq_driver containing the values# |
1865 | * submitted by the CPU Frequency driver. | 1969 | * submitted by the CPU Frequency driver. |
1866 | * | 1970 | * |
1867 | * Registers a CPU Frequency driver to this core code. This code | 1971 | * Registers a CPU Frequency driver to this core code. This code |
1868 | * returns zero on success, -EBUSY when another driver got here first | 1972 | * returns zero on success, -EBUSY when another driver got here first |
1869 | * (and isn't unregistered in the meantime). | 1973 | * (and isn't unregistered in the meantime). |
1870 | * | 1974 | * |
@@ -1931,11 +2035,10 @@ err_null_driver: | |||
1931 | } | 2035 | } |
1932 | EXPORT_SYMBOL_GPL(cpufreq_register_driver); | 2036 | EXPORT_SYMBOL_GPL(cpufreq_register_driver); |
1933 | 2037 | ||
1934 | |||
1935 | /** | 2038 | /** |
1936 | * cpufreq_unregister_driver - unregister the current CPUFreq driver | 2039 | * cpufreq_unregister_driver - unregister the current CPUFreq driver |
1937 | * | 2040 | * |
1938 | * Unregister the current CPUFreq driver. Only call this if you have | 2041 | * Unregister the current CPUFreq driver. Only call this if you have |
1939 | * the right to do so, i.e. if you have succeeded in initialising before! | 2042 | * the right to do so, i.e. if you have succeeded in initialising before! |
1940 | * Returns zero if successful, and -EINVAL if the cpufreq_driver is | 2043 | * Returns zero if successful, and -EINVAL if the cpufreq_driver is |
1941 | * currently not initialised. | 2044 | * currently not initialised. |
@@ -1972,7 +2075,7 @@ static int __init cpufreq_core_init(void) | |||
1972 | init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); | 2075 | init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); |
1973 | } | 2076 | } |
1974 | 2077 | ||
1975 | cpufreq_global_kobject = kobject_create_and_add("cpufreq", &cpu_subsys.dev_root->kobj); | 2078 | cpufreq_global_kobject = kobject_create(); |
1976 | BUG_ON(!cpufreq_global_kobject); | 2079 | BUG_ON(!cpufreq_global_kobject); |
1977 | register_syscore_ops(&cpufreq_syscore_ops); | 2080 | register_syscore_ops(&cpufreq_syscore_ops); |
1978 | 2081 | ||
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index dc9b72e25c1a..464587697561 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c | |||
@@ -23,21 +23,12 @@ | |||
23 | #include <linux/kernel_stat.h> | 23 | #include <linux/kernel_stat.h> |
24 | #include <linux/mutex.h> | 24 | #include <linux/mutex.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/tick.h> | ||
27 | #include <linux/types.h> | 26 | #include <linux/types.h> |
28 | #include <linux/workqueue.h> | 27 | #include <linux/workqueue.h> |
29 | #include <linux/cpu.h> | 28 | #include <linux/cpu.h> |
30 | 29 | ||
31 | #include "cpufreq_governor.h" | 30 | #include "cpufreq_governor.h" |
32 | 31 | ||
33 | static struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy) | ||
34 | { | ||
35 | if (have_governor_per_policy()) | ||
36 | return &policy->kobj; | ||
37 | else | ||
38 | return cpufreq_global_kobject; | ||
39 | } | ||
40 | |||
41 | static struct attribute_group *get_sysfs_attr(struct dbs_data *dbs_data) | 32 | static struct attribute_group *get_sysfs_attr(struct dbs_data *dbs_data) |
42 | { | 33 | { |
43 | if (have_governor_per_policy()) | 34 | if (have_governor_per_policy()) |
@@ -46,41 +37,6 @@ static struct attribute_group *get_sysfs_attr(struct dbs_data *dbs_data) | |||
46 | return dbs_data->cdata->attr_group_gov_sys; | 37 | return dbs_data->cdata->attr_group_gov_sys; |
47 | } | 38 | } |
48 | 39 | ||
49 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) | ||
50 | { | ||
51 | u64 idle_time; | ||
52 | u64 cur_wall_time; | ||
53 | u64 busy_time; | ||
54 | |||
55 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); | ||
56 | |||
57 | busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER]; | ||
58 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM]; | ||
59 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ]; | ||
60 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ]; | ||
61 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL]; | ||
62 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE]; | ||
63 | |||
64 | idle_time = cur_wall_time - busy_time; | ||
65 | if (wall) | ||
66 | *wall = cputime_to_usecs(cur_wall_time); | ||
67 | |||
68 | return cputime_to_usecs(idle_time); | ||
69 | } | ||
70 | |||
71 | u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy) | ||
72 | { | ||
73 | u64 idle_time = get_cpu_idle_time_us(cpu, io_busy ? wall : NULL); | ||
74 | |||
75 | if (idle_time == -1ULL) | ||
76 | return get_cpu_idle_time_jiffy(cpu, wall); | ||
77 | else if (!io_busy) | ||
78 | idle_time += get_cpu_iowait_time_us(cpu, wall); | ||
79 | |||
80 | return idle_time; | ||
81 | } | ||
82 | EXPORT_SYMBOL_GPL(get_cpu_idle_time); | ||
83 | |||
84 | void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) | 40 | void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) |
85 | { | 41 | { |
86 | struct cpu_dbs_common_info *cdbs = dbs_data->cdata->get_cpu_cdbs(cpu); | 42 | struct cpu_dbs_common_info *cdbs = dbs_data->cdata->get_cpu_cdbs(cpu); |
@@ -278,6 +234,9 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
278 | return rc; | 234 | return rc; |
279 | } | 235 | } |
280 | 236 | ||
237 | if (!have_governor_per_policy()) | ||
238 | WARN_ON(cpufreq_get_global_kobject()); | ||
239 | |||
281 | rc = sysfs_create_group(get_governor_parent_kobj(policy), | 240 | rc = sysfs_create_group(get_governor_parent_kobj(policy), |
282 | get_sysfs_attr(dbs_data)); | 241 | get_sysfs_attr(dbs_data)); |
283 | if (rc) { | 242 | if (rc) { |
@@ -316,6 +275,9 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
316 | sysfs_remove_group(get_governor_parent_kobj(policy), | 275 | sysfs_remove_group(get_governor_parent_kobj(policy), |
317 | get_sysfs_attr(dbs_data)); | 276 | get_sysfs_attr(dbs_data)); |
318 | 277 | ||
278 | if (!have_governor_per_policy()) | ||
279 | cpufreq_put_global_kobject(); | ||
280 | |||
319 | if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) && | 281 | if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) && |
320 | (policy->governor->initialized == 1)) { | 282 | (policy->governor->initialized == 1)) { |
321 | struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; | 283 | struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; |
@@ -404,6 +366,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
404 | 366 | ||
405 | mutex_lock(&dbs_data->mutex); | 367 | mutex_lock(&dbs_data->mutex); |
406 | mutex_destroy(&cpu_cdbs->timer_mutex); | 368 | mutex_destroy(&cpu_cdbs->timer_mutex); |
369 | cpu_cdbs->cur_policy = NULL; | ||
407 | 370 | ||
408 | mutex_unlock(&dbs_data->mutex); | 371 | mutex_unlock(&dbs_data->mutex); |
409 | 372 | ||
diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index e16a96130cb3..6663ec3b3056 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h | |||
@@ -81,7 +81,7 @@ static ssize_t show_##file_name##_gov_sys \ | |||
81 | return sprintf(buf, "%u\n", tuners->file_name); \ | 81 | return sprintf(buf, "%u\n", tuners->file_name); \ |
82 | } \ | 82 | } \ |
83 | \ | 83 | \ |
84 | static ssize_t show_##file_name##_gov_pol \ | 84 | static ssize_t show_##file_name##_gov_pol \ |
85 | (struct cpufreq_policy *policy, char *buf) \ | 85 | (struct cpufreq_policy *policy, char *buf) \ |
86 | { \ | 86 | { \ |
87 | struct dbs_data *dbs_data = policy->governor_data; \ | 87 | struct dbs_data *dbs_data = policy->governor_data; \ |
@@ -91,7 +91,7 @@ static ssize_t show_##file_name##_gov_pol \ | |||
91 | 91 | ||
92 | #define store_one(_gov, file_name) \ | 92 | #define store_one(_gov, file_name) \ |
93 | static ssize_t store_##file_name##_gov_sys \ | 93 | static ssize_t store_##file_name##_gov_sys \ |
94 | (struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) \ | 94 | (struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) \ |
95 | { \ | 95 | { \ |
96 | struct dbs_data *dbs_data = _gov##_dbs_cdata.gdbs_data; \ | 96 | struct dbs_data *dbs_data = _gov##_dbs_cdata.gdbs_data; \ |
97 | return store_##file_name(dbs_data, buf, count); \ | 97 | return store_##file_name(dbs_data, buf, count); \ |
@@ -256,7 +256,6 @@ static ssize_t show_sampling_rate_min_gov_pol \ | |||
256 | return sprintf(buf, "%u\n", dbs_data->min_sampling_rate); \ | 256 | return sprintf(buf, "%u\n", dbs_data->min_sampling_rate); \ |
257 | } | 257 | } |
258 | 258 | ||
259 | u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy); | ||
260 | void dbs_check_cpu(struct dbs_data *dbs_data, int cpu); | 259 | void dbs_check_cpu(struct dbs_data *dbs_data, int cpu); |
261 | bool need_load_eval(struct cpu_dbs_common_info *cdbs, | 260 | bool need_load_eval(struct cpu_dbs_common_info *cdbs, |
262 | unsigned int sampling_rate); | 261 | unsigned int sampling_rate); |
diff --git a/drivers/cpufreq/cpufreq_performance.c b/drivers/cpufreq/cpufreq_performance.c index ceee06849b91..9fef7d6e4e6a 100644 --- a/drivers/cpufreq/cpufreq_performance.c +++ b/drivers/cpufreq/cpufreq_performance.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/cpufreq.h> | 17 | #include <linux/cpufreq.h> |
18 | #include <linux/init.h> | 18 | #include <linux/init.h> |
19 | 19 | ||
20 | |||
21 | static int cpufreq_governor_performance(struct cpufreq_policy *policy, | 20 | static int cpufreq_governor_performance(struct cpufreq_policy *policy, |
22 | unsigned int event) | 21 | unsigned int event) |
23 | { | 22 | { |
@@ -44,19 +43,16 @@ struct cpufreq_governor cpufreq_gov_performance = { | |||
44 | .owner = THIS_MODULE, | 43 | .owner = THIS_MODULE, |
45 | }; | 44 | }; |
46 | 45 | ||
47 | |||
48 | static int __init cpufreq_gov_performance_init(void) | 46 | static int __init cpufreq_gov_performance_init(void) |
49 | { | 47 | { |
50 | return cpufreq_register_governor(&cpufreq_gov_performance); | 48 | return cpufreq_register_governor(&cpufreq_gov_performance); |
51 | } | 49 | } |
52 | 50 | ||
53 | |||
54 | static void __exit cpufreq_gov_performance_exit(void) | 51 | static void __exit cpufreq_gov_performance_exit(void) |
55 | { | 52 | { |
56 | cpufreq_unregister_governor(&cpufreq_gov_performance); | 53 | cpufreq_unregister_governor(&cpufreq_gov_performance); |
57 | } | 54 | } |
58 | 55 | ||
59 | |||
60 | MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>"); | 56 | MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>"); |
61 | MODULE_DESCRIPTION("CPUfreq policy governor 'performance'"); | 57 | MODULE_DESCRIPTION("CPUfreq policy governor 'performance'"); |
62 | MODULE_LICENSE("GPL"); | 58 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/cpufreq/cpufreq_powersave.c b/drivers/cpufreq/cpufreq_powersave.c index 2d948a171155..32109a14f5dc 100644 --- a/drivers/cpufreq/cpufreq_powersave.c +++ b/drivers/cpufreq/cpufreq_powersave.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/cpufreq/cpufreq_powersave.c | 2 | * linux/drivers/cpufreq/cpufreq_powersave.c |
3 | * | 3 | * |
4 | * Copyright (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> | 4 | * Copyright (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> |
5 | * | 5 | * |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
@@ -48,13 +48,11 @@ static int __init cpufreq_gov_powersave_init(void) | |||
48 | return cpufreq_register_governor(&cpufreq_gov_powersave); | 48 | return cpufreq_register_governor(&cpufreq_gov_powersave); |
49 | } | 49 | } |
50 | 50 | ||
51 | |||
52 | static void __exit cpufreq_gov_powersave_exit(void) | 51 | static void __exit cpufreq_gov_powersave_exit(void) |
53 | { | 52 | { |
54 | cpufreq_unregister_governor(&cpufreq_gov_powersave); | 53 | cpufreq_unregister_governor(&cpufreq_gov_powersave); |
55 | } | 54 | } |
56 | 55 | ||
57 | |||
58 | MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>"); | 56 | MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>"); |
59 | MODULE_DESCRIPTION("CPUfreq policy governor 'powersave'"); | 57 | MODULE_DESCRIPTION("CPUfreq policy governor 'powersave'"); |
60 | MODULE_LICENSE("GPL"); | 58 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index fb65decffa28..cd9e81713a71 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -27,7 +27,7 @@ static spinlock_t cpufreq_stats_lock; | |||
27 | struct cpufreq_stats { | 27 | struct cpufreq_stats { |
28 | unsigned int cpu; | 28 | unsigned int cpu; |
29 | unsigned int total_trans; | 29 | unsigned int total_trans; |
30 | unsigned long long last_time; | 30 | unsigned long long last_time; |
31 | unsigned int max_state; | 31 | unsigned int max_state; |
32 | unsigned int state_num; | 32 | unsigned int state_num; |
33 | unsigned int last_index; | 33 | unsigned int last_index; |
@@ -116,7 +116,7 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) | |||
116 | len += snprintf(buf + len, PAGE_SIZE - len, "%9u: ", | 116 | len += snprintf(buf + len, PAGE_SIZE - len, "%9u: ", |
117 | stat->freq_table[i]); | 117 | stat->freq_table[i]); |
118 | 118 | ||
119 | for (j = 0; j < stat->state_num; j++) { | 119 | for (j = 0; j < stat->state_num; j++) { |
120 | if (len >= PAGE_SIZE) | 120 | if (len >= PAGE_SIZE) |
121 | break; | 121 | break; |
122 | len += snprintf(buf + len, PAGE_SIZE - len, "%9u ", | 122 | len += snprintf(buf + len, PAGE_SIZE - len, "%9u ", |
@@ -349,6 +349,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb, | |||
349 | 349 | ||
350 | switch (action) { | 350 | switch (action) { |
351 | case CPU_ONLINE: | 351 | case CPU_ONLINE: |
352 | case CPU_ONLINE_FROZEN: | ||
352 | cpufreq_update_policy(cpu); | 353 | cpufreq_update_policy(cpu); |
353 | break; | 354 | break; |
354 | case CPU_DOWN_PREPARE: | 355 | case CPU_DOWN_PREPARE: |
diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c index bbeb9c0720a6..03078090b5f7 100644 --- a/drivers/cpufreq/cpufreq_userspace.c +++ b/drivers/cpufreq/cpufreq_userspace.c | |||
@@ -13,55 +13,13 @@ | |||
13 | 13 | ||
14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
15 | 15 | ||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/smp.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/spinlock.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/cpufreq.h> | 16 | #include <linux/cpufreq.h> |
23 | #include <linux/cpu.h> | 17 | #include <linux/init.h> |
24 | #include <linux/types.h> | 18 | #include <linux/module.h> |
25 | #include <linux/fs.h> | ||
26 | #include <linux/sysfs.h> | ||
27 | #include <linux/mutex.h> | 19 | #include <linux/mutex.h> |
28 | 20 | ||
29 | /** | ||
30 | * A few values needed by the userspace governor | ||
31 | */ | ||
32 | static DEFINE_PER_CPU(unsigned int, cpu_max_freq); | ||
33 | static DEFINE_PER_CPU(unsigned int, cpu_min_freq); | ||
34 | static DEFINE_PER_CPU(unsigned int, cpu_cur_freq); /* current CPU freq */ | ||
35 | static DEFINE_PER_CPU(unsigned int, cpu_set_freq); /* CPU freq desired by | ||
36 | userspace */ | ||
37 | static DEFINE_PER_CPU(unsigned int, cpu_is_managed); | 21 | static DEFINE_PER_CPU(unsigned int, cpu_is_managed); |
38 | |||
39 | static DEFINE_MUTEX(userspace_mutex); | 22 | static DEFINE_MUTEX(userspace_mutex); |
40 | static int cpus_using_userspace_governor; | ||
41 | |||
42 | /* keep track of frequency transitions */ | ||
43 | static int | ||
44 | userspace_cpufreq_notifier(struct notifier_block *nb, unsigned long val, | ||
45 | void *data) | ||
46 | { | ||
47 | struct cpufreq_freqs *freq = data; | ||
48 | |||
49 | if (!per_cpu(cpu_is_managed, freq->cpu)) | ||
50 | return 0; | ||
51 | |||
52 | if (val == CPUFREQ_POSTCHANGE) { | ||
53 | pr_debug("saving cpu_cur_freq of cpu %u to be %u kHz\n", | ||
54 | freq->cpu, freq->new); | ||
55 | per_cpu(cpu_cur_freq, freq->cpu) = freq->new; | ||
56 | } | ||
57 | |||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | static struct notifier_block userspace_cpufreq_notifier_block = { | ||
62 | .notifier_call = userspace_cpufreq_notifier | ||
63 | }; | ||
64 | |||
65 | 23 | ||
66 | /** | 24 | /** |
67 | * cpufreq_set - set the CPU frequency | 25 | * cpufreq_set - set the CPU frequency |
@@ -80,13 +38,6 @@ static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq) | |||
80 | if (!per_cpu(cpu_is_managed, policy->cpu)) | 38 | if (!per_cpu(cpu_is_managed, policy->cpu)) |
81 | goto err; | 39 | goto err; |
82 | 40 | ||
83 | per_cpu(cpu_set_freq, policy->cpu) = freq; | ||
84 | |||
85 | if (freq < per_cpu(cpu_min_freq, policy->cpu)) | ||
86 | freq = per_cpu(cpu_min_freq, policy->cpu); | ||
87 | if (freq > per_cpu(cpu_max_freq, policy->cpu)) | ||
88 | freq = per_cpu(cpu_max_freq, policy->cpu); | ||
89 | |||
90 | /* | 41 | /* |
91 | * We're safe from concurrent calls to ->target() here | 42 | * We're safe from concurrent calls to ->target() here |
92 | * as we hold the userspace_mutex lock. If we were calling | 43 | * as we hold the userspace_mutex lock. If we were calling |
@@ -104,10 +55,9 @@ static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq) | |||
104 | return ret; | 55 | return ret; |
105 | } | 56 | } |
106 | 57 | ||
107 | |||
108 | static ssize_t show_speed(struct cpufreq_policy *policy, char *buf) | 58 | static ssize_t show_speed(struct cpufreq_policy *policy, char *buf) |
109 | { | 59 | { |
110 | return sprintf(buf, "%u\n", per_cpu(cpu_cur_freq, policy->cpu)); | 60 | return sprintf(buf, "%u\n", policy->cur); |
111 | } | 61 | } |
112 | 62 | ||
113 | static int cpufreq_governor_userspace(struct cpufreq_policy *policy, | 63 | static int cpufreq_governor_userspace(struct cpufreq_policy *policy, |
@@ -119,73 +69,37 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy, | |||
119 | switch (event) { | 69 | switch (event) { |
120 | case CPUFREQ_GOV_START: | 70 | case CPUFREQ_GOV_START: |
121 | BUG_ON(!policy->cur); | 71 | BUG_ON(!policy->cur); |
122 | mutex_lock(&userspace_mutex); | 72 | pr_debug("started managing cpu %u\n", cpu); |
123 | |||
124 | if (cpus_using_userspace_governor == 0) { | ||
125 | cpufreq_register_notifier( | ||
126 | &userspace_cpufreq_notifier_block, | ||
127 | CPUFREQ_TRANSITION_NOTIFIER); | ||
128 | } | ||
129 | cpus_using_userspace_governor++; | ||
130 | 73 | ||
74 | mutex_lock(&userspace_mutex); | ||
131 | per_cpu(cpu_is_managed, cpu) = 1; | 75 | per_cpu(cpu_is_managed, cpu) = 1; |
132 | per_cpu(cpu_min_freq, cpu) = policy->min; | ||
133 | per_cpu(cpu_max_freq, cpu) = policy->max; | ||
134 | per_cpu(cpu_cur_freq, cpu) = policy->cur; | ||
135 | per_cpu(cpu_set_freq, cpu) = policy->cur; | ||
136 | pr_debug("managing cpu %u started " | ||
137 | "(%u - %u kHz, currently %u kHz)\n", | ||
138 | cpu, | ||
139 | per_cpu(cpu_min_freq, cpu), | ||
140 | per_cpu(cpu_max_freq, cpu), | ||
141 | per_cpu(cpu_cur_freq, cpu)); | ||
142 | |||
143 | mutex_unlock(&userspace_mutex); | 76 | mutex_unlock(&userspace_mutex); |
144 | break; | 77 | break; |
145 | case CPUFREQ_GOV_STOP: | 78 | case CPUFREQ_GOV_STOP: |
146 | mutex_lock(&userspace_mutex); | 79 | pr_debug("managing cpu %u stopped\n", cpu); |
147 | cpus_using_userspace_governor--; | ||
148 | if (cpus_using_userspace_governor == 0) { | ||
149 | cpufreq_unregister_notifier( | ||
150 | &userspace_cpufreq_notifier_block, | ||
151 | CPUFREQ_TRANSITION_NOTIFIER); | ||
152 | } | ||
153 | 80 | ||
81 | mutex_lock(&userspace_mutex); | ||
154 | per_cpu(cpu_is_managed, cpu) = 0; | 82 | per_cpu(cpu_is_managed, cpu) = 0; |
155 | per_cpu(cpu_min_freq, cpu) = 0; | ||
156 | per_cpu(cpu_max_freq, cpu) = 0; | ||
157 | per_cpu(cpu_set_freq, cpu) = 0; | ||
158 | pr_debug("managing cpu %u stopped\n", cpu); | ||
159 | mutex_unlock(&userspace_mutex); | 83 | mutex_unlock(&userspace_mutex); |
160 | break; | 84 | break; |
161 | case CPUFREQ_GOV_LIMITS: | 85 | case CPUFREQ_GOV_LIMITS: |
162 | mutex_lock(&userspace_mutex); | 86 | mutex_lock(&userspace_mutex); |
163 | pr_debug("limit event for cpu %u: %u - %u kHz, " | 87 | pr_debug("limit event for cpu %u: %u - %u kHz, currently %u kHz\n", |
164 | "currently %u kHz, last set to %u kHz\n", | ||
165 | cpu, policy->min, policy->max, | 88 | cpu, policy->min, policy->max, |
166 | per_cpu(cpu_cur_freq, cpu), | 89 | policy->cur); |
167 | per_cpu(cpu_set_freq, cpu)); | 90 | |
168 | if (policy->max < per_cpu(cpu_set_freq, cpu)) { | 91 | if (policy->max < policy->cur) |
169 | __cpufreq_driver_target(policy, policy->max, | 92 | __cpufreq_driver_target(policy, policy->max, |
170 | CPUFREQ_RELATION_H); | 93 | CPUFREQ_RELATION_H); |
171 | } else if (policy->min > per_cpu(cpu_set_freq, cpu)) { | 94 | else if (policy->min > policy->cur) |
172 | __cpufreq_driver_target(policy, policy->min, | 95 | __cpufreq_driver_target(policy, policy->min, |
173 | CPUFREQ_RELATION_L); | 96 | CPUFREQ_RELATION_L); |
174 | } else { | ||
175 | __cpufreq_driver_target(policy, | ||
176 | per_cpu(cpu_set_freq, cpu), | ||
177 | CPUFREQ_RELATION_L); | ||
178 | } | ||
179 | per_cpu(cpu_min_freq, cpu) = policy->min; | ||
180 | per_cpu(cpu_max_freq, cpu) = policy->max; | ||
181 | per_cpu(cpu_cur_freq, cpu) = policy->cur; | ||
182 | mutex_unlock(&userspace_mutex); | 97 | mutex_unlock(&userspace_mutex); |
183 | break; | 98 | break; |
184 | } | 99 | } |
185 | return rc; | 100 | return rc; |
186 | } | 101 | } |
187 | 102 | ||
188 | |||
189 | #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE | 103 | #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE |
190 | static | 104 | static |
191 | #endif | 105 | #endif |
@@ -202,13 +116,11 @@ static int __init cpufreq_gov_userspace_init(void) | |||
202 | return cpufreq_register_governor(&cpufreq_gov_userspace); | 116 | return cpufreq_register_governor(&cpufreq_gov_userspace); |
203 | } | 117 | } |
204 | 118 | ||
205 | |||
206 | static void __exit cpufreq_gov_userspace_exit(void) | 119 | static void __exit cpufreq_gov_userspace_exit(void) |
207 | { | 120 | { |
208 | cpufreq_unregister_governor(&cpufreq_gov_userspace); | 121 | cpufreq_unregister_governor(&cpufreq_gov_userspace); |
209 | } | 122 | } |
210 | 123 | ||
211 | |||
212 | MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>, " | 124 | MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>, " |
213 | "Russell King <rmk@arm.linux.org.uk>"); | 125 | "Russell King <rmk@arm.linux.org.uk>"); |
214 | MODULE_DESCRIPTION("CPUfreq policy governor 'userspace'"); | 126 | MODULE_DESCRIPTION("CPUfreq policy governor 'userspace'"); |
diff --git a/drivers/cpufreq/davinci-cpufreq.c b/drivers/cpufreq/davinci-cpufreq.c index c33c76c360fa..551dd655c6f2 100644 --- a/drivers/cpufreq/davinci-cpufreq.c +++ b/drivers/cpufreq/davinci-cpufreq.c | |||
@@ -114,6 +114,9 @@ static int davinci_target(struct cpufreq_policy *policy, | |||
114 | pdata->set_voltage(idx); | 114 | pdata->set_voltage(idx); |
115 | 115 | ||
116 | out: | 116 | out: |
117 | if (ret) | ||
118 | freqs.new = freqs.old; | ||
119 | |||
117 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 120 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
118 | 121 | ||
119 | return ret; | 122 | return ret; |
diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c index 6ec6539ae041..1fdb02b9f1ec 100644 --- a/drivers/cpufreq/dbx500-cpufreq.c +++ b/drivers/cpufreq/dbx500-cpufreq.c | |||
@@ -57,13 +57,13 @@ static int dbx500_cpufreq_target(struct cpufreq_policy *policy, | |||
57 | if (ret) { | 57 | if (ret) { |
58 | pr_err("dbx500-cpufreq: Failed to set armss_clk to %d Hz: error %d\n", | 58 | pr_err("dbx500-cpufreq: Failed to set armss_clk to %d Hz: error %d\n", |
59 | freqs.new * 1000, ret); | 59 | freqs.new * 1000, ret); |
60 | return ret; | 60 | freqs.new = freqs.old; |
61 | } | 61 | } |
62 | 62 | ||
63 | /* post change notification */ | 63 | /* post change notification */ |
64 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 64 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
65 | 65 | ||
66 | return 0; | 66 | return ret; |
67 | } | 67 | } |
68 | 68 | ||
69 | static unsigned int dbx500_cpufreq_getspeed(unsigned int cpu) | 69 | static unsigned int dbx500_cpufreq_getspeed(unsigned int cpu) |
diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c index 37380fb92621..a60efaeb4cf8 100644 --- a/drivers/cpufreq/e_powersaver.c +++ b/drivers/cpufreq/e_powersaver.c | |||
@@ -161,6 +161,9 @@ postchange: | |||
161 | current_multiplier); | 161 | current_multiplier); |
162 | } | 162 | } |
163 | #endif | 163 | #endif |
164 | if (err) | ||
165 | freqs.new = freqs.old; | ||
166 | |||
164 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 167 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
165 | return err; | 168 | return err; |
166 | } | 169 | } |
@@ -188,7 +191,7 @@ static int eps_target(struct cpufreq_policy *policy, | |||
188 | } | 191 | } |
189 | 192 | ||
190 | /* Make frequency transition */ | 193 | /* Make frequency transition */ |
191 | dest_state = centaur->freq_table[newstate].index & 0xffff; | 194 | dest_state = centaur->freq_table[newstate].driver_data & 0xffff; |
192 | ret = eps_set_state(centaur, policy, dest_state); | 195 | ret = eps_set_state(centaur, policy, dest_state); |
193 | if (ret) | 196 | if (ret) |
194 | printk(KERN_ERR "eps: Timeout!\n"); | 197 | printk(KERN_ERR "eps: Timeout!\n"); |
@@ -380,9 +383,9 @@ static int eps_cpu_init(struct cpufreq_policy *policy) | |||
380 | f_table = ¢aur->freq_table[0]; | 383 | f_table = ¢aur->freq_table[0]; |
381 | if (brand != EPS_BRAND_C7M) { | 384 | if (brand != EPS_BRAND_C7M) { |
382 | f_table[0].frequency = fsb * min_multiplier; | 385 | f_table[0].frequency = fsb * min_multiplier; |
383 | f_table[0].index = (min_multiplier << 8) | min_voltage; | 386 | f_table[0].driver_data = (min_multiplier << 8) | min_voltage; |
384 | f_table[1].frequency = fsb * max_multiplier; | 387 | f_table[1].frequency = fsb * max_multiplier; |
385 | f_table[1].index = (max_multiplier << 8) | max_voltage; | 388 | f_table[1].driver_data = (max_multiplier << 8) | max_voltage; |
386 | f_table[2].frequency = CPUFREQ_TABLE_END; | 389 | f_table[2].frequency = CPUFREQ_TABLE_END; |
387 | } else { | 390 | } else { |
388 | k = 0; | 391 | k = 0; |
@@ -391,7 +394,7 @@ static int eps_cpu_init(struct cpufreq_policy *policy) | |||
391 | for (i = min_multiplier; i <= max_multiplier; i++) { | 394 | for (i = min_multiplier; i <= max_multiplier; i++) { |
392 | voltage = (k * step) / 256 + min_voltage; | 395 | voltage = (k * step) / 256 + min_voltage; |
393 | f_table[k].frequency = fsb * i; | 396 | f_table[k].frequency = fsb * i; |
394 | f_table[k].index = (i << 8) | voltage; | 397 | f_table[k].driver_data = (i << 8) | voltage; |
395 | k++; | 398 | k++; |
396 | } | 399 | } |
397 | f_table[k].frequency = CPUFREQ_TABLE_END; | 400 | f_table[k].frequency = CPUFREQ_TABLE_END; |
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c index 475b4f607f0d..0d32f02ef4d6 100644 --- a/drivers/cpufreq/exynos-cpufreq.c +++ b/drivers/cpufreq/exynos-cpufreq.c | |||
@@ -113,7 +113,8 @@ static int exynos_cpufreq_scale(unsigned int target_freq) | |||
113 | if (ret) { | 113 | if (ret) { |
114 | pr_err("%s: failed to set cpu voltage to %d\n", | 114 | pr_err("%s: failed to set cpu voltage to %d\n", |
115 | __func__, arm_volt); | 115 | __func__, arm_volt); |
116 | goto out; | 116 | freqs.new = freqs.old; |
117 | goto post_notify; | ||
117 | } | 118 | } |
118 | } | 119 | } |
119 | 120 | ||
@@ -123,14 +124,19 @@ static int exynos_cpufreq_scale(unsigned int target_freq) | |||
123 | if (ret) { | 124 | if (ret) { |
124 | pr_err("%s: failed to set cpu voltage to %d\n", | 125 | pr_err("%s: failed to set cpu voltage to %d\n", |
125 | __func__, safe_arm_volt); | 126 | __func__, safe_arm_volt); |
126 | goto out; | 127 | freqs.new = freqs.old; |
128 | goto post_notify; | ||
127 | } | 129 | } |
128 | } | 130 | } |
129 | 131 | ||
130 | exynos_info->set_freq(old_index, index); | 132 | exynos_info->set_freq(old_index, index); |
131 | 133 | ||
134 | post_notify: | ||
132 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 135 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
133 | 136 | ||
137 | if (ret) | ||
138 | goto out; | ||
139 | |||
134 | /* When the new frequency is lower than current frequency */ | 140 | /* When the new frequency is lower than current frequency */ |
135 | if ((freqs.new < freqs.old) || | 141 | if ((freqs.new < freqs.old) || |
136 | ((freqs.new > freqs.old) && safe_arm_volt)) { | 142 | ((freqs.new > freqs.old) && safe_arm_volt)) { |
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index d7a79662e24c..f0d87412cc91 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c | |||
@@ -34,8 +34,8 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, | |||
34 | 34 | ||
35 | continue; | 35 | continue; |
36 | } | 36 | } |
37 | pr_debug("table entry %u: %u kHz, %u index\n", | 37 | pr_debug("table entry %u: %u kHz, %u driver_data\n", |
38 | i, freq, table[i].index); | 38 | i, freq, table[i].driver_data); |
39 | if (freq < min_freq) | 39 | if (freq < min_freq) |
40 | min_freq = freq; | 40 | min_freq = freq; |
41 | if (freq > max_freq) | 41 | if (freq > max_freq) |
@@ -97,11 +97,11 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | |||
97 | unsigned int *index) | 97 | unsigned int *index) |
98 | { | 98 | { |
99 | struct cpufreq_frequency_table optimal = { | 99 | struct cpufreq_frequency_table optimal = { |
100 | .index = ~0, | 100 | .driver_data = ~0, |
101 | .frequency = 0, | 101 | .frequency = 0, |
102 | }; | 102 | }; |
103 | struct cpufreq_frequency_table suboptimal = { | 103 | struct cpufreq_frequency_table suboptimal = { |
104 | .index = ~0, | 104 | .driver_data = ~0, |
105 | .frequency = 0, | 105 | .frequency = 0, |
106 | }; | 106 | }; |
107 | unsigned int i; | 107 | unsigned int i; |
@@ -129,12 +129,12 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | |||
129 | if (freq <= target_freq) { | 129 | if (freq <= target_freq) { |
130 | if (freq >= optimal.frequency) { | 130 | if (freq >= optimal.frequency) { |
131 | optimal.frequency = freq; | 131 | optimal.frequency = freq; |
132 | optimal.index = i; | 132 | optimal.driver_data = i; |
133 | } | 133 | } |
134 | } else { | 134 | } else { |
135 | if (freq <= suboptimal.frequency) { | 135 | if (freq <= suboptimal.frequency) { |
136 | suboptimal.frequency = freq; | 136 | suboptimal.frequency = freq; |
137 | suboptimal.index = i; | 137 | suboptimal.driver_data = i; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | break; | 140 | break; |
@@ -142,26 +142,26 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | |||
142 | if (freq >= target_freq) { | 142 | if (freq >= target_freq) { |
143 | if (freq <= optimal.frequency) { | 143 | if (freq <= optimal.frequency) { |
144 | optimal.frequency = freq; | 144 | optimal.frequency = freq; |
145 | optimal.index = i; | 145 | optimal.driver_data = i; |
146 | } | 146 | } |
147 | } else { | 147 | } else { |
148 | if (freq >= suboptimal.frequency) { | 148 | if (freq >= suboptimal.frequency) { |
149 | suboptimal.frequency = freq; | 149 | suboptimal.frequency = freq; |
150 | suboptimal.index = i; | 150 | suboptimal.driver_data = i; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | break; | 153 | break; |
154 | } | 154 | } |
155 | } | 155 | } |
156 | if (optimal.index > i) { | 156 | if (optimal.driver_data > i) { |
157 | if (suboptimal.index > i) | 157 | if (suboptimal.driver_data > i) |
158 | return -EINVAL; | 158 | return -EINVAL; |
159 | *index = suboptimal.index; | 159 | *index = suboptimal.driver_data; |
160 | } else | 160 | } else |
161 | *index = optimal.index; | 161 | *index = optimal.driver_data; |
162 | 162 | ||
163 | pr_debug("target is %u (%u kHz, %u)\n", *index, table[*index].frequency, | 163 | pr_debug("target is %u (%u kHz, %u)\n", *index, table[*index].frequency, |
164 | table[*index].index); | 164 | table[*index].driver_data); |
165 | 165 | ||
166 | return 0; | 166 | return 0; |
167 | } | 167 | } |
diff --git a/drivers/cpufreq/ia64-acpi-cpufreq.c b/drivers/cpufreq/ia64-acpi-cpufreq.c index c0075dbaa633..573c14ea802d 100644 --- a/drivers/cpufreq/ia64-acpi-cpufreq.c +++ b/drivers/cpufreq/ia64-acpi-cpufreq.c | |||
@@ -326,7 +326,7 @@ acpi_cpufreq_cpu_init ( | |||
326 | /* table init */ | 326 | /* table init */ |
327 | for (i = 0; i <= data->acpi_data.state_count; i++) | 327 | for (i = 0; i <= data->acpi_data.state_count; i++) |
328 | { | 328 | { |
329 | data->freq_table[i].index = i; | 329 | data->freq_table[i].driver_data = i; |
330 | if (i < data->acpi_data.state_count) { | 330 | if (i < data->acpi_data.state_count) { |
331 | data->freq_table[i].frequency = | 331 | data->freq_table[i].frequency = |
332 | data->acpi_data.states[i].core_frequency * 1000; | 332 | data->acpi_data.states[i].core_frequency * 1000; |
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index b78bc35973ba..e37cdaedbb5b 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c | |||
@@ -68,8 +68,6 @@ static int imx6q_set_target(struct cpufreq_policy *policy, | |||
68 | if (freqs.old == freqs.new) | 68 | if (freqs.old == freqs.new) |
69 | return 0; | 69 | return 0; |
70 | 70 | ||
71 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | ||
72 | |||
73 | rcu_read_lock(); | 71 | rcu_read_lock(); |
74 | opp = opp_find_freq_ceil(cpu_dev, &freq_hz); | 72 | opp = opp_find_freq_ceil(cpu_dev, &freq_hz); |
75 | if (IS_ERR(opp)) { | 73 | if (IS_ERR(opp)) { |
@@ -86,13 +84,16 @@ static int imx6q_set_target(struct cpufreq_policy *policy, | |||
86 | freqs.old / 1000, volt_old / 1000, | 84 | freqs.old / 1000, volt_old / 1000, |
87 | freqs.new / 1000, volt / 1000); | 85 | freqs.new / 1000, volt / 1000); |
88 | 86 | ||
87 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | ||
88 | |||
89 | /* scaling up? scale voltage before frequency */ | 89 | /* scaling up? scale voltage before frequency */ |
90 | if (freqs.new > freqs.old) { | 90 | if (freqs.new > freqs.old) { |
91 | ret = regulator_set_voltage_tol(arm_reg, volt, 0); | 91 | ret = regulator_set_voltage_tol(arm_reg, volt, 0); |
92 | if (ret) { | 92 | if (ret) { |
93 | dev_err(cpu_dev, | 93 | dev_err(cpu_dev, |
94 | "failed to scale vddarm up: %d\n", ret); | 94 | "failed to scale vddarm up: %d\n", ret); |
95 | return ret; | 95 | freqs.new = freqs.old; |
96 | goto post_notify; | ||
96 | } | 97 | } |
97 | 98 | ||
98 | /* | 99 | /* |
@@ -145,15 +146,18 @@ static int imx6q_set_target(struct cpufreq_policy *policy, | |||
145 | if (ret) { | 146 | if (ret) { |
146 | dev_err(cpu_dev, "failed to set clock rate: %d\n", ret); | 147 | dev_err(cpu_dev, "failed to set clock rate: %d\n", ret); |
147 | regulator_set_voltage_tol(arm_reg, volt_old, 0); | 148 | regulator_set_voltage_tol(arm_reg, volt_old, 0); |
148 | return ret; | 149 | freqs.new = freqs.old; |
150 | goto post_notify; | ||
149 | } | 151 | } |
150 | 152 | ||
151 | /* scaling down? scale voltage after frequency */ | 153 | /* scaling down? scale voltage after frequency */ |
152 | if (freqs.new < freqs.old) { | 154 | if (freqs.new < freqs.old) { |
153 | ret = regulator_set_voltage_tol(arm_reg, volt, 0); | 155 | ret = regulator_set_voltage_tol(arm_reg, volt, 0); |
154 | if (ret) | 156 | if (ret) { |
155 | dev_warn(cpu_dev, | 157 | dev_warn(cpu_dev, |
156 | "failed to scale vddarm down: %d\n", ret); | 158 | "failed to scale vddarm down: %d\n", ret); |
159 | ret = 0; | ||
160 | } | ||
157 | 161 | ||
158 | if (freqs.old == FREQ_1P2_GHZ / 1000) { | 162 | if (freqs.old == FREQ_1P2_GHZ / 1000) { |
159 | regulator_set_voltage_tol(pu_reg, | 163 | regulator_set_voltage_tol(pu_reg, |
@@ -163,9 +167,10 @@ static int imx6q_set_target(struct cpufreq_policy *policy, | |||
163 | } | 167 | } |
164 | } | 168 | } |
165 | 169 | ||
170 | post_notify: | ||
166 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 171 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
167 | 172 | ||
168 | return 0; | 173 | return ret; |
169 | } | 174 | } |
170 | 175 | ||
171 | static int imx6q_cpufreq_init(struct cpufreq_policy *policy) | 176 | static int imx6q_cpufreq_init(struct cpufreq_policy *policy) |
diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c index b2644af985ec..c233ea617366 100644 --- a/drivers/cpufreq/kirkwood-cpufreq.c +++ b/drivers/cpufreq/kirkwood-cpufreq.c | |||
@@ -59,7 +59,7 @@ static void kirkwood_cpufreq_set_cpu_state(struct cpufreq_policy *policy, | |||
59 | unsigned int index) | 59 | unsigned int index) |
60 | { | 60 | { |
61 | struct cpufreq_freqs freqs; | 61 | struct cpufreq_freqs freqs; |
62 | unsigned int state = kirkwood_freq_table[index].index; | 62 | unsigned int state = kirkwood_freq_table[index].driver_data; |
63 | unsigned long reg; | 63 | unsigned long reg; |
64 | 64 | ||
65 | freqs.old = kirkwood_cpufreq_get_cpu_frequency(0); | 65 | freqs.old = kirkwood_cpufreq_get_cpu_frequency(0); |
diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c index b448638e34de..b6a0a7a406b0 100644 --- a/drivers/cpufreq/longhaul.c +++ b/drivers/cpufreq/longhaul.c | |||
@@ -254,7 +254,7 @@ static void longhaul_setstate(struct cpufreq_policy *policy, | |||
254 | u32 bm_timeout = 1000; | 254 | u32 bm_timeout = 1000; |
255 | unsigned int dir = 0; | 255 | unsigned int dir = 0; |
256 | 256 | ||
257 | mults_index = longhaul_table[table_index].index; | 257 | mults_index = longhaul_table[table_index].driver_data; |
258 | /* Safety precautions */ | 258 | /* Safety precautions */ |
259 | mult = mults[mults_index & 0x1f]; | 259 | mult = mults[mults_index & 0x1f]; |
260 | if (mult == -1) | 260 | if (mult == -1) |
@@ -487,7 +487,7 @@ static int __cpuinit longhaul_get_ranges(void) | |||
487 | if (ratio > maxmult || ratio < minmult) | 487 | if (ratio > maxmult || ratio < minmult) |
488 | continue; | 488 | continue; |
489 | longhaul_table[k].frequency = calc_speed(ratio); | 489 | longhaul_table[k].frequency = calc_speed(ratio); |
490 | longhaul_table[k].index = j; | 490 | longhaul_table[k].driver_data = j; |
491 | k++; | 491 | k++; |
492 | } | 492 | } |
493 | if (k <= 1) { | 493 | if (k <= 1) { |
@@ -508,8 +508,8 @@ static int __cpuinit longhaul_get_ranges(void) | |||
508 | if (min_i != j) { | 508 | if (min_i != j) { |
509 | swap(longhaul_table[j].frequency, | 509 | swap(longhaul_table[j].frequency, |
510 | longhaul_table[min_i].frequency); | 510 | longhaul_table[min_i].frequency); |
511 | swap(longhaul_table[j].index, | 511 | swap(longhaul_table[j].driver_data, |
512 | longhaul_table[min_i].index); | 512 | longhaul_table[min_i].driver_data); |
513 | } | 513 | } |
514 | } | 514 | } |
515 | 515 | ||
@@ -517,7 +517,7 @@ static int __cpuinit longhaul_get_ranges(void) | |||
517 | 517 | ||
518 | /* Find index we are running on */ | 518 | /* Find index we are running on */ |
519 | for (j = 0; j < k; j++) { | 519 | for (j = 0; j < k; j++) { |
520 | if (mults[longhaul_table[j].index & 0x1f] == mult) { | 520 | if (mults[longhaul_table[j].driver_data & 0x1f] == mult) { |
521 | longhaul_index = j; | 521 | longhaul_index = j; |
522 | break; | 522 | break; |
523 | } | 523 | } |
@@ -613,7 +613,7 @@ static void __cpuinit longhaul_setup_voltagescaling(void) | |||
613 | pos = (speed - min_vid_speed) / kHz_step + minvid.pos; | 613 | pos = (speed - min_vid_speed) / kHz_step + minvid.pos; |
614 | else | 614 | else |
615 | pos = minvid.pos; | 615 | pos = minvid.pos; |
616 | longhaul_table[j].index |= mV_vrm_table[pos] << 8; | 616 | longhaul_table[j].driver_data |= mV_vrm_table[pos] << 8; |
617 | vid = vrm_mV_table[mV_vrm_table[pos]]; | 617 | vid = vrm_mV_table[mV_vrm_table[pos]]; |
618 | printk(KERN_INFO PFX "f: %d kHz, index: %d, vid: %d mV\n", | 618 | printk(KERN_INFO PFX "f: %d kHz, index: %d, vid: %d mV\n", |
619 | speed, j, vid.mV); | 619 | speed, j, vid.mV); |
@@ -656,12 +656,12 @@ static int longhaul_target(struct cpufreq_policy *policy, | |||
656 | * this in hardware, C3 is old and we need to do this | 656 | * this in hardware, C3 is old and we need to do this |
657 | * in software. */ | 657 | * in software. */ |
658 | i = longhaul_index; | 658 | i = longhaul_index; |
659 | current_vid = (longhaul_table[longhaul_index].index >> 8); | 659 | current_vid = (longhaul_table[longhaul_index].driver_data >> 8); |
660 | current_vid &= 0x1f; | 660 | current_vid &= 0x1f; |
661 | if (table_index > longhaul_index) | 661 | if (table_index > longhaul_index) |
662 | dir = 1; | 662 | dir = 1; |
663 | while (i != table_index) { | 663 | while (i != table_index) { |
664 | vid = (longhaul_table[i].index >> 8) & 0x1f; | 664 | vid = (longhaul_table[i].driver_data >> 8) & 0x1f; |
665 | if (vid != current_vid) { | 665 | if (vid != current_vid) { |
666 | longhaul_setstate(policy, i); | 666 | longhaul_setstate(policy, i); |
667 | current_vid = vid; | 667 | current_vid = vid; |
diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c index d53912768946..bb838b985077 100644 --- a/drivers/cpufreq/loongson2_cpufreq.c +++ b/drivers/cpufreq/loongson2_cpufreq.c | |||
@@ -72,7 +72,7 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy, | |||
72 | 72 | ||
73 | freq = | 73 | freq = |
74 | ((cpu_clock_freq / 1000) * | 74 | ((cpu_clock_freq / 1000) * |
75 | loongson2_clockmod_table[newstate].index) / 8; | 75 | loongson2_clockmod_table[newstate].driver_data) / 8; |
76 | if (freq < policy->min || freq > policy->max) | 76 | if (freq < policy->min || freq > policy->max) |
77 | return -EINVAL; | 77 | return -EINVAL; |
78 | 78 | ||
diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c index 0279d18a57f9..29468a522ee9 100644 --- a/drivers/cpufreq/omap-cpufreq.c +++ b/drivers/cpufreq/omap-cpufreq.c | |||
@@ -93,9 +93,6 @@ static int omap_target(struct cpufreq_policy *policy, | |||
93 | if (freqs.old == freqs.new && policy->cur == freqs.new) | 93 | if (freqs.old == freqs.new && policy->cur == freqs.new) |
94 | return ret; | 94 | return ret; |
95 | 95 | ||
96 | /* notifiers */ | ||
97 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | ||
98 | |||
99 | freq = freqs.new * 1000; | 96 | freq = freqs.new * 1000; |
100 | ret = clk_round_rate(mpu_clk, freq); | 97 | ret = clk_round_rate(mpu_clk, freq); |
101 | if (IS_ERR_VALUE(ret)) { | 98 | if (IS_ERR_VALUE(ret)) { |
@@ -125,6 +122,9 @@ static int omap_target(struct cpufreq_policy *policy, | |||
125 | freqs.old / 1000, volt_old ? volt_old / 1000 : -1, | 122 | freqs.old / 1000, volt_old ? volt_old / 1000 : -1, |
126 | freqs.new / 1000, volt ? volt / 1000 : -1); | 123 | freqs.new / 1000, volt ? volt / 1000 : -1); |
127 | 124 | ||
125 | /* notifiers */ | ||
126 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | ||
127 | |||
128 | /* scaling up? scale voltage before frequency */ | 128 | /* scaling up? scale voltage before frequency */ |
129 | if (mpu_reg && (freqs.new > freqs.old)) { | 129 | if (mpu_reg && (freqs.new > freqs.old)) { |
130 | r = regulator_set_voltage(mpu_reg, volt - tol, volt + tol); | 130 | r = regulator_set_voltage(mpu_reg, volt - tol, volt + tol); |
diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c index 421ef37d0bb3..9ee78170ff86 100644 --- a/drivers/cpufreq/p4-clockmod.c +++ b/drivers/cpufreq/p4-clockmod.c | |||
@@ -118,7 +118,7 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy, | |||
118 | return -EINVAL; | 118 | return -EINVAL; |
119 | 119 | ||
120 | freqs.old = cpufreq_p4_get(policy->cpu); | 120 | freqs.old = cpufreq_p4_get(policy->cpu); |
121 | freqs.new = stock_freq * p4clockmod_table[newstate].index / 8; | 121 | freqs.new = stock_freq * p4clockmod_table[newstate].driver_data / 8; |
122 | 122 | ||
123 | if (freqs.new == freqs.old) | 123 | if (freqs.new == freqs.old) |
124 | return 0; | 124 | return 0; |
@@ -131,7 +131,7 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy, | |||
131 | * Developer's Manual, Volume 3 | 131 | * Developer's Manual, Volume 3 |
132 | */ | 132 | */ |
133 | for_each_cpu(i, policy->cpus) | 133 | for_each_cpu(i, policy->cpus) |
134 | cpufreq_p4_setdc(i, p4clockmod_table[newstate].index); | 134 | cpufreq_p4_setdc(i, p4clockmod_table[newstate].driver_data); |
135 | 135 | ||
136 | /* notifiers */ | 136 | /* notifiers */ |
137 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 137 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
diff --git a/arch/powerpc/platforms/pasemi/cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c index be1e7958909e..b704da404067 100644 --- a/arch/powerpc/platforms/pasemi/cpufreq.c +++ b/drivers/cpufreq/pasemi-cpufreq.c | |||
@@ -204,7 +204,8 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
204 | 204 | ||
205 | /* initialize frequency table */ | 205 | /* initialize frequency table */ |
206 | for (i=0; pas_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) { | 206 | for (i=0; pas_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) { |
207 | pas_freqs[i].frequency = get_astate_freq(pas_freqs[i].index) * 100000; | 207 | pas_freqs[i].frequency = |
208 | get_astate_freq(pas_freqs[i].driver_data) * 100000; | ||
208 | pr_debug("%d: %d\n", i, pas_freqs[i].frequency); | 209 | pr_debug("%d: %d\n", i, pas_freqs[i].frequency); |
209 | } | 210 | } |
210 | 211 | ||
@@ -280,7 +281,7 @@ static int pas_cpufreq_target(struct cpufreq_policy *policy, | |||
280 | pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n", | 281 | pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n", |
281 | policy->cpu, | 282 | policy->cpu, |
282 | pas_freqs[pas_astate_new].frequency, | 283 | pas_freqs[pas_astate_new].frequency, |
283 | pas_freqs[pas_astate_new].index); | 284 | pas_freqs[pas_astate_new].driver_data); |
284 | 285 | ||
285 | current_astate = pas_astate_new; | 286 | current_astate = pas_astate_new; |
286 | 287 | ||
diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c index 0de00081a81e..1581fcc4cf4a 100644 --- a/drivers/cpufreq/pcc-cpufreq.c +++ b/drivers/cpufreq/pcc-cpufreq.c | |||
@@ -243,6 +243,8 @@ static int pcc_cpufreq_target(struct cpufreq_policy *policy, | |||
243 | return 0; | 243 | return 0; |
244 | 244 | ||
245 | cmd_incomplete: | 245 | cmd_incomplete: |
246 | freqs.new = freqs.old; | ||
247 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | ||
246 | iowrite16(0, &pcch_hdr->status); | 248 | iowrite16(0, &pcch_hdr->status); |
247 | spin_unlock(&pcc_lock); | 249 | spin_unlock(&pcc_lock); |
248 | return -EINVAL; | 250 | return -EINVAL; |
diff --git a/arch/powerpc/platforms/powermac/cpufreq_32.c b/drivers/cpufreq/pmac32-cpufreq.c index 3104fad82480..3104fad82480 100644 --- a/arch/powerpc/platforms/powermac/cpufreq_32.c +++ b/drivers/cpufreq/pmac32-cpufreq.c | |||
diff --git a/arch/powerpc/platforms/powermac/cpufreq_64.c b/drivers/cpufreq/pmac64-cpufreq.c index 7ba423431cfe..7ba423431cfe 100644 --- a/arch/powerpc/platforms/powermac/cpufreq_64.c +++ b/drivers/cpufreq/pmac64-cpufreq.c | |||
diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c index ea0222a45b7b..ea8e10382ec5 100644 --- a/drivers/cpufreq/powernow-k6.c +++ b/drivers/cpufreq/powernow-k6.c | |||
@@ -58,7 +58,7 @@ static int powernow_k6_get_cpu_multiplier(void) | |||
58 | msrval = POWERNOW_IOPORT + 0x0; | 58 | msrval = POWERNOW_IOPORT + 0x0; |
59 | wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */ | 59 | wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */ |
60 | 60 | ||
61 | return clock_ratio[(invalue >> 5)&7].index; | 61 | return clock_ratio[(invalue >> 5)&7].driver_data; |
62 | } | 62 | } |
63 | 63 | ||
64 | 64 | ||
@@ -75,13 +75,13 @@ static void powernow_k6_set_state(struct cpufreq_policy *policy, | |||
75 | unsigned long msrval; | 75 | unsigned long msrval; |
76 | struct cpufreq_freqs freqs; | 76 | struct cpufreq_freqs freqs; |
77 | 77 | ||
78 | if (clock_ratio[best_i].index > max_multiplier) { | 78 | if (clock_ratio[best_i].driver_data > max_multiplier) { |
79 | printk(KERN_ERR PFX "invalid target frequency\n"); | 79 | printk(KERN_ERR PFX "invalid target frequency\n"); |
80 | return; | 80 | return; |
81 | } | 81 | } |
82 | 82 | ||
83 | freqs.old = busfreq * powernow_k6_get_cpu_multiplier(); | 83 | freqs.old = busfreq * powernow_k6_get_cpu_multiplier(); |
84 | freqs.new = busfreq * clock_ratio[best_i].index; | 84 | freqs.new = busfreq * clock_ratio[best_i].driver_data; |
85 | 85 | ||
86 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | 86 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
87 | 87 | ||
@@ -156,7 +156,7 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy) | |||
156 | 156 | ||
157 | /* table init */ | 157 | /* table init */ |
158 | for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) { | 158 | for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) { |
159 | f = clock_ratio[i].index; | 159 | f = clock_ratio[i].driver_data; |
160 | if (f > max_multiplier) | 160 | if (f > max_multiplier) |
161 | clock_ratio[i].frequency = CPUFREQ_ENTRY_INVALID; | 161 | clock_ratio[i].frequency = CPUFREQ_ENTRY_INVALID; |
162 | else | 162 | else |
diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c index 53888dacbe58..b9f80b713fda 100644 --- a/drivers/cpufreq/powernow-k7.c +++ b/drivers/cpufreq/powernow-k7.c | |||
@@ -186,7 +186,7 @@ static int get_ranges(unsigned char *pst) | |||
186 | fid = *pst++; | 186 | fid = *pst++; |
187 | 187 | ||
188 | powernow_table[j].frequency = (fsb * fid_codes[fid]) / 10; | 188 | powernow_table[j].frequency = (fsb * fid_codes[fid]) / 10; |
189 | powernow_table[j].index = fid; /* lower 8 bits */ | 189 | powernow_table[j].driver_data = fid; /* lower 8 bits */ |
190 | 190 | ||
191 | speed = powernow_table[j].frequency; | 191 | speed = powernow_table[j].frequency; |
192 | 192 | ||
@@ -203,7 +203,7 @@ static int get_ranges(unsigned char *pst) | |||
203 | maximum_speed = speed; | 203 | maximum_speed = speed; |
204 | 204 | ||
205 | vid = *pst++; | 205 | vid = *pst++; |
206 | powernow_table[j].index |= (vid << 8); /* upper 8 bits */ | 206 | powernow_table[j].driver_data |= (vid << 8); /* upper 8 bits */ |
207 | 207 | ||
208 | pr_debug(" FID: 0x%x (%d.%dx [%dMHz]) " | 208 | pr_debug(" FID: 0x%x (%d.%dx [%dMHz]) " |
209 | "VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10, | 209 | "VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10, |
@@ -212,7 +212,7 @@ static int get_ranges(unsigned char *pst) | |||
212 | mobile_vid_table[vid]%1000); | 212 | mobile_vid_table[vid]%1000); |
213 | } | 213 | } |
214 | powernow_table[number_scales].frequency = CPUFREQ_TABLE_END; | 214 | powernow_table[number_scales].frequency = CPUFREQ_TABLE_END; |
215 | powernow_table[number_scales].index = 0; | 215 | powernow_table[number_scales].driver_data = 0; |
216 | 216 | ||
217 | return 0; | 217 | return 0; |
218 | } | 218 | } |
@@ -260,8 +260,8 @@ static void change_speed(struct cpufreq_policy *policy, unsigned int index) | |||
260 | * vid are the upper 8 bits. | 260 | * vid are the upper 8 bits. |
261 | */ | 261 | */ |
262 | 262 | ||
263 | fid = powernow_table[index].index & 0xFF; | 263 | fid = powernow_table[index].driver_data & 0xFF; |
264 | vid = (powernow_table[index].index & 0xFF00) >> 8; | 264 | vid = (powernow_table[index].driver_data & 0xFF00) >> 8; |
265 | 265 | ||
266 | rdmsrl(MSR_K7_FID_VID_STATUS, fidvidstatus.val); | 266 | rdmsrl(MSR_K7_FID_VID_STATUS, fidvidstatus.val); |
267 | cfid = fidvidstatus.bits.CFID; | 267 | cfid = fidvidstatus.bits.CFID; |
@@ -373,8 +373,8 @@ static int powernow_acpi_init(void) | |||
373 | fid = pc.bits.fid; | 373 | fid = pc.bits.fid; |
374 | 374 | ||
375 | powernow_table[i].frequency = fsb * fid_codes[fid] / 10; | 375 | powernow_table[i].frequency = fsb * fid_codes[fid] / 10; |
376 | powernow_table[i].index = fid; /* lower 8 bits */ | 376 | powernow_table[i].driver_data = fid; /* lower 8 bits */ |
377 | powernow_table[i].index |= (vid << 8); /* upper 8 bits */ | 377 | powernow_table[i].driver_data |= (vid << 8); /* upper 8 bits */ |
378 | 378 | ||
379 | speed = powernow_table[i].frequency; | 379 | speed = powernow_table[i].frequency; |
380 | speed_mhz = speed / 1000; | 380 | speed_mhz = speed / 1000; |
@@ -417,7 +417,7 @@ static int powernow_acpi_init(void) | |||
417 | } | 417 | } |
418 | 418 | ||
419 | powernow_table[i].frequency = CPUFREQ_TABLE_END; | 419 | powernow_table[i].frequency = CPUFREQ_TABLE_END; |
420 | powernow_table[i].index = 0; | 420 | powernow_table[i].driver_data = 0; |
421 | 421 | ||
422 | /* notify BIOS that we exist */ | 422 | /* notify BIOS that we exist */ |
423 | acpi_processor_notify_smm(THIS_MODULE); | 423 | acpi_processor_notify_smm(THIS_MODULE); |
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c index b828efe4b2f8..78f018f2a5de 100644 --- a/drivers/cpufreq/powernow-k8.c +++ b/drivers/cpufreq/powernow-k8.c | |||
@@ -584,9 +584,9 @@ static void print_basics(struct powernow_k8_data *data) | |||
584 | CPUFREQ_ENTRY_INVALID) { | 584 | CPUFREQ_ENTRY_INVALID) { |
585 | printk(KERN_INFO PFX | 585 | printk(KERN_INFO PFX |
586 | "fid 0x%x (%d MHz), vid 0x%x\n", | 586 | "fid 0x%x (%d MHz), vid 0x%x\n", |
587 | data->powernow_table[j].index & 0xff, | 587 | data->powernow_table[j].driver_data & 0xff, |
588 | data->powernow_table[j].frequency/1000, | 588 | data->powernow_table[j].frequency/1000, |
589 | data->powernow_table[j].index >> 8); | 589 | data->powernow_table[j].driver_data >> 8); |
590 | } | 590 | } |
591 | } | 591 | } |
592 | if (data->batps) | 592 | if (data->batps) |
@@ -632,13 +632,13 @@ static int fill_powernow_table(struct powernow_k8_data *data, | |||
632 | 632 | ||
633 | for (j = 0; j < data->numps; j++) { | 633 | for (j = 0; j < data->numps; j++) { |
634 | int freq; | 634 | int freq; |
635 | powernow_table[j].index = pst[j].fid; /* lower 8 bits */ | 635 | powernow_table[j].driver_data = pst[j].fid; /* lower 8 bits */ |
636 | powernow_table[j].index |= (pst[j].vid << 8); /* upper 8 bits */ | 636 | powernow_table[j].driver_data |= (pst[j].vid << 8); /* upper 8 bits */ |
637 | freq = find_khz_freq_from_fid(pst[j].fid); | 637 | freq = find_khz_freq_from_fid(pst[j].fid); |
638 | powernow_table[j].frequency = freq; | 638 | powernow_table[j].frequency = freq; |
639 | } | 639 | } |
640 | powernow_table[data->numps].frequency = CPUFREQ_TABLE_END; | 640 | powernow_table[data->numps].frequency = CPUFREQ_TABLE_END; |
641 | powernow_table[data->numps].index = 0; | 641 | powernow_table[data->numps].driver_data = 0; |
642 | 642 | ||
643 | if (query_current_values_with_pending_wait(data)) { | 643 | if (query_current_values_with_pending_wait(data)) { |
644 | kfree(powernow_table); | 644 | kfree(powernow_table); |
@@ -810,7 +810,7 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) | |||
810 | 810 | ||
811 | powernow_table[data->acpi_data.state_count].frequency = | 811 | powernow_table[data->acpi_data.state_count].frequency = |
812 | CPUFREQ_TABLE_END; | 812 | CPUFREQ_TABLE_END; |
813 | powernow_table[data->acpi_data.state_count].index = 0; | 813 | powernow_table[data->acpi_data.state_count].driver_data = 0; |
814 | data->powernow_table = powernow_table; | 814 | data->powernow_table = powernow_table; |
815 | 815 | ||
816 | if (cpumask_first(cpu_core_mask(data->cpu)) == data->cpu) | 816 | if (cpumask_first(cpu_core_mask(data->cpu)) == data->cpu) |
@@ -865,7 +865,7 @@ static int fill_powernow_table_fidvid(struct powernow_k8_data *data, | |||
865 | pr_debug(" %d : fid 0x%x, vid 0x%x\n", i, fid, vid); | 865 | pr_debug(" %d : fid 0x%x, vid 0x%x\n", i, fid, vid); |
866 | 866 | ||
867 | index = fid | (vid<<8); | 867 | index = fid | (vid<<8); |
868 | powernow_table[i].index = index; | 868 | powernow_table[i].driver_data = index; |
869 | 869 | ||
870 | freq = find_khz_freq_from_fid(fid); | 870 | freq = find_khz_freq_from_fid(fid); |
871 | powernow_table[i].frequency = freq; | 871 | powernow_table[i].frequency = freq; |
@@ -941,8 +941,8 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data, | |||
941 | * the cpufreq frequency table in find_psb_table, vid | 941 | * the cpufreq frequency table in find_psb_table, vid |
942 | * are the upper 8 bits. | 942 | * are the upper 8 bits. |
943 | */ | 943 | */ |
944 | fid = data->powernow_table[index].index & 0xFF; | 944 | fid = data->powernow_table[index].driver_data & 0xFF; |
945 | vid = (data->powernow_table[index].index & 0xFF00) >> 8; | 945 | vid = (data->powernow_table[index].driver_data & 0xFF00) >> 8; |
946 | 946 | ||
947 | pr_debug("table matched fid 0x%x, giving vid 0x%x\n", fid, vid); | 947 | pr_debug("table matched fid 0x%x, giving vid 0x%x\n", fid, vid); |
948 | 948 | ||
@@ -967,9 +967,9 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data, | |||
967 | 967 | ||
968 | res = transition_fid_vid(data, fid, vid); | 968 | res = transition_fid_vid(data, fid, vid); |
969 | if (res) | 969 | if (res) |
970 | return res; | 970 | freqs.new = freqs.old; |
971 | 971 | else | |
972 | freqs.new = find_khz_freq_from_fid(data->currfid); | 972 | freqs.new = find_khz_freq_from_fid(data->currfid); |
973 | 973 | ||
974 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 974 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
975 | return res; | 975 | return res; |
diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c new file mode 100644 index 000000000000..3cae4529f959 --- /dev/null +++ b/drivers/cpufreq/ppc-corenet-cpufreq.c | |||
@@ -0,0 +1,380 @@ | |||
1 | /* | ||
2 | * Copyright 2013 Freescale Semiconductor, Inc. | ||
3 | * | ||
4 | * CPU Frequency Scaling driver for Freescale PowerPC corenet SoCs. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
12 | |||
13 | #include <linux/clk.h> | ||
14 | #include <linux/cpufreq.h> | ||
15 | #include <linux/errno.h> | ||
16 | #include <sysdev/fsl_soc.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/mutex.h> | ||
21 | #include <linux/of.h> | ||
22 | #include <linux/slab.h> | ||
23 | #include <linux/smp.h> | ||
24 | |||
25 | /** | ||
26 | * struct cpu_data - per CPU data struct | ||
27 | * @clk: the clk of CPU | ||
28 | * @parent: the parent node of cpu clock | ||
29 | * @table: frequency table | ||
30 | */ | ||
31 | struct cpu_data { | ||
32 | struct clk *clk; | ||
33 | struct device_node *parent; | ||
34 | struct cpufreq_frequency_table *table; | ||
35 | }; | ||
36 | |||
37 | /** | ||
38 | * struct soc_data - SoC specific data | ||
39 | * @freq_mask: mask the disallowed frequencies | ||
40 | * @flag: unique flags | ||
41 | */ | ||
42 | struct soc_data { | ||
43 | u32 freq_mask[4]; | ||
44 | u32 flag; | ||
45 | }; | ||
46 | |||
47 | #define FREQ_MASK 1 | ||
48 | /* see hardware specification for the allowed frqeuencies */ | ||
49 | static const struct soc_data sdata[] = { | ||
50 | { /* used by p2041 and p3041 */ | ||
51 | .freq_mask = {0x8, 0x8, 0x2, 0x2}, | ||
52 | .flag = FREQ_MASK, | ||
53 | }, | ||
54 | { /* used by p5020 */ | ||
55 | .freq_mask = {0x8, 0x2}, | ||
56 | .flag = FREQ_MASK, | ||
57 | }, | ||
58 | { /* used by p4080, p5040 */ | ||
59 | .freq_mask = {0}, | ||
60 | .flag = 0, | ||
61 | }, | ||
62 | }; | ||
63 | |||
64 | /* | ||
65 | * the minimum allowed core frequency, in Hz | ||
66 | * for chassis v1.0, >= platform frequency | ||
67 | * for chassis v2.0, >= platform frequency / 2 | ||
68 | */ | ||
69 | static u32 min_cpufreq; | ||
70 | static const u32 *fmask; | ||
71 | |||
72 | /* serialize frequency changes */ | ||
73 | static DEFINE_MUTEX(cpufreq_lock); | ||
74 | static DEFINE_PER_CPU(struct cpu_data *, cpu_data); | ||
75 | |||
76 | /* cpumask in a cluster */ | ||
77 | static DEFINE_PER_CPU(cpumask_var_t, cpu_mask); | ||
78 | |||
79 | #ifndef CONFIG_SMP | ||
80 | static inline const struct cpumask *cpu_core_mask(int cpu) | ||
81 | { | ||
82 | return cpumask_of(0); | ||
83 | } | ||
84 | #endif | ||
85 | |||
86 | static unsigned int corenet_cpufreq_get_speed(unsigned int cpu) | ||
87 | { | ||
88 | struct cpu_data *data = per_cpu(cpu_data, cpu); | ||
89 | |||
90 | return clk_get_rate(data->clk) / 1000; | ||
91 | } | ||
92 | |||
93 | /* reduce the duplicated frequencies in frequency table */ | ||
94 | static void freq_table_redup(struct cpufreq_frequency_table *freq_table, | ||
95 | int count) | ||
96 | { | ||
97 | int i, j; | ||
98 | |||
99 | for (i = 1; i < count; i++) { | ||
100 | for (j = 0; j < i; j++) { | ||
101 | if (freq_table[j].frequency == CPUFREQ_ENTRY_INVALID || | ||
102 | freq_table[j].frequency != | ||
103 | freq_table[i].frequency) | ||
104 | continue; | ||
105 | |||
106 | freq_table[i].frequency = CPUFREQ_ENTRY_INVALID; | ||
107 | break; | ||
108 | } | ||
109 | } | ||
110 | } | ||
111 | |||
112 | /* sort the frequencies in frequency table in descenting order */ | ||
113 | static void freq_table_sort(struct cpufreq_frequency_table *freq_table, | ||
114 | int count) | ||
115 | { | ||
116 | int i, j, ind; | ||
117 | unsigned int freq, max_freq; | ||
118 | struct cpufreq_frequency_table table; | ||
119 | for (i = 0; i < count - 1; i++) { | ||
120 | max_freq = freq_table[i].frequency; | ||
121 | ind = i; | ||
122 | for (j = i + 1; j < count; j++) { | ||
123 | freq = freq_table[j].frequency; | ||
124 | if (freq == CPUFREQ_ENTRY_INVALID || | ||
125 | freq <= max_freq) | ||
126 | continue; | ||
127 | ind = j; | ||
128 | max_freq = freq; | ||
129 | } | ||
130 | |||
131 | if (ind != i) { | ||
132 | /* exchange the frequencies */ | ||
133 | table.driver_data = freq_table[i].driver_data; | ||
134 | table.frequency = freq_table[i].frequency; | ||
135 | freq_table[i].driver_data = freq_table[ind].driver_data; | ||
136 | freq_table[i].frequency = freq_table[ind].frequency; | ||
137 | freq_table[ind].driver_data = table.driver_data; | ||
138 | freq_table[ind].frequency = table.frequency; | ||
139 | } | ||
140 | } | ||
141 | } | ||
142 | |||
143 | static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy) | ||
144 | { | ||
145 | struct device_node *np; | ||
146 | int i, count, ret; | ||
147 | u32 freq, mask; | ||
148 | struct clk *clk; | ||
149 | struct cpufreq_frequency_table *table; | ||
150 | struct cpu_data *data; | ||
151 | unsigned int cpu = policy->cpu; | ||
152 | |||
153 | np = of_get_cpu_node(cpu, NULL); | ||
154 | if (!np) | ||
155 | return -ENODEV; | ||
156 | |||
157 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
158 | if (!data) { | ||
159 | pr_err("%s: no memory\n", __func__); | ||
160 | goto err_np; | ||
161 | } | ||
162 | |||
163 | data->clk = of_clk_get(np, 0); | ||
164 | if (IS_ERR(data->clk)) { | ||
165 | pr_err("%s: no clock information\n", __func__); | ||
166 | goto err_nomem2; | ||
167 | } | ||
168 | |||
169 | data->parent = of_parse_phandle(np, "clocks", 0); | ||
170 | if (!data->parent) { | ||
171 | pr_err("%s: could not get clock information\n", __func__); | ||
172 | goto err_nomem2; | ||
173 | } | ||
174 | |||
175 | count = of_property_count_strings(data->parent, "clock-names"); | ||
176 | table = kcalloc(count + 1, sizeof(*table), GFP_KERNEL); | ||
177 | if (!table) { | ||
178 | pr_err("%s: no memory\n", __func__); | ||
179 | goto err_node; | ||
180 | } | ||
181 | |||
182 | if (fmask) | ||
183 | mask = fmask[get_hard_smp_processor_id(cpu)]; | ||
184 | else | ||
185 | mask = 0x0; | ||
186 | |||
187 | for (i = 0; i < count; i++) { | ||
188 | clk = of_clk_get(data->parent, i); | ||
189 | freq = clk_get_rate(clk); | ||
190 | /* | ||
191 | * the clock is valid if its frequency is not masked | ||
192 | * and large than minimum allowed frequency. | ||
193 | */ | ||
194 | if (freq < min_cpufreq || (mask & (1 << i))) | ||
195 | table[i].frequency = CPUFREQ_ENTRY_INVALID; | ||
196 | else | ||
197 | table[i].frequency = freq / 1000; | ||
198 | table[i].driver_data = i; | ||
199 | } | ||
200 | freq_table_redup(table, count); | ||
201 | freq_table_sort(table, count); | ||
202 | table[i].frequency = CPUFREQ_TABLE_END; | ||
203 | |||
204 | /* set the min and max frequency properly */ | ||
205 | ret = cpufreq_frequency_table_cpuinfo(policy, table); | ||
206 | if (ret) { | ||
207 | pr_err("invalid frequency table: %d\n", ret); | ||
208 | goto err_nomem1; | ||
209 | } | ||
210 | |||
211 | data->table = table; | ||
212 | per_cpu(cpu_data, cpu) = data; | ||
213 | |||
214 | /* update ->cpus if we have cluster, no harm if not */ | ||
215 | cpumask_copy(policy->cpus, per_cpu(cpu_mask, cpu)); | ||
216 | for_each_cpu(i, per_cpu(cpu_mask, cpu)) | ||
217 | per_cpu(cpu_data, i) = data; | ||
218 | |||
219 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | ||
220 | policy->cur = corenet_cpufreq_get_speed(policy->cpu); | ||
221 | |||
222 | cpufreq_frequency_table_get_attr(table, cpu); | ||
223 | of_node_put(np); | ||
224 | |||
225 | return 0; | ||
226 | |||
227 | err_nomem1: | ||
228 | kfree(table); | ||
229 | err_node: | ||
230 | of_node_put(data->parent); | ||
231 | err_nomem2: | ||
232 | per_cpu(cpu_data, cpu) = NULL; | ||
233 | kfree(data); | ||
234 | err_np: | ||
235 | of_node_put(np); | ||
236 | |||
237 | return -ENODEV; | ||
238 | } | ||
239 | |||
240 | static int __exit corenet_cpufreq_cpu_exit(struct cpufreq_policy *policy) | ||
241 | { | ||
242 | struct cpu_data *data = per_cpu(cpu_data, policy->cpu); | ||
243 | unsigned int cpu; | ||
244 | |||
245 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
246 | of_node_put(data->parent); | ||
247 | kfree(data->table); | ||
248 | kfree(data); | ||
249 | |||
250 | for_each_cpu(cpu, per_cpu(cpu_mask, policy->cpu)) | ||
251 | per_cpu(cpu_data, cpu) = NULL; | ||
252 | |||
253 | return 0; | ||
254 | } | ||
255 | |||
256 | static int corenet_cpufreq_verify(struct cpufreq_policy *policy) | ||
257 | { | ||
258 | struct cpufreq_frequency_table *table = | ||
259 | per_cpu(cpu_data, policy->cpu)->table; | ||
260 | |||
261 | return cpufreq_frequency_table_verify(policy, table); | ||
262 | } | ||
263 | |||
264 | static int corenet_cpufreq_target(struct cpufreq_policy *policy, | ||
265 | unsigned int target_freq, unsigned int relation) | ||
266 | { | ||
267 | struct cpufreq_freqs freqs; | ||
268 | unsigned int new; | ||
269 | struct clk *parent; | ||
270 | int ret; | ||
271 | struct cpu_data *data = per_cpu(cpu_data, policy->cpu); | ||
272 | |||
273 | cpufreq_frequency_table_target(policy, data->table, | ||
274 | target_freq, relation, &new); | ||
275 | |||
276 | if (policy->cur == data->table[new].frequency) | ||
277 | return 0; | ||
278 | |||
279 | freqs.old = policy->cur; | ||
280 | freqs.new = data->table[new].frequency; | ||
281 | |||
282 | mutex_lock(&cpufreq_lock); | ||
283 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | ||
284 | |||
285 | parent = of_clk_get(data->parent, data->table[new].driver_data); | ||
286 | ret = clk_set_parent(data->clk, parent); | ||
287 | if (ret) | ||
288 | freqs.new = freqs.old; | ||
289 | |||
290 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | ||
291 | mutex_unlock(&cpufreq_lock); | ||
292 | |||
293 | return ret; | ||
294 | } | ||
295 | |||
296 | static struct freq_attr *corenet_cpufreq_attr[] = { | ||
297 | &cpufreq_freq_attr_scaling_available_freqs, | ||
298 | NULL, | ||
299 | }; | ||
300 | |||
301 | static struct cpufreq_driver ppc_corenet_cpufreq_driver = { | ||
302 | .name = "ppc_cpufreq", | ||
303 | .owner = THIS_MODULE, | ||
304 | .flags = CPUFREQ_CONST_LOOPS, | ||
305 | .init = corenet_cpufreq_cpu_init, | ||
306 | .exit = __exit_p(corenet_cpufreq_cpu_exit), | ||
307 | .verify = corenet_cpufreq_verify, | ||
308 | .target = corenet_cpufreq_target, | ||
309 | .get = corenet_cpufreq_get_speed, | ||
310 | .attr = corenet_cpufreq_attr, | ||
311 | }; | ||
312 | |||
313 | static const struct of_device_id node_matches[] __initdata = { | ||
314 | { .compatible = "fsl,p2041-clockgen", .data = &sdata[0], }, | ||
315 | { .compatible = "fsl,p3041-clockgen", .data = &sdata[0], }, | ||
316 | { .compatible = "fsl,p5020-clockgen", .data = &sdata[1], }, | ||
317 | { .compatible = "fsl,p4080-clockgen", .data = &sdata[2], }, | ||
318 | { .compatible = "fsl,p5040-clockgen", .data = &sdata[2], }, | ||
319 | { .compatible = "fsl,qoriq-clockgen-2.0", }, | ||
320 | {} | ||
321 | }; | ||
322 | |||
323 | static int __init ppc_corenet_cpufreq_init(void) | ||
324 | { | ||
325 | int ret; | ||
326 | struct device_node *np; | ||
327 | const struct of_device_id *match; | ||
328 | const struct soc_data *data; | ||
329 | unsigned int cpu; | ||
330 | |||
331 | np = of_find_matching_node(NULL, node_matches); | ||
332 | if (!np) | ||
333 | return -ENODEV; | ||
334 | |||
335 | for_each_possible_cpu(cpu) { | ||
336 | if (!alloc_cpumask_var(&per_cpu(cpu_mask, cpu), GFP_KERNEL)) | ||
337 | goto err_mask; | ||
338 | cpumask_copy(per_cpu(cpu_mask, cpu), cpu_core_mask(cpu)); | ||
339 | } | ||
340 | |||
341 | match = of_match_node(node_matches, np); | ||
342 | data = match->data; | ||
343 | if (data) { | ||
344 | if (data->flag) | ||
345 | fmask = data->freq_mask; | ||
346 | min_cpufreq = fsl_get_sys_freq(); | ||
347 | } else { | ||
348 | min_cpufreq = fsl_get_sys_freq() / 2; | ||
349 | } | ||
350 | |||
351 | of_node_put(np); | ||
352 | |||
353 | ret = cpufreq_register_driver(&ppc_corenet_cpufreq_driver); | ||
354 | if (!ret) | ||
355 | pr_info("Freescale PowerPC corenet CPU frequency scaling driver\n"); | ||
356 | |||
357 | return ret; | ||
358 | |||
359 | err_mask: | ||
360 | for_each_possible_cpu(cpu) | ||
361 | free_cpumask_var(per_cpu(cpu_mask, cpu)); | ||
362 | |||
363 | return -ENOMEM; | ||
364 | } | ||
365 | module_init(ppc_corenet_cpufreq_init); | ||
366 | |||
367 | static void __exit ppc_corenet_cpufreq_exit(void) | ||
368 | { | ||
369 | unsigned int cpu; | ||
370 | |||
371 | for_each_possible_cpu(cpu) | ||
372 | free_cpumask_var(per_cpu(cpu_mask, cpu)); | ||
373 | |||
374 | cpufreq_unregister_driver(&ppc_corenet_cpufreq_driver); | ||
375 | } | ||
376 | module_exit(ppc_corenet_cpufreq_exit); | ||
377 | |||
378 | MODULE_LICENSE("GPL"); | ||
379 | MODULE_AUTHOR("Tang Yuantian <Yuantian.Tang@freescale.com>"); | ||
380 | MODULE_DESCRIPTION("cpufreq driver for Freescale e500mc series SoCs"); | ||
diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c index e577a1dbbfcd..5936f8d6f2cc 100644 --- a/drivers/cpufreq/ppc_cbe_cpufreq.c +++ b/drivers/cpufreq/ppc_cbe_cpufreq.c | |||
@@ -106,7 +106,7 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
106 | 106 | ||
107 | /* initialize frequency table */ | 107 | /* initialize frequency table */ |
108 | for (i=0; cbe_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) { | 108 | for (i=0; cbe_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) { |
109 | cbe_freqs[i].frequency = max_freq / cbe_freqs[i].index; | 109 | cbe_freqs[i].frequency = max_freq / cbe_freqs[i].driver_data; |
110 | pr_debug("%d: %d\n", i, cbe_freqs[i].frequency); | 110 | pr_debug("%d: %d\n", i, cbe_freqs[i].frequency); |
111 | } | 111 | } |
112 | 112 | ||
@@ -165,7 +165,7 @@ static int cbe_cpufreq_target(struct cpufreq_policy *policy, | |||
165 | "1/%d of max frequency\n", | 165 | "1/%d of max frequency\n", |
166 | policy->cpu, | 166 | policy->cpu, |
167 | cbe_freqs[cbe_pmode_new].frequency, | 167 | cbe_freqs[cbe_pmode_new].frequency, |
168 | cbe_freqs[cbe_pmode_new].index); | 168 | cbe_freqs[cbe_pmode_new].driver_data); |
169 | 169 | ||
170 | rc = set_pmode(policy->cpu, cbe_pmode_new); | 170 | rc = set_pmode(policy->cpu, cbe_pmode_new); |
171 | 171 | ||
diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c index 9e5bc8e388a0..fb3981ac829f 100644 --- a/drivers/cpufreq/pxa2xx-cpufreq.c +++ b/drivers/cpufreq/pxa2xx-cpufreq.c | |||
@@ -420,7 +420,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy) | |||
420 | /* Generate pxa25x the run cpufreq_frequency_table struct */ | 420 | /* Generate pxa25x the run cpufreq_frequency_table struct */ |
421 | for (i = 0; i < NUM_PXA25x_RUN_FREQS; i++) { | 421 | for (i = 0; i < NUM_PXA25x_RUN_FREQS; i++) { |
422 | pxa255_run_freq_table[i].frequency = pxa255_run_freqs[i].khz; | 422 | pxa255_run_freq_table[i].frequency = pxa255_run_freqs[i].khz; |
423 | pxa255_run_freq_table[i].index = i; | 423 | pxa255_run_freq_table[i].driver_data = i; |
424 | } | 424 | } |
425 | pxa255_run_freq_table[i].frequency = CPUFREQ_TABLE_END; | 425 | pxa255_run_freq_table[i].frequency = CPUFREQ_TABLE_END; |
426 | 426 | ||
@@ -428,7 +428,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy) | |||
428 | for (i = 0; i < NUM_PXA25x_TURBO_FREQS; i++) { | 428 | for (i = 0; i < NUM_PXA25x_TURBO_FREQS; i++) { |
429 | pxa255_turbo_freq_table[i].frequency = | 429 | pxa255_turbo_freq_table[i].frequency = |
430 | pxa255_turbo_freqs[i].khz; | 430 | pxa255_turbo_freqs[i].khz; |
431 | pxa255_turbo_freq_table[i].index = i; | 431 | pxa255_turbo_freq_table[i].driver_data = i; |
432 | } | 432 | } |
433 | pxa255_turbo_freq_table[i].frequency = CPUFREQ_TABLE_END; | 433 | pxa255_turbo_freq_table[i].frequency = CPUFREQ_TABLE_END; |
434 | 434 | ||
@@ -440,9 +440,9 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy) | |||
440 | if (freq > pxa27x_maxfreq) | 440 | if (freq > pxa27x_maxfreq) |
441 | break; | 441 | break; |
442 | pxa27x_freq_table[i].frequency = freq; | 442 | pxa27x_freq_table[i].frequency = freq; |
443 | pxa27x_freq_table[i].index = i; | 443 | pxa27x_freq_table[i].driver_data = i; |
444 | } | 444 | } |
445 | pxa27x_freq_table[i].index = i; | 445 | pxa27x_freq_table[i].driver_data = i; |
446 | pxa27x_freq_table[i].frequency = CPUFREQ_TABLE_END; | 446 | pxa27x_freq_table[i].frequency = CPUFREQ_TABLE_END; |
447 | 447 | ||
448 | /* | 448 | /* |
diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpufreq.c index 15d60f857ad5..9c92ef032a9e 100644 --- a/drivers/cpufreq/pxa3xx-cpufreq.c +++ b/drivers/cpufreq/pxa3xx-cpufreq.c | |||
@@ -98,10 +98,10 @@ static int setup_freqs_table(struct cpufreq_policy *policy, | |||
98 | return -ENOMEM; | 98 | return -ENOMEM; |
99 | 99 | ||
100 | for (i = 0; i < num; i++) { | 100 | for (i = 0; i < num; i++) { |
101 | table[i].index = i; | 101 | table[i].driver_data = i; |
102 | table[i].frequency = freqs[i].cpufreq_mhz * 1000; | 102 | table[i].frequency = freqs[i].cpufreq_mhz * 1000; |
103 | } | 103 | } |
104 | table[num].index = i; | 104 | table[num].driver_data = i; |
105 | table[num].frequency = CPUFREQ_TABLE_END; | 105 | table[num].frequency = CPUFREQ_TABLE_END; |
106 | 106 | ||
107 | pxa3xx_freqs = freqs; | 107 | pxa3xx_freqs = freqs; |
diff --git a/drivers/cpufreq/s3c2416-cpufreq.c b/drivers/cpufreq/s3c2416-cpufreq.c index 4f1881eee3f1..e35865af96e2 100644 --- a/drivers/cpufreq/s3c2416-cpufreq.c +++ b/drivers/cpufreq/s3c2416-cpufreq.c | |||
@@ -244,7 +244,7 @@ static int s3c2416_cpufreq_set_target(struct cpufreq_policy *policy, | |||
244 | if (ret != 0) | 244 | if (ret != 0) |
245 | goto out; | 245 | goto out; |
246 | 246 | ||
247 | idx = s3c_freq->freq_table[i].index; | 247 | idx = s3c_freq->freq_table[i].driver_data; |
248 | 248 | ||
249 | if (idx == SOURCE_HCLK) | 249 | if (idx == SOURCE_HCLK) |
250 | to_dvs = 1; | 250 | to_dvs = 1; |
@@ -312,7 +312,7 @@ static void __init s3c2416_cpufreq_cfg_regulator(struct s3c2416_data *s3c_freq) | |||
312 | if (freq->frequency == CPUFREQ_ENTRY_INVALID) | 312 | if (freq->frequency == CPUFREQ_ENTRY_INVALID) |
313 | continue; | 313 | continue; |
314 | 314 | ||
315 | dvfs = &s3c2416_dvfs_table[freq->index]; | 315 | dvfs = &s3c2416_dvfs_table[freq->driver_data]; |
316 | found = 0; | 316 | found = 0; |
317 | 317 | ||
318 | /* Check only the min-voltage, more is always ok on S3C2416 */ | 318 | /* Check only the min-voltage, more is always ok on S3C2416 */ |
@@ -462,7 +462,7 @@ static int __init s3c2416_cpufreq_driver_init(struct cpufreq_policy *policy) | |||
462 | freq = s3c_freq->freq_table; | 462 | freq = s3c_freq->freq_table; |
463 | while (freq->frequency != CPUFREQ_TABLE_END) { | 463 | while (freq->frequency != CPUFREQ_TABLE_END) { |
464 | /* special handling for dvs mode */ | 464 | /* special handling for dvs mode */ |
465 | if (freq->index == 0) { | 465 | if (freq->driver_data == 0) { |
466 | if (!s3c_freq->hclk) { | 466 | if (!s3c_freq->hclk) { |
467 | pr_debug("cpufreq: %dkHz unsupported as it would need unavailable dvs mode\n", | 467 | pr_debug("cpufreq: %dkHz unsupported as it would need unavailable dvs mode\n", |
468 | freq->frequency); | 468 | freq->frequency); |
diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c index 3c0e78ede0da..3513e7477160 100644 --- a/drivers/cpufreq/s3c24xx-cpufreq.c +++ b/drivers/cpufreq/s3c24xx-cpufreq.c | |||
@@ -70,7 +70,7 @@ static void s3c_cpufreq_getcur(struct s3c_cpufreq_config *cfg) | |||
70 | cfg->freq.pclk = pclk = clk_get_rate(clk_pclk); | 70 | cfg->freq.pclk = pclk = clk_get_rate(clk_pclk); |
71 | cfg->freq.armclk = armclk = clk_get_rate(clk_arm); | 71 | cfg->freq.armclk = armclk = clk_get_rate(clk_arm); |
72 | 72 | ||
73 | cfg->pll.index = __raw_readl(S3C2410_MPLLCON); | 73 | cfg->pll.driver_data = __raw_readl(S3C2410_MPLLCON); |
74 | cfg->pll.frequency = fclk; | 74 | cfg->pll.frequency = fclk; |
75 | 75 | ||
76 | cfg->freq.hclk_tns = 1000000000 / (cfg->freq.hclk / 10); | 76 | cfg->freq.hclk_tns = 1000000000 / (cfg->freq.hclk / 10); |
@@ -431,7 +431,7 @@ static unsigned int suspend_freq; | |||
431 | static int s3c_cpufreq_suspend(struct cpufreq_policy *policy) | 431 | static int s3c_cpufreq_suspend(struct cpufreq_policy *policy) |
432 | { | 432 | { |
433 | suspend_pll.frequency = clk_get_rate(_clk_mpll); | 433 | suspend_pll.frequency = clk_get_rate(_clk_mpll); |
434 | suspend_pll.index = __raw_readl(S3C2410_MPLLCON); | 434 | suspend_pll.driver_data = __raw_readl(S3C2410_MPLLCON); |
435 | suspend_freq = s3c_cpufreq_get(0) * 1000; | 435 | suspend_freq = s3c_cpufreq_get(0) * 1000; |
436 | 436 | ||
437 | return 0; | 437 | return 0; |
diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c index 27cacb524796..13bb4bae64ee 100644 --- a/drivers/cpufreq/s3c64xx-cpufreq.c +++ b/drivers/cpufreq/s3c64xx-cpufreq.c | |||
@@ -87,7 +87,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy, | |||
87 | freqs.old = clk_get_rate(armclk) / 1000; | 87 | freqs.old = clk_get_rate(armclk) / 1000; |
88 | freqs.new = s3c64xx_freq_table[i].frequency; | 88 | freqs.new = s3c64xx_freq_table[i].frequency; |
89 | freqs.flags = 0; | 89 | freqs.flags = 0; |
90 | dvfs = &s3c64xx_dvfs_table[s3c64xx_freq_table[i].index]; | 90 | dvfs = &s3c64xx_dvfs_table[s3c64xx_freq_table[i].driver_data]; |
91 | 91 | ||
92 | if (freqs.old == freqs.new) | 92 | if (freqs.old == freqs.new) |
93 | return 0; | 93 | return 0; |
@@ -104,7 +104,8 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy, | |||
104 | if (ret != 0) { | 104 | if (ret != 0) { |
105 | pr_err("Failed to set VDDARM for %dkHz: %d\n", | 105 | pr_err("Failed to set VDDARM for %dkHz: %d\n", |
106 | freqs.new, ret); | 106 | freqs.new, ret); |
107 | goto err; | 107 | freqs.new = freqs.old; |
108 | goto post_notify; | ||
108 | } | 109 | } |
109 | } | 110 | } |
110 | #endif | 111 | #endif |
@@ -113,10 +114,13 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy, | |||
113 | if (ret < 0) { | 114 | if (ret < 0) { |
114 | pr_err("Failed to set rate %dkHz: %d\n", | 115 | pr_err("Failed to set rate %dkHz: %d\n", |
115 | freqs.new, ret); | 116 | freqs.new, ret); |
116 | goto err; | 117 | freqs.new = freqs.old; |
117 | } | 118 | } |
118 | 119 | ||
120 | post_notify: | ||
119 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 121 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
122 | if (ret) | ||
123 | goto err; | ||
120 | 124 | ||
121 | #ifdef CONFIG_REGULATOR | 125 | #ifdef CONFIG_REGULATOR |
122 | if (vddarm && freqs.new < freqs.old) { | 126 | if (vddarm && freqs.new < freqs.old) { |
diff --git a/drivers/cpufreq/sc520_freq.c b/drivers/cpufreq/sc520_freq.c index f740b134d27b..77a210975fc4 100644 --- a/drivers/cpufreq/sc520_freq.c +++ b/drivers/cpufreq/sc520_freq.c | |||
@@ -71,7 +71,7 @@ static void sc520_freq_set_cpu_state(struct cpufreq_policy *policy, | |||
71 | local_irq_disable(); | 71 | local_irq_disable(); |
72 | 72 | ||
73 | clockspeed_reg = *cpuctl & ~0x03; | 73 | clockspeed_reg = *cpuctl & ~0x03; |
74 | *cpuctl = clockspeed_reg | sc520_freq_table[state].index; | 74 | *cpuctl = clockspeed_reg | sc520_freq_table[state].driver_data; |
75 | 75 | ||
76 | local_irq_enable(); | 76 | local_irq_enable(); |
77 | 77 | ||
diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c index 306ae462bba6..93061a408773 100644 --- a/drivers/cpufreq/sparc-us2e-cpufreq.c +++ b/drivers/cpufreq/sparc-us2e-cpufreq.c | |||
@@ -308,17 +308,17 @@ static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy) | |||
308 | struct cpufreq_frequency_table *table = | 308 | struct cpufreq_frequency_table *table = |
309 | &us2e_freq_table[cpu].table[0]; | 309 | &us2e_freq_table[cpu].table[0]; |
310 | 310 | ||
311 | table[0].index = 0; | 311 | table[0].driver_data = 0; |
312 | table[0].frequency = clock_tick / 1; | 312 | table[0].frequency = clock_tick / 1; |
313 | table[1].index = 1; | 313 | table[1].driver_data = 1; |
314 | table[1].frequency = clock_tick / 2; | 314 | table[1].frequency = clock_tick / 2; |
315 | table[2].index = 2; | 315 | table[2].driver_data = 2; |
316 | table[2].frequency = clock_tick / 4; | 316 | table[2].frequency = clock_tick / 4; |
317 | table[2].index = 3; | 317 | table[2].driver_data = 3; |
318 | table[2].frequency = clock_tick / 6; | 318 | table[2].frequency = clock_tick / 6; |
319 | table[2].index = 4; | 319 | table[2].driver_data = 4; |
320 | table[2].frequency = clock_tick / 8; | 320 | table[2].frequency = clock_tick / 8; |
321 | table[2].index = 5; | 321 | table[2].driver_data = 5; |
322 | table[3].frequency = CPUFREQ_TABLE_END; | 322 | table[3].frequency = CPUFREQ_TABLE_END; |
323 | 323 | ||
324 | policy->cpuinfo.transition_latency = 0; | 324 | policy->cpuinfo.transition_latency = 0; |
diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c index c71ee142347a..880ee293d61e 100644 --- a/drivers/cpufreq/sparc-us3-cpufreq.c +++ b/drivers/cpufreq/sparc-us3-cpufreq.c | |||
@@ -169,13 +169,13 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy) | |||
169 | struct cpufreq_frequency_table *table = | 169 | struct cpufreq_frequency_table *table = |
170 | &us3_freq_table[cpu].table[0]; | 170 | &us3_freq_table[cpu].table[0]; |
171 | 171 | ||
172 | table[0].index = 0; | 172 | table[0].driver_data = 0; |
173 | table[0].frequency = clock_tick / 1; | 173 | table[0].frequency = clock_tick / 1; |
174 | table[1].index = 1; | 174 | table[1].driver_data = 1; |
175 | table[1].frequency = clock_tick / 2; | 175 | table[1].frequency = clock_tick / 2; |
176 | table[2].index = 2; | 176 | table[2].driver_data = 2; |
177 | table[2].frequency = clock_tick / 32; | 177 | table[2].frequency = clock_tick / 32; |
178 | table[3].index = 0; | 178 | table[3].driver_data = 0; |
179 | table[3].frequency = CPUFREQ_TABLE_END; | 179 | table[3].frequency = CPUFREQ_TABLE_END; |
180 | 180 | ||
181 | policy->cpuinfo.transition_latency = 0; | 181 | policy->cpuinfo.transition_latency = 0; |
diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c index 156829f4576d..c3efa7f2a908 100644 --- a/drivers/cpufreq/spear-cpufreq.c +++ b/drivers/cpufreq/spear-cpufreq.c | |||
@@ -250,11 +250,11 @@ static int spear_cpufreq_driver_init(void) | |||
250 | } | 250 | } |
251 | 251 | ||
252 | for (i = 0; i < cnt; i++) { | 252 | for (i = 0; i < cnt; i++) { |
253 | freq_tbl[i].index = i; | 253 | freq_tbl[i].driver_data = i; |
254 | freq_tbl[i].frequency = be32_to_cpup(val++); | 254 | freq_tbl[i].frequency = be32_to_cpup(val++); |
255 | } | 255 | } |
256 | 256 | ||
257 | freq_tbl[i].index = i; | 257 | freq_tbl[i].driver_data = i; |
258 | freq_tbl[i].frequency = CPUFREQ_TABLE_END; | 258 | freq_tbl[i].frequency = CPUFREQ_TABLE_END; |
259 | 259 | ||
260 | spear_cpufreq.freq_tbl = freq_tbl; | 260 | spear_cpufreq.freq_tbl = freq_tbl; |
diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c index 618e6f417b1c..0915e712fbdc 100644 --- a/drivers/cpufreq/speedstep-centrino.c +++ b/drivers/cpufreq/speedstep-centrino.c | |||
@@ -79,11 +79,11 @@ static struct cpufreq_driver centrino_driver; | |||
79 | 79 | ||
80 | /* Computes the correct form for IA32_PERF_CTL MSR for a particular | 80 | /* Computes the correct form for IA32_PERF_CTL MSR for a particular |
81 | frequency/voltage operating point; frequency in MHz, volts in mV. | 81 | frequency/voltage operating point; frequency in MHz, volts in mV. |
82 | This is stored as "index" in the structure. */ | 82 | This is stored as "driver_data" in the structure. */ |
83 | #define OP(mhz, mv) \ | 83 | #define OP(mhz, mv) \ |
84 | { \ | 84 | { \ |
85 | .frequency = (mhz) * 1000, \ | 85 | .frequency = (mhz) * 1000, \ |
86 | .index = (((mhz)/100) << 8) | ((mv - 700) / 16) \ | 86 | .driver_data = (((mhz)/100) << 8) | ((mv - 700) / 16) \ |
87 | } | 87 | } |
88 | 88 | ||
89 | /* | 89 | /* |
@@ -307,7 +307,7 @@ static unsigned extract_clock(unsigned msr, unsigned int cpu, int failsafe) | |||
307 | per_cpu(centrino_model, cpu)->op_points[i].frequency | 307 | per_cpu(centrino_model, cpu)->op_points[i].frequency |
308 | != CPUFREQ_TABLE_END; | 308 | != CPUFREQ_TABLE_END; |
309 | i++) { | 309 | i++) { |
310 | if (msr == per_cpu(centrino_model, cpu)->op_points[i].index) | 310 | if (msr == per_cpu(centrino_model, cpu)->op_points[i].driver_data) |
311 | return per_cpu(centrino_model, cpu)-> | 311 | return per_cpu(centrino_model, cpu)-> |
312 | op_points[i].frequency; | 312 | op_points[i].frequency; |
313 | } | 313 | } |
@@ -501,7 +501,7 @@ static int centrino_target (struct cpufreq_policy *policy, | |||
501 | break; | 501 | break; |
502 | } | 502 | } |
503 | 503 | ||
504 | msr = per_cpu(centrino_model, cpu)->op_points[newstate].index; | 504 | msr = per_cpu(centrino_model, cpu)->op_points[newstate].driver_data; |
505 | 505 | ||
506 | if (first_cpu) { | 506 | if (first_cpu) { |
507 | rdmsr_on_cpu(good_cpu, MSR_IA32_PERF_CTL, &oldmsr, &h); | 507 | rdmsr_on_cpu(good_cpu, MSR_IA32_PERF_CTL, &oldmsr, &h); |
diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c index c74c0e130ef4..cd66b85d927c 100644 --- a/drivers/cpufreq/tegra-cpufreq.c +++ b/drivers/cpufreq/tegra-cpufreq.c | |||
@@ -28,17 +28,16 @@ | |||
28 | #include <linux/io.h> | 28 | #include <linux/io.h> |
29 | #include <linux/suspend.h> | 29 | #include <linux/suspend.h> |
30 | 30 | ||
31 | /* Frequency table index must be sequential starting at 0 */ | ||
32 | static struct cpufreq_frequency_table freq_table[] = { | 31 | static struct cpufreq_frequency_table freq_table[] = { |
33 | { 0, 216000 }, | 32 | { .frequency = 216000 }, |
34 | { 1, 312000 }, | 33 | { .frequency = 312000 }, |
35 | { 2, 456000 }, | 34 | { .frequency = 456000 }, |
36 | { 3, 608000 }, | 35 | { .frequency = 608000 }, |
37 | { 4, 760000 }, | 36 | { .frequency = 760000 }, |
38 | { 5, 816000 }, | 37 | { .frequency = 816000 }, |
39 | { 6, 912000 }, | 38 | { .frequency = 912000 }, |
40 | { 7, 1000000 }, | 39 | { .frequency = 1000000 }, |
41 | { 8, CPUFREQ_TABLE_END }, | 40 | { .frequency = CPUFREQ_TABLE_END }, |
42 | }; | 41 | }; |
43 | 42 | ||
44 | #define NUM_CPUS 2 | 43 | #define NUM_CPUS 2 |
@@ -138,12 +137,12 @@ static int tegra_update_cpu_speed(struct cpufreq_policy *policy, | |||
138 | if (ret) { | 137 | if (ret) { |
139 | pr_err("cpu-tegra: Failed to set cpu frequency to %d kHz\n", | 138 | pr_err("cpu-tegra: Failed to set cpu frequency to %d kHz\n", |
140 | freqs.new); | 139 | freqs.new); |
141 | return ret; | 140 | freqs.new = freqs.old; |
142 | } | 141 | } |
143 | 142 | ||
144 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 143 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
145 | 144 | ||
146 | return 0; | 145 | return ret; |
147 | } | 146 | } |
148 | 147 | ||
149 | static unsigned long tegra_cpu_highest_speed(void) | 148 | static unsigned long tegra_cpu_highest_speed(void) |
diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig index e21cdfa4002a..0e2cd5cab4d0 100644 --- a/drivers/cpuidle/Kconfig +++ b/drivers/cpuidle/Kconfig | |||
@@ -1,7 +1,9 @@ | |||
1 | 1 | ||
2 | config CPU_IDLE | 2 | menuconfig CPU_IDLE |
3 | bool "CPU idle PM support" | 3 | bool "CPU idle PM support" |
4 | default y if ACPI || PPC_PSERIES | 4 | default y if ACPI || PPC_PSERIES |
5 | select CPU_IDLE_GOV_LADDER if (!NO_HZ && !NO_HZ_IDLE) | ||
6 | select CPU_IDLE_GOV_MENU if (NO_HZ || NO_HZ_IDLE) | ||
5 | help | 7 | help |
6 | CPU idle is a generic framework for supporting software-controlled | 8 | CPU idle is a generic framework for supporting software-controlled |
7 | idle processor power management. It includes modular cross-platform | 9 | idle processor power management. It includes modular cross-platform |
@@ -9,9 +11,10 @@ config CPU_IDLE | |||
9 | 11 | ||
10 | If you're using an ACPI-enabled platform, you should say Y here. | 12 | If you're using an ACPI-enabled platform, you should say Y here. |
11 | 13 | ||
14 | if CPU_IDLE | ||
15 | |||
12 | config CPU_IDLE_MULTIPLE_DRIVERS | 16 | config CPU_IDLE_MULTIPLE_DRIVERS |
13 | bool "Support multiple cpuidle drivers" | 17 | bool "Support multiple cpuidle drivers" |
14 | depends on CPU_IDLE | ||
15 | default n | 18 | default n |
16 | help | 19 | help |
17 | Allows the cpuidle framework to use different drivers for each CPU. | 20 | Allows the cpuidle framework to use different drivers for each CPU. |
@@ -19,20 +22,13 @@ config CPU_IDLE_MULTIPLE_DRIVERS | |||
19 | states. If unsure say N. | 22 | states. If unsure say N. |
20 | 23 | ||
21 | config CPU_IDLE_GOV_LADDER | 24 | config CPU_IDLE_GOV_LADDER |
22 | bool | 25 | bool "Ladder governor (for periodic timer tick)" |
23 | depends on CPU_IDLE | ||
24 | default y | 26 | default y |
25 | 27 | ||
26 | config CPU_IDLE_GOV_MENU | 28 | config CPU_IDLE_GOV_MENU |
27 | bool | 29 | bool "Menu governor (for tickless system)" |
28 | depends on CPU_IDLE && NO_HZ | ||
29 | default y | 30 | default y |
30 | 31 | ||
31 | config ARCH_NEEDS_CPU_IDLE_COUPLED | ||
32 | def_bool n | ||
33 | |||
34 | if CPU_IDLE | ||
35 | |||
36 | config CPU_IDLE_CALXEDA | 32 | config CPU_IDLE_CALXEDA |
37 | bool "CPU Idle Driver for Calxeda processors" | 33 | bool "CPU Idle Driver for Calxeda processors" |
38 | depends on ARCH_HIGHBANK | 34 | depends on ARCH_HIGHBANK |
@@ -40,4 +36,13 @@ config CPU_IDLE_CALXEDA | |||
40 | help | 36 | help |
41 | Select this to enable cpuidle on Calxeda processors. | 37 | Select this to enable cpuidle on Calxeda processors. |
42 | 38 | ||
39 | config CPU_IDLE_ZYNQ | ||
40 | bool "CPU Idle Driver for Xilinx Zynq processors" | ||
41 | depends on ARCH_ZYNQ | ||
42 | help | ||
43 | Select this to enable cpuidle on Xilinx Zynq processors. | ||
44 | |||
43 | endif | 45 | endif |
46 | |||
47 | config ARCH_NEEDS_CPU_IDLE_COUPLED | ||
48 | def_bool n | ||
diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile index 0d8bd55e776f..8767a7b3eb91 100644 --- a/drivers/cpuidle/Makefile +++ b/drivers/cpuidle/Makefile | |||
@@ -7,3 +7,4 @@ obj-$(CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED) += coupled.o | |||
7 | 7 | ||
8 | obj-$(CONFIG_CPU_IDLE_CALXEDA) += cpuidle-calxeda.o | 8 | obj-$(CONFIG_CPU_IDLE_CALXEDA) += cpuidle-calxeda.o |
9 | obj-$(CONFIG_ARCH_KIRKWOOD) += cpuidle-kirkwood.o | 9 | obj-$(CONFIG_ARCH_KIRKWOOD) += cpuidle-kirkwood.o |
10 | obj-$(CONFIG_CPU_IDLE_ZYNQ) += cpuidle-zynq.o | ||
diff --git a/drivers/cpuidle/cpuidle-zynq.c b/drivers/cpuidle/cpuidle-zynq.c new file mode 100644 index 000000000000..38e03a183591 --- /dev/null +++ b/drivers/cpuidle/cpuidle-zynq.c | |||
@@ -0,0 +1,83 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012-2013 Xilinx | ||
3 | * | ||
4 | * CPU idle support for Xilinx Zynq | ||
5 | * | ||
6 | * based on arch/arm/mach-at91/cpuidle.c | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms and conditions of the GNU General Public License, | ||
10 | * version 2, as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
15 | * more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License along with | ||
18 | * this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | * | ||
20 | * The cpu idle uses wait-for-interrupt and RAM self refresh in order | ||
21 | * to implement two idle states - | ||
22 | * #1 wait-for-interrupt | ||
23 | * #2 wait-for-interrupt and RAM self refresh | ||
24 | * | ||
25 | * Maintainer: Michal Simek <michal.simek@xilinx.com> | ||
26 | */ | ||
27 | |||
28 | #include <linux/init.h> | ||
29 | #include <linux/cpu_pm.h> | ||
30 | #include <linux/cpuidle.h> | ||
31 | #include <linux/of.h> | ||
32 | #include <asm/proc-fns.h> | ||
33 | #include <asm/cpuidle.h> | ||
34 | |||
35 | #define ZYNQ_MAX_STATES 2 | ||
36 | |||
37 | /* Actual code that puts the SoC in different idle states */ | ||
38 | static int zynq_enter_idle(struct cpuidle_device *dev, | ||
39 | struct cpuidle_driver *drv, int index) | ||
40 | { | ||
41 | /* Devices must be stopped here */ | ||
42 | cpu_pm_enter(); | ||
43 | |||
44 | /* Add code for DDR self refresh start */ | ||
45 | cpu_do_idle(); | ||
46 | |||
47 | /* Add code for DDR self refresh stop */ | ||
48 | cpu_pm_exit(); | ||
49 | |||
50 | return index; | ||
51 | } | ||
52 | |||
53 | static struct cpuidle_driver zynq_idle_driver = { | ||
54 | .name = "zynq_idle", | ||
55 | .owner = THIS_MODULE, | ||
56 | .states = { | ||
57 | ARM_CPUIDLE_WFI_STATE, | ||
58 | { | ||
59 | .enter = zynq_enter_idle, | ||
60 | .exit_latency = 10, | ||
61 | .target_residency = 10000, | ||
62 | .flags = CPUIDLE_FLAG_TIME_VALID | | ||
63 | CPUIDLE_FLAG_TIMER_STOP, | ||
64 | .name = "RAM_SR", | ||
65 | .desc = "WFI and RAM Self Refresh", | ||
66 | }, | ||
67 | }, | ||
68 | .safe_state_index = 0, | ||
69 | .state_count = ZYNQ_MAX_STATES, | ||
70 | }; | ||
71 | |||
72 | /* Initialize CPU idle by registering the idle states */ | ||
73 | static int __init zynq_cpuidle_init(void) | ||
74 | { | ||
75 | if (!of_machine_is_compatible("xlnx,zynq-7000")) | ||
76 | return -ENODEV; | ||
77 | |||
78 | pr_info("Xilinx Zynq CpuIdle Driver started\n"); | ||
79 | |||
80 | return cpuidle_register(&zynq_idle_driver, NULL); | ||
81 | } | ||
82 | |||
83 | device_initcall(zynq_cpuidle_init); | ||
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index c3a93fece819..fdc432f18022 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c | |||
@@ -466,7 +466,7 @@ void cpuidle_unregister(struct cpuidle_driver *drv) | |||
466 | int cpu; | 466 | int cpu; |
467 | struct cpuidle_device *device; | 467 | struct cpuidle_device *device; |
468 | 468 | ||
469 | for_each_possible_cpu(cpu) { | 469 | for_each_cpu(cpu, drv->cpumask) { |
470 | device = &per_cpu(cpuidle_dev, cpu); | 470 | device = &per_cpu(cpuidle_dev, cpu); |
471 | cpuidle_unregister_device(device); | 471 | cpuidle_unregister_device(device); |
472 | } | 472 | } |
@@ -498,7 +498,7 @@ int cpuidle_register(struct cpuidle_driver *drv, | |||
498 | return ret; | 498 | return ret; |
499 | } | 499 | } |
500 | 500 | ||
501 | for_each_possible_cpu(cpu) { | 501 | for_each_cpu(cpu, drv->cpumask) { |
502 | device = &per_cpu(cpuidle_dev, cpu); | 502 | device = &per_cpu(cpuidle_dev, cpu); |
503 | device->cpu = cpu; | 503 | device->cpu = cpu; |
504 | 504 | ||
diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c index 8dfaaae94444..3ac499d5a207 100644 --- a/drivers/cpuidle/driver.c +++ b/drivers/cpuidle/driver.c | |||
@@ -18,182 +18,249 @@ | |||
18 | 18 | ||
19 | DEFINE_SPINLOCK(cpuidle_driver_lock); | 19 | DEFINE_SPINLOCK(cpuidle_driver_lock); |
20 | 20 | ||
21 | static void __cpuidle_set_cpu_driver(struct cpuidle_driver *drv, int cpu); | 21 | #ifdef CONFIG_CPU_IDLE_MULTIPLE_DRIVERS |
22 | static struct cpuidle_driver * __cpuidle_get_cpu_driver(int cpu); | ||
23 | 22 | ||
24 | static void cpuidle_setup_broadcast_timer(void *arg) | 23 | static DEFINE_PER_CPU(struct cpuidle_driver *, cpuidle_drivers); |
24 | |||
25 | /** | ||
26 | * __cpuidle_get_cpu_driver - return the cpuidle driver tied to a CPU. | ||
27 | * @cpu: the CPU handled by the driver | ||
28 | * | ||
29 | * Returns a pointer to struct cpuidle_driver or NULL if no driver has been | ||
30 | * registered for @cpu. | ||
31 | */ | ||
32 | static struct cpuidle_driver *__cpuidle_get_cpu_driver(int cpu) | ||
25 | { | 33 | { |
26 | int cpu = smp_processor_id(); | 34 | return per_cpu(cpuidle_drivers, cpu); |
27 | clockevents_notify((long)(arg), &cpu); | ||
28 | } | 35 | } |
29 | 36 | ||
30 | static void __cpuidle_driver_init(struct cpuidle_driver *drv, int cpu) | 37 | /** |
38 | * __cpuidle_unset_driver - unset per CPU driver variables. | ||
39 | * @drv: a valid pointer to a struct cpuidle_driver | ||
40 | * | ||
41 | * For each CPU in the driver's CPU mask, unset the registered driver per CPU | ||
42 | * variable. If @drv is different from the registered driver, the corresponding | ||
43 | * variable is not cleared. | ||
44 | */ | ||
45 | static inline void __cpuidle_unset_driver(struct cpuidle_driver *drv) | ||
31 | { | 46 | { |
32 | int i; | 47 | int cpu; |
33 | |||
34 | drv->refcnt = 0; | ||
35 | 48 | ||
36 | for (i = drv->state_count - 1; i >= 0 ; i--) { | 49 | for_each_cpu(cpu, drv->cpumask) { |
37 | 50 | ||
38 | if (!(drv->states[i].flags & CPUIDLE_FLAG_TIMER_STOP)) | 51 | if (drv != __cpuidle_get_cpu_driver(cpu)) |
39 | continue; | 52 | continue; |
40 | 53 | ||
41 | drv->bctimer = 1; | 54 | per_cpu(cpuidle_drivers, cpu) = NULL; |
42 | on_each_cpu_mask(get_cpu_mask(cpu), cpuidle_setup_broadcast_timer, | ||
43 | (void *)CLOCK_EVT_NOTIFY_BROADCAST_ON, 1); | ||
44 | break; | ||
45 | } | 55 | } |
46 | } | 56 | } |
47 | 57 | ||
48 | static int __cpuidle_register_driver(struct cpuidle_driver *drv, int cpu) | 58 | /** |
59 | * __cpuidle_set_driver - set per CPU driver variables the the given driver. | ||
60 | * @drv: a valid pointer to a struct cpuidle_driver | ||
61 | * | ||
62 | * For each CPU in the driver's cpumask, unset the registered driver per CPU | ||
63 | * to @drv. | ||
64 | * | ||
65 | * Returns 0 on success, -EBUSY if the CPUs have driver(s) already. | ||
66 | */ | ||
67 | static inline int __cpuidle_set_driver(struct cpuidle_driver *drv) | ||
49 | { | 68 | { |
50 | if (!drv || !drv->state_count) | 69 | int cpu; |
51 | return -EINVAL; | ||
52 | |||
53 | if (cpuidle_disabled()) | ||
54 | return -ENODEV; | ||
55 | 70 | ||
56 | if (__cpuidle_get_cpu_driver(cpu)) | 71 | for_each_cpu(cpu, drv->cpumask) { |
57 | return -EBUSY; | ||
58 | 72 | ||
59 | __cpuidle_driver_init(drv, cpu); | 73 | if (__cpuidle_get_cpu_driver(cpu)) { |
74 | __cpuidle_unset_driver(drv); | ||
75 | return -EBUSY; | ||
76 | } | ||
60 | 77 | ||
61 | __cpuidle_set_cpu_driver(drv, cpu); | 78 | per_cpu(cpuidle_drivers, cpu) = drv; |
79 | } | ||
62 | 80 | ||
63 | return 0; | 81 | return 0; |
64 | } | 82 | } |
65 | 83 | ||
66 | static void __cpuidle_unregister_driver(struct cpuidle_driver *drv, int cpu) | 84 | #else |
67 | { | ||
68 | if (drv != __cpuidle_get_cpu_driver(cpu)) | ||
69 | return; | ||
70 | 85 | ||
71 | if (!WARN_ON(drv->refcnt > 0)) | 86 | static struct cpuidle_driver *cpuidle_curr_driver; |
72 | __cpuidle_set_cpu_driver(NULL, cpu); | ||
73 | 87 | ||
74 | if (drv->bctimer) { | 88 | /** |
75 | drv->bctimer = 0; | 89 | * __cpuidle_get_cpu_driver - return the global cpuidle driver pointer. |
76 | on_each_cpu_mask(get_cpu_mask(cpu), cpuidle_setup_broadcast_timer, | 90 | * @cpu: ignored without the multiple driver support |
77 | (void *)CLOCK_EVT_NOTIFY_BROADCAST_OFF, 1); | 91 | * |
78 | } | 92 | * Return a pointer to a struct cpuidle_driver object or NULL if no driver was |
93 | * previously registered. | ||
94 | */ | ||
95 | static inline struct cpuidle_driver *__cpuidle_get_cpu_driver(int cpu) | ||
96 | { | ||
97 | return cpuidle_curr_driver; | ||
79 | } | 98 | } |
80 | 99 | ||
81 | #ifdef CONFIG_CPU_IDLE_MULTIPLE_DRIVERS | 100 | /** |
101 | * __cpuidle_set_driver - assign the global cpuidle driver variable. | ||
102 | * @drv: pointer to a struct cpuidle_driver object | ||
103 | * | ||
104 | * Returns 0 on success, -EBUSY if the driver is already registered. | ||
105 | */ | ||
106 | static inline int __cpuidle_set_driver(struct cpuidle_driver *drv) | ||
107 | { | ||
108 | if (cpuidle_curr_driver) | ||
109 | return -EBUSY; | ||
82 | 110 | ||
83 | static DEFINE_PER_CPU(struct cpuidle_driver *, cpuidle_drivers); | 111 | cpuidle_curr_driver = drv; |
84 | 112 | ||
85 | static void __cpuidle_set_cpu_driver(struct cpuidle_driver *drv, int cpu) | 113 | return 0; |
86 | { | ||
87 | per_cpu(cpuidle_drivers, cpu) = drv; | ||
88 | } | 114 | } |
89 | 115 | ||
90 | static struct cpuidle_driver *__cpuidle_get_cpu_driver(int cpu) | 116 | /** |
117 | * __cpuidle_unset_driver - unset the global cpuidle driver variable. | ||
118 | * @drv: a pointer to a struct cpuidle_driver | ||
119 | * | ||
120 | * Reset the global cpuidle variable to NULL. If @drv does not match the | ||
121 | * registered driver, do nothing. | ||
122 | */ | ||
123 | static inline void __cpuidle_unset_driver(struct cpuidle_driver *drv) | ||
91 | { | 124 | { |
92 | return per_cpu(cpuidle_drivers, cpu); | 125 | if (drv == cpuidle_curr_driver) |
126 | cpuidle_curr_driver = NULL; | ||
93 | } | 127 | } |
94 | 128 | ||
95 | static void __cpuidle_unregister_all_cpu_driver(struct cpuidle_driver *drv) | 129 | #endif |
130 | |||
131 | /** | ||
132 | * cpuidle_setup_broadcast_timer - enable/disable the broadcast timer | ||
133 | * @arg: a void pointer used to match the SMP cross call API | ||
134 | * | ||
135 | * @arg is used as a value of type 'long' with on of the two values: | ||
136 | * - CLOCK_EVT_NOTIFY_BROADCAST_ON | ||
137 | * - CLOCK_EVT_NOTIFY_BROADCAST_OFF | ||
138 | * | ||
139 | * Set the broadcast timer notification for the current CPU. This function | ||
140 | * is executed per CPU by an SMP cross call. It not supposed to be called | ||
141 | * directly. | ||
142 | */ | ||
143 | static void cpuidle_setup_broadcast_timer(void *arg) | ||
96 | { | 144 | { |
97 | int cpu; | 145 | int cpu = smp_processor_id(); |
98 | for_each_present_cpu(cpu) | 146 | clockevents_notify((long)(arg), &cpu); |
99 | __cpuidle_unregister_driver(drv, cpu); | ||
100 | } | 147 | } |
101 | 148 | ||
102 | static int __cpuidle_register_all_cpu_driver(struct cpuidle_driver *drv) | 149 | /** |
150 | * __cpuidle_driver_init - initialize the driver's internal data | ||
151 | * @drv: a valid pointer to a struct cpuidle_driver | ||
152 | * | ||
153 | * Returns 0 on success, a negative error code otherwise. | ||
154 | */ | ||
155 | static int __cpuidle_driver_init(struct cpuidle_driver *drv) | ||
103 | { | 156 | { |
104 | int ret = 0; | 157 | int i; |
105 | int i, cpu; | ||
106 | 158 | ||
107 | for_each_present_cpu(cpu) { | 159 | drv->refcnt = 0; |
108 | ret = __cpuidle_register_driver(drv, cpu); | ||
109 | if (ret) | ||
110 | break; | ||
111 | } | ||
112 | 160 | ||
113 | if (ret) | 161 | /* |
114 | for_each_present_cpu(i) { | 162 | * Use all possible CPUs as the default, because if the kernel boots |
115 | if (i == cpu) | 163 | * with some CPUs offline and then we online one of them, the CPU |
116 | break; | 164 | * notifier has to know which driver to assign. |
117 | __cpuidle_unregister_driver(drv, i); | 165 | */ |
118 | } | 166 | if (!drv->cpumask) |
167 | drv->cpumask = (struct cpumask *)cpu_possible_mask; | ||
168 | |||
169 | /* | ||
170 | * Look for the timer stop flag in the different states, so that we know | ||
171 | * if the broadcast timer has to be set up. The loop is in the reverse | ||
172 | * order, because usually on of the the deeper states has this flag set. | ||
173 | */ | ||
174 | for (i = drv->state_count - 1; i >= 0 ; i--) { | ||
119 | 175 | ||
176 | if (!(drv->states[i].flags & CPUIDLE_FLAG_TIMER_STOP)) | ||
177 | continue; | ||
120 | 178 | ||
121 | return ret; | 179 | drv->bctimer = 1; |
180 | break; | ||
181 | } | ||
182 | |||
183 | return 0; | ||
122 | } | 184 | } |
123 | 185 | ||
124 | int cpuidle_register_cpu_driver(struct cpuidle_driver *drv, int cpu) | 186 | /** |
187 | * __cpuidle_register_driver: register the driver | ||
188 | * @drv: a valid pointer to a struct cpuidle_driver | ||
189 | * | ||
190 | * Do some sanity checks, initialize the driver, assign the driver to the | ||
191 | * global cpuidle driver variable(s) and set up the broadcast timer if the | ||
192 | * cpuidle driver has some states that shut down the local timer. | ||
193 | * | ||
194 | * Returns 0 on success, a negative error code otherwise: | ||
195 | * * -EINVAL if the driver pointer is NULL or no idle states are available | ||
196 | * * -ENODEV if the cpuidle framework is disabled | ||
197 | * * -EBUSY if the driver is already assigned to the global variable(s) | ||
198 | */ | ||
199 | static int __cpuidle_register_driver(struct cpuidle_driver *drv) | ||
125 | { | 200 | { |
126 | int ret; | 201 | int ret; |
127 | 202 | ||
128 | spin_lock(&cpuidle_driver_lock); | 203 | if (!drv || !drv->state_count) |
129 | ret = __cpuidle_register_driver(drv, cpu); | 204 | return -EINVAL; |
130 | spin_unlock(&cpuidle_driver_lock); | ||
131 | 205 | ||
132 | return ret; | 206 | if (cpuidle_disabled()) |
133 | } | 207 | return -ENODEV; |
134 | 208 | ||
135 | void cpuidle_unregister_cpu_driver(struct cpuidle_driver *drv, int cpu) | 209 | ret = __cpuidle_driver_init(drv); |
136 | { | 210 | if (ret) |
137 | spin_lock(&cpuidle_driver_lock); | 211 | return ret; |
138 | __cpuidle_unregister_driver(drv, cpu); | ||
139 | spin_unlock(&cpuidle_driver_lock); | ||
140 | } | ||
141 | 212 | ||
142 | /** | 213 | ret = __cpuidle_set_driver(drv); |
143 | * cpuidle_register_driver - registers a driver | 214 | if (ret) |
144 | * @drv: the driver | 215 | return ret; |
145 | */ | ||
146 | int cpuidle_register_driver(struct cpuidle_driver *drv) | ||
147 | { | ||
148 | int ret; | ||
149 | 216 | ||
150 | spin_lock(&cpuidle_driver_lock); | 217 | if (drv->bctimer) |
151 | ret = __cpuidle_register_all_cpu_driver(drv); | 218 | on_each_cpu_mask(drv->cpumask, cpuidle_setup_broadcast_timer, |
152 | spin_unlock(&cpuidle_driver_lock); | 219 | (void *)CLOCK_EVT_NOTIFY_BROADCAST_ON, 1); |
153 | 220 | ||
154 | return ret; | 221 | return 0; |
155 | } | 222 | } |
156 | EXPORT_SYMBOL_GPL(cpuidle_register_driver); | ||
157 | 223 | ||
158 | /** | 224 | /** |
159 | * cpuidle_unregister_driver - unregisters a driver | 225 | * __cpuidle_unregister_driver - unregister the driver |
160 | * @drv: the driver | 226 | * @drv: a valid pointer to a struct cpuidle_driver |
227 | * | ||
228 | * Check if the driver is no longer in use, reset the global cpuidle driver | ||
229 | * variable(s) and disable the timer broadcast notification mechanism if it was | ||
230 | * in use. | ||
231 | * | ||
161 | */ | 232 | */ |
162 | void cpuidle_unregister_driver(struct cpuidle_driver *drv) | 233 | static void __cpuidle_unregister_driver(struct cpuidle_driver *drv) |
163 | { | 234 | { |
164 | spin_lock(&cpuidle_driver_lock); | 235 | if (WARN_ON(drv->refcnt > 0)) |
165 | __cpuidle_unregister_all_cpu_driver(drv); | 236 | return; |
166 | spin_unlock(&cpuidle_driver_lock); | ||
167 | } | ||
168 | EXPORT_SYMBOL_GPL(cpuidle_unregister_driver); | ||
169 | |||
170 | #else | ||
171 | |||
172 | static struct cpuidle_driver *cpuidle_curr_driver; | ||
173 | 237 | ||
174 | static inline void __cpuidle_set_cpu_driver(struct cpuidle_driver *drv, int cpu) | 238 | if (drv->bctimer) { |
175 | { | 239 | drv->bctimer = 0; |
176 | cpuidle_curr_driver = drv; | 240 | on_each_cpu_mask(drv->cpumask, cpuidle_setup_broadcast_timer, |
177 | } | 241 | (void *)CLOCK_EVT_NOTIFY_BROADCAST_OFF, 1); |
242 | } | ||
178 | 243 | ||
179 | static inline struct cpuidle_driver *__cpuidle_get_cpu_driver(int cpu) | 244 | __cpuidle_unset_driver(drv); |
180 | { | ||
181 | return cpuidle_curr_driver; | ||
182 | } | 245 | } |
183 | 246 | ||
184 | /** | 247 | /** |
185 | * cpuidle_register_driver - registers a driver | 248 | * cpuidle_register_driver - registers a driver |
186 | * @drv: the driver | 249 | * @drv: a pointer to a valid struct cpuidle_driver |
250 | * | ||
251 | * Register the driver under a lock to prevent concurrent attempts to | ||
252 | * [un]register the driver from occuring at the same time. | ||
253 | * | ||
254 | * Returns 0 on success, a negative error code (returned by | ||
255 | * __cpuidle_register_driver()) otherwise. | ||
187 | */ | 256 | */ |
188 | int cpuidle_register_driver(struct cpuidle_driver *drv) | 257 | int cpuidle_register_driver(struct cpuidle_driver *drv) |
189 | { | 258 | { |
190 | int ret, cpu; | 259 | int ret; |
191 | 260 | ||
192 | cpu = get_cpu(); | ||
193 | spin_lock(&cpuidle_driver_lock); | 261 | spin_lock(&cpuidle_driver_lock); |
194 | ret = __cpuidle_register_driver(drv, cpu); | 262 | ret = __cpuidle_register_driver(drv); |
195 | spin_unlock(&cpuidle_driver_lock); | 263 | spin_unlock(&cpuidle_driver_lock); |
196 | put_cpu(); | ||
197 | 264 | ||
198 | return ret; | 265 | return ret; |
199 | } | 266 | } |
@@ -201,23 +268,24 @@ EXPORT_SYMBOL_GPL(cpuidle_register_driver); | |||
201 | 268 | ||
202 | /** | 269 | /** |
203 | * cpuidle_unregister_driver - unregisters a driver | 270 | * cpuidle_unregister_driver - unregisters a driver |
204 | * @drv: the driver | 271 | * @drv: a pointer to a valid struct cpuidle_driver |
272 | * | ||
273 | * Unregisters the cpuidle driver under a lock to prevent concurrent attempts | ||
274 | * to [un]register the driver from occuring at the same time. @drv has to | ||
275 | * match the currently registered driver. | ||
205 | */ | 276 | */ |
206 | void cpuidle_unregister_driver(struct cpuidle_driver *drv) | 277 | void cpuidle_unregister_driver(struct cpuidle_driver *drv) |
207 | { | 278 | { |
208 | int cpu; | ||
209 | |||
210 | cpu = get_cpu(); | ||
211 | spin_lock(&cpuidle_driver_lock); | 279 | spin_lock(&cpuidle_driver_lock); |
212 | __cpuidle_unregister_driver(drv, cpu); | 280 | __cpuidle_unregister_driver(drv); |
213 | spin_unlock(&cpuidle_driver_lock); | 281 | spin_unlock(&cpuidle_driver_lock); |
214 | put_cpu(); | ||
215 | } | 282 | } |
216 | EXPORT_SYMBOL_GPL(cpuidle_unregister_driver); | 283 | EXPORT_SYMBOL_GPL(cpuidle_unregister_driver); |
217 | #endif | ||
218 | 284 | ||
219 | /** | 285 | /** |
220 | * cpuidle_get_driver - return the current driver | 286 | * cpuidle_get_driver - return the driver tied to the current CPU. |
287 | * | ||
288 | * Returns a struct cpuidle_driver pointer, or NULL if no driver is registered. | ||
221 | */ | 289 | */ |
222 | struct cpuidle_driver *cpuidle_get_driver(void) | 290 | struct cpuidle_driver *cpuidle_get_driver(void) |
223 | { | 291 | { |
@@ -233,7 +301,11 @@ struct cpuidle_driver *cpuidle_get_driver(void) | |||
233 | EXPORT_SYMBOL_GPL(cpuidle_get_driver); | 301 | EXPORT_SYMBOL_GPL(cpuidle_get_driver); |
234 | 302 | ||
235 | /** | 303 | /** |
236 | * cpuidle_get_cpu_driver - return the driver tied with a cpu | 304 | * cpuidle_get_cpu_driver - return the driver registered for a CPU. |
305 | * @dev: a valid pointer to a struct cpuidle_device | ||
306 | * | ||
307 | * Returns a struct cpuidle_driver pointer, or NULL if no driver is registered | ||
308 | * for the CPU associated with @dev. | ||
237 | */ | 309 | */ |
238 | struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev) | 310 | struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev) |
239 | { | 311 | { |
@@ -244,6 +316,14 @@ struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev) | |||
244 | } | 316 | } |
245 | EXPORT_SYMBOL_GPL(cpuidle_get_cpu_driver); | 317 | EXPORT_SYMBOL_GPL(cpuidle_get_cpu_driver); |
246 | 318 | ||
319 | /** | ||
320 | * cpuidle_driver_ref - get a reference to the driver. | ||
321 | * | ||
322 | * Increment the reference counter of the cpuidle driver associated with | ||
323 | * the current CPU. | ||
324 | * | ||
325 | * Returns a pointer to the driver, or NULL if the current CPU has no driver. | ||
326 | */ | ||
247 | struct cpuidle_driver *cpuidle_driver_ref(void) | 327 | struct cpuidle_driver *cpuidle_driver_ref(void) |
248 | { | 328 | { |
249 | struct cpuidle_driver *drv; | 329 | struct cpuidle_driver *drv; |
@@ -257,6 +337,12 @@ struct cpuidle_driver *cpuidle_driver_ref(void) | |||
257 | return drv; | 337 | return drv; |
258 | } | 338 | } |
259 | 339 | ||
340 | /** | ||
341 | * cpuidle_driver_unref - puts down the refcount for the driver | ||
342 | * | ||
343 | * Decrement the reference counter of the cpuidle driver associated with | ||
344 | * the current CPU. | ||
345 | */ | ||
260 | void cpuidle_driver_unref(void) | 346 | void cpuidle_driver_unref(void) |
261 | { | 347 | { |
262 | struct cpuidle_driver *drv = cpuidle_get_driver(); | 348 | struct cpuidle_driver *drv = cpuidle_get_driver(); |
diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig index 0f079be13305..31f3adba4cf3 100644 --- a/drivers/devfreq/Kconfig +++ b/drivers/devfreq/Kconfig | |||
@@ -67,7 +67,7 @@ comment "DEVFREQ Drivers" | |||
67 | 67 | ||
68 | config ARM_EXYNOS4_BUS_DEVFREQ | 68 | config ARM_EXYNOS4_BUS_DEVFREQ |
69 | bool "ARM Exynos4210/4212/4412 Memory Bus DEVFREQ Driver" | 69 | bool "ARM Exynos4210/4212/4412 Memory Bus DEVFREQ Driver" |
70 | depends on CPU_EXYNOS4210 || CPU_EXYNOS4212 || CPU_EXYNOS4412 | 70 | depends on CPU_EXYNOS4210 || SOC_EXYNOS4212 || SOC_EXYNOS4412 |
71 | select ARCH_HAS_OPP | 71 | select ARCH_HAS_OPP |
72 | select DEVFREQ_GOV_SIMPLE_ONDEMAND | 72 | select DEVFREQ_GOV_SIMPLE_ONDEMAND |
73 | help | 73 | help |
@@ -78,4 +78,14 @@ config ARM_EXYNOS4_BUS_DEVFREQ | |||
78 | To operate with optimal voltages, ASV support is required | 78 | To operate with optimal voltages, ASV support is required |
79 | (CONFIG_EXYNOS_ASV). | 79 | (CONFIG_EXYNOS_ASV). |
80 | 80 | ||
81 | config ARM_EXYNOS5_BUS_DEVFREQ | ||
82 | bool "ARM Exynos5250 Bus DEVFREQ Driver" | ||
83 | depends on SOC_EXYNOS5250 | ||
84 | select ARCH_HAS_OPP | ||
85 | select DEVFREQ_GOV_SIMPLE_ONDEMAND | ||
86 | help | ||
87 | This adds the DEVFREQ driver for Exynos5250 bus interface (vdd_int). | ||
88 | It reads PPMU counters of memory controllers and adjusts the | ||
89 | operating frequencies and voltages with OPP support. | ||
90 | |||
81 | endif # PM_DEVFREQ | 91 | endif # PM_DEVFREQ |
diff --git a/drivers/devfreq/Makefile b/drivers/devfreq/Makefile index 8c464234f7e7..16138c9e0d58 100644 --- a/drivers/devfreq/Makefile +++ b/drivers/devfreq/Makefile | |||
@@ -5,4 +5,5 @@ obj-$(CONFIG_DEVFREQ_GOV_POWERSAVE) += governor_powersave.o | |||
5 | obj-$(CONFIG_DEVFREQ_GOV_USERSPACE) += governor_userspace.o | 5 | obj-$(CONFIG_DEVFREQ_GOV_USERSPACE) += governor_userspace.o |
6 | 6 | ||
7 | # DEVFREQ Drivers | 7 | # DEVFREQ Drivers |
8 | obj-$(CONFIG_ARM_EXYNOS4_BUS_DEVFREQ) += exynos4_bus.o | 8 | obj-$(CONFIG_ARM_EXYNOS4_BUS_DEVFREQ) += exynos/ |
9 | obj-$(CONFIG_ARM_EXYNOS5_BUS_DEVFREQ) += exynos/ | ||
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 3b367973a802..44c407986f64 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c | |||
@@ -271,6 +271,7 @@ void devfreq_monitor_suspend(struct devfreq *devfreq) | |||
271 | return; | 271 | return; |
272 | } | 272 | } |
273 | 273 | ||
274 | devfreq_update_status(devfreq, devfreq->previous_freq); | ||
274 | devfreq->stop_polling = true; | 275 | devfreq->stop_polling = true; |
275 | mutex_unlock(&devfreq->lock); | 276 | mutex_unlock(&devfreq->lock); |
276 | cancel_delayed_work_sync(&devfreq->work); | 277 | cancel_delayed_work_sync(&devfreq->work); |
@@ -287,6 +288,8 @@ EXPORT_SYMBOL(devfreq_monitor_suspend); | |||
287 | */ | 288 | */ |
288 | void devfreq_monitor_resume(struct devfreq *devfreq) | 289 | void devfreq_monitor_resume(struct devfreq *devfreq) |
289 | { | 290 | { |
291 | unsigned long freq; | ||
292 | |||
290 | mutex_lock(&devfreq->lock); | 293 | mutex_lock(&devfreq->lock); |
291 | if (!devfreq->stop_polling) | 294 | if (!devfreq->stop_polling) |
292 | goto out; | 295 | goto out; |
@@ -295,8 +298,14 @@ void devfreq_monitor_resume(struct devfreq *devfreq) | |||
295 | devfreq->profile->polling_ms) | 298 | devfreq->profile->polling_ms) |
296 | queue_delayed_work(devfreq_wq, &devfreq->work, | 299 | queue_delayed_work(devfreq_wq, &devfreq->work, |
297 | msecs_to_jiffies(devfreq->profile->polling_ms)); | 300 | msecs_to_jiffies(devfreq->profile->polling_ms)); |
301 | |||
302 | devfreq->last_stat_updated = jiffies; | ||
298 | devfreq->stop_polling = false; | 303 | devfreq->stop_polling = false; |
299 | 304 | ||
305 | if (devfreq->profile->get_cur_freq && | ||
306 | !devfreq->profile->get_cur_freq(devfreq->dev.parent, &freq)) | ||
307 | devfreq->previous_freq = freq; | ||
308 | |||
300 | out: | 309 | out: |
301 | mutex_unlock(&devfreq->lock); | 310 | mutex_unlock(&devfreq->lock); |
302 | } | 311 | } |
@@ -518,6 +527,8 @@ EXPORT_SYMBOL(devfreq_add_device); | |||
518 | /** | 527 | /** |
519 | * devfreq_remove_device() - Remove devfreq feature from a device. | 528 | * devfreq_remove_device() - Remove devfreq feature from a device. |
520 | * @devfreq: the devfreq instance to be removed | 529 | * @devfreq: the devfreq instance to be removed |
530 | * | ||
531 | * The opposite of devfreq_add_device(). | ||
521 | */ | 532 | */ |
522 | int devfreq_remove_device(struct devfreq *devfreq) | 533 | int devfreq_remove_device(struct devfreq *devfreq) |
523 | { | 534 | { |
@@ -533,6 +544,10 @@ EXPORT_SYMBOL(devfreq_remove_device); | |||
533 | /** | 544 | /** |
534 | * devfreq_suspend_device() - Suspend devfreq of a device. | 545 | * devfreq_suspend_device() - Suspend devfreq of a device. |
535 | * @devfreq: the devfreq instance to be suspended | 546 | * @devfreq: the devfreq instance to be suspended |
547 | * | ||
548 | * This function is intended to be called by the pm callbacks | ||
549 | * (e.g., runtime_suspend, suspend) of the device driver that | ||
550 | * holds the devfreq. | ||
536 | */ | 551 | */ |
537 | int devfreq_suspend_device(struct devfreq *devfreq) | 552 | int devfreq_suspend_device(struct devfreq *devfreq) |
538 | { | 553 | { |
@@ -550,6 +565,10 @@ EXPORT_SYMBOL(devfreq_suspend_device); | |||
550 | /** | 565 | /** |
551 | * devfreq_resume_device() - Resume devfreq of a device. | 566 | * devfreq_resume_device() - Resume devfreq of a device. |
552 | * @devfreq: the devfreq instance to be resumed | 567 | * @devfreq: the devfreq instance to be resumed |
568 | * | ||
569 | * This function is intended to be called by the pm callbacks | ||
570 | * (e.g., runtime_resume, resume) of the device driver that | ||
571 | * holds the devfreq. | ||
553 | */ | 572 | */ |
554 | int devfreq_resume_device(struct devfreq *devfreq) | 573 | int devfreq_resume_device(struct devfreq *devfreq) |
555 | { | 574 | { |
@@ -905,11 +924,11 @@ static ssize_t show_trans_table(struct device *dev, struct device_attribute *att | |||
905 | { | 924 | { |
906 | struct devfreq *devfreq = to_devfreq(dev); | 925 | struct devfreq *devfreq = to_devfreq(dev); |
907 | ssize_t len; | 926 | ssize_t len; |
908 | int i, j, err; | 927 | int i, j; |
909 | unsigned int max_state = devfreq->profile->max_state; | 928 | unsigned int max_state = devfreq->profile->max_state; |
910 | 929 | ||
911 | err = devfreq_update_status(devfreq, devfreq->previous_freq); | 930 | if (!devfreq->stop_polling && |
912 | if (err) | 931 | devfreq_update_status(devfreq, devfreq->previous_freq)) |
913 | return 0; | 932 | return 0; |
914 | 933 | ||
915 | len = sprintf(buf, " From : To\n"); | 934 | len = sprintf(buf, " From : To\n"); |
diff --git a/drivers/devfreq/exynos/Makefile b/drivers/devfreq/exynos/Makefile new file mode 100644 index 000000000000..bfaaf5b0d61d --- /dev/null +++ b/drivers/devfreq/exynos/Makefile | |||
@@ -0,0 +1,3 @@ | |||
1 | # Exynos DEVFREQ Drivers | ||
2 | obj-$(CONFIG_ARM_EXYNOS4_BUS_DEVFREQ) += exynos4_bus.o | ||
3 | obj-$(CONFIG_ARM_EXYNOS5_BUS_DEVFREQ) += exynos_ppmu.o exynos5_bus.o | ||
diff --git a/drivers/devfreq/exynos4_bus.c b/drivers/devfreq/exynos/exynos4_bus.c index 3f37f3b3f268..c5f86d8caca3 100644 --- a/drivers/devfreq/exynos4_bus.c +++ b/drivers/devfreq/exynos/exynos4_bus.c | |||
@@ -974,6 +974,7 @@ static int exynos4_busfreq_pm_notifier_event(struct notifier_block *this, | |||
974 | rcu_read_unlock(); | 974 | rcu_read_unlock(); |
975 | dev_err(data->dev, "%s: unable to find a min freq\n", | 975 | dev_err(data->dev, "%s: unable to find a min freq\n", |
976 | __func__); | 976 | __func__); |
977 | mutex_unlock(&data->lock); | ||
977 | return PTR_ERR(opp); | 978 | return PTR_ERR(opp); |
978 | } | 979 | } |
979 | new_oppinfo.rate = opp_get_freq(opp); | 980 | new_oppinfo.rate = opp_get_freq(opp); |
diff --git a/drivers/devfreq/exynos/exynos5_bus.c b/drivers/devfreq/exynos/exynos5_bus.c new file mode 100644 index 000000000000..574b16b59be5 --- /dev/null +++ b/drivers/devfreq/exynos/exynos5_bus.c | |||
@@ -0,0 +1,503 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2012 Samsung Electronics Co., Ltd. | ||
3 | * http://www.samsung.com/ | ||
4 | * | ||
5 | * EXYNOS5 INT clock frequency scaling support using DEVFREQ framework | ||
6 | * Based on work done by Jonghwan Choi <jhbird.choi@samsung.com> | ||
7 | * Support for only EXYNOS5250 is present. | ||
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 version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/module.h> | ||
16 | #include <linux/devfreq.h> | ||
17 | #include <linux/io.h> | ||
18 | #include <linux/opp.h> | ||
19 | #include <linux/slab.h> | ||
20 | #include <linux/suspend.h> | ||
21 | #include <linux/opp.h> | ||
22 | #include <linux/clk.h> | ||
23 | #include <linux/delay.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | #include <linux/pm_qos.h> | ||
26 | #include <linux/regulator/consumer.h> | ||
27 | #include <linux/of_address.h> | ||
28 | #include <linux/of_platform.h> | ||
29 | |||
30 | #include "exynos_ppmu.h" | ||
31 | |||
32 | #define MAX_SAFEVOLT 1100000 /* 1.10V */ | ||
33 | /* Assume that the bus is saturated if the utilization is 25% */ | ||
34 | #define INT_BUS_SATURATION_RATIO 25 | ||
35 | |||
36 | enum int_level_idx { | ||
37 | LV_0, | ||
38 | LV_1, | ||
39 | LV_2, | ||
40 | LV_3, | ||
41 | LV_4, | ||
42 | _LV_END | ||
43 | }; | ||
44 | |||
45 | enum exynos_ppmu_list { | ||
46 | PPMU_RIGHT, | ||
47 | PPMU_END, | ||
48 | }; | ||
49 | |||
50 | struct busfreq_data_int { | ||
51 | struct device *dev; | ||
52 | struct devfreq *devfreq; | ||
53 | struct regulator *vdd_int; | ||
54 | struct exynos_ppmu ppmu[PPMU_END]; | ||
55 | unsigned long curr_freq; | ||
56 | bool disabled; | ||
57 | |||
58 | struct notifier_block pm_notifier; | ||
59 | struct mutex lock; | ||
60 | struct pm_qos_request int_req; | ||
61 | struct clk *int_clk; | ||
62 | }; | ||
63 | |||
64 | struct int_bus_opp_table { | ||
65 | unsigned int idx; | ||
66 | unsigned long clk; | ||
67 | unsigned long volt; | ||
68 | }; | ||
69 | |||
70 | static struct int_bus_opp_table exynos5_int_opp_table[] = { | ||
71 | {LV_0, 266000, 1025000}, | ||
72 | {LV_1, 200000, 1025000}, | ||
73 | {LV_2, 160000, 1025000}, | ||
74 | {LV_3, 133000, 1025000}, | ||
75 | {LV_4, 100000, 1025000}, | ||
76 | {0, 0, 0}, | ||
77 | }; | ||
78 | |||
79 | static void busfreq_mon_reset(struct busfreq_data_int *data) | ||
80 | { | ||
81 | unsigned int i; | ||
82 | |||
83 | for (i = PPMU_RIGHT; i < PPMU_END; i++) { | ||
84 | void __iomem *ppmu_base = data->ppmu[i].hw_base; | ||
85 | |||
86 | /* Reset the performance and cycle counters */ | ||
87 | exynos_ppmu_reset(ppmu_base); | ||
88 | |||
89 | /* Setup count registers to monitor read/write transactions */ | ||
90 | data->ppmu[i].event[PPMU_PMNCNT3] = RDWR_DATA_COUNT; | ||
91 | exynos_ppmu_setevent(ppmu_base, PPMU_PMNCNT3, | ||
92 | data->ppmu[i].event[PPMU_PMNCNT3]); | ||
93 | |||
94 | exynos_ppmu_start(ppmu_base); | ||
95 | } | ||
96 | } | ||
97 | |||
98 | static void exynos5_read_ppmu(struct busfreq_data_int *data) | ||
99 | { | ||
100 | int i, j; | ||
101 | |||
102 | for (i = PPMU_RIGHT; i < PPMU_END; i++) { | ||
103 | void __iomem *ppmu_base = data->ppmu[i].hw_base; | ||
104 | |||
105 | exynos_ppmu_stop(ppmu_base); | ||
106 | |||
107 | /* Update local data from PPMU */ | ||
108 | data->ppmu[i].ccnt = __raw_readl(ppmu_base + PPMU_CCNT); | ||
109 | |||
110 | for (j = PPMU_PMNCNT0; j < PPMU_PMNCNT_MAX; j++) { | ||
111 | if (data->ppmu[i].event[j] == 0) | ||
112 | data->ppmu[i].count[j] = 0; | ||
113 | else | ||
114 | data->ppmu[i].count[j] = | ||
115 | exynos_ppmu_read(ppmu_base, j); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | busfreq_mon_reset(data); | ||
120 | } | ||
121 | |||
122 | static int exynos5_int_setvolt(struct busfreq_data_int *data, | ||
123 | unsigned long volt) | ||
124 | { | ||
125 | return regulator_set_voltage(data->vdd_int, volt, MAX_SAFEVOLT); | ||
126 | } | ||
127 | |||
128 | static int exynos5_busfreq_int_target(struct device *dev, unsigned long *_freq, | ||
129 | u32 flags) | ||
130 | { | ||
131 | int err = 0; | ||
132 | struct platform_device *pdev = container_of(dev, struct platform_device, | ||
133 | dev); | ||
134 | struct busfreq_data_int *data = platform_get_drvdata(pdev); | ||
135 | struct opp *opp; | ||
136 | unsigned long old_freq, freq; | ||
137 | unsigned long volt; | ||
138 | |||
139 | rcu_read_lock(); | ||
140 | opp = devfreq_recommended_opp(dev, _freq, flags); | ||
141 | if (IS_ERR(opp)) { | ||
142 | rcu_read_unlock(); | ||
143 | dev_err(dev, "%s: Invalid OPP.\n", __func__); | ||
144 | return PTR_ERR(opp); | ||
145 | } | ||
146 | |||
147 | freq = opp_get_freq(opp); | ||
148 | volt = opp_get_voltage(opp); | ||
149 | rcu_read_unlock(); | ||
150 | |||
151 | old_freq = data->curr_freq; | ||
152 | |||
153 | if (old_freq == freq) | ||
154 | return 0; | ||
155 | |||
156 | dev_dbg(dev, "targetting %lukHz %luuV\n", freq, volt); | ||
157 | |||
158 | mutex_lock(&data->lock); | ||
159 | |||
160 | if (data->disabled) | ||
161 | goto out; | ||
162 | |||
163 | if (freq > exynos5_int_opp_table[0].clk) | ||
164 | pm_qos_update_request(&data->int_req, freq * 16 / 1000); | ||
165 | else | ||
166 | pm_qos_update_request(&data->int_req, -1); | ||
167 | |||
168 | if (old_freq < freq) | ||
169 | err = exynos5_int_setvolt(data, volt); | ||
170 | if (err) | ||
171 | goto out; | ||
172 | |||
173 | err = clk_set_rate(data->int_clk, freq * 1000); | ||
174 | |||
175 | if (err) | ||
176 | goto out; | ||
177 | |||
178 | if (old_freq > freq) | ||
179 | err = exynos5_int_setvolt(data, volt); | ||
180 | if (err) | ||
181 | goto out; | ||
182 | |||
183 | data->curr_freq = freq; | ||
184 | out: | ||
185 | mutex_unlock(&data->lock); | ||
186 | return err; | ||
187 | } | ||
188 | |||
189 | static int exynos5_get_busier_dmc(struct busfreq_data_int *data) | ||
190 | { | ||
191 | int i, j; | ||
192 | int busy = 0; | ||
193 | unsigned int temp = 0; | ||
194 | |||
195 | for (i = PPMU_RIGHT; i < PPMU_END; i++) { | ||
196 | for (j = PPMU_PMNCNT0; j < PPMU_PMNCNT_MAX; j++) { | ||
197 | if (data->ppmu[i].count[j] > temp) { | ||
198 | temp = data->ppmu[i].count[j]; | ||
199 | busy = i; | ||
200 | } | ||
201 | } | ||
202 | } | ||
203 | |||
204 | return busy; | ||
205 | } | ||
206 | |||
207 | static int exynos5_int_get_dev_status(struct device *dev, | ||
208 | struct devfreq_dev_status *stat) | ||
209 | { | ||
210 | struct platform_device *pdev = container_of(dev, struct platform_device, | ||
211 | dev); | ||
212 | struct busfreq_data_int *data = platform_get_drvdata(pdev); | ||
213 | int busier_dmc; | ||
214 | |||
215 | exynos5_read_ppmu(data); | ||
216 | busier_dmc = exynos5_get_busier_dmc(data); | ||
217 | |||
218 | stat->current_frequency = data->curr_freq; | ||
219 | |||
220 | /* Number of cycles spent on memory access */ | ||
221 | stat->busy_time = data->ppmu[busier_dmc].count[PPMU_PMNCNT3]; | ||
222 | stat->busy_time *= 100 / INT_BUS_SATURATION_RATIO; | ||
223 | stat->total_time = data->ppmu[busier_dmc].ccnt; | ||
224 | |||
225 | return 0; | ||
226 | } | ||
227 | static void exynos5_int_exit(struct device *dev) | ||
228 | { | ||
229 | struct platform_device *pdev = container_of(dev, struct platform_device, | ||
230 | dev); | ||
231 | struct busfreq_data_int *data = platform_get_drvdata(pdev); | ||
232 | |||
233 | devfreq_unregister_opp_notifier(dev, data->devfreq); | ||
234 | } | ||
235 | |||
236 | static struct devfreq_dev_profile exynos5_devfreq_int_profile = { | ||
237 | .initial_freq = 160000, | ||
238 | .polling_ms = 100, | ||
239 | .target = exynos5_busfreq_int_target, | ||
240 | .get_dev_status = exynos5_int_get_dev_status, | ||
241 | .exit = exynos5_int_exit, | ||
242 | }; | ||
243 | |||
244 | static int exynos5250_init_int_tables(struct busfreq_data_int *data) | ||
245 | { | ||
246 | int i, err = 0; | ||
247 | |||
248 | for (i = LV_0; i < _LV_END; i++) { | ||
249 | err = opp_add(data->dev, exynos5_int_opp_table[i].clk, | ||
250 | exynos5_int_opp_table[i].volt); | ||
251 | if (err) { | ||
252 | dev_err(data->dev, "Cannot add opp entries.\n"); | ||
253 | return err; | ||
254 | } | ||
255 | } | ||
256 | |||
257 | return 0; | ||
258 | } | ||
259 | |||
260 | static int exynos5_busfreq_int_pm_notifier_event(struct notifier_block *this, | ||
261 | unsigned long event, void *ptr) | ||
262 | { | ||
263 | struct busfreq_data_int *data = container_of(this, | ||
264 | struct busfreq_data_int, pm_notifier); | ||
265 | struct opp *opp; | ||
266 | unsigned long maxfreq = ULONG_MAX; | ||
267 | unsigned long freq; | ||
268 | unsigned long volt; | ||
269 | int err = 0; | ||
270 | |||
271 | switch (event) { | ||
272 | case PM_SUSPEND_PREPARE: | ||
273 | /* Set Fastest and Deactivate DVFS */ | ||
274 | mutex_lock(&data->lock); | ||
275 | |||
276 | data->disabled = true; | ||
277 | |||
278 | rcu_read_lock(); | ||
279 | opp = opp_find_freq_floor(data->dev, &maxfreq); | ||
280 | if (IS_ERR(opp)) { | ||
281 | rcu_read_unlock(); | ||
282 | err = PTR_ERR(opp); | ||
283 | goto unlock; | ||
284 | } | ||
285 | freq = opp_get_freq(opp); | ||
286 | volt = opp_get_voltage(opp); | ||
287 | rcu_read_unlock(); | ||
288 | |||
289 | err = exynos5_int_setvolt(data, volt); | ||
290 | if (err) | ||
291 | goto unlock; | ||
292 | |||
293 | err = clk_set_rate(data->int_clk, freq * 1000); | ||
294 | |||
295 | if (err) | ||
296 | goto unlock; | ||
297 | |||
298 | data->curr_freq = freq; | ||
299 | unlock: | ||
300 | mutex_unlock(&data->lock); | ||
301 | if (err) | ||
302 | return NOTIFY_BAD; | ||
303 | return NOTIFY_OK; | ||
304 | case PM_POST_RESTORE: | ||
305 | case PM_POST_SUSPEND: | ||
306 | /* Reactivate */ | ||
307 | mutex_lock(&data->lock); | ||
308 | data->disabled = false; | ||
309 | mutex_unlock(&data->lock); | ||
310 | return NOTIFY_OK; | ||
311 | } | ||
312 | |||
313 | return NOTIFY_DONE; | ||
314 | } | ||
315 | |||
316 | static int exynos5_busfreq_int_probe(struct platform_device *pdev) | ||
317 | { | ||
318 | struct busfreq_data_int *data; | ||
319 | struct opp *opp; | ||
320 | struct device *dev = &pdev->dev; | ||
321 | struct device_node *np; | ||
322 | unsigned long initial_freq; | ||
323 | unsigned long initial_volt; | ||
324 | int err = 0; | ||
325 | int i; | ||
326 | |||
327 | data = devm_kzalloc(&pdev->dev, sizeof(struct busfreq_data_int), | ||
328 | GFP_KERNEL); | ||
329 | if (data == NULL) { | ||
330 | dev_err(dev, "Cannot allocate memory.\n"); | ||
331 | return -ENOMEM; | ||
332 | } | ||
333 | |||
334 | np = of_find_compatible_node(NULL, NULL, "samsung,exynos5250-ppmu"); | ||
335 | if (np == NULL) { | ||
336 | pr_err("Unable to find PPMU node\n"); | ||
337 | return -ENOENT; | ||
338 | } | ||
339 | |||
340 | for (i = PPMU_RIGHT; i < PPMU_END; i++) { | ||
341 | /* map PPMU memory region */ | ||
342 | data->ppmu[i].hw_base = of_iomap(np, i); | ||
343 | if (data->ppmu[i].hw_base == NULL) { | ||
344 | dev_err(&pdev->dev, "failed to map memory region\n"); | ||
345 | return -ENOMEM; | ||
346 | } | ||
347 | } | ||
348 | data->pm_notifier.notifier_call = exynos5_busfreq_int_pm_notifier_event; | ||
349 | data->dev = dev; | ||
350 | mutex_init(&data->lock); | ||
351 | |||
352 | err = exynos5250_init_int_tables(data); | ||
353 | if (err) | ||
354 | goto err_regulator; | ||
355 | |||
356 | data->vdd_int = regulator_get(dev, "vdd_int"); | ||
357 | if (IS_ERR(data->vdd_int)) { | ||
358 | dev_err(dev, "Cannot get the regulator \"vdd_int\"\n"); | ||
359 | err = PTR_ERR(data->vdd_int); | ||
360 | goto err_regulator; | ||
361 | } | ||
362 | |||
363 | data->int_clk = clk_get(dev, "int_clk"); | ||
364 | if (IS_ERR(data->int_clk)) { | ||
365 | dev_err(dev, "Cannot get clock \"int_clk\"\n"); | ||
366 | err = PTR_ERR(data->int_clk); | ||
367 | goto err_clock; | ||
368 | } | ||
369 | |||
370 | rcu_read_lock(); | ||
371 | opp = opp_find_freq_floor(dev, | ||
372 | &exynos5_devfreq_int_profile.initial_freq); | ||
373 | if (IS_ERR(opp)) { | ||
374 | rcu_read_unlock(); | ||
375 | dev_err(dev, "Invalid initial frequency %lu kHz.\n", | ||
376 | exynos5_devfreq_int_profile.initial_freq); | ||
377 | err = PTR_ERR(opp); | ||
378 | goto err_opp_add; | ||
379 | } | ||
380 | initial_freq = opp_get_freq(opp); | ||
381 | initial_volt = opp_get_voltage(opp); | ||
382 | rcu_read_unlock(); | ||
383 | data->curr_freq = initial_freq; | ||
384 | |||
385 | err = clk_set_rate(data->int_clk, initial_freq * 1000); | ||
386 | if (err) { | ||
387 | dev_err(dev, "Failed to set initial frequency\n"); | ||
388 | goto err_opp_add; | ||
389 | } | ||
390 | |||
391 | err = exynos5_int_setvolt(data, initial_volt); | ||
392 | if (err) | ||
393 | goto err_opp_add; | ||
394 | |||
395 | platform_set_drvdata(pdev, data); | ||
396 | |||
397 | busfreq_mon_reset(data); | ||
398 | |||
399 | data->devfreq = devfreq_add_device(dev, &exynos5_devfreq_int_profile, | ||
400 | "simple_ondemand", NULL); | ||
401 | |||
402 | if (IS_ERR(data->devfreq)) { | ||
403 | err = PTR_ERR(data->devfreq); | ||
404 | goto err_devfreq_add; | ||
405 | } | ||
406 | |||
407 | devfreq_register_opp_notifier(dev, data->devfreq); | ||
408 | |||
409 | err = register_pm_notifier(&data->pm_notifier); | ||
410 | if (err) { | ||
411 | dev_err(dev, "Failed to setup pm notifier\n"); | ||
412 | goto err_devfreq_add; | ||
413 | } | ||
414 | |||
415 | /* TODO: Add a new QOS class for int/mif bus */ | ||
416 | pm_qos_add_request(&data->int_req, PM_QOS_NETWORK_THROUGHPUT, -1); | ||
417 | |||
418 | return 0; | ||
419 | |||
420 | err_devfreq_add: | ||
421 | devfreq_remove_device(data->devfreq); | ||
422 | platform_set_drvdata(pdev, NULL); | ||
423 | err_opp_add: | ||
424 | clk_put(data->int_clk); | ||
425 | err_clock: | ||
426 | regulator_put(data->vdd_int); | ||
427 | err_regulator: | ||
428 | return err; | ||
429 | } | ||
430 | |||
431 | static int exynos5_busfreq_int_remove(struct platform_device *pdev) | ||
432 | { | ||
433 | struct busfreq_data_int *data = platform_get_drvdata(pdev); | ||
434 | |||
435 | pm_qos_remove_request(&data->int_req); | ||
436 | unregister_pm_notifier(&data->pm_notifier); | ||
437 | devfreq_remove_device(data->devfreq); | ||
438 | regulator_put(data->vdd_int); | ||
439 | clk_put(data->int_clk); | ||
440 | platform_set_drvdata(pdev, NULL); | ||
441 | |||
442 | return 0; | ||
443 | } | ||
444 | |||
445 | static int exynos5_busfreq_int_resume(struct device *dev) | ||
446 | { | ||
447 | struct platform_device *pdev = container_of(dev, struct platform_device, | ||
448 | dev); | ||
449 | struct busfreq_data_int *data = platform_get_drvdata(pdev); | ||
450 | |||
451 | busfreq_mon_reset(data); | ||
452 | return 0; | ||
453 | } | ||
454 | |||
455 | static const struct dev_pm_ops exynos5_busfreq_int_pm = { | ||
456 | .resume = exynos5_busfreq_int_resume, | ||
457 | }; | ||
458 | |||
459 | /* platform device pointer for exynos5 devfreq device. */ | ||
460 | static struct platform_device *exynos5_devfreq_pdev; | ||
461 | |||
462 | static struct platform_driver exynos5_busfreq_int_driver = { | ||
463 | .probe = exynos5_busfreq_int_probe, | ||
464 | .remove = exynos5_busfreq_int_remove, | ||
465 | .driver = { | ||
466 | .name = "exynos5-bus-int", | ||
467 | .owner = THIS_MODULE, | ||
468 | .pm = &exynos5_busfreq_int_pm, | ||
469 | }, | ||
470 | }; | ||
471 | |||
472 | static int __init exynos5_busfreq_int_init(void) | ||
473 | { | ||
474 | int ret; | ||
475 | |||
476 | ret = platform_driver_register(&exynos5_busfreq_int_driver); | ||
477 | if (ret < 0) | ||
478 | goto out; | ||
479 | |||
480 | exynos5_devfreq_pdev = | ||
481 | platform_device_register_simple("exynos5-bus-int", -1, NULL, 0); | ||
482 | if (IS_ERR_OR_NULL(exynos5_devfreq_pdev)) { | ||
483 | ret = PTR_ERR(exynos5_devfreq_pdev); | ||
484 | goto out1; | ||
485 | } | ||
486 | |||
487 | return 0; | ||
488 | out1: | ||
489 | platform_driver_unregister(&exynos5_busfreq_int_driver); | ||
490 | out: | ||
491 | return ret; | ||
492 | } | ||
493 | late_initcall(exynos5_busfreq_int_init); | ||
494 | |||
495 | static void __exit exynos5_busfreq_int_exit(void) | ||
496 | { | ||
497 | platform_device_unregister(exynos5_devfreq_pdev); | ||
498 | platform_driver_unregister(&exynos5_busfreq_int_driver); | ||
499 | } | ||
500 | module_exit(exynos5_busfreq_int_exit); | ||
501 | |||
502 | MODULE_LICENSE("GPL"); | ||
503 | MODULE_DESCRIPTION("EXYNOS5 busfreq driver with devfreq framework"); | ||
diff --git a/drivers/devfreq/exynos/exynos_ppmu.c b/drivers/devfreq/exynos/exynos_ppmu.c new file mode 100644 index 000000000000..85fc5ac1036a --- /dev/null +++ b/drivers/devfreq/exynos/exynos_ppmu.c | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2012 Samsung Electronics Co., Ltd. | ||
3 | * http://www.samsung.com/ | ||
4 | * | ||
5 | * EXYNOS - PPMU support | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/types.h> | ||
14 | #include <linux/io.h> | ||
15 | |||
16 | #include "exynos_ppmu.h" | ||
17 | |||
18 | void exynos_ppmu_reset(void __iomem *ppmu_base) | ||
19 | { | ||
20 | __raw_writel(PPMU_CYCLE_RESET | PPMU_COUNTER_RESET, ppmu_base); | ||
21 | __raw_writel(PPMU_ENABLE_CYCLE | | ||
22 | PPMU_ENABLE_COUNT0 | | ||
23 | PPMU_ENABLE_COUNT1 | | ||
24 | PPMU_ENABLE_COUNT2 | | ||
25 | PPMU_ENABLE_COUNT3, | ||
26 | ppmu_base + PPMU_CNTENS); | ||
27 | } | ||
28 | |||
29 | void exynos_ppmu_setevent(void __iomem *ppmu_base, unsigned int ch, | ||
30 | unsigned int evt) | ||
31 | { | ||
32 | __raw_writel(evt, ppmu_base + PPMU_BEVTSEL(ch)); | ||
33 | } | ||
34 | |||
35 | void exynos_ppmu_start(void __iomem *ppmu_base) | ||
36 | { | ||
37 | __raw_writel(PPMU_ENABLE, ppmu_base); | ||
38 | } | ||
39 | |||
40 | void exynos_ppmu_stop(void __iomem *ppmu_base) | ||
41 | { | ||
42 | __raw_writel(PPMU_DISABLE, ppmu_base); | ||
43 | } | ||
44 | |||
45 | unsigned int exynos_ppmu_read(void __iomem *ppmu_base, unsigned int ch) | ||
46 | { | ||
47 | unsigned int total; | ||
48 | |||
49 | if (ch == PPMU_PMNCNT3) | ||
50 | total = ((__raw_readl(ppmu_base + PMCNT_OFFSET(ch)) << 8) | | ||
51 | __raw_readl(ppmu_base + PMCNT_OFFSET(ch + 1))); | ||
52 | else | ||
53 | total = __raw_readl(ppmu_base + PMCNT_OFFSET(ch)); | ||
54 | |||
55 | return total; | ||
56 | } | ||
diff --git a/drivers/devfreq/exynos/exynos_ppmu.h b/drivers/devfreq/exynos/exynos_ppmu.h new file mode 100644 index 000000000000..7dfb221eaccd --- /dev/null +++ b/drivers/devfreq/exynos/exynos_ppmu.h | |||
@@ -0,0 +1,78 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2012 Samsung Electronics Co., Ltd. | ||
3 | * http://www.samsung.com/ | ||
4 | * | ||
5 | * EXYNOS PPMU header | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #ifndef __DEVFREQ_EXYNOS_PPMU_H | ||
13 | #define __DEVFREQ_EXYNOS_PPMU_H __FILE__ | ||
14 | |||
15 | #include <linux/ktime.h> | ||
16 | |||
17 | /* For PPMU Control */ | ||
18 | #define PPMU_ENABLE BIT(0) | ||
19 | #define PPMU_DISABLE 0x0 | ||
20 | #define PPMU_CYCLE_RESET BIT(1) | ||
21 | #define PPMU_COUNTER_RESET BIT(2) | ||
22 | |||
23 | #define PPMU_ENABLE_COUNT0 BIT(0) | ||
24 | #define PPMU_ENABLE_COUNT1 BIT(1) | ||
25 | #define PPMU_ENABLE_COUNT2 BIT(2) | ||
26 | #define PPMU_ENABLE_COUNT3 BIT(3) | ||
27 | #define PPMU_ENABLE_CYCLE BIT(31) | ||
28 | |||
29 | #define PPMU_CNTENS 0x10 | ||
30 | #define PPMU_FLAG 0x50 | ||
31 | #define PPMU_CCNT_OVERFLOW BIT(31) | ||
32 | #define PPMU_CCNT 0x100 | ||
33 | |||
34 | #define PPMU_PMCNT0 0x110 | ||
35 | #define PPMU_PMCNT_OFFSET 0x10 | ||
36 | #define PMCNT_OFFSET(x) (PPMU_PMCNT0 + (PPMU_PMCNT_OFFSET * x)) | ||
37 | |||
38 | #define PPMU_BEVT0SEL 0x1000 | ||
39 | #define PPMU_BEVTSEL_OFFSET 0x100 | ||
40 | #define PPMU_BEVTSEL(x) (PPMU_BEVT0SEL + (ch * PPMU_BEVTSEL_OFFSET)) | ||
41 | |||
42 | /* For Event Selection */ | ||
43 | #define RD_DATA_COUNT 0x5 | ||
44 | #define WR_DATA_COUNT 0x6 | ||
45 | #define RDWR_DATA_COUNT 0x7 | ||
46 | |||
47 | enum ppmu_counter { | ||
48 | PPMU_PMNCNT0, | ||
49 | PPMU_PMCCNT1, | ||
50 | PPMU_PMNCNT2, | ||
51 | PPMU_PMNCNT3, | ||
52 | PPMU_PMNCNT_MAX, | ||
53 | }; | ||
54 | |||
55 | struct bus_opp_table { | ||
56 | unsigned int idx; | ||
57 | unsigned long clk; | ||
58 | unsigned long volt; | ||
59 | }; | ||
60 | |||
61 | struct exynos_ppmu { | ||
62 | void __iomem *hw_base; | ||
63 | unsigned int ccnt; | ||
64 | unsigned int event[PPMU_PMNCNT_MAX]; | ||
65 | unsigned int count[PPMU_PMNCNT_MAX]; | ||
66 | unsigned long long ns; | ||
67 | ktime_t reset_time; | ||
68 | bool ccnt_overflow; | ||
69 | bool count_overflow[PPMU_PMNCNT_MAX]; | ||
70 | }; | ||
71 | |||
72 | void exynos_ppmu_reset(void __iomem *ppmu_base); | ||
73 | void exynos_ppmu_setevent(void __iomem *ppmu_base, unsigned int ch, | ||
74 | unsigned int evt); | ||
75 | void exynos_ppmu_start(void __iomem *ppmu_base); | ||
76 | void exynos_ppmu_stop(void __iomem *ppmu_base); | ||
77 | unsigned int exynos_ppmu_read(void __iomem *ppmu_base, unsigned int ch); | ||
78 | #endif /* __DEVFREQ_EXYNOS_PPMU_H */ | ||
diff --git a/drivers/dma/intel_mid_dma.c b/drivers/dma/intel_mid_dma.c index a0de82e21a7c..a975ebebea8a 100644 --- a/drivers/dma/intel_mid_dma.c +++ b/drivers/dma/intel_mid_dma.c | |||
@@ -1405,7 +1405,7 @@ static int dma_runtime_idle(struct device *dev) | |||
1405 | return -EAGAIN; | 1405 | return -EAGAIN; |
1406 | } | 1406 | } |
1407 | 1407 | ||
1408 | return pm_schedule_suspend(dev, 0); | 1408 | return 0; |
1409 | } | 1409 | } |
1410 | 1410 | ||
1411 | /****************************************************************************** | 1411 | /****************************************************************************** |
diff --git a/drivers/gpio/gpio-langwell.c b/drivers/gpio/gpio-langwell.c index f4b72456faaf..bfa1af1b519f 100644 --- a/drivers/gpio/gpio-langwell.c +++ b/drivers/gpio/gpio-langwell.c | |||
@@ -300,11 +300,7 @@ static const struct irq_domain_ops lnw_gpio_irq_ops = { | |||
300 | 300 | ||
301 | static int lnw_gpio_runtime_idle(struct device *dev) | 301 | static int lnw_gpio_runtime_idle(struct device *dev) |
302 | { | 302 | { |
303 | int err = pm_schedule_suspend(dev, 500); | 303 | pm_schedule_suspend(dev, 500); |
304 | |||
305 | if (!err) | ||
306 | return 0; | ||
307 | |||
308 | return -EBUSY; | 304 | return -EBUSY; |
309 | } | 305 | } |
310 | 306 | ||
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 48e31ed69dbf..f32ca293ae0e 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -435,7 +435,7 @@ static const struct dev_pm_ops i2c_device_pm_ops = { | |||
435 | SET_RUNTIME_PM_OPS( | 435 | SET_RUNTIME_PM_OPS( |
436 | pm_generic_runtime_suspend, | 436 | pm_generic_runtime_suspend, |
437 | pm_generic_runtime_resume, | 437 | pm_generic_runtime_resume, |
438 | pm_generic_runtime_idle | 438 | NULL |
439 | ) | 439 | ) |
440 | }; | 440 | }; |
441 | 441 | ||
diff --git a/drivers/mfd/ab8500-gpadc.c b/drivers/mfd/ab8500-gpadc.c index 13f7866de46e..3598b0ecf8c7 100644 --- a/drivers/mfd/ab8500-gpadc.c +++ b/drivers/mfd/ab8500-gpadc.c | |||
@@ -886,12 +886,6 @@ static int ab8500_gpadc_runtime_resume(struct device *dev) | |||
886 | return ret; | 886 | return ret; |
887 | } | 887 | } |
888 | 888 | ||
889 | static int ab8500_gpadc_runtime_idle(struct device *dev) | ||
890 | { | ||
891 | pm_runtime_suspend(dev); | ||
892 | return 0; | ||
893 | } | ||
894 | |||
895 | static int ab8500_gpadc_suspend(struct device *dev) | 889 | static int ab8500_gpadc_suspend(struct device *dev) |
896 | { | 890 | { |
897 | struct ab8500_gpadc *gpadc = dev_get_drvdata(dev); | 891 | struct ab8500_gpadc *gpadc = dev_get_drvdata(dev); |
@@ -1039,7 +1033,7 @@ static int ab8500_gpadc_remove(struct platform_device *pdev) | |||
1039 | static const struct dev_pm_ops ab8500_gpadc_pm_ops = { | 1033 | static const struct dev_pm_ops ab8500_gpadc_pm_ops = { |
1040 | SET_RUNTIME_PM_OPS(ab8500_gpadc_runtime_suspend, | 1034 | SET_RUNTIME_PM_OPS(ab8500_gpadc_runtime_suspend, |
1041 | ab8500_gpadc_runtime_resume, | 1035 | ab8500_gpadc_runtime_resume, |
1042 | ab8500_gpadc_runtime_idle) | 1036 | NULL) |
1043 | SET_SYSTEM_SLEEP_PM_OPS(ab8500_gpadc_suspend, | 1037 | SET_SYSTEM_SLEEP_PM_OPS(ab8500_gpadc_suspend, |
1044 | ab8500_gpadc_resume) | 1038 | ab8500_gpadc_resume) |
1045 | 1039 | ||
diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c index a292a1deff9a..3c157faee645 100644 --- a/drivers/mfd/db8500-prcmu.c +++ b/drivers/mfd/db8500-prcmu.c | |||
@@ -1725,9 +1725,9 @@ static long round_clock_rate(u8 clock, unsigned long rate) | |||
1725 | 1725 | ||
1726 | /* CPU FREQ table, may be changed due to if MAX_OPP is supported. */ | 1726 | /* CPU FREQ table, may be changed due to if MAX_OPP is supported. */ |
1727 | static struct cpufreq_frequency_table db8500_cpufreq_table[] = { | 1727 | static struct cpufreq_frequency_table db8500_cpufreq_table[] = { |
1728 | { .frequency = 200000, .index = ARM_EXTCLK,}, | 1728 | { .frequency = 200000, .driver_data = ARM_EXTCLK,}, |
1729 | { .frequency = 400000, .index = ARM_50_OPP,}, | 1729 | { .frequency = 400000, .driver_data = ARM_50_OPP,}, |
1730 | { .frequency = 800000, .index = ARM_100_OPP,}, | 1730 | { .frequency = 800000, .driver_data = ARM_100_OPP,}, |
1731 | { .frequency = CPUFREQ_TABLE_END,}, /* To be used for MAX_OPP. */ | 1731 | { .frequency = CPUFREQ_TABLE_END,}, /* To be used for MAX_OPP. */ |
1732 | { .frequency = CPUFREQ_TABLE_END,}, | 1732 | { .frequency = CPUFREQ_TABLE_END,}, |
1733 | }; | 1733 | }; |
@@ -1902,7 +1902,7 @@ static int set_armss_rate(unsigned long rate) | |||
1902 | return -EINVAL; | 1902 | return -EINVAL; |
1903 | 1903 | ||
1904 | /* Set the new arm opp. */ | 1904 | /* Set the new arm opp. */ |
1905 | return db8500_prcmu_set_arm_opp(db8500_cpufreq_table[i].index); | 1905 | return db8500_prcmu_set_arm_opp(db8500_cpufreq_table[i].driver_data); |
1906 | } | 1906 | } |
1907 | 1907 | ||
1908 | static int set_plldsi_rate(unsigned long rate) | 1908 | static int set_plldsi_rate(unsigned long rate) |
@@ -3106,7 +3106,7 @@ static void db8500_prcmu_update_cpufreq(void) | |||
3106 | { | 3106 | { |
3107 | if (prcmu_has_arm_maxopp()) { | 3107 | if (prcmu_has_arm_maxopp()) { |
3108 | db8500_cpufreq_table[3].frequency = 1000000; | 3108 | db8500_cpufreq_table[3].frequency = 1000000; |
3109 | db8500_cpufreq_table[3].index = ARM_MAX_OPP; | 3109 | db8500_cpufreq_table[3].driver_data = ARM_MAX_OPP; |
3110 | } | 3110 | } |
3111 | } | 3111 | } |
3112 | 3112 | ||
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index e219c97a02a4..9d5c71125576 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c | |||
@@ -164,7 +164,7 @@ static int mmc_runtime_resume(struct device *dev) | |||
164 | 164 | ||
165 | static int mmc_runtime_idle(struct device *dev) | 165 | static int mmc_runtime_idle(struct device *dev) |
166 | { | 166 | { |
167 | return pm_runtime_suspend(dev); | 167 | return 0; |
168 | } | 168 | } |
169 | 169 | ||
170 | #endif /* !CONFIG_PM_RUNTIME */ | 170 | #endif /* !CONFIG_PM_RUNTIME */ |
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c index 546c67c2bbbf..6d67492a9247 100644 --- a/drivers/mmc/core/sdio_bus.c +++ b/drivers/mmc/core/sdio_bus.c | |||
@@ -211,7 +211,7 @@ static const struct dev_pm_ops sdio_bus_pm_ops = { | |||
211 | SET_RUNTIME_PM_OPS( | 211 | SET_RUNTIME_PM_OPS( |
212 | pm_generic_runtime_suspend, | 212 | pm_generic_runtime_suspend, |
213 | pm_generic_runtime_resume, | 213 | pm_generic_runtime_resume, |
214 | pm_generic_runtime_idle | 214 | NULL |
215 | ) | 215 | ) |
216 | }; | 216 | }; |
217 | 217 | ||
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 79277fb36c6b..e6515e21afa3 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -1050,26 +1050,22 @@ static int pci_pm_runtime_idle(struct device *dev) | |||
1050 | { | 1050 | { |
1051 | struct pci_dev *pci_dev = to_pci_dev(dev); | 1051 | struct pci_dev *pci_dev = to_pci_dev(dev); |
1052 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; | 1052 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
1053 | int ret = 0; | ||
1053 | 1054 | ||
1054 | /* | 1055 | /* |
1055 | * If pci_dev->driver is not set (unbound), the device should | 1056 | * If pci_dev->driver is not set (unbound), the device should |
1056 | * always remain in D0 regardless of the runtime PM status | 1057 | * always remain in D0 regardless of the runtime PM status |
1057 | */ | 1058 | */ |
1058 | if (!pci_dev->driver) | 1059 | if (!pci_dev->driver) |
1059 | goto out; | 1060 | return 0; |
1060 | 1061 | ||
1061 | if (!pm) | 1062 | if (!pm) |
1062 | return -ENOSYS; | 1063 | return -ENOSYS; |
1063 | 1064 | ||
1064 | if (pm->runtime_idle) { | 1065 | if (pm->runtime_idle) |
1065 | int ret = pm->runtime_idle(dev); | 1066 | ret = pm->runtime_idle(dev); |
1066 | if (ret) | ||
1067 | return ret; | ||
1068 | } | ||
1069 | 1067 | ||
1070 | out: | 1068 | return ret; |
1071 | pm_runtime_suspend(dev); | ||
1072 | return 0; | ||
1073 | } | 1069 | } |
1074 | 1070 | ||
1075 | #else /* !CONFIG_PM_RUNTIME */ | 1071 | #else /* !CONFIG_PM_RUNTIME */ |
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c index 95cebf0185de..9357aa779048 100644 --- a/drivers/pnp/manager.c +++ b/drivers/pnp/manager.c | |||
@@ -211,6 +211,12 @@ static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) | |||
211 | res->start = -1; | 211 | res->start = -1; |
212 | res->end = -1; | 212 | res->end = -1; |
213 | 213 | ||
214 | if (!rule->map) { | ||
215 | res->flags |= IORESOURCE_DISABLED; | ||
216 | pnp_dbg(&dev->dev, " dma %d disabled\n", idx); | ||
217 | goto __add; | ||
218 | } | ||
219 | |||
214 | for (i = 0; i < 8; i++) { | 220 | for (i = 0; i < 8; i++) { |
215 | if (rule->map & (1 << xtab[i])) { | 221 | if (rule->map & (1 << xtab[i])) { |
216 | res->start = res->end = xtab[i]; | 222 | res->start = res->end = xtab[i]; |
@@ -218,11 +224,9 @@ static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) | |||
218 | goto __add; | 224 | goto __add; |
219 | } | 225 | } |
220 | } | 226 | } |
221 | #ifdef MAX_DMA_CHANNELS | 227 | |
222 | res->start = res->end = MAX_DMA_CHANNELS; | 228 | pnp_dbg(&dev->dev, " couldn't assign dma %d\n", idx); |
223 | #endif | 229 | return -EBUSY; |
224 | res->flags |= IORESOURCE_DISABLED; | ||
225 | pnp_dbg(&dev->dev, " disable dma %d\n", idx); | ||
226 | 230 | ||
227 | __add: | 231 | __add: |
228 | pnp_add_dma_resource(dev, res->start, res->flags); | 232 | pnp_add_dma_resource(dev, res->start, res->flags); |
diff --git a/drivers/power/avs/smartreflex.c b/drivers/power/avs/smartreflex.c index 6b2238bb6a81..db9973bb53f1 100644 --- a/drivers/power/avs/smartreflex.c +++ b/drivers/power/avs/smartreflex.c | |||
@@ -27,7 +27,8 @@ | |||
27 | #include <linux/pm_runtime.h> | 27 | #include <linux/pm_runtime.h> |
28 | #include <linux/power/smartreflex.h> | 28 | #include <linux/power/smartreflex.h> |
29 | 29 | ||
30 | #define SMARTREFLEX_NAME_LEN 16 | 30 | #define DRIVER_NAME "smartreflex" |
31 | #define SMARTREFLEX_NAME_LEN 32 | ||
31 | #define NVALUE_NAME_LEN 40 | 32 | #define NVALUE_NAME_LEN 40 |
32 | #define SR_DISABLE_TIMEOUT 200 | 33 | #define SR_DISABLE_TIMEOUT 200 |
33 | 34 | ||
@@ -207,12 +208,11 @@ static void sr_stop_vddautocomp(struct omap_sr *sr) | |||
207 | static int sr_late_init(struct omap_sr *sr_info) | 208 | static int sr_late_init(struct omap_sr *sr_info) |
208 | { | 209 | { |
209 | struct omap_sr_data *pdata = sr_info->pdev->dev.platform_data; | 210 | struct omap_sr_data *pdata = sr_info->pdev->dev.platform_data; |
210 | struct resource *mem; | ||
211 | int ret = 0; | 211 | int ret = 0; |
212 | 212 | ||
213 | if (sr_class->notify && sr_class->notify_flags && sr_info->irq) { | 213 | if (sr_class->notify && sr_class->notify_flags && sr_info->irq) { |
214 | ret = request_irq(sr_info->irq, sr_interrupt, | 214 | ret = devm_request_irq(&sr_info->pdev->dev, sr_info->irq, |
215 | 0, sr_info->name, sr_info); | 215 | sr_interrupt, 0, sr_info->name, sr_info); |
216 | if (ret) | 216 | if (ret) |
217 | goto error; | 217 | goto error; |
218 | disable_irq(sr_info->irq); | 218 | disable_irq(sr_info->irq); |
@@ -224,14 +224,10 @@ static int sr_late_init(struct omap_sr *sr_info) | |||
224 | return ret; | 224 | return ret; |
225 | 225 | ||
226 | error: | 226 | error: |
227 | iounmap(sr_info->base); | ||
228 | mem = platform_get_resource(sr_info->pdev, IORESOURCE_MEM, 0); | ||
229 | release_mem_region(mem->start, resource_size(mem)); | ||
230 | list_del(&sr_info->node); | 227 | list_del(&sr_info->node); |
231 | dev_err(&sr_info->pdev->dev, "%s: ERROR in registering" | 228 | dev_err(&sr_info->pdev->dev, "%s: ERROR in registering" |
232 | "interrupt handler. Smartreflex will" | 229 | "interrupt handler. Smartreflex will" |
233 | "not function as desired\n", __func__); | 230 | "not function as desired\n", __func__); |
234 | kfree(sr_info); | ||
235 | 231 | ||
236 | return ret; | 232 | return ret; |
237 | } | 233 | } |
@@ -341,9 +337,9 @@ static struct omap_sr_nvalue_table *sr_retrieve_nvalue_row( | |||
341 | /* Public Functions */ | 337 | /* Public Functions */ |
342 | 338 | ||
343 | /** | 339 | /** |
344 | * sr_configure_errgen() - Configures the smrtreflex to perform AVS using the | 340 | * sr_configure_errgen() - Configures the SmartReflex to perform AVS using the |
345 | * error generator module. | 341 | * error generator module. |
346 | * @voltdm: VDD pointer to which the SR module to be configured belongs to. | 342 | * @sr: SR module to be configured. |
347 | * | 343 | * |
348 | * This API is to be called from the smartreflex class driver to | 344 | * This API is to be called from the smartreflex class driver to |
349 | * configure the error generator module inside the smartreflex module. | 345 | * configure the error generator module inside the smartreflex module. |
@@ -352,17 +348,17 @@ static struct omap_sr_nvalue_table *sr_retrieve_nvalue_row( | |||
352 | * SR CLASS 2 can choose between ERROR module and MINMAXAVG | 348 | * SR CLASS 2 can choose between ERROR module and MINMAXAVG |
353 | * module. Returns 0 on success and error value in case of failure. | 349 | * module. Returns 0 on success and error value in case of failure. |
354 | */ | 350 | */ |
355 | int sr_configure_errgen(struct voltagedomain *voltdm) | 351 | int sr_configure_errgen(struct omap_sr *sr) |
356 | { | 352 | { |
357 | u32 sr_config, sr_errconfig, errconfig_offs; | 353 | u32 sr_config, sr_errconfig, errconfig_offs; |
358 | u32 vpboundint_en, vpboundint_st; | 354 | u32 vpboundint_en, vpboundint_st; |
359 | u32 senp_en = 0, senn_en = 0; | 355 | u32 senp_en = 0, senn_en = 0; |
360 | u8 senp_shift, senn_shift; | 356 | u8 senp_shift, senn_shift; |
361 | struct omap_sr *sr = _sr_lookup(voltdm); | ||
362 | 357 | ||
363 | if (IS_ERR(sr)) { | 358 | if (!sr) { |
364 | pr_warning("%s: omap_sr struct for voltdm not found\n", __func__); | 359 | pr_warn("%s: NULL omap_sr from %pF\n", __func__, |
365 | return PTR_ERR(sr); | 360 | (void *)_RET_IP_); |
361 | return -EINVAL; | ||
366 | } | 362 | } |
367 | 363 | ||
368 | if (!sr->clk_length) | 364 | if (!sr->clk_length) |
@@ -414,22 +410,22 @@ int sr_configure_errgen(struct voltagedomain *voltdm) | |||
414 | 410 | ||
415 | /** | 411 | /** |
416 | * sr_disable_errgen() - Disables SmartReflex AVS module's errgen component | 412 | * sr_disable_errgen() - Disables SmartReflex AVS module's errgen component |
417 | * @voltdm: VDD pointer to which the SR module to be configured belongs to. | 413 | * @sr: SR module to be configured. |
418 | * | 414 | * |
419 | * This API is to be called from the smartreflex class driver to | 415 | * This API is to be called from the smartreflex class driver to |
420 | * disable the error generator module inside the smartreflex module. | 416 | * disable the error generator module inside the smartreflex module. |
421 | * | 417 | * |
422 | * Returns 0 on success and error value in case of failure. | 418 | * Returns 0 on success and error value in case of failure. |
423 | */ | 419 | */ |
424 | int sr_disable_errgen(struct voltagedomain *voltdm) | 420 | int sr_disable_errgen(struct omap_sr *sr) |
425 | { | 421 | { |
426 | u32 errconfig_offs; | 422 | u32 errconfig_offs; |
427 | u32 vpboundint_en, vpboundint_st; | 423 | u32 vpboundint_en, vpboundint_st; |
428 | struct omap_sr *sr = _sr_lookup(voltdm); | ||
429 | 424 | ||
430 | if (IS_ERR(sr)) { | 425 | if (!sr) { |
431 | pr_warning("%s: omap_sr struct for voltdm not found\n", __func__); | 426 | pr_warn("%s: NULL omap_sr from %pF\n", __func__, |
432 | return PTR_ERR(sr); | 427 | (void *)_RET_IP_); |
428 | return -EINVAL; | ||
433 | } | 429 | } |
434 | 430 | ||
435 | switch (sr->ip_type) { | 431 | switch (sr->ip_type) { |
@@ -449,19 +445,24 @@ int sr_disable_errgen(struct voltagedomain *voltdm) | |||
449 | return -EINVAL; | 445 | return -EINVAL; |
450 | } | 446 | } |
451 | 447 | ||
452 | /* Disable the interrupts of ERROR module */ | ||
453 | sr_modify_reg(sr, errconfig_offs, vpboundint_en | vpboundint_st, 0); | ||
454 | |||
455 | /* Disable the Sensor and errorgen */ | 448 | /* Disable the Sensor and errorgen */ |
456 | sr_modify_reg(sr, SRCONFIG, SRCONFIG_SENENABLE | SRCONFIG_ERRGEN_EN, 0); | 449 | sr_modify_reg(sr, SRCONFIG, SRCONFIG_SENENABLE | SRCONFIG_ERRGEN_EN, 0); |
457 | 450 | ||
451 | /* | ||
452 | * Disable the interrupts of ERROR module | ||
453 | * NOTE: modify is a read, modify,write - an implicit OCP barrier | ||
454 | * which is required is present here - sequencing is critical | ||
455 | * at this point (after errgen is disabled, vpboundint disable) | ||
456 | */ | ||
457 | sr_modify_reg(sr, errconfig_offs, vpboundint_en | vpboundint_st, 0); | ||
458 | |||
458 | return 0; | 459 | return 0; |
459 | } | 460 | } |
460 | 461 | ||
461 | /** | 462 | /** |
462 | * sr_configure_minmax() - Configures the smrtreflex to perform AVS using the | 463 | * sr_configure_minmax() - Configures the SmartReflex to perform AVS using the |
463 | * minmaxavg module. | 464 | * minmaxavg module. |
464 | * @voltdm: VDD pointer to which the SR module to be configured belongs to. | 465 | * @sr: SR module to be configured. |
465 | * | 466 | * |
466 | * This API is to be called from the smartreflex class driver to | 467 | * This API is to be called from the smartreflex class driver to |
467 | * configure the minmaxavg module inside the smartreflex module. | 468 | * configure the minmaxavg module inside the smartreflex module. |
@@ -470,16 +471,16 @@ int sr_disable_errgen(struct voltagedomain *voltdm) | |||
470 | * SR CLASS 2 can choose between ERROR module and MINMAXAVG | 471 | * SR CLASS 2 can choose between ERROR module and MINMAXAVG |
471 | * module. Returns 0 on success and error value in case of failure. | 472 | * module. Returns 0 on success and error value in case of failure. |
472 | */ | 473 | */ |
473 | int sr_configure_minmax(struct voltagedomain *voltdm) | 474 | int sr_configure_minmax(struct omap_sr *sr) |
474 | { | 475 | { |
475 | u32 sr_config, sr_avgwt; | 476 | u32 sr_config, sr_avgwt; |
476 | u32 senp_en = 0, senn_en = 0; | 477 | u32 senp_en = 0, senn_en = 0; |
477 | u8 senp_shift, senn_shift; | 478 | u8 senp_shift, senn_shift; |
478 | struct omap_sr *sr = _sr_lookup(voltdm); | ||
479 | 479 | ||
480 | if (IS_ERR(sr)) { | 480 | if (!sr) { |
481 | pr_warning("%s: omap_sr struct for voltdm not found\n", __func__); | 481 | pr_warn("%s: NULL omap_sr from %pF\n", __func__, |
482 | return PTR_ERR(sr); | 482 | (void *)_RET_IP_); |
483 | return -EINVAL; | ||
483 | } | 484 | } |
484 | 485 | ||
485 | if (!sr->clk_length) | 486 | if (!sr->clk_length) |
@@ -546,7 +547,7 @@ int sr_configure_minmax(struct voltagedomain *voltdm) | |||
546 | 547 | ||
547 | /** | 548 | /** |
548 | * sr_enable() - Enables the smartreflex module. | 549 | * sr_enable() - Enables the smartreflex module. |
549 | * @voltdm: VDD pointer to which the SR module to be configured belongs to. | 550 | * @sr: pointer to which the SR module to be configured belongs to. |
550 | * @volt: The voltage at which the Voltage domain associated with | 551 | * @volt: The voltage at which the Voltage domain associated with |
551 | * the smartreflex module is operating at. | 552 | * the smartreflex module is operating at. |
552 | * This is required only to program the correct Ntarget value. | 553 | * This is required only to program the correct Ntarget value. |
@@ -555,16 +556,16 @@ int sr_configure_minmax(struct voltagedomain *voltdm) | |||
555 | * enable a smartreflex module. Returns 0 on success. Returns error | 556 | * enable a smartreflex module. Returns 0 on success. Returns error |
556 | * value if the voltage passed is wrong or if ntarget value is wrong. | 557 | * value if the voltage passed is wrong or if ntarget value is wrong. |
557 | */ | 558 | */ |
558 | int sr_enable(struct voltagedomain *voltdm, unsigned long volt) | 559 | int sr_enable(struct omap_sr *sr, unsigned long volt) |
559 | { | 560 | { |
560 | struct omap_volt_data *volt_data; | 561 | struct omap_volt_data *volt_data; |
561 | struct omap_sr *sr = _sr_lookup(voltdm); | ||
562 | struct omap_sr_nvalue_table *nvalue_row; | 562 | struct omap_sr_nvalue_table *nvalue_row; |
563 | int ret; | 563 | int ret; |
564 | 564 | ||
565 | if (IS_ERR(sr)) { | 565 | if (!sr) { |
566 | pr_warning("%s: omap_sr struct for voltdm not found\n", __func__); | 566 | pr_warn("%s: NULL omap_sr from %pF\n", __func__, |
567 | return PTR_ERR(sr); | 567 | (void *)_RET_IP_); |
568 | return -EINVAL; | ||
568 | } | 569 | } |
569 | 570 | ||
570 | volt_data = omap_voltage_get_voltdata(sr->voltdm, volt); | 571 | volt_data = omap_voltage_get_voltdata(sr->voltdm, volt); |
@@ -606,17 +607,16 @@ int sr_enable(struct voltagedomain *voltdm, unsigned long volt) | |||
606 | 607 | ||
607 | /** | 608 | /** |
608 | * sr_disable() - Disables the smartreflex module. | 609 | * sr_disable() - Disables the smartreflex module. |
609 | * @voltdm: VDD pointer to which the SR module to be configured belongs to. | 610 | * @sr: pointer to which the SR module to be configured belongs to. |
610 | * | 611 | * |
611 | * This API is to be called from the smartreflex class driver to | 612 | * This API is to be called from the smartreflex class driver to |
612 | * disable a smartreflex module. | 613 | * disable a smartreflex module. |
613 | */ | 614 | */ |
614 | void sr_disable(struct voltagedomain *voltdm) | 615 | void sr_disable(struct omap_sr *sr) |
615 | { | 616 | { |
616 | struct omap_sr *sr = _sr_lookup(voltdm); | 617 | if (!sr) { |
617 | 618 | pr_warn("%s: NULL omap_sr from %pF\n", __func__, | |
618 | if (IS_ERR(sr)) { | 619 | (void *)_RET_IP_); |
619 | pr_warning("%s: omap_sr struct for voltdm not found\n", __func__); | ||
620 | return; | 620 | return; |
621 | } | 621 | } |
622 | 622 | ||
@@ -847,34 +847,33 @@ static int __init omap_sr_probe(struct platform_device *pdev) | |||
847 | struct dentry *nvalue_dir; | 847 | struct dentry *nvalue_dir; |
848 | int i, ret = 0; | 848 | int i, ret = 0; |
849 | 849 | ||
850 | sr_info = kzalloc(sizeof(struct omap_sr), GFP_KERNEL); | 850 | sr_info = devm_kzalloc(&pdev->dev, sizeof(struct omap_sr), GFP_KERNEL); |
851 | if (!sr_info) { | 851 | if (!sr_info) { |
852 | dev_err(&pdev->dev, "%s: unable to allocate sr_info\n", | 852 | dev_err(&pdev->dev, "%s: unable to allocate sr_info\n", |
853 | __func__); | 853 | __func__); |
854 | return -ENOMEM; | 854 | return -ENOMEM; |
855 | } | 855 | } |
856 | 856 | ||
857 | sr_info->name = devm_kzalloc(&pdev->dev, | ||
858 | SMARTREFLEX_NAME_LEN, GFP_KERNEL); | ||
859 | if (!sr_info->name) { | ||
860 | dev_err(&pdev->dev, "%s: unable to allocate SR instance name\n", | ||
861 | __func__); | ||
862 | return -ENOMEM; | ||
863 | } | ||
864 | |||
857 | platform_set_drvdata(pdev, sr_info); | 865 | platform_set_drvdata(pdev, sr_info); |
858 | 866 | ||
859 | if (!pdata) { | 867 | if (!pdata) { |
860 | dev_err(&pdev->dev, "%s: platform data missing\n", __func__); | 868 | dev_err(&pdev->dev, "%s: platform data missing\n", __func__); |
861 | ret = -EINVAL; | 869 | return -EINVAL; |
862 | goto err_free_devinfo; | ||
863 | } | 870 | } |
864 | 871 | ||
865 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 872 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
866 | if (!mem) { | 873 | sr_info->base = devm_ioremap_resource(&pdev->dev, mem); |
867 | dev_err(&pdev->dev, "%s: no mem resource\n", __func__); | 874 | if (IS_ERR(sr_info->base)) { |
868 | ret = -ENODEV; | 875 | dev_err(&pdev->dev, "%s: ioremap fail\n", __func__); |
869 | goto err_free_devinfo; | 876 | return PTR_ERR(sr_info->base); |
870 | } | ||
871 | |||
872 | mem = request_mem_region(mem->start, resource_size(mem), | ||
873 | dev_name(&pdev->dev)); | ||
874 | if (!mem) { | ||
875 | dev_err(&pdev->dev, "%s: no mem region\n", __func__); | ||
876 | ret = -EBUSY; | ||
877 | goto err_free_devinfo; | ||
878 | } | 877 | } |
879 | 878 | ||
880 | irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 879 | irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
@@ -882,13 +881,7 @@ static int __init omap_sr_probe(struct platform_device *pdev) | |||
882 | pm_runtime_enable(&pdev->dev); | 881 | pm_runtime_enable(&pdev->dev); |
883 | pm_runtime_irq_safe(&pdev->dev); | 882 | pm_runtime_irq_safe(&pdev->dev); |
884 | 883 | ||
885 | sr_info->name = kasprintf(GFP_KERNEL, "%s", pdata->name); | 884 | snprintf(sr_info->name, SMARTREFLEX_NAME_LEN, "%s", pdata->name); |
886 | if (!sr_info->name) { | ||
887 | dev_err(&pdev->dev, "%s: Unable to alloc SR instance name\n", | ||
888 | __func__); | ||
889 | ret = -ENOMEM; | ||
890 | goto err_release_region; | ||
891 | } | ||
892 | 885 | ||
893 | sr_info->pdev = pdev; | 886 | sr_info->pdev = pdev; |
894 | sr_info->srid = pdev->id; | 887 | sr_info->srid = pdev->id; |
@@ -905,13 +898,6 @@ static int __init omap_sr_probe(struct platform_device *pdev) | |||
905 | sr_info->autocomp_active = false; | 898 | sr_info->autocomp_active = false; |
906 | sr_info->ip_type = pdata->ip_type; | 899 | sr_info->ip_type = pdata->ip_type; |
907 | 900 | ||
908 | sr_info->base = ioremap(mem->start, resource_size(mem)); | ||
909 | if (!sr_info->base) { | ||
910 | dev_err(&pdev->dev, "%s: ioremap fail\n", __func__); | ||
911 | ret = -ENOMEM; | ||
912 | goto err_free_name; | ||
913 | } | ||
914 | |||
915 | if (irq) | 901 | if (irq) |
916 | sr_info->irq = irq->start; | 902 | sr_info->irq = irq->start; |
917 | 903 | ||
@@ -927,7 +913,7 @@ static int __init omap_sr_probe(struct platform_device *pdev) | |||
927 | ret = sr_late_init(sr_info); | 913 | ret = sr_late_init(sr_info); |
928 | if (ret) { | 914 | if (ret) { |
929 | pr_warning("%s: Error in SR late init\n", __func__); | 915 | pr_warning("%s: Error in SR late init\n", __func__); |
930 | goto err_iounmap; | 916 | goto err_list_del; |
931 | } | 917 | } |
932 | } | 918 | } |
933 | 919 | ||
@@ -938,7 +924,7 @@ static int __init omap_sr_probe(struct platform_device *pdev) | |||
938 | ret = PTR_ERR(sr_dbg_dir); | 924 | ret = PTR_ERR(sr_dbg_dir); |
939 | pr_err("%s:sr debugfs dir creation failed(%d)\n", | 925 | pr_err("%s:sr debugfs dir creation failed(%d)\n", |
940 | __func__, ret); | 926 | __func__, ret); |
941 | goto err_iounmap; | 927 | goto err_list_del; |
942 | } | 928 | } |
943 | } | 929 | } |
944 | 930 | ||
@@ -991,16 +977,8 @@ static int __init omap_sr_probe(struct platform_device *pdev) | |||
991 | 977 | ||
992 | err_debugfs: | 978 | err_debugfs: |
993 | debugfs_remove_recursive(sr_info->dbg_dir); | 979 | debugfs_remove_recursive(sr_info->dbg_dir); |
994 | err_iounmap: | 980 | err_list_del: |
995 | list_del(&sr_info->node); | 981 | list_del(&sr_info->node); |
996 | iounmap(sr_info->base); | ||
997 | err_free_name: | ||
998 | kfree(sr_info->name); | ||
999 | err_release_region: | ||
1000 | release_mem_region(mem->start, resource_size(mem)); | ||
1001 | err_free_devinfo: | ||
1002 | kfree(sr_info); | ||
1003 | |||
1004 | return ret; | 982 | return ret; |
1005 | } | 983 | } |
1006 | 984 | ||
@@ -1008,7 +986,6 @@ static int omap_sr_remove(struct platform_device *pdev) | |||
1008 | { | 986 | { |
1009 | struct omap_sr_data *pdata = pdev->dev.platform_data; | 987 | struct omap_sr_data *pdata = pdev->dev.platform_data; |
1010 | struct omap_sr *sr_info; | 988 | struct omap_sr *sr_info; |
1011 | struct resource *mem; | ||
1012 | 989 | ||
1013 | if (!pdata) { | 990 | if (!pdata) { |
1014 | dev_err(&pdev->dev, "%s: platform data missing\n", __func__); | 991 | dev_err(&pdev->dev, "%s: platform data missing\n", __func__); |
@@ -1027,13 +1004,8 @@ static int omap_sr_remove(struct platform_device *pdev) | |||
1027 | if (sr_info->dbg_dir) | 1004 | if (sr_info->dbg_dir) |
1028 | debugfs_remove_recursive(sr_info->dbg_dir); | 1005 | debugfs_remove_recursive(sr_info->dbg_dir); |
1029 | 1006 | ||
1007 | pm_runtime_disable(&pdev->dev); | ||
1030 | list_del(&sr_info->node); | 1008 | list_del(&sr_info->node); |
1031 | iounmap(sr_info->base); | ||
1032 | kfree(sr_info->name); | ||
1033 | kfree(sr_info); | ||
1034 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1035 | release_mem_region(mem->start, resource_size(mem)); | ||
1036 | |||
1037 | return 0; | 1009 | return 0; |
1038 | } | 1010 | } |
1039 | 1011 | ||
@@ -1064,7 +1036,7 @@ static struct platform_driver smartreflex_driver = { | |||
1064 | .remove = omap_sr_remove, | 1036 | .remove = omap_sr_remove, |
1065 | .shutdown = omap_sr_shutdown, | 1037 | .shutdown = omap_sr_shutdown, |
1066 | .driver = { | 1038 | .driver = { |
1067 | .name = "smartreflex", | 1039 | .name = DRIVER_NAME, |
1068 | }, | 1040 | }, |
1069 | }; | 1041 | }; |
1070 | 1042 | ||
diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c index 42539ee2cb11..4c5aabe21755 100644 --- a/drivers/scsi/scsi_pm.c +++ b/drivers/scsi/scsi_pm.c | |||
@@ -229,8 +229,6 @@ static int scsi_runtime_resume(struct device *dev) | |||
229 | 229 | ||
230 | static int scsi_runtime_idle(struct device *dev) | 230 | static int scsi_runtime_idle(struct device *dev) |
231 | { | 231 | { |
232 | int err; | ||
233 | |||
234 | dev_dbg(dev, "scsi_runtime_idle\n"); | 232 | dev_dbg(dev, "scsi_runtime_idle\n"); |
235 | 233 | ||
236 | /* Insert hooks here for targets, hosts, and transport classes */ | 234 | /* Insert hooks here for targets, hosts, and transport classes */ |
@@ -240,14 +238,11 @@ static int scsi_runtime_idle(struct device *dev) | |||
240 | 238 | ||
241 | if (sdev->request_queue->dev) { | 239 | if (sdev->request_queue->dev) { |
242 | pm_runtime_mark_last_busy(dev); | 240 | pm_runtime_mark_last_busy(dev); |
243 | err = pm_runtime_autosuspend(dev); | 241 | pm_runtime_autosuspend(dev); |
244 | } else { | 242 | return -EBUSY; |
245 | err = pm_runtime_suspend(dev); | ||
246 | } | 243 | } |
247 | } else { | ||
248 | err = pm_runtime_suspend(dev); | ||
249 | } | 244 | } |
250 | return err; | 245 | return 0; |
251 | } | 246 | } |
252 | 247 | ||
253 | int scsi_autopm_get_device(struct scsi_device *sdev) | 248 | int scsi_autopm_get_device(struct scsi_device *sdev) |
diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c index 7715de2629c1..74727851820d 100644 --- a/drivers/sh/clk/core.c +++ b/drivers/sh/clk/core.c | |||
@@ -63,12 +63,12 @@ void clk_rate_table_build(struct clk *clk, | |||
63 | else | 63 | else |
64 | freq = clk->parent->rate * mult / div; | 64 | freq = clk->parent->rate * mult / div; |
65 | 65 | ||
66 | freq_table[i].index = i; | 66 | freq_table[i].driver_data = i; |
67 | freq_table[i].frequency = freq; | 67 | freq_table[i].frequency = freq; |
68 | } | 68 | } |
69 | 69 | ||
70 | /* Termination entry */ | 70 | /* Termination entry */ |
71 | freq_table[i].index = i; | 71 | freq_table[i].driver_data = i; |
72 | freq_table[i].frequency = CPUFREQ_TABLE_END; | 72 | freq_table[i].frequency = CPUFREQ_TABLE_END; |
73 | } | 73 | } |
74 | 74 | ||
diff --git a/drivers/sh/pm_runtime.c b/drivers/sh/pm_runtime.c index afe9282629b9..8afa5a4589f2 100644 --- a/drivers/sh/pm_runtime.c +++ b/drivers/sh/pm_runtime.c | |||
@@ -25,7 +25,7 @@ | |||
25 | static int default_platform_runtime_idle(struct device *dev) | 25 | static int default_platform_runtime_idle(struct device *dev) |
26 | { | 26 | { |
27 | /* suspend synchronously to disable clocks immediately */ | 27 | /* suspend synchronously to disable clocks immediately */ |
28 | return pm_runtime_suspend(dev); | 28 | return 0; |
29 | } | 29 | } |
30 | 30 | ||
31 | static struct dev_pm_domain default_pm_domain = { | 31 | static struct dev_pm_domain default_pm_domain = { |
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 32b7bb111eb6..095cfaded1c0 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -223,7 +223,7 @@ static const struct dev_pm_ops spi_pm = { | |||
223 | SET_RUNTIME_PM_OPS( | 223 | SET_RUNTIME_PM_OPS( |
224 | pm_generic_runtime_suspend, | 224 | pm_generic_runtime_suspend, |
225 | pm_generic_runtime_resume, | 225 | pm_generic_runtime_resume, |
226 | pm_generic_runtime_idle | 226 | NULL |
227 | ) | 227 | ) |
228 | }; | 228 | }; |
229 | 229 | ||
diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index c6dc1846943f..119d486a5cf7 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <asm/cacheflush.h> | 20 | #include <asm/cacheflush.h> |
21 | #include <linux/fdtable.h> | 21 | #include <linux/fdtable.h> |
22 | #include <linux/file.h> | 22 | #include <linux/file.h> |
23 | #include <linux/freezer.h> | ||
23 | #include <linux/fs.h> | 24 | #include <linux/fs.h> |
24 | #include <linux/list.h> | 25 | #include <linux/list.h> |
25 | #include <linux/miscdevice.h> | 26 | #include <linux/miscdevice.h> |
@@ -2140,13 +2141,13 @@ retry: | |||
2140 | if (!binder_has_proc_work(proc, thread)) | 2141 | if (!binder_has_proc_work(proc, thread)) |
2141 | ret = -EAGAIN; | 2142 | ret = -EAGAIN; |
2142 | } else | 2143 | } else |
2143 | ret = wait_event_interruptible_exclusive(proc->wait, binder_has_proc_work(proc, thread)); | 2144 | ret = wait_event_freezable_exclusive(proc->wait, binder_has_proc_work(proc, thread)); |
2144 | } else { | 2145 | } else { |
2145 | if (non_block) { | 2146 | if (non_block) { |
2146 | if (!binder_has_thread_work(thread)) | 2147 | if (!binder_has_thread_work(thread)) |
2147 | ret = -EAGAIN; | 2148 | ret = -EAGAIN; |
2148 | } else | 2149 | } else |
2149 | ret = wait_event_interruptible(thread->wait, binder_has_thread_work(thread)); | 2150 | ret = wait_event_freezable(thread->wait, binder_has_thread_work(thread)); |
2150 | } | 2151 | } |
2151 | 2152 | ||
2152 | binder_lock(__func__); | 2153 | binder_lock(__func__); |
diff --git a/drivers/tty/serial/mfd.c b/drivers/tty/serial/mfd.c index e266eca0ec76..4a82267af83f 100644 --- a/drivers/tty/serial/mfd.c +++ b/drivers/tty/serial/mfd.c | |||
@@ -1252,13 +1252,8 @@ static int serial_hsu_resume(struct pci_dev *pdev) | |||
1252 | #ifdef CONFIG_PM_RUNTIME | 1252 | #ifdef CONFIG_PM_RUNTIME |
1253 | static int serial_hsu_runtime_idle(struct device *dev) | 1253 | static int serial_hsu_runtime_idle(struct device *dev) |
1254 | { | 1254 | { |
1255 | int err; | 1255 | pm_schedule_suspend(dev, 500); |
1256 | 1256 | return -EBUSY; | |
1257 | err = pm_schedule_suspend(dev, 500); | ||
1258 | if (err) | ||
1259 | return -EBUSY; | ||
1260 | |||
1261 | return 0; | ||
1262 | } | 1257 | } |
1263 | 1258 | ||
1264 | static int serial_hsu_runtime_suspend(struct device *dev) | 1259 | static int serial_hsu_runtime_suspend(struct device *dev) |
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 6eab440e1542..7609ac4aed1c 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -1765,7 +1765,8 @@ int usb_runtime_idle(struct device *dev) | |||
1765 | */ | 1765 | */ |
1766 | if (autosuspend_check(udev) == 0) | 1766 | if (autosuspend_check(udev) == 0) |
1767 | pm_runtime_autosuspend(dev); | 1767 | pm_runtime_autosuspend(dev); |
1768 | return 0; | 1768 | /* Tell the core not to suspend it, though. */ |
1769 | return -EBUSY; | ||
1769 | } | 1770 | } |
1770 | 1771 | ||
1771 | int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable) | 1772 | int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable) |
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c index 5fd3fee58f8b..d6b0fadf53e9 100644 --- a/drivers/usb/core/port.c +++ b/drivers/usb/core/port.c | |||
@@ -141,7 +141,6 @@ static const struct dev_pm_ops usb_port_pm_ops = { | |||
141 | #ifdef CONFIG_PM_RUNTIME | 141 | #ifdef CONFIG_PM_RUNTIME |
142 | .runtime_suspend = usb_port_runtime_suspend, | 142 | .runtime_suspend = usb_port_runtime_suspend, |
143 | .runtime_resume = usb_port_runtime_resume, | 143 | .runtime_resume = usb_port_runtime_resume, |
144 | .runtime_idle = pm_generic_runtime_idle, | ||
145 | #endif | 144 | #endif |
146 | }; | 145 | }; |
147 | 146 | ||
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 1996d6ceb833..6fdcb1b4a106 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c | |||
@@ -447,7 +447,7 @@ wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *midQ) | |||
447 | { | 447 | { |
448 | int error; | 448 | int error; |
449 | 449 | ||
450 | error = wait_event_freezekillable(server->response_q, | 450 | error = wait_event_freezekillable_unsafe(server->response_q, |
451 | midQ->mid_state != MID_REQUEST_SUBMITTED); | 451 | midQ->mid_state != MID_REQUEST_SUBMITTED); |
452 | if (error < 0) | 452 | if (error < 0) |
453 | return -ERESTARTSYS; | 453 | return -ERESTARTSYS; |
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index deecc7294a67..0cff4434880d 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/mutex.h> | 34 | #include <linux/mutex.h> |
35 | #include <linux/anon_inodes.h> | 35 | #include <linux/anon_inodes.h> |
36 | #include <linux/device.h> | 36 | #include <linux/device.h> |
37 | #include <linux/freezer.h> | ||
37 | #include <asm/uaccess.h> | 38 | #include <asm/uaccess.h> |
38 | #include <asm/io.h> | 39 | #include <asm/io.h> |
39 | #include <asm/mman.h> | 40 | #include <asm/mman.h> |
@@ -1602,7 +1603,8 @@ fetch_events: | |||
1602 | } | 1603 | } |
1603 | 1604 | ||
1604 | spin_unlock_irqrestore(&ep->lock, flags); | 1605 | spin_unlock_irqrestore(&ep->lock, flags); |
1605 | if (!schedule_hrtimeout_range(to, slack, HRTIMER_MODE_ABS)) | 1606 | if (!freezable_schedule_hrtimeout_range(to, slack, |
1607 | HRTIMER_MODE_ABS)) | ||
1606 | timed_out = 1; | 1608 | timed_out = 1; |
1607 | 1609 | ||
1608 | spin_lock_irqsave(&ep->lock, flags); | 1610 | spin_lock_irqsave(&ep->lock, flags); |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index c1c7a9d78722..ce727047ee87 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -79,7 +79,7 @@ int nfs_wait_bit_killable(void *word) | |||
79 | { | 79 | { |
80 | if (fatal_signal_pending(current)) | 80 | if (fatal_signal_pending(current)) |
81 | return -ERESTARTSYS; | 81 | return -ERESTARTSYS; |
82 | freezable_schedule(); | 82 | freezable_schedule_unsafe(); |
83 | return 0; | 83 | return 0; |
84 | } | 84 | } |
85 | EXPORT_SYMBOL_GPL(nfs_wait_bit_killable); | 85 | EXPORT_SYMBOL_GPL(nfs_wait_bit_killable); |
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index 43ea96ced28c..ce90eb4775c2 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c | |||
@@ -33,7 +33,7 @@ nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags) | |||
33 | res = rpc_call_sync(clnt, msg, flags); | 33 | res = rpc_call_sync(clnt, msg, flags); |
34 | if (res != -EJUKEBOX) | 34 | if (res != -EJUKEBOX) |
35 | break; | 35 | break; |
36 | freezable_schedule_timeout_killable(NFS_JUKEBOX_RETRY_TIME); | 36 | freezable_schedule_timeout_killable_unsafe(NFS_JUKEBOX_RETRY_TIME); |
37 | res = -ERESTARTSYS; | 37 | res = -ERESTARTSYS; |
38 | } while (!fatal_signal_pending(current)); | 38 | } while (!fatal_signal_pending(current)); |
39 | return res; | 39 | return res; |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index d7ba5616989c..28241a42f363 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -268,7 +268,7 @@ static int nfs4_delay(struct rpc_clnt *clnt, long *timeout) | |||
268 | *timeout = NFS4_POLL_RETRY_MIN; | 268 | *timeout = NFS4_POLL_RETRY_MIN; |
269 | if (*timeout > NFS4_POLL_RETRY_MAX) | 269 | if (*timeout > NFS4_POLL_RETRY_MAX) |
270 | *timeout = NFS4_POLL_RETRY_MAX; | 270 | *timeout = NFS4_POLL_RETRY_MAX; |
271 | freezable_schedule_timeout_killable(*timeout); | 271 | freezable_schedule_timeout_killable_unsafe(*timeout); |
272 | if (fatal_signal_pending(current)) | 272 | if (fatal_signal_pending(current)) |
273 | res = -ERESTARTSYS; | 273 | res = -ERESTARTSYS; |
274 | *timeout <<= 1; | 274 | *timeout <<= 1; |
@@ -4528,7 +4528,7 @@ int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4 | |||
4528 | static unsigned long | 4528 | static unsigned long |
4529 | nfs4_set_lock_task_retry(unsigned long timeout) | 4529 | nfs4_set_lock_task_retry(unsigned long timeout) |
4530 | { | 4530 | { |
4531 | freezable_schedule_timeout_killable(timeout); | 4531 | freezable_schedule_timeout_killable_unsafe(timeout); |
4532 | timeout <<= 1; | 4532 | timeout <<= 1; |
4533 | if (timeout > NFS4_LOCK_MAXTIMEOUT) | 4533 | if (timeout > NFS4_LOCK_MAXTIMEOUT) |
4534 | return NFS4_LOCK_MAXTIMEOUT; | 4534 | return NFS4_LOCK_MAXTIMEOUT; |
diff --git a/fs/select.c b/fs/select.c index 8c1c96c27062..6b14dc7df3a4 100644 --- a/fs/select.c +++ b/fs/select.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/rcupdate.h> | 27 | #include <linux/rcupdate.h> |
28 | #include <linux/hrtimer.h> | 28 | #include <linux/hrtimer.h> |
29 | #include <linux/sched/rt.h> | 29 | #include <linux/sched/rt.h> |
30 | #include <linux/freezer.h> | ||
30 | 31 | ||
31 | #include <asm/uaccess.h> | 32 | #include <asm/uaccess.h> |
32 | 33 | ||
@@ -236,7 +237,8 @@ int poll_schedule_timeout(struct poll_wqueues *pwq, int state, | |||
236 | 237 | ||
237 | set_current_state(state); | 238 | set_current_state(state); |
238 | if (!pwq->triggered) | 239 | if (!pwq->triggered) |
239 | rc = schedule_hrtimeout_range(expires, slack, HRTIMER_MODE_ABS); | 240 | rc = freezable_schedule_hrtimeout_range(expires, slack, |
241 | HRTIMER_MODE_ABS); | ||
240 | __set_current_state(TASK_RUNNING); | 242 | __set_current_state(TASK_RUNNING); |
241 | 243 | ||
242 | /* | 244 | /* |
diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h index 14ceff788c40..1c16f821434f 100644 --- a/include/acpi/acconfig.h +++ b/include/acpi/acconfig.h | |||
@@ -219,8 +219,8 @@ | |||
219 | * | 219 | * |
220 | *****************************************************************************/ | 220 | *****************************************************************************/ |
221 | 221 | ||
222 | #define ACPI_DEBUGGER_MAX_ARGS 8 /* Must be max method args + 1 */ | 222 | #define ACPI_DEBUGGER_MAX_ARGS ACPI_METHOD_NUM_ARGS + 4 /* Max command line arguments */ |
223 | #define ACPI_DB_LINE_BUFFER_SIZE 512 | 223 | #define ACPI_DB_LINE_BUFFER_SIZE 512 |
224 | 224 | ||
225 | #define ACPI_DEBUGGER_COMMAND_PROMPT '-' | 225 | #define ACPI_DEBUGGER_COMMAND_PROMPT '-' |
226 | #define ACPI_DEBUGGER_EXECUTE_PROMPT '%' | 226 | #define ACPI_DEBUGGER_EXECUTE_PROMPT '%' |
diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h index 4f52ea795c7a..4607b027a657 100644 --- a/include/acpi/acoutput.h +++ b/include/acpi/acoutput.h | |||
@@ -428,27 +428,21 @@ | |||
428 | * This is the non-debug case -- make everything go away, | 428 | * This is the non-debug case -- make everything go away, |
429 | * leaving no executable debug code! | 429 | * leaving no executable debug code! |
430 | */ | 430 | */ |
431 | #define ACPI_FUNCTION_NAME(a) | ||
432 | #define ACPI_DEBUG_PRINT(pl) | 431 | #define ACPI_DEBUG_PRINT(pl) |
433 | #define ACPI_DEBUG_PRINT_RAW(pl) | 432 | #define ACPI_DEBUG_PRINT_RAW(pl) |
434 | #define ACPI_DEBUG_EXEC(a) | 433 | #define ACPI_DEBUG_EXEC(a) |
435 | #define ACPI_DEBUG_ONLY_MEMBERS(a) | 434 | #define ACPI_DEBUG_ONLY_MEMBERS(a) |
435 | #define ACPI_FUNCTION_NAME(a) | ||
436 | #define ACPI_FUNCTION_TRACE(a) | 436 | #define ACPI_FUNCTION_TRACE(a) |
437 | #define ACPI_FUNCTION_TRACE_PTR(a, b) | 437 | #define ACPI_FUNCTION_TRACE_PTR(a, b) |
438 | #define ACPI_FUNCTION_TRACE_U32(a, b) | 438 | #define ACPI_FUNCTION_TRACE_U32(a, b) |
439 | #define ACPI_FUNCTION_TRACE_STR(a, b) | 439 | #define ACPI_FUNCTION_TRACE_STR(a, b) |
440 | #define ACPI_FUNCTION_EXIT | ||
441 | #define ACPI_FUNCTION_STATUS_EXIT(s) | ||
442 | #define ACPI_FUNCTION_VALUE_EXIT(s) | ||
443 | #define ACPI_FUNCTION_ENTRY() | 440 | #define ACPI_FUNCTION_ENTRY() |
444 | #define ACPI_DUMP_STACK_ENTRY(a) | 441 | #define ACPI_DUMP_STACK_ENTRY(a) |
445 | #define ACPI_DUMP_OPERANDS(a, b, c) | 442 | #define ACPI_DUMP_OPERANDS(a, b, c) |
446 | #define ACPI_DUMP_ENTRY(a, b) | 443 | #define ACPI_DUMP_ENTRY(a, b) |
447 | #define ACPI_DUMP_TABLES(a, b) | ||
448 | #define ACPI_DUMP_PATHNAME(a, b, c, d) | 444 | #define ACPI_DUMP_PATHNAME(a, b, c, d) |
449 | #define ACPI_DUMP_BUFFER(a, b) | 445 | #define ACPI_DUMP_BUFFER(a, b) |
450 | #define ACPI_DEBUG_PRINT(pl) | ||
451 | #define ACPI_DEBUG_PRINT_RAW(pl) | ||
452 | #define ACPI_IS_DEBUG_ENABLED(level, component) 0 | 446 | #define ACPI_IS_DEBUG_ENABLED(level, component) 0 |
453 | 447 | ||
454 | /* Return macros must have a return statement at the minimum */ | 448 | /* Return macros must have a return statement at the minimum */ |
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index c13c919ab99e..ca081ace2a1d 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
@@ -63,13 +63,6 @@ acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld | |||
63 | #define ACPI_BUS_FILE_ROOT "acpi" | 63 | #define ACPI_BUS_FILE_ROOT "acpi" |
64 | extern struct proc_dir_entry *acpi_root_dir; | 64 | extern struct proc_dir_entry *acpi_root_dir; |
65 | 65 | ||
66 | enum acpi_bus_removal_type { | ||
67 | ACPI_BUS_REMOVAL_NORMAL = 0, | ||
68 | ACPI_BUS_REMOVAL_EJECT, | ||
69 | ACPI_BUS_REMOVAL_SUPRISE, | ||
70 | ACPI_BUS_REMOVAL_TYPE_COUNT | ||
71 | }; | ||
72 | |||
73 | enum acpi_bus_device_type { | 66 | enum acpi_bus_device_type { |
74 | ACPI_BUS_TYPE_DEVICE = 0, | 67 | ACPI_BUS_TYPE_DEVICE = 0, |
75 | ACPI_BUS_TYPE_POWER, | 68 | ACPI_BUS_TYPE_POWER, |
@@ -163,12 +156,10 @@ struct acpi_device_flags { | |||
163 | u32 dynamic_status:1; | 156 | u32 dynamic_status:1; |
164 | u32 removable:1; | 157 | u32 removable:1; |
165 | u32 ejectable:1; | 158 | u32 ejectable:1; |
166 | u32 suprise_removal_ok:1; | ||
167 | u32 power_manageable:1; | 159 | u32 power_manageable:1; |
168 | u32 performance_manageable:1; | ||
169 | u32 eject_pending:1; | 160 | u32 eject_pending:1; |
170 | u32 match_driver:1; | 161 | u32 match_driver:1; |
171 | u32 reserved:24; | 162 | u32 reserved:26; |
172 | }; | 163 | }; |
173 | 164 | ||
174 | /* File System */ | 165 | /* File System */ |
@@ -286,6 +277,7 @@ struct acpi_device_physical_node { | |||
286 | u8 node_id; | 277 | u8 node_id; |
287 | struct list_head node; | 278 | struct list_head node; |
288 | struct device *dev; | 279 | struct device *dev; |
280 | bool put_online:1; | ||
289 | }; | 281 | }; |
290 | 282 | ||
291 | /* set maximum of physical nodes to 32 for expansibility */ | 283 | /* set maximum of physical nodes to 32 for expansibility */ |
@@ -310,7 +302,6 @@ struct acpi_device { | |||
310 | struct acpi_driver *driver; | 302 | struct acpi_driver *driver; |
311 | void *driver_data; | 303 | void *driver_data; |
312 | struct device dev; | 304 | struct device dev; |
313 | enum acpi_bus_removal_type removal_type; /* indicate for different removal type */ | ||
314 | u8 physical_node_count; | 305 | u8 physical_node_count; |
315 | struct list_head physical_node_list; | 306 | struct list_head physical_node_list; |
316 | struct mutex physical_node_lock; | 307 | struct mutex physical_node_lock; |
@@ -468,8 +459,6 @@ acpi_status acpi_add_pm_notifier(struct acpi_device *adev, | |||
468 | acpi_notify_handler handler, void *context); | 459 | acpi_notify_handler handler, void *context); |
469 | acpi_status acpi_remove_pm_notifier(struct acpi_device *adev, | 460 | acpi_status acpi_remove_pm_notifier(struct acpi_device *adev, |
470 | acpi_notify_handler handler); | 461 | acpi_notify_handler handler); |
471 | int acpi_device_power_state(struct device *dev, struct acpi_device *adev, | ||
472 | u32 target_state, int d_max_in, int *d_min_p); | ||
473 | int acpi_pm_device_sleep_state(struct device *, int *, int); | 462 | int acpi_pm_device_sleep_state(struct device *, int *, int); |
474 | void acpi_dev_pm_add_dependent(acpi_handle handle, struct device *depdev); | 463 | void acpi_dev_pm_add_dependent(acpi_handle handle, struct device *depdev); |
475 | void acpi_dev_pm_remove_dependent(acpi_handle handle, struct device *depdev); | 464 | void acpi_dev_pm_remove_dependent(acpi_handle handle, struct device *depdev); |
@@ -485,23 +474,13 @@ static inline acpi_status acpi_remove_pm_notifier(struct acpi_device *adev, | |||
485 | { | 474 | { |
486 | return AE_SUPPORT; | 475 | return AE_SUPPORT; |
487 | } | 476 | } |
488 | static inline int __acpi_device_power_state(int m, int *p) | 477 | static inline int acpi_pm_device_sleep_state(struct device *d, int *p, int m) |
489 | { | 478 | { |
490 | if (p) | 479 | if (p) |
491 | *p = ACPI_STATE_D0; | 480 | *p = ACPI_STATE_D0; |
481 | |||
492 | return (m >= ACPI_STATE_D0 && m <= ACPI_STATE_D3) ? m : ACPI_STATE_D0; | 482 | return (m >= ACPI_STATE_D0 && m <= ACPI_STATE_D3) ? m : ACPI_STATE_D0; |
493 | } | 483 | } |
494 | static inline int acpi_device_power_state(struct device *dev, | ||
495 | struct acpi_device *adev, | ||
496 | u32 target_state, int d_max_in, | ||
497 | int *d_min_p) | ||
498 | { | ||
499 | return __acpi_device_power_state(d_max_in, d_min_p); | ||
500 | } | ||
501 | static inline int acpi_pm_device_sleep_state(struct device *d, int *p, int m) | ||
502 | { | ||
503 | return __acpi_device_power_state(m, p); | ||
504 | } | ||
505 | static inline void acpi_dev_pm_add_dependent(acpi_handle handle, | 484 | static inline void acpi_dev_pm_add_dependent(acpi_handle handle, |
506 | struct device *depdev) {} | 485 | struct device *depdev) {} |
507 | static inline void acpi_dev_pm_remove_dependent(acpi_handle handle, | 486 | static inline void acpi_dev_pm_remove_dependent(acpi_handle handle, |
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h index 454881e6450a..1b09300810e6 100644 --- a/include/acpi/acpixf.h +++ b/include/acpi/acpixf.h | |||
@@ -46,7 +46,7 @@ | |||
46 | 46 | ||
47 | /* Current ACPICA subsystem version in YYYYMMDD format */ | 47 | /* Current ACPICA subsystem version in YYYYMMDD format */ |
48 | 48 | ||
49 | #define ACPI_CA_VERSION 0x20130328 | 49 | #define ACPI_CA_VERSION 0x20130517 |
50 | 50 | ||
51 | #include <acpi/acconfig.h> | 51 | #include <acpi/acconfig.h> |
52 | #include <acpi/actypes.h> | 52 | #include <acpi/actypes.h> |
@@ -80,6 +80,7 @@ extern bool acpi_gbl_enable_aml_debug_object; | |||
80 | extern u8 acpi_gbl_copy_dsdt_locally; | 80 | extern u8 acpi_gbl_copy_dsdt_locally; |
81 | extern u8 acpi_gbl_truncate_io_addresses; | 81 | extern u8 acpi_gbl_truncate_io_addresses; |
82 | extern u8 acpi_gbl_disable_auto_repair; | 82 | extern u8 acpi_gbl_disable_auto_repair; |
83 | extern u8 acpi_gbl_disable_ssdt_table_load; | ||
83 | 84 | ||
84 | /* | 85 | /* |
85 | * Hardware-reduced prototypes. All interfaces that use these macros will | 86 | * Hardware-reduced prototypes. All interfaces that use these macros will |
diff --git a/include/acpi/processor.h b/include/acpi/processor.h index ea69367fdd3b..66096d06925e 100644 --- a/include/acpi/processor.h +++ b/include/acpi/processor.h | |||
@@ -6,6 +6,10 @@ | |||
6 | #include <linux/thermal.h> | 6 | #include <linux/thermal.h> |
7 | #include <asm/acpi.h> | 7 | #include <asm/acpi.h> |
8 | 8 | ||
9 | #define ACPI_PROCESSOR_CLASS "processor" | ||
10 | #define ACPI_PROCESSOR_DEVICE_NAME "Processor" | ||
11 | #define ACPI_PROCESSOR_DEVICE_HID "ACPI0007" | ||
12 | |||
9 | #define ACPI_PROCESSOR_BUSY_METRIC 10 | 13 | #define ACPI_PROCESSOR_BUSY_METRIC 10 |
10 | 14 | ||
11 | #define ACPI_PROCESSOR_MAX_POWER 8 | 15 | #define ACPI_PROCESSOR_MAX_POWER 8 |
@@ -207,6 +211,7 @@ struct acpi_processor { | |||
207 | struct acpi_processor_throttling throttling; | 211 | struct acpi_processor_throttling throttling; |
208 | struct acpi_processor_limit limit; | 212 | struct acpi_processor_limit limit; |
209 | struct thermal_cooling_device *cdev; | 213 | struct thermal_cooling_device *cdev; |
214 | struct device *dev; /* Processor device. */ | ||
210 | }; | 215 | }; |
211 | 216 | ||
212 | struct acpi_processor_errata { | 217 | struct acpi_processor_errata { |
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 17b5b5967641..353ba256f368 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
@@ -352,8 +352,7 @@ extern acpi_status acpi_pci_osc_control_set(acpi_handle handle, | |||
352 | 352 | ||
353 | /* Enable _OST when all relevant hotplug operations are enabled */ | 353 | /* Enable _OST when all relevant hotplug operations are enabled */ |
354 | #if defined(CONFIG_ACPI_HOTPLUG_CPU) && \ | 354 | #if defined(CONFIG_ACPI_HOTPLUG_CPU) && \ |
355 | (defined(CONFIG_ACPI_HOTPLUG_MEMORY) || \ | 355 | defined(CONFIG_ACPI_HOTPLUG_MEMORY) && \ |
356 | defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE)) && \ | ||
357 | defined(CONFIG_ACPI_CONTAINER) | 356 | defined(CONFIG_ACPI_CONTAINER) |
358 | #define ACPI_HOTPLUG_OST | 357 | #define ACPI_HOTPLUG_OST |
359 | #endif | 358 | #endif |
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 037d36ae63e5..4d7390bc1727 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h | |||
@@ -1,8 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * linux/include/linux/cpufreq.h | 2 | * linux/include/linux/cpufreq.h |
3 | * | 3 | * |
4 | * Copyright (C) 2001 Russell King | 4 | * Copyright (C) 2001 Russell King |
5 | * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> | 5 | * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License version 2 as | 8 | * it under the terms of the GNU General Public License version 2 as |
@@ -26,7 +26,6 @@ | |||
26 | /* Print length for names. Extra 1 space for accomodating '\n' in prints */ | 26 | /* Print length for names. Extra 1 space for accomodating '\n' in prints */ |
27 | #define CPUFREQ_NAME_PLEN (CPUFREQ_NAME_LEN + 1) | 27 | #define CPUFREQ_NAME_PLEN (CPUFREQ_NAME_LEN + 1) |
28 | 28 | ||
29 | |||
30 | /********************************************************************* | 29 | /********************************************************************* |
31 | * CPUFREQ NOTIFIER INTERFACE * | 30 | * CPUFREQ NOTIFIER INTERFACE * |
32 | *********************************************************************/ | 31 | *********************************************************************/ |
@@ -71,6 +70,10 @@ struct cpufreq_governor; | |||
71 | 70 | ||
72 | /* /sys/devices/system/cpu/cpufreq: entry point for global variables */ | 71 | /* /sys/devices/system/cpu/cpufreq: entry point for global variables */ |
73 | extern struct kobject *cpufreq_global_kobject; | 72 | extern struct kobject *cpufreq_global_kobject; |
73 | int cpufreq_get_global_kobject(void); | ||
74 | void cpufreq_put_global_kobject(void); | ||
75 | int cpufreq_sysfs_create_file(const struct attribute *attr); | ||
76 | void cpufreq_sysfs_remove_file(const struct attribute *attr); | ||
74 | 77 | ||
75 | #define CPUFREQ_ETERNAL (-1) | 78 | #define CPUFREQ_ETERNAL (-1) |
76 | struct cpufreq_cpuinfo { | 79 | struct cpufreq_cpuinfo { |
@@ -107,6 +110,7 @@ struct cpufreq_policy { | |||
107 | unsigned int policy; /* see above */ | 110 | unsigned int policy; /* see above */ |
108 | struct cpufreq_governor *governor; /* see below */ | 111 | struct cpufreq_governor *governor; /* see below */ |
109 | void *governor_data; | 112 | void *governor_data; |
113 | bool governor_enabled; /* governor start/stop flag */ | ||
110 | 114 | ||
111 | struct work_struct update; /* if update_policy() needs to be | 115 | struct work_struct update; /* if update_policy() needs to be |
112 | * called, but you're in IRQ context */ | 116 | * called, but you're in IRQ context */ |
@@ -115,6 +119,7 @@ struct cpufreq_policy { | |||
115 | 119 | ||
116 | struct kobject kobj; | 120 | struct kobject kobj; |
117 | struct completion kobj_unregister; | 121 | struct completion kobj_unregister; |
122 | bool transition_ongoing; /* Tracks transition status */ | ||
118 | }; | 123 | }; |
119 | 124 | ||
120 | #define CPUFREQ_ADJUST (0) | 125 | #define CPUFREQ_ADJUST (0) |
@@ -148,17 +153,18 @@ struct cpufreq_freqs { | |||
148 | u8 flags; /* flags of cpufreq_driver, see below. */ | 153 | u8 flags; /* flags of cpufreq_driver, see below. */ |
149 | }; | 154 | }; |
150 | 155 | ||
151 | |||
152 | /** | 156 | /** |
153 | * cpufreq_scale - "old * mult / div" calculation for large values (32-bit-arch safe) | 157 | * cpufreq_scale - "old * mult / div" calculation for large values (32-bit-arch |
158 | * safe) | ||
154 | * @old: old value | 159 | * @old: old value |
155 | * @div: divisor | 160 | * @div: divisor |
156 | * @mult: multiplier | 161 | * @mult: multiplier |
157 | * | 162 | * |
158 | * | 163 | * |
159 | * new = old * mult / div | 164 | * new = old * mult / div |
160 | */ | 165 | */ |
161 | static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mult) | 166 | static inline unsigned long cpufreq_scale(unsigned long old, u_int div, |
167 | u_int mult) | ||
162 | { | 168 | { |
163 | #if BITS_PER_LONG == 32 | 169 | #if BITS_PER_LONG == 32 |
164 | 170 | ||
@@ -211,14 +217,12 @@ extern int __cpufreq_driver_target(struct cpufreq_policy *policy, | |||
211 | unsigned int target_freq, | 217 | unsigned int target_freq, |
212 | unsigned int relation); | 218 | unsigned int relation); |
213 | 219 | ||
214 | |||
215 | extern int __cpufreq_driver_getavg(struct cpufreq_policy *policy, | 220 | extern int __cpufreq_driver_getavg(struct cpufreq_policy *policy, |
216 | unsigned int cpu); | 221 | unsigned int cpu); |
217 | 222 | ||
218 | int cpufreq_register_governor(struct cpufreq_governor *governor); | 223 | int cpufreq_register_governor(struct cpufreq_governor *governor); |
219 | void cpufreq_unregister_governor(struct cpufreq_governor *governor); | 224 | void cpufreq_unregister_governor(struct cpufreq_governor *governor); |
220 | 225 | ||
221 | |||
222 | /********************************************************************* | 226 | /********************************************************************* |
223 | * CPUFREQ DRIVER INTERFACE * | 227 | * CPUFREQ DRIVER INTERFACE * |
224 | *********************************************************************/ | 228 | *********************************************************************/ |
@@ -229,7 +233,7 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor); | |||
229 | struct freq_attr; | 233 | struct freq_attr; |
230 | 234 | ||
231 | struct cpufreq_driver { | 235 | struct cpufreq_driver { |
232 | struct module *owner; | 236 | struct module *owner; |
233 | char name[CPUFREQ_NAME_LEN]; | 237 | char name[CPUFREQ_NAME_LEN]; |
234 | u8 flags; | 238 | u8 flags; |
235 | /* | 239 | /* |
@@ -277,11 +281,11 @@ struct cpufreq_driver { | |||
277 | int cpufreq_register_driver(struct cpufreq_driver *driver_data); | 281 | int cpufreq_register_driver(struct cpufreq_driver *driver_data); |
278 | int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); | 282 | int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); |
279 | 283 | ||
280 | |||
281 | void cpufreq_notify_transition(struct cpufreq_policy *policy, | 284 | void cpufreq_notify_transition(struct cpufreq_policy *policy, |
282 | struct cpufreq_freqs *freqs, unsigned int state); | 285 | struct cpufreq_freqs *freqs, unsigned int state); |
283 | 286 | ||
284 | static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned int min, unsigned int max) | 287 | static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, |
288 | unsigned int min, unsigned int max) | ||
285 | { | 289 | { |
286 | if (policy->min < min) | 290 | if (policy->min < min) |
287 | policy->min = min; | 291 | policy->min = min; |
@@ -337,12 +341,16 @@ const char *cpufreq_get_current_driver(void); | |||
337 | /********************************************************************* | 341 | /********************************************************************* |
338 | * CPUFREQ 2.6. INTERFACE * | 342 | * CPUFREQ 2.6. INTERFACE * |
339 | *********************************************************************/ | 343 | *********************************************************************/ |
344 | u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy); | ||
340 | int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); | 345 | int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); |
341 | int cpufreq_update_policy(unsigned int cpu); | 346 | int cpufreq_update_policy(unsigned int cpu); |
342 | bool have_governor_per_policy(void); | 347 | bool have_governor_per_policy(void); |
348 | struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy); | ||
343 | 349 | ||
344 | #ifdef CONFIG_CPU_FREQ | 350 | #ifdef CONFIG_CPU_FREQ |
345 | /* query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it */ | 351 | /* |
352 | * query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it | ||
353 | */ | ||
346 | unsigned int cpufreq_get(unsigned int cpu); | 354 | unsigned int cpufreq_get(unsigned int cpu); |
347 | #else | 355 | #else |
348 | static inline unsigned int cpufreq_get(unsigned int cpu) | 356 | static inline unsigned int cpufreq_get(unsigned int cpu) |
@@ -351,7 +359,9 @@ static inline unsigned int cpufreq_get(unsigned int cpu) | |||
351 | } | 359 | } |
352 | #endif | 360 | #endif |
353 | 361 | ||
354 | /* query the last known CPU freq (in kHz). If zero, cpufreq couldn't detect it */ | 362 | /* |
363 | * query the last known CPU freq (in kHz). If zero, cpufreq couldn't detect it | ||
364 | */ | ||
355 | #ifdef CONFIG_CPU_FREQ | 365 | #ifdef CONFIG_CPU_FREQ |
356 | unsigned int cpufreq_quick_get(unsigned int cpu); | 366 | unsigned int cpufreq_quick_get(unsigned int cpu); |
357 | unsigned int cpufreq_quick_get_max(unsigned int cpu); | 367 | unsigned int cpufreq_quick_get_max(unsigned int cpu); |
@@ -366,16 +376,14 @@ static inline unsigned int cpufreq_quick_get_max(unsigned int cpu) | |||
366 | } | 376 | } |
367 | #endif | 377 | #endif |
368 | 378 | ||
369 | |||
370 | /********************************************************************* | 379 | /********************************************************************* |
371 | * CPUFREQ DEFAULT GOVERNOR * | 380 | * CPUFREQ DEFAULT GOVERNOR * |
372 | *********************************************************************/ | 381 | *********************************************************************/ |
373 | 382 | ||
374 | |||
375 | /* | 383 | /* |
376 | Performance governor is fallback governor if any other gov failed to | 384 | * Performance governor is fallback governor if any other gov failed to auto |
377 | auto load due latency restrictions | 385 | * load due latency restrictions |
378 | */ | 386 | */ |
379 | #ifdef CONFIG_CPU_FREQ_GOV_PERFORMANCE | 387 | #ifdef CONFIG_CPU_FREQ_GOV_PERFORMANCE |
380 | extern struct cpufreq_governor cpufreq_gov_performance; | 388 | extern struct cpufreq_governor cpufreq_gov_performance; |
381 | #endif | 389 | #endif |
@@ -395,7 +403,6 @@ extern struct cpufreq_governor cpufreq_gov_conservative; | |||
395 | #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_conservative) | 403 | #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_conservative) |
396 | #endif | 404 | #endif |
397 | 405 | ||
398 | |||
399 | /********************************************************************* | 406 | /********************************************************************* |
400 | * FREQUENCY TABLE HELPERS * | 407 | * FREQUENCY TABLE HELPERS * |
401 | *********************************************************************/ | 408 | *********************************************************************/ |
@@ -404,7 +411,7 @@ extern struct cpufreq_governor cpufreq_gov_conservative; | |||
404 | #define CPUFREQ_TABLE_END ~1 | 411 | #define CPUFREQ_TABLE_END ~1 |
405 | 412 | ||
406 | struct cpufreq_frequency_table { | 413 | struct cpufreq_frequency_table { |
407 | unsigned int index; /* any */ | 414 | unsigned int driver_data; /* driver specific data, not used by core */ |
408 | unsigned int frequency; /* kHz - doesn't need to be in ascending | 415 | unsigned int frequency; /* kHz - doesn't need to be in ascending |
409 | * order */ | 416 | * order */ |
410 | }; | 417 | }; |
@@ -432,4 +439,7 @@ void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table, | |||
432 | void cpufreq_frequency_table_update_policy_cpu(struct cpufreq_policy *policy); | 439 | void cpufreq_frequency_table_update_policy_cpu(struct cpufreq_policy *policy); |
433 | 440 | ||
434 | void cpufreq_frequency_table_put_attr(unsigned int cpu); | 441 | void cpufreq_frequency_table_put_attr(unsigned int cpu); |
442 | |||
443 | ssize_t cpufreq_show_cpus(const struct cpumask *mask, char *buf); | ||
444 | |||
435 | #endif /* _LINUX_CPUFREQ_H */ | 445 | #endif /* _LINUX_CPUFREQ_H */ |
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 8f0406230a0a..0bc4b74668e9 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h | |||
@@ -111,6 +111,9 @@ struct cpuidle_driver { | |||
111 | struct cpuidle_state states[CPUIDLE_STATE_MAX]; | 111 | struct cpuidle_state states[CPUIDLE_STATE_MAX]; |
112 | int state_count; | 112 | int state_count; |
113 | int safe_state_index; | 113 | int safe_state_index; |
114 | |||
115 | /* the driver handles the cpus in cpumask */ | ||
116 | struct cpumask *cpumask; | ||
114 | }; | 117 | }; |
115 | 118 | ||
116 | #ifdef CONFIG_CPU_IDLE | 119 | #ifdef CONFIG_CPU_IDLE |
@@ -135,9 +138,6 @@ extern void cpuidle_disable_device(struct cpuidle_device *dev); | |||
135 | extern int cpuidle_play_dead(void); | 138 | extern int cpuidle_play_dead(void); |
136 | 139 | ||
137 | extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev); | 140 | extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev); |
138 | extern int cpuidle_register_cpu_driver(struct cpuidle_driver *drv, int cpu); | ||
139 | extern void cpuidle_unregister_cpu_driver(struct cpuidle_driver *drv, int cpu); | ||
140 | |||
141 | #else | 141 | #else |
142 | static inline void disable_cpuidle(void) { } | 142 | static inline void disable_cpuidle(void) { } |
143 | static inline int cpuidle_idle_call(void) { return -ENODEV; } | 143 | static inline int cpuidle_idle_call(void) { return -ENODEV; } |
diff --git a/include/linux/debug_locks.h b/include/linux/debug_locks.h index 21ca773f77bf..822c1354f3a6 100644 --- a/include/linux/debug_locks.h +++ b/include/linux/debug_locks.h | |||
@@ -51,7 +51,7 @@ struct task_struct; | |||
51 | extern void debug_show_all_locks(void); | 51 | extern void debug_show_all_locks(void); |
52 | extern void debug_show_held_locks(struct task_struct *task); | 52 | extern void debug_show_held_locks(struct task_struct *task); |
53 | extern void debug_check_no_locks_freed(const void *from, unsigned long len); | 53 | extern void debug_check_no_locks_freed(const void *from, unsigned long len); |
54 | extern void debug_check_no_locks_held(struct task_struct *task); | 54 | extern void debug_check_no_locks_held(void); |
55 | #else | 55 | #else |
56 | static inline void debug_show_all_locks(void) | 56 | static inline void debug_show_all_locks(void) |
57 | { | 57 | { |
@@ -67,7 +67,7 @@ debug_check_no_locks_freed(const void *from, unsigned long len) | |||
67 | } | 67 | } |
68 | 68 | ||
69 | static inline void | 69 | static inline void |
70 | debug_check_no_locks_held(struct task_struct *task) | 70 | debug_check_no_locks_held(void) |
71 | { | 71 | { |
72 | } | 72 | } |
73 | #endif | 73 | #endif |
diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index fe8c4476f7e4..5f1ab92107e6 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h | |||
@@ -181,6 +181,8 @@ extern struct devfreq *devfreq_add_device(struct device *dev, | |||
181 | const char *governor_name, | 181 | const char *governor_name, |
182 | void *data); | 182 | void *data); |
183 | extern int devfreq_remove_device(struct devfreq *devfreq); | 183 | extern int devfreq_remove_device(struct devfreq *devfreq); |
184 | |||
185 | /* Supposed to be called by PM_SLEEP/PM_RUNTIME callbacks */ | ||
184 | extern int devfreq_suspend_device(struct devfreq *devfreq); | 186 | extern int devfreq_suspend_device(struct devfreq *devfreq); |
185 | extern int devfreq_resume_device(struct devfreq *devfreq); | 187 | extern int devfreq_resume_device(struct devfreq *devfreq); |
186 | 188 | ||
diff --git a/include/linux/device.h b/include/linux/device.h index 9d4835a8f8b8..bcf8c0d4cd98 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -71,6 +71,10 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *); | |||
71 | * the specific driver's probe to initial the matched device. | 71 | * the specific driver's probe to initial the matched device. |
72 | * @remove: Called when a device removed from this bus. | 72 | * @remove: Called when a device removed from this bus. |
73 | * @shutdown: Called at shut-down time to quiesce the device. | 73 | * @shutdown: Called at shut-down time to quiesce the device. |
74 | * | ||
75 | * @online: Called to put the device back online (after offlining it). | ||
76 | * @offline: Called to put the device offline for hot-removal. May fail. | ||
77 | * | ||
74 | * @suspend: Called when a device on this bus wants to go to sleep mode. | 78 | * @suspend: Called when a device on this bus wants to go to sleep mode. |
75 | * @resume: Called to bring a device on this bus out of sleep mode. | 79 | * @resume: Called to bring a device on this bus out of sleep mode. |
76 | * @pm: Power management operations of this bus, callback the specific | 80 | * @pm: Power management operations of this bus, callback the specific |
@@ -105,6 +109,9 @@ struct bus_type { | |||
105 | int (*remove)(struct device *dev); | 109 | int (*remove)(struct device *dev); |
106 | void (*shutdown)(struct device *dev); | 110 | void (*shutdown)(struct device *dev); |
107 | 111 | ||
112 | int (*online)(struct device *dev); | ||
113 | int (*offline)(struct device *dev); | ||
114 | |||
108 | int (*suspend)(struct device *dev, pm_message_t state); | 115 | int (*suspend)(struct device *dev, pm_message_t state); |
109 | int (*resume)(struct device *dev); | 116 | int (*resume)(struct device *dev); |
110 | 117 | ||
@@ -652,6 +659,9 @@ struct acpi_dev_node { | |||
652 | * device (i.e. the bus driver that discovered the device). | 659 | * device (i.e. the bus driver that discovered the device). |
653 | * @iommu_group: IOMMU group the device belongs to. | 660 | * @iommu_group: IOMMU group the device belongs to. |
654 | * | 661 | * |
662 | * @offline_disabled: If set, the device is permanently online. | ||
663 | * @offline: Set after successful invocation of bus type's .offline(). | ||
664 | * | ||
655 | * At the lowest level, every device in a Linux system is represented by an | 665 | * At the lowest level, every device in a Linux system is represented by an |
656 | * instance of struct device. The device structure contains the information | 666 | * instance of struct device. The device structure contains the information |
657 | * that the device model core needs to model the system. Most subsystems, | 667 | * that the device model core needs to model the system. Most subsystems, |
@@ -723,6 +733,9 @@ struct device { | |||
723 | 733 | ||
724 | void (*release)(struct device *dev); | 734 | void (*release)(struct device *dev); |
725 | struct iommu_group *iommu_group; | 735 | struct iommu_group *iommu_group; |
736 | |||
737 | bool offline_disabled:1; | ||
738 | bool offline:1; | ||
726 | }; | 739 | }; |
727 | 740 | ||
728 | static inline struct device *kobj_to_dev(struct kobject *kobj) | 741 | static inline struct device *kobj_to_dev(struct kobject *kobj) |
@@ -859,6 +872,15 @@ extern const char *device_get_devnode(struct device *dev, | |||
859 | extern void *dev_get_drvdata(const struct device *dev); | 872 | extern void *dev_get_drvdata(const struct device *dev); |
860 | extern int dev_set_drvdata(struct device *dev, void *data); | 873 | extern int dev_set_drvdata(struct device *dev, void *data); |
861 | 874 | ||
875 | static inline bool device_supports_offline(struct device *dev) | ||
876 | { | ||
877 | return dev->bus && dev->bus->offline && dev->bus->online; | ||
878 | } | ||
879 | |||
880 | extern void lock_device_hotplug(void); | ||
881 | extern void unlock_device_hotplug(void); | ||
882 | extern int device_offline(struct device *dev); | ||
883 | extern int device_online(struct device *dev); | ||
862 | /* | 884 | /* |
863 | * Root device objects for grouping under /sys/devices | 885 | * Root device objects for grouping under /sys/devices |
864 | */ | 886 | */ |
diff --git a/include/linux/freezer.h b/include/linux/freezer.h index e70df40d84f6..7fd81b8c4897 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h | |||
@@ -3,6 +3,7 @@ | |||
3 | #ifndef FREEZER_H_INCLUDED | 3 | #ifndef FREEZER_H_INCLUDED |
4 | #define FREEZER_H_INCLUDED | 4 | #define FREEZER_H_INCLUDED |
5 | 5 | ||
6 | #include <linux/debug_locks.h> | ||
6 | #include <linux/sched.h> | 7 | #include <linux/sched.h> |
7 | #include <linux/wait.h> | 8 | #include <linux/wait.h> |
8 | #include <linux/atomic.h> | 9 | #include <linux/atomic.h> |
@@ -46,7 +47,11 @@ extern int freeze_kernel_threads(void); | |||
46 | extern void thaw_processes(void); | 47 | extern void thaw_processes(void); |
47 | extern void thaw_kernel_threads(void); | 48 | extern void thaw_kernel_threads(void); |
48 | 49 | ||
49 | static inline bool try_to_freeze(void) | 50 | /* |
51 | * DO NOT ADD ANY NEW CALLERS OF THIS FUNCTION | ||
52 | * If try_to_freeze causes a lockdep warning it means the caller may deadlock | ||
53 | */ | ||
54 | static inline bool try_to_freeze_unsafe(void) | ||
50 | { | 55 | { |
51 | might_sleep(); | 56 | might_sleep(); |
52 | if (likely(!freezing(current))) | 57 | if (likely(!freezing(current))) |
@@ -54,6 +59,13 @@ static inline bool try_to_freeze(void) | |||
54 | return __refrigerator(false); | 59 | return __refrigerator(false); |
55 | } | 60 | } |
56 | 61 | ||
62 | static inline bool try_to_freeze(void) | ||
63 | { | ||
64 | if (!(current->flags & PF_NOFREEZE)) | ||
65 | debug_check_no_locks_held(); | ||
66 | return try_to_freeze_unsafe(); | ||
67 | } | ||
68 | |||
57 | extern bool freeze_task(struct task_struct *p); | 69 | extern bool freeze_task(struct task_struct *p); |
58 | extern bool set_freezable(void); | 70 | extern bool set_freezable(void); |
59 | 71 | ||
@@ -115,6 +127,14 @@ static inline void freezer_count(void) | |||
115 | try_to_freeze(); | 127 | try_to_freeze(); |
116 | } | 128 | } |
117 | 129 | ||
130 | /* DO NOT ADD ANY NEW CALLERS OF THIS FUNCTION */ | ||
131 | static inline void freezer_count_unsafe(void) | ||
132 | { | ||
133 | current->flags &= ~PF_FREEZER_SKIP; | ||
134 | smp_mb(); | ||
135 | try_to_freeze_unsafe(); | ||
136 | } | ||
137 | |||
118 | /** | 138 | /** |
119 | * freezer_should_skip - whether to skip a task when determining frozen | 139 | * freezer_should_skip - whether to skip a task when determining frozen |
120 | * state is reached | 140 | * state is reached |
@@ -139,28 +159,86 @@ static inline bool freezer_should_skip(struct task_struct *p) | |||
139 | } | 159 | } |
140 | 160 | ||
141 | /* | 161 | /* |
142 | * These macros are intended to be used whenever you want allow a sleeping | 162 | * These functions are intended to be used whenever you want allow a sleeping |
143 | * task to be frozen. Note that neither return any clear indication of | 163 | * task to be frozen. Note that neither return any clear indication of |
144 | * whether a freeze event happened while in this function. | 164 | * whether a freeze event happened while in this function. |
145 | */ | 165 | */ |
146 | 166 | ||
147 | /* Like schedule(), but should not block the freezer. */ | 167 | /* Like schedule(), but should not block the freezer. */ |
148 | #define freezable_schedule() \ | 168 | static inline void freezable_schedule(void) |
149 | ({ \ | 169 | { |
150 | freezer_do_not_count(); \ | 170 | freezer_do_not_count(); |
151 | schedule(); \ | 171 | schedule(); |
152 | freezer_count(); \ | 172 | freezer_count(); |
153 | }) | 173 | } |
174 | |||
175 | /* DO NOT ADD ANY NEW CALLERS OF THIS FUNCTION */ | ||
176 | static inline void freezable_schedule_unsafe(void) | ||
177 | { | ||
178 | freezer_do_not_count(); | ||
179 | schedule(); | ||
180 | freezer_count_unsafe(); | ||
181 | } | ||
182 | |||
183 | /* | ||
184 | * Like freezable_schedule_timeout(), but should not block the freezer. Do not | ||
185 | * call this with locks held. | ||
186 | */ | ||
187 | static inline long freezable_schedule_timeout(long timeout) | ||
188 | { | ||
189 | long __retval; | ||
190 | freezer_do_not_count(); | ||
191 | __retval = schedule_timeout(timeout); | ||
192 | freezer_count(); | ||
193 | return __retval; | ||
194 | } | ||
195 | |||
196 | /* | ||
197 | * Like schedule_timeout_interruptible(), but should not block the freezer. Do not | ||
198 | * call this with locks held. | ||
199 | */ | ||
200 | static inline long freezable_schedule_timeout_interruptible(long timeout) | ||
201 | { | ||
202 | long __retval; | ||
203 | freezer_do_not_count(); | ||
204 | __retval = schedule_timeout_interruptible(timeout); | ||
205 | freezer_count(); | ||
206 | return __retval; | ||
207 | } | ||
154 | 208 | ||
155 | /* Like schedule_timeout_killable(), but should not block the freezer. */ | 209 | /* Like schedule_timeout_killable(), but should not block the freezer. */ |
156 | #define freezable_schedule_timeout_killable(timeout) \ | 210 | static inline long freezable_schedule_timeout_killable(long timeout) |
157 | ({ \ | 211 | { |
158 | long __retval; \ | 212 | long __retval; |
159 | freezer_do_not_count(); \ | 213 | freezer_do_not_count(); |
160 | __retval = schedule_timeout_killable(timeout); \ | 214 | __retval = schedule_timeout_killable(timeout); |
161 | freezer_count(); \ | 215 | freezer_count(); |
162 | __retval; \ | 216 | return __retval; |
163 | }) | 217 | } |
218 | |||
219 | /* DO NOT ADD ANY NEW CALLERS OF THIS FUNCTION */ | ||
220 | static inline long freezable_schedule_timeout_killable_unsafe(long timeout) | ||
221 | { | ||
222 | long __retval; | ||
223 | freezer_do_not_count(); | ||
224 | __retval = schedule_timeout_killable(timeout); | ||
225 | freezer_count_unsafe(); | ||
226 | return __retval; | ||
227 | } | ||
228 | |||
229 | /* | ||
230 | * Like schedule_hrtimeout_range(), but should not block the freezer. Do not | ||
231 | * call this with locks held. | ||
232 | */ | ||
233 | static inline int freezable_schedule_hrtimeout_range(ktime_t *expires, | ||
234 | unsigned long delta, const enum hrtimer_mode mode) | ||
235 | { | ||
236 | int __retval; | ||
237 | freezer_do_not_count(); | ||
238 | __retval = schedule_hrtimeout_range(expires, delta, mode); | ||
239 | freezer_count(); | ||
240 | return __retval; | ||
241 | } | ||
164 | 242 | ||
165 | /* | 243 | /* |
166 | * Freezer-friendly wrappers around wait_event_interruptible(), | 244 | * Freezer-friendly wrappers around wait_event_interruptible(), |
@@ -177,33 +255,45 @@ static inline bool freezer_should_skip(struct task_struct *p) | |||
177 | __retval; \ | 255 | __retval; \ |
178 | }) | 256 | }) |
179 | 257 | ||
258 | /* DO NOT ADD ANY NEW CALLERS OF THIS FUNCTION */ | ||
259 | #define wait_event_freezekillable_unsafe(wq, condition) \ | ||
260 | ({ \ | ||
261 | int __retval; \ | ||
262 | freezer_do_not_count(); \ | ||
263 | __retval = wait_event_killable(wq, (condition)); \ | ||
264 | freezer_count_unsafe(); \ | ||
265 | __retval; \ | ||
266 | }) | ||
267 | |||
180 | #define wait_event_freezable(wq, condition) \ | 268 | #define wait_event_freezable(wq, condition) \ |
181 | ({ \ | 269 | ({ \ |
182 | int __retval; \ | 270 | int __retval; \ |
183 | for (;;) { \ | 271 | freezer_do_not_count(); \ |
184 | __retval = wait_event_interruptible(wq, \ | 272 | __retval = wait_event_interruptible(wq, (condition)); \ |
185 | (condition) || freezing(current)); \ | 273 | freezer_count(); \ |
186 | if (__retval || (condition)) \ | ||
187 | break; \ | ||
188 | try_to_freeze(); \ | ||
189 | } \ | ||
190 | __retval; \ | 274 | __retval; \ |
191 | }) | 275 | }) |
192 | 276 | ||
193 | #define wait_event_freezable_timeout(wq, condition, timeout) \ | 277 | #define wait_event_freezable_timeout(wq, condition, timeout) \ |
194 | ({ \ | 278 | ({ \ |
195 | long __retval = timeout; \ | 279 | long __retval = timeout; \ |
196 | for (;;) { \ | 280 | freezer_do_not_count(); \ |
197 | __retval = wait_event_interruptible_timeout(wq, \ | 281 | __retval = wait_event_interruptible_timeout(wq, (condition), \ |
198 | (condition) || freezing(current), \ | 282 | __retval); \ |
199 | __retval); \ | 283 | freezer_count(); \ |
200 | if (__retval <= 0 || (condition)) \ | ||
201 | break; \ | ||
202 | try_to_freeze(); \ | ||
203 | } \ | ||
204 | __retval; \ | 284 | __retval; \ |
205 | }) | 285 | }) |
206 | 286 | ||
287 | #define wait_event_freezable_exclusive(wq, condition) \ | ||
288 | ({ \ | ||
289 | int __retval; \ | ||
290 | freezer_do_not_count(); \ | ||
291 | __retval = wait_event_interruptible_exclusive(wq, condition); \ | ||
292 | freezer_count(); \ | ||
293 | __retval; \ | ||
294 | }) | ||
295 | |||
296 | |||
207 | #else /* !CONFIG_FREEZER */ | 297 | #else /* !CONFIG_FREEZER */ |
208 | static inline bool frozen(struct task_struct *p) { return false; } | 298 | static inline bool frozen(struct task_struct *p) { return false; } |
209 | static inline bool freezing(struct task_struct *p) { return false; } | 299 | static inline bool freezing(struct task_struct *p) { return false; } |
@@ -225,18 +315,37 @@ static inline void set_freezable(void) {} | |||
225 | 315 | ||
226 | #define freezable_schedule() schedule() | 316 | #define freezable_schedule() schedule() |
227 | 317 | ||
318 | #define freezable_schedule_unsafe() schedule() | ||
319 | |||
320 | #define freezable_schedule_timeout(timeout) schedule_timeout(timeout) | ||
321 | |||
322 | #define freezable_schedule_timeout_interruptible(timeout) \ | ||
323 | schedule_timeout_interruptible(timeout) | ||
324 | |||
228 | #define freezable_schedule_timeout_killable(timeout) \ | 325 | #define freezable_schedule_timeout_killable(timeout) \ |
229 | schedule_timeout_killable(timeout) | 326 | schedule_timeout_killable(timeout) |
230 | 327 | ||
328 | #define freezable_schedule_timeout_killable_unsafe(timeout) \ | ||
329 | schedule_timeout_killable(timeout) | ||
330 | |||
331 | #define freezable_schedule_hrtimeout_range(expires, delta, mode) \ | ||
332 | schedule_hrtimeout_range(expires, delta, mode) | ||
333 | |||
231 | #define wait_event_freezable(wq, condition) \ | 334 | #define wait_event_freezable(wq, condition) \ |
232 | wait_event_interruptible(wq, condition) | 335 | wait_event_interruptible(wq, condition) |
233 | 336 | ||
234 | #define wait_event_freezable_timeout(wq, condition, timeout) \ | 337 | #define wait_event_freezable_timeout(wq, condition, timeout) \ |
235 | wait_event_interruptible_timeout(wq, condition, timeout) | 338 | wait_event_interruptible_timeout(wq, condition, timeout) |
236 | 339 | ||
340 | #define wait_event_freezable_exclusive(wq, condition) \ | ||
341 | wait_event_interruptible_exclusive(wq, condition) | ||
342 | |||
237 | #define wait_event_freezekillable(wq, condition) \ | 343 | #define wait_event_freezekillable(wq, condition) \ |
238 | wait_event_killable(wq, condition) | 344 | wait_event_killable(wq, condition) |
239 | 345 | ||
346 | #define wait_event_freezekillable_unsafe(wq, condition) \ | ||
347 | wait_event_killable(wq, condition) | ||
348 | |||
240 | #endif /* !CONFIG_FREEZER */ | 349 | #endif /* !CONFIG_FREEZER */ |
241 | 350 | ||
242 | #endif /* FREEZER_H_INCLUDED */ | 351 | #endif /* FREEZER_H_INCLUDED */ |
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 3e622c610925..dd38e62b84d2 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h | |||
@@ -234,6 +234,8 @@ static inline void unlock_memory_hotplug(void) {} | |||
234 | 234 | ||
235 | extern int is_mem_section_removable(unsigned long pfn, unsigned long nr_pages); | 235 | extern int is_mem_section_removable(unsigned long pfn, unsigned long nr_pages); |
236 | extern void try_offline_node(int nid); | 236 | extern void try_offline_node(int nid); |
237 | extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages); | ||
238 | extern void remove_memory(int nid, u64 start, u64 size); | ||
237 | 239 | ||
238 | #else | 240 | #else |
239 | static inline int is_mem_section_removable(unsigned long pfn, | 241 | static inline int is_mem_section_removable(unsigned long pfn, |
@@ -243,15 +245,23 @@ static inline int is_mem_section_removable(unsigned long pfn, | |||
243 | } | 245 | } |
244 | 246 | ||
245 | static inline void try_offline_node(int nid) {} | 247 | static inline void try_offline_node(int nid) {} |
248 | |||
249 | static inline int offline_pages(unsigned long start_pfn, unsigned long nr_pages) | ||
250 | { | ||
251 | return -EINVAL; | ||
252 | } | ||
253 | |||
254 | static inline void remove_memory(int nid, u64 start, u64 size) {} | ||
246 | #endif /* CONFIG_MEMORY_HOTREMOVE */ | 255 | #endif /* CONFIG_MEMORY_HOTREMOVE */ |
247 | 256 | ||
257 | extern int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn, | ||
258 | void *arg, int (*func)(struct memory_block *, void *)); | ||
248 | extern int mem_online_node(int nid); | 259 | extern int mem_online_node(int nid); |
249 | extern int add_memory(int nid, u64 start, u64 size); | 260 | extern int add_memory(int nid, u64 start, u64 size); |
250 | extern int arch_add_memory(int nid, u64 start, u64 size); | 261 | extern int arch_add_memory(int nid, u64 start, u64 size); |
251 | extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages); | 262 | extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages); |
252 | extern int offline_memory_block(struct memory_block *mem); | ||
253 | extern bool is_memblock_offlined(struct memory_block *mem); | 263 | extern bool is_memblock_offlined(struct memory_block *mem); |
254 | extern int remove_memory(int nid, u64 start, u64 size); | 264 | extern void remove_memory(int nid, u64 start, u64 size); |
255 | extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn, | 265 | extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn, |
256 | int nr_pages); | 266 | int nr_pages); |
257 | extern void sparse_remove_one_section(struct zone *zone, struct mem_section *ms); | 267 | extern void sparse_remove_one_section(struct zone *zone, struct mem_section *ms); |
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h index 7d7e09efff9b..6fa7cea25da9 100644 --- a/include/linux/pm_runtime.h +++ b/include/linux/pm_runtime.h | |||
@@ -37,7 +37,6 @@ extern void pm_runtime_enable(struct device *dev); | |||
37 | extern void __pm_runtime_disable(struct device *dev, bool check_resume); | 37 | extern void __pm_runtime_disable(struct device *dev, bool check_resume); |
38 | extern void pm_runtime_allow(struct device *dev); | 38 | extern void pm_runtime_allow(struct device *dev); |
39 | extern void pm_runtime_forbid(struct device *dev); | 39 | extern void pm_runtime_forbid(struct device *dev); |
40 | extern int pm_generic_runtime_idle(struct device *dev); | ||
41 | extern int pm_generic_runtime_suspend(struct device *dev); | 40 | extern int pm_generic_runtime_suspend(struct device *dev); |
42 | extern int pm_generic_runtime_resume(struct device *dev); | 41 | extern int pm_generic_runtime_resume(struct device *dev); |
43 | extern void pm_runtime_no_callbacks(struct device *dev); | 42 | extern void pm_runtime_no_callbacks(struct device *dev); |
@@ -143,7 +142,6 @@ static inline bool pm_runtime_active(struct device *dev) { return true; } | |||
143 | static inline bool pm_runtime_status_suspended(struct device *dev) { return false; } | 142 | static inline bool pm_runtime_status_suspended(struct device *dev) { return false; } |
144 | static inline bool pm_runtime_enabled(struct device *dev) { return false; } | 143 | static inline bool pm_runtime_enabled(struct device *dev) { return false; } |
145 | 144 | ||
146 | static inline int pm_generic_runtime_idle(struct device *dev) { return 0; } | ||
147 | static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; } | 145 | static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; } |
148 | static inline int pm_generic_runtime_resume(struct device *dev) { return 0; } | 146 | static inline int pm_generic_runtime_resume(struct device *dev) { return 0; } |
149 | static inline void pm_runtime_no_callbacks(struct device *dev) {} | 147 | static inline void pm_runtime_no_callbacks(struct device *dev) {} |
diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h index c0f44c2b006d..d8b187c3925d 100644 --- a/include/linux/power/smartreflex.h +++ b/include/linux/power/smartreflex.h | |||
@@ -299,11 +299,11 @@ void omap_sr_disable_reset_volt(struct voltagedomain *voltdm); | |||
299 | void omap_sr_register_pmic(struct omap_sr_pmic_data *pmic_data); | 299 | void omap_sr_register_pmic(struct omap_sr_pmic_data *pmic_data); |
300 | 300 | ||
301 | /* Smartreflex driver hooks to be called from Smartreflex class driver */ | 301 | /* Smartreflex driver hooks to be called from Smartreflex class driver */ |
302 | int sr_enable(struct voltagedomain *voltdm, unsigned long volt); | 302 | int sr_enable(struct omap_sr *sr, unsigned long volt); |
303 | void sr_disable(struct voltagedomain *voltdm); | 303 | void sr_disable(struct omap_sr *sr); |
304 | int sr_configure_errgen(struct voltagedomain *voltdm); | 304 | int sr_configure_errgen(struct omap_sr *sr); |
305 | int sr_disable_errgen(struct voltagedomain *voltdm); | 305 | int sr_disable_errgen(struct omap_sr *sr); |
306 | int sr_configure_minmax(struct voltagedomain *voltdm); | 306 | int sr_configure_minmax(struct omap_sr *sr); |
307 | 307 | ||
308 | /* API to register the smartreflex class driver with the smartreflex driver */ | 308 | /* API to register the smartreflex class driver with the smartreflex driver */ |
309 | int sr_register_class(struct omap_sr_class_data *class_data); | 309 | int sr_register_class(struct omap_sr_class_data *class_data); |
diff --git a/include/linux/suspend.h b/include/linux/suspend.h index d4e3f16d5e89..f73cabf59012 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h | |||
@@ -363,6 +363,7 @@ extern bool pm_wakeup_pending(void); | |||
363 | extern bool pm_get_wakeup_count(unsigned int *count, bool block); | 363 | extern bool pm_get_wakeup_count(unsigned int *count, bool block); |
364 | extern bool pm_save_wakeup_count(unsigned int count); | 364 | extern bool pm_save_wakeup_count(unsigned int count); |
365 | extern void pm_wakep_autosleep_enabled(bool set); | 365 | extern void pm_wakep_autosleep_enabled(bool set); |
366 | extern void pm_print_active_wakeup_sources(void); | ||
366 | 367 | ||
367 | static inline void lock_system_sleep(void) | 368 | static inline void lock_system_sleep(void) |
368 | { | 369 | { |
diff --git a/include/trace/events/power.h b/include/trace/events/power.h index 427acab5d69a..8e42410bd159 100644 --- a/include/trace/events/power.h +++ b/include/trace/events/power.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #define _TRACE_POWER_H | 5 | #define _TRACE_POWER_H |
6 | 6 | ||
7 | #include <linux/ktime.h> | 7 | #include <linux/ktime.h> |
8 | #include <linux/pm_qos.h> | ||
8 | #include <linux/tracepoint.h> | 9 | #include <linux/tracepoint.h> |
9 | 10 | ||
10 | DECLARE_EVENT_CLASS(cpu, | 11 | DECLARE_EVENT_CLASS(cpu, |
@@ -177,6 +178,178 @@ DEFINE_EVENT(power_domain, power_domain_target, | |||
177 | 178 | ||
178 | TP_ARGS(name, state, cpu_id) | 179 | TP_ARGS(name, state, cpu_id) |
179 | ); | 180 | ); |
181 | |||
182 | /* | ||
183 | * The pm qos events are used for pm qos update | ||
184 | */ | ||
185 | DECLARE_EVENT_CLASS(pm_qos_request, | ||
186 | |||
187 | TP_PROTO(int pm_qos_class, s32 value), | ||
188 | |||
189 | TP_ARGS(pm_qos_class, value), | ||
190 | |||
191 | TP_STRUCT__entry( | ||
192 | __field( int, pm_qos_class ) | ||
193 | __field( s32, value ) | ||
194 | ), | ||
195 | |||
196 | TP_fast_assign( | ||
197 | __entry->pm_qos_class = pm_qos_class; | ||
198 | __entry->value = value; | ||
199 | ), | ||
200 | |||
201 | TP_printk("pm_qos_class=%s value=%d", | ||
202 | __print_symbolic(__entry->pm_qos_class, | ||
203 | { PM_QOS_CPU_DMA_LATENCY, "CPU_DMA_LATENCY" }, | ||
204 | { PM_QOS_NETWORK_LATENCY, "NETWORK_LATENCY" }, | ||
205 | { PM_QOS_NETWORK_THROUGHPUT, "NETWORK_THROUGHPUT" }), | ||
206 | __entry->value) | ||
207 | ); | ||
208 | |||
209 | DEFINE_EVENT(pm_qos_request, pm_qos_add_request, | ||
210 | |||
211 | TP_PROTO(int pm_qos_class, s32 value), | ||
212 | |||
213 | TP_ARGS(pm_qos_class, value) | ||
214 | ); | ||
215 | |||
216 | DEFINE_EVENT(pm_qos_request, pm_qos_update_request, | ||
217 | |||
218 | TP_PROTO(int pm_qos_class, s32 value), | ||
219 | |||
220 | TP_ARGS(pm_qos_class, value) | ||
221 | ); | ||
222 | |||
223 | DEFINE_EVENT(pm_qos_request, pm_qos_remove_request, | ||
224 | |||
225 | TP_PROTO(int pm_qos_class, s32 value), | ||
226 | |||
227 | TP_ARGS(pm_qos_class, value) | ||
228 | ); | ||
229 | |||
230 | TRACE_EVENT(pm_qos_update_request_timeout, | ||
231 | |||
232 | TP_PROTO(int pm_qos_class, s32 value, unsigned long timeout_us), | ||
233 | |||
234 | TP_ARGS(pm_qos_class, value, timeout_us), | ||
235 | |||
236 | TP_STRUCT__entry( | ||
237 | __field( int, pm_qos_class ) | ||
238 | __field( s32, value ) | ||
239 | __field( unsigned long, timeout_us ) | ||
240 | ), | ||
241 | |||
242 | TP_fast_assign( | ||
243 | __entry->pm_qos_class = pm_qos_class; | ||
244 | __entry->value = value; | ||
245 | __entry->timeout_us = timeout_us; | ||
246 | ), | ||
247 | |||
248 | TP_printk("pm_qos_class=%s value=%d, timeout_us=%ld", | ||
249 | __print_symbolic(__entry->pm_qos_class, | ||
250 | { PM_QOS_CPU_DMA_LATENCY, "CPU_DMA_LATENCY" }, | ||
251 | { PM_QOS_NETWORK_LATENCY, "NETWORK_LATENCY" }, | ||
252 | { PM_QOS_NETWORK_THROUGHPUT, "NETWORK_THROUGHPUT" }), | ||
253 | __entry->value, __entry->timeout_us) | ||
254 | ); | ||
255 | |||
256 | DECLARE_EVENT_CLASS(pm_qos_update, | ||
257 | |||
258 | TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value), | ||
259 | |||
260 | TP_ARGS(action, prev_value, curr_value), | ||
261 | |||
262 | TP_STRUCT__entry( | ||
263 | __field( enum pm_qos_req_action, action ) | ||
264 | __field( int, prev_value ) | ||
265 | __field( int, curr_value ) | ||
266 | ), | ||
267 | |||
268 | TP_fast_assign( | ||
269 | __entry->action = action; | ||
270 | __entry->prev_value = prev_value; | ||
271 | __entry->curr_value = curr_value; | ||
272 | ), | ||
273 | |||
274 | TP_printk("action=%s prev_value=%d curr_value=%d", | ||
275 | __print_symbolic(__entry->action, | ||
276 | { PM_QOS_ADD_REQ, "ADD_REQ" }, | ||
277 | { PM_QOS_UPDATE_REQ, "UPDATE_REQ" }, | ||
278 | { PM_QOS_REMOVE_REQ, "REMOVE_REQ" }), | ||
279 | __entry->prev_value, __entry->curr_value) | ||
280 | ); | ||
281 | |||
282 | DEFINE_EVENT(pm_qos_update, pm_qos_update_target, | ||
283 | |||
284 | TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value), | ||
285 | |||
286 | TP_ARGS(action, prev_value, curr_value) | ||
287 | ); | ||
288 | |||
289 | DEFINE_EVENT_PRINT(pm_qos_update, pm_qos_update_flags, | ||
290 | |||
291 | TP_PROTO(enum pm_qos_req_action action, int prev_value, int curr_value), | ||
292 | |||
293 | TP_ARGS(action, prev_value, curr_value), | ||
294 | |||
295 | TP_printk("action=%s prev_value=0x%x curr_value=0x%x", | ||
296 | __print_symbolic(__entry->action, | ||
297 | { PM_QOS_ADD_REQ, "ADD_REQ" }, | ||
298 | { PM_QOS_UPDATE_REQ, "UPDATE_REQ" }, | ||
299 | { PM_QOS_REMOVE_REQ, "REMOVE_REQ" }), | ||
300 | __entry->prev_value, __entry->curr_value) | ||
301 | ); | ||
302 | |||
303 | DECLARE_EVENT_CLASS(dev_pm_qos_request, | ||
304 | |||
305 | TP_PROTO(const char *name, enum dev_pm_qos_req_type type, | ||
306 | s32 new_value), | ||
307 | |||
308 | TP_ARGS(name, type, new_value), | ||
309 | |||
310 | TP_STRUCT__entry( | ||
311 | __string( name, name ) | ||
312 | __field( enum dev_pm_qos_req_type, type ) | ||
313 | __field( s32, new_value ) | ||
314 | ), | ||
315 | |||
316 | TP_fast_assign( | ||
317 | __assign_str(name, name); | ||
318 | __entry->type = type; | ||
319 | __entry->new_value = new_value; | ||
320 | ), | ||
321 | |||
322 | TP_printk("device=%s type=%s new_value=%d", | ||
323 | __get_str(name), | ||
324 | __print_symbolic(__entry->type, | ||
325 | { DEV_PM_QOS_LATENCY, "DEV_PM_QOS_LATENCY" }, | ||
326 | { DEV_PM_QOS_FLAGS, "DEV_PM_QOS_FLAGS" }), | ||
327 | __entry->new_value) | ||
328 | ); | ||
329 | |||
330 | DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_add_request, | ||
331 | |||
332 | TP_PROTO(const char *name, enum dev_pm_qos_req_type type, | ||
333 | s32 new_value), | ||
334 | |||
335 | TP_ARGS(name, type, new_value) | ||
336 | ); | ||
337 | |||
338 | DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_update_request, | ||
339 | |||
340 | TP_PROTO(const char *name, enum dev_pm_qos_req_type type, | ||
341 | s32 new_value), | ||
342 | |||
343 | TP_ARGS(name, type, new_value) | ||
344 | ); | ||
345 | |||
346 | DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request, | ||
347 | |||
348 | TP_PROTO(const char *name, enum dev_pm_qos_req_type type, | ||
349 | s32 new_value), | ||
350 | |||
351 | TP_ARGS(name, type, new_value) | ||
352 | ); | ||
180 | #endif /* _TRACE_POWER_H */ | 353 | #endif /* _TRACE_POWER_H */ |
181 | 354 | ||
182 | /* This part must be outside protection */ | 355 | /* This part must be outside protection */ |
diff --git a/include/xen/acpi.h b/include/xen/acpi.h index 68d73d09b770..46aa3d1c1654 100644 --- a/include/xen/acpi.h +++ b/include/xen/acpi.h | |||
@@ -78,11 +78,25 @@ static inline int xen_acpi_get_pxm(acpi_handle h) | |||
78 | int xen_acpi_notify_hypervisor_state(u8 sleep_state, | 78 | int xen_acpi_notify_hypervisor_state(u8 sleep_state, |
79 | u32 pm1a_cnt, u32 pm1b_cnd); | 79 | u32 pm1a_cnt, u32 pm1b_cnd); |
80 | 80 | ||
81 | static inline int xen_acpi_suspend_lowlevel(void) | ||
82 | { | ||
83 | /* | ||
84 | * Xen will save and restore CPU context, so | ||
85 | * we can skip that and just go straight to | ||
86 | * the suspend. | ||
87 | */ | ||
88 | acpi_enter_sleep_state(ACPI_STATE_S3); | ||
89 | return 0; | ||
90 | } | ||
91 | |||
81 | static inline void xen_acpi_sleep_register(void) | 92 | static inline void xen_acpi_sleep_register(void) |
82 | { | 93 | { |
83 | if (xen_initial_domain()) | 94 | if (xen_initial_domain()) { |
84 | acpi_os_set_prepare_sleep( | 95 | acpi_os_set_prepare_sleep( |
85 | &xen_acpi_notify_hypervisor_state); | 96 | &xen_acpi_notify_hypervisor_state); |
97 | |||
98 | acpi_suspend_lowlevel = xen_acpi_suspend_lowlevel; | ||
99 | } | ||
86 | } | 100 | } |
87 | #else | 101 | #else |
88 | static inline void xen_acpi_sleep_register(void) | 102 | static inline void xen_acpi_sleep_register(void) |
diff --git a/kernel/exit.c b/kernel/exit.c index 7bb73f9d09db..6a057750ebbb 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -835,7 +835,7 @@ void do_exit(long code) | |||
835 | /* | 835 | /* |
836 | * Make sure we are holding no locks: | 836 | * Make sure we are holding no locks: |
837 | */ | 837 | */ |
838 | debug_check_no_locks_held(tsk); | 838 | debug_check_no_locks_held(); |
839 | /* | 839 | /* |
840 | * We can do this unlocked here. The futex code uses this flag | 840 | * We can do this unlocked here. The futex code uses this flag |
841 | * just to verify whether the pi state cleanup has been done | 841 | * just to verify whether the pi state cleanup has been done |
diff --git a/kernel/freezer.c b/kernel/freezer.c index c38893b0efba..8b2afc1c9df0 100644 --- a/kernel/freezer.c +++ b/kernel/freezer.c | |||
@@ -110,6 +110,18 @@ bool freeze_task(struct task_struct *p) | |||
110 | { | 110 | { |
111 | unsigned long flags; | 111 | unsigned long flags; |
112 | 112 | ||
113 | /* | ||
114 | * This check can race with freezer_do_not_count, but worst case that | ||
115 | * will result in an extra wakeup being sent to the task. It does not | ||
116 | * race with freezer_count(), the barriers in freezer_count() and | ||
117 | * freezer_should_skip() ensure that either freezer_count() sees | ||
118 | * freezing == true in try_to_freeze() and freezes, or | ||
119 | * freezer_should_skip() sees !PF_FREEZE_SKIP and freezes the task | ||
120 | * normally. | ||
121 | */ | ||
122 | if (freezer_should_skip(p)) | ||
123 | return false; | ||
124 | |||
113 | spin_lock_irqsave(&freezer_lock, flags); | 125 | spin_lock_irqsave(&freezer_lock, flags); |
114 | if (!freezing(p) || frozen(p)) { | 126 | if (!freezing(p) || frozen(p)) { |
115 | spin_unlock_irqrestore(&freezer_lock, flags); | 127 | spin_unlock_irqrestore(&freezer_lock, flags); |
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index fd4b13b131f8..3ee4d06c6fc2 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <linux/sched/sysctl.h> | 47 | #include <linux/sched/sysctl.h> |
48 | #include <linux/sched/rt.h> | 48 | #include <linux/sched/rt.h> |
49 | #include <linux/timer.h> | 49 | #include <linux/timer.h> |
50 | #include <linux/freezer.h> | ||
50 | 51 | ||
51 | #include <asm/uaccess.h> | 52 | #include <asm/uaccess.h> |
52 | 53 | ||
@@ -1545,7 +1546,7 @@ static int __sched do_nanosleep(struct hrtimer_sleeper *t, enum hrtimer_mode mod | |||
1545 | t->task = NULL; | 1546 | t->task = NULL; |
1546 | 1547 | ||
1547 | if (likely(t->task)) | 1548 | if (likely(t->task)) |
1548 | schedule(); | 1549 | freezable_schedule(); |
1549 | 1550 | ||
1550 | hrtimer_cancel(&t->timer); | 1551 | hrtimer_cancel(&t->timer); |
1551 | mode = HRTIMER_MODE_ABS; | 1552 | mode = HRTIMER_MODE_ABS; |
diff --git a/kernel/lockdep.c b/kernel/lockdep.c index 1f3186b37fd5..e16c45b9ee77 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c | |||
@@ -4090,7 +4090,7 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len) | |||
4090 | } | 4090 | } |
4091 | EXPORT_SYMBOL_GPL(debug_check_no_locks_freed); | 4091 | EXPORT_SYMBOL_GPL(debug_check_no_locks_freed); |
4092 | 4092 | ||
4093 | static void print_held_locks_bug(struct task_struct *curr) | 4093 | static void print_held_locks_bug(void) |
4094 | { | 4094 | { |
4095 | if (!debug_locks_off()) | 4095 | if (!debug_locks_off()) |
4096 | return; | 4096 | return; |
@@ -4099,22 +4099,21 @@ static void print_held_locks_bug(struct task_struct *curr) | |||
4099 | 4099 | ||
4100 | printk("\n"); | 4100 | printk("\n"); |
4101 | printk("=====================================\n"); | 4101 | printk("=====================================\n"); |
4102 | printk("[ BUG: lock held at task exit time! ]\n"); | 4102 | printk("[ BUG: %s/%d still has locks held! ]\n", |
4103 | current->comm, task_pid_nr(current)); | ||
4103 | print_kernel_ident(); | 4104 | print_kernel_ident(); |
4104 | printk("-------------------------------------\n"); | 4105 | printk("-------------------------------------\n"); |
4105 | printk("%s/%d is exiting with locks still held!\n", | 4106 | lockdep_print_held_locks(current); |
4106 | curr->comm, task_pid_nr(curr)); | ||
4107 | lockdep_print_held_locks(curr); | ||
4108 | |||
4109 | printk("\nstack backtrace:\n"); | 4107 | printk("\nstack backtrace:\n"); |
4110 | dump_stack(); | 4108 | dump_stack(); |
4111 | } | 4109 | } |
4112 | 4110 | ||
4113 | void debug_check_no_locks_held(struct task_struct *task) | 4111 | void debug_check_no_locks_held(void) |
4114 | { | 4112 | { |
4115 | if (unlikely(task->lockdep_depth > 0)) | 4113 | if (unlikely(current->lockdep_depth > 0)) |
4116 | print_held_locks_bug(task); | 4114 | print_held_locks_bug(); |
4117 | } | 4115 | } |
4116 | EXPORT_SYMBOL_GPL(debug_check_no_locks_held); | ||
4118 | 4117 | ||
4119 | void debug_show_all_locks(void) | 4118 | void debug_show_all_locks(void) |
4120 | { | 4119 | { |
diff --git a/kernel/power/main.c b/kernel/power/main.c index d77663bfedeb..1d1bf630e6e9 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
@@ -424,6 +424,8 @@ static ssize_t wakeup_count_store(struct kobject *kobj, | |||
424 | if (sscanf(buf, "%u", &val) == 1) { | 424 | if (sscanf(buf, "%u", &val) == 1) { |
425 | if (pm_save_wakeup_count(val)) | 425 | if (pm_save_wakeup_count(val)) |
426 | error = n; | 426 | error = n; |
427 | else | ||
428 | pm_print_active_wakeup_sources(); | ||
427 | } | 429 | } |
428 | 430 | ||
429 | out: | 431 | out: |
@@ -528,6 +530,10 @@ pm_trace_store(struct kobject *kobj, struct kobj_attribute *attr, | |||
528 | 530 | ||
529 | if (sscanf(buf, "%d", &val) == 1) { | 531 | if (sscanf(buf, "%d", &val) == 1) { |
530 | pm_trace_enabled = !!val; | 532 | pm_trace_enabled = !!val; |
533 | if (pm_trace_enabled) { | ||
534 | pr_warn("PM: Enabling pm_trace changes system date and time during resume.\n" | ||
535 | "PM: Correct system time has to be restored manually after resume.\n"); | ||
536 | } | ||
531 | return n; | 537 | return n; |
532 | } | 538 | } |
533 | return -EINVAL; | 539 | return -EINVAL; |
diff --git a/kernel/power/process.c b/kernel/power/process.c index 98088e0e71e8..fc0df8486449 100644 --- a/kernel/power/process.c +++ b/kernel/power/process.c | |||
@@ -30,9 +30,10 @@ static int try_to_freeze_tasks(bool user_only) | |||
30 | unsigned int todo; | 30 | unsigned int todo; |
31 | bool wq_busy = false; | 31 | bool wq_busy = false; |
32 | struct timeval start, end; | 32 | struct timeval start, end; |
33 | u64 elapsed_csecs64; | 33 | u64 elapsed_msecs64; |
34 | unsigned int elapsed_csecs; | 34 | unsigned int elapsed_msecs; |
35 | bool wakeup = false; | 35 | bool wakeup = false; |
36 | int sleep_usecs = USEC_PER_MSEC; | ||
36 | 37 | ||
37 | do_gettimeofday(&start); | 38 | do_gettimeofday(&start); |
38 | 39 | ||
@@ -68,22 +69,25 @@ static int try_to_freeze_tasks(bool user_only) | |||
68 | 69 | ||
69 | /* | 70 | /* |
70 | * We need to retry, but first give the freezing tasks some | 71 | * We need to retry, but first give the freezing tasks some |
71 | * time to enter the refrigerator. | 72 | * time to enter the refrigerator. Start with an initial |
73 | * 1 ms sleep followed by exponential backoff until 8 ms. | ||
72 | */ | 74 | */ |
73 | msleep(10); | 75 | usleep_range(sleep_usecs / 2, sleep_usecs); |
76 | if (sleep_usecs < 8 * USEC_PER_MSEC) | ||
77 | sleep_usecs *= 2; | ||
74 | } | 78 | } |
75 | 79 | ||
76 | do_gettimeofday(&end); | 80 | do_gettimeofday(&end); |
77 | elapsed_csecs64 = timeval_to_ns(&end) - timeval_to_ns(&start); | 81 | elapsed_msecs64 = timeval_to_ns(&end) - timeval_to_ns(&start); |
78 | do_div(elapsed_csecs64, NSEC_PER_SEC / 100); | 82 | do_div(elapsed_msecs64, NSEC_PER_MSEC); |
79 | elapsed_csecs = elapsed_csecs64; | 83 | elapsed_msecs = elapsed_msecs64; |
80 | 84 | ||
81 | if (todo) { | 85 | if (todo) { |
82 | printk("\n"); | 86 | printk("\n"); |
83 | printk(KERN_ERR "Freezing of tasks %s after %d.%02d seconds " | 87 | printk(KERN_ERR "Freezing of tasks %s after %d.%03d seconds " |
84 | "(%d tasks refusing to freeze, wq_busy=%d):\n", | 88 | "(%d tasks refusing to freeze, wq_busy=%d):\n", |
85 | wakeup ? "aborted" : "failed", | 89 | wakeup ? "aborted" : "failed", |
86 | elapsed_csecs / 100, elapsed_csecs % 100, | 90 | elapsed_msecs / 1000, elapsed_msecs % 1000, |
87 | todo - wq_busy, wq_busy); | 91 | todo - wq_busy, wq_busy); |
88 | 92 | ||
89 | if (!wakeup) { | 93 | if (!wakeup) { |
@@ -96,8 +100,8 @@ static int try_to_freeze_tasks(bool user_only) | |||
96 | read_unlock(&tasklist_lock); | 100 | read_unlock(&tasklist_lock); |
97 | } | 101 | } |
98 | } else { | 102 | } else { |
99 | printk("(elapsed %d.%02d seconds) ", elapsed_csecs / 100, | 103 | printk("(elapsed %d.%03d seconds) ", elapsed_msecs / 1000, |
100 | elapsed_csecs % 100); | 104 | elapsed_msecs % 1000); |
101 | } | 105 | } |
102 | 106 | ||
103 | return todo ? -EBUSY : 0; | 107 | return todo ? -EBUSY : 0; |
diff --git a/kernel/power/qos.c b/kernel/power/qos.c index 587dddeebf15..06fe28589e9c 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c | |||
@@ -44,6 +44,7 @@ | |||
44 | 44 | ||
45 | #include <linux/uaccess.h> | 45 | #include <linux/uaccess.h> |
46 | #include <linux/export.h> | 46 | #include <linux/export.h> |
47 | #include <trace/events/power.h> | ||
47 | 48 | ||
48 | /* | 49 | /* |
49 | * locking rule: all changes to constraints or notifiers lists | 50 | * locking rule: all changes to constraints or notifiers lists |
@@ -202,6 +203,7 @@ int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node, | |||
202 | 203 | ||
203 | spin_unlock_irqrestore(&pm_qos_lock, flags); | 204 | spin_unlock_irqrestore(&pm_qos_lock, flags); |
204 | 205 | ||
206 | trace_pm_qos_update_target(action, prev_value, curr_value); | ||
205 | if (prev_value != curr_value) { | 207 | if (prev_value != curr_value) { |
206 | blocking_notifier_call_chain(c->notifiers, | 208 | blocking_notifier_call_chain(c->notifiers, |
207 | (unsigned long)curr_value, | 209 | (unsigned long)curr_value, |
@@ -272,6 +274,7 @@ bool pm_qos_update_flags(struct pm_qos_flags *pqf, | |||
272 | 274 | ||
273 | spin_unlock_irqrestore(&pm_qos_lock, irqflags); | 275 | spin_unlock_irqrestore(&pm_qos_lock, irqflags); |
274 | 276 | ||
277 | trace_pm_qos_update_flags(action, prev_value, curr_value); | ||
275 | return prev_value != curr_value; | 278 | return prev_value != curr_value; |
276 | } | 279 | } |
277 | 280 | ||
@@ -333,6 +336,7 @@ void pm_qos_add_request(struct pm_qos_request *req, | |||
333 | } | 336 | } |
334 | req->pm_qos_class = pm_qos_class; | 337 | req->pm_qos_class = pm_qos_class; |
335 | INIT_DELAYED_WORK(&req->work, pm_qos_work_fn); | 338 | INIT_DELAYED_WORK(&req->work, pm_qos_work_fn); |
339 | trace_pm_qos_add_request(pm_qos_class, value); | ||
336 | pm_qos_update_target(pm_qos_array[pm_qos_class]->constraints, | 340 | pm_qos_update_target(pm_qos_array[pm_qos_class]->constraints, |
337 | &req->node, PM_QOS_ADD_REQ, value); | 341 | &req->node, PM_QOS_ADD_REQ, value); |
338 | } | 342 | } |
@@ -361,6 +365,7 @@ void pm_qos_update_request(struct pm_qos_request *req, | |||
361 | 365 | ||
362 | cancel_delayed_work_sync(&req->work); | 366 | cancel_delayed_work_sync(&req->work); |
363 | 367 | ||
368 | trace_pm_qos_update_request(req->pm_qos_class, new_value); | ||
364 | if (new_value != req->node.prio) | 369 | if (new_value != req->node.prio) |
365 | pm_qos_update_target( | 370 | pm_qos_update_target( |
366 | pm_qos_array[req->pm_qos_class]->constraints, | 371 | pm_qos_array[req->pm_qos_class]->constraints, |
@@ -387,6 +392,8 @@ void pm_qos_update_request_timeout(struct pm_qos_request *req, s32 new_value, | |||
387 | 392 | ||
388 | cancel_delayed_work_sync(&req->work); | 393 | cancel_delayed_work_sync(&req->work); |
389 | 394 | ||
395 | trace_pm_qos_update_request_timeout(req->pm_qos_class, | ||
396 | new_value, timeout_us); | ||
390 | if (new_value != req->node.prio) | 397 | if (new_value != req->node.prio) |
391 | pm_qos_update_target( | 398 | pm_qos_update_target( |
392 | pm_qos_array[req->pm_qos_class]->constraints, | 399 | pm_qos_array[req->pm_qos_class]->constraints, |
@@ -416,6 +423,7 @@ void pm_qos_remove_request(struct pm_qos_request *req) | |||
416 | 423 | ||
417 | cancel_delayed_work_sync(&req->work); | 424 | cancel_delayed_work_sync(&req->work); |
418 | 425 | ||
426 | trace_pm_qos_remove_request(req->pm_qos_class, PM_QOS_DEFAULT_VALUE); | ||
419 | pm_qos_update_target(pm_qos_array[req->pm_qos_class]->constraints, | 427 | pm_qos_update_target(pm_qos_array[req->pm_qos_class]->constraints, |
420 | &req->node, PM_QOS_REMOVE_REQ, | 428 | &req->node, PM_QOS_REMOVE_REQ, |
421 | PM_QOS_DEFAULT_VALUE); | 429 | PM_QOS_DEFAULT_VALUE); |
@@ -477,7 +485,7 @@ static int find_pm_qos_object_by_minor(int minor) | |||
477 | { | 485 | { |
478 | int pm_qos_class; | 486 | int pm_qos_class; |
479 | 487 | ||
480 | for (pm_qos_class = 0; | 488 | for (pm_qos_class = PM_QOS_CPU_DMA_LATENCY; |
481 | pm_qos_class < PM_QOS_NUM_CLASSES; pm_qos_class++) { | 489 | pm_qos_class < PM_QOS_NUM_CLASSES; pm_qos_class++) { |
482 | if (minor == | 490 | if (minor == |
483 | pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) | 491 | pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) |
@@ -491,7 +499,7 @@ static int pm_qos_power_open(struct inode *inode, struct file *filp) | |||
491 | long pm_qos_class; | 499 | long pm_qos_class; |
492 | 500 | ||
493 | pm_qos_class = find_pm_qos_object_by_minor(iminor(inode)); | 501 | pm_qos_class = find_pm_qos_object_by_minor(iminor(inode)); |
494 | if (pm_qos_class >= 0) { | 502 | if (pm_qos_class >= PM_QOS_CPU_DMA_LATENCY) { |
495 | struct pm_qos_request *req = kzalloc(sizeof(*req), GFP_KERNEL); | 503 | struct pm_qos_request *req = kzalloc(sizeof(*req), GFP_KERNEL); |
496 | if (!req) | 504 | if (!req) |
497 | return -ENOMEM; | 505 | return -ENOMEM; |
@@ -584,7 +592,7 @@ static int __init pm_qos_power_init(void) | |||
584 | 592 | ||
585 | BUILD_BUG_ON(ARRAY_SIZE(pm_qos_array) != PM_QOS_NUM_CLASSES); | 593 | BUILD_BUG_ON(ARRAY_SIZE(pm_qos_array) != PM_QOS_NUM_CLASSES); |
586 | 594 | ||
587 | for (i = 1; i < PM_QOS_NUM_CLASSES; i++) { | 595 | for (i = PM_QOS_CPU_DMA_LATENCY; i < PM_QOS_NUM_CLASSES; i++) { |
588 | ret = register_pm_qos_misc(pm_qos_array[i]); | 596 | ret = register_pm_qos_misc(pm_qos_array[i]); |
589 | if (ret < 0) { | 597 | if (ret < 0) { |
590 | printk(KERN_ERR "pm_qos_param: %s setup failed\n", | 598 | printk(KERN_ERR "pm_qos_param: %s setup failed\n", |
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index 0de28576807d..7872a35eafe7 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c | |||
@@ -642,8 +642,9 @@ __register_nosave_region(unsigned long start_pfn, unsigned long end_pfn, | |||
642 | region->end_pfn = end_pfn; | 642 | region->end_pfn = end_pfn; |
643 | list_add_tail(®ion->list, &nosave_regions); | 643 | list_add_tail(®ion->list, &nosave_regions); |
644 | Report: | 644 | Report: |
645 | printk(KERN_INFO "PM: Registered nosave memory: %016lx - %016lx\n", | 645 | printk(KERN_INFO "PM: Registered nosave memory: [mem %#010llx-%#010llx]\n", |
646 | start_pfn << PAGE_SHIFT, end_pfn << PAGE_SHIFT); | 646 | (unsigned long long) start_pfn << PAGE_SHIFT, |
647 | ((unsigned long long) end_pfn << PAGE_SHIFT) - 1); | ||
647 | } | 648 | } |
648 | 649 | ||
649 | /* | 650 | /* |
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index bef86d121eb2..ece04223bb1e 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c | |||
@@ -269,7 +269,7 @@ int suspend_devices_and_enter(suspend_state_t state) | |||
269 | suspend_test_start(); | 269 | suspend_test_start(); |
270 | error = dpm_suspend_start(PMSG_SUSPEND); | 270 | error = dpm_suspend_start(PMSG_SUSPEND); |
271 | if (error) { | 271 | if (error) { |
272 | printk(KERN_ERR "PM: Some devices failed to suspend\n"); | 272 | pr_err("PM: Some devices failed to suspend, or early wake event detected\n"); |
273 | goto Recover_platform; | 273 | goto Recover_platform; |
274 | } | 274 | } |
275 | suspend_test_finish("suspend devices"); | 275 | suspend_test_finish("suspend devices"); |
diff --git a/kernel/signal.c b/kernel/signal.c index 113411bfe8b1..50e41075ac77 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -2848,7 +2848,7 @@ int do_sigtimedwait(const sigset_t *which, siginfo_t *info, | |||
2848 | recalc_sigpending(); | 2848 | recalc_sigpending(); |
2849 | spin_unlock_irq(&tsk->sighand->siglock); | 2849 | spin_unlock_irq(&tsk->sighand->siglock); |
2850 | 2850 | ||
2851 | timeout = schedule_timeout_interruptible(timeout); | 2851 | timeout = freezable_schedule_timeout_interruptible(timeout); |
2852 | 2852 | ||
2853 | spin_lock_irq(&tsk->sighand->siglock); | 2853 | spin_lock_irq(&tsk->sighand->siglock); |
2854 | __set_task_blocked(tsk, &tsk->real_blocked); | 2854 | __set_task_blocked(tsk, &tsk->real_blocked); |
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 1ad92b46753e..081b4d654ed6 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c | |||
@@ -1621,6 +1621,7 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages) | |||
1621 | { | 1621 | { |
1622 | return __offline_pages(start_pfn, start_pfn + nr_pages, 120 * HZ); | 1622 | return __offline_pages(start_pfn, start_pfn + nr_pages, 120 * HZ); |
1623 | } | 1623 | } |
1624 | #endif /* CONFIG_MEMORY_HOTREMOVE */ | ||
1624 | 1625 | ||
1625 | /** | 1626 | /** |
1626 | * walk_memory_range - walks through all mem sections in [start_pfn, end_pfn) | 1627 | * walk_memory_range - walks through all mem sections in [start_pfn, end_pfn) |
@@ -1634,7 +1635,7 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages) | |||
1634 | * | 1635 | * |
1635 | * Returns the return value of func. | 1636 | * Returns the return value of func. |
1636 | */ | 1637 | */ |
1637 | static int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn, | 1638 | int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn, |
1638 | void *arg, int (*func)(struct memory_block *, void *)) | 1639 | void *arg, int (*func)(struct memory_block *, void *)) |
1639 | { | 1640 | { |
1640 | struct memory_block *mem = NULL; | 1641 | struct memory_block *mem = NULL; |
@@ -1671,24 +1672,7 @@ static int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn, | |||
1671 | return 0; | 1672 | return 0; |
1672 | } | 1673 | } |
1673 | 1674 | ||
1674 | /** | 1675 | #ifdef CONFIG_MEMORY_HOTREMOVE |
1675 | * offline_memory_block_cb - callback function for offlining memory block | ||
1676 | * @mem: the memory block to be offlined | ||
1677 | * @arg: buffer to hold error msg | ||
1678 | * | ||
1679 | * Always return 0, and put the error msg in arg if any. | ||
1680 | */ | ||
1681 | static int offline_memory_block_cb(struct memory_block *mem, void *arg) | ||
1682 | { | ||
1683 | int *ret = arg; | ||
1684 | int error = offline_memory_block(mem); | ||
1685 | |||
1686 | if (error != 0 && *ret == 0) | ||
1687 | *ret = error; | ||
1688 | |||
1689 | return 0; | ||
1690 | } | ||
1691 | |||
1692 | static int is_memblock_offlined_cb(struct memory_block *mem, void *arg) | 1676 | static int is_memblock_offlined_cb(struct memory_block *mem, void *arg) |
1693 | { | 1677 | { |
1694 | int ret = !is_memblock_offlined(mem); | 1678 | int ret = !is_memblock_offlined(mem); |
@@ -1814,54 +1798,22 @@ void try_offline_node(int nid) | |||
1814 | } | 1798 | } |
1815 | EXPORT_SYMBOL(try_offline_node); | 1799 | EXPORT_SYMBOL(try_offline_node); |
1816 | 1800 | ||
1817 | int __ref remove_memory(int nid, u64 start, u64 size) | 1801 | void __ref remove_memory(int nid, u64 start, u64 size) |
1818 | { | 1802 | { |
1819 | unsigned long start_pfn, end_pfn; | 1803 | int ret; |
1820 | int ret = 0; | ||
1821 | int retry = 1; | ||
1822 | |||
1823 | start_pfn = PFN_DOWN(start); | ||
1824 | end_pfn = PFN_UP(start + size - 1); | ||
1825 | |||
1826 | /* | ||
1827 | * When CONFIG_MEMCG is on, one memory block may be used by other | ||
1828 | * blocks to store page cgroup when onlining pages. But we don't know | ||
1829 | * in what order pages are onlined. So we iterate twice to offline | ||
1830 | * memory: | ||
1831 | * 1st iterate: offline every non primary memory block. | ||
1832 | * 2nd iterate: offline primary (i.e. first added) memory block. | ||
1833 | */ | ||
1834 | repeat: | ||
1835 | walk_memory_range(start_pfn, end_pfn, &ret, | ||
1836 | offline_memory_block_cb); | ||
1837 | if (ret) { | ||
1838 | if (!retry) | ||
1839 | return ret; | ||
1840 | |||
1841 | retry = 0; | ||
1842 | ret = 0; | ||
1843 | goto repeat; | ||
1844 | } | ||
1845 | 1804 | ||
1846 | lock_memory_hotplug(); | 1805 | lock_memory_hotplug(); |
1847 | 1806 | ||
1848 | /* | 1807 | /* |
1849 | * we have offlined all memory blocks like this: | 1808 | * All memory blocks must be offlined before removing memory. Check |
1850 | * 1. lock memory hotplug | 1809 | * whether all memory blocks in question are offline and trigger a BUG() |
1851 | * 2. offline a memory block | 1810 | * if this is not the case. |
1852 | * 3. unlock memory hotplug | ||
1853 | * | ||
1854 | * repeat step1-3 to offline the memory block. All memory blocks | ||
1855 | * must be offlined before removing memory. But we don't hold the | ||
1856 | * lock in the whole operation. So we should check whether all | ||
1857 | * memory blocks are offlined. | ||
1858 | */ | 1811 | */ |
1859 | 1812 | ret = walk_memory_range(PFN_DOWN(start), PFN_UP(start + size - 1), NULL, | |
1860 | ret = walk_memory_range(start_pfn, end_pfn, NULL, | ||
1861 | is_memblock_offlined_cb); | 1813 | is_memblock_offlined_cb); |
1862 | if (ret) { | 1814 | if (ret) { |
1863 | unlock_memory_hotplug(); | 1815 | unlock_memory_hotplug(); |
1864 | return ret; | 1816 | BUG(); |
1865 | } | 1817 | } |
1866 | 1818 | ||
1867 | /* remove memmap entry */ | 1819 | /* remove memmap entry */ |
@@ -1872,17 +1824,6 @@ repeat: | |||
1872 | try_offline_node(nid); | 1824 | try_offline_node(nid); |
1873 | 1825 | ||
1874 | unlock_memory_hotplug(); | 1826 | unlock_memory_hotplug(); |
1875 | |||
1876 | return 0; | ||
1877 | } | 1827 | } |
1878 | #else | ||
1879 | int offline_pages(unsigned long start_pfn, unsigned long nr_pages) | ||
1880 | { | ||
1881 | return -EINVAL; | ||
1882 | } | ||
1883 | int remove_memory(int nid, u64 start, u64 size) | ||
1884 | { | ||
1885 | return -EINVAL; | ||
1886 | } | ||
1887 | #endif /* CONFIG_MEMORY_HOTREMOVE */ | ||
1888 | EXPORT_SYMBOL_GPL(remove_memory); | 1828 | EXPORT_SYMBOL_GPL(remove_memory); |
1829 | #endif /* CONFIG_MEMORY_HOTREMOVE */ | ||
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index 5356b120dbf8..77d251e02593 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c | |||
@@ -254,7 +254,7 @@ static int rpc_wait_bit_killable(void *word) | |||
254 | { | 254 | { |
255 | if (fatal_signal_pending(current)) | 255 | if (fatal_signal_pending(current)) |
256 | return -ERESTARTSYS; | 256 | return -ERESTARTSYS; |
257 | freezable_schedule(); | 257 | freezable_schedule_unsafe(); |
258 | return 0; | 258 | return 0; |
259 | } | 259 | } |
260 | 260 | ||
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 826e09938bff..c4ce243824bb 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -114,6 +114,7 @@ | |||
114 | #include <linux/mount.h> | 114 | #include <linux/mount.h> |
115 | #include <net/checksum.h> | 115 | #include <net/checksum.h> |
116 | #include <linux/security.h> | 116 | #include <linux/security.h> |
117 | #include <linux/freezer.h> | ||
117 | 118 | ||
118 | struct hlist_head unix_socket_table[2 * UNIX_HASH_SIZE]; | 119 | struct hlist_head unix_socket_table[2 * UNIX_HASH_SIZE]; |
119 | EXPORT_SYMBOL_GPL(unix_socket_table); | 120 | EXPORT_SYMBOL_GPL(unix_socket_table); |
@@ -1879,7 +1880,7 @@ static long unix_stream_data_wait(struct sock *sk, long timeo, | |||
1879 | 1880 | ||
1880 | set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); | 1881 | set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); |
1881 | unix_state_unlock(sk); | 1882 | unix_state_unlock(sk); |
1882 | timeo = schedule_timeout(timeo); | 1883 | timeo = freezable_schedule_timeout(timeo); |
1883 | unix_state_lock(sk); | 1884 | unix_state_lock(sk); |
1884 | clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); | 1885 | clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); |
1885 | } | 1886 | } |