[DO NOT MERGE] msm8x60: squashed commit of updates for sony msm8960

msm: mpq8064: Dummy read to prevent false interrupt from triggering

The VBIF is capable of triggering a false bus error the first time
it performs a read. This fix creates a dummy read event that
happens every time that the VCAP is powered on that will ignore
the false positive VBIF interrupt error, so that during normal
operation the error can be properly identified.

Change-Id: Ie56e60faf2067fab7a05a0f16c2d840408c35035
Signed-off-by: Terence Hampson <thampson@codeaurora.org>

Conflicts:
	drivers/media/video/vcap_v4l2.c

msm: mpq8064: Enable separate ioctl call for noise reduction (nr)

NR for VCAP is capable of receiving manual tuning parameters. In
order for the client to pass in these parameters a separate ioctl
was developed.

Change-Id: Ia8d7e8de80ee4fd7ccd2019d30b4457f1000e106
Signed-off-by: Terence Hampson <thampson@codeaurora.org>

msm: mpq8064: Use ION to alloc driver buffers

Since VCAP is behind IOMMU, in order to get proper address for VCAP
hw to write to driver needs to alloc buffer from ION and not
kzalloc.

Change-Id: I1f4fcc6834d0ea09ba0fc812b301219d35f40721
Signed-off-by: Terence Hampson <thampson@codeaurora.org>

Conflicts:
	drivers/media/video/vcap_vp.c

msm: video: wfd: Move WFD related files out of camera directory

The msm/ directory is intended for camera. Hence moving up the wfd/
directory one level higher and renaming it as msm_wfd/.

Change-Id: I9309ccfee91a04b6d55cf3be7ed88da15364b475
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

msm: wfd: Fix bug in calcuating number of MDP updates

The mdp_updates variable is getting incremented when giving a buffer to
MDP subdev.  It should be getting incremented when we get it back from
the subdev.

Change-Id: I467f512e5d33484fd5c82579c168d66d3c48dd5a
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>

msm: wfd: Make wfd-util thread-safe

update_stats() in wfd-utils gets called from various thread contexts.
Make this thread-safe to avoid list corruptions.

CRs-Fixed: 441415
Change-Id: I71c1da78b1f4e11b4f25852063a578e43ff18fb6
Signed-off-by: Rajeshwar Kurapaty <rkurapat@codeaurora.org>

Conflicts:
	drivers/media/video/msm_wfd/wfd-util.c
	drivers/media/video/msm_wfd/wfd-util.h

msm: vidc: wfd: Add WFD support for msm8974

Adds three new subdevices:
- Encoder subdevice to interface with new venus driver
    o Renamed enc-subdev.c to enc-mfc-subdev.c which only
      compiles for targets using the Samsung MFC core.
- MDP subdevice to interface with new MDSS driver
    o Renamed mdp-subdev.c to mdp-4-subdev.c used for targets
      using MDP4.
- MDP subdevice for debugging purposes
- Introduce a Kconfig file to properly choose between subdevices
  according to target

Change-Id: I125b39cfdeb1fbb4adf7c15d0c4452146764f985
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
Signed-off-by: Amara Venkata Mastan Manoj Kumar <manojavm@codeaurora.org>

Conflicts:
	arch/arm/configs/msm8974_defconfig

[DO NOT MERGE] msm8x60: hacks to enable building

* fix GCC 4.7 errors
* disable PRIMA_LEGACY for now - hack of all hacks

Change-Id: I52920c101a23ad1e9919b632f56830bc5da73696

netfilter: xt_socket: fix compilation warnings with gcc 4.7

This patch fixes compilation warnings in xt_socket with gcc-4.7.

In file included from net/netfilter/xt_socket.c:22:0:
net/netfilter/xt_socket.c: In function ‘socket_mt6_v1’:
include/net/netfilter/nf_tproxy_core.h:175:23: warning: ‘sport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:265:16: note: ‘sport’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:23: warning: ‘dport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:265:9: note: ‘dport’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:6: warning: ‘saddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:264:27: note: ‘saddr’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:6: warning: ‘daddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:264:19: note: ‘daddr’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
net/netfilter/xt_socket.c: In function ‘socket_match.isra.4’:
include/net/netfilter/nf_tproxy_core.h:75:2: warning: ‘protocol’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:113:5: note: ‘protocol’ was declared here
In file included from include/net/tcp.h:37:0,
                 from net/netfilter/xt_socket.c:17:
include/net/inet_hashtables.h:356:45: warning: ‘sport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:112:16: note: ‘sport’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:106:23: warning: ‘dport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:112:9: note: ‘dport’ was declared here
In file included from include/net/tcp.h:37:0,
                 from net/netfilter/xt_socket.c:17:
include/net/inet_hashtables.h:356:15: warning: ‘saddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:111:16: note: ‘saddr’ was declared here
In file included from include/net/tcp.h:37:0,
                 from net/netfilter/xt_socket.c:17:
include/net/inet_hashtables.h:356:15: warning: ‘daddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:111:9: note: ‘daddr’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
net/netfilter/xt_socket.c: In function ‘socket_mt6_v1’:
include/net/netfilter/nf_tproxy_core.h:175:23: warning: ‘sport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:268:16: note: ‘sport’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:23: warning: ‘dport’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:268:9: note: ‘dport’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:6: warning: ‘saddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:267:27: note: ‘saddr’ was declared here
In file included from net/netfilter/xt_socket.c:22:0:
include/net/netfilter/nf_tproxy_core.h:175:6: warning: ‘daddr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
net/netfilter/xt_socket.c:267:19: note: ‘daddr’ was declared here

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

Conflicts:
	net/netfilter/xt_socket.c

Change-Id: Id5f41a8f20a02c95a7e6b374a6e55e2d8b6501a0

msm: vidc: Adds AU delimiter support for AVC.

Add new V4L2 control to set AU delimiter for AVC.

Change-Id: Iaf2309bab99a213c85304927dfcd53f5a127cd5d
CRs-Fixed: 389030
Signed-off-by: Srinu Gorle <sgorle@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>

msm: video: wfd: Move domain specific mappings into subdevices

