Commit Graph

29781 Commits

Author SHA1 Message Date
Colin Cross
0fa571fe60 mm: add a field to store names for private anonymous memory
Userspace processes often have multiple allocators that each do
anonymous mmaps to get memory.  When examining memory usage of
individual processes or systems as a whole, it is useful to be
able to break down the various heaps that were allocated by
each layer and examine their size, RSS, and physical memory
usage.

This patch adds a user pointer to the shared union in
vm_area_struct that points to a null terminated string inside
the user process containing a name for the vma.  vmas that
point to the same address will be merged, but vmas that
point to equivalent strings at different addresses will
not be merged.

Userspace can set the name for a region of memory by calling
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, start, len, (unsigned long)name);
Setting the name to NULL clears it.

The names of named anonymous vmas are shown in /proc/pid/maps
as [anon:<name>] and in /proc/pid/smaps in a new "Name" field
that is only present for named vmas.  If the userspace pointer
is no longer valid all or part of the name will be replaced
with "<fault>".

The idea to store a userspace pointer to reduce the complexity
within mm (at the expense of the complexity of reading
/proc/pid/mem) came from Dave Hansen.  This results in no
runtime overhead in the mm subsystem other than comparing
the anon_name pointers when considering vma merging.  The pointer
is stored in a union with fieds that are only used on file-backed
mappings, so it does not increase memory usage.

Change-Id: Ie2ffc0967d4ffe7ee4c70781313c7b00cf7e3092
Signed-off-by: Colin Cross <ccross@android.com>
2013-10-11 10:02:06 -07:00
Carter Cooper
42ee55d4bd msm: kgsl: Bypass SP counter 4 on A33x
SP performance counter 4 is broken on A33x targets so do not assign
this counter.  The counter does not reliably return correct values
which can make results misleading.

Change-Id: I87c36e021c547b630e8dfd89abbdb5c65d4b3c46
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
2013-09-11 22:41:31 -07:00
Devin Kim
03053d709b panic: resume console if panic after console suspend.
Device rebooted by kernel panic but no panic message.
This helps to get the panic messages in this case.

Bug: 10184128
Change-Id: I24545b1ce2f9e3e239795089d8564c2cc5f89fe7
Signed-off-by: shihhao.feng <shihhao.feng@lge.com>
Signed-off-by: Devin Kim <dojip.kim@lge.com>
2013-09-09 17:16:14 -07:00
Theodore Ts'o
eff211bddf random: remove rand_initialize_irq()
commit c5857ccf293968348e5eb4ebedc68074de3dcda6 upstream.

With the new interrupt sampling system, we are no longer using the
timer_rand_state structure in the irq descriptor, so we can stop
initializing it now.

[ Merged in fixes from Sedat to find some last missing references to
  rand_initialize_irq() ]

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ed Tam <etam@google.com>
2013-09-09 17:01:42 -07:00
Theodore Ts'o
1e8002c17d random: add new get_random_bytes_arch() function
commit c2557a303ab6712bb6e09447df828c557c710ac9 upstream.

Create a new function, get_random_bytes_arch() which will use the
architecture-specific hardware random number generator if it is
present.  Change get_random_bytes() to not use the HW RNG, even if it
is avaiable.

The reason for this is that the hw random number generator is fast (if
it is present), but it requires that we trust the hardware
manufacturer to have not put in a back door.  (For example, an
increasing counter encrypted by an AES key known to the NSA.)

It's unlikely that Intel (for example) was paid off by the US
Government to do this, but it's impossible for them to prove otherwise
  --- especially since Bull Mountain is documented to use AES as a
whitener.  Hence, the output of an evil, trojan-horse version of
RDRAND is statistically indistinguishable from an RDRAND implemented
to the specifications claimed by Intel.  Short of using a tunnelling
electronic microscope to reverse engineer an Ivy Bridge chip and
disassembling and analyzing the CPU microcode, there's no way for us
to tell for sure.

Since users of get_random_bytes() in the Linux kernel need to be able
to support hardware systems where the HW RNG is not present, most
time-sensitive users of this interface have already created their own
cryptographic RNG interface which uses get_random_bytes() as a seed.
So it's much better to use the HW RNG to improve the existing random
number generator, by mixing in any entropy returned by the HW RNG into
/dev/random's entropy pool, but to always _use_ /dev/random's entropy
pool.

This way we get almost of the benefits of the HW RNG without any
potential liabilities.  The only benefits we forgo is the
speed/performance enhancements --- and generic kernel code can't
depend on depend on get_random_bytes() having the speed of a HW RNG
anyway.

For those places that really want access to the arch-specific HW RNG,
if it is available, we provide get_random_bytes_arch().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ed Tam <etam@google.com>
2013-09-09 17:01:30 -07:00
Linus Torvalds
438cb44895 random: create add_device_randomness() interface
commit a2080a67abe9e314f9e9c2cc3a4a176e8a8f8793 upstream.

Add a new interface, add_device_randomness() for adding data to the
random pool that is likely to differ between two devices (or possibly
even per boot).  This would be things like MAC addresses or serial
numbers, or the read-out of the RTC. This does *not* add any actual
entropy to the pool, but it initializes the pool to different values
for devices that might otherwise be identical and have very little
entropy available to them (particularly common in the embedded world).

[ Modified by tytso to mix in a timestamp, since there may be some
  variability caused by the time needed to detect/configure the hardware
  in question. ]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ed Tam <etam@google.com>
2013-09-09 14:44:07 -07:00
Theodore Ts'o
a1cca5558b random: make 'add_interrupt_randomness()' do something sane
commit 775f4b297b780601e61787b766f306ed3e1d23eb upstream.

We've been moving away from add_interrupt_randomness() for various
reasons: it's too expensive to do on every interrupt, and flooding the
CPU with interrupts could theoretically cause bogus floods of entropy
from a somewhat externally controllable source.

This solves both problems by limiting the actual randomness addition
to just once a second or after 64 interrupts, whicever comes first.
During that time, the interrupt cycle data is buffered up in a per-cpu
pool.  Also, we make sure the the nonblocking pool used by urandom is
initialized before we start feeding the normal input pool.  This
assures that /dev/urandom is returning unpredictable data as soon as
possible.

(Based on an original patch by Linus, but significantly modified by
tytso.)

Tested-by: Eric Wustrow <ewust@umich.edu>
Reported-by: Eric Wustrow <ewust@umich.edu>
Reported-by: Nadia Heninger <nadiah@cs.ucsd.edu>
Reported-by: Zakir Durumeric <zakir@umich.edu>
Reported-by: J. Alex Halderman <jhalderm@umich.edu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ed Tam <etam@google.com>
2013-09-09 14:43:59 -07:00
Ohad Ben-Cohen
6c0572bb9b iommu/core: pass a user-provided token to fault handlers
Sometimes a single IOMMU user may have to deal with several
different IOMMU devices (e.g. remoteproc).

When an IOMMU fault happens, such users have to regain their
context in order to deal with the fault.

Users can't use the private fields of neither the iommu_domain nor
the IOMMU device, because those are already used by the IOMMU core
and low level driver (respectively).

This patch just simply allows users to pass a private token (most
notably their own context pointer) to iommu_set_fault_handler(),
and then makes sure it is provided back to the users whenever
an IOMMU fault happens.

