usb: gadget: f_audio_source: change max ISO packet size

Re-applying from
https://gitorious.org/shr/linux/commit/eb4c9d2db894c3492c0a848581bd4f6790f93d5f

Most USB-AUDIO devices are limited to 256 byte for max iso buffer size.
If a IN_EP_MAX_PACKET_SIZE is bigger than a USB-AUDIO device's max iso
buffer size, it will cause noise. This patch will prevent this case as
possibe by reducing packet size. When using 44.1khz, 2ch, 16bit audio
data, if max packet size is bigger than 176 bytes, it's no problem.

Credits to: Iliyan Malchev <malchev@google.com>

Change-Id: Ic2a1c19ea65d5fb42bf12926b51b255b465d7215
Signed-off-by: Anson Jacob <ansonkuzhumbil@gmail.com>
usb: gadget: f_audio_source: Fixed USB Audio Class Interface Descriptor

Fixed Android Issue #56549.

When both Vendor Class and Audio Class are activated for AOA 2.0,
the baInterfaceNr of the AudioControl Interface Descriptor points
to wrong interface numbers. They should be pointing to
Audio Control Device and Audio Streaming interfaces.

Replaced baInterfaceNr with the correct value.

Change-Id: Iaa083f3d97c1f0fc9481bf87852b2b51278a6351
Signed-off-by: Anson Jacob <ansonkuzhumbil@gmail.com>
ext4: Add support for FIDTRIM, a best-effort ioctl for deep discard trim

* What
This provides an interface for issuing an FITRIM which uses the
secure discard instead of just a discard.
Only the eMMC command is "secure", and not how the FS uses it:
due to the fact that the FS might reassign a region somewhere else,
the original deleted data will not be affected by the "trim" which only
handles un-used regions.
So we'll just call it "deep discard", and note that this is a
"best effort" cleanup.

* Why
Once in a while, We want to be able to cleanup most of the unused blocks
after erasing a bunch of files.
We don't want to constantly secure-discard via a mount option.

From an eMMC spec perspective, it tells the device to really get rid of
all the data for the specified blocks and not just put them back into the
pool of free ones (unlike the normal TRIM). The eMMC spec says the
secure trim handling must make sure the data (and metadata) is not available
anymore. A simple TRIM doesn't clear the data, it just puts blocks in the
free pool.
JEDEC Standard No. 84-A441
  7.6.9 Secure Erase
  7.6.10 Secure Trim

From an FS perspective, it is acceptable to leave some data behind.
 - directory entries related to deleted files
 - databases entries related to deleted files
 - small-file data stored in inode extents
 - blocks held by the FS waiting to be re-used (mitigated by sync).
 - blocks reassigned by the FS prior to FIDTRIM.

Change-Id: I676a1404a80130d93930c84898360f2e6fb2f81e
Signed-off-by: Geremy Condra <gcondra@google.com>
Signed-off-by: JP Abgrall <jpa@google.com>
video: tegra: dc: implement vblank event

Implement TEGRA_DC_EXT_EVENT_VBLANK for user space notification of
vblank events.  Implement TEGRA_DC_EXT_SET_VBLANK to enable/disable
vblank notification per display.

bug 200016696

Change-Id: Idf8d02b71976a32e06fe972cfb69b838183bcf02
Signed-off-by: Michael I. Gold <gold@nvidia.com>
Reviewed-on: http://git-master/r/432658
(cherry picked from commit 48f3294dcd7044dbe9dd2845dc9096fefbb244fa)
Reviewed-on: http://git-master/r/442025
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
regmap: Make regmap-mmio usable from atomic contexts

regmap-mmio uses a spinlock with spin_lock() and spin_unlock() for locking.
To be able to use the regmap API from different contexts (atomic vs non-atomic),
without the risk of race conditions, we need to use spin_lock_irqsave() and
spin_lock_irqrestore() instead. A new field, the spinlock_flags field, is added
to regmap struct to store the flags between regmap_{,un}lock_spinlock(). The
spinlock_flags field itself is also protected by the spinlock.

Thanks to Stephen Warren for the suggestion of this particular solution.

Change-Id: Id808b77eccd547ee2eb7533eb1e2b0036d3794ea

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
(cherry picked from commit 92ab1aab59c61b3e05200b9aa0e05ab770059142)
Signed-off-by: Ravindra Lokhande <rlokhande@nvidia.com>
Change-Id: Ic33d5c97842204e69b0e13fdee7455be52f5ea35
Reviewed-on: http://git-master/r/448807
Reviewed-by: Prajakta Gudadhe <pgudadhe@nvidia.com>
video: tegra: dc: fix holding refcount

Fix a logic error in tegra_dc_hold_dc_out which increments a refcount
twice during initialization.

bug 200016696

Change-Id: Ia21e3c5f6d734a3fdafbc43b3c4bd253f5bdcd44
Signed-off-by: Michael I. Gold <gold@nvidia.com>
video: tegra: adf: Remove DC_EXTENSIONS dependency

