sched: fix race between try_to_wake_up() and move_task()

Until a task's state has been seen as interruptible/uninterruptible
and it is no longer on_cpu, it is possible that the task may move
to another CPU (load balancing may cause this). Here is an example
where the race condition results in incorrect operation:

- cpu 0 calls put_prev_task on task A, task A's state is TASK_RUNNING
- cpu 0 runs task B, which attempts to wake up A
- cpu 0 begins try_to_wake_up(), recording src_cpu for task A as cpu 0
- cpu 1 then pulls task A (perhaps due to idle balance)
- cpu 1 runs task A, which then sleeps, becoming INTERRUPTIBLE
- cpu 0 continues in try_to_wake_up(), thinking task A's previous
  cpu is 0, where it is actually 1
- if select_task_rq returns cpu 0, task A will be woken up on cpu 0
  without properly updating its cpu to 0 in set_task_cpu()

Change-Id: I870f7ffefe30ba2aae1114fd5e66d1a73e6a54fb
CRs-Fixed: 665958
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
video: mdss: Sunlight readability enhancement support

 * This hardware supports a postprocessing mode which improves
   readbility in bright sunlight. Add support for enabling
   this mode when the backlight value crosses a threshold.
 * Enable the feature using /sys/class/graphics/fb0/sre
 * Also add a max backlight level for using CABC. It's not
   effective at full brightness and causes too much visible
   distortion with many images.

Change-Id: I213eb5d91e526c80a0dc88e6e05e6d6f35841fdf
mmc: core: Optimize entering HS400 mode

In the current HS400 selection sequence high speed mode is entered
twice unnecessarily. Skip the first hs selection as it is also done
as part of entering high speed DDR mode.

CRs-fixed: 707453
Change-Id: Id027af977fe416056a6fbef39da1a84e41d89e53
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Revert "qseecom: Add support to handle multiple app load & unload"

This reverts commit f856ce3045a68e12089c7dc2152f5c53bb259305.

Change-Id: I31b5994fb42118edd46e453b0d453225c92000a1
ARM: dts: msm: use a corner regulator for wcnss VDD_CX on all boards

Update wcnss nodes to use voltage corner regulators for VDD_CX on MSM8226,
MSM8610, MSM8974, and MSM8974Pro.

Also update the wcnss platform driver to use voltage corner values for the
VDD_CX regulator supply.

Change-Id: I3f42104c2609a8cd237a34c66ff76be4426e9de8
Signed-off-by: Yue Ma <yuem@codeaurora.org>
msm: mdss: double check mdp ping pong done state

There are cases where the irq trigger may get delayed for more than
expected, in such cases the ping pong done status may have been updated
by MDP hw. Add additional check to see if this has been triggered even
though interrupt wasn't scheduled for pingpong done.

Change-Id: I4730d166d95f238f4525eab2b5c99be40b30699b
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: always set mdp_busy when partial update is disabled

mdp_busy flag is used to serialze kickoff operations by ensuring
that any pending kickoffs are first completed before issuing any
new kickoffs. This avoids any potential mpd_busy_wait timeouts.
Therefore, for normal operations (partial update disabled), mdp_busy
flag should always be set. However, when partial update is enabled,
width and height of panel's ROI need to be checked before setting
mdp_busy flag. Otherwise mdp_busy_wait will timeout since no update
will be sent to the panel. In addition, perform roi merge from both
panels if roi-merge is enabled to decide whether column and page address
has changed. If it was changed, then new column and page address need
to be sent to the panel.

CRs-Fixed: 692382
Change-Id: Ib0070b84a626afffd4c51a65f59bc97aae1d8994
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
video: mdss: Color enhancement feature

 * Add support for color enhancement feature of JDI panel

Change-Id: I6bacd36a329a0c648a5541efdb87b1142aefbfdf
qcom: rpm-smd: Mask the interrupt before sending the sleep set.

Sending a sleep set would cause an SMD interrupt to fire. If the
interrupt was previously affine to a different CPU, it could cause a
premature wakeup of that CPU. Prevent this by masking the interrupt
before sending the sleep set.

