diff options
| author | Lan Tianyu <tianyu.lan@intel.com> | 2014-11-23 08:22:54 -0500 |
|---|---|---|
| committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-11-23 19:04:55 -0500 |
| commit | 40e7fcb19293cbdff02c74cb0668413480f82ea1 (patch) | |
| tree | 05e1c91e4f3b06bf4234d0ac1014acdf4757766b /drivers | |
| parent | 5d01410fe4d92081f349b013a2e7a95429e4f2c9 (diff) | |
ACPI: Add _DEP support to fix battery issue on Asus T100TA
ACPI 5.0 introduces _DEP (Operation Region Dependencies) to designate
device objects that OSPM should assign a higher priority in start
ordering due to future operation region accesses.
On Asus T100TA, ACPI battery info are read from a I2C slave device via
I2C operation region. Before I2C operation region handler is installed,
battery _STA always returns 0. There is a _DEP method of designating
start order under battery device node.
This patch is to implement _DEP feature to fix battery issue on the
Asus T100TA. Introducing acpi_dep_list and adding dep_unmet count
in struct acpi_device. During ACPI namespace scan, create struct
acpi_dep_data for a valid pair of master (device pointed to by _DEP)/
slave(device with _DEP), record master's and slave's ACPI handle in
it and put it into acpi_dep_list. The dep_unmet count will increase
by one if there is a device under its _DEP. Driver's probe() should
return EPROBE_DEFER when find dep_unmet is larger than 0. When I2C
operation region handler is installed, remove all struct acpi_dep_data
on the acpi_dep_list whose master is pointed to I2C host controller
and decrease slave's dep_unmet. When dep_unmet decreases to 0, all
_DEP conditions are met and then do acpi_bus_attach() for the device
in order to resolve battery _STA issue on the Asus T100TA.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=69011
Tested-by: Jan-Michael Brummer <jan.brummer@tabos.org>
Tested-by: Adam Williamson <adamw@happyassassin.net>
Tested-by: Michael Shigorin <shigorin@gmail.com>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/acpi/battery.c | 4 | ||||
| -rw-r--r-- | drivers/acpi/scan.c | 85 | ||||
| -rw-r--r-- | drivers/i2c/i2c-core.c | 1 |
3 files changed, 90 insertions, 0 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 8ec8a89a20ab..d98ba4355819 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
| @@ -1180,6 +1180,10 @@ static int acpi_battery_add(struct acpi_device *device) | |||
| 1180 | 1180 | ||
| 1181 | if (!device) | 1181 | if (!device) |
| 1182 | return -EINVAL; | 1182 | return -EINVAL; |
| 1183 | |||
| 1184 | if (device->dep_unmet) | ||
| 1185 | return -EPROBE_DEFER; | ||
| 1186 | |||
| 1183 | battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); | 1187 | battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); |
| 1184 | if (!battery) | 1188 | if (!battery) |
| 1185 | return -ENOMEM; | 1189 | return -ENOMEM; |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 0476e90b2091..00189ad63c8f 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
| @@ -36,6 +36,8 @@ bool acpi_force_hot_remove; | |||
| 36 | 36 | ||
| 37 | static const char *dummy_hid = "device"; | 37 | static const char *dummy_hid = "device"; |
| 38 | 38 | ||
| 39 | static LIST_HEAD(acpi_dep_list); | ||
| 40 | static DEFINE_MUTEX(acpi_dep_list_lock); | ||
| 39 | static LIST_HEAD(acpi_bus_id_list); | 41 | static LIST_HEAD(acpi_bus_id_list); |
| 40 | static DEFINE_MUTEX(acpi_scan_lock); | 42 | static DEFINE_MUTEX(acpi_scan_lock); |
| 41 | static LIST_HEAD(acpi_scan_handlers_list); | 43 | static LIST_HEAD(acpi_scan_handlers_list); |
| @@ -43,6 +45,12 @@ DEFINE_MUTEX(acpi_device_lock); | |||
| 43 | LIST_HEAD(acpi_wakeup_device_list); | 45 | LIST_HEAD(acpi_wakeup_device_list); |
| 44 | static DEFINE_MUTEX(acpi_hp_context_lock); | 46 | static DEFINE_MUTEX(acpi_hp_context_lock); |
| 45 | 47 | ||
| 48 | struct acpi_dep_data { | ||
| 49 | struct list_head node; | ||
| 50 | acpi_handle master; | ||
| 51 | acpi_handle slave; | ||
| 52 | }; | ||
| 53 | |||
| 46 | struct acpi_device_bus_id{ | 54 | struct acpi_device_bus_id{ |
| 47 | char bus_id[15]; | 55 | char bus_id[15]; |
| 48 | unsigned int instance_no; | 56 | unsigned int instance_no; |
| @@ -2086,6 +2094,59 @@ static void acpi_scan_init_hotplug(struct acpi_device *adev) | |||
| 2086 | } | 2094 | } |
| 2087 | } | 2095 | } |
| 2088 | 2096 | ||
| 2097 | static void acpi_device_dep_initialize(struct acpi_device *adev) | ||
| 2098 | { | ||
| 2099 | struct acpi_dep_data *dep; | ||
| 2100 | struct acpi_handle_list dep_devices; | ||
| 2101 | acpi_status status; | ||
| 2102 | int i; | ||
| 2103 | |||
| 2104 | if (!acpi_has_method(adev->handle, "_DEP")) | ||
| 2105 | return; | ||
| 2106 | |||
| 2107 | status = acpi_evaluate_reference(adev->handle, "_DEP", NULL, | ||
| 2108 | &dep_devices); | ||
| 2109 | if (ACPI_FAILURE(status)) { | ||
| 2110 | dev_err(&adev->dev, "Failed to evaluate _DEP.\n"); | ||
| 2111 | return; | ||
| 2112 | } | ||
| 2113 | |||
| 2114 | for (i = 0; i < dep_devices.count; i++) { | ||
| 2115 | struct acpi_device_info *info; | ||
| 2116 | int skip; | ||
| 2117 | |||
| 2118 | status = acpi_get_object_info(dep_devices.handles[i], &info); | ||
| 2119 | if (ACPI_FAILURE(status)) { | ||
| 2120 | dev_err(&adev->dev, "Error reading device info\n"); | ||
| 2121 | continue; | ||
| 2122 | } | ||
| 2123 | |||
| 2124 | /* | ||
| 2125 | * Skip the dependency of Windows System Power | ||
| 2126 | * Management Controller | ||
| 2127 | */ | ||
| 2128 | skip = info->valid & ACPI_VALID_HID && | ||
| 2129 | !strcmp(info->hardware_id.string, "INT3396"); | ||
| 2130 | |||
| 2131 | kfree(info); | ||
| 2132 | |||
| 2133 | if (skip) | ||
| 2134 | continue; | ||
| 2135 | |||
| 2136 | dep = kzalloc(sizeof(struct acpi_dep_data), GFP_KERNEL); | ||
| 2137 | if (!dep) | ||
| 2138 | return; | ||
| 2139 | |||
| 2140 | dep->master = dep_devices.handles[i]; | ||
| 2141 | dep->slave = adev->handle; | ||
| 2142 | adev->dep_unmet++; | ||
| 2143 | |||
| 2144 | mutex_lock(&acpi_dep_list_lock); | ||
| 2145 | list_add_tail(&dep->node , &acpi_dep_list); | ||
| 2146 | mutex_unlock(&acpi_dep_list_lock); | ||
| 2147 | } | ||
| 2148 | } | ||
| 2149 | |||
| 2089 | static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, | 2150 | static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, |
| 2090 | void *not_used, void **return_value) | 2151 | void *not_used, void **return_value) |
| 2091 | { | 2152 | { |
| @@ -2112,6 +2173,7 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, | |||
| 2112 | return AE_CTRL_DEPTH; | 2173 | return AE_CTRL_DEPTH; |
| 2113 | 2174 | ||
| 2114 | acpi_scan_init_hotplug(device); | 2175 | acpi_scan_init_hotplug(device); |
| 2176 | acpi_device_dep_initialize(device); | ||
| 2115 | 2177 | ||
| 2116 | out: | 2178 | out: |
| 2117 | if (!*return_value) | 2179 | if (!*return_value) |
| @@ -2232,6 +2294,29 @@ static void acpi_bus_attach(struct acpi_device *device) | |||
| 2232 | device->handler->hotplug.notify_online(device); | 2294 | device->handler->hotplug.notify_online(device); |
| 2233 | } | 2295 | } |
| 2234 | 2296 | ||
| 2297 | void acpi_walk_dep_device_list(acpi_handle handle) | ||
| 2298 | { | ||
| 2299 | struct acpi_dep_data *dep, *tmp; | ||
| 2300 | struct acpi_device *adev; | ||
| 2301 | |||
| 2302 | mutex_lock(&acpi_dep_list_lock); | ||
| 2303 | list_for_each_entry_safe(dep, tmp, &acpi_dep_list, node) { | ||
| 2304 | if (dep->master == handle) { | ||
| 2305 | acpi_bus_get_device(dep->slave, &adev); | ||
| 2306 | if (!adev) | ||
| 2307 | continue; | ||
| 2308 | |||
| 2309 | adev->dep_unmet--; | ||
| 2310 | if (!adev->dep_unmet) | ||
| 2311 | acpi_bus_attach(adev); | ||
| 2312 | list_del(&dep->node); | ||
| 2313 | kfree(dep); | ||
| 2314 | } | ||
| 2315 | } | ||
| 2316 | mutex_unlock(&acpi_dep_list_lock); | ||
| 2317 | } | ||
| 2318 | EXPORT_SYMBOL_GPL(acpi_walk_dep_device_list); | ||
| 2319 | |||
| 2235 | /** | 2320 | /** |
| 2236 | * acpi_bus_scan - Add ACPI device node objects in a given namespace scope. | 2321 | * acpi_bus_scan - Add ACPI device node objects in a given namespace scope. |
| 2237 | * @handle: Root of the namespace scope to scan. | 2322 | * @handle: Root of the namespace scope to scan. |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index f43b4e11647a..68aeb8eedae0 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
| @@ -403,6 +403,7 @@ static int acpi_i2c_install_space_handler(struct i2c_adapter *adapter) | |||
| 403 | return -ENOMEM; | 403 | return -ENOMEM; |
| 404 | } | 404 | } |
| 405 | 405 | ||
| 406 | acpi_walk_dep_device_list(handle); | ||
| 406 | return 0; | 407 | return 0; |
| 407 | } | 408 | } |
| 408 | 409 | ||