The patch also adopts remoteproc to the new fault handling
interface, but the real functionality using this (recovery of
remote processors) will only be added later in a subsequent patch
set.

Change-Id: Ic04659686e72838a0db518e9303dd037191e3879
Cc: Fernando Guzman Lugo <fernando.lugo@ti.com>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
[ohaugan@codeaurora.org: Resolved compilation and merge issues]
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>

Conflicts:
	drivers/video/msm/mdss/mdss_mdp.c
2013-09-06 16:20:47 -07:00
Thomas Hellstrom
c9cb68da74 kref: Implement kref_get_unless_zero v3
This function is intended to simplify locking around refcounting for
objects that can be looked up from a lookup structure, and which are
removed from that lookup structure in the object destructor.
Operations on such objects require at least a read lock around
lookup + kref_get, and a write lock around kref_put + remove from lookup
structure. Furthermore, RCU implementations become extremely tricky.
With a lookup followed by a kref_get_unless_zero *with return value check*
locking in the kref_put path can be deferred to the actual removal from
the lookup structure and RCU lookups become trivial.

v2: Formatting fixes.
v3: Invert the return value.

Change-Id: Ibcb524294c2cebe1d832e77714895822adc1c89a
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Git-commit: 4b20db3de8dab005b07c74161cb041db8c5ff3a7
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[shrenujb@codeaurora.org: resolve trivial merge conflicts]
Signed-off-by: Shrenuj Bansal <shrenujb@codeaurora.org>
2013-09-06 16:15:39 -07:00
Sameer Thalappil
f175e9c50b wcnss: Add API to expose the IRIS XO mode set
IRIS XO mode can be configured thru module parameter; and it can also
be auto detected. Add an API to expose the IRIS XO mode set. WLAN driver
can use this API for it's XO specific operation.

Change-Id: If40ae715f5e400e13a6fc9588d2bd144958ee8c2
Signed-off-by: Sameer Thalappil <sameert@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>

Conflicts:
	include/linux/wcnss_wlan.h
2013-09-04 12:44:28 -07:00
Mahesh Palivela
06e1b2e84f ieee80211: Rename VHT cap struct
Rename struct ieee80211_vht_capabilities to ieee80211_vht_cap
and renamed its member vht_capabilities_info to vht_cap_info.

Change-Id: I2cfee9b9fa558a9c742d6f8a3827c21d443e9156
CRs-fixed: 452921

Signed-off-by: Mahesh Palivela <maheshp@posedge.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2013-09-04 12:43:32 -07:00
Mahesh Palivela
798685c1d9 wireless: add VHT (802.11ac) definitions
Add the VHT definitions to be used by drivers supporting it.

Change-Id: Ia301cf72940cef19767f4f485a09c9afc12ae514
CRs-fixed: 452921

Signed-off-by: Mahesh Palivela <maheshp@posedge.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2013-09-04 12:43:30 -07:00
Jouni Malinen
6eee28bb12 cfg80211: Allow TDLS peer AID to be configured for VHT
VHT uses peer AID in the PARTIAL_AID field in TDLS frames. The
current design for TDLS is to first add a dummy STA entry before
completing TDLS Setup and then update information on this STA
entry based on what was received from the peer during the setup
exchange.

In theory, this could use NL80211_ATTR_STA_AID to set
the peer AID just like this is used in AP mode to set the AID
of an association station. However, existing cfg80211 validation
rules prevent this attribute from being used with set_station
operation. To avoid interoperability issues between different
kernel and user space version combinations, introduce a new
nl80211 attribute for the purpose of setting TDLS peer AID.
This attribute can be used in both the new_station and set_station
operations. It is not supposed to be allowed to change the AID
value during the lifetime of the STA entry, but that validation
is left for drivers to do in the change_station callback.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Git-commit: 5e4b6f5698421d94226cc2f80eae6d613c9acef8
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-testing.git
Change-Id: I1d2f6d2f5a291f91858b45ad004de66a0080f1d2
CRs-fixed: 483290
[duttus@codeaurora.org: backport to 3.4-This commit includes the
changes from following commits in include/linux/nl80211.h to compile
for msm-3.4.
5de17984898c5758fc6ebe08eccea9f4b6548914 :
cfg80211: introduce critical protocol indication from user-space.]
Signed-off-by: Sunil Dutt <duttus@codeaurora.org>
2013-09-04 12:43:29 -07:00
Vasanthakumar Thiagarajan
649820b4c4 cfg80211/nl80211: add API for MAC address ACLs
Add API to enable drivers to implement MAC address based
access control in AP/P2P GO mode. Capable drivers advertise
this capability by setting the maximum number of MAC
addresses in such a list in wiphy->max_acl_mac_addrs.

An initial ACL may be given to the NL80211_CMD_START_AP
command and/or changed later with NL80211_CMD_SET_MAC_ACL.

Black- and whitelists are supported, but not simultaneously.

Signed-off-by: Vasanthakumar Thiagarajan <vthiagar@qca.qualcomm.com>
[rewrite commit log, many cleanups]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Git-commit: 77765eaf5cfb6b8dd98ec8b54b411d74ff6095f1
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
CRs-fixed: 487410
Change-Id: I9593b887941be5efa5e96546ad92cd6c6bf8fb87
[duttus@codeaurora.org: resolved 3.4 backport issues]
Signed-off-by: Sunil Dutt <duttus@codeaurora.org>
2013-09-04 12:43:29 -07:00
Jouni Malinen
9cc28cf8a5 cfg80211: Extend support for IEEE 802.11r Fast BSS Transition
Add NL80211_CMD_UPDATE_FT_IES to support update of FT IEs to the
WLAN driver and NL80211_CMD_FT_EVENT to send FT events from the
WLAN driver. This will carry the target AP's MAC address along
cfg80211: Extend support for IEEE 802.11r Fast BSS Transition

Add NL80211_CMD_UPDATE_FT_IES to support update of FT IEs to the
WLAN driver and NL80211_CMD_FT_EVENT to send FT events from the
WLAN driver. This will carry the target AP's MAC address along
with the relevant Information Elements. This event is used to
report received FT IEs (MDIE, FTIE, RSN IE, TIE, RICIE). These
changes allow FT to be supported with drivers that use an internal
SME instead of user space option (like FT implementation in
wpa_supplicant with mac80211-based drivers).

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Git-commit: 355199e02b831fd4f652c34d6c7673d973da1369
Git-repo: http://git.kernel.org/cgit/linux/kernel/git/linville/
wireless-testing.git/
Change-Id: I439155b3d7bf4df9c45087a4deb6ec0cd7577225
CRs-fixed: 434525
[duttus@codeaurora.org: backport to 3.4-This commit includes the
changes from following commits to compile for jb_2.5.
5314526b1743e8e8614293db7d86e480b4fe9824 : cfg80211: add channel
switch notify event
98104fdeda63d57631c9f89e90a7b83b58fcee40 : cfg80211: add P2P
Device abstraction
f4e583c8935c6f52f9385ee7cfbea8f65c66a737 : nl/cfg80211: add the
NL80211_CMD_SET_MCAST_RATE command
ed44a951c72ab409f932b1c15914488308e86da2 : cfg80211/nl80211: Notify
connection request failure in AP mode
77765eaf5cfb6b8dd98ec8b54b411d74ff6095f1 : cfg80211/nl80211: add
API for MAC address ACLs.
04f39047af2a6df64b763ea5a271db24879d0391 : nl80211/cfg80211: add
radar detection command/event.
3713b4e364effef4b170c97d54528b1cdb16aa6b : nl80211: allow splitting
wiphy information in dumps.
ee2aca343c9aa64d277a75a5df043299dc84cfd9 : cfg80211: add ability
to override VHT capabilities.
355199e02b831fd4f652c34d6c7673d973da1369 : cfg80211: Extend
support for IEEE 802.11r Fast BSS Transition.]
Signed-off-by: Sunil Dutt <duttus@codeaurora.org>
2013-09-04 12:43:28 -07:00
Jouni Malinen
3f913934a5 cfg80211: Pass station (extended) capability info to kernel
The information of the peer's capabilities and extended capabilities are
required for the driver to perform TDLS Peer UAPSD operations and off
channel operations. This information of the peer is passed from user space
using NL80211_CMD_SET_STATION command. This commit enhances
the function nl80211_set_station to pass the capability information of
the peer to the driver.

