kernel: gtod: Add MSM-specific user-accessible timers

Enable MSM-specific timers to be readable from user-space.
This allows implementation of a higher-performance
gettimeofday in user-space.

Change-Id: I1f322b5396ee335b10aeb81c681593621d151176
Signed-off-by: Brent DeGraaf <bdegraaf@codeaurora.org>
msm: correctly handle multiple memory holes

The function adjust_meminfo() did not correctly set the
size of any meminfo which was beyond the second memory hole.

Change-Id: I5bf6c5b30f7657ce9b975c9b4afb8fb3b2ce343f
CRs-Fixed: 455187
Signed-off-by: Larry Bassel <lbassel@codeaurora.org>
msm: Update meminfo to reflect consecutive memory holes

The device tree now has a node for each of the memory regions
belonging to the subsystems. The meminfo blocks are updated to
reflect these memory holes in such a way that every meminfo block
is of a non-zero size. The start and end of the largest memory
hole is calculated using the meminfo.

Change-Id: I9eb9984f9d74cf2a493846cb2ae7f83db9f92719
Signed-off-by: Neeti Desai <neetid@codeaurora.org>
msm: arm: make nohlt readable

Make the debugfs node 'nohlt' readable.

It is a common use case to want to turn nohlt
on or off, but there is no way to see the current state.
Writing to nohlt increments or decrements its reference
counter, and does not absolutely set the state. By making
it readable, its current state can be checked so that
it can be determined if a write is needed to change the
state.

Change-Id: I08e327808299aef3e125f04bff8b6aad28d020cc
Signed-off-by: Neil Leeder <nleeder@codeaurora.org>
arm: Move to upstream udelay via timer implementation

This is a squash of a handful of changes and reverts of the
Qualcomm specific implementation:

  Revert "arm: Implement a timer based __delay() loop"

  This reverts commit 976eafa8b18252876e15f861944acf693b07ce7e.

  Revert "arm: Allow machines to override __delay()"

  This reverts commit bc0ef8ab167272890f1aab62928b04a9aeb87ce9.

  Revert "arm: Translate delay.S into (mostly) C"

  This reverts commit 8d5868d8205d10a0a8e423f53e9cc9bb3e9d1a34.

  ARM: 7451/1: arch timer: implement read_current_timer and get_cycles

  This patch implements read_current_timer using the architected timers
  when they are selected via CONFIG_ARM_ARCH_TIMER. If they are detected
  not to be usable at runtime, we return -ENXIO to the caller.

  Furthermore, if read_current_timer is exported then we can implement
  get_cycles in terms of it for use as both an entropy source and for
  implementing __udelay and friends.

  Tested-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
  Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
  Signed-off-by: Will Deacon <will.deacon@arm.com>
  Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

  ARM: 7452/1: delay: allow timer-based delay implementation to be
  selected

  This patch allows a timer-based delay implementation to be selected by
  switching the delay routines over to use get_cycles, which is
  implemented in terms of read_current_timer. This further allows us to
  skip the loop calibration and have a consistent delay function in the
  face of core frequency scaling.

  To avoid the pain of dealing with memory-mapped counters, this
  implementation uses the co-processor interface to the architected timers
  when they are available. The previous loop-based implementation is
  kept around for CPUs without the architected timers and we retain both
  the maximum delay (2ms) and the corresponding conversion factors for
  determining the number of loops required for a given interval. Since the
  indirection of the timer routines will only work when called from C,
  the sa1100 sleep routines are modified to branch to the loop-based delay
  functions directly.

  Tested-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
  Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
  Signed-off-by: Will Deacon <will.deacon@arm.com>
  Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

  ARM: delay: set loops_per_jiffy when moving to timer-based loop

  The delay functions may be called by some platforms between switching to
  the timer-based delay loop but before calibration. In this case, the
  initial loops_per_jiffy may not be suitable for the timer (although a
  compromise may be achievable) and delay times may be considered too
  inaccurate.

  This patch updates loops_per_jiffy when switching to the timer-based
  delay loop so that delays are consistent prior to calibration.

  Signed-off-by: Will Deacon <will.deacon@arm.com>

  ARM: delay: add registration mechanism for delay timer sources

  The current timer-based delay loop relies on the architected timer to
  initiate the switch away from the polling-based implementation. This is
  unfortunate for platforms without the architected timers but with a
  suitable delay source (that is, constant frequency, always powered-up
  and ticking as long as the CPUs are online).

  This patch introduces a registration mechanism for the delay timer
  (which provides an unconditional read_current_timer implementation) and
  updates the architected timer code to use the new interface.

  Signed-off-by: Jonathan Austin <jonathan.austin@arm.com>
  Signed-off-by: Will Deacon <will.deacon@arm.com>

  ARM: export default read_current_timer

  read_current_timer is used by get_cycles since "ARM: 7538/1: delay:
  add registration mechanism for delay timer sources", and get_cycles
  can be used by device drivers in loadable modules, so it has to
  be exported.

  Without this patch, building imote2_defconfig fails with

  ERROR: "read_current_timer" [crypto/tcrypt.ko] undefined!

  Signed-off-by: Arnd Bergmann <arnd@arndb.de>
  Cc: Stephen Boyd <sboyd@codeaurora.org>
  Cc: Jonathan Austin <jonathan.austin@arm.com>
  Cc: Will Deacon <will.deacon@arm.com>
  Cc: Russell King <rmk+kernel@arm.linux.org.uk>

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

