Commit Graph

642 Commits

Author SHA1 Message Date
Linux Build Service Account e6581a6b58 Merge "msm: limits: Fix out of bound access" 2015-04-30 23:29:22 -07:00
Linux Build Service Account 6c4bc2f1bd Merge "msm: thermal: Fix sensor number printed during thermal WD bite" 2015-04-30 12:50:34 -07:00
Ram Chandrasekar 7d1fbe4693 msm: limits: Fix out of bound access
Out of bound access is reported by kernel address
sanitizer (KASan) tool.

==================================================================
BUG: KASan: out of bounds access in lmh_mon_init_call+0xec/0x180
at addr ffffffc0a297e108
Write of size 8 by task swapper/0/1

===========================================================================
BUG kmalloc-64 (Not tainted): kasan: bad access detected

---------------------------------------------------------------------------

Disabling lock debugging due to kernel taint
INFO: Slab 0xffffffbc0659eec0 objects=64 used=64 fp=0x(null) flags=0x0080
INFO: Object 0xffffffc0a297e100 @offset=256 fp=0xffffffc0a3b87cb0
Bytes b4 ffffffc0a297e0f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Object ffffffc0a297e100: b0 7c b8 a3 c0 ff ff ff 00 00 00 00 00 00 00 00
Object ffffffc0a297e110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Object ffffffc0a297e120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Object ffffffc0a297e130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
CPU: 0 PID: 1 Comm: swapper/0 Tainted: G    B
3.10.49-gef71b0c-00348-g4f06d68-dirty #160
Call trace:
[<ffffffc00040a2d4>] dump_backtrace+0x0/0x1d4
[<ffffffc00040a4b8>] show_stack+0x10/0x1c
[<ffffffc000face70>] dump_stack+0x1c/0x28
[<ffffffc00054d3a0>] print_trailer+0x144/0x158
[<ffffffc00054d6fc>] object_err+0x38/0x4c
[<ffffffc0005523dc>] kasan_report_error+0x228/0x3e4
[<ffffffc0005526a8>] kasan_report+0x68/0x78
[<ffffffc00055173c>] __asan_store8+0x94/0xa0
[<ffffffc00183c0a8>] lmh_mon_init_call+0xe8/0x180
[<ffffffc000400b08>] do_one_initcall+0xcc/0x188
[<ffffffc001800bd0>] kernel_init_freeable+0x1c0/0x264
[<ffffffc000f9f338>] kernel_init+0x10/0xcc
Memory state around the buggy address:
ffffffc0a297e000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffffffc0a297e080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffffffc0a297e100: 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                       ^
ffffffc0a297e180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffffffc0a297e200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Fix out of bound access by allocating the buffer
with right size.

Change-Id: I90d669095030dd80c09d3e69ad3fdfa3f7483b19
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2015-04-29 13:00:22 -06:00
Jeff Bernard f99c4dcb56 msm: thermal: Fix sensor number printed during thermal WD bite
Fix sensor number printed during thermal watchdog bite.
This change adds a lookup table to do a conversion between
sensor id and thermal zone id.

Change-Id: I06939c5707a7b89f7a796f0c524fcc82f833650e
Signed-off-by: Jeff Bernard <jbernard@codeaurora.org>
2015-04-29 02:46:11 -07:00
Ian Maund cd50d4cdb5 Update target name references for 8976
With the official announcement of 8976, remove all references to its
internal code name, and replace them with 8976.

Change-Id: I6d507418e5259908addedf2975e391200b4e0c83
Signed-off-by: Ian Maund <imaund@codeaurora.org>
Signed-off-by: Srinivas Ramana <sramana@codeaurora.org>
2015-04-29 15:07:39 +05:30
Ram Chandrasekar debc5cbbf6 msm: thermal: Retry on failure to hotplug
Add support in thermal driver to retry hotplug
request on failure to fulfill the request.

This retrying will be disabled when the device
enters suspend and will resume after the device
exits from suspend.

Change-Id: I9e2c305754465eb458566c0224804c5ad4bda240
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2015-04-28 10:42:18 -06:00
Ram Chandrasekar 7a412027b3 msm: thermal: Retry hotplug when exiting from suspend
Update thermal driver to retry hotplug, when
device exits from suspend. This will ensure that
any failure to offline/online the cores during
suspend will be re-applied, when device exits
suspend.

CRs-Fixed: 823919
Change-Id: Ifc25ad61288d88f984b18fe51b9dd5776f650cf5
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2015-04-28 10:41:30 -06:00
Shiju Mathew 5c90e88bcb msm: thermal: Update scm calls in KTM with non-atomic calls
Update KTM to use scm_call() and scm_call2()instead
of scm_call_atomic1() and scm_call2_atomic()
respectively to avoid possible race condition.

