UPSTREAM: ARM: mm: use phys_addr_t appropriately in p2v and v2p conversions

Fix remainder types used when converting back and forth between
physical and virtual addresses.

BUG=chrome-os-partner:27723
TEST=cause crash and see ramoops in /dev/pstore on reboot.

Cc: Russell King <linux@arm.linux.org.uk>

Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
(cherry picked from commit ca5a45c06cd4764fb8510740f7fc550d9a0208d4)

Change-Id: I51ba32e11d4cec4d14c0330a697289ec06567b3c
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/193189
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
CHROMIUM: persistent_ram: remove atomic operations

The atomic operations (LDREX/STREX) to handle a buffer's start pointer
and size do not seem to work well on Logan.  The ldrex/strex instruction
always work on ARM when using the cache.  However, if the cache is
disabled then the instructions are dependent on SoC support.

Cherry picked from android-tegra-3.10 commit:
eae036b44aea75669573f1bfef953ac6bc9205f2

BUG=chrome-os-partner:27723
TEST=cause crash and see ramoops in /dev/pstore on reboot.

Suggested by: Colin Cross <ccross@android.com>

Change-Id: I4a698dbf206ec414cff8f7b3d6783d24fe654df6
Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
Signed-off-by: Johnny Qiu <joqiu@nvidia.com>
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/193220
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
CHROMIUM: mmc: sdhci: support infinite discard timeout

Some host controllers (e.g. Tegra) may support an infinite discard
timeout, indicated by a timeout_clock of 0.  max_discard_to should
be set to 0 in this case to indicate to the MMC core that the timeout
is infinite.

BUG=chrome-os-partner:27213
TEST=Run chromeos-install on Big

Change-Id: I1f311dd3bdf5b7a6ee766f75be3e25ca151c9b93
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/193514
Reviewed-by: Dylan Reid <dgreid@chromium.org>
CHROMIUM: mmc: tegra: fix timeout value reporting

With NVQUIRK_INFINITE_ERASE_TIMEOUT set (as is the case on Tegra124),
there will be no timeout clock.  Clear SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK
in this case and add a get_timeout_clock() callback to return 0.  Tegra
host controllers which do not enable INFINITE_ERASE_TIMEOUT will still use
the host clock frequency since the return value of get_timeout_clock() is
ignored if SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK is set.

BUG=chrome-os-partner:27213
TEST=Run chromeos-install on Big

Change-Id: Ia95343d7d541a4850e40b46b1749db786646a58c
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/193515
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Revert "CHROMIUM: cfg80211: hold BSS over association process"

This reverts commit a2612721d6b1a7e61a4d355d420c429e53418981.

Signed-off-by: Jason Abele <jabele@chromium.org>
Signed-off-by: Paul Stewart <pstew@chromium.org>

BUG=chrome-os-partner:27738
TEST=On 8897+PCIe:
   test_that chromeos5-372g-host3.cros network_WiFi_Roam.wifi_roamNone \
       network_WiFi_Roam.wifi_roamWEP network_WiFi_VerifyRouter \
       network_WiFi_PMKSACaching
ensure that the PMKSACaching test passes and that "iw mlan0 scan" does
not return a ton of very old BSSes.

Change-Id: I37e7a241e30cd4738205038b3c96b2ee14fd48f9
Reviewed-on: https://chromium-review.googlesource.com/193603
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Commit-Queue: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
CHROMIUM: pwm: tegra: Fix duty cycle calculation

The max value for the duty cycle is actually 256, not 255.  So when
converting from duty_ns / period_ns to actual duty / period, use 256 as
the max.

BUG=chrome-os-partner:27408
TEST=Instrumented the pwm-tegra driver, and made sure that when we set
brightness to 256, that we are actually using a duty cycle of 256.

Change-Id: I24f66aeb66ef7697fd7fbde0afae0af12482c39b
Reviewed-on: https://chromium-review.googlesource.com/193111
Tested-by: Andrew Chew <achew@nvidia.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Andrew Chew <achew@nvidia.com>
CHROMIUM: ARM: dts: nyan: Change brightness curve to linear

Make the display backlight brightness curve for generic nyan linear.
If a particular platform's panel is tuned against a light meter or
whatever, we can override the brightness-levels property in a
platform-specific leaf dts file.

BUG=chrome-os-partner:27408
TEST=Built the kernel with the new brightness-levels table.

