Commit graph

677 commits

Author SHA1 Message Date
Iliyan Malchev
953a4840dd PM: extend suspend_again mechanism to use partialresume
The old platform suspend_again callback overrides drivers' votes, such that if
it implemented and returns false, then we do not call the partialresume
handlers.  When it doesn't exists or returns true, then we also query the
registered drivers for consensus.

When a device resumes from suspend, the suspend/resume code invokes
partialresume to check to see if the set of wakeup interrupts all have matching
handlers. If this is not the case, the PM subsystem can continue to resume as
before.  If all of the wakeup sources have matching handlers, then those are
invoked in turn (and can block), and if all of them reach consensus that the
reason for the wakeup can be ignored, they say so to the PM subsystem, which
goes right back into suspend.

Signed-off-by: Iliyan Malchev <malchev@google.com>
Change-Id: Iaeb9ed78c4b5fb815c6e9c701233e703f481f962
2017-10-15 17:05:08 +03:00
Iliyan Malchev
4e0c8780cc power: add partial-resume framework
Partial resume refers to the concept of not waking up userspace when the kernel
comes out of suspend for certain types of events that we wish to discard.  An
example is a network packet that can be disacarded in the kernel, or spurious
wakeup event that we wish to ignore.  Partial resume allows drivers to register
callbacks, one one hand, and provides hooks into the PM's suspend/resume
mechanism, on the other.

When a device resumes from suspend, the core suspend/resume code invokes
partialresume to check to see if the set of wakeup interrupts all have
matching handlers. If this is not the case, the PM subsystem can continue to
resume as before.  If all of the wakeup sources have matching handlers, then
those are invoked in turn (and can block), and if all of them reach consensus
that the reason for the wakeup can be ignored, they say so to the PM subsystem,
which goes right back into suspend.  This latter support is implemented in a
separate change.

Signed-off-by: Iliyan Malchev <malchev@google.com>
Change-Id: Id50940bb22a550b413412264508d259f7121d442
2017-10-15 17:05:08 +03:00
Iliyan Malchev
7e87a4dc87 PM: wakeup_reason: correctly deduce wakeup interrupts
The wakeup_reason driver works by having a callback log_wakeup_reason(), be
called by the resume path once for each wakeup interrupt, with the irq number
as argument.  It then saves this interrupt in an array, and reports it when
requested (via /sys/kernel/wakeup_reasons/last_resume_reason) and also prints
the information out in kmsg.

This approach works, but it has the deficiency that often the reported wakeup
interrupt, while correct, is not the interrupt truly responsible for the
wakeup.  The reason for this is due to chained interrupt controllers (whether
in hardware or simulated in software).  It could be, for example, that the
power button is wired to a GPIO handled by a single interrupt for all GPIOs,
which interrupt then determines the GPIO and maps this to a software interrupt.
Whether this is done in software, or by chaining interrupt controllers, the end
result is that the wakeup reason will show not the interrupt associated with
the power button, but the base-GPIO interrupt instead.

This patch reworks the wakeup_sources driver such that it reports those final
interrupts we are interested in, and not the intermediate (and not the base)
ones.  It does so as follows:

-- The assumption is that generic_handle_irq() is called to dispatch all
   interrupts; due to this, chained interrupts result in recursive calls of
   generic_handle_irq().
-- We reconstruct the chains of interrupts that originate with the base wakeup
   interrupt and terminate with the interrupt we are interested in by tracing
   the calls to generic_handle_irq()
-- The tracing works by maitaining a per-cpu counter that is incremented with
   each call to generic_handle_irq(); that counter is reported to the
   wakeup_sources driver by a pair of functions, called
   log_possible_wakeup_reason_start() and log_possible_wakeup_reason_complete().
   The former is called before generic_handle_irq() handles the interrupt
   (thereby potentially calling itself recusively) and the latter afterward.