Similarly, there may be need for capability information for other modes,
so allow this to be provided with both add_station and change_station.

Change-Id: I1e626512a0f849ae05bbbd24c4e262d303b8f8ea
CRs-fixed: 452921

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2013-09-04 12:43:26 -07:00
Mahesh Palivela
b672fbac86 {nl,cfg}80211: Peer STA VHT caps
To save STAs VHT caps in AP mode

Change-Id: I1930ec05a3e079733c00837c93bda615289fceda
CRs-fixed: 452921

Signed-off-by: Mahesh Palivela <maheshp@posedge.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2013-09-04 12:43:25 -07:00
Mahesh Palivela
0ad86a6a16 cfg80211: allow advertising VHT capabilities
Allow drivers to advertise their VHT capabilities
and export them to userspace via nl80211.

Change-Id: I2d2825a09dfddccca1bd3edacd7fc382d765bea5
CRs-fixed: 452921

Signed-off-by: Mahesh Palivela <maheshp@posedge.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2013-09-04 12:43:25 -07:00
Ajay Dudani
6f78c7af16 power: pm8921-bms: expose coulomb counter based charge
Average current drawn can be calculated by reading the coulomb
counter based charge before and after the usecase is run and
dividing the difference in the charge by the time it took to
run the usecase.

Use power supply property POWER_SUPPLY_PROP_CHARGE_NOW, to
expose the coulomb counter based charge.

Change-Id: I43e26a2932ab3e3d9d79bb5af7daf2364ca133b7
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
2013-07-17 10:23:28 -07:00
Colin Cross
43088e18e5 freezer: add new freezable helpers using freezer_do_not_count()
Freezing tasks will wake up almost every userspace task from
where it is blocking and force it to run until it hits a
call to try_to_sleep(), generally on the exit path from the syscall
it is blocking in.  On resume each task will run again, usually
restarting the syscall and running until it hits the same
blocking call as it was originally blocked in.

To allow tasks to avoid running on every suspend/resume cycle,
this patch adds additional freezable wrappers around blocking calls
that call freezer_do_not_count().  Combined with the previous patch,
these tasks will not run during suspend or resume unless they wake
up for another reason, in which case they will run until they hit
the try_to_freeze() in freezer_count(), and then continue processing
the wakeup after tasks are thawed.

Additional patches will convert the most common locations that
userspace blocks in to use freezable helpers.

Change-Id: Id909760ce460f2532801a4b00d344f0816bfefc9
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-07-12 14:22:57 -07:00
Colin Cross
9d1d742f54 freezer: convert freezable helpers to static inline where possible
Some of the freezable helpers have to be macros because their
condition argument needs to get evaluated every time through
the wait loop.  Convert the others to static inline to make
future changes easier.

Change-Id: I69d3fc10d26522cb9bf3a616ff4f21245f9c071a
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-07-12 14:22:57 -07:00
Colin Cross
f44f3d1bb5 freezer: convert freezable helpers to freezer_do_not_count()
Freezing tasks will wake up almost every userspace task from
where it is blocking and force it to run until it hits a
call to try_to_sleep(), generally on the exit path from the syscall
it is blocking in.  On resume each task will run again, usually
restarting the syscall and running until it hits the same
blocking call as it was originally blocked in.

Convert the existing wait_event_freezable* wrappers to use
freezer_do_not_count().  Combined with a previous patch,
these tasks will not run during suspend or resume unless they wake
up for another reason, in which case they will run until they hit
the try_to_freeze() in freezer_count(), and then continue processing
the wakeup after tasks are thawed.

This results in a small change in behavior, previously a race
between freezing and a normal wakeup would be won by the wakeup,
now the task will freeze and then handle the wakeup after thawing.

Change-Id: I532e62251f58c1a9ca488b3fb6220c53acf7d33d
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-07-12 14:22:57 -07:00
Mandeep Singh Baines
f94bc0bd68 lockdep: check that no locks held at freeze time
We shouldn't try_to_freeze if locks are held.  Holding a lock can cause a
deadlock if the lock is later acquired in the suspend or hibernate path
(e.g.  by dpm).  Holding a lock can also cause a deadlock in the case of
cgroup_freezer if a lock is held inside a frozen cgroup that is later
acquired by a process outside that group.

History:
This patch was originally applied as 6aa9707099c and reverted in
dbf520a9d7d4 because NFS was freezing with locks held.  It was
deemed better to keep the bad freeze point in NFS to allow laptops
to suspend consistently.  The previous patch in this series converts
NFS to call _unsafe versions of the freezable helpers so that
lockdep doesn't complain about them until a more correct fix
can be applied.

Change-Id: Ib9d4299fb75a39e611b868be42e413909a994baa
[akpm@linux-foundation.org: export debug_check_no_locks_held]
Signed-off-by: Mandeep Singh Baines <msb@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Acked-by: Pavel Machek <pavel@ucw.cz>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-07-12 14:22:56 -07:00
Colin Cross
3b8c86d0b4 lockdep: remove task argument from debug_check_no_locks_held
The only existing caller to debug_check_no_locks_held calls it
with 'current' as the task, and the freezer needs to call
debug_check_no_locks_held but doesn't already have a current
task pointer, so remove the argument.  It is already assuming
that the current task is relevant by dumping the current stack
trace as part of the warning.

This was originally part of 6aa9707099c (lockdep: check that
no locks held at freeze time) which was reverted in
dbf520a9d7d4.

Change-Id: Idbaf1332ce6c80dc49c1d31c324c7fbf210657c5
Original-author: Mandeep Singh Baines <msb@chromium.org>
Acked-by: Pavel Machek <pavel@ucw.cz>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-07-12 14:22:56 -07:00
Colin Cross
e265007670 freezer: add unsafe versions of freezable helpers for CIFS
CIFS calls wait_event_freezekillable_unsafe with a VFS lock held,
which is unsafe and will cause lockdep warnings when 6aa9707
"lockdep: check that no locks held at freeze time" is reapplied
(it was reverted in dbf520a).  CIFS shouldn't be doing this, but
it has long-running syscalls that must hold a lock but also
shouldn't block suspend.  Until CIFS freeze handling is rewritten
to use a signal to exit out of the critical section, add a new
wait_event_freezekillable_unsafe helper that will not run the
lockdep test when 6aa9707 is reapplied, and call it from CIFS.

