fix definition of 'finish_arch_switch()'

Commit b2628c861cd67e447242227876096b105b3be6e1
	('ARM: spinlock: use inner-shareable dsb variant prior to sev instruction')

...introduced a defintion for: 'finish_arch_switch()'

On MSM kernels this got however already defined at:
		arch/arm/mach-msm/include/mach/memory.h

Fix it by ignoring the re-definition done by the ARM commit.
msm_fb: Avoid memset of frame buffer during early suspend

At present, we have backlight disabled before frame buffer
early suspend and there is mechanism in place to enable backlight
only after first frame update after display resume. This makes sure
to avoid panel specific artifacts being visible. Hence,
remove memset of frame buffer during suspend. This change
reduces latencies during frame buffer's early suspend.

Change-Id: I4a4d1d28ba10912f24ba38861fdb7086b78192a4
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
ARM: 7430/1: sizes.h: move from asm-generic to <linux/sizes.h>

sizes.h is used throughout the AMBA code and drivers, so the header
should be available to everyone in order to driver AMBA/PrimeCell
peripherals behind a PCI bridge where the host can be any platform
(I'm doing it under x86).

At this step <asm-generic/sizes.h> includes <linux/sizes.h>,
to allow a grace period for both in-tree and out-of-tree drivers.

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
Acked-by: Giancarlo Asnaghi <giancarlo.asnaghi@st.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Alan Cox <alan@linux.intel.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
DMA mapping: upstreaming to mainline as of March 2014

ARM: 7979/1: mm: Remove hugetlb warning from Coherent DMA allocator

ARM: add coherent dma ops
ARM: add coherent iommu dma ops

ARM: another fix for the DMA mapping checks

ARM: DMA-API: better handing of DMA masks for coherent allocations

ARM: fix executability of CMA mappings

arm: dma mapping: Export a dma ops function arm_dma_set_mask
arm: dma mapping: export arm iommu functions
ARM: DMA mapping: fix bad atomic test
arm: dma-mapping: Add APIs for other memory types
ARM: dma-mapping: Add arm_iommu_detach_device()
ARM: DMA-Mapping: add function for setting coherent pool size from platform code
ARM: dma-mapping: Add maximum alignment order for dma iommu buffers
ARM: DMA-mapping: add missing GFP_DMA flag for atomic buffer allocation
ARM: dma-mapping: Add missing static storage class specifier
ARM: dma-mapping: add more sanity checks in arm_dma_mmap()
ARM: dma-mapping: add support for CMA regions placed in highmem zone
ARM: dma-mapping: add support for DMA_ATTR_FORCE_CONTIGUOUS attribute
ARM: dma-mapping: add support for DMA_ATTR_NO_KERNEL_MAPPING attribute
ARM: dma-mapping: add support for DMA_ATTR_SKIP_CPU_SYNC attribute
ARM: dma-mapping: add support for dma_get_sgtable()
ARM: dma-mapping: add support for IOMMU mapper
arm: dma-mapping: Add support to extend DMA IOMMU mappings
ARM: dma-mapping: Always pass proper prot flags to iommu_map()
ARM: dma-mapping: atomic_pool with struct page **pages
ARM: dma-mapping: check DMA mask against available memory
ARM: dma-mapping: convert DMA direction into IOMMU protection attributes
ARM: dma-mapping: don't allow DMA mappings to be marked executable
ARM: dma-mapping: fix atomic allocation alignment
ARM: dma-mapping: fix buffer chunk allocation order
ARM: dma-mapping: fix build warning in __dma_alloc()
ARM: dma-mapping: fix debug messages in dmabounce code
ARM: dma-mapping: fix error path for memory allocation failure
ARM: dma-mapping: fix GFP_ATOMIC macro usage
ARM: dma-mapping: fix incorrect freeing of atomic allocations
arm: dma-mapping: Fix mapping size value
ARM: DMA-mapping: fix memory leak in IOMMU dma-mapping implementation
ARM: dma-mapping: Fix potential memory leak in atomic_pool_init()
ARM: dma-mapping: Get pages if the cpu_addr is out of atomic_pool
ARM: dma-mapping: implement dma sg methods on top of any generic dma ops
ARM: dma-mapping: Introduce __atomic_get_pages() for __iommu_get_pages()
ARM: dma-mapping: introduce DMA_ERROR_CODE constant
ARM: dma-mapping: IOMMU allocates pages from atomic_pool with GFP_ATOMIC
ARM: DMA-mapping: mark all !DMA_TO_DEVICE pages in unmapping as clean
ARM: dma-mapping: modify condition check while freeing pages
ARM: dma-mapping: move all dma bounce code to separate dma ops structure
ARM: dma-mapping: NULLify dev->archdata.mapping pointer on detach
ARM: DMA-Mapping: print warning when atomic coherent allocation fails
ARM: dma-mapping: Refactor out to introduce __in_atomic_pool
ARM: dma-mapping: Refrain noisy console message
ARM: dma-mapping: remove custom consistent dma region
ARM: dma-mapping: remove init_consistent_dma_size() stub
ARM: dma-mapping: remove offset parameter to prepare for generic dma_ops
arm: dma-mapping: remove order parameter from arm_iommu_create_mapping()
ARM: dma-mapping: remove redundant code and do the cleanup
ARM: dma-mapping: Remove unsed var at arm_coherent_iommu_unmap_page
ARM: dma-mapping: Remove unsed var at arm_coherent_iommu_unmap_page
ARM: dma-mapping: Small logical clean up
ARM: dma-mapping: support debug_dma_mapping_error
ARM: dma-mapping: use alloc, mmap, free from dma_ops
ARM: dma-mapping: use asm-generic/dma-mapping-common.h
ARM: dma-mapping: use dma_mmap_from_coherent()
ARM: dma-mapping: use himem for DMA buffers for IOMMU-mapped devices
ARM: dma-mapping: use PMD size for section unmap
ARM: dma-mapping: use pr_* instread of printk

ARM: dma: Drop __GFP_COMP for iommu dma memory allocations
ARM: DMA: Fix struct page iterator in dma_cache_maint() to work with sparsemem

arm: mm: fix DMA pool affiliation check
ARM: mm: HugeTLB support for LPAE systems.
ARM: mm: remove redundant dsb() prior to range TLB invalidation
ARM: mm: Remove unused arm_vmregion priv field

common: add dma_mmap_from_coherent() function
common: DMA-mapping: add DMA_ATTR_FORCE_CONTIGUOUS attribute
common: DMA-mapping: add DMA_ATTR_NO_KERNEL_MAPPING attribute
common: DMA-mapping: add DMA_ATTR_SKIP_CPU_SYNC attribute
common: DMA-mapping: Add strongly ordered memory attribute
common: dma-mapping: add support for generic dma_mmap_* calls
common: dma-mapping: introduce dma_get_sgtable() function

mm: vmalloc: use const void * for caller argument
ARM: 7805/1: mm: change max*pfn to include the physical offset of memory

Most of the kernel code assumes that max*pfn is maximum pfns because
the physical start of memory is expected to be PFN0. Since this
assumption is not true on ARM architectures, the meaning of max*pfn
is number of memory pages. This is done to keep drivers happy which
are making use of of these variable to calculate the dma bounce limit
using dma_mask.

Now since we have a architecture override possibility for DMAable
maximum pfns, lets make meaning of max*pfns as maximum pnfs on ARM
as well.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
dma-debug: *squashing updates*

dma-debug: debugfs_create_bool() takes a u32 pointer

	Even though it has "bool" in the name, you have pass a u32 pointer to
	debugfs_create_bool().  Otherwise you get memory corruption in
	write_file_bool().  Fortunately in this case the corruption happens in
	an alignment hole between variables so it doesn't cause any problems.

	Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
	Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>

lib/dma-debug.c: fix __hash_bucket_find()

	If there is only one match, the unique matched entry should be returned.

	Without the fix, the upcoming dma debug interfaces ("dma-debug: new
	interfaces to debug dma mapping errors") can't work reliably because
	only device and dma_addr are passed to dma_mapping_error().

	Signed-off-by: Ming Lei <ming.lei@canonical.com>
	Reported-by: Wu Fengguang <fengguang.wu@intel.com>
	Cc: Joerg Roedel <joerg.roedel@amd.com>
	Tested-by: Shuah Khan <shuah.khan@hp.com>
	Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
	Cc: Jakub Kicinski <kubakici@wp.pl>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
	Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

dma-debug: New interfaces to debug dma mapping errors

	Add dma-debug interface debug_dma_mapping_error() to debug
	drivers that fail to check dma mapping errors on addresses
	returned by dma_map_single() and dma_map_page() interfaces.
	This interface clears a flag set by debug_dma_map_page() to
	indicate that dma_mapping_error() has been called by the
	driver. When driver does unmap, debug_dma_unmap() checks the
	flag and if this flag is still set, prints warning message
	that includes call trace that leads up to the unmap. This
	interface can be called from dma_mapping_error() routines to
	enable dma mapping error check debugging.

	Tested: Intel iommu and swiotlb (iommu=soft) on x86-64 with
		CONFIG_DMA_API_DEBUG enabled and disabled.

	Signed-off-by: Shuah Khan <shuah.khan@hp.com>
	Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
	Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>

dma-debug: fix to not have dependency on get_dma_ops() interface

	dma-debug depends on get_dma_ops() interface. Several architectures
	do not define dma_ops and get_dma_ops(). When dma debug interfaces are
	used on an architecture (e.g: c6x) that doesn't define get_dmap_ops(),
	compilation fails. Changing dma-debug to call dma_mapping_error() instead
	of defining its own that calls get_dma_ops(), such that the internal use of
	dma_mapping_error() doesn't interfere with the debug_dma_mapping_error()
	interface's mapping error checks. Moving dma_mapping_error() checks in
	check_unmap() under the dma debug entry not found is sufficient to fix the
	problem.

	Reference: https://lkml.org/lkml/2012/10/26/367

	Signed-off-by: Shuah Khan <shuah.khan@hp.com>
	Reported-by: Mark Salter <msalter@redhat.com>
	Signed-off-by: Joerg Roedel <joro@8bytes.org>

	# This is the 5th commit message:

	dma-debug: fix locking bug in check_unmap()

	In check_unmap() it is possible to get into a dead-locked state if
	dma_mapping_error is called.  The problem is that the bucket is locked in
	check_unmap, and locked again by debug_dma_mapping_error which is called
	by dma_mapping_error.  To resolve that we must release the lock on the
	bucket before making the call to dma_mapping_error.

	[akpm@linux-foundation.org: restore 80-col trickery to be consistent with the rest of the file]
	Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
	Cc: Joerg Roedel <joro@8bytes.org>
	Reviewed-by: Shuah Khan <shuah.khan@hp.com>
	Tested-by: Shuah Khan <shuah.khan@hp.com>
	Cc: Jakub Kicinski <kubakici@wp.pl>
	Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
	Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

dma-debug: update DMA debug API to better handle multiple mappings of a buffer

	There were reports of the igb driver unmapping buffers without calling
	dma_mapping_error.  On closer inspection issues were found in the DMA
	debug API and how it handled multiple mappings of the same buffer.

	The issue I found is the fact that the debug_dma_mapping_error would
	only set the map_err_type to MAP_ERR_CHECKED in the case that the was
	only one match for device and device address.  However in the case of
	non-IOMMU, multiple addresses existed and as a result it was not setting
	this field once a second mapping was instantiated.  I have resolved this
	by changing the search so that it instead will now set MAP_ERR_CHECKED
	on the first buffer that matches the device and DMA address that is
	currently in the state MAP_ERR_NOT_CHECKED.

	A secondary side effect of this patch is that in the case of multiple
	buffers using the same address only the last mapping will have a valid
	map_err_type.  The previous mappings will all end up with map_err_type
	set to MAP_ERR_CHECKED because of the dma_mapping_error call in
	debug_dma_map_page.  However this behavior may be preferable as it means
	you will likely only see one real error per multi-mapped buffer, versus
	the current behavior of multiple false errors mer multi-mapped buffer.

	Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
	Cc: Joerg Roedel <joro@8bytes.org>
	Reviewed-by: Shuah Khan <shuah.khan@hp.com>
	Tested-by: Shuah Khan <shuah.khan@hp.com>
	Cc: Jakub Kicinski <kubakici@wp.pl>
	Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
	Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Signed-off-by: moddingg33k <moddingg33k@t-online.de>
dma-buf: *squashing updates*

dma-buf: add vmap interface

	The main requirement I have for this interface is for scanning out
	using the USB gpu devices. Since these devices have to read the
	framebuffer on updates and linearly compress it, using kmaps
	is a major overhead for every update.

	v2: fix warn issues pointed out by Sylwester Nawrocki.

	v3: fix compile !CONFIG_DMA_SHARED_BUFFER and add _GPL for now

	Signed-off-by: Dave Airlie <airlied@redhat.com>
	Reviewed-by: Rob Clark <rob.clark@linaro.org>
	Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>

dma-buf: minor documentation fixes.

	Some minor inline documentation fixes for gaps resulting from new patches.

	Signed-off-by: Sumit Semwal <sumit.semwal@ti.com>
	Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>

driver core: fix some kernel-doc warnings in dma*.c

	Fix kernel-doc warnings in drivers/base/dma*.c:

	Warning(drivers/base/dma-buf.c:498): No description found for parameter 'vaddr'
	Warning(drivers/base/dma-coherent.c:199): No description found for parameter 'ret'

	Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
	Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

dma-buf: might_sleep() in dma_buf_unmap_attachment()

	We never really clarified if unmap could be done in atomic context.
	But since mapping might require sleeping, this implies mutex in use
	to synchronize mapping/unmapping, so unmap could sleep as well.  Add
	a might_sleep() to clarify this.

	Signed-off-by: Rob Clark <rob@ti.com>
	Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
	Reviewed-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
	Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>

dma_buf: Cleanup dma_buf_fd

	Remove redundant 'error' variable.

	Signed-off-by: Borislav Petkov <bp@alien8.de>
	Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

dma-buf: implement vmap refcounting in the interface logic

	All drivers which implement this need to have some sort of refcount to
	allow concurrent vmap usage. Hence implement this in the dma-buf core.

	To protect against concurrent calls we need a lock, which potentially
	causes new funny locking inversions. But this shouldn't be a problem
	for exporters with statically allocated backing storage, and more
	dynamic drivers have decent issues already anyway.

	Inspired by some refactoring patches from Aaron Plattner, who
	implemented the same idea, but only for drm/prime drivers.

	v2: Check in dma_buf_release that no dangling vmaps are left.
	Suggested by Aaron Plattner. We might want to do similar checks for
	attachments, but that's for another patch. Also fix up ERR_PTR return
	for vmap.

	v3: Check whether the passed-in vmap address matches with the cached
	one for vunmap. Eventually we might want to remove that parameter -
	compared to the kmap functions there's no need for the vaddr for
	unmapping.  Suggested by Chris Wilson.

	v4: Fix a brown-paper-bag bug spotted by Aaron Plattner.

	Cc: Aaron Plattner <aplattner@nvidia.com>
	Reviewed-by: Aaron Plattner <aplattner@nvidia.com>
	Tested-by: Aaron Plattner <aplattner@nvidia.com>
	Reviewed-by: Rob Clark <rob@ti.com>
	Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
	Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>

dma-buf: Check return value of anon_inode_getfile

	anon_inode_getfile might fail, so check its return value.

	Signed-off-by: Tuomas Tynkkynen <ttynkkynen@nvidia.com>
	Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>

dma-buf: Expose buffer size to userspace (v2)

	Each dma-buf has an associated size and it's reasonable for userspace
	to want to know what it is.

	Since userspace already has an fd, expose the size using the
	size = lseek(fd, SEEK_END, 0); lseek(fd, SEEK_CUR, 0);
	idiom.

	v2: Added Daniel's sugeested documentation, with minor fixups

	Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
	Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
	Tested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
	Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>

Signed-off-by: moddingg33k <moddingg33k@t-online.de>
drivers: dma-contiguous: *squashing updates*

mm: cma: fix alignment requirements for contiguous regions

	Contiguous Memory Allocator requires each of its regions to be aligned
	in such a way that it is possible to change migration type for all
	pageblocks holding it and then isolate page of largest possible order from
	the buddy allocator (which is MAX_ORDER-1). This patch relaxes alignment
	requirements by one order, because MAX_ORDER alignment is not really
	needed.

	Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
	CC: Michal Nazarewicz <mina86@mina86.com>
	Acked-by: Michal Nazarewicz <mina86@mina86.com>

drivers: dma-contiguous: refactor dma_alloc_from_contiguous()

	The dma_alloc_from_contiguous() function returns either a valid pointer
	to a page structure or NULL, the error code set when pageno >= cma->count
	is not used at all and can be safely removed.

	This commit also changes the function to avoid goto and have only one exit
	path and one place where mutex is unlocked.

	Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
	[fixed compilation break caused by missing semicolon]
	Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

drivers: dma-contiguous: Don't redefine SZ_1M

	Use the definition from linux/sizes.h instead.

	Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
	Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

drivers: cma: represent physical addresses as phys_addr_t

	This commit changes the CMA early initialization code to use phys_addr_t
	for representing physical addresses instead of unsigned long.

	Without this change, among other things, dma_declare_contiguous() simply
	discards any memory regions whose address is not representable as unsigned
	long.

	This is a problem on 32-bit PAE machines where unsigned long is 32-bit
	but physical address space is larger.

	Signed-off-by: Vitaly Andrianov <vitalya@ti.com>
	Signed-off-by: Cyril Chemparathy <cyril@ti.com>
	Acked-by: Michal Nazarewicz <mina86@mina86.com>
	Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

drivers / dma-contiguous: Fix __init attribute location

	__init belongs after the return type on functions, not before it.

	Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
	Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: moddingg33k <moddingg33k@t-online.de>