Backport from cm-10.1

cfgp2p: silence p2p error

Change-Id: Id991f6d5bc4c5205008ad87c2a1382735e39fc4e

tegra: make sure nvhost is on before sync

hwcomposer wrapper can cause this.

Change-Id: I118ba96d44baefbcd838a3527b9b46818824139f

Enable zram

Change-Id: I1f94d6d1ea828623f72c0891da4f394a947ef121

tegra: usb_phy: use kzalloc instead of kmalloc

Change-Id: I5ee396a98f901472be669f390fe907e691746874

video: tegra: switch to kzalloc/vzalloc

Change-Id: I0575566ad1811ccac62b95010cacbdb7a0962dc2

Enable compaction

Change-Id: I00beaf43a20559bf0fd86ad62063c327e3f9c123

Revert "tegra: Adjust clocks, volts"

This reverts commit 188c4e647902d49a67242f5401d12d37914f9d65.

tegra: dc: update nvhdcp

From the grouper kernel.

Change-Id: Ibd303a6e52611f495f7d4eda1193689fac751731

i2c: tegra: update from nvidia

Improve stability while using HDMI.

Change-Id: I1ca1aa672dfdf0ca6e9e9b0252005c4a42bd13d5

cfg80211/nl80211: support GTK rekey offload

In certain circumstances, like WoWLAN scenarios,
devices may implement (partial) GTK rekeying on
the device to avoid waking up the host for it.

In order to successfully go through GTK rekeying,
the KEK, KCK and the replay counter are required.

Add API to let the supplicant hand the parameters
to the driver which may store it for future GTK
rekey operations.

Note that, of course, if GTK rekeying is done by
the device, the EAP frame must not be passed up
to userspace, instead a rekey event needs to be
sent to let userspace update its replay counter.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

Conflicts:
	include/linux/nl80211.h
	include/net/cfg80211.h
	net/wireless/nl80211.c

Change-Id: Ie0e56b2e3409d99473a54ba5ad65dbd1c6243e48

cfg80211/nl80211: Add PMKSA caching candidate event

When the driver (or most likely firmware) decides which AP to use
for roaming based on internal scan result processing, user space
needs to be notified of PMKSA caching candidates to allow RSN
pre-authentication to be used.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

Conflicts:
	include/linux/nl80211.h

Change-Id: I20cf44942fd96c4feb5e267f0154253eb16f9f33

nl80211: support sending TDLS commands/frames

Add support for sending high-level TDLS commands and TDLS frames via
NL80211_CMD_TDLS_OPER and NL80211_CMD_TDLS_MGMT, respectively. Add
appropriate cfg80211 callbacks for lower level drivers.

Add wiphy capability flags for TDLS support and advertise them via
nl80211.

Signed-off-by: Arik Nemtsov <arik@wizery.com>
Cc: Kalyan C Gaddam <chakkal@iit.edu>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

Conflicts:
	include/linux/nl80211.h

Change-Id: I784fdbf51b3ae7860ce0843959f44d5d79d74e04

nl80211: advertise GTK rekey support, new triggers

Since we now have the necessary API in place to support
GTK rekeying, applications will need to know whether it
is supported by a device. Add a pseudo-trigger that is
used only to advertise that capability. Also, add some
new triggers that match what iwlagn devices can do.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

nl80211: advertise device AP SME

Add the ability to advertise that the device
contains the AP SME and what features it can
support. There are currently no features in
the bitmap -- probe response offload will be
advertised by a few patches Arik is working
on now (who took over from Guy Eilam) and a
device with AP SME will typically implement
and require response offload.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

Change-Id: Ib1a65814860cf97cadd142c17be0e91f43743832

nl80211: allow subscribing to unexpected class3 frames

To implement AP mode without monitor interfaces we
need to be able to send a deauth to stations that
send frames without being associated. Enable this
by adding a new nl80211 event for such frames that
an application can subscribe to.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

nl80211: add API to probe a client

When the AP SME in hostapd is used it wants to
probe the clients when they have been idle for
some time. Add explicit API to support this.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

cfg80211: allow registering to beacons

Add the ability to register to received beacon frames
to allow implementing OLBC logic in userspace. The
registration is per wiphy since there's no point in
receiving the same frame multiple times.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

net: wireless: bcmdhd: Update to version 5.90.195.104

- Fix p2p support for new wpa_supplicant
- Propagate disconnect error code for cfg80211

Change-Id: I9643fbad7b6170b0e794fd7854201931d5eefb22
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

net: wireless: bcmdhd: Add ASSOC event processing

Change-Id: Ide0b887ba52af56d0aaa415111df5ba16265c8d8
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

net: wireless: bcmdhd: Fix sending ctrl packet

