3.12.2-stable review
Greg Kroah-Hartman
maintainercover 3.12.2-stable review
This is the start of the stable review cycle for the 3.12.2 release. There are 116 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri Nov 29 00:57:18 UTC 2013. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.12.2-rc1.gz
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 3.12.2-rc1
Mauro Carvalho Chehab <[email protected]>
cris: media platform drivers: fix build
Miklos Szeredi <[email protected]>
GFS2: fix dentry leaks
Miklos Szeredi <[email protected]>
GFS2: d_splice_alias() can't return error
Junxiao Bi <[email protected]>
configfs: fix race between dentry put and lookup
Martin Schwidefsky <[email protected]>
s390/vtime: correct idle time calculation
Martin Schwidefsky <[email protected]>
s390/time: fix get_tod_clock_ext inline assembly
Sebastian Andrzej Siewior <[email protected]>
usb: musb: core: properly free host / device structs in err path
Sebastian Andrzej Siewior <[email protected]>
usb: musb: dsps: redo the otg timer
Sebastian Andrzej Siewior <[email protected]>
usb: musb: dsps: move try_idle to start hook
Sebastian Andrzej Siewior <[email protected]>
usb: musb: call musb_start() only once in OTG mode
Sebastian Andrzej Siewior <[email protected]>
usb: musb: cancel work on removal
Stanislaw Gruszka <[email protected]>
rt2800usb: slow down TX status polling
Thomas Pugliese <[email protected]>
usb: wusbcore: set the RPIPE wMaxPacketSize value correctly
Julius Werner <[email protected]>
usb: hub: Clear Port Reset Change during init/resume
Sarah Sharp <[email protected]>
usb: Disable USB 2.0 Link PM before device reset.
Sarah Sharp <[email protected]>
xhci: Set L1 device slot on USB2 LPM enable/disable.
Mathias Nyman <[email protected]>
xhci: Enable LPM support only for hardwired or BESL devices
Sarah Sharp <[email protected]>
usb: Don't enable USB 2.0 Link PM by default.
Tomas Winkler <[email protected]>
mei: nfc: fix memory leak in error path
Trond Myklebust <[email protected]>
SUNRPC: Avoid deep recursion in rpc_release_client
Trond Myklebust <[email protected]>
SUNRPC: Fix a data corruption issue when retransmitting RPC calls
Trond Myklebust <[email protected]>
SUNRPC: gss_alloc_msg - choose _either_ a v0 message or a v1 message
Christoph Lameter <[email protected]>
slub: Handle NULL parameter in kmem_cache_flags
Anton Blanchard <[email protected]>
powerpc/pseries: Duplicate dtl entries sometimes sent to userspace
Gavin Shan <[email protected]>
powerpc/eeh: Enable PCI_COMMAND_MASTER for PCI bridges
Michael Neuling <[email protected]>
powerpc/signals: Mark VSX not saved with small contexts
Heiko Carstens <[email protected]>
powerpc: Fix __get_user_pages_fast() irq handling
Anton Blanchard <[email protected]>
powerpc: ppc64 address space capped at 32TB, mmap randomisation disabled
Gavin Shan <[email protected]>
powerpc/powernv: Add PE to its own PELTV
Prarit Bhargava <[email protected]>
powerpc/vio: use strcpy in modalias_show
Gerhard Sittig <[email protected]>
powerpc/mpc512x: silence build warning upon disabled DIU
Anatolij Gustschin <[email protected]>
powerpc/52xx: fix build breakage for MPC5200 LPBFIFO module
Mike Snitzer <[email protected]>
block: properly stack underlying max_segment_size to DM device
Mikulas Patocka <[email protected]>
block: fix a probe argument to blk_register_region
Jeff Moyer <[email protected]>
block: fix race between request completion and timeout handling
Roger Tseng <[email protected]>
drivers/memstick/core/ms_block.c: fix unreachable state in h_msb_read_page()
Guenter Roeck <[email protected]>
hwmon: (lm90) Fix max6696 alarm handling
Christoffer Dall <[email protected]>
arm/arm64: KVM: Fix hyp mappings of vmalloc regions
Greg Edwards <[email protected]>
KVM: IOMMU: hva align mapping page size
Kevin Hao <[email protected]>
ftrace/x86: skip over the breakpoint for ftrace caller
Paolo Bonzini <[email protected]>
KVM: x86: fix emulation of "movzbl %bpl, %eax"
Thomas Renninger <[email protected]>
x86/microcode/amd: Tone down printk(), don't treat a missing firmware file as an error
Fenghua Yu <[email protected]>
x86/apic: Disable I/O APIC before shutdown of the local APIC
J. Bruce Fields <[email protected]>
nfsd4: fix xdr decoding of large non-write compounds
Christoph Hellwig <[email protected]>
nfsd: make sure to balance get/put_write_access
Christoph Hellwig <[email protected]>
nfsd: split up nfsd_setattr
Jeff Layton <[email protected]>
nfs: don't retry detect_trunking with RPC_AUTH_UNIX more than once
J. Bruce Fields <[email protected]>
nfsd4: fix discarded security labels on setattr
J. Bruce Fields <[email protected]>
nfsd: return better errors to exportfs
Trond Myklebust <[email protected]>
NFS: Fix a missing initialisation when reading the SELinux label
Jeff Layton <[email protected]>
nfs: fix oops when trying to set SELinux label
Jeff Layton <[email protected]>
nfs: fix inverted test for delegation in nfs4_reclaim_open_state
Trond Myklebust <[email protected]>
NFSv4: Fix state reference counting in _nfs4_opendata_reclaim_to_nfs4_state
Weston Andros Adamson <[email protected]>
NFSv4: don't reprocess cached open CLAIM_PREVIOUS
Weston Andros Adamson <[email protected]>
NFSv4: don't fail on missing fattr in open recover
Weston Andros Adamson <[email protected]>
NFSv4: fix NULL dereference in open recover
Trond Myklebust <[email protected]>
NFSv4: Fix a use-after-free situation in _nfs4_proc_getlk()
Trond Myklebust <[email protected]>
NFSv4.2: Fix a mismatch between Linux labeled NFS and the NFSv4.2 spec
Takashi Iwai <[email protected]>
ALSA: hda - Provide missing pin configs for VAIO with ALC260
David Henningsson <[email protected]>
ALSA: hda - Add headset quirk for Dell Inspiron 3135
Takashi Iwai <[email protected]>
ALSA: hda - Fix the headphone jack detection on Sony VAIO TX
Takashi Iwai <[email protected]>
ALSA: hda - Fix unbalanced runtime PM notification at resume
Takashi Iwai <[email protected]>
ALSA: hda - Don't clear the power state at snd_hda_codec_reset()
Takashi Iwai <[email protected]>
ALSA: hda - Don't turn off EAPD for headphone on Lenovo N100
Takashi Iwai <[email protected]>
ALSA: hda - Check keep_eapd_on before inv_eapd
David Henningsson <[email protected]>
ALSA: hda - Fix Line Out automute on Realtek multifunction jacks
Takashi Iwai <[email protected]>
ALSA: hda - Add pincfg fixup for ASUS W5A
Takashi Iwai <[email protected]>
ALSA: hda - Add support for CX20952
David Henningsson <[email protected]>
ALSA: hda - Make sure mute LEDs stay on during runtime suspend (Realtek)
Takashi Iwai <[email protected]>
ALSA: hda - Force buffer alignment for Haswell HDMI controllers
Takashi Iwai <[email protected]>
ALSA: hda - Enable SPDIF for Acer TravelMate 6293
Takashi Iwai <[email protected]>
ALSA: hda - Introduce the bitmask for excluding output volume
Kailang Yang <[email protected]>
ALSA: hda - Add support of ALC255 codecs
Takashi Iwai <[email protected]>
ALSA: msnd: Avoid duplicated driver name
Takashi Iwai <[email protected]>
ALSA: hda - Apply MacBook fixups for CS4208 correctly
Takashi Iwai <[email protected]>
ALSA: hda - Apply GPIO setup for MacBooks with CS4208
Takashi Iwai <[email protected]>
ALSA: pcsp: Fix the order of input device unregistration
Vinod Koul <[email protected]>
ALSA: compress: fix drain calls blocking other compress functions (v6)
Vinod Koul <[email protected]>
ALSA: compress: fix drain calls blocking other compress functions
Takashi Iwai <[email protected]>
ALSA: 6fire: Fix probe of multiple cards
Kees Cook <[email protected]>
exec/ptrace: fix get_dumpable() incorrect tests
Mimi Zohar <[email protected]>
Revert "ima: policy for RAMFS"
Hans de Goede <[email protected]>
Bluetooth: revert: "Bluetooth: Add missing reset_resume dev_pm_ops"
Stanislaw Gruszka <[email protected]>
rt2x00: fix HT TX descriptor settings regression
Gabor Juhos <[email protected]>
rt2x00: rt2800lib: fix VGC adjustment for RT5592
Stanislaw Gruszka <[email protected]>
rt2x00: check if device is still available on rt2x00mac_flush()
Felix Fietkau <[email protected]>
rt2x00: fix a crash bug in the HT descriptor handling fix
K. Y. Srinivasan <[email protected]>
Drivers: hv: vmbus: Fix a bug in channel rescind code
Kees Cook <[email protected]>
lkdtm: isolate stack corruption test
Ian Abbott <[email protected]>
staging: comedi: avoid memleak for subdevice private
Larry Finger <[email protected]>
staging: r8188eu: Set device type to wlan
Rashika Kheria <[email protected]>
Staging: zram: Fix access of NULL pointer
Rafael J. Wysocki <[email protected]>
ACPI / hotplug: Do not execute "insert in progress" _OST
Rafael J. Wysocki <[email protected]>
ACPI / hotplug: Fix handle_root_bridge_removal()
Aaron Lu <[email protected]>
ACPI / video: Quirk initial backlight level 0
Puneet Kumar <[email protected]>
ACPI / EC: Ensure lock is acquired before accessing ec struct members
Steven Rostedt <[email protected]>
perf/ftrace: Fix paranoid level for enabling function tracer
Peter Zijlstra <[email protected]>
sched, idle: Fix the idle polling state logic
Suman Anna <[email protected]>
ARM: OMAP2+: hwmod: check for module address space during init
Takashi Iwai <[email protected]>
thinkpad_acpi: Fix build error when CONFIG_SND_MAX_CARDS > 32
Ben Skeggs <[email protected]>
drm/nvc0-/gr: fix a number of missing explicit array terminators...
John Stultz <[email protected]>
staging: ashmem: Fix ASHMEM_PURGE_ALL_CACHES return value
Laurent Pinchart <[email protected]>
drm: shmobile: Add dependency on BACKLIGHT_CLASS_DEVICE
Greg Thelen <[email protected]>
ipc,shm: fix shm_file deletion races
Jesper Nilsson <[email protected]>
ipc,shm: correct error return value in shmctl (SHM_UNLOCK)
hahnjo <[email protected]>
alx: Reset phy speed after resume
Markus Pargmann <[email protected]>
can: c_can: Fix RX message handling, handle lost message before EOB
Herbert Xu <[email protected]>
crypto: s390 - Fix aes-cbc IV corruption
Neil Horman <[email protected]>
crypto: ansi_cprng - Fix off by one error in non-block size request
Josef Bacik <[email protected]>
Btrfs: relocate csums properly with prealloc extents
Olivier Sobrie <[email protected]>
can: kvaser_usb: fix usb endpoints detection
Johan Hovold <[email protected]>
USB: mos7840: fix tiocmget error handling
Eric Sandeen <[email protected]>
xfs: be more forgiving of a v4 secondary sb w/ junk in v5 fields
Mahesh Rajashekhara <[email protected]>
aacraid: prevent invalid pointer dereference
Dan Carpenter <[email protected]>
libertas: potential oops in debugfs
Al Viro <[email protected]>
prepend_path() needs to reinitialize dentry/vfsmount/mnt on restarts
-------------
Diffstat:
Makefile | 4 +- arch/arm/kvm/mmu.c | 34 +++- arch/arm/mach-omap2/omap_hwmod.c | 29 ++-- arch/cris/include/asm/io.h | 1 + arch/ia64/include/asm/processor.h | 2 +- arch/powerpc/kernel/eeh.c | 9 ++ arch/powerpc/kernel/signal_32.c | 10 +- arch/powerpc/kernel/time.c | 4 +- arch/powerpc/kernel/vio.c | 4 +- arch/powerpc/mm/gup.c | 5 +- arch/powerpc/mm/slice.c | 2 +- arch/powerpc/platforms/512x/mpc512x_shared.c | 3 + arch/powerpc/platforms/52xx/Kconfig | 2 +- arch/powerpc/platforms/powernv/pci-ioda.c | 12 +- arch/s390/crypto/aes_s390.c | 19 ++- arch/s390/include/asm/timex.h | 6 +- arch/s390/kernel/smp.c | 4 +- arch/s390/kernel/vtime.c | 2 +- arch/x86/kernel/crash.c | 2 +- arch/x86/kernel/ftrace.c | 14 +- arch/x86/kernel/microcode_amd.c | 2 +- arch/x86/kernel/process.c | 6 +- arch/x86/kernel/reboot.c | 8 +- arch/x86/kvm/emulate.c | 5 +- block/blk-core.c | 1 + block/blk-settings.c | 1 + block/blk-timeout.c | 3 +- crypto/ansi_cprng.c | 4 +- drivers/acpi/ec.c | 3 +- drivers/acpi/pci_root.c | 5 +- drivers/acpi/processor_idle.c | 46 ++---- drivers/acpi/scan.c | 2 - drivers/acpi/video.c | 2 +- drivers/block/brd.c | 2 +- drivers/block/loop.c | 2 +- drivers/bluetooth/btusb.c | 1 - .../gpu/drm/nouveau/core/engine/graph/ctxnvc1.c | 4 + .../gpu/drm/nouveau/core/engine/graph/ctxnvd7.c | 1 + .../gpu/drm/nouveau/core/engine/graph/ctxnvd9.c | 1 + drivers/gpu/drm/shmobile/Kconfig | 1 + drivers/hv/channel_mgmt.c | 5 +- drivers/hwmon/lm90.c | 11 +- drivers/idle/intel_idle.c | 2 +- drivers/memstick/core/ms_block.c | 2 +- drivers/misc/lkdtm.c | 16 +- drivers/misc/mei/nfc.c | 10 +- drivers/net/can/c_can/c_can.c | 6 +- drivers/net/can/usb/kvaser_usb.c | 20 ++- drivers/net/ethernet/atheros/alx/main.c | 3 + drivers/net/wireless/libertas/debugfs.c | 6 +- drivers/net/wireless/rt2x00/rt2800lib.c | 11 +- drivers/net/wireless/rt2x00/rt2800usb.c | 12 +- drivers/net/wireless/rt2x00/rt2x00dev.c | 3 +- drivers/net/wireless/rt2x00/rt2x00lib.h | 2 +- drivers/net/wireless/rt2x00/rt2x00mac.c | 7 +- drivers/net/wireless/rt2x00/rt2x00queue.c | 4 +- drivers/platform/x86/thinkpad_acpi.c | 7 +- drivers/scsi/aacraid/commctrl.c | 3 +- drivers/staging/android/ashmem.c | 2 +- drivers/staging/comedi/comedi_fops.c | 5 +- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 5 + drivers/staging/zram/zram_drv.c | 6 +- drivers/usb/core/driver.c | 3 + drivers/usb/core/hub.c | 39 +++++ drivers/usb/core/sysfs.c | 6 +- drivers/usb/host/xhci-mem.c | 10 -- drivers/usb/host/xhci.c | 165 +++----------------- drivers/usb/host/xhci.h | 1 + drivers/usb/musb/musb_core.c | 4 + drivers/usb/musb/musb_dsps.c | 25 +-- drivers/usb/musb/musb_virthub.c | 19 ++- drivers/usb/serial/mos7840.c | 4 + drivers/usb/wusbcore/wa-rpipe.c | 5 +- fs/btrfs/relocation.c | 18 ++- fs/configfs/dir.c | 16 +- fs/dcache.c | 9 +- fs/exec.c | 6 + fs/gfs2/inode.c | 30 ++-- fs/nfs/nfs4proc.c | 36 ++--- fs/nfs/nfs4state.c | 9 +- fs/nfsd/export.c | 15 +- fs/nfsd/nfs4xdr.c | 4 +- fs/nfsd/vfs.c | 173 ++++++++++++--------- fs/xfs/xfs_sb.c | 13 +- include/linux/binfmts.h | 3 - include/linux/nfs4.h | 2 +- include/linux/sched.h | 82 +++++++++- include/linux/thread_info.h | 2 + include/linux/usb.h | 4 +- include/sound/compress_driver.h | 9 ++ ipc/shm.c | 37 ++++- kernel/cpu/idle.c | 9 +- kernel/ptrace.c | 3 +- kernel/trace/trace_event_perf.c | 2 +- mm/slub.c | 4 +- net/sunrpc/auth_gss/auth_gss.c | 1 + net/sunrpc/clnt.c | 29 ++-- net/sunrpc/xprtsock.c | 28 +++- security/integrity/ima/ima_policy.c | 1 - sound/core/compress_offload.c | 54 ++++++- sound/drivers/pcsp/pcsp.c | 2 +- sound/isa/msnd/msnd_pinnacle.c | 4 +- sound/pci/hda/hda_codec.c | 7 +- sound/pci/hda/hda_generic.c | 12 +- sound/pci/hda/hda_generic.h | 3 + sound/pci/hda/hda_intel.c | 14 +- sound/pci/hda/patch_analog.c | 6 +- sound/pci/hda/patch_cirrus.c | 28 +++- sound/pci/hda/patch_conexant.c | 3 + sound/pci/hda/patch_realtek.c | 83 +++++++++- sound/usb/6fire/chip.c | 2 +- virt/kvm/iommu.c | 4 + 112 files changed, 945 insertions(+), 519 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/116 prepend_path() needs to reinitialize dentry/vfsmount/mnt on restarts
3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit ede4cebce16f5643c61aedd6d88d9070a1d23a68 upstream.
... and equivalent is needed in 3.12; it's broken there as well
--- fs/dcache.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
fs/dcache.c +6 -3
@@ -2881,9 +2881,9 @@ static int prepend_path(const struct patconst struct path *root, char **buffer, int *buflen) { - struct dentry *dentry = path->dentry; -struct vfsmount *vfsmnt = path->mnt; -struct mount *mnt =real_mount (vfsmnt); + struct dentry *dentry; +struct vfsmount *vfsmnt; +struct mount *mnt;int error =0 ;unsigned seq =0 ;char *bptr;
@@ -2893,6 +2893,9 @@ static int prepend_path(const struct pat restart: bptr = *buffer; blen = *buflen; + dentry = path->dentry; + vfsmnt = path->mnt; + mnt =real_mount (vfsmnt);read_seqbegin_or_lock (&rename_lock, &seq);while (dentry != root->dentry || vfsmnt != root->mnt) {struct dentry * parent;
Greg Kroah-Hartman
maintainerPATCH 2/116 libertas: potential oops in debugfs
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit a497e47d4aec37aaf8f13509f3ef3d1f6a717d88 upstream.
If we do a zero size allocation then it will oops. Also we can't be sure the user passes us a NUL terminated string so I've added a terminator.
This code can only be triggered by root.
--- drivers/net/wireless/libertas/debugfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireless/libertas/debugfs.c +5 -1
@@ -913,7 +913,10 @@ static ssize_t lbs_debugfs_write(structchar *p2;struct debug_data *d = f->private_data; - pdata =kmalloc (cnt,GFP_KERNEL ); +if (cnt ==0 ) +return 0 ; + + pdata =kmalloc (cnt +1 ,GFP_KERNEL );if (pdata ==NULL )return 0 ;
@@ -922,6 +925,7 @@ static ssize_t lbs_debugfs_write(structkfree (pdata);return 0 ; } + pdata[cnt] ='\0' ; p0 = pdata;for (i =0 ; i < num_of_items; i++) {
Greg Kroah-Hartman
maintainerPATCH 3/116 aacraid: prevent invalid pointer dereference
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mahesh Rajashekhara <[email protected]>
commit b4789b8e6be3151a955ade74872822f30e8cd914 upstream.
It appears that driver runs into a problem here if fibsize is too small because we allocate user_srbcmd with fibsize size only but later we access it until user_srbcmd->sg.count to copy it over to srbcmd.
It is not correct to test (fibsize < sizeof(*user_srbcmd)) because this structure already includes one sg element and this is not needed for commands without data. So, we would recommend to add the following (instead of test for fibsize == 0).
--- drivers/scsi/aacraid/commctrl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/aacraid/commctrl.c +2 -1
@@ -511,7 +511,8 @@ static int aac_send_raw_srb(struct aac_d goto cleanup; } -if (fibsize > (dev->max_fib_size -sizeof (struct aac_fibhdr ))) { +if ((fibsize < (sizeof (struct user_aac_srb ) -sizeof (struct user_sgentry ))) || + (fibsize > (dev->max_fib_size -sizeof (struct aac_fibhdr )))) { rcode = -EINVAL ; goto cleanup; }
Greg Kroah-Hartman
maintainerPATCH 4/116 xfs: be more forgiving of a v4 secondary sb w/ junk in v5 fields
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Sandeen <[email protected]>
commit 10e6e65dfcedff63275c3d649d329c044caa8e26 upstream.
Today, if xfs_sb_read_verify encounters a v4 superblock with junk past v4 fields which includes data in sb_crc, it will be treated as a failing checksum and a significant corruption.
There are known prior bugs which leave junk at the end of the V4 superblock; we don't need to actually fail the verification in this case if other checks pan out ok.
So if this is a secondary superblock, and the primary superblock doesn't indicate that this is a V5 filesystem, don't treat this as an actual checksum failure.
We should probably check the garbage condition as we do in xfs_repair, and possibly warn about it or self-heal, but that's a different scope of work.
Stable folks: This can go back to v3.10, which is what introduced the sb CRC checking that is tripped up by old, stale, incorrect V4 superblocks w/ unzeroed bits.
--- fs/xfs/xfs_sb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
fs/xfs/xfs_sb.c +11 -2
@@ -596,6 +596,11 @@ xfs_sb_verify(* single bit error could clear the feature bit and unused parts of the * superblock are supposed to be zero. Hence a non-null crc field indicates that * we've potentially lost a feature bit and we should check it anyway. +* +* However, past bugs (i.e. in growfs) left non-zeroed regions beyond the +* last field in V4 secondary superblocks. So for secondary superblocks, +* we are more forgiving, and ignore CRC failures if the primary doesn't +* indicate that the fs version is V5. */ static void xfs_sb_read_verify(
@@ -616,8 +621,12 @@ xfs_sb_read_verify(if (!xfs_verify_cksum (bp->b_addr,be16_to_cpu (dsb->sb_sectsize), offsetof(struct xfs_sb , sb_crc))) { - error =EFSCORRUPTED ; - goto out_error; +/* Only fail bad secondaries on a known V5 filesystem */ +if (bp->b_bn !=XFS_SB_DADDR && +xfs_sb_version_hascrc (&mp->m_sb)) { + error =EFSCORRUPTED ; + goto out_error; + } } } error =xfs_sb_verify (bp, true);
Greg Kroah-Hartman
maintainerPATCH 5/116 USB: mos7840: fix tiocmget error handling
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit a91ccd26e75235d86248d018fe3779732bcafd8d upstream.
Make sure to return errors from tiocmget rather than rely on uninitialised stack data.
--- drivers/usb/serial/mos7840.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/serial/mos7840.c +4 -0
@@ -1532,7 +1532,11 @@ static int mos7840_tiocmget(struct tty_sreturn -ENODEV ; status =mos7840_get_uart_reg (port,MODEM_STATUS_REGISTER , &msr); +if (status !=1 ) +return -EIO ; status =mos7840_get_uart_reg (port,MODEM_CONTROL_REGISTER , &mcr); +if (status !=1 ) +return -EIO ; result = ((mcr &MCR_DTR ) ?TIOCM_DTR :0 ) | ((mcr &MCR_RTS ) ?TIOCM_RTS :0 ) | ((mcr &MCR_LOOPBACK ) ?TIOCM_LOOP :0 )
Greg Kroah-Hartman
maintainerPATCH 6/116 can: kvaser_usb: fix usb endpoints detection
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Olivier Sobrie <[email protected]>
commit 896e23bd04ea50a146dffd342e2f96180f0812a5 upstream.
Some devices, like the Kvaser Memorator Professional, have several bulk in endpoints. Only the first one found must be used by the driver. The same holds for the bulk out endpoint. The official Kvaser driver (leaf) was used as reference for this patch.
--- drivers/net/can/usb/kvaser_usb.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/net/can/usb/kvaser_usb.c +13 -7
@@ -1544,9 +1544,9 @@ static int kvaser_usb_init_one(struct usreturn 0 ; } -static void kvaser_usb_get_endpoints (const struct usb_interface *intf, -struct usb_endpoint_descriptor **in, -struct usb_endpoint_descriptor **out) +static int kvaser_usb_get_endpoints (const struct usb_interface *intf, +struct usb_endpoint_descriptor **in, +struct usb_endpoint_descriptor **out) {const struct usb_host_interface *iface_desc;struct usb_endpoint_descriptor *endpoint;
@@ -1557,12 +1557,18 @@ static void kvaser_usb_get_endpoints(confor (i =0 ; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; -if (usb_endpoint_is_bulk_in (endpoint)) +if (!*in &&usb_endpoint_is_bulk_in (endpoint)) *in = endpoint; -if (usb_endpoint_is_bulk_out (endpoint)) +if (!*out &&usb_endpoint_is_bulk_out (endpoint)) *out = endpoint; + +/* use first bulk endpoint for in and out */ +if (*in && *out) +return 0 ; } + +return -ENODEV ; } static int kvaser_usb_probe(struct usb_interface *intf,
@@ -1576,8 +1582,8 @@ static int kvaser_usb_probe(struct usb_iif (!dev)return -ENOMEM ; -kvaser_usb_get_endpoints (intf, &dev->bulk_in, &dev->bulk_out); -if (!dev->bulk_in || !dev->bulk_out) { + err =kvaser_usb_get_endpoints (intf, &dev->bulk_in, &dev->bulk_out); +if (err) {dev_err (&intf->dev,"Cannot get usb endpoint(s)" );return err; }
Greg Kroah-Hartman
maintainerPATCH 7/116 Btrfs: relocate csums properly with prealloc extents
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 4577b014d1bc3db386da3246f625888fc48083a9 upstream.
A user reported a problem where they were getting csum errors when running a balance and running systemd's journal. This is because systemd is awesome and fallocate()'s its log space and writes into it. Unfortunately we assume that when we read in all the csums for an extent that they are sequential starting at the bytenr we care about. This obviously isn't the case for prealloc extents, where we could have written to the middle of the prealloc extent only, which means the csum would be for the bytenr in the middle of our range and not the front of our range. Fix this by offsetting the new bytenr we are logging to based on the original bytenr the csum was for. With this patch I no longer see the csum errors I was seeing. Thanks,
--- fs/btrfs/relocation.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
fs/btrfs/relocation.c +15 -3
@@ -4481,6 +4481,7 @@ int btrfs_reloc_clone_csums(struct inodestruct btrfs_root *root =BTRFS_I (inode)->root;int ret;u64 disk_bytenr; +u64 new_bytenr;LIST_HEAD (list); ordered =btrfs_lookup_ordered_extent (inode, file_pos);
@@ -4492,13 +4493,24 @@ int btrfs_reloc_clone_csums(struct inodeif (ret) goto out; - disk_bytenr = ordered->start;while (!list_empty (&list)) { sums = list_entry(list.next, struct btrfs_ordered_sum, list);list_del_init (&sums->list); - sums->bytenr = disk_bytenr; - disk_bytenr += sums->len; +/* +* We need to offset the new_bytenr based on where the csum is. +* We need to do this because we will read in entire prealloc +* extents but we may have written to say the middle of the +* prealloc extent, so we need to make sure the csum goes with +* the right disk offset. +* +* We can do this because the data reloc inode refers strictly +* to the on disk bytes, so we don't have to worry about +* disk_len vs real len like with real inodes since it's all +* disk length. +*/ + new_bytenr = ordered->start + (sums->bytenr - disk_bytenr); + sums->bytenr = new_bytenr;btrfs_add_ordered_sum (inode, ordered, sums); }
Greg Kroah-Hartman
maintainerPATCH 8/116 crypto: ansi_cprng - Fix off by one error in non-block size request
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Neil Horman <[email protected]>
commit 714b33d15130cbb5ab426456d4e3de842d6c5b8a upstream.
Stephan Mueller reported to me recently a error in random number generation in the ansi cprng. If several small requests are made that are less than the instances block size, the remainder for loop code doesn't increment rand_data_valid in the last iteration, meaning that the last bytes in the rand_data buffer gets reused on the subsequent smaller-than-a-block request for random data.
The fix is pretty easy, just re-code the for loop to make sure that rand_data_valid gets incremented appropriately
--- crypto/ansi_cprng.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
crypto/ansi_cprng.c +2 -2
@@ -230,11 +230,11 @@ remainder:*/ if (byte_count <DEFAULT_BLK_SZ ) { empty_rbuf: -for (; ctx->rand_data_valid <DEFAULT_BLK_SZ ; - ctx->rand_data_valid++) { +while (ctx->rand_data_valid <DEFAULT_BLK_SZ ) { *ptr = ctx->rand_data[ctx->rand_data_valid]; ptr++; byte_count--; + ctx->rand_data_valid++;if (byte_count ==0 ) goto done; }
Greg Kroah-Hartman
maintainerPATCH 9/116 crypto: s390 - Fix aes-cbc IV corruption
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit f262f0f5cad0c9eca61d1d383e3b67b57dcbe5ea upstream.
The cbc-aes-s390 algorithm incorrectly places the IV in the tfm data structure. As the tfm is shared between multiple threads, this introduces a possibility of data corruption.
This patch fixes this by moving the parameter block containing the IV and key onto the stack (the block is 48 bytes long).
The same bug exists elsewhere in the s390 crypto system and they will be fixed in subsequent patches.
--- arch/s390/crypto/aes_s390.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
arch/s390/crypto/aes_s390.c +12 -7
@@ -35,7 +35,6 @@ static u8 *ctrblk;static char keylen_flag;struct s390_aes_ctx { -u8 iv[AES_BLOCK_SIZE ];u8 key[AES_MAX_KEY_SIZE ];long enc;long dec;
@@ -441,30 +440,36 @@ static int cbc_aes_set_key(struct cryptoreturn aes_set_key (tfm, in_key, key_len); } -static int cbc_aes_crypt (struct blkcipher_desc *desc,long func,void *param, +static int cbc_aes_crypt (struct blkcipher_desc *desc,long func,struct blkcipher_walk *walk) { +struct s390_aes_ctx *sctx =crypto_blkcipher_ctx (desc->tfm);int ret =blkcipher_walk_virt (desc, walk);unsigned int nbytes = walk->nbytes; +struct { +u8 iv[AES_BLOCK_SIZE ]; +u8 key[AES_MAX_KEY_SIZE ]; + } param;if (!nbytes) goto out; -memcpy (param, walk->iv,AES_BLOCK_SIZE ); +memcpy (param.iv, walk->iv,AES_BLOCK_SIZE ); +memcpy (param.key, sctx->key, sctx->key_len);do {/* only use complete blocks */ unsigned int n = nbytes & ~(AES_BLOCK_SIZE -1 );u8 *out = walk->dst.virt.addr;u8 *in = walk->src.virt.addr; - ret =crypt_s390_kmc (func, param, out, in, n); + ret =crypt_s390_kmc (func, ¶m, out, in, n);if (ret <0 || ret != n)return -EIO ; nbytes &=AES_BLOCK_SIZE -1 ; ret =blkcipher_walk_done (desc, walk, nbytes); }while ((nbytes = walk->nbytes)); -memcpy (walk->iv, param,AES_BLOCK_SIZE ); +memcpy (walk->iv, param.iv,AES_BLOCK_SIZE ); out:return ret;
@@ -481,7 +486,7 @@ static int cbc_aes_encrypt(struct blkcipreturn fallback_blk_enc (desc, dst, src, nbytes);blkcipher_walk_init (&walk, dst, src, nbytes); -return cbc_aes_crypt (desc, sctx->enc, sctx->iv, &walk); +return cbc_aes_crypt (desc, sctx->enc, &walk); } static int cbc_aes_decrypt(struct blkcipher_desc *desc,
@@ -495,7 +500,7 @@ static int cbc_aes_decrypt(struct blkcipreturn fallback_blk_dec (desc, dst, src, nbytes);blkcipher_walk_init (&walk, dst, src, nbytes); -return cbc_aes_crypt (desc, sctx->dec, sctx->iv, &walk); +return cbc_aes_crypt (desc, sctx->dec, &walk); }static struct crypto_alg cbc_aes_alg = {
Greg Kroah-Hartman
maintainerPATCH 10/116 can: c_can: Fix RX message handling, handle lost message before EOB
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Markus Pargmann <[email protected]>
commit 5d0f801a2ccec3b1fdabc3392c8d99ed0413d216 upstream.
If we handle end of block messages with higher priority than a lost message, we can run into an endless interrupt loop.
This is reproducable with a am335x processor and "cansequence -r" at 1Mbit. As soon as we loose a packet we can't escape from an interrupt loop.
This patch fixes the problem by handling lost packets before EOB packets.
--- drivers/net/can/c_can/c_can.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/can/c_can/c_can.c +3 -3
@@ -814,9 +814,6 @@ static int c_can_do_rx_poll(struct net_d msg_ctrl_save = priv->read_reg (priv,C_CAN_IFACE (MSGCTRL_REG ,0 )); -if (msg_ctrl_save &IF_MCONT_EOB ) -return num_rx_pkts; -if (msg_ctrl_save &IF_MCONT_MSGLST ) {c_can_handle_lost_msg_obj (dev,0 , msg_obj); num_rx_pkts++;
@@ -824,6 +821,9 @@ static int c_can_do_rx_poll(struct net_dcontinue ; } +if (msg_ctrl_save &IF_MCONT_EOB ) +return num_rx_pkts; +if (!(msg_ctrl_save &IF_MCONT_NEWDAT ))continue ;
Greg Kroah-Hartman
maintainerPATCH 11/116 alx: Reset phy speed after resume
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: hahnjo <[email protected]>
commit b54629e226d196e802abdd30c5e34f2a47cddcf2 upstream.
This fixes bug 62491 (https://bugzilla.kernel.org/show_bug.cgi?id=62491).
After resuming some users got the following error flooding the kernel log:
alx 0000:02:00.0: invalid PHY speed/duplex: 0xffff
--- drivers/net/ethernet/atheros/alx/main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/atheros/alx/main.c +3 -0
@@ -1389,6 +1389,9 @@ static int alx_resume(struct device *dev {struct pci_dev *pdev =to_pci_dev (dev);struct alx_priv *alx =pci_get_drvdata (pdev); +struct alx_hw *hw = &alx->hw; + +alx_reset_phy (hw);if (!netif_running (alx->dev))return 0 ;
Greg Kroah-Hartman
maintainerPATCH 12/116 ipc,shm: correct error return value in shmctl (SHM_UNLOCK)
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jesper Nilsson <[email protected]>
commit 3a72660b07d86d60457ca32080b1ce8c2b628ee2 upstream.
Commit 2caacaa82a51 ("ipc,shm: shorten critical region for shmctl") restructured the ipc shm to shorten critical region, but introduced a path where the return value could be -EPERM, even if the operation actually was performed.
Before the commit, the err return value was reset by the return value from security_shm_shmctl() after the if (!ns_capable(...)) statement.
Now, we still exit the if statement with err set to -EPERM, and in the case of SHM_UNLOCK, it is not reset at all, and used as the return value from shmctl.
To fix this, we only set err when errors occur, leaving the fallthrough case alone.
--- ipc/shm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
ipc/shm.c +6 -3
@@ -974,12 +974,15 @@ SYSCALL_DEFINE3(shmctl, int, shmid, int,ipc_lock_object (&shp->shm_perm);if (!ns_capable (ns->user_ns,CAP_IPC_LOCK )) {kuid_t euid =current_euid (); - err = -EPERM ;if (!uid_eq (euid, shp->shm_perm.uid) && - !uid_eq (euid, shp->shm_perm.cuid)) + !uid_eq (euid, shp->shm_perm.cuid)) { + err = -EPERM ; goto out_unlock0; -if (cmd ==SHM_LOCK && !rlimit (RLIMIT_MEMLOCK )) + } +if (cmd ==SHM_LOCK && !rlimit (RLIMIT_MEMLOCK )) { + err = -EPERM ; goto out_unlock0; + } } shm_file = shp->shm_file;
Greg Kroah-Hartman
maintainerPATCH 13/116 ipc,shm: fix shm_file deletion races
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Thelen <[email protected]>
commit a399b29dfbaaaf91162b2dc5a5875dd51bbfa2a1 upstream.
When IPC_RMID races with other shm operations there's potential for use-after-free of the shm object's associated file (shm_file).
Here's the race before this patch:
TASK 1 TASK 2
------ ------
shm_rmid()
ipc_lock_object()
shmctl()
shp = shm_obtain_object_check()
shm_destroy()
shum_unlock()
fput(shp->shm_file)
ipc_lock_object()
shmem_lock(shp->shm_file)
<OOPS>The oops is caused because shm_destroy() calls fput() after dropping the ipc_lock. fput() clears the file's f_inode, f_path.dentry, and f_path.mnt, which causes various NULL pointer references in task 2. I reliably see the oops in task 2 if with shmlock, shmu
This patch fixes the races by:
1) set shm_file=NULL in shm_destroy() while holding ipc_object_lock().
2) modify at risk operations to check shm_file while holding ipc_object_lock().
Example workloads, which each trigger oops...
Workload 1:
while true; do
id=$(shmget 1 4096)
shm_rmid $id &
shmlock $id &
wait
done
The oops stack shows accessing NULL f_inode due to racing fput:
_raw_spin_lock
shmem_lock
SyS_shmctl
Workload 2:
while true; do
id=$(shmget 1 4096)
shmat $id 4096 &
shm_rmid $id &
waitdone
The oops stack is similar to workload 1 due to NULL f_inode:
touch_atime
shmem_mmap
shm_mmap
mmap_region
do_mmap_pgoff
do_shmat
SyS_shmat
Workload 3:
while true; do
id=$(shmget 1 4096)
shmlock $id
shm_rmid $id &
shmunlock $id &
wait
done
The oops stack shows second fput tripping on an NULL f_inode. The first fput() completed via from shm_destroy(), but a racing thread did a get_file() and queued this fput():
locks_remove_flock
__fput
____fput
task_work_run
do_notify_resume
int_signal--- ipc/shm.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)
ipc/shm.c +23 -5
@@ -208,15 +208,18 @@ static void shm_open(struct vm_area_stru*/ static void shm_destroy (struct ipc_namespace *ns,struct shmid_kernel *shp) { +struct file *shm_file; + + shm_file = shp->shm_file; + shp->shm_file =NULL ; ns->shm_tot -= (shp->shm_segsz +PAGE_SIZE -1 ) >>PAGE_SHIFT ;shm_rmid (ns, shp);shm_unlock (shp); -if (!is_file_hugepages (shp->shm_file)) -shmem_lock (shp->shm_file,0 , shp->mlock_user); +if (!is_file_hugepages (shm_file)) +shmem_lock (shm_file,0 , shp->mlock_user);else if (shp->mlock_user) -user_shm_unlock (file_inode (shp->shm_file)->i_size, - shp->mlock_user); -fput (shp->shm_file); +user_shm_unlock (file_inode (shm_file)->i_size, shp->mlock_user); +fput (shm_file);ipc_rcu_putref (shp, shm_rcu_free); }
@@ -986,6 +989,13 @@ SYSCALL_DEFINE3(shmctl, int, shmid, int, } shm_file = shp->shm_file; + +/* check if shm_destroy() is tearing down shp */ +if (shm_file ==NULL ) { + err = -EIDRM ; + goto out_unlock0; + } +if (is_file_hugepages (shm_file)) goto out_unlock0;
@@ -1104,6 +1114,14 @@ long do_shmat(int shmid, char __user *sh goto out_unlock;ipc_lock_object (&shp->shm_perm); + +/* check if shm_destroy() is tearing down shp */ +if (shp->shm_file ==NULL ) { +ipc_unlock_object (&shp->shm_perm); + err = -EIDRM ; + goto out_unlock; + } + path = shp->shm_file->f_path;path_get (&path); shp->shm_nattch++;
Greg Kroah-Hartman
maintainerPATCH 14/116 drm: shmobile: Add dependency on BACKLIGHT_CLASS_DEVICE
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurent Pinchart <[email protected]>
commit 0a5a5499ad886dde4a032203d01e324cfe593f99 upstream.
The driver registers a backlight device and thus requires BACKLIGHT_CLASS_DEVICE to be selected to avoid compilation breakages.
--- drivers/gpu/drm/shmobile/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/shmobile/Kconfig +1 -0
@@ -1,6 +1,7 @@ config DRM_SHMOBILE tristate "DRM Support for SH Mobile" depends on DRM && (ARM || SUPERH) + select BACKLIGHT_CLASS_DEVICE select DRM_KMS_HELPER select DRM_KMS_CMA_HELPER select DRM_GEM_CMA_HELPER
Greg Kroah-Hartman
maintainerPATCH 15/116 staging: ashmem: Fix ASHMEM_PURGE_ALL_CACHES return value
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Stultz <[email protected]>
commit 5957324045ba2c127c9401fa3ac61ac52e043ca8 upstream.
Hopefully this isn't too late for 3.12.
In commit 7dc19d5aff (convert shrinkers to new count/scan API) the return value to PURGE_ALL_CACHES was dropped, causing -EPERM to always be returned.
This patch re-adds the ret assignment, setting it to the the ashmem_shrink_count(), which is the lru_count.
(Sorry this was missed in the review!)
--- drivers/staging/android/ashmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/android/ashmem.c +1 -1
@@ -706,7 +706,7 @@ static long ashmem_ioctl(struct file *fi .gfp_mask = GFP_KERNEL, .nr_to_scan = LONG_MAX, }; - + ret =ashmem_shrink_count (&ashmem_shrinker, &sc);nodes_setall (sc.nodes_to_scan);ashmem_shrink_scan (&ashmem_shrinker, &sc); }
Greg Kroah-Hartman
maintainerPATCH 16/116 drm/nvc0-/gr: fix a number of missing explicit array terminators...
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Skeggs <[email protected]>
commit 13d2b35a065399fb447c84e80368927e5f8bf086 upstream.
--- drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc1.c | 4 ++++ drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd7.c | 1 + drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd9.c | 1 + 3 files changed, 6 insertions(+)
drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc1.c +4 -0
@@ -587,6 +587,7 @@ nvc1_grctx_init_unk58xx[] = { { 0x405870, 4, 0x04, 0x00000001 }, { 0x405a00, 2, 0x04, 0x00000000 }, { 0x405a18, 1, 0x04, 0x00000000 }, + {} }; static struct nvc0_graph_init
@@ -598,6 +599,7 @@ nvc1_grctx_init_rop[] = { { 0x408904, 1, 0x04, 0x62000001 }, { 0x408908, 1, 0x04, 0x00c80929 }, { 0x408980, 1, 0x04, 0x0000011d }, + {} }; static struct nvc0_graph_init
@@ -671,6 +673,7 @@ nvc1_grctx_init_gpc_0[] = { { 0x419000, 1, 0x04, 0x00000780 }, { 0x419004, 2, 0x04, 0x00000000 }, { 0x419014, 1, 0x04, 0x00000004 }, + {} }; static struct nvc0_graph_init
@@ -717,6 +720,7 @@ nvc1_grctx_init_tpc[] = { { 0x419e98, 1, 0x04, 0x00000000 }, { 0x419ee0, 1, 0x04, 0x00011110 }, { 0x419f30, 11, 0x04, 0x00000000 }, + {} };void
drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd7.c +1 -0
@@ -258,6 +258,7 @@ nvd7_grctx_init_hub[] = { nvc0_grctx_init_unk78xx, nvc0_grctx_init_unk80xx, nvd9_grctx_init_rop, +NULL }; struct nvc0_graph_init *
drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd9.c +1 -0
@@ -466,6 +466,7 @@ nvd9_grctx_init_hub[] = { nvc0_grctx_init_unk78xx, nvc0_grctx_init_unk80xx, nvd9_grctx_init_rop, +NULL }; struct nvc0_graph_init *
Greg Kroah-Hartman
maintainerPATCH 17/116 thinkpad_acpi: Fix build error when CONFIG_SND_MAX_CARDS > 32
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit cab6661344f14a09d7aecdf821a40f68ef9b18cc upstream.
SNDRV_CARDS can be specified via Kconfig since 3.11 kernel, so this can be over 32bit integer range, which leads to a build error.
--- drivers/platform/x86/thinkpad_acpi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/platform/x86/thinkpad_acpi.c +6 -1
@@ -6420,7 +6420,12 @@ static struct ibm_struct brightness_driv#define TPACPI_ALSA_SHRTNAME "ThinkPad Console Audio Control"#define TPACPI_ALSA_MIXERNAME TPACPI_ALSA_SHRTNAME -static int alsa_index = ~((1 << (SNDRV_CARDS -3 )) -1 );/* last three slots */ +#if SNDRV_CARDS <=32 +#define DEFAULT_ALSA_IDX ~((1 << (SNDRV_CARDS - 3)) - 1) +#else +#define DEFAULT_ALSA_IDX ~((1 << (32 - 3)) - 1) +#endif +static int alsa_index =DEFAULT_ALSA_IDX ;/* last three slots */ static char *alsa_id ="ThinkPadEC" ;static bool alsa_enable =SNDRV_DEFAULT_ENABLE1 ;
Greg Kroah-Hartman
maintainerPATCH 18/116 ARM: OMAP2+: hwmod: check for module address space during init
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suman Anna <[email protected]>
commit 6423d6df1440a8acfc2f375d7cbc4cd66c2e6910 upstream.
The hwmod init sequence involves initializing and idling all the hwmods during bootup. If a module class has sysconfig, the init sequence utilizes the module register base for performing any sysc configuration.
The module address space is being removed from hwmod database and retrieved from the <reg> property of the corresponding DT node. If a hwmod does not have its corresponding DT node defined and the memory address space is not defined in the corresponding omap_hwmod_ocp_if, then the module register target address space would be NULL and any sysc programming would result in a NULL pointer dereference and a kernel boot hang.
Handle this scenario by checking for a valid module address space during the _init of each hwmod, and leaving it in the registered state if no module register address base is defined in either of the hwmod data or the DT data.
[[email protected]: use -ENXIO rather than -ENOMEM to indicate a missing address
space error; fixed checkpatch.pl problem]
--- arch/arm/mach-omap2/omap_hwmod.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
arch/arm/mach-omap2/omap_hwmod.c +19 -10
@@ -2361,21 +2361,23 @@ static struct device_node *of_dev_hwmod_* Cache the virtual address used by the MPU to access this IP block's * registers. This address is needed early so the OCP registers that * are part of the device's address space can be ioremapped properly. -* No return value. +* +* Returns 0 on success, -EINVAL if an invalid hwmod is passed, and +* -ENXIO on absent or invalid register target address space. */ -static void __init _init_mpu_rt_base (struct omap_hwmod *oh,void *data) +static int __init _init_mpu_rt_base (struct omap_hwmod *oh,void *data) {struct omap_hwmod_addr_space *mem;void __iomem *va_start =NULL ;struct device_node *np;if (!oh) -return ; +return -EINVAL ;_save_mpu_port_index (oh);if (oh->_int_flags & _HWMOD_NO_MPU_PORT) -return ; +return -ENXIO ; mem =_find_mpu_rt_addr_space (oh);if (!mem) {
@@ -2384,7 +2386,7 @@ static void __init _init_mpu_rt_base(str/* Extract the IO space from device tree blob */ if (!of_have_populated_dt ()) -return ; +return -ENXIO ; np =of_dev_hwmod_lookup (of_find_node_by_name (NULL ,"ocp" ), oh);if (np)
@@ -2395,13 +2397,14 @@ static void __init _init_mpu_rt_base(strif (!va_start) {pr_err ("omap_hwmod: %s: Could not ioremap\n" , oh->name); -return ; +return -ENXIO ; }pr_debug ("omap_hwmod: %s: MPU register target at va %p\n" , oh->name, va_start); oh->_mpu_rt_va = va_start; +return 0 ; }/**
@@ -2414,8 +2417,8 @@ static void __init _init_mpu_rt_base(str* registered at this point. This is the first of two phases for * hwmod initialization. Code called here does not touch any hardware * registers, it simply prepares internal data structures. Returns 0 -* upon success or if the hwmod isn't registered, or -EINVAL upon -* failure. +* upon success or if the hwmod isn't registered or if the hwmod's +* address space is not defined, or -EINVAL upon failure. */ static int __init _init (struct omap_hwmod *oh,void *data) {
@@ -2424,8 +2427,14 @@ static int __init _init(struct omap_hwmoif (oh->_state != _HWMOD_STATE_REGISTERED)return 0 ; -if (oh->class->sysc) -_init_mpu_rt_base (oh,NULL ); +if (oh->class->sysc) { + r =_init_mpu_rt_base (oh,NULL ); +if (r <0 ) { +WARN (1 ,"omap_hwmod: %s: doesn't have mpu register target base\n" , + oh->name); +return 0 ; + } + } r =_init_clocks (oh,NULL );if (r <0 ) {
Greg Kroah-Hartman
maintainerPATCH 19/116 sched, idle: Fix the idle polling state logic
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit ea8117478918a4734586d35ff530721b682425be upstream.
Mike reported that commit 7d1a9417 ("x86: Use generic idle loop") regressed several workloads and caused excessive reschedule interrupts.
The patch in question failed to notice that the x86 code had an inverted sense of the polling state versus the new generic code (x86:
default polling, generic: default !polling).
Fix the two prominent x86 mwait based idle drivers and introduce a few new generic polling helpers (fixing the wrong smp_mb__after_clear_bit usage).
Also switch the idle routines to using tif_need_resched() which is an immediate TIF_NEED_RESCHED test as opposed to need_resched which will end up being slightly different.
--- arch/x86/kernel/process.c | 6 +-- drivers/acpi/processor_idle.c | 46 +++++------------------- drivers/idle/intel_idle.c | 2 - include/linux/sched.h | 78 ++++++++++++++++++++++++++++++++++++++---- include/linux/thread_info.h | 2 + kernel/cpu/idle.c | 9 ++-- 6 files changed, 91 insertions(+), 52 deletions(-)
arch/x86/kernel/process.c +3 -3
@@ -391,9 +391,9 @@ static void amd_e400_idle(void)* The switch back from broadcast mode needs to be * called with interrupts disabled. */ -local_irq_disable (); -clockevents_notify (CLOCK_EVT_NOTIFY_BROADCAST_EXIT , &cpu); -local_irq_enable (); +local_irq_disable (); +clockevents_notify (CLOCK_EVT_NOTIFY_BROADCAST_EXIT , &cpu); +local_irq_enable (); }else default_idle (); }
drivers/acpi/processor_idle.c +10 -36
87 lines not on this page · raw message
drivers/idle/intel_idle.c +1 -1
@@ -359,7 +359,7 @@ static int intel_idle(struct cpuidle_devif (!(lapic_timer_reliable_states & (1 << (cstate))))clockevents_notify (CLOCK_EVT_NOTIFY_BROADCAST_ENTER , &cpu); -if (!need_resched ()) { +if (!current_set_polling_and_test ()) {__monitor ((void *)¤t_thread_info ()->flags,0 ,0 );smp_mb ();
include/linux/sched.h +71 -7
105 lines not on this page · raw message
include/linux/thread_info.h +2 -0
@@ -107,6 +107,8 @@ static inline int test_ti_thread_flag(st#define set_need_resched () set_thread_flag(TIF_NEED_RESCHED)#define clear_need_resched () clear_thread_flag(TIF_NEED_RESCHED) +#define tif_need_resched () test_thread_flag(TIF_NEED_RESCHED) +#if definedTIF_RESTORE_SIGMASK && !definedHAVE_SET_RESTORE_SIGMASK /* * An arch can define its own version of set_restore_sigmask() to get the
kernel/cpu/idle.c +4 -5
@@ -44,7 +44,7 @@ static inline int cpu_idle_poll(void)rcu_idle_enter ();trace_cpu_idle_rcuidle (0 ,smp_processor_id ());local_irq_enable (); -while (!need_resched ()) +while (!tif_need_resched ())cpu_relax ();trace_cpu_idle_rcuidle (PWR_EVENT_EXIT ,smp_processor_id ());rcu_idle_exit ();
@@ -92,8 +92,7 @@ static void cpu_idle_loop(void)if (cpu_idle_force_poll ||tick_check_broadcast_expired ()) {cpu_idle_poll (); }else { -current_clr_polling (); -if (!need_resched ()) { +if (!current_clr_polling_and_test ()) {stop_critical_timings ();rcu_idle_enter ();arch_cpu_idle ();
@@ -103,7 +102,7 @@ static void cpu_idle_loop(void) }else {local_irq_enable (); } -current_set_polling (); +__current_set_polling (); }arch_cpu_idle_exit (); }
@@ -129,7 +128,7 @@ void cpu_startup_entry(enum cpuhp_state*/ boot_init_stack_canary ();#endif -current_set_polling (); +__current_set_polling ();arch_cpu_idle_prepare ();cpu_idle_loop (); }
Greg Kroah-Hartman
maintainerPATCH 20/116 perf/ftrace: Fix paranoid level for enabling function tracer
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
commit 12ae030d54ef250706da5642fc7697cc60ad0df7 upstream.
The current default perf paranoid level is "1" which has "perf_paranoid_kernel()" return false, and giving any operations that use it, access to normal users. Unfortunately, this includes function tracing and normal users should not be allowed to enable function tracing by default.
The proper level is defined at "-1" (full perf access), which "perf_paranoid_tracepoint_raw()" will only give access to. Use that check instead for enabling function tracing.
CVE: CVE-2013-2930
--- kernel/trace/trace_event_perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_event_perf.c +1 -1
@@ -26,7 +26,7 @@ static int perf_trace_event_perm(struct {/* The ftrace function trace is allowed only for root. */ if (ftrace_event_is_function (tp_event) && -perf_paranoid_kernel () && !capable (CAP_SYS_ADMIN )) +perf_paranoid_tracepoint_raw () && !capable (CAP_SYS_ADMIN ))return -EPERM ;/* No tracing, just counting, so no obvious leak */
Greg Kroah-Hartman
maintainerPATCH 21/116 ACPI / EC: Ensure lock is acquired before accessing ec struct members
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Puneet Kumar <[email protected]>
commit 36b15875a7819a2ec4cb5748ff7096ad7bd86cbb upstream.
A bug was introduced by commit b76b51ba0cef ('ACPI / EC: Add more debug info and trivial code cleanup') that erroneously caused the struct member to be accessed before acquiring the required lock. This change fixes it by ensuring the lock acquisition is done first.
Found by Aaron Durbin <[email protected]>
References: http://crbug.com/319019
--- drivers/acpi/ec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/ec.c +2 -1
@@ -175,9 +175,10 @@ static void start_transaction(struct acpstatic void advance_transaction (struct acpi_ec *ec,u8 status) {unsigned long flags; -struct transaction *t = ec->curr; +struct transaction *t;spin_lock_irqsave (&ec->lock, flags); + t = ec->curr;if (!t) goto unlock;if (t->wlen > t->wi) {
Greg Kroah-Hartman
maintainerPATCH 22/116 ACPI / video: Quirk initial backlight level 0
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Lu <[email protected]>
commit 2c62333a408f5badd2d2ffd7177f95deeccc5ca4 upstream.
Some firmware doesn't initialize initial backlight level to a proper value and _BQC will return 0 on first time evaluation. We used to be able to detect such incorrect value with our code logic, as value 0 normally isn't a valid value in _BCL. But with the introduction of Win8, firmware begins to fill _BCL with values from 0 to 100, now 0 becomes a valid value but that value will make user's screen black. This patch test initial _BQC for value 0, if such a value is returned, do not use it.
References: https://bugzilla.kernel.org/show_bug.cgi?id=64031
References: https://bugzilla.kernel.org/show_bug.cgi?id=61231
References: https://bugzilla.kernel.org/show_bug.cgi?id=63111
--- drivers/acpi/video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/video.c +1 -1
@@ -832,7 +832,7 @@ acpi_video_init_brightness(struct acpi_vfor (i =2 ; i < br->count; i++)if (level_old == br->levels[i])break ; -if (i == br->count) +if (i == br->count || !level) level = max_level; }
Greg Kroah-Hartman
maintainerPATCH 23/116 ACPI / hotplug: Fix handle_root_bridge_removal()
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Rafael J. Wysocki" <[email protected]>
commit 2441191a19039002b2c454a261fb45986df15184 upstream.
It is required to do get_device() on the struct acpi_device in question before passing it to acpi_bus_hot_remove_device() through acpi_os_hotplug_execute(), because acpi_bus_hot_remove_device() calls acpi_scan_hot_remove() that does put_device() on that object.
The ACPI PCI root removal routine, handle_root_bridge_removal(), doesn't do that, which may lead to premature freeing of the device object or to executing put_device() on an object that has been freed already.
Fix this problem by making handle_root_bridge_removal() use get_device() as appropriate.
--- drivers/acpi/pci_root.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/acpi/pci_root.c +4 -1
@@ -608,9 +608,12 @@ static void handle_root_bridge_removal(s ej_event->device = device; ej_event->event =ACPI_NOTIFY_EJECT_REQUEST ; +get_device (&device->dev); status =acpi_os_hotplug_execute (acpi_bus_hot_remove_device, ej_event); -if (ACPI_FAILURE (status)) +if (ACPI_FAILURE (status)) { +put_device (&device->dev);kfree (ej_event); + } }static void _handle_hotplug_event_root (struct work_struct *work)
Greg Kroah-Hartman
maintainerPATCH 24/116 ACPI / hotplug: Do not execute "insert in progress" _OST
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Rafael J. Wysocki" <[email protected]>
commit 176a88d79d6b5aebabaff16734e8b3107efcaaad upstream.
According to the ACPI spec (5.0, Section 6.3.5), the "Device insertion in progress (pending)" (0x80) _OST status code is reserved for the "Insertion Processing" (0x200) source event which is "a result of an OSPM action". Specifically, it is not a notification, so that status code should not be used during notification processing, which unfortunately is done by acpi_scan_bus_device_check().
For this reason, drop the ACPI_OST_SC_INSERT_IN_PROGRESS _OST status evaluation from there (it was a mistake to put it in there in the first place).
--- drivers/acpi/scan.c | 2 -- 1 file changed, 2 deletions(-)
drivers/acpi/scan.c +0 -2
@@ -331,8 +331,6 @@ static void acpi_scan_bus_device_check(a goto out; } } -acpi_evaluate_hotplug_ost (handle, ost_source, -ACPI_OST_SC_INSERT_IN_PROGRESS ,NULL ); error =acpi_bus_scan (handle);if (error) {acpi_handle_warn (handle,"Namespace scan failure\n" );
Greg Kroah-Hartman
maintainerPATCH 25/116 Staging: zram: Fix access of NULL pointer
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rashika Kheria <[email protected]>
commit 46a51c80216cb891f271ad021f59009f34677499 upstream.
This patch fixes the bug in reset_store caused by accessing NULL pointer.
The bdev gets its value from bdget_disk() which could fail when memory pressure is severe and hence can return NULL because allocation of inode in bdget could fail.
Hence, this patch introduces a check for bdev to prevent reference to a NULL pointer in the later part of the code. It also removes unnecessary check of bdev for fsync_bdev().
--- drivers/staging/zram/zram_drv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/zram/zram_drv.c +4 -2
@@ -648,6 +648,9 @@ static ssize_t reset_store(struct device zram =dev_to_zram (dev); bdev =bdget_disk (zram->disk,0 ); +if (!bdev) +return -ENOMEM ; +/* Do not reset an active device! */ if (bdev->bd_holders)return -EBUSY ;
@@ -660,8 +663,7 @@ static ssize_t reset_store(struct devicereturn -EINVAL ;/* Make sure all pending I/O is finished */ -if (bdev) -fsync_bdev (bdev); +fsync_bdev (bdev);zram_reset_device (zram, true);return len;
Greg Kroah-Hartman
maintainerPATCH 26/116 staging: r8188eu: Set device type to wlan
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Larry Finger <[email protected]>
commit 0d1206be229697f897f00822bc142e66da731417 upstream.
The latest version of NetworkManager does not recognize the device as wireless without this change.
--- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/staging/rtl8188eu/os_dep/os_intfs.c +5 -0
@@ -707,6 +707,10 @@ int rtw_init_netdev_name(struct net_devireturn 0 ; } +static const struct device_type wlan_type = { + .name ="wlan" , +}; +struct net_device *rtw_init_netdev (struct adapter *old_padapter) {struct adapter *padapter;
@@ -722,6 +726,7 @@ struct net_device *rtw_init_netdev(strucif (!pnetdev)return NULL ; + pnetdev->dev.type = &wlan_type; padapter =rtw_netdev_priv (pnetdev); padapter->pnetdev = pnetdev;DBG_88E ("register rtw_netdev_ops to netdev_ops\n" );
Greg Kroah-Hartman
maintainerPATCH 27/116 staging: comedi: avoid memleak for subdevice private
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Abbott <[email protected]>
commit 67aa4acbc97f6a55b328e4e2305ef19cbe949d85 upstream.
comedi_alloc_spriv() allocates private storage for a comedi subdevice and sets the SRF_FREE_SPRIV flag in the runflags member of the subdevice to allow the private storage to be automatically freed when the comedi device is being cleaned up. Unfortunately, the flag gets clobbered by do_cmd_ioctl() which calls comedi_set_subdevice_runflags() with a mask value ~0 and only the SRF_USER and SRF_RUNNING flags set, all the other SRF flags being cleared.
Change the calls to comedi_set_subdevice_runflags() that currently use a mask value of ~0 to use a more relevant mask value. For do_cmd_ioctl(), the relevant SRF flags are SRF_USER, SRF_ERROR and SRF_RUNNING. (At one time, SRF_RT would be included in that set of flags, but it is no longer used.) For comedi_alloc_spriv() replace the call to comedi_set_subdevice_runflags() with a simple OR-assignment to avoid unnecessary use of a spin-lock.
--- drivers/staging/comedi/comedi_fops.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/comedi/comedi_fops.c +3 -2
@@ -543,7 +543,7 @@ void *comedi_alloc_spriv(struct comedi_s { s->private =kzalloc (size,GFP_KERNEL );if (s->private) -comedi_set_subdevice_runflags (s, ~0 ,SRF_FREE_SPRIV ); + s->runflags |=SRF_FREE_SPRIV ;return s->private; }EXPORT_SYMBOL_GPL (comedi_alloc_spriv);
@@ -1485,7 +1485,8 @@ static int do_cmd_ioctl(struct comedi_deif (async->cmd.flags &TRIG_WAKE_EOS ) async->cb_mask |=COMEDI_CB_EOS ; -comedi_set_subdevice_runflags (s, ~0 ,SRF_USER |SRF_RUNNING ); +comedi_set_subdevice_runflags (s,SRF_USER |SRF_ERROR |SRF_RUNNING , +SRF_USER |SRF_RUNNING );/* set s->busy _after_ setting SRF_RUNNING flag to avoid race with * comedi_read() or comedi_write() */
Greg Kroah-Hartman
maintainerPATCH 28/116 lkdtm: isolate stack corruption test
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit 629c66a22c21b692b6e58b9c1d8fa56a60ccb52d upstream.
When tests were added to lkdtm that grew the stack frame, the stack corruption test stopped working. This isolates the test in its own function, and forces it not to be inlined.
--- drivers/misc/lkdtm.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/misc/lkdtm.c +10 -6
@@ -297,6 +297,14 @@ static void do_nothing(void)return ; } +static noinline void corrupt_stack(void) +{ +/* Use default char array length that triggers stack protection. */ +char data[8 ]; + +memset ((void *)data,0 ,64 ); +} +static void execute_location (void *dst) {void (*func)(void ) = dst;
@@ -327,13 +335,9 @@ static void lkdtm_do_action(enum ctype wcase CT_OVERFLOW : (void )recursive_loop (0 );break ; -case CT_CORRUPT_STACK : { -/* Make sure the compiler creates and uses an 8 char array. */ -volatile char data[8 ]; - -memset ((void *)data,0 ,64 ); +case CT_CORRUPT_STACK : +corrupt_stack ();break ; - }case CT_UNALIGNED_LOAD_STORE_WRITE : { static u8 data[5] __attribute__((aligned(4))) = {1, 2, 3, 4, 5};
Greg Kroah-Hartman
maintainerPATCH 29/116 Drivers: hv: vmbus: Fix a bug in channel rescind code
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: "K. Y. Srinivasan" <[email protected]>
commit 565ce6422ff92f5af71e4d5a09f78215433b2695 upstream.
Rescind of subchannels were not being correctly handled. Fix the bug.
--- drivers/hv/channel_mgmt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/hv/channel_mgmt.c +3 -2
@@ -203,7 +203,8 @@ static void vmbus_process_rescind_offer(struct vmbus_channel *primary_channel;struct vmbus_channel_relid_released msg; -vmbus_device_unregister (channel->device_obj); +if (channel->device_obj) +vmbus_device_unregister (channel->device_obj);memset (&msg,0 ,sizeof (struct vmbus_channel_relid_released )); msg.child_relid = channel->offermsg.child_relid; msg.header.msgtype =CHANNELMSG_RELID_RELEASED ;
@@ -216,7 +217,7 @@ static void vmbus_process_rescind_offer( }else { primary_channel = channel->primary_channel;spin_lock_irqsave (&primary_channel->sc_lock, flags); -list_del (&channel->listentry); +list_del (&channel->sc_list);spin_unlock_irqrestore (&primary_channel->sc_lock, flags); }free_channel (channel);
Greg Kroah-Hartman
maintainerPATCH 30/116 rt2x00: fix a crash bug in the HT descriptor handling fix
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
commit b4089d6d8e71a7293e2192025dfa507a04f661c4 upstream.
Commit "rt2x00: fix HT TX descriptor settings regression" assumes that the control parameter to rt2x00mac_tx is always non-NULL. There is an internal call in rt2x00lib_bc_buffer_iter where NULL is passed. Fix the resulting crash by adding an initialized dummy on-stack ieee80211_tx_control struct.
--- drivers/net/wireless/rt2x00/rt2x00dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/rt2x00/rt2x00dev.c +2 -1
@@ -181,6 +181,7 @@ static void rt2x00lib_autowakeup(structstatic void rt2x00lib_bc_buffer_iter (void *data,u8 *mac,struct ieee80211_vif *vif) { +struct ieee80211_tx_control control = {};struct rt2x00_dev *rt2x00dev = data;struct sk_buff *skb;
@@ -195,7 +196,7 @@ static void rt2x00lib_bc_buffer_iter(voi*/ skb =ieee80211_get_buffered_bc (rt2x00dev->hw, vif);while (skb) { -rt2x00mac_tx (rt2x00dev->hw,NULL , skb); +rt2x00mac_tx (rt2x00dev->hw, &control, skb); skb =ieee80211_get_buffered_bc (rt2x00dev->hw, vif); } }
Greg Kroah-Hartman
maintainerPATCH 31/116 rt2x00: check if device is still available on rt2x00mac_flush()
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislaw Gruszka <[email protected]>
commit 5671ab05cf2a579218985ef56595387932d78ee4 upstream.
Fix random kernel panic with below messages when remove dongle.
[ 2212.355447] BUG: unable to handle kernel NULL pointer dereference at 0000000000000250 [ 2212.355527] IP: [<ffffffffa02667f2>] rt2x00usb_kick_tx_entry+0x12/0x160 [rt2x00usb] [ 2212.355599] PGD 0 [ 2212.355626] Oops: 0000 [#1] SMP [ 2212.355664] Modules linked in: rt2800usb rt2x00usb rt2800lib crc_ccitt rt2x00lib mac80211 cfg80211 tun arc4 fuse rfcomm bnep snd_hda_codec_realtek snd_hda_intel snd_hda_codec btusb uvcvideo bluetooth snd_hwdep x86_pkg_temp_thermal snd_seq coretemp aesni_intel aes_x86_64 snd_seq_device glue_helper snd_pcm ablk_helper videobuf2_vmalloc sdhci_pci videobuf2_memops videobuf2_core sdhci videodev mmc_core serio_raw snd_page_alloc microcode i2c_i801 snd_timer hid_multitouch thinkpad_acpi lpc_ich mfd_core snd tpm_tis wmi tpm tpm_bios soundcore acpi_cpufreq i915 i2c_algo_bit drm_kms_helper drm i2c_core video [last unloaded: cfg80211] [ 2212.356224] CPU: 0 PID: 34 Comm: khubd Not tainted 3.12.0-rc3-wl+ #3 [ 2212.356268] Hardware name: LENOVO 3444CUU/3444CUU, BIOS G6ET93WW (2.53 ) 02/04/2013 [ 2212.356319] task: ffff880212f687c0 ti: ffff880212f66000 task.ti: ffff880212f66000 [ 2212.356392] RIP: 0010:[<ffffffffa02667f2>] [<ffffffffa02667f2>] rt2x00usb_kick_tx_entry+0x12/0x160 [rt2x00usb] [ 2212.356481] RSP: 0018:ffff880212f67750 EFLAGS: 00010202 [ 2212.356519] RAX: 000000000000000c RBX: 000000000000000c RCX: 0000000000000293 [ 2212.356568] RDX: ffff8801f4dc219a RSI: 0000000000000000 RDI: 0000000000000240 [ 2212.356617] RBP: ffff880212f67778 R08: ffffffffa02667e0 R09: 0000000000000002 [ 2212.356665] R10: 0001f95254ab4b40 R11: ffff880212f675be R12: ffff8801f4dc2150 [ 2212.356712] R13: 0000000000000000 R14: ffffffffa02667e0 R15: 000000000000000d [ 2212.356761] FS: 0000000000000000(0000) GS:ffff88021e200000(0000) knlGS:0000000000000000 [ 2212.356813] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 2212.356852] CR2: 0000000000000250 CR3: 0000000001a0c000 CR4: 00000000001407f0 [ 2212.356899] Stack: [ 2212.356917] 000000000000000c ffff8801f4dc2150 0000000000000000 ffffffffa02667e0 [ 2212.356980] 000000000000000d ffff880212f677b8 ffffffffa03a31ad ffff8801f4dc219a [ 2212.357038] ffff8801f4dc2150 0000000000000000 ffff8800b93217a0 ffff8801f49bc800 [ 2212.357099] Call Trace: [ 2212.357122] [<ffffffffa02667e0>] ? rt2x00usb_interrupt_txdone+0x90/0x90 [rt2x00usb] [ 2212.357174] [<ffffffffa03a31ad>] rt2x00queue_for_each_entry+0xed/0x170 [rt2x00lib] [ 2212.357244] [<ffffffffa026701c>] rt2x00usb_kick_queue+0x5c/0x60 [rt2x00usb] [ 2212.357314] [<ffffffffa03a3682>] rt2x00queue_flush_queue+0x62/0xa0 [rt2x00lib] [ 2212.357386] [<ffffffffa03a2930>] rt2x00mac_flush+0x30/0x70 [rt2x00lib] [ 2212.357470] [<ffffffffa04edded>] ieee80211_flush_queues+0xbd/0x140 [mac80211] [ 2212.357555] [<ffffffffa0502e52>] ieee80211_set_disassoc+0x2d2/0x3d0 [mac80211] [ 2212.357645] [<ffffffffa0506da3>] ieee80211_mgd_deauth+0x1d3/0x240 [mac80211] [ 2212.357718] [<ffffffff8108b17c>] ? try_to_wake_up+0xec/0x290 [ 2212.357788] [<ffffffffa04dbd18>] ieee80211_deauth+0x18/0x20 [mac80211] [ 2212.357872] [<ffffffffa0418ddc>] cfg80211_mlme_deauth+0x9c/0x140 [cfg80211] [ 2212.357913] [<ffffffffa041907c>] cfg80211_mlme_down+0x5c/0x60 [cfg80211] [ 2212.357962] [<ffffffffa041cd18>] cfg80211_disconnect+0x188/0x1a0 [cfg80211] [ 2212.358014] [<ffffffffa04013bc>] ? __cfg80211_stop_sched_scan+0x1c/0x130 [cfg80211] [ 2212.358067] [<ffffffffa03f8954>] cfg80211_leave+0xc4/0xe0 [cfg80211] [ 2212.358124] [<ffffffffa03f8d1b>] cfg80211_netdev_notifier_call+0x3ab/0x5e0 [cfg80211] [ 2212.358177] [<ffffffff815140f8>] ? inetdev_event+0x38/0x510 [ 2212.358217] [<ffffffff81085a94>] ? __wake_up+0x44/0x50 [ 2212.358254] [<ffffffff8155995c>] notifier_call_chain+0x4c/0x70 [ 2212.358293] [<ffffffff81081156>] raw_notifier_call_chain+0x16/0x20 [ 2212.358361] [<ffffffff814b6dd5>] call_netdevice_notifiers_info+0x35/0x60 [ 2212.358429] [<ffffffff814b6ec9>] __dev_close_many+0x49/0xd0 [ 2212.358487] [<ffffffff814b7028>] dev_close_many+0x88/0x100 [ 2212.358546] [<ffffffff814b8150>] rollback_registered_many+0xb0/0x220 [ 2212.358612] [<ffffffff814b8319>] unregister_netdevice_many+0x19/0x60 [ 2212.358694] [<ffffffffa04d8eb2>] ieee80211_remove_interfaces+0x112/0x190 [mac80211] [ 2212.358791] [<ffffffffa04c585f>] ieee80211_unregister_hw+0x4f/0x100 [mac80211] [ 2212.361994] [<ffffffffa03a1221>] rt2x00lib_remove_dev+0x161/0x1a0 [rt2x00lib] [ 2212.365240] [<ffffffffa0266e2e>] rt2x00usb_disconnect+0x2e/0x70 [rt2x00usb] [ 2212.368470] [<ffffffff81419ce4>] usb_unbind_interface+0x64/0x1c0 [ 2212.371734] [<ffffffff813b446f>] __device_release_driver+0x7f/0xf0 [ 2212.374999] [<ffffffff813b4503>] device_release_driver+0x23/0x30 [ 2212.378131] [<ffffffff813b3c98>] bus_remove_device+0x108/0x180 [ 2212.381358] [<ffffffff813b0565>] device_del+0x135/0x1d0 [ 2212.384454] [<ffffffff81417760>] usb_disable_device+0xb0/0x270 [ 2212.387451] [<ffffffff8140d9cd>] usb_disconnect+0xad/0x1d0 [ 2212.390294] [<ffffffff8140f6cd>] hub_thread+0x63d/0x1660 [ 2212.393034] [<ffffffff8107c860>] ? wake_up_atomic_t+0x30/0x30 [ 2212.395728] [<ffffffff8140f090>] ? hub_port_debounce+0x130/0x130 [ 2212.398412] [<ffffffff8107baa0>] kthread+0xc0/0xd0 [ 2212.401058] [<ffffffff8107b9e0>] ? insert_kthread_work+0x40/0x40 [ 2212.403639] [<ffffffff8155de3c>] ret_from_fork+0x7c/0xb0 [ 2212.406193] [<ffffffff8107b9e0>] ? insert_kthread_work+0x40/0x40 [ 2212.408732] Code: 24 58 08 00 00 bf 80 00 00 00 e8 3a c3 e0 e0 5b 41 5c 5d c3 0f 1f 44 00 00 0f 1f 44 00 00 55 48 89 e5 41 57 41 56 41 55 41 54 53 <48> 8b 47 10 48 89 fb 4c 8b 6f 28 4c 8b 20 49 8b 04 24 4c 8b 30 [ 2212.414671] RIP [<ffffffffa02667f2>] rt2x00usb_kick_tx_entry+0x12/0x160 [rt2x00usb] [ 2212.417646] RSP <ffff880212f67750> [ 2212.420547] CR2: 0000000000000250 [ 2212.441024] ---[ end trace 5442918f33832bce ]---
--- drivers/net/wireless/rt2x00/rt2x00mac.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/rt2x00/rt2x00mac.c +3 -0
@@ -754,6 +754,9 @@ void rt2x00mac_flush(struct ieee80211_hwstruct rt2x00_dev *rt2x00dev = hw->priv;struct data_queue *queue; +if (!test_bit (DEVICE_STATE_PRESENT , &rt2x00dev->flags)) +return ; +tx_queue_for_each (rt2x00dev, queue)rt2x00queue_flush_queue (queue, drop); }
Greg Kroah-Hartman
maintainerPATCH 32/116 rt2x00: rt2800lib: fix VGC adjustment for RT5592
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabor Juhos <[email protected]>
commit 0beb1bbf19c72f17809e42b8f33522a55c2cc18c upstream.
In commit 3d81535ea5940446510a8a5cee1c6ad23c90c753 (rt2800: 5592: add chip specific vgc calculations) the rt2800_link_tuner function has been modified to adjust VGC level for the RT5592 chipset.
On the RT5592 chipset, the VGC level must be adjusted only if rssi is greater than -65. However the current code adjusts the VGC value by 0x10 regardless of the actual chipset if the rssi value is between -80 and -65.
Fix the broken behaviour by reordering the if-else statements.
--- drivers/net/wireless/rt2x00/rt2800lib.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +7 -4
@@ -4461,10 +4461,13 @@ void rt2800_link_tuner(struct rt2x00_dev vgc =rt2800_get_default_vgc (rt2x00dev); -if (rt2x00_rt (rt2x00dev,RT5592 ) && qual->rssi >-65 ) - vgc +=0x20 ; -else if (qual->rssi >-80 ) - vgc +=0x10 ; +if (rt2x00_rt (rt2x00dev,RT5592 )) { +if (qual->rssi >-65 ) + vgc +=0x20 ; + }else { +if (qual->rssi >-80 ) + vgc +=0x10 ; + }rt2800_set_vgc (rt2x00dev, qual, vgc); }
Greg Kroah-Hartman
maintainerPATCH 33/116 rt2x00: fix HT TX descriptor settings regression
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislaw Gruszka <[email protected]>
commit 3d8bfe141be8e5c21261fc63da8e7964d44f2645 upstream.
Since:
commit 36323f817af0376c78612cfdab714b0feb05fea5
Author: Thomas Huehn <[email protected]> Date: Mon Jul 23 21:33:42 2012 +0200
mac80211: move TX station pointer and restructure TX
we do not pass sta pointer to rt2x00queue_create_tx_descriptor_ht(), hence we do not correctly set station WCID and AMPDU density parameters.
--- drivers/net/wireless/rt2x00/rt2x00lib.h | 2 +- drivers/net/wireless/rt2x00/rt2x00mac.c | 4 ++-- drivers/net/wireless/rt2x00/rt2x00queue.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/rt2x00/rt2x00lib.h +1 -1
@@ -146,7 +146,7 @@ void rt2x00queue_remove_l2pad(struct sk_* @local: frame is not from mac80211 */ int rt2x00queue_write_tx_frame (struct data_queue *queue,struct sk_buff *skb, -bool local); +struct ieee80211_sta *sta,bool local);/** * rt2x00queue_update_beacon - Send new beacon from mac80211
drivers/net/wireless/rt2x00/rt2x00mac.c +2 -2
@@ -90,7 +90,7 @@ static int rt2x00mac_tx_rts_cts(struct r frag_skb->data, data_length, tx_info, (struct ieee80211_rts *)(skb->data)); - retval =rt2x00queue_write_tx_frame (queue, skb, true); + retval =rt2x00queue_write_tx_frame (queue, skb,NULL , true);if (retval) {dev_kfree_skb_any (skb);rt2x00_warn (rt2x00dev,"Failed to send RTS/CTS frame\n" );
@@ -151,7 +151,7 @@ void rt2x00mac_tx(struct ieee80211_hw *h goto exit_fail; } -if (unlikely (rt2x00queue_write_tx_frame (queue, skb, false))) +if (unlikely (rt2x00queue_write_tx_frame (queue, skb, control->sta, false))) goto exit_fail;/*
drivers/net/wireless/rt2x00/rt2x00queue.c +2 -2
@@ -635,7 +635,7 @@ static void rt2x00queue_bar_check(struct }int rt2x00queue_write_tx_frame (struct data_queue *queue,struct sk_buff *skb, -bool local) +struct ieee80211_sta *sta,bool local) {struct ieee80211_tx_info *tx_info;struct queue_entry *entry;
@@ -649,7 +649,7 @@ int rt2x00queue_write_tx_frame(struct da* after that we are free to use the skb->cb array * for our information. */ -rt2x00queue_create_tx_descriptor (queue->rt2x00dev, skb, &txdesc,NULL ); +rt2x00queue_create_tx_descriptor (queue->rt2x00dev, skb, &txdesc, sta);/* * All information is retrieved from the skb->cb array,
Greg Kroah-Hartman
maintainerPATCH 34/116 Bluetooth: revert: "Bluetooth: Add missing reset_resume dev_pm_ops"
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit b1a8014471b01dd862de9f91bbbff1296afac42d upstream.
Many btusb devices have 2 modes, a hid mode and a bluetooth hci mode. These devices default to hid mode for BIOS use. This means that after having been reset they will revert to HID mode, and are no longer usable as a HCI.
Therefor it is a very bad idea to just blindly make reset_resume point to the regular resume handler. Note that the btusb driver has no clue how to switch these devices from hid to hci mode, this is done in userspace through udev rules, so the proper way to deal with this is to not have a reset-resume handler and instead let the usb-system re-enumerate the device, and re-run the udev rules.
I must also note, that the commit message for the commit causing this problem has a very weak motivation for the change:
"Add missing reset_resume dev_pm_ops. Missing reset_resume results in the following message after power management device test. This change sets reset_resume to btusb_resume().
[ 2506.936134] btusb 1-1.5:1.0: no reset_resume for driver btusb? [ 2506.936137] btusb 1-1.5:1.1: no reset_resume for driver btusb?"
Making a change solely to silence a warning while also changing important behavior (normal resume handling versus re-enumeration) requires a commit message with a proper explanation why it is safe to do so, which clearly lacks here, and unsurprisingly it turns out to not be safe to make this change.
Reverting the commit in question fixes bt no longer working on my Dell E6430 after a suspend/resume, and I believe it likely also fixes the following bugs:
https://bugzilla.redhat.com/show_bug.cgi?id=988481
https://bugzilla.redhat.com/show_bug.cgi?id=1010649
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1213239
This reverts commit 502f769662978a2fe99d0caed5e53e3006107381.
--- drivers/bluetooth/btusb.c | 1 - 1 file changed, 1 deletion(-)
drivers/bluetooth/btusb.c +0 -1
@@ -1628,7 +1628,6 @@ static struct usb_driver btusb_driver =#ifdef CONFIG_PM .suspend = btusb_suspend, .resume = btusb_resume, - .reset_resume = btusb_resume, #endif .id_table = btusb_table, .supports_autosuspend = 1,
Greg Kroah-Hartman
maintainerPATCH 35/116 Revert "ima: policy for RAMFS"
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mimi Zohar <[email protected]>
commit 08de59eb144d7c41351a467442f898d720f0f15f upstream.
This reverts commit 4c2c392763a682354fac65b6a569adec4e4b5387.
Everything in the initramfs should be measured and appraised, but until the initramfs has extended attribute support, at least measured.
--- security/integrity/ima/ima_policy.c | 1 - 1 file changed, 1 deletion(-)
security/integrity/ima/ima_policy.c +0 -1
@@ -73,7 +73,6 @@ static struct ima_rule_entry default_rul {.action = DONT_MEASURE,.fsmagic = SYSFS_MAGIC,.flags = IMA_FSMAGIC}, {.action = DONT_MEASURE,.fsmagic = DEBUGFS_MAGIC,.flags = IMA_FSMAGIC}, {.action = DONT_MEASURE,.fsmagic = TMPFS_MAGIC,.flags = IMA_FSMAGIC}, - {.action = DONT_MEASURE,.fsmagic = RAMFS_MAGIC,.flags = IMA_FSMAGIC}, {.action = DONT_MEASURE,.fsmagic = DEVPTS_SUPER_MAGIC,.flags = IMA_FSMAGIC}, {.action = DONT_MEASURE,.fsmagic = BINFMTFS_MAGIC,.flags = IMA_FSMAGIC}, {.action = DONT_MEASURE,.fsmagic = SECURITYFS_MAGIC,.flags = IMA_FSMAGIC},
Greg Kroah-Hartman
maintainerPATCH 36/116 exec/ptrace: fix get_dumpable() incorrect tests
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit d049f74f2dbe71354d43d393ac3a188947811348 upstream.
The get_dumpable() return value is not boolean. Most users of the function actually want to be testing for non-SUID_DUMP_USER(1) rather than SUID_DUMP_DISABLE(0). The SUID_DUMP_ROOT(2) is also considered a protected state. Almost all places did this correctly, excepting the two places fixed in this patch.
Wrong logic:
if (dumpable == SUID_DUMP_DISABLE) { /* be protective */ }
or
if (dumpable == 0) { /* be protective */ }
or
if (!dumpable) { /* be protective */ }Correct logic:
if (dumpable != SUID_DUMP_USER) { /* be protective */ }
or
if (dumpable != 1) { /* be protective */ }Without this patch, if the system had set the sysctl fs/suid_dumpable=2, a user was able to ptrace attach to processes that had dropped privileges to that user. (This may have been partially mitigated if Yama was enabled.)
The macros have been moved into the file that declares get/set_dumpable(), which means things like the ia64 code can see them too.
CVE-2013-2929
--- arch/ia64/include/asm/processor.h | 2 +- fs/exec.c | 6 ++++++ include/linux/binfmts.h | 3 --- include/linux/sched.h | 4 ++++ kernel/ptrace.c | 3 ++- 5 files changed, 13 insertions(+), 5 deletions(-)
arch/ia64/include/asm/processor.h +1 -1
@@ -319,7 +319,7 @@ struct thread_struct { regs->loadrs =0 ; \ regs->r8 =get_dumpable (current->mm);/* set "don't zap registers" flag */ \ regs->r12 = new_sp -16 ;/* allocate 16 byte scratch area */ \ -if (unlikely (!get_dumpable (current->mm))) { \ +if (unlikely (get_dumpable (current->mm) !=SUID_DUMP_USER )) { \/* \ * Zap scratch regs to avoid leaking bits between processes with different \ * uid/privileges. \
fs/exec.c +6 -0
@@ -1668,6 +1668,12 @@ int __get_dumpable(unsigned long mm_flagreturn (ret >SUID_DUMP_USER ) ?SUID_DUMP_ROOT : ret; } +/* +* This returns the actual value of the suid_dumpable flag. For things +* that are using this for checking for privilege transitions, it must +* test against SUID_DUMP_USER rather than treating it as a boolean +* value. +*/ int get_dumpable (struct mm_struct *mm) {return __get_dumpable (mm->flags);
include/linux/binfmts.h +0 -3
@@ -99,9 +99,6 @@ extern void setup_new_exec(struct linux_extern void would_dump (struct linux_binprm *,struct file *);extern int suid_dumpable; -#define SUID_DUMP_DISABLE 0/* No setuid dumping */ -#define SUID_DUMP_USER 1/* Dump as user of process */ -#define SUID_DUMP_ROOT 2/* Dump as root */ /* Stack area protections */ #define EXSTACK_DEFAULT 0/* Whatever the arch defaults to */
include/linux/sched.h +4 -0
@@ -322,6 +322,10 @@ static inline void arch_pick_mmap_layoutextern void set_dumpable (struct mm_struct *mm,int value);extern int get_dumpable (struct mm_struct *mm); +#define SUID_DUMP_DISABLE 0/* No setuid dumping */ +#define SUID_DUMP_USER 1/* Dump as user of process */ +#define SUID_DUMP_ROOT 2/* Dump as root */ +/* mm flags */ /* dumpable bits */ #define MMF_DUMPABLE 0/* core dump is permitted */
kernel/ptrace.c +2 -1
@@ -257,7 +257,8 @@ ok:if (task->mm) dumpable =get_dumpable (task->mm);rcu_read_lock (); -if (!dumpable && !ptrace_has_cap (__task_cred (task)->user_ns, mode)) { +if (dumpable !=SUID_DUMP_USER && + !ptrace_has_cap (__task_cred (task)->user_ns, mode)) {rcu_read_unlock ();return -EPERM ; }
Greg Kroah-Hartman
maintainerPATCH 37/116 ALSA: 6fire: Fix probe of multiple cards
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 9b389a8a022110b4bc055a19b888283544d9eba6 upstream.
The probe code of snd-usb-6fire driver overrides the devices[] pointer wrongly without checking whether it's already occupied or not. This would screw up the device disconnection later.
Spotted by coverity CID 141423.
--- sound/usb/6fire/chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/6fire/chip.c +1 -1
@@ -101,7 +101,7 @@ static int usb6fire_chip_probe(struct ususb_set_intfdata (intf, chips[i]);mutex_unlock (®ister_mutex);return 0 ; - }else if (regidx <0 ) + }else if (!devices[i] && regidx <0 ) regidx = i; }if (regidx <0 ) {
Greg Kroah-Hartman
maintainerPATCH 38/116 ALSA: compress: fix drain calls blocking other compress functions
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vinod Koul <[email protected]>
commit 917f4b5cba78980a527098a910d94139d3e82c8d upstream.
The drain and drain_notify callback were blocked by low level driver untill the draining was complete. Due to this being invoked with big fat mutex held, others ops like reading timestamp, calling pause, drop were blocked.
So to fix this we add a new snd_compr_drain_notify() API. This would be required to be invoked by low level driver when drain or partial drain has been completed by the DSP. Thus we make the drain and partial_drain callback as non blocking and driver returns immediately after notifying DSP.
The waiting is done while relasing the lock so that other ops can go ahead.
--- include/sound/compress_driver.h | 12 +++++++++++ sound/core/compress_offload.c | 41 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 3 deletions(-)
include/sound/compress_driver.h +12 -0
@@ -48,6 +48,8 @@ struct snd_compr_ops;* the ring buffer * @total_bytes_transferred: cumulative bytes transferred by offload DSP * @sleep: poll sleep +* @wait: drain wait queue +* @drain_wake: condition for drain wake */ struct snd_compr_runtime {snd_pcm_state_t state;
@@ -59,6 +61,8 @@ struct snd_compr_runtime {u64 total_bytes_available;u64 total_bytes_transferred;wait_queue_head_t sleep; +wait_queue_head_t wait; +unsigned int drain_wake;void *private_data; };
@@ -171,4 +175,12 @@ static inline void snd_compr_fragment_el wake_up(&stream->runtime->sleep); } +static inline void snd_compr_drain_notify (struct snd_compr_stream *stream) +{ +snd_BUG_ON (!stream); + + stream->runtime->drain_wake =1 ; +wake_up (&stream->runtime->wait); +} +#endif
sound/core/compress_offload.c +38 -3
77 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 39/116 ALSA: compress: fix drain calls blocking other compress functions (v6)
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vinod Koul <[email protected]>
commit f44f2a5417b2968a8724b352cc0b2545a6bcb1f4 upstream.
The drain and drain_notify callback were blocked by low level driver until the draining was complete. Due to this being invoked with big fat mutex held, others ops like reading timestamp, calling pause, drop were blocked.
So to fix this we add a new snd_compr_drain_notify() API. This would be required to be invoked by low level driver when drain or partial drain has been completed by the DSP. Thus we make the drain and partial_drain callback as non blocking and driver returns immediately after notifying DSP. The waiting is done while releasing the lock so that other ops can go ahead.
[ The commit 917f4b5cba78 was wrongly applied from the preliminary
patch. This commit corrects to the final version. Sorry for inconvenience! -- tiwai ]
--- include/sound/compress_driver.h | 11 ++++------- sound/core/compress_offload.c | 31 +++++++++++++++++++------------ 2 files changed, 23 insertions(+), 19 deletions(-)
include/sound/compress_driver.h +4 -7
@@ -48,8 +48,6 @@ struct snd_compr_ops;* the ring buffer * @total_bytes_transferred: cumulative bytes transferred by offload DSP * @sleep: poll sleep -* @wait: drain wait queue -* @drain_wake: condition for drain wake */ struct snd_compr_runtime {snd_pcm_state_t state;
@@ -61,8 +59,6 @@ struct snd_compr_runtime {u64 total_bytes_available;u64 total_bytes_transferred;wait_queue_head_t sleep; -wait_queue_head_t wait; -unsigned int drain_wake;void *private_data; };
@@ -177,10 +173,11 @@ static inline void snd_compr_fragment_elstatic inline void snd_compr_drain_notify (struct snd_compr_stream *stream) { -snd_BUG_ON (!stream); +if (snd_BUG_ON (!stream)) +return ; - stream->runtime->drain_wake =1 ; -wake_up (&stream->runtime->wait); + stream->runtime->state =SNDRV_PCM_STATE_SETUP ; +wake_up (&stream->runtime->sleep); }#endif
sound/core/compress_offload.c +19 -12
@@ -123,7 +123,6 @@ static int snd_compr_open(struct inode * } runtime->state =SNDRV_PCM_STATE_OPEN ;init_waitqueue_head (&runtime->sleep); -init_waitqueue_head (&runtime->wait); data->stream.runtime = runtime; f->private_data = (void *)data;mutex_lock (&compr->lock);
@@ -681,8 +680,6 @@ static int snd_compr_stop(struct snd_comreturn -EPERM ; retval = stream->ops->trigger (stream,SNDRV_PCM_TRIGGER_STOP );if (!retval) { - stream->runtime->state =SNDRV_PCM_STATE_SETUP ; -wake_up (&stream->runtime->sleep);snd_compr_drain_notify (stream); stream->runtime->total_bytes_available =0 ; stream->runtime->total_bytes_transferred =0 ;
@@ -692,6 +689,8 @@ static int snd_compr_stop(struct snd_comstatic int snd_compress_wait_for_drain (struct snd_compr_stream *stream) { +int ret; +/* * We are called with lock held. So drop the lock while we wait for * drain complete notfication from the driver
@@ -703,12 +702,24 @@ static int snd_compress_wait_for_drain(s stream->runtime->state =SNDRV_PCM_STATE_DRAINING ;mutex_unlock (&stream->device->lock); -wait_event (stream->runtime->wait, stream->runtime->drain_wake); +/* we wait for drain to complete here, drain can return when +* interruption occurred, wait returned error or success. +* For the first two cases we don't do anything different here and +* return after waking up +*/ + + ret =wait_event_interruptible (stream->runtime->sleep, + (stream->runtime->state !=SNDRV_PCM_STATE_DRAINING )); +if (ret == -ERESTARTSYS ) +pr_debug ("wait aborted by a signal" ); +else if (ret) +pr_debug ("wait for drain failed with %d\n" , ret); +wake_up (&stream->runtime->sleep);mutex_lock (&stream->device->lock); -return 0 ; +return ret; }static int snd_compr_drain (struct snd_compr_stream *stream)
@@ -719,17 +730,14 @@ static int snd_compr_drain(struct snd_co stream->runtime->state == SNDRV_PCM_STATE_SETUP) return -EPERM; - stream->runtime->drain_wake =0 ; retval = stream->ops->trigger (stream,SND_COMPR_TRIGGER_DRAIN );if (retval) { -pr_err ("SND_COMPR_TRIGGER_DRAIN failed %d\n" , retval); +pr_debug ("SND_COMPR_TRIGGER_DRAIN failed %d\n" , retval);wake_up (&stream->runtime->sleep);return retval; } - retval =snd_compress_wait_for_drain (stream); - stream->runtime->state =SNDRV_PCM_STATE_SETUP ; -return retval; +return snd_compress_wait_for_drain (stream); }static int snd_compr_next_track (struct snd_compr_stream *stream)
@@ -764,10 +772,9 @@ static int snd_compr_partial_drain(strucif (stream->next_track == false)return -EPERM ; - stream->runtime->drain_wake =0 ; retval = stream->ops->trigger (stream,SND_COMPR_TRIGGER_PARTIAL_DRAIN );if (retval) { -pr_err ("Partial drain returned failure\n" ); +pr_debug ("Partial drain returned failure\n" );wake_up (&stream->runtime->sleep);return retval; }
Greg Kroah-Hartman
maintainerPATCH 40/116 ALSA: pcsp: Fix the order of input device unregistration
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 6408eac2665955343cd0e4bcd7d6237ce39611ed upstream.
The current code may access to the already freed object. The input device must be accessed and unregistered before freeing the top level sound object.
--- sound/drivers/pcsp/pcsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/drivers/pcsp/pcsp.c +1 -1
@@ -187,8 +187,8 @@ static int pcsp_probe(struct platform_destatic int pcsp_remove (struct platform_device *dev) {struct snd_pcsp *chip =platform_get_drvdata (dev); -alsa_card_pcsp_exit (chip);pcspkr_input_remove (chip->input_dev); +alsa_card_pcsp_exit (chip);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 41/116 ALSA: hda - Apply GPIO setup for MacBooks with CS4208
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 8fe7b65ab4656e5db466a7d98b1fd48ff83b2c64 upstream.
Apply the existing GPIO0 fixup as default for MacBooks with CS4208 codec.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=64401
--- sound/pci/hda/patch_cirrus.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_cirrus.c +1 -0
@@ -611,6 +611,7 @@ static const struct snd_pci_quirk cs4208/* codec SSID */ SND_PCI_QUIRK (0x106b ,0x7100 ,"MacBookAir 6,1" ,CS4208_MBA6 ),SND_PCI_QUIRK (0x106b ,0x7200 ,"MacBookAir 6,2" ,CS4208_MBA6 ), + SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS4208_GPIO0), {} /* terminator */ };
Greg Kroah-Hartman
maintainerPATCH 42/116 ALSA: hda - Apply MacBook fixups for CS4208 correctly
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 885845d78551be7bf8570f6283df8b7a7797c4d1 upstream.
The commit [8fe7b65ab465: ALSA: hda - Apply GPIO setup for MacBooks with CS4208] added a fixup entry matching with the vendor id 0x106b. This broke the fixups for previous MBA6,1 and 6,2, since the PCI SSID vendor id matches before evaluating the codec SSIDs.
We had a similar issue on Mac with Sigmatel codecs, and solve this problem again similarly, by introducing a skeleton entry matching with the all MacBooks, then remap to the right one.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=64401
--- sound/pci/hda/patch_cirrus.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
sound/pci/hda/patch_cirrus.c +25 -2
@@ -597,6 +597,7 @@ static int patch_cs420x(struct hda_codec* Its layout is no longer compatible with CS4206/CS4207 */ enum { +CS4208_MAC_AUTO ,CS4208_MBA6 ,CS4208_GPIO0 , };
@@ -608,10 +609,14 @@ static const struct hda_model_fixup cs42 };static const struct snd_pci_quirk cs4208_fixup_tbl[] = { -/* codec SSID */ +SND_PCI_QUIRK_VENDOR (0x106b ,"Apple" ,CS4208_MAC_AUTO ), + {}/* terminator */ +}; + +/* codec SSID matching */ +static const struct snd_pci_quirk cs4208_mac_fixup_tbl[] = {SND_PCI_QUIRK (0x106b ,0x7100 ,"MacBookAir 6,1" ,CS4208_MBA6 ),SND_PCI_QUIRK (0x106b ,0x7200 ,"MacBookAir 6,2" ,CS4208_MBA6 ), -SND_PCI_QUIRK_VENDOR (0x106b ,"Apple" ,CS4208_GPIO0 ), {}/* terminator */ };
@@ -627,6 +632,20 @@ static void cs4208_fixup_gpio0(struct hd } } +static const struct hda_fixup cs4208_fixups[]; + +/* remap the fixup from codec SSID and apply it */ +static void cs4208_fixup_mac (struct hda_codec *codec, +const struct hda_fixup *fix,int action) +{ +if (action !=HDA_FIXUP_ACT_PRE_PROBE ) +return ; +snd_hda_pick_fixup (codec,NULL , cs4208_mac_fixup_tbl, cs4208_fixups); +if (codec->fixup_id <0 || codec->fixup_id ==CS4208_MAC_AUTO ) + codec->fixup_id =CS4208_GPIO0 ;/* default fixup */ +snd_hda_apply_fixup (codec, action); +} +static const struct hda_fixup cs4208_fixups[] = { [CS4208_MBA6 ] = { .type =HDA_FIXUP_PINS ,
@@ -638,6 +657,10 @@ static const struct hda_fixup cs4208_fix .type = HDA_FIXUP_FUNC, .v.func = cs4208_fixup_gpio0, }, + [CS4208_MAC_AUTO] = { + .type = HDA_FIXUP_FUNC, + .v.func = cs4208_fixup_mac, + }, };/* correct the 0dB offset of input pins */
Greg Kroah-Hartman
maintainerPATCH 43/116 ALSA: msnd: Avoid duplicated driver name
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 092f9cd16aac7d054af1755c945f37c1b33399e6 upstream.
msnd_pinnacle.c is used for both snd-msnd-pinnacle and snd-msnd-classic drivers, and both should have different driver names. Using the same driver name results in the sysfs warning for duplicated entries like
kobject: 'msnd-pinnacle.7' (cec33408): kobject_release, parent (null) (delayed)
kobject: 'msnd-pinnacle' (cecd4980): kobject_release, parent cf3ad9b0 (delayed)
------------[ cut here ]------------ WARNING: CPU: 0 PID: 1 at fs/sysfs/dir.c:486 sysfs_warn_dup+0x7d/0xa0() sysfs: cannot create duplicate filename '/bus/isa/drivers/msnd-pinnacle' ......
--- sound/isa/msnd/msnd_pinnacle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/isa/msnd/msnd_pinnacle.c +2 -2
@@ -73,9 +73,11 @@#ifdef MSND_CLASSIC # include "msnd_classic.h" # define LOGNAME "msnd_classic" +# define DEV_NAME "msnd-classic"#else # include "msnd_pinnacle.h" # define LOGNAME "snd_msnd_pinnacle" +# define DEV_NAME "msnd-pinnacle"#endif static void set_default_audio_parameters (struct snd_msnd *chip)
@@ -1067,8 +1069,6 @@ static int snd_msnd_isa_remove(struct dereturn 0 ; } -#define DEV_NAME "msnd-pinnacle" -static struct isa_driver snd_msnd_driver = { .match = snd_msnd_isa_match, .probe = snd_msnd_isa_probe,
Greg Kroah-Hartman
maintainerPATCH 44/116 ALSA: hda - Add support of ALC255 codecs
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kailang Yang <[email protected]>
commit 1d04c9de5c76df113e4af7120feb53c628b5efcc upstream.
It's just another variant of ALC269 & co.
--- sound/pci/hda/patch_realtek.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/pci/hda/patch_realtek.c +6 -0
@@ -2540,6 +2540,7 @@ enum {ALC269_TYPE_ALC283 ,ALC269_TYPE_ALC284 ,ALC269_TYPE_ALC286 , + ALC269_TYPE_ALC255, };/*
@@ -2565,6 +2566,7 @@ static int alc269_parse_auto_config(strucase ALC269_TYPE_ALC282 :case ALC269_TYPE_ALC283 :case ALC269_TYPE_ALC286 : +case ALC269_TYPE_ALC255 : ssids = alc269_ssids;break ;default :
@@ -4128,6 +4130,9 @@ static int patch_alc269(struct hda_codeccase 0x10ec0286 : spec->codec_variant =ALC269_TYPE_ALC286 ;break ; +case 0x10ec0255 : + spec->codec_variant =ALC269_TYPE_ALC255 ; +break ; }if (snd_hda_codec_read (codec,0x51 ,0 ,AC_VERB_PARAMETERS ,0 ) ==0x10ec5505 ) {
@@ -4842,6 +4847,7 @@ static int patch_alc680(struct hda_codecstatic const struct hda_codec_preset snd_hda_preset_realtek[] = { { .id =0x10ec0221 , .name ="ALC221" , .patch = patch_alc269 }, { .id =0x10ec0233 , .name ="ALC233" , .patch = patch_alc269 }, + { .id =0x10ec0255 , .name ="ALC255" , .patch = patch_alc269 }, { .id =0x10ec0260 , .name ="ALC260" , .patch = patch_alc260 }, { .id =0x10ec0262 , .name ="ALC262" , .patch = patch_alc262 }, { .id =0x10ec0267 , .name ="ALC267" , .patch = patch_alc268 },
Greg Kroah-Hartman
maintainerPATCH 45/116 ALSA: hda - Introduce the bitmask for excluding output volume
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit a1114a8c681b0724d6ad905f53ff06aa756f5fb8 upstream.
Add a bitmask to hda_gen_spec indicating NIDs to exclude from the possible volume controls. That is, when the bit is set, the NID corresponding to the bit won't be picked as an output volume control any longer.
Basically this is just a band-aid for working around the issue found with CS4208 codec, where only the headphone pin has a volume AMP with different dB steps.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=60811
--- sound/pci/hda/hda_generic.c | 8 ++++++-- sound/pci/hda/hda_generic.h | 3 +++ sound/pci/hda/patch_cirrus.c | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-)
sound/pci/hda/hda_generic.c +6 -2
@@ -549,11 +549,15 @@ static hda_nid_t look_for_out_mute_nid(sstatic hda_nid_t look_for_out_vol_nid (struct hda_codec *codec,struct nid_path *path) { +struct hda_gen_spec *spec = codec->spec;int i;for (i = path->depth -1 ; i >=0 ; i--) { -if (nid_has_volume (codec, path->path[i],HDA_OUTPUT )) -return path->path[i]; +hda_nid_t nid = path->path[i]; +if ((spec->out_vol_mask >> nid) &1 ) +continue ; +if (nid_has_volume (codec, nid,HDA_OUTPUT )) +return nid; }return 0 ; }
sound/pci/hda/hda_generic.h +3 -0
@@ -242,6 +242,9 @@ struct hda_gen_spec {/* additional mute flags (only effective with auto_mute_via_amp=1) */ u64 mute_bits; +/* bitmask for skipping volume controls */ +u64 out_vol_mask; +/* badness tables for output path evaluations */ const struct badness_table *main_out_badness;const struct badness_table *extra_out_badness;
sound/pci/hda/patch_cirrus.c +2 -0
@@ -684,6 +684,8 @@ static int patch_cs4208(struct hda_codecreturn -ENOMEM ; spec->gen.automute_hook = cs_automute; +/* exclude NID 0x10 (HP) from output volumes due to different steps */ + spec->gen.out_vol_mask =1ULL <<0x10 ;snd_hda_pick_fixup (codec, cs4208_models, cs4208_fixup_tbl, cs4208_fixups);
Greg Kroah-Hartman
maintainerPATCH 46/116 ALSA: hda - Enable SPDIF for Acer TravelMate 6293
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 24eff328f65c8ef352c90b6adb7c2f39eb94205d upstream.
BIOS on Acer TravelMate 6293 doesn't set up the SPDIF output pin correctly as default, so enable it via a fixup entry.
--- sound/pci/hda/patch_realtek.c | 9 +++++++++ 1 file changed, 9 insertions(+)
sound/pci/hda/patch_realtek.c +9 -0
@@ -2388,6 +2388,7 @@ static const struct hda_verb alc268_beepenum {ALC268_FIXUP_INV_DMIC ,ALC268_FIXUP_HP_EAPD , +ALC268_FIXUP_SPDIF , };static const struct hda_fixup alc268_fixups[] = {
@@ -2402,6 +2403,13 @@ static const struct hda_fixup alc268_fix {} } }, + [ALC268_FIXUP_SPDIF ] = { + .type =HDA_FIXUP_PINS , + .v.pins = (const struct hda_pintbl []) { + {0x1e ,0x014b1180 },/* enable SPDIF out */ + {} + } + }, };static const struct hda_model_fixup alc268_fixup_models[] = {
@@ -2411,6 +2419,7 @@ static const struct hda_model_fixup alc2 };static const struct snd_pci_quirk alc268_fixup_tbl[] = { +SND_PCI_QUIRK (0x1025 ,0x0139 ,"Acer TravelMate 6293" ,ALC268_FIXUP_SPDIF ),SND_PCI_QUIRK (0x1025 ,0x015b ,"Acer AOA 150 (ZG5)" ,ALC268_FIXUP_INV_DMIC ),/* below is codec SSID since multiple Toshiba laptops have the * same PCI SSID 1179:ff00
Greg Kroah-Hartman
maintainerPATCH 47/116 ALSA: hda - Force buffer alignment for Haswell HDMI controllers
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 33499a15c2f7addc81695778753c2338b960eff7 upstream.
Haswell HDMI audio controllers seem to get stuck when unaligned buffer size is used. Let's enable the buffer alignment for the corresponding entries.
Since AZX_DCAPS_INTEL_PCH contains AZX_DCAPS_BUFSIZE that disables the buffer alignment forcibly, define AZX_DCAPS_INTEL_HASWELL and put the necessary AZX_DCAPS bits there.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=60769
--- sound/pci/hda/hda_intel.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
sound/pci/hda/hda_intel.c +8 -6
@@ -612,6 +612,11 @@ enum {#define AZX_DCAPS_INTEL_PCH \ (AZX_DCAPS_INTEL_PCH_NOPM | AZX_DCAPS_PM_RUNTIME) +#define AZX_DCAPS_INTEL_HASWELL \ + (AZX_DCAPS_SCH_SNOOP | AZX_DCAPS_ALIGN_BUFSIZE | \ + AZX_DCAPS_COUNT_LPIB_DELAY | AZX_DCAPS_PM_RUNTIME | \ + AZX_DCAPS_I915_POWERWELL) +/* quirks for ATI SB / AMD Hudson */ #define AZX_DCAPS_PRESET_ATI_SB \ (AZX_DCAPS_ATI_SNOOP | AZX_DCAPS_NO_TCSEL | \
@@ -3987,14 +3992,11 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },/* Haswell */ { PCI_DEVICE(0x8086, 0x0a0c), - .driver_data =AZX_DRIVER_SCH |AZX_DCAPS_INTEL_PCH | - AZX_DCAPS_I915_POWERWELL }, + .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_HASWELL }, { PCI_DEVICE(0x8086, 0x0c0c), - .driver_data =AZX_DRIVER_SCH |AZX_DCAPS_INTEL_PCH | - AZX_DCAPS_I915_POWERWELL }, + .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_HASWELL }, { PCI_DEVICE(0x8086, 0x0d0c), - .driver_data =AZX_DRIVER_SCH |AZX_DCAPS_INTEL_PCH | - AZX_DCAPS_I915_POWERWELL }, + .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_HASWELL }, /* 5 Series/3400 */ { PCI_DEVICE(0x8086, 0x3b56), .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH_NOPM },
Greg Kroah-Hartman
maintainerPATCH 48/116 ALSA: hda - Make sure mute LEDs stay on during runtime suspend (Realtek)
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Henningsson <[email protected]>
commit d5b6b65e75ce607c2734227524e11574317a1c1a upstream.
Some HP machines with Realtek codecs have mute LEDs connected to VREF pins. However when these go into runtime suspend, the pin powers down and its pin control is disabled, thus disabling the LED too.
This patch fixes that issue by making sure that the pin stays in D0 with correct pin control.
--- sound/pci/hda/patch_realtek.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
sound/pci/hda/patch_realtek.c +20 -0
@@ -2955,6 +2955,23 @@ static void alc269_fixup_mic_mute_hook(vsnd_hda_set_pin_ctl_cache (codec, spec->mute_led_nid, pinval); } +/* Make sure the led works even in runtime suspend */ +static unsigned int led_power_filter (struct hda_codec *codec, +hda_nid_t nid, +unsigned int power_state) +{ +struct alc_spec *spec = codec->spec; + +if (power_state !=AC_PWRST_D3 || nid != spec->mute_led_nid) +return power_state; + +/* Set pin ctl again, it might have just been set to 0 */ +snd_hda_set_pin_ctl (codec, nid, +snd_hda_codec_get_pin_target (codec, nid)); + +return AC_PWRST_D0 ; +} +static void alc269_fixup_hp_mute_led (struct hda_codec *codec,const struct hda_fixup *fix,int action) {
@@ -2974,6 +2991,7 @@ static void alc269_fixup_hp_mute_led(str spec->mute_led_nid = pin -0x0a +0x18 ; spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; spec->gen.vmaster_mute_enum =1 ; + codec->power_filter = led_power_filter;snd_printd ("Detected mute LED for %x:%d\n" , spec->mute_led_nid, spec->mute_led_polarity);break ;
@@ -2989,6 +3007,7 @@ static void alc269_fixup_hp_mute_led_mic spec->mute_led_nid =0x18 ; spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; spec->gen.vmaster_mute_enum =1 ; + codec->power_filter = led_power_filter; } }
@@ -3001,6 +3020,7 @@ static void alc269_fixup_hp_mute_led_mic spec->mute_led_nid =0x19 ; spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; spec->gen.vmaster_mute_enum =1 ; + codec->power_filter = led_power_filter; } }
Greg Kroah-Hartman
maintainerPATCH 49/116 ALSA: hda - Add support for CX20952
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 8f42d7698751a45cd9f7134a5da49bc5b6206179 upstream.
It's a superset of the existing CX2075x codecs, so we can reuse the existing parser code.
--- sound/pci/hda/patch_conexant.c | 3 +++ 1 file changed, 3 insertions(+)
sound/pci/hda/patch_conexant.c +3 -0
@@ -3568,6 +3568,8 @@ static const struct hda_codec_preset snd .patch = patch_conexant_auto }, { .id = 0x14f15115, .name = "CX20757", .patch = patch_conexant_auto }, + { .id = 0x14f151d7, .name = "CX20952", + .patch = patch_conexant_auto }, {}/* terminator */ };
@@ -3594,6 +3596,7 @@ MODULE_ALIAS("snd-hda-codec-id:14f15111"MODULE_ALIAS ("snd-hda-codec-id:14f15113" );MODULE_ALIAS ("snd-hda-codec-id:14f15114" );MODULE_ALIAS ("snd-hda-codec-id:14f15115" ); +MODULE_ALIAS ("snd-hda-codec-id:14f151d7" );MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("Conexant HD-audio codec" );
Greg Kroah-Hartman
maintainerPATCH 50/116 ALSA: hda - Add pincfg fixup for ASUS W5A
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 487a588d09db0d6508261867df208d8bdc718251 upstream.
BIOS on ASUS W5A laptop with ALC880 codec doesn't provide any pin configurations, so we have to set up all pins manually.
--- sound/pci/hda/patch_realtek.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
sound/pci/hda/patch_realtek.c +22 -0
@@ -1043,6 +1043,7 @@ enum {ALC880_FIXUP_UNIWILL ,ALC880_FIXUP_UNIWILL_DIG ,ALC880_FIXUP_Z71V , +ALC880_FIXUP_ASUS_W5A ,ALC880_FIXUP_3ST_BASE ,ALC880_FIXUP_3ST , ALC880_FIXUP_3ST_DIG,
@@ -1213,6 +1214,26 @@ static const struct hda_fixup alc880_fix { } } }, + [ALC880_FIXUP_ASUS_W5A] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl[]) { + /* set up the whole pins as BIOS is utterly broken */ + { 0x14, 0x0121411f }, /* HP */ + { 0x15, 0x411111f0 }, /* N/A */ + { 0x16, 0x411111f0 }, /* N/A */ + { 0x17, 0x411111f0 }, /* N/A */ + { 0x18, 0x90a60160 }, /* mic */ + { 0x19, 0x411111f0 }, /* N/A */ + { 0x1a, 0x411111f0 }, /* N/A */ + { 0x1b, 0x411111f0 }, /* N/A */ + { 0x1c, 0x411111f0 }, /* N/A */ + { 0x1d, 0x411111f0 }, /* N/A */ + { 0x1e, 0xb743111e }, /* SPDIF out */ + { } + }, + .chained = true, + .chain_id = ALC880_FIXUP_GPIO1, + }, [ALC880_FIXUP_3ST_BASE] = { .type = HDA_FIXUP_PINS, .v.pins = (const struct hda_pintbl[]) {
@@ -1334,6 +1355,7 @@ static const struct hda_fixup alc880_fixstatic const struct snd_pci_quirk alc880_fixup_tbl[] = {SND_PCI_QUIRK (0x1019 ,0x0f69 ,"Coeus G610P" ,ALC880_FIXUP_W810 ), +SND_PCI_QUIRK (0x1043 ,0x10c3 ,"ASUS W5A" ,ALC880_FIXUP_ASUS_W5A ),SND_PCI_QUIRK (0x1043 ,0x1964 ,"ASUS Z71V" ,ALC880_FIXUP_Z71V ),SND_PCI_QUIRK_VENDOR (0x1043 ,"ASUS" ,ALC880_FIXUP_GPIO1 ),SND_PCI_QUIRK (0x1558 ,0x5401 ,"Clevo GPIO2" ,ALC880_FIXUP_GPIO2 ),
Greg Kroah-Hartman
maintainerPATCH 51/116 ALSA: hda - Fix Line Out automute on Realtek multifunction jacks
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Henningsson <[email protected]>
commit 5959a6bc1124211a359525d209005abc07b0197b upstream.
In case there is both a multifunction headset jack and a Line Out jack, automuting was not working properly from the Line Out jack. This patch fixes that issue.
--- sound/pci/hda/patch_realtek.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/pci/hda/patch_realtek.c +3 -1
@@ -3283,8 +3283,10 @@ static void alc_update_headset_mode(struelse new_headset_mode =ALC_HEADSET_MODE_HEADPHONE ; -if (new_headset_mode == spec->current_headset_mode) +if (new_headset_mode == spec->current_headset_mode) { +snd_hda_gen_update_outputs (codec);return ; + }switch (new_headset_mode) {case ALC_HEADSET_MODE_UNPLUGGED :
Greg Kroah-Hartman
maintainerPATCH 52/116 ALSA: hda - Check keep_eapd_on before inv_eapd
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 468ac413045af1e0e4d1272291bed6878f248a69 upstream.
We don't change the EAPD bit in set_pin_eapd() if keep_eapd_on flag is set by the codec driver and enable is false. But, we also apply the flipping of enable value according to inv_eapd flag in the same function, and this confused the former check, handled as if it's turned ON. The inverted EAPD check must be applied after keep_eapd_on check, instead.
--- sound/pci/hda/hda_generic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/hda/hda_generic.c +2 -2
@@ -796,10 +796,10 @@ static void set_pin_eapd(struct hda_codeif (spec->own_eapd_ctl || !(snd_hda_query_pin_caps (codec, pin) &AC_PINCAP_EAPD ))return ; -if (codec->inv_eapd) - enable = !enable;if (spec->keep_eapd_on && !enable)return ; +if (codec->inv_eapd) + enable = !enable;snd_hda_codec_update_cache (codec, pin,0 ,AC_VERB_SET_EAPD_BTLENABLE , enable ?0x02 :0x00 );
Greg Kroah-Hartman
maintainerPATCH 53/116 ALSA: hda - Dont turn off EAPD for headphone on Lenovo N100
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 7a3e6107f94344e65c35bfe62de6c096a7b48965 upstream.
The only EAPD on AD1986A is on NID 0x1b where usually the speaker. But this doesn't control only the speaker amp but may influence on all outputs, e.g. Lenovo N100 laptop seems to have this issue.
--- sound/pci/hda/patch_analog.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/pci/hda/patch_analog.c +5 -1
@@ -219,8 +219,12 @@ static int alloc_ad_spec(struct hda_codestatic void ad_fixup_inv_jack_detect (struct hda_codec *codec,const struct hda_fixup *fix,int action) { -if (action ==HDA_FIXUP_ACT_PRE_PROBE ) +struct ad198x_spec *spec = codec->spec; + +if (action ==HDA_FIXUP_ACT_PRE_PROBE ) { codec->inv_jack_detect =1 ; + spec->gen.keep_eapd_on =1 ; + } }enum {
Greg Kroah-Hartman
maintainerPATCH 54/116 ALSA: hda - Dont clear the power state at snd_hda_codec_reset()
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit d183b4fc463489b6bbe05c99afa0257a6fe578eb upstream.
snd_hda_codec_reset() is called either in resetting the whole setup at error paths or hwdep clear/reconfig sysfs triggers. But all of these don't assume that the power has to be off, rather they want to keep the power state unchanged (e.g. reconfig_codec() calls the power up/down by itself). Thus, unconditionally clearing the power state in snd_hda_codec_reset() leads to the inconsistency, confuses the further
operation. This patch gets rid of the lines doing that bad thing.
--- sound/pci/hda/hda_codec.c | 3 --- 1 file changed, 3 deletions(-)
sound/pci/hda/hda_codec.c +0 -3
@@ -2579,9 +2579,6 @@ int snd_hda_codec_reset(struct hda_codeccancel_delayed_work_sync (&codec->jackpoll_work);#ifdef CONFIG_PM cancel_delayed_work_sync (&codec->power_work); - codec->power_on =0 ; - codec->power_transition =0 ; - codec->power_jiffies = jiffies;flush_workqueue (bus->workq);#endif snd_hda_ctls_clear (codec);
Greg Kroah-Hartman
maintainerPATCH 55/116 ALSA: hda - Fix unbalanced runtime PM notification at resume
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 0fc28fc030a85aa3d6d14e9e9fca0c8237c9ffb5 upstream.
When a codec is resumed, it keeps the power on while the resuming phase via hda_keep_power_on(), then turns down via snd_hda_power_down(). At that point, snd_hda_power_down() notifies the power down to the controller, and this may confuse the refcount if the codec was already powered up before the resume.
In the end result, the controller goes to runtime suspend even before the codec is kicked off to the power save, and the communication stalls happens.
The fix is to add the power-up notification together with hda_keep_power_on(), and clears the flag appropriately.
--- sound/pci/hda/hda_codec.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/pci/hda/hda_codec.c +4 -0
@@ -3988,6 +3988,10 @@ static void hda_call_codec_resume(struct* in the resume / power-save sequence */ hda_keep_power_on (codec); +if (codec->pm_down_notified) { + codec->pm_down_notified =0 ; +hda_call_pm_notify (codec->bus, true); + }hda_set_power_state (codec,AC_PWRST_D0 );restore_shutup_pins (codec);hda_exec_init_verbs (codec);
Greg Kroah-Hartman
maintainerPATCH 56/116 ALSA: hda - Fix the headphone jack detection on Sony VAIO TX
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 0f5a5b8515472a0219768423226b58228001e3d5 upstream.
BIOS sets MISC_NO_PRESENCE bit wrongly to the pin config on NID 0x0f.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -1649,6 +1649,7 @@ static const struct snd_pci_quirk alc260SND_PCI_QUIRK (0x1025 ,0x008f ,"Acer" ,ALC260_FIXUP_GPIO1 ),SND_PCI_QUIRK (0x103c ,0x280a ,"HP dc5750" ,ALC260_FIXUP_HP_DC5750 ),SND_PCI_QUIRK (0x103c ,0x30ba ,"HP Presario B1900" ,ALC260_FIXUP_HP_B1900 ), +SND_PCI_QUIRK (0x104d ,0x81e2 ,"Sony VAIO TX" ,ALC260_FIXUP_HP_PIN_0F ),SND_PCI_QUIRK (0x10cf ,0x1326 ,"FSC LifeBook S7020" ,ALC260_FIXUP_FSC_S7020 ),SND_PCI_QUIRK (0x1509 ,0x4540 ,"Favorit 100XS" ,ALC260_FIXUP_GPIO1 ), SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
Greg Kroah-Hartman
maintainerPATCH 57/116 ALSA: hda - Add headset quirk for Dell Inspiron 3135
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Henningsson <[email protected]>
commit b8362e70cbbb397db50939bc4c7c78dc3246c3eb upstream.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -3951,6 +3951,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x1028 ,0x0608 ,"Dell" ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1028 ,0x0609 ,"Dell" ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1028 ,0x0613 ,"Dell" ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE ), +SND_PCI_QUIRK (0x1028 ,0x0614 ,"Dell Inspiron 3135" ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1028 ,0x0616 ,"Dell Vostro 5470" ,ALC290_FIXUP_MONO_SPEAKERS ),SND_PCI_QUIRK (0x1028 ,0x15cc ,"Dell X5 Precision" ,ALC269_FIXUP_DELL2_MIC_NO_PRESENCE ), SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
Greg Kroah-Hartman
maintainerPATCH 58/116 ALSA: hda - Provide missing pin configs for VAIO with ALC260
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit d08c5ef2a039393eaf2ab2152db5f07790fa0f40 upstream.
Some models (or maybe depending on BIOS version) of Sony VAIO with ALC260 give no proper pin configurations as default, resulting in the non-working speaker, etc. Just provide the whole pin configurations via a fixup.
--- sound/pci/hda/patch_realtek.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
sound/pci/hda/patch_realtek.c +20 -0
@@ -1501,6 +1501,7 @@ enum {ALC260_FIXUP_KN1 ,ALC260_FIXUP_FSC_S7020 ,ALC260_FIXUP_FSC_S7020_JWSE , + ALC260_FIXUP_VAIO_PINS, };static void alc260_gpio1_automute (struct hda_codec *codec)
@@ -1641,6 +1642,24 @@ static const struct hda_fixup alc260_fix .chained = true, .chain_id = ALC260_FIXUP_FSC_S7020, }, + [ALC260_FIXUP_VAIO_PINS] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl []) { +/* Pin configs are missing completely on some VAIOs */ + {0x0f ,0x01211020 }, + {0x10 ,0x0001003f }, + {0x11 ,0x411111f0 }, + {0x12 ,0x01a15930 }, + {0x13 ,0x411111f0 }, + {0x14 ,0x411111f0 }, + {0x15 ,0x411111f0 }, + {0x16 ,0x411111f0 }, + {0x17 ,0x411111f0 }, + {0x18 ,0x411111f0 }, + {0x19 ,0x411111f0 }, + { } + } + }, };static const struct snd_pci_quirk alc260_fixup_tbl[] = {
@@ -1649,6 +1668,7 @@ static const struct snd_pci_quirk alc260SND_PCI_QUIRK (0x1025 ,0x008f ,"Acer" ,ALC260_FIXUP_GPIO1 ),SND_PCI_QUIRK (0x103c ,0x280a ,"HP dc5750" ,ALC260_FIXUP_HP_DC5750 ),SND_PCI_QUIRK (0x103c ,0x30ba ,"HP Presario B1900" ,ALC260_FIXUP_HP_B1900 ), +SND_PCI_QUIRK (0x104d ,0x81bb ,"Sony VAIO" ,ALC260_FIXUP_VAIO_PINS ),SND_PCI_QUIRK (0x104d ,0x81e2 ,"Sony VAIO TX" ,ALC260_FIXUP_HP_PIN_0F ),SND_PCI_QUIRK (0x10cf ,0x1326 ,"FSC LifeBook S7020" ,ALC260_FIXUP_FSC_S7020 ), SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
Greg Kroah-Hartman
maintainerPATCH 59/116 NFSv4.2: Fix a mismatch between Linux labeled NFS and the NFSv4.2 spec
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit f3f5a0f8cc40b942f4c0ae117df82eeb65f07d4d upstream.
In the spec, the security label attribute id is '80', which means that it should be bit number 80-64 == 16 in the 3rd word of the bitmap.
--- include/linux/nfs4.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/nfs4.h +1 -1
@@ -395,7 +395,7 @@ enum lock_type4 {#define FATTR4_WORD1_FS_LAYOUT_TYPES (1UL << 30)#define FATTR4_WORD2_LAYOUT_BLKSIZE (1UL << 1)#define FATTR4_WORD2_MDSTHRESHOLD (1UL << 4) -#define FATTR4_WORD2_SECURITY_LABEL (1UL << 17) +#define FATTR4_WORD2_SECURITY_LABEL (1UL << 16)/* MDS threshold bitmap bits */ #define THRESHOLD_RD (1UL << 0)
Greg Kroah-Hartman
maintainerPATCH 60/116 NFSv4: Fix a use-after-free situation in _nfs4_proc_getlk()
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit a6f951ddbdfb7bd87d31a44f61abe202ed6ce57f upstream.
In nfs4_proc_getlk(), when some error causes a retry of the call to _nfs4_proc_getlk(), we can end up with Oopses of the form
BUG: unable to handle kernel NULL pointer dereference at 0000000000000134 IP: [<ffffffff8165270e>] _raw_spin_lock+0xe/0x30 <snip> Call Trace: [<ffffffff812f287d>] _atomic_dec_and_lock+0x4d/0x70 [<ffffffffa053c4f2>] nfs4_put_lock_state+0x32/0xb0 [nfsv4] [<ffffffffa053c585>] nfs4_fl_release_lock+0x15/0x20 [nfsv4] [<ffffffffa0522c06>] _nfs4_proc_getlk.isra.40+0x146/0x170 [nfsv4] [<ffffffffa052ad99>] nfs4_proc_lock+0x399/0x5a0 [nfsv4]
The problem is that we don't clear the request->fl_ops after the first try and so when we retry, nfs4_set_lock_state() exits early without setting the lock stateid.
Regression introduced by commit 70cc6487a4e08b8698c0e2ec935fb48d10490162 (locks: make ->lock release private data before returning in GETLK case)
--- fs/nfs/nfs4proc.c | 1 + 1 file changed, 1 insertion(+)
fs/nfs/nfs4proc.c +1 -0
@@ -5106,6 +5106,7 @@ static int _nfs4_proc_getlk(struct nfs4_ status =0 ; } request->fl_ops->fl_release_private (request); + request->fl_ops =NULL ; out:return status; }
Greg Kroah-Hartman
maintainerPATCH 61/116 NFSv4: fix NULL dereference in open recover
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weston Andros Adamson <[email protected]>
commit f494a6071d31e3294a3b51ad7a3684f983953f9f upstream.
_nfs4_opendata_reclaim_to_nfs4_state doesn't expect to see a cached open CLAIM_PREVIOUS, but this can happen. An example is when there are RDWR openers and RDONLY openers on a delegation stateid. The recovery path will first try an open CLAIM_PREVIOUS for the RDWR openers, this marks the delegation as not needing RECLAIM anymore, so the open CLAIM_PREVIOUS for the RDONLY openers will not actually send an rpc.
The NULL dereference is due to _nfs4_opendata_reclaim_to_nfs4_state returning PTR_ERR(rpc_status) when !rpc_done. When the open is cached, rpc_done == 0 and rpc_status == 0, thus _nfs4_opendata_reclaim_to_nfs4_state returns NULL - this is unexpected by callers of nfs4_opendata_to_nfs4_state().
This can be reproduced easily by opening the same file two times on an NFSv4.0 mount with delegations enabled, once as RDWR and once as RDONLY then sleeping for a long time. While the files are held open, kick off state recovery and this NULL dereference will be hit every time.
An example OOPS:
[ 65.003602] BUG: unable to handle kernel NULL pointer dereference at 00000000 00000030 [ 65.005312] IP: [<ffffffffa037d6ee>] __nfs4_close+0x1e/0x160 [nfsv4] [ 65.006820] PGD 7b0ea067 PUD 791ff067 PMD 0 [ 65.008075] Oops: 0000 [#1] SMP [ 65.008802] Modules linked in: rpcsec_gss_krb5 nfsv4 dns_resolver nfs fscache
snd_ens1371 gameport nfsd snd_rawmidi snd_ac97_codec ac97_bus btusb snd_seq snd _seq_device snd_pcm ppdev bluetooth auth_rpcgss coretemp snd_page_alloc crc32_pc lmul crc32c_intel ghash_clmulni_intel microcode rfkill nfs_acl vmw_balloon serio _raw snd_timer lockd parport_pc e1000 snd soundcore parport i2c_piix4 shpchp vmw _vmci sunrpc ata_generic mperf pata_acpi mptspi vmwgfx ttm scsi_transport_spi dr m mptscsih mptbase i2c_core
[ 65.018684] CPU: 0 PID: 473 Comm: 192.168.10.85-m Not tainted 3.11.2-201.fc19 .x86_64 #1 [ 65.020113] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 07/31/2013 [ 65.022012] task: ffff88003707e320 ti: ffff88007b906000 task.ti: ffff88007b906000 [ 65.023414] RIP: 0010:[<ffffffffa037d6ee>] [<ffffffffa037d6ee>] __nfs4_close+0x1e/0x160 [nfsv4] [ 65.025079] RSP: 0018:ffff88007b907d10 EFLAGS: 00010246 [ 65.026042] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 [ 65.027321] RDX: 0000000000000050 RSI: 0000000000000001 RDI: 0000000000000000 [ 65.028691] RBP: ffff88007b907d38 R08: 0000000000016f60 R09: 0000000000000000 [ 65.029990] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000001 [ 65.031295] R13: 0000000000000050 R14: 0000000000000000 R15: 0000000000000001 [ 65.032527] FS: 0000000000000000(0000) GS:ffff88007f600000(0000) knlGS:0000000000000000 [ 65.033981] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 65.035177] CR2: 0000000000000030 CR3: 000000007b27f000 CR4: 00000000000407f0 [ 65.036568] Stack: [ 65.037011] 0000000000000000 0000000000000001 ffff88007b907d90 ffff88007a880220 [ 65.038472] ffff88007b768de8 ffff88007b907d48 ffffffffa037e4a5 ffff88007b907d80 [ 65.039935] ffffffffa036a6c8 ffff880037020e40 ffff88007a880000 ffff880037020e40 [ 65.041468] Call Trace: [ 65.042050] [<ffffffffa037e4a5>] nfs4_close_state+0x15/0x20 [nfsv4] [ 65.043209] [<ffffffffa036a6c8>] nfs4_open_recover_helper+0x148/0x1f0 [nfsv4] [ 65.044529] [<ffffffffa036a886>] nfs4_open_recover+0x116/0x150 [nfsv4] [ 65.045730] [<ffffffffa036d98d>] nfs4_open_reclaim+0xad/0x150 [nfsv4] [ 65.046905] [<ffffffffa037d979>] nfs4_do_reclaim+0x149/0x5f0 [nfsv4] [ 65.048071] [<ffffffffa037e1dc>] nfs4_run_state_manager+0x3bc/0x670 [nfsv4] [ 65.049436] [<ffffffffa037de20>] ? nfs4_do_reclaim+0x5f0/0x5f0 [nfsv4] [ 65.050686] [<ffffffffa037de20>] ? nfs4_do_reclaim+0x5f0/0x5f0 [nfsv4] [ 65.051943] [<ffffffff81088640>] kthread+0xc0/0xd0 [ 65.052831] [<ffffffff81088580>] ? insert_kthread_work+0x40/0x40 [ 65.054697] [<ffffffff8165686c>] ret_from_fork+0x7c/0xb0 [ 65.056396] [<ffffffff81088580>] ? insert_kthread_work+0x40/0x40 [ 65.058208] Code: 5c 41 5d 5d c3 0f 1f 84 00 00 00 00 00 66 66 66 66 90 55 48 89 e5 41 57 41 89 f7 41 56 41 89 ce 41 55 41 89 d5 41 54 53 48 89 fb <4c> 8b 67 30 f0 41 ff 44 24 44 49 8d 7c 24 40 e8 0e 0a 2d e1 44 [ 65.065225] RIP [<ffffffffa037d6ee>] __nfs4_close+0x1e/0x160 [nfsv4] [ 65.067175] RSP <ffff88007b907d10> [ 65.068570] CR2: 0000000000000030 [ 65.070098] ---[ end trace 0d1fe4f5c7dd6f8b ]---
--- fs/nfs/nfs4proc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfs/nfs4proc.c +2 -1
@@ -1317,7 +1317,8 @@ _nfs4_opendata_reclaim_to_nfs4_state(strstruct nfs4_state *state = data->state;int ret; -if (!data->rpc_done) { +/* allow cached opens (!rpc_done && !rpc_status) */ +if (!data->rpc_done && data->rpc_status) { ret = data->rpc_status; goto err; }
Greg Kroah-Hartman
maintainerPATCH 62/116 NFSv4: dont fail on missing fattr in open recover
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weston Andros Adamson <[email protected]>
commit a43ec98b72aae3e330f0673438f58316c3769b84 upstream.
This is an unneeded check that could cause the client to fail to recover opens.
--- fs/nfs/nfs4proc.c | 6 ------ 1 file changed, 6 deletions(-)
fs/nfs/nfs4proc.c +0 -6
@@ -1323,12 +1323,6 @@ _nfs4_opendata_reclaim_to_nfs4_state(str goto err; } - ret = -ESTALE ; -if (!(data->f_attr.valid &NFS_ATTR_FATTR_TYPE ) || - !(data->f_attr.valid &NFS_ATTR_FATTR_FILEID ) || - !(data->f_attr.valid &NFS_ATTR_FATTR_CHANGE )) - goto err; - ret = -ENOMEM ; state =nfs4_get_open_state (inode, data->owner);if (state ==NULL )
Greg Kroah-Hartman
maintainerPATCH 63/116 NFSv4: dont reprocess cached open CLAIM_PREVIOUS
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weston Andros Adamson <[email protected]>
commit d2bfda2e7aa036f90ccea610a657064b1e267913 upstream.
Cached opens have already been handled by _nfs4_opendata_reclaim_to_nfs4_state and can safely skip being reprocessed, but must still call update_open_stateid to make sure that all active fmodes are recovered.
--- fs/nfs/nfs4proc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
fs/nfs/nfs4proc.c +8 -4
@@ -1317,10 +1317,13 @@ _nfs4_opendata_reclaim_to_nfs4_state(strstruct nfs4_state *state = data->state;int ret; -/* allow cached opens (!rpc_done && !rpc_status) */ -if (!data->rpc_done && data->rpc_status) { - ret = data->rpc_status; - goto err; +if (!data->rpc_done) { +if (data->rpc_status) { + ret = data->rpc_status; + goto err; + } +/* cached opens have already been processed */ + goto update; } ret = -ENOMEM ;
@@ -1336,6 +1339,7 @@ _nfs4_opendata_reclaim_to_nfs4_state(strif (data->o_res.delegation_type !=0 )nfs4_opendata_check_deleg (data, state); +update:update_open_stateid (state, &data->o_res.stateid,NULL , data->o_arg.fmode);
Greg Kroah-Hartman
maintainerPATCH 64/116 NFSv4: Fix state reference counting in _nfs4_opendata_reclaim_to_nfs4_state
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit d49f042aeec99c5f87160bb52dd52088b1051311 upstream.
Currently, if the call to nfs_refresh_inode fails, then we end up leaking a reference count, due to the call to nfs4_get_open_state. While we're at it, replace nfs4_get_open_state with a simple call to atomic_inc(); there is no need to do a full lookup of the struct nfs_state since it is passed as an argument in the struct nfs4_opendata, and is already assigned to the variable 'state'.
--- fs/nfs/nfs4proc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
fs/nfs/nfs4proc.c +1 -5
@@ -1326,11 +1326,6 @@ _nfs4_opendata_reclaim_to_nfs4_state(str goto update; } - ret = -ENOMEM ; - state =nfs4_get_open_state (inode, data->owner); -if (state ==NULL ) - goto err; - ret =nfs_refresh_inode (inode, &data->f_attr);if (ret) goto err;
@@ -1342,6 +1337,7 @@ _nfs4_opendata_reclaim_to_nfs4_state(str update:update_open_stateid (state, &data->o_res.stateid,NULL , data->o_arg.fmode); +atomic_inc (&state->count);return state; err:
Greg Kroah-Hartman
maintainerPATCH 65/116 nfs: fix inverted test for delegation in nfs4_reclaim_open_state
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
commit 1acd1c301f4faae80f4d2c7bbd9a4553b131c0e3 upstream.
commit 6686390bab6a0e0 (NFS: remove incorrect "Lock reclaim failed!" warning.) added a test for a delegation before checking to see if any reclaimed locks failed. The test however is backward and is only doing that check when a delegation is held instead of when one isn't.
--- fs/nfs/nfs4state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4state.c +1 -1
@@ -1422,7 +1422,7 @@ restart:if (status >=0 ) { status =nfs4_reclaim_locks (state, ops);if (status >=0 ) { -if (test_bit (NFS_DELEGATED_STATE , &state->flags) !=0 ) { +if (!test_bit (NFS_DELEGATED_STATE , &state->flags)) {spin_lock (&state->state_lock);list_for_each_entry (lock, &state->lock_states, ls_locks) {if (!test_bit (NFS_LOCK_INITIALIZED , &lock->ls_flags))
Greg Kroah-Hartman
maintainerPATCH 66/116 nfs: fix oops when trying to set SELinux label
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
commit 12207f69b3ef4d6eea6a5568281e49f671977ab1 upstream.
Chao reported the following oops when testing labeled NFS:
BUG: unable to handle kernel NULL pointer dereference at (null) IP: [<ffffffffa0568703>] nfs4_xdr_enc_setattr+0x43/0x110 [nfsv4] PGD 277bbd067 PUD 2777ea067 PMD 0 Oops: 0000 [#1] SMP Modules linked in: rpcsec_gss_krb5 nfsv4 dns_resolver nfs fscache sg coretemp kvm_intel kvm crc32_pclmul crc32c_intel ghash_clmulni_intel aesni_intel lrw gf128mul iTCO_wdt glue_helper ablk_helper cryptd iTCO_vendor_support bnx2 pcspkr serio_raw i7core_edac cdc_ether microcode usbnet edac_core mii lpc_ich i2c_i801 mfd_core shpchp ioatdma dca acpi_cpufreq mperf nfsd auth_rpcgss nfs_acl lockd sunrpc xfs libcrc32c sr_mod sd_mod cdrom crc_t10dif mgag200 syscopyarea sysfillrect sysimgblt i2c_algo_bit drm_kms_helper ata_generic ttm pata_acpi drm ata_piix libata megaraid_sas i2c_core dm_mirror dm_region_hash dm_log dm_mod CPU: 4 PID: 25657 Comm: chcon Not tainted 3.10.0-33.el7.x86_64 #1 Hardware name: IBM System x3550 M3 -[7944OEJ]-/90Y4784 , BIOS -[D6E150CUS-1.11]- 02/08/2011 task: ffff880178397220 ti: ffff8801595d2000 task.ti: ffff8801595d2000 RIP: 0010:[<ffffffffa0568703>] [<ffffffffa0568703>] nfs4_xdr_enc_setattr+0x43/0x110 [nfsv4] RSP: 0018:ffff8801595d3888 EFLAGS: 00010296 RAX: 0000000000000000 RBX: ffff8801595d3b30 RCX: 0000000000000b4c RDX: ffff8801595d3b30 RSI: ffff8801595d38e0 RDI: ffff880278b6ec00 RBP: ffff8801595d38c8 R08: ffff8801595d3b30 R09: 0000000000000001 R10: 0000000000000000 R11: 0000000000000000 R12: ffff8801595d38e0 R13: ffff880277a4a780 R14: ffffffffa05686c0 R15: ffff8802765f206c FS: 00007f2c68486800(0000) GS:ffff88027fc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 000000027651a000 CR4: 00000000000007e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Stack: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 ffff880277865800 ffff880278b6ec00 ffff880277a4a780 ffff8801595d3948 ffffffffa02ad926 ffff8801595d3b30 ffff8802765f206c Call Trace: [<ffffffffa02ad926>] rpcauth_wrap_req+0x86/0xd0 [sunrpc] [<ffffffffa02a1d40>] ? call_connect+0xb0/0xb0 [sunrpc] [<ffffffffa02a1d40>] ? call_connect+0xb0/0xb0 [sunrpc] [<ffffffffa02a1ecb>] call_transmit+0x18b/0x290 [sunrpc] [<ffffffffa02a1d40>] ? call_connect+0xb0/0xb0 [sunrpc] [<ffffffffa02aae14>] __rpc_execute+0x84/0x400 [sunrpc] [<ffffffffa02ac40e>] rpc_execute+0x5e/0xa0 [sunrpc] [<ffffffffa02a2ea0>] rpc_run_task+0x70/0x90 [sunrpc] [<ffffffffa02a2f03>] rpc_call_sync+0x43/0xa0 [sunrpc] [<ffffffffa055284d>] _nfs4_do_set_security_label+0x11d/0x170 [nfsv4] [<ffffffffa0558861>] nfs4_set_security_label.isra.69+0xf1/0x1d0 [nfsv4] [<ffffffff815fca8b>] ? avc_alloc_node+0x24/0x125 [<ffffffff815fcd2f>] ? avc_compute_av+0x1a3/0x1b5 [<ffffffffa055897b>] nfs4_xattr_set_nfs4_label+0x3b/0x50 [nfsv4] [<ffffffff811bc772>] generic_setxattr+0x62/0x80 [<ffffffff811bcfc3>] __vfs_setxattr_noperm+0x63/0x1b0 [<ffffffff811bd1c5>] vfs_setxattr+0xb5/0xc0 [<ffffffff811bd2fe>] setxattr+0x12e/0x1c0 [<ffffffff811a4d22>] ? final_putname+0x22/0x50 [<ffffffff811a4f2b>] ? putname+0x2b/0x40 [<ffffffff811aa1cf>] ? user_path_at_empty+0x5f/0x90 [<ffffffff8119bc29>] ? __sb_start_write+0x49/0x100 [<ffffffff811bd66f>] SyS_lsetxattr+0x8f/0xd0 [<ffffffff8160cf99>] system_call_fastpath+0x16/0x1b Code: 48 8b 02 48 c7 45 c0 00 00 00 00 48 c7 45 c8 00 00 00 00 48 c7 45 d0 00 00 00 00 48 c7 45 d8 00 00 00 00 48 c7 45 e0 00 00 00 00 <48> 8b 00 48 8b 00 48 85 c0 0f 84 ae 00 00 00 48 8b 80 b8 03 00 RIP [<ffffffffa0568703>] nfs4_xdr_enc_setattr+0x43/0x110 [nfsv4] RSP <ffff8801595d3888>
CR2: 0000000000000000
The problem is that _nfs4_do_set_security_label calls rpc_call_sync() directly which fails to do any setup of the SEQUENCE call. Have it use nfs4_call_sync() instead which does the right thing. While we're at it change the name of "args" to "arg" to better match the pattern in _nfs4_do_setattr.
--- fs/nfs/nfs4proc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/nfs/nfs4proc.c +4 -4
@@ -4625,7 +4625,7 @@ static int _nfs4_do_set_security_label(sstruct iattr sattr = {0 };struct nfs_server *server =NFS_SERVER (inode);const u32 bitmask[3 ] = {0 ,0 ,FATTR4_WORD2_SECURITY_LABEL }; -struct nfs_setattrargs args = { +struct nfs_setattrargs arg = { .fh =NFS_FH (inode), .iap = &sattr, .server = server,
@@ -4639,14 +4639,14 @@ static int _nfs4_do_set_security_label(s };struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETATTR ], - .rpc_argp = &args, + .rpc_argp = &arg, .rpc_resp = &res, };int status; -nfs4_stateid_copy (&args.stateid, &zero_stateid); +nfs4_stateid_copy (&arg.stateid, &zero_stateid); - status =rpc_call_sync (server->client, &msg,0 ); + status =nfs4_call_sync (server->client, server, &msg, &arg.seq_args, &res.seq_res,1 );if (status)dprintk ("%s failed: %d\n" , __func__, status);
Greg Kroah-Hartman
maintainerPATCH 67/116 NFS: Fix a missing initialisation when reading the SELinux label
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit fcb63a9bd8427fc584229048ea14f1453dc9a2e1 upstream.
Ensure that _nfs4_do_get_security_label() also initialises the SEQUENCE call correctly, by having it call into nfs4_call_sync().
--- fs/nfs/nfs4proc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/nfs/nfs4proc.c +3 -3
@@ -4570,7 +4570,7 @@ static int _nfs4_get_security_label(strustruct nfs4_label label = {0 ,0 , buflen, buf};u32 bitmask[3 ] = {0 ,0 ,FATTR4_WORD2_SECURITY_LABEL }; -struct nfs4_getattr_arg args = { +struct nfs4_getattr_arg arg = { .fh =NFS_FH (inode), .bitmask = bitmask, };
@@ -4581,14 +4581,14 @@ static int _nfs4_get_security_label(stru };struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_GETATTR ], - .rpc_argp = &args, + .rpc_argp = &arg, .rpc_resp = &res, };int ret;nfs_fattr_init (&fattr); - ret =rpc_call_sync (server->client, &msg,0 ); + ret =nfs4_call_sync (server->client, server, &msg, &arg.seq_args, &res.seq_res,0 );if (ret)return ret;if (!(fattr.valid &NFS_ATTR_FATTR_V4_SECURITY_LABEL ))
Greg Kroah-Hartman
maintainerPATCH 68/116 nfsd: return better errors to exportfs
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: "J. Bruce Fields" <[email protected]>
commit 427d6c6646d868fbd3094e7e2e1644d480cd9204 upstream.
Someone noticed exportfs happily accepted exports that would later be rejected when mountd tried to give them to the kernel. Fix this.
This is a regression from 4c1e1b34d5c800ad3ac9a7e2805b0bea70ad2278 "nfsd: Store ex_anon_uid and ex_anon_gid as kuids and kgids".
--- fs/nfsd/export.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
fs/nfsd/export.c +11 -4
@@ -536,16 +536,12 @@ static int svc_export_parse(struct cacheif (err) goto out3; exp.ex_anon_uid=make_kuid (&init_user_ns, an_int); -if (!uid_valid (exp.ex_anon_uid)) - goto out3;/* anon gid */ err =get_int (&mesg, &an_int);if (err) goto out3; exp.ex_anon_gid=make_kgid (&init_user_ns, an_int); -if (!gid_valid (exp.ex_anon_gid)) - goto out3;/* fsid */ err =get_int (&mesg, &an_int);
@@ -583,6 +579,17 @@ static int svc_export_parse(struct cache exp.ex_uuid);if (err) goto out4; +/* +* For some reason exportfs has been passing down an +* invalid (-1) uid & gid on the "dummy" export which it +* uses to test export support. To make sure exportfs +* sees errors from check_export we therefore need to +* delay these checks till after check_export: +*/ +if (!uid_valid (exp.ex_anon_uid)) + goto out4; +if (!gid_valid (exp.ex_anon_gid)) + goto out4; } expp =svc_export_lookup (&exp);
Greg Kroah-Hartman
maintainerPATCH 69/116 nfsd4: fix discarded security labels on setattr
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: "J. Bruce Fields" <[email protected]>
commit 3378b7f40d79930f0f447a164c7e8fcbe4480e40 upstream.
Security labels in setattr calls are currently ignored because we forget to set label->len.
--- fs/nfsd/nfs4xdr.c | 1 + 1 file changed, 1 insertion(+)
fs/nfsd/nfs4xdr.c +1 -0
@@ -411,6 +411,7 @@ nfsd4_decode_fattr(struct nfsd4_compound label->data =kzalloc (dummy32 +1 ,GFP_KERNEL );if (!label->data)return nfserr_jukebox; + label->len = dummy32;defer_free (argp, kfree, label->data);memcpy (label->data, buf, dummy32); }
Greg Kroah-Hartman
maintainerPATCH 70/116 nfs: dont retry detect_trunking with RPC_AUTH_UNIX more than once
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
commit 6d769f1e1420179d1f83cf1a9cdc585b46c28545 upstream.
Currently, when we try to mount and get back NFS4ERR_CLID_IN_USE or NFS4ERR_WRONGSEC, we create a new rpc_clnt and then try the call again. There is no guarantee that doing so will work however, so we can end up retrying the call in an infinite loop.
Worse yet, we create the new client using rpc_clone_client_set_auth, which creates the new client as a child of the old one. Thus, we can end up with a *very* long lineage of rpc_clnts. When we go to put all of the references to them, we can end up with a long call chain that can smash the stack as each rpc_free_client() call can recurse back into itself.
This patch fixes this by simply ensuring that the SETCLIENTID call will only be retried in this situation if the last attempt did not use RPC_AUTH_UNIX.
Note too that with this change, we don't need the (i > 2) check in the -EACCES case since we now have a more reliable test as to whether we should reattempt.
Cc: Chuck Lever <[email protected]> Tested-by/Acked-by: Weston Andros Adamson <[email protected]>
--- fs/nfs/nfs4state.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/nfs/nfs4state.c +6 -1
@@ -1881,10 +1881,15 @@ again:nfs4_root_machine_cred (clp); goto again; } -if (i >2 ) +if (clnt->cl_auth->au_flavor ==RPC_AUTH_UNIX )break ;case -NFS4ERR_CLID_INUSE :case -NFS4ERR_WRONGSEC : +/* No point in retrying if we already used RPC_AUTH_UNIX */ +if (clnt->cl_auth->au_flavor ==RPC_AUTH_UNIX ) { + status = -EPERM ; +break ; + } clnt =rpc_clone_client_set_auth (clnt,RPC_AUTH_UNIX );if (IS_ERR (clnt)) { status =PTR_ERR (clnt);
Greg Kroah-Hartman
maintainerPATCH 71/116 nfsd: split up nfsd_setattr
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
commit 818e5a22e907fbae75e9c1fd78233baec9fa64b6 upstream.
Split out two helpers to make the code more readable and easier to verify for correctness.
--- fs/nfsd/vfs.c | 144 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 84 insertions(+), 60 deletions(-)
fs/nfsd/vfs.c +84 -60
@@ -298,41 +298,12 @@ commit_metadata(struct svc_fh *fhp) }/* -* Set various file attributes. -* N.B. After this call fhp needs an fh_put +* Go over the attributes and take care of the small differences between +* NFS semantics and what Linux expects. */ -__be32 -nfsd_setattr (struct svc_rqst *rqstp,struct svc_fh *fhp,struct iattr *iap, -int check_guard,time_t guardtime) +static void +nfsd_sanitize_attrs (struct inode *inode,struct iattr *iap) { -struct dentry *dentry; -struct inode *inode; -int accmode =NFSD_MAY_SATTR ; -umode_t ftype =0 ; -__be32 err; -int host_err; -int size_change =0 ; - -if (iap->ia_valid & (ATTR_ATIME |ATTR_MTIME |ATTR_SIZE )) - accmode |=NFSD_MAY_WRITE |NFSD_MAY_OWNER_OVERRIDE ; -if (iap->ia_valid &ATTR_SIZE ) - ftype =S_IFREG ; - -/* Get inode */ - err =fh_verify (rqstp, fhp, ftype, accmode); -if (err) - goto out; - - dentry = fhp->fh_dentry; - inode = dentry->d_inode; - -/* Ignore any mode updates on symlinks */ -if (S_ISLNK (inode->i_mode)) - iap->ia_valid &= ~ATTR_MODE ; - -if (!iap->ia_valid) - goto out; -/* * NFSv2 does not differentiate between "set-[ac]time-to-now" * which only requires access, and "set-[ac]time-to-X" which
@@ -342,8 +313,7 @@ nfsd_setattr(struct svc_rqst *rqstp, str* convert to "set to now" instead of "set to explicit time" * * We only call inode_change_ok as the last test as technically -* it is not an interface that we should be using. It is only -* valid if the filesystem does not define it's own i_op->setattr. +* it is not an interface that we should be using. */ #define BOTH_TIME_SET (ATTR_ATIME_SET | ATTR_MTIME_SET)#define MAX_TOUCH_TIME_ERROR (30*60)
@@ -369,30 +339,6 @@ nfsd_setattr(struct svc_rqst *rqstp, str iap->ia_valid &= ~BOTH_TIME_SET ; } } - -/* -* The size case is special. -* It changes the file as well as the attributes. -*/ -if (iap->ia_valid &ATTR_SIZE ) { -if (iap->ia_size < inode->i_size) { - err =nfsd_permission (rqstp, fhp->fh_export, dentry, -NFSD_MAY_TRUNC |NFSD_MAY_OWNER_OVERRIDE ); -if (err) - goto out; - } - - host_err =get_write_access (inode); -if (host_err) - goto out_nfserr; - - size_change =1 ; - host_err =locks_verify_truncate (inode,NULL , iap->ia_size); -if (host_err) { -put_write_access (inode); - goto out_nfserr; - } - }/* sanitize the mode change */ if (iap->ia_valid &ATTR_MODE ) {
@@ -415,8 +361,86 @@ nfsd_setattr(struct svc_rqst *rqstp, str iap->ia_valid |= (ATTR_KILL_SUID |ATTR_KILL_SGID ); } } +} + +static __be32 +nfsd_get_write_access (struct svc_rqst *rqstp,struct svc_fh *fhp, +struct iattr *iap) +{ +struct inode *inode = fhp->fh_dentry->d_inode; +int host_err; + +if (iap->ia_size < inode->i_size) { +__be32 err; + + err =nfsd_permission (rqstp, fhp->fh_export, fhp->fh_dentry, +NFSD_MAY_TRUNC |NFSD_MAY_OWNER_OVERRIDE ); +if (err) +return err; + } + + host_err =get_write_access (inode); +if (host_err) + goto out_nfserrno; + + host_err =locks_verify_truncate (inode,NULL , iap->ia_size); +if (host_err) + goto out_put_write_access; +return 0 ; + +out_put_write_access: +put_write_access (inode); +out_nfserrno: +return nfserrno (host_err); +} + +/* +* Set various file attributes. After this call fhp needs an fh_put. +*/ +__be32 +nfsd_setattr (struct svc_rqst *rqstp,struct svc_fh *fhp,struct iattr *iap, +int check_guard,time_t guardtime) +{ +struct dentry *dentry; +struct inode *inode; +int accmode =NFSD_MAY_SATTR ; +umode_t ftype =0 ; +__be32 err; +int host_err; +int size_change =0 ; + +if (iap->ia_valid & (ATTR_ATIME |ATTR_MTIME |ATTR_SIZE )) + accmode |=NFSD_MAY_WRITE |NFSD_MAY_OWNER_OVERRIDE ; +if (iap->ia_valid &ATTR_SIZE ) + ftype =S_IFREG ; + +/* Get inode */ + err =fh_verify (rqstp, fhp, ftype, accmode); +if (err) + goto out; + + dentry = fhp->fh_dentry; + inode = dentry->d_inode; + +/* Ignore any mode updates on symlinks */ +if (S_ISLNK (inode->i_mode)) + iap->ia_valid &= ~ATTR_MODE ; + +if (!iap->ia_valid) + goto out; + +nfsd_sanitize_attrs (inode, iap); -/* Change the attributes. */ +/* +* The size case is special, it changes the file in addition to the +* attributes. +*/ +if (iap->ia_valid &ATTR_SIZE ) { + err =nfsd_get_write_access (rqstp, fhp, iap); +if (err) + goto out; + size_change =1 ; + } iap->ia_valid |=ATTR_CTIME ;
Greg Kroah-Hartman
maintainerPATCH 72/116 nfsd: make sure to balance get/put_write_access
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
commit 987da4791052fa298b7cfcde4dea9f6f2bbc786b upstream.
Use a straight goto error label style in nfsd_setattr to make sure we always do the put_write_access call after we got it earlier.
Note that the we have been failing to do that in the case nfsd_break_lease() returns an error, a bug introduced into 2.6.38 with 6a76bebefe15d9a08864f824d7f8d5beaf37c997 "nfsd4: break lease on nfsd setattr".
--- fs/nfsd/vfs.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
fs/nfsd/vfs.c +15 -14
@@ -444,27 +444,28 @@ nfsd_setattr(struct svc_rqst *rqstp, str iap->ia_valid |=ATTR_CTIME ; - err = nfserr_notsync; -if (!check_guard || guardtime == inode->i_ctime.tv_sec) { - host_err =nfsd_break_lease (inode); -if (host_err) - goto out_nfserr; -fh_lock (fhp); - - host_err =notify_change (dentry, iap); - err =nfserrno (host_err); -fh_unlock (fhp); +if (check_guard && guardtime != inode->i_ctime.tv_sec) { + err = nfserr_notsync; + goto out_put_write_access; } + + host_err =nfsd_break_lease (inode); +if (host_err) + goto out_put_write_access_nfserror; + +fh_lock (fhp); + host_err =notify_change (dentry, iap); +fh_unlock (fhp); + +out_put_write_access_nfserror: + err =nfserrno (host_err); +out_put_write_access:if (size_change)put_write_access (inode);if (!err)commit_metadata (fhp); out:return err; - -out_nfserr: - err =nfserrno (host_err); - goto out; } #if defined(CONFIG_NFSD_V2_ACL) || \
Greg Kroah-Hartman
maintainerPATCH 73/116 nfsd4: fix xdr decoding of large non-write compounds
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: "J. Bruce Fields" <[email protected]>
commit 365da4adebb1c012febf81019ad3dc5bb52e2a13 upstream.
This fixes a regression from 247500820ebd02ad87525db5d9b199e5b66f6636 "nfsd4: fix decoding of compounds across page boundaries". The previous code was correct: argp->pagelist is initialized in nfs4svc_deocde_compoundargs to rqstp->rq_arg.pages, and is therefore a pointer to the page *after* the page we are currently decoding.
The reason that patch nevertheless fixed a problem with decoding compounds containing write was a bug in the write decoding introduced by 5a80a54d21c96590d013378d8c5f65f879451ab4 "nfsd4: reorganize write decoding", after which write decoding no longer adhered to the rule that argp->pagelist point to the next page.
--- fs/nfsd/nfs4xdr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfsd/nfs4xdr.c +2 -1
@@ -141,8 +141,8 @@ xdr_error: \static void next_decode_page (struct nfsd4_compoundargs *argp) { - argp->pagelist++; argp->p =page_address (argp->pagelist[0 ]); + argp->pagelist++;if (argp->pagelen <PAGE_SIZE ) { argp->end = argp->p + (argp->pagelen>>2 ); argp->pagelen =0 ;
@@ -1209,6 +1209,7 @@ nfsd4_decode_write(struct nfsd4_compound len -= pages *PAGE_SIZE ; argp->p = (__be32 *)page_address (argp->pagelist[0 ]); + argp->pagelist++; argp->end = argp->p +XDR_QUADLEN (PAGE_SIZE ); } argp->p +=XDR_QUADLEN (len);
Greg Kroah-Hartman
maintainerPATCH 74/116 x86/apic: Disable I/O APIC before shutdown of the local APIC
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fenghua Yu <[email protected]>
commit 522e66464467543c0d88d023336eec4df03ad40b upstream.
In reboot and crash path, when we shut down the local APIC, the I/O APIC is still active. This may cause issues because external interrupts can still come in and disturb the local APIC during shutdown process.
To quiet external interrupts, disable I/O APIC before shutdown local APIC.
--- arch/x86/kernel/crash.c | 2 +- arch/x86/kernel/reboot.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
arch/x86/kernel/crash.c +1 -1
@@ -127,12 +127,12 @@ void native_machine_crash_shutdown(struccpu_emergency_vmxoff ();cpu_emergency_svm_disable (); -lapic_shutdown ();#ifdef CONFIG_X86_IO_APIC /* Prevent crash_kexec() from deadlocking on ioapic_lock. */ ioapic_zap_locks ();disable_IO_APIC ();#endif +lapic_shutdown ();#ifdef CONFIG_HPET_TIMER hpet_disable ();#endif
arch/x86/kernel/reboot.c +4 -4
@@ -550,6 +550,10 @@ static void native_machine_emergency_resvoid native_machine_shutdown (void ) {/* Stop the cpus and apics */ +#ifdef CONFIG_X86_IO_APIC +disable_IO_APIC (); +#endif +#ifdef CONFIG_SMP /* * Stop all of the others. Also disable the local irq to
@@ -562,10 +566,6 @@ void native_machine_shutdown(void)lapic_shutdown (); -#ifdef CONFIG_X86_IO_APIC -disable_IO_APIC (); -#endif -#ifdef CONFIG_HPET_TIMER hpet_disable ();#endif
Greg Kroah-Hartman
maintainerPATCH 75/116 x86/microcode/amd: Tone down printk(), dont treat a missing firmware file as an error
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Renninger <[email protected]>
commit 11f918d3e2d3861b6931e97b3aa778e4984935aa upstream.
Do it the same way as done in microcode_intel.c: use pr_debug() for missing firmware files.
There seem to be CPUs out there for which no microcode update has been submitted to kernel-firmware repo yet resulting in scary sounding error messages in dmesg:
microcode: failed to load file amd-ucode/microcode_amd_fam16h.bin
--- arch/x86/kernel/microcode_amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/microcode_amd.c +1 -1
@@ -431,7 +431,7 @@ static enum ucode_state request_microcodsnprintf (fw_name,sizeof (fw_name),"amd-ucode/microcode_amd_fam%.2xh.bin" , c->x86);if (request_firmware (&fw, (const char *)fw_name, device)) { -pr_err ("failed to load file %s\n" , fw_name); +pr_debug ("failed to load file %s\n" , fw_name); goto out; }
Greg Kroah-Hartman
maintainerPATCH 76/116 KVM: x86: fix emulation of "movzbl %bpl, %eax"
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Bonzini <[email protected]>
commit daf727225b8abfdfe424716abac3d15a3ac5626a upstream.
When I was looking at RHEL5.9's failure to start with unrestricted_guest=0/emulate_invalid_guest_state=1, I got it working with a slightly older tree than kvm.git. I now debugged the remaining failure, which was introduced by commit 660696d1 (KVM: X86 emulator: fix source operand decoding for 8bit mov[zs]x instructions, 2013-04-24) introduced a similar mis-emulation to the one in commit 8acb4207 (KVM:
fix sil/dil/bpl/spl in the mod/rm fields, 2013-05-30). The incorrect decoding occurs in 8-bit movzx/movsx instructions whose 8-bit operand is sil/dil/bpl/spl.
Needless to say, "movzbl %bpl, %eax" does occur in RHEL5.9's decompression prolog, just a handful of instructions before finally giving control to the decompressed vmlinux and getting out of the invalid guest state.
Because OpMem8 bypasses decode_modrm, the same handling of the REX prefix must be applied to OpMem8.
--- arch/x86/kvm/emulate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/kvm/emulate.c +4 -1
@@ -4040,7 +4040,10 @@ static int decode_operand(struct x86_emucase OpMem8: ctxt->memop.bytes =1 ;if (ctxt->memop.type ==OP_REG ) { - ctxt->memop.addr.reg =decode_register (ctxt, ctxt->modrm_rm,1 ); +int highbyte_regs = ctxt->rex_prefix ==0 ; + + ctxt->memop.addr.reg =decode_register (ctxt, ctxt->modrm_rm, + highbyte_regs);fetch_register_operand (&ctxt->memop); } goto mem_common;
Greg Kroah-Hartman
maintainerPATCH 77/116 ftrace/x86: skip over the breakpoint for ftrace caller
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kevin Hao <[email protected]>
commit ab4ead02ec235d706d0611d8741964628291237e upstream.
In commit 8a4d0a687a59 "ftrace: Use breakpoint method to update ftrace caller", we choose to use breakpoint method to update the ftrace caller. But we also need to skip over the breakpoint in function ftrace_int3_handler() for them. Otherwise weird things would happen.
--- arch/x86/kernel/ftrace.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
arch/x86/kernel/ftrace.c +13 -1
@@ -248,6 +248,15 @@ int ftrace_update_ftrace_func(ftrace_funreturn ret; } +static int is_ftrace_caller (unsigned long ip) +{ +if (ip == (unsigned long )(&ftrace_call) || + ip == (unsigned long )(&ftrace_regs_call)) +return 1 ; + +return 0 ; +} +/* * A breakpoint was added to the code address we are about to * modify, and this is the handle that will just skip over it.
@@ -257,10 +266,13 @@ int ftrace_update_ftrace_func(ftrace_fun*/ int ftrace_int3_handler (struct pt_regs *regs) { +unsigned long ip; +if (WARN_ON_ONCE (!regs))return 0 ; -if (!ftrace_location (regs->ip -1 )) + ip = regs->ip -1 ; +if (!ftrace_location (ip) && !is_ftrace_caller (ip))return 0 ; regs->ip +=MCOUNT_INSN_SIZE -1 ;
Greg Kroah-Hartman
maintainerPATCH 78/116 KVM: IOMMU: hva align mapping page size
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Edwards <[email protected]>
commit 27ef63c7e97d1e5dddd85051c03f8d44cc887f34 upstream.
When determining the page size we could use to map with the IOMMU, the page size should also be aligned with the hva, not just the gfn. The gfn may not reflect the real alignment within the hugetlbfs file.
Most of the time, this works fine. However, if the hugetlbfs file is backed by non-contiguous huge pages, a multi-huge page memslot starts at an unaligned offset within the hugetlbfs file, and the gfn is aligned with respect to the huge page size, kvm_host_page_size() will return the huge page size and we will use that to map with the IOMMU.
When we later unpin that same memslot, the IOMMU returns the unmap size as the huge page size, and we happily unpin that many pfns in monotonically increasing order, not realizing we are spanning non-contiguous huge pages and partially unpin the wrong huge page.
Ensure the IOMMU mapping page size is aligned with the hva corresponding to the gfn, which does reflect the alignment within the hugetlbfs file.
--- virt/kvm/iommu.c | 4 ++++ 1 file changed, 4 insertions(+)
virt/kvm/iommu.c +4 -0
@@ -103,6 +103,10 @@ int kvm_iommu_map_pages(struct kvm *kvm,while ((gfn <<PAGE_SHIFT ) & (page_size -1 )) page_size >>=1 ; +/* Make sure hva is aligned to the page size we want to map */ +while (__gfn_to_hva_memslot (slot, gfn) & (page_size -1 )) + page_size >>=1 ; +/* * Pin all pages we are about to map in memory. This is * important because we unmap and unpin in 4kb steps later.
Greg Kroah-Hartman
maintainerPATCH 79/116 arm/arm64: KVM: Fix hyp mappings of vmalloc regions
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoffer Dall <[email protected]>
commit 40c2729bab48e2832b17c1fa8af9db60e776131b upstream.
Using virt_to_phys on percpu mappings is horribly wrong as it may be backed by vmalloc. Introduce kvm_kaddr_to_phys which translates both types of valid kernel addresses to the corresponding physical address.
At the same time resolves a typing issue where we were storing the physical address as a 32 bit unsigned long (on arm), truncating the physical address for addresses above the 4GB limit. This caused breakage on Keystone.
--- arch/arm/kvm/mmu.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)
arch/arm/kvm/mmu.c +28 -6
@@ -307,6 +307,17 @@ out:return err; } +static phys_addr_t kvm_kaddr_to_phys (void *kaddr) +{ +if (!is_vmalloc_addr (kaddr)) { +BUG_ON (!virt_addr_valid (kaddr)); +return __pa (kaddr); + }else { +return page_to_phys (vmalloc_to_page (kaddr)) + +offset_in_page (kaddr); + } +} +/** * create_hyp_mappings - duplicate a kernel virtual address range in Hyp mode * @from: The virtual kernel start address of the range
@@ -318,16 +329,27 @@ out:*/ int create_hyp_mappings (void *from,void *to) { -unsigned long phys_addr =virt_to_phys (from); +phys_addr_t phys_addr; +unsigned long virt_addr;unsigned long start =KERN_TO_HYP ((unsigned long )from);unsigned long end =KERN_TO_HYP ((unsigned long )to); -/* Check for a valid kernel memory mapping */ -if (!virt_addr_valid (from) || !virt_addr_valid (to -1 )) -return -EINVAL ; + start = start &PAGE_MASK ; + end =PAGE_ALIGN (end); + +for (virt_addr = start; virt_addr < end; virt_addr +=PAGE_SIZE ) { +int err; + + phys_addr =kvm_kaddr_to_phys (from + virt_addr - start); + err =__create_hyp_mappings (hyp_pgd, virt_addr, + virt_addr +PAGE_SIZE , +__phys_to_pfn (phys_addr), +PAGE_HYP ); +if (err) +return err; + } -return __create_hyp_mappings (hyp_pgd, start, end, -__phys_to_pfn (phys_addr),PAGE_HYP ); +return 0 ; }/**
Greg Kroah-Hartman
maintainerPATCH 80/116 hwmon: (lm90) Fix max6696 alarm handling
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
commit e41fae2b1ed8c78283d73651cd65be0228c0dd1c upstream.
Bit 2 of status register 2 on MAX6696 (external diode 2 open) sets ALERT; the bit thus has to be listed in alert_alarms. Also display a message in the alert handler if the condition is encountered.
Even though not all overtemperature conditions cause ALERT to be set, we should not ignore them in the alert handler. Display messages for all out-of-range conditions.
--- drivers/hwmon/lm90.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/hwmon/lm90.c +7 -4
@@ -278,7 +278,7 @@ static const struct lm90_params lm90_par [max6696] = { .flags =LM90_HAVE_EMERGENCY | LM90_HAVE_EMERGENCY_ALARM | LM90_HAVE_TEMP3, - .alert_alarms = 0x187c, + .alert_alarms = 0x1c7c, .max_convrate = 6, .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL, },
@@ -1500,19 +1500,22 @@ static void lm90_alert(struct i2c_clientif ((alarms &0x7f ) ==0 && (alarms2 &0xfe ) ==0 ) {dev_info (&client->dev,"Everything OK\n" ); }else { -if (alarms &0x61 ) +if ((alarms &0x61 ) || (alarms2 &0x80 ))dev_warn (&client->dev,"temp%d out of range, please check!\n" ,1 ); -if (alarms &0x1a ) +if ((alarms &0x1a ) || (alarms2 &0x20 ))dev_warn (&client->dev,"temp%d out of range, please check!\n" ,2 );if (alarms &0x04 )dev_warn (&client->dev,"temp%d diode open, please check!\n" ,2 ); -if (alarms2 &0x18 ) +if (alarms2 &0x5a )dev_warn (&client->dev,"temp%d out of range, please check!\n" ,3 ); +if (alarms2 &0x04 ) +dev_warn (&client->dev, +"temp%d diode open, please check!\n" ,3 );/* * Disable ALERT# output, because these chips don't implement
Greg Kroah-Hartman
maintainerPATCH 81/116 drivers/memstick/core/ms_block.c: fix unreachable state in h_msb_read_page()
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roger Tseng <[email protected]>
commit a0e5a12fd18d47aa87a7a8c60ca5bc422b136564 upstream.
In h_msb_read_page() in ms_block.c, flow never reaches case MSB_RP_RECIVE_STATUS_REG. This causes error when MEMSTICK_INT_ERR is encountered and status error bits are going to be examined, but the status will never be copied back.
Fix it by transitioning to MSB_RP_RECIVE_STATUS_REG right after MSB_RP_SEND_READ_STATUS_REG.
--- drivers/memstick/core/ms_block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memstick/core/ms_block.c +1 -1
@@ -401,7 +401,7 @@ again: sizeof(struct ms_status_register)))return 0 ; - msb->state =MSB_RP_RECEIVE_OOB_READ ; + msb->state =MSB_RP_RECIVE_STATUS_REG ;return 0 ;case MSB_RP_RECIVE_STATUS_REG :
Greg Kroah-Hartman
maintainerPATCH 82/116 block: fix race between request completion and timeout handling
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Moyer <[email protected]>
commit 4912aa6c11e6a5d910264deedbec2075c6f1bb73 upstream.
crocode i2c_i801 i2c_core iTCO_wdt iTCO_vendor_support shpchp ioatdma dca be2net sg ses enclosure ext4 mbcache jbd2 sd_mod crc_t10dif ahci megaraid_sas(U) dm_mirror dm_region_hash dm_log dm_mod [last unloaded: scsi_wait_scan]
Pid: 491, comm: scsi_eh_0 Tainted: G W ---------------- 2.6.32-220.13.1.el6.x86_64 #1 IBM -[8722PAX]-/00D1461
RIP: 0010:[<ffffffff8124e424>] [<ffffffff8124e424>] blk_requeue_request+0x94/0xa0 RSP: 0018:ffff881057eefd60 EFLAGS: 00010012 RAX: ffff881d99e3e8a8 RBX: ffff881d99e3e780 RCX: ffff881d99e3e8a8 RDX: ffff881d99e3e8a8 RSI: ffff881d99e3e780 RDI: ffff881d99e3e780 RBP: ffff881057eefd80 R08: ffff881057eefe90 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffff881057f92338 R13: 0000000000000000 R14: ffff881057f92338 R15: ffff883058188000 FS: 0000000000000000(0000) GS:ffff880040200000(0000) knlGS:0000000000000000 CS: 0010 DS: 0018 ES: 0018 CR0: 000000008005003b CR2: 00000000006d3ec0 CR3: 000000302cd7d000 CR4: 00000000000406b0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Process scsi_eh_0 (pid: 491, threadinfo ffff881057eee000, task ffff881057e29540) Stack: 0000000000001057 0000000000000286 ffff8810275efdc0 ffff881057f16000 <0> ffff881057eefdd0 ffffffff81362323 ffff881057eefe20 ffffffff8135f393 <0> ffff881057e29af8 ffff8810275efdc0 ffff881057eefe78 ffff881057eefe90 Call Trace: [<ffffffff81362323>] __scsi_queue_insert+0xa3/0x150 [<ffffffff8135f393>] ? scsi_eh_ready_devs+0x5e3/0x850 [<ffffffff81362a23>] scsi_queue_insert+0x13/0x20 [<ffffffff8135e4d4>] scsi_eh_flush_done_q+0x104/0x160 [<ffffffff8135fb6b>] scsi_error_handler+0x35b/0x660 [<ffffffff8135f810>] ? scsi_error_handler+0x0/0x660 [<ffffffff810908c6>] kthread+0x96/0xa0 [<ffffffff8100c14a>] child_rip+0xa/0x20 [<ffffffff81090830>] ? kthread+0x0/0xa0 [<ffffffff8100c140>] ? child_rip+0x0/0x20 Code: 00 00 eb d1 4c 8b 2d 3c 8f 97 00 4d 85 ed 74 bf 49 8b 45 00 49 83 c5 08 48 89 de 4c 89 e7 ff d0 49 8b 45 00 48 85 c0 75 eb eb a4 <0f> 0b eb fe 0f 1f 84 00 00 00 00 00 55 48 89 e5 0f 1f 44 00 00 RIP [<ffffffff8124e424>] blk_requeue_request+0x94/0xa0 RSP <ffff881057eefd60>
The RIP is this line:
BUG_ON(blk_queued_rq(rq));
After digging through the code, I think there may be a race between the request completion and the timer handler running.
A timer is started for each request put on the device's queue (see blk_start_request->blk_add_timer). If the request does not complete before the timer expires, the timer handler (blk_rq_timed_out_timer) will mark the request complete atomically:
static inline int blk_mark_rq_complete(struct request *rq)
{
return test_and_set_bit(REQ_ATOM_COMPLETE, &rq->atomic_flags);
}and then call blk_rq_timed_out. The latter function will call scsi_times_out, which will return one of BLK_EH_HANDLED, BLK_EH_RESET_TIMER or BLK_EH_NOT_HANDLED. If BLK_EH_RESET_TIMER is returned, blk_clear_rq_complete is called, and blk_add_timer is again called to simply wait longer for the request to complete.
Now, if the request happens to complete while this is going on, what happens? Given that we know the completion handler will bail if it finds the REQ_ATOM_COMPLETE bit set, we need to focus on the completion handler running after that bit is cleared. So, from the above paragraph, after the call to blk_clear_rq_complete. If the completion sets REQ_ATOM_COMPLETE before the BUG_ON in blk_add_timer, we go boom there (I haven't seen this in the cores). Next, if we get the completion before the call to list_add_tail, then the timer will eventually fire for an old req, which may either be freed or reallocated (there is evidence that this might be the case). Finally, if the completion comes in *after* the addition to the timeout list, I think it's harmless. The request will be removed from the timeout list, req_atom_complete will be set, and all will be well.
This will only actually explain the coredumps *IF* the request structure was freed, reallocated *and* queued before the error handler thread had a chance to process it. That is possible, but it may make sense to keep digging for another race. I think that if this is what was happening, we would see other instances of this problem showing up as null pointer or garbage pointer dereferences, for example when the request structure was not re-used. It looks like we actually do run into that situation in other reports.
This patch moves the BUG_ON(test_bit(REQ_ATOM_COMPLETE, &req->atomic_flags)); from blk_add_timer to the only caller that could trip over it (blk_start_request). It then inverts the calls to blk_clear_rq_complete and blk_add_timer in blk_rq_timed_out to address the race. I've boot tested this patch, but nothing more.
--- block/blk-core.c | 1 + block/blk-timeout.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-)
block/blk-core.c +1 -0
@@ -2227,6 +2227,7 @@ void blk_start_request(struct request *rif (unlikely (blk_bidi_rq (req))) req->next_rq->resid_len =blk_rq_bytes (req->next_rq); +BUG_ON (test_bit (REQ_ATOM_COMPLETE , &req->atomic_flags));blk_add_timer (req); }EXPORT_SYMBOL (blk_start_request);
block/blk-timeout.c +1 -2
@@ -91,8 +91,8 @@ static void blk_rq_timed_out(struct requ__blk_complete_request (req);break ;case BLK_EH_RESET_TIMER : -blk_clear_rq_complete (req);blk_add_timer (req); +blk_clear_rq_complete (req);break ;case BLK_EH_NOT_HANDLED :/*
@@ -174,7 +174,6 @@ void blk_add_timer(struct request *req)return ;BUG_ON (!list_empty (&req->timeout_list)); -BUG_ON (test_bit (REQ_ATOM_COMPLETE , &req->atomic_flags));/* * Some LLDs, like scsi, peek at the timeout to prevent a
Greg Kroah-Hartman
maintainerPATCH 83/116 block: fix a probe argument to blk_register_region
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit a207f5937630dd35bd2550620bef416937a1365e upstream.
The probe function is supposed to return NULL on failure (as we can see inkobj_lookup: kobj = probe(dev, index, data); ... if (kobj) return kobj;
However, in loop and brd, it returns negative error from ERR_PTR.
This causes a crash if we simulate disk allocation failure and run less -f /dev/loop0 because the negative number is interpreted as a pointer:
BUG: unable to handle kernel NULL pointer dereference at 00000000000002b4 IP: [<ffffffff8118b188>] __blkdev_get+0x28/0x450 PGD 23c677067 PUD 23d6d1067 PMD 0 Oops: 0000 [#1] PREEMPT SMP Modules linked in: loop hpfs nvidia(PO) ip6table_filter ip6_tables uvesafb cfbcopyarea cfbimgblt cfbfillrect fbcon font bitblit fbcon_rotate fbcon_cw fbcon_ud fbcon_ccw softcursor fb fbdev msr ipt_MASQUERADE iptable_nat nf_nat_ipv4 nf_conntrack_ipv4 nf_defrag_ipv4 xt_state ipt_REJECT xt_tcpudp iptable_filter ip_tables x_tables bridge stp llc tun ipv6 cpufreq_stats cpufreq_ondemand cpufreq_userspace cpufreq_powersave cpufreq_conservative hid_generic spadfs usbhid hid fuse raid0 snd_usb_audio snd_pcm_oss snd_mixer_oss md_mod snd_pcm snd_timer snd_page_alloc snd_hwdep snd_usbmidi_lib dmi_sysfs snd_rawmidi nf_nat_ftp nf_nat nf_conntrack_ftp nf_conntrack snd soundcore lm85 hwmon_vid ohci_hcd ehci_pci ehci_hcd serverworks sata_svw libata acpi_cpufreq freq_table mperf ide_core usbcore kvm_amd kvm tg3 i2c_piix4 libphy microcode e100 usb_common ptp skge i2c_core pcspkr k10temp evdev floppy hwmon pps_core mii rtc_cmos button processor unix [last unloaded: nvidia] CPU: 1 PID: 6831 Comm: less Tainted: P W O 3.10.15-devel #18 Hardware name: empty empty/S3992-E, BIOS 'V1.06 ' 06/09/2009 task: ffff880203cc6bc0 ti: ffff88023e47c000 task.ti: ffff88023e47c000 RIP: 0010:[<ffffffff8118b188>] [<ffffffff8118b188>] __blkdev_get+0x28/0x450 RSP: 0018:ffff88023e47dbd8 EFLAGS: 00010286 RAX: ffffffffffffff74 RBX: ffffffffffffff74 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000001 RBP: ffff88023e47dc18 R08: 0000000000000002 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffff88023f519658 R13: ffffffff8118c300 R14: 0000000000000000 R15: ffff88023f519640 FS: 00007f2070bf7700(0000) GS:ffff880247400000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000000002b4 CR3: 000000023da1d000 CR4: 00000000000007e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Stack: 0000000000000002 0000001d00000000 000000003e47dc50 ffff88023f519640 ffff88043d5bb668 ffffffff8118c300 ffff88023d683550 ffff88023e47de60 ffff88023e47dc98 ffffffff8118c10d 0000001d81605698 0000000000000292 Call Trace: [<ffffffff8118c300>] ? blkdev_get_by_dev+0x60/0x60 [<ffffffff8118c10d>] blkdev_get+0x1dd/0x370 [<ffffffff8118c300>] ? blkdev_get_by_dev+0x60/0x60 [<ffffffff813cea6c>] ? _raw_spin_unlock+0x2c/0x50 [<ffffffff8118c300>] ? blkdev_get_by_dev+0x60/0x60 [<ffffffff8118c365>] blkdev_open+0x65/0x80 [<ffffffff8114d12e>] do_dentry_open.isra.18+0x23e/0x2f0 [<ffffffff8114d214>] finish_open+0x34/0x50 [<ffffffff8115e122>] do_last.isra.62+0x2d2/0xc50 [<ffffffff8115eb58>] path_openat.isra.63+0xb8/0x4d0 [<ffffffff81115a8e>] ? might_fault+0x4e/0xa0 [<ffffffff8115f4f0>] do_filp_open+0x40/0x90 [<ffffffff813cea6c>] ? _raw_spin_unlock+0x2c/0x50 [<ffffffff8116db85>] ? __alloc_fd+0xa5/0x1f0 [<ffffffff8114e45f>] do_sys_open+0xef/0x1d0 [<ffffffff8114e559>] SyS_open+0x19/0x20 [<ffffffff813cff16>] system_call_fastpath+0x1a/0x1f Code: 44 00 00 55 48 89 e5 41 57 49 89 ff 41 56 41 89 d6 41 55 41 54 4c 8d 67 18 53 48 83 ec 18 89 75 cc e9 f2 00 00 00 0f 1f 44 00 00 <48> 8b 80 40 03 00 00 48 89 df 4c 8b 68 58 e8 d5
a4 07 00 44 89
RIP [<ffffffff8118b188>] __blkdev_get+0x28/0x450
RSP <ffff88023e47dbd8>
CR2: 00000000000002b4
---[ end trace bb7f32dbf02398dc ]---
The brd change should be backported to stable kernels starting with 2.6.25. The loop change should be backported to stable kernels starting with 2.6.22.
--- drivers/block/brd.c | 2 +- drivers/block/loop.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/block/brd.c +1 -1
@@ -545,7 +545,7 @@ static struct kobject *brd_probe(dev_t dmutex_lock (&brd_devices_mutex); brd =brd_init_one (MINOR (dev) >> part_shift); - kobj = brd ?get_disk (brd->brd_disk) :ERR_PTR (-ENOMEM ); + kobj = brd ?get_disk (brd->brd_disk) :NULL ;mutex_unlock (&brd_devices_mutex); *part =0 ;
drivers/block/loop.c +1 -1
@@ -1741,7 +1741,7 @@ static struct kobject *loop_probe(dev_tif (err <0 ) err =loop_add (&lo,MINOR (dev) >> part_shift);if (err <0 ) - kobj =ERR_PTR (err); + kobj =NULL ;else kobj =get_disk (lo->lo_disk);mutex_unlock (&loop_index_mutex);
Greg Kroah-Hartman
maintainerPATCH 84/116 block: properly stack underlying max_segment_size to DM device
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Snitzer <[email protected]>
commit d82ae52e68892338068e7559a0c0657193341ce4 upstream.
Without this patch all DM devices will default to BLK_MAX_SEGMENT_SIZE (65536) even if the underlying device(s) have a larger value -- this is due to blk_stack_limits() using min_not_zero() when stacking the max_segment_size limit.
1073741824
before patch:
65536
after patch:
1073741824
--- block/blk-settings.c | 1 + 1 file changed, 1 insertion(+)
block/blk-settings.c +1 -0
@@ -144,6 +144,7 @@ void blk_set_stacking_limits(struct queu lim->discard_zeroes_data =1 ; lim->max_segments =USHRT_MAX ; lim->max_hw_sectors =UINT_MAX ; + lim->max_segment_size =UINT_MAX ; lim->max_sectors =UINT_MAX ; lim->max_write_same_sectors =UINT_MAX ; }
Greg Kroah-Hartman
maintainerPATCH 85/116 powerpc/52xx: fix build breakage for MPC5200 LPBFIFO module
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anatolij Gustschin <[email protected]>
commit 2bf75084f6d9f9a91ba6e30a501ff070d8a1acf6 upstream.
The MPC5200 LPBFIFO driver requires the bestcomm module to be enabled, otherwise building will fail. Fix it.
--- arch/powerpc/platforms/52xx/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/52xx/Kconfig +1 -1
@@ -57,5 +57,5 @@ config PPC_MPC5200_BUGFIX config PPC_MPC5200_LPBFIFO tristate "MPC5200 LocalPlus bus FIFO driver" - depends on PPC_MPC52xx + depends on PPC_MPC52xx && PPC_BESTCOMM select PPC_BESTCOMM_GEN_BD
Greg Kroah-Hartman
maintainerPATCH 86/116 powerpc/mpc512x: silence build warning upon disabled DIU
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gerhard Sittig <[email protected]>
commit 45d20e8348969a165c53cfb91f445e7cc599a9f0 upstream.
a disabled Kconfig option results in a reference to a not implemented routine when the IS_ENABLED() macro is used for both conditional implementation of the routine as well as a C language source code test at the call site -- the "if (0) func();" construct only gets eliminated later by the optimizer, while the compiler already has emitted its warning about "func()" being undeclared
provide an empty implementation for the mpc512x_setup_diu() and mpc512x_init_diu() routines in case of the disabled option, to avoid the compiler warning which is considered fatal and breaks compilation
the bug appeared with commit 2abbbb63c90ab55ca3f054772c2e5ba7df810c48 "powerpc/mpc512x: move common code to shared.c file", how to reproduce:
make mpc512x_defconfig echo CONFIG_FB_FSL_DIU=n >> .config && make olddefconfig make
CC arch/powerpc/platforms/512x/mpc512x_shared.o
.../arch/powerpc/platforms/512x/mpc512x_shared.c: In function 'mpc512x_init_early':
.../arch/powerpc/platforms/512x/mpc512x_shared.c:456:3: error: implicit declaration of function 'mpc512x_init_diu' [-Werror=implicit-function-declaration] .../arch/powerpc/platforms/512x/mpc512x_shared.c: In function 'mpc512x_setup_arch':
.../arch/powerpc/platforms/512x/mpc512x_shared.c:469:3: error: implicit declaration of function 'mpc512x_setup_diu' [-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
make[4]: *** [arch/powerpc/platforms/512x/mpc512x_shared.o] Error 1
--- arch/powerpc/platforms/512x/mpc512x_shared.c | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/platforms/512x/mpc512x_shared.c +3 -0
@@ -303,6 +303,9 @@ void __init mpc512x_setup_diu(void) diu_ops.release_bootmem = mpc512x_release_bootmem; } +#else +void __init mpc512x_setup_diu (void ) {/* EMPTY */ } +void __init mpc512x_init_diu (void ) {/* EMPTY */ }#endif void __init mpc512x_init_IRQ (void )
Greg Kroah-Hartman
maintainerPATCH 87/116 powerpc/vio: use strcpy in modalias_show
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prarit Bhargava <[email protected]>
commit 411cabf79e684171669ad29a0628c400b4431e95 upstream.
Commit e82b89a6f19bae73fb064d1b3dd91fcefbb478f4 used strcat instead of strcpy which can result in an overflow of newlines on the buffer.
--- arch/powerpc/kernel/vio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kernel/vio.c +2 -2
@@ -1531,12 +1531,12 @@ static ssize_t modalias_show(struct devi dn = dev->of_node;if (!dn) { -strcat (buf,"\n" ); +strcpy (buf,"\n" );return strlen (buf); } cp =of_get_property (dn,"compatible" ,NULL );if (!cp) { -strcat (buf,"\n" ); +strcpy (buf,"\n" );return strlen (buf); }
Greg Kroah-Hartman
maintainerPATCH 88/116 powerpc/powernv: Add PE to its own PELTV
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gavin Shan <[email protected]>
commit 631ad691b5818291d89af9be607d2fe40be0886e upstream.
We need add PE to its own PELTV. Otherwise, the errors originated from the PE might contribute to other PEs. In the result, we can't clear up the error successfully even we're checking and clearing errors during access to PCI config space.
--- arch/powerpc/platforms/powernv/pci-ioda.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/powerpc/platforms/powernv/pci-ioda.c +11 -1
@@ -153,13 +153,23 @@ static int pnv_ioda_configure_pe(struct rid_end = pe->rid +1 ; } -/* Associate PE in PELT */ +/* +* Associate PE in PELT. We need add the PE into the +* corresponding PELT-V as well. Otherwise, the error +* originated from the PE might contribute to other +* PEs. +*/ rc =opal_pci_set_pe (phb->opal_id, pe->pe_number, pe->rid, bcomp, dcomp, fcomp,OPAL_MAP_PE );if (rc) {pe_err (pe,"OPAL error %ld trying to setup PELT table\n" , rc);return -ENXIO ; } + + rc =opal_pci_set_peltv (phb->opal_id, pe->pe_number, + pe->pe_number,OPAL_ADD_PE_TO_DOMAIN ); +if (rc) +pe_warn (pe,"OPAL error %d adding self to PELTV\n" , rc);opal_pci_eeh_freeze_clear (phb->opal_id, pe->pe_number,OPAL_EEH_ACTION_CLEAR_FREEZE_ALL );
Greg Kroah-Hartman
maintainerPATCH 89/116 powerpc: ppc64 address space capped at 32TB, mmap randomisation disabled
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anton Blanchard <[email protected]>
commit 5a049f14902982c26538250bdc8d54156d357252 upstream.
Commit fba2369e6ceb (mm: use vm_unmapped_area() on powerpc architecture) has a bug in slice_scan_available() where we compare an unsigned long (high_slices) against a shifted int. As a result, comparisons against the top 32 bits of high_slices (representing the top 32TB) always returns 0 and the top of our mmap region is clamped at 32TB
This also breaks mmap randomisation since the randomised address is always up near the top of the address space and it gets clamped down to 32TB.
--- arch/powerpc/mm/slice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/mm/slice.c +1 -1
@@ -258,7 +258,7 @@ static bool slice_scan_available(unsigne slice =GET_HIGH_SLICE_INDEX (addr); *boundary_addr = (slice + end) ? ((slice + end) <<SLICE_HIGH_SHIFT ) :SLICE_LOW_TOP ; -return !!(available.high_slices & (1u << slice)); +return !!(available.high_slices & (1ul << slice)); } }
Greg Kroah-Hartman
maintainerPATCH 90/116 powerpc: Fix __get_user_pages_fast() irq handling
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
commit 95f715b08fa4a953771398d20cbe35a6803ea41d upstream.
__get_user_pages_fast() may be called with interrupts disabled (see e.g. get_futex_key() in kernel/futex.c) and therefore should use local_irq_save() and local_irq_restore() instead of local_irq_disable()/enable().
--- arch/powerpc/mm/gup.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/powerpc/mm/gup.c +3 -2
@@ -123,6 +123,7 @@ int __get_user_pages_fast(unsigned longstruct mm_struct *mm = current->mm;unsigned long addr, len, end;unsigned long next; +unsigned long flags;pgd_t *pgdp;int nr =0 ;
@@ -156,7 +157,7 @@ int __get_user_pages_fast(unsigned long* So long as we atomically load page table pointers versus teardown, * we can follow the address down to the the page and take a ref on it. */ -local_irq_disable (); +local_irq_save (flags); pgdp =pgd_offset (mm, addr); do {
@@ -179,7 +180,7 @@ int __get_user_pages_fast(unsigned longbreak ; }while (pgdp++, addr = next, addr != end); -local_irq_enable (); +local_irq_restore (flags);return nr; }
Greg Kroah-Hartman
maintainerPATCH 91/116 powerpc/signals: Mark VSX not saved with small contexts
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Neuling <[email protected]>
commit c13f20ac48328b05cd3b8c19e31ed6c132b44b42 upstream.
The VSX MSR bit in the user context indicates if the context contains VSX state. Currently we set this when the process has touched VSX at any stage.
Unfortunately, if the user has not provided enough space to save the VSX state, we can't save it but we currently still set the MSR VSX bit.
This patch changes this to clear the MSR VSX bit when the user doesn't provide enough space. This indicates that there is no valid VSX state in the user context.
This is needed to support get/set/make/swapcontext for applications that use VSX but only provide a small context. For example, getcontext in glibc provides a smaller context since the VSX registers don't need to be saved over the glibc function call. But since the program calling getcontext may have used VSX, the kernel currently says the VSX state is valid when it's not. If the returned context is then used in setcontext (ie. a small context without VSX but with MSR VSX set), the kernel will refuse the context. This situation has been reported by the glibc community.
Based on patch from Carlos O'Donell.
--- arch/powerpc/kernel/signal_32.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
arch/powerpc/kernel/signal_32.c +9 -1
@@ -457,7 +457,15 @@ static int save_user_regs(struct pt_regsif (copy_vsx_to_user (&frame->mc_vsregs, current))return 1 ; msr |= MSR_VSX; - } + }else if (!ctx_has_vsx_region) +/* +* With a small context structure we can't hold the VSX +* registers, hence clear the MSR value to indicate the state +* was not saved. +*/ + msr &= ~MSR_VSX ; + +#endif /* CONFIG_VSX */ #ifdef CONFIG_SPE /* save spe registers */
Greg Kroah-Hartman
maintainerPATCH 92/116 powerpc/eeh: Enable PCI_COMMAND_MASTER for PCI bridges
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gavin Shan <[email protected]>
commit bf898ec5cbd33be11147743bee27b66b10cb2f85 upstream.
On PHB3, we will fail to fetch IODA tables without PCI_COMMAND_MASTER on PCI bridges. According to one experiment I had, the MSIx interrupts didn't raise from the adapter without the bit applied to all upstream PCI bridges including root port of the adapter. The patch forces to have that bit enabled accordingly.
--- arch/powerpc/kernel/eeh.c | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/powerpc/kernel/eeh.c +9 -0
@@ -687,6 +687,15 @@ void eeh_save_bars(struct eeh_dev *edev)for (i =0 ; i <16 ; i++) eeh_ops->read_config (dn, i *4 ,4 , &edev->config_space[i]); + +/* +* For PCI bridges including root port, we need enable bus +* master explicitly. Otherwise, it can't fetch IODA table +* entries correctly. So we cache the bit in advance so that +* we can restore it after reset, either PHB range or PE range. +*/ +if (edev->mode &EEH_DEV_BRIDGE ) + edev->config_space[1 ] |=PCI_COMMAND_MASTER ; }/**
Greg Kroah-Hartman
maintainerPATCH 93/116 powerpc/pseries: Duplicate dtl entries sometimes sent to userspace
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anton Blanchard <[email protected]>
commit 84b073868b9d9e754ae48b828337633d1b386482 upstream.
When reading from the dispatch trace log (dtl) userspace interface, I sometimes see duplicate entries. One example:
# hexdump -C dtl.out
00000000 07 04 00 0c 00 00 48 44 00 00 00 00 00 00 00 00 00000010 00 0c a0 b4 16 83 6d 68 00 00 00 00 00 00 00 00 00000020 00 00 00 00 10 00 13 50 80 00 00 00 00 00 d0 32
00000030 07 04 00 0c 00 00 48 44 00 00 00 00 00 00 00 00 00000040 00 0c a0 b4 16 83 6d 68 00 00 00 00 00 00 00 00 00000050 00 00 00 00 10 00 13 50 80 00 00 00 00 00 d0 32
The problem is in scan_dispatch_log() where we call dtl_consumer() but bail out before incrementing the index.
To fix this I moved dtl_consumer() after the timebase comparison.
--- arch/powerpc/kernel/time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kernel/time.c +2 -2
@@ -213,8 +213,6 @@ static u64 scan_dispatch_log(u64 stop_tbif (i ==be64_to_cpu (vpa->dtl_idx))return 0 ;while (i <be64_to_cpu (vpa->dtl_idx)) { -if (dtl_consumer) -dtl_consumer (dtl, i); dtb =be64_to_cpu (dtl->timebase); tb_delta =be32_to_cpu (dtl->enqueue_to_dispatch_time) +be32_to_cpu (dtl->ready_to_enqueue_time);
@@ -227,6 +225,8 @@ static u64 scan_dispatch_log(u64 stop_tb }if (dtb > stop_tb)break ; +if (dtl_consumer) +dtl_consumer (dtl, i); stolen += tb_delta; ++i; ++dtl;
Greg Kroah-Hartman
maintainerPATCH 94/116 slub: Handle NULL parameter in kmem_cache_flags
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Lameter <[email protected]>
commit c6f58d9b362b45c52afebe4342c9137d0dabe47f upstream.
Andreas Herrmann writes:
When I've used slub_debug kernel option (e.g. "slub_debug=,skbuff_fclone_cache" or similar) on a debug session I've seen a panic like:
Highbank #setenv bootargs console=ttyAMA0 root=/dev/sda2 kgdboc.kgdboc=ttyAMA0,115200 slub_debug=,kmalloc-4096 earlyprintk=ttyAMA0
...
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = c0004000
[00000000] *pgd=00000000
Internal error: Oops: 5 [#1] SMP ARM
Modules linked in:
CPU: 0 PID: 0 Comm: swapper Tainted: G W 3.12.0-00048-gbe408cd #314
task: c0898360 ti: c088a000 task.ti: c088a000
PC is at strncmp+0x1c/0x84
LR is at kmem_cache_flags.isra.46.part.47+0x44/0x60
pc : [<c02c6da0>] lr : [<c0110a3c>] psr: 200001d3
sp : c088bea8 ip : c088beb8 fp : c088beb4
r10: 00000000 r9 : 413fc090 r8 : 00000001
r7 : 00000000 r6 : c2984a08 r5 : c0966e78 r4 : 00000000
r3 : 0000006b r2 : 0000000c r1 : 00000000 r0 : c2984a08
Flags: nzCv IRQs off FIQs off Mode SVC_32 ISA ARM Segment kernel
Control: 10c5387d Table: 0000404a DAC: 00000015
Process swapper (pid: 0, stack limit = 0xc088a248)
Stack: (0xc088bea8 to 0xc088c000)
bea0: c088bed4 c088beb8 c0110a3c c02c6d90 c0966e78 00000040
bec0: ef001f00 00000040 c088bf14 c088bed8 c0112070 c0110a04 00000005 c010fac8
bee0: c088bf5c c088bef0 c010fac8 ef001f00 00000040 00000000 00000040 00000001
bf00: 413fc090 00000000 c088bf34 c088bf18 c0839190 c0112040 00000000 ef001f00
bf20: 00000000 00000000 c088bf54 c088bf38 c0839200 c083914c 00000006 c0961c4c
bf40: c0961c28 00000000 c088bf7c c088bf58 c08392ac c08391c0 c08a2ed8 c0966e78
bf60: c086b874 c08a3f50 c0961c28 00000001 c088bfb4 c088bf80 c083b258 c0839248
bf80: 2f800000 0f000000 c08935b4 ffffffff c08cd400 ffffffff c08cd400 c0868408
bfa0: c29849c0 00000000 c088bff4 c088bfb8 c0824974 c083b1e4 ffffffff ffffffff
bfc0: c08245c0 00000000 00000000 c0868408 00000000 10c5387d c0892bcc c0868404
bfe0: c0899440 0000406a 00000000 c088bff8 00008074 c0824824 00000000 00000000
[<c02c6da0>] (strncmp+0x1c/0x84) from [<c0110a3c>] (kmem_cache_flags.isra.46.part.47+0x44/0x60)
[<c0110a3c>] (kmem_cache_flags.isra.46.part.47+0x44/0x60) from [<c0112070>] (__kmem_cache_create+0x3c/0x410)
[<c0112070>] (__kmem_cache_create+0x3c/0x410) from [<c0839190>] (create_boot_cache+0x50/0x74)
[<c0839190>] (create_boot_cache+0x50/0x74) from [<c0839200>] (create_kmalloc_cache+0x4c/0x88)
[<c0839200>] (create_kmalloc_cache+0x4c/0x88) from [<c08392ac>] (create_kmalloc_caches+0x70/0x114)
[<c08392ac>] (create_kmalloc_caches+0x70/0x114) from [<c083b258>] (kmem_cache_init+0x80/0xe0)
[<c083b258>] (kmem_cache_init+0x80/0xe0) from [<c0824974>] (start_kernel+0x15c/0x318)
[<c0824974>] (start_kernel+0x15c/0x318) from [<00008074>] (0x8074)
Code: e3520000 01a00002 089da800 e5d03000 (e5d1c000)
---[ end trace 1b75b31a2719ed1d ]---
Kernel panic - not syncing: Fatal exception Problem is that slub_debug option is not parsed before create_boot_cache is called. Solve this by changing slub_debug to early_param.
Kernels 3.11, 3.10 are also affected. I am not sure about older kernels.
Christoph Lameter explains:
kmem_cache_flags may be called with NULL parameter during early boot. Skip the test in that case.
--- mm/slub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/slub.c +2 -2
@@ -1217,8 +1217,8 @@ static unsigned long kmem_cache_flags(un/* * Enable debugging if selected on the kernel commandline. */ -if (slub_debug && (!slub_debug_slabs || - !strncmp (slub_debug_slabs, name,strlen (slub_debug_slabs)))) +if (slub_debug && (!slub_debug_slabs || (name && + !strncmp (slub_debug_slabs, name,strlen (slub_debug_slabs))))) flags |= slub_debug;return flags;
Greg Kroah-Hartman
maintainerPATCH 95/116 SUNRPC: gss_alloc_msg - choose _either_ a v0 message or a v1 message
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit 5fccc5b52ee07d07a74ce53c6f174bff81e26a16 upstream.
Add the missing 'break' to ensure that we don't corrupt a legacy 'v0' type message by appending the 'v1'.
--- net/sunrpc/auth_gss/auth_gss.c | 1 + 1 file changed, 1 insertion(+)
net/sunrpc/auth_gss/auth_gss.c +1 -0
@@ -482,6 +482,7 @@ gss_alloc_msg(struct gss_auth *gss_auth,switch (vers) {case 0 :gss_encode_v0_msg (gss_msg); +break ;default :gss_encode_v1_msg (gss_msg, service_name, gss_auth->target_name); };
Greg Kroah-Hartman
maintainerPATCH 96/116 SUNRPC: Fix a data corruption issue when retransmitting RPC calls
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit a6b31d18b02ff9d7915c5898c9b5ca41a798cd73 upstream.
The following scenario can cause silent data corruption when doing NFS writes. It has mainly been observed when doing database writes using O_DIRECT.
1) The RPC client uses sendpage() to do zero-copy of the page data.
2) Due to networking issues, the reply from the server is delayed, and so the RPC client times out.
3) The client issues a second sendpage of the page data as part of an RPC call retransmission.
4) The reply to the first transmission arrives from the server _before_ the client hardware has emptied the TCP socket send buffer.
5) After processing the reply, the RPC state machine rules that the call to be done, and triggers the completion callbacks.
6) The application notices the RPC call is done, and reuses the pages to store something else (e.g. a new write).
7) The client NIC drains the TCP socket send buffer. Since the page data has now changed, it reads a corrupted version of the initial RPC call, and puts it on the wire.
This patch fixes the problem in the following manner:
The ordering guarantees of TCP ensure that when the server sends a reply, then we know that the _first_ transmission has completed. Using zero-copy in that situation is therefore safe.
If a time out occurs, we then send the retransmission using sendmsg() (i.e. no zero-copy), We then know that the socket contains a full copy of the data, and so it will retransmit a faithful reproduction even if the RPC call completes, and the application reuses the O_DIRECT buffer in the meantime.
--- net/sunrpc/xprtsock.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
net/sunrpc/xprtsock.c +21 -7
@@ -393,8 +393,10 @@ static int xs_send_kvec(struct socket *sreturn kernel_sendmsg (sock, &msg,NULL ,0 ,0 ); } -static int xs_send_pagedata (struct socket *sock,struct xdr_buf *xdr,unsigned int base,int more) +static int xs_send_pagedata (struct socket *sock,struct xdr_buf *xdr,unsigned int base,int more,bool zerocopy) { +ssize_t (*do_sendpage)(struct socket *sock,struct page *page, +int offset,size_t size,int flags);struct page **ppage;unsigned int remainder;int err, sent =0 ;
@@ -403,6 +405,9 @@ static int xs_send_pagedata(struct socke base += xdr->page_base; ppage = xdr->pages + (base >>PAGE_SHIFT ); base &= ~PAGE_MASK ; + do_sendpage = sock->ops->sendpage; +if (!zerocopy) + do_sendpage = sock_no_sendpage;for (;;) { unsigned int len = min_t(unsigned int, PAGE_SIZE - base, remainder);int flags =XS_SENDMSG_FLAGS ;
@@ -410,7 +415,7 @@ static int xs_send_pagedata(struct socke remainder -= len;if (remainder !=0 || more) flags |=MSG_MORE ; - err = sock->ops->sendpage (sock, *ppage, base, len, flags); + err =do_sendpage (sock, *ppage, base, len, flags);if (remainder ==0 || err != len)break ; sent += err;
@@ -431,9 +436,10 @@ static int xs_send_pagedata(struct socke* @addrlen: UDP only -- length of destination address * @xdr: buffer containing this request * @base: starting position in the buffer +* @zerocopy: true if it is safe to use sendpage() * */ -static int xs_sendpages (struct socket *sock,struct sockaddr *addr,int addrlen,struct xdr_buf *xdr,unsigned int base) +static int xs_sendpages (struct socket *sock,struct sockaddr *addr,int addrlen,struct xdr_buf *xdr,unsigned int base,bool zerocopy) {unsigned int remainder = xdr->len - base;int err, sent =0 ;
@@ -461,7 +467,7 @@ static int xs_sendpages(struct socket *sif (base < xdr->page_len) {unsigned int len = xdr->page_len - base; remainder -= len; - err =xs_send_pagedata (sock, xdr, base, remainder !=0 ); + err =xs_send_pagedata (sock, xdr, base, remainder !=0 , zerocopy);if (remainder ==0 || err != len) goto out; sent += err;
@@ -564,7 +570,7 @@ static int xs_local_send_request(struct req->rq_svec->iov_base, req->rq_svec->iov_len); status =xs_sendpages (transport->sock,NULL ,0 , - xdr, req->rq_bytes_sent); + xdr, req->rq_bytes_sent, true);dprintk ("RPC: %s(%u) = %d\n" , __func__, xdr->len - req->rq_bytes_sent, status);if (likely (status >=0 )) {
@@ -620,7 +626,7 @@ static int xs_udp_send_request(struct rp status =xs_sendpages (transport->sock,xs_addr (xprt), xprt->addrlen, xdr, - req->rq_bytes_sent); + req->rq_bytes_sent, true);dprintk ("RPC: xs_udp_send_request(%u) = %d\n" , xdr->len - req->rq_bytes_sent, status);
@@ -693,6 +699,7 @@ static int xs_tcp_send_request(struct rpstruct rpc_xprt *xprt = req->rq_xprt; struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);struct xdr_buf *xdr = &req->rq_snd_buf; +bool zerocopy = true;int status;xs_encode_stream_record_marker (&req->rq_snd_buf);
@@ -700,13 +707,20 @@ static int xs_tcp_send_request(struct rpxs_pktdump ("packet data:" , req->rq_svec->iov_base, req->rq_svec->iov_len); +/* Don't use zero copy if this is a resend. If the RPC call +* completes while the socket holds a reference to the pages, +* then we may end up resending corrupted data. +*/ +if (task->tk_flags &RPC_TASK_SENT ) + zerocopy = false;/* Continue transmitting the packet/record. We must be careful * to cope with writespace callbacks arriving _after_ we have * called sendmsg(). */ while (1 ) { status =xs_sendpages (transport->sock, -NULL ,0 , xdr, req->rq_bytes_sent); +NULL ,0 , xdr, req->rq_bytes_sent, + zerocopy);dprintk ("RPC: xs_tcp_send_request(%u) = %d\n" , xdr->len - req->rq_bytes_sent, status);
Greg Kroah-Hartman
maintainerPATCH 97/116 SUNRPC: Avoid deep recursion in rpc_release_client
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit d07ba8422f1e58be94cc98a1f475946dc1b89f1b upstream.
In cases where an rpc client has a parent hierarchy, then rpc_free_client may end up calling rpc_release_client() on the parent, thus recursing back into rpc_free_client. If the hierarchy is deep enough, then we can get into situations where the stack simply overflows.
The fix is to have rpc_release_client() loop so that it can take care of the parent rpc client hierarchy without needing to recurse.
--- net/sunrpc/clnt.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
net/sunrpc/clnt.c +17 -12
@@ -656,14 +656,16 @@ EXPORT_SYMBOL_GPL(rpc_shutdown_client);/* * Free an RPC client */ -static void +static struct rpc_clnt *rpc_free_client (struct rpc_clnt *clnt) { +struct rpc_clnt *parent =NULL ; +dprintk_rcu ("RPC: destroying %s client for %s\n" , clnt->cl_program->name,rcu_dereference (clnt->cl_xprt)->servername);if (clnt->cl_parent != clnt) -rpc_release_client (clnt->cl_parent); + parent = clnt->cl_parent;rpc_clnt_remove_pipedir (clnt);rpc_unregister_client (clnt);rpc_free_iostats (clnt->cl_metrics);
@@ -672,18 +674,17 @@ rpc_free_client(struct rpc_clnt *clnt)rpciod_down ();rpc_free_clid (clnt);kfree (clnt); +return parent; }/* * Free an RPC client */ -static void +static struct rpc_clnt *rpc_free_auth (struct rpc_clnt *clnt) { -if (clnt->cl_auth ==NULL ) { -rpc_free_client (clnt); -return ; - } +if (clnt->cl_auth ==NULL ) +return rpc_free_client (clnt);/* * Note: RPCSEC_GSS may need to send NULL RPC calls in order to
@@ -694,7 +695,8 @@ rpc_free_auth(struct rpc_clnt *clnt)rpcauth_release (clnt->cl_auth); clnt->cl_auth =NULL ;if (atomic_dec_and_test (&clnt->cl_count)) -rpc_free_client (clnt); +return rpc_free_client (clnt); +return NULL ; }/*
@@ -705,10 +707,13 @@ rpc_release_client(struct rpc_clnt *clnt {dprintk ("RPC: rpc_release_client(%p)\n" , clnt); -if (list_empty (&clnt->cl_tasks)) -wake_up (&destroy_wait); -if (atomic_dec_and_test (&clnt->cl_count)) -rpc_free_auth (clnt); +do { +if (list_empty (&clnt->cl_tasks)) +wake_up (&destroy_wait); +if (!atomic_dec_and_test (&clnt->cl_count)) +break ; + clnt =rpc_free_auth (clnt); + }while (clnt !=NULL ); }EXPORT_SYMBOL_GPL (rpc_release_client);
Greg Kroah-Hartman
maintainerPATCH 98/116 mei: nfc: fix memory leak in error path
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomas Winkler <[email protected]>
commit 4bff7208f332b2b1d7cf1338e50527441283a198 upstream.
The flow may reach the err label without freeing cl and cl_info
cl and cl_info weren't assigned to ndev->cl and cl_info so they weren't freed in mei_nfc_free called on error path
--- drivers/misc/mei/nfc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/misc/mei/nfc.c +6 -4
@@ -485,8 +485,11 @@ int mei_nfc_host_init(struct mei_deviceif (ndev->cl_info)return 0 ; - cl_info =mei_cl_allocate (dev); - cl =mei_cl_allocate (dev); + ndev->cl_info =mei_cl_allocate (dev); + ndev->cl =mei_cl_allocate (dev); + + cl = ndev->cl; + cl_info = ndev->cl_info;if (!cl || !cl_info) { ret = -ENOMEM ;
@@ -527,10 +530,9 @@ int mei_nfc_host_init(struct mei_device cl->device_uuid = mei_nfc_guid; +list_add_tail (&cl->device_link, &dev->device_list); - ndev->cl_info = cl_info; - ndev->cl = cl; ndev->req_id =1 ;INIT_WORK (&ndev->init_work, mei_nfc_init);
Greg Kroah-Hartman
maintainerPATCH 99/116 usb: Dont enable USB 2.0 Link PM by default.
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sarah Sharp <[email protected]>
commit de68bab4fa96014cfaa6fcbcdb9750e32969fb86 upstream.
How it's supposed to work:
--------------------------
USB 2.0 Link PM is a lower power state that some newer USB 2.0 devices support. USB 3.0 devices certified by the USB-IF are required to support it if they are plugged into a USB 2.0 only port, or a USB 2.0 cable is used. USB 2.0 Link PM requires both a USB device and a host controller that supports USB 2.0 hardware-enabled LPM.
USB 2.0 Link PM is designed to be enabled once by software, and the host hardware handles transitions to the L1 state automatically. The premise of USB 2.0 Link PM is to be able to put the device into a lower power link state when the bus is idle or the device NAKs USB IN transfers for a specified amount of time.
...but hardware is broken:
--------------------------
It turns out many USB 3.0 devices claim to support USB 2.0 Link PM (by setting the LPM bit in their USB 2.0 BOS descriptor), but they don't actually implement it correctly. This manifests as the USB device refusing to respond to transfers when it is plugged into a USB 2.0 only port under the Haswell-ULT/Lynx Point LP xHCI host.
These devices pass the xHCI driver's simple test to enable USB 2.0 Link PM, wait for the port to enter L1, and then bring it back into L0. They only start to break when L1 entry is interleaved with transfers.
Some devices then fail to respond to the next control transfer (usually a Set Configuration). This results in devices never enumerating.
Other mass storage devices (such as a later model Western Digital My Passport USB 3.0 hard drive) respond fine to going into L1 between control transfers. They ACK the entry, come out of L1 when the host needs to send a control transfer, and respond properly to those control transfers. However, when the first READ10 SCSI command is sent, the device NAKs the data phase while it's reading from the spinning disk. Eventually, the host requests to put the link into L1, and the device ACKs that request. Then it never responds to the data phase of the READ10 command. This results in not being able to read from the drive.
Some mass storage devices (like the Corsair Survivor USB 3.0 flash drive) are well behaved. They ACK the entry into L1 during control transfers, and when SCSI commands start coming in, they NAK the requests to go into L1, because they need to be at full power.
Not all USB 3.0 devices advertise USB 2.0 link PM support. My Point Grey USB 3.0 webcam advertises itself as a USB 2.1 device, but doesn't have a USB 2.0 BOS descriptor, so we don't enable USB 2.0 Link PM. I suspect that means the device isn't certified.
What do we do about it?
-----------------------
There's really no good way for the kernel to test these devices. Therefore, the kernel needs to disable USB 2.0 Link PM by default, and distros will have to enable it by writing 1 to the sysfs file /sys/bus/usb/devices/../power/usb2_hardware_lpm. Rip out the xHCI Link PM test, since it's not sufficient to detect these buggy devices, and don't automatically enable LPM after the device is addressed.
This patch should be backported to kernels as old as 3.11, that contain the commit a558ccdcc71c7770c5e80c926a31cfe8a3892a09 "usb: xhci:
add USB2 Link power management BESL support". Without this fix, some USB 3.0 devices will not enumerate or work properly under USB 2.0 ports on Haswell-ULT systems.
--- drivers/usb/core/driver.c | 3 drivers/usb/core/hub.c | 1 drivers/usb/core/sysfs.c | 6 + drivers/usb/host/xhci-mem.c | 10 -- drivers/usb/host/xhci.c | 161 ++++---------------------------------------- include/linux/usb.h | 4 - 6 files changed, 29 insertions(+), 156 deletions(-)
drivers/usb/core/driver.c +3 -0
@@ -1790,6 +1790,9 @@ int usb_set_usb2_hardware_lpm(struct usbstruct usb_hcd *hcd =bus_to_hcd (udev->bus);int ret = -EPERM ; +if (enable && !udev->usb2_hw_lpm_allowed) +return 0 ; +if (hcd->driver->set_usb2_hw_lpm) { ret = hcd->driver->set_usb2_hw_lpm (hcd, udev, enable);if (!ret)
drivers/usb/core/hub.c +1 -0
@@ -5198,6 +5198,7 @@ static int usb_reset_and_verify_device(s done:/* Now that the alt settings are re-installed, enable LTM and LPM. */ +usb_set_usb2_hardware_lpm (udev,1 );usb_unlocked_enable_lpm (udev);usb_enable_ltm (udev);usb_release_bos_descriptor (udev);
drivers/usb/core/sysfs.c +4 -2
@@ -449,7 +449,7 @@ static ssize_t usb2_hardware_lpm_show(ststruct usb_device *udev =to_usb_device (dev);const char *p; -if (udev->usb2_hw_lpm_enabled ==1 ) +if (udev->usb2_hw_lpm_allowed ==1 ) p ="enabled" ;else p ="disabled" ;
@@ -469,8 +469,10 @@ static ssize_t usb2_hardware_lpm_store(s ret =strtobool (buf, &value); -if (!ret) +if (!ret) { + udev->usb2_hw_lpm_allowed = value; ret =usb_set_usb2_hardware_lpm (udev, value); + }usb_unlock_device (udev);
drivers/usb/host/xhci-mem.c +0 -10
@@ -1693,9 +1693,7 @@ void xhci_free_command(struct xhci_hcd *void xhci_mem_cleanup (struct xhci_hcd *xhci) {struct pci_dev *pdev =to_pci_dev (xhci_to_hcd (xhci)->self.controller); -struct dev_info *dev_info, *next;struct xhci_cd *cur_cd, *next_cd; -unsigned long flags;int size;int i, j, num_ports;
@@ -1756,13 +1754,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xscratchpad_free (xhci); -spin_lock_irqsave (&xhci->lock, flags); -list_for_each_entry_safe (dev_info, next, &xhci->lpm_failed_devs, list) { -list_del (&dev_info->list); -kfree (dev_info); - } -spin_unlock_irqrestore (&xhci->lock, flags); -if (!xhci->rh_bw) goto no_bw;
@@ -2231,7 +2222,6 @@ int xhci_mem_init(struct xhci_hcd *xhci,u32 page_size, temp;int i; -INIT_LIST_HEAD (&xhci->lpm_failed_devs);INIT_LIST_HEAD (&xhci->cancel_cmd_list); page_size =xhci_readl (xhci, &xhci->op_regs->page_size);
drivers/usb/host/xhci.c +18 -143
175 lines not on this page · raw message
include/linux/usb.h +3 -1
@@ -475,7 +475,8 @@ struct usb3_lpm_parameters {* @lpm_capable: device supports LPM * @usb2_hw_lpm_capable: device can perform USB2 hardware LPM * @usb2_hw_lpm_besl_capable: device can perform USB2 hardware BESL LPM -* @usb2_hw_lpm_enabled: USB2 hardware LPM enabled +* @usb2_hw_lpm_enabled: USB2 hardware LPM is enabled +* @usb2_hw_lpm_allowed: Userspace allows USB 2.0 LPM to be enabled * @usb3_lpm_enabled: USB3 hardware LPM enabled * @string_langid: language ID for strings * @product: iProduct string, if present (static)
@@ -548,6 +549,7 @@ struct usb_device { unsigned usb2_hw_lpm_capable:1; unsigned usb2_hw_lpm_besl_capable:1; unsigned usb2_hw_lpm_enabled:1; + unsigned usb2_hw_lpm_allowed:1; unsigned usb3_lpm_enabled:1;int string_langid;
Greg Kroah-Hartman
maintainerPATCH 100/116 xhci: Enable LPM support only for hardwired or BESL devices
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit 890dae88672175f1d39f6105444d9bdc71c89258 upstream.
Some usb3 devices falsely claim they support usb2 hardware Link PM when connected to a usb2 port. We only trust hardwired devices or devices with the later BESL LPM support to be LPM enabled as default.
[Note: Sarah re-worked the original patch to move the code into the USB core, and updated it to check whether the USB device supports BESL, instead of checking if the xHCI port it's connected to supports BESL encoding.]
This patch should be backported to kernels as old as 3.11, that contain the commit a558ccdcc71c7770c5e80c926a31cfe8a3892a09 "usb: xhci:
add USB2 Link power management BESL support". Without this fix, some USB 3.0 devices will not enumerate or work properly under USB 2.0 ports on Haswell-ULT systems.
--- drivers/usb/core/hub.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/usb/core/hub.c +27 -0
@@ -3954,6 +3954,32 @@ static int hub_set_address(struct usb_dereturn retval; } +/* +* There are reports of USB 3.0 devices that say they support USB 2.0 Link PM +* when they're plugged into a USB 2.0 port, but they don't work when LPM is +* enabled. +* +* Only enable USB 2.0 Link PM if the port is internal (hardwired), or the +* device says it supports the new USB 2.0 Link PM errata by setting the BESL +* support bit in the BOS descriptor. +*/ +static void hub_set_initial_usb2_lpm_policy (struct usb_device *udev) +{ +int connect_type; + +if (!udev->usb2_hw_lpm_capable) +return ; + + connect_type =usb_get_hub_port_connect_type (udev->parent, + udev->portnum); + +if ((udev->bos->ext_cap->bmAttributes &USB_BESL_SUPPORT ) || + connect_type ==USB_PORT_CONNECT_TYPE_HARD_WIRED ) { + udev->usb2_hw_lpm_allowed =1 ; +usb_set_usb2_hardware_lpm (udev,1 ); + } +} +/* Reset device, (re)assign address, get device descriptor. * Device connection must be stable, no more debouncing needed. * Returns device in USB_STATE_ADDRESS, except on error.
@@ -4247,6 +4273,7 @@ hub_port_init (struct usb_hub *hub, stru/* notify HCD that we have a device connected and addressed */ if (hcd->driver->update_device) hcd->driver->update_device (hcd, udev); +hub_set_initial_usb2_lpm_policy (udev); fail:if (retval) {hub_port_disable (hub, port1,0 );
Greg Kroah-Hartman
maintainerPATCH 101/116 xhci: Set L1 device slot on USB2 LPM enable/disable.
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sarah Sharp <[email protected]>
commit 58e21f73975ec927119370635bf68b9023831c56 upstream.
To enable USB 2.0 Link Power Management (LPM), the xHCI host controller needs the device slot ID to generate the device address used in L1 entry tokens. That information is set in the L1 device slot ID field of the USB 2.0 LPM registers.
Currently, the L1 device slot ID is overwritten when the xHCI driver initiates the software test of USB 2.0 Link PM in xhci_usb2_software_lpm_test. It is never cleared when USB 2.0 Link PM is disabled for the device. That should be harmless, because the Hardware LPM Enable (HLE) bit is cleared when USB 2.0 Link PM is disabled, so the host should not pay attention to the slot ID.
This patch should have no effect on host behavior, but since xhci_usb2_software_lpm_test is going away in an upcoming bug fix patch, we need to move that code to the function that enables and disables USB 2.0 Link PM.
This patch should be backported to kernels as old as 3.11, that contain the commit a558ccdcc71c7770c5e80c926a31cfe8a3892a09 "usb: xhci: add USB2 Link power management BESL support". The upcoming bug fix patch is also marked for that stable kernel.
--- drivers/usb/host/xhci.c | 4 ++-- drivers/usb/host/xhci.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/usb/host/xhci.c +2 -2
@@ -4101,7 +4101,7 @@ int xhci_set_usb2_hardware_lpm(struct us } pm_val &= ~PORT_HIRD_MASK ; - pm_val |=PORT_HIRD (hird) |PORT_RWE ; + pm_val |=PORT_HIRD (hird) |PORT_RWE |PORT_L1DS (udev->slot_id);xhci_writel (xhci, pm_val, pm_addr); pm_val =xhci_readl (xhci, pm_addr); pm_val |=PORT_HLE ;
@@ -4109,7 +4109,7 @@ int xhci_set_usb2_hardware_lpm(struct us/* flush write */ xhci_readl (xhci, pm_addr); }else { - pm_val &= ~(PORT_HLE |PORT_RWE |PORT_HIRD_MASK ); + pm_val &= ~(PORT_HLE |PORT_RWE |PORT_HIRD_MASK |PORT_L1DS_MASK );xhci_writel (xhci, pm_val, pm_addr);/* flush write */ xhci_readl (xhci, pm_addr);
drivers/usb/host/xhci.h +1 -0
@@ -383,6 +383,7 @@ struct xhci_op_regs {#define PORT_RWE (1 << 3)#define PORT_HIRD (p) (((p) & 0xf) << 4)#define PORT_HIRD_MASK (0xf << 4) +#define PORT_L1DS_MASK (0xff << 8)#define PORT_L1DS (p) (((p) & 0xff) << 8)#define PORT_HLE (1 << 16)
Greg Kroah-Hartman
maintainerPATCH 102/116 usb: Disable USB 2.0 Link PM before device reset.
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sarah Sharp <[email protected]>
commit dcc01c0864823f91c3bf3ffca6613e2351702b87 upstream.
Before the USB core resets a device, we need to disable the L1 timeout for the roothub, if USB 2.0 Link PM is enabled. Otherwise the port may transition into L1 in between descriptor fetches, before we know if the USB device descriptors changed. LPM will be re-enabled after the full device descriptors are fetched, and we can confirm the device still supports USB 2.0 LPM after the reset.
We don't need to wait for the USB device to exit L1 before resetting the device, since the xHCI roothub port diagrams show a transition to the Reset state from any of the Ux states (see Figure 34 in the 2012-08-14 xHCI specification update).
This patch should be backported to kernels as old as 3.2, that contain the commit 65580b4321eb36f16ae8b5987bfa1bb948fc5112 "xHCI: set USB2 hardware LPM". That was the first commit to enable USB 2.0 hardware-driven Link Power Management.
--- drivers/usb/core/hub.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/core/hub.c +6 -0
@@ -5118,6 +5118,12 @@ static int usb_reset_and_verify_device(s } parent_hub =usb_hub_to_struct_hub (parent_hdev); +/* Disable USB2 hardware LPM. +* It will be re-enabled by the enumeration process. +*/ +if (udev->usb2_hw_lpm_enabled ==1 ) +usb_set_usb2_hardware_lpm (udev,0 ); + bos = udev->bos; udev->bos =NULL ;
Greg Kroah-Hartman
maintainerPATCH 103/116 usb: hub: Clear Port Reset Change during init/resume
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julius Werner <[email protected]>
commit e92aee330837e4911553761490a8fb843f2053a6 upstream.
This patch adds the Port Reset Change flag to the set of bits that are preemptively cleared on init/resume of a hub. In theory this bit should never be set unexpectedly... in practice it can still happen if BIOS, SMM or ACPI code plays around with USB devices without cleaning up correctly. This is especially dangerous for XHCI root hubs, which don't generate any more Port Status Change Events until all change bits are cleared, so this is a good precaution to have (similar to how it's already done for the Warm Port Reset Change flag).
--- drivers/usb/core/hub.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/core/hub.c +5 -0
@@ -1135,6 +1135,11 @@ static void hub_activate(struct usb_hubusb_clear_port_feature (hub->hdev, port1,USB_PORT_FEAT_C_ENABLE ); } +if (portchange &USB_PORT_STAT_C_RESET ) { + need_debounce_delay = true; +usb_clear_port_feature (hub->hdev, port1, +USB_PORT_FEAT_C_RESET ); + }if ((portchange &USB_PORT_STAT_C_BH_RESET ) &&hub_is_superspeed (hub->hdev)) { need_debounce_delay = true;
Greg Kroah-Hartman
maintainerPATCH 104/116 usb: wusbcore: set the RPIPE wMaxPacketSize value correctly
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Pugliese <[email protected]>
commit 7b6bc07ab554e929c85d51b3d5b26cf7f12c6a3b upstream.
For isochronous endpoints, set the RPIPE wMaxPacketSize value using wOverTheAirPacketSize from the endpoint companion descriptor instead of wMaxPacketSize from the normal endpoint descriptor.
--- drivers/usb/wusbcore/wa-rpipe.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/wusbcore/wa-rpipe.c +4 -1
@@ -333,7 +333,10 @@ static int rpipe_aim(struct wa_rpipe *rp/* FIXME: compute so seg_size > ep->maxpktsize */ rpipe->descr.wBlocks =cpu_to_le16 (16 );/* given */ /* ep0 maxpktsize is 0x200 (WUSB1.0[4.8.1]) */ - rpipe->descr.wMaxPacketSize =cpu_to_le16 (ep->desc.wMaxPacketSize); +if (usb_endpoint_xfer_isoc (&ep->desc)) + rpipe->descr.wMaxPacketSize = epcd->wOverTheAirPacketSize; +else + rpipe->descr.wMaxPacketSize = ep->desc.wMaxPacketSize; rpipe->descr.hwa_bMaxBurst = max(min_t(unsigned int, epcd->bMaxBurst,16U ),1U );
Greg Kroah-Hartman
maintainerPATCH 105/116 rt2800usb: slow down TX status polling
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislaw Gruszka <[email protected]>
commit 36165fd5b00bf8163f89c21bb16a3e9834555b10 upstream.
Polling TX statuses too frequently has two negative effects. First is randomly peek CPU usage, causing overall system functioning delays. Second bad effect is that device is not able to fill TX statuses in H/W register on some workloads and we get lot of timeouts like below:
ieee80211 phy4: rt2800usb_entry_txstatus_timeout: Warning - TX status timeout for entry 7 in queue 2 ieee80211 phy4: rt2800usb_entry_txstatus_timeout: Warning - TX status timeout for entry 7 in queue 2 ieee80211 phy4: rt2800usb_txdone: Warning - Got TX status for an empty queue 2, dropping
This not only cause flood of messages in dmesg, but also bad throughput, since rate scaling algorithm can not work optimally.
In the future, we should probably make polling interval be adjusted automatically, but for now just increase values, this make mentioned problems gone.
Resolve:
https://bugzilla.kernel.org/show_bug.cgi?id=62781
--- drivers/net/wireless/rt2x00/rt2800usb.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/wireless/rt2x00/rt2800usb.c +8 -4
@@ -148,6 +148,8 @@ static bool rt2800usb_txstatus_timeout(sreturn false; } +#define TXSTATUS_READ_INTERVAL 1000000 +static bool rt2800usb_tx_sta_fifo_read_completed (struct rt2x00_dev *rt2x00dev,int urb_status,u32 tx_status) {
@@ -176,8 +178,9 @@ static bool rt2800usb_tx_sta_fifo_read_cqueue_work (rt2x00dev->workqueue, &rt2x00dev->txdone_work);if (rt2800usb_txstatus_pending (rt2x00dev)) { -/* Read register after 250 us */ -hrtimer_start (&rt2x00dev->txstatus_timer,ktime_set (0 ,250000 ), +/* Read register after 1 ms */ +hrtimer_start (&rt2x00dev->txstatus_timer, +ktime_set (0 ,TXSTATUS_READ_INTERVAL ),HRTIMER_MODE_REL );return false; }
@@ -202,8 +205,9 @@ static void rt2800usb_async_read_tx_statif (test_and_set_bit (TX_STATUS_READING , &rt2x00dev->flags))return ; -/* Read TX_STA_FIFO register after 500 us */ -hrtimer_start (&rt2x00dev->txstatus_timer,ktime_set (0 ,500000 ), +/* Read TX_STA_FIFO register after 2 ms */ +hrtimer_start (&rt2x00dev->txstatus_timer, +ktime_set (0 ,2 *TXSTATUS_READ_INTERVAL ),HRTIMER_MODE_REL ); }
Greg Kroah-Hartman
maintainerPATCH 106/116 usb: musb: cancel work on removal
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
commit c5340bd14336b902604ab95212a8877de109d9ae upstream.
So I captured this:
|WARNING: CPU: 0 PID: 2078 at /home/bigeasy/work/new/TI/linux/lib/debugobjects.c:260 debug_print_object+0x94/0xc4() |ODEBUG: free active (active state 0) object type: work_struct hint: musb_irq_work+0x0/0x38 [musb_hdrc] |CPU: 0 PID: 2078 Comm: rmmod Not tainted 3.12.0-rc4+ #338 |[<c0014d38>] (unwind_backtrace+0x0/0xf4) from [<c001249c>] (show_stack+0x14/0x1c) |[<c001249c>] (show_stack+0x14/0x1c) from [<c0037720>] (warn_slowpath_common+0x64/0x84) |[<c0037720>] (warn_slowpath_common+0x64/0x84) from [<c00377d4>] (warn_slowpath_fmt+0x30/0x40) |[<c00377d4>] (warn_slowpath_fmt+0x30/0x40) from [<c022ae90>] (debug_print_object+0x94/0xc4) |[<c022ae90>] (debug_print_object+0x94/0xc4) from [<c022b7e0>] (debug_check_no_obj_freed+0x1c0/0x228) |[<c022b7e0>] (debug_check_no_obj_freed+0x1c0/0x228) from [<c00f1f38>] (kfree+0xf8/0x228) |[<c00f1f38>] (kfree+0xf8/0x228) from [<c02921c4>] (release_nodes+0x1a8/0x248) |[<c02921c4>] (release_nodes+0x1a8/0x248) from [<c028f70c>] (__device_release_driver+0x98/0xf0) |[<c028f70c>] (__device_release_driver+0x98/0xf0) from [<c028f840>] (device_release_driver+0x24/0x34) |[<c028f840>] (device_release_driver+0x24/0x34) from [<c028ebe8>] (bus_remove_device+0x148/0x15c) |[<c028ebe8>] (bus_remove_device+0x148/0x15c) from [<c028d120>] (device_del+0x104/0x1c0) |[<c028d120>] (device_del+0x104/0x1c0) from [<c02911e4>] (platform_device_del+0x18/0xac) |[<c02911e4>] (platform_device_del+0x18/0xac) from [<c029179c>] (platform_device_unregister+0xc/0x18) |[<c029179c>] (platform_device_unregister+0xc/0x18) from [<bf1902fc>] (dsps_remove+0x20/0x4c [musb_dsps]) |[<bf1902fc>] (dsps_remove+0x20/0x4c [musb_dsps]) from [<c0290d7c>] (platform_drv_remove+0x1c/0x24) |[<c0290d7c>] (platform_drv_remove+0x1c/0x24) from [<c028f704>] (__device_release_driver+0x90/0xf0) |[<c028f704>] (__device_release_driver+0x90/0xf0) from [<c028f818>] (driver_detach+0xb4/0xb8) |[<c028f818>] (driver_detach+0xb4/0xb8) from [<c028e6e8>] (bus_remove_driver+0x98/0xec) |[<c028e6e8>] (bus_remove_driver+0x98/0xec) from [<c008fc70>] (SyS_delete_module+0x1e0/0x24c) |[<c008fc70>] (SyS_delete_module+0x1e0/0x24c) from [<c000e680>] (ret_fast_syscall+0x0/0x48) |---[ end trace d79045419a3e51ec ]---
The workqueue is only scheduled from the ep0 and never canceled in case the musb is removed before the work has a chance to run.
--- drivers/usb/musb/musb_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/musb/musb_core.c +1 -0
@@ -1809,6 +1809,7 @@ static void musb_free(struct musb *musb)disable_irq_wake (musb->nIrq);free_irq (musb->nIrq, musb); } +cancel_work_sync (&musb->irq_work);if (musb->dma_controller)dma_controller_destroy (musb->dma_controller);
Greg Kroah-Hartman
maintainerPATCH 107/116 usb: musb: call musb_start() only once in OTG mode
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
commit ae44df2e21b50f9fff28ac75c57e399c04df812c upstream.
In commit 001dd84 ("usb: musb: start musb on the udc side, too") it was ensured that the state engine is started also in OTG mode after a removal / insertion of the gadget.
Unfortunately this change also introduced a bug: If the device is configured as OTG and it connected with a remote host _without_ loading a gadget then we bug() later (because musb->otg->gadget is not initialized).
Initially I assumed it might be nice to have the host part of musb in OTG mode working without having a gadget loaded. This bug and fact that it wasn't working like this before the host/gadget split made me realize that this was a silly idea.
This patch now introduces back the old behavior where in OTG mode the host mode is only working after the gadget has been loaded.
--- drivers/usb/musb/musb_virthub.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/usb/musb/musb_virthub.c +18 -1
@@ -220,6 +220,23 @@ int musb_hub_status_data(struct usb_hcdreturn retval; } +static int musb_has_gadget (struct musb *musb) +{ +/* +* In host-only mode we start a connection right away. In OTG mode +* we have to wait until we loaded a gadget. We don't really need a +* gadget if we operate as a host but we should not start a session +* as a device without a gadget or else we explode. +*/ +#ifdef CONFIG_USB_MUSB_HOST +return 1 ; +#else +if (musb->port_mode ==MUSB_PORT_MODE_HOST ) +return 1 ; +return musb->g.dev.driver !=NULL ; +#endif +} + int musb_hub_control( struct usb_hcd *hcd, u16 typeReq,
@@ -362,7 +379,7 @@ int musb_hub_control(* initialization logic, e.g. for OTG, or change any * logic relating to VBUS power-up. */ -if (!hcd->self.is_b_host) +if (!hcd->self.is_b_host &&musb_has_gadget (musb))musb_start (musb);break ;case USB_PORT_FEAT_RESET :
Greg Kroah-Hartman
maintainerPATCH 108/116 usb: musb: dsps: move try_idle to start hook
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
commit 8b9fcce2d88586b9a120ff3e039d8f42413f0bb0 upstream.
The timer is initialized right after musb is probed. There is actually no need to have this timer running because _nothing_ will happen until we have the gadget loaded. Also we need this timer only if we run in OTG mode _and_ we need it also after the gadget has been replaced with another one.
I've been looking at am35x.c, da8xx.c, omap2430.c, tusb6010.c. da8xx seem to have the same problem as dsps and doing mostly the same thing. tusb6010 seem to do something different and do some actual "idle / power saving" work so I am not too comfortable to remove musb_platform_try_idle() from musb_gadget_setup().
Therefore this patch does not start the timer if there is no gadget active (which is at musb_gadget_setup() at time). In order to have the timer active after the gadget is loaded it will be triggered from dsps_musb_enable().
--- drivers/usb/musb/musb_dsps.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/musb/musb_dsps.c +5 -0
@@ -121,6 +121,7 @@ struct dsps_glue {unsigned long last_timer;/* last timer data for each instance */ }; +static void dsps_musb_try_idle (struct musb *musb,unsigned long timeout);/** * dsps_musb_enable - enable interrupts */
@@ -143,6 +144,7 @@ static void dsps_musb_enable(struct musb/* Force the DRVVBUS IRQ so we can start polling for ID change. */ dsps_writel (reg_base, wrp->coreintr_set, (1 << wrp->drvvbus) << wrp->usb_shift); +dsps_musb_try_idle (musb,0 ); }/**
@@ -234,6 +236,9 @@ static void dsps_musb_try_idle(struct muif (musb->port_mode ==MUSB_PORT_MODE_HOST )return ; +if (!musb->g.dev.driver) +return ; +if (time_after (glue->last_timer, timeout) &&timer_pending (&glue->timer)) { dev_dbg(musb->controller,
Greg Kroah-Hartman
maintainerPATCH 109/116 usb: musb: dsps: redo the otg timer
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
commit 0f901c980110cd69b63670096465b35377e73b1c upstream.
According to the comments, we rely on the OTG timer because the core does not expose some important OTG details. So far this is all I know. After playing with OTG I stumbled over a problem:
musb is recognized as a B-device without a problem. Whenever a cable is plugged, the VBUS rises, musb recognizes this as a starting session, sets the MUSB_DEVCTL_SESSION bit by itself and a RESET interrupt occurs, the session starts. Good.
After a disconnect, the timer is started and re-starts itself because it remains in B_IDLE with the BDEVICE set. I didn't figure the the reason or the need for it. Nothing changes here except for OTG state from B to A device if the BDEVICE bit disappears. This doesn't make much sense to me because nothing happens after this. _IF_ we receive an interrupt before the state change then we may act on wrong condition. Plugging a B-device (and letting MUSB act as host) doesn't work here. The reason seems to be that the MUSB tries to start a session, it fails and then it removes the bit. So we never start as a host.
This patch sets the MUSB_DEVCTL_SESSION bit in the IDLE state so musb can try to establish a session as host. After the bit is set, musb tries to start a session and if it fails it clears the bit. Therefore it will try over and over again until a session either as host or as device is established.
The readout of the MUSB_DEVCTL register after the removal the MUSB_DEVCTL_SESSION (in A_WAIT_BCON) has been removed because it did not contain the BDEVICE bit set (in the second read) leading to A_IDLE. After plugging a host musb assumed that it is also a host and complained about a missing reset. However a third read of the register has has the BDEVICE bit set so it seems that it is not stable.
This mostly what da8xx.c is doing except that we set the timer also after A_WAIT_BCON so the session bit can be triggered.
Whit this change I was able to keep am335x-evm in OTG mode and plug in either a HOST or a DEVICE and in a random order and the device was recognized.
--- drivers/usb/musb/musb_dsps.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/usb/musb/musb_dsps.c +9 -11
@@ -173,6 +173,7 @@ static void otg_timer(unsigned long _musconst struct dsps_musb_wrapper *wrp = glue->wrp;u8 devctl;unsigned long flags; +int skip_session =0 ;/* * We poll because DSPS IP's won't expose several OTG-critical
@@ -185,10 +186,12 @@ static void otg_timer(unsigned long _musspin_lock_irqsave (&musb->lock, flags);switch (musb->xceiv->state) {case OTG_STATE_A_WAIT_BCON : - devctl &= ~MUSB_DEVCTL_SESSION ; -dsps_writeb (musb->mregs,MUSB_DEVCTL , devctl); +dsps_writeb (musb->mregs,MUSB_DEVCTL ,0 ); + skip_session =1 ; +/* fall */ - devctl =dsps_readb (musb->mregs,MUSB_DEVCTL ); +case OTG_STATE_A_IDLE : +case OTG_STATE_B_IDLE :if (devctl &MUSB_DEVCTL_BDEVICE ) { musb->xceiv->state =OTG_STATE_B_IDLE ;MUSB_DEV_MODE (musb);
@@ -196,20 +199,15 @@ static void otg_timer(unsigned long _mus musb->xceiv->state =OTG_STATE_A_IDLE ;MUSB_HST_MODE (musb); } +if (!(devctl &MUSB_DEVCTL_SESSION ) && !skip_session) +dsps_writeb (mregs,MUSB_DEVCTL ,MUSB_DEVCTL_SESSION ); +mod_timer (&glue->timer, jiffies + wrp->poll_seconds *HZ );break ;case OTG_STATE_A_WAIT_VFALL : musb->xceiv->state =OTG_STATE_A_WAIT_VRISE ;dsps_writel (musb->ctrl_base, wrp->coreintr_set,MUSB_INTR_VBUSERROR << wrp->usb_shift);break ; -case OTG_STATE_B_IDLE : - devctl =dsps_readb (mregs,MUSB_DEVCTL ); -if (devctl &MUSB_DEVCTL_BDEVICE ) -mod_timer (&glue->timer, - jiffies + wrp->poll_seconds *HZ ); -else - musb->xceiv->state =OTG_STATE_A_IDLE ; -break ;default :break ; }
Greg Kroah-Hartman
maintainerPATCH 110/116 usb: musb: core: properly free host / device structs in err path
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
commit 0d2dd7eaed1dac07b266ca2c662ff4a184a3060f upstream.
The patch fixes two issues in the error path cleanup:
- in MUSB_PORT_MODE_DUAL_ROLE mode, if musb_gadget_setup() fails we never cleanup the host struct earlier allocated.
- if musb_init_debugfs() or sysfs_create_group() fails, then we never free the host part initialization, only device part.
--- drivers/usb/musb/musb_core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/musb/musb_core.c +3 -0
@@ -1947,6 +1947,8 @@ musb_init_controller(struct device *dev,if (status <0 ) goto fail3; status =musb_gadget_setup (musb); +if (status) +musb_host_cleanup (musb);break ;default :dev_err (dev,"unsupported port mode %d\n" , musb->port_mode);
@@ -1973,6 +1975,7 @@ fail5: fail4:musb_gadget_cleanup (musb); +musb_host_cleanup (musb); fail3:if (musb->dma_controller)
Greg Kroah-Hartman
maintainerPATCH 111/116 s390/time: fix get_tod_clock_ext inline assembly
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Schwidefsky <[email protected]>
commit 7ab64a85e1a009046f97413a573e83fd85f7804d upstream.
The get_tod_clock_ext inline assembly does not specify its output operands correctly. This can cause incorrect code to be generated.
--- arch/s390/include/asm/timex.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/s390/include/asm/timex.h +4 -2
@@ -71,9 +71,11 @@ static inline void local_tick_enable(unstypedef unsigned long long cycles_t ; -static inline void get_tod_clock_ext (char *clk) +static inline void get_tod_clock_ext (char clk[16 ]) { - asmvolatile ("stcke %0" :"=Q" (*clk) : :"cc" ); +typedef struct {char _[sizeof (clk)]; }addrtype ; + + asmvolatile ("stcke %0" :"=Q" (*(addrtype *) clk) : :"cc" ); }static inline unsigned long long get_tod_clock (void )
Greg Kroah-Hartman
maintainerPATCH 112/116 s390/vtime: correct idle time calculation
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Schwidefsky <[email protected]>
commit 4560e7c3317c7a2b370e36dadd3a3bac2ed70818 upstream.
Use the ACCESS_ONCE macro for both accesses to idle->sequence in the loops to calculate the idle time. If only one access uses the macro, the compiler is free to cache the value for the second access which can cause endless loops.
--- arch/s390/kernel/smp.c | 4 ++-- arch/s390/kernel/vtime.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/s390/kernel/smp.c +2 -2
@@ -929,7 +929,7 @@ static ssize_t show_idle_count(struct de idle_count =ACCESS_ONCE (idle->idle_count);if (ACCESS_ONCE (idle->clock_idle_enter)) idle_count++; - }while ((sequence &1 ) || (idle->sequence != sequence)); + }while ((sequence &1 ) || (ACCESS_ONCE (idle->sequence) != sequence));return sprintf (buf,"%llu\n" , idle_count); } static DEVICE_ATTR(idle_count, 0444, show_idle_count, NULL);
@@ -947,7 +947,7 @@ static ssize_t show_idle_time(struct dev idle_time =ACCESS_ONCE (idle->idle_time); idle_enter =ACCESS_ONCE (idle->clock_idle_enter); idle_exit =ACCESS_ONCE (idle->clock_idle_exit); - }while ((sequence &1 ) || (idle->sequence != sequence)); + }while ((sequence &1 ) || (ACCESS_ONCE (idle->sequence) != sequence)); idle_time += idle_enter ? ((idle_exit ? : now) - idle_enter) :0 ;return sprintf (buf,"%llu\n" , idle_time >>12 ); }
arch/s390/kernel/vtime.c +1 -1
@@ -191,7 +191,7 @@ cputime64_t s390_get_idle_time(int cpu) sequence =ACCESS_ONCE (idle->sequence); idle_enter =ACCESS_ONCE (idle->clock_idle_enter); idle_exit =ACCESS_ONCE (idle->clock_idle_exit); - }while ((sequence &1 ) || (idle->sequence != sequence)); + }while ((sequence &1 ) || (ACCESS_ONCE (idle->sequence) != sequence));return idle_enter ? ((idle_exit ?: now) - idle_enter) :0 ; }
Greg Kroah-Hartman
maintainerPATCH 113/116 configfs: fix race between dentry put and lookup
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junxiao Bi <[email protected]>
commit 76ae281f6307331aa063288edb6422ae99f435f0 upstream.
A race window in configfs, it starts from one dentry is UNHASHED and end before configfs_d_iput is called. In this window, if a lookup happen, since the original dentry was UNHASHED, so a new dentry will be allocated, and then in configfs_attach_attr(), sd->s_dentry will be updated to the new dentry. Then in configfs_d_iput(), BUG_ON(sd->s_dentry != dentry) will be triggered and system panic.
sys_open: sys_close:
... fput
dput
dentry_kill
__d_drop <--- dentry unhashed here,
but sd->dentry still point to this dentry.
lookup_real
configfs_lookup
configfs_attach_attr---> update sd->s_dentry
to new allocated dentry here.
d_kill
configfs_d_iput <--- BUG_ON(sd->s_dentry != dentry)
triggered here.
To fix it, change configfs_d_iput to not update sd->s_dentry if sd->s_count > 2, that means there are another dentry is using the sd beside the one that is going to be put. Use configfs_dirent_lock in configfs_attach_attr to sync with configfs_d_iput.
With the following steps, you can reproduce the bug.
1. enable ocfs2, this will mount configfs at /sys/kernel/config and fill configure in it.
2. run the following script.
while [ 1 ]; do cat /sys/kernel/config/cluster/$your_cluster_name/idle_timeout_ms > /dev/null; done & while [ 1 ]; do cat /sys/kernel/config/cluster/$your_cluster_name/idle_timeout_ms > /dev/null; done &
--- fs/configfs/dir.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
fs/configfs/dir.c +14 -2
@@ -56,10 +56,19 @@ static void configfs_d_iput(struct dentrstruct configfs_dirent *sd = dentry->d_fsdata;if (sd) { -BUG_ON (sd->s_dentry != dentry);/* Coordinate with configfs_readdir */ spin_lock (&configfs_dirent_lock); - sd->s_dentry =NULL ; +/* Coordinate with configfs_attach_attr where will increase +* sd->s_count and update sd->s_dentry to new allocated one. +* Only set sd->dentry to null when this dentry is the only +* sd owner. +* If not do so, configfs_d_iput may run just after +* configfs_attach_attr and set sd->s_dentry to null +* even it's still in use. +*/ +if (atomic_read (&sd->s_count) <=2 ) + sd->s_dentry =NULL ; +spin_unlock (&configfs_dirent_lock);configfs_put (sd); }
@@ -426,8 +435,11 @@ static int configfs_attach_attr(struct cstruct configfs_attribute * attr = sd->s_element;int error; +spin_lock (&configfs_dirent_lock); dentry->d_fsdata =configfs_get (sd); sd->s_dentry = dentry; +spin_unlock (&configfs_dirent_lock); + error =configfs_create (dentry, (attr->ca_mode &S_IALLUGO ) |S_IFREG , configfs_init_file);if (error) {
Greg Kroah-Hartman
maintainerPATCH 114/116 GFS2: d_splice_alias() cant return error
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <[email protected]>
commit 0d0d110720d7960b77c03c9f2597faaff4b484ae upstream.
unless it was given an IS_ERR(inode), which isn't the case here. So clean up the unnecessary error handling in gfs2_create_inode().
This paves the way for real fixes (hence the stable Cc).
--- fs/gfs2/inode.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/gfs2/inode.c +1 -3
@@ -584,7 +584,7 @@ static int gfs2_create_inode(struct inodif (!IS_ERR (inode)) { d =d_splice_alias (inode, dentry); error =0 ; -if (file && !IS_ERR (d)) { +if (file) {if (d ==NULL ) d = dentry;if (S_ISREG (inode->i_mode))
@@ -593,8 +593,6 @@ static int gfs2_create_inode(struct inod error =finish_no_open (file, d); }gfs2_glock_dq_uninit (ghs); -if (IS_ERR (d)) -return PTR_ERR (d);return error; }else if (error != -ENOENT ) { goto fail_gunlock;
Greg Kroah-Hartman
maintainerPATCH 115/116 GFS2: fix dentry leaks
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <[email protected]>
commit 5ca1db41ecdeb0358b968265fadb755213558a85 upstream.
We need to dput() the result of d_splice_alias(), unless it is passed to finish_no_open().
Edited by Steven Whitehouse in order to make it apply to the current GFS2 git tree, and taking account of a prerequisite patch which hasn't been applied.
--- fs/gfs2/inode.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
fs/gfs2/inode.c +16 -10
@@ -585,12 +585,14 @@ static int gfs2_create_inode(struct inod d =d_splice_alias (inode, dentry); error =0 ;if (file) { -if (d ==NULL ) - d = dentry; -if (S_ISREG (inode->i_mode)) - error =finish_open (file, d, gfs2_open_common, opened); -else +if (S_ISREG (inode->i_mode)) { +WARN_ON (d !=NULL ); + error =finish_open (file, dentry, gfs2_open_common, opened); + }else { error =finish_no_open (file, d); + } + }else { +dput (d); }gfs2_glock_dq_uninit (ghs);return error;
@@ -779,8 +781,10 @@ static struct dentry *__gfs2_lookup(stru error =finish_open (file, dentry, gfs2_open_common, opened);gfs2_glock_dq_uninit (&gh); -if (error) +if (error) { +dput (d);return ERR_PTR (error); + }return d; }
@@ -1161,14 +1165,16 @@ static int gfs2_atomic_open(struct inode d =__gfs2_lookup (dir, dentry, file, opened);if (IS_ERR (d))return PTR_ERR (d); -if (d ==NULL ) - d = dentry; -if (d->d_inode) { +if (d !=NULL ) + dentry = d; +if (dentry->d_inode) {if (!(*opened &FILE_OPENED )) -return finish_no_open (file, d); +return finish_no_open (file, dentry); +dput (d);return 0 ; } +BUG_ON (d !=NULL );if (!(flags &O_CREAT ))return -ENOENT ;
Greg Kroah-Hartman
maintainerPATCH 116/116 cris: media platform drivers: fix build
In reply to Greg Kroah-Hartman3.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit 72a0c5571351f5184195754d23db3e14495b2080 upstream.
On cris arch, the functions below aren't defined:
drivers/media/platform/sh_veu.c: In function 'sh_veu_reg_read':
drivers/media/platform/sh_veu.c:228:2: error: implicit declaration of function 'ioread32' [-Werror=implicit-function-declaration] drivers/media/platform/sh_veu.c: In function 'sh_veu_reg_write':
drivers/media/platform/sh_veu.c:234:2: error: implicit declaration of function 'iowrite32' [-Werror=implicit-function-declaration] drivers/media/platform/vsp1/vsp1.h: In function 'vsp1_read':
drivers/media/platform/vsp1/vsp1.h:66:2: error: implicit declaration of function 'ioread32' [-Werror=implicit-function-declaration] drivers/media/platform/vsp1/vsp1.h: In function 'vsp1_write':
drivers/media/platform/vsp1/vsp1.h:71:2: error: implicit declaration of function 'iowrite32' [-Werror=implicit-function-declaration] drivers/media/platform/vsp1/vsp1.h: In function 'vsp1_read':
drivers/media/platform/vsp1/vsp1.h:66:2: error: implicit declaration of function 'ioread32' [-Werror=implicit-function-declaration] drivers/media/platform/vsp1/vsp1.h: In function 'vsp1_write':
drivers/media/platform/vsp1/vsp1.h:71:2: error: implicit declaration of function 'iowrite32' [-Werror=implicit-function-declaration] drivers/media/platform/soc_camera/rcar_vin.c: In function 'rcar_vin_setup':
drivers/media/platform/soc_camera/rcar_vin.c:284:3: error: implicit declaration of function 'iowrite32' [-Werror=implicit-function-declaration]
drivers/media/platform/soc_camera/rcar_vin.c: In function 'rcar_vin_request_capture_stop':
drivers/media/platform/soc_camera/rcar_vin.c:353:2: error: implicit declaration of function 'ioread32' [-Werror=implicit-function-declaration]
Yet, they're available, as CONFIG_GENERIC_IOMAP is defined. What happens is that asm/io.h was not including asm-generic/iomap.h.
--- arch/cris/include/asm/io.h | 1 + 1 file changed, 1 insertion(+)
arch/cris/include/asm/io.h +1 -0
@@ -3,6 +3,7 @@#include <asm/page.h> /* for __va, __pa */ #include <arch/io.h> +#include <asm-generic/iomap.h> #include <linux/kernel.h> struct cris_io_operations
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.12.2 release. There are 116 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri Nov 29 00:57:18 UTC 2013. Anything received after that time might be too late.
Build results:
total: 110 pass: 107 skipped: 3 fail: 0
qemu tests all passed.
Perfect results.
Thanks,
Guenter
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.12.2 release. There are 116 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri Nov 29 00:57:18 UTC 2013. Anything received after that time might be too late.
Quoted 7 lines
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.12.2-rc1.gzand the diffstat can be found below.
thanks,
greg k-h
Patch applied cleanly
Compile testing - passed
Boot testing - passed
dmesg regression testing - passed
Cross-compile testing - didn't test this time.
dmesgs look good. No regressions compared to the previous dmesgs for this release. dmesg emerg, crit, alert, err are clean. No regressions in warn.
HP ProBook 6475b AMD A10-4600M APU with Radeon(tm) HD Graphics Dell OptiPlex 790 Intel(R) Core(TM) i5-2400
-- Shuah
Signature · 4 lines
Shuah Khan Senior Linux Kernel Developer - Open Source Group Samsung Research America(Silicon Valley) [email protected] | (970) 672-0658
At Tue, 26 Nov 2013 16:56:13 -0800,
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.12.2 release. There are 116 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri Nov 29 00:57:18 UTC 2013. Anything received after that time might be too late.
This kernel can be built and boot without any problem. Building a kernel with this kernel also works fine.
- Build Machine: debian jessy x86_64
CPU: Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz x 4
memory: 8GB
- Test machine: debian jessy x86_64(KVM guest on the Build Machine)
vCPU: x2
memory: 2GB
Thanks,
Satoru