Conflicts:

	arch/arm/lib/Makefile
ARM: hw_breakpoint: enable HAVE_HW_BREAKPOINT feature flag

HAVE_HW_BREAKPOINT was disabled temporarily from commit
480a82f59712136b51ee5ca05c4f22c1738010c5. Issue not seen with the
latest kernel hence re-enable the feature and fix merge issue from
previous kernel upgrade.

Change-Id: Ia6e7e8282c848dd73108e4d951b3375bb7caa63c
Signed-off-by: Jin Hong <jinh@codeaurora.org>
Signed-off-by: Taniya Das <tdas@codeaurora.org>
msm: pm-8x60: Remove timeout waiting for cpu to power collapse

The delays in the CPU_DYING notication path could result in the core
initiating the hotplug to send out CPU_DEAD notifications after
msm_pm_wait_cpu_shutdown() times out. This could result in a unknown
resets when regulator/clocks are disabled in the CPU_DEAD path. To
prevent unknown resets, wait infinitely to enter power collapse but
throw a warning after the 1ms mark.

The platform_cpu_kill() path is also executed in the reboot path when a
core tries to stop secondary cores. In these cases, platform_cpu_kill
shouldn't wait infinitely for the secondary cores to power collapse. To
circumvent this scenario, track dying cpus as a part of the hotplug
notification and skip waiting for the core to power collpase during
reboot path.

Change-Id: I144e95a6d019e897381d2bca62ab50ecefd56b5b
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: hotplug: remove code related to cpu_killed

Earlier the completion event cpu_killed was used to synchronize
notify to hot plug framework that the CPU is dead. But now it is
replaced with another completion event cpu_died and it is placed
in the hotplug framework itself. So there is no need for a
platform to implement a completion event.

But in msm platform driver the completion event related code
was not removed with the changes in hotplug framework. This
patch removes the unused code.

Change-Id: I4418e5e397821e39a7b6a6efa997c4a866e9b46b
Signed-off-by: Venkat Devarasetty <vdevaras@codeaurora.org>
msm: implement ARCH_RANDOM

Currently, the software random number generator is not intialized
until relatively late in the boot process. Software that relies on
random numbers early will not be reliable. Entropy sources are
available early but not early enough for some use cases which means
that moving the software random number generation earlier is not an
option. As an alternate solution, implement the functions associated
with CONFIG_ARCH_RANDOM. These functions currently make a call into
trustzone to get reliable random numbers. The functions are disabled
once the regular random number generator is sufficiently reliable.

