Skip to content

Commit b5bca89

Browse files
Lv Zhengrafaeljw
authored andcommitted
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>
1 parent f252cb0 commit b5bca89

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

‎drivers/acpi/ec.c‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
/* Uncomment next line to get verbose printout */
3333
/* #define DEBUG */
34+
#define DEBUG_REF 0
3435
#define pr_fmt(fmt) "ACPI : EC: " fmt
3536

3637
#include <linux/kernel.h>
@@ -90,6 +91,13 @@ enum {
9091
#define ACPI_EC_COMMAND_POLL 0x01 /* Available for command byte */
9192
#define ACPI_EC_COMMAND_COMPLETE 0x02 /* Completed last byte */
9293

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+
93101
/* ec.c is compiled in acpi namespace so this shows up as acpi.ec_delay param */
94102
static unsigned int ec_delay __read_mostly = ACPI_EC_DELAY;
95103
module_param(ec_delay, uint, 0644);
@@ -356,12 +364,14 @@ static void acpi_ec_submit_event(struct acpi_ec *ec)
356364
/* Hold reference for pending event */
357365
if (!acpi_ec_submit_flushable_request(ec, true))
358366
return;
367+
ec_debug_ref(ec, "Increase event\n");
359368
if (!test_and_set_bit(EC_FLAGS_EVENT_PENDING, &ec->flags)) {
360369
pr_debug("***** Event query started *****\n");
361370
schedule_work(&ec->work);
362371
return;
363372
}
364373
acpi_ec_complete_request(ec);
374+
ec_debug_ref(ec, "Decrease event\n");
365375
}
366376

367377
static void acpi_ec_complete_event(struct acpi_ec *ec)
@@ -371,6 +381,7 @@ static void acpi_ec_complete_event(struct acpi_ec *ec)
371381
pr_debug("***** Event query stopped *****\n");
372382
/* Unhold reference for pending event */
373383
acpi_ec_complete_request(ec);
384+
ec_debug_ref(ec, "Decrease event\n");
374385
/* Check if there is another SCI_EVT detected */
375386
acpi_ec_submit_event(ec);
376387
}
@@ -381,12 +392,14 @@ static void acpi_ec_submit_detection(struct acpi_ec *ec)
381392
/* Hold reference for query submission */
382393
if (!acpi_ec_submit_flushable_request(ec, false))
383394
return;
395+
ec_debug_ref(ec, "Increase query\n");
384396
if (!test_and_set_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags)) {
385397
pr_debug("***** Event detection blocked *****\n");
386398
acpi_ec_submit_event(ec);
387399
return;
388400
}
389401
acpi_ec_complete_request(ec);
402+
ec_debug_ref(ec, "Decrease query\n");
390403
}
391404

392405
static void acpi_ec_complete_detection(struct acpi_ec *ec)
@@ -396,6 +409,7 @@ static void acpi_ec_complete_detection(struct acpi_ec *ec)
396409
pr_debug("***** Event detetion unblocked *****\n");
397410
/* Unhold reference for query submission */
398411
acpi_ec_complete_request(ec);
412+
ec_debug_ref(ec, "Decrease query\n");
399413
}
400414
}
401415

@@ -570,6 +584,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
570584
ret = -EINVAL;
571585
goto unlock;
572586
}
587+
ec_debug_ref(ec, "Increase command\n");
573588
/* following two actions should be kept atomic */
574589
ec->curr = t;
575590
pr_debug("***** Command(%s) started *****\n",
@@ -585,6 +600,7 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
585600
ec->curr = NULL;
586601
/* Disable GPE for command processing (IBF=0/OBF=1) */
587602
acpi_ec_complete_request(ec);
603+
ec_debug_ref(ec, "Decrease command\n");
588604
unlock:
589605
spin_unlock_irqrestore(&ec->lock, tmp);
590606
return ret;
@@ -746,8 +762,10 @@ static void acpi_ec_start(struct acpi_ec *ec, bool resuming)
746762
if (!test_and_set_bit(EC_FLAGS_STARTED, &ec->flags)) {
747763
pr_debug("+++++ Starting EC +++++\n");
748764
/* Enable GPE for event processing (SCI_EVT=1) */
749-
if (!resuming)
765+
if (!resuming) {
750766
acpi_ec_submit_request(ec);
767+
ec_debug_ref(ec, "Increase driver\n");
768+
}
751769
pr_info("+++++ EC started +++++\n");
752770
}
753771
spin_unlock_irqrestore(&ec->lock, flags);
@@ -776,8 +794,10 @@ static void acpi_ec_stop(struct acpi_ec *ec, bool suspending)
776794
wait_event(ec->wait, acpi_ec_stopped(ec));
777795
spin_lock_irqsave(&ec->lock, flags);
778796
/* Disable GPE for event processing (SCI_EVT=1) */
779-
if (!suspending)
797+
if (!suspending) {
780798
acpi_ec_complete_request(ec);
799+
ec_debug_ref(ec, "Decrease driver\n");
800+
}
781801
clear_bit(EC_FLAGS_STARTED, &ec->flags);
782802
clear_bit(EC_FLAGS_STOPPED, &ec->flags);
783803
pr_info("+++++ EC stopped +++++\n");

0 commit comments

Comments
 (0)