CRs-fixed: 734431
Change-Id: Ibb81c4c15a47d1f66ffa38cb65481e3c48fcb065
Signed-off-by: Shiju Mathew <shijum@codeaurora.org>
2015-04-28 10:40:24 -04:00
Manaf Meethalavalappu Pallikunhi f2d6c3cae3 msm: thermal: Fix KTM code to check psm is enabled before handling it
During boot up polling mode mitigation, KTM handles psm code even if
feature is disabled. Add a check in psm code whether feature is enabled
or not before handling this.

Change-Id: I55d6ed43e829dbf8a35cf8af4a3ca28cfb10c013
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
2015-04-14 10:25:42 -07:00
Chunmei Cai 9994d296b5 thermal: qpnp-adc-tm: add new scale function for skue battery thermistor
The skue is using the different battery thermistor and mapping table
from the default. A new scale function is needed to use this mapping
table in the thermal adc driver.

Change-Id: Ib154bafe821ceae33803efced3c15321a39f1dad
Signed-off-by: Chunmei Cai <ccai@codeaurora.org>
2015-04-09 18:50:00 -07:00
Linux Build Service Account c820809375 Merge "msm: lmh_lite: check intensity value before enabling interrupt" 2015-03-25 11:29:29 -07:00
Ram Chandrasekar 0a744ea6e7 msm: lmh_lite: check intensity value before enabling interrupt
Update the driver to check the last read intensity
value for all sensors before enabling the interrupt.
Also clear the last read value before getting the
intensity value from trustzone. This will cover the
cases, where the trustzone read errored out.

Change-Id: Iac22078c0ba92704e2448670248e99880e133d08
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2015-03-23 12:20:22 -06:00
Linux Build Service Account c25131573e Merge "msm: thermal: Limit the emergency mitigation messages" 2015-03-16 12:30:40 -07:00
Linux Build Service Account 465ddd9a99 Merge "msm: lmh_lite: Don't assume phys addresses can't exceed 4GB" 2015-03-14 00:59:36 -07:00
Linux Build Service Account 987ef8f64d Merge "thermal: tsens: Update TSENS fuse map for 8939 3.0" 2015-03-14 00:59:24 -07:00
Jeff Bernard a9f04bce3a msm: thermal: disable trim error when missing lmh-trim-err-offset dt
Interpret missing devicetree property lmh-trim-err-offset as
there being no trim error.Some asics have no trim error.

Change-Id: I6760184b74b0dd8ace6220675eac8034ff8151c0
Signed-off-by: Jeff Bernard <jbernard@codeaurora.org>
[imaund@codeaurora.org: Resolved context conflicts]
Signed-off-by: Ian Maund <imaund@codeaurora.org>
2015-03-11 13:17:46 -07:00
Jeff Bernard dcf160ae33 msm: thermal: Add scaling factor for thermal sensors
Add a scale factor to scale the temperature and
set points for asics that have a different thermal
sensor accuracy.

On MSM Thulium temperature sensors report in deci degree
C while previous asics report in degree C. KTM expects
the temperature in C.

Change-Id: I1a94652de48e1fb69164dfc63764a346333ca849
Signed-off-by: Jeff Bernard <jbernard@codeaurora.org>
[imaund@codeaurora.org: Resolved context conflicts, updated
  instances of hi_temp to high_temp]
Signed-off-by: Ian Maund <imaund@codeaurora.org>
2015-03-11 13:17:43 -07:00
Vikram Mulukutla 4aecfc85b2 msm: lmh_lite: Don't assume phys addresses can't exceed 4GB
Virtual and physical memory allocators may return buffers
that are at physical addresses higher than 4GB. When
passing addresses to TZ, don't assume otherwise. Fix the
code to not truncate down to 32 bits (the assignment operation
u64 = u32 = u64 truncates down 64 bit addresses to 32 bits)
unnecessarily; perform the assignment in two discrete steps
to allow the desc.args[X] field to store the full 64 bit
address.

Change-Id: I209b272fc47c91f3dec5ea9ab631fdb1d8c81fb9
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
2015-03-11 01:49:59 -07:00
Ram Chandrasekar 3569f9be0f msm: thermal: Limit the emergency mitigation messages
Thermal can set tsens threshold even if the threshold
value is equal to the current temperature. This will
trigger a tsens notification immediately, which will
print a kernel message. If the temperature stays in
the current value then the emergency mitigation
messages will flood the kernel logs.

Use rate limit feature in printk to reduce the amount
of messages printed from thermal.

CRs-Fixed: 803110
Change-Id: I8fa62ac73421a80658e3696577c0086a27c1102a
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2015-03-10 12:52:05 -06:00
Linux Build Service Account d1ab509541 Merge "msm: thermal: Use phandle to input the cluster cpu map" 2015-03-09 17:16:19 -07:00
Linux Build Service Account 8ba77ee944 Merge "msm: limits: Bypass sensor poll disable if sensor throttling" 2015-03-07 13:43:12 -08:00
Linux Build Service Account b37c4d0291 Merge "msm: lmh_lite: Return error on disabling a throttling sensor" 2015-03-07 13:43:12 -08:00
Linux Build Service Account 901e1d2d2a Merge "thermal: tsens: Update msmterbium TSENS type" 2015-03-06 23:41:58 -08:00
Linux Build Service Account 47bde582ca Merge "msm: thermal: Use CPU phandles instead of cpu mask in KTM" 2015-03-06 19:29:53 -08:00
Linux Build Service Account 5824f8ce10 Merge "msm: limits: Clean up SUPPLY_LM driver" 2015-03-06 06:46:25 -08:00
Rama Krishna Phani A 9005cf3874 thermal: tsens: Update msmterbium TSENS type
Update the msmterbium TSENS type to read the on die temperature from
supported sensors.