Move the domain specific mappings into subdevices to abstract away iommu
from wfd-ioctl.c.  This is especially needed as the encoder subdevices
for MSM8x60 and MSM8x74 differ in the iommu domain to which they map the
buffer to.  This target specific handling needs to taken care of by the
respective subdevices rather than by wfd-ioctl which should be target
agnostic.

Change-Id: I3b81ff82566d30158f3a574c3a9c24d63ccc939a
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>

msm: vidc: Adds VUI timing info support for AVC encoding.

Poor video quality is observed as VUI fps information is not present in
the encoded bit stream. Add support for VUI timing info in video driver
and an additional V4L2 control to set from user space.

CRs-Fixed: 399017
Signed-off-by: Srinu Gorle <sgorle@codeaurora.org>
Conflicts:

	include/linux/videodev2.h

Change-Id: I42acebcac4f59eeb42172e2272389dfed9e7d4ee
Signed-off-by: Neha Pandey <nehap@codeaurora.org>

msm: vidc: Separate meta buffers support in secure mode

Extradata is appended at the end of each output buffer
in non secure video use case but in secure video playback,
the client/CPU don't have access to the output buffer
to parse the extradata. This change allows the client/CPU
to parse the extradata by allocating separate buffers for
video hardware to store extradata.

Change-Id: Ie3dce6da948abec82ddc12d18619c30d54857dd6
Signed-off-by: Deepak Verma <dverma@codeaurora.org>

msm: vidc: Add a check for separate metadata buffers

Added a check for separate metadata buffers based on
the board specific platform data.

Signed-off-by: Deepak Verma <dverma@codeaurora.org>

Conflicts:

	drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker.c

Signed-off-by: Deepak Verma <dverma@codeaurora.org>

Conflicts:
	drivers/video/msm/vidc/1080p/ddl/vcd_ddl.c
	drivers/video/msm/vidc/1080p/resource_tracker/vcd_res_tracker.c

Change-Id: Ibcfafb7ab968d155c98364819123c5666425dd82

msm: vidc: add support for the bitstream_restrict flag

Adds support for the MFC core to add the bitstream_restrict flag in the
sps/pps for H264 codecs.  This allows for the decoder to determine how
many frames to buffer when decoding.

Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>

Conflicts:
	drivers/video/msm/vidc/1080p/ddl/vcd_ddl.h
	drivers/video/msm/vidc/1080p/ddl/vcd_ddl_properties.c
	drivers/video/msm/vidc/1080p/ddl/vcd_ddl_shared_mem.c
	drivers/video/msm/vidc/1080p/ddl/vcd_ddl_shared_mem.h
	drivers/video/msm/vidc/1080p/ddl/vcd_ddl_vidc.c
	include/media/msm/vcd_property.h

Change-Id: Iba60b20e1eaaee2aa9c0e372dd353d678a4a5f4d

ASoc: Reduce number of periods in low latency driver.

- Reduce number of periods to 2 from 4.

Signed-off-by: SathishKumar Mani <smani@codeaurora.org>

ASoc: msm: Increase max buffer size to 4k for lowlatency playback

- Small buffersize is resulting in scheduling issues.
- Increase max buffer size so that user space can
  configure large buffer size to avoid scheduling
  issues.

bug-id: 6865729
Signed-off-by: SathishKumar Mani <smani@codeaurora.org>

ASoC: msm: Reduce min buffer size for low latency

The current low latency driver has 512 bytes as
the min buffer size threshold. With this reducing
the playback time to lower values is not possible.
Setting it to 128 bytes gives us more room
to try out lower buffer sizes from the user space

Signed-off-by: Alexy Joseph <alexyj@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>

net/ipv6/addrconf: IPv6 tethering enhancement

Added new procfs flag to toggle the automatic addition of prefix
routes on a per device basis. The new flag is accept_ra_prefix_route.
Defaults to 1 as to not break existing behavior.

Change-Id: If25493890c7531c27f5b2c4855afebbbbf5d072a
CRs-Fixed: 504095
Signed-off-by: Harout Hedeshian <harouth@codeaurora.org>

Revert "Revert "ARM: 7169/1: topdown mmap support""

This reverts commit f27e4f0e730b99ca4dabed0b408d96dbf73a8fac.

An alternate fix has been proposed where userspace programs
set ADDR_COMPAT_LAYOUT. Bring back the topdown mmap support.

Change-Id: Ibd6e74d406db3a5ddb609e2d2a7a6e9dc2080eca
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

msm: kgsl: set GPU register RB_GMEM_BASE_ADDR

GPU register RB_GMEM_BASE_ADDR needs to be initialized with GMEM base
address. From A330, OCMEM is utilized to be GMEM dynamically; when
OCMEM is allocated for GFX, the allocated region address may vary
every time, GPU register RB_GMEM_BASE_ADDR need to be initialized
with the allocated OCMEM region address.

Change-Id: I5cb4472a9f18759d2af160a15d83f1404378a530
Signed-off-by: liu zhong <zhongl@codeaurora.org>
Signed-off-by: Rajeev Kulkarni <krajeev@codeaurora.org>

msm: kgsl: Watch SP_FS_FULL_ALU_INSTRUCTIONS for hang detection

Some intensive shader operations can go for the full timeout
in the SP block without changes in th RBBM and CP registers
that we monitor for hang detection. Add the performance counter
SP_FS_FULL_ALU_INSTRUCTIONS to see if any full precision
instructions have been executed during the hang detection interval.

CRs-Fixed: 392730
Change-Id: Ic0dedbadd6e5bcd0b46aab4209430de2f74711f7
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Rajeev Kulkarni <krajeev@codeaurora.org>

msm: kgsl: Change GPU Fast Hang detection to 50ms

Fast hang detection algorithm is improved to use additional
performance counters to monitor shader processor activity.
Shader processor's active alu cycles, icl0 misses
and fs cflow instructions are added to list of activities
monitored for fast hang detection.

Change-Id: Ie74b2ca2d8eb587dbdae40f8fafd901e71f50ddb
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>

msm: kgsl: Submit a draw command on resume