- Schedule dpc thread to send ctrl frame if we cannot
  send ctrl packet immediately.

Change-Id: I5ae8b705a6ccddcc1f5c86b4c094342b57d26c7f
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

net: wireless: bcmdhd: Add ROAM setting per platform from Makefle

Change-Id: Ia6bc3025e3641cb6b91022ab1c9976c0f6ad16a4
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

net: wireless: bcmdhd: Update wifi stack ps state if was changed

Change-Id: Ib1ee0b6ee05077d1ed6cfb578b6384dfc9787c81
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

Conflicts:

	drivers/net/wireless/bcmdhd/wl_cfg80211.h

net: wireless: bcmdhd: Add print when power-save mode is OFF

Change-Id: Idc72198b2d59c76dd45ba918cef982bcd7b570ab
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

net: wireless: bcmdhd: Adjust roaming treshold to -65 dB

Change-Id: I88bb0cf759ee4262f31f054ef2dd5fc6258e8628
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

net: wireless: bcmdhd: Fix BSSID report for disassoc

Change-Id: I5e3b01a1a471e5983ab934fc9d65802a389ab1af
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

net: wireless: bcmdhd: Fix WD wakelock behavior

Change-Id: I7ebae2be248cbb4bc98e2b448641f65b77a320f4
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

Conflicts:

	drivers/net/wireless/bcmdhd/dhd_linux.c

net: wireless: bcmdhd: Avoid suspend on watchdog

Change-Id: Ic41a8f369a2ee8b2a0084e6a1cbf6b454ff53353
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

net: wireless: bcmdhd: Enable P2P probe request handling only during discovery

Change-Id: I2db29d5ed7f66f2a45feb890c81d510fcad24dd2
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

cfg80211: fix antenna gain handling

commit c4a9fafc77a5318f5ed26c509bbcddf03e18c201 upstream.

No driver initializes chan->max_antenna_gain to something sensible, and
the only place where it is being used right now is inside ath9k. This
leads to ath9k potentially using less tx power than it can use, which can
decrease performance/range in some rare cases.

Rather than going through every single driver, this patch initializes
chan->orig_mag in wiphy_register(), ignoring whatever value the driver
left in there. If a driver for some reason wishes to limit it independent
from regulatory rulesets, it can do so internally.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

net: usb: Fix memory leak on Tx data path

[ Upstream commit 39707c2a3ba5011038b363f84d37c8a98d2d9db1 ]

Driver anchors the tx urbs and defers the urb submission if
a transmit request comes when the interface is suspended.
Anchoring urb increments the urb reference count. These
deferred urbs are later accessed by calling usb_get_from_anchor()
for submission during interface resume. usb_get_from_anchor()
unanchors the urb but urb reference count remains same.
This causes the urb reference count to remain non-zero
after usb_free_urb() gets called and urb never gets freed.
Hence call usb_put_urb() after anchoring the urb to properly
balance the reference count for these deferred urbs. Also,
unanchor these deferred urbs during disconnect, to free them
up.

Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Acked-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

net: correct check in dev_addr_del()

[ Upstream commit a652208e0b52c190e57f2a075ffb5e897fe31c3b ]

Check (ha->addr == dev->dev_addr) is always true because dev_addr_init()
sets this. Correct the check to behave properly on addr removal.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

netfilter: Validate the sequence number of dataless ACK packets as well

commit 4a70bbfaef0361d27272629d1a250a937edcafe4 upstream.

We spare nothing by not validating the sequence number of dataless
ACK packets and enabling it makes harder off-path attacks.

See: "Reflection scan: an Off-Path Attack on TCP" by Jan Wrobel,
http://arxiv.org/abs/1201.2074

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

netfilter: Mark SYN/ACK packets as invalid from original direction

commit 64f509ce71b08d037998e93dd51180c19b2f464c upstream.

Clients should not send such packets. By accepting them, we open
up a hole by wich ephemeral ports can be discovered in an off-path
attack.

See: "Reflection scan: an Off-Path Attack on TCP" by Jan Wrobel,
http://arxiv.org/abs/1201.2074

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

netfilter: nf_nat: don't check for port change on ICMP tuples

commit 38fe36a248ec3228f8e6507955d7ceb0432d2000 upstream.

ICMP tuples have id in src and type/code in dst.
So comparing src.u.all with dst.u.all will always fail here
and ip_xfrm_me_harder() is called for every ICMP packet,
even if there was no NAT.

Signed-off-by: Ulrich Weber <ulrich.weber@sophos.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

net: wireless: bcmdhd: Increase PNO wakelock to 7 sec

Change-Id: Ife7bac08d16e19b37d16f697e4ad9765ca6efbb7
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

net: wireless: bcmdhd: Prevent HT Avail timeout to frozen device while asleep

