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>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
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>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
ARM: 7643/1: sched: correct update_sched_clock()

If we want load epoch_cyc and epoch_ns atomically,
we should update epoch_cyc_copy first of all.
This notify reader that updating is in progress.

If we update epoch_cyc first like as current implementation,
there is subtle error case.
Look at the below example.

<Initial Condition>
cyc = 9
ns = 900
cyc_copy = 9

== CASE 1 ==
<CPU A = reader>           <CPU B = updater>
                           write cyc = 10
read cyc = 10
read ns = 900
                           write ns = 1000
                           write cyc_copy = 10
read cyc_copy = 10

output = (10, 900)

== CASE 2 ==
<CPU A = reader>           <CPU B = updater>
read cyc = 9
                           write cyc = 10
                           write ns = 1000
read ns = 1000
read cyc_copy = 9
                           write cyc_copy = 10
output = (9, 1000)

If atomic read is ensured, output should be (9, 900) or (10, 1000).
But, output in example case are not.

So, change updating sequence in order to correct this problem.

Change-Id: Ia9196dd50a519f516f70c3138233624b669ef96a
Cc: <stable@vger.kernel.org>
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
CRs-Fixed: 497236
Git-commit: 7c4e9ced424be4d36df6a3e3825763e97ee97607
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Srivatsa Vaddagiri <vatsa@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
ARM: sched_clock: Load cycle count after epoch stabilizes

There is a small race between when the cycle count is read from
the hardware and when the epoch stabilizes. Consider this
scenario:

 CPU0                           CPU1
 ----                           ----
 cyc = read_sched_clock()
 cyc_to_sched_clock()
                                 update_sched_clock()
                                  ...
                                  cd.epoch_cyc = cyc;
  epoch_cyc = cd.epoch_cyc;
  ...
  epoch_ns + cyc_to_ns((cyc - epoch_cyc)

The cyc on cpu0 was read before the epoch changed. But we
calculate the nanoseconds based on the new epoch by subtracting
the new epoch from the old cycle count. Since epoch is most likely
larger than the old cycle count we calculate a large number that
will be converted to nanoseconds and added to epoch_ns, causing
time to jump forward too much.

Fix this problem by reading the hardware after the epoch has
stabilized.

Change-Id: I995133b229b2c2fedd5091406d1dc366d8bfff7b
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Git-commit: 336ae1180df5f69b9e0fb6561bec01c5f64361cf
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[sboyd: reworked for file movement kernel/time -> arm/kernel]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
ARM: Fix negative idle stats for offline cpu

We see negative idle stats because of cpu dying without
cleaning up idle entry statistics. When a cpu is offline,
the most immediate thing you'd want to do is just call
into cpu_die() and not waste time calling notifier(IDLE_START).

CRs-Fixed: 414554
Change-Id: Iadc6a3ca39997e0ccf65d2a29b004e24b1b211a1
Signed-off-by: Srivatsa Vaddagiri <vatsa@codeaurora.org>
Signed-off-by: Taniya Das <tdas@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
prima: release v3.2.2.17b

	git://codeaurora.org/external/wlan/prima.git

	4990d1c Wlan: Release 3.2.2.17B
	d6b217f wlan: DTIM3 changed to DTIM1 after roaming
	f83a6cd Wlan: Release 3.2.2.17A
	2f45a43 Fix for "crash in pMac->cfg.gCfgEntry"
	c8faf30 wlan: Change regulatory followed customer request
	82e75bf wlan: Add msecs_to_jiffies() to wake lock argument
	f1bb518 Revert "wlan: Release 3.2.2.18"
	a65fc60 Revert "wlan: Set the country code in cfg before creating channel list."
	d235ff4 Revert "wlan: Release 3.2.2.19"
	2742bc2 Revert "wlan: Decrease SAP timeout from 100 to 10 seconds"
	768b6f5 Revert "wlan: Change RX wakelock to 50 milliseconds"
	4edbdc7 Revert "wlan: Fix for spectrum management bit in AddBss for SM disabled AP"
	2b46b25 Revert "wlan: Release 3.2.2.20"
	0647d89 wlan: Release 3.2.2.20
	e1c76a3 wlan: Fix for spectrum management bit in AddBss for SM disabled AP
	b8493a3 wlan: Change RX wakelock to 50 milliseconds
	476a501 wlan: Decrease SAP timeout from 100 to 10 seconds
	c883f13 wlan: Release 3.2.2.19
	4dbdab2 wlan: Set the country code in cfg before creating channel list.
	7cabdd8 wlan: Release 3.2.2.18

Signed-off-by: Iliyan Malchev <malchev@google.com>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
EHCI: HSIC: Halt the controller while resetting the port

commit 9ecc39cd (EHCI: HSIC: Implement new reset sequence to workaround
PHY lockup issue) does not halt controller before proceeding to reset
sequence.  If the controller is not halted and SOFs are transmitted, PHY
may stuck during port reset.

CRs-Fixed: 459280
Change-Id: I213ca7d41420596b91eb9b5e6803d1e237167136
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
drivers: net: usb: rmnet_usb_data: Modify the autosuspend_delay_time of usb suspend to 2 second.

Avoid the modem suspend/resume frequently.

b/9911201

Change-Id: I0872f894c450b697bb2f0e05fc97c6ed0731b36a
Signed-off-by: yi-hsin_hung <yi-hsin_hung@asus.com>
(cherry picked from commit 3aceb26a7e3f96ce03bc748fa271bb32b979ae87)

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
kgsl: merge changes added on flo to make the alrgorithm a bit smarter.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
msm: thermal: increase the threshold to 70ºC and decrease the threshold delta to 5ºC after the device is throttled.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Merge remote-tracking branch 'upstream/nightlies-4.3-JWR' into sm-4.3-JWR