Change-Id: I212b987d8cc709da57b3e0ff738be2e1e4b933c7
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
2015-03-05 10:12:03 +05:30
Manaf Meethalavalappu Pallikunhi d4ca5209af msm: thermal: Use CPU phandles instead of cpu mask in KTM
Use CPU phandles to map the physical cores to the corresponding
logical cores for all cpu mask related nodes in KTM. This will
ensure KTM will mitigate even if a CPU is removed or the physical
to logical core mapping is altered.

Change-Id: Ic225c5079aca301cdaf85fa568c3d7329b9f1f63
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
2015-03-04 23:35:57 +05:30
Ram Chandrasekar d428d4b331 msm: thermal: Use phandle to input the cluster cpu map
Modify to use cpu phandles to input cluster and
cpu mapping.

Use of static bit-mask wont work well with removing
cpus during run time. With the new implementation, KTM
using phandles, will try to map the physical cores to
the corresponding logical cores to establish the cluster
cpu mask.

Change-Id: Id1fa76be35c2c70bf0d98408bd3ae5fc4c108cbd
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2015-03-04 10:33:03 -07:00
Rama Krishna Phani A 6432a962ce thermal: tsens: Update TSENS fuse map for 8939 3.0
Update the msm8939 fuse map to accommodate the new TSENS
fuse bit allocations.

Change-Id: I1f19a216bb13f3b38be514c4abec478d6d045415
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
2015-03-04 17:19:52 +05:30
Maulik Shah 15016e06ea tsens: add support for generic sensor calibration.
Add support to parse calibration data from devicetree
and also add generic sensor calibration function.

Change-Id: I8e89813c7c37bc52a06d4cf59eeff62c83a6dd88
Signed-off-by: Maulik Shah <mkshah@codeaurora.org>
2015-03-04 09:35:40 +05:30
Ram Chandrasekar 8d9bfa52f7 msm: limits: Bypass sensor poll disable if sensor throttling
Fix concurrency issues when a read and new throttling
intensity value updation happens simultaneously.

Added a new return value in interrupt reset API to notify
the caller that the particular sensor is still throttling.
On receiving this error, the lmh interface driver should
not reset interrupt but try again to read the throttling
intensity value later.

Change-Id: I883e4c6b9438ff73d9451acc897b623db9c677cf
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2015-03-03 11:58:48 -07:00
Ram Chandrasekar 5b4bf97071 msm: lmh_lite: Return error on disabling a throttling sensor
Return error when sensor polling is disabled when
it is still throttling. This case can occur due
to a race condition between the sensor value read
and sensor throttling value update.

Change-Id: I1e9a9fa97e0e4221752208cf139df05d6eedccbf
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2015-03-03 11:58:39 -07:00
Linux Build Service Account a4e7b63ddf Merge "hwmon: qpnp-adc: Add support to vote for a regulator" 2015-03-01 12:39:15 -08:00
Linux Build Service Account 97ffc324e8 Merge "msm: thermal: Update thermal to mitigate during shutdown" 2015-02-28 17:17:18 -08:00
Manaf Meethalavalappu Pallikunhi 7a12df1f73 msm: limits: Clean up SUPPLY_LM driver
Fix NULL pointer dereference and possible array over flow
scenarios in SUPPLY_LM driver.

Change-Id: Id895ee97d0c45eb7f3e1e8017dfe6c399dbd76e8
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
2015-02-27 20:29:41 +05:30
Siddartha Mohanadoss 994647d879 hwmon: qpnp-adc: Add support to vote for a regulator
Add support to vote for HKADC LDO and HKADC LDO ok signal
if needed.

Change-Id: I92dcb8bf0495e93a8eaedabfbd82c3cc9a527f7c
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2015-02-26 19:24:06 -08:00
Maulik Shah cb61689771 thermal: tsens: Rename tsens driver.
Remove reference to target number and rename the driver to a generic name.

Change-Id: I135b4d0fad0416ceb14bb21134964f1413f5b810
Signed-off-by: Maulik Shah <mkshah@codeaurora.org>
2015-02-26 10:08:16 +05:30
Ram Chandrasekar b62ce23928 msm: thermal: Update thermal to mitigate during shutdown
Existing thermal driver can mitigate the CPUs during
reboot scenario. Extend this feature to support CPU
shutdown and halt scenarios.