Change-Id: I6ccd035539a3a3074b7ff1e06854ce396d784fc4

net: wireless: bcmdhd: Postpone taking wd_wake lock

Change-Id: I3926d7a1a357d173144f408996f35f0929db711e
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

net: sched: integer overflow fix

[ Upstream commit d2fe85da52e89b8012ffad010ef352a964725d5f ]

Fixed integer overflow in function htb_dequeue

Signed-off-by: Stefan Hasko <hasko.stevo@gmail.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

net: wireless: bcmdhd: Fix PEAP with dynamic WEP

Change-Id: I62dffdb3b759ea5ccdf9f7ea0f0e67f928ace92b
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

Wifi sleep power mode sysfs

0 is PM_MAX (default), 1 is PM_FAST
path is /sys/module/bcmdhd/parameters/wifi_pm

Change-Id: Ie0bc5c31f85d43f7414412d4ed9ba1b417ab2c05

Conflicts:
	drivers/net/wireless/bcmdhd/dhd_linux.c

net: wireless: bring in line with 3.0

Also update ieee80211.

Change-Id: I2c472eb080bdbf07425397ca912a08d4546d7179

net: bcmdhd: remove kernel version checks

Change-Id: Ia0d8ea80638feb280d6eb82038522fc3b88079ac

Update defconfig

Clean it up with makedefconfig.
Re-enable TV tuners.

Change-Id: I16fc00f56cafbec0fd6ddb555b57382656419b0b

MMC: Adjust unaligned write accesses.

Adjust unaligned write accesses spanning preferred align
size into two accesses - an unaligned and an aligned access.
This is meant to be used for card quirks, and is off
by default. A limiting value in transfer size
for this adjustment is available, as on some cards there is a
perf decrease for larger transfers.

Signed-off-by: Andrei Warkentin <andreiw@vmware.com>

MMC: Add block quirks support.

Quirks are card-specific workarounds. Usually they involve
tuning mmcblk parameters at mmc_blk_probe time.

Signed-off-by: Andrei Warkentin <andreiw@vmware.com>

MMC: Toshiba eMMC - Split 8K-unaligned accesses.

These cards show abysmal write performance when
writes < 12K that are 8K unaligned cross an 8K barrier.

Signed-off-by: Andrei Warkentin <andreiw@vmware.com>

MMC: Block quirks request adjust support.

Lets a card specific quirk affect how MMC requests are made.
Necessary for Toshiba block-splitting part reliability workaround.

Change-Id: Iceb4b0e45c40e8f5d84236404ef6db08c31b159c
Signed-off-by: Andrei Warkentin <andreiw@vmware.com>

MMC: Toshiba eMMC - Part reliability improvement.

Split-up accesses into smaller chunks, to improve
lifespan, by using 8K reliable writes into 8K Buffer A,
instead of 4MB Buffer B, reducing number of 4MB write-erase
cycles. Upper and lower bounds should be experimentally
found to match the desired performance/reliability
characteristics.

Change-Id: I14b22e1383fe277946967425c21fd13e17dcedda
Signed-off-by: Andrei Warkentin <andreiw@vmware.com>

Enable MMC quirks

Change-Id: I24598bb4c207953a0b70334166b86628b81966b3

lowmemorykiller: Compact memory when killing processes

* Memory compaction is never invoked on Android because we avoid swap
   and don't allocate huge pages. Fix it by invoking compaction from the LMK when
   a process is killed to reduce memory fragmentation.

Change-Id: I2bda790c2093e65fd6f43d52ea5149d6b57cb1e9

Conflicts:

	drivers/staging/android/lowmemorykiller.c

lowmemorykiller: Use asynchronous compaction

Change-Id: I6a65d06fc30b88fcedaaf1abf1855fdd19e3c912

hardlockup: detect hard lockups without NMIs using secondary cpus

Emulate NMIs on systems where they are not available by using timer
interrupts on other cpus.  Each cpu will use its softlockup hrtimer
to check that the next cpu is processing hrtimer interrupts by
verifying that a counter is increasing.

This patch is useful on systems where the hardlockup detector is not
available due to a lack of NMIs, for example most ARM SoCs.
Without this patch any cpu stuck with interrupts disabled can
cause a hardware watchdog reset with no debugging information,
but with this patch the kernel can detect the lockup and panic,
which can result in useful debugging info.

Modified for older 2.6.39 kernel.

Changes since v1:
    renamed variables to clarify when referring to the next cpu
    factored out function to get next cpu
    fixed int vs unsigned int mismatches
    fixed race condition when offlining cpus

Change-Id: I0fc455beb1f249c3041e926d9e10da6a2b6feb9f
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Takazumi Matsumoto <tdr@cyanogenmod.org>