For A305, submit an extra draw command while resuming the GPU from
SLUMBER state. This fixes corruption seen when the screen is
turned on.

Change-Id: Iafed90b617b0a700ac3f2afcb6d9ecadca590914
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>

msm: kgsl: Fix the extra draw packet on resume for A305

The extra draw command on resume was missing some state. Add the missing
state registers, to avoid stability issues.

Change-Id: Iad51cbe3be7b2951563c989625a690178491e0c8
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>

sync: Limit logging to particular fence on timeout and error

Change-Id: I5bd7d62260666cdd2a32212f0e828d2d5d7d7bba
Signed-off-by: Prakash Kamliya <pkamliya@codeaurora.org>

hwmon: epm_adc: fix compilation warning

New version of gcc gives an uninitialized warning for
the array of adc data. Fix it.

Change-Id: Ic56a8d11b30920248ca756175847bd26381c7caa
Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
(cherry picked from commit ce16bfde8b16f6f1c7003061eec8e9f2fbb98d7c)

msm: vidc: Amend error check conditions on ION APIs

Amend error check conditions appropriately to return
properly from video applications in case of ION API
failures.

Change-Id: Ibe95a8438a66e88b35dbff0af8842ff4b038c5e1
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>

Conflicts:
	drivers/video/msm/vidc/common/dec/vdec.c

msm: vidc: Get the current performance level

This change supports client to get the current
performance level of the video driver via
IOCTL_GET_PERF_LEVEL. The current performance
level indicate the number of MBs per second
is being processed by video hardware.

Change-Id: Ic6f5b2b14e0d77bf801c4f857f8a0e20339c199f
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>

Conflicts:
	include/media/msm/vcd_property.h

msm: vidc: Don't free shared memory on channel close

The driver already frees the memory in vcd_ddl.c at ddl_close().
No need to prematurely free the memory here.

Change-Id: If1ddacf68770113423d4aeb2b72e79caf5ca07ce
Signed-off-by: Deepak Verma <dverma@codeaurora.org>

msm: vidc: Reset stop_called state when START is called

The driver needs to reset the stop_called field once START called.
Otherwise in START, STOP, START, STOP sequences the secondary STOP will
be treated as a duplicate STOP and ignored.

Change-Id: I8b7d069236027a01103c80b7deeb19c331ede05a
Signed-off-by: Deepak Verma <dverma@codeaurora.org>

vidc: Handle EOS with Codec config buffer.

Change will handle codec config buffer with EOS.
Video driver will make sure that the codec config buffer with
EOS will be requeued in case of reconfig and non-reconfig paths.

CRs-fixed: 399347
Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
(cherry picked from commit 43b203869814fe5f0ddcb265a8f859aebdaa652f)

Change-Id: Ib9a41fb842d2295804db86b2e03a62238c29984d
Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>

msm: vidc: Fix codec config frame with EOS flag issue

This change fixes the issue with improper handling of
codec config frame with eos flag in smooth streaming
scenario.

CRs-fixed: 467211
Change-Id: Iafd0a1a5a9073458fd139ed5845585747e51be8a
Signed-off-by: Deepak Verma <dverma@codeaurora.org>

vidc: Fix EOS handling if video h/w has a frame in transaction

In case of video hardware is encoding a frame and EOS buffer with
with zero data length arrived, set the EOS flag to the transaction
available in the transaction table which will be passed to the
client in frame done callback from the video hardware.

Change-Id: I03862906be603ff769fb6aa0a2191a9ea87529ca
Signed-off-by: Deepak Verma <dverma@codeaurora.org>

msm: vidc: set EOS on output buffer pending transaction

If EOS is signalled while an output buffer is in transaction,
mark EOS when that buffer is returned.
This is observed in case client sends an empty buffer with EOS

Change-Id: I9b4ce6331eb7a70886c1802d1f99e1d77d65fa64
Signed-off-by: Deepak Verma <dverma@codeaurora.org>

Bluetooth : hidp: Get the valid hci_conn while unlink

Since the context where unlink will be called is unaware of
validity of hci_conn pointer, fetch the valid hci_conn
before unlinking.

CRs-Fixed: 433361
Change-Id: Ief71997a3f007ea43431765c6cf543ab0d6416a8
Signed-off-by: Sumit Bajpai <sbajpai@codeaurora.org>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>

remove compilation error by changing int to uint32_t
Signed-off-by: Supreet Mysore Suresh <supreet@codeaurora.org>

Change-Id: Ia7de2f4a9eae4cc16f957163683ddf83c135d379
Signed-off-by: Supreet Mysore Suresh <supreet@codeaurora.org>

Conflicts:
	include/video/msm_hdmi_modes.h

netfilter: xt_qtaguid: extend iface stat to report protocols

In the past the iface_stat_fmt would only show global bytes/packets
for the skb-based numbers.
For stall detection in userspace, distinguishing tcp vs other protocols
makes it easier.
Now we report
  ifname total_skb_rx_bytes total_skb_rx_packets total_skb_tx_bytes
  total_skb_tx_packets {rx,tx}_{tcp,udp,ohter}_{bytes,packets}

Bug: 6818637

CRs-Fixed: 509089 511633
Change-Id: I06b91826d142fda8444aa6ebe3d0efd6a0a1ce8b
Signed-off-by: JP Abgrall <jpa@google.com>
Git-commit: 01d1733e27c7c03dc700cd8cd7658b326bc0b1b2
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>

msm: display: Do not commit in unset for external.

In case of external, commit is happening in unset itself which
is causing flickers. This patch fixes the issue.

Change-Id: Id55346be7a155108954e23bef236db80e7b65152
Signed-off-by: Vishnuvardhan Prodduturi <vproddut@codeaurora.org>

ion: change ion kernel map function to not take flags argument

Buffer flags are going to be specified at allocation time rather than
map time. This removes the flags argument from the ion kernel map
function.

Change-Id: Ib983ecd0dcd7befb36287ae7037c71d4ca475f90
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

Conflicts:
	drivers/media/video/msm_vidc/msm_smem.c
	drivers/media/video/vcap_vp.c
	drivers/video/msm/vidc/common/dec/vdec.c

