CHROMIUM: dt: Increase big panel power-off time

The Full HD panel of BIG requires 500ms power-off time.
Since we can't define different skus in DT, we have to
increase the power-off time in BIG DT to make all panels
happy.

BUG=chrome-os-partner:28128
TEST=Display works and system boots up normally

Change-Id: I19794ff7b462d8dbae81c9e224e8caaca0ed2a8d
Signed-off-by: Mark Zhang <markz@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/200545
Tested-by: Bill Huang <bilhuang@nvidia.com>
Tested-by: Vince Hsu <vinceh@nvidia.com>
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
CHROMIUM: powergate: Powergate refcount based partitions when boot

venc/disp1/disp2/sor are 4 powergate partitions which are refcount
based. CoreBoot may enable something(e.g: display) so when kernel
takes over the system, we need to make sure the hardware environment
is clean.

So this change makes powergate driver powergate all these 4 partitions
when booting, so that the refcounts for these 4 partitions can be zero.

BUG=chrome-os-partner:28128
TEST=Display works and system boots up

Signed-off-by: Mark Zhang <markz@nvidia.com>

Change-Id: I93d44e5424f1e6bf11685cbc2cf0b1d33a63c4a0
Reviewed-on: https://chromium-review.googlesource.com/200419
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
CHROMIUM: memory: tegra124: export vpr check function

The VPR should be locked down before enabling GPU. This
patch exports the vpr check function, and then the GPU
driver can verify the VPR status by this.

BUG=None
TEST=System boots ok on Big

Change-Id: I0d3dc0827786958064cc5f81852e11e89da462a5
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Signed-off-by: Vince Hsu <vinceh@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/200524
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
CHROMIUM: video: tegra: host: gk20a: check vpr before enabling gk20a

Make sure we have VPR locked down and then enable gk20a.

BUG=None
TEST=System boots ok on Big

Change-Id: Ie42379e45e8b74d6e5784953f4292a998c8ad862
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Signed-off-by: Vince Hsu <vinceh@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/200525
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
CHROMIUM: clk: tegra124: add flag TEGRA_PLL_ACCURATE for pll_dp

We need clock rate of "PLL_DP" to be accurate, add flags
TEGRA_PLL_ACCURATE for clock "PLL_DP".

BUG=chrome-os-partner:28128
TEST=Read clock rate of pll_dp in clk_summary, it should be 270MHz
     instead of 268MHz.

Change-Id: I4208b849558daa48c0bf370f561ec64cfb6a57fc
Signed-off-by: Bill Huang <bilhuang@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/200542
Tested-by: Vince Hsu <vinceh@nvidia.com>
Reviewed-by: <pdeschrijver@nvidia.com>
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
CHROMIUM: clk: tegra: fix VCO rate

Fix VCO rate by taking vco_min into account.

BUG=chrome-os-partner:28128
TEST=check if the calculated VCO rate is bigger than the VCO_MIN, it
     should be.

Change-Id: I74ebda42f0c252002194d487d3d8c033ce34f9b0
Signed-off-by: Bill Huang <bilhuang@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/200527
Tested-by: Vince Hsu <vinceh@nvidia.com>
Reviewed-by: <pdeschrijver@nvidia.com>
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
CHROMIUM: ARM: dt: blaze: change AS3722 adc channel

Blaze uses ADC channel 21 to sense AS3728 SD6 regulator
temperature. Change the dt setting accordingly.

BUG=chrome-os-partner:28994
TEST=cat /sys/class/thermal/thermal_zone5/temp returned a fixed
and invalid value, but the value looks good and changes with this
change.

Change-Id: I3228c8d7e76b8012be097c407e75fc4cace1e182
Signed-off-by: Ken Chang <kenc@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/199999
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
CHROMIUM: drm/edid: Fix the panel id for CMN N116BGE-EB2

The panel id is in hex, not in decimal. This should make the graphics_Idle
test pass.

BUG=none
TEST=none