Enable debugging

And also disable tegra watchdog.
A few devices are plagued by random reboots, so try to recover some
debug information from them.

Change-Id: I998f8e60b3a2974f79f59613fe226fc02ace3053

staging: logger: hold mutex while removing reader

The readers list is traversed under the log->mutex lock
(for example from fix_up_readers()), but the deletion of
elements from this list is not being done under this lock.

Cc: Brian Swetland <swetland@google.com>
Cc: Dima Zavin <dima@android.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

net: wireless: bcmdhd: Update to version 5.90.195.114

- Get AP beacon and DTIM to set proper DTIM skipping

Change-Id: I6bc23f050c144bf8361078ad587bcadbfe3a37fc
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

netfilter: xt_qtaguid: fix error exit that would keep a spinlock.

qtudev_open() could return with a uid_tag_data_tree_lock held
when an kzalloc(..., GFP_ATOMIC) would fail.
Very unlikely to get triggered AND survive the mayhem of running out of mem.

Signed-off-by: JP Abgrall <jpa@google.com>

netfilter: qtaguid: Don't BUG_ON if create_if_tag_stat fails

If create_if_tag_stat fails to allocate memory (GFP_ATOMIC) the
following will happen:

qtaguid: iface_stat: tag stat alloc failed
...
kernel BUG at xt_qtaguid.c:1482!

Signed-off-by: Pontus Fuchs <pontus.fuchs@gmail.com>

netfilter: xt_qtaguid: remove AID_* dependency for access control

qtaguid limits what can be done with /ctrl and /stats based on group
membership.
This changes removes AID_NET_BW_STATS and AID_NET_BW_ACCT, and picks
up the groups from the gid of the matching proc entry files.

Signed-off-by: JP Abgrall <jpa@google.com>
Change-Id: I42e477adde78a12ed5eb58fbc0b277cdaadb6f94

netfilter: xt_qtaguid: extend iface stat to report protocols

In the past the iface_stat_fmt would only show global bytes/packets
for the skb-based numbers.
For stall detection in userspace, distinguishing tcp vs other protocols
makes it easier.
Now we report
  ifname total_skb_rx_bytes total_skb_rx_packets total_skb_tx_bytes
  total_skb_tx_packets {rx,tx}_{tcp,udp,ohter}_{bytes,packets}

Bug: 6818637
Signed-off-by: JP Abgrall <jpa@google.com>
Change-Id: I179c5ebf2fe822acec0bce4973b4bbb5e7d5076d

netfilter: xt_qtaguid: Allow tracking loopback

In the past it would always ignore interfaces with loopback addresses.
Now we just treat them like any other.
This also helps with writing tests that check for the presence
of the qtaguid module.

Signed-off-by: JP Abgrall <jpa@google.com>

net: wireless: bcmdhd: Add SUPPORT_PM2_ONLY option

Change-Id: Ieb2569cb7fb2bbc56ff9abbc8728a7741fda0027
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Signed-off-by: Takazumi Matsumoto <tdr@cyanogenmod.org>

Conflicts:
	drivers/net/wireless/bcmdhd/dhd_linux.c

i2c: tegra: match grouper

Change-Id: I23b9f53649ed5aeda7d64ac777796d0e4dd751d9

mmc: core: update mmc_suspend_host

Change-Id: I38f6352e794fa58f5d325b3b7dbdb068f77effe5

Disable MMC debugging

Change-Id: I0b0d6006afcb44018e5a25a13aebcf273cd949fb

net: wireless: bcmdhd: Fix p2p "linear" IE parsing

Change-Id: Id9e358897529940eaaa6654f67297e1b77f52d15
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

bcmdhd: Enable Ad-Hoc (IBSS) mode

Enable Ad-Hoc (IBSS) mode for bcmdhd. We basically just need to set the
interface flag and avoid some P2P specific settings while scanning.

Also add the "station get" command for IBSS mode.

Change-Id: Ice320bc65b0b9b738fa09acc1e3dea2a58805ad9
Signed-off-by: Bruno Randolf <br1@einfach.org>

stingray: disable MMC deferred resume

A few devices regularly fail to wake up with this enabled.
Nvidia disabled this but most devices (including stingray) have it
enabled.

Not sure if it's a software or hardware issue, so just turn it off.

Change-Id: Id5285281f732185cd8bfab342c428bfd08b3c7da

stingray: update defconfig

Remove some debugging.
Enable WEXT.
Adjust netfilter.

Change-Id: If1693a9433e95af95bc3f81ab46d16a2aefc6d2f

Revert "netfilter: xt_qtaguid: remove AID_* dependency for access control"

This reverts commit ffe51fe6c4a519edcb149490593f3a27ffb5e6ec.

Causes insufficient priv errors.