Signed-off-by: Andrew Chew <achew@nvidia.com>
Change-Id: Id37394fa05c16b74b9fb3d4fdf83b0e0ca72201c
Reviewed-on: https://chromium-review.googlesource.com/192503
Reviewed-by: Dylan Reid <dgreid@chromium.org>
CHROMIUM: ARM: dts: blaze: fix trackpad i2c address

The elan trackpad i2c slave address shall be 0x15. Change the dts
file to the correct value.

BUG=chrome-os-partner:27750
TEST=emerge-nyan_blaze chromeos-kernel-3_10, booted successfully
on the blaze board and trackpad working fine.

Change-Id: I207bd9e481e0b47d98dde73c52e3e7ba2b919201
Signed-off-by: Ken Chang <kenc@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/192954
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
Revert "CHROMIUM: ARM: mm: fix section mappings after boot"

This reverts commit f4f83986290a669cf7dd69418775eeffcbebf00f.

BUG=chromium:356988
TEST=nyan build/boot

Change-Id: I745d436991d09f3cfcf7fc4df204d140716515b7
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/193522
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
Revert "CHROMIUM: ARM: mm: split kernel text from init"

This reverts commit a2611cf9011ec0739265b3f5ca1cf9aff9b650af.

BUG=chromium:356988
TEST=nyan build/boot

Change-Id: I8ff1f65f504f0984e0c5e9f50b01c7d2e5259078
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/193523
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
CHROMIUM: arm: ftrace: work with CONFIG_DEBUG_SET_MODULE_RONX

Make ftrace work with CONFIG_DEBUG_SET_MODULE_RONX by making module text
writable around the place where ftrace does its work, like it is done on
x86 in the patch which introduced CONFIG_DEBUG_SET_MODULE_RONX,
84e1c6bb38eb ("x86: Add RO/NX protection for loadable kernel modules").

Tested-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Signed-off-by: Rabin Vincent <rabin@rab.in>

BUG=chromium:356988
TEST=ftrace on nyan works again

Change-Id: I83b5498bff2c78d0d5bac926ab10b6367933ca58
(pending upstream http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=8022/1)
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/193524
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
CHROMIUM: ARM: mm: allow non-text sections to be non-executable

Adds CONFIG_ARM_KERNMEM_PERMS to separate the kernel memory regions
into section-sized areas that can have different permisions. Performs
the NX permission changes during free_initmem, so that init memory can
be reclaimed.

This uses section size instead of PMD size to reduce memory lost to
padding on non-LPAE systems.

Based on work by Brad Spengler, Larry Bassel, and Laura Abbott.

Signed-off-by: Kees Cook <keescook@chromium.org>

BUG=chromium:356988
TEST=ftrace on nyan works again