-- The two functions mentioned above are complemented by log_base_wake_reason()
   (renamed from log_wakeup_reason()), which is used to report the base wakeup
   interrupts to the wakeup_reason driver.
-- The three functions work together to build a set of trees, one per base
   wakeup reason, the leaves of which correspond to the interrupts we are
   interesed in; these trees can be arbitratily complex, though in reality they
   most often are a single node, or a chain of two nodes.  The complexity
   supports arbitrarily involved interrupt dispatch.
-- On resume, we build the tree; once the tree is completed, we walk it
   recursively, and print out to kmesg the (more useful) list of wakeup
   sources; simiarly, we walk the tree and print the leaves when
   /sys/kernel/wakeup_reasons/last_resume_reason is read.

Signed-off-by: Iliyan Malchev <malchev@google.com>
Change-Id: If8acb2951b61d2c6bcf4d011fe04d7f91057d139
2017-10-15 17:05:07 +03:00
Dmitry Shmidt
13e2b3277d PM: wakeup_reason: add check_wakeup_reason() to verify wakeup source irq
Wakeup reason is set before driver resume handlers are called.
It is cleared before driver suspend handlers are called, on
PM_SUSPEND_PREPARE.

Change-Id: I04218c9b0c115a7877e8029c73e6679ff82e0aa4
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Signed-off-by: Iliyan Malchev <malchev@google.com>
2017-10-15 16:24:04 +03:00
Ruchi Kandoi
e532467dab power: log the last suspend abort reason.
Extends the last_resume_reason to log suspend abort reason. The abort
reasons will have "Abort:" appended at the start to distinguish itself
from the resume reason.

Change-Id: Id3c62fc0cb86ca2e05a69e40de040b94f32be389
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Signed-off-by: Iliyan Malchev <malchev@google.com>
2017-10-15 16:23:56 +03:00
Ruchi Kandoi
1154a48192 PM: wakeup_reason: add functionality to log the last suspend-abort reason.
Extends the last_resume_reason to log suspend abort reason. The abort
reasons will have "Abort:" appended at the start to distinguish itself
from the resume reason.

Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Signed-off-by: Iliyan Malchev <malchev@google.com>
Change-Id: I3207f1844e3d87c706dfc298fb10e1c648814c5f
2017-10-15 16:17:14 +03:00
Iliyan Malchev
c9816de694 PM: wakeup_reason: add functions to query and clear wakeup reasons
The query results are valid until the next PM_SUSPEND_PREPARE.

Change-Id: I6bc2bd47c830262319576a001d39ac9a994916cf
Signed-off-by: Iliyan Malchev <malchev@google.com>
2017-10-15 16:17:14 +03:00
jinqian
ec32c90b65 Power: Report suspend times from last_suspend_time
This node epxorts two values separated by space.
From left to right:
1. time spent in suspend/resume process
2. time spent sleep in suspend state

Change-Id: I2cb9a9408a5fd12166aaec11b935a0fd6a408c63
2017-10-15 16:17:13 +03:00
Ruchi Kandoi
92b3e919c4 Power: Add guard condition for maximum wakeup reasons
Ensure the array for the wakeup reason IRQs does not overflow.

Change-Id: Iddc57a3aeb1888f39d4e7b004164611803a4d37c
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
2017-10-15 16:17:13 +03:00
Stepan Moskovchenko
6365c6e304 PM / Sleep: Clean up remnants of workqueue-based sync
When legacy wakelock code was removed in commit
f85607a715a74c65db812cd3901022888257f966, some of the code
for moving calls to sys_sync() from suspend paths into a
workqueue item had not been properly removed. Specifically,
one of the call sites to suspend_sys_sync_wait() has been
mistakenly replaced with a call to sys_sync(), which is not
necessary because the corresponding instance of
suspend_sys_sync_queue() was already replaced with
sys_sync(). Clean up the remnants of the legacy wakelock
code by removing the extraneous call to sys_sync() and
restoring some of the surrounding printk statements that
had been moved to suspend_sys_sync_queue() and subsequently
lost.