msm: Add indicator for separate metadata buffers support

Add variable to check if separate metabuffers can be
enabled in video driver for specific targets.

Change-Id: I0ab3be7077d7d8286bfaa37be63705992939b72d
Signed-off-by: Deepak Verma <dverma@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/devices-8064.c
	arch/arm/mach-msm/devices-8930.c
	arch/arm/mach-msm/devices-8960.c

msm: mpq8064: VCAP corner case bug fixes

Closing VCAP devices could be called without calling stream off:
This problem would make VCAP resources taken by devices no longer
running.

Using unsigned variable to store signed result: This problem would
allow stream on to continue even when function returned error.

Fix problem of reading VP irq status register too early: It was
possible for cadence detection bit to be propgated faster by only
a few clock cycles then the picture done bit. When the irq status
read was performed and by the time a write to the clear register
was performed the picture done bit would propgate. Since the irq
is rising edge triggered this would cause a problem and the irq
would not be triggered until VP was reset.

Remove unused code

Change-Id: Iba72354c06287efb27178edf64d8d3f459dbf954
Signed-off-by: Terence Hampson <thampson@codeaurora.org>

Conflicts:
	drivers/media/video/vcap_v4l2.c
	drivers/media/video/vcap_vp.c
	include/media/vcap_v4l2.h

msm: mpq8064: Separate q/dq buffer for VCAP de-interlacing mode

This change fixes a crash when running VCAP in de-interlace mode.
The problem was noticed in the introduction of kernel 3.4. VCAP
was improperly using the videobuf2 framework APIs. Since VCAP is
already reliant on queue structure provided by videobuf2 framework,
we created our own basic version of the qbuf and dqbuf calls that
have some similarities to the videobuf2 framework. This addition
was necessary since we are calling qbuf from a kernel work thread.
Since moving to kernel 3.4 there has been a change in videobuf2
qbuf that dereferences the current process.s mm_struct, from a
kernel work thread this struct is NULL, which was causing a crash.
When we are de-interlacing a captured video we are cycling the
buffers internally in the driver, which is why we needed to create
our own q/dq buffer functionality.

Change-Id: Id51b775ae7f0a58bbac8a581e07fa02417802a30
Signed-off-by: Terence Hampson <thampson@codeaurora.org>

Conflicts:
	include/media/vcap_v4l2.h

Change-Id: I1edfc4a477406f1b52fce0027096e00fdfadc18b
msm8x60: net: sqaushed update

netfilter: xt_qtaguid: Allow tracking loopback

In the past it would always ignore interfaces with loopback addresses.
Now we just treat them like any other.
This also helps with writing tests that check for the presence
of the qtaguid module.

Change-Id: Ib6c6138d4efc94de388b4062b2a2c0fc4c85010f
Signed-off-by: JP Abgrall <jpa@google.com>

netfilter: qtaguid: rate limit some of the printks

Some of the printks are in the packet handling path.
We now ratelimit the very unlikely errors to avoid
kmsg spamming.

Change-Id: Ie892accb7c3a94fc8a9e10c632c9f66de35840eb
Signed-off-by: JP Abgrall <jpa@google.com>

netfilter: xt_qtaguid: remove AID_* dependency for access control

qtaguid limits what can be done with /ctrl and /stats based on group
membership.
This changes removes AID_NET_BW_STATS and AID_NET_BW_ACCT, and picks
up the groups from the gid of the matching proc entry files.

Signed-off-by: JP Abgrall <jpa@google.com>
Change-Id: I42e477adde78a12ed5eb58fbc0b277cdaadb6f94

net: ipv6: Don't purge default router if accept_ra=2

Setting net.ipv6.conf.<interface>.accept_ra=2 causes the kernel
to accept RAs even when forwarding is enabled. However, enabling
forwarding purges all default routes on the system, breaking
connectivity until the next RA is received. Fix this by not
purging default routes on interfaces that have accept_ra=2.

Change-Id: I4146923edd04c7efddb94979ea6a5df904eddb0d
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Iliyan Malchev <malchev@google.com>

tcp: fix FIONREAD/SIOCINQ

tcp_ioctl() tries to take into account if tcp socket received a FIN
to report correct number bytes in receive queue.

But its flaky because if the application ate the last skb,
we return 1 instead of 0.

Correct way to detect that FIN was received is to test SOCK_DONE.

Reported-by: Elliot Hughes <enh@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Neal Cardwell <ncardwell@google.com>
Cc: Tom Herbert <therbert@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Change-Id: I04f1386b56fdee9ec01a9690d6371072eae13bbc
Revert "msm_fb: display: return fail if pipe still staged"

This reverts commit 7e754830782f13c9c9fb5b1d7521bf5563773193.

Change-Id: Ie8d2fb419c5dd44e09a50388fec3e6e53983b872
msm8x60: sqaushed update to DCVS updates

msm: mpdecision: Add mpdecision driver code.

This driver is mainly responsible to convey the runqueue average and
iowait average values to the TZ periodically. The TZ returns the mask
of the cpu's that should be online and the slack timer.

The mpdecision code brings cpus up or down to match the online mask
from TZ. Also starts the slack timer as specified by TZ.

Upon expiry of the slack timer mpdecision calls TZ to get a new
mask and a new slack timer.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit a599de41a47b0b1a9f81a77227e16aff5a16a072)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit d2cf2db9632c3c2a33bc66ff61b2c2b758c10c86)

Change-Id: I30020fade79b61f86cbec52c90a1f5861a673a4c
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: 8064: add board file structures for mpdecision and msm governor.

Add device structures in the board file for mpdecision and the msm
governor. This essentially probes mpdecision driver and the msm
governor driver. When enabled mpdecision communicates the run queue
average with TZ and obtains back a mask of which cpus should be
online. The msm governor communicates the frequencies of the cpus
with TZ and obtains newer frequency for that cpu.

Both combined they govern which cpus stay online and how fast they
run.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit fb4a2f8e62af9cfa0852b16b2370f0d3df324e59)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit 2015b46a54dbcae9439cec27dddee1916d3071f3)

Conflicts:

	arch/arm/mach-msm/board-8064.c

