firefly-linux-kernel-4.4.55.git
8 years agoprocess: Add display of memory around registers when displaying regs.
San Mehat [Tue, 25 Aug 2009 23:52:22 +0000 (16:52 -0700)]
process: Add display of memory around registers when displaying regs.

This is extremely useful in diagnosing remote crashes, and is based heavily
on original work by <md@google.com>.

Signed-off-by: San Mehat <san@google.com>
Cc: Michael Davidson <md@google.com>
[ARM] process: Use uber-safe probe_kernel_address() to read mem when dumping.

This prevents the dump from taking pagefaults / external aborts.

Change-Id: I8df76e8638780f94fb1bd7ea4471e3f7b01df950
Signed-off-by: San Mehat <san@google.com>
8 years agoion: fix page pool cache policy
Amit Pundir [Mon, 18 Jan 2016 19:47:30 +0000 (01:17 +0530)]
ion: fix page pool cache policy

Fix redundant "buffer->private_flags & ION_PRIV_FLAG_SHRINKER_FREE"
checks in if(!cached ...) condition block.

AOSP Change-Id: I98ee8902df0c80135dddfa998c4ca4c2bb44e40e,
"ion: Handle the memory mapping correctly on x86", is broken
on android-3.18+ kernels. It conflicts with upstream commit
53a91c68fa7b, "staging: ion: Add private buffer flag to skip
page pooling on free", and break the ION_PRIV_FLAG_SHRINKER_FREE
private flag check logic.

Change-Id: I9cee4bcc3545cf92e07c21c2b42d27cf88da3316
Reported-by: chenfeng <puck.chen@hisilicon.com>
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agostaging: ion: Add X86 dependency for ION_POOL_CACHE_POLICY
Daniel Rosenberg [Thu, 1 Oct 2015 03:44:16 +0000 (20:44 -0700)]
staging: ion: Add X86 dependency for ION_POOL_CACHE_POLICY

ION_POOL_CACHE_POLICY uses x86 specific commands.
Only allow it to be used for x86.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Change-Id: Ic66e175fa41486b0b5f77872f2193add77cbe66f
(cherry picked from commit 43f4056cbec017c4414d74b032e9c14e009eabb0)

8 years agoion: Handle the memory mapping correctly on x86
Vinil Cheeramvelil [Wed, 8 Jul 2015 02:35:06 +0000 (10:35 +0800)]
ion: Handle the memory mapping correctly on x86

This patch modifies the ion page pool code to address
limitation in x86 PAT. When one physical page is mapped
to multiple virtual pages, the same cache policy
should be used. Add set_memory_wc/uc call to avoid aliases.
If not, all mappings will be cached(write back).

Change-Id: I98ee8902df0c80135dddfa998c4ca4c2bb44e40e
Signed-off-by: Zhebin Jin <zhebin.jin@intel.com>
Signed-off-by: Vinil Cheeramvelil <vinil.cheeramvelil@intel.com>
8 years agoion : In carveout heap, change minimum allocation order from 12 to PAGE_SHIFT, After...
Rajmal Menariya [Wed, 26 Aug 2015 13:02:52 +0000 (21:02 +0800)]
ion : In carveout heap, change minimum allocation order from 12 to PAGE_SHIFT, After this change each bit in bitmap (genalloc - General purpose special memory pool)

represents one page size memory.

Cc:sprd-ind-kernel-group@googlegroups.com
Cc:sanjeev.yadav@spreadtrum.com
Cc:Colin Cross <ccross@android.com>
cc:John Stultz <john.stultz@linaro.org>

Change-Id: I1172285dac014ecd2f1a965604b697d6739c1726
Signed-off-by: Rajmal Menariya <rajmal.menariya@spreadtrum.com>
8 years agoSELinux: build fix for 4.1
Amit Pundir [Thu, 29 Oct 2015 19:17:53 +0000 (00:47 +0530)]
SELinux: build fix for 4.1

Commit "SELinux: Enable setting security contexts on rootfs inodes."
cherry-picked in experimental/android-4.1 used a now obsolete flag
SE_SBLABELSUPP. Rename it to SBLABEL_MNT as intended by upstream
commit 12f348b9dcf6 "SELinux: rename SE_SBLABELSUPP to SBLABEL_MNT",
otherwise we run into following build error:

  CC      security/selinux/hooks.o
security/selinux/hooks.c: In function ‘sb_finish_set_opts’:
security/selinux/hooks.c:459:19: error: ‘SE_SBLABELSUPP’ undeclared (first use in this function)
   sbsec->flags |= SE_SBLABELSUPP;
                   ^
security/selinux/hooks.c:459:19: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [security/selinux/hooks.o] Error 1

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agoselinux: Android kernel compatibility with M userspace
Jeff Vander Stoep [Thu, 22 Oct 2015 16:30:40 +0000 (09:30 -0700)]
selinux: Android kernel compatibility with M userspace

NOT intended for new Android devices - this commit is unnecessary
for a target device that does not have a previous M variant.

DO NOT upstream. Android only.

Motivation:

This commit mitigates a mismatch between selinux kernel and
selinux userspace. The selinux ioctl white-listing binary policy
format that was accepted into Android M differs slightly from what
was later accepted into the upstream kernel. This leaves Android
master branch kernels incompatible with Android M releases. This
patch restores backwards compatibility. This is important because:

1. kernels may be updated on a different cycle than the rest of the
   OS e.g. security patching.
2. Android M bringup may still be ongoing for some devices. The
   same kernel should work for both M and master.

Backwards compatibility is achieved by checking for an Android M
policy characteristic during initial policy read and converting to
upstream policy format. The inverse conversion is done for policy
write as required for CTS testing.

Bug: 22846070
Change-Id: I2f1ee2eee402f37cf3c9df9f9e03c1b9ddec1929
Signed-off-by: Jeff Vander Stoep <jeffv@google.com>
8 years agoSELinux: Enable setting security contexts on rootfs inodes.
Stephen Smalley [Tue, 23 Jul 2013 21:38:41 +0000 (17:38 -0400)]
SELinux: Enable setting security contexts on rootfs inodes.

rootfs (ramfs) can support setting of security contexts
by userspace due to the vfs fallback behavior of calling
the security module to set the in-core inode state
for security.* attributes when the filesystem does not
provide an xattr handler.  No xattr handler required
as the inodes are pinned in memory and have no backing
store.

This is useful in allowing early userspace to label individual
files within a rootfs while still providing a policy-defined
default via genfs.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Paul Moore <pmoore@redhat.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
8 years agosecurity: Add proper checks for Android specific capability checks
Tushar Behera [Mon, 26 Mar 2012 11:24:15 +0000 (16:54 +0530)]
security: Add proper checks for Android specific capability checks