Change-Id: I40fa8960ed54b36409836a615dd04d7a829a278c
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2015-02-25 18:52:24 -07:00
Linux Build Service Account b8b04d2d56 Merge "ARM: dts: msm: Rename msmtellurium to msm8952" 2015-02-25 08:40:35 -08:00
Linux Build Service Account d303a3ac2a Merge "msm: thermal: Optimize locking in thermal frequency mitigation thread" 2015-02-25 02:50:35 -08:00
Linux Build Service Account b4e34256e0 Merge "thermal: tsens: Add support for fsm9010 target" 2015-02-25 02:50:31 -08:00
Kaushal Kumar 991d26fd41 ARM: dts: msm: Rename msmtellurium to msm8952
Introduce msm8952 as the official name for msmtellurium.

Change-Id: Iad17e670df9107d5d2ba144fd90f2dac9e476fce
Signed-off-by: Kaushal Kumar <kaushalk@codeaurora.org>
2015-02-25 13:11:49 +05:30
Linux Build Service Account eef5906c05 Merge "thermal: tsens: Add MTC support for sensors" 2015-02-24 14:24:26 -08:00
Rama Krishna Phani A 125c1672f3 thermal: tsens: Add MTC support for sensors
Multi-Zone Temperature Control (MTC) provides an interface to
clients to enable or disable thresholds for supported zone of sensors
and to get log of recent commands.

Change-Id: Idb4d2725241f5b95a93bbe9c6969067f68a6bc6d
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
2015-02-24 10:54:34 +05:30
Venkatesh Yadav Abbarapu ec31c366da thermal: tsens: Add support for fsm9010 target
Add the calibration masks used to abstract the fuse
data needed to obtain the offsets for each of the sensors.
The offsets are used in the temperature calculations.
The temperature sensors (TSENS) provides an interface
to clients to read temperature and set temperature
thresholds.

Change-Id: Ie8e0b93eb45a2235aac9d539ca5f37c505336a2a
Acked-by: Jim Granitzki <jamesg@qti.qualcomm.com>
Signed-off-by: Venkatesh Yadav Abbarapu <quicvenkat@codeaurora.org>
2015-02-23 22:00:57 -05:00
Manaf Meethalavalappu Pallikunhi 8606a159b3 msm: thermal: Revert devm_kzalloc to kzalloc in sensor manager APIs
Sensor manager APIs uses devm_kzalloc to allocate memory for
thresholds. If probe is deferred, device related memory releases.
Later during re-probe, driver doesn't re-initialize all thresholds
which was successsful during first probe, which causes unexpected
values in previously initialized thresholds. Revert devm_kzalloc and
devm_kfree to kzalloc and kfree respectively in sensor manager APIs.

Change-Id: If1f39274e97c201d542b02fd501dbf60fac87de9
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
2015-02-22 00:11:02 +05:30
bait_dispatcher_monitor_system ae7c8ae2ea Merge "msm: limits: Remove devices init and de-init from probe of supply lm" 2015-02-20 09:04:25 -08:00
bait_dispatcher_monitor_system 80759ae40b Merge "msm: thermal: Fix potential memory leak in sensor manager API in KTM" 2015-02-20 09:04:24 -08:00
Linux Build Service Account 987db4bf1a Merge "thermal: tsens: Update msmtellurium TSENS fuse map" 2015-02-18 15:12:38 -08:00
Rama Krishna Phani A c8e358a914 thermal: tsens: Update msmtellurium TSENS fuse map
Update the msmtellurium fuse map to accommodate the
new TSENS fuse bit allocations.

Change-Id: I47758792ec146e47e7ada9e4af3d27ec9e2888bc
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
2015-02-17 11:29:40 +05:30
Manaf Meethalavalappu Pallikunhi accb100193 msm: limits: Remove devices init and de-init from probe of supply lm
Remove supply lm devices init and de-init from probe function.
Devices initialization happens only when user requests to enable it.
Cleanup driver code in the error path to avoid any unexpected
behaviour.

Change-Id: Id43a9118173d3cd192b6b91e2cb33fc34e2b0126
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
2015-02-16 23:24:32 +05:30
Manaf Meethalavalappu Pallikunhi b94c6d6f87 msm: thermal: Fix potential memory leak in sensor manager API in KTM
Cancel sensor trip for both high and low thresholds and fix memory
leak in sensor_mgr_remove_threshold API. Modify sensor manager APIs
to use client device to allocate/release memory for thresholds
using devm_kzalloc and devm_kfree.

Change-Id: Icf3b0253d72441e192be5f87c04bdf94799bb036
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
2015-02-16 16:56:24 +05:30
Rama Krishna Phani A 3634896bdf thermal: tsens: Add fuse-based correction factors
Additional per-sensor offets are being observed after factory
calibration.

Fuse-based correction factors are implemented to the existing 30 / 120
deg C calibration fuses

