drivers/power/qpnp-charger.c: fix charging issues with non-Oppo chargers

1. refactor the current limiting code to use existing temperature sensing
   capability rather than some arbitrary 1 minute loop

2. removed all current check loops below 900mA. Due to inaccurate ADC input
   readings, some non-Oppo wall chargers are mis-identified and their charging
   capabilities severely limited by the over protective driver

USB data port charging are unaffected by these changes

Change-Id: Id888a25b02b99556d29156520e01d21f7a487168
Signed-off-by: Paul Reioux <reioux@gmail.com>
drivers/power/qpnp-charger.c: add back dropped aicl control

Change-Id: Ib62d2a948aec7c2974ed6a98b11df208cdb8af4c
Signed-off-by: Paul Reioux <reioux@gmail.com>
msm: kgsl: Use high priority workqueue

Change-Id: If245f7876a68da079b2e0b9e371fdcbeb85ef0b5
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
net/ipv6/addrconf: fix wdog_bark caused by infinite spinning on a deadlock

A synchronization issue may occur while addrconf_ifdown(),
when it updates inet6_addr_lst[] with already destroyed *ifp
by ipv6_add/del_addr(), using the same addrconf_hash_lock.

[core 0]                                        [core 1]
   |                                               |
   |->ipv6_add_addr                                |->addrconf_ifdown
       |                                               |
       |                                               |-> spin_lock(&addrconf_hash_lock);
       |                                               |-> remove ifa->addr_lst from inet6_addr_lst
       |                                               |-> spin_unlock(&addrconf_hash_lock);
       |-> spin_lock(&addrconf_hash_lock);             |
       |-> add ifa->addr_lst to inet6_addr_lst[hash]   |
       |-> spin_unlock(&addrconf_hash_lock);           |
       |-> write_lock(&idev-lock);                     |
       |-> add ifa->if_list to idev->addr_list         |
       |-> write_unlock(&idev->lock);                  |
       |                                               |-> write_lock(&idev->lock);
       |                                               |-> remove ifa->if_list from idev->addr_list
       |                                               |-> write_unlock(&idev->lock);

[28055.378524] ------------[ cut here ]------------
[28055.378591] WARNING: at net/ipv6/addrconf.c:546 inet6_ifa_finish_destroy+0x98/0xc8()
[28055.378691] [<c010de1c>] (unwind_backtrace+0x0/0x144) from [<c09fd08c>] (dump_stack+0x20/0x24)
[28055.378747] [<c09fd08c>] (dump_stack+0x20/0x24) from [<c0192adc>] (warn_slowpath_common+0x58/0x70)
[28055.378840] [<c0192adc>] (warn_slowpath_common+0x58/0x70) from [<c0192bec>] (warn_slowpath_null+0x2c/0x34)
[28055.378931] [<c0192bec>] (warn_slowpath_null+0x2c/0x34) from [<c0911a90>] (inet6_ifa_finish_destroy+0x98/0xc8)
[28055.379026] [<c0911a90>] (inet6_ifa_finish_destroy+0x98/0xc8) from [<c091498c>] (addrconf_ifdown+0x2e4/0x430)
[28055.379120] [<c091498c>] (addrconf_ifdown+0x2e4/0x430) from [<c0915b70>] (addrconf_notify+0xe4/0x3ac)
[28055.379209] [<c0915b70>] (addrconf_notify+0xe4/0x3ac) from [<c01b9df0>] (notifier_call_chain+0x54/0x94)
[28055.379321] [<c01b9df0>] (notifier_call_chain+0x54/0x94) from [<c01ba3ac>] (__raw_notifier_call_chain+0x24/0x2c)
[28055.379379] [<c01ba3ac>] (__raw_notifier_call_chain+0x24/0x2c) from [<c01ba3dc>] (raw_notifier_call_chain+0x28/0x30)
[28055.379475] [<c01ba3dc>] (raw_notifier_call_chain+0x28/0x30) from [<c0840ea4>] (call_netdevice_notifiers+0x38/0x60)
[28055.379568] [<c0840ea4>] (call_netdevice_notifiers+0x38/0x60) from [<c0844d5c>] (__dev_notify_flags+0x3c/0x6c)
[28055.379657] [<c0844d5c>] (__dev_notify_flags+0x3c/0x6c) from [<c0844dcc>] (dev_change_flags+0x40/0x58)
[28055.379747] [<c0844dcc>] (dev_change_flags+0x40/0x58) from [<c08d2834>] (devinet_ioctl+0x79c/0x8bc)
[28055.379837] [<c08d2834>] (devinet_ioctl+0x79c/0x8bc) from [<c08d3488>] (inet_ioctl+0x1c0/0x1d0)
[28055.379928] [<c08d3488>] (inet_ioctl+0x1c0/0x1d0) from [<c082d7f0>] (sock_ioctl+0x80/0x248)
[28055.379982] [<c082d7f0>] (sock_ioctl+0x80/0x248) from [<c0275364>] (do_vfs_ioctl+0x94/0x5bc)
[28055.380071] [<c0275364>] (do_vfs_ioctl+0x94/0x5bc) from [<c0275908>] (sys_ioctl+0x7c/0x8c)
[28055.380164] [<c0275908>] (sys_ioctl+0x7c/0x8c) from [<c0107300>] (ret_fast_syscall+0x0/0x30)
[28055.380252] ---[ end trace 920b8b321354f066 ]---
[28061.735021] Watchdog bark! Now = 28061.735014
[28061.735106] Watchdog last pet at 28050.179294
[28061.735245] cpu alive mask from last pet 0-3
[28061.735321] Causing a watchdog bite!

