Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'acpi-ec'

* acpi-ec:
Revert "ACPI / EC: Add query flushing support"
Revert "ACPI / EC: Add GPE reference counting debugging messages"

+18 -107
+18 -107
drivers/acpi/ec.c
··· 31 31 32 32 /* Uncomment next line to get verbose printout */ 33 33 /* #define DEBUG */ 34 - #define DEBUG_REF 0 35 34 #define pr_fmt(fmt) "ACPI : EC: " fmt 36 35 37 36 #include <linux/kernel.h> ··· 76 77 * when trying to clear the EC */ 77 78 78 79 enum { 79 - EC_FLAGS_EVENT_ENABLED, /* Event is enabled */ 80 - EC_FLAGS_EVENT_PENDING, /* Event is pending */ 81 - EC_FLAGS_EVENT_DETECTED, /* Event is detected */ 80 + EC_FLAGS_QUERY_PENDING, /* Query is pending */ 82 81 EC_FLAGS_HANDLERS_INSTALLED, /* Handlers for GPE and 83 82 * OpReg are installed */ 84 83 EC_FLAGS_STARTED, /* Driver is started */ ··· 87 90 88 91 #define ACPI_EC_COMMAND_POLL 0x01 /* Available for command byte */ 89 92 #define ACPI_EC_COMMAND_COMPLETE 0x02 /* Completed last byte */ 90 - 91 - #define ec_debug_ref(ec, fmt, ...) \ 92 - do { \ 93 - if (DEBUG_REF) \ 94 - pr_debug("%lu: " fmt, ec->reference_count, \ 95 - ## __VA_ARGS__); \ 96 - } while (0) 97 93 98 94 /* ec.c is compiled in acpi namespace so this shows up as acpi.ec_delay param */ 99 95 static unsigned int ec_delay __read_mostly = ACPI_EC_DELAY; ··· 149 159 static bool acpi_ec_flushed(struct acpi_ec *ec) 150 160 { 151 161 return ec->reference_count == 1; 152 - } 153 - 154 - static bool acpi_ec_has_pending_event(struct acpi_ec *ec) 155 - { 156 - return test_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags) || 157 - test_bit(EC_FLAGS_EVENT_PENDING, &ec->flags); 158 162 } 159 163 160 164 /* -------------------------------------------------------------------------- ··· 318 334 * the flush operation is not in 319 335 * progress 320 336 * @ec: the EC device 321 - * @allow_event: whether event should be handled 322 337 * 323 338 * This function must be used before taking a new action that should hold 324 339 * the reference count. If this function returns false, then the action 325 340 * must be discarded or it will prevent the flush operation from being 326 341 * completed. 327 - * 328 - * During flushing, QR_EC command need to pass this check when there is a 329 - * pending event, so that the reference count held for the pending event 330 - * can be decreased by the completion of the QR_EC command. 331 342 */ 332 - static bool acpi_ec_submit_flushable_request(struct acpi_ec *ec, 333 - bool allow_event) 343 + static bool acpi_ec_submit_flushable_request(struct acpi_ec *ec) 334 344 { 335 - if (!acpi_ec_started(ec)) { 336 - if (!allow_event || !acpi_ec_has_pending_event(ec)) 337 - return false; 338 - } 345 + if (!acpi_ec_started(ec)) 346 + return false; 339 347 acpi_ec_submit_request(ec); 340 348 return true; 341 349 } 342 350 343 - static void acpi_ec_submit_event(struct acpi_ec *ec) 351 + static void acpi_ec_submit_query(struct acpi_ec *ec) 344 352 { 345 - if (!test_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags) || 346 - !test_bit(EC_FLAGS_EVENT_ENABLED, &ec->flags)) 347 - return; 348 - /* Hold reference for pending event */ 349 - if (!acpi_ec_submit_flushable_request(ec, true)) 350 - return; 351 - ec_debug_ref(ec, "Increase event\n"); 352 - if (!test_and_set_bit(EC_FLAGS_EVENT_PENDING, &ec->flags)) { 353 - pr_debug("***** Event query started *****\n"); 353 + if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) { 354 + pr_debug("***** Event started *****\n"); 354 355 schedule_work(&ec->work); 355 - return; 356 356 } 357 - acpi_ec_complete_request(ec); 358 - ec_debug_ref(ec, "Decrease event\n"); 359 357 } 360 358 361 - static void acpi_ec_complete_event(struct acpi_ec *ec) 359 + static void acpi_ec_complete_query(struct acpi_ec *ec) 362 360 { 363 361 if (ec->curr->command == ACPI_EC_COMMAND_QUERY) { 364 - clear_bit(EC_FLAGS_EVENT_PENDING, &ec->flags); 365 - pr_debug("***** Event query stopped *****\n"); 366 - /* Unhold reference for pending event */ 367 - acpi_ec_complete_request(ec); 368 - ec_debug_ref(ec, "Decrease event\n"); 369 - /* Check if there is another SCI_EVT detected */ 370 - acpi_ec_submit_event(ec); 362 + clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); 363 + pr_debug("***** Event stopped *****\n"); 371 364 } 372 - } 373 - 374 - static void acpi_ec_submit_detection(struct acpi_ec *ec) 375 - { 376 - /* Hold reference for query submission */ 377 - if (!acpi_ec_submit_flushable_request(ec, false)) 378 - return; 379 - ec_debug_ref(ec, "Increase query\n"); 380 - if (!test_and_set_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags)) { 381 - pr_debug("***** Event detection blocked *****\n"); 382 - acpi_ec_submit_event(ec); 383 - return; 384 - } 385 - acpi_ec_complete_request(ec); 386 - ec_debug_ref(ec, "Decrease query\n"); 387 - } 388 - 389 - static void acpi_ec_complete_detection(struct acpi_ec *ec) 390 - { 391 - if (ec->curr->command == ACPI_EC_COMMAND_QUERY) { 392 - clear_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags); 393 - pr_debug("***** Event detetion unblocked *****\n"); 394 - /* Unhold reference for query submission */ 395 - acpi_ec_complete_request(ec); 396 - ec_debug_ref(ec, "Decrease query\n"); 397 - } 398 - } 399 - 400 - static void acpi_ec_enable_event(struct acpi_ec *ec) 401 - { 402 - unsigned long flags; 403 - 404 - spin_lock_irqsave(&ec->lock, flags); 405 - set_bit(EC_FLAGS_EVENT_ENABLED, &ec->flags); 406 - /* 407 - * An event may be pending even with SCI_EVT=0, so QR_EC should 408 - * always be issued right after started. 409 - */ 410 - acpi_ec_submit_detection(ec); 411 - spin_unlock_irqrestore(&ec->lock, flags); 412 365 } 413 366 414 367 static int ec_transaction_completed(struct acpi_ec *ec) ··· 389 468 t->rdata[t->ri++] = acpi_ec_read_data(ec); 390 469 if (t->rlen == t->ri) { 391 470 t->flags |= ACPI_EC_COMMAND_COMPLETE; 392 - acpi_ec_complete_event(ec); 393 471 if (t->command == ACPI_EC_COMMAND_QUERY) 394 472 pr_debug("***** Command(%s) hardware completion *****\n", 395 473 acpi_ec_cmd_string(t->command)); ··· 399 479 } else if (t->wlen == t->wi && 400 480 (status & ACPI_EC_FLAG_IBF) == 0) { 401 481 t->flags |= ACPI_EC_COMMAND_COMPLETE; 402 - acpi_ec_complete_event(ec); 403 482 wakeup = true; 404 483 } 405 484 goto out; ··· 407 488 !(status & ACPI_EC_FLAG_SCI) && 408 489 (t->command == ACPI_EC_COMMAND_QUERY)) { 409 490 t->flags |= ACPI_EC_COMMAND_POLL; 410 - acpi_ec_complete_detection(ec); 491 + acpi_ec_complete_query(ec); 411 492 t->rdata[t->ri++] = 0x00; 412 493 t->flags |= ACPI_EC_COMMAND_COMPLETE; 413 - acpi_ec_complete_event(ec); 414 494 pr_debug("***** Command(%s) software completion *****\n", 415 495 acpi_ec_cmd_string(t->command)); 416 496 wakeup = true; 417 497 } else if ((status & ACPI_EC_FLAG_IBF) == 0) { 418 498 acpi_ec_write_cmd(ec, t->command); 419 499 t->flags |= ACPI_EC_COMMAND_POLL; 420 - acpi_ec_complete_detection(ec); 500 + acpi_ec_complete_query(ec); 421 501 } else 422 502 goto err; 423 503 goto out; ··· 437 519 } 438 520 out: 439 521 if (status & ACPI_EC_FLAG_SCI) 440 - acpi_ec_submit_detection(ec); 522 + acpi_ec_submit_query(ec); 441 523 if (wakeup && in_interrupt()) 442 524 wake_up(&ec->wait); 443 525 } ··· 498 580 /* start transaction */ 499 581 spin_lock_irqsave(&ec->lock, tmp); 500 582 /* Enable GPE for command processing (IBF=0/OBF=1) */ 501 - if (!acpi_ec_submit_flushable_request(ec, true)) { 583 + if (!acpi_ec_submit_flushable_request(ec)) { 502 584 ret = -EINVAL; 503 585 goto unlock; 504 586 } 505 - ec_debug_ref(ec, "Increase command\n"); 506 587 /* following two actions should be kept atomic */ 507 588 ec->curr = t; 508 589 pr_debug("***** Command(%s) started *****\n", ··· 517 600 ec->curr = NULL; 518 601 /* Disable GPE for command processing (IBF=0/OBF=1) */ 519 602 acpi_ec_complete_request(ec); 520 - ec_debug_ref(ec, "Decrease command\n"); 521 603 unlock: 522 604 spin_unlock_irqrestore(&ec->lock, tmp); 523 605 return ret; ··· 678 762 if (!test_and_set_bit(EC_FLAGS_STARTED, &ec->flags)) { 679 763 pr_debug("+++++ Starting EC +++++\n"); 680 764 /* Enable GPE for event processing (SCI_EVT=1) */ 681 - if (!resuming) { 765 + if (!resuming) 682 766 acpi_ec_submit_request(ec); 683 - ec_debug_ref(ec, "Increase driver\n"); 684 - } 685 767 pr_info("+++++ EC started +++++\n"); 686 768 } 687 769 spin_unlock_irqrestore(&ec->lock, flags); ··· 708 794 wait_event(ec->wait, acpi_ec_stopped(ec)); 709 795 spin_lock_irqsave(&ec->lock, flags); 710 796 /* Disable GPE for event processing (SCI_EVT=1) */ 711 - if (!suspending) { 797 + if (!suspending) 712 798 acpi_ec_complete_request(ec); 713 - ec_debug_ref(ec, "Decrease driver\n"); 714 - } 715 799 clear_bit(EC_FLAGS_STARTED, &ec->flags); 716 800 clear_bit(EC_FLAGS_STOPPED, &ec->flags); 717 801 pr_info("+++++ EC stopped +++++\n"); ··· 879 967 { 880 968 struct acpi_ec *ec = container_of(work, struct acpi_ec, work); 881 969 882 - pr_debug("***** Event poller started *****\n"); 883 970 acpi_ec_query(ec, NULL); 884 - pr_debug("***** Event poller stopped *****\n"); 885 971 } 886 972 887 973 static u32 acpi_ec_gpe_handler(acpi_handle gpe_device, ··· 949 1039 950 1040 if (!ec) 951 1041 return NULL; 1042 + ec->flags = 1 << EC_FLAGS_QUERY_PENDING; 952 1043 mutex_init(&ec->mutex); 953 1044 init_waitqueue_head(&ec->wait); 954 1045 INIT_LIST_HEAD(&ec->list); ··· 1100 1189 ret = ec_install_handlers(ec); 1101 1190 1102 1191 /* EC is fully operational, allow queries */ 1103 - acpi_ec_enable_event(ec); 1192 + clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); 1104 1193 1105 1194 /* Clear stale _Q events if hardware might require that */ 1106 1195 if (EC_FLAGS_CLEAR_ON_RESUME)