Change-Id: I18cca9e93b7b6b07f8d957c2b3c3fbcac087be29
Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200710
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Olof Johansson <olofj@chromium.org>
Commit-Queue: Olof Johansson <olofj@chromium.org>
CHROMIUM: Input: atmel_mxt_ts - Clean up lid filter corner cases

The lid filter and suspend/resume interactions were not clean
prior to this patch. The lid filter code would save T9 or T100 ctrl
on lid close, ensuring that whenever the system resumes the next time,
it always restores the *active* mode value of T9 or T100.

In the case of T9, it would restore 0x83, turning the pad or screen
on.

This is incorrect if we do a lid closed resume. We end up with the touchscreen
or touchpad active while lid closed, causing stray touches.
Instead, suspend should save the value, and resume should restore.

That way, if the lid was closed, and touch device disabled before suspend,
the resume should leave the device in the same disabled state.

This patch also covers the behavior of the lid open event firing shortly after
system resume, but before mxt_resume can be called. In that case,
it will invalidate the saved value, causing mxt_resume to set to full
active using mxt_start.

Signed-off-by: Benson Leung <bleung@chromium.org>

BUG=chromium:369738
TEST=Do the following on Pixel.
Test normal lid-closed suspend :
1. log in as guest
2. close the lid, wait for suspend
3. open the lid to resume
4. Check that touchpad and touchscreen are both responsive.

Test normal lid-open, suspend, then lid-closed:
1. login in as guest with external DISPLAY+keyboard connected with lid-open
2. wait for the suspend
3. close the lid
4. wake up the device with external keyboard
5. ensure no stray touches from touchpad or touchscreen

Test Docked mode, lid close-open, no suspend :
1. log in as guest
2. connect external display via mini-dp to extend monitor
3. close the lid to enter docked mode
4. ensure no stray touches from touchpad or touchscreen here*
5. open the lid
6. Check that touchpad and touchscreen are both responsive.

Test Docked mode, lid closed, idle suspend :
1. log in as guest
2. connect external display via mini-ip to extend monitor. Connect USB keyboard.
3. close the lid to enter docked mode
4. ensure no stray touches from touchpad or touchscreen here*
5. from a remote shell (ssh) : powerd_dbus_suspend
6. strike a key from usb keyboard to resume.
7. ensure no stray touches from touchpad or touchscreen here*
8. open the lid
9. Check that touchpad and touchscreen are both responsive.

*: To check that no stray touches occur:
a) ssh to dut.
b) run "evtest" command.
c) Select the event number for Atmel maXTouch Touchscreen
d) do a-c again in a separate ssh window for Atmel maXTouch Touchpad also
e) check that no reports from (ABS_MT_POSITION_X) or (ABS_MT_POSITION_Y) etc
   occur.

Change-Id: Icc2275611663a626a95326ec0628dd255fa55e7e
Signed-off-by: Chung-yih Wang <cywang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/199149
Reviewed-by: Benson Leung <bleung@chromium.org>
(cherry picked from commit 6ef67b8d25cb664db35dd4f03a6e582adf2e0aac)
Signed-off-by: Chung-yih Wang <cywang@chromium.org>
(cherry picked from commit 8337d4d7d2f4833d131bae3ae11141042f1f086a)
Signed-off-by: Chung-yih Wang <cywang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/199177
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
CHROMIUM: config: blaze: enable elan touch screen driver in base.config

Add CONFIG_TOUCHSCREEN_ELAN=y in base.config to enable elan touch screen driver.

BUG=chrome-os-partner:27621
TEST=manual
build kernel which enable elan touch screen driver in base.config and update elan touch screen FW.
check if touch screen work or not

Change-Id: I42aecbfae54e4e2897d265016e5167729d2588e9
Signed-off-by: Wisley Chen <Wisley.Chen@quantatw.com>
Reviewed-by: Charles Mooney <charliemooney@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200539
Tested-by: Chen Wisley <wisley.chen@quantatw.com>
Commit-Queue: Katie Roberts-Hoffman <katierh@chromium.org>
CHROMIUM: ARM: dts: blaze: clock GEN2 I2C at 400KHz

