kmemleak: use rbtree instead of prio tree

kmemleak uses a tree where each node represents an allocated memory object
in order to quickly find out what object a given address is part of.
However, the objects don't overlap, so rbtrees are a better choice than
prio tree for this use.  They are both faster and have lower memory
overhead.

Tested by booting a kernel with kmemleak enabled, loading the
kmemleak_test module, and looking for the expected messages.

Signed-off-by: Michel Lespinasse <walken@google.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Hillf Danton <dhillf@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Tested-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
kmemleak: Replace list_for_each_continue_rcu with new interface

This patch replaces list_for_each_continue_rcu() with
list_for_each_entry_continue_rcu() to save a few lines
of code and allow removing list_for_each_continue_rcu().

Signed-off-by: Michael Wang <wangyun@linux.vnet.ibm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
mm/kmemleak.c: remove obsolete simple_strtoul

Replace the obsolete simple_strtoul() with kstrtoul().

Signed-off-by: Abhijit Pawar <abhi.c.pawar@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
cpufreq: sync ondemand / interactive with CAF
msm: bam_dmux: move sps_disconnect calls to the reconnect case

The A2 BAM hardware may be powered off when disconnect_to_bam() is called.
If so, sps_disconnect() will cause L2 errors a possibly a watchdog crash.
Move the sps_disconnect() calls to the reconnect case where A2 BAM has
powered back up and it is safe to call sps_disconnect()

CRs-Fixed: 402645
Change-Id: I4a365a3a4b91255429cbc326f31ab29aacc273b6
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: handle system wide low memory conditions

When A2 turns on, queue_rx() is first run from the SMSM thread, and
attempts to allocate 32 2kB-buffers with GFP_KERNEL for DMA transactions.
If the system is low on memory, the allocation could put the thread to
sleep while the memory allocator scavenges for enough memory to satisfy
the request.  This is not desired as it stalls a critical system thread
that is communicating with a real-time system.

Instead, use GFP_NOWAIT which will return immediately if no memory is
available for the allocation request so that bam_dmux may handle the
situation gracefully and possibly reschedule the allocations for a later
time.

CRs-Fixed: 406946
Change-Id: I645acd29f7e0fa27883a27c043fc951cbdd91b84
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/bam_dmux.c
msm: bam_dmux: remove A2_DEFAULT_DESCRIPTORS

The A2_DEFAULT_DESCRIPTORS macro is unused and has no apparent purpose.
Remove it to clean out dead code.

Change-Id: I593179ed4f0ccb777ed4178a9e6c138b04da61de
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: configure satellite mode via devicetree

Add support to allow satellite mode configuration of the BAM hardware
via device tree.  Satellite mode is only used on specific targets where
shared access of the BAM is possible.

Change-Id: I6ac4e2ad7827b5651034651d18cf716324462d0f
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_bmux: Add in_global_reset check while rescheduling queue_rx

In modem SSR case rescheduling of queue_rx_work for every 100ms
causing system to overload by rescheduling unnecessary work and
overflow kernel meesages with rescheduling logs.
Hence block the rescheduling of queue_rx_info
by adding in_global_reset flag check during modem SSR.

CRs-Fixed: 422096
Change-Id: I14bc8d82e44231a86b58faa0158740565177653d
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
msm: bam_dmux: reset bam hardware when A2 goes into pc

Reset the bam hardware when A2 goes into power collapse so that the A2
can be reset after the disconnect ack is sent from bam_dmux to A2.  This
allows the A2 to remain in sync with the bam hardware which prevents
possible unrecoverable data stalls from occuring.

This change reverts commit b11a52c7748e3f5fba7850fb843cabd9ad4878e7 but
adds special handling for the subsystem restart case so that the issue
fixed by b11a52 is not reintroduced.

CRs-Fixed: 433400
Change-Id: Ie476e249b03bb6bd40abc8981472684664d34ae6
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: revert the skb state when memory allocation fails

bam_dmux_write() function modifies the state of a skb via skb_push(), but
if a later allocation fails, the state of the skb is not reverted to the
pre skb_push() state.

The error returned to the caller as a result of the allocation failure gets
propagated to the TCP/IP framework, which re-schedules a retry of the skb
at a later time.  if enough retries occur due to allocation failures,
causes the assertion in skb_push() to fail.