Change-Id: I9caf5e3c74744df01033e733bf131bc38d4d1acc
(discussing w/ upstream https://lkml.org/lkml/2014/4/3/424)
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/193525
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
CHROMIUM: ARM: mm: allow text and rodata sections to be read-only

This introduces CONFIG_DEBUG_RODATA, making kernel text and rodata
read-only. Additionally, this splits rodata from text so that rodata can
also be NX, which may lead to wasted memory when aligning to SECTION_SIZE.

The read-only areas are made writable during ftrace updates. Additional
work is needed for kprobes and kexec, so the feature is temporarily
marked as unavailable in Kconfig when those options are selected.

Signed-off-by: Kees Cook <keescook@chromium.org>

BUG=chromium:356988
TEST=ftrace on nyan works

Change-Id: Ic807c347c8807ae548fe3b579b97e2f8eb449c06
(discussing w/ upstream https://lkml.org/lkml/2014/4/3/418)
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/193526
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
CHROMIUM: config: enable ARM upstream kernel memory restrictions

This enables the proposed-to-upstream kernel memory restrictions:
    CONFIG_ARM_STRICT_KERNMEM
    CONFIG_DEBUG_RODATA

BUG=chromium:356988
TEST=nyan build/boot

Change-Id: Iea4a8d472487e4f65dac92bfc9eb7322c72e9167
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/193527
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
CHROMIUM: config: Normalize iwl configuration

The upstream 3.8 kernel did not provide a driver for the Intel 7xxx wireless
hardware. This shortcoming has been addressed by the iwlwifi driver in the 3.10
kernel.

Signed-off-by: Scott Reynolds <scottr@clank.org>

BUG=chromium:353447
TEST=Build amd64-generic and verify that iwl drivers are available, and confirm
that 4965 (iwl4965) and 5300 (iwlwifi) hardware is recognized and working.

Change-Id: Ic9f26f13d1c4cf48eb88fae65edd8cbdc182b5cb
Reviewed-on: https://chromium-review.googlesource.com/190078
Reviewed-by: Paul Stewart <pstew@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
Tested-by: Benson Leung <bleung@chromium.org>
Tested-by: Scott Reynolds <scottr@clank.org>
Commit-Queue: Benson Leung <bleung@chromium.org>
CHROMIUM: wireless-3.8: Normalize iwl configuration

If the iwl7000 module is enabled when using wireless-3.8, avoid building the
conflicting upstream iwlwifi module.

Signed-off-by: Scott Reynolds <scottr@clank.org>

BUG=chromium:353447
TEST=Build amd64-generic and verify that iwlwifi.ko includes 7260 support.

Change-Id: Ie94d072cbca0f6487376aa0df810525d78e265fd
Reviewed-on: https://chromium-review.googlesource.com/190801
Reviewed-by: Paul Stewart <pstew@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
Tested-by: Benson Leung <bleung@chromium.org>
Tested-by: Scott Reynolds <scottr@clank.org>
Commit-Queue: Benson Leung <bleung@chromium.org>
BACKPORT: ASoC: Maxim98090: Re-work PLL lock fixer to wait longer and remove loop.

Rework the PLL lock recovery to wait 50ms in between switching SHDN OFF
and then switching SHDN back ON.

Only do one iteration instead off looping. Since the IRQ will occur again
if lock is not attained. The extra 50ms delay here seems to help since I've
not seen any dropped IRQs yet (as would happen before). I dont think the
dropped IRQs were a result of masking since they would still happen after
reverting the IRQ mask code.

We also wait 10ms after enabling the PLL so that the work is not rescheduled
immediately upon PLL lock failure.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
(cherry picked from commit 0ec525ae6e18e8ec4d4f7912bb24b10784d1fba7)

Conflicts:

	sound/soc/codecs/max98090.c

BUG=chrome-os-partner:26948
TEST=Manual: Check that playback is never silent

Change-Id: I257baf78b77cefabecf3a1d3e5dc216d3ae8c81c
Signed-off-by: Kevin Strasser <kevin.strasser@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/193178
Reviewed-by: Benson Leung <bleung@chromium.org>
Tested-by: Benson Leung <bleung@chromium.org>
Commit-Queue: Benson Leung <bleung@chromium.org>
CHROMIUM: ASoC: Byt-max98090: Add byt_max98090_stop method

Put the codec into shutdown when all streams have been stopped.

BUG=chrome-os-partner:26948
TEST=Manual: Check that playback is never silent

Change-Id: I78c5366bc4f46f23321f8b7a34c11618a85f6db4
Signed-off-by: Kevin Strasser <kevin.strasser@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/193179
Reviewed-by: Benson Leung <bleung@chromium.org>
Tested-by: Benson Leung <bleung@chromium.org>
Commit-Queue: Benson Leung <bleung@chromium.org>
CHROMIUM: Input: elan_i2c - Add structure point checking

We add checking structure point is null or not before calling
input sub-system in elan_isr() to avoid excepted kernl panic.

Signed-off-by: Duson Lin <dusonlin@emc.com.tw>
BUG=chrome-os-partner:27191
TEST=on chromebook with Elan touchpad, boot and touchpad works.

Change-Id: I987151e41b985ee2b93b6468f40a73bf822143f9
Reviewed-on: https://chromium-review.googlesource.com/191666
Reviewed-by: Benson Leung <bleung@chromium.org>
Tested-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Bernie Thompson <bhthompson@chromium.org>
Commit-Queue: Bernie Thompson <bhthompson@chromium.org>
CHROMIUM: video: tegra: host: Fix PMU irq enable ordering.

Do not unmask PMU interrupts until after the PMU software
module is fully initialized. This ensures that all PMU
software context will be initialized when the first PMU
interrupt is handled.

BUG=chrome-os-partner:27803
TEST=10000 cycles LP0 stress passed(along with other changes)

Change-Id: Ic21fcf9c7f4efe798010ae5c996c024278176930
Signed-off-by: Neil Gabriel <ngabriel@nvidia.com>
Signed-off-by: Peer Chen <pchen@nvidia.com>
Tested-by: Peer Chen <pchen@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/193574
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
Tested-by: Mark Zhang <markz@nvidia.com>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>