In practice the likley result of holding the lock while freezing
is that a second task blocked on the lock will never freeze,
aborting suspend, but it is possible to manufacture a case using
the cgroup freezer, the lock, and the suspend freezer to create
a deadlock.  Silencing the lockdep warning here will allow
problems to be found in other drivers that may have a more
serious deadlock risk, and prevent new problems from being added.

Change-Id: I420c5392bacf68e58e268293b2b36068ad4df753
Acked-by: Pavel Machek <pavel@ucw.cz>
Acked-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-07-12 14:22:55 -07:00
Colin Cross
ac88fa1646 freezer: add unsafe versions of freezable helpers for NFS
NFS calls the freezable helpers with locks held, which is unsafe
and will cause lockdep warnings when 6aa9707 "lockdep: check
that no locks held at freeze time" is reapplied (it was reverted
in dbf520a).  NFS shouldn't be doing this, but it has
long-running syscalls that must hold a lock but also shouldn't
block suspend.  Until NFS freeze handling is rewritten to use a
signal to exit out of the critical section, add new *_unsafe
versions of the helpers that will not run the lockdep test when
6aa9707 is reapplied, and call them from NFS.

In practice the likley result of holding the lock while freezing
is that a second task blocked on the lock will never freeze,
aborting suspend, but it is possible to manufacture a case using
the cgroup freezer, the lock, and the suspend freezer to create
a deadlock.  Silencing the lockdep warning here will allow
problems to be found in other drivers that may have a more
serious deadlock risk, and prevent new problems from being added.

Change-Id: Ia17d32cdd013a6517bdd5759da900970a4427170
Signed-off-by: Colin Cross <ccross@android.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-07-12 14:22:55 -07:00
Colin Cross
a997718e25 HACK: ARM: disable sleeping while atomic warning in do_signal
ARM disables interrupts in do_signal, which triggers a warning in
try_to_freeze, see details at https://lkml.org/lkml/2011/8/23/221.
To prevent the warnings, add try_to_freeze_nowarn and call it from
do_signal.

Change-Id: If7482de21c386adc705fa1ac4ecb8c7ece5bb356
Signed-off-by: Colin Cross <ccross@android.com>
2013-07-12 14:22:55 -07:00
Iliyan Malchev
1b23972213 Revert "freezer: comment out might_sleep()"
This reverts commit 6cdb09deef.
2013-07-12 14:22:55 -07:00
Tejun Heo
5d5d984e11 freezer: add missing mb's to freezer_count() and freezer_should_skip()
commit dd67d32dbc5de299d70cc9e10c6c1e29ffa56b92 upstream.

A task is considered frozen enough between freezer_do_not_count() and
freezer_count() and freezers use freezer_should_skip() to test this
condition.  This supposedly works because freezer_count() always calls
try_to_freezer() after clearing %PF_FREEZER_SKIP.

However, there currently is nothing which guarantees that
freezer_count() sees %true freezing() after clearing %PF_FREEZER_SKIP
when freezing is in progress, and vice-versa.  A task can escape the
freezing condition in effect by freezer_count() seeing !freezing() and
freezer_should_skip() seeing %PF_FREEZER_SKIP.

This patch adds smp_mb()'s to freezer_count() and
freezer_should_skip() such that either %true freezing() is visible to
freezer_count() or !PF_FREEZER_SKIP is visible to
freezer_should_skip().

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-07-12 14:22:54 -07:00
rock_lin
03e0f4d463 Cap1106: Disable RF Noise filter in sensnor's setting
Resolve issue:
RF Noise filter is enabled by default, proximity detection is blocked
when sensor's hardware detects the RF noise.