If a later allocation fails, revert the skb buffer state to pre skb_push()
by calling skb_pull().

CRs-Fixed: 441277
Change-Id: If33e13f00ced164d174ce2c7d9d29762abafa720
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
msm: bam_dmux: Enable IPC logging for bam_dmux

Currently a kfifo is used for internal BAM DMUX logging
and crash dump analysis. With this change, the kfifo is
replaced with the IPC logging framework.

Change-Id: Ic5ac32490d1afb22990ba460a3fcae2b160a408c
Signed-off-by: Zaheerulla Meer <zmeer@codeaurora.org>
msm: bam_dmux: wait for DL thread to shutdown in case of SSR

In case of Subsystem Restart, recent targets require that the downlink
processing thread be signaled to shutdown eariler and that the SSR
process wait for the DL thread completely shutdown otherwise an unclocked
register access could occur which might cause a kernel panic.

CRs-Fixed: 451694
Change-Id: I9216c6006bdc8941dd3c03bd6aff14cd732540bc
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: Use IPC Logging for string formatting

BAM DMUX currently formats a string into a local buffer before passing the
pre-formated string directly to IPC Logging. This results in an extra copy
operation and adds an extra timestamp. It also limits the printed string to
the size of the local buffer (which is currently 80 characters). Remove the
pre-formatting code and use the formatting capability in IPC Logging which
removes the local length limitations, improves performance and removes the
duplicate timestamp.

Change-Id: I11712d5232daee58ac2f0d5ec78a8ba11af1ca04
Signed-off-by: Zaheerulla Meer <zmeer@codeaurora.org>
msm: bam_dmux: make rx ring buffer pool size configurable

The recieve ring buffer pool size defaults to 32 buffers, which maintains
a good balance between performance and memory consumption.  The hardware
is capable of supporting larger pools, which could be tuned to
non-standard usecases or new requirements.

Add support for an optional dt property that allows the default size to
be overridden with a target specific size.

Change-Id: Ib73b3836d91cfb6ac0c95d2c1f54a01e26a100a2
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: correct sps_transfer_one() flag usage

From debugging the underlying BAM layer, bam_dmux has been discovered to
be using extraneous flags when invoking sps_transfer_one.  Although these
extra flags have no functional impact, they confuse debug efforts by
masking when events actually happen.

In the transmit direction, SPS_IOVEC_FLAG_INT is redundant when
SPS_IOVEC_FLAG_EOT is specified.  Remove the TX uses of FLAG_INT.

In the receive direction, neither SPS_IOVEC_FLAG_INT nor
SPS_IOVEC_FLAG_EOT is required.  FLAG_EOT is set by the remote side when
it transmits, and FLAG_INT is assumed by the hardware.

CRs-Fixed: 471804
Change-Id: Ia867f5685ab3dacb2a8cbb3070874e401c1a08ea
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: reduce kernel log chatter

Every time a uplink wakeup sequence occurs, the underlying SPS driver
logs some BAM information to the kernel log.  The message is identical
for each occurence, and the information is only relevant at system boot.
To reduce the log chatter after system boot, make use of the constrained
logging SPS feature.

CRs-Fixed: 473102
Change-Id: I1454722d387317ad1b74f5ae09bb55f6a9a9d941
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: Fix potential memory leaks

Added code to fix potential memory leaks.

Change-Id: I76f92fc95539feee67600a6ab4a730bbb50643a1
Signed-off-by: Brent Hronik <bhronik@codeaurora.org>
msm: bam_dmux: reduce notify_all() logging

Notify_all() logs a message to the internal log for each client that gets
notified.  This consumes a lot of log space for little real information.

Reduce the logging to a single statement indicating when and why
notify_all() was called.  It can be safely assumed that every valid
client will be notified when notify_all() is called.

Change-Id: I5ae6ea72a734e37dce05539e2de3108ed5b2b40d
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: trigger modem subsystem restart in case of timeout

If bam_dmux times out waiting for a power collapse protocol response from
the modem, bam_dmux assumes the modem has crashed and will disable itself
until the subsystem restart callback is triggered.

Change the behavior in bam_dmux to request that the modem subsystem
restarts regardless of its current state so that the restart callback is
always triggered.

CRs-Fixed: 495690
Change-Id: I076ab16dd727694feb68b9e9052b1b6a60a2b0ca
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/bam_dmux.c