BACKPORT: mwifiex: replace mdelay with msleep

It is observed that when wrong firmware is downloaded for
PCIe card, system hangs for 10 seconds. The reason is mdelay()
is used when firmware status is polled.

Replace mdelay with msleep(non-blocking API) to fix the issue.

BUG=chromium:348637
TEST=reboot and listen to intro sound 10 times, no cracks and pops.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
(cherry picked from commit a76b20e5ca8a9ec0b45a4150b4ad19e27dd19699)

Change-Id: If2e73c770a21981007c2105023af9678fbdf83f9
Reviewed-on: https://chromium-review.googlesource.com/206432
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Chih-Chung Chang <chihchung@chromium.org>
Commit-Queue: Chih-Chung Chang <chihchung@chromium.org>
CHROMIUM: input: cyapa - Clean up lid filter corner cases

The lid filter and suspend/resume interactions were not clean
prior to this patch. It is incorrect if we do a lid closed resume.
We end up with the touchpad active while lid closed, causing stray touches.
Instead, we check the lid state when system resumes.

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 cyapa_resume can be called.

BUG=chromium:372082
TEST=Do the following on device with Cypress touchpad.
  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 is 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*

  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 here*
  5. open the lid
  6. Check that touchpad is responsive.

  Test Docked mode, lid closed, idle suspend :
  1. log in as guest
  2. connect external display and connect USB keyboard.
  3. close the lid to enter docked mode
  4. ensure no stray touches from touchpad 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 here*
  8. open the lid
  9. Check that touchpad is responsive.

  Test normal lid-closed suspend with external mouse, docked mode, lid open:
  1. log in as guest
  2. connect USB keyboard.
  3. close the lid to enter suspend mode
  4. connect external display
  5. strike a key from usb keyboard to resume.
  6. ensure no stray touches from touchpad here*
  7. open the lid
  8. Check that touchpad is responsive.

  *: To check that no stray touches occur:
  a) ssh to dut.
  b) run "evtest" command.
  c) open the lid a little bit(good enough for your finger to touch the pad, but
     make sure it won't trigger lid open event.
  d) a finger touches the pad to verify that touchpad should not be responsive.

Change-Id: Ia33f8f9ce15f601ea9b5a32637c6e1562816819a
Signed-off-by: Chung-yih Wang <cywang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/204302
Reviewed-by: Benson Leung <bleung@chromium.org>
Tested-by: Benson Leung <bleung@chromium.org>
Merge branch 'chromeos-3.8' of https://chromium.googlesource.com/chromiumos/third_party/kernel into chromeos-3.8
UPSTREAM: ptrace,x86: force IRET path after a ptrace_stop()

The 'sysret' fastpath does not correctly restore even all regular
registers, much less any segment registers or reflags values.  That is
very much part of why it's faster than 'iret'.

Normally that isn't a problem, because the normal ptrace() interface
catches the process using the signal handler infrastructure, which
always returns with an iret.

However, some paths can get caught using ptrace_event() instead of the
signal path, and for those we need to make sure that we aren't going to
return to user space using 'sysret'.  Otherwise the modifications that
may have been done to the register set by the tracer wouldn't
necessarily take effect.

Fix it by forcing IRET path by setting TIF_NOTIFY_RESUME from
arch_ptrace_stop_needed() which is invoked from ptrace_stop().

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Andy Lutomirski <luto@amacapital.net>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit e438b405e71e4b430f41791a503a87151100cf0a)

BUG=chromium:391743
TEST=`emerge-$BOARD chromeos-kernel-3_8`

Change-Id: I51e39409a7f8b98d5a1c8510524839471807b393
Signed-off-by: Ben Chan <benchan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/206938
Reviewed-by: Kees Cook <keescook@chromium.org>
CHROMIUM: mwifiex: add missing memset in sta_tx.c

CL 205831 has missed this line. Add it to match upstream patch:
http://marc.info/?l=linux-wireless&m=140425083601658&w=4

BUG=chrome-os-partner:30211
TEST=reboot, connect to AP and browser Internet.

Change-Id: I47c737d82cfacc5a4e3867df16c0a1b9d3ed570a
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Reviewed-on: https://chromium-review.googlesource.com/206660
Reviewed-by: Paul Stewart <pstew@chromium.org>
UPSTREAM: mwifiex: add tx info to skb when forming mgmt frame

In function 'mwifiex_write_data_complete' it need tx info to find
the mwifiex_private to updates statistics and wake up tx queues.
Or we may trigger tx queues timeout when transmitting lots of mgmt
frames.

Signed-off-by: Huawei Yang <harvey.huawei.yang@gmail.com>
Signed-off-by: Stone Piao <piaoyun@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

Add memset line manually to match upstream patch:
http://marc.info/?l=linux-wireless&m=140425083601658&w=4

BUG=chrome-os-partner:30211
TEST=autotest

Change-Id: I834e9579331cc274d13cbf084dd5f8b6bc163aa3
Reviewed-on: https://chromium-review.googlesource.com/206661
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Bing Zhao <bzhao@marvell.com>
Commit-Queue: Bing Zhao <bzhao@marvell.com>
CHROMIUM: config: Enable OTI6858 usb-to-serial driver for all boards

Some users might find it useful to have this driver enabled by default.

BUG=none
TEST=kernel_ConfigVerify

Change-Id: I63d79a4e6becf1d99fb76d801a8ccac37b818c17
Signed-off-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/205637
Reviewed-by: Olof Johansson <olofj@chromium.org>
drm/exynos: add mixer_mode_valid() and call it from hdmi_mode_valid()