CRs-Fixed: 782238
Change-Id: Ib70e074782ae38ee164afcaa27d5868d87075457
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
2015-02-12 13:48:54 +05:30
Shiju Mathew cab83adb0a msm: thermal: Optimize locking in thermal frequency mitigation thread
Optimize locking in thermal frequency mitigation thread
to reduce lock contention with hotplug mitigation thread.
This lock is not explicitly required since the cpu driver
already have a per cluster lock down the freqency mitigation
call path. This would be much optimized since the new changes
will hold the lock for a shorter period and unlike previously
where the lock was for entire cluster, this is per cluster
lock that will further reduce lock contention. This would
help thermal to do mitigation faster.

Change-Id: I192efa77df8ad9b128759f31300d4a64a558cc16
Signed-off-by: Shiju Mathew <shijum@codeaurora.org>
2015-01-29 18:02:02 -08:00
Manaf Meethalavalappu Pallikunhi 2b81902ec5 msm: limits: Add S1 supply current limiting driver for MSM8909
This driver is a current limit management module to help manage
instantaneous peak current drawn by multiple subsystems on shared
supply. The inputs to the mitigation algorithm are current states
of different subsystems sharing this supply like cpu frequency,
gpu frequency, number of cores online, soc temperature, core leakage,
and modem state. It throttles cpu frequency and limits number of
online cores to reduce the dynamic current so as to keep the total
current drawn from supply in safe limits.

Change-Id: I4592b8be48bad3709e8cfb09da53f23279a8ff9b
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
2015-01-29 06:58:48 -08:00
Manaf Meethalavalappu Pallikunhi 040309ee4e msm: thermal: Add support for device manager in KTM
Add support for device manager framework to KTM. Device manager allows
for aggregation of muliple kernel clients request on mitigation
devices. Clients can set and register for device change notifications.
Currently it supports hotplug device and cpuX (X= 0... NR_CPUS - 1)
devices.

Device manager framework exports below 3 APIs for a device for
clients to use.

1. struct device_clnt_data *devmgr_register_mitigation_client(
                        struct device *dev,
                        const char *device_name,
                        void (*callback)(struct device_clnt_data *,
                                union device_request *, void *))

API to register mitigation device. This API returns handle, which
should be used by clients when placing mitigation request.
It supports to register for device change notification with callback
as an optional parameter to client.

@dev: Client device structure.
@device_name: Mitgation device name which the client is interested
              to mitigate.
@callback: Optional callback pointer for device change notification,
           otherwise pass NULL.

Returns client handle structure for that device on success, or NULL
with IS_ERR() condition containing error number.

2. int devmgr_client_request_mitigation(struct device_clnt_data *clnt,
                                enum device_req_type type,
                                union device_request *req);

API for clients to set valid mitigation for a registered device.

@clnt: Client handle for device.
@type: Type of device request populated above.
@req:  Valid mitigation request.

Returns zero on successful mitigation update or
negative error number.

3. void devmgr_unregister_mitigation_client(
                                struct device *dev,
                                struct device_clnt_data *clnt)

API for clients to unregister for a device whenever it is done with
device.

@dev: Client device structure.
@clnt: Client handle for device.

Change-Id: Ieda99577a035a32b745df6b004b5487a55ec70ac
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
2015-01-28 03:54:18 +05:30
Manaf Meethalavalappu Pallikunhi 3f439d9e2a msm: thermal: Add support for sensor manager in KTM
Add and export sensor manager framework APIs for kernel clients
who are interested in thermal sensors. Sensor manager allows
multiple clients to set and get notification for a threshold.
Clients can also use multiple sensors to trigger a single
mitigation action.

Below are main sensor manager APIs to monitor sensor thresholds.

1.int sensor_mgr_init_threshold(struct threshold_info *thresh_inp,
			int sensor_id, int32_t high_temp,
			int32_t low_temp,
			void (*callback)(struct therm_threshold *))

API to initialize thresholds data structure for sensor(s) with high
and low thresholds and threshold callback.
@thresh_inp: Client threshold data structure.
@sensor_id: Sensor h/w ID to be monitored. Use MONITOR_ALL_TSENS to
            monitor all temperature sensor.
@high_temp: Trigger threshold value for sensor_id or all sensors.
@low_temp: Clear threshold value for sensor_id or all sensors.
@callback: Callback pointer for threshold notification.

Returns zero on success, negative error number on failure.

2.int sensor_mgr_set_threshold(uint32_t zone_id,
			struct sensor_threshold *threshold)

It sets thermal threshold trips for a sensor.
@zone_id: Thermal zone id for the sensor.
@threshold: Threshold info for the sensor.

Returns which threshold is set on success, negative error number
on failure. MACRO IS_HI_THRESHOLD_SET/IS_LOW_THRESHOLD_SET can be
used to decipher which threshold being set.

3.int sensor_mgr_convert_id_and_set_threshold(
			struct threshold_info *thresh_inp)

It accepts sensor HW id, converts it to sensor zone id and sets
thermal threshold for those sensors listed in threshold info.
@thresh_inp: Client threshold data structure.