The addrconf_hash_lock should cover both modification of inet6_addr_list and idev->addr_list
to resolve any possible synchronization issue between addrconf_ifdown() and ipv6_add/del_addr().

Bug: 11293746
Change-Id: If263fc375b411bf21eacade0d094bff95939f7fe
Signed-off-by: David C. Park <davidc.park@lge.com>
cpufreq: cpu-boost: Don't register for cpufreq notifiers too early

The cpufreq notifiers should be registered only after all the data
structures used in the notifier callbacks have been initialized. So, move
the cpufreq notifier registration to a later point in the init function.

Change-Id: I043ab5bc0ebb98164c40549fe151a8d801c8c186
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
vfs: fix bad hashing of dentries

Josef Bacik found a performance regression between 3.2 and 3.10 and
narrowed it down to commit bfcfaa77bdf0 ("vfs: use 'unsigned long'
accesses for dcache name comparison and hashing"). He reports:

 "The test case is essentially

      for (i = 0; i < 1000000; i++)
              mkdir("a$i");

  On xfs on a fio card this goes at about 20k dir/sec with 3.2, and 12k
  dir/sec with 3.10.  This is because we spend waaaaay more time in
  __d_lookup on 3.10 than in 3.2.

  The new hashing function for strings is suboptimal for <
  sizeof(unsigned long) string names (and hell even > sizeof(unsigned
  long) string names that I've tested).  I broke out the old hashing
  function and the new one into a userspace helper to get real numbers
  and this is what I'm getting:

      Old hash table had 1000000 entries, 0 dupes, 0 max dupes
      New hash table had 12628 entries, 987372 dupes, 900 max dupes
      We had 11400 buckets with a p50 of 30 dupes, p90 of 240 dupes, p99 of 567 dupes for the new hash

  My test does the hash, and then does the d_hash into a integer pointer
  array the same size as the dentry hash table on my system, and then
  just increments the value at the address we got to see how many
  entries we overlap with.

  As you can see the old hash function ended up with all 1 million
  entries in their own bucket, whereas the new one they are only
  distributed among ~12.5k buckets, which is why we're using so much
  more CPU in __d_lookup".

The reason for this hash regression is two-fold:

 - On 64-bit architectures the down-mixing of the original 64-bit
   word-at-a-time hash into the final 32-bit hash value is very
   simplistic and suboptimal, and just adds the two 32-bit parts
   together.

   In particular, because there is no bit shuffling and the mixing
   boundary is also a byte boundary, similar character patterns in the
   low and high word easily end up just canceling each other out.

 - the old byte-at-a-time hash mixed each byte into the final hash as it
   hashed the path component name, resulting in the low bits of the hash
   generally being a good source of hash data.  That is not true for the
   word-at-a-time case, and the hash data is distributed among all the
   bits.

The fix is the same in both cases: do a better job of mixing the bits up
and using as much of the hash data as possible.  We already have the
"hash_32|64()" functions to do that.

Reported-by: Josef Bacik <jbacik@fb.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Chris Mason <clm@fb.com>
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
wlan: fix VOSS packet leak

The VOSS API to return packets to the system
had a bug which causes packet leak, the problem
occurs when low resource condition is hit and
the API is called to return a chain of VOSS packets
to the system. When the condition is hit the VOSS
packets are not added to the free or replenish
list and they are lost forever from the system.

Change-Id: I62d9238ba4ccb62365443650c8ad765c5042826f
CRs-Fixed: 653612
wlan: add check for size of cache aligned skb->data

In receive path we check if the memory DMA'd is more
than the allocated memory. alloc_skb() can allocate
more memory than specified if the specified memory
size is not cache aligned, so check for the size
of cache aligned memory for deciding if the data
DMA's was more that allocated memory.

Change-Id: Iaf5b75b73d1f84d6d64ed0975414218a7bb6f591
CRs-Fixed: 717798
wlan: flush cached frames on assoc failure

Prima driver caches RX frames till the peer
is registered in TL. If assocication failure
occurs then free the cached frames so that
the RX resources are returned back to the
system.

Change-Id: I37d6c08075dc77026ad85863e4838eb5e3742fc3
CRs-Fixed: 643670
wlan: avoid race condition while accessing wpalPacketAvailableCB

wpalPacketAvailableCB can be called from the MC_Thread as well
as the RX_Thread, the race condition can occur when the callback
is called from the MC_Thread and immediately set to NULL after
the function returns and in between that the RX_Thread running
on another core has detected a low resource condition and set
wpalPacketAvailableCB before the MC_Thread sets it to NULL.
To avoid the race conditions always set/reset the values to
wpalPacketAvailableCB in RX_thread only.

Change-Id: Idb1700287186df4b3ede45324cfa2062b1b81d9e
CRs-Fixed: 599184
prima: update to LNX.LA.3.5.1.5

Change-Id: I17cd07b80cb6f3e2f43532cfb3928db0d0cffa3b
wlan: Filter out all zero bssid from Scan results.

Some malfunctional APs will send zero bssid in probe response
which causes connection failure.
Filter out these wrong bssids in driver.

CRs-Fixed: 690979
Change-Id: I526db27dd84fcf96d81273df6f3a400b90e05df7
wlan: LIM: check add to null check dereference

Add code to check null dereference check.

Change-Id: I339f3aa9014b013f939179f22ed1650e8c3d6aed
Crs-Fixed: 667938
wlan: Fix static analysis issue(Buffer Overflow) in HDD

Fix Buffer Overflow Array Index Out of Boundsfound in static
analysis in HDD.In hdd_wmm_select_queue/hdd_hostapd_select_queue
skb->priority is assigned as enum which can have value 0 to 8,
we use global array hddLinuxUpToAcMap for up to ac mapping purpose,
which can take maximum index range from 0 to 7.As up (enum)
might be assgined up to 0-8(8 is SME_QOS_WMM_UP_MAX), so
we should check up before going for mapping to ac.

Change-Id: Ia2855cd0989fef44c55aa2b7af73f95ad0c5954a
CRs-Fixed: 689045
wlan: Failed to Send Action frame.

When GO exist and  invites peer on the same
operating channel where GO is formed,i.e
when GO is on channel, if supplicant sends,
a non zero wait time , driver is not able to
send action frame. As a part of fix , setting
wait time as zero when GO is operating on channel
explicitly in driver.

Change-Id: I652060c53fb4b731b381ebb28996124bc39b4480
CRs-Fixed: 668530
wlan: Acquire rtnl lock while unregistering ioctls.

While unregistering ioctl, HOST will set wireless_handlers to NULL,
at the same time if kernel is processing any IOCTL command
(wireless_process_ioctl), there are chances of deferring
wireless_handler, leading to crash.
Hence, taking rtnl_lock while making wireless_handlers to NULL, as
same lock is taken while processing ioctl.

Change-Id: Idcd907fa345eae9e36d3698225aaa8780576f679
CRs-Fixed: 716024
wlan: Switch off the carrier in case of NULL bss.

In hdd_AssociationCompletionHandler, if we get NULL bss
from wlan_hdd_cfg80211_update_bss_db, it returns from
there only. But when it does, hdd_AssociationCompletionHandler
has to make sure that it does not leave the carrier on with
TX queues enabled, this leads to hdd_tx_timeout being called
continuously.
This crash is avoided by turning off the carrier when
wlan_hdd_cfg80211_update_bss_db fails.

Change-Id: Ie927cb920f20bfaf89c4a2319397a16d4efa4d8f
CRs-Fixed: 716690
wlan: Fix possible null pointer dereference in WDA_IsSelfSTA

In function WDA_IsSelfSTA(), pointer pWDA will be NULL
dereferenced if VOS_GET_WDA_CTXT() returns NULL.
Added NULL pointer check before accessing the pointer.

Change-Id: I40dcac790d0bc76939c13b4af864139889403a02
CRs-Fixed: 679406.
wlan: check for pAdapter NULL dereference.

this fix will ensure NULL pointer derefernce
in function hdd_deinit_batch_scan.

Change-Id: I0877dde6fff3534477c4a866a91607561b61d33c
CRs-Fixed: 621421
wlan: Clean up WD thread to avoid crash.

In function VosWDThread() we check if resetinprogress
is set in WD context but still execute WLAN re-init
which causes system to crash.
Clean up WD thread so that it doesnot execute WLAN
re-init when it is not shutdown.

Change-Id: Ica0ab74e98f2153dcab91e9aa111bc6dacc6e9ba
CRs-Fixed: 682616