Commit b641072 ("security: Add AID_NET_RAW and AID_NET_ADMIN capability
check in cap_capable().") introduces additional checks for AID_NET_xxx
macros. Since the header file including those macros are conditionally
included, the checks should also be conditionally executed.

Change-Id: Iaec5208d5b95a46b1ac3f2db8449c661e803fa5b
Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
8 years agouid_cputime: skip power reporting per uid for now
Amit Pundir [Mon, 14 Dec 2015 06:26:35 +0000 (11:56 +0530)]
uid_cputime: skip power reporting per uid for now

AOSP's cpufreq_stats patch to report power/current
per cpufreq is broken at the moment so skip power
reporting for now.

Change-Id: I07779511f51ff3a9303dc98a3b71ac0a5882a4e9
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agouid_cputime: Check for the range while removing range of UIDs.
Ruchi Kandoi [Sat, 24 Oct 2015 00:49:11 +0000 (17:49 -0700)]
uid_cputime: Check for the range while removing range of UIDs.

Checking if the uid_entry->uid matches the uid intended to be removed will
prevent deleting unwanted uid_entry.
Type cast the key for the hashtable to the same size, as when they were
inserted. This will make sure that we can find the uid_entry we want.

Bug: 25195548
Change-Id: I567942123cfb20e4b61ad624da19ec4cc84642c1
Signed-off: Ruchi kandoi <kandoiruchi@google.com>

8 years agouid_cputime: Iterates over all the threads instead of processes.
Ruchi Kandoi [Fri, 31 Jul 2015 17:17:54 +0000 (10:17 -0700)]
uid_cputime: Iterates over all the threads instead of processes.

Bug: 22833116
Change-Id: I775a18f61bd2f4df2bec23d01bd49421d0969f87
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
8 years agouid_cputime: fix cputime overflow
Jin Qian [Tue, 14 Jul 2015 01:16:55 +0000 (18:16 -0700)]
uid_cputime: fix cputime overflow

Converting cputime_t to usec caused overflow when the value is greater
than 1 hour. Use msec and convert to unsigned long long to support bigger
range.

Bug: 22461683

Change-Id: I853fe3e8e7dbf0d3e2cc5c6f9688a5a6e1f1fb3e
Signed-off-by: Jin Qian <jinqian@google.com>
8 years agouid_cputime: Avoids double accounting of process stime, utime and cpu_power in task...
Ruchi Kandoi [Fri, 26 Jun 2015 21:19:21 +0000 (14:19 -0700)]
uid_cputime: Avoids double accounting of process stime, utime and cpu_power in task exit.

This avoids the race where a particular process is terminating and we
read the show_uid_stats. At this time since the task_struct still exists
and we will account for the terminating process as one of the active
task, where as the stats would have been added in the task exit
callback.

Bug: 22064385
Change-Id: Id2ae04b33fcd230eda9683a41b6019d4dd8f5d85
Signed-off-by: Jin Qian <jinqian@google.com>
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
8 years agouid_cputime: Extends the cputime functionality to report power per uid
Ruchi Kandoi [Fri, 17 Apr 2015 23:52:54 +0000 (16:52 -0700)]
uid_cputime: Extends the cputime functionality to report power per uid

/proc/uid_cputime/show_uid_stats shows a third field power for each of
the uids. It represents the power in the units (uAusec)

Change-Id: I52fdc5e59647e9dc97561a26d56f462a2689ba9c
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
8 years agoproc: uid_cputime: fix show_uid_stat permission
Jin Qian [Tue, 12 May 2015 00:57:52 +0000 (17:57 -0700)]
proc: uid_cputime: fix show_uid_stat permission

Change-Id: Ice9084e39da599261df0be6dc305b817b50cfbbf
Signed-off-by: Jin Qian <jinqian@google.com>
8 years agoproc: uid_cputime: create uids from kuids
Amit Pundir [Tue, 14 Apr 2015 19:10:21 +0000 (00:40 +0530)]
proc: uid_cputime: create uids from kuids

Create uids from kuids using from_kuid_munged(),
otherwise we run into following build error and warnings:
--------------------
  CC      drivers/misc/uid_cputime.o
drivers/misc/uid_cputime.c: In function ‘uid_stat_show’:
drivers/misc/uid_cputime.c:90:36: error: incompatible type for argument 1 of ‘find_or_register_uid’
drivers/misc/uid_cputime.c:54:26: note: expected ‘uid_t’ but argument is of type ‘kuid_t’
drivers/misc/uid_cputime.c:94:4: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘kuid_t’ [-Wformat]
drivers/misc/uid_cputime.c: In function ‘process_notifier’:
drivers/misc/uid_cputime.c:194:6: error: incompatible types when assigning to type ‘uid_t’ from type ‘kuid_t’
make[2]: *** [drivers/misc/uid_cputime.o] Error 1
--------------------

Change-Id: Ifecb98001f7fe2fac74d1ef3e1abd03d43fc9059
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
(cherry picked from commit b0f4decae627cf2d74e6f72c7ecb939c77d48625)

8 years agoproc: uid: Adds accounting for the cputimes per uid.
jinqian [Wed, 11 Mar 2015 17:44:50 +0000 (10:44 -0700)]
proc: uid: Adds accounting for the cputimes per uid.

Adds proc files /proc/uid_cputime/show_uid_stat and
/proc/uid_cputime/remove_uid_range.

show_uid_stat lists the total utime and stime for the active as well as
terminated processes for each of the uids.

Writing a range of uids to remove_uid_range will delete the accounting
for all the uids within that range.

Change-Id: I21d9210379da730b33ddc1a0ea663c8c9d2ac15b

8 years agofixup! proc: make oom adjustment files user read-only
Dan Willemsen [Wed, 18 Mar 2015 18:22:44 +0000 (11:22 -0700)]
fixup! proc: make oom adjustment files user read-only

Fix the build by removing the duplicate line that uses the obsolete INF
macro.

Signed-off-by: Dan Willemsen <dwillemsen@nvidia.com>
8 years agoproc: make oom adjustment files user read-only
Rom Lemarchand [Sat, 7 Mar 2015 17:38:05 +0000 (09:38 -0800)]
proc: make oom adjustment files user read-only

Make oom_adj and oom_score_adj user read-only.

Bug: 19636629
Change-Id: I055bb172d5b4d3d856e25918f3c5de8edf31e4a3
Signed-off-by: Rom Lemarchand <romlem@google.com>
8 years agoproc: smaps: Allow smaps access for CAP_SYS_RESOURCE
San Mehat [Wed, 16 Sep 2009 19:39:10 +0000 (12:39 -0700)]
proc: smaps: Allow smaps access for CAP_SYS_RESOURCE

Signed-off-by: San Mehat <san@google.com>
8 years agoprctl: reset PR_SET_TIMERSLACK_PID value to avoid conflict
Amit Pundir [Wed, 30 Sep 2015 10:31:08 +0000 (16:01 +0530)]
prctl: reset PR_SET_TIMERSLACK_PID value to avoid conflict

PR_SET_TIMERSLACK_PID value keep colliding with that of
newer prctls in mainline (e.g. first with PR_SET_THP_DISABLE,
and again with PR_MPX_ENABLE_MANAGEMENT).

So reset PR_SET_TIMERSLACK_PID to a large number so as to
avoid conflict in the near term while it is out of mainline
tree.

Corresponding Change-Id up for review in platform/system/core
is Icd8c658c8eb62136dc26c2c4c94f7782e9827cdb

Change-Id: I061b25473acc020c13ee22ecfb32336bc358e76a
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agoprctl: make PR_SET_TIMERSLACK_PID pid namespace aware
Micha Kalfon [Tue, 13 Jan 2015 10:12:57 +0000 (12:12 +0200)]
prctl: make PR_SET_TIMERSLACK_PID pid namespace aware

Make PR_SET_TIMERSLACK_PID consider pid namespace and resolve the
target pid in the caller's namespace. Otherwise, calls from pid
namespace other than init would fail or affect the wrong task.

Change-Id: I1da15196abc4096536713ce03714e99d2e63820a
Signed-off-by: Micha Kalfon <micha@cellrox.com>
Acked-by: Oren Laadan <orenl@cellrox.com>
8 years agoprctl: fix misplaced PR_SET_TIMERSLACK_PID case
Micha Kalfon [Tue, 13 Jan 2015 09:47:20 +0000 (11:47 +0200)]
prctl: fix misplaced PR_SET_TIMERSLACK_PID case

The case clause for the PR_SET_TIMERSLACK_PID option was placed inside
the an internal switch statement for PR_MCE_KILL (see commits 37a591d4
and 8ae872f1) . This commit moves it to the right place.

Change-Id: I63251669d7e2f2aa843d1b0900e7df61518c3dea
Signed-off-by: Micha Kalfon <micha@cellrox.com>
Acked-by: Oren Laadan <orenl@cellrox.com>
8 years agoprctl: adds the capable(CAP_SYS_NICE) check to PR_SET_TIMERSLACK_PID.
Ruchi Kandoi [Sat, 14 Jun 2014 00:03:01 +0000 (17:03 -0700)]
prctl: adds the capable(CAP_SYS_NICE) check to PR_SET_TIMERSLACK_PID.

Adds a capable() check to make sure that arbitary apps do not change the
timer slack for other apps.

Bug: 15000427
Change-Id: I558a2551a0e3579c7f7e7aae54b28aa9d982b209
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
8 years agoprctl: adds PR_SET_TIMERSLACK_PID for setting timer slack of an arbitrary thread.
Ruchi Kandoi [Fri, 18 Apr 2014 21:07:28 +0000 (14:07 -0700)]
prctl: adds PR_SET_TIMERSLACK_PID for setting timer slack of an arbitrary thread.

Second argument is similar to PR_SET_TIMERSLACK, if non-zero then the
slack is set to that value otherwise sets it to the default for the thread.

Takes PID of the thread as the third argument.

This allows power/performance management software to set timer slack for
other threads according to its policy for the thread (such as when the
thread is designated foreground vs. background activity)

Change-Id: I744d451ff4e60dae69f38f53948ff36c51c14a3f
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
8 years agoUPSTREAM: memcg: Only free spare array when readers are done
Martijn Coenen [Thu, 14 Jan 2016 13:33:52 +0000 (14:33 +0100)]
UPSTREAM: memcg: Only free spare array when readers are done

A spare array holding mem cgroup threshold events is kept around
to make sure we can always safely deregister an event and have an
array to store the new set of events in.

In the scenario where we're going from 1 to 0 registered events, the
pointer to the primary array containing 1 event is copied to the spare
slot, and then the spare slot is freed because no events are left.
However, it is freed before calling synchronize_rcu(), which means
readers may still be accessing threshold->primary after it is freed.

Fixed by only freeing after synchronize_rcu().

Signed-off-by: Martijn Coenen <maco@google.com>
8 years agocgroup: refactor allow_attach handler for 4.4
Amit Pundir [Mon, 21 Dec 2015 10:31:10 +0000 (16:01 +0530)]
cgroup: refactor allow_attach handler for 4.4

Refactor *allow_attach() handler to align it with the changes
from mainline commit 1f7dd3e5a6e4 "cgroup: fix handling of
multi-destination migration from subtree_control enabling".

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agocgroup: fix cgroup_taskset_for_each call in allow_attach() for 4.1
Dmitry Shmidt [Wed, 28 Oct 2015 01:18:04 +0000 (18:18 -0700)]
cgroup: fix cgroup_taskset_for_each call in allow_attach() for 4.1

Change-Id: I05013f6e76c30b0ece3671f9f2b4bbdc626cd35c
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
8 years agoinclude: linux: cgroup: Fix compiler warning
Daniel Rosenberg [Mon, 12 Jan 2015 22:21:52 +0000 (14:21 -0800)]
include: linux: cgroup: Fix compiler warning

Signed-off-by: Daniel Rosenberg <drosen@google.com>
8 years agoFix generic cgroup subsystem permission checks
Christian Poetzsch [Wed, 3 Jun 2015 11:07:33 +0000 (12:07 +0100)]
Fix generic cgroup subsystem permission checks

In 53b5e2f generic cgroup subsystem permission checks have been added.
When this is been done within procs_write an empty taskset is added to
the tasks css set. When a task later on migrates to a new group we see a
dmesg warning cause the mg_node isn't empty (cgroup.c:2086). Cause this
happens all the time this spams dmesg.

I am not really familiar with this code, but it looks to me like adding
the taskset is just a temporary action in this context. Therefore this
taskset should be removed after the actual check. This is what this fix
does.

This problem was seen and the fix tested on x86 using l-mr1 and master.

Change-Id: I9894d39e8b5692ef65149002b07e65a84a33ffea
Signed-off-by: Christian Poetzsch <christian.potzsch@imgtec.com>
8 years agocgroup: Fix issues in allow_attach callback
Rom Lemarchand [Wed, 27 May 2015 00:00:44 +0000 (17:00 -0700)]
cgroup: Fix issues in allow_attach callback

- Return -EINVAL when cgroups support isn't enabled
- Add allow_attach callback in CPU cgroups

Change-Id: Id3360b4a39919524fc4b6fcbd44fa2050009f000
Signed-off-by: Rom Lemarchand <romlem@android.com>
8 years agocgroup: memcg: pass correct argument to subsys_cgroup_allow_attach
Amit Pundir [Wed, 1 Apr 2015 08:28:39 +0000 (13:58 +0530)]
cgroup: memcg: pass correct argument to subsys_cgroup_allow_attach

Pass correct argument to subsys_cgroup_allow_attach(), which
expects 'struct cgroup_subsys_state *' argument but we pass
'struct cgroup *' instead which doesn't seem right.

This fixes following 'incompatible pointer type' compiler warning:
----------
  CC      mm/memcontrol.o
mm/memcontrol.c: In function ‘mem_cgroup_allow_attach’:
mm/memcontrol.c:5052:2: warning: passing argument 1 of ‘subsys_cgroup_allow_attach’ from incompatible pointer type [enabled by default]
In file included from include/linux/memcontrol.h:22:0,
                 from mm/memcontrol.c:29:
include/linux/cgroup.h:953:5: note: expected ‘struct cgroup_subsys_state *’ but argument is of type ‘struct cgroup *’
----------

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agocgroup: Add generic cgroup subsystem permission checks
Colin Cross [Wed, 13 Jul 2011 02:53:24 +0000 (19:53 -0700)]
cgroup: Add generic cgroup subsystem permission checks

Rather than using explicit euid == 0 checks when trying to move
tasks into a cgroup via CFS, move permission checks into each
specific cgroup subsystem. If a subsystem does not specify a
'allow_attach' handler, then we fall back to doing our checks
the old way.

Use the 'allow_attach' handler for the 'cpu' cgroup to allow
non-root processes to add arbitrary processes to a 'cpu' cgroup
if it has the CAP_SYS_NICE capability set.

This version of the patch adds a 'allow_attach' handler instead
of reusing the 'can_attach' handler.  If the 'can_attach' handler
is reused, a new cgroup that implements 'can_attach' but not
the permission checks could end up with no permission checks
at all.

Change-Id: Icfa950aa9321d1ceba362061d32dc7dfa2c64f0c
Original-Author: San Mehat <san@google.com>
Signed-off-by: Colin Cross <ccross@android.com>
8 years agomemcg: add permission check
Rom Lemarchand [Fri, 7 Nov 2014 17:42:40 +0000 (09:42 -0800)]
memcg: add permission check

Use the 'allow_attach' handler for the 'mem' cgroup to allow
non-root processes to add arbitrary processes to a 'mem' cgroup
if it has the CAP_SYS_NICE capability set.

Bug: 18260435
Change-Id: If7d37bf90c1544024c4db53351adba6a64966250
Signed-off-by: Rom Lemarchand <romlem@android.com>
8 years agocgroup: refactor allow_attach function into common code
Rom Lemarchand [Fri, 7 Nov 2014 20:48:17 +0000 (12:48 -0800)]
cgroup: refactor allow_attach function into common code

move cpu_cgroup_allow_attach to a common subsys_cgroup_allow_attach.
This allows any process with CAP_SYS_NICE to move tasks across cgroups if
they use this function as their allow_attach handler.

Bug: 18260435
Change-Id: I6bb4933d07e889d0dc39e33b4e71320c34a2c90f
Signed-off-by: Rom Lemarchand <romlem@android.com>
8 years agowakeup_reason: use vsnprintf instead of snsprintf for vargs.
Ruchi Kandoi [Wed, 5 Aug 2015 23:54:53 +0000 (16:54 -0700)]
wakeup_reason: use vsnprintf instead of snsprintf for vargs.

Bug: 22368519
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
8 years agopower: wakeup_reason: fix suspend time reporting
Amit Pundir [Mon, 13 Apr 2015 21:08:20 +0000 (02:38 +0530)]
power: wakeup_reason: fix suspend time reporting

Suspend time reporting Change-Id: I2cb9a9408a5fd12166aaec11b935a0fd6a408c63
(Power: Report suspend times from last_suspend_time), is broken on 3.16+
kernels because get_xtime_and_monotonic_and_sleep_offset() hrtimer helper
routine is removed from kernel timekeeping.

The replacement helper routines ktime_get_update_offsets_{tick,now}()
are private to core kernel timekeeping so we can't use them, hence using
ktime_get() and ktime_get_boottime() instead and sampling the time twice.

Idea is to use Monotonic boottime offset to calculate total time spent
in last suspend state and CLOCK_MONOTONIC to calculate time spent in
last suspend-resume process.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agowakeup: Add last wake up source logging for suspend abort reason.
Ruchi Kandoi [Wed, 8 Apr 2015 22:42:29 +0000 (15:42 -0700)]
wakeup: Add last wake up source logging for suspend abort reason.

There is a possibility that a wakeup source event is received after
the device prepares to suspend which might cause the suspend to abort.

This patch adds the functionality of reporting the last active wakeup
source which is currently not active but caused the suspend to abort reason
via the /sys/kernel/power/last_wakeup_reason file.

Change-Id: I1760d462f497b33e425f5565cb6cff5973932ec3
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
8 years agoPower: Report suspend times from last_suspend_time
jinqian [Wed, 25 Mar 2015 23:18:44 +0000 (16:18 -0700)]
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

8 years agopower: Remove HAS_WAKELOCK config and document WAKELOCK
Dylan Reid [Tue, 3 Mar 2015 17:38:28 +0000 (09:38 -0800)]
power: Remove HAS_WAKELOCK config and document WAKELOCK

Remove the HAS_WAKELOCK config as it doesn't seem to have been used in
the 3.10 or 3.14 kernels.

Add some Documentation to CONFIG_WAKELOCK so that it is selectable and
can be disabled is desired.

Signed-off-by: Dylan Reid <dgreid@chromium.org>
8 years agoMake suspend abort reason logging depend on CONFIG_PM_SLEEP
Lorenzo Colitti [Thu, 27 Nov 2014 06:12:10 +0000 (15:12 +0900)]
Make suspend abort reason logging depend on CONFIG_PM_SLEEP

This unbreaks the build on architectures such as um that do not
support CONFIG_PM_SLEEP.

Change-Id: Ia846ed0a7fca1d762ececad20748d23610e8544f
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
8 years agopower: Add check_wakeup_reason() to verify wakeup source irq
Dmitry Shmidt [Fri, 31 Oct 2014 23:05:46 +0000 (16:05 -0700)]
power: 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>
8 years agopower: Adds functionality to log the last suspend abort reason.
Ruchi Kandoi [Wed, 29 Oct 2014 17:36:27 +0000 (10:36 -0700)]
power: Adds 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>
Change-Id: I3207f1844e3d87c706dfc298fb10e1c648814c5f

8 years agopower: Avoids bogus error messages for the suspend aborts.
Ruchi Kandoi [Wed, 15 Oct 2014 00:43:21 +0000 (17:43 -0700)]
power: Avoids bogus error messages for the suspend aborts.

Avoids printing bogus error message "tasks refusing to freeze", in cases
where pending wakeup source caused the suspend abort.

Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Change-Id: I913ad290f501b31cd536d039834c8d24c6f16928

8 years agopower: Add property CHARGE_COUNTER_EXT and 64-bit precision properties
Todd Poynor [Thu, 12 Dec 2013 23:59:09 +0000 (15:59 -0800)]
power: Add property CHARGE_COUNTER_EXT and 64-bit precision properties

Add POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT that stores accumulated charge
in nAh units as a signed 64-bit value.

Add generic support for signed 64-bit property values.

Change-Id: I2bd34b1e95ffba24e7bfef81f398f22bd2aaf05e
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agoPower: Changes the permission to read only for sysfs file /sys/kernel/wakeup_reasons...
Ruchi Kandoi [Thu, 24 Apr 2014 21:31:57 +0000 (14:31 -0700)]
Power: Changes the permission to read only for sysfs file /sys/kernel/wakeup_reasons/last_resume_reason

Change-Id: I8ac568a7cb58c31decd379195de517ff3c6f9c65
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
8 years agopower: wakeup_reason: rename irq_count to irqcount
Greg Hackmann [Mon, 10 Mar 2014 21:21:30 +0000 (14:21 -0700)]
power: wakeup_reason: rename irq_count to irqcount

On x86, irq_count conflicts with a declaration in
arch/x86/include/asm/processor.h

Change-Id: I3e4fde0ff64ef59ff5ed2adc0ea3a644641ee0b7
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agoPower: Add guard condition for maximum wakeup reasons
Ruchi Kandoi [Fri, 7 Mar 2014 20:54:30 +0000 (12:54 -0800)]
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>
(cherry picked from commit b5ea40cdfcf38296535f931a7e5e7bf47b6fad7f)

8 years agoPOWER: fix compile warnings in log_wakeup_reason
Ruchi Kandoi [Fri, 21 Feb 2014 03:47:38 +0000 (19:47 -0800)]
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>
8 years agoPower: add an API to log wakeup reasons
Ruchi Kandoi [Wed, 19 Feb 2014 23:30:47 +0000 (15:30 -0800)]
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>
8 years agoPM / Suspend: Print wall time at suspend entry and exit
Todd Poynor [Wed, 30 May 2012 00:33:56 +0000 (17:33 -0700)]
PM / Suspend: Print wall time at suspend entry and exit

Change-Id: I92f252414c013b018b9a392eae1ee039aa0e89dc
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agodrivers: power: Add watchdog timer to catch drivers which lockup during suspend.
Benoit Goby [Thu, 13 Aug 2009 16:40:42 +0000 (09:40 -0700)]
drivers: power: Add watchdog timer to catch drivers which lockup during suspend.

Rather than hard-lock the kernel, dump the suspend thread stack and
BUG() when a driver takes too long to suspend.  The timeout is set
to 12 seconds to be longer than the usbhid 10 second timeout.

Exclude from the watchdog the time spent waiting for children that
are resumed asynchronously and time every device, whether or not they
resumed synchronously.

Change-Id: Ifd211c06b104860c2fee6eecfe0d61774aa4508a
Original-author: San Mehat <san@google.com>
Signed-off-by: Benoit Goby <benoit@android.com>
8 years agopower: power_supply: add POWER_SUPPLY_PROP_CHARGE_ENABLED
Todd Poynor [Wed, 18 Jul 2012 23:28:50 +0000 (16:28 -0700)]
power: power_supply: add POWER_SUPPLY_PROP_CHARGE_ENABLED

Change-Id: I3e93b502452811cbfc4d904202b4f1d94edc143d
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agopower: power_supply: add POWER_SUPPLY_PROP_USB_OTG
Todd Poynor [Fri, 13 Jul 2012 20:30:04 +0000 (13:30 -0700)]
power: power_supply: add POWER_SUPPLY_PROP_USB_OTG

Change-Id: Idfc6ef2e37d62aad6f26cc8eafa53db642cd352b
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agopower: power_supply: move POWER_SUPPLY_PROP_USB_HC to type 'int' order
Todd Poynor [Fri, 13 Jul 2012 03:27:16 +0000 (20:27 -0700)]
power: power_supply: move POWER_SUPPLY_PROP_USB_HC to type 'int' order

Change-Id: I001af30ab5fe06dde5f368241f21b9e0864777a1
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agopower_supply: Add custom property for USB High Current mode
Todd Poynor [Tue, 3 Jul 2012 22:41:20 +0000 (15:41 -0700)]
power_supply: Add custom property for USB High Current mode

For smb347.

Change-Id: I3323469072e1ee5085d61af8a89612b06b91f94a
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agotrace: power: add trace_clock_set_parent
Colin Cross [Wed, 9 May 2012 23:09:50 +0000 (16:09 -0700)]
trace: power: add trace_clock_set_parent

Adds a new trace event to be called from clk_set_parent.  Some
cpufreq drivers, including Tegra, reparent the cpu clock to a
slower clock while the main pll is relocking, tracing
clk_set_parent allows traces to show how for long the cpu is
running slower.

Uses a separate TRACE_EVENT instead of the clock event class to
allow the event to contain string names for the child and the
parent.

Signed-off-by: Colin Cross <ccross@android.com>
8 years agomisc seq_printf fixes for 4.4
Amit Pundir [Thu, 1 Oct 2015 05:14:36 +0000 (10:44 +0530)]
misc seq_printf fixes for 4.4

Update seq_printf() usage in aosp patches to align
with changes from mainline commit 6798a8caaf64
"fs/seq_file: convert int seq_vprint/seq_printf/etc...
returns to void".

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agomisc: uidstat: Remove use of obsolete create_proc_read_entry api
Arve Hjønnevåg [Tue, 14 May 2013 03:34:22 +0000 (20:34 -0700)]
misc: uidstat: Remove use of obsolete create_proc_read_entry api

Signed-off-by: Arve Hjønnevåg <arve@android.com>
8 years agomisc: uidstat: avoid create_stat() race and blockage.
JP Abgrall [Thu, 30 May 2013 22:31:17 +0000 (15:31 -0700)]
misc: uidstat: avoid create_stat() race and blockage.

* create_stat() race would lead to:
  [   58.132324] proc_dir_entry 'uid_stat/10061' already registered

* blocking kmalloc reported by sbranden
 tcp_read_sock()
  uid_stat_tcp_rcv()
    create_stat()
      kmalloc(GFP_KERNEL)

Signed-off-by: JP Abgrall <jpa@google.com>
8 years agotrace: cpufreq: Add tracing for min/max cpufreq
Ruchi Kandoi [Fri, 20 Nov 2015 00:07:19 +0000 (16:07 -0800)]
trace: cpufreq: Add tracing for min/max cpufreq

Change-Id: I73f6ec437c1f805437d9376abb6510d1364b07ec
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
8 years agotracing/sched: Add trace events to track cpu hotplug.
Arun Bharadwaj [Wed, 3 Jul 2013 17:35:02 +0000 (10:35 -0700)]
tracing/sched: Add trace events to track cpu hotplug.

Add ftrace event trace_sched_cpu_hotplug to track cpu
hot-add and hot-remove events.

This is useful in a variety of power, performance and
debug analysis scenarios.

Change-Id: I5d202c7a229ffacc3aafb7cf9afee0b0ee7b0931
Signed-off-by: Arun Bharadwaj <abharadw@codeaurora.org>
8 years agotrace: fix compilation for 4.1
Dmitry Shmidt [Wed, 28 Oct 2015 17:45:04 +0000 (10:45 -0700)]
trace: fix compilation for 4.1

Change-Id: Id88b5d30847bc6d3cfe1d8cd00cbdc975c9712d1
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
8 years agommc: Add tracepoints of mmc block operations
Ken Sumrall [Thu, 16 May 2013 03:13:13 +0000 (20:13 -0700)]
mmc: Add tracepoints of mmc block operations

Add tracepoints to record the start and end of each mmc block
operation.  This includes read, write, erase, secure erase,
trim, secure trim1 and secure trim 2, discard and
sanitize commands.

Change-Id: Ic5d1cbdb9adb940d8b1a2a13c73970023575df50
Signed-off-by: Ken Sumrall <ksumrall@android.com>
8 years agotrace/events: fix gpu event timestamp formatting
Jamie Gennis [Fri, 19 Apr 2013 03:36:21 +0000 (20:36 -0700)]
trace/events: fix gpu event timestamp formatting

This change fixes the how the gpu_sched_switch timestamp field is formatted.

Signed-off-by: Jamie Gennis <jgennis@google.com>
Change-Id: I273234935254ed15772c9e561c9af20e480004ae

8 years agotrace: add non-hierarchical function_graph option
Jamie Gennis [Thu, 22 Nov 2012 04:14:09 +0000 (20:14 -0800)]
trace: add non-hierarchical function_graph option

Add the 'funcgraph-flat' option to the function_graph tracer to use the default
trace printing format rather than the hierarchical formatting normally used.

Change-Id: If2900bfb86e6f8f51379f56da4f6fabafa630909
Signed-off-by: Jamie Gennis <jgennis@google.com>
8 years agotrace: Add an option to show tgids in trace output
Jamie Gennis [Wed, 21 Nov 2012 23:04:25 +0000 (15:04 -0800)]
trace: Add an option to show tgids in trace output

The tgids are tracked along side the saved_cmdlines tracking, and can be
included in trace output by enabling the 'print-tgid' trace option. This is
useful when doing post-processing of the trace data, as it allows events to be
grouped by tgid.

Change-Id: I52ed04c3a8ca7fddbb868b792ce5d21ceb76250e
Signed-off-by: Jamie Gennis <jgennis@google.com>
8 years agotrace/events: add gpu trace events
Jamie Gennis [Fri, 22 Feb 2013 01:55:28 +0000 (17:55 -0800)]
trace/events: add gpu trace events

Change-Id: I0607b9c776acf61cb796b8572cf8cfb8b2dc1377
Signed-off-by: Jamie Gennis <jgennis@google.com>
8 years agoCHROMIUM: android: Unconditionally remove callbacks in sync_fence_free()
Andrew Bresticker [Mon, 12 Oct 2015 20:31:45 +0000 (13:31 -0700)]
CHROMIUM: android: Unconditionally remove callbacks in sync_fence_free()

Using fence->status to determine whether or not there are callbacks
remaining on the sync_fence is racy since fence->status may have been
decremented to 0 on another CPU before fence_check_cb_func() has
completed.  By unconditionally calling fence_remove_callback() for each
fence in the sync_fence, we guarantee that each callback has either
completed (since fence_remove_callback() grabs the fence lock) or been
removed.

BUG=chrome-os-partner:46382
TEST=Reboot cycle test on Smaug; no crashes seen.

Change-Id: I837180ef633aed3c5ae1e52e0d6ded838342b8fa
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/305331
Reviewed-by: Puneet Kumar <puneetster@chromium.org>
8 years agoCHROMIUM: android: fix warning when releasing active sync point
Dmitry Torokhov [Wed, 9 Sep 2015 00:30:52 +0000 (17:30 -0700)]
CHROMIUM: android: fix warning when releasing active sync point

Userspace can close the sync device while there are still active fence
points, in which case kernel produces the following warning:

[   43.853176] ------------[ cut here ]------------
[   43.857834] WARNING: CPU: 0 PID: 892 at /mnt/host/source/src/third_party/kernel/v3.18/drivers/staging/android/sync.c:439 android_fence_release+0x88/0x104()
[   43.871741] CPU: 0 PID: 892 Comm: Binder_5 Tainted: G     U 3.18.0-07661-g0550ce9 #1
[   43.880176] Hardware name: Google Tegra210 Smaug Rev 1+ (DT)
[   43.885834] Call trace:
[   43.888294] [<ffffffc000207464>] dump_backtrace+0x0/0x10c
[   43.893697] [<ffffffc000207580>] show_stack+0x10/0x1c
[   43.898756] [<ffffffc000ab1258>] dump_stack+0x74/0xb8
[   43.903814] [<ffffffc00021d414>] warn_slowpath_common+0x84/0xb0
[   43.909736] [<ffffffc00021d530>] warn_slowpath_null+0x14/0x20
[   43.915482] [<ffffffc00088aefc>] android_fence_release+0x84/0x104
[   43.921582] [<ffffffc000671cc4>] fence_release+0x104/0x134
[   43.927066] [<ffffffc00088b0cc>] sync_fence_free+0x74/0x9c
[   43.932552] [<ffffffc00088b128>] sync_fence_release+0x34/0x48
[   43.938304] [<ffffffc000317bbc>] __fput+0x100/0x1b8
[   43.943185] [<ffffffc000317cc8>] ____fput+0x8/0x14
[   43.947982] [<ffffffc000237f38>] task_work_run+0xb0/0xe4
[   43.953297] [<ffffffc000207074>] do_notify_resume+0x44/0x5c
[   43.958867] ---[ end trace 5a2aa4027cc5d171 ]---

Let's fix it by introducing a new optional callback (disable_signaling)
to fence operations so that drivers can do proper clean ups when we
remove last callback for given fence.

BUG=chrome-os-partner:40303
TEST=Boot Smaug and observe that warning is gone.

Change-Id: I05c34dcf74438c28405438c7ead0706b1f810fff
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/303409
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
8 years agosync: add Documentation/sync.txt
Erik Gilling [Fri, 14 Sep 2012 21:36:34 +0000 (14:36 -0700)]
sync: add Documentation/sync.txt

Change-Id: Ic7f3a6d4622083be607b82ddd8d676609225bb8f
Signed-off-by: Erik Gilling <konkers@android.com>
8 years agovideo: adf: build fixes for 4.1
Amit Pundir [Mon, 6 Jul 2015 19:39:40 +0000 (01:09 +0530)]
video: adf: build fixes for 4.1

Couple of ADF build fixes for v4.1

adf/adf_fops.c fix:
get_unused_fd() is obsolete, use get_unused_fd_flags(O_CLOEXEC)
instead to allocate a default file descriptor. This fix is a
followup of upstream commit f938612dd97d "include/linux/file.h:
remove get_unused_fd() macro".

adf/adf_memblock.c fix:
Fix dma_buf_export() call. Based on mainline commit d8fbe341beb6
"dma-buf: cleanup dma_buf_export() to make it easily extensible".

Otherwise we run into following build failures:
----------
  CC      drivers/video/adf/adf_fops.o
  CC      drivers/video/adf/adf_memblock.o
drivers/video/adf/adf_memblock.c: In function ‘adf_memblock_export’:
drivers/video/adf/adf_memblock.c:154:2: warning: passing argument 1 of ‘dma_buf_export’ from incompatible pointer type [enabled by default]
In file included from drivers/video/adf/adf_memblock.c:15:0:
include/linux/dma-buf.h:211:17: note: expected ‘const struct dma_buf_export_info *’ but argument is of type ‘struct adf_memblock_pdata *’
drivers/video/adf/adf_memblock.c:154:2: error: too many arguments to function ‘dma_buf_export’
In file included from drivers/video/adf/adf_memblock.c:15:0:
include/linux/dma-buf.h:211:17: note: declared here
make[3]: *** [drivers/video/adf/adf_memblock.o] Error 1
make[3]: *** Waiting for unfinished jobs....
drivers/video/adf/adf_fops.c: In function ‘adf_device_post_config’:
drivers/video/adf/adf_fops.c:228:2: error: implicit declaration of function ‘get_unused_fd’ [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors
make[3]: *** [drivers/video/adf/adf_fops.o] Error 1
make[2]: *** [drivers/video/adf] Error 2
make[2]: *** Waiting for unfinished jobs....
----------

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agovideo: adf: fix memblock build failure
Amit Pundir [Wed, 1 Apr 2015 11:14:44 +0000 (16:44 +0530)]
video: adf: fix memblock build failure

Pass 'NULL' as the 5th argument to dma_buf_export() to fix
the following build failure:
----------
  CC      drivers/video/adf/adf_memblock.o
drivers/video/adf/adf_memblock.c: In function ‘adf_memblock_export’:
drivers/video/adf/adf_memblock.c:154:60: error: macro "dma_buf_export" requires 5 arguments, but only 4 given
drivers/video/adf/adf_memblock.c:154:8: error: ‘dma_buf_export’ undeclared (first use in this function)
drivers/video/adf/adf_memblock.c:154:8: note: each undeclared identifier is reported only once for each function it appears in
make[3]: *** [drivers/video/adf/adf_memblock.o] Error 1
make[2]: *** [drivers/video/adf] Error 2
----------

5th argument to dma_buf_export() is a pointer to 'reservation-object'
and a new 'reservation-object' is allocated in case 'NULL' is passed.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agovideo: adf: fix wrong bitops in adf_modeinfo_to_fb_videomode()
Greg Hackmann [Tue, 16 Dec 2014 23:59:51 +0000 (15:59 -0800)]
video: adf: fix wrong bitops in adf_modeinfo_to_fb_videomode()

Change-Id: I1296153e382c0b66b713a0e7d09665ed5961f13d
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
8 years agovideo: adf: Cleanup sw_sync timeline at adf_device_destroy
Jonathan Hamilton [Thu, 17 Jul 2014 22:54:44 +0000 (15:54 -0700)]
video: adf: Cleanup sw_sync timeline at adf_device_destroy

If a sw_sync timeline was created by ADF (for drivers that do not implement
ops->complete_fence) we should clean it up when the ADF device is
destroyed.

Change-Id: Idd90180fcae56a87111f7d12bdd80190756a6b80
Signed-off-by: Jonathan Hamilton <jonathan.hamilton@imgtec.com>
8 years agovideo: adf: fbdev: add stubs for kernels without ADF_FBDEV
Greg Hackmann [Tue, 29 Apr 2014 18:18:45 +0000 (11:18 -0700)]
video: adf: fbdev: add stubs for kernels without ADF_FBDEV

Change-Id: I42e087cddc29f6b93749791606e80dbd3e6f59ce
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: memblock: map buffer for dma
Greg Hackmann [Tue, 29 Apr 2014 00:00:44 +0000 (17:00 -0700)]
video: adf: memblock: map buffer for dma

Change-Id: I4df13c8b45b57fd0594b5e7bf351a4da33a8cb11
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: use rb_erase in adf_obj_destroy.
Alistair Strachan [Mon, 21 Apr 2014 20:09:23 +0000 (13:09 -0700)]
video: adf: use rb_erase in adf_obj_destroy.

Not calling rb_erase() can cause slab corruption, as the rb_first() call
after kfree() in adf_obj_destroy() can return the same node twice unless
it is erased.

This problem was reproduced by unloading a kernel module that used the
adf framework *after* a vsync event was registered. A crash would occur
in rb_first(). (Just loading and immediately unloading the module without
the vsync event worked correctly.)

Change-Id: I9fa7cb5d7519691e38a281439844aa193da13d1b
Signed-off-by: Alistair Strachan <alistair.strachan@imgtec.com>
Cc: Jonathan Hamilton <jonathan.hamilton@imgtec.com>
Cc: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: adf_memblock_export symbol should be exported
Greg Hackmann [Tue, 8 Apr 2014 20:07:29 +0000 (13:07 -0700)]
video: adf: adf_memblock_export symbol should be exported

Change-Id: I228db28da885b47b6fa9fc7e4001663797d24f49
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: add buffer padding quirk
Greg Hackmann [Tue, 8 Apr 2014 19:36:41 +0000 (12:36 -0700)]
video: adf: add buffer padding quirk

Quirks specify common behaviors that vary slightly among devices, and
which ADF must account for.

The buffer padding quirk captures the way different devices fetch the
last scanline in a buffer: some devices fetch an entire line (including
padding to the pitch) while others only fetch up to the visible width.
ADF's buffer size validation now takes this quirk into account.

Change-Id: I828b13316e27621d8a9efd9d5fffa6ce12a525ff
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: document adf_format_validate_yuv's origin
Greg Hackmann [Tue, 8 Apr 2014 19:25:12 +0000 (12:25 -0700)]
video: adf: document adf_format_validate_yuv's origin

Change-Id: I929045a96a56bdb2c915be92b8ef11b560f3ab79
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: ensure consistent alignment on userspace facing structs
Greg Hackmann [Wed, 26 Mar 2014 23:43:23 +0000 (16:43 -0700)]
video: adf: ensure consistent alignment on userspace facing structs

64-bit types in structs create alignment problems when a 32-bit x86
userspace talks to an x86_64 kernel.  In most cases the 64-bit types can
be replaced with 32-bit ones, since they're being used for fds and
should have been __s32 in the first place.  For adf_vsync_event,
alignment can be enforced by making the timestamp an __aligned_u64.

Change-Id: I87cf73d8f57730bd7bb43ffce6b7b411eb0ff198
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: replace fbdev helper's open flag with refcount
Greg Hackmann [Mon, 24 Mar 2014 23:45:43 +0000 (16:45 -0700)]
video: adf: replace fbdev helper's open flag with refcount

A device's fb_info is shared between clients.  fb_release() is called
when each client is released, not just the last one.  Since the fbdev
helper needs to release its dma-buf when the last client goes away, it
must keep its own reference count.

fbmem and fbcon hold different locks while calling fb_release(), so
explicit locking is needed.

Change-Id: I42cd659f7633adba7c11f407d4b594bd43305d6a
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: export the adf_attachment_allow symbol to modules.
Alistair Strachan [Tue, 11 Mar 2014 00:00:25 +0000 (17:00 -0700)]
video: adf: export the adf_attachment_allow symbol to modules.

There are no in-tree users of adf_attachment_allow, but out-of-tree
modules want to use it. It looks like this function should be
EXPORT_SYMBOL.

Change-Id: Iad522dc5d32ac09fec6483bbc317db8ecae12e97
Signed-off-by: Alistair Strachan <alistair.strachan@imgtec.com>
8 years agovideo: adf: use %zu when printing size_t
Greg Hackmann [Fri, 14 Feb 2014 23:35:38 +0000 (15:35 -0800)]
video: adf: use %zu when printing size_t

Change-Id: I9cf7ebc368bad0a83db9e5aa370feadf117b21c0
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: fix compat ioctls calling ioctl with wrong cmd
Greg Hackmann [Fri, 14 Feb 2014 23:38:49 +0000 (15:38 -0800)]
video: adf: fix compat ioctls calling ioctl with wrong cmd

Change-Id: Icdbac3edd123b3114103dc138a60e6955006cda4
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: use ADF_IOCTL_TYPE in compat ioctl definitions
Greg Hackmann [Fri, 14 Feb 2014 23:39:52 +0000 (15:39 -0800)]
video: adf: use ADF_IOCTL_TYPE in compat ioctl definitions

Change-Id: I7451a282d9d972c9957568b366c164b67b4b47e8
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: define constants for device-custom ioctls
Greg Hackmann [Mon, 13 Jan 2014 23:24:24 +0000 (15:24 -0800)]
video: adf: define constants for device-custom ioctls

Device-custom ADF ioctls can use type ADF_IOCTL_TYPE and
nr >= ADF_IOCTL_NR_CUSTOM

Change-Id: Ia8270973df5100e996ca0e021ede60e54b9af72a
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: fix fbdev blank -> dpms state mapping
Greg Hackmann [Fri, 22 Nov 2013 21:50:24 +0000 (13:50 -0800)]
video: adf: fix fbdev blank -> dpms state mapping

Change-Id: I96132a1b7275d389a6d0ba8899c6be838b63c422
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: validate dpms state passed to blank
Greg Hackmann [Wed, 20 Nov 2013 20:10:35 +0000 (12:10 -0800)]
video: adf: validate dpms state passed to blank

Change-Id: I3a4228d50fc4a2553b3e92e5675a94cbc6e71b8a
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: fix ADF_MAX_ATTACHMENTS declaration
Greg Hackmann [Mon, 11 Nov 2013 22:31:12 +0000 (14:31 -0800)]
video: adf: fix ADF_MAX_ATTACHMENTS declaration

Userspace-facing ADF_MAX_ATTACHMENTS must be in terms of
userspace-facing struct adf_attachment_config

Change-Id: Iaaddcd6366f13b3e52eb3911efcfff8a61e0b225
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: remove PAGE_SIZE from userspace-facing header
Greg Hackmann [Wed, 20 Nov 2013 22:02:09 +0000 (14:02 -0800)]
video: adf: remove PAGE_SIZE from userspace-facing header

Systems may define PAGE_SIZE in userspace limits.h but don't have to.
PAGE_SIZE was picked as an arbitrary "reasonable" limit so just use 4096
instead.

Change-Id: I9555e39aba64a3a70f61eb6ded2a4129ab236ce0
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: make device node names less hierarchical
Greg Hackmann [Thu, 7 Nov 2013 18:12:00 +0000 (10:12 -0800)]
video: adf: make device node names less hierarchical

adf/foobar/device -> adf0
adf/foobar/interface1 -> adf-interface0.1
adf/foobar/overlay-engine1 -> adf-overlay-engine0.1

Change-Id: I7af7f84ce3f101ecb02f448070c200ff3e03f2ec
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: expose adf_modeinfo_set_{name,vrefresh} to drivers
Greg Hackmann [Thu, 17 Oct 2013 20:18:53 +0000 (13:18 -0700)]
video: adf: expose adf_modeinfo_set_{name,vrefresh} to drivers

Change-Id: Id9f8b2184927a77b244ce0b33d619d6e44a0f17a
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: set default interface dpms_state to OFF
Greg Hackmann [Wed, 16 Oct 2013 21:53:12 +0000 (14:53 -0700)]
video: adf: set default interface dpms_state to OFF

Interfaces default to unplugged, so they should also default to off

Change-Id: I36500a54b11f354a0d7dd2c9924a79e0d9c6f855
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: make dpms_state sysfs attribute writable
Greg Hackmann [Thu, 15 Aug 2013 19:51:22 +0000 (12:51 -0700)]
video: adf: make dpms_state sysfs attribute writable

Change-Id: I04e7785cbddac160003e6c9edaf62d20b367fdc9
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: add helpers for validating custom formats
Greg Hackmann [Tue, 15 Oct 2013 19:51:20 +0000 (12:51 -0700)]
video: adf: add helpers for validating custom formats

Many custom formats look a lot like the standard ones, but with
different subsampling, bpp, etc.  Expose and document
adf_buffer_validate()'s main body, so drivers can reuse its logic when
validating these formats.

Change-Id: I1d06981c9e5aab26f3ab2956c08c679f2c823bcc
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: add informational flags to interfaces
Greg Hackmann [Fri, 13 Sep 2013 18:23:05 +0000 (11:23 -0700)]
video: adf: add informational flags to interfaces

Informational flags don't affect ADF directly but may be useful to
clients.  Currently used to indicate primary and external displays.

Change-Id: I343c7f0148da0869244c8e818350e9855525df85
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: add fbdev compatibility helper
Greg Hackmann [Tue, 9 Jul 2013 20:07:26 +0000 (13:07 -0700)]
video: adf: add fbdev compatibility helper

Change-Id: I2b82bb625f805e8edb27799743b290dda5befb97
Signed-off-by: Greg Hackmann <ghackmann@google.com>