Blaze shall be able to clock trackpad/touchpad I2C bus at 400KHz.
Change the dt setting accordingly to improve the performance.

BUG=chrome-os-partner:29023
TEST=emerged blaze kernel, captured the waveform from gen2 i2c bus,
scl running at ~400Kz and the waveform looks good.

Change-Id: I381627cca42e66406a90518a4fdac3e440f0c928
Signed-off-by: Ken Chang <kenc@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/200720
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
CHROMIUM : DPTF update to v8.0.10001

Fixes:
	Added "extern C" declarations for C++ SDK
	Added pragma pack code for data structures
	Removed SYSFS instrumentation

Other:
	Code clean-up
	Refactored event handling code
	Future policy support

BUG=chromium:360249
TEST=Manually tested
CQ-DEPEND=CL:200631

Change-Id: Ib2511e6fc17623479f1f40b13d8069290f92ae0e
Signed-off-by: Brad Geltz <brad.geltz@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/200633
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
CHROMIUM: mmc: tegra: use HW timeout corresponding to SW value

tegra_sdhci_issue_tuning_cmd() currently programs the maximum available
timeout value, which corresponds to about 650ms at 200Mhz, into
SDHCI_TIMEOUT_CONTROL, but we only poll SDHCI_INT_STATUS for 5ms before
giving up and resetting the controller.  Writes to SDHCI_SOFTWARE_RESET,
however, may stall until in-progress command has timed out, causing the
entire system to hang for that time.  Removing an SD card during tuning,
for example, could cause the entire system to hang for 100s of ms.
Instead of using the maximum timeout value, choose one which is about
equal to what we'll wait for in software before timing out and resetting.

BUG=chrome-os-partner:28547
TEST=Build and boot on Big

Change-Id: Ib30a9b2cd6cb114a8e74f83bf59513d5bf2dd763
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/201158
Reviewed-by: Christopher Freeman <cfreeman@nvidia.com>
Tested-by: Christopher Freeman <cfreeman@nvidia.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
CHROMIUM: atmel_mxt_ts: Add sysfs for requesting T19 status

T19 status can be used to differentiate the touch sensors
that are attached to the touch controller. This CL adds a
sysfs entry for
1) when written to, it requests the touch controller to report the T19 status
2) when read, it returns the latest T19 status

BUG=chrome-os-partner:29065
TEST=tested on clapper that the T19 status can be read as 0x3C, which represents
the correct touch sensor.

Change-Id: I46d9793da242b07aa03b4cb6b1eaf538319b097b
Signed-off-by: Yufeng Shen <miletus@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200814
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
UPSTREAM: mwifiex: fix PCIe hs_cfg cancel cmd timeout

For pcie8897, the hs_cfg cancel command (0xe5) times out when host
comes out of suspend. This is caused by an incompleted host sleep
handshake between driver and firmware.

Like SDIO interface, PCIe also needs to go through firmware power
save events to complete the handshake for host sleep configuration.
Only USB interface doesn't require power save events for hs_cfg.

Cc: <stable@vger.kernel.org> # 3.10+
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>

BUG=chrome-os-partner:27663
TEST=suspend_stress_test

Change-Id: Ifbcdc59bbd69b9b9d3f06bbe19b5195b3c8da03d
Reviewed-on: https://chromium-review.googlesource.com/200810
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Bing Zhao <bzhao@marvell.com>
Tested-by: Bing Zhao <bzhao@marvell.com>
UPSTREAM: n_tty: Fix n_tty_write crash when echoing in raw mode

The tty atomic_write_lock does not provide an exclusion guarantee for
the tty driver if the termios settings are LECHO & !OPOST.  And since
it is unexpected and not allowed to call TTY buffer helpers like
tty_insert_flip_string concurrently, this may lead to crashes when
concurrect writers call pty_write. In that case the following two
writers:
* the ECHOing from a workqueue and
* pty_write from the process
race and can overflow the corresponding TTY buffer like follows.