CRs-Fixed: 498669
Change-Id: Ifb2ede7808560f456c824d3d6359a4541c51b73f
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
2017-10-15 15:46:58 +03:00
Arve Hjønnevåg
516049d328 PM / Sleep: Fix a mistake in a conditional in autosleep_store()
The condition check in autosleep_store() is incorrect and prevents
/sys/power/autosleep from working as advertised.  Fix that.

[rjw: Added the changelog.]

Change-Id: I231cc24fc3f245003dcf5053ff6a71eb69ffa273
Signed-off-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Git-commit: 040e5bf65e
Git-repo: git://codeaurora.org/kernel/msm.git
Signed-off-by: Anurag Singh <anursing@codeaurora.org>
2017-10-15 15:46:58 +03:00
Amar Singhal
9801869142 power: main: Add conditional compilation for touch nodes
Add conditional compilation for touch event sysfs nodes. Otherwise,
if CONFIG_PM_SLEEP is not defined, there could be compilation errors.

Change-Id: I1ac7f284ec35eae2cfa076ef8e71c29ddc24817c
Signed-off-by: Amar Singhal <asinghal@codeaurora.org>
Signed-off-by: Anurag Singh <anursing@codeaurora.org>
2017-10-15 15:46:57 +03:00
Rafael J. Wysocki
d364a08bcc PM / Sleep: User space wakeup sources garbage collector Kconfig option
Make it possible to configure out the user space wakeup sources
garbage collector for debugging and default Android builds.

Change-Id: I85ca6caa92c8e82d863f0fa58d8861b5571c1b4a
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Arve Hjønnevåg <arve@android.com>
Git-commit: 4e585d25e1
Git-repo: git://codeaurora.org/kernel/msm.git
Signed-off-by: Anurag Singh <anursing@codeaurora.org>
2017-10-15 15:46:57 +03:00
Rafael J. Wysocki
5265f5b2e8 PM / Sleep: Make the limit of user space wakeup sources configurable
Make it possible to configure out the check against the limit of
user space wakeup sources for debugging and default Android builds.

Change-Id: I8f74d7c8391627df970d2df666938069b012e2fe
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Arve Hjønnevåg <arve@android.com>
Git-commit: c73893e2ca
Git-repo: git://codeaurora.org/kernel/msm.git
Signed-off-by: Anurag Singh <anursing@codeaurora.org>
2017-10-15 15:46:56 +03:00
Anurag Singh
e535fb5292 power: Remove unnecessary options from Kconfig
The config options HAS_WAKELOCK and WAKELOCK are
not needed any more since a wakeup sources-based
wakelock implementation will be used.

Change-Id: I4163f048c079ec3d10a02d9db16c3ca6fb5fd759
Signed-off-by: Anurag Singh <anursing@codeaurora.org>
2017-10-15 15:46:56 +03:00
Arve Hjønnevåg
f484965275 PM / Sleep: Add wake lock api wrapper on top of wakeup sources
Change-Id: Icaad02fe1e8856fdc2e4215f380594a5dde8e002
Signed-off-by: Arve Hjønnevåg <arve@android.com>
Git-commit: e9911f4efd
Git-repo: git://codeaurora.org/kernel/msm.git
[anursing@codeaurora.org: replace existing implementation, resolve
merge conflicts]
Signed-off-by: Anurag Singh <anursing@codeaurora.org>
2017-10-15 15:46:56 +03:00
Rafael J. Wysocki
9f3de1bd53 PM / Sleep: Add user space interface for manipulating wakeup sources, v3
Android allows user space to manipulate wakelocks using two
sysfs file located in /sys/power/, wake_lock and wake_unlock.
Writing a wakelock name and optionally a timeout to the wake_lock
file causes the wakelock whose name was written to be acquired (it
is created before is necessary), optionally with the given timeout.
Writing the name of a wakelock to wake_unlock causes that wakelock
to be released.

