gpu: msm: Add new Adreno driver
* Temporary place for this.

sync with upstream

Signed-off-by: jerrylzy <jerrylzy@live.com>
gpu: msm: Add new Adreno driver and sync with upstream
from CM

Signed-off-by: jerrylzy <jerrylzy@live.com>
Add separate kernel memory mapping for GPU shader memory.
Previously, both the register and the shader memory were mapped
as one entity, with the mapping length being equal to combined
size of register memory and shader memory. Now, we separate the
shader memory mapping to help in cases of GPU devices where the
shader and register memory may not be adjacent. This helps to
dump the shader memory in the postmortem snapshot. By having a
separate mapping for shader memory, the snapshot dump routine
simply reads in the shader memory range specified and dumps.

Change-Id: I30e59dffe849fefcfbbaf0e5245cc1024ccedcb1
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>

msm: Fix mem leak when using per-process pages

When GPU is using per process page tables the code creates
a new page table (domain) for every process. There is also
some associated structures allocated to keep track of each
domain. However, when cleaning up the memory used for a page
table only the domain is freed and not the associated structures.

Add a function to allow a client to properly unregister a domain
which will free all the memory associated with a domain.
Call the unregister function from kgsl driver code.

CRs-fixed: 480801
Change-Id: I9704c12c66a95ce66cea63b619bbdbafa0f1eac8
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>

Conflicts:
	arch/arm/mach-msm/iommu_domains.c

msm: kgsl: Remove nap_allowed variable and functionality

Allow NAP on all targets.  The splitting of the clock enable
and disable calls into enable/prepare and disable/unprepare
allows us to safely make this change for all targets.

Change-Id: I03d909b86aef33631a887d159cf0a807a6d0ae75
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>
Signed-off-by: jerrylzy <jerrylzy@live.com>
iommu/core: pass a user-provided token to fault handlers
Sometimes a single IOMMU user may have to deal with several
different IOMMU devices (e.g. remoteproc).

When an IOMMU fault happens, such users have to regain their
context in order to deal with the fault.

Users can't use the private fields of neither the iommu_domain nor
the IOMMU device, because those are already used by the IOMMU core
and low level driver (respectively).

This patch just simply allows users to pass a private token (most
notably their own context pointer) to iommu_set_fault_handler(),
and then makes sure it is provided back to the users whenever
an IOMMU fault happens.

The patch also adopts remoteproc to the new fault handling
interface, but the real functionality using this (recovery of
remote processors) will only be added later in a subsequent patch
set.

Change-Id: Ic04659686e72838a0db518e9303dd037191e3879
Cc: Fernando Guzman Lugo <fernando.lugo@ti.com>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
[ohaugan@codeaurora.org: Resolved compilation and merge issues]
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
Signed-off-by: jerrylzy <jerrylzy@live.com>
msm: copper: Add bus topology data for copper
Add Master/slave data for copper to define the topology for
bus scaling driver

Change-Id: I2c7912f82aabdc1971126bf55cfa642b0c43b597
Signed-off-by: Gagan Mac <gmac@codeaurora.org>
Signed-off-by: jerrylzy <jerrylzy@live.com>
msm: msm_bus: Add device tree support for bus scaling clients
This patch enables clients to specify vectors in device tree
format. Clients will no longer need to specify vectors in
the boards file. Instead, they can add the bus-scaling
related data to their own device-nodes.
The clients can then call an API exposed by the bus driver
which will build the pdata out of those strings.
The registration process using pdata remains unchanged.

Signed-off-by: Gagan Mac <gmac@codeaurora.org>
(cherry picked from commit bf3676d)

Change-Id: Iec994d8949bef9a45a401147c7f2aeebaf748e4f
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: msm_bus: Add support for 64-bit bandwidth requests
With 8974, bandwidth requests are exceeding integer size.
Update ab and ib to ensure values over 4Gbps can be requested.
For 64-bit support, there are four changes in this patch:
Changes in the bus driver structures and functions to
update ab and ib values to uint64.
Updates in client drivers to ensure that the bus APIs
are called with the right types.
Updates to the device-tree. Device-tree nodes don't
provide a clean mechanism to read a combination of u32
and u64 variables within the same property name. So, the
ab and ib values must be specified in kbps instead of
bytes/sec from the device tree. The bus driver function
will convert the ab and ib values read from device-tree
to Mbps.
Change the existing property names to make them consistent
with the convention used by the new property  name, which
abides to the Device Tree convention.

