tcp: fix MSG_SENDPAGE_NOTLAST logic

[ Upstream commit ae62ca7b03217be5e74759dc6d7698c95df498b3 ]

commit 35f9c09fe9c72e (tcp: tcp_sendpages() should call tcp_push() once)
added an internal flag : MSG_SENDPAGE_NOTLAST meant to be set on all
frags but the last one for a splice() call.

The condition used to set the flag in pipe_to_sendpage() relied on
splice() user passing the exact number of bytes present in the pipe,
or a smaller one.

But some programs pass an arbitrary high value, and the test fails.

The effect of this bug is a lack of tcp_push() at the end of a
splice(pipe -> socket) call, and possibly very slow or erratic TCP
sessions.

We should both test sd->total_len and fact that another fragment
is in the pipe (pipe->nrbufs > 1)

Many thanks to Willy for providing very clear bug report, bisection
and test programs.

Reported-by: Willy Tarreau <w@1wt.eu>
Bisected-by: Willy Tarreau <w@1wt.eu>
Tested-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Revert "splice: fix racy pipe->buffers uses"

This reverts commit c1e4877100c4a281acc8136f459cc688876c516d.
cpu_input_boost: Add cpufreq notifier and make it super fancy

*Everything is much cleaner
*Boosting is far less expensive now
*Now completely self-sufficient (doesn't require code to be added to other drivers)

Signed-off-by: Sultanxda <sultanxda@gmail.com>
gpu: ion: Backport from CAF LA.AF.1.1_rb1.7

*Patched for 3.0 kernels
*Reverted "gpu: ion: Add support for CMA allocations in cp heap" to avoid a massive update to dma-mapping (we don't use CMA anyway)

Signed-off-by: Sultanxda <sultanxda@gmail.com>
ion: ioctl compatibility with userland using old api

As far as I can tell, flags passed by userland are now used to determine
buffer caching.

Note in ION_IOC_ALLOC_COMPAT we are currently forcing uncached buffer
allocations (needed to make a choice here).  This
may need to change.

Signed-off-by: Flemmard <flemmard@gmail.com>
include: msm_ion: Use old ioctls

Our proprietary camera HAL could be calling these, so switch back to the old ioctls to avoid a possible mismatch.

Signed-off-by: Sultanxda <sultanxda@gmail.com>
msm: Enable ARM_HAS_SG_CHAIN

This is needed by the new Ion drivers.
gpu: ion: Restore old Ion functionality (non-dmabuf)

Our proprietary camera libraries were not designed for the new Ion API. Currently, with dma-buf, the kernel crashes when using the camera (crashes when trying to free Ion handle).

Restore old Ion functionality to maintain compatibility with our proprietary camera blobs. ion_import_dma_buf now emulates ion_import_fd.

Signed-off-by: Sultanxda <sultanxda@gmail.com>
Revert "gpu: msm: kgsl: Fix compatibility with old Ion drivers"

This reverts commit 800c33f88e262a9885567ca78fc0c92f04a12016.
gpu: ion: Update ion_map_iommu_by_force for new Ion drivers

Signed-off-by: Sultanxda <sultanxda@gmail.com>
gpu: ion: Introduce option for memory heap usage statistics

When enabled, this causes a kernel panic and prints Ion memory heap usage statistics for all heaps when an Ion heap (content-protect or carveout) runs out of memory. This should not be used in production builds.

Also added back some useful debug info.

Signed-off-by: Sultanxda <sultanxda@gmail.com>
ksm: Provide support to use deferred timers for scanner thread

KSM thread to scan pages is getting schedule on definite timeout.
That wakes up CPU from idle state and hence may affect the power
consumption. Provide an optional support to use deferred timer
which suites low-power use-cases.

To enable deferred timers,
$ echo 1 > /sys/kernel/mm/ksm/deferred_timer

Change-Id: I07fe199f97fe1f72f9a9e1b0b757a3ac533719e8
Signed-off-by: Chintan Pandya <cpandya@codeaurora.org>
Sultan_*defconfig: Enable KSM
audio: Backport from CAF LA.AF.1.1_rb1.7

*Retained support for Samsung MSM8x60 audio

Signed-off-by: Sultanxda <sultanxda@gmail.com>
msm: mdp: Validate input arguments from user space

Fully verify the input arguments from user client are safe
to use.

Change-Id: Ie14332443b187951009c63ebfb78456dcd9ba60f
Signed-off-by: Raghavendra Ambadas <rambad@codeaurora.org>
msm8x60_celox: Set Ondemand 2-phase freq to 1134MHz
Revert "SoC: msm: Add Buffer overflow check"

This reverts commit 7984181b225432a03dc69dcdb7bfd087841e7551.

Breaks audio on Samsung MSM8x60.
msm8x60_celox: Optimize RAM

Userspace gains 20MB of RAM (for a total of 860MB of RAM).

Signed-off-by: Sultanxda <sultanxda@gmail.com>
vibetonz: Add sysfs interface for vibrator intensity
input: Add BLN support

Credit to neldar, creams, and Mr. X. Original commit could not be found.