[media] usbtv: Throw corrupted frames away

Ignore out of order data and mark incomplete buffers as errored.
This gets rid of annoying flicker due to occassional garbage from hardware.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: linux-kernel@vger.kernel.org
Cc: linux-media@vger.kernel.org
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
PCI: pciehp: Convert pciehp to be builtin only, not modular

Convert pciehp to be builtin only, with no module option.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
[media] usbtv: fix dependency

This fixes a dependency problem as found by Randy Dunlap:
https://lkml.org/lkml/2013/6/27/501

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
PCI: Retry allocation of only the resource type that failed

Ben Herrenschmidt reported the following problem:

  - The bus has space for all desired MMIO resources, including optional
    space for SR-IOV devices
  - We attempt to allocate I/O port space, but it fails because the bus
    has no I/O space
  - Because of the I/O allocation failure, we retry MMIO allocation,
    requesting only the required space, without the optional SR-IOV space

This means we don't allocate the optional SR-IOV space, even though we
could.

This is related to 0c5be0cb0e ("PCI: Retry on IORESOURCE_IO type
allocations").

This patch changes how we handle allocation failures.  We will now retry
allocation of only the resource type that failed.  If MMIO allocation
fails, we'll retry only MMIO allocation.  If I/O port allocation fails,
we'll retry only I/O port allocation.

[bhelgaas: changelog]
Reference: https://lkml.kernel.org/r/1367712653.11982.19.camel@pasglop
Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Tested-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: stable@vger.kernel.org	# v3.10+
[media] hdpvr: fix iteration over uninitialized lists in hdpvr_probe()

free_buff_list and rec_buff_list are initialized in the middle of hdpvr_probe(),
but if something bad happens before that, error handling code calls hdpvr_delete(),
which contains iteration over the lists (via hdpvr_free_buffers()).
The patch moves the lists initialization to the beginning and by the way fixes
goto label in error handling of registering videodev.
Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
x86, efi: correct call to free_pages

Specify memory size in pages, not bytes.

Signed-off-by: Roy Franz <roy.franz@linaro.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
[media] em28xx: fix assignment of the eeprom data

Set the config structure pointer to the eeprom data pointer (data,
here eedata dereferenced) not the pointer to the pointer to
the eeprom data (eedata itself).

Signed-off-by: Alban Browaeys <prahal@yahoo.com>
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Cc: stable@vger.kernel.org      # for v3.10
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
x86, fpu: correct the asm constraints for fxsave, unbreak mxcsr.daz

GCC will optimize mxcsr_feature_mask_init in arch/x86/kernel/i387.c:

		memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct));
		asm volatile("fxsave %0" : : "m" (fx_scratch));
		mask = fx_scratch.mxcsr_mask;
		if (mask == 0)
			mask = 0x0000ffbf;

to

		memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct));
		asm volatile("fxsave %0" : : "m" (fx_scratch));
		mask = 0x0000ffbf;

since asm statement doesn’t say it will update fx_scratch.  As the
result, the DAZ bit will be cleared.  This patch fixes it. This bug
dates back to at least kernel 2.6.12.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: <stable@vger.kernel.org>
RDMA/ocrdma: Remove unused include

I'd like to remove rdma/ib_cache.h some day, so let's avoid
proliferating uses of it unnecessarily.

Signed-off-by: Roland Dreier <roland@purestorage.com>
Merge branch 'for-3.11-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata

Pull libata fixes from Tejun Heo:
 "Assorted libata updates.

  The most critical one is a fix for ahci oops during boot.  Also, a new
  smallish platform ahci driver is added and sata_inic162x is marked
  clearly as experimental (it whines during boot too) as data corruption
  seems rather common on the device and it's unlikely to get any love in
  the foreseeable future.  If the whining doesn't draw any attention, I
  think we'd probably be better of making the driver depend on BROKEN in
  a couple releases"

This is v2 of this pull request with fixed dependencies for ahci_imx.

* 'for-3.11-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata:
  ahci_imx: depend on CONFIG_MFD_SYSCON
  ahci_imx: add ahci sata support on imx platforms
  ARM: imx6q: update the sata bits definitions of gpr13
  ahci: fix Null pointer dereference in achi_host_active()
  libata: make it clear that sata_inic162x is experimental
  libata: replace strict_strtol() with kstrtol()
  ata: Fix DVD not dectected at some platform with Wellsburg PCH
Merge tag 'md/3.11-fixes' of git://neil.brown.name/md

Pull md fixes from Neil Brown:
 "Two more bugfixes for md in 3.11

  Both marked for -stable, both since 3.3.  I guess I should spend more
  time testing..."

* tag 'md/3.11-fixes' of git://neil.brown.name/md:
  md/raid5: fix interaction of 'replace' and 'recovery'.
  md/raid10: remove use-after-free bug.
Merge branch 'for-3.11' of git://linux-nfs.org/~bfields/linux

Pull nfsd fix from Bruce Fields:
 "One more nfsd bugfix for 3.11"

* 'for-3.11' of git://linux-nfs.org/~bfields/linux:
  nfsd: nfsd_open: when dentry_open returns an error do not propagate as struct file
Merge tag 'for-linus-v3.11-rc3' of git://oss.sgi.com/xfs/xfs

Pull xfs fix from Ben Myers:
 "Fix for regression in commit cca9f93a52d2 ("xfs: don't do IO when
  creating an new inode"), recovery causing filesystem corruption after
  a crash"

* tag 'for-linus-v3.11-rc3' of git://oss.sgi.com/xfs/xfs:
  xfs: di_flushiter considered harmful
Merge tag 'sound-3.11' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound

Pull sound fixes from Takashi Iwai:
 "Just a handful of regression and small fixes in ASoC, HD-audio and
  USB-audio drivers.

   - Sigmetal HD-audio codec regression fixes
   - A copule of XRUN indication fixes for usb-audio devices
   - ASoC: ep93xx build fix, sgtl5000 fix for probe order changes,
     max98088 register access fix, etc"

* tag 'sound-3.11' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
  ALSA: hiface: return correct XRUN indication
  ASoC: tegra: correct playback_dma_data setup
  ASoC: core: double free in snd_soc_add_platform()
  ALSA: usb-audio: 6fire: return correct XRUN indication
  ASoC: ep93xx: fix build of ep93xx-ac97.c
  ALSA: hda - Remove NO_PRESENCE bit override for Dell 1420n Laptop
  ALSA: hda - Fix EAPD GPIO control for Sigmatel codecs
  ASoC: atmel-ssc: remove clk_disable_unprepare call from critical section
  ASoC: sgtl5000: defer the probe if clock is not found
  ASoC: max98088 - fix element type of the register cache.
Merge tag 'char-misc-3.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull char/misc patches from Greg KH:
 "Here are some char/misc patches for 3.11-rc3.  It's pretty much just:
   - mei fixes
   - hyperv fixes
   - new ja_JP translation update
  all tiny stuff, but fixes for issues people have reported."

* tag 'char-misc-3.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
  HOWTO ja_JP sync
  mei: me: fix waiting for hw ready
  mei: don't have to clean the state on power up
  mei: me: fix reset state machine
  mei: hbm: fix typo in error message
  Tools: hv: KVP: Fix a bug in IPV6 subnet enumeration
  Drivers: hv: balloon: Do not post pressure status if interrupted
  Drivers: hv: balloon: Fix a bug in the hot-add code
  Drivers: hv: vmbus: incorrect device name is printed when child device is unregistered
Merge tag 'staging-3.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging fixes from Greg KH:
 "Here are some tiny drivers/staging/ fixes for 3.11-rc3

  A number of bugfixes, all pretty tiny, but resolve issues that have
  been reported (the kstrtos32 change fixes a data corruption problem
  that Dan found).  And a MAINTAINERS file update for the comedi
  drivers"

* tag 'staging-3.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
  MAINTAINERS: Update the list of maintainers for staging/comedi driver.
  staging: tidspbridge: replace strict_strtol() with kstrtos32()
  staging: android: logger: Correct write offset reset on error
  staging: zram: protect zram_reset_device() call
  staging: gdm72xx: potential use after free in send_qos_list()
  staging: drm/imx: drop "select OF_VIDEOMODE"
  staging: frontier: use after free in disconnect()
  staging: comedi: fix a race between do_cmd_ioctl() and read/write
  staging: comedi: COMEDI_CANCEL ioctl should wake up read/write
Merge tag 'tty-3.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty

Pull tty/serial fixes from Greg KH:
 "Here are 3 fixes for TTY and serial issues that have been reported.
  Nothing huge, but nice to get fixed"

* tag 'tty-3.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
  serial: tegra: correct help message in Kconfig from 'ttyHS' to 'ttyTHS'
  tty/8250_early: Don't truncate last character of options
  TTY: snyclinkmp: calculating wrong addresses
Merge tag 'usb-3.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH:
 "Here are a number of USB fixes for 3.11-rc3.

  Lots of little things, nothing major.  A number of new device ids,
  build fixes for DMA, and a bunch of other minor things.  All of these
  have been in the linux-next tree"

* tag 'usb-3.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (40 commits)
  usb: Clear both buffers when clearing a control transfer TT buffer.
  usb/gadget: free opts struct on error recovery
  USB: mos7840: fix memory leak in open
  usb: serial: option.c: remove ONDA MT825UP product ID fromdriver
  usb: serial: option: add Olivetti Olicard 200
  usb: serial: option: blacklist ONDA MT689DC QMI interface
  xhci: fix null pointer dereference on ring_doorbell_for_active_rings
  usb: host: xhci: Enable XHCI_SPURIOUS_SUCCESS for all controllers with xhci 1.0
  usb: fix build warning in pci-quirks.h when CONFIG_PCI is not enabled
  usb: xhci: Mark two functions __maybe_unused
  xhci: Avoid NULL pointer deref when host dies.
  usb: serial: option: Add ONYX 3G device support
  USB: ti_usb_3410_5052: fix dynamic-id matching
  usb: option: add TP-LINK MA260
  USB: option: add D-Link DWM-152/C1 and DWM-156/C1
  USB: EHCI: Fix resume signalling on remote wakeup
  USB: cp210x: add MMB and PI ZigBee USB Device Support
  usb: cp210x support SEL C662 Vendor/Device
  USB: option: append Petatel NP10T device to GSM modems list
  USB: misc: Add Manhattan Hi-Speed USB DVI Converter to sisusbvga
  ...
ext4: make sure group number is bumped after a inode allocation race

When we try to allocate an inode, and there is a race between two
CPU's trying to grab the same inode, _and_ this inode is the last free
inode in the block group, make sure the group number is bumped before
we continue searching the rest of the block groups.  Otherwise, we end
up searching the current block group twice, and we end up skipping
searching the last block group.  So in the unlikely situation where
almost all of the inodes are allocated, it's possible that we will
return ENOSPC even though there might be free inodes in that last
block group.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@vger.kernel.org
ext4: destroy ext4_es_cachep on module unload

Without this, module can't be reloaded.

[  500.521980] kmem_cache_sanity_check (ext4_extent_status): Cache name already exists.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@vger.kernel.org  # v3.8+