Change-Id: Ic720e88e110b320ef3ce1ae35901411202066951
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/board-8064.c
	arch/arm/mach-msm/devices.h

msm: dcvs: update the event enum in preparation for mpdecision.

The event numbers used to communicate with TZ have changed. Update
them here in preparation of mpdecision.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 0db555f69e8e5b5237f2c053fffeeec3926084a1)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit deda7f0ef23aea568975ec73d4f54022f468adef)

Change-Id: I8a0bd62d06135714ce954c4cf6083523f5c1ca84
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: rearrange platform data.

This change
-removes the use of group id and instead introduces core type
-rearranges platform data, adds energy curve coefficients and power
 parameters
-allow for the energy params to be -ve numbers

The change also mandates updates to the msm8974-gpu.dtsi and the
associated binding documentation.

Also take this opportunity to remove devices for unsupported platform
- 8930 and 8960

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 4445166ad16be0c45b077bfb10487de355ed2e05)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit 24d2351f6a5e7069e5d554dbc999280a69288c5d)

Change-Id: I5c65c0e65cc7652eee72c525f0db10e128061cf9
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

Conflicts:
	Documentation/devicetree/bindings/arm/msm/dcvs-core-info.txt
	arch/arm/boot/dts/msm8974-gpu.dtsi
	arch/arm/mach-msm/devices-8960.c

msm: dcvs: Add thermal interfaces.

The algorithm needs thermal inputs for all the cores. Create members in
the internal core_info strucutre and platform data/device tree to pass
in the sensors they use.

Update the dcvs code to notify the temperature to TZ.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit fc7dca4c325725492af997fa282e07b9d03154d1)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit eb478c5b7b55ea8a57e0336e4cf9979be935b289)

Change-Id: I505903eb8b9779f2065aebfab5b3f2aefc874200
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

cpufreq: msm: remove gov_mutex from stop.

The stop could end up calling set_frequency callback. The set_frequency
callback takes the same gov_mutex lock and we end up in a deadlock.

Fix this by removing the locks around stop.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 5106c477a747279dbf045eed5a6ab4f68ac3501c)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit e0fa1831db0c57a8be8d5471ee3382b0f8a9165e)

Change-Id: I306f9cd2c05ce1e9c4c36d22d16b775a42881f0d
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

cpufreq: msm: fix race in cpufreq.

__cpufreq_driver_target expects to be called with the rw semaphore
held. We are not doing this when the frequency is asked to be changed
by dcvs.

Use cpufreq_driver_target variant of that function which gets the
rw semaphore before setting the frequency.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 54fc08ea6d33c6c561167f369cba060fe33755c9)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit a63446bcd75909db632ffc8ff3c4e6a96c8593c5)

Change-Id: I33cdac0aaac7fb44acf6f9eb451a80ff94175c46
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: hide -13 errors when communicating with the secure side.

-13 errors from the secure side are benign, dont print an error when
that happens.

Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
(cherry picked from commit 3cb914d56d65b9ad1dea8d186f74d3a1bc760769)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit dee3d749bbf60315080a2fb455bf8b2bd0640f36)

Change-Id: Id22bad3f3ee88e4292b3155014e43aa043a5df12
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: prevent thread creations upon cpu hotplug insertions.

Numerous threads were seen created and left idle as cpu's were
hotplugged in and out. Avoid creating new threads unnecessarily.

Instead create just one thread when a core is registered and use
it later.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit e039aac0c0be7c0d914055224103e8f41821320d)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit dbbe1e71a6f1be2dee99104281ad47e6884891bc)

Change-Id: Ib1255f9df5b41fbb49d25fdd6d661ebfa7f7642b
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: get rid of the pending freq array.

Only one pending frequency should be set, there is no need to
maintain an array of intermediate requests.

Cleanup the code and remove new_freq[] array and the index to
it. Introduce pending_freq a single entity that carries the
latest frequency request. Use the core's cpu_lock to protect
it.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit bea1b7628356bd953a88596c556373a6ec355f94)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit 32f01b8af255b565d5bcf1496a1aaea77250e205)

Change-Id: Ie939700f7f62e453638e73f489e729105e363d29
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: use wait_q.

It is cleaner to use wait_q mechanism instead of waking up the thread
and managing the scheduling flag ourselves.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 33bf417160e9340f2dd5f9f275e7e6021987bfe1)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit de943e4aff2a26e0d21b208d85b5876c31bfda85)

Change-Id: I4316ee58633f7353197654074263466cdaa25778
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: update dcvs if the governor limits change.

We had seen issues where dcvs goes out of sync with the actual
freq the cpu is running at. The root cause was if the userspace
changes the limits on the governor, the governor ends up changing
the frequency without notifying dcvs.

Provide an api for the governor to call dcvs when a frequency change
happens.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 68c970e38fcb700d851301dbacc56da9387294c6)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit a7d720e513cfae2d3f9c03c25f2ce2f10c2e9de7)

Change-Id: I3f321df0270e997531d1a4cf3ee2251f86aef0bc
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: provide frequency set/get callbacks at registration.

There is no need to register a separate structure for setting and
getting frequency.

Simply pass function pointers to set and get callbacks when a
core is registered.

While at it rename the msm_dcvs_freq_sink_register/unregister to
msm_dcvs_freq_sink_start/stop to better reflect that those
apis are meant to do.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 69134111c2a24002d1995a05c99f84403ac6a7e8)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit 52cb57c3c6bc1c0d08c1ae9eb5dd0ff1e1125a96)

Change-Id: Iee7aee1cbb2f33ed2852f1816ab62416b96fa7e6
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: remove idle notification registration.

Register the idle enable callback along with the core. The code
becomes cleaner and easy to update.

Importantly, the msm_dcvs_idle driver becomes useless. Remove it
and instead let the msm governor handle idle enabling and disabling.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit c1ed66c9035b4fbf240e46837d86a9a6442531f1)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit b4f5c2274fa2180b53563f2db0922eef212c0fcd)

Change-Id: Ice039e608d45bdeb9b8b718e5fbbf82a698d584d
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/devices-8064.c

msm: dcvs: split get_core in add/get_core.

