msm: pm-8x60: Don't save or restore GIC,VFP state in power collapse

Don't save or restore the GIC,VFP registers when entering or exiting power
collapse. The GIC and VFP drivers already register for PM notifications and
do the respective save/restore thereby making these operations redundant in
pm-8x60 driver.

Change-Id: If9969f8052843b2c7c1417dfeceaab203c6453b5
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/pm-8x60.c
spi_qsd: DM mode support for different fifo sizes

SPI driver doesn't support different block size in
DM mode because based on assumption that GSBI tx&rx
FIFOs are of same size. Some GSBI configuration
can have different tx/rx fifo size. Tx/Rx fifo size
is defined based on input/output block size.

Adds support for different rx/tx fifo size in
case of DMA transaction.

CRs-Fixed: 452986
Change-Id: Ie86f487ea97037ed14e9838a3bd52dfe95f56974
Signed-off-by: Alok Chauhan <alokc@codeaurora.org>
spi_qsd: Correction in DMA mode check.

Due to bug in the if() condition msm_use_dm function
is always returning '0' when cs_change is true. Due to
this issue the DMA mode is not bieng used when it has to be.

This patch fixes this issue.

CRs-Fixed: 475841
Change-Id: Ib4d7c4f816c2df71683d0901eb0fab78f441a208
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
spi_qsd: Auto-select nearest lower available clock rate

Specifying max clock frequency for SPI, via platform data, requires
a frequency that is available to SPI. The frequencies that are
available to SPI and the devices max-frequency are specified in
different places and in different files. As a result theses values
can easily go out of sync.
SPI devices typically can operate at some maximum frequency, with
some tolerance for the actual-frequency being lower. SPI users
typically know their target-device's max-speed, but they have
to dig in platform data files to find the best matching frequency
that is available.
This patch lets users specify the device's max-frequency, while the
actual frequency is automatically selected by the driver. The selected
frequency is the same as the requested one, or the nearest lower one.

CRs-Fixed: 467687
Change-Id: I293ec1b66ad56e4a2b4643482917f79dabd7a758
Signed-off-by: Gilad Avidov <gavidov@codeaurora.org>
Signed-off-by: Alok Chauhan <alokc@codeaurora.org>
spi_qsd: Add runtime PM support to SPI QSD driver

Enable and disable the clocks and gpios to the SPI controller
using runtime PM. This serves the dual purpose of reducing power
Consumption a little and letting the core know when the device is idle.

If runtime_pm is not supported, then make sure the device becomes
active in first transaction after system-suspend, instead of
system-resume.

CRs-Fixed: 460988
Change-Id: I2360b6f48491cd0e8e5f1ce54805079daf92e36b
Signed-off-by: Alok Chauhan <alokc@codeaurora.org>
spi_qsd: set device's runtime PM status to 'suspended'

Device's runtime PM status is not in suspended state during
system suspend.

CRs-Fixed: 512718
Change-Id: I5c0cb39c0b91782d8686c1b3da81125169ccf9be
Signed-off-by: Alok Chauhan <alokc@codeaurora.org>
mmc: core: Add sysfs entries for dynamic control of clock scaling

Add sysfs attributes to allow dynamic control of clock scaling
parameters. These attributes are used to enable/disable clock
scaling at runtime and change the up_threshold, down_threshold,
and polling_interval values. Complete documentation for these
sysfs entries are provided at "Documentation/mmc/mmc-dev-attrs.txt".

Change-Id: I4753c75c3b3eeea91e93bceba7af2535b793612e
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
mmc: core: Add support for notifying host driver while scaling clocks

Host drivers can participate in clock scaling by registering
->notify_load host operation, which allows host driver to carry out
platform specific operations for further power savings or increasing
throughput based on whether load is LOW or HIGH respectively. This
can be applicable to non-ultra high speed cards as well so remove
the check for ultra high speed cards to initialize clock scaling.

Change-Id: Icaab9520135e384f5470db68b2f25c5cdce5663a
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>