Change-Id: Ie641dff567ed1c43955b446b1f2db2d8b8156659
Signed-off-by: rock lin <Rock_Lin@asus.com>
2013-07-03 16:06:33 +00:00
Jordan Crouse
26ec3b0af3 msm: kgsl: implement server-side waits
msm: kgsl: Add device init function

	Some device specific parameters need to be setup only once during
	device initialization. Create an init function for this purpose
	rather than re-doing this init everytime the device is started.

	Change-Id: I45c7fcda8d61fd2b212044c9167b64f793eedcda
	Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 2nd commit message:

	msm: kgsl: improve active_cnt and ACTIVE state management

	Require any code path which intends to touch the hardware
	to take a reference on active_cnt with kgsl_active_count_get()
	and release it with kgsl_active_count_put() when finished.
	These functions now do the wake / sleep steps that were
	previously handled by kgsl_check_suspended() and
	kgsl_check_idle().

	Additionally, kgsl_pre_hwaccess() will no longer turn on
	the clocks, it just enforces via BUG_ON that the clocks
	are enabled before a register is touched.

	Change-Id: I31b0d067e6d600f0228450dbd73f69caa919ce13
	Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 3rd commit message:

	msm: kgsl: Sync memory with CFF from places where it was missing

	Before submitting any indirect buffer to GPU via the ringbuffer,
	the indirect buffer memory should be synced with CFF so that the
	CFF capture will be complete. Add the syncing of memory with CFF
	in places where this was missing

	Change-Id: I18f506dd1ab7bdfb1a68181016e6f661a36ed5a2
	Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 4th commit message:

	msm: kgsl: Export some kgsl-core functions to EXPORT_SYMBOLS

	Export some functions in the KGSL core driver so they can
	be seen by the leaf drivers.

	Change-Id: Ic0dedbad5dbe562c2e674f8e885a3525b6feac7b
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 5th commit message:

	msm: kgsl: Send the right IB size to adreno_find_ctxtmem

	adreno_find_ctxtmem expects byte lengths and we were sending it
	dword lengths which was about as effective as you would expect.

	Change-Id: Ic0dedbad536ed377f6253c3a5e75e5d6cb838acf
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 6th commit message:

	msm: kgsl: Add 8974 default GPR0 & clk gating values

	Add correct clock gating values for A330, A305 and A320.
	Add generic function to return the correct default clock
	gating values for the respective gpu. Add default GPR0
	value for A330.

	Change-Id: I039e8e3622cbda04924b0510e410a9dc95bec598
	Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 7th commit message:

	msm: kgsl: Move A3XX VBIF settings decision to a table

	The vbif selection code is turning into a long series of if/else
	clauses. Move the decision to a look up table that will be easier
	to update and maintain when when we have eleventy A3XX GPUs.

	Change-Id: Ic0dedbadd6b16734c91060d7e5fa50dcc9b8774d
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 8th commit message:

	msm: kgsl: Update settings for the A330v2 GPU in 8972v2

	The new GPU spin in 8974v2 has some slightly different settings
	then the 8974v1: add support for identifying a v2 spin, add a new
	table of VBIF register settings and update the clock gating
	registers.

	Change-Id: Ic0dedbad22bd3ed391b02f6327267cf32f17af3d
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 9th commit message:

	msm: kgsl: Fix compilation errors when CFF is turned on

	Fix the compilation errors when option MSM_KGSL_CFF_DUMP option
	is turned on.

	Change-Id: I59b0a7314ba77e2c2fef03338e061cd503e88714
	Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 10th commit message:

	msm: kgsl: Convert the Adreno GPU cycle counters to run free

	In anticipation of allowing multiple entities to share access to the
	performance counters; make the few performance counters that KGSL
	uses run free.

	Change-Id: Ic0dedbadbefb400b04e4f3552eed395770ddbb7b
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 11th commit message:

	msm: kgsl: Handle a possible ringbuffer allocspace error

	In the GPU specific start functions, account for the possibility
	that ringbuffer allocation routine might return NULL.

	Change-Id: Ic0dedbadf6199fee78b6a8c8210a1e76961873a0
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 12th commit message:

	msm: kgsl: Add a new API to allow sharing of GPU performance counters

	Adreno uses programmable performance counters, meaning that while there
	are a limited number of physical counters each counter can be programmed
	to count a vast number of different measurements (we refer to these as
	countables).  This could cause problems if multiple apps want to use
	the performance counters, so this API and infrastructure allows the
	counters to be safely shared.

	The kernel tracks which countable is selected for each of the physical
	counters for each counter group (where groups closely match hardware
	blocks). If the desired countable is already in use, or there is an
	open physical counter, then the process is allowed to use the counter.

	The get ioctl reserves the counter and returns the dword offset of the
	register associated with that physical counter.  The put ioctl
	releases the physical counter.  The query ioctl gets the countables
	used for all of the counters in the block - up to 8 values can be
	returned.  The read ioctl gets the current hardware value in the counter

	Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
	Signed-off-by: Carter Cooper <ccooper@codeaurora.org>

	# This is the 13th commit message:

	msm: kgsl: Print the nearest active GPU buffers to a faulting address

	Print the two active GPU memory entries that bracket a faulting GPU
	address. This will help diagnose premature frees and buffer ovverruns.

	Check if the faulting GPU address was freed by the same process.

	Change-Id: Ic0dedbadebf57be9abe925a45611de8e597447ea
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
	Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org>

	# This is the 14th commit message:

	msm: kgsl: Remove an uneeded register write for A3XX GPUs

	A3XX doesn't have the MH block and so the register at 0x40 points
	somewhere else. Luckily the write was harmless but remove it anyway.

	Change-Id: Ic0dedbadd1e043cd38bbaec8fcf0c490dcdedc8c
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 15th commit message:

	msm: kgsl: clean up iommu/gpummu protflag handling

	Make kgsl_memdesc_protflags() return the correct type of flags
	for the type of mmu being used. Query the memdesc with this
	function in kgsl_mmu_map(), rather than passing in the
	protflags. This prevents translation at multiple layers of
	the code and makes it easier to enforce that the mapping matches
	the allocation flags.

	Change-Id: I2a2f4a43026ae903dd134be00e646d258a83f79f
	Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 16th commit message:

	msm: kgsl: remove kgsl_mem_entry.flags

	The two flags fields in kgsl_memdesc should be enough for
	anyone.  Move the only flag using kgsl_mem_entry, the
	FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv.

	Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf
	Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 17th commit message:

	msm: kgsl: map the guard page readonly on the iommu

	The guard page needs to be readable by the GPU, due to
	a prefetch range issue, but it should never be writable.
	Change the page fault message to indicate if nearby
	buffers have a guard page.

	Change-Id: I3955de1409cbf4ccdde92def894945267efa044d
	Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 18th commit message:

	msm: kgsl: Add support for VBIF and VBIF_PWR performance counters

	These 2 counter groups are also "special cases" that require
	different programming sequences.

	Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee
	Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 19th commit message:

	msm: kgsl: Only allow two counters for VBIF performance counters

	There are only two VBIF counter groups so validate that the user
	doesn't pass in > 1 and clean up the if/else clause.

	Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 20th commit message:

	msm: kgsl: Avoid an array overrun in the perfcounter API

	Make sure the passed group is less than the size of the list of
	performance counters.

	Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 21st commit message:

	msm: kgsl: Don't go to slumber if active_count is non zero

	If active_cnt happens to be set when we go into
	kgsl_early_suspend_driver() then don't go to SLUMBER.  This
	avoids trouble if we come back and and try to access the
	hardware while it is off.

	Change-Id: Ic0dedbadb13514a052af6199c8ad1982d7483b3f
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 22nd commit message:

	msm: kgsl: Enable HLSQ registers in snapshot when available

	Reading the HLSQ registers during a GPU hang recovery might cause
	the device to hang depending on the state of the HLSQ block.
	Enable the HLSQ register reads when we know that they will
	succeed.

	Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad
	Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 23rd commit message:

	msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure

	Stop parsing an indirect buffer if an error is encountered (such as
	a missing buffer). This is a pretty good indication that the buffers
	are not reliable and the further the parser goes with a unreliable
	buffer the more likely it is to get confused.

	Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 24th commit message:

	msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space

	Some IB1 buffers have hundreds of little IB2 buffers and only one of them
	will actually be interesting enough to push into the static space.  Only
	push the last executed IB1 and IB2 into the static space.

	Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 25th commit message:

	msm: kgsl: Save the last active context in snapshot

	Save the last active context that was executing when the hang happened
	in snapshot.

	Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395
	Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 26th commit message:

	msm: kgsl: In snapshot track a larger object size if address is same

	If the object being tracked has the same address as a previously
	tracked object then only track a single object with larger size
	as the smaller object will be a part of the larger one anyway.

	Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504
	Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 27th commit message:

	msm: kgsl: Track memory address from 2 additional registers

	Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG
	registers in snapshot. This makes snapshot more complete in terms of
	tracking data that is used by the GPU at the time of hang.

	Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069
	Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 28th commit message:

	msm: kgsl: Loop till correct index on type0 packets

	When searching for memory addresses in type0 packet we were looping
	from start of the type0 packet till it's end, but the first DWORD
	is a header so we only need to loop till packet_size - 1. Fix this.

	Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62
	Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 29th commit message:

	msm: kgsl: Add global timestamp information to snapshot

	Make sure that we always add global timestamp information to
	snapshot. This is needed in playbacks for searching whereabouts
	of last executed IB.

	Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a
	Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 30th commit message:

	msm: kgsl: Skip cff dump for certain functions when its disabled

	Certain functions were generating CFF when CFF was disabled. Make
	sure these functions do not dump CFF when it is disabled.

	Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d
	Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 31st commit message:

	msm: kgsl: Fix searching of memory object

	Make sure that at least a size of 1 byte is searched when locating
	the memory entry of a region. If size is 0 then a memory region
	whose last address is equal to the start address of the memory being
	searched will be returned which is wrong.

	Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5
	Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 32nd commit message:

	msm: kgsl: If adreno start fails then restore state of device

	Restore the state of the device back to what it was at the
	start of the adreno_start function if this function fails to
	execute successfully.

	Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8
	Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 33rd commit message:

	msm: kgsl: Fix early exit condition in ringbuffer drain

	The ringbuffer drain function can be called when the ringbuffer
	start flag is not set. This happens on startup. Hence,
	exiting the function early based on start flag is incorrect.
	Simply execute this function regardless of the start flag.

	Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49
	Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 34th commit message:

	msm: kgsl: Do not return an error on NULL gpu address

	If a NULL gpu address is passed to snapshot object tracking
	function then do not treat this as an error and return 0. NULL
	objects may be present in an IB so just skip over these objects
	instead of exiting due to an error.

	Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
	Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 35th commit message:

	msm: kgsl: Don't hold process list global mutex in process private create

	Don't hold process list global mutex for long. Instead make
	use of process specific spin_lock() to serialize access
	to process private structure while creating it. Holding
	process list global mutex could lead to deadlocks as other
	functions depend on it.

	CRs-fixed: 480732
	Change-Id: Id54316770f911d0e23384f54ba5c14a1c9113680
	Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
	Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 36th commit message:

	msm: kgsl: Use CPU path to program pagetable when active count is 0

	When active count is 0 then we should use the CPU path to program
	pagetables because the GPU path requires event registration. Events
	can only be queued when active count is valid. Hence, if the active
	count is NULL then use the CPU path.

	Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82
	CRs-fixed: 481887
	Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 37th commit message:

	iommu: msm: prevent partial mappings on error

	If msm_iommu_map_range() fails mid way through the va
	range with an error, clean up the PTEs that have already
	been created so they are not leaked.

	Change-Id: Ie929343cd6e36cade7b2cc9b4b4408c3453e6b5f
	Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 38th commit message:

	msm: kgsl: better handling of virtual address fragmentation

	When KGSL_MEMFLAGS_USE_CPU_MAP is enabled, the mmap address
	must try to match the GPU alignment requirements of the buffer,
	as well as include space in the mapping for the guard page.
	This can cause -ENOMEM to be returned from get_unmapped_area()
	when there are a large number of mappings. When this happens,
	fall back to page alignment and retry to avoid failure.

	Change-Id: I2176fe57afc96d8cf1fe1c694836305ddc3c3420
	Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 39th commit message:

	iommu: msm: Don't treat address 0 as an error case

	Currently, the iommu page table code treats a scattergather
	list with physical address 0 as an error. This may not be
	correct in all cases. Physical address 0 is a valid part
	of the system and may be used for valid page allocations.
	Nothing else in the system checks for physical address 0
	for error so don't treat it as an error.

	Change-Id: Ie9f0dae9dace4fff3b1c3449bc89c3afdd2e63a0
	CRs-Fixed: 478304
	Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 40th commit message:

	msm: kgsl: prevent race between mmap() and free on timestamp

	When KGSL_MEMFLAGS_USE_CPU_MAP is set, we must check that the
	address from get_unmapped_area() is not used as part of a
	mapping that is present only in the GPU pagetable and not the
	CPU pagetable. These mappings can occur because when a buffer
	is freed on timestamp, the CPU mapping is destroyed immediately
	but the GPU mapping is not destroyed until the GPU timestamp
	has passed.

	Because kgsl_mem_entry_detach_process() removed the rbtree
	entry before removing the iommu mapping, there was a window
	of time where kgsl thought the address was available even
	though it was still present in the iommu pagetable. This
	could cause the address to get assigned to a new buffer,
	which would cause iommu_map_range() to fail since the old
	mapping was still in the pagetable. Prevent this race by
	removing the iommu mapping before removing the rbtree entry
	tracking the address.

	Change-Id: I8f42d6d97833293b55fcbc272d180564862cef8a
	CRs-Fixed: 480222
	Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 41st commit message:

	msm: kgsl: add guard page support for imported memory

	Imported memory buffers sometimes do not have enough
	padding to prevent page faults due to overzealous
	GPU prefetch. Attach guard pages to their mappings
	to prevent these faults.

	Because we don't create the scatterlist for some
	types of imported memory, such as ion, the guard
	page is no longer included as the last entry in
	the scatterlist. Instead, it is handled by
	size ajustments and a separate iommu_map() call
	in the kgsl_mmu_map() and kgsl_mmu_unmap() paths.

	Change-Id: I3af3c29c3983f8cacdc366a2423f90c8ecdc3059
	Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 42nd commit message:

	msm: kgsl: fix kgsl_mem_entry refcounting

	Make kgsl_sharedmem_find* return a reference to the
	entry that was found. This makes using an entry
	without the mem_lock held less race prone.

	Change-Id: If6eb6470ecfea1332d3130d877922c70ca037467
	Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 43rd commit message:

	msm: kgsl: add ftrace for cache operations

	Add the event kgsl_mem_sync_cache. This event is
	emitted when only a cache operation is actually
	performed. Attempts to flush uncached memory,
	which do nothing, do not cause this event.

	Change-Id: Id4a940a6b50e08b54fbef0025c4b8aaa71641462
	Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 44th commit message:

	msm: kgsl: Add support for bulk cache operations

	Add a new ioctl, IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK, which can be used
	to sync a number of memory ids at once. This gives the driver an
	opportunity to optimize the cache operations based on the total
	working set of memory that needs to be managed.

	Change-Id: I9693c54cb6f12468b7d9abb0afaef348e631a114
	Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 45th commit message:

	msm: kgsl: flush the entire cache when the bulk batch is large

	On 8064 and 8974, flushing more than 16mb of virtual address
	space is slower than flushing the entire cache. So flush
	the entire cache when the working set is larger than this.
	The threshold for full cache flush can be tuned at runtime via
	the full_cache_threshold sysfs file.

	Change-Id: If525e4c44eb043d0afc3fe42d7ef2c7de0ba2106
	Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 46th commit message:

	msm: kgsl: Use a read/lock for the context idr

	Everybody loves a rcu but in this case we are dangerously mixing rcus and
	atomic operations.  Add a read/write lock to explicitly protect the idr.
	Also fix a few spots where the idr was used without protection.

	Change-Id: Ic0dedbad517a9f89134cbcf7af29c8bf0f034708
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 47th commit message:

	msm: kgsl: embed kgsl_context struct in adreno_context struct

	Having a separate allocated struct for the device specific context
	makes ownership unclear, which could lead to reference counting
	problems or invalid pointers. Also, duplicate members were
	starting to appear in adreno_context because there wasn't a safe
	way to reach the kgsl_context from some parts of the adreno code.
	This can now be done via container_of().

	This change alters the lifecycle of the context->id, which is
	now freed when the context reference count hits zero rather
	than in kgsl_context_detach().

	It also changes the context creation and destruction sequence.
	The device specific code must allocate a structure containing
	a struct kgsl_context and passes a pointer it to kgsl_init_context()
	before doing any device specific initialization. There is also a
	separate drawctxt_detach() callback for doing device specific
	cleanup. This is separate from freeing memory, which is done
	by the drawctxt_destroy() callback.

	Change-Id: I7d238476a3bfec98fd8dbc28971cf3187a81dac2
	Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 48th commit message:

	msm: kgsl: Take a reference count on the active adreno draw context

	Take a reference count on the currently active draw context to keep
	it from going away while we are maintaining a pointer to it in the
	adreno device.

	Change-Id: Ic0dedbade8c09ecacf822e9a3c5fbaf6e017ec0c
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 49th commit message:

	msm: kgsl: Add a command dispatcher to manage the ringbuffer

	Implements a centralized dispatcher for sending user commands
	to the ringbuffer. Incoming commands are queued by context and
	sent to the hardware on a round robin basis ensuring each context
	a small burst of commands at a time.  Each command is tracked
	throughout the pipeline giving the dispatcher better knowledge
	of how the hardware is being used.  This will be the basis for
	future per-context and cross context enhancements as priority
	queuing and server-side syncronization.

	Change-Id: Ic0dedbad49a43e8e6096d1362829c800266c2de3
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 50th commit message:

	msm: kgsl: Only turn on the idle timer when active_cnt is 0

	Only turn on the idle timer when the GPU expected to be quiet.

	Change-Id: Ic0dedbad57846f1e7bf7820ec3152cd20598b448
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 51st commit message:

	msm: kgsl: Add a ftrace event for active_cnt

	Add a new ftrace event for watching the rise and fall of active_cnt:

	  echo 1 > /sys/kernel/debug/tracing/events/kgsl/kgsl_active_count/enable

	This will give you the current active count and the caller of the function:

	  kgsl_active_count: d_name=kgsl-3d0 active_cnt=8e9 func=kgsl_ioctl

	Change-Id: Ic0dedbadc80019e96ce759d9d4e0ad43bbcfedd2
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 52nd commit message:

	msm: kgsl: Implement KGSL fault tolerance policy in the dispatcher

	Implement the KGSL fault tolerance policy for faults in the dispatcher.
	Replay (or skip) the inflight command batches as dictated by the policy,
	iterating progressively through the various behaviors.

	Change-Id: Ic0dedbade98cc3aa35b26813caf4265c74ccab56
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 53rd commit message:

	msm: kgsl: Don't process events if the timestamp hasn't changed

	Keep track of the global timestamp every time the event code runs.
	If the timestamp hasn't changed then we are caught up and we can
	politely bow out.  This avoids the situation where multiple
	interrupts queue the work queue multiple times:

	   IRQ
	     -> process events
	   IRQ
	   IRQ
	     -> process events

	The actual retired timestamp in the first work item might be well
	ahead of the delivered interrupts. The event loop will end up
	processing every event that has been retired by the hardware
	at that point. If the work item gets re-queued by a subesquent
	interrupt then we might have already addressed all the pending
	timestamps.

	Change-Id: Ic0dedbad79722654cb17e82b7149e93d3c3f86a0
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 54th commit message:

	msm: kgsl: Make active_cnt an atomic variable

	In kgsl_active_cnt_light() the mutex was needed just to check and
	increment the active_cnt value.  Move active_cnt to an atomic to
	begin the task of freeing ourselves from the grip of the device
	mutex if we can avoid it.

	Change-Id: Ic0dedbad78e086e3aa3559fab8ecebc43539f769
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 55th commit message:

	msm: kgsl: Add a new command submission API

	Add an new ioctl entry point for submitting commands to the GPU
	called IOCTL_KGSL_SUBMIT_COMMANDS.

	As with IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS the user passes a list of
	indirect buffers, flags and optionally a user specified timestamp. The
	old way of passing a list of indirect buffers is no longer supported.

	IOCTL_KGSL_SUBMIT_COMMANDS also allows the user to define a
	list of sync points for the command. Sync points are dependencies
	on events that need to be satisfied before the command will be issued
	to the hardware.  Events are designed to be flexible.  To start with
	the only events that are supported are GPU events for a given context/
	timestamp pair.

	Pending events are stored in a list in the command batch. As each event is
	expired it is deleted from the list. The adreno dispatcher won't send the
	command until the list is empty.  Sync points are not supported for Z180.

	CRs-Fixed: 468770
	Change-Id: Ic0dedbad5a5935f486acaeb033ae9a6010f82346
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 56th commit message:

	msm: kgsl: add kgsl_sync_fence_waiter for server side sync

	For server side sync the KGSL kernel module needs to perform
	an asynchronous wait for a fence object prior to issuing
	subsequent commands.

	Change-Id: I1ee614aa3af84afc4813f1e47007f741beb3bc92
	Signed-off-by: Jeff Boody <jboody@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 57th commit message:

	msm: kgsl: Add support for KGSL_CMD_SYNCPOINT_TYPE_FENCE

	Allow command batches to wait for external fence sync events.

	Change-Id: Ic0dedbad3a211019e1cd3a3d62ab6a3e4d4eeb05
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 58th commit message:

	msm: kgsl: fix potential double free of the kwaiter

	Change-Id: Ic0dedbad66a0af6eaef52b2ad53c067110bdc6e4
	Signed-off-by: Jeff Boody <jboody@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

	# This is the 59th commit message:

	msm: kgsl: free an event only after canceling successfully

	Change-Id: Ic0dedbade256443d090dd11df452dc9cdf65530b
	Signed-off-by: Jeff Boody <jboody@codeaurora.org>
	Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
