diff options
190 files changed, 5769 insertions, 2849 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-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-hotplug.txt b/Documentation/cpu-hotplug.txt index 9f401350f502..67f733d6f848 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 2fe6e767b3d6..7f64e0f0258a 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
| @@ -3229,6 +3229,15 @@ bytes respectively. Such letter suffixes can also be entirely omitted. | |||
| 3229 | video= [FB] Frame buffer configuration | 3229 | video= [FB] Frame buffer configuration |
| 3230 | See Documentation/fb/modedb.txt. | 3230 | See Documentation/fb/modedb.txt. |
| 3231 | 3231 | ||
| 3232 | video.brightness_switch_enabled= [0,1] | ||
| 3233 | If set to 1, on receiving an ACPI notify event | ||
| 3234 | generated by hotkey, video driver will adjust brightness | ||
| 3235 | level and then send out the event to user space through | ||
| 3236 | the allocated input device; If set to 0, video driver | ||
| 3237 | will only send out the event without touching backlight | ||
| 3238 | brightness level. | ||
| 3239 | default: 1 | ||
| 3240 | |||
| 3232 | virtio_mmio.device= | 3241 | virtio_mmio.device= |
| 3233 | [VMMIO] Memory mapped virtio (platform) device. | 3242 | [VMMIO] Memory mapped virtio (platform) device. |
| 3234 | 3243 | ||
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/MAINTAINERS b/MAINTAINERS index 041df42fc34d..04a5fef84415 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> |
| @@ -1309,6 +1311,7 @@ W: http://wiki.xilinx.com | |||
| 1309 | T: git git://git.xilinx.com/linux-xlnx.git | 1311 | T: git git://git.xilinx.com/linux-xlnx.git |
| 1310 | S: Supported | 1312 | S: Supported |
| 1311 | F: arch/arm/mach-zynq/ | 1313 | F: arch/arm/mach-zynq/ |
| 1314 | F: drivers/cpuidle/cpuidle-zynq.c | ||
| 1312 | 1315 | ||
| 1313 | ARM64 PORT (AARCH64 ARCHITECTURE) | 1316 | ARM64 PORT (AARCH64 ARCHITECTURE) |
| 1314 | M: Catalin Marinas <catalin.marinas@arm.com> | 1317 | M: Catalin Marinas <catalin.marinas@arm.com> |
| @@ -2517,7 +2520,7 @@ F: drivers/usb/dwc3/ | |||
| 2517 | DEVICE FREQUENCY (DEVFREQ) | 2520 | DEVICE FREQUENCY (DEVFREQ) |
| 2518 | M: MyungJoo Ham <myungjoo.ham@samsung.com> | 2521 | M: MyungJoo Ham <myungjoo.ham@samsung.com> |
| 2519 | M: Kyungmin Park <kyungmin.park@samsung.com> | 2522 | M: Kyungmin Park <kyungmin.park@samsung.com> |
| 2520 | L: linux-kernel@vger.kernel.org | 2523 | L: linux-pm@vger.kernel.org |
| 2521 | S: Maintained | 2524 | S: Maintained |
| 2522 | F: drivers/devfreq/ | 2525 | F: drivers/devfreq/ |
| 2523 | 2526 | ||
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/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/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..5f3597b87f27 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,39 @@ 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_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_p, &d_max); |
| 564 | if (ret) | ||
| 565 | return ret; | ||
| 566 | |||
| 567 | if (d_max_in < *d_min_p) | ||
| 568 | return -EINVAL; | ||
| 569 | |||
| 570 | if (d_max > d_max_in) { | ||
| 571 | for (d_max = d_max_in; d_max > *d_min_p; d_max--) { | ||
| 572 | if (adev->power.states[d_max].flags.valid) | ||
| 573 | break; | ||
| 574 | } | ||
| 575 | } | ||
| 576 | return d_max; | ||
| 548 | } | 577 | } |
| 549 | EXPORT_SYMBOL(acpi_pm_device_sleep_state); | 578 | EXPORT_SYMBOL(acpi_pm_device_sleep_state); |
| 550 | 579 | ||
| @@ -695,17 +724,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, | 724 | static int acpi_dev_pm_low_power(struct device *dev, struct acpi_device *adev, |
| 696 | u32 system_state) | 725 | u32 system_state) |
| 697 | { | 726 | { |
| 698 | int power_state; | 727 | int ret, state; |
| 699 | 728 | ||
| 700 | if (!acpi_device_power_manageable(adev)) | 729 | if (!acpi_device_power_manageable(adev)) |
| 701 | return 0; | 730 | return 0; |
| 702 | 731 | ||
| 703 | power_state = acpi_device_power_state(dev, adev, system_state, | 732 | ret = acpi_dev_pm_get_state(dev, adev, system_state, NULL, &state); |
| 704 | ACPI_STATE_D3, NULL); | 733 | 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 | } | 734 | } |
| 710 | 735 | ||
| 711 | /** | 736 | /** |
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index ec117c6c996c..14de9f46972e 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c | |||
| @@ -66,20 +66,21 @@ struct dock_station { | |||
| 66 | spinlock_t dd_lock; | 66 | spinlock_t dd_lock; |
| 67 | struct mutex hp_lock; | 67 | struct mutex hp_lock; |
| 68 | struct list_head dependent_devices; | 68 | struct list_head dependent_devices; |
| 69 | struct list_head hotplug_devices; | ||
| 70 | 69 | ||
| 71 | struct list_head sibling; | 70 | struct list_head sibling; |
| 72 | struct platform_device *dock_device; | 71 | struct platform_device *dock_device; |
| 73 | }; | 72 | }; |
| 74 | static LIST_HEAD(dock_stations); | 73 | static LIST_HEAD(dock_stations); |
| 75 | static int dock_station_count; | 74 | static int dock_station_count; |
| 75 | static DEFINE_MUTEX(hotplug_lock); | ||
| 76 | 76 | ||
| 77 | struct dock_dependent_device { | 77 | struct dock_dependent_device { |
| 78 | struct list_head list; | 78 | struct list_head list; |
| 79 | struct list_head hotplug_list; | ||
| 80 | acpi_handle handle; | 79 | acpi_handle handle; |
| 81 | const struct acpi_dock_ops *ops; | 80 | const struct acpi_dock_ops *hp_ops; |
| 82 | void *context; | 81 | void *hp_context; |
| 82 | unsigned int hp_refcount; | ||
| 83 | void (*hp_release)(void *); | ||
| 83 | }; | 84 | }; |
| 84 | 85 | ||
| 85 | #define DOCK_DOCKING 0x00000001 | 86 | #define DOCK_DOCKING 0x00000001 |
| @@ -111,7 +112,6 @@ add_dock_dependent_device(struct dock_station *ds, acpi_handle handle) | |||
| 111 | 112 | ||
| 112 | dd->handle = handle; | 113 | dd->handle = handle; |
| 113 | INIT_LIST_HEAD(&dd->list); | 114 | INIT_LIST_HEAD(&dd->list); |
| 114 | INIT_LIST_HEAD(&dd->hotplug_list); | ||
| 115 | 115 | ||
| 116 | spin_lock(&ds->dd_lock); | 116 | spin_lock(&ds->dd_lock); |
| 117 | list_add_tail(&dd->list, &ds->dependent_devices); | 117 | list_add_tail(&dd->list, &ds->dependent_devices); |
| @@ -121,35 +121,90 @@ add_dock_dependent_device(struct dock_station *ds, acpi_handle handle) | |||
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | /** | 123 | /** |
| 124 | * dock_add_hotplug_device - associate a hotplug handler with the dock station | 124 | * dock_init_hotplug - Initialize a hotplug device on a docking station. |
| 125 | * @ds: The dock station | 125 | * @dd: Dock-dependent device. |
| 126 | * @dd: The dependent device struct | 126 | * @ops: Dock operations to attach to the dependent device. |
| 127 | * | 127 | * @context: Data to pass to the @ops callbacks and @release. |
| 128 | * Add the dependent device to the dock's hotplug device list | 128 | * @init: Optional initialization routine to run after setting up context. |
| 129 | * @release: Optional release routine to run on removal. | ||
| 129 | */ | 130 | */ |
| 130 | static void | 131 | static int dock_init_hotplug(struct dock_dependent_device *dd, |
| 131 | dock_add_hotplug_device(struct dock_station *ds, | 132 | const struct acpi_dock_ops *ops, void *context, |
| 132 | struct dock_dependent_device *dd) | 133 | void (*init)(void *), void (*release)(void *)) |
| 133 | { | 134 | { |
| 134 | mutex_lock(&ds->hp_lock); | 135 | int ret = 0; |
| 135 | list_add_tail(&dd->hotplug_list, &ds->hotplug_devices); | 136 | |
| 136 | mutex_unlock(&ds->hp_lock); | 137 | mutex_lock(&hotplug_lock); |
| 138 | |||
| 139 | if (dd->hp_context) { | ||
| 140 | ret = -EEXIST; | ||
| 141 | } else { | ||
| 142 | dd->hp_refcount = 1; | ||
| 143 | dd->hp_ops = ops; | ||
| 144 | dd->hp_context = context; | ||
| 145 | dd->hp_release = release; | ||
| 146 | } | ||
| 147 | |||
| 148 | if (!WARN_ON(ret) && init) | ||
| 149 | init(context); | ||
| 150 | |||
| 151 | mutex_unlock(&hotplug_lock); | ||
| 152 | return ret; | ||
| 137 | } | 153 | } |
| 138 | 154 | ||
| 139 | /** | 155 | /** |
| 140 | * dock_del_hotplug_device - remove a hotplug handler from the dock station | 156 | * dock_release_hotplug - Decrement hotplug reference counter of dock device. |
| 141 | * @ds: The dock station | 157 | * @dd: Dock-dependent device. |
| 142 | * @dd: the dependent device struct | ||
| 143 | * | 158 | * |
| 144 | * Delete the dependent device from the dock's hotplug device list | 159 | * Decrement the reference counter of @dd and if 0, detach its hotplug |
| 160 | * operations from it, reset its context pointer and run the optional release | ||
| 161 | * routine if present. | ||
| 145 | */ | 162 | */ |
| 146 | static void | 163 | static void dock_release_hotplug(struct dock_dependent_device *dd) |
| 147 | dock_del_hotplug_device(struct dock_station *ds, | ||
| 148 | struct dock_dependent_device *dd) | ||
| 149 | { | 164 | { |
| 150 | mutex_lock(&ds->hp_lock); | 165 | void (*release)(void *) = NULL; |
| 151 | list_del(&dd->hotplug_list); | 166 | void *context = NULL; |
| 152 | mutex_unlock(&ds->hp_lock); | 167 | |
| 168 | mutex_lock(&hotplug_lock); | ||
| 169 | |||
| 170 | if (dd->hp_context && !--dd->hp_refcount) { | ||
| 171 | dd->hp_ops = NULL; | ||
| 172 | context = dd->hp_context; | ||
| 173 | dd->hp_context = NULL; | ||
| 174 | release = dd->hp_release; | ||
| 175 | dd->hp_release = NULL; | ||
| 176 | } | ||
| 177 | |||
| 178 | if (release && context) | ||
| 179 | release(context); | ||
| 180 | |||
| 181 | mutex_unlock(&hotplug_lock); | ||
| 182 | } | ||
| 183 | |||
| 184 | static void dock_hotplug_event(struct dock_dependent_device *dd, u32 event, | ||
| 185 | bool uevent) | ||
| 186 | { | ||
| 187 | acpi_notify_handler cb = NULL; | ||
| 188 | bool run = false; | ||
| 189 | |||
| 190 | mutex_lock(&hotplug_lock); | ||
| 191 | |||
| 192 | if (dd->hp_context) { | ||
| 193 | run = true; | ||
| 194 | dd->hp_refcount++; | ||
| 195 | if (dd->hp_ops) | ||
| 196 | cb = uevent ? dd->hp_ops->uevent : dd->hp_ops->handler; | ||
| 197 | } | ||
| 198 | |||
| 199 | mutex_unlock(&hotplug_lock); | ||
| 200 | |||
| 201 | if (!run) | ||
| 202 | return; | ||
| 203 | |||
| 204 | if (cb) | ||
| 205 | cb(dd->handle, event, dd->hp_context); | ||
| 206 | |||
| 207 | dock_release_hotplug(dd); | ||
| 153 | } | 208 | } |
| 154 | 209 | ||
| 155 | /** | 210 | /** |
| @@ -360,9 +415,8 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event) | |||
| 360 | /* | 415 | /* |
| 361 | * First call driver specific hotplug functions | 416 | * First call driver specific hotplug functions |
| 362 | */ | 417 | */ |
| 363 | list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list) | 418 | list_for_each_entry(dd, &ds->dependent_devices, list) |
| 364 | if (dd->ops && dd->ops->handler) | 419 | dock_hotplug_event(dd, event, false); |
| 365 | dd->ops->handler(dd->handle, event, dd->context); | ||
| 366 | 420 | ||
| 367 | /* | 421 | /* |
| 368 | * Now make sure that an acpi_device is created for each | 422 | * Now make sure that an acpi_device is created for each |
| @@ -398,9 +452,8 @@ static void dock_event(struct dock_station *ds, u32 event, int num) | |||
| 398 | if (num == DOCK_EVENT) | 452 | if (num == DOCK_EVENT) |
| 399 | kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp); | 453 | kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp); |
| 400 | 454 | ||
| 401 | list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list) | 455 | list_for_each_entry(dd, &ds->dependent_devices, list) |
| 402 | if (dd->ops && dd->ops->uevent) | 456 | dock_hotplug_event(dd, event, true); |
| 403 | dd->ops->uevent(dd->handle, event, dd->context); | ||
| 404 | 457 | ||
| 405 | if (num != DOCK_EVENT) | 458 | if (num != DOCK_EVENT) |
| 406 | kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp); | 459 | kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp); |
| @@ -570,19 +623,24 @@ EXPORT_SYMBOL_GPL(unregister_dock_notifier); | |||
| 570 | * @handle: the handle of the device | 623 | * @handle: the handle of the device |
| 571 | * @ops: handlers to call after docking | 624 | * @ops: handlers to call after docking |
| 572 | * @context: device specific data | 625 | * @context: device specific data |
| 626 | * @init: Optional initialization routine to run after registration | ||
| 627 | * @release: Optional release routine to run on unregistration | ||
| 573 | * | 628 | * |
| 574 | * If a driver would like to perform a hotplug operation after a dock | 629 | * If a driver would like to perform a hotplug operation after a dock |
| 575 | * event, they can register an acpi_notifiy_handler to be called by | 630 | * event, they can register an acpi_notifiy_handler to be called by |
| 576 | * the dock driver after _DCK is executed. | 631 | * the dock driver after _DCK is executed. |
| 577 | */ | 632 | */ |
| 578 | int | 633 | int register_hotplug_dock_device(acpi_handle handle, |
| 579 | register_hotplug_dock_device(acpi_handle handle, const struct acpi_dock_ops *ops, | 634 | const struct acpi_dock_ops *ops, void *context, |
| 580 | void *context) | 635 | void (*init)(void *), void (*release)(void *)) |
| 581 | { | 636 | { |
| 582 | struct dock_dependent_device *dd; | 637 | struct dock_dependent_device *dd; |
| 583 | struct dock_station *dock_station; | 638 | struct dock_station *dock_station; |
| 584 | int ret = -EINVAL; | 639 | int ret = -EINVAL; |
| 585 | 640 | ||
| 641 | if (WARN_ON(!context)) | ||
| 642 | return -EINVAL; | ||
| 643 | |||
| 586 | if (!dock_station_count) | 644 | if (!dock_station_count) |
| 587 | return -ENODEV; | 645 | return -ENODEV; |
| 588 | 646 | ||
| @@ -597,12 +655,8 @@ register_hotplug_dock_device(acpi_handle handle, const struct acpi_dock_ops *ops | |||
| 597 | * ops | 655 | * ops |
| 598 | */ | 656 | */ |
| 599 | dd = find_dock_dependent_device(dock_station, handle); | 657 | dd = find_dock_dependent_device(dock_station, handle); |
| 600 | if (dd) { | 658 | if (dd && !dock_init_hotplug(dd, ops, context, init, release)) |
| 601 | dd->ops = ops; | ||
| 602 | dd->context = context; | ||
| 603 | dock_add_hotplug_device(dock_station, dd); | ||
| 604 | ret = 0; | 659 | ret = 0; |
| 605 | } | ||
| 606 | } | 660 | } |
| 607 | 661 | ||
| 608 | return ret; | 662 | return ret; |
| @@ -624,7 +678,7 @@ void unregister_hotplug_dock_device(acpi_handle handle) | |||
| 624 | list_for_each_entry(dock_station, &dock_stations, sibling) { | 678 | list_for_each_entry(dock_station, &dock_stations, sibling) { |
| 625 | dd = find_dock_dependent_device(dock_station, handle); | 679 | dd = find_dock_dependent_device(dock_station, handle); |
| 626 | if (dd) | 680 | if (dd) |
| 627 | dock_del_hotplug_device(dock_station, dd); | 681 | dock_release_hotplug(dd); |
| 628 | } | 682 | } |
| 629 | } | 683 | } |
| 630 | EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device); | 684 | EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device); |
| @@ -953,7 +1007,6 @@ static int __init dock_add(acpi_handle handle) | |||
| 953 | mutex_init(&dock_station->hp_lock); | 1007 | mutex_init(&dock_station->hp_lock); |
| 954 | spin_lock_init(&dock_station->dd_lock); | 1008 | spin_lock_init(&dock_station->dd_lock); |
| 955 | INIT_LIST_HEAD(&dock_station->sibling); | 1009 | INIT_LIST_HEAD(&dock_station->sibling); |
| 956 | INIT_LIST_HEAD(&dock_station->hotplug_devices); | ||
| 957 | ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list); | 1010 | ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list); |
| 958 | INIT_LIST_HEAD(&dock_station->dependent_devices); | 1011 | INIT_LIST_HEAD(&dock_station->dependent_devices); |
| 959 | 1012 | ||
| @@ -994,30 +1047,6 @@ err_unregister: | |||
| 994 | } | 1047 | } |
| 995 | 1048 | ||
| 996 | /** | 1049 | /** |
| 997 | * dock_remove - free up resources related to the dock station | ||
| 998 | */ | ||
| 999 | static int dock_remove(struct dock_station *ds) | ||
| 1000 | { | ||
| 1001 | struct dock_dependent_device *dd, *tmp; | ||
| 1002 | struct platform_device *dock_device = ds->dock_device; | ||
| 1003 | |||
| 1004 | if (!dock_station_count) | ||
| 1005 | return 0; | ||
| 1006 | |||
| 1007 | /* remove dependent devices */ | ||
| 1008 | list_for_each_entry_safe(dd, tmp, &ds->dependent_devices, list) | ||
| 1009 | kfree(dd); | ||
| 1010 | |||
| 1011 | list_del(&ds->sibling); | ||
| 1012 | |||
| 1013 | /* cleanup sysfs */ | ||
| 1014 | sysfs_remove_group(&dock_device->dev.kobj, &dock_attribute_group); | ||
| 1015 | platform_device_unregister(dock_device); | ||
| 1016 | |||
| 1017 | return 0; | ||
| 1018 | } | ||
| 1019 | |||
| 1020 | /** | ||
| 1021 | * find_dock_and_bay - look for dock stations and bays | 1050 | * find_dock_and_bay - look for dock stations and bays |
| 1022 | * @handle: acpi handle of a device | 1051 | * @handle: acpi handle of a device |
| 1023 | * @lvl: unused | 1052 | * @lvl: unused |
| @@ -1035,7 +1064,7 @@ find_dock_and_bay(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
| 1035 | return AE_OK; | 1064 | return AE_OK; |
| 1036 | } | 1065 | } |
| 1037 | 1066 | ||
| 1038 | static int __init dock_init(void) | 1067 | int __init acpi_dock_init(void) |
| 1039 | { | 1068 | { |
| 1040 | if (acpi_disabled) | 1069 | if (acpi_disabled) |
| 1041 | return 0; | 1070 | return 0; |
| @@ -1054,19 +1083,3 @@ static int __init dock_init(void) | |||
| 1054 | ACPI_DOCK_DRIVER_DESCRIPTION, dock_station_count); | 1083 | ACPI_DOCK_DRIVER_DESCRIPTION, dock_station_count); |
| 1055 | return 0; | 1084 | return 0; |
| 1056 | } | 1085 | } |
| 1057 | |||
| 1058 | static void __exit dock_exit(void) | ||
| 1059 | { | ||
| 1060 | struct dock_station *tmp, *dock_station; | ||
| 1061 | |||
| 1062 | unregister_acpi_bus_notifier(&dock_acpi_notifier); | ||
| 1063 | list_for_each_entry_safe(dock_station, tmp, &dock_stations, sibling) | ||
| 1064 | dock_remove(dock_station); | ||
| 1065 | } | ||
| 1066 | |||
| 1067 | /* | ||
| 1068 | * Must be called before drivers of devices in dock, otherwise we can't know | ||
| 1069 | * which devices are in a dock | ||
| 1070 | */ | ||
| 1071 | subsys_initcall(dock_init); | ||
| 1072 | module_exit(dock_exit); | ||
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 297cbf456f86..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 |
| @@ -40,11 +41,23 @@ void acpi_container_init(void); | |||
| 40 | #else | 41 | #else |
| 41 | static inline void acpi_container_init(void) {} | 42 | static inline void acpi_container_init(void) {} |
| 42 | #endif | 43 | #endif |
| 44 | #ifdef CONFIG_ACPI_DOCK | ||
| 45 | void acpi_dock_init(void); | ||
| 46 | #else | ||
| 47 | static inline void acpi_dock_init(void) {} | ||
| 48 | #endif | ||
| 43 | #ifdef CONFIG_ACPI_HOTPLUG_MEMORY | 49 | #ifdef CONFIG_ACPI_HOTPLUG_MEMORY |
| 44 | void acpi_memory_hotplug_init(void); | 50 | void acpi_memory_hotplug_init(void); |
| 45 | #else | 51 | #else |
| 46 | static inline void acpi_memory_hotplug_init(void) {} | 52 | static inline void acpi_memory_hotplug_init(void) {} |
| 47 | #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; | ||
| 48 | 61 | ||
| 49 | void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug, | 62 | void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug, |
| 50 | const char *name); | 63 | const char *name); |
| @@ -76,6 +89,8 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, | |||
| 76 | int type, unsigned long long sta); | 89 | int type, unsigned long long sta); |
| 77 | void acpi_device_add_finalize(struct acpi_device *device); | 90 | void acpi_device_add_finalize(struct acpi_device *device); |
| 78 | 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); | ||
| 79 | 94 | ||
| 80 | /* -------------------------------------------------------------------------- | 95 | /* -------------------------------------------------------------------------- |
| 81 | Power Resource | 96 | Power Resource |
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index e72186340fec..da6b6634e5b3 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
| @@ -1715,6 +1715,17 @@ acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object) | |||
| 1715 | } | 1715 | } |
| 1716 | #endif | 1716 | #endif |
| 1717 | 1717 | ||
| 1718 | static int __init acpi_no_auto_ssdt_setup(char *s) | ||
| 1719 | { | ||
| 1720 | printk(KERN_NOTICE PREFIX "SSDT auto-load disabled\n"); | ||
| 1721 | |||
| 1722 | acpi_gbl_disable_ssdt_table_load = TRUE; | ||
| 1723 | |||
| 1724 | return 1; | ||
| 1725 | } | ||
| 1726 | |||
| 1727 | __setup("acpi_no_auto_ssdt", acpi_no_auto_ssdt_setup); | ||
| 1728 | |||
| 1718 | acpi_status __init acpi_os_initialize(void) | 1729 | acpi_status __init acpi_os_initialize(void) |
| 1719 | { | 1730 | { |
| 1720 | acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1a_event_block); | 1731 | 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..d93963f1e8f4 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,52 +26,29 @@ | |||
| 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" | 46 | #define ACPI_PROCESSOR_FILE_INFO "info" |
| 67 | #define ACPI_PROCESSOR_FILE_THROTTLING "throttling" | 47 | #define ACPI_PROCESSOR_FILE_THROTTLING "throttling" |
| 68 | #define ACPI_PROCESSOR_FILE_LIMIT "limit" | 48 | #define ACPI_PROCESSOR_FILE_LIMIT "limit" |
| 69 | #define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80 | 49 | #define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80 |
| 70 | #define ACPI_PROCESSOR_NOTIFY_POWER 0x81 | 50 | #define ACPI_PROCESSOR_NOTIFY_POWER 0x81 |
| 71 | #define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82 | 51 | #define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82 |
| 72 | #define ACPI_PROCESSOR_DEVICE_HID "ACPI0007" | ||
| 73 | 52 | ||
| 74 | #define ACPI_PROCESSOR_LIMIT_USER 0 | 53 | #define ACPI_PROCESSOR_LIMIT_USER 0 |
| 75 | #define ACPI_PROCESSOR_LIMIT_THERMAL 1 | 54 | #define ACPI_PROCESSOR_LIMIT_THERMAL 1 |
| @@ -81,12 +60,8 @@ MODULE_AUTHOR("Paul Diefenbaugh"); | |||
| 81 | MODULE_DESCRIPTION("ACPI Processor Driver"); | 60 | MODULE_DESCRIPTION("ACPI Processor Driver"); |
| 82 | MODULE_LICENSE("GPL"); | 61 | MODULE_LICENSE("GPL"); |
| 83 | 62 | ||
| 84 | static int acpi_processor_add(struct acpi_device *device); | 63 | static int acpi_processor_start(struct device *dev); |
| 85 | static int acpi_processor_remove(struct acpi_device *device); | 64 | 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 | 65 | ||
| 91 | static const struct acpi_device_id processor_device_ids[] = { | 66 | static const struct acpi_device_id processor_device_ids[] = { |
| 92 | {ACPI_PROCESSOR_OBJECT_HID, 0}, | 67 | {ACPI_PROCESSOR_OBJECT_HID, 0}, |
| @@ -95,295 +70,24 @@ static const struct acpi_device_id processor_device_ids[] = { | |||
| 95 | }; | 70 | }; |
| 96 | MODULE_DEVICE_TABLE(acpi, processor_device_ids); | 71 | MODULE_DEVICE_TABLE(acpi, processor_device_ids); |
| 97 | 72 | ||
| 98 | static struct acpi_driver acpi_processor_driver = { | 73 | static struct device_driver acpi_processor_driver = { |
| 99 | .name = "processor", | 74 | .name = "processor", |
| 100 | .class = ACPI_PROCESSOR_CLASS, | 75 | .bus = &cpu_subsys, |
| 101 | .ids = processor_device_ids, | 76 | .acpi_match_table = processor_device_ids, |
| 102 | .ops = { | 77 | .probe = acpi_processor_start, |
| 103 | .add = acpi_processor_add, | 78 | .remove = acpi_processor_stop, |
| 104 | .remove = acpi_processor_remove, | ||
| 105 | .notify = acpi_processor_notify, | ||
| 106 | }, | ||
| 107 | }; | 79 | }; |
| 108 | 80 | ||
| 109 | #define INSTALL_NOTIFY_HANDLER 1 | 81 | 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 | { | 82 | { |
| 123 | u8 value1 = 0; | 83 | struct acpi_device *device = data; |
| 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 | { | ||
| 224 | int result = 0; | ||
| 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; | 84 | 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; | 85 | int saved; |
| 386 | 86 | ||
| 87 | if (device->handle != handle) | ||
| 88 | return; | ||
| 89 | |||
| 90 | pr = acpi_driver_data(device); | ||
| 387 | if (!pr) | 91 | if (!pr) |
| 388 | return; | 92 | return; |
| 389 | 93 | ||
| @@ -420,55 +124,62 @@ static void acpi_processor_notify(struct acpi_device *device, u32 event) | |||
| 420 | return; | 124 | return; |
| 421 | } | 125 | } |
| 422 | 126 | ||
| 423 | static int acpi_cpu_soft_notify(struct notifier_block *nfb, | 127 | static __cpuinit int __acpi_processor_start(struct acpi_device *device); |
| 424 | unsigned long action, void *hcpu) | 128 | |
| 129 | static int __cpuinit acpi_cpu_soft_notify(struct notifier_block *nfb, | ||
| 130 | unsigned long action, void *hcpu) | ||
| 425 | { | 131 | { |
| 426 | unsigned int cpu = (unsigned long)hcpu; | 132 | unsigned int cpu = (unsigned long)hcpu; |
| 427 | struct acpi_processor *pr = per_cpu(processors, cpu); | 133 | struct acpi_processor *pr = per_cpu(processors, cpu); |
| 134 | struct acpi_device *device; | ||
| 135 | |||
| 136 | if (!pr || acpi_bus_get_device(pr->handle, &device)) | ||
| 137 | return NOTIFY_DONE; | ||
| 428 | 138 | ||
| 429 | if (action == CPU_ONLINE && pr) { | 139 | if (action == CPU_ONLINE) { |
| 430 | /* CPU got physically hotplugged and onlined the first time: | 140 | /* |
| 431 | * Initialize missing things | 141 | * CPU got physically hotplugged and onlined for the first time: |
| 142 | * Initialize missing things. | ||
| 432 | */ | 143 | */ |
| 433 | if (pr->flags.need_hotplug_init) { | 144 | if (pr->flags.need_hotplug_init) { |
| 145 | int ret; | ||
| 146 | |||
| 434 | pr_info("Will online and init hotplugged CPU: %d\n", | 147 | pr_info("Will online and init hotplugged CPU: %d\n", |
| 435 | pr->id); | 148 | pr->id); |
| 436 | WARN(acpi_processor_start(pr), "Failed to start CPU:" | ||
| 437 | " %d\n", pr->id); | ||
| 438 | pr->flags.need_hotplug_init = 0; | 149 | pr->flags.need_hotplug_init = 0; |
| 439 | /* Normal CPU soft online event */ | 150 | ret = __acpi_processor_start(device); |
| 151 | WARN(ret, "Failed to start CPU: %d\n", pr->id); | ||
| 440 | } else { | 152 | } else { |
| 153 | /* Normal CPU soft online event. */ | ||
| 441 | acpi_processor_ppc_has_changed(pr, 0); | 154 | acpi_processor_ppc_has_changed(pr, 0); |
| 442 | acpi_processor_hotplug(pr); | 155 | acpi_processor_hotplug(pr); |
| 443 | acpi_processor_reevaluate_tstate(pr, action); | 156 | acpi_processor_reevaluate_tstate(pr, action); |
| 444 | acpi_processor_tstate_has_changed(pr); | 157 | acpi_processor_tstate_has_changed(pr); |
| 445 | } | 158 | } |
| 446 | } | 159 | } else if (action == CPU_DEAD) { |
| 447 | if (action == CPU_DEAD && pr) { | 160 | /* 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); | 161 | acpi_processor_reevaluate_tstate(pr, action); |
| 450 | } | 162 | } |
| 451 | return NOTIFY_OK; | 163 | return NOTIFY_OK; |
| 452 | } | 164 | } |
| 453 | 165 | ||
| 454 | static struct notifier_block acpi_cpu_notifier = | 166 | static struct notifier_block __refdata acpi_cpu_notifier = |
| 455 | { | 167 | { |
| 456 | .notifier_call = acpi_cpu_soft_notify, | 168 | .notifier_call = acpi_cpu_soft_notify, |
| 457 | }; | 169 | }; |
| 458 | 170 | ||
| 459 | /* | 171 | 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 | { | 172 | { |
| 469 | struct acpi_device *device = per_cpu(processor_device_array, pr->id); | 173 | struct acpi_processor *pr = acpi_driver_data(device); |
| 174 | acpi_status status; | ||
| 470 | int result = 0; | 175 | int result = 0; |
| 471 | 176 | ||
| 177 | if (!pr) | ||
| 178 | return -ENODEV; | ||
| 179 | |||
| 180 | if (pr->flags.need_hotplug_init) | ||
| 181 | return 0; | ||
| 182 | |||
| 472 | #ifdef CONFIG_CPU_FREQ | 183 | #ifdef CONFIG_CPU_FREQ |
| 473 | acpi_processor_ppc_has_changed(pr, 0); | 184 | acpi_processor_ppc_has_changed(pr, 0); |
| 474 | acpi_processor_load_module(pr); | 185 | acpi_processor_load_module(pr); |
| @@ -506,462 +217,95 @@ static __ref int acpi_processor_start(struct acpi_processor *pr) | |||
| 506 | goto err_remove_sysfs_thermal; | 217 | goto err_remove_sysfs_thermal; |
| 507 | } | 218 | } |
| 508 | 219 | ||
| 509 | return 0; | 220 | status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, |
| 221 | acpi_processor_notify, device); | ||
| 222 | if (ACPI_SUCCESS(status)) | ||
| 223 | return 0; | ||
| 510 | 224 | ||
| 511 | err_remove_sysfs_thermal: | 225 | sysfs_remove_link(&pr->cdev->device.kobj, "device"); |
| 226 | err_remove_sysfs_thermal: | ||
| 512 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); | 227 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); |
| 513 | err_thermal_unregister: | 228 | err_thermal_unregister: |
| 514 | thermal_cooling_device_unregister(pr->cdev); | 229 | thermal_cooling_device_unregister(pr->cdev); |
| 515 | err_power_exit: | 230 | err_power_exit: |
| 516 | acpi_processor_power_exit(pr); | 231 | acpi_processor_power_exit(pr); |
| 517 | |||
| 518 | return result; | 232 | return result; |
| 519 | } | 233 | } |
| 520 | 234 | ||
| 521 | /* | 235 | 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 | { | 236 | { |
| 529 | struct acpi_processor *pr = NULL; | 237 | 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 | |||
| 553 | #ifdef CONFIG_SMP | ||
| 554 | if (pr->id >= setup_max_cpus && pr->id != 0) | ||
| 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 | |||
| 575 | per_cpu(processors, pr->id) = pr; | ||
| 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 | 238 | ||
| 583 | /* | 239 | if (acpi_bus_get_device(ACPI_HANDLE(dev), &device)) |
| 584 | * Do not start hotplugged CPUs now, but when they | 240 | return -ENODEV; |
| 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 | 241 | ||
| 596 | err_remove_sysfs: | 242 | return __acpi_processor_start(device); |
| 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 | } | 243 | } |
| 609 | 244 | ||
| 610 | static int acpi_processor_remove(struct acpi_device *device) | 245 | static int acpi_processor_stop(struct device *dev) |
| 611 | { | 246 | { |
| 612 | struct acpi_processor *pr = NULL; | 247 | struct acpi_device *device; |
| 248 | struct acpi_processor *pr; | ||
| 613 | 249 | ||
| 250 | if (acpi_bus_get_device(ACPI_HANDLE(dev), &device)) | ||
| 251 | return 0; | ||
| 614 | 252 | ||
| 615 | if (!device || !acpi_driver_data(device)) | 253 | acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, |
| 616 | return -EINVAL; | 254 | acpi_processor_notify); |
| 617 | 255 | ||
| 618 | pr = acpi_driver_data(device); | 256 | pr = acpi_driver_data(device); |
| 619 | 257 | if (!pr) | |
| 620 | if (pr->id >= nr_cpu_ids) | 258 | 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 | 259 | ||
| 628 | acpi_processor_power_exit(pr); | 260 | acpi_processor_power_exit(pr); |
| 629 | 261 | ||
| 630 | sysfs_remove_link(&device->dev.kobj, "sysdev"); | ||
| 631 | |||
| 632 | if (pr->cdev) { | 262 | if (pr->cdev) { |
| 633 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); | 263 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); |
| 634 | sysfs_remove_link(&pr->cdev->device.kobj, "device"); | 264 | sysfs_remove_link(&pr->cdev->device.kobj, "device"); |
| 635 | thermal_cooling_device_unregister(pr->cdev); | 265 | thermal_cooling_device_unregister(pr->cdev); |
| 636 | pr->cdev = NULL; | 266 | pr->cdev = NULL; |
| 637 | } | 267 | } |
| 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; | 268 | return 0; |
| 648 | } | 269 | } |
| 649 | 270 | ||
| 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 | /* | 271 | /* |
| 917 | * We keep the driver loaded even when ACPI is not running. | 272 | * We keep the driver loaded even when ACPI is not running. |
| 918 | * This is needed for the powernow-k8 driver, that works even without | 273 | * This is needed for the powernow-k8 driver, that works even without |
| 919 | * ACPI, but needs symbols from this driver | 274 | * ACPI, but needs symbols from this driver |
| 920 | */ | 275 | */ |
| 921 | 276 | ||
| 922 | static int __init acpi_processor_init(void) | 277 | static int __init acpi_processor_driver_init(void) |
| 923 | { | 278 | { |
| 924 | int result = 0; | 279 | int result = 0; |
| 925 | 280 | ||
| 926 | if (acpi_disabled) | 281 | if (acpi_disabled) |
| 927 | return 0; | 282 | return 0; |
| 928 | 283 | ||
| 929 | result = acpi_bus_register_driver(&acpi_processor_driver); | 284 | result = driver_register(&acpi_processor_driver); |
| 930 | if (result < 0) | 285 | if (result < 0) |
| 931 | return result; | 286 | return result; |
| 932 | 287 | ||
| 933 | acpi_processor_syscore_init(); | 288 | acpi_processor_syscore_init(); |
| 934 | 289 | register_hotcpu_notifier(&acpi_cpu_notifier); | |
| 935 | acpi_processor_install_hotplug_notify(); | ||
| 936 | |||
| 937 | acpi_thermal_cpufreq_init(); | 290 | acpi_thermal_cpufreq_init(); |
| 938 | |||
| 939 | acpi_processor_ppc_init(); | 291 | acpi_processor_ppc_init(); |
| 940 | |||
| 941 | acpi_processor_throttling_init(); | 292 | acpi_processor_throttling_init(); |
| 942 | |||
| 943 | return 0; | 293 | return 0; |
| 944 | } | 294 | } |
| 945 | 295 | ||
| 946 | static void __exit acpi_processor_exit(void) | 296 | static void __exit acpi_processor_driver_exit(void) |
| 947 | { | 297 | { |
| 948 | if (acpi_disabled) | 298 | if (acpi_disabled) |
| 949 | return; | 299 | return; |
| 950 | 300 | ||
| 951 | acpi_processor_ppc_exit(); | 301 | acpi_processor_ppc_exit(); |
| 952 | |||
| 953 | acpi_thermal_cpufreq_exit(); | 302 | acpi_thermal_cpufreq_exit(); |
| 954 | 303 | unregister_hotcpu_notifier(&acpi_cpu_notifier); | |
| 955 | acpi_processor_uninstall_hotplug_notify(); | ||
| 956 | |||
| 957 | acpi_processor_syscore_exit(); | 304 | acpi_processor_syscore_exit(); |
| 958 | 305 | driver_unregister(&acpi_processor_driver); | |
| 959 | acpi_bus_unregister_driver(&acpi_processor_driver); | ||
| 960 | |||
| 961 | return; | ||
| 962 | } | 306 | } |
| 963 | 307 | ||
| 964 | module_init(acpi_processor_init); | 308 | module_init(acpi_processor_driver_init); |
| 965 | module_exit(acpi_processor_exit); | 309 | module_exit(acpi_processor_driver_exit); |
| 966 | 310 | ||
| 967 | MODULE_ALIAS("processor"); | 311 | 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/scan.c b/drivers/acpi/scan.c index b14ac46948c9..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,10 +2129,13 @@ 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(); |
| 2138 | acpi_dock_init(); | ||
| 2045 | 2139 | ||
| 2046 | mutex_lock(&acpi_scan_lock); | 2140 | mutex_lock(&acpi_scan_lock); |
| 2047 | /* | 2141 | /* |
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/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index 87f2f395d79a..cf4e7020adac 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c | |||
| @@ -156,8 +156,10 @@ static void ata_acpi_handle_hotplug(struct ata_port *ap, struct ata_device *dev, | |||
| 156 | 156 | ||
| 157 | spin_unlock_irqrestore(ap->lock, flags); | 157 | spin_unlock_irqrestore(ap->lock, flags); |
| 158 | 158 | ||
| 159 | if (wait) | 159 | if (wait) { |
| 160 | ata_port_wait_eh(ap); | 160 | ata_port_wait_eh(ap); |
| 161 | flush_work(&ap->hotplug_task.work); | ||
| 162 | } | ||
| 161 | } | 163 | } |
| 162 | 164 | ||
| 163 | static void ata_acpi_dev_notify_dock(acpi_handle handle, u32 event, void *data) | 165 | static void ata_acpi_dev_notify_dock(acpi_handle handle, u32 event, void *data) |
| @@ -214,6 +216,39 @@ static const struct acpi_dock_ops ata_acpi_ap_dock_ops = { | |||
| 214 | .uevent = ata_acpi_ap_uevent, | 216 | .uevent = ata_acpi_ap_uevent, |
| 215 | }; | 217 | }; |
| 216 | 218 | ||
| 219 | void ata_acpi_hotplug_init(struct ata_host *host) | ||
| 220 | { | ||
| 221 | int i; | ||
| 222 | |||
| 223 | for (i = 0; i < host->n_ports; i++) { | ||
| 224 | struct ata_port *ap = host->ports[i]; | ||
| 225 | acpi_handle handle; | ||
| 226 | struct ata_device *dev; | ||
| 227 | |||
| 228 | if (!ap) | ||
| 229 | continue; | ||
| 230 | |||
| 231 | handle = ata_ap_acpi_handle(ap); | ||
| 232 | if (handle) { | ||
| 233 | /* we might be on a docking station */ | ||
| 234 | register_hotplug_dock_device(handle, | ||
| 235 | &ata_acpi_ap_dock_ops, ap, | ||
| 236 | NULL, NULL); | ||
| 237 | } | ||
| 238 | |||
| 239 | ata_for_each_dev(dev, &ap->link, ALL) { | ||
| 240 | handle = ata_dev_acpi_handle(dev); | ||
| 241 | if (!handle) | ||
| 242 | continue; | ||
| 243 | |||
| 244 | /* we might be on a docking station */ | ||
| 245 | register_hotplug_dock_device(handle, | ||
| 246 | &ata_acpi_dev_dock_ops, | ||
| 247 | dev, NULL, NULL); | ||
| 248 | } | ||
| 249 | } | ||
| 250 | } | ||
| 251 | |||
| 217 | /** | 252 | /** |
| 218 | * ata_acpi_dissociate - dissociate ATA host from ACPI objects | 253 | * ata_acpi_dissociate - dissociate ATA host from ACPI objects |
| 219 | * @host: target ATA host | 254 | * @host: target ATA host |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index f2184276539d..adf002a3c584 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
| @@ -6148,6 +6148,8 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) | |||
| 6148 | if (rc) | 6148 | if (rc) |
| 6149 | goto err_tadd; | 6149 | goto err_tadd; |
| 6150 | 6150 | ||
| 6151 | ata_acpi_hotplug_init(host); | ||
| 6152 | |||
| 6151 | /* set cable, sata_spd_limit and report */ | 6153 | /* set cable, sata_spd_limit and report */ |
| 6152 | for (i = 0; i < host->n_ports; i++) { | 6154 | for (i = 0; i < host->n_ports; i++) { |
| 6153 | struct ata_port *ap = host->ports[i]; | 6155 | struct ata_port *ap = host->ports[i]; |
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index c949dd311b2e..577d902bc4de 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h | |||
| @@ -122,6 +122,7 @@ extern int ata_acpi_register(void); | |||
| 122 | extern void ata_acpi_unregister(void); | 122 | extern void ata_acpi_unregister(void); |
| 123 | extern void ata_acpi_bind(struct ata_device *dev); | 123 | extern void ata_acpi_bind(struct ata_device *dev); |
| 124 | extern void ata_acpi_unbind(struct ata_device *dev); | 124 | extern void ata_acpi_unbind(struct ata_device *dev); |
| 125 | extern void ata_acpi_hotplug_init(struct ata_host *host); | ||
| 125 | #else | 126 | #else |
| 126 | static inline void ata_acpi_dissociate(struct ata_host *host) { } | 127 | static inline void ata_acpi_dissociate(struct ata_host *host) { } |
| 127 | static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; } | 128 | static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; } |
| @@ -134,6 +135,7 @@ static inline int ata_acpi_register(void) { return 0; } | |||
| 134 | static inline void ata_acpi_unregister(void) { } | 135 | static inline void ata_acpi_unregister(void) { } |
| 135 | static inline void ata_acpi_bind(struct ata_device *dev) { } | 136 | static inline void ata_acpi_bind(struct ata_device *dev) { } |
| 136 | static inline void ata_acpi_unbind(struct ata_device *dev) { } | 137 | static inline void ata_acpi_unbind(struct ata_device *dev) { } |
| 138 | static inline void ata_acpi_hotplug_init(struct ata_host *host) {} | ||
| 137 | #endif | 139 | #endif |
| 138 | 140 | ||
| 139 | /* libata-scsi.c */ | 141 | /* libata-scsi.c */ |
diff --git a/drivers/base/core.c b/drivers/base/core.c index 2499cefdcdf2..2166f34b7d84 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) |
| @@ -1433,6 +1470,99 @@ EXPORT_SYMBOL_GPL(put_device); | |||
| 1433 | EXPORT_SYMBOL_GPL(device_create_file); | 1470 | EXPORT_SYMBOL_GPL(device_create_file); |
| 1434 | EXPORT_SYMBOL_GPL(device_remove_file); | 1471 | EXPORT_SYMBOL_GPL(device_remove_file); |
| 1435 | 1472 | ||
| 1473 | static DEFINE_MUTEX(device_hotplug_lock); | ||
| 1474 | |||
| 1475 | void lock_device_hotplug(void) | ||
| 1476 | { | ||
| 1477 | mutex_lock(&device_hotplug_lock); | ||
| 1478 | } | ||
| 1479 | |||
| 1480 | void unlock_device_hotplug(void) | ||
| 1481 | { | ||
| 1482 | mutex_unlock(&device_hotplug_lock); | ||
| 1483 | } | ||
| 1484 | |||
| 1485 | static int device_check_offline(struct device *dev, void *not_used) | ||
| 1486 | { | ||
| 1487 | int ret; | ||
| 1488 | |||
| 1489 | ret = device_for_each_child(dev, NULL, device_check_offline); | ||
| 1490 | if (ret) | ||
| 1491 | return ret; | ||
| 1492 | |||
| 1493 | return device_supports_offline(dev) && !dev->offline ? -EBUSY : 0; | ||
| 1494 | } | ||
| 1495 | |||
| 1496 | /** | ||
| 1497 | * device_offline - Prepare the device for hot-removal. | ||
| 1498 | * @dev: Device to be put offline. | ||
| 1499 | * | ||
| 1500 | * Execute the device bus type's .offline() callback, if present, to prepare | ||
| 1501 | * the device for a subsequent hot-removal. If that succeeds, the device must | ||
| 1502 | * not be used until either it is removed or its bus type's .online() callback | ||
| 1503 | * is executed. | ||
| 1504 | * | ||
| 1505 | * Call under device_hotplug_lock. | ||
| 1506 | */ | ||
| 1507 | int device_offline(struct device *dev) | ||
| 1508 | { | ||
| 1509 | int ret; | ||
| 1510 | |||
| 1511 | if (dev->offline_disabled) | ||
| 1512 | return -EPERM; | ||
| 1513 | |||
| 1514 | ret = device_for_each_child(dev, NULL, device_check_offline); | ||
| 1515 | if (ret) | ||
| 1516 | return ret; | ||
| 1517 | |||
| 1518 | device_lock(dev); | ||
| 1519 | if (device_supports_offline(dev)) { | ||
| 1520 | if (dev->offline) { | ||
| 1521 | ret = 1; | ||
| 1522 | } else { | ||
| 1523 | ret = dev->bus->offline(dev); | ||
| 1524 | if (!ret) { | ||
| 1525 | kobject_uevent(&dev->kobj, KOBJ_OFFLINE); | ||
| 1526 | dev->offline = true; | ||
| 1527 | } | ||
| 1528 | } | ||
| 1529 | } | ||
| 1530 | device_unlock(dev); | ||
| 1531 | |||
| 1532 | return ret; | ||
| 1533 | } | ||
| 1534 | |||
| 1535 | /** | ||
| 1536 | * device_online - Put the device back online after successful device_offline(). | ||
| 1537 | * @dev: Device to be put back online. | ||
| 1538 | * | ||
| 1539 | * If device_offline() has been successfully executed for @dev, but the device | ||
| 1540 | * has not been removed subsequently, execute its bus type's .online() callback | ||
| 1541 | * to indicate that the device can be used again. | ||
| 1542 | * | ||
| 1543 | * Call under device_hotplug_lock. | ||
| 1544 | */ | ||
| 1545 | int device_online(struct device *dev) | ||
| 1546 | { | ||
| 1547 | int ret = 0; | ||
| 1548 | |||
| 1549 | device_lock(dev); | ||
| 1550 | if (device_supports_offline(dev)) { | ||
| 1551 | if (dev->offline) { | ||
| 1552 | ret = dev->bus->online(dev); | ||
| 1553 | if (!ret) { | ||
| 1554 | kobject_uevent(&dev->kobj, KOBJ_ONLINE); | ||
| 1555 | dev->offline = false; | ||
| 1556 | } | ||
| 1557 | } else { | ||
| 1558 | ret = 1; | ||
| 1559 | } | ||
| 1560 | } | ||
| 1561 | device_unlock(dev); | ||
| 1562 | |||
| 1563 | return ret; | ||
| 1564 | } | ||
| 1565 | |||
| 1436 | struct root_device { | 1566 | struct root_device { |
| 1437 | struct device dev; | 1567 | struct device dev; |
| 1438 | struct module *owner; | 1568 | struct module *owner; |
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 3d48fc887ef4..1d110dc6f0c1 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,69 +38,45 @@ 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; | ||
| 42 | 47 | ||
| 43 | return sprintf(buf, "%u\n", !!cpu_online(cpu->dev.id)); | 48 | cpu_hotplug_driver_lock(); |
| 49 | |||
| 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 | 73 | ||
| 88 | static void __cpuinit register_cpu_control(struct cpu *cpu) | ||
| 89 | { | ||
| 90 | device_create_file(&cpu->dev, &dev_attr_online); | ||
| 91 | } | ||
| 92 | void unregister_cpu(struct cpu *cpu) | 74 | void unregister_cpu(struct cpu *cpu) |
| 93 | { | 75 | { |
| 94 | int logical_cpu = cpu->dev.id; | 76 | int logical_cpu = cpu->dev.id; |
| 95 | 77 | ||
| 96 | unregister_cpu_under_node(logical_cpu, cpu_to_node(logical_cpu)); | 78 | unregister_cpu_under_node(logical_cpu, cpu_to_node(logical_cpu)); |
| 97 | 79 | ||
| 98 | device_remove_file(&cpu->dev, &dev_attr_online); | ||
| 99 | |||
| 100 | device_unregister(&cpu->dev); | 80 | device_unregister(&cpu->dev); |
| 101 | per_cpu(cpu_sys_devices, logical_cpu) = NULL; | 81 | per_cpu(cpu_sys_devices, logical_cpu) = NULL; |
| 102 | return; | 82 | return; |
| @@ -123,12 +103,19 @@ static DEVICE_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); | |||
| 123 | static DEVICE_ATTR(release, S_IWUSR, NULL, cpu_release_store); | 103 | static DEVICE_ATTR(release, S_IWUSR, NULL, cpu_release_store); |
| 124 | #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ | 104 | #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ |
| 125 | 105 | ||
| 126 | #else /* ... !CONFIG_HOTPLUG_CPU */ | ||
| 127 | static inline void register_cpu_control(struct cpu *cpu) | ||
| 128 | { | ||
| 129 | } | ||
| 130 | #endif /* CONFIG_HOTPLUG_CPU */ | 106 | #endif /* CONFIG_HOTPLUG_CPU */ |
| 131 | 107 | ||
| 108 | struct bus_type cpu_subsys = { | ||
| 109 | .name = "cpu", | ||
| 110 | .dev_name = "cpu", | ||
| 111 | .match = cpu_subsys_match, | ||
| 112 | #ifdef CONFIG_HOTPLUG_CPU | ||
| 113 | .online = cpu_subsys_online, | ||
| 114 | .offline = cpu_subsys_offline, | ||
| 115 | #endif | ||
| 116 | }; | ||
| 117 | EXPORT_SYMBOL_GPL(cpu_subsys); | ||
| 118 | |||
| 132 | #ifdef CONFIG_KEXEC | 119 | #ifdef CONFIG_KEXEC |
| 133 | #include <linux/kexec.h> | 120 | #include <linux/kexec.h> |
| 134 | 121 | ||
| @@ -277,12 +264,12 @@ int __cpuinit register_cpu(struct cpu *cpu, int num) | |||
| 277 | cpu->dev.id = num; | 264 | cpu->dev.id = num; |
| 278 | cpu->dev.bus = &cpu_subsys; | 265 | cpu->dev.bus = &cpu_subsys; |
| 279 | cpu->dev.release = cpu_device_release; | 266 | cpu->dev.release = cpu_device_release; |
| 267 | cpu->dev.offline_disabled = !cpu->hotpluggable; | ||
| 268 | cpu->dev.offline = !cpu_online(num); | ||
| 280 | #ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE | 269 | #ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE |
| 281 | cpu->dev.bus->uevent = arch_cpu_uevent; | 270 | cpu->dev.bus->uevent = arch_cpu_uevent; |
| 282 | #endif | 271 | #endif |
| 283 | error = device_register(&cpu->dev); | 272 | error = device_register(&cpu->dev); |
| 284 | if (!error && cpu->hotpluggable) | ||
| 285 | register_cpu_control(cpu); | ||
| 286 | if (!error) | 273 | if (!error) |
| 287 | per_cpu(cpu_sys_devices, num) = &cpu->dev; | 274 | per_cpu(cpu_sys_devices, num) = &cpu->dev; |
| 288 | if (!error) | 275 | if (!error) |
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 14f8a6954da0..4ebf97f99fae 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); |
| @@ -88,6 +93,7 @@ int register_memory(struct memory_block *memory) | |||
| 88 | memory->dev.bus = &memory_subsys; | 93 | memory->dev.bus = &memory_subsys; |
| 89 | memory->dev.id = memory->start_section_nr / sections_per_block; | 94 | memory->dev.id = memory->start_section_nr / sections_per_block; |
| 90 | memory->dev.release = memory_block_release; | 95 | memory->dev.release = memory_block_release; |
| 96 | memory->dev.offline = memory->state == MEM_OFFLINE; | ||
| 91 | 97 | ||
| 92 | error = device_register(&memory->dev); | 98 | error = device_register(&memory->dev); |
| 93 | return error; | 99 | return error; |
| @@ -278,33 +284,64 @@ static int __memory_block_change_state(struct memory_block *mem, | |||
| 278 | { | 284 | { |
| 279 | int ret = 0; | 285 | int ret = 0; |
| 280 | 286 | ||
| 281 | if (mem->state != from_state_req) { | 287 | if (mem->state != from_state_req) |
| 282 | ret = -EINVAL; | 288 | return -EINVAL; |
| 283 | goto out; | ||
| 284 | } | ||
| 285 | 289 | ||
| 286 | if (to_state == MEM_OFFLINE) | 290 | if (to_state == MEM_OFFLINE) |
| 287 | mem->state = MEM_GOING_OFFLINE; | 291 | mem->state = MEM_GOING_OFFLINE; |
| 288 | 292 | ||
| 289 | ret = memory_block_action(mem->start_section_nr, to_state, online_type); | 293 | ret = memory_block_action(mem->start_section_nr, to_state, online_type); |
| 294 | mem->state = ret ? from_state_req : to_state; | ||
| 295 | return ret; | ||
| 296 | } | ||
| 290 | 297 | ||
| 291 | if (ret) { | 298 | static int memory_subsys_online(struct device *dev) |
| 292 | mem->state = from_state_req; | 299 | { |
| 293 | goto out; | 300 | struct memory_block *mem = container_of(dev, struct memory_block, dev); |
| 294 | } | 301 | int ret; |
| 295 | 302 | ||
| 296 | mem->state = to_state; | 303 | mutex_lock(&mem->state_mutex); |
| 297 | switch (mem->state) { | 304 | |
| 298 | case MEM_OFFLINE: | 305 | ret = mem->state == MEM_ONLINE ? 0 : |
| 299 | kobject_uevent(&mem->dev.kobj, KOBJ_OFFLINE); | 306 | __memory_block_change_state(mem, MEM_ONLINE, MEM_OFFLINE, |
| 300 | break; | 307 | ONLINE_KEEP); |
| 301 | case MEM_ONLINE: | 308 | |
| 302 | kobject_uevent(&mem->dev.kobj, KOBJ_ONLINE); | 309 | mutex_unlock(&mem->state_mutex); |
| 303 | break; | 310 | return ret; |
| 304 | default: | 311 | } |
| 305 | break; | 312 | |
| 313 | static int memory_subsys_offline(struct device *dev) | ||
| 314 | { | ||
| 315 | struct memory_block *mem = container_of(dev, struct memory_block, dev); | ||
| 316 | int ret; | ||
| 317 | |||
| 318 | mutex_lock(&mem->state_mutex); | ||
| 319 | |||
| 320 | ret = mem->state == MEM_OFFLINE ? 0 : | ||
| 321 | __memory_block_change_state(mem, MEM_OFFLINE, MEM_ONLINE, -1); | ||
| 322 | |||
| 323 | mutex_unlock(&mem->state_mutex); | ||
| 324 | return ret; | ||
| 325 | } | ||
| 326 | |||
| 327 | static int __memory_block_change_state_uevent(struct memory_block *mem, | ||
| 328 | unsigned long to_state, unsigned long from_state_req, | ||
| 329 | int online_type) | ||
| 330 | { | ||
| 331 | int ret = __memory_block_change_state(mem, to_state, from_state_req, | ||
| 332 | online_type); | ||
| 333 | if (!ret) { | ||
| 334 | switch (mem->state) { | ||
| 335 | case MEM_OFFLINE: | ||
| 336 | kobject_uevent(&mem->dev.kobj, KOBJ_OFFLINE); | ||
| 337 | break; | ||
| 338 | case MEM_ONLINE: | ||
| 339 | kobject_uevent(&mem->dev.kobj, KOBJ_ONLINE); | ||
| 340 | break; | ||
| 341 | default: | ||
| 342 | break; | ||
| 343 | } | ||
| 306 | } | 344 | } |
| 307 | out: | ||
| 308 | return ret; | 345 | return ret; |
| 309 | } | 346 | } |
| 310 | 347 | ||
| @@ -315,8 +352,8 @@ static int memory_block_change_state(struct memory_block *mem, | |||
| 315 | int ret; | 352 | int ret; |
| 316 | 353 | ||
| 317 | mutex_lock(&mem->state_mutex); | 354 | mutex_lock(&mem->state_mutex); |
| 318 | ret = __memory_block_change_state(mem, to_state, from_state_req, | 355 | ret = __memory_block_change_state_uevent(mem, to_state, from_state_req, |
| 319 | online_type); | 356 | online_type); |
| 320 | mutex_unlock(&mem->state_mutex); | 357 | mutex_unlock(&mem->state_mutex); |
| 321 | 358 | ||
| 322 | return ret; | 359 | return ret; |
| @@ -326,22 +363,34 @@ store_mem_state(struct device *dev, | |||
| 326 | struct device_attribute *attr, const char *buf, size_t count) | 363 | struct device_attribute *attr, const char *buf, size_t count) |
| 327 | { | 364 | { |
| 328 | struct memory_block *mem; | 365 | struct memory_block *mem; |
| 366 | bool offline; | ||
| 329 | int ret = -EINVAL; | 367 | int ret = -EINVAL; |
| 330 | 368 | ||
| 331 | mem = container_of(dev, struct memory_block, dev); | 369 | mem = container_of(dev, struct memory_block, dev); |
| 332 | 370 | ||
| 333 | if (!strncmp(buf, "online_kernel", min_t(int, count, 13))) | 371 | lock_device_hotplug(); |
| 372 | |||
| 373 | if (!strncmp(buf, "online_kernel", min_t(int, count, 13))) { | ||
| 374 | offline = false; | ||
| 334 | ret = memory_block_change_state(mem, MEM_ONLINE, | 375 | ret = memory_block_change_state(mem, MEM_ONLINE, |
| 335 | MEM_OFFLINE, ONLINE_KERNEL); | 376 | MEM_OFFLINE, ONLINE_KERNEL); |
| 336 | else if (!strncmp(buf, "online_movable", min_t(int, count, 14))) | 377 | } else if (!strncmp(buf, "online_movable", min_t(int, count, 14))) { |
| 378 | offline = false; | ||
| 337 | ret = memory_block_change_state(mem, MEM_ONLINE, | 379 | ret = memory_block_change_state(mem, MEM_ONLINE, |
| 338 | MEM_OFFLINE, ONLINE_MOVABLE); | 380 | MEM_OFFLINE, ONLINE_MOVABLE); |
| 339 | else if (!strncmp(buf, "online", min_t(int, count, 6))) | 381 | } else if (!strncmp(buf, "online", min_t(int, count, 6))) { |
| 382 | offline = false; | ||
| 340 | ret = memory_block_change_state(mem, MEM_ONLINE, | 383 | ret = memory_block_change_state(mem, MEM_ONLINE, |
| 341 | MEM_OFFLINE, ONLINE_KEEP); | 384 | MEM_OFFLINE, ONLINE_KEEP); |
| 342 | else if(!strncmp(buf, "offline", min_t(int, count, 7))) | 385 | } else if(!strncmp(buf, "offline", min_t(int, count, 7))) { |
| 386 | offline = true; | ||
| 343 | ret = memory_block_change_state(mem, MEM_OFFLINE, | 387 | ret = memory_block_change_state(mem, MEM_OFFLINE, |
| 344 | MEM_ONLINE, -1); | 388 | MEM_ONLINE, -1); |
| 389 | } | ||
| 390 | if (!ret) | ||
| 391 | dev->offline = offline; | ||
| 392 | |||
| 393 | unlock_device_hotplug(); | ||
| 345 | 394 | ||
| 346 | if (ret) | 395 | if (ret) |
| 347 | return ret; | 396 | return ret; |
| @@ -679,21 +728,6 @@ int unregister_memory_section(struct mem_section *section) | |||
| 679 | } | 728 | } |
| 680 | #endif /* CONFIG_MEMORY_HOTREMOVE */ | 729 | #endif /* CONFIG_MEMORY_HOTREMOVE */ |
| 681 | 730 | ||
| 682 | /* | ||
| 683 | * offline one memory block. If the memory block has been offlined, do nothing. | ||
| 684 | */ | ||
| 685 | int offline_memory_block(struct memory_block *mem) | ||
| 686 | { | ||
| 687 | int ret = 0; | ||
| 688 | |||
| 689 | mutex_lock(&mem->state_mutex); | ||
| 690 | if (mem->state != MEM_OFFLINE) | ||
| 691 | ret = __memory_block_change_state(mem, MEM_OFFLINE, MEM_ONLINE, -1); | ||
| 692 | mutex_unlock(&mem->state_mutex); | ||
| 693 | |||
| 694 | return ret; | ||
| 695 | } | ||
| 696 | |||
| 697 | /* return true if the memory block is offlined, otherwise, return false */ | 731 | /* return true if the memory block is offlined, otherwise, return false */ |
| 698 | bool is_memblock_offlined(struct memory_block *mem) | 732 | bool is_memblock_offlined(struct memory_block *mem) |
| 699 | { | 733 | { |
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/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index 2c5906d71397..f4fef0acc183 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c | |||
| @@ -1036,4 +1036,11 @@ static const struct x86_cpu_id acpi_cpufreq_ids[] = { | |||
| 1036 | }; | 1036 | }; |
| 1037 | MODULE_DEVICE_TABLE(x86cpu, acpi_cpufreq_ids); | 1037 | MODULE_DEVICE_TABLE(x86cpu, acpi_cpufreq_ids); |
| 1038 | 1038 | ||
| 1039 | static const struct acpi_device_id processor_device_ids[] = { | ||
| 1040 | {ACPI_PROCESSOR_OBJECT_HID, }, | ||
| 1041 | {ACPI_PROCESSOR_DEVICE_HID, }, | ||
| 1042 | {}, | ||
| 1043 | }; | ||
| 1044 | MODULE_DEVICE_TABLE(acpi, processor_device_ids); | ||
| 1045 | |||
| 1039 | MODULE_ALIAS("acpi"); | 1046 | MODULE_ALIAS("acpi"); |
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 4b9bb5def6f1..93eb5cbcc1f6 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
| @@ -47,6 +47,8 @@ static struct od_ops od_ops; | |||
| 47 | static struct cpufreq_governor cpufreq_gov_ondemand; | 47 | static struct cpufreq_governor cpufreq_gov_ondemand; |
| 48 | #endif | 48 | #endif |
| 49 | 49 | ||
| 50 | static unsigned int default_powersave_bias; | ||
| 51 | |||
| 50 | static void ondemand_powersave_bias_init_cpu(int cpu) | 52 | static void ondemand_powersave_bias_init_cpu(int cpu) |
| 51 | { | 53 | { |
| 52 | struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, cpu); | 54 | struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, cpu); |
| @@ -543,7 +545,7 @@ static int od_init(struct dbs_data *dbs_data) | |||
| 543 | 545 | ||
| 544 | tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR; | 546 | tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR; |
| 545 | tuners->ignore_nice = 0; | 547 | tuners->ignore_nice = 0; |
| 546 | tuners->powersave_bias = 0; | 548 | tuners->powersave_bias = default_powersave_bias; |
| 547 | tuners->io_is_busy = should_io_be_busy(); | 549 | tuners->io_is_busy = should_io_be_busy(); |
| 548 | 550 | ||
| 549 | dbs_data->tuners = tuners; | 551 | dbs_data->tuners = tuners; |
| @@ -585,6 +587,7 @@ static void od_set_powersave_bias(unsigned int powersave_bias) | |||
| 585 | unsigned int cpu; | 587 | unsigned int cpu; |
| 586 | cpumask_t done; | 588 | cpumask_t done; |
| 587 | 589 | ||
| 590 | default_powersave_bias = powersave_bias; | ||
| 588 | cpumask_clear(&done); | 591 | cpumask_clear(&done); |
| 589 | 592 | ||
| 590 | get_online_cpus(); | 593 | get_online_cpus(); |
| @@ -593,11 +596,17 @@ static void od_set_powersave_bias(unsigned int powersave_bias) | |||
| 593 | continue; | 596 | continue; |
| 594 | 597 | ||
| 595 | policy = per_cpu(od_cpu_dbs_info, cpu).cdbs.cur_policy; | 598 | policy = per_cpu(od_cpu_dbs_info, cpu).cdbs.cur_policy; |
| 596 | dbs_data = policy->governor_data; | 599 | if (!policy) |
| 597 | od_tuners = dbs_data->tuners; | 600 | continue; |
| 598 | od_tuners->powersave_bias = powersave_bias; | ||
| 599 | 601 | ||
| 600 | cpumask_or(&done, &done, policy->cpus); | 602 | cpumask_or(&done, &done, policy->cpus); |
| 603 | |||
| 604 | if (policy->governor != &cpufreq_gov_ondemand) | ||
| 605 | continue; | ||
| 606 | |||
| 607 | dbs_data = policy->governor_data; | ||
| 608 | od_tuners = dbs_data->tuners; | ||
| 609 | od_tuners->powersave_bias = default_powersave_bias; | ||
| 601 | } | 610 | } |
| 602 | put_online_cpus(); | 611 | put_online_cpus(); |
| 603 | } | 612 | } |
diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig index c4cc27e5c8a5..81de5d96749b 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,24 +22,26 @@ 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 |
| 39 | help | 35 | help |
| 40 | Select this to enable cpuidle on Calxeda processors. | 36 | Select this to enable cpuidle on Calxeda processors. |
| 41 | 37 | ||
| 38 | config CPU_IDLE_ZYNQ | ||
| 39 | bool "CPU Idle Driver for Xilinx Zynq processors" | ||
| 40 | depends on ARCH_ZYNQ | ||
| 41 | help | ||
| 42 | Select this to enable cpuidle on Xilinx Zynq processors. | ||
| 43 | |||
| 42 | endif | 44 | endif |
| 45 | |||
| 46 | config ARCH_NEEDS_CPU_IDLE_COUPLED | ||
| 47 | 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/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 716aa93fff76..59df8575a48c 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
| @@ -61,6 +61,7 @@ static DEFINE_MUTEX(bridge_mutex); | |||
| 61 | static void handle_hotplug_event_bridge (acpi_handle, u32, void *); | 61 | static void handle_hotplug_event_bridge (acpi_handle, u32, void *); |
| 62 | static void acpiphp_sanitize_bus(struct pci_bus *bus); | 62 | static void acpiphp_sanitize_bus(struct pci_bus *bus); |
| 63 | static void acpiphp_set_hpp_values(struct pci_bus *bus); | 63 | static void acpiphp_set_hpp_values(struct pci_bus *bus); |
| 64 | static void hotplug_event_func(acpi_handle handle, u32 type, void *context); | ||
| 64 | static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context); | 65 | static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context); |
| 65 | static void free_bridge(struct kref *kref); | 66 | static void free_bridge(struct kref *kref); |
| 66 | 67 | ||
| @@ -147,7 +148,7 @@ static int post_dock_fixups(struct notifier_block *nb, unsigned long val, | |||
| 147 | 148 | ||
| 148 | 149 | ||
| 149 | static const struct acpi_dock_ops acpiphp_dock_ops = { | 150 | static const struct acpi_dock_ops acpiphp_dock_ops = { |
| 150 | .handler = handle_hotplug_event_func, | 151 | .handler = hotplug_event_func, |
| 151 | }; | 152 | }; |
| 152 | 153 | ||
| 153 | /* Check whether the PCI device is managed by native PCIe hotplug driver */ | 154 | /* Check whether the PCI device is managed by native PCIe hotplug driver */ |
| @@ -179,6 +180,20 @@ static bool device_is_managed_by_native_pciehp(struct pci_dev *pdev) | |||
| 179 | return true; | 180 | return true; |
| 180 | } | 181 | } |
| 181 | 182 | ||
| 183 | static void acpiphp_dock_init(void *data) | ||
| 184 | { | ||
| 185 | struct acpiphp_func *func = data; | ||
| 186 | |||
| 187 | get_bridge(func->slot->bridge); | ||
| 188 | } | ||
| 189 | |||
| 190 | static void acpiphp_dock_release(void *data) | ||
| 191 | { | ||
| 192 | struct acpiphp_func *func = data; | ||
| 193 | |||
| 194 | put_bridge(func->slot->bridge); | ||
| 195 | } | ||
| 196 | |||
| 182 | /* callback routine to register each ACPI PCI slot object */ | 197 | /* callback routine to register each ACPI PCI slot object */ |
| 183 | static acpi_status | 198 | static acpi_status |
| 184 | register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | 199 | register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) |
| @@ -298,7 +313,8 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
| 298 | */ | 313 | */ |
| 299 | newfunc->flags &= ~FUNC_HAS_EJ0; | 314 | newfunc->flags &= ~FUNC_HAS_EJ0; |
| 300 | if (register_hotplug_dock_device(handle, | 315 | if (register_hotplug_dock_device(handle, |
| 301 | &acpiphp_dock_ops, newfunc)) | 316 | &acpiphp_dock_ops, newfunc, |
| 317 | acpiphp_dock_init, acpiphp_dock_release)) | ||
| 302 | dbg("failed to register dock device\n"); | 318 | dbg("failed to register dock device\n"); |
| 303 | 319 | ||
| 304 | /* we need to be notified when dock events happen | 320 | /* we need to be notified when dock events happen |
| @@ -670,6 +686,7 @@ static int __ref enable_device(struct acpiphp_slot *slot) | |||
| 670 | struct pci_bus *bus = slot->bridge->pci_bus; | 686 | struct pci_bus *bus = slot->bridge->pci_bus; |
| 671 | struct acpiphp_func *func; | 687 | struct acpiphp_func *func; |
| 672 | int num, max, pass; | 688 | int num, max, pass; |
| 689 | LIST_HEAD(add_list); | ||
| 673 | 690 | ||
| 674 | if (slot->flags & SLOT_ENABLED) | 691 | if (slot->flags & SLOT_ENABLED) |
| 675 | goto err_exit; | 692 | goto err_exit; |
| @@ -694,13 +711,15 @@ static int __ref enable_device(struct acpiphp_slot *slot) | |||
| 694 | max = pci_scan_bridge(bus, dev, max, pass); | 711 | max = pci_scan_bridge(bus, dev, max, pass); |
| 695 | if (pass && dev->subordinate) { | 712 | if (pass && dev->subordinate) { |
| 696 | check_hotplug_bridge(slot, dev); | 713 | check_hotplug_bridge(slot, dev); |
| 697 | pci_bus_size_bridges(dev->subordinate); | 714 | pcibios_resource_survey_bus(dev->subordinate); |
| 715 | __pci_bus_size_bridges(dev->subordinate, | ||
| 716 | &add_list); | ||
| 698 | } | 717 | } |
| 699 | } | 718 | } |
| 700 | } | 719 | } |
| 701 | } | 720 | } |
| 702 | 721 | ||
| 703 | pci_bus_assign_resources(bus); | 722 | __pci_bus_assign_resources(bus, &add_list, NULL); |
| 704 | acpiphp_sanitize_bus(bus); | 723 | acpiphp_sanitize_bus(bus); |
| 705 | acpiphp_set_hpp_values(bus); | 724 | acpiphp_set_hpp_values(bus); |
| 706 | acpiphp_set_acpi_region(slot); | 725 | acpiphp_set_acpi_region(slot); |
| @@ -1065,22 +1084,12 @@ static void handle_hotplug_event_bridge(acpi_handle handle, u32 type, | |||
| 1065 | alloc_acpi_hp_work(handle, type, context, _handle_hotplug_event_bridge); | 1084 | alloc_acpi_hp_work(handle, type, context, _handle_hotplug_event_bridge); |
| 1066 | } | 1085 | } |
| 1067 | 1086 | ||
| 1068 | static void _handle_hotplug_event_func(struct work_struct *work) | 1087 | static void hotplug_event_func(acpi_handle handle, u32 type, void *context) |
| 1069 | { | 1088 | { |
| 1070 | struct acpiphp_func *func; | 1089 | struct acpiphp_func *func = context; |
| 1071 | char objname[64]; | 1090 | char objname[64]; |
| 1072 | struct acpi_buffer buffer = { .length = sizeof(objname), | 1091 | struct acpi_buffer buffer = { .length = sizeof(objname), |
| 1073 | .pointer = objname }; | 1092 | .pointer = objname }; |
| 1074 | struct acpi_hp_work *hp_work; | ||
| 1075 | acpi_handle handle; | ||
| 1076 | u32 type; | ||
| 1077 | |||
| 1078 | hp_work = container_of(work, struct acpi_hp_work, work); | ||
| 1079 | handle = hp_work->handle; | ||
| 1080 | type = hp_work->type; | ||
| 1081 | func = (struct acpiphp_func *)hp_work->context; | ||
| 1082 | |||
| 1083 | acpi_scan_lock_acquire(); | ||
| 1084 | 1093 | ||
| 1085 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | 1094 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); |
| 1086 | 1095 | ||
| @@ -1113,6 +1122,18 @@ static void _handle_hotplug_event_func(struct work_struct *work) | |||
| 1113 | warn("notify_handler: unknown event type 0x%x for %s\n", type, objname); | 1122 | warn("notify_handler: unknown event type 0x%x for %s\n", type, objname); |
| 1114 | break; | 1123 | break; |
| 1115 | } | 1124 | } |
| 1125 | } | ||
| 1126 | |||
| 1127 | static void _handle_hotplug_event_func(struct work_struct *work) | ||
| 1128 | { | ||
| 1129 | struct acpi_hp_work *hp_work; | ||
| 1130 | struct acpiphp_func *func; | ||
| 1131 | |||
| 1132 | hp_work = container_of(work, struct acpi_hp_work, work); | ||
| 1133 | func = hp_work->context; | ||
| 1134 | acpi_scan_lock_acquire(); | ||
| 1135 | |||
| 1136 | hotplug_event_func(hp_work->handle, hp_work->type, func); | ||
| 1116 | 1137 | ||
| 1117 | acpi_scan_lock_release(); | 1138 | acpi_scan_lock_release(); |
| 1118 | kfree(hp_work); /* allocated in handle_hotplug_event_func */ | 1139 | kfree(hp_work); /* allocated in handle_hotplug_event_func */ |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 68678ed76b0d..d1182c4a754e 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
| @@ -202,6 +202,11 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, | |||
| 202 | struct resource *res, unsigned int reg); | 202 | struct resource *res, unsigned int reg); |
| 203 | int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type); | 203 | int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type); |
| 204 | void pci_configure_ari(struct pci_dev *dev); | 204 | void pci_configure_ari(struct pci_dev *dev); |
| 205 | void __ref __pci_bus_size_bridges(struct pci_bus *bus, | ||
| 206 | struct list_head *realloc_head); | ||
| 207 | void __ref __pci_bus_assign_resources(const struct pci_bus *bus, | ||
| 208 | struct list_head *realloc_head, | ||
| 209 | struct list_head *fail_head); | ||
| 205 | 210 | ||
| 206 | /** | 211 | /** |
| 207 | * pci_ari_enabled - query ARI forwarding status | 212 | * pci_ari_enabled - query ARI forwarding status |
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 16abaaa1f83c..d254e2379533 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
| @@ -1044,7 +1044,7 @@ handle_done: | |||
| 1044 | ; | 1044 | ; |
| 1045 | } | 1045 | } |
| 1046 | 1046 | ||
| 1047 | static void __ref __pci_bus_size_bridges(struct pci_bus *bus, | 1047 | void __ref __pci_bus_size_bridges(struct pci_bus *bus, |
| 1048 | struct list_head *realloc_head) | 1048 | struct list_head *realloc_head) |
| 1049 | { | 1049 | { |
| 1050 | struct pci_dev *dev; | 1050 | struct pci_dev *dev; |
| @@ -1115,9 +1115,9 @@ void __ref pci_bus_size_bridges(struct pci_bus *bus) | |||
| 1115 | } | 1115 | } |
| 1116 | EXPORT_SYMBOL(pci_bus_size_bridges); | 1116 | EXPORT_SYMBOL(pci_bus_size_bridges); |
| 1117 | 1117 | ||
| 1118 | static void __ref __pci_bus_assign_resources(const struct pci_bus *bus, | 1118 | void __ref __pci_bus_assign_resources(const struct pci_bus *bus, |
| 1119 | struct list_head *realloc_head, | 1119 | struct list_head *realloc_head, |
| 1120 | struct list_head *fail_head) | 1120 | struct list_head *fail_head) |
| 1121 | { | 1121 | { |
| 1122 | struct pci_bus *b; | 1122 | struct pci_bus *b; |
| 1123 | struct pci_dev *dev; | 1123 | struct pci_dev *dev; |
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/staging/android/binder.c b/drivers/staging/android/binder.c index 1567ac296b39..1ffc2ebdf612 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/fs/cifs/transport.c b/fs/cifs/transport.c index bfbf4700d160..b70aa7c91394 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/acpi_drivers.h b/include/acpi/acpi_drivers.h index e6168a24b9f0..b420939f5eb5 100644 --- a/include/acpi/acpi_drivers.h +++ b/include/acpi/acpi_drivers.h | |||
| @@ -123,7 +123,9 @@ extern int register_dock_notifier(struct notifier_block *nb); | |||
| 123 | extern void unregister_dock_notifier(struct notifier_block *nb); | 123 | extern void unregister_dock_notifier(struct notifier_block *nb); |
| 124 | extern int register_hotplug_dock_device(acpi_handle handle, | 124 | extern int register_hotplug_dock_device(acpi_handle handle, |
| 125 | const struct acpi_dock_ops *ops, | 125 | const struct acpi_dock_ops *ops, |
| 126 | void *context); | 126 | void *context, |
| 127 | void (*init)(void *), | ||
| 128 | void (*release)(void *)); | ||
| 127 | extern void unregister_hotplug_dock_device(acpi_handle handle); | 129 | extern void unregister_hotplug_dock_device(acpi_handle handle); |
| 128 | #else | 130 | #else |
| 129 | static inline int is_dock_device(acpi_handle handle) | 131 | static inline int is_dock_device(acpi_handle handle) |
| @@ -139,7 +141,9 @@ static inline void unregister_dock_notifier(struct notifier_block *nb) | |||
| 139 | } | 141 | } |
| 140 | static inline int register_hotplug_dock_device(acpi_handle handle, | 142 | static inline int register_hotplug_dock_device(acpi_handle handle, |
| 141 | const struct acpi_dock_ops *ops, | 143 | const struct acpi_dock_ops *ops, |
| 142 | void *context) | 144 | void *context, |
| 145 | void (*init)(void *), | ||
| 146 | void (*release)(void *)) | ||
| 143 | { | 147 | { |
| 144 | return -ENODEV; | 148 | return -ENODEV; |
| 145 | } | 149 | } |
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/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 c0a126125325..eeb33315514c 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 |
| @@ -104,6 +108,9 @@ struct bus_type { | |||
| 104 | int (*remove)(struct device *dev); | 108 | int (*remove)(struct device *dev); |
| 105 | void (*shutdown)(struct device *dev); | 109 | void (*shutdown)(struct device *dev); |
| 106 | 110 | ||
| 111 | int (*online)(struct device *dev); | ||
| 112 | int (*offline)(struct device *dev); | ||
| 113 | |||
| 107 | int (*suspend)(struct device *dev, pm_message_t state); | 114 | int (*suspend)(struct device *dev, pm_message_t state); |
| 108 | int (*resume)(struct device *dev); | 115 | int (*resume)(struct device *dev); |
| 109 | 116 | ||
| @@ -648,6 +655,8 @@ struct acpi_dev_node { | |||
| 648 | * @release: Callback to free the device after all references have | 655 | * @release: Callback to free the device after all references have |
| 649 | * gone away. This should be set by the allocator of the | 656 | * gone away. This should be set by the allocator of the |
| 650 | * device (i.e. the bus driver that discovered the device). | 657 | * device (i.e. the bus driver that discovered the device). |
| 658 | * @offline_disabled: If set, the device is permanently online. | ||
| 659 | * @offline: Set after successful invocation of bus type's .offline(). | ||
| 651 | * | 660 | * |
| 652 | * At the lowest level, every device in a Linux system is represented by an | 661 | * At the lowest level, every device in a Linux system is represented by an |
| 653 | * instance of struct device. The device structure contains the information | 662 | * instance of struct device. The device structure contains the information |
| @@ -720,6 +729,9 @@ struct device { | |||
| 720 | 729 | ||
| 721 | void (*release)(struct device *dev); | 730 | void (*release)(struct device *dev); |
| 722 | struct iommu_group *iommu_group; | 731 | struct iommu_group *iommu_group; |
| 732 | |||
| 733 | bool offline_disabled:1; | ||
| 734 | bool offline:1; | ||
| 723 | }; | 735 | }; |
| 724 | 736 | ||
| 725 | static inline struct device *kobj_to_dev(struct kobject *kobj) | 737 | static inline struct device *kobj_to_dev(struct kobject *kobj) |
| @@ -856,6 +868,15 @@ extern const char *device_get_devnode(struct device *dev, | |||
| 856 | extern void *dev_get_drvdata(const struct device *dev); | 868 | extern void *dev_get_drvdata(const struct device *dev); |
| 857 | extern int dev_set_drvdata(struct device *dev, void *data); | 869 | extern int dev_set_drvdata(struct device *dev, void *data); |
| 858 | 870 | ||
| 871 | static inline bool device_supports_offline(struct device *dev) | ||
| 872 | { | ||
| 873 | return dev->bus && dev->bus->offline && dev->bus->online; | ||
| 874 | } | ||
| 875 | |||
| 876 | extern void lock_device_hotplug(void); | ||
| 877 | extern void unlock_device_hotplug(void); | ||
| 878 | extern int device_offline(struct device *dev); | ||
| 879 | extern int device_online(struct device *dev); | ||
| 859 | /* | 880 | /* |
| 860 | * Root device objects for grouping under /sys/devices | 881 | * Root device objects for grouping under /sys/devices |
| 861 | */ | 882 | */ |
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/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/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/futex.c b/kernel/futex.c index b26dcfc02c94..d710fae8abbe 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
| @@ -61,6 +61,7 @@ | |||
| 61 | #include <linux/nsproxy.h> | 61 | #include <linux/nsproxy.h> |
| 62 | #include <linux/ptrace.h> | 62 | #include <linux/ptrace.h> |
| 63 | #include <linux/sched/rt.h> | 63 | #include <linux/sched/rt.h> |
| 64 | #include <linux/freezer.h> | ||
| 64 | 65 | ||
| 65 | #include <asm/futex.h> | 66 | #include <asm/futex.h> |
| 66 | 67 | ||
| @@ -1807,7 +1808,7 @@ static void futex_wait_queue_me(struct futex_hash_bucket *hb, struct futex_q *q, | |||
| 1807 | * is no timeout, or if it has yet to expire. | 1808 | * is no timeout, or if it has yet to expire. |
| 1808 | */ | 1809 | */ |
| 1809 | if (!timeout || timeout->task) | 1810 | if (!timeout || timeout->task) |
| 1810 | schedule(); | 1811 | freezable_schedule(); |
| 1811 | } | 1812 | } |
| 1812 | __set_current_state(TASK_RUNNING); | 1813 | __set_current_state(TASK_RUNNING); |
| 1813 | } | 1814 | } |
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/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/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 | } |
