[General Kernel cleanup and updates]

mm/vmalloc.c: remove static declaration of va from __get_vm_area_node

Static storage is not required for the struct vmap_area in
__get_vm_area_node.

Removing "static" to store this variable on the stack instead.

Change-Id: I10ab04052dcc56830b3e3a7993326a0ef6c9da3b
Signed-off-by: Kautuk Consul <consul.kautuk@gmail.com>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

mm/vmalloc.c: change void* into explict vm_struct*

vmap_area->private is void* but we don't use the field for various purpose
but use only for vm_struct.  So change it to a vm_struct* with naming to
improve for readability and type checking.

Change-Id: I1d403afa7df5c83c3fb051e8fbccf18eb6a0325c
Signed-off-by: Minchan Kim <minchan@kernel.org>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

mm/vmalloc.c: eliminate extra loop in pcpu_get_vm_areas error path

If either of the vas or vms arrays are not properly kzalloced, then the
code jumps to the err_free label.

The err_free label runs a loop to check and free each of the array members
of the vas and vms arrays which is not required for this situation as none
of the array members have been allocated till this point.

Eliminate the extra loop we have to go through by introducing a new label
err_free2 and then jumping to it.

[akpm@linux-foundation.org: remove now-unneeded tests]
Signed-off-by: Kautuk Consul <consul.kautuk@gmail.com>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Change-Id: I44a9943ed4cfd2bbcad57430a7caaf7d59073c54

mm: fix faulty initialization in vmalloc_init()

The transfer of ->flags causes some of the static mapping virtual
addresses to be prematurely freed (before the mapping is removed) because
VM_LAZY_FREE gets "set" if tmp->flags has VM_IOREMAP set.  This might
cause subsequent vmalloc/ioremap calls to fail because it might allocate
one of the freed virtual address ranges that aren't unmapped.

va->flags has different types of flags from tmp->flags.  If a region with
VM_IOREMAP set is registered with vm_area_add_early(), it will be removed
by __purge_vmap_area_lazy().

Fix vmalloc_init() to correctly initialize vmap_area for the given
vm_struct.

Also initialise va->vm.  If it is not set, find_vm_area() for the early
vm regions will always fail.

Change-Id: I8d72d344587c50e692ae9d343ca8763d96ad6bd6
Signed-off-by: KyongHo Cho <pullip.cho@samsung.com>
Cc: "Olav Haugan" <ohaugan@codeaurora.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>

ARM: 7059/1: LPAE: Use PMD_(SHIFT|SIZE|MASK) instead of PGDIR_*

PGDIR_SHIFT and PMD_SHIFT for the classic 2-level page table format have
the same value (21). This patch converts the PGDIR_* uses in the kernel
to the PMD_* equivalent so that LPAE builds can reuse the same code.

Change-Id: Ie29916344607ca551a7678394cae008fab9a85d3
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

arm: ensure enough memory is available for movable zone

If CONFIG_HIGHMEM is enabled, the memory from the movable
zone will come from highmem as the zone of highest
address present is converted to ZONE_MOVABLE, and only
one zone may be used for ZONE_MOVABLE.

Ensure that ZONE_HIGHMEM is large enough for the
movable zone's required size to be created from
it if CONFIG_FIX_MOVABLE_ZONE is enabled as well.

There needs to be a small ZONE_HIGHMEM even after
memory hotremove (due to a generic 3.0 bug), so
extra is reserved for now.

Change-Id: I285c6ad24a6f2f18fc9e6510d379b126f201b082
Signed-off-by: Larry Bassel <lbassel@codeaurora.org>

ARM: move initialization of the high_memory variable earlier

Some upcoming changes must know the VMALLOC_START value, which is based
on high_memory, before bootmem_init() is called.

The best location to set it is in sanity_check_meminfo() where the needed
computation is already done, and in the non MMU case it is trivial to do
now that the meminfo array is already sorted at that point.

Change-Id: I6733568a53749880b26bda5c8da2067b05268ec6
Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>

ARM: move iotable mappings within the vmalloc region

In order to remove the build time variation between different SOCs with
regards to VMALLOC_END, the iotable mappings are now allocated inside
the vmalloc region.  This allows for VMALLOC_END to be identical across
all machines.

The value for VMALLOC_END is now set to 0xff000000 which is right where
the consistent DMA area starts.

To accommodate all static mappings on machines with possible highmem usage,
the default vmalloc area size is changed to 240 MB so that VMALLOC_START
is no higher than 0xf0000000 by default.

Change-Id: Iff8214b53764ede697a8866575ec3b19a4a07077
Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Tested-by: Stephen Warren <swarren@nvidia.com>
Tested-by: Kevin Hilman <khilman@ti.com>
Tested-by: Jamie Iles <jamie@jamieiles.com>

ARM: 7129/1: Add __arm_ioremap_exec for mapping external memory as MT_MEMORY

This allows mapping external memory such as SRAM for use.

This is needed for some small chunks of code, such as reprogramming
SDRAM memory source clocks that can't be executed in SDRAM. Other
use cases include some PM related code.

