msm: iommu: Check for NULL genpools during domain teardown

During domain creation, some of the genpools will be set to NULL if
there is not enough memory for creation. Check for these NULL
genpools during domain destruction to avoid NULL dereferences.

Change-Id: I60238c138b809ef5c13383f5b1752ab6c799707d
CRs-Fixed: 573612
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
msm: camera: Update sensor mount angle and position

Update sensor driver to add sensor mount angle and
position as part of media entity flag. This info
is used by upper layers to get the info from
media device entity insted of opening camera
to reduce the launch latency.

Change-Id: I33e047cd52a87e9770de10c101631864b8737501
Signed-off-by: Aditya Jonnalagadda <ajonnala@codeaurora.org>
swap: add per-partition lock for swapfile

swap_lock is heavily contended when I test swap to 3 fast SSD (even
slightly slower than swap to 2 such SSD).  The main contention comes
from swap_info_get().  This patch tries to fix the gap with adding a new
per-partition lock.

Global data like nr_swapfiles, total_swap_pages, least_priority and
swap_list are still protected by swap_lock.

nr_swap_pages is an atomic now, it can be changed without swap_lock.  In
theory, it's possible get_swap_page() finds no swap pages but actually
there are free swap pages.  But sounds not a big problem.

Accessing partition specific data (like scan_swap_map and so on) is only
protected by swap_info_struct.lock.

Changing swap_info_struct.flags need hold swap_lock and
swap_info_struct.lock, because scan_scan_map() will check it.  read the
flags is ok with either the locks hold.

If both swap_lock and swap_info_struct.lock must be hold, we always hold
the former first to avoid deadlock.

swap_entry_free() can change swap_list.  To delete that code, we add a
new highest_priority_index.  Whenever get_swap_page() is called, we
check it.  If it's valid, we use it.

It's a pity get_swap_page() still holds swap_lock().  But in practice,
swap_lock() isn't heavily contended in my test with this patch (or I can
say there are other much more heavier bottlenecks like TLB flush).  And
BTW, looks get_swap_page() doesn't really need the lock.  We never free
swap_info[] and we check SWAP_WRITEOK flag.  The only risk without the
lock is we could swapout to some low priority swap, but we can quickly
recover after several rounds of swap, so sounds not a big deal to me.
But I'd prefer to fix this if it's a real problem.

"swap: make each swap partition have one address_space" improved the
swapout speed from 1.7G/s to 2G/s.  This patch further improves the
speed to 2.3G/s, so around 15% improvement.  It's a multi-process test,
so TLB flush isn't the biggest bottleneck before the patches.

Change-Id: Ic8d600653479c0e6767f04462c3f057b0fe94332
[arnd@arndb.de: fix it for nommu]
[hughd@google.com: add missing unlock]
[minchan@kernel.org: get rid of lockdep whinge on sys_swapon]
Signed-off-by: Shaohua Li <shli@fusionio.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Seth Jennings <sjenning@linux.vnet.ibm.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Cc: Dan Magenheimer <dan.magenheimer@oracle.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Git-commit: ec8acf20afb8534ed511f6613dd2226b9e301010
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[lauraa@codeaurora.org: Various context fixups due to backport]
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
msm: mdss: hdmi: Clear and disable interrupts when HDCP is inactive

When an HDCP interrupt is received while the HDCP session is
inactive, ensure that the interrupt it acknowledged and cleared
to avoid any potential interrupt storms.

Change-Id: Id297cb9a7d08a094727c966cf48966a6a37bb1f0
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
mmc: cd-gpio: Add sanity checks in mmc_cd_gpio_free()

Add necessary sanity checks in mmc_cd_gpio_free() to fix
below warning:

[    5.856209] WARNING: at
local/mnt/workspace/builds/jb2/kernel/kernel/irq/manage.c:1219
__free_irq+0x88/0x1a8()
[    5.856215] Trying to free already-free IRQ 0
[    5.856219] Modules linked in:
[    5.856239] [<c010be94>] (unwind_backtrace+0x0/0x11c) from [<c0190f38>]
(warn_slowpath_common+0x4c/0x64)

CRs-fixed: 564084
Change-Id: Ia9ea0e82453e645ce44046a762cd78aeb544e8b1
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
mm: vmscan: fix do_try_to_free_pages() livelock

This patch is based on KOSAKI's work and I add a little more description,
please refer https://lkml.org/lkml/2012/6/14/74.

Currently, I found system can enter a state that there are lots of free
pages in a zone but only order-0 and order-1 pages which means the zone is
heavily fragmented, then high order allocation could make direct reclaim
path's long stall(ex, 60 seconds) especially in no swap and no compaciton
enviroment.  This problem happened on v3.4, but it seems issue still lives
in current tree, the reason is do_try_to_free_pages enter live lock:

kswapd will go to sleep if the zones have been fully scanned and are still
not balanced.  As kswapd thinks there's little point trying all over again
to avoid infinite loop.  Instead it changes order from high-order to
0-order because kswapd think order-0 is the most important.  Look at
73ce02e9 in detail.  If watermarks are ok, kswapd will go back to sleep
and may leave zone->all_unreclaimable =3D 0.  It assume high-order users
can still perform direct reclaim if they wish.

Direct reclaim continue to reclaim for a high order which is not a
COSTLY_ORDER without oom-killer until kswapd turn on
zone->all_unreclaimble= .  This is because to avoid too early oom-kill.
So it means direct_reclaim depends on kswapd to break this loop.

