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>
ARM64: fix unaligned loop in copy_from_user and copy_to_user

The unaligned loops added in commit
275a80309907a687d21a0f6fe991a0710d3a9a10 (arm64: mm: align
copy_*_user accesses) don't initialize x4, but the fault
handlers expect x4 to be the end address of the copy.
Move the initialization of x4 before the unaligned loop,
and replace the usage of x4 with x5 in the unaligned loop.

bug 1537811

Change-Id: Ic1aeaca56a9d45c4f1de9bbf9588cfc072dd5d28
Signed-off-by: Colin Cross <ccross@android.com>
Reviewed-on: http://git-master/r/450404
Reviewed-by: Richard Wiley <rwiley@nvidia.com>
Tested-by: Richard Wiley <rwiley@nvidia.com>
Reviewed-by: Karan Jhavar <kjhavar@nvidia.com>
Reviewed-by: Prajakta Gudadhe <pgudadhe@nvidia.com>
ARM64: tlbflush: fix incorrect local tlb flush check

commit 123e4f9fdd0823ce45881e5c12cf0b0c941ad823 (arm64: tlb: avoid
use of smp_processor_id()) made the incorrect assumption that
an mm with only a single cpu in the cpumask must be running on the
current cpu.  That is true for tlb flushes triggered by the process,
but is not true for tlb flushes that come from another process,
for example in direct reclaim, which may unmap clean pages from other
processes in order to free memory.

Go back to the simpler check for whether the mm has been used on
any other cpu, but disable preemption to avoid a context switch
between smp_processor_id() and the local tlb flush.

bug 1539886

Change-Id: I09a65776e102885460ade0a1fabe13afb8253214
Signed-off-by: Colin Cross <ccross@android.com>
Reviewed-on: http://git-master/r/450405
Reviewed-by: Richard Wiley <rwiley@nvidia.com>
Tested-by: Richard Wiley <rwiley@nvidia.com>
Reviewed-by: Karan Jhavar <kjhavar@nvidia.com>
Reviewed-by: Prajakta Gudadhe <pgudadhe@nvidia.com>
video: tegra: adf: replace nvmap_alloc_dmabuf with v4l2 API

Replace deprecated nvmap_alloc_dmabuf with V4L2 videobuf2 contig dma API.

Bug 1540346

Change-Id: I06dd4a64a5a548d29443a0dfb8e4ccdeee62644c
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: http://git-master/r/450681
Reviewed-by: Mandar Padmawar <mpadmawar@nvidia.com>
Tested-by: Mandar Padmawar <mpadmawar@nvidia.com>
video: adf: fix incorrect dependency on DMA_SHARED_BUFFER

ADF should select DMA_SHARED_BUFFER instead of depending on it.

Bug 1540346

Change-Id: I6e9e83df1e30834d072a86b525f80461e1b13e62
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: http://git-master/r/451063
Tested-by: Michael I Gold <gold@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Michael I Gold <gold@nvidia.com>
video: tegra: nvmap: Fix sleeping while atomic warning

When reading /d/nvmap/iovmm/procrank, we first take clients_lock
spin_lock and then take ref_lock mutex inside nvmap_iovmm_get_client_mss.
This creates mutex inside spin_lock situation. To fix this,
clients_lock is converted to mutex.

bug 1540937

Change-Id: I7f3b37791c119dd94a3ce65e06a2926a7e1db25c
Signed-off-by: Gaurav Sarode <gsarode@nvidia.com>
Reviewed-on: http://git-master/r/451076
Reviewed-by: Maneet Maneet Singh <mmaneetsingh@nvidia.com>
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Prajakta Gudadhe <pgudadhe@nvidia.com>