Change-Id: Ib0a6db0e221af366c61c51cc21ac722f02cb7a34
CRs-Fixed: 408786
Signed-off-by: Gagan Mac <gmac@codeaurora.org>
Signed-off-by: Rajeev Kulkarni <krajeev@codeaurora.org>
msm: 8960ab: Correct graphics 3d port representation
The graphics 3d ports need to be separately halted/unhalted.
Facilitate this by mapping to separate external IDs.

Change-Id: I88221ba574267ffcc42d1b30df3c77647df3df8f
Signed-off-by: Gagan Mac <gmac@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
msm: msm_bus: Fix the 64-bit division during interleaving
When interleaving flag is enabled, the bandwidth is divided
between ports. There was an error in the division as the
macro was not correctly updated with the right order of using
bandwidth and port number when 64-bit division function
was used by the bus driver.
Correcting this for fixing the token allocation issues
observed.

CRs-Fixed: 472791
Change-Id: Ie7c7f9557006cbb946eaa9eff4b50771cc60525e
Signed-off-by: Gagan Mac <gmac@codeaurora.org>
msm: msm_bus: Change MDP port interleaved setting
When display driver requests bandwidth on MDP port 0, it was
automatically divided between port 0 and port 1 by the bus driver
as a part of interleaving. Since MDP port 1 was never used,
this did not have any impact.

Now, the display driver needs to use MDP port 1 such that MDP
ports should be able to use the bandwidth non-uniformally.
To enable these ports to use unequal amount of bandwidth,
it is required that bus driver does not divide bandwidth
between port 0 and port 1.
The display team is now responsible for requesting bandwidth
explicitly on both ports.

CRs-Fixed: 474499
Change-Id: I826a4c20a113a32f6d6bcf13f1c6474040f35f46
Signed-off-by: Gagan Mac <gmac@codeaurora.org>
(cherry-pick from Change-Id: I826a4c20a113a32f6d6bcf13f1c6474040f35f46)
msm: msm_bus: Add NULL pointer checks.

Bus driver is crashing due to a NULL pointer
access sent by the client. A few NULL pointer
checks have been added to protect the driver
from invalid/NULL client handle.

CRs-Fixed: 458264
Change-Id: I822ad312ba1a0c0939d97eb92ea53094d408a836
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>
msm: msm_bus: Explicitly clear client requests before removal

Clients can potentially leave non-zero requests before
unregistering. Such requests persist and cause instability
and severe power and performance impact.

Protect the system against such clients by explicitly
clearing the client requests before unregistration

Change-Id: I6a905b097de41af168b5f5048b682ba995b581c2
CRs-Fixed: 407057
Signed-off-by: Gagan Mac <gmac@codeaurora.org>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>
msm: msm_bus: Correct the return value from register-client

On failure, return 0, and not a non-zero value as that can
be interpreted as a valid client ID.

CRs-Fixed: 486328
Change-Id: I7a5b448bc398b4a4792170147a5e5317d25f8b3c
Signed-off-by: Gagan Mac <gmac@codeaurora.org>
Signed-off-by: Alok Chauhan <alokc@codeaurora.org>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
Signed-off-by: poondog <markj338@gmail.com>
msm: msm_bus: Add NULL pointer check
This patch protects the bus driver against clients who try to
update requests without registering the client

Change-Id: Ie740844218dbabe5fca098798c461590aba42e97
CRs-Fixed: 459651
Signed-off-by: Gagan Mac <gmac@codeaurora.org>
mach-msm:bus_config:fix possible missing error check
There is a possibility of msm_bus_board_get_iid returning the error.
ERROR check is required before proceeding with the msm_bus_get_fabric_device

CRs-Fixed: 588802
Change-Id: I1353ed1b2505b117b61b72600e74b5d68d0bc508
Signed-off-by: Swetha Chikkaboraiah <schikk@codeaurora.org>
msm: msm_bus: fix merge derp
Signed-off-by: jerrylzy <jerrylzy@live.com>