block: prepare I/O context code for BFQ-v5r1 for 3.0

BFQ uses struct cfq_io_context to store its per-process per-device data,
reusing the same code for cic handling of CFQ.  The code is not shared
ATM to minimize the impact of these patches.

This patch introduces a new hlist to each io_context to store all the
cic's allocated by BFQ to allow calling the right destructor on module
unload; the radix tree used for cic lookup needs to be duplicated
because it can contain dead keys inserted by a scheduler and later
retrieved by the other one.

Update the io_context exit and free paths to take care also of
the BFQ cic's.

Change the type of cfqq inside struct cfq_io_context to void *
to use it also for BFQ per-queue data.

A new bfq-specific ioprio_changed field is necessary, too, to avoid
clobbering cfq's one, so switch ioprio_changed to a bitmap, with one
element per scheduler.

Signed-off-by: Paolo Valente <paolo.valente@unimore.it>
Signed-off-by: Arianna Avanzini <avanzini.arianna@gmail.com>
block: cgroups, kconfig, build bits for BFQ-v5r1-3.0

Add a Kconfig option and do the related Makefile changes to compile
the BFQ I/O scheduler.  Also let the cgroups subsystem know about the
BFQ I/O controller.

Signed-off-by: Paolo Valente <paolo.valente@unimore.it>
Signed-off-by: Arianna Avanzini <avanzini.arianna@gmail.com>
block: introduce the BFQ-v5r1 I/O sched for 3.0

Add the BFQ-v5r1 I/O scheduler to 3.0.
The general structure is borrowed from CFQ, as much code. A (bfq_)queue is
associated to each task doing I/O on a device, and each time a scheduling
decision has to be taken a queue is selected and it is served until it expires.

    - Slices are given in the service domain: tasks are assigned budgets,
      measured in number of sectors. Once got the disk, a task must
      however consume its assigned budget within a configurable maximum time
      (by default, the maximum possible value of the budgets is automatically
      computed to comply with this timeout). This allows the desired latency
      vs "throughput boosting" tradeoff to be set.

    - Budgets are scheduled according to a variant of WF2Q+, implemented
      using an augmented rb-tree to take eligibility into account while
      preserving an O(log N) overall complexity.

    - A low-latency tunable is provided; if enabled, both interactive and soft
      real-time applications are guaranteed very low latency.

    - Latency guarantees are preserved also in presence of NCQ.

    - High throughput with flash-based devices, while still preserving
      latency guarantees.

    - Useful features borrowed from CFQ: cooperating-queues merging (with
      some additional optimizations with respect to the original CFQ version),
      static fallback queue for OOM.

    - BFQ supports full hierarchical scheduling, exporting a cgroups
      interface.  Each node has a full scheduler, so each group can
      be assigned its own ioprio and an ioprio_class.

    - If the cgroups interface is used, weights can be explictly assigned,
      otherwise ioprio values are mapped to weights using the relation
      weight = IOPRIO_BE_NR - ioprio.

    - ioprio classes are served in strict priority order, i.e., lower
      priority queues are not served as long as there are higher priority
      queues.  Among queues in the same class the bandwidth is distributed
      in proportion to the weights of each queue. A very thin extra bandwidth
      is however guaranteed to the Idle class, to prevent it from starving.

Signed-off-by: Paolo Valente <paolo.valente@unimore.it>
Signed-off-by: Arianna Avanzini <avanzini.arianna@gmail.com>
msm_fb: Use an exclusive semaphore for Vsync IOCTL

Vsync IOCTL runs in a separate thread context and is independent of the
other display IOCTLs. Right now, we have the same semaphore shared
for Vsync IOCTL along with other IOCTLs. This will cause performance
drop if a Vsync enable/disable IOCTL thread waits to acquire the
semaphore since composition might be happening through Overlay/Blit
IOCTL. Hence, use a different semaphore for the Vsync IOCTL.

Change-Id: I190505740b289b01812b2a46d237854a31d047e8
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
defconfig: enable IOSCHED_BFQ and CGROUP_BFQIO

Change-Id: Iab707533206062461bbefa7b0f9dc76f3ead4542
qup_i2c: Move to new clock APIs

Replace use of clk_enable() and clk_disable() with calls to
clk_prepare_enable() and clk_disable_unprepare(), respectively.

Change-Id: Ib29b5e4340f1a8cbde85efe3d129470788cbf0cd
Signed-off-by: Harini Jayaraman <harinij@codeaurora.org>

Conflicts:
	drivers/i2c/busses/i2c-qup.c
qup_i2c: Enabling CORE_ON_EN bit while disabling the QuPE PCLKs

To disable the GSBI QuPE PCLKs it is important to enable
the CORE_ON_EN bit for some targets like 7x27a.

CRs-Fixed: 302634
Change-Id: I309d7aa0de435b18658e3bb1a879368d06610c5e
Signed-off-by: Trilok Soni <tsoni@codeaurora.org>
qup_i2c: Remove Soc specific check while enabling CORE_ON_EN bit

Enabling of CORE_ON_EN bit in qup_i2c driver is not dependent on soc.
Same code will work for all. Hence remove the SOC specific part from the
function.

CRs-Fixed: 335884
Change-Id: I55054b0c17e1710c1d268322f1a78c42c94b3db8
Signed-off-by: Pankaj Kumar <pakuma@codeaurora.org>
qup_i2c: Use clk_prepare, clk_unprepare APIs correctly.

clk_unprepare cannot be called from timer context since the call may
block.

Change-Id: I7decb011031231046c4f0b822b3f47ed086bd7df
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
i2c: qup: Add Device tree support for Qualcomm I2C controller

Device tree support is added for Qualcomm I2C controller and
documentation is provided for required and optional device-node
properties.
Slave devices can be added using register_board_info (boards file),
or by listing them as child of I2C of_node in the device tree.

Change-Id: I10e9b8c7805c49dfe6a51975129f1599bbca84eb
Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
qup_i2c: Reset QUP before registering for interrupts.

If bootloaders leave a pending interrupt on certain GSBI's,
the driver registers for an interrupt handler during boot up.
The interrupt handler immediately fires because the interrupt was
triggered in the bootloader. The ahb clock is also off at this time,
hence any register writes in the interrupt handler does not go through.
Thus we loop forever in the interrupt handler effectively hanging the
device.

CRs-Fixed: 345805
Change-Id: I5545785142a39f8b78132745e74dfc55a8a5c917
Signed-off-by: Harini Jayaraman <harinij@codeaurora.org>
qup_i2c: Set the clock rate before enabling the clock.

There is a warning during boot up since the driver
enables the QUP clock before setting its rate. Hence,
make sure clock rate is set for applicable targets to
fix warning.

Change-Id: I249d642f5f14c5ff627c00766f9d399f48f55610
Signed-off-by: Harini Jayaraman <harinij@codeaurora.org>
defconfig: enable BFQ I/O scheduler as default

Change-Id: Iceccd52c3fa9eb83119cfd545220af318bf62377