In worst case, direct-reclaim may continue to page reclaim forever when
kswapd sleeps forever until someone like watchdog detect and finally kill
the process.  As described in:
http://thread.gmane.org/gmane.linux.kernel.mm/103737

We can't turn on zone->all_unreclaimable from direct reclaim path because
direct reclaim path don't take any lock and this way is racy.  Thus this
patch removes zone->all_unreclaimable field completely and recalculates
zone reclaimable state every time.

Note: we can't take the idea that direct-reclaim see zone->pages_scanned
directly and kswapd continue to use zone->all_unreclaimable.  Because, it
is racy.  commit 929bea7c71 (vmscan: all_unreclaimable() use
zone->all_unreclaimable as a name) describes the detail.

Change-Id: I49970a0fa751cf33af293fd1ee784e36422785b1
[akpm@linux-foundation.org: uninline zone_reclaimable_pages() and zone_reclaimable()]
Cc: Aaditya Kumar <aaditya.kumar.30@gmail.com>
Cc: Ying Han <yinghan@google.com>
Cc: Nick Piggin <npiggin@gmail.com>
Acked-by: Rik van Riel <riel@redhat.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Bob Liu <lliubbo@gmail.com>
Cc: Neil Zhang <zhangwm@marvell.com>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
Acked-by: Minchan Kim <minchan@kernel.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Lisa Du <cldu@marvell.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Git-commit: 6e543d5780e36ff5ee56c44d7e2e30db3457a7ed
[lauraa@codeaurora.org: Some context fixups and variable name changes due
to backporting. Dropped parts that don't apply to older kernels]
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
msm: vidc: Halt axi bus before clock disable.

Before turning off venus clock, host should make sure
that there are no pending AXI transactions. This is achieved
by halting AXI.

CRs-Fixed: 578007

Change-Id: Ib4a71d1097f2f62e910e00c7be5d32e006d4c62b
Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org>
Signed-off-by: Abhishek Ranjan <aranja@codeaurora.org>
Merge "msm: vidc: Halt axi bus before clock disable." into jb_3.2.1_rb4.6
Merge "mmc: cd-gpio: Add sanity checks in mmc_cd_gpio_free()" into jb_3.2.1_rb4.6
Merge "msm: mdss: hdmi: Clear and disable interrupts when HDCP is inactive" into jb_3.2.1_rb4.6
msm: vidc: remove api declation to compile .

This change will remove unwanted api declaration
to compile on jb_3.2.1_rb4 branch

CRs-Fixed: 578007
Change-Id: Ifd1e2e5be1a6c69f7b64712bde2b4f66c6bd10d9
Signed-off-by: Abhishek Ranjan <aranja@codeaurora.org>
of: batterydata: fix a typo on flat-ocv-threshold-uv property reading

This typo cause flat_ocv_threshold_uv value can't be read correctly,
and make adjust_soc() assign a wrong value to correction_limit_uv in
bms driver.

CRs-fixed: 572797
Change-Id: Ifc00c63070281e3adfafd3f10559f2660644af90
Signed-off-by: Wu Fenglin <fenglinw@codeaurora.org>
msm:Camera: Fix Power leak with sp1628 camera sensor

Instead of hard code to  GPIOF_OUT_INIT_LOW .
make use of power setting config value
for sensor power down.

Change-Id: Ib1037af550541b16be1f57c1145d83ea8bce4a27
Signed-off-by: Praveen Ac <praveenac@codeaurora.org>
ARM: dts: msm: update BMS OCV correction limits

The BMS OCV correction limits are currently wrong. The limit for higher
OCVs should be 100uV and the limit for lower OCVs should be 50uV. Fix
this in their respective BMS device tree nodes. Also, increase the OCV
correction thresholds by 50uV for low OCVs and 150uV for high OCVs in
order to allow additional compensation for inaccuracies that can occur.

Change-Id: Ib7482b70733c50a79a801152c333f2b0be0ed808
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
Merge "ARM: dts: msm: update BMS OCV correction limits" into jb_3.2.1_rb4.6
Merge "msm:Camera: Fix Power leak with sp1628 camera sensor" into jb_3.2.1_rb4.6
radio: iris: Add NULL pointer check

Dereferencing a NULL pointer may cause kernel crash,
Check for NULL pointer before dereferencing.

Change-Id: I43b1aa8054646f29833f82b7203192aa3494d912
CRs-Fixed: 548404
Signed-off-by: Ayaz Ahmad <aahmad@codeaurora.org>
msm: mdss: Fix NULL pointer dereference in mdss_mdp_display_wait4comp

Add sanity check for ctl to prevent NULL pointer dereference
leading to kernel panic.

CRs-Fixed: 578595
Change-Id: Iace727501856d9f93ba87eca92f9f000c32d2c8f
Signed-off-by: Jayant Shekhar <jshekhar@codeaurora.org>
msm: camera: Avoid uninitialized data copy to userspace

Add proper intialization to avoid invalid access in
userspace.

CRs-fixed: 552359
Change-Id: Iea1d6684fb4b061f7ab51945f15387b7f686ccf3
Signed-off-by: Deepak Cherian <dcheri@codeaurora.org>
lib: spinlock_debug: increase spin dump timeout

On certain targets the worst case console buffer draining time can
exceed the aggressive spin dump timeout value. Relax the timeout value
to cater to these scenarios.

Change-Id: I7312ffe06bafd2dc7adf0f4e8b73a53fc5839235
Signed-off-by: Syed Rameez Mustafa <rameezmustafa@codeaurora.org>