Exynos 5250 mixer does not support certain modes which recently appeared
available because driver now supports mode pixel clocks. This change
adds a check in hdmi_mode_valid() that calls new function mixer_mode_valid()
to determine whether the mode is supported in mixer as well. This will
result in modes not supported by mixer being correctly pruned from kernel mode
list and X server will not attempt to set them at boot time.

BUG=chromium:374985,382941
TEST=boot Daisy with 1280x1024 native LCD monitor attached

Change-Id: I042cf11d840c68e72a80ad4fbeead3bb5b183824
Signed-off-by: Dominik Behr <dbehr@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/206600
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
BACKPORT: reservation: add support for fences to enable cross-device synchronisation

BUG=chromium:340541
TEST=built and boot Chrome OS on Peach Pi
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
(cherry picked from commit c4df9f37339bbfca673bca8b6d3f268cf73c7a1b)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: Ief1a388a78db568c497e2ef86b922e3a0ab1ed50
Reviewed-on: https://chromium-review.googlesource.com/202792
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Dominik Behr <dbehr@chromium.org>
BACKPORT: dma-buf: use reservation objects

This allows reservation objects to be used in dma-buf. it's required
for implementing polling support on the fences that belong to a dma-buf.

BUG=chromium:340541
TEST=built and boot Chrome OS on Peach Pi

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Acked-by: Mauro Carvalho Chehab <m.chehab@samsung.com> #drivers/media/v4l2-core/
Acked-by: Thomas Hellstrom <thellstrom@vmware.com> #drivers/gpu/drm/ttm
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
(cherry picked from commit 8b992497e8c2f7a30ba0ec8b88773d65f9d29859)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Conflicts:
	drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
	drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
	drivers/gpu/drm/ttm/ttm_object.c
	drivers/staging/android/ion/ion.c
	include/linux/dma-buf.h

Change-Id: I794c684a95b28a095290de94ebb8ab022f07c5c7
Reviewed-on: https://chromium-review.googlesource.com/202793
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Commit-Queue: Dominik Behr <dbehr@chromium.org>
BACKPORT: reservation: update api and add some helpers

Move the list of shared fences to a struct, and return it in
reservation_object_get_list().
Add reservation_object_get_excl to get the exclusive fence.

Add reservation_object_reserve_shared(), which reserves space
in the reservation_object for 1 more shared fence.

reservation_object_add_shared_fence() and
reservation_object_add_excl_fence() are used to assign a new
fence to a reservation_object pointer, to complete a reservation.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>

Changes since v1:
- Add reservation_object_get_excl, reorder code a bit.

BUG=chromium:340541
TEST=built and boot Chrome OS on Peach Pi

(cherry picked from commit d2dd1fd2bf1ea93c8b5146ba99c773d7f71b0789)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Conflicts:
	drivers/base/dma-buf.c

Change-Id: I5cd631ce4c39e46804f3a909f6d0216a81808489
Reviewed-on: https://chromium-review.googlesource.com/202794
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Dominik Behr <dbehr@chromium.org>
BACKPORT: reservation: add suppport for read-only access using rcu

This adds 4 more functions to deal with rcu.

reservation_object_get_fences_rcu() will obtain the list of shared
and exclusive fences without obtaining the ww_mutex.

reservation_object_wait_timeout_rcu() will wait on all fences of the
reservation_object, without obtaining the ww_mutex.

reservation_object_test_signaled_rcu() will test if all fences of the
reservation_object are signaled without using the ww_mutex.

reservation_object_get_excl() is added because touching the fence_excl
member directly will trigger a sparse warning.

BUG=chromium:340541
TEST=built and boot Chrome OS on Peach Pi

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
(cherry picked from commit ccb008ae5bc5c89250c04a37bd2b0b114a13058a)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Conflicts:
	drivers/base/dma-buf.c

Change-Id: I26ed086b38a9486fa518c5fd7b9f4e4ff9ff7339
Reviewed-on: https://chromium-review.googlesource.com/202795
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Dominik Behr <dbehr@chromium.org>
CHROMIUM: dark resume: fix memory leak

This fixes the sysfs files getting leaked for non-source dark resume devices

BUG=chrome-os-partner:28391
TEST=On link
Enable kernel configs:
CONFIG_HAVE_DEBUG_KMEMLEAK=y
CONFIG_DEBUG_KMEMLEAK=y
CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE=4000
Boot system
Plug and unplug usb drive several times
echo scan > /sys/kernel/debug/kmemleak
cat /sys/kernel/debug/kmemleak
See that there's nothing from the usb stack leaking

Change-Id: Id005084b1d4daa79541a12e650af52781b0dcaac
Signed-off-by: Derek Basehore <dbasehore@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/207215
Reviewed-by: Julius Werner <jwerner@chromium.org>
CHROMIUM: fence and reservation based mali-exynos synchronization

Replace KDS based synchronization with fences and reservation objects for
CRTC page flips, CPU acquire/release and Mali driver external resources.
Add exynos_fence objects which are simple software implementation of fences.
Add reservation_cb objects that can collect fences from multiple reservation
objects and implement synchronous and asynchronous wait on them.

BUG=chromium:340541
TEST=run webgl aquarium and big buck bunny in two windows side by side

Change-Id: I4187aa4aff0ac4a8fad6a53503101a598f93a22a
Signed-off-by: Dominik Behr <dbehr@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202796
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: John Einar Reitan <john.reitan@arm.com>
Merge branch 'chromeos-3.8' of https://chromium.googlesource.com/chromiumos/third_party/kernel into chromeos-3.8