diff options
author | Lv Zheng <lv.zheng@intel.com> | 2015-02-05 19:58:16 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-02-06 09:48:10 -0500 |
commit | b5bca896ef3c4dd8aa1aac55256cb094c7376a77 (patch) | |
tree | c1c76b2ac04d301028da66e8d0a9cab88c3a525c | |
parent | f252cb09e1cb46834014aaa3814fbfb2352e9071 (diff) |
ACPI / EC: Add GPE reference counting debugging messages
This patch enhances debugging with the GPE reference count messages added.
No functional changes.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/ec.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 40002ae7db2b..14d0c89ada2a 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -31,6 +31,7 @@ | |||
31 | 31 | ||
32 | /* Uncomment next line to get verbose printout */ | 32 | /* Uncomment next line to get verbose printout */ |
33 | /* #define DEBUG */ | 33 | /* #define DEBUG */ |
34 | #define DEBUG_REF 0 | ||
34 | #define pr_fmt(fmt) "ACPI : EC: " fmt | 35 | #define pr_fmt(fmt) "ACPI : EC: " fmt |
35 | 36 | ||
36 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
@@ -90,6 +91,13 @@ enum { | |||
90 | #define ACPI_EC_COMMAND_POLL 0x01 /* Available for command byte */ | 91 | #define ACPI_EC_COMMAND_POLL 0x01 /* Available for command byte */ |
91 | #define ACPI_EC_COMMAND_COMPLETE 0x02 /* Completed last byte */ | 92 | #define ACPI_EC_COMMAND_COMPLETE 0x02 /* Completed last byte */ |
92 | 93 | ||
94 | #define ec_debug_ref(ec, fmt, ...) \ | ||
95 | do { \ | ||
96 | if (DEBUG_REF) \ | ||
97 | pr_debug("%lu: " fmt, ec->reference_count, \ | ||
98 | ## __VA_ARGS__); \ | ||
99 | } while (0) | ||
100 | |||
93 | /* ec.c is compiled in acpi namespace so this shows up as acpi.ec_delay param */ | 101 | /* ec.c is compiled in acpi namespace so this shows up as acpi.ec_delay param */ |
94 | static unsigned int ec_delay __read_mostly = ACPI_EC_DELAY; | 102 | static unsigned int ec_delay __read_mostly = ACPI_EC_DELAY; |
95 | module_param(ec_delay, uint, 0644); | 103 | module_param(ec_delay, uint, 0644); |
@@ -356,12 +364,14 @@ static void acpi_ec_submit_event(struct acpi_ec *ec) | |||
356 | /* Hold reference for pending event */ | 364 | /* Hold reference for pending event */ |
357 | if (!acpi_ec_submit_flushable_request(ec, true)) | 365 | if (!acpi_ec_submit_flushable_request(ec, true)) |
358 | return; | 366 | return; |
367 | ec_debug_ref(ec, "Increase event\n"); | ||
359 | if (!test_and_set_bit(EC_FLAGS_EVENT_PENDING, &ec->flags)) { | 368 | if (!test_and_set_bit(EC_FLAGS_EVENT_PENDING, &ec->flags)) { |
360 | pr_debug("***** Event query started *****\n"); | 369 | pr_debug("***** Event query started *****\n"); |
361 | schedule_work(&ec->work); | 370 | schedule_work(&ec->work); |
362 | return; | 371 | return; |
363 | } | 372 | } |
364 | acpi_ec_complete_request(ec); | 373 | acpi_ec_complete_request(ec); |
374 | ec_debug_ref(ec, "Decrease event\n"); | ||
365 | } | 375 | } |
366 | 376 | ||
367 | static void acpi_ec_complete_event(struct acpi_ec *ec) | 377 | static void acpi_ec_complete_event(struct acpi_ec *ec) |
@@ -371,6 +381,7 @@ static void acpi_ec_complete_event(struct acpi_ec *ec) | |||
371 | pr_debug("***** Event query stopped *****\n"); | 381 | pr_debug("***** Event query stopped *****\n"); |
372 | /* Unhold reference for pending event */ | 382 | /* Unhold reference for pending event */ |
373 | acpi_ec_complete_request(ec); | 383 | acpi_ec_complete_request(ec); |
384 | ec_debug_ref(ec, "Decrease event\n"); | ||
374 | /* Check if there is another SCI_EVT detected */ | 385 | /* Check if there is another SCI_EVT detected */ |
375 | acpi_ec_submit_event(ec); | 386 | acpi_ec_submit_event(ec); |
376 | } | 387 | } |
@@ -381,12 +392,14 @@ static void acpi_ec_submit_detection(struct acpi_ec *ec) | |||
381 | /* Hold reference for query submission */ | 392 | /* Hold reference for query submission */ |
382 | if (!acpi_ec_submit_flushable_request(ec, false)) | 393 | if (!acpi_ec_submit_flushable_request(ec, false)) |
383 | return; | 394 | return; |
395 | ec_debug_ref(ec, "Increase query\n"); | ||
384 | if (!test_and_set_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags)) { | 396 | if (!test_and_set_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags)) { |
385 | pr_debug("***** Event detection blocked *****\n"); | 397 | pr_debug("***** Event detection blocked *****\n"); |
386 | acpi_ec_submit_event(ec); | 398 | acpi_ec_submit_event(ec); |
387 | return; | 399 | return; |
388 | } | 400 | } |
389 | acpi_ec_complete_request(ec); | 401 | acpi_ec_complete_request(ec); |
402 | ec_debug_ref(ec, "Decrease query\n"); | ||
390 | } | 403 | } |
391 | 404 | ||
392 | static void acpi_ec_complete_detection(struct acpi_ec *ec) | 405 | static void acpi_ec_complete_detection(struct acpi_ec *ec) |
@@ -396,6 +409,7 @@ static void acpi_ec_complete_detection(struct acpi_ec *ec) | |||
396 | pr_debug("***** Event detetion unblocked *****\n"); | 409 | pr_debug("***** Event detetion unblocked *****\n"); |
397 | /* Unhold reference for query submission */ | 410 | /* Unhold reference for query submission */ |
398 | acpi_ec_complete_request(ec); | 411 | acpi_ec_complete_request(ec); |
412 | ec_debug_ref(ec, "Decrease query\n"); | ||
399 | } | 413 | } |
400 | } | 414 | } |
401 | 415 | ||
@@ -570,6 +584,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, | |||
570 | ret = -EINVAL; | 584 | ret = -EINVAL; |
571 | goto unlock; | 585 | goto unlock; |
572 | } | 586 | } |
587 | ec_debug_ref(ec, "Increase command\n"); | ||
573 | /* following two actions should be kept atomic */ | 588 | /* following two actions should be kept atomic */ |
574 | ec->curr = t; | 589 | ec->curr = t; |
575 | pr_debug("***** Command(%s) started *****\n", | 590 | pr_debug("***** Command(%s) started *****\n", |
@@ -585,6 +600,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, | |||
585 | ec->curr = NULL; | 600 | ec->curr = NULL; |
586 | /* Disable GPE for command processing (IBF=0/OBF=1) */ | 601 | /* Disable GPE for command processing (IBF=0/OBF=1) */ |
587 | acpi_ec_complete_request(ec); | 602 | acpi_ec_complete_request(ec); |
603 | ec_debug_ref(ec, "Decrease command\n"); | ||
588 | unlock: | 604 | unlock: |
589 | spin_unlock_irqrestore(&ec->lock, tmp); | 605 | spin_unlock_irqrestore(&ec->lock, tmp); |
590 | return ret; | 606 | return ret; |
@@ -746,8 +762,10 @@ static void acpi_ec_start(struct acpi_ec *ec, bool resuming) | |||
746 | if (!test_and_set_bit(EC_FLAGS_STARTED, &ec->flags)) { | 762 | if (!test_and_set_bit(EC_FLAGS_STARTED, &ec->flags)) { |
747 | pr_debug("+++++ Starting EC +++++\n"); | 763 | pr_debug("+++++ Starting EC +++++\n"); |
748 | /* Enable GPE for event processing (SCI_EVT=1) */ | 764 | /* Enable GPE for event processing (SCI_EVT=1) */ |
749 | if (!resuming) | 765 | if (!resuming) { |
750 | acpi_ec_submit_request(ec); | 766 | acpi_ec_submit_request(ec); |
767 | ec_debug_ref(ec, "Increase driver\n"); | ||
768 | } | ||
751 | pr_info("+++++ EC started +++++\n"); | 769 | pr_info("+++++ EC started +++++\n"); |
752 | } | 770 | } |
753 | spin_unlock_irqrestore(&ec->lock, flags); | 771 | spin_unlock_irqrestore(&ec->lock, flags); |
@@ -776,8 +794,10 @@ static void acpi_ec_stop(struct acpi_ec *ec, bool suspending) | |||
776 | wait_event(ec->wait, acpi_ec_stopped(ec)); | 794 | wait_event(ec->wait, acpi_ec_stopped(ec)); |
777 | spin_lock_irqsave(&ec->lock, flags); | 795 | spin_lock_irqsave(&ec->lock, flags); |
778 | /* Disable GPE for event processing (SCI_EVT=1) */ | 796 | /* Disable GPE for event processing (SCI_EVT=1) */ |
779 | if (!suspending) | 797 | if (!suspending) { |
780 | acpi_ec_complete_request(ec); | 798 | acpi_ec_complete_request(ec); |
799 | ec_debug_ref(ec, "Decrease driver\n"); | ||
800 | } | ||
781 | clear_bit(EC_FLAGS_STARTED, &ec->flags); | 801 | clear_bit(EC_FLAGS_STARTED, &ec->flags); |
782 | clear_bit(EC_FLAGS_STOPPED, &ec->flags); | 802 | clear_bit(EC_FLAGS_STOPPED, &ec->flags); |
783 | pr_info("+++++ EC stopped +++++\n"); | 803 | pr_info("+++++ EC stopped +++++\n"); |