There is currently only one function to add and get a core. Clean this
up by splitting that in two functions one for adding core and the other
for getting one.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit fbd7ea63accf3624f2c80d4a638495817b634d3a)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit a7a1905ceeb345d31b4dedba2054b509eb4ba5f0)

Change-Id: Ieefc853f1b3e1c4dd84e253ccc0d54cf4d1fdb24
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: remove core name.

Currently core_name is used to identify which core the dcvs operates on.
Instead use a type and the type num while registration with dcvs and
return an id (dcvs_core_id) upon successfull registration.

The dcvs_core_id is used by the clients of msm_dcvs to call upon its
apis viz. freq_start, freq_stop, msm_dcvs_idle etc.

The dcvs inturn uses the type num passed in at registration time to
invoke apis on the clients viz. set_freq, get_freq, idle_enable.

This further cleans up the internal dcvs add_core and get_core
implementation. One need not pass around the core_name and use the type
instead.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 1bbc0321a6871e018c17da6f244b9df442faead6)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit 09456d7d7618e6d0fc6b907b7af75268ea08a942)

Change-Id: Id27751a8ec8f5d3d386bbe7c7625ed56757b8bd7
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: cleanup debug prints.

The debug print mechanism is not much useful. Remove that code.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 0e1679b1ed8419f44c8976853f0070517f84cb14)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit fc7e8af6d5dee3744390220113483fec2e452081)

Change-Id: I5b574aa4bf2784f8cdfe065bb17ab8246d0d9e73
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: functions to start/stop/restart hrtimer.

The slack timer is supposed to be activated only when the core
is out of idle and that the governor for that core has started.
If any of the conditions is not met one should not activate
the slack timer.

To implement such a scheme, create two variables idle_entered,
and pending freq protected by their respective spinlocks
idle_state change_lock and pending_freq_lock. Whenever the
idle is entered or exited stop/start_slack_timer is called
which grabs the appropriate spinlocks and udpates the idle_entered
variable and starts and stops the hrtimer.

Moreover there are situations when a activated timer needs to
be restarted. This happens when a frequency is updated and a new
slack timer is received. We provide restart_slack_timer() callback
which cancels the hrtimer and restarts it only if the conditions
mentioned above are met.

There is also a situation when one has to forcefully cancel the timer
when the governor stops. Provide an api for that too. Note that one
cannot use stop_slack_timer becuase stop_slack_timer manipulates
idle_entered flag.

Also on related note, cleanup the code that handles pending_freq.
We get a new freq to set for a core when
- the slack timer expires
- when the governor starts when the cpu is brought back online
- when the cpu comes out of idle

Use pending_freq_lock to serialize updates to pending_freq.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit d6911b9e6d9cf51a8a7acc7363b424e325658e1f)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit ac4d9b3c58b998ecf6b83f5ae920eb47e5aef006)

Change-Id: I4db5b4de0c02bef62749c9e727a59171ae3f4ac0
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: change tz buffer to 32KB.

Only around 32K of buffer is required for normal operation.
Request the scm buffer of 32kb from the contiguous area.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit dca26f7215b4bc0ae4e4c17948f96c63d7af5266)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit 69e6a4d39b234cf02642337ecc6df5ef67b9b2c8)

Change-Id: Ie1c9997fdf79796458aacaa5d3169e24666fcac4
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: add thermal control.

Add capability to read the sensor data and report the temperature of
a core to the TZ.

Note that this was done earlier whenever a frequency update was done,
instead create a delayed workqueue per core. Also create a attribute
that controls the rate of thermal update per core.

If that attribute is not set use 60seconds as the default update rate.
If it is less than one second, default to using one second.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 80add4203ec4538046ca926e2747db6d01c14783)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit 2155283a8adf2c8b9dd27249f9c07a313a6ff710)

Change-Id: If91343b975d490c05ea63c9977d81f9572072773
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: get rid of unused attributes.

There are certain attributes that are not used. Get rid of them.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit f3650430ba202eae30a60870cf5adb50bacfa057)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit 47b62ce68c47883e94d7d11e461df68626e1bf4a)

Change-Id: Ia666e025aae47918471a55575646455764ca42f8
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: force on the slack timer,

For performance reasons the kernel should execute
a ONLINE call on TZ when the governor starts. The return
 values from ONLINE call are a new frequency and a new
 slack timer.

This new frequency would be queued up for the thread to set it up
on that core.

The way we handle the new slack timer is interesting. When the
governor starts we really dont know what the state of idle pulses
is, this is indicated by setting idle_entered = -1.  However we
want to start the slack timer. To handle this situation create
a function to force on the hrtimer without checking idle_entered or
pending_freq.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 973671aee4b5f2955a0bb85107022189bc12e75c)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit 082cbae484c44d4d0096b0f406dc89e18a96bf8d)

Change-Id: I7f6cd678323588f6d411c17526dc04a5748ed9b4
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: mpdcvs: add ftrace events.

Add ftrace events at interesting points in the dcvs and mpdecision code.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit f17f2d347acf17097ab5c6907bdc5a4c9e631a6d)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit 950f6a4af8454ffff69b84bd3830c7091bc53c0c)

Change-Id: Ic5cc00539b837090010627f364428c157137f052
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: allow re-registration of cores.

If a core has already been registered with dcvs, just
return the previous dcvs core id if it is registered
again.

Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit b162e2b79d36fb7cb870b7b7184ed52ecafbf849)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit 629fcfc3aac9a9bd7b435a2057c8a4b5702613fb)

Change-Id: I03b3519f4659e1c3adfee99f0b361b233fa2a918
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: add frequency transient control to sysfs

It is useful to be able to toggle at runtime whether
particular DCVS points are used as transient levels. This
adds a sysfs node per core which when read returns a list
of the currently enabled DCVS transient levels. Writing
the frequency of a DCVS transient level toggles whether it
is enabled or not.

Change-Id: I69ebb6974e97efa832798047259b9acdfd08aa7c
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 2f6db34b3216695d4f624d2204d5e1356e62c3d5)

msm: dcvs: run dcvs, mpdecision threads at default priority

