Merge branches 'acpi-ec', 'acpi-battery' and 'acpi-pmic'

* acpi-ec:
ACPI / EC: Call acpi_walk_dep_device_list() after installing EC opregion handler
ACPI / EC: Add GPE reference counting debugging messages.
ACPI / EC: Cleanup logging/debugging splitter support.

* acpi-battery:
ACPI / battery: make warning greppable

* acpi-pmic:
ACPI/PMIC: Fix typo in MODULE_DESCRIPTION in intel_pmic_crc.c

+90 -39
+2 -2
drivers/acpi/battery.c
··· 530 battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN && 531 (s16)(battery->rate_now) < 0) { 532 battery->rate_now = abs((s16)battery->rate_now); 533 - printk_once(KERN_WARNING FW_BUG "battery: (dis)charge rate" 534 - " invalid.\n"); 535 } 536 537 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)
··· 530 battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN && 531 (s16)(battery->rate_now) < 0) { 532 battery->rate_now = abs((s16)battery->rate_now); 533 + printk_once(KERN_WARNING FW_BUG 534 + "battery: (dis)charge rate invalid.\n"); 535 } 536 537 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)
+87 -36
drivers/acpi/ec.c
··· 137 static int EC_FLAGS_QUERY_HANDSHAKE; /* Needs QR_EC issued when SCI_EVT set */ 138 139 /* -------------------------------------------------------------------------- 140 * Device Flags 141 * -------------------------------------------------------------------------- */ 142 ··· 203 { 204 u8 x = inb(ec->command_addr); 205 206 - pr_debug("EC_SC(R) = 0x%2.2x " 207 - "SCI_EVT=%d BURST=%d CMD=%d IBF=%d OBF=%d\n", 208 - x, 209 - !!(x & ACPI_EC_FLAG_SCI), 210 - !!(x & ACPI_EC_FLAG_BURST), 211 - !!(x & ACPI_EC_FLAG_CMD), 212 - !!(x & ACPI_EC_FLAG_IBF), 213 - !!(x & ACPI_EC_FLAG_OBF)); 214 return x; 215 } 216 ··· 219 u8 x = inb(ec->data_addr); 220 221 ec->curr->timestamp = jiffies; 222 - pr_debug("EC_DATA(R) = 0x%2.2x\n", x); 223 return x; 224 } 225 226 static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command) 227 { 228 - pr_debug("EC_SC(W) = 0x%2.2x\n", command); 229 outb(command, ec->command_addr); 230 ec->curr->timestamp = jiffies; 231 } 232 233 static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) 234 { 235 - pr_debug("EC_DATA(W) = 0x%2.2x\n", data); 236 outb(data, ec->data_addr); 237 ec->curr->timestamp = jiffies; 238 } ··· 284 * software need to manually trigger a pseudo GPE event on 285 * EN=1 writes. 286 */ 287 - pr_debug("***** Polling quirk *****\n"); 288 advance_transaction(ec); 289 } 290 } ··· 343 { 344 if (!test_bit(flag, &ec->flags)) { 345 acpi_ec_disable_gpe(ec, false); 346 - pr_debug("+++++ Polling enabled +++++\n"); 347 set_bit(flag, &ec->flags); 348 } 349 } ··· 353 if (test_bit(flag, &ec->flags)) { 354 clear_bit(flag, &ec->flags); 355 acpi_ec_enable_gpe(ec, false); 356 - pr_debug("+++++ Polling disabled +++++\n"); 357 } 358 } 359 ··· 379 static void acpi_ec_submit_query(struct acpi_ec *ec) 380 { 381 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) { 382 - pr_debug("***** Event started *****\n"); 383 schedule_work(&ec->work); 384 } 385 } ··· 388 { 389 if (ec->curr->command == ACPI_EC_COMMAND_QUERY) { 390 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); 391 - pr_debug("***** Event stopped *****\n"); 392 } 393 } 394 ··· 410 u8 status; 411 bool wakeup = false; 412 413 - pr_debug("===== %s (%d) =====\n", 414 - in_interrupt() ? "IRQ" : "TASK", smp_processor_id()); 415 /* 416 * By always clearing STS before handling all indications, we can 417 * ensure a hardware STS 0->1 change after this clearing can always ··· 434 if (t->rlen == t->ri) { 435 t->flags |= ACPI_EC_COMMAND_COMPLETE; 436 if (t->command == ACPI_EC_COMMAND_QUERY) 437 - pr_debug("***** Command(%s) hardware completion *****\n", 438 - acpi_ec_cmd_string(t->command)); 439 wakeup = true; 440 } 441 } else ··· 454 acpi_ec_complete_query(ec); 455 t->rdata[t->ri++] = 0x00; 456 t->flags |= ACPI_EC_COMMAND_COMPLETE; 457 - pr_debug("***** Command(%s) software completion *****\n", 458 - acpi_ec_cmd_string(t->command)); 459 wakeup = true; 460 } else if ((status & ACPI_EC_FLAG_IBF) == 0) { 461 acpi_ec_write_cmd(ec, t->command); ··· 546 ret = -EINVAL; 547 goto unlock; 548 } 549 /* following two actions should be kept atomic */ 550 ec->curr = t; 551 - pr_debug("***** Command(%s) started *****\n", 552 - acpi_ec_cmd_string(t->command)); 553 start_transaction(ec); 554 spin_unlock_irqrestore(&ec->lock, tmp); 555 ret = ec_poll(ec); 556 spin_lock_irqsave(&ec->lock, tmp); 557 if (t->irq_count == ec_storm_threshold) 558 acpi_ec_clear_storm(ec, EC_FLAGS_COMMAND_STORM); 559 - pr_debug("***** Command(%s) stopped *****\n", 560 - acpi_ec_cmd_string(t->command)); 561 ec->curr = NULL; 562 /* Disable GPE for command processing (IBF=0/OBF=1) */ 563 acpi_ec_complete_request(ec); 564 unlock: 565 spin_unlock_irqrestore(&ec->lock, tmp); 566 return ret; ··· 720 721 spin_lock_irqsave(&ec->lock, flags); 722 if (!test_and_set_bit(EC_FLAGS_STARTED, &ec->flags)) { 723 - pr_debug("+++++ Starting EC +++++\n"); 724 /* Enable GPE for event processing (SCI_EVT=1) */ 725 - if (!resuming) 726 acpi_ec_submit_request(ec); 727 - pr_debug("EC started\n"); 728 } 729 spin_unlock_irqrestore(&ec->lock, flags); 730 } ··· 748 749 spin_lock_irqsave(&ec->lock, flags); 750 if (acpi_ec_started(ec)) { 751 - pr_debug("+++++ Stopping EC +++++\n"); 752 set_bit(EC_FLAGS_STOPPED, &ec->flags); 753 spin_unlock_irqrestore(&ec->lock, flags); 754 wait_event(ec->wait, acpi_ec_stopped(ec)); 755 spin_lock_irqsave(&ec->lock, flags); 756 /* Disable GPE for event processing (SCI_EVT=1) */ 757 - if (!suspending) 758 acpi_ec_complete_request(ec); 759 clear_bit(EC_FLAGS_STARTED, &ec->flags); 760 clear_bit(EC_FLAGS_STOPPED, &ec->flags); 761 - pr_debug("EC stopped\n"); 762 } 763 spin_unlock_irqrestore(&ec->lock, flags); 764 } ··· 872 873 if (!handler) 874 return; 875 - pr_debug("##### Query(0x%02x) started #####\n", handler->query_bit); 876 if (handler->func) 877 handler->func(handler->data); 878 else if (handler->handle) 879 acpi_evaluate_object(handler->handle, NULL, NULL, NULL); 880 - pr_debug("##### Query(0x%02x) stopped #####\n", handler->query_bit); 881 acpi_ec_put_query_handler(handler); 882 } 883 ··· 909 if (value == handler->query_bit) { 910 /* have custom handler for this bit */ 911 handler = acpi_ec_get_query_handler(handler); 912 - pr_debug("##### Query(0x%02x) scheduled #####\n", 913 - handler->query_bit); 914 status = acpi_os_execute((handler->func) ? 915 OSL_NOTIFY_HANDLER : OSL_GPE_HANDLER, 916 acpi_ec_run, handler); ··· 1146 ec->gpe, ec->command_addr, ec->data_addr); 1147 1148 ret = ec_install_handlers(ec); 1149 1150 /* EC is fully operational, allow queries */ 1151 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
··· 137 static int EC_FLAGS_QUERY_HANDSHAKE; /* Needs QR_EC issued when SCI_EVT set */ 138 139 /* -------------------------------------------------------------------------- 140 + * Logging/Debugging 141 + * -------------------------------------------------------------------------- */ 142 + 143 + /* 144 + * Splitters used by the developers to track the boundary of the EC 145 + * handling processes. 146 + */ 147 + #ifdef DEBUG 148 + #define EC_DBG_SEP " " 149 + #define EC_DBG_DRV "+++++" 150 + #define EC_DBG_STM "=====" 151 + #define EC_DBG_REQ "*****" 152 + #define EC_DBG_EVT "#####" 153 + #else 154 + #define EC_DBG_SEP "" 155 + #define EC_DBG_DRV 156 + #define EC_DBG_STM 157 + #define EC_DBG_REQ 158 + #define EC_DBG_EVT 159 + #endif 160 + 161 + #define ec_log_raw(fmt, ...) \ 162 + pr_info(fmt "\n", ##__VA_ARGS__) 163 + #define ec_dbg_raw(fmt, ...) \ 164 + pr_debug(fmt "\n", ##__VA_ARGS__) 165 + #define ec_log(filter, fmt, ...) \ 166 + ec_log_raw(filter EC_DBG_SEP fmt EC_DBG_SEP filter, ##__VA_ARGS__) 167 + #define ec_dbg(filter, fmt, ...) \ 168 + ec_dbg_raw(filter EC_DBG_SEP fmt EC_DBG_SEP filter, ##__VA_ARGS__) 169 + 170 + #define ec_log_drv(fmt, ...) \ 171 + ec_log(EC_DBG_DRV, fmt, ##__VA_ARGS__) 172 + #define ec_dbg_drv(fmt, ...) \ 173 + ec_dbg(EC_DBG_DRV, fmt, ##__VA_ARGS__) 174 + #define ec_dbg_stm(fmt, ...) \ 175 + ec_dbg(EC_DBG_STM, fmt, ##__VA_ARGS__) 176 + #define ec_dbg_req(fmt, ...) \ 177 + ec_dbg(EC_DBG_REQ, fmt, ##__VA_ARGS__) 178 + #define ec_dbg_evt(fmt, ...) \ 179 + ec_dbg(EC_DBG_EVT, fmt, ##__VA_ARGS__) 180 + #define ec_dbg_ref(ec, fmt, ...) \ 181 + ec_dbg_raw("%lu: " fmt, ec->reference_count, ## __VA_ARGS__) 182 + 183 + /* -------------------------------------------------------------------------- 184 * Device Flags 185 * -------------------------------------------------------------------------- */ 186 ··· 159 { 160 u8 x = inb(ec->command_addr); 161 162 + ec_dbg_raw("EC_SC(R) = 0x%2.2x " 163 + "SCI_EVT=%d BURST=%d CMD=%d IBF=%d OBF=%d", 164 + x, 165 + !!(x & ACPI_EC_FLAG_SCI), 166 + !!(x & ACPI_EC_FLAG_BURST), 167 + !!(x & ACPI_EC_FLAG_CMD), 168 + !!(x & ACPI_EC_FLAG_IBF), 169 + !!(x & ACPI_EC_FLAG_OBF)); 170 return x; 171 } 172 ··· 175 u8 x = inb(ec->data_addr); 176 177 ec->curr->timestamp = jiffies; 178 + ec_dbg_raw("EC_DATA(R) = 0x%2.2x", x); 179 return x; 180 } 181 182 static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command) 183 { 184 + ec_dbg_raw("EC_SC(W) = 0x%2.2x", command); 185 outb(command, ec->command_addr); 186 ec->curr->timestamp = jiffies; 187 } 188 189 static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) 190 { 191 + ec_dbg_raw("EC_DATA(W) = 0x%2.2x", data); 192 outb(data, ec->data_addr); 193 ec->curr->timestamp = jiffies; 194 } ··· 240 * software need to manually trigger a pseudo GPE event on 241 * EN=1 writes. 242 */ 243 + ec_dbg_raw("Polling quirk"); 244 advance_transaction(ec); 245 } 246 } ··· 299 { 300 if (!test_bit(flag, &ec->flags)) { 301 acpi_ec_disable_gpe(ec, false); 302 + ec_dbg_drv("Polling enabled"); 303 set_bit(flag, &ec->flags); 304 } 305 } ··· 309 if (test_bit(flag, &ec->flags)) { 310 clear_bit(flag, &ec->flags); 311 acpi_ec_enable_gpe(ec, false); 312 + ec_dbg_drv("Polling disabled"); 313 } 314 } 315 ··· 335 static void acpi_ec_submit_query(struct acpi_ec *ec) 336 { 337 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) { 338 + ec_dbg_req("Event started"); 339 schedule_work(&ec->work); 340 } 341 } ··· 344 { 345 if (ec->curr->command == ACPI_EC_COMMAND_QUERY) { 346 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); 347 + ec_dbg_req("Event stopped"); 348 } 349 } 350 ··· 366 u8 status; 367 bool wakeup = false; 368 369 + ec_dbg_stm("%s (%d)", in_interrupt() ? "IRQ" : "TASK", 370 + smp_processor_id()); 371 /* 372 * By always clearing STS before handling all indications, we can 373 * ensure a hardware STS 0->1 change after this clearing can always ··· 390 if (t->rlen == t->ri) { 391 t->flags |= ACPI_EC_COMMAND_COMPLETE; 392 if (t->command == ACPI_EC_COMMAND_QUERY) 393 + ec_dbg_req("Command(%s) hardware completion", 394 + acpi_ec_cmd_string(t->command)); 395 wakeup = true; 396 } 397 } else ··· 410 acpi_ec_complete_query(ec); 411 t->rdata[t->ri++] = 0x00; 412 t->flags |= ACPI_EC_COMMAND_COMPLETE; 413 + ec_dbg_req("Command(%s) software completion", 414 + acpi_ec_cmd_string(t->command)); 415 wakeup = true; 416 } else if ((status & ACPI_EC_FLAG_IBF) == 0) { 417 acpi_ec_write_cmd(ec, t->command); ··· 502 ret = -EINVAL; 503 goto unlock; 504 } 505 + ec_dbg_ref(ec, "Increase command"); 506 /* following two actions should be kept atomic */ 507 ec->curr = t; 508 + ec_dbg_req("Command(%s) started", acpi_ec_cmd_string(t->command)); 509 start_transaction(ec); 510 spin_unlock_irqrestore(&ec->lock, tmp); 511 ret = ec_poll(ec); 512 spin_lock_irqsave(&ec->lock, tmp); 513 if (t->irq_count == ec_storm_threshold) 514 acpi_ec_clear_storm(ec, EC_FLAGS_COMMAND_STORM); 515 + ec_dbg_req("Command(%s) stopped", acpi_ec_cmd_string(t->command)); 516 ec->curr = NULL; 517 /* Disable GPE for command processing (IBF=0/OBF=1) */ 518 acpi_ec_complete_request(ec); 519 + ec_dbg_ref(ec, "Decrease command"); 520 unlock: 521 spin_unlock_irqrestore(&ec->lock, tmp); 522 return ret; ··· 676 677 spin_lock_irqsave(&ec->lock, flags); 678 if (!test_and_set_bit(EC_FLAGS_STARTED, &ec->flags)) { 679 + ec_dbg_drv("Starting EC"); 680 /* Enable GPE for event processing (SCI_EVT=1) */ 681 + if (!resuming) { 682 acpi_ec_submit_request(ec); 683 + ec_dbg_ref(ec, "Increase driver"); 684 + } 685 + ec_log_drv("EC started"); 686 } 687 spin_unlock_irqrestore(&ec->lock, flags); 688 } ··· 702 703 spin_lock_irqsave(&ec->lock, flags); 704 if (acpi_ec_started(ec)) { 705 + ec_dbg_drv("Stopping EC"); 706 set_bit(EC_FLAGS_STOPPED, &ec->flags); 707 spin_unlock_irqrestore(&ec->lock, flags); 708 wait_event(ec->wait, acpi_ec_stopped(ec)); 709 spin_lock_irqsave(&ec->lock, flags); 710 /* Disable GPE for event processing (SCI_EVT=1) */ 711 + if (!suspending) { 712 acpi_ec_complete_request(ec); 713 + ec_dbg_ref(ec, "Decrease driver"); 714 + } 715 clear_bit(EC_FLAGS_STARTED, &ec->flags); 716 clear_bit(EC_FLAGS_STOPPED, &ec->flags); 717 + ec_log_drv("EC stopped"); 718 } 719 spin_unlock_irqrestore(&ec->lock, flags); 720 } ··· 824 825 if (!handler) 826 return; 827 + ec_dbg_evt("Query(0x%02x) started", handler->query_bit); 828 if (handler->func) 829 handler->func(handler->data); 830 else if (handler->handle) 831 acpi_evaluate_object(handler->handle, NULL, NULL, NULL); 832 + ec_dbg_evt("Query(0x%02x) stopped", handler->query_bit); 833 acpi_ec_put_query_handler(handler); 834 } 835 ··· 861 if (value == handler->query_bit) { 862 /* have custom handler for this bit */ 863 handler = acpi_ec_get_query_handler(handler); 864 + ec_dbg_evt("Query(0x%02x) scheduled", 865 + handler->query_bit); 866 status = acpi_os_execute((handler->func) ? 867 OSL_NOTIFY_HANDLER : OSL_GPE_HANDLER, 868 acpi_ec_run, handler); ··· 1098 ec->gpe, ec->command_addr, ec->data_addr); 1099 1100 ret = ec_install_handlers(ec); 1101 + 1102 + /* Reprobe devices depending on the EC */ 1103 + acpi_walk_dep_device_list(ec->handle); 1104 1105 /* EC is fully operational, allow queries */ 1106 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
+1 -1
drivers/acpi/pmic/intel_pmic_crc.c
··· 207 } 208 module_init(intel_crc_pmic_opregion_driver_init); 209 210 - MODULE_DESCRIPTION("CrystalCove ACPI opration region driver"); 211 MODULE_LICENSE("GPL");
··· 207 } 208 module_init(intel_crc_pmic_opregion_driver_init); 209 210 + MODULE_DESCRIPTION("CrystalCove ACPI operation region driver"); 211 MODULE_LICENSE("GPL");