Disable CONFIG_TEGRA_DC_EXTENSIONS when ADF is enabled.  Add
appropriate ifdefs code so DC_EXTENSIONS ciode won't build as part of
an ADF-enabled driver.

ADF has two seperate interface for hotplug connect and disconnect,
and ADF_EVENT_HOTPLUG must have connect state as payload.  Thus
event simulation in debugfs was modified us following:

ADF:
0x0 - ADF_EVENT_HOTPLUG (connect=1)
0x1 - ADF_EVENT_HOTPLUG (connect=0)
0x2 - TEGRA_ADF_EVENT_BANDWIDTH_RENEGOTIATE (bw=0)

DC_EXT:
0x0 - TEGRA_DC_EXT_EVENT_HOTPLUG
0x1 - TEGRA_DC_EXT_EVENT_HOTPLUG
0x2 - TEGRA_DC_EXT_EVENT_BANDWIDTH_DEC

Bug 1459374

Change-Id: Idecbc269504966c371d49dc0307bddce96c52fbe
Signed-off-by: Xia Yang <xiay@nvidia.com>
Reviewed-on: http://git-master/r/427912
Reviewed-by: Michael I Gold <gold@nvidia.com>
Tested-by: Michael I Gold <gold@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Prajakta Gudadhe <pgudadhe@nvidia.com>
usb: gadget: android: add default setup packet complete callback

Adding the default setup packet complete callback in
android gadget driver. If this is not initialized in current
thread, initialization from previous thread calls are carried forward
and calling unnecessary complete callback is leading system to
undesirable state. Issue is seen when booted with accessory device.

Bug 200014405

Change-Id: Ib3075f65803e754138b47e7c705fa407ab6f1dea
Signed-off-by: Rakesh Bodla <rbodla@nvidia.com>
Reviewed-on: http://git-master/r/449312
Reviewed-by: Mandar Padmawar <mpadmawar@nvidia.com>
Tested-by: Mandar Padmawar <mpadmawar@nvidia.com>
video: tegra: hdmi: Fix HDMI connect state

Revert 006fffc2 partially to fix HDMI connect state tracking.

Bug 1459374

Change-Id: Icc1b0eee3ae6f4202b4a46f858d447ad5656aebc
Signed-off-by: Xia Yang <xiay@nvidia.com>
Reviewed-on: http://git-master/r/433313
Reviewed-by: Michael I Gold <gold@nvidia.com>
Tested-by: Michael I Gold <gold@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Jon Mayo <jmayo@nvidia.com>
Reviewed-by: Prajakta Gudadhe <pgudadhe@nvidia.com>
Revert "mm: memblock: add memblock_end_of_4G(...)"

The upstream memblock_find_in_range() can be used to find viable carveouts in a
specified region.  Since memblock_find_in_range() takes a size, it also ensures
the carveout has not been previously memblock_alloc()ed.

Bug 1459374

This reverts commit 9e49471324c862392206faba60ac5632f0e34d64.
(cherry picked from commit efccb5a48493231e4fd4212377caa040a86ecc0f)

Change-Id: I93d1d3a9cb99e1ea53930ad8cf41ca80a2927289
Signed-off-by: Michael I. Gold <gold@nvidia.com>
Reviewed-on: http://git-master/r/448244
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
video: tegra: adf: clear DPMS state on unplug

Notify the higher level code that the display is disabled on HDMI
unplug.

bug 1459374

Change-Id: I9bb74313378c3050096fe2e0162d8d83ce726400
Signed-off-by: Michael I. Gold <gold@nvidia.com>
Reviewed-on: http://git-master/r/448296
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
Reviewed-by: Jon Mayo <jmayo@nvidia.com>
video: tegra: adf: pass fb_info to fb_notifier

Pass the fb_info pointer to the fb_notifier to fix a NULL pointer
deref in .fb_check().

bug 1459374

Change-Id: I6be42bfbadfee91dc7dc31d47c9f2525d92659e0
Signed-off-by: Michael I. Gold <gold@nvidia.com>
Reviewed-on: http://git-master/r/449522
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
Reviewed-by: Jon Mayo <jmayo@nvidia.com>
ARM: tegra: replace memblock_end_of_4G() with memblock_find_in_range()

memblock_end_of_4G() is not part of the upstream kernel, and does not
protect the caller from carving out a range that overlaps with a
memblock_alloc()ed region.  Reimplement memblock_end_of_4G() as a helper
in terms of memblock_find_in_range().

Bug 1459374

Change-Id: Iea8ea360c9c3548b758a59059f309956434e5513
Signed-off-by: Greg Hackmann <ghackmann@google.com>
(cherry picked from commit 91e05337b74dc68fc24a31e79e68a75b1ddcebc7)
Reviewed-on: http://git-master/r/437893
Reviewed-by: Michael I Gold <gold@nvidia.com>
Tested-by: Michael I Gold <gold@nvidia.com>
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
ARM: tegra: update DFLL tune parameters

