msm_fb: Clear real pipe attributes in the pipe free

Clear original pipe attributes in the pipe free call.

Change-Id: I776869e7997e5b70e4c2b102e1a394034247bbcd
Signed-off-by: Kalyan Thota <kalyant@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
video: msm: Add missing wait_for_fence lost in merge

Change-Id: I9baf47987686c638aa4424c800bb549d72ea9bd1
msm_fb: display: empty pending queue during suspend

Overlay_play() adds a pipe into pending queue and pan_display()
will commit those pipes to hardware and empty queue. This patch
will make sure queue is empty at suspend so that no unexpected
pipes will be commited to hardware by pan_display() at resume.
Otherwise, iommu page fault may happen.

Change-Id: Ib35c247550bb8754f9bff68a6352022d58c55ff8
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
msm: fb: make the pan task interruptible

Change-Id: Iaed69687071e266ef8cc3d4c8e79441a63247a57
msm_fb: unlock semaphore on error

Change-Id: Id9bc387d07319619cb100e961c7e84f8f3cc7af3
Signed-off-by: Iliyan Malchev <malchev@google.com>
msm_fb: display: Proper pipes solidfill

For MPQ/hdmi as primary, solid fill the pipes only during suspend.
This change also take care of the solidfill of the pipes unset
during overlay and pan display at suspend.

CRs-Fixed: 421461
Change-Id: I15096df681cbd94ae3cea63ecbfe915e01b7387f
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
Revert "msm_fb: display: Increase MDP IOMMU buffer mapping size"

This reverts commit 7db99f5daf46acaf51479f5c0b1d143c4bd9c1c6.
Revert "msm_fb: display: add per stage alpha drop detection"

This reverts commit da1b41d2b465d0fd3e8f7af037aa063be8bebf57.
msm_fb: display: Add alpha enable check in blend

FIR and M/N scalar when used for downscaling, drops
alpha channel of the given layer. To notify this, alpha_drop flag
is updated accordingly. This flag need not be checked for layers
with no alpha plane. In some scenarios alpha_drop may get enabled
for the layers with no alpha plane and cause issues realted to blend
composition of layers. Check for setting alpha_drop only if source
ayer has alpha plane.

Change-Id: Ie64b30c045a78d0d68eb9efacc76902afae7850d
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
display: removed the code exhausts file descriptor in mdp overlay and rotator.

Fix the problem crashed while playing video clips and VT camera test.
ion_share_dma_buf is called in pr_debug.
So, it is called depends on build option and makes crash problem.

Change-Id: Ia96fdb7838eb2f3cdf979d8e0f886cb64eba6ca8
iopoll: Introduce memory-mapped IO polling macros

It is sometimes necessary to poll a memory-mapped register until its
value satisfies some condition. Introduce a family of convenience macros
that do this. Tight-loop and sleeping versions are provided with and
without timeouts.

Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
Change-Id: Ia7db00cbe60ded8b0ed9bbff264aaea0841da92a
iopoll: Tweak min sleep time used with usleep_range()

Users of the iopoll macros may need to poll addresses that take
a long time to update. In such cases, the hardcoded value of 1 us
passed as the minimum delay to usleep_range() may result in
reads that occur more often than necessary.

Use (sleep_us/4) as the min delay instead of 1 us to resolve this
is a scalable way.

Change-Id: I8f679a7ecdb9ea2666c78aabca3c8ba806e0ead3
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
iopoll: Introduce the readl_iopoll_timeout_noirq macro

It is sometimes necessary to poll a register - until a
certain value is read - in atomic context. Introduce
a macro that allows one to specify the maximum number
of reads attempts and the number of microseconds to
delay between each read attempt.

Change-Id: Ice27e78cf4e156da9de00d58783c220bdbc758d3
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
(cherry picked from commit 7a35f5abde0192e72d4e7982411e376d8b898944)
msm: event_timer: Support to add event timers.

Add support to allow drivers to specify future events
that need to be treated as hard deadlines. Upon event timer
expiry the driver will be notified by callback function
that the driver provides.
The pm code can query the earliest event and modify
the event timer accounting for the back off based on the
latency of the low power mode being entered.

(cherry picked from commit 388c308cebef8e9cdbd80608a032abc810d46e62)
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>

