Revert "msm: thermal: add my cleaned up in-kernel driver"

This reverts commit 1a744930237b76e58719faefaec0c646cfe5ea52.
Revert "msm: thermal: fix init with msm_thermal"

This reverts commit e7fbee4cf258ad745d7465f009fa4aced2b5d04a.
msm: thermal: Add support for cpu temp limit recommendation for SoC

Add support in KTM to get SoC parts info by reading appropriate
efuse bits and recommend default cpu temperature limit based on
efuse value temperature map to userspace through sysfs interface
'/sys/module/msm_thermal/default_cpu_temp_limit'. Efuse data
to be read such as address, row number, starting bit number
of the row, number of bits for identifying parts etc, default core
temperature and efuse temperature value map are read from dt.
The default cpu temperature information is exported in the format
<temperature in degree celsius>.

Change-Id: Icbf43c3fd56e95d49a886d309e613d2fe146a506
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
msm: thermal: Add thermal reset feature to KTM

Add support for issuing a thermal reset from msm thermal driver.
The thermal driver is capable of monitoring all the tsens
temperatures and issuing a reset right from the boot.
The reset temperature can be given as input using devicetree.
Failure to do so will disable this feature for the target.

Change-Id: Iaf8f1764d4e4e3abb7e65f1d4397d895d195636d
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
ARM: dts: msm: Enable thermal reset feature for MSM8974

Enable thermal reset feature for MSM8974, where the KTM does
a secure watchdog bite when the temperature of tsens reaches
the preset threshold.

Change-Id: I7f3e576ad7b7e7abef6ece0c64c90d09be180967
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
mdss: Add MDP_SMP_FORCE_ALLOC mdp flag

MDP_SMP_FORCE_ALLOC flag is used to allow SMP
allocations even when there is mismatch between
allocated and requested SMPs for a pipe.
User space can make use of this flag in extreme scenarios
where SMP allocations need to pass like GPU composition
and playback of protected  or secure videos.

Change-Id: I369b4361e7e2bbfc8150add467678c4ef8d5cfb6
Signed-off-by: Justin Philip <jphili@codeaurora.org>
msm: kgsl: Immediately signal a timeline if the timestamp has retired

When creating a new fence immediately signal the timeline if the target
timestamp has already expired and don't create a new GPU event.  This
cuts down on the number of events being fired for already expired
timestamps and removes the brief delay for the event to go out and
immediately come back.

Change-Id: Ic0dedbadc0512977f662bda5fdb4c4d3db7bd51f
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
msm: kgsl: Log correct fence pointer when cmdbatch timer expires

When cmdbatch timer expires, fence address at log entry is incorrect.
Hence sync_fence & kgsl logs don't match for timed out fence pointer.
This is inconvenience to debug fence timeouts. Log correct fence
address if valid.

Change-Id: I7cead43989d5551e9b2d5f6eefb8baacd37bd69b
Signed-off-by: Ananta Kishore K <akollipa@codeaurora.org>
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
sync: Add a "details" callback for sync points

Allow drivers to add a callback for expanded details about a sync
point.  This provides for a much richer debug experience than can
be provided by the simpler callbacks.

Change-Id: Ic0dedbad19fddc2f9b753d886994247e8025d6dc
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
msm: kgsl: Add a sync fence timeout callback

Add a callback to get notification of timeouts on fences
that we own and use that to dump additional information.

Change-Id: Ic0dedbadec6af50cc8c741484a5547ae0ca92a83
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
sync: Only print details for active fences

Only call the pt_log callback for active fences.

CRs-Fixed: 744197
Change-Id: Ic0dedbadf0f5979fc155cdef332fedda9047f440
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
msm: kgsl: log debug info to help detect syncpoint deadlock

Dump sync fence info of a fence for which a KGSL context is waiting
for more than 5 seconds. This info will help detect if there is
a possible gpu syncpoint deadlock.

Change-Id: I53282ce08e716cfdb44ca448f880e84816dc4ded
Signed-off-by: Harshdeep Dhatt <hdhatt@codeaurora.org>
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
msm: kgsl: Prevent recursion when dumping sync fence logs

Attempt to detect recursion in the sync fence logging mechanism
whereby a syncpoint is waiting for a fence that ends up waiting for
the same context that owns the syncpoint.

CRs-Fixed: 744197
Change-Id: Ic0dedbadb4207ad5823f882b20007914bd80c391
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
msm: kgsl: Restrict GPU memory object alignment to 32MB

The code was being very generous in giving the user the ability to
align GPU objects on 4GB boundaries. Cut the restriction down to
32MB which is still pretty generous but within the realm of
possiblity (especially for a 32 bit GPU).  While we are at it fix
a bug in the page_alloc code that was accidently resetting the
alignment to the alloc page size.  The alignment cannot be _less_
than the max page_alloc size but there certainly isn't any reason
why you couldn't specify a larger alignment if you so wished.

Change-Id: Ic0dedbadebd4c6fd98e3bf2f3d6d5bb924223157
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
msm: kgsl: Track the submitted timestamp for a draw context

Track the last timestamp that each draw context has submitted to
the ringbuffer.  This complete the picture for the draw context
dump:

kgsl-3d0: context[13]: queue=165, submit=115, start=101, retire=100

here, timestamp 165-116 are on the queue, 115-102 are on the
ringbuffer, 101 is in the GPU and 100 and older have been retired.
If we get a fence timeout with this data we can easily see where the
fence timestamp is in the pipeline.

Change-Id: Ic0dedbadf54c1714296149af02b6938eef375d50
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
i2c-qup: don't ignore the last byte of a message

Ignoring the last byte of the I2C write message when
the I2C transfer has the multiple messages with
write and read from different slave addresses. This
leads to i2c master pulls the clock line low and
also client misses one byte of data from the
write message.

This patch allows the last byte of the write message
in this particular case also.

Change-Id: I433479e95c5f167dce56d57e5c9ca1c65312ff68
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
msm: kgsl: Fix race in active count wait

Active count is a variable that is mutex protected. When waiting
for this variable the value should be verified with mutex held.

Change-Id: Iee8c43cacd22f05b03a350f3b46b3e5a9fff5c63
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
msm: kgsl: Add syncpoint tracepoints

The point is to add syncpoint tracepoints to trace the point at
which syncpoints are created and expired.

Change-Id: Ic0dedbadb9cd913c2949e9786c84f7517b8e0581
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
msm: kgsl: Save a copy of the fence name for syncpoint events

Android native fences have the annoying habit of disappearing before
we are done querying them. Instead of reaching into the fence struct
to find the name for the fence, copy it off at init time and use that
for our various logging needs.

CRs-fixed: 743080
Change-Id: Ic0dedbad21eddf71d5e8a086eea09c5201660f0a
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Call sync_fence_log only if CONFIG_SYNC is defined

Add a wrapper kgsl_sync_fence_log around sync_fence_log.
This helps get rid of compilation error if CONFIG_SYNC is
not defined.

CRs-Fixed: 748003
Change-Id: I20d9c0e4b449cb2352274b5f4062300d5562bae6
Signed-off-by: Harshdeep Dhatt <hdhatt@codeaurora.org>