Currently we set CONFIG_CC_OPTIMIZE_FOR_SIZE which suppressed the compiler
warning of unused variables which can lead undefined behavior e.g. memory
corruption and panic. See https://lkml.org/lkml/2013/3/25/347.
This patch fixes all the uninitilized variables in kernel
Bug: 33353384
Test: On device
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I0ae1082f447b435d71156d471878ba71aa16c378
In cleanup_stats(), a freed memory pointer pos might be accessed for
list traversal. Switch to using _safe() variant of the list API to
prevent undefined accesses.
Bug: 79421260
Change-Id: I7d068cb7813ccb9bfdbcab4646b4ec890145828a
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
* For some reason 'hard reset' is being used for
recovery command. Rather than trying to understand
why is this happening it's way easier and cleaner to
just reset this to latest CAF tag as we don't need to
support custom reboot commands that Samsung implemented.
There can be use after free with multiple ioctl calls.
Add mutex lock when updating userspace power.
Change-Id: Ieae08d05478a462b19cf7f91b64267177eaebe84
Signed-off-by: Maulik Shah <mkshah@codeaurora.org>
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Userspace data is directly used without copying it to kernel memory.
Ensure all the data reads within ioctl happen from the kernel memory.
Change-Id: I17f6c0c4675e64e121c166b0a062e83a4c5c9757
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
The buffer allocated in file open operations need to be
protected as there can be a possiblity of use-after-free
scenario.
Process A B
| |
open |
| |
read started |
| close
Add mutex lock to protect the buffer to avoid this.
Change-Id: I1e066fd0a047bcec2af7829015089d5c882fb2f3
Signed-off-by: Raju P.L.S.S.S.N <rplsssn@codeaurora.org>
Signed-off-by: Naresh Malladi <namall@codeaurora.org>
There is a possible race condition when FG debugfs files are concurrently
accessed by multiple threads. Fix this.
CRs-Fixed: 1105481
Change-Id: I154e7f3cdd8d51cf67ef1dfd9d78f423f183cb64
Signed-off-by: ansharma <ansharma@codeaurora.org>
Currently userspace data is getting accessed directly
and leading to crash, So use get_user() API to copy
userspace data/settings to kernel space.
Change-Id: I3a75ec9503d8207829640bf88e1c3160bf72c9f0
Signed-off-by: Mohammed Khajapasha <mkhaja@codeaurora.org>
Signed-off-by: Srinivasarao P <spathi@codeaurora.org>
Update the number of power-freq pair value supported in the debug
interface. Parse the arguments as uint32_t instead of uint64_t which
might cause memory corruption.
CRs-fixed: 1054344
Change-Id: I30492b79b96356177cdcc72e4e2ee656317de500
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
Ptable and enable node parses the input arguments incorrectly. Parse the
input message into exact number of arguments that are required for the
respective nodes.
CRs-fixed: 1032875
Change-Id: I881f18217b703a497efa4799288dee39a28ea8ab
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
Handle removal of USB during QC 3.0 pulsing operation.
While at it, cancel hvdcp detection work before updating input
status to USB driver on charger removal.
CRs-Fixed: 1011956
Change-Id: I28cf37e60746eab126e7cd6822de9b35b8f832bf
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
Write magic cookies to indicate reasons of dm-verity corruption,
re-enable enforcing mode, and (unrelated) keys clear.
Change-Id: I49904c79940515863d794b23fa7ac84e472b2466
Signed-off-by: David Ng <dave@codeaurora.org>
On certain circumstances, empty soc interrupt cannot fire even
with the proper configuration. Clearing the empty soc config
and setting it back again after a FG cycle (~1.5 seconds) is
the only way to trigger empty soc interrupt again. Add it.
While at it, remove some unused macros in the driver.
CRs-Fixed: 1003838
Change-Id: I5dda1b52e19eb2086543035e0d8d1998ce709d53
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Currently, we request USB PHY to float DP/DM lines in usbin_uv
handler whenever USBIN_UV and SRC_DET bits are not set during
a charger insertion. This is to help with charger to run APSD
on DP/DM lines without any interference from USB PHY.
Eventually during QC3.0 detection, we run fake removal and
insertion in between. During this sequence, we disable APSD in
charger as well thereby floating DP/DM lines for a period of
~800ms. On some charger adaptors, this is detected as a different
charger type failing QC3.0 detection and also failing to operate
in QC2.0 mode.
Fix this by setting DP to 0.6V and DM to floating after fake
removal and before disabling APSD. Also, do not request USB PHY
to float DP/DM lines again during fake insertion.
CRs-Fixed: 1006776
Change-Id: I3a9f2ef71b657b3926ccd2325585c9b2a4edead9
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Force input current limit to 300mA during QC3.0 DP/DM pulsing for PMI8950.
While at it, update the error handling during pulsing to force 9V QC2.0
in case of failure.
CRs-Fixed: 984187
Change-Id: I7d48ff9fb4505dae1ed231691ba8efcd845df27c
Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
In scenarios where fast-charge/taper interrupt fires even before
src_detect_handler detects the parallel charger, parallel charging
will remain disabled. Fix this by adding a parallel charger detection
check in fastcharge and taper handler.
CRs-Fixed: 984187
Change-Id: I082cad6cf1bc3e8d9a5c327222f72d046190f9ca
Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
Add support to configure high ICL for SDP chargers, this is useful in case
of SDP or floating chargers which supports high current.
If 'qcom,override-usb-current' property is present override and set ICL
based on current reported by the USB driver otherwise set to USB500 mode.
CRs-Fixed: 963417
Change-Id: I31304cd2a4e710f4e450e6ec5a4da90c50fdfc88
Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
Remove vote for input current limit(ICL) on charger removal, this
will make sure ICL voter state is updated on charger removal and
vote for next insertion is not discarded as duplicate request.
CRs-Fixed: 981047
Change-Id: Iab16d12d27920183251820659c40d149c01b731e
Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
Currently, if regulator_register() of smbcharger-external-otg
regulator returns an error (e.g. -EPROBE_DEFER),
regulator_unregister() is not called for smbcharger-boost-otg
regulator which got registered before that.
This causes problems during bootup later because of an invalid
regulator device being left registered indefinitely.
Fix this by unregistering the regulator that got registered
already when there is an error in registering the other.
CRs-Fixed: 895622
Change-Id: I363693888f357555dbb82ef2566ed855cea9fe94
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Currently, HVDCP3 detection is enabled by default. Add support
to control it dynamically through a power supply property
"allow_hvdcp3".
If hvdcp3 adapter is connected and "allow_hvdcp3" is set to
false, it will get detected as hvdcp.
CRs-Fixed: 991060
Change-Id: Ibc1523f218fb55577c09b9b8317e5aac45d0fb6c
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Currently, HVDCP3 detection is enabled by default. Add support
to control it dynamically through a power supply property
"allow_hvdcp3".
CRs-Fixed: 991060
Change-Id: Id283b572cdb51094ad53d590e230104dc3e1beb7
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
In case of hardware coulomb counting based capacity learning the
wake-up source is not released in error conditions. Fix the same.
CRs-Fixed: 977956
Change-Id: I816642281aa2663b504ef3532653ff49aecc4f30
Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
commit 90adf98d9530054b8e665ba5a928de4307231d84 upstream.
Since commit 1c6c69525b ("genirq: Reject bogus threaded irq requests")
threaded IRQs without a primary handler need to be requested with
IRQF_ONESHOT, otherwise the request will fail.
scripts/coccinelle/misc/irqf_oneshot.cocci detected this issue.
Fixes: b5874f33bb ("wm831x_power: Use genirq")
Signed-off-by: Valentin Rothberg <valentinrothberg@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This reverts 'commit 9890d1939491 ("driver: lpm-workarounds:
disable/enable L2 low power modes")' as power regression seen
with disabling L2 low power modes.
Change-Id: I2a4fea67a62065c64bfa7ec3af8a20a18480dd13
Signed-off-by: Maulik Shah <mkshah@codeaurora.org>
Report the input current limited status via the power supply in parallel
mode in order to better optimize for HVDCP usecases.
CRs-Fixed: 930588
Change-Id: I9d802227ebd0289b796477020a51826717fc908f
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
SCHG_LITE supports additional aicl-restart values, update the table
accordingly. While at it, use the right mask to update the AICL_WL_SEL
register.
CRs-Fixed: 954243
Change-Id: Icf18c1556c4598896c5ae6d0e9ed55bbd46fa41e
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
when device battery capacity is less than 2%, PLL turn on
through spm is not working and causing lpm workarounds to
get struck in infinite loop.
Register for power supply notifications and postpone the
L1/L2 dynamic clock gating enablement till battery reach
safe level.
Change-Id: I21acdc6b097937bc54a06b72434e0a0a61570b8a
Signed-off-by: Anji Jonnala <anjir@codeaurora.org>
In the current implementation AICL is not re-run if its already
in progress. However in case where ICL gets updated while AICL
is in progress, the updated ICL value is not considered unless
AICL re-runs again. Handle this by re-running AICL irrespective of
the AICL status.
CRs-Fixed: 907473
Change-Id: I4a021e6ca148d0c218701cfb8a671d1e2dac6fee
Signed-off-by: Anirudh Ghayal <aghayal@codeaurora.org>
Add module parameters to configure default ICLs for USB DCP and HVDCPs
in order to facilitate testing.
CRs-Fixed: 930588
Change-Id: I5fa1cdef010821211d3baa1797fdb72110d86a10
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
Use the BATT_TYPE voter for FCC instead of USER. This way the user can
set FCCs higher than the device tree limit.
Change-Id: Id386f8afd1bef2d1774730b214f1b97d64a6476b
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
Support adjusting the usb ICL up and down through the DP_DM interface for
HVDCP 3.0.
CRs-Fixed: 930588
Change-Id: Ic24f946522d7ae0ec0a52f127118ac5a0d908277
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
Current the smbcharger is splitting the ICL and charge current fairly
naively. This can cause problems where one charger is FCC limited and
another charger is ICL limited, causing a lot of wasted charge current.
Do a better current distribution to maximize the amount of charge
current going into the battery. By default, raise the ICL ratio of the
primary charger up to 60% to avoid issues with system load prematurely
causing the charger to current limit. Lower the FCC ratio back to 50% to
accommodate this.
Also, make both of these properties configurable through module
parameters and device tree in order to accommodate differences in pcb
and battery limitation.
CRs-Fixed: 930588
Change-Id: I77ec8483232e4297936baaad1e9bb4399474d444
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
At 9V, the smbcharger is more efficient at a switching frequency of
1MHz. Switch to this when the driver detects that it is in HVDCP 2.0
mode. Also, switch the VFIX clamping voltage threshold so that the
frequency is maintained.
CRs-Fixed: 910651
Change-Id: I4b8e1d360fe301671e882f20b2460cdb737204b0
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
Allow the charger to pull 3A of charge current from HVDCP chargers,
since they are certified to handle that much current.
CRs-Fixed: 918587
Change-Id: I411da6ffe0756ed8c3f3b23d1ed13cd31dbb7fa1
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
This method uses a variable to track the current closest value's
index. The implementation was checking the distance between the
value and this index instead of the value at that index. Fix
this bug.
CRs-Fixed: 923805
Change-Id: Iac3cc125c4c5fabbe027ec38890d5c47e199187e
Signed-off-by: Devesh Jhunjhunwala <deveshj@codeaurora.org>
The smbcharger's battery overvoltage detection cannot be trusted.
Many times, it will trip even though the battery voltage is still well
within safe limits. Because of this, simply ignore the interrupt if it
fires.
CRs-Fixed: 924317
Change-Id: I57decb3a11f6b7bacbe82b0fe69c844f308e890d
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
After the voter is initialized and before the first valid vote
is made, the voter state is invalid. Introduce some changes to
accommodate this state:
1. Initialize effective_result and all client states to -EINVAL.
2. If the current vote does not change effective_result, or if
there are no valid votes in the array, skip the callback and
maintain the current effective result.
3. Allow the user to provide a default_value, which is returned
in the scenario where the effective_result is queried before
making a valid vote.
CRs-Fixed: 927044
Change-Id: Ic00064d95e5a9234bcf44a415ad2bbff6e84a2f3
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
The AICL done interrupt rises when an valid AICL measurement or collapse
occurs, and falls when a new AICL measurement starts. The software is
only interested in when a valid AICL measurement becomes available.
Disable the falling edge case for this interrupt since it just becomes
more noise for the driver.
CRs-Fixed: 920791
Change-Id: Idf8471dfe4bba731480a09e43af8d791a71a122e
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
Some times the battery ov status appears to not change even though the
status changes. This could be attributed to a fast battery ov pulse not
triggering the down interrupt.
Read the batt-ov status instead for reporting to the userspace.
Change-Id: I5bdb8cc6564ad37dde0e5901f0543a1c1b7b8761
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
Add the dtsi property qcom,aicl-rerun-period-s in order to allow for the
configuration of how often AICL is reran in hardware.
CRs-Fixed: 920791
Change-Id: Id262f26b409d75f7c82ee79b25c4258baed43840
Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>