Change-Id: If40cfcb96b091fa26a28047c10a902287b26f6c1
CRs-Fixed: 498392
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Kconfig: Enable config to allow vmalloc savings

Enable the config to reclaim the vmalloc space in lowmem
and disable the map around the hole config, as both the
configs cannot be enabled together.

Change-Id: I5689d871e6b657f6de45ee22fed33cc77e508db9
Signed-off-by: Neeti Desai <neetid@codeaurora.org>
kernel: Add hooks for user-accessible timers in the kernel.

Hooks for user-accessible timers allow implementation of a
more efficient gettimeofday in user-space.

Change-Id: If2f63d010c1cf142eb84f3745617e756913e46f7
Signed-off-by: Brent DeGraaf <bdegraaf@codeaurora.org>
ARM: proc: Add Krait proc info

Add processor info for the Qualcomm, Inc. Krait family of
processors, to use the generic ARMv7 initialisation
procedure but explicitly enable the IDIV hardware
capability flag.

Change-Id: I080f60189fada2e4f87c79c6b8ef522cdc070759
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
kernel: gtod: vsyscall

Introduce kernel user helper vsyscall to allow a higher performance
gettimeofday implementation in user-space.

Change-Id: I9b9971d217382129170ecd6a35461539dac9eebb
Signed-off-by: Brent DeGraaf <bdegraaf@codeaurora.org>
kernel: ARM-specific implementation of user-accessible timers

Expose a read-only timer page to user-space to allow for a more
efficient implementation of gettimeofday in user-space.

Change-Id: Ibd6ce41f5f4ff9435e4bf4582ef5de721283d56b
Signed-off-by: Brent DeGraaf <bdegraaf@codeaurora.org>
jtag: make debug arch defines local to jtag.c

Move debug arch defines to jtag.c since they aren't used anywhere else.
Also rename ARM_DEBUG_ARCH_V7_1 to ARM_DEBUG_ARCH_V7p1 to avoid clashes
with similar define in hw_breakpoint.h that is enabled when hardware
breakpoints are enabled.

Change-Id: I5f4b24b7aec50413f97a5b1854e6fadf2e4ab514
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
msm: pm: Bring back Standalone Power Collapse

This was removed by LG, put it back

Change-Id: I9d577897e9e2688154177e2ee3e520a5cdc6d4b9
gk: Let the venc do non-secure allocations out of the CP heap

Change-Id: I9e0916405d41bb8ff8ef8901659ac14a517f8ec5
Revert "msm: vidc: Remove kernel mapping on input/output buffers"

This reverts commit 644ccb375081f2e2cb23cdbb1bc58e868803ab75.

Change-Id: I4d05ef73ac7e000c70fc752e60c43eac2e6ae5b3

Conflicts:
	drivers/video/msm/vidc/1080p/ddl/vcd_ddl_metadata.c
	drivers/video/msm/vidc/common/enc/venc.c
	include/linux/msm_vidc_enc.h
	include/media/msm/vcd_api.h
Revert "msm_fb: display: restore previous mdp bandwidth when resume"

This reverts commit 1cdf26e9c81b9c426fdf580a68b7b247f3461842.
Revert gfx3d footswitch updates

These are breaking 1080p display on the GK

This is a combination of 4 commits.
Revert "footswitch: Fix setting MSM_RPM_ID_RPM_CTL for force_bus_clocks"

This reverts commit cb3a682595dd96a55d6017fa31808bd44e3167fc.

Revert "msm: footswitch-8x60: Skip GFX memory power collapse on 8064."

This reverts commit 44c96b035016e8434c349a8b83d4fb579b122012.

Revert "msm: footswitch-8x60: Allow specification of per-fs reset delays"

This reverts commit 2fe0a6446eb9aa7eddd11255357daeccd45647b4.

Revert "msm: footswitch-8x60: Update 8064 footswitch_enable() sequence for GFX3D"

This reverts commit 52bfecf2c84e53f19a568cb9349e8973af6405a7.

Change-Id: I28ded61af63482f38eff036c31810a3b660d05f7