2013-06-28 18:40:41 +00:00
Naseer Ahmed
3ff9b8e96a msm: mdp: Update sync pt. behaviour
Add a retire fence and clean up the existing release fence
implementation

Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
Change-Id: Iecf7e95d0786ac43aa6a12d70442936600c0249a
2013-06-26 16:28:49 -07:00
yetta_wu
951ba1b0f4 display: slimport: update phy register values for flo
update phy register values for flo to pass HDMI eye diagram test

Change-Id: I8075ee0f2137581fa256f378c380e41ac034ca1d
Signed-off-by: yetta_wu <yetta_wu@asus.com>
2013-06-05 15:26:15 +00:00
Mekala Natarajan
d4e18f2c32 msm:rq_stats: Add hotplug disable attribute
Register for suspend and resume notifications from kernel. This should
be done as part of core_initcall so as to receive notification as close
as possible to the actual event. Add hotplug_disable attribute to
rq-stats node. Set/clear this attribute based on the suspend/resume events.

CRS-fixed: 452456
Bug: 9022807
Change-Id: I76fee349b57f47df40785e9c2503e2e1cc6e064e
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
2013-06-03 16:22:04 +00:00
yetta_wu
545a7ece19 display: slimport: update driver to v0.4
2013-05-10
V0.4
1. To be compatible with combo dongle.
2. To be compatible with dongle of other venders'.
3. Add HDCP dynamically switch sysfs path
   /sys/devices/i2c-0/0-0039/hdcp_switch
