xtensa: Export __invalidate_icache_range

When modular code calls flush_icache_range():

    ERROR: "__invalidate_icache_range" [drivers/misc/lkdtm.ko] undefined!
    make[1]: *** [__modpost] Error 1

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: export __{invalidate,flush}_dcache_range

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: enable sorting extable at build time

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Acked-by: David Daney <ddaney.cavm@gmail.com>
xtensa: split bootparam and kernel meminfo

Bootparam meminfo is a bootloader ABI, kernel meminfo is for the kernel
bookkeeping, keep them separate. Kernel doesn't care of memory region
types, so drop the type field and don't pass it to add_sysmem_bank.
Move kernel sysmem structures and prototypes to asm/sysmem.h and sysmem
variable and add_sysmem_bank to mm/init.c

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: keep sysmem banks ordered in add_sysmem_bank

Rewrite add_sysmem_bank so that it keeps bank order and merges
adjacent/overlapping banks.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: keep sysmem banks ordered in mem_reserve

Rewrite mem_reserve so that it keeps bank order.
Also make its return code more traditional.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: handle memmap kernel option

This option is useful for reserving memory regions for secondary cores
in AMP configurations.

Implement the following memmap variants:
- memmap=nn[KMG]@ss[KMG]: force usage of a specific region of memory;
- memmap=nn[KMG]$ss[KMG]: mark specified memory as reserved;
- memmap=nn[KMG]: set end of memory.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: dump sysmem from the bootmem_init

Debug dump of physical memory configuration. Useful for inspection of
resulting memory map, esp. in the presence of memmap= kernel option.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: optimize local_flush_tlb_kernel_range

Don't flush whole TLB if only a small kernel range is requested.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: add HIGHMEM support

Introduce fixmap area just below the vmalloc region. Use it for atomic
mapping of high memory pages.
High memory on cores with cache aliasing is not supported and is still
to be implemented. Fail build for such configurations for now.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: xtfpga: introduce SoC I/O bus

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: add support for KC705

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
dm thin: irqsave must always be used with the pool->lock spinlock

Commit c140e1c4e23 ("dm thin: use per thin device deferred bio lists")
incorrectly stopped disabling irqs when taking the pool's spinlock.

Irqs must be disabled when taking the pool's spinlock otherwise a thread
could spin_lock(), then get interrupted to service thin_endio() in
interrupt context, which would then deadlock in spin_lock_irqsave().

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
dm thin: fix rcu_read_lock being held in code that can sleep

Commit c140e1c4e23 ("dm thin: use per thin device deferred bio lists")
introduced the use of an rculist for all active thin devices.  The use
of rcu_read_lock() in process_deferred_bios() can result in a BUG if a
dm_bio_prison_cell must be allocated as a side-effect of bio_detain():

 BUG: sleeping function called from invalid context at mm/mempool.c:203
 in_atomic(): 1, irqs_disabled(): 0, pid: 6, name: kworker/u8:0
 3 locks held by kworker/u8:0/6:
   #0:  ("dm-" "thin"){.+.+..}, at: [<ffffffff8106be42>] process_one_work+0x192/0x550
   #1:  ((&pool->worker)){+.+...}, at: [<ffffffff8106be42>] process_one_work+0x192/0x550
   #2:  (rcu_read_lock){.+.+..}, at: [<ffffffff816360b5>] do_worker+0x5/0x4d0

We can't process deferred bios with the rcu lock held, since
dm_bio_prison_cell allocation may block if the bio-prison's cell mempool
is exhausted.

To fix:

- Introduce a refcount and completion field to each thin_c

- Add thin_get/put methods for adjusting the refcount.  If the refcount
  hits zero then the completion is triggered.

- Initialise refcount to 1 when creating thin_c

- When iterating the active_thins list we thin_get() whilst the rcu
  lock is held.

- After the rcu lock is dropped we process the deferred bios for that
  thin.

- When destroying a thin_c we thin_put() and then wait for the
  completion -- to avoid a race between the worker thread iterating
  from that thin_c and destroying the thin_c.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Merge tag 'xtensa-for-next-20140406' of git://github.com/jcmvbkbc/linux-xtensa into for_next

Merging from Max' tree.

Xtensa fixes for 3.15:
- add missing cache manipulation symbol exports to fix build failures;
- sort extable at build time;
- clean up sysmem code, support memmap boot parameter;
- add highmem support for cores with non-aliasing caches;
- add DTS for xtfpga on KC705.

Signed-off-by: Chris Zankel <chris@zankel.net>
xtensa: xt2000: drop redundant sysmem initialization

sysmem structure initialization in xt2000 platform_init is identical to
the one done in init_arch just before the call to platform_init.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
dm verity: fix biovecs hash calculation regression

Commit 003b5c5719f159f4f4bf97511c4702a0638313dd ("block: Convert drivers
to immutable biovecs") incorrectly converted biovec iteration in
dm-verity to always calculate the hash from a full biovec, but the
function only needs to calculate the hash from part of the biovec (up to
the calculated "todo" value).

Fix this issue by limiting hash input to only the requested data size.

This problem was identified using the cryptsetup regression test for
veritysetup (verity-compat-test).

Signed-off-by: Milan Broz <gmazyland@gmail.com>
Acked-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org # 3.14+
s390/chsc: fix SEI usage on old FW levels

Using a notification type mask for the store event information chsc
is unsupported on some firmware levels. Retry SEI with that mask set
to zero (which is the old way of requesting only channel subsystem
related events).

Cc: <stable@vger.kernel.org>
Reported-and-tested-by: Stefan Haberland <stefan.haberland@de.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
i40e: remove open-coded skb_cow_head

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Kavindya Deegala <kavindya.s.deegala@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
i40e: fix TCP flag replication for hardware offload

As reported by Eric Dumazet, the i40e driver was allowing the hardware
to replicate the PSH flag on all segments of a TSO operation.

This patch fixes the first/middle/last TCP flags settings which
makes the TSO operations work correctly.

With this change we are now configuring the CWR bit to only be set
in the first packet of a TSO, so this patch also enables TSO_ECN,
in order to advertise to the stack that we do the right thing
on the wire.

Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Kavindya Deegala <kavindya.s.deegala@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>