Implement an analogous interface for user space using wakeup sources.
Add the /sys/power/wake_lock and /sys/power/wake_unlock files
allowing user space to create, activate and deactivate wakeup
sources, such that writing a name and optionally a timeout to
wake_lock causes the wakeup source of that name to be activated,
optionally with the given timeout.  If that wakeup source doesn't
exist, it will be created and then activated.  Writing a name to
wake_unlock causes the wakeup source of that name, if there is one,
to be deactivated.  Wakeup sources created with the help of
wake_lock that haven't been used for more than 5 minutes are garbage
collected and destroyed.  Moreover, there can be only WL_NUMBER_LIMIT
wakeup sources created with the help of wake_lock present at a time.

The data type used to track wakeup sources created by user space is
called "struct wakelock" to indicate the origins of this feature.

This version of the patch includes an rbtree manipulation fix from John Stultz.

Change-Id: Icb452cfd54362b49dcb1cff88345928a2528ad97
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: NeilBrown <neilb@suse.de>
Git-commit: b86ff9820f
Git-repo: git://codeaurora.org/kernel/msm.git
[anursing@codeaurora.org: replace existing implementation, resolve
merge conflicts]
Signed-off-by: Anurag Singh <anursing@codeaurora.org>
2017-10-15 15:46:55 +03:00
Rafael J. Wysocki
aeeab22b61 PM / Sleep: Add "prevent autosleep time" statistics to wakeup sources
Android uses one wakelock statistics that is only necessary for
opportunistic sleep.  Namely, the prevent_suspend_time field
accumulates the total time the given wakelock has been locked
while "automatic suspend" was enabled.  Add an analogous field,
prevent_sleep_time, to wakeup sources and make it behave in a similar
way.

Change-Id: I4b9719d05da020757d7cc21ed3b52b7c32261bea
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Git-commit: 55850945e8
Git-repo: git://codeaurora.org/kernel/msm.git
Signed-off-by: Anurag Singh <anursing@codeaurora.org>
2017-10-15 15:46:55 +03:00
Rafael J. Wysocki
18c69d40cd PM / Sleep: Implement opportunistic sleep, v2
Introduce a mechanism by which the kernel can trigger global
transitions to a sleep state chosen by user space if there are no
active wakeup sources.

It consists of a new sysfs attribute, /sys/power/autosleep, that
can be written one of the strings returned by reads from
/sys/power/state, an ordered workqueue and a work item carrying out
the "suspend" operations.  If a string representing the system's
sleep state is written to /sys/power/autosleep, the work item
triggering transitions to that state is queued up and it requeues
itself after every execution until user space writes "off" to
/sys/power/autosleep.

That work item enables the detection of wakeup events using the
functions already defined in drivers/base/power/wakeup.c (with one
small modification) and calls either pm_suspend(), or hibernate() to
put the system into a sleep state.  If a wakeup event is reported
while the transition is in progress, it will abort the transition and
the "system suspend" work item will be queued up again.

Change-Id: Ic3214de009c64feab606e93811bd442ccfc49d86
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: NeilBrown <neilb@suse.de>
Git-commit: 7483b4a4d9
Git-repo: git://codeaurora.org/kernel/msm.git
[anursing@codeaurora.org: replace existing implementation, resolve
merge conflicts]
Signed-off-by: Anurag Singh <anursing@codeaurora.org>
2017-10-15 15:46:54 +03:00
Anurag Singh
960ea7ac6c power: Remove legacy wakelock code.
Remove parts of code that use the legacy wakelock
implementation as we make the switch to the upstream
kernel's wakeup sources-based implementation.

Change-Id: Idab9e3dd54e8a256b059c88606c9368f7ddb1c1b
Signed-off-by: Anurag Singh <anursing@codeaurora.org>
2017-10-10 15:41:57 +03:00
Anurag Singh
23ad8549f7 Revert "power: main: Add conditional compilation for touch nodes"
This reverts commit 8c880ff58fd257d3e9f20e04704cd9d1f3371fc7.
Reverting the change is required to allow for cleaner conflict
resolution as we move to the upstream kernel's wakeup sources
based wakelock implementation.

