ARM: 7486/1: sched_clock: update epoch_cyc on resume

Many clocks that are used to provide sched_clock will reset during
suspend.  If read_sched_clock returns 0 after suspend, sched_clock will
appear to jump forward.  This patch resets cd.epoch_cyc to the current
value of read_sched_clock during resume, which causes sched_clock() just
after suspend to return the same value as sched_clock() just before
suspend.

In addition, during the window where epoch_ns has been updated before
suspend, but epoch_cyc has not been updated after suspend, it is unknown
whether the clock has reset or not, and sched_clock() could return a
bogus value.  Add a suspended flag, and return the pre-suspend epoch_ns
value during this period.

The new behavior is triggered by calling setup_sched_clock_needs_suspend
instead of setup_sched_clock.

Change-Id: I7441ef74dc6802c00eea61f3b8c0a25ac00a724d
Signed-off-by: Colin Cross <ccross@android.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
CRs-Fixed: 497236
Git-commit: 237ec6f2e51d2fc2ff37c7c5f1ccc9264d09c85b
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Srivatsa Vaddagiri <vatsa@codeaurora.org>
ARM: 7565/1: sched: stop sched_clock() during suspend

The scheduler imposes a requirement to sched_clock()
which is to stop the clock during suspend, if we don't
do that any RT thread will be rescheduled in the future
which might cause any sort of problems.

This became an issue on OMAP when we converted omap-i2c.c
to use threaded IRQs, it turned out that depending on how
much time we spent on suspend, the I2C IRQ thread would
end up being rescheduled so far in the future that I2C
transfers would timeout and, because omap_hsmmc depends
on an I2C-connected device to detect if an MMC card is
inserted in the slot, our rootfs would just vanish.

arch/arm/kernel/sched_clock.c already had an optional
implementation (sched_clock_needs_suspend()) which would
handle scheduler's requirement properly, what this patch
does is simply to make that implementation non-optional.

Note that this has the side-effect that printk timings
won't reflect the actual time spent on suspend so other
methods to measure that will have to be used.

This has been tested with beagleboard XM (OMAP3630) and
pandaboard rev A3 (OMAP4430). Suspend to RAM is now working
after this patch.

Thanks to Kevin Hilman for helping out with debugging.

Change-Id: Ie2f9e3b22eb3d1f3806cf8c598f22e2fa1b8651f
Acked-by: Kevin Hilman <khilman@ti.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
CRs-Fixed: 497236
Git-commit: 6a4dae5e138a32b45ca5218cc2b81802f9d378c3
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Srivatsa Vaddagiri <vatsa@codeaurora.org>
ARM: dts: msm: fix wrong command mode panel format.

dsi command packet format has been changed, so revise
command mode dts file accordingly.

Change-Id: I34833c2747eda319c1fd4a0da3f40cb9bf30bbea
Signed-off-by: Ray Zhang <rayzhang@codeaurora.org>
msm: mdss: cleanup dsi interrupt handling logic

Use reference counting for DSI interrupt enable/disable, masking out
DSI_MDP_DONE interrupt.

Change-Id: I83a8136b8bfeeebd2cbb6a8f711b4dd818f49bd2
Signed-off-by: Xiaoming Zhou <zhoux@codeaurora.org>
mdss: dsi_v2: verify return value from dma_cmds_tx

When driver was calling dma_cmds_tx it was not checking the return
value.

Change-Id: Ia8903b71a5162d6290a0c841a7a17409dfdddd43
Signed-off-by: Terence Hampson <thampson@codeaurora.org>
msm: mdss: Add error handling in mdss_fb_no_update_notify_timer_cb

Return in case mfd is NULL to avoid NULL pointer dereference.

CRs-Fixed: 563125
Change-Id: I82415ed5f1f7b3d27796e9e3a0c96178aa54bdc5
Signed-off-by: Jayant Shekhar <jshekhar@codeaurora.org>
msm: mdss: Return suspend without delay in NOTIFY UPDATE

NOTIFY_UPDATE returns Suspend after 4 seconds delay.
Delay would cause HISTOGRAM_STOP ioctl to be called late.

Return suspend case without setting timer for no delay.

Change-Id: I356086de96cab85cd203bf1ad529ecf0b3bbfce3
Signed-off-by: Krishna Chaitanya Parimi <cparimi@codeaurora.org>
mdss: display: Check for non-zero msleep values for LDOs

Change LDO power on/off sequence to check for
non-zero sleep values to prevent input values
of 0 from sleeping for a jiffy.

Change-Id: I66c0ded92e9c76bd43364de701effa96f0d5c9a5
CRs-Fixed: 514628
Signed-off-by: Casey Piper <cpiper@codeaurora.org>
msm: mdss: restructure rotator code and add mutex for rotator api

