PM: wakeup_reasons: disable wakeup-reason deduction by default

Introduce a config item, CONFIG_DEDUCE_WAKEUP_REASONS, disabled by default.
Make CONFIG_PARTUALRESUME select it.

Change-Id: I7d831ff0a9dfe0a504824f4bc65ba55c4d92546b
Signed-off-by: Iliyan Malchev <malchev@google.com>
This commit is contained in:
Iliyan Malchev 2015-05-20 20:04:52 -07:00 committed by Artem Borisov
parent 9ff16b88b8
commit a50130f1be
3 changed files with 38 additions and 8 deletions

View file

@ -54,6 +54,8 @@ struct wakeup_irq_node {
bool handled;
};
#ifdef CONFIG_DEDUCE_WAKEUP_REASONS
/* Called in the resume path, with interrupts and nonboot cpus disabled; on
* need for a spinlock.
*/
@ -77,19 +79,26 @@ static inline bool logging_wakeup_reasons(void)
return logging_wakeup_reasons_nosync();
}
void log_base_wakeup_reason(int irq);
void log_suspend_abort_reason(const char *fmt, ...);
bool log_possible_wakeup_reason(int irq,
struct irq_desc *desc,
bool (*handler)(unsigned int, struct irq_desc *));
int check_wakeup_reason(int irq);
#else
static inline void start_logging_wakeup_reasons(void) {}
static inline bool logging_wakeup_reasons_nosync(void) { return false; }
static inline bool logging_wakeup_reasons(void) { return false; }
static inline bool log_possible_wakeup_reason(int irq,
struct irq_desc *desc,
bool (*handler)(unsigned int, struct irq_desc *)) { return true; }
#endif
const struct list_head*
get_wakeup_reasons(unsigned long timeout, struct list_head *unfinished);
void log_base_wakeup_reason(int irq);
void clear_wakeup_reasons(void);
void log_suspend_abort_reason(const char *fmt, ...);
int check_wakeup_reason(int irq);
#endif /* _LINUX_WAKEUP_REASON_H */

View file

@ -278,8 +278,13 @@ config SUSPEND_TIME
keeps statistics on the time spent in suspend in
/sys/kernel/debug/suspend_time
config DEDUCE_WAKEUP_REASONS
bool
default n
config PARTIALRESUME
bool "Partial-resume framework"
select DEDUCE_WAKEUP_REASONS
---help---
Provides hooks for drivers to register partial-resume handlers.
Similar to suspend_again support already in kernel, except that it
@ -288,3 +293,4 @@ config PARTIALRESUME
Partial resume will occur only if all wakeup sources have
partial-resume handlers associated with them, and they all return
true.

View file

@ -115,6 +115,7 @@ add_to_siblings(struct wakeup_irq_node *root, int irq)
return n;
}
#ifdef CONFIG_DEDUCE_WAKEUP_REASONS
static struct wakeup_irq_node* add_child(struct wakeup_irq_node *root, int irq)
{
if (!root->child) {
@ -155,6 +156,7 @@ get_base_node(struct wakeup_irq_node *node, unsigned depth)
return node;
}
#endif /* CONFIG_DEDUCE_WAKEUP_REASONS */
static const struct list_head* get_wakeup_reasons_nosync(void);
@ -199,6 +201,7 @@ static bool walk_irq_node_tree(struct wakeup_irq_node *root,
return visit(root, cookie);
}
#ifdef CONFIG_DEDUCE_WAKEUP_REASONS
static bool is_node_handled(struct wakeup_irq_node *n, void *_p)
{
return n->handled;
@ -208,6 +211,7 @@ static bool base_irq_nodes_done(void)
{
return walk_irq_node_tree(base_irq_nodes, is_node_handled, NULL);
}
#endif
struct buf_cookie {
char *buf;
@ -321,8 +325,13 @@ void log_base_wakeup_reason(int irq)
*/
base_irq_nodes = add_to_siblings(base_irq_nodes, irq);
BUG_ON(!base_irq_nodes);
#ifndef CONFIG_DEDUCE_WAKEUP_REASONS
base_irq_nodes->handled = true;
#endif
}
#ifdef CONFIG_DEDUCE_WAKEUP_REASONS
/* This function is called by generic_handle_irq, which may call itself
* recursively. This happens with interrupts disabled. Using
* log_possible_wakeup_reason, we build a tree of interrupts, tracing the call
@ -341,7 +350,7 @@ void log_base_wakeup_reason(int irq)
*/
struct wakeup_irq_node *
static struct wakeup_irq_node *
log_possible_wakeup_reason_start(int irq, struct irq_desc *desc, unsigned depth)
{
BUG_ON(!irqs_disabled());
@ -390,7 +399,7 @@ log_possible_wakeup_reason_start(int irq, struct irq_desc *desc, unsigned depth)
return cur_irq_tree;
}
void log_possible_wakeup_reason_complete(struct wakeup_irq_node *n,
static void log_possible_wakeup_reason_complete(struct wakeup_irq_node *n,
unsigned depth,
bool handled)
{
@ -435,6 +444,8 @@ bool log_possible_wakeup_reason(int irq,
return handled;
}
#endif /* CONFIG_DEDUCE_WAKEUP_REASONS */
void log_suspend_abort_reason(const char *fmt, ...)
{
va_list args;
@ -578,11 +589,15 @@ static int wakeup_reason_pm_event(struct notifier_block *notifier,
timespec_sub(curr_xtime, last_xtime));
}
#ifdef CONFIG_DEDUCE_WAKEUP_REASONS
/* log_wakeups should have been cleared by now. */
if (WARN_ON(logging_wakeup_reasons())) {
stop_logging_wakeup_reasons();
print_wakeup_sources();
}
#else
print_wakeup_sources();
#endif
break;
default:
break;