Change-Id: Ie14fe26a0fa244815dde7845330351beeef66f99
Signed-off-by: Anurag Singh <anursing@codeaurora.org>
2017-10-10 15:40:54 +03:00
Ruchi Kandoi
451076288b Power: Changes the permission to read only for sysfs file
/sys/kernel/wakeup_reasons/last_resume_reason

Change-Id: If25e8e416ee9726996518b58b6551a61dc1591e3
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
2014-08-05 19:00:47 +00:00
Ruchi Kandoi
30908e1f38 POWER: fix compile warnings in log_wakeup_reason
Change I81addaf420f1338255c5d0638b0d244a99d777d1 introduced compile
warnings, fix these.

Change-Id: I05482a5335599ab96c0a088a7d175c8d4cf1cf69
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
2014-03-13 17:28:54 +00:00
Ruchi Kandoi
9d6760b608 Power: add an API to log wakeup reasons
Add API log_wakeup_reason() and expose it to userspace via sysfs path
/sys/kernel/wakeup_reasons/last_resume_reason

Change-Id: I81addaf420f1338255c5d0638b0d244a99d777d1
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
2014-03-12 21:50:58 +00:00
Colin Cross
a63bae96bf freezer: shorten freezer sleep time using exponential backoff
All tasks can easily be frozen in under 10 ms, switch to using
an initial 1 ms sleep followed by exponential backoff until
8 ms.  Also convert the printed time to ms instead of centiseconds.

Change-Id: I7b198b16eefb623c2b0fc45dce50d9bca320afdc
Acked-by: Pavel Machek <pavel@ucw.cz>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-07-12 14:22:56 -07:00
Iliyan Malchev
495e27f2d1 Revert "PM: wakelock: Abort task freezing if a wake lock is held."
This reverts commit 649c5ec14a.
2013-07-12 14:22:56 -07:00
paris_yeh
b4c9504324 power: debug: enable debugging msg when CONFIG_PM_DEBUG is set
When CONFIG_PM_DEBUG is set, kmsg is able to reflect
  1)status of active wakelock held,
  2)callbacks registered with early_suspend and late_resume, and
  3)when entering kernel PM transition.

Change-Id: I41a7bb3e1ee47a02f80b1433fdeeb5e691acd0e2
Signed-off-by: paris_yeh <paris_yeh@asus.com>
Reviewed-on: http://mcrd1-5.corpnet.asus/code-review/master/62176
Reviewed-by: Chuang Simon <Simon_Chuang@asus.com>
Reviewed-by: Sam hblee <Sam_hblee@asus.com>
Reviewed-on: http://mcrd1-5.corpnet.asus/code-review/master/62899
Reviewed-on: http://mcrd1-5.corpnet.asus/code-review/master/68031
Reviewed-by: Jive Hwang <jive_hwang@asus.com>
Tested-by: Jive Hwang <jive_hwang@asus.com>
2013-04-18 16:07:54 -07:00
Stephen Boyd
84d1c1a3a3 Merge branch 'goog/googly' (early part) into goog/msm-soc-3.4
Fix NR_IPI to be 7 instead of 6 because both googly and core add
an IPI.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

Conflicts:
	arch/arm/Kconfig
	arch/arm/common/Makefile
	arch/arm/include/asm/hardware/cache-l2x0.h
	arch/arm/mm/cache-l2x0.c
	arch/arm/mm/mmu.c
	include/linux/wakelock.h
	kernel/power/Kconfig
	kernel/power/Makefile
	kernel/power/main.c
	kernel/power/power.h
2013-02-25 11:25:46 -08:00
Arve Hjønnevåg
72a790d2e2 consoleearlysuspend: Fix for 2.6.32
vt_waitactive now needs a 1 based console number

