Add ROW I/O Scheduler by Qualcomm.

Change-Id: I937bfa6d1d7c3911fa5193e4849310a6a04bd0c2
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>

block: Add support for reinsert a dispatched req

Add support for reinserting a dispatched request back to the
scheduler's internal data structures.
This capability is used by the device driver when it chooses to
interrupt the current request transmission and execute another (more
urgent) pending request. For example: interrupting long write in order
to handle pending read. The device driver re-inserts the
remaining write request back to the scheduler, to be rescheduled
for transmission later on.

Add API for verifying whether the current scheduler
supports reinserting requests mechanism. If reinsert mechanism isn't
supported by the scheduler, this code path will never be activated.

Change-Id: I5c982a66b651ebf544aae60063ac8a340d79e67f
Signed-off-by: Tatyana Brokhman <tlinder@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>

block: Add API for urgent request handling

This patch add support in block & elevator layers for handling
urgent requests. The decision if a request is urgent or not is taken
by the scheduler. Urgent request notification is passed to the underlying
block device driver (eMMC for example). Block device driver may decide to
interrupt the currently running low priority request to serve the new
urgent request. By doing so READ latency is greatly reduced in read&write
collision scenarios.

Note that if the current scheduler doesn't implement the urgent request
mechanism, this code path is never activated.

Change-Id: I8aa74b9b45c0d3a2221bd4e82ea76eb4103e7cfa
Signed-off-by: Tatyana Brokhman <tlinder@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>

block: row: squash commits from codeaurora.

Change-Id: I4b2da028b463005cff7f7ab58ddfdaf1c77d6792
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>

block: fixes required to make the kernel compile with ROW.

Change-Id: I162bf4e86c611093270929059ca594651512d51f
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>

sysfs: Fix memory leak in sysfs_sd_setsecdata().

This patch fixies follwing two memory leak patterns that reported by kmemleak.
sysfs_sd_setsecdata() is called during sys_lsetxattr() operation.
It checks sd->s_iattr is NULL or not. Then if it is NULL, it calls
sysfs_init_inode_attrs() to allocate memory.
That code is this.

iattrs = sd->s_iattr;
if (!iattrs)
                iattrs = sysfs_init_inode_attrs(sd);

The iattrs recieves sysfs_init_inode_attrs()'s result,  but sd->s_iattr
doesn't know the address. so it needs to set correct address to
sd->s_iattr to free memory in other function.

unreferenced object 0xffff880250b73e60 (size 32):
  comm "systemd", pid 1, jiffies 4294683888 (age 94.553s)
  hex dump (first 32 bytes):
    73 79 73 74 65 6d 5f 75 3a 6f 62 6a 65 63 74 5f  system_u:object_
    72 3a 73 79 73 66 73 5f 74 3a 73 30 00 00 00 00  r:sysfs_t:s0....
  backtrace:
    [<ffffffff814cb1d0>] kmemleak_alloc+0x73/0x98
    [<ffffffff811270ab>] __kmalloc+0x100/0x12c
    [<ffffffff8120775a>] context_struct_to_string+0x106/0x210
    [<ffffffff81207cc1>] security_sid_to_context_core+0x10b/0x129
    [<ffffffff812090ef>] security_sid_to_context+0x10/0x12
    [<ffffffff811fb0da>] selinux_inode_getsecurity+0x7d/0xa8
    [<ffffffff811fb127>] selinux_inode_getsecctx+0x22/0x2e
    [<ffffffff811f4d62>] security_inode_getsecctx+0x16/0x18
    [<ffffffff81191dad>] sysfs_setxattr+0x96/0x117
    [<ffffffff811542f0>] __vfs_setxattr_noperm+0x73/0xd9
    [<ffffffff811543d9>] vfs_setxattr+0x83/0xa1
    [<ffffffff811544c6>] setxattr+0xcf/0x101
    [<ffffffff81154745>] sys_lsetxattr+0x6a/0x8f
    [<ffffffff814efda9>] system_call_fastpath+0x16/0x1b
    [<ffffffffffffffff>] 0xffffffffffffffff
unreferenced object 0xffff88024163c5a0 (size 96):
  comm "systemd", pid 1, jiffies 4294683888 (age 94.553s)
  hex dump (first 32 bytes):
    00 00 00 00 ed 41 00 00 00 00 00 00 00 00 00 00  .....A..........
    00 00 00 00 00 00 00 00 0c 64 42 4f 00 00 00 00  .........dBO....
  backtrace:
    [<ffffffff814cb1d0>] kmemleak_alloc+0x73/0x98
    [<ffffffff81127402>] kmem_cache_alloc_trace+0xc4/0xee
    [<ffffffff81191cbe>] sysfs_init_inode_attrs+0x2a/0x83
    [<ffffffff81191dd6>] sysfs_setxattr+0xbf/0x117
    [<ffffffff811542f0>] __vfs_setxattr_noperm+0x73/0xd9
    [<ffffffff811543d9>] vfs_setxattr+0x83/0xa1
    [<ffffffff811544c6>] setxattr+0xcf/0x101
    [<ffffffff81154745>] sys_lsetxattr+0x6a/0x8f
    [<ffffffff814efda9>] system_call_fastpath+0x16/0x1b
    [<ffffffffffffffff>] 0xffffffffffffffff