It is not necessary to run these threads at a realtime
priority level.

Change-Id: I8c6492f22e803811db5757c51beeeb81f93f32b6
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 8862f41f1c632ba84f0a21e8045d70278fd67fd3)

msm: dcvs: create cpu freq table dynamically

CPU frequencies can differ between different revisions, so create
the table of cpu frequencies dynamically based on data from
acpuclock rather than using a fixed table.

Some of the data in the table comes from sync points that will be
implemented between CPU and GPU frequencies. The sync points are
defined here, but the sync implementation itself will come in a
subsequent commit.

Change-Id: I24cf17b199df1e5d064c1894b269e49118b39ac7
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit f9a8749b17961be653e9cbb426b1b72cada7f61c)

msm: dcvs: gpu minimum frequency levels

System performance is enhanced if the gpu frequency is given a
minimum corresponding to various frequency levels of CPU 0.

Change-Id: Iba168d708524fc8ef164428bb5f4e0631a499342
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 682c7a01c1d86518cdc7bec25cb413498811137b)

Conflicts:
	drivers/gpu/msm/kgsl_pwrscale_msm.c

msm: dcvs: start and stop temp updates with core sink

Temperature updates should not be sent continuously just
because a core has registered with dcvs. Instead, start
and stop the updates when the core starts and stops as a
dcvs frequency sink.

Change-Id: If7721f523eb44026c421dd7ec4fa3975bc65cd09
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 4eb5d7cf22bbea963251ff70a7b4e28a2d883b77)

msm: dcvs: drop pending frequency update on stop sink

If there is a pending frequency update when a core stops
acting as a dcvs sink, it should just be dropped, rather
than trying to honor that last frequency request.

Change-Id: Iac30cc7e06a8a70eecc4da712fdf160b788a7c2c
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 016af00bf66bb267cab573131598edbf83204f3f)

msm: dcvs: do not run gpu set_floor_frequency callbacks after stop_sink

Once a gpu calls stop_sink and is no longer participating in dcvs, we
should not call set_floor_frequency callbacks for that gpu.

Change-Id: I3cde82dc9975bcb37f065ea7ab8eb88a8f7fc933
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 77c66a3c6c27729aa0594b2f1b140aaf8f556b67)

msm: dcvs: set gpu frequency floor when multiple CPUs online

Performance is enhanced if the GPU frequency is floored at its
maximum nominal frequency when multiple CPUs are online.

Change-Id: Ib6bfd5007d660064844876b06f552f4d8c84865c
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 749f301c94312d2ec827c67cecb858e02383c8ab)

msm: dcvs: set algo params according to number of online CPUs

It is desirable for performance reasons to be able to run dcvs
with different algorithm parameters depending on the number of
CPUs that are online. The algorithm parameters are already replicated
per-CPU, but all CPUs operate in DCVS with the same parameters at
any given time.

These per-CPU parameters now correspond to the total number of CPUs
online. For example, if 2 CPUs are online, the algorithm parameters
for CPU2 are used.

Change-Id: If308a2fa949ac669823e759e0fd8e2cdbf6e4c03
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit c48381e2336125410549d7df1425dc8009c0c495)

msm: dcvs: add sysfs parameter for active and leakage offsets

The active and leakage energy offsets for each frequency are
best left configurable from userspace to make tuning easier.

Change-Id: I435a30d46cc02861dd7e8371b21d0433c0aa6a28
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 8104d6dde814e8dbb4f91a3e37a19627e7512f50)

msm: dcvs: set gpu actual freq when setting gpu floor

If actual_freq of gpu is not updated when a gpu floor
is set, TZ is unaware of the gpu frequency change and
computations are based on an incorrect value. By setting
actual_freq, TZ is notified of the new gpu frequency at
the next idle exit.

Change-Id: Ifc69996ef309ed4f8a5d46a2048757e57dd1a8ec
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 81599d50a0d122c52c966279640d6d8c64def656)

msm: dcvs: add ss_no_corr_below_freq parameter

The busy/idle behavior of different cores can be correlated by
DCVS when determining what frequency to run cores at. However,
this is not desirable below a certain frequency. Add a parameter
to establish what this frequency is. The parameter is configurable
in userspace via sysfs.

The ss_iobusy_conv parameter is currently unused, so it is
being replaced with ss_no_corr_below_freq.

(cherry picked from commit e8c6d615259af5fde8a6613f53c41c212407bda9)

Change-Id: Ibf814f3f93b92a532d7b3af80721a5bc7db1bd31
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>

Conflicts:
	Documentation/devicetree/bindings/gpu/adreno.txt

msm: dcvs: check power collapse state after updating params

The dcvs params are updated when the number of online cores change.
When this happens, the low power modes of each CPU need to be
enabled or disabled depending on how fast they are running and what
the new power collapse frequency thresholds are.

(cherry picked from commit 1b82c72e23f013ea2bdc526ad2859b421a97f48a)

Change-Id: I88c779dc21f47acd7a1fa1ded02e90825d7dc9d6
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>

msm: dcvs: enable/disable power collapse on CPU 0 only

Idle power collapse is not currently used on secondary cores
with DCVS, so it should not be manipulated after boot by DCVS.

(cherry picked from commit 7419749fb656f2f6b406d61c1df5993b2385af0a)

Change-Id: Id75829172c7c529d2b3e42a1ad406e591a94d1e9
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>

msm: dcvs: fail gracefully if TZ does not support dcvs

If dcvs attempts to initialize on a system where TZ does not support
dcvs, it will eventually cause a crash. Prevent this by disabling
dcvs if TZ does not successfully initialize its part of dcvs.

Signed-off-by: Steve Muckle <smuckle@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/devices-8064.c
	arch/arm/mach-msm/devices-8930.c
	arch/arm/mach-msm/devices-8960.c

Change-Id: I1f7dfbd3c8b1fd05a6ef664d2a601fd932ed9a35
msm8x60: kang apq8064 kgsl and update board to match

* should fix the random reboots people have been reporting for a while

Conflicts:
	drivers/gpu/msm/adreno.c
	drivers/gpu/msm/adreno_a3xx.c
	drivers/gpu/msm/kgsl_device.h