The rotator data structure should be maintained in the rotator file
and rotator api calls should be following current ioctls, namely,
rotator_setup follows overlay_set, rotator_play follows overlay_play,
and rotator_unset follows overlay_unset. In this way, rotator code is
modulized and data is isolated easily by adding proper locking.

CRs-fixed: 563019
Change-Id: I3aa0db57d65cf9ae88c7e7cbccb3fa73a25e5902
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm: mdss: do proper error handling in case of rotator setup fail

When rotator setup fails, the session should only be finished internally
if it hasn't been reported to userspace. At the same time, need to
ensure that proper cleanup of rotator list is happening, through
internal release path.

Change-Id: I7a6f46261bf8783547de1c7f7fd6893916b25827
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: move rotator SMP reservation to rotator setup

Shared memory pool (SMP) blocks are limited, in some cases where there
are many overlay pipes used, we may not be able to get enough blocks for
rotator sessions. In such cases fall-back solution must be considered,
however for this to happen this would need to be identified during
rotator session setup. Move logic to do pipe resource reservation in
rotator setup if possible.

Change-Id: I223281fb51b81baf852cac415a8c61c0de35c2c4
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: mdss: Fix under run on interlace clip play in landscape

Rotator src rect y co-ordinate is getting odd after de-interlace
calculation but mdss expects even.

Change-Id: I124d059c89c51126208ad1de02a9d34d87b0f553
Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>
msm: kgsl: Sync up to kk_3.5_rb1.15's...

msm: kgsl: Release hang detect performance counters when not in use

If hang detection is disabled via sysfs or ioctl() release the
performance counters that the hang detection uses so the counters
can be available to other consumers.

CRs-fixed: 533729
Change-Id: Ic0dedbad6998bbdab0f088a45c2bbf6e426e232d
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: When switching pagetable use current context ID

When we switch pagetables then the pagetable switch commands
should be executed on behalf of the currect active context and
not the context to which we are switching. This is because
until the pagetable switch occurs the GPU will be using the
pagetable of the active context.

CRs-fixed: 574989
Change-Id: I9ca65ea399e39a158dc72adc2c7b661f62f18c93
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
msm: kgsl: Account for fixed perfcounter groups

Most performance counter groups have general purpose counters that
can be programmed to any number of countable types.  That said
some groups have counters with fixed countables.  When reserving those
groups the countable is equal to the register - so when you ask for
countable 0 in VBIF_PWR for example it is expected that will always
match to a certain register.  Add a flag member to the perfcounter
group and declare PWR and VBIF_PWR as fixed groups and handle them
accordingly in adreno_perfcounter_get() so that the correct register
is returned.

CRs-fixed: 582739
Change-Id: Ic0dedbad271c7472efce5f79e9055b7b3d224d17
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Re-enable performance counters

Commit b80b6c9daf379b3784e68 accidently disabled all performance
counters which caused the fault tolerance to falsely trigger more
often.  Re-enable the performance counters and remove duplicate
code to enable the VBIF registers (they are enabled by the
a3xx_perfcounter_enable function).

CRs-fixed: 581430
Change-Id: Ic0dedbad277e796e6b2e7bd8e938cb8afe03207b
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Restrict the maximum memory entries for bulk cache sync

Restrict the maximum number of memory entries that can be specified
to a single bulk cache sync call to PAGE_SIZE / sizeof(unsigned int)
so that the allocation can always fit within one page.

CRs-fixed: 578062
Change-Id: Ic0dedbad07e1986cd6ccc5b260ffef82b5adb6d3
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: avoid zero length scatterlist allocation

During sglist allocation we calculate sglen as
per below

sglen_alloc = PAGE_ALIGN(size) >> PAGE_SHIFT;

sglen_alloc can be zero if size falls within the
last page. For example, when size = 0xFFFF_FF7B,
PAGE_ALIGN(0xFFFF_FF7B) will be 0, considering
0x1000 (4kb) PAGE_SIZE. if kzalloc() with
zero size, it will return ZERO_SIZE_PTR which is
not NULL and we always do NULL check. Dereferencing
ZERO_SIZE_PTR will lead to a distinct access fault.

Conflicts:
	drivers/gpu/msm/kgsl_sharedmem.h

Change-Id: Ibcc6198438c13b5111be0faa736328db92511597
CRs-Fixed: 563106
Signed-off-by: Prakash Kamliya <pkamliya@codeaurora.org>
msm: kgsl: Don't enable VBIF counters for targets that don't use them

Only targets with separate bus control need the VBIF counters enabled
by default.

Change-Id: I3a7fcedebf7a7cc80bc1bec5a7fd298b49b9b165
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
msm: kgsl: Prevent device start after it is already started

Check if device is already started in high priority workqueue thread,
this check prevents calling device start after it is already started,
thereby avoiding unpredictable behavior.

Change-Id: Iffcd065f8c02746d168c8e5779d10d4b0e2404a9
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>