Returns zero on success, negative error number on failure.

4.void sensor_mgr_remove_threshold(struct threshold_info *thresh_inp)

It cancels threshold notification and removes threshold from sensor
manager threshold list.
@thresh_inp: Threshold info which needs to be removed.

Change-Id: I916104bde472bd9b45bdb66d81b09cd850e11fba
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
2015-01-28 03:54:18 +05:30
Ram Chandrasekar b919b7cebf msm: lmh_lite: Add ftraces for LMH Lite events
Add LMH Lite ftraces for the LMH Lite event.
Ftraces are added to events like,
1. SCM call entry and exit
2. Trim error event
3. LMH interrupt trigger and clear event
4. LMH sensor interrupt event with intensity value
5. LMH sensor intensity reading

Change-Id: I2bc0c31fab751f0ee23b52e7d978a90d20a0eea1
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2015-01-23 13:20:01 -07:00
Ram Chandrasekar dba65ba8dc Revert "thermal-core: Add a lock to tz_notify_trip()"
This reverts commit 383ac33a1e.

The temperature sensor drivers registering with thermal
core framework can call the thermal_sensor_trip() API in
interrupt context. This might cause potential thermal
reset issues because the interrupt might be disabled till
this API returns.

Change-Id: I8d6dfc55386fbdea8e51e7abbb0e7632208c6c38
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2015-01-07 14:43:15 -07:00
Linux Build Service Account ff56aaf1dc Merge "thermal-core: Add separate threads for sysfs notify" 2015-01-06 07:30:04 -08:00
Shiju Mathew 283ab050ef thermal-core: Add separate threads for sysfs notify
Add separate threads for sysfs notify. This is required
so that any thermal trip is not blocked while handling
sysfs notify.

Change-Id: Ifee206c29fd1b3c226a342b7f048250d5062397e
Signed-off-by: Shiju Mathew <shijum@codeaurora.org>
2015-01-05 23:58:08 -05:00
Linux Build Service Account 3f0e8c4f34 Merge "msm: thermal: Add RT priority to kernel hotplug thread" 2015-01-05 02:51:13 -08:00
Shiju Mathew 0c0790a25e msm: thermal: Add RT priority to kernel hotplug thread
Add RT priority to KTM hotplug mitigation thread. This
is required since we have seen cases where the thread
is not scheduled fast enough during high temperature rampup
that lead to thermal runaway. So this change would make sure
the thermal hotplug mitigation thread gets high priority
and mitigate core as soon as a temperature threshold is triggered.

Change-Id: I72ecf69ede0444fe74fd9c4eaf40a12e8734326c
Signed-off-by: Shiju Mathew <shijum@codeaurora.org>
2015-01-04 22:05:17 -05:00
Siddartha Mohanadoss 4f8a6417fb thermal: tsens: Update interrupt handling to threaded irq
Update registering the TSENS IRQ with request_threaded_irq()
instead of request_irq() to execute checking for the sensors
threshold. This is done to run with SCHED_FIFO and MAX_RT_PRIO/2
by default which request_threaded_irq() provides on the
threaded function to improve the response to notify clients
for temperature threshold crossing. Use the IRQF_ONESHOT flag
while registering the interrupt to keep the irq line at the
interrupt controller disabled until the threaded handler has been run.

Change-Id: I9dec7a21719a0a6a6f0bcbac3221b4a4bfdca322
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2014-12-29 14:02:21 -08:00
Linux Build Service Account 1ca2dbf70f Merge "thermal: tsens_debug: Add tsens debug" 2014-12-24 14:53:44 -08:00
Linux Build Service Account 1dd4f7d380 Merge "msm: thermal: Restore hotplug cores started outside of thermal driver" 2014-12-24 14:53:27 -08:00
Jeff Bernard b3293c81f2 msm: thermal: Restore hotplug cores started outside of thermal driver
Track cores onlined by system prior to registering for cpu notifier
callbacks by copying cpu online mask. Use core up and down notfiers to
track cores being previously online when registered via cpu notifier.
Cores enabled by thermal driver to read cpu freq table are not counted
as previously enabled unless they were enabled by some external driver
and this was previously detected by the methods described earlier.

CRs-fixed: 772172
Change-Id: I7f3a53544d336d44644ad00ac1728f5a89b9e056
Signed-off-by: Jeff Bernard <jbernard@codeaurora.org>
2014-12-23 16:21:16 -05:00
Linux Build Service Account cfe199ab9e Merge "thermal-core: Re-program the thresholds every time" 2014-12-23 05:57:52 -08:00
Linux Build Service Account 3be793c5b3 Merge "thermal-core: Add a lock to tz_notify_trip()" 2014-12-23 05:57:51 -08:00
Jeff Bernard 213fdf23a4 thermal-core: Re-program the thresholds every time
Program the thresholds every time regardless so we guarantee
the threshold is programmed.  Previous code didn't reprogram
the threshold if it was already believed to be set.  This
check can be wrong is some cornor cases.