If we look into tty_insert_flip_string_fixed_flag, there is:
  int space = __tty_buffer_request_room(port, goal, flags);
  struct tty_buffer *tb = port->buf.tail;
  ...
  memcpy(char_buf_ptr(tb, tb->used), chars, space);
  ...
  tb->used += space;

so the race of the two can result in something like this:
              A                                B
__tty_buffer_request_room
                                  __tty_buffer_request_room
memcpy(buf(tb->used), ...)
tb->used += space;
                                  memcpy(buf(tb->used), ...) ->BOOM

B's memcpy is past the tty_buffer due to the previous A's tb->used
increment.

Since the N_TTY line discipline input processing can output
concurrently with a tty write, obtain the N_TTY ldisc output_lock to
serialize echo output with normal tty writes.  This ensures the tty
buffer helper tty_insert_flip_string is not called concurrently and
everything is fine.

Note that this is nicely reproducible by an ordinary user using
forkpty and some setup around that (raw termios + ECHO). And it is
present in kernels at least after commit
d945cb9cce20ac7143c2de8d88b187f62db99bdc (pty: Rework the pty layer to
use the normal buffering logic) in 2.6.31-rc3.

js: add more info to the commit log
js: switch to bool
js: lock unconditionally
js: lock only the tty->ops->write call

References: CVE-2014-0196
Reported-and-tested-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

BUG=chromium:371214
TEST=nyan build & boot

Change-Id: I2ba8ccf646f2e0efa7bba1f0525b9f28a1c02bca
(cherry picked from upstream commit 4291086b1f081b869c6d79e5b7441633dc3ace00)
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200625
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
CHROMIUM: video: tegra: host: Do not dump channel if error

Do not dump channel state if the channel could not be initialized.

BUG=chrome-os-partner:29063
TEST=visit
https://www.khronos.org/registry/webgl/conformance-suites/1.0.0/extra/lots-of-polys-example.html
and let it run, see if it crashes the system

Change-Id: Ib1d8d0ccad0eb1254584e3fa6093c66921f36688
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/201071
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
CHROMIUM: config: enable Wacom tablet driver

BUG=chromium:194865
TEST=manually tested; with this patch, wacom tablet can work as a mouse device.

Change-Id: Icea3867887dea07cb15a9dc0ae7730fc3747d0b5
Tested-by: Hung-ying Tyan <tyanh@chromium.org>
Signed-off-by: Chung-yih Wang <cywang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/201207
Reviewed-by: Hung-ying Tyan <tyanh@chromium.org>
CHROMIUM: drm/i915/vlv: Fix BLM_PWM_ENABLE check in pwm invariant

Misplaced paren causing test to always fail.

BUG=chrome-os-partner:27096,chrome-os-partner:28914
TEST=Manual: Check that the screen immediately goes black at
minimum brightness.

Change-Id: If9d813ab4ef8cfd9c90f2183f1bb674172bdffe9
Signed-off-by: Kevin Strasser <kevin.strasser@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/200809
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
UPSTREAM: sched: Remove redundant update_runtime notifier

migration_call() will do all the things that update_runtime() does.
So let's remove it.

Furthermore, there is potential risk that the current code will catch
BUG_ON at line 689 of rt.c when do cpu hotplug while there are realtime
threads running because of enabling runtime twice while the rt_runtime
may already changed.

Signed-off-by: Neil Zhang <zhangwm@marvell.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1365685499-26515-1-git-send-email-zhangwm@marvell.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
(cherry picked from commit c5405a495e88d93cf9b4f4cc91507c7f4afcb901)

BUG=chrome-os-partner:29119
TEST=build and boot on nyan

Change-Id: I6809cb44998269e44458a6443f086f5bc05edd07
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/201388
Reviewed-by: Dylan Reid <dgreid@chromium.org>