Change-Id: I07ab9a3773c93d67c09d928c8d5494ce823ffa2e
(cherry picked from commit b28a6a111c2c4779f92f310cfefe10606df4999f)
2013-02-20 01:32:22 -08:00
Arve Hjønnevåg
649c5ec14a PM: wakelock: Abort task freezing if a wake lock is held.
Avoids a problem where the device sometimes hangs for 20 seconds
before the screen is turned on.

Change-Id: Ib24dad1f0f56d280a80be820200ee9e9aea7a911
(cherry picked from commit 044fb1a352b4d367048b24c8c39abc2e572dc0e7)

Conflicts:

	kernel/power/process.c
2013-02-20 01:32:21 -08:00
Todd Poynor
6f9c00a76c PM: wakelocks: Display wakelocks preventing suspend by default
Use DEBUG_WAKEUP flag to show wakelocks that abort suspend, in
addition to showing wakelocks held during system resume.
DEBUG_WAKEUP is enabled by default.

Change-Id: If6fa68e8afbc482a5300ffab2964694b02b34f41
Signed-off-by: Todd Poynor <toddpoynor@google.com>
(cherry picked from commit ca64b0cd3a12d7704f4e98f4f5d51f41eb5047a2)
2013-02-20 01:32:20 -08:00
Colin Cross
da26fcfd19 wakelock: Fix operator precedence bug
Change-Id: I21366ace371d1b8f4684ddbe4ea8d555a926ac21
Signed-off-by: Colin Cross <ccross@google.com>
(cherry picked from commit 0c7841ce3e0a90bab630f671992348dafb022558)
2013-02-20 01:32:20 -08:00
Todd Poynor
a0c7f405af PM: wakelocks: Don't report wake up wakelock if suspend aborted
If the wakelock driver aborts suspend due to an already-held
wakelock, don't report the next wakelock held as the "wake up
wakelock".

Change-Id: I582ffbb87a3c361739a77d839a0c62921cff11a6
Signed-off-by: Todd Poynor <toddpoynor@google.com>
(cherry picked from commit ed27e538aa97278e26a6c00f14f6e2e076a1a2ae)
2013-02-20 01:32:19 -08:00
Mike Chan
cf83708fcc power: wakelock: Print active wakelocks when has_wake_lock() is called
When DEBUG_SUSPEND is enabled print active wakelocks when we check
if there are any active wakelocks.

In print_active_locks(), print expired wakelocks if DEBUG_EXPIRE is enabled

Change-Id: Ib1cb795555e71ff23143a2bac7c8a58cbce16547
Signed-off-by: Mike Chan <mike@android.com>
(cherry picked from commit af62b25adba1fe01c91aa88c95d1584371ab2bf9)
2013-02-20 01:32:18 -08:00
Mike Chan
714fdaf2e8 power: Prevent spinlock recursion when wake_unlock() is called
Signed-off-by: Mike Chan <mike@android.com>
(cherry picked from commit 97a0a74383d19a1a43ffca81271894ba3edc07b6)
2013-02-20 01:32:18 -08:00
Arve Hjønnevåg
75880a8986 PM: wakelocks: Use seq_file for /proc/wakelocks so we can get more than 3K of stats.
Change-Id: I42ed8bea639684f7a8a95b2057516764075c6b01
Signed-off-by: Arve Hjønnevåg <arve@android.com>
(cherry picked from commit 1b0749512f76005ce41607472e6f36411fa96649)
2013-02-20 01:32:17 -08:00
Todd Poynor
eef8bae31e PM: Backoff suspend if repeated attempts fail
Change-Id: I32289676d95a307ea3aa5e78f6c126ca979c0fec
Signed-off-by: Todd Poynor <toddpoynor@google.com>
(cherry picked from commit 7013f4976374ea75cb35446393be7bdc37bf607f)

Conflicts:

	kernel/power/wakelock.c