Change-Id: Ie94cb40302c585b2b779da57ad70d32cc2445c96
Signed-off-by: Jeff Bernard <jbernard@codeaurora.org>
2014-12-22 18:14:34 -05:00
Jeff Bernard 383ac33a1e thermal-core: Add a lock to tz_notify_trip()
Lock the sensor threshold list during notifications so it
isn't updated until notifications are sent out nor can
something else update thresholds until all notifications
are sent out.

Change-Id: Iafce75fa7fceda3de867044861e4a2e3eef47c95
Signed-off-by: Jeff Bernard <jbernard@codeaurora.org>
2014-12-22 18:08:25 -05:00
Shiju Mathew 36cccd7d78 msm: thermal: Intimate EA driver about core frequency mitigation
Add support in KTM driver to intimate EA driver
the current status of core frequency mitigation.
This is required for scheduler to optimize core
migration.

Change-Id: I6f5c3f7a7fe8656d6c6185ce23bce232c129c3c4
Signed-off-by: Shiju Mathew <shijum@codeaurora.org>
2014-12-17 10:58:13 -07:00
Siddartha Mohanadoss 2c7ed23c85 thermal: tsens_debug: Add tsens debug
-Add debug count to the ISR and workqueue patch with timestamp.
-Log the last 10 samples of temperature read for each sensor.

Change-Id: Icc2e3809460eb382bbc1e6b2549706b9b21f9994
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2014-12-12 14:16:03 -08:00
Linux Build Service Account cb884872a7 Merge "thermal: tsens: Fix TSENS Upper/Lower IRQ type" 2014-12-12 08:49:14 -08:00
Linux Build Service Account 28bfeab487 Merge "msm: lmh_lite: Fix issue with LMh lite sensor read failure" 2014-12-09 20:44:53 -08:00
Siddartha Mohanadoss d7566613c4 thermal: tsens: Fix TSENS Upper/Lower IRQ type
Update TSENS IRQ to level trigger instead of using
edge trigger interrupt.

When a sensors temperature threshold is crossed the
controller asserts a level trigger. This level goes
low when the Upper/Lower status threshold is masked.
However, if another sensor threshold is crossed while we
are in the middle of servicing the previous sensors
threshold crossing in the workqueue the new sensors
threshold crossing will be missed as the interrupt level
remains high. Fix it by registering the interrupt as a
level interrupt, disable the interrupt in the
handler and enable it while we exit from the workqueue.

CRs-Fixed: 768227
Change-Id: I7b3f38afd8acb2903f85dcc23e1bfe70d7d9059a
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2014-12-09 16:48:18 -08:00
Shiju Mathew 996953c1c1 msm: lmh_lite: Fix issue with LMh lite sensor read failure
This patch fix failure to read LMh lite sensor from
TZ caused by out-of-order access. The change will
make the memory strongly ordered.

Change-Id: I868165ace6cd28010eb8d274d08a4b241535e3d2
Signed-off-by: Shiju Mathew <shijum@codeaurora.org>
2014-12-08 18:34:45 -05:00
Linux Build Service Account 1ec2c754aa Merge "msm: lmh_lite: Add memory barrier before reading data from trustzone" 2014-12-08 13:08:05 -08:00
Siddartha Mohanadoss e208a35185 thermal: tsens: Update fuse map and physical sensor mapping
MSM8992 has 13 sensors. Update the fusemap and physical
sensor mapping to accomodate change to read the corresponding
sensors offset for temperature calculation.

Change-Id: Ibd42d37d378762614f2b2840a6799b7ca2f20594
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
2014-12-04 15:53:04 -08:00
Linux Build Service Account 73843ecb64 Merge "msm: thermal: Update cluster info only if sync cluster DT is defined" 2014-12-02 17:40:34 -08:00
Manaf Meethalavalappu Pallikunhi 22538e39e3 msm: thermal: Update cluster info only if sync cluster DT is defined
KTM checks cpu topology info for all targets irrespective of
cluster or non cluster targets which will leads unexpected behaviour
for non cluster targets. Configure cluster related info only if
"qcom,synchronous-cluster-id" DT node is defined.

Change-Id: Icb460c40f9d3d1733aabe635f0f42bbedad17a81
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
2014-12-01 23:03:41 +05:30
Linux Build Service Account 980ffe1a77 Merge "msm: thermal: Add RT priority to kernel thermal threads" 2014-11-27 18:29:03 -08:00
Linux Build Service Account 179f2f6f9c Merge "msm: thermal: Add reboot notify callback in KTM" 2014-11-27 18:29:02 -08:00
Ram Chandrasekar 94c6e23581 thermal_core: Add sysfs notification support for userspace
Add support to notify the userspace through sysfs
notification when a userspace threshold is crossed.