`

Change-Id: I07f43b8ca5cb298a7865bb2302e9d1533118de57
Signed-off-by: Masami Ichikawa <masami256@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

SELinux: include definition of new capabilities

The kernel has added CAP_WAKE_ALARM and CAP_EPOLLWAKEUP.  We need to
define these in SELinux so they can be mediated by policy.

Change-Id: I8a3e0db15ec5f4eb05d455a57e8446a8c2b484c2
Signed-off-by: Eric Paris <eparis@redhat.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
[sds: rename epollwakeup to block_suspend to match upstream merge]
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Ed Tam <etam@google.com>

tcp: add a sysctl to config the tcp_default_init_rwnd

The default initial rwnd was hardcoded to 10.

Now we allow it to be controlled via
  /proc/sys/net/ipv4/tcp_default_init_rwnd
which limits the values from 3 to 100

This is somewhat needed because ipv6 routes are
autoconfigured by the kernel.

See "An Argument for Increasing TCP's Initial Congestion Window"
in https://developers.google.com/speed/articles/tcp_initcwnd_paper.pdf

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

Conflicts:
	include/net/tcp.h

Change-Id: Ib2d21ceae130d0bed676ae2d2c7d29e12a6cb299

net/l2tp: don't fall back on UDP [get|set]sockopt

The l2tp [get|set]sockopt() code has fallen back to the UDP functions
for socket option levels != SOL_PPPOL2TP since day one, but that has
never actually worked, since the l2tp socket isn't an inet socket.

As David Miller points out:

  "If we wanted this to work, it'd have to look up the tunnel and then
   use tunnel->sk, but I wonder how useful that would be"

Since this can never have worked so nobody could possibly have depended
on that functionality, just remove the broken code and return -EINVAL.

Reported-by: Sasha Levin <sasha.levin@oracle.com>
Acked-by: James Chapman <jchapman@katalix.com>
Acked-by: David Miller <davem@davemloft.net>
Cc: Phil Turnbull <phil.turnbull@oracle.com>
Cc: Vegard Nossum <vegard.nossum@oracle.com>
Cc: Willy Tarreau <w@1wt.eu>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Change-Id: Iccb3384e7090e8c7cbcd717c12465c45d22c4393

fix false disconnect due to a signal sent to the reading process

- In the current implementation, when a signal is sent to the reading process,
  read is cancelled by calling usb_ep_dequeue, which lead into calling
  acc_complete_out with ECONNRESET, but the current logic treats it as
  disconnection, which makes the device inaccessible until cable is actually
  disconnected.
- The fix calls disconnect only when ESHUTDOWN error is passed.
- If data has already arrived while trying cancelling, the data is marked
  as available, and it will be read out on the next read. This is necessary
  as USB bulk is assumed to guarantee no data loss.

Change-Id: I97132d819ff37a2805ab4a74779ee59ef3944139
Signed-off-by: keunyoung <keunyoung@google.com>

ALSA: pcm - add support for hostless audio

Allow some PCM devices to be hostless, i.e. there is no PCM data transferred
to or from the host CPU. This can be used to minimise power on systems since
the CPU can idle/sleep during the PCM device operation (e.g. a phone call
where the DAI is between a MODEM and DSP)

TODO: cleanup, look at adding a read/write blocker.

Change-Id: I36f521a77f4426d38713739e4313b99c6f506089
Singed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>

ALSA: pcm - reject calls to open backend PCMs (temporary)

This stops userspace opening backlemd PCMs.

TODO: rework for upstream.

Change-Id: I579dcbf608cb30561dbb9fe7cb709190d3068111
Signed-off-by: Liam Girdwood <lrg@ti.com>

ALSA: pcm - Export snd_pcm_lib_default_mmap() helper

Export the default mmap function, snd_pcm_lib_default_mmap().
The upcoming non-snooping support in HD-audio driver will use this
to override the mmap method.

Change-Id: I9e93bb240dfc3302f26c86e0b072abf38186d913
Signed-off-by: Takashi Iwai <tiwai@suse.de>

ALSA: pcm - remove the dead code from snd_pcm_open_file()

The rpcm_file parameter is never used in current ALSA code, so remove
it to make it cleaner.

Change-Id: Iae08c17a22b865d38fb8a24803ad2e48de0bf457
Signed-off-by: Feng Tang <feng.tang@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

sound: Add module.h to the previously silent sound users

Lots of sound drivers were getting module.h via the implicit presence
of it in <linux/device.h> but we are going to clean that up.  So
fix up those users now.

Change-Id: I5cc8cd4356f6217a91155c2dec2df575747ba623
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>

ALSA: core: Add support to handle compressed audio IOCTLs

This is needed to support the compressed audio till the
compressed core is done with development.

Change-Id: Ida1dff0d6952241809ea23b6b9de6e07c71305bb
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>

ALSA: pcm - Avoid GFP_ATOMIC in snd_pcm_link()

GFP_ATOMIC is used in snd_pcm_link() just because the kmalloc is
called inside a lock.  Since this function isn't too critical for
speed and is rarely called in practice, better to allocate the chunk
at first before spinlock and free it in error paths, so that
GFP_KERNEL can be used.

Change-Id: I3d9d27db884150fe612c860aec0fb54892a443d7
Signed-off-by: Takashi Iwai <tiwai@suse.de>

ALSA: core: Add support to handle compressed audio IOCTLs for capture

This is needed to support the compressed audio capture so that the
IOCTL commands for capture can pass to the ALSA SOC audio driver

Change-Id: I78c796275946e6e02f61aeab6579f3e9362f208b
Signed-off-by: Subhash Chandra Bose Naripeddy <snariped@codeaurora.org>

ALSA: PCM: Fix some races at disconnection

commit 9b0573c07f278e9888c352aa9724035c75784ea0 upstream.

Fix races at PCM disconnection:
- while a PCM device is being opened or closed
- while the PCM state is being changed without lock in prepare,
  hw_params, hw_free ops

Change-Id: Ie2d8ffeeb507b15e4214385eafd2a945ee393cd8
Reported-by: Matthieu CASTET <matthieu.castet@parrot.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ALSA: core: add support for compress_offload

This patch adds core.c, the file which implements the ioctls and
registers the devices

Change-Id: I7c31f7bc9b56ef117f01ef50661d7d0ac5988ada
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

ALSA: Fix memory leak on error in snd_compr_set_params()

If copy_from_user() does not return 0 we'll leak the memory we
allocated for 'params' when that variable goes out of scope.

Also a small CodingStyle cleanup: Use braces on both branches of
if/else when one branch needs it.

Change-Id: If27c4802cd2a8f7aa456ea9df42966846abaf96a
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Acked-by: Vinod Koul <vinod.koul@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

ALSA: Add a reference counter to card instance

commit a0830dbd4e42b38aefdf3fb61ba5019a1a99ea85 upstream.

For more strict protection for wild disconnections, a refcount is
introduced to the card instance, and let it up/down when an object is
referred via snd_lookup_*() in the open ops.

The free-after-last-close check is also changed to check this refcount
instead of the empty list, too.

Change-Id: I07c1145df28f0e7b51491c4c2e2d881ea5872707
Reported-by: Matthieu CASTET <matthieu.castet@parrot.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ALSA: Avoid endless sleep after disconnect

commit 0914f7961babbf28aaa2f19b453951fb4841c03f upstream.

When disconnect callback is called, each component should wake up
sleepers and check card->shutdown flag for avoiding the endless sleep
blocking the proper resource release.

Change-Id: I69a42da9e46e9b3659558e0b90d0aec9ce7904c9
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ALSA: Fix card refcount unbalance

commit 8bb4d9ce08b0a92ca174e41d92c180328f86173f upstream.

There are uncovered cases whether the card refcount introduced by the
commit a0830dbd isn't properly increased or decreased:
- OSS PCM and mixer success paths
- When lookup function gets NULL

This patch fixes these places.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=50251

Change-Id: I2ad443e03838bb572064a5dc9fdf39e7fb8b2dd0
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

ALSA: core: add compress parameter definations

The patch adds the various definations used to define the encoder
and decoder parameters

Change-Id: Iac1f483b40c05a4b3ad75936fb44f94150ae0488
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

headers: include linux/types.h where appropriate

This addresses some header check warnings.  DRM headers which include
"drm.h" have been excluded, as they indirectly include types.h.

Change-Id: I087dd4a2230ad15a5484eff4a51f4dfe9346f559
Signed-off-by: Bobby Powers <bobbypowers@gmail.com>
Cc: Chris Ball <cjb@laptop.org>
Cc: Dave Airlie <airlied@linux.ie>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

compress: add API header and driver header files

This patch adds the header files for ioctl definations and header file for
driver APIs for lower level device drivers to use

Change-Id: I9d35b1a34aab0aaee8f8b3cd3d9fad1c2d633158
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>

compress: add compress parameter definations

The patch adds the various definations used to define the encoder and decoder
parameters

Change-Id: Iaf4cced5e4a89ecb92337e2f9cf45b62c23945e7
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>

compress: add the core file

This patch ads core.c, the file which implements the ioctls and
registers the devices

Change-Id: I30a1d8b561ecd15b6a862d6948368394edd49665
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>

Fixes for 1. fixes for comments recieved on alsa-devel

2. cosmetic edits
	s/period/fragment
	corrected comments
	fixed parameters and descriptors
3. More cosmetic edits and checkpatch fixes

Squash the commits

Change-Id: I6c849673d58e8c8314c0d1e48f55c7660dcca54c
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>

Enrc2b: Make ROW default

Change-Id: Ic70e07ce3a4e5301e93a80597448916850398061

audio adjustment

Change-Id: I22b2d2f2c429f6263130b55620b863388dbce1a8