2013-02-20 01:32:17 -08:00
Colin Cross
9fd5fc24ec power: wakelock: use get_xtime_and_monotonic_and_sleep_offset in get_expired_time
Change-Id: I6ebe6b954b2ff328d46898d683650dafb9c4fe74
Signed-off-by: Erik Gilling <konkers@android.com>
(cherry picked from commit 28e23cf73c26d2bb13451804e328797a55f471e4)

Conflicts:

	kernel/power/wakelock.c
2013-02-20 01:32:16 -08:00
Erik Gilling
72baef3e87 power: wakelocks: fix buffer overflow in print_wake_locks
Change-Id: Ic944e3b3d3bc53eddc6fd0963565fd072cac373c
Signed-off-by: Erik Gilling <konkers@android.com>
(cherry picked from commit 10f0138c56a31a39c2a123af5af95cf8fd5de1ac)
2013-02-20 01:32:15 -08:00
Pratik Patel
2da9b910c0 power: fix suspend_sys_sync_wait()
Since the workqueue code deletes the work before executing it,
checking for no work item being currently queued to the workqueue
is not sufficient to guarantee that all the works have finished
execution.

Use a counter to guarantee that all the pending suspend_sys_sync()
works have finished execution before returning from
suspend_sys_sync_wait().

CRs-Fixed: 293595
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>

Conflicts:

	kernel/power/wakelock.c
(cherry picked from commit 529461b70c7dc20b0371e54a63844edae905d7a2)

Conflicts:

	kernel/power/wakelock.c

Change-Id: I501743b6b76e492e1598df83ebc1178835ae8405
2013-02-20 01:32:15 -08:00
Amar Singhal
77c5678ea8 framebuffer: add a pollable sysfs entry for display status
Wakeup the userspace poll on change of display status. The
userspace then may take action to change the
power/performance characteristics of the device.

Change-Id: I9bd11f3d895d3d83230104f5d8dcd1deeaa754cd
Signed-off-by: Amar Singhal <asinghal@codeaurora.org>
(cherry picked from commit 2fb0354486e2d7b8d73622cbdbb941748a921240)
2013-02-20 01:32:14 -08:00
Pratik Patel
1ae5815864 power: fix lcd resume taking long time with an ongoing file copy
This fixes the issue where LCD takes a long time to come back up
since the execution of backlight on and late_resume works by the
suspend worker thread is delayed due to one (or more) of the
sys_sync calls in early_suspend and suspend paths taking a long
time (sometimes 15sec or more) for the below reported scenario(s):

Scenario 1 (copy with usb connected):
1. plug usb
2. adb shell
3. busybox cp /sdcard/file1 /sdcard/file2 (copy >= 100MB file1
   in sdcard/emmc to file2 in sdcard/emmc)
4. press end key to suspend
5. press end key again and it takes a long time for LCD to come
   back up

Scenario 2 (background copy):
1. plug usb
2. adb shell
3. busybox cp /sdcard/file1 /sdcard/file2 & (copy >= 100MB file1
   in sdcard/emmc to file2 in sdcard/emmc)
4. disconnect usb
5. press end key to suspend
6. press end key again and it takes a long time for LCD to come
   back up

A more common form of Scenario 2 is for the user to just use the
copy function on the UI to copy large file(s).

We address this by moving sys_sync calls to a separate workqueue
and having a timeout polling based mechanism to bail out of suspend
in case of user invoking a wakeup event (like end key press) while
we are waiting for the sys_sync completion at the synchronization
point in suspend worker thread context.

CRs-Fixed: 283994
Change-Id: I6b54af8432e58fd5442817b7388ce2e0b83354b6
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
(cherry picked from commit 8564b5ebeafa2be276e0004d7d32bd101642fb3d)

Conflicts:

	kernel/power/process.c
2013-02-20 01:32:14 -08:00
Erik Gilling
57806f1cf0 earlysuspend: add verbose debug flag
when enabled, prints out the function of each handler as they are called

