ion: free low memory from page pools first

The patch is ported from Linux3.13, since the directory structure was
changed, we apply the patch manually.

Below is the patch detail infromation:
From ce3d10933a3e2e1d2cb3b9ae91b6b945f189bb90 Mon Sep 17 00:00:00 2001
From: Colin Cross <ccross@android.com>
Date: Fri, 13 Dec 2013 19:26:22 -0800
Subject: ion: free low memory from page pools first

When the shrinkers are called with GFP_HIGH free low memory first,
it is more important to have free than high memory.

Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Change-Id: I12f4dd3dc99af53b40b19c30581f9a0ff762011c
Signed-off-by: Hong-Mei Li <a21834@motorola.com>
Reviewed-on: http://gerrit.mot.com/653080
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Fred Fettinger <fettinge@motorola.com>
Reviewed-by: Patrick Auchter <auchter@motorola.com>
Reviewed-by: Joseph Swantek <jswantek@motorola.com>
Reviewed-by: Yi-Wei Zhao <gbjc64@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
SLTApproved: Connie Zhao <czhao1@motorola.com>
(cherry picked from commit 7aca22460496f8326a87168764a02546b4c3459c)

Signed-off-by: klozz <xxx.reptar.rawrr.xxx@gmail.com>
 ion: shrink highmem pages on kswapd

The patch is ported from Linux3.16, since the directory structure was
changed, I merged the patch manually.

Below is the patch detail information:

From 0cd2dc4db3ba23ff8ab38b8ae81b126626f795d5 Mon Sep 17 00:00:00 2001
From: Heesub Shin <heesub.shin@samsung.com>
Date: Wed, 28 May 2014 15:52:59 +0900
Subject: staging: ion: shrink highmem pages on kswapd

ION system heap keeps pages in its pool for better performance. When the
system is under memory pressure, slab shrinker calls the callback
registered and then the pages pooled get freed.

When the shrinker is called, it checks gfp_mask and determines whether
the pages from highmem need to be freed or the pages from lowmem.
Usually, slab shrinker is invoked on kswapd context which gfp_mask is
always GFP_KERNEL, so only lowmem pages are released on kswapd context.
This means that highmem pages in the pool are never reclaimed until
direct reclaim occurs. This can be problematic when the page pool holds
excessive amounts of highmem.

For now, the shrinker callback cannot know exactly which zone should be
targeted for reclamation, as enough information are not passed to. Thus,
it makes sense to shrink both lowmem and highmem zone on kswapd context.

Reported-by: Wonseo Choi <wonseo.choi@samsung.com>
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
Reviewed-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Tested-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Hong-Mei Li <a21834@motorola.com>

Change-Id: If5b10cea87d0222a81c54eb6fedc04fc05247438
Reviewed-on: http://gerrit.mot.com/653081
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Fred Fettinger <fettinge@motorola.com>
Reviewed-by: Joseph Swantek <jswantek@motorola.com>
Reviewed-by: Patrick Auchter <auchter@motorola.com>
Reviewed-by: Yi-Wei Zhao <gbjc64@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
SLTApproved: Connie Zhao <czhao1@motorola.com>
(cherry picked from commit 11fb404929c73bd82453c4b16f9074078686951f)

Signed-off-by: klozz <xxx.reptar.rawrr.xxx@gmail.com>
 ion: Add missing unlock on error path

A mutex_unlock was missing for the alloc_lock on an error
path. Add it.

Change-Id: If88b72fbc2fd18504347b784d5daa2bc9170c55f
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

Signed-off-by: klozz <xxx.reptar.rawrr.xxx@gmail.com>
Unified patch 3.4.50

Signed-off-by: klozz <xxx.reptar.rawrr.xxx@gmail.com>
mm: Increase number of GFP masks

The __GFP_CMA mask is now placed after all available GFP masks.
With this we need to increase the total number of GFP flags.
Do so accordingly.

Bug: 17626969
CRs-Fixed: 648978
Change-Id: I53f5f064ac16a50ee10c84ff2bb50fdb7e085bd0
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Naveen Ramaraj <nramaraj@codeaurora.org>
Signed-off-by: klozz <xxx.reptar.rawrr.xxx@gmail.com>
cpufreq: Always allow update of user policy

In the cases where the system boots up in a constraint with policy min and
max lower than cpuinfo min/max, and user tries to set a higher user
policy min, the value would be overridden during the verifying the
limits.

Once user initiates the sysfs write the previous user policy is
maintained in policy min and max thus changing the limits for verification
of the current policy. Once the verification is completed restore the
current user policy min/max with the updated values if any. This would take
care of cases uwhere user policy min/max input is higher/lesser than the
current min and max.

Bug: 17889870
Change-Id: I5ad92ba05162cb5c32c3ba3fdae21d2e505493d3
Signed-off-by: Taniya Das <tdas@codeaurora.org>
Signed-off-by: Naveen Ramaraj <nramaraj@codeaurora.org>
Signed-off-by: klozz <xxx.reptar.rawrr.xxx@gmail.com>
Unified patch 3.4.51

Signed-off-by: klozz <xxx.reptar.rawrr.xxx@gmail.com>
UNIFIED 3.4.52

Signed-off-by: klozz <xxx.reptar.rawrr.xxx@gmail.com>
Unified 3.4.53

Signed-off-by: klozz <xxx.reptar.rawrr.xxx@gmail.com>
unified 3.4.54

Signed-off-by: klozz <xxx.reptar.rawrr.xxx@gmail.com>
Unified 3.4.55

Signed-off-by: klozz <xxx.reptar.rawrr.xxx@gmail.com>
unified 3.4.56

Signed-off-by: klozz <xxx.reptar.rawrr.xxx@gmail.com>
3.4.57

Signed-off-by: klozz <xxx.reptar.rawrr.xxx@gmail.com>
Unified patch 3.4.38

Signed-off-by: klozz <xxx.reptar.rawrr.xxx@gmail.com>
Unified Patch 3.4.59

Signed-off-by: klozz <xxx.reptar.rawrr.xxx@gmail.com>