4. Add some phy register settings for eye diagram on deb
5. Modify the codes to conform to linux coding style

Change-Id: I22a085be67143c74960f391af03ee42a7106d196
Signed-off-by: yetta_wu <yetta_wu@asus.com>
2013-05-28 11:36:00 +08:00
Mekala Natarajan
5eea299803 sched: provide per cpu-cgroup option to notify on migrations
On systems where CPUs may run asynchronously, task migrations
between CPUs running at grossly different speeds can cause
problems.

This change provides a mechanism to notify a subsystem
in the kernel if a task in a particular cgroup migrates to a
different CPU. Other subsystems (such as cpufreq) may then
register for this notifier to take appropriate action when
such a task is migrated.

The cgroup attribute to set for this behavior is
"notify_on_migrate" .

Change-Id: Ie1868249e53ef901b89c837fdc33b0ad0c0a4590
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
2013-05-23 06:08:25 +00:00
Hank_Lee
3291013b3d charger: smb345: setup wireless charging current limit orderly
1. detect wireless charging
2. set input current limit as 300 mA and disable AICL
3. after 2 seconds, set input current limit as 500 mA
4. after 2 seconds, set input current limit as 700 mA

Change-Id: Ia91ea674ba7eea45f92421d13b75a578a2d21a77
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
2013-05-09 16:41:50 +00:00
tryout_chen
c7b57708c1 CAP1106: Fine tune params based on BODYSAR, add APP2MDM_SAR support, code refinement.
Change-Id: Ic7499b0dc1a5005cc6dfba29d061bd4164cd4a7a
Signed-off-by: tryout_chen <tryout_chen@asus.com>
2013-05-09 16:33:36 +00:00
Hank_Lee
fdf1b1cd3a charger: smb345: config charging type priority since hardware rev_c
Priority is : 1. AC, 2. wireless charging, 3. USB.
Charger default setting is that wireless charger has higher priority,
so disable wireless charging when AC is plugged in since hardare rev_c.