Change-Id: I5ed251867e0e3aa3cd05f030ff3579808cedd0c2
Signed-off-by: Erik Gilling <konkers@android.com>
(cherry picked from commit fec502d9a18bbe8045c67bd4f9d3a1ade4e78555)
2013-02-20 01:32:13 -08:00
Arve Hjønnevåg
3153586f73 PM: Enable early suspend through /sys/power/state
If EARLYSUSPEND is enabled then writes to /sys/power/state no longer
blocks, and the kernel will try to enter the requested state every
time no wakelocks are held. Write "on" to resume normal operation.

Change-Id: Icbe3c6fe6f5e0f4a3f948f1495546690ac9fd6e6
(cherry picked from commit 219955f707852f68f5118a515fc43ad067728ab9)
2013-02-20 01:32:12 -08:00
Amar Singhal
c387a7f0fb kernel/main: fix calling sysfs_notify from atomic context
Sysfs_notify takes a mutex and therefore cannot be called from atomic
context like interrupt handler in this case. Use a workqueue to schedule
the work instead.

Change-Id: I0a5230fe379aa51f1065df4af9b27f471aa22440
Signed-off-by: Amar Singhal <asinghal@codeaurora.org>
(cherry picked from commit 97d68a8b69e87480c436dd8365b438c3d18fed47)

Conflicts:

	kernel/power/main.c
2013-02-20 01:32:12 -08:00
Amar Singhal
6cc6e7bc61 kernel/power: add pollable sysfs entries for touch events
Provide userspace with a pollable sysfs entry that it can poll
on waiting for touch event notifiction. Once it
is woken up, the userspace can take action to change the
power/performance characteristics of the device for the duration
of the event.

Change-Id: Iab84f729f2ea3a5352c4e5173f78544023a276c1
Signed-off-by: Amar Singhal <asinghal@codeaurora.org>
(cherry picked from commit ac2a6d6453c50db7ba7c0b3aa328a3ba48a84abf)
2013-02-20 01:32:11 -08:00
Arve Hjønnevåg
da87d74481 PM: Add user-space wake lock api.
This adds /sys/power/wake_lock and /sys/power/wake_unlock.
Writing a string to wake_lock creates a wake lock the
first time is sees a string and locks it. Optionally, the
string can be followed by a timeout.
To unlock the wake lock, write the same string to wake_unlock.

Change-Id: I66c6e3fe6487d17f9c2fafde1174042e57d15cd7
(cherry picked from commit 025ff0ad2f)

Conflicts:

	kernel/power/Makefile
	kernel/power/power.h
2013-02-20 01:32:11 -08:00
Rebecca Schultz
af5692826b PM: earlysuspend: Removing dependence on console.
Rather than signaling a full update of the display from userspace via a
console switch, this patch introduces 2 files int /sys/power,
wait_for_fb_sleep and wait_for_fb_wake.  Reading these files will block
until the requested state has been entered.  When a read from
wait_for_fb_sleep returns userspace should stop drawing.  When
wait_for_fb_wake returns, it should do a full update.  If either are called
when the fb driver is already in the requested state, they will return
immediately.

Signed-off-by: Rebecca Schultz <rschultz@google.com>
Signed-off-by: Arve Hjønnevåg <arve@android.com>
(cherry picked from commit 4b0ea27fc8202b21ce338c82b55eee9c281bd7da)
2013-02-20 01:31:53 -08:00
Arve Hjønnevåg
08e9da6c0e PM: earlysuspend: Add console switch when user requested sleep state changes.
Signed-off-by: Arve Hjønnevåg <arve@android.com>
(cherry picked from commit c8bb31538d668c9d451e029d45edcd7c35892624)
2013-02-20 01:31:52 -08:00
Arve Hjønnevåg
de6c8784e4 PM: Implement early suspend api
(cherry picked from commit c1783f55b10d7dfb4ada9a7149821b644255d8df)
2013-02-08 15:14:36 -08:00