Change-Id: Ifdea7f15f288d1dca5365aedad16d1bdbc80be6c
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2014-11-26 14:01:59 -08:00
Ram Chandrasekar 27bcfc79c4 thermal: tsens: Remove sysfs notification
Remove sysfs notification from tsens driver. Thermal core
framework will be the right place to determine the
userspace threshold trip and do a sysfs notify.

Change-Id: I14be7a01074ce4e9f6d309424115cbebd2e2b6cf
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2014-11-26 13:52:13 -08:00
Joonwoo Park 4944cd99d2 mdm9640: rename msmzirc to mdm9640
Introduce mdm9640 as the official name for msmzirc.

Update msm-tsens and clock-a7 bindings to make checkpatch happy along with
renaming.

Change-Id: I364cc0feab4cf4a1bac03dc08eec0214e09f40f7
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
2014-11-24 18:27:32 -08:00
Shiju Mathew 46e2d96854 msm: thermal: Add RT priority to kernel thermal threads
Add RT priority to KTM frequency mitigation thread. This
is required since we have seen cases where this thread
is not scheduled fast enough during high temperature rampup
that lead to thermal runaway. So this change would make sure
the thermal frequency mitigation thread gets high priority
and mitigate core as soon as a temperature threshold is triggered.

Change-Id: Ie8a6fd80fb8e9bdb894a26a8bf7abd159a3f3bce
Signed-off-by: Shiju Mathew <shijum@codeaurora.org>
2014-11-22 06:22:05 -08:00
Shiju Mathew d69df5a4d4 msm: thermal: Add reboot notify callback in KTM
Add reboot notify in KTM to do mitigation actions during
reboot. This would prevent from triggering PS_HOLD resets.
Currently the callback does core frequency mitigation to
minimum frequency support by a core.

Change-Id: I3294e60107d4f120f608fb8af7a6648e310e89a1
Signed-off-by: Shiju Mathew <shijum@codeaurora.org>
2014-11-22 06:21:56 -08:00
Ram Chandrasekar a10bbc96a4 msm: lmh_lite: Add memory barrier before reading data from trustzone
Add memory barrier before reading data from trustzone
to make sure LMH driver doesnt fails because of
reading the data in out of order execution.

CRs-Fixed: 759855
Change-Id: Id2e917bf8100fc2f775186d8db630a39089337a2
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2014-11-20 11:37:15 -07:00
Linux Build Service Account 4b89e0e725 Merge "thermal: tsens: Remove the check for low trip less than high trip" 2014-11-18 23:29:41 -08:00
Ram Chandrasekar 883711dae4 thermal: tsens: Remove the check for low trip less than high trip
Remove the error check for the input low trip less
than the high trip value. Thermal core framework
handles multiple clients and there is a possibility
where high trip is less than low trip. In this
case, tsens driver should proceed further.

Change-Id: Ifa8b7898f36c75468ebf8b3ea027b34a7ff75734
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2014-11-18 17:58:41 -07:00
Linux Build Service Account db33b46d05 Merge "msm: lmh_lite: Move LMH interrupt logs to debug level" 2014-11-17 11:55:02 -08:00
Linux Build Service Account df481da607 Merge "msm: thermal: Proceed thermal late init only if probe is successful" 2014-11-17 08:32:51 -08:00
Shiju Mathew 111e0bd249 msm: thermal: Proceed thermal late init only if probe is successful
Skip thermal late init if thermal probe has not
completed since all the tasks in late init depend
on successful completion of thermal probe.

Change-Id: Iab763b80d2c878dd57a2401c92799c2534b349d2
Signed-off-by: Shiju Mathew <shijum@codeaurora.org>
2014-11-14 18:52:14 -05:00
Ram Chandrasekar 9e6cd0554c msm: lmh_lite: Move LMH interrupt logs to debug level
Move the logs that give information about the LMH
interrupt and the LMH sensors to debug log level.

Change-Id: I69291334e05a16400174bbcbaf53ef1e848b2745
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2014-11-14 10:32:36 -07:00
Linux Build Service Account d164e9cb05 Merge "msm: lmh_lite: Avoid accessing sensor remove API in critical section" 2014-11-14 01:15:00 -08:00
Ram Chandrasekar ad38209c1a msm: lmh_lite: Avoid accessing sensor remove API in critical section
The sensor remove API already has semaphore locks
to protect the critical section access. Update the
calls, where this sensor remove API was called inside
the critical section leading to potential deadlock.

CRs-Fixed: 754828
Change-Id: Ia838843ae9d5202b347791df887616c65816f35e
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
2014-11-13 10:55:10 -07:00
Linux Build Service Account 8d75538bba Merge "msm: thermal: Add KTM sysfs node to get limits bucket" 2014-11-10 10:24:13 -08:00
Linux Build Service Account a5a01c1939 Merge "msm: thermal: Add IOCTL command in KTM to query cluster voltage plan" 2014-11-10 10:24:12 -08:00
Linux Build Service Account e652d8b007 Merge "hwmon: qpnp-adc: add battery thermistor mapping table for SKUT1" 2014-11-10 03:57:59 -08:00