update tune1 from 0x99 to 0x95

bug 1442659

Change-Id: I8f6fb9b2400504d0884b322254082aa814bd8cb9
Signed-off-by: Ishwarya Balaji Gururajan <igururajan@nvidia.com>
Reviewed-on: http://git-master/r/439470
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Aleksandr Frid <afrid@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Thomas Cherry <tcherry@nvidia.com>
arch: arm64: dts: remove 'pmu_undershoot_gb' property initialization

bug 1528672

Change-Id: I2219e9d06ddd0e72761397a265734e43c25a0c1b
Signed-off-by: Hridya Valsaraju <hvalsaraju@nvidia.com>
Reviewed-on: http://git-master/r/439485
Reviewed-by: Mandar Padmawar <mpadmawar@nvidia.com>
Tested-by: Mandar Padmawar <mpadmawar@nvidia.com>
Merge branch 'android-tegra-nv-3.10' into android-tegra-3.10

Conflicts:
	arch/arm/mach-tegra/common.c
	arch/arm/mach-tegra/include/mach/tegra_dc_ext.h
	drivers/video/tegra/dc/ext/dev.c

Change-Id: I917e9aa78f3d36024e87bf9df2c6edb15a7001cd
arm64: restrict effects of ARMV7_COMPAT_CPUINFO to ARMv7 tasks

Bug: 16819658

Change-Id: I00ab24f667a8ace97d0b9e8d1851e25715c1f1f9
Signed-off-by: Greg Hackmann <ghackmann@google.com>
input: cfboost: disable gpu_wakeup by default

gpu_wakeup causes the GPU to load its firmware, but the partition it's
stored on is not always available.  Instead default to 0; init.rc can
set it 1 after the needed partition is mounted.

Bug: 16777410

Change-Id: I9b03f62c25e491b230f1385e5b0c66fdf4789b63
Signed-off-by: Greg Hackmann <ghackmann@google.com>
staging: android: ashmem: Avoid deadlock with mmap/shrink

Both ashmem_mmap and ashmem_shrink take the ashmem_lock. It may
be possible for ashmem_mmap to invoke ashmem_shrink:

-000|mutex_lock(lock = 0x0)
-001|ashmem_shrink(?, sc = 0x0) <--- try to take ashmem_mutex again
-002|shrink_slab(shrink = 0xDA5F1CC0, nr_pages_scanned = 0, lru_pages
-002|=
-002|124)
-003|try_to_free_pages(zonelist = 0x0, ?, ?, ?)
-004|__alloc_pages_nodemask(gfp_mask = 21200, order = 1, zonelist =
-004|0xC11D0940,
-005|new_slab(s = 0xE4841E80, ?, node = -1)
-006|__slab_alloc.isra.43.constprop.50(s = 0xE4841E80, gfpflags =
-006|2148925462, ad
-007|kmem_cache_alloc(s = 0xE4841E80, gfpflags = 208)
-008|shmem_alloc_inode(?)
-009|alloc_inode(sb = 0xE480E800)
-010|new_inode_pseudo(?)
-011|new_inode(?)
-012|shmem_get_inode(sb = 0xE480E800, dir = 0x0, ?, dev = 0, flags =
-012|187)
-013|shmem_file_setup(?, ?, flags = 187)
-014|ashmem_mmap(?, vma = 0xC5D64210) <---- Acquire ashmem_mutex
-015|mmap_region(file = 0xDF8E2C00, addr = 1772974080, len = 233472,
-015|flags = 57,
-016|sys_mmap_pgoff(addr = 0, len = 230400, prot = 3, flags = 1, fd =
-016|157, pgoff
-017|ret_fast_syscall(asm)
-->|exception
-018|NUR:0x40097508(asm)
---|end of frame

Avoid this deadlock by using mutex_trylock in ashmem_shrink; if the mutex
is already held, do not attempt to shrink.

Change-Id: I222bbf55856d5849da813b730de0636c80966c8e
Reported-by: Matt Wagantall <mattw@codeaurora.org>
Reported-by: Syed Rameez Mustafa <rameezmustafa@codeaurora.org>
Reported-by: Osvaldo Banuelos <osvaldob@codeaurora.org>
Reported-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
firmware: Avoid deadlock of usermodehelper lock at shutdown

When a system goes to reboot/shutdown, it tries to disable the
usermode helper via usermodehelper_disable().  This might be blocked
when a driver tries to load a firmware beforehand and it's stuck by
some reason.  For example, dell_rbu driver loads the firmware in
non-hotplug mode and waits for user-space clearing the loading sysfs
flag.  If user-space doesn't clear the flag, it waits forever, thus
blocks the reboot, too.

As a workaround, in this patch, the firmware class driver registers a
reboot notifier so that it can abort all pending f/w bufs before
issuing usermodehelper_disable().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Acked-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Conflicts:
	drivers/base/firmware_class.c

Change-Id: I7ff6c198cd34090e55845b9d4035b1e5dc86226b