Conflicts:
	drivers/mmc/core/core.c
mmc: core: run clock scaling only in valid card state

Clock scaling requires the tuning and if the tuning command
is sent to the card in invalid state, tuning procedure will
fail.

With urgent request mechanism implemented, there is a chance
that clock scaling invoked when card is not in a proper state
to receive the tuning command.

This change checks the card state (by sending the status command)
before invoking the clock scaling request.

Change-Id: Icb71a8e74a9afdc70380a5901cd3d28931959e9c
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>

Conflicts:
	drivers/mmc/core/core.c
mmc: sh_mmcif: maximize power saving

This patch uses runtime PM to allow the system to power down the MMC
controller, when the MMC closk is switched off.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Chris Ball <cjb@laptop.org>

Conflicts:
	drivers/mmc/host/sh_mmcif.c
msm: pm: add failed stats

for idle and suspend failed cases the stats
are not updated correctly, they are just added to
success bucket.

This patch is to log the failed stats separately.

Change-Id: I4b290944e3f4b74ada13ef0ba51b812c83b5ec5d
Signed-off-by: Venkat Devarasetty <vdevaras@codeaurora.org>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
msm: pm: send notification only for SPC and PC

Today the pm notification is sent for all the power
modes of each CPU. This is not necessary for shallow
power modes.

This change is to send the notification for only
standalone power collapse for each core and idle
power collapse of core0.

Change-Id: I9b3df3d72e43d645387c94b1b9c5da3bcf2f2e5f
Signed-off-by: Venkat Devarasetty <vdevaras@codeaurora.org>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/cpuidle.c
Revert "msm: pm: Add API to enable/disable retention mode On 8974 targets, retention mode voltage is controlled by the LDO regulator, which in turn is powered through a ganged PMIC regulators. At certain low voltage levels, the ganged PMIC will not be able to power the LDO retention voltage. The regulator framework would invoke this API to enable/disable retention mode in these scenarios."

This reverts commit 6691045d89e2e1297c59ce096c5af595df5ef5fd.

Conflicts:
	arch/arm/mach-msm/pm-8x60.c
msm: pm-8x60: Save and restore the GIC_CPU_CTRL during power collapse

9615 runs in secure mode and has different QGIC settings. Instead of
writing 0x1, read the GIC_CPU_CTRL register before power-collapse and
restore the value during resume.
This makes sure that power-collapse continues to work on all targets.

Change-Id: I094c4605b89559d777587394ff9f479640459e0a
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/pm-8x60.c
msm: pm-8x60: Use relative time for events

There is a bug when adjusting for event wakeups. The adjusted time
is being set in absolute mode incorrectly. Instead just use relative
times.

Without this core wakeups may not happen on time.

CRs-fixed: 486466
Change-Id: If625f25bd573b05befb6e0f922c80db646428b86
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
Signed-off-by: Venkat Devarasetty <vdevaras@codeaurora.org>
Add /dev/frandom
mm/ksm.c: use new hashtable implementation

Switch ksm to use the new hashtable implementation.  This reduces the
amount of generic unrelated code in the ksm module.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Acked-by: Hugh Dickins <hughd@google.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Mel Gorman <mgorman@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Luis Cruz <ljc2491@gmail.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
hashtable: introduce a small and naive hashtable

This hashtable implementation is using hlist buckets to provide a simple
hashtable to prevent it from getting reimplemented all over the kernel.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
block,elevator: use new hashtable implementation

Switch elevator to use the new hashtable implementation. This reduces the
amount of generic unrelated code in the elevator.

This also removes the dymanic allocation of the hash table. The size of the table is
constant so there's no point in paying the price of an extra dereference when accessing
it.

This patch depends on 2f21477058e69a440fb65fb16ddfb1891bac5703 ("hashtable: introduce a small and naive
hashtable") which was merged in v3.6.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
cgroup: use new hashtable implementation

Switch cgroup to use the new hashtable implementation. No functional changes.

Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>