Bug: 8411313
Change-Id: I6da25d1d6fbdf683421918229babba0ab97afebc
Signed-off-by: Hank_Lee <Hank_Lee@asus.com>
2013-04-30 16:30:18 +08:00
Mekala Natarajan
e63c5a50c9 msm: ipc: Security updates to IPC Router
In order to provide fine-grained access control to QMI services,
a security script from user-space will feed the security rules to
IPC Router. The security rule implies that in order to send a QMI
message to a service, a client process should belong to a specific
Linux/Android group. IPC Router, after receiving the security rules,
will enforce the access control rules.

Change-Id: I49f8d7c0067fc37cb0b4de2ccb46a575905ef64f
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
Signed-off-by: Mekala Natarajan <mekalan@codeaurora.org>
2013-04-23 19:31:34 -07:00
Sameer Thalappil
1fd2476da5 nl80211/cfg80211: add VHT MCS support
Add support for reporting and calculating VHT MCSes.

Note that I'm not completely sure that the bitrate
calculations are correct, nor that they can't be
simplified.

Change-Id: Id4c132850a85ff59f0fc16396763ed717689bec0
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Git-commit: db9c64cf8d9d3fcbc34b09d037f266d1fc9f928c
Git-repo:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Sameer Thalappil <sameert@codeaurora.org>
2013-04-18 16:09:30 -07:00
Sakshi Agrawal
efe7e4749a msm: kgsl: Add a type field to the adreno draw context flags
Allow the user space to pass in a type field to indicate the
type of upper level library that owns the context. The type
field is added to all the appropriate ftrace output for easier
debugging.

Change-Id: Ic0dedbadd42fc5ccfffd89738affd4794a6ab85e
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Sakshi Agrawal <sakshia@codeaurora.org>
2013-04-18 16:09:28 -07:00
sam_chen
4095062f42 Audio: soc: wcd9310: workaround for d-mic noise on flo hardware revision C.
On flo hardware revision C, micbias1 is not grounded with external
capacity, so it should set micbias1 capless setting as 1
(no external bypass capacity) to avoid noise.

Bug:8611206

Change-Id: I82644a9123d092490ccc0acf6cdfa68964ef9c22
Signed-off-by: sam_chen <sam_chen@asus.com>
2013-04-18 16:09:24 -07:00
Alexandre SIMON
b2a127bf8c printk: fix buffer overflow when calling log_prefix function from call_console_drivers
This patch corrects a buffer overflow in kernels from 3.0 to 3.4 when calling
log_prefix() function from call_console_drivers().

This bug existed in previous releases but has been revealed with commit
162a7e7500 (2.6.39 => 3.0) that made changes
about how to allocate memory for early printk buffer (use of memblock_alloc).
It disappears with commit 7ff9554bb578ba02166071d2d487b7fc7d860d62 (3.4 => 3.5)
that does a refactoring of printk buffer management.

In log_prefix(), the access to "p[0]", "p[1]", "p[2]" or
"simple_strtoul(&p[1], &endp, 10)" may cause a buffer overflow as this
function is called from call_console_drivers by passing "&LOG_BUF(cur_index)"
where the index must be masked to do not exceed the buffer's boundary.

The trick is to prepare in call_console_drivers() a buffer with the necessary
data (PRI field of syslog message) to be safely evaluated in log_prefix().

This patch can be applied to stable kernel branches 3.0.y, 3.2.y and 3.4.y.

Without this patch, one can freeze a server running this loop from shell :
  $ export DUMMY=`cat /dev/urandom | tr -dc '12345AZERTYUIOPQSDFGHJKLMWXCVBNazertyuiopqsdfghjklmwxcvbn' | head -c255`
  $ while true do ; echo $DUMMY > /dev/kmsg ; done

The "server freeze" depends on where memblock_alloc does allocate printk buffer :
if the buffer overflow is inside another kernel allocation the problem may not
be revealed, else the server may hangs up.

Signed-off-by: Alexandre SIMON <Alexandre.Simon@univ-lorraine.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-04-18 16:09:23 -07:00
mars_kao
85d0fd9a18 TouchScreen:571K/KL: Modify the Y resolution.
the y coordinate is from 0 to 1343.

Change-Id: Ie06c25bf469e42b8db6b5479530df299823d04ef
Signed-off-by: mars_kao <mars_kao@asus.com>
2013-04-18 16:09:23 -07:00
yetta_wu
8ca7624ab7 display: JDI: config backlight level when kernel init
1. Remove the gpio 26 config in board-flo-pmic.c
   since this gpio is already config as PWM function in LK.

2. Add pwm_init function implementation.

3. Config backlight level in pm8xxx_led_probe(), and remove the
   pwm_request() part in panel probe function.

Change-Id: I3ce71a9c792ce155bebabd80a24a8ff8fc361ae9
Signed-off-by: yetta_wu <yetta_wu@asus.com>
2013-04-18 16:09:22 -07:00
Naseer Ahmed
d25a3ce0e5 msm: display: plane alpha support
Clean up the blending rule to follow blend_op set from hwc.
Use modulate alpha for plane alpha when it is not 0xff.
Keep backward compatibility if blend_op is not set.

Change-Id: I02fd3c3c7b5ace2e6eec22b2db0284161404a0fc
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
2013-04-18 16:09:22 -07:00
Naseer Ahmed
9beb37026c msm: rotator: non-blocking rotate
Send request to a work queue and return right away.
Work queue will go through the commit queue to do the
rotation. wait_for_finish can be set to true to make
rotation go back to blocking.

Change-Id: Ifc2e36bd24d9681d42105f4ccbb62a8777af2a6c
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
2013-04-18 16:09:21 -07:00
Naseer Ahmed
8b091599cd msm: rotator: sync point support
Add MSM_ROTATOR_IOCTL_BUFFER_SYNC ioctl interface.
Rotator will create a timeline for each session at START, wait for
input fence and create released fence in this ioctl call,
signal the timeline after rotation is done.

Change-Id: I3738f8287d804ccd94e0a16ac0afb8b41b299c75
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
2013-04-18 16:09:21 -07:00
Naseer Ahmed
74410ce2f0 msm_fb: Fix adb shell start/stop issue when bypass enabled
Currently when 2/3/4 layer bypass is enabled, doing a adb shell
stop/start is failing overlay and composition happens through
GPU. Fix this issue by proper overlay configuration during this
scenario.

Change-Id: Ia04f1839bf80ed552671e48445af63a4dcd6bdfd
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
2013-04-18 16:08:50 -07:00