Change-Id: I45734c6fa52b7f69c0d68c5b3cd221185a516248
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: mdss: refactor MDSS idle power collapse logic

MDSS GDSC can be turned off, or power-collased for command mode panels
in static screen use-cases. In the current implementation, the power
collapse is triggered by a worker thread in the interface driver
whenever once it enters the idle state. However, MDP driver already
registers pm_runtime callbacks for idle and suspend notifications and
also maintains a count of active overlay sessions. It is much simpler
and cleaner to trigger idle-power collapse based on that. This also
avoids unnecessary synchronization issues pertaining to the power
collapse worker thread.

Change-Id: I96ee339b96ad794b2d87d19d1c14768fca3fa192
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
video: mdss: Fixup power collapse

Change-Id: Iaf58e785e86c994b25001e6589162ba5c3043abc
msm: mdss: reset runtime status upon device resume

MDSS is power-collapsed in idle screen cases using the pm runtime
framework. However, it is possible that the runtime PM status may
not match with the post-system sleep status when the device is
resumed. This sometimes leads to the inconsistencies in MDSS
idle-power collapse upon system resume. To address this issue,
reset the runtime PM status in the pm resume handler.

Change-Id: I74b082d2ff80c3719996a482510ba24e1f5f8170
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
msm: mdss: release pipes associated with respective process

It is possible that fb_open and fb_release APIs are called
from different processes for same file node. fb_release
finds correct process through file descriptor node in
such scenario and releases respective ref count. However,
overlay_release API tries to release the pipes associated
with current process id. This check fails to find correct
resources and does not release any pipe. This change calls
overlay release API with respective process id to release
all pipes associated with it.

Change-Id: Icc176032401483e05f347d3c08a4b344f61686f2
Signed-off-by: Dhaval Patel <pdhaval@codeaurora.org>
mdss: mdp: start vreg release index from PANEL_PM

Start vreg release index from PANEL_PM to avoid
release call with DSI_MAX_PM in error case. This
avoids crash in dsi_probe if panel node parsing fails.

Change-Id: I236f40851d41831fe37eea77aa83e2f4ce031a3b
Signed-off-by: Dhaval Patel <pdhaval@codeaurora.org>
video: mdss: Fix control of batfet regulator

Change-Id: I4b88a83e3c7caf1c1f5c57005731a05d05c774c8
msm: mdss: fix handling of runtime pm ref counts for fb device

In the current implementation, pm runtime status for the framebuffer
device changes to active when the overlay session is started. With idle
power collapse feature enabled, it is possible that the MDSS core could
be turned off prior to starting the overlay session depending on the
duration of the idle timeout. This may result in an invalid hardware
configuration leading to various target instabilities. Fix this by
holding a reference to the pm runtime when mdp overlay is turned on.
Similarly, when the userspace process is killed, wake up MDSS from idle
power collapse before shutting down the fb device.

Change-Id: Ie7748732fe76f9b2766da32b972e1e9fe7ff8751
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
msm: mdss: Configure TE GPIO using gpiomux framework

The TE GPIO needed on command mode panels has a gpio_func
value of 1. Acquiring resources of this gpio using gpio_request
API might configure this to a common gpio which has
gpio_func value equal to 0. Hence control this gpio using
the gpiomux framework.

Change-Id: I2e14ada484a6d20774030393ae6549f05ac1e8db
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
msm8974: Add TE gpio to gpiomux framework for Oppo boards

Change-Id: I12a91634a2aaf77c2b9cd0220c54e153280af15e
msm: mdss: fix screen shifting in some scenarios when split display enabled

Split display configuration requires that lower and upper pipe
control registers get programmed accordingly. This change fixes
a missing configuration bit in one of the control registers.

Change-Id: I17c71c004dbf6807483f132cb22271230b27960c
Signed-off-by: Ingrid Gallardo <ingridg@codeaurora.org>
video: mdss: Fix another unbalanced clock ctrl

Change-Id: Ia993ab7532197f94e400f34df989d7d576a11552