Change-Id: I461e2c31c285b93588aa56dd25905efab020e0c8
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
msm: pm: Adjust for events with hard wakeups

Get the next event and setup a new timer to expire
earlier than the next event after accounting for the
latency of the low power state being entered. This
will ensure that the core is active to handle the event
when it arrives.

(cherry picked from commit dc318fd0c3d04f7af9720af50c0eb0c6ed2653e9)
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>

Change-Id: I6609a886df227c68ce78e270ef7d235e07725d44
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
msm_fb: display: wake up system around vsync

To avoid frame drops due to power collapse,
wake up cpu right before vsync.

Change-Id: I63385eb329ae5e74cbac5256823fd3a213e0a0e1
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
msm_fb: display: change the location of wakeup timer call

There are two pathes (pan display and overlay commit) to commit
display buffer, so change the location of cpu timer wakup call to the
common pipe_commit function to make sure cpu get waked up around
vsync.

Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
Change-Id: Idbe6049d740a7e17a6a90e28566f7a9c74e348f2
cpufreq: Avoid using smp_processor_id() in preemptible context

Even though this work item runs on only one cpu at a time (due to
queue_work_on()) it is possible for the work item to be preempted
and so use of smp_processor_id() is illegal.

BUG: using smp_processor_id() in preemptible [00000000]
code: kworker/3:1/4162 caller is dbs_refresh_callback+0xc/0x188
[<c00151b0>] (unwind_backtrace+0x0/0x120) from [<c0279058>]
(debug_smp_processor_id+0xbc/0xf0)
[<c0279058>] (debug_smp_processor_id+0xbc/0xf0) from [<c0454b54>]
(dbs_refresh_callback+0xc/0x188)
[<c0454b54>] (dbs_refresh_callback+0xc/0x188) from [<c0087290>]
(process_one_work+0x354/0x648)
[<c0087290>] (process_one_work+0x354/0x648) from [<c0089754>]
(worker_thread+0x1a8/0x2a8)
[<c0089754>] (worker_thread+0x1a8/0x2a8) from [<c008e480>]
(kthread+0x90/0xa0)
[<c008e480>] (kthread+0x90/0xa0) from [<c000f438>]
(kernel_thread_exit+0x0/0x8)

The intent of the code is to determine which CPU this work item
is running on, which we can easily do by passing that information
in a wrapper struct around the work struct. Do this so we avoid
this problem.

Change-Id: I05ca0ff2b3cbaa239930463ea0760e3e9d75145f
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

Conflicts:
	drivers/cpufreq/cpufreq_ondemand.c
lib/sha1: use the git implementation of SHA-1

For ChromiumOS, we use SHA-1 to verify the integrity of the root
filesystem.  The speed of the kernel sha-1 implementation has a major
impact on our boot performance.

To improve boot performance, we investigated using the heavily optimized
sha-1 implementation used in git.  With the git sha-1 implementation, we
see a 11.7% improvement in boot time.

10 reboots, remove slowest/fastest.

Before:

  Mean: 6.58 seconds Stdev: 0.14

After (with git sha-1, this patch):

  Mean: 5.89 seconds Stdev: 0.07

The other cool thing about the git SHA-1 implementation is that it only
needs 64 bytes of stack for the workspace while the original kernel
implementation needed 320 bytes.

Signed-off-by: Mandeep Singh Baines <msb@chromium.org>
Cc: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Cc: Nicolas Pitre <nico@cam.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: David S. Miller <davem@davemloft.net>
Cc: linux-crypto@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arm: remove "optimized" SHA1 routines

Since commit 1eb19a12bd22 ("lib/sha1: use the git implementation of
SHA-1"), the ARM SHA1 routines no longer work.  The reason? They
depended on the larger 320-byte workspace, and now the sha1 workspace is
just 16 words (64 bytes).  So the assembly version would overwrite the
stack randomly.

The optimized asm version is also probably slower than the new improved
C version, so there's no reason to keep it around.  At least that was
the case in git, where what appears to be the same assembly language
version was removed two years ago because the optimized C BLK_SHA1 code
was faster.

Reported-and-tested-by: Joachim Eastwood <manabian@gmail.com>
Cc: Andreas Schwab <schwab@linux-m68k.org>
Cc: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>