Change-Id: I360798a8da7035590ac827ee14b50c5fcf877894
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Acked-by: Andres Salomon <dilinger@queued.net>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

ARM: simplify __iounmap() when dealing with section based mapping

Firstly, there is no need to have a double pointer here as we're only
walking the vmlist and not modifying it.

Secondly, for the same reason, we don't need a write lock but only a
read lock here, since the lock only protects the coherency of the list
nothing else.

Lastly, the reason for holding a lock is not what the comment says, so
let's remove that misleading piece of information.

Change-Id: Ib02521a65093bffa4af200c31f8f6c888922f925
Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>

ARM: add generic ioremap optimization by reusing static mappings

Now that we have all the static mappings from iotable_init() located
in the vmalloc area, it is trivial to optimize ioremap by reusing those
static mappings when the requested physical area fits in one of them,
and so in a generic way for all platforms.

Change-Id: I9f0091f80559bcdc1bd0e7fc200b505441fd157f
Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Tested-by: Stephen Warren <swarren@nvidia.com>
Tested-by: Kevin Hilman <khilman@ti.com>
Tested-by: Jamie Iles <jamie@jamieiles.com>

swiotlb: Expose swiotlb_nr_tlb function to modules

As a mechanism to detect whether SWIOTLB is enabled or not.
We also fix the spelling - it was swioltb instead of
swiotlb.

Change-Id: If8e9997ff49a686b065853d5295ea246550b665d
CC: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
[v1: Ripped out swiotlb_enabled]
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

Revert "block: Introduce blk_set_stacking_limits function"

This reverts commit 7e0418f14f188efab1aee2d2b23314b63cde9274.

Change-Id: Id8f76d3d3f8ff010c018edb58e5d7d1ce7f36272

Revert "block: properly stack underlying max_segment_size to DM device"

This reverts commit 5b947efd34deab837226197627f166d78d02b63b.

Change-Id: Ie76f13d36197c227074985f8fb925d207db30725

block: Introduce blk_set_stacking_limits function

Stacking driver queue limits are typically bounded exclusively by the
capabilities of the low level devices, not by the stacking driver
itself.

This patch introduces blk_set_stacking_limits() which has more liberal
metrics than the default queue limits function. This allows us to
inherit topology parameters from bottom devices without manually
tweaking the default limits in each driver prior to calling the stacking
function.

Since there is now a clear distinction between stacking and low-level
devices, blk_set_default_limits() has been modified to carry the more
conservative values that we used to manually set in
blk_queue_make_request().

Change-Id: Icd6b0eb00cb6d13ac991248de5a79400c2b8df42
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Acked-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

block: properly stack underlying max_segment_size to DM device

commit d82ae52e68892338068e7559a0c0657193341ce4 upstream.

Without this patch all DM devices will default to BLK_MAX_SEGMENT_SIZE
(65536) even if the underlying device(s) have a larger value -- this is
due to blk_stack_limits() using min_not_zero() when stacking the
max_segment_size limit.

1073741824

before patch:
65536

after patch:
1073741824

Change-Id: I6940d9ad8a8be12fa40ea9fd1af336c721a33842
Reported-by: Lukasz Flis <l.flis@cyfronet.pl>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Revert "block: fail SCSI passthrough ioctls on partition devices"

This reverts commit 78fc8b77bad76b94636c8ed3f270872c479bcf16.

Change-Id: Ieb7c7eb94275d10c76bbf4591f24d449aed65ed7

Revert "block: add and use scsi_blk_cmd_ioctl"

This reverts commit 45e3287d0f77a474b01ea34b9c11a8f460e7b250.

Change-Id: I2e30faff31ab8802fce1f8d74b5f6c0b616cd042

Revert "block: Add BLKROTATIONAL ioctl"

This reverts commit 0568800c03fd943413ef81d8532006fcebe16876.

Change-Id: Ide2f86db56c049d454f83b3483b43bcf8039c08c

Revert "Proportional Rate Reduction for TCP."

This reverts commit 67552ecb1d0a44a95d2c8edd0d08543ac192a6e8.

Change-Id: Ic0c296587cd6e1b6a23ce4b51e51679f3d89f828

arm: mm: Remove 5MB offset for vmalloc

commit f973fab6921 added a 5MB highmem zone to fix
a page fault error due to generic 3.0 bug.
Remove this extra 5MB offset because we now have a 256MB
highmem zone.

Change-Id: I430fed88baccd44d438c21607f87219206f1f20a
Signed-off-by: Jack Cheung <jackc@codeaurora.org>

Revert "ARM: add generic ioremap optimization by reusing static mappings"

This reverts commit ccae5a1a3468869f92ac9cac306ddce1340bac95.

Change-Id: Id15f1984b901036121cd55885993e5a9633dc53f

Revert "ARM: move iotable mappings within the vmalloc region"

This reverts commit 1e6fa036d9a6407856a27f53a317a5c69b35da45.

Change-Id: I16c0262467e4fa6c7261266dfcd9563cf9c7dcfc
Merge branch 'cm-11.0' into kk_mkt