Change-Id: Ie9e4895c9a050a534972db59fad9a246a2c89190
msm8x60: fix prima compile errors and enable wlan

Change-Id: I67b62e8102f0c95ff77937268d6cae2ec94e22f3
msm8x60: squashed include msm-specific ion header

msm: board-8064: include msm-specific ion header

All msm_ion clients need to use <linux/msm_ion.h> instead of
<linux/ion.h>

Change-Id: I41320985706f1771ed98d982b02f20db1990d29e
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

msm: board-8930: include msm-specific ion header

All msm_ion clients need to use <linux/msm_ion.h> instead of
<linux/ion.h>

Change-Id: Id9ca03e8f9c8c53b2ad8f17ebbe6ceecc596a211
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

msm: 8930: include msm-specific ion header

All msm_ion clients need to use <linux/msm_ion.h> instead of
<linux/ion.h>

Change-Id: I7abd97d3beeee7b3d5639871ebd50ebf89d87f5d
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

msm: 8960: include msm-specific ion header

All msm_ion clients need to use <linux/msm_ion.h> instead of
<linux/ion.h>

Change-Id: I834f3959985e74843b81b367df92fa48aa87cec7
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

msm: 9615: include msm-specific ion header

All msm_ion clients need to use <linux/msm_ion.h> instead of
<linux/ion.h>

Change-Id: Iccf733e83c0621125f5e32e58f4bc7891b2159a0
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

msm: 9615: include msm-specific ion header

All msm_ion clients need to use <linux/msm_ion.h> instead of
<linux/ion.h>

Change-Id: I16ad3bb40a76e414881bbf41b789d7bbed07ccdd
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

msm: 7627a: include msm-specific ion header

All msm_ion clients need to use <linux/msm_ion.h> instead of
<linux/ion.h>

Change-Id: I3a1609e57c5156742300706cee698bd6e829c948
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

msm: 8660: include msm-specific ion header

All msm_ion clients need to use <linux/msm_ion.h> instead of
<linux/ion.h>

Change-Id: I8572215d3826824044e71f624143d612637dd4b2
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

msm: 7627a: include msm-specific ion header

All msm_ion clients need to use <linux/msm_ion.h> instead of
<linux/ion.h>

Change-Id: I809bc6b523e5469591ca38e663ebc0e0a38181f6
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

msm: 8064: include msm-specific ion header

All msm_ion clients need to use <linux/msm_ion.h> instead of
<linux/ion.h>

Change-Id: I7ab1595d0811dc6d053195ec80cb57cc108b23d6
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

msm: 8930: include msm-specific ion header

All msm_ion clients need to use <linux/msm_ion.h> instead of
<linux/ion.h>

Change-Id: I05f5fb6c606768b480f664fc780d88edcd1b95bc
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

media: dvb: mpq: include msm-specific ion header

All msm_ion clients need to use <linux/msm_ion.h> instead of
<linux/ion.h>

Change-Id: I8f76b1c78d2a435de337a88d00d4369a88dcbc99
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

gpu: ion: include msm-specific ion header

All msm_ion clients need to use <linux/msm_ion.h> instead of
<linux/ion.h>

Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

Change-Id: Iaf825bd2d1c76d9dfe2313fa53efbc50fb4cae51
ASoC: msm: Change QOS value for low latency path

There were variations in the time taken to
return from each write. This was due
to the delay in switching in and out of
power collapse. To manage this set QOS
value to 1ms so that the core has enough
time to wake up from power collapse

Signed-off-by: Alexy Joseph <alexyj@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
Revert "ASoC: msm: Decrease the playback period size of PCM driver"

This reverts commit b0580099ac7d5e735fb42946612a499bf196cda1.

Change-Id: I487797334cf75978daa3c536ff92de8a54b1f7fb
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
ASoC: msm: Flexible period size for pcm playback

PCM driver was configured for fixed buffer
size on the playback path. With this, varying
the buffer sizes on the playback path was not
possible. To fix this, support for flexible
period sizes is added by setting different
values for min and max buffer sizes

Change-Id: I7f69db4940f67e5e3a795101af1b1682afbdb530
Signed-off-by: Alexy Joseph <alexyj@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
msm: kgsl: Use the kmalloc/vmalloc trick for the sharedmem page array

It was previously assumed that most GPU memory allocations would be
small enough to allow us to fit the array of page pointers into one
or two pages allocated via kmalloc.  Recent reports have proven
those assumptions to be wrong - allocations on the order of 32MB will
end up trying to get 8 pages from kmalloc and 8 contiguous pages
on a busy system are a rare beast indeed.

So use the usual kmalloc/vmalloc trick instead - use kmalloc for the
page array when we can and vmalloc if we can't.

CRs-fixed: 513469
Change-Id: Ic0dedbad0a5b14abe6a8bd73342b3e68faa8c8b7
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: send ringbuffer NOP padding with the next command

If there isn't enough room at the bottom of the ringbuffer for a
whole command, the remaining space is filled with NOPs and
the command starts again at the top of the ringbuffer, the write
pointer of the ringbuffer shall update accordingly; the existing
implementation sends out in-complete NOP command which may potentially
cause GPU hang. This fix submits the NOP command along with the next
command instead of submitting them separately to have GPU read both
commands in the same fetch.

Change-Id: Ia3c9933c11d986c6743d8026b809bbcb1eaf54bf
Signed-off-by: Zhong Liu <zhongl@codeaurora.org>
msm: kgsl: Add a check to free the kgsl_timeline object.

Add a check to free the kgsl_timeline object only after
destroy flag is set. This is to avoid further references to timeline
from kgsl if it is already freed and also to catch any unbalanced
kref count.

Change-Id: I8017b9a928a26b703eb92b17ab6a361e4b479e5a
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>
msm: pm: add failed stats

for idle and suspend failed cases the stats
are not updated correctly, they are just added to
success bucket.

This patch is to log the failed stats separately.

Change-Id: I4b290944e3f4b74ada13ef0ba51b812c83b5ec5d
Signed-off-by: Venkat Devarasetty <vdevaras@codeaurora.org>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>