power: android-battery: use freezable workqueue for monitor

Alarmtimer may execute the monitor early in the resume sequence.  Freeze the
monitor while suspended, and unfreeze after the battery charger and fuel gauge,
etc. drivers are resumed.

Change-Id: Iefda1c642d4b2440169d90d2bee2888fc70e030a
Signed-off-by: Todd Poynor <toddpoynor@google.com>
gpu: ion: Fix several issues with page pool

Split out low and high mem pages so they are correctly reported
when the shrinker is called.
Fix potential deadlock caused by holding the page pool lock while
allocationg and also needing that lock from the shrink function

Change-Id: I6def3a3111f59914ef6b5b59d81a6fde37cb60c5
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
netfilter: xt_qtaguid: fix error exit that would keep a spinlock.

qtudev_open() could return with a uid_tag_data_tree_lock held
when an kzalloc(..., GFP_ATOMIC) would fail.
Very unlikely to get triggered AND survive the mayhem of running out of mem.


Signed-off-by: JP Abgrall <jpa@google.com>
gpu: ion: Fix lockdep issue in ion_page_pool

Currently the mutex is held while kmalloc is called, under a low memory
condition this might trigger the shrinker which also takes this mutex.
Refactor so the mutex is not held during allocation.

Change-Id: Ic1d3b2f69e61209191bac84724ba56f6b98e2bc4
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
gpu: ion: Switch to using a single shrink function

The single shrink function will free lower order pages first. This
enables compaction to work properly.

Change-Id: Icbeefa9e84c2eacf6962d9536ab66a8b059cc941
sync: dump sync state of fence errors

Change-Id: I297a43aadf83504993040ea875c7f22d988628f1
Signed-off-by: Erik Gilling <konkers@android.com>
power: android-battery: Battery health check only when connected to charger

Only check battery health when connected to a charger.

Change-Id: I43e3f73ac1e5862f8e6dbaa19daa6d322f3bba20
Signed-off-by: HongMin Son <hongmin.son@samsung.com>
sync: protect unlocked access to fence status

Fence status is checked outside of locks in both sync_fence_wait and
sync_fence_poll.  This patch adds propper barrier protection in these
cases to avoid seeing stale status.

Change-Id: I9d8b6ce6accb415e797df58068a1ccd54e6be445
Signed-off-by: Erik Gilling <konkers@android.com>
gpu: ion: Refactor locking

Removes contention for lock between allocate and free by reducing
the length of time the lock is held for.  Split out a seperate
lock to protect the list of heaps and replace it with a rwsem since
the list will most likely only be updated during initialization.

Change-Id: I3017ccaa2126c7a24ab22b18e1ee553983977c37
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
ext4: protect group inode free counting with group lock

Now when we set the group inode free count, we don't have a proper
group lock so that multiple threads may decrease the inode free
count at the same time. And e2fsck will complain something like:

Free inodes count wrong for group #1 (1, counted=0).
Fix? no

Free inodes count wrong for group #2 (3, counted=0).
Fix? no

Directories count wrong for group #2 (780, counted=779).
Fix? no

Free inodes count wrong for group #3 (2272, counted=2273).
Fix? no

So this patch try to protect it with the ext4_lock_group.

btw, it is found by xfstests test case 269 and the volume is
mkfsed with the parameter
"-O ^resize_inode,^uninit_bg,extent,meta_bg,flex_bg,ext_attr"
and I have run it 100 times and the error in e2fsck doesn't
show up again.

Change-Id: Icfa95256688b50734e9152cbdc84a851a39b8ed5
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
sync: update new fence status with sync_fence_signal_pt

If a fence's pt is signaled before sync_fence_create is called, the fence
will never transition into the signaled state.  This also address a tiny
race if a merged fence's pt after sync_fence_get_status checks it's status
and before fence->status is updated.

Change-Id: Ic8e292a323db26c6f04cb4757d920278b3125ff6
Signed-off-by: Erik Gilling <konkers@android.com>
sync: use proper barriers when waiting indefinitely

The previous fix only addressed waiting with a timeout.

Change-Id: I8ad735d2d0dfdd53592904e8a54f5689cb5eaa5e
Signed-off-by: Erik Gilling <konkers@android.com>
net: wireless: bcmdhd: Propagate FW failure to upper layer

Bug: 7324935

Change-Id: I944a6da8a008ec3bcaf2f5a606e15e46eebac537
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
net: wireless: bcmdhd: Skip turning chip off if not responding

Bug: 7324935

Change-Id: I7ae2baea80c66a39b9fc9f3a640f3a999cd193eb
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
staging:iio:events: Don't copy data to user-space with a locked spinlock.

iio_event_chrdev_read would return -EFAULT if the user-space page was
not resident.

Change-Id: I4ac5d3bc791bb503d014d9db576b9d6d522505b2
Signed-off-by: Arve Hjønnevåg <arve@android.com>
sync: refactor sync debug printing

Move driver callbacks to fill strings instead of using seq_files.  This
will allow those values to be used in a future tracepoint patch.

Change-Id: I9b706343e35b11124141fe520e520514a32003d2
Signed-off-by: Erik Gilling <konkers@android.com>
sw_sync: convert to new value_str debug ops

Change-Id: I9bad0cac1198043e04637641feb8112e2e7a9d11
Signed-off-by: Erik Gilling <konkers@android.com>
sync: add tracepoint support

Change-Id: I181326db4247009161557e45444c9b3548b83d25
Signed-off-by: Erik Gilling <konkers@android.com>
power: android-battery: Allow changing current in charging state

When a new charge source is set, enable charging and set the charging
current, unless we've paused charging due to battery full or battery
health problems.

Change-Id: I129e621c455a941e264dc431b4eb9db6a17c9f7b
Signed-off-by: Danke Xie <d.xie@sta.samsung.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
ARM: Use TTBR1 instead of reserved context ID

On ARMv7 CPUs that cache first level page table entries (like the
Cortex-A15), using a reserved ASID while changing the TTBR or flushing
the TLB is unsafe.

This is because the CPU may cache the first level entry as the result of
a speculative memory access while the reserved ASID is assigned. After
the process owning the page tables dies, the memory will be reallocated
and may be written with junk values which can be interpreted as global,
valid PTEs by the processor. This will result in the TLB being populated
with bogus global entries.

This patch avoids the use of a reserved context ID in the v7 switch_mm
and ASID rollover code by temporarily using the swapper_pg_dir pointed
at by TTBR1, which contains only global entries that are not tagged
with ASIDs.

Reviewed-by: Frank Rowand <frank.rowand@am.sony.com>
Tested-by: Marc Zyngier <Marc.Zyngier@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
[catalin.marinas@arm.com: add LPAE support]
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>