3.16.2-stable review
Subsystems (2)
Greg Kroah-Hartman
maintainercover 3.16.2-stable review
--------------------------
Note, there are a _lot_ of patches submitted for stable kernels that have yet to be applied, well over 200+ at the moment. Given that this series is already over 100 patches, I figured it was a good as a time as any to push this out. Don't worry, if you have emailed/marked patches to be included, and they aren't here, wait a few more releases for me to catch up, thanks.
--------------------------
This is the start of the stable review cycle for the 3.16.2 release. There are 125 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 Sep 5 22:06:09 UTC 2014. 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.16.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.16.2-rc1
Oleg Nesterov <[email protected]>
vm_is_stack: use for_each_thread() rather then buggy while_each_thread()
Trond Myklebust <[email protected]>
NFSv4: Fix problems with close in the presence of a delegation
Trond Myklebust <[email protected]>
NFSv4: Don't clear the open state when we just did an OPEN_DOWNGRADE
Trond Myklebust <[email protected]>
NFSv3: Fix another acl regression
Chuck Lever <[email protected]>
svcrdma: Select NFSv4.1 backchannel transport based on forward channel
Scott Mayhew <[email protected]>
nfs: reject changes to resvport and sharecache during remount
Andrey Utkin <[email protected]>
nfs3_list_one_acl(): check get_acl() result with IS_ERR_OR_NULL
Eric W. Biederman <[email protected]>
NFS: Fix /proc/fs/nfsfs/servers and /proc/fs/nfsfs/volumes
Kinglong Mee <[email protected]>
NFSD: Decrease nfsd_users in nfsd_startup_generic fail
Takashi Iwai <[email protected]>
usbcore: Fix wrong device in an error message in hub_port_connect()
Roger Quadros <[email protected]>
usb: hub: Prevent hub autosuspend if usbcore.autosuspend is -1
Peter Chen <[email protected]>
usb: ehci: using wIndex + 1 for hub port
James Forshaw <[email protected]>
USB: whiteheat: Added bounds checking for bulk command response
Jaša Bartelj <[email protected]>
USB: ftdi_sio: Added PID for new ekey device
Johan Hovold <[email protected]>
USB: ftdi_sio: add Basic Micro ATOM Nano USB2Serial PID
Tony Lindgren <[email protected]>
ARM: OMAP2+: hwmod: Rearm wake-up interrupts for DT when MUSB is idled
Hans de Goede <[email protected]>
xhci: Disable streams on Via XHCI with device-id 0x3432
Mathias Nyman <[email protected]>
xhci: rework cycle bit checking for new dequeue pointers
Huang Rui <[email protected]>
usb: xhci: amd chipset also needs short TX quirk
Hans de Goede <[email protected]>
xhci: Treat not finding the event_seg on COMP_STOP the same as COMP_STOP_INVAL
Larry Finger <[email protected]>
staging: r8188eu: Add new USB ID
Holger Paradies <[email protected]>
staging/rtl8188eu: add 0df6:0076 Sitecom Europe B.V.
Mark Einon <[email protected]>
staging: et131x: Fix errors caused by phydev->addr accesses before initialisation
Pranith Kumar <[email protected]>
staging: lustre: Remove circular dependency on header
Darrick J. Wong <[email protected]>
jbd2: fix descriptor block size handling errors with journal_csum
Darrick J. Wong <[email protected]>
jbd2: fix infinite loop when recovering corrupt journal blocks
Darrick J. Wong <[email protected]>
ext4: fix same-dir rename when inline data directory overflows
Dmitry Monakhov <[email protected]>
ext4: update i_disksize coherently with block allocation on error path
Dmitry Monakhov <[email protected]>
ext4: fix transaction issues for ext4_fallocate and ext_zero_range
Dmitry Monakhov <[email protected]>
ext4: fix incorect journal credits reservation in ext4_zero_range
Dmitry Monakhov <[email protected]>
ext4: move i_size,i_disksize update routines to helper function
Theodore Ts'o <[email protected]>
ext4: propagate errors up to ext4_find_entry()'s callers
Alexander Usyskin <[email protected]>
mei: nfc: fix memory leak in error path
Alexander Usyskin <[email protected]>
mei: reset client state on queued connect request
Liu Bo <[email protected]>
Btrfs: fix task hang under heavy compressed write
Chris Mason <[email protected]>
Btrfs: fix filemap_flush call in btrfs_file_release
Liu Bo <[email protected]>
Btrfs: fix crash on endio of reading corrupted block
Chris Mason <[email protected]>
btrfs: disable strict file flushes for renames and truncates
Liu Bo <[email protected]>
Btrfs: fix compressed write corruption on enospc
Filipe Manana <[email protected]>
Btrfs: read lock extent buffer while walking backrefs
Filipe Manana <[email protected]>
Btrfs: fix csum tree corruption, duplicate and outdated checksums
Takashi Iwai <[email protected]>
Btrfs: Fix memory corruption by ulist_add_merge() on 32bit arch
Stephen M. Cameron <[email protected]>
hpsa: fix bad -ENOMEM return value in hpsa_big_passthru_ioctl
Hugh Dickins <[email protected]>
x86,mm: fix pte_special versus pte_numa
David Vrabel <[email protected]>
x86/xen: resume timer irqs early
David Vrabel <[email protected]>
x86/xen: use vmap() to map grant table pages in PVH guests
Matt Fleming <[email protected]>
x86/efi: Enforce CONFIG_RELOCATABLE for EFI boot stub
David Vrabel <[email protected]>
xen/events/fifo: ensure all bitops are properly aligned even on x86
Thomas Gleixner <[email protected]>
x86: MCE: Add raw_lock conversion again
Arnd Bergmann <[email protected]>
hpsa: fix non-x86 builds
Andy Lutomirski <[email protected]>
x86_64/vsyscall: Fix warn_bad_vsyscall log output
Brian W Hart <[email protected]>
powerpc/powernv: Update dev->dma_mask in pci_set_dma_mask() path
Tyrel Datwyler <[email protected]>
powerpc/pci: Reorder pci bus/bridge unregistration during PHB removal
Mike Qiu <[email protected]>
powerpc/eeh: Wrong place to call pci_get_slot()
Christoph Schulz <[email protected]>
x86: don't exclude low BIOS area when allocating address space for non-PCI cards
Simone Gotti <[email protected]>
ACPI / PCI: Fix sysfs acpi_index and label errors
Myron Stowe <[email protected]>
PCI: pciehp: Clear Data Link Layer State Changed during init
Guo Chao <[email protected]>
PCI: Keep original resource if we fail to expand it
Vidya Sagar <[email protected]>
PCI: Configure ASPM when enabling device
Alex Deucher <[email protected]>
drm/radeon: add additional SI pci ids
Alex Deucher <[email protected]>
drm/radeon: add new bonaire pci ids
Alex Deucher <[email protected]>
drm/radeon: add new KV pci id
Theodore Ts'o <[email protected]>
ext4: fix BUG_ON in mb_free_blocks()
Michael S. Tsirkin <[email protected]>
kvm: iommu: fix the third parameter of kvm_iommu_put_pages (CVE-2014-3601)
Paolo Bonzini <[email protected]>
Revert "KVM: x86: Increase the number of fixed MTRR regs to 10"
Wanpeng Li <[email protected]>
KVM: nVMX: fix "acknowledge interrupt on exit" when APICv is in use
Alexey Kardashevskiy <[email protected]>
KVM: PPC: Book3S: Fix LPCR one_reg interface
Christian Borntraeger <[email protected]>
KVM: s390/mm: Fix page table locking vs. split pmd lock
Paolo Bonzini <[email protected]>
KVM: x86: always exit on EOIs for interrupts listed in the IOAPIC redir table
Nadav Amit <[email protected]>
KVM: x86: Inter-privilege level ret emulation is not implemeneted
Steven Rostedt <[email protected]>
debugfs: Fix corrupted loop in debugfs_remove_recursive
Arnd Bergmann <[email protected]>
crypto: ux500 - make interrupt mode plausible
Peter Hurley <[email protected]>
serial: core: Preserve termios c_cflag for console resume
Theodore Ts'o <[email protected]>
ext4: fix ext4_discard_allocated_blocks() if we can't allocate the pa struct
Lukas Czerner <[email protected]>
ext4: fix punch hole on files with indirect mapping
addy ke <[email protected]>
i2c: rk3x: fix interrupt handling issue
Wolfram Sang <[email protected]>
drivers/i2c/busses: use correct type for dma_map/unmap
Jason Gunthorpe <[email protected]>
tpm: Add missing tpm_do_selftest to ST33 I2C driver
Axel Lin <[email protected]>
hwmon: (lm92) Prevent overflow problem when writing large limits
Axel Lin <[email protected]>
hwmon: (dme1737) Prevent overflow problem when writing large limits
Axel Lin <[email protected]>
hwmon: (ads1015) Fix out-of-bounds array access
Guenter Roeck <[email protected]>
hwmon: (lm85) Fix various errors on attribute writes
Axel Lin <[email protected]>
hwmon: (ads1015) Fix off-by-one for valid channel index checking
Axel Lin <[email protected]>
hwmon: (gpio-fan) Prevent overflow problem when writing large limits
Guenter Roeck <[email protected]>
hwmon: (lm78) Fix overflow problems seen when writing large temperature limits
Axel Lin <[email protected]>
hwmon: (amc6821) Fix possible race condition bug
Axel Lin <[email protected]>
hwmon: (sis5595) Prevent overflow problem when writing large limits
Ulf Hansson <[email protected]>
mmc: mmci: Move all CMD irq handling to mmci_cmd_irq()
Ulf Hansson <[email protected]>
mmc: mmci: Remove redundant check of status for DATA irq
Russell King <[email protected]>
drm: omapdrm: fix compiler errors
Jeremy Vial <[email protected]>
ARM: OMAP3: Fix choice of omap3_restore_es function in OMAP34XX rev3.1.2 case.
Baruch Siach <[email protected]>
ARM: 8097/1: unistd.h: relocate comments back to place
Suman Anna <[email protected]>
ARM: dts: AM4372: Correct mailbox node data
Semen Protsenko <[email protected]>
efi/arm64: Store Runtime Services revision
Will Deacon <[email protected]>
arm64: don't call break hooks for BRK exceptions from EL0
Catalin Marinas <[email protected]>
arm64: Fix barriers used for page table modifications
Daniel Bristot de Oliveira <[email protected]>
sched: Fix sched_setparam() policy == -1 logic
Hans de Goede <[email protected]>
xhci: Blacklist using streams on the Etron EJ168 controller
Alexander Usyskin <[email protected]>
mei: fix return value on disconnect timeout
Alexander Usyskin <[email protected]>
mei: don't schedule suspend in pm idle
Alexander Usyskin <[email protected]>
mei: start disconnect request timer consistently
Alexander Usyskin <[email protected]>
mei: reset client connection state on timeout
Takashi Iwai <[email protected]>
ALSA: hda/realtek - Avoid setting wrong COEF on ALC269 & co
Hui Wang <[email protected]>
ALSA: hda - restore the gpio led after resume
David Henningsson <[email protected]>
ALSA: hda - Add mute LED pin quirk for HP 15 touchsmart
Clemens Ladisch <[email protected]>
ALSA: usb-audio: fix BOSS ME-25 MIDI regression
Takashi Iwai <[email protected]>
ALSA: hda/ca0132 - Don't try loading firmware at resume when already failed
Clemens Ladisch <[email protected]>
ALSA: virtuoso: add Xonar Essence STX II support
Paul S McSpadden <[email protected]>
ALSA: usb-audio: Adjust Gamecom 780 volume level
Hui Wang <[email protected]>
ALSA: hda - fix an external mic jack problem on a HP machine
Pratyush Anand <[email protected]>
USB: Fix persist resume of some SS USB devices
Bryan O'Donoghue <[email protected]>
USB: ehci-pci: USB host controller support for Intel Quark X1000
Patrick Riphagen <[email protected]>
USB: serial: ftdi_sio: Add support for new Xsens devices
Patrick Riphagen <[email protected]>
USB: serial: ftdi_sio: Annotate the current Xsens PID assignments
Oliver Neukum <[email protected]>
USB: devio: fix issue with log flooding
Oliver Neukum <[email protected]>
usbcore: don't log on consecutive debounce failures of the same port
Alan Stern <[email protected]>
USB: OHCI: don't lose track of EDs when a controller dies
Alan Stern <[email protected]>
USB: OHCI: fix bugs in debug routines
Hans de Goede <[email protected]>
uas: Limit qdepth to 32 when connected over usb-2
Jan Kara <[email protected]>
isofs: Fix unbounded recursion when processing relocated directories
Jiri Kosina <[email protected]>
HID: fix a couple of off-by-ones
Jiri Kosina <[email protected]>
HID: logitech: perform bounds checking on device_id early enough
Jiri Kosina <[email protected]>
HID: logitech: fix bounds checking on LED report size
Rob Kendrick <[email protected]>
MIPS: math-emu: Fix instruction decoding.
Dave Chiluk <[email protected]>
stable_kernel_rules: Add pointer to netdev-FAQ for network patches
-------------
Diffstat:
Documentation/sound/alsa/ALSA-Configuration.txt | 4 +- Documentation/stable_kernel_rules.txt | 3 + Documentation/virtual/kvm/api.txt | 3 +- Makefile | 4 +- arch/arm/boot/dts/am4372.dtsi | 3 - arch/arm/include/asm/unistd.h | 10 + arch/arm/include/uapi/asm/unistd.h | 11 - arch/arm/mach-omap2/control.c | 3 +- arch/arm/mach-omap2/omap_hwmod.c | 4 + arch/arm64/include/asm/cacheflush.h | 11 +- arch/arm64/include/asm/pgtable.h | 13 + arch/arm64/include/asm/tlbflush.h | 5 +- arch/arm64/kernel/debug-monitors.c | 22 +- arch/arm64/kernel/efi.c | 2 + arch/mips/math-emu/cp1emu.c | 2 +- arch/powerpc/include/uapi/asm/kvm.h | 1 + arch/powerpc/kernel/eeh_pe.c | 46 +--- arch/powerpc/kvm/book3s_hv.c | 13 +- arch/powerpc/kvm/book3s_pr.c | 2 + arch/powerpc/platforms/powernv/pci-ioda.c | 1 + arch/powerpc/platforms/pseries/pci_dlpar.c | 4 +- arch/s390/mm/pgtable.c | 5 +- arch/x86/Kconfig | 1 + arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/include/asm/pgtable.h | 9 +- arch/x86/kernel/cpu/mcheck/mce_intel.c | 18 +- arch/x86/kernel/resource.c | 8 +- arch/x86/kernel/vsyscall_64.c | 8 +- arch/x86/kvm/emulate.c | 4 + arch/x86/kvm/irq.c | 2 +- arch/x86/kvm/lapic.c | 52 +++- arch/x86/pci/i386.c | 4 + arch/x86/xen/grant-table.c | 10 +- arch/x86/xen/time.c | 2 +- drivers/char/tpm/tpm_i2c_stm_st33.c | 1 + drivers/crypto/ux500/cryp/cryp_core.c | 25 +- drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 6 +- drivers/gpu/drm/omapdrm/omap_gem.c | 10 +- drivers/gpu/drm/omapdrm/omap_plane.c | 4 +- drivers/gpu/drm/radeon/cik.c | 1 + drivers/hid/hid-cherry.c | 2 +- drivers/hid/hid-kye.c | 2 +- drivers/hid/hid-lg.c | 4 +- drivers/hid/hid-logitech-dj.c | 15 +- drivers/hid/hid-monterey.c | 2 +- drivers/hid/hid-petalynx.c | 2 +- drivers/hid/hid-sunplus.c | 2 +- drivers/hwmon/ads1015.c | 4 +- drivers/hwmon/amc6821.c | 17 +- drivers/hwmon/dme1737.c | 33 +-- drivers/hwmon/gpio-fan.c | 2 +- drivers/hwmon/lm78.c | 2 +- drivers/hwmon/lm85.c | 9 +- drivers/hwmon/lm92.c | 13 +- drivers/hwmon/sis5595.c | 2 +- drivers/i2c/busses/i2c-at91.c | 4 +- drivers/i2c/busses/i2c-rk3x.c | 2 +- drivers/misc/mei/client.c | 18 +- drivers/misc/mei/nfc.c | 11 +- drivers/misc/mei/pci-me.c | 2 +- drivers/misc/mei/pci-txe.c | 2 +- drivers/mmc/host/mmci.c | 33 +-- drivers/pci/hotplug/pciehp_hpc.c | 2 +- drivers/pci/pci-label.c | 18 +- drivers/pci/pci.c | 12 +- drivers/pci/setup-res.c | 7 + drivers/scsi/hpsa.c | 6 +- drivers/staging/et131x/et131x.c | 68 ++--- drivers/staging/lustre/lustre/obdclass/class_obd.c | 2 +- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 2 + drivers/tty/serial/serial_core.c | 3 + drivers/usb/core/devio.c | 2 +- drivers/usb/core/hub.c | 56 +++- drivers/usb/host/ehci-hub.c | 2 +- drivers/usb/host/ehci-pci.c | 25 ++ drivers/usb/host/ohci-dbg.c | 9 +- drivers/usb/host/ohci-hcd.c | 10 +- drivers/usb/host/ohci-q.c | 46 ++-- drivers/usb/host/xhci-pci.c | 13 +- drivers/usb/host/xhci-ring.c | 104 +++----- drivers/usb/host/xhci.c | 6 +- drivers/usb/host/xhci.h | 2 + drivers/usb/serial/ftdi_sio.c | 5 + drivers/usb/serial/ftdi_sio_ids.h | 20 +- drivers/usb/serial/whiteheat.c | 7 +- drivers/usb/storage/uas.c | 2 +- drivers/xen/events/events_fifo.c | 5 +- fs/btrfs/async-thread.c | 44 +++- fs/btrfs/async-thread.h | 28 +- fs/btrfs/backref.c | 14 +- fs/btrfs/btrfs_inode.h | 6 - fs/btrfs/delayed-inode.c | 4 +- fs/btrfs/disk-io.c | 85 +++---- fs/btrfs/extent-tree.c | 7 +- fs/btrfs/extent_io.c | 1 + fs/btrfs/file-item.c | 2 +- fs/btrfs/file.c | 22 +- fs/btrfs/inode.c | 94 +++---- fs/btrfs/ordered-data.c | 124 +-------- fs/btrfs/ordered-data.h | 5 - fs/btrfs/qgroup.c | 1 + fs/btrfs/raid56.c | 9 +- fs/btrfs/reada.c | 3 +- fs/btrfs/scrub.c | 14 +- fs/btrfs/transaction.c | 33 +-- fs/btrfs/transaction.h | 1 - fs/btrfs/ulist.h | 15 ++ fs/btrfs/volumes.c | 3 +- fs/debugfs/inode.c | 33 ++- fs/ext4/ext4.h | 22 +- fs/ext4/extents.c | 88 +++---- fs/ext4/indirect.c | 281 +++++++++++++++------ fs/ext4/inode.c | 46 ++-- fs/ext4/mballoc.c | 26 +- fs/ext4/namei.c | 56 +++- fs/ext4/super.c | 5 +- fs/isofs/inode.c | 15 +- fs/isofs/isofs.h | 23 +- fs/isofs/rock.c | 39 ++- fs/jbd2/commit.c | 21 +- fs/jbd2/journal.c | 56 ++-- fs/jbd2/recovery.c | 33 ++- fs/jbd2/revoke.c | 6 +- fs/nfs/client.c | 95 ++++--- fs/nfs/inode.c | 3 +- fs/nfs/internal.h | 9 + fs/nfs/netns.h | 3 + fs/nfs/nfs3acl.c | 7 +- fs/nfs/nfs4proc.c | 26 +- fs/nfs/super.c | 9 +- fs/nfsd/nfs4callback.c | 3 +- fs/nfsd/nfssvc.c | 5 +- include/drm/drm_pciids.h | 7 + include/linux/jbd2.h | 30 ++- include/linux/sunrpc/svc_xprt.h | 1 + kernel/sched/core.c | 5 +- mm/memory.c | 7 +- mm/util.c | 9 +- net/sunrpc/svcsock.c | 2 + net/sunrpc/xprt.c | 2 +- net/sunrpc/xprtrdma/svc_rdma_transport.c | 1 + sound/pci/Kconfig | 4 +- sound/pci/hda/patch_ca0132.c | 7 +- sound/pci/hda/patch_realtek.c | 28 +- sound/pci/hda/patch_sigmatel.c | 12 + sound/pci/oxygen/virtuoso.c | 1 + sound/pci/oxygen/xonar_pcm179x.c | 12 +- sound/usb/quirks-table.h | 29 +++ sound/usb/quirks.c | 2 +- virt/kvm/ioapic.c | 7 +- virt/kvm/iommu.c | 19 +- 151 files changed, 1505 insertions(+), 1061 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/125 stable_kernel_rules: Add pointer to netdev-FAQ for network patches
3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Chiluk <[email protected]>
commit b76fc285337b6b256e9ba20a40cfd043f70c27af upstream.
Stable_kernel_rules should point submitters of network stable patches to the netdev_FAQ.txt as requests for stable network patches should go to netdev first.
--- Documentation/stable_kernel_rules.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/stable_kernel_rules.txt +3 -0
@@ -29,6 +29,9 @@ Rules on what kind of patches are accept Procedure for submitting patches to the -stable tree: + - If the patch covers files in net/ or drivers/net please follow netdev stable + submission guidelines as described in + Documentation/networking/netdev-FAQ.txt - Send the patch, after verifying that it follows the above rules, to [email protected]. You must note the upstream commit ID in the changelog of your submission, as well as the kernel version you wish
Greg Kroah-Hartman
maintainerPATCH 2/125 MIPS: math-emu: Fix instruction decoding.
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Kendrick <[email protected]>
commit c3b9b945e02e011c63522761e91133ea43eb6939 upstream.
--- arch/mips/math-emu/cp1emu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/math-emu/cp1emu.c +1 -1
@@ -1827,7 +1827,7 @@ dcopuop:case -1 :if (cpu_has_mips_4_5_r) - cbit = fpucondbit[MIPSInst_RT (ir) >>2 ]; + cbit = fpucondbit[MIPSInst_FD (ir) >>2 ];else cbit =FPU_CSR_COND ;if (rv.w)
Greg Kroah-Hartman
maintainerPATCH 3/125 HID: logitech: fix bounds checking on LED report size
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Kosina <[email protected]>
commit 51217e69697fba92a06e07e16f55c9a52d8e8945 upstream.
The check on report size for REPORT_TYPE_LEDS in logi_dj_ll_raw_request() is wrong; the current check doesn't make any sense -- the report allocated by HID core in hid_hw_raw_request() can be much larger than DJREPORT_SHORT_LENGTH, and currently logi_dj_ll_raw_request() doesn't handle this properly at all.
Fix the check by actually trimming down the report size properly if it is too large.
--- drivers/hid/hid-logitech-dj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-logitech-dj.c +1 -1
@@ -557,7 +557,7 @@ static int logi_dj_ll_raw_request(structif (!out_buf)return -ENOMEM ; -if (count <DJREPORT_SHORT_LENGTH -2 ) +if (count >DJREPORT_SHORT_LENGTH -2 ) count =DJREPORT_SHORT_LENGTH -2 ; out_buf[0 ] =REPORT_ID_DJ_SHORT ;
Greg Kroah-Hartman
maintainerPATCH 4/125 HID: logitech: perform bounds checking on device_id early enough
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Kosina <[email protected]>
commit ad3e14d7c5268c2e24477c6ef54bbdf88add5d36 upstream.
device_index is a char type and the size of paired_dj_deivces is 7 elements, therefore proper bounds checking has to be applied to device_index before it is used.
We are currently performing the bounds checking in logi_dj_recv_add_djhid_device(), which is too late, as malicious device could send REPORT_TYPE_NOTIF_DEVICE_UNPAIRED early enough and trigger the problem in one of the report forwarding functions called from logi_dj_raw_event().
Fix this by performing the check at the earliest possible ocasion in logi_dj_raw_event().
--- drivers/hid/hid-logitech-dj.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/hid/hid-logitech-dj.c +6 -7
@@ -238,13 +238,6 @@ static void logi_dj_recv_add_djhid_devicreturn ; } -if ((dj_report->device_index <DJ_DEVICE_INDEX_MIN ) || - (dj_report->device_index >DJ_DEVICE_INDEX_MAX )) { -dev_err (&djrcv_hdev->dev,"%s: invalid device index:%d\n" , - __func__, dj_report->device_index); -return ; - } -if (djrcv_dev->paired_dj_devices[dj_report->device_index]) {/* The device is already known. No need to reallocate it. */ dbg_hid ("%s: device is already known\n" , __func__);
@@ -690,6 +683,12 @@ static int logi_dj_raw_event(struct hid_* device (via hid_input_report() ) and return 1 so hid-core does not do * anything else with it. */ +if ((dj_report->device_index <DJ_DEVICE_INDEX_MIN ) || + (dj_report->device_index >DJ_DEVICE_INDEX_MAX )) { +dev_err (&hdev->dev,"%s: invalid device index:%d\n" , + __func__, dj_report->device_index); +return false; + }spin_lock_irqsave (&djrcv_dev->lock, flags);if (dj_report->report_id ==REPORT_ID_DJ_SHORT ) {
Greg Kroah-Hartman
maintainerPATCH 5/125 HID: fix a couple of off-by-ones
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Kosina <[email protected]>
commit 4ab25786c87eb20857bbb715c3ae34ec8fd6a214 upstream.
There are a few very theoretical off-by-one bugs in report descriptor size checking when performing a pre-parsing fixup. Fix those.
--- drivers/hid/hid-cherry.c | 2 +- drivers/hid/hid-kye.c | 2 +- drivers/hid/hid-lg.c | 4 ++-- drivers/hid/hid-monterey.c | 2 +- drivers/hid/hid-petalynx.c | 2 +- drivers/hid/hid-sunplus.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-)
drivers/hid/hid-cherry.c +1 -1
@@ -28,7 +28,7 @@static __u8 *ch_report_fixup (struct hid_device *hdev,__u8 *rdesc,unsigned int *rsize) { -if (*rsize >=17 && rdesc[11 ] ==0x3c && rdesc[12 ] ==0x02 ) { +if (*rsize >=18 && rdesc[11 ] ==0x3c && rdesc[12 ] ==0x02 ) {hid_info (hdev,"fixing up Cherry Cymotion report descriptor\n" ); rdesc[11 ] = rdesc[16 ] =0xff ; rdesc[12 ] = rdesc[17 ] =0x03 ;
drivers/hid/hid-kye.c +1 -1
@@ -300,7 +300,7 @@ static __u8 *kye_report_fixup(struct hid* - change the button usage range to 4-7 for the extra * buttons */ - if (*rsize >= 74 && + if (*rsize >= 75 && rdesc[61] == 0x05 && rdesc[62] == 0x08 && rdesc[63] == 0x19 && rdesc[64] == 0x08 && rdesc[65] == 0x29 && rdesc[66] == 0x0f &&
drivers/hid/hid-lg.c +2 -2
@@ -345,14 +345,14 @@ static __u8 *lg_report_fixup(struct hid_struct usb_device_descriptor *udesc;__u16 bcdDevice, rev_maj, rev_min; -if ((drv_data->quirks &LG_RDESC ) && *rsize >=90 && rdesc[83 ] ==0x26 && +if ((drv_data->quirks &LG_RDESC ) && *rsize >=91 && rdesc[83 ] ==0x26 && rdesc[84 ] ==0x8c && rdesc[85 ] ==0x02 ) {hid_info (hdev,"fixing up Logitech keyboard report descriptor\n" ); rdesc[84 ] = rdesc[89 ] =0x4d ; rdesc[85 ] = rdesc[90 ] =0x10 ; } -if ((drv_data->quirks &LG_RDESC_REL_ABS ) && *rsize >=50 && +if ((drv_data->quirks &LG_RDESC_REL_ABS ) && *rsize >=51 && rdesc[32 ] ==0x81 && rdesc[33 ] ==0x06 && rdesc[49 ] ==0x81 && rdesc[50 ] ==0x06 ) { hid_info(hdev,
drivers/hid/hid-monterey.c +1 -1
@@ -24,7 +24,7 @@static __u8 *mr_report_fixup (struct hid_device *hdev,__u8 *rdesc,unsigned int *rsize) { -if (*rsize >=30 && rdesc[29 ] ==0x05 && rdesc[30 ] ==0x09 ) { +if (*rsize >=31 && rdesc[29 ] ==0x05 && rdesc[30 ] ==0x09 ) {hid_info (hdev,"fixing up button/consumer in HID report descriptor\n" ); rdesc[30 ] =0x0c ; }
drivers/hid/hid-petalynx.c +1 -1
@@ -25,7 +25,7 @@static __u8 *pl_report_fixup (struct hid_device *hdev,__u8 *rdesc,unsigned int *rsize) { -if (*rsize >=60 && rdesc[39 ] ==0x2a && rdesc[40 ] ==0xf5 && +if (*rsize >=62 && rdesc[39 ] ==0x2a && rdesc[40 ] ==0xf5 && rdesc[41 ] ==0x00 && rdesc[59 ] ==0x26 && rdesc[60 ] ==0xf9 && rdesc[61 ] ==0x00 ) {hid_info (hdev,"fixing up Petalynx Maxter Remote report descriptor\n" );
drivers/hid/hid-sunplus.c +1 -1
@@ -24,7 +24,7 @@static __u8 *sp_report_fixup (struct hid_device *hdev,__u8 *rdesc,unsigned int *rsize) { -if (*rsize >=107 && rdesc[104 ] ==0x26 && rdesc[105 ] ==0x80 && +if (*rsize >=112 && rdesc[104 ] ==0x26 && rdesc[105 ] ==0x80 && rdesc[106 ] ==0x03 ) {hid_info (hdev,"fixing up Sunplus Wireless Desktop report descriptor\n" ); rdesc[105 ] = rdesc[110 ] =0x03 ;
Greg Kroah-Hartman
maintainerPATCH 6/125 isofs: Fix unbounded recursion when processing relocated directories
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 410dd3cf4c9b36f27ed4542ee18b1af5e68645a4 upstream.
We did not check relocated directory in any way when processing Rock Ridge 'CL' tag. Thus a corrupted isofs image can possibly have a CL entry pointing to another CL entry leading to possibly unbounded recursion in kernel code and thus stack overflow or deadlocks (if there is a loop created from CL entries).
Fix the problem by not allowing CL entry to point to a directory entry with CL entry (such use makes no good sense anyway) and by checking whether CL entry doesn't point to itself.
--- fs/isofs/inode.c | 15 ++++++++------- fs/isofs/isofs.h | 23 +++++++++++++++++++---- fs/isofs/rock.c | 39 ++++++++++++++++++++++++++++----------- 3 files changed, 55 insertions(+), 22 deletions(-)
fs/isofs/inode.c +8 -7
@@ -61,7 +61,7 @@ static void isofs_put_super(struct superreturn ; } -static int isofs_read_inode (struct inode *); +static int isofs_read_inode (struct inode *,int relocated);static int isofs_statfs (struct dentry *,struct kstatfs *);static struct kmem_cache *isofs_inode_cachep;
@@ -1259,7 +1259,7 @@ out_toomany: goto out; } -static int isofs_read_inode (struct inode *inode) +static int isofs_read_inode (struct inode *inode,int relocated) {struct super_block *sb = inode->i_sb;struct isofs_sb_info *sbi =ISOFS_SB (sb);
@@ -1404,7 +1404,7 @@ static int isofs_read_inode(struct inode*/ if (!high_sierra) { -parse_rock_ridge_inode (de, inode); +parse_rock_ridge_inode (de, inode, relocated);/* if we want uid/gid set, override the rock ridge setting */ if (sbi->s_uid_set) inode->i_uid = sbi->s_uid;
@@ -1483,9 +1483,10 @@ static int isofs_iget5_set(struct inode* offset that point to the underlying meta-data for the inode. The * code below is otherwise similar to the iget() code in * include/linux/fs.h */ -struct inode *isofs_iget (struct super_block *sb, -unsigned long block, -unsigned long offset) +struct inode *__isofs_iget (struct super_block *sb, +unsigned long block, +unsigned long offset, +int relocated) {unsigned long hashval;struct inode *inode;
@@ -1507,7 +1508,7 @@ struct inode *isofs_iget(struct super_blreturn ERR_PTR (-ENOMEM );if (inode->i_state &I_NEW ) { - ret =isofs_read_inode (inode); + ret =isofs_read_inode (inode, relocated);if (ret <0 ) {iget_failed (inode); inode =ERR_PTR (ret);
fs/isofs/isofs.h +19 -4
@@ -107,7 +107,7 @@ extern int iso_date(char *, int);struct inode ;/* To make gcc happy */ -extern int parse_rock_ridge_inode (struct iso_directory_record *,struct inode *); +extern int parse_rock_ridge_inode (struct iso_directory_record *,struct inode *,int relocated);extern int get_rock_ridge_filename (struct iso_directory_record *,char *,struct inode *);extern int isofs_name_translate (struct iso_directory_record *,char *,struct inode *);
@@ -118,9 +118,24 @@ extern struct dentry *isofs_lookup(strucextern struct buffer_head *isofs_bread (struct inode *,sector_t );extern int isofs_get_blocks (struct inode *,sector_t ,struct buffer_head **,unsigned long ); -extern struct inode *isofs_iget (struct super_block *sb, -unsigned long block, -unsigned long offset); +struct inode *__isofs_iget (struct super_block *sb, +unsigned long block, +unsigned long offset, +int relocated); + +static inline struct inode *isofs_iget (struct super_block *sb, +unsigned long block, +unsigned long offset) +{ +return __isofs_iget (sb, block, offset,0 ); +} + +static inline struct inode *isofs_iget_reloc (struct super_block *sb, +unsigned long block, +unsigned long offset) +{ +return __isofs_iget (sb, block, offset,1 ); +}/* Because the inode number is no longer relevant to finding the * underlying meta-data for an inode, we are free to choose a more
fs/isofs/rock.c +28 -11
@@ -288,12 +288,16 @@ eio: goto out; } +#define RR_REGARD_XA 1 +#define RR_RELOC_DE 2 +static int parse_rock_ridge_inode_internal (struct iso_directory_record *de, -struct inode *inode,int regard_xa) +struct inode *inode,int flags) {int symlink_len =0 ;int cnt, sig; +unsigned int reloc_block;struct inode *reloc;struct rock_ridge *rr;int rootflag;
@@ -305,7 +309,7 @@ parse_rock_ridge_inode_internal(struct iinit_rock_state (&rs, inode);setup_rock_ridge (de, inode, &rs); -if (regard_xa) { +if (flags &RR_REGARD_XA ) { rs.chr +=14 ; rs.len -=14 ;if (rs.len <0 )
@@ -485,12 +489,22 @@ repeat: "relocated directory\n"); goto out;case SIG ('C' ,'L' ): -ISOFS_I (inode)->i_first_extent = -isonum_733 (rr->u.CL.location); - reloc = -isofs_iget (inode->i_sb, -ISOFS_I (inode)->i_first_extent, -0 ); +if (flags &RR_RELOC_DE ) { +printk (KERN_ERR +"ISOFS: Recursive directory relocation " +"is not supported\n" ); + goto eio; + } + reloc_block =isonum_733 (rr->u.CL.location); +if (reloc_block ==ISOFS_I (inode)->i_iget5_block && +ISOFS_I (inode)->i_iget5_offset ==0 ) { +printk (KERN_ERR +"ISOFS: Directory relocation points to " +"itself\n" ); + goto eio; + } +ISOFS_I (inode)->i_first_extent = reloc_block; + reloc =isofs_iget_reloc (inode->i_sb, reloc_block,0 );if (IS_ERR (reloc)) { ret =PTR_ERR (reloc); goto out;
@@ -637,9 +651,11 @@ static char *get_symlink_chunk(char *rpnreturn rpnt; } -int parse_rock_ridge_inode (struct iso_directory_record *de,struct inode *inode) +int parse_rock_ridge_inode (struct iso_directory_record *de,struct inode *inode, +int relocated) { -int result =parse_rock_ridge_inode_internal (de, inode,0 ); +int flags = relocated ?RR_RELOC_DE :0 ; +int result =parse_rock_ridge_inode_internal (de, inode, flags);/* * if rockridge flag was reset and we didn't look for attributes
@@ -647,7 +663,8 @@ int parse_rock_ridge_inode(struct iso_di*/ if ((ISOFS_SB (inode->i_sb)->s_rock_offset ==-1 ) && (ISOFS_SB (inode->i_sb)->s_rock ==2 )) { - result =parse_rock_ridge_inode_internal (de, inode,14 ); + result =parse_rock_ridge_inode_internal (de, inode, + flags |RR_REGARD_XA ); }return result; }
Greg Kroah-Hartman
maintainerPATCH 7/125 uas: Limit qdepth to 32 when connected over usb-2
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit e2875c33787ebda21aeecc1a9d3ff52b3aa413ec upstream.
Some jmicron uas chipsets act up (they disconnect from the bus) when sending more then 32 commands to them at once.
Rather then building an ever growing list with usb-id based quirks for devices using this chipset, simply reduce the qdepth to 32 when connected over usb-2. 32 should be plenty to keep things close to maximum possible throughput on usb-2.
--- drivers/usb/storage/uas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/storage/uas.c +1 -1
@@ -1026,7 +1026,7 @@ static int uas_configure_endpoints(struc usb_endpoint_num(&eps[3]->desc));if (udev->speed !=USB_SPEED_SUPER ) { - devinfo->qdepth =256 ; + devinfo->qdepth =32 ; devinfo->use_streams =0 ; }else { devinfo->qdepth = usb_alloc_streams(devinfo->intf, eps + 1,
Greg Kroah-Hartman
maintainerPATCH 8/125 USB: OHCI: fix bugs in debug routines
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 256dbcd80f1ccf8abf421c1d72ba79a4e29941dd upstream.
The debug routine fill_async_buffer() in ohci-hcd is buggy: It never produces any output because it forgets to initialize the output buffer size. Also, the debug routine ohci_dump() has an unused argument.
This patch adds the correct initialization and removes the unused argument.
--- drivers/usb/host/ohci-dbg.c | 9 +++++---- drivers/usb/host/ohci-hcd.c | 10 +++++----- 2 files changed, 10 insertions(+), 9 deletions(-)
drivers/usb/host/ohci-dbg.c +5 -4
@@ -236,7 +236,7 @@ ohci_dump_roothub ( } } -static void ohci_dump (struct ohci_hcd *controller,int verbose) +static void ohci_dump (struct ohci_hcd *controller) {ohci_dbg (controller,"OHCI controller state\n" );
@@ -464,15 +464,16 @@ show_list (struct ohci_hcd *ohci, char *static ssize_t fill_async_buffer (struct debug_buffer *buf) {struct ohci_hcd *ohci; -size_t temp; +size_t temp, size;unsigned long flags; ohci = buf->ohci; + size =PAGE_SIZE ;/* display control and bulk lists together, for simplicity */ spin_lock_irqsave (&ohci->lock, flags); - temp =show_list (ohci, buf->page, buf->count, ohci->ed_controltail); - temp +=show_list (ohci, buf->page + temp, buf->count - temp, + temp =show_list (ohci, buf->page, size, ohci->ed_controltail); + temp +=show_list (ohci, buf->page + temp, size - temp, ohci->ed_bulktail);spin_unlock_irqrestore (&ohci->lock, flags);
drivers/usb/host/ohci-hcd.c +5 -5
@@ -76,8 +76,8 @@ static const char hcd_name [] = "ohci_hc#include "ohci.h" #include "pci-quirks.h" -static void ohci_dump (struct ohci_hcd *ohci,int verbose); -static void ohci_stop (struct usb_hcd *hcd); +static void ohci_dump (struct ohci_hcd *ohci); +static void ohci_stop (struct usb_hcd *hcd);#include "ohci-hub.c" #include "ohci-dbg.c"
@@ -744,7 +744,7 @@ retry: ohci->ed_to_check =NULL ; } -ohci_dump (ohci,1 ); +ohci_dump (ohci);return 0 ; }
@@ -825,7 +825,7 @@ static irqreturn_t ohci_irq (struct usb_usb_hc_died (hcd); } -ohci_dump (ohci,1 ); +ohci_dump (ohci);ohci_usb_reset (ohci); }
@@ -925,7 +925,7 @@ static void ohci_stop (struct usb_hcd *h {struct ohci_hcd *ohci =hcd_to_ohci (hcd); -ohci_dump (ohci,1 ); +ohci_dump (ohci);if (quirk_nec (ohci))flush_work (&ohci->nec_work);
Greg Kroah-Hartman
maintainerPATCH 9/125 USB: OHCI: dont lose track of EDs when a controller dies
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 977dcfdc60311e7aa571cabf6f39c36dde13339e upstream.
This patch fixes a bug in ohci-hcd. When an URB is unlinked, the corresponding Endpoint Descriptor is added to the ed_rm_list and taken off the hardware schedule. Once the ED is no longer visible to the hardware, finish_unlinks() handles the URBs that were unlinked or have completed. If any URBs remain attached to the ED, the ED is added back to the hardware schedule -- but only if the controller is running.
This fails when a controller dies. A non-empty ED does not get added back to the hardware schedule and does not remain on the ed_rm_list; ohci-hcd loses track of it. The remaining URBs cannot be unlinked, which causes the USB stack to hang.
The patch changes finish_unlinks() so that non-empty EDs remain on the ed_rm_list if the controller isn't running. This requires moving some of the existing code around, to avoid modifying the ED's hardware fields more than once.
--- drivers/usb/host/ohci-q.c | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-)
drivers/usb/host/ohci-q.c +29 -17
@@ -311,8 +311,7 @@ static void periodic_unlink (struct ohci* - ED_OPER: when there's any request queued, the ED gets rescheduled * immediately. HC should be working on them. * -* - ED_IDLE: when there's no TD queue. there's no reason for the HC -* to care about this ED; safe to disable the endpoint. +* - ED_IDLE: when there's no TD queue or the HC isn't running. * * When finish_unlinks() runs later, after SOF interrupt, it will often * complete one or more URB unlinks before making that state change.
@@ -926,6 +925,10 @@ rescan_all:int completed, modified;__hc32 *prev; +/* Is this ED already invisible to the hardware? */ +if (ed->state ==ED_IDLE ) + goto ed_idle; +/* only take off EDs that the HC isn't using, accounting for * frame counter wraps and EDs with partially retired TDs */
@@ -955,12 +958,20 @@ skip_ed: } } +/* ED's now officially unlinked, hc doesn't see */ + ed->state =ED_IDLE ; +if (quirk_zfmicro (ohci) && ed->type ==PIPE_INTERRUPT ) + ohci->eds_scheduled--; + ed->hwHeadP &= ~cpu_to_hc32 (ohci,ED_H ); + ed->hwNextED =0 ; +wmb (); + ed->hwINFO &= ~cpu_to_hc32 (ohci,ED_SKIP |ED_DEQUEUE ); +ed_idle: +/* reentrancy: if we drop the schedule lock, someone might * have modified this list. normally it's just prepending * entries (which we'd ignore), but paranoia won't hurt. */ - *last = ed->ed_next; - ed->ed_next =NULL ; modified =0 ;/* unlink urbs as requested, but rescan the list after
@@ -1018,19 +1029,20 @@ rescan_this:if (completed && !list_empty (&ed->td_list)) goto rescan_this; -/* ED's now officially unlinked, hc doesn't see */ - ed->state =ED_IDLE ; -if (quirk_zfmicro (ohci) && ed->type ==PIPE_INTERRUPT ) - ohci->eds_scheduled--; - ed->hwHeadP &= ~cpu_to_hc32 (ohci,ED_H ); - ed->hwNextED =0 ; -wmb (); - ed->hwINFO &= ~cpu_to_hc32 (ohci,ED_SKIP |ED_DEQUEUE ); - -/* but if there's work queued, reschedule */ -if (!list_empty (&ed->td_list)) { -if (ohci->rh_state ==OHCI_RH_RUNNING ) -ed_schedule (ohci, ed); +/* +* If no TDs are queued, take ED off the ed_rm_list. +* Otherwise, if the HC is running, reschedule. +* If not, leave it on the list for further dequeues. +*/ +if (list_empty (&ed->td_list)) { + *last = ed->ed_next; + ed->ed_next =NULL ; + }else if (ohci->rh_state ==OHCI_RH_RUNNING ) { + *last = ed->ed_next; + ed->ed_next =NULL ; +ed_schedule (ohci, ed); + }else { + last = &ed->ed_next; }if (modified)
Greg Kroah-Hartman
maintainerPATCH 10/125 usbcore: dont log on consecutive debounce failures of the same port
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 5ee0f803cc3a0738a63288e4a2f453c85889fbda upstream.
Some laptops have an internal port for a BT device which picks up noise when the kill switch is used, but not enough to trigger printk_rlimit(). So we shouldn't log consecutive faults of this kind.
--- drivers/usb/core/hub.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/usb/core/hub.c +8 -3
@@ -4550,6 +4550,7 @@ static void hub_port_connect(struct usb_struct usb_hcd *hcd =bus_to_hcd (hdev->bus);struct usb_port *port_dev = hub->ports[port1 -1 ];struct usb_device *udev = port_dev->child; +static int unreliable_port =-1 ;/* Disconnect any existing devices under this port */ if (udev) {
@@ -4570,10 +4571,14 @@ static void hub_port_connect(struct usb_ USB_PORT_STAT_C_ENABLE)) { status =hub_port_debounce_be_stable (hub, port1);if (status <0 ) { -if (status != -ENODEV &&printk_ratelimit ()) -dev_err (&port_dev->dev, -"connect-debounce failed\n" ); +if (status != -ENODEV && + port1 != unreliable_port && +printk_ratelimit ()) +dev_err (&udev->dev,"connect-debounce failed, port %d disabled\n" , + port1); + portstatus &= ~USB_PORT_STAT_CONNECTION ; + unreliable_port = port1; }else { portstatus = status; }
Greg Kroah-Hartman
maintainerPATCH 11/125 USB: devio: fix issue with log flooding
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit d310d05f1225d1f6f2bf505255fdf593bfbb3051 upstream.
usbfs allows user space to pass down an URB which sets URB_SHORT_NOT_OK for output URBs. That causes usbcore to log messages without limit for a nonsensical disallowed combination. The fix is to silently drop the attribute in usbfs.
The problem is reported to exist since 3.14
https://www.virtualbox.org/ticket/13085
--- drivers/usb/core/devio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/core/devio.c +1 -1
@@ -1509,7 +1509,7 @@ static int proc_do_submiturb(struct usb_ u = (is_in ?URB_DIR_IN :URB_DIR_OUT );if (uurb->flags &USBDEVFS_URB_ISO_ASAP ) u |=URB_ISO_ASAP ; -if (uurb->flags &USBDEVFS_URB_SHORT_NOT_OK ) +if (uurb->flags &USBDEVFS_URB_SHORT_NOT_OK && is_in) u |=URB_SHORT_NOT_OK ;if (uurb->flags &USBDEVFS_URB_NO_FSBR ) u |=URB_NO_FSBR ;
Greg Kroah-Hartman
maintainerPATCH 12/125 USB: serial: ftdi_sio: Annotate the current Xsens PID assignments
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrick Riphagen <[email protected]>
commit 9273b8a270878906540349422ab24558b9d65716 upstream.
The converters are used in specific products. It can be useful to know which they are exactly.
--- drivers/usb/serial/ftdi_sio_ids.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/usb/serial/ftdi_sio_ids.h +5 -5
@@ -140,12 +140,12 @@/* * Xsens Technologies BV products (http://www.xsens.com). */ -#define XSENS_CONVERTER_0_PID 0xD388 -#define XSENS_CONVERTER_1_PID 0xD389 +#define XSENS_CONVERTER_0_PID 0xD388/* Xsens USB converter */ +#define XSENS_CONVERTER_1_PID 0xD389/* Xsens Wireless Receiver */ #define XSENS_CONVERTER_2_PID 0xD38A -#define XSENS_CONVERTER_3_PID 0xD38B -#define XSENS_CONVERTER_4_PID 0xD38C -#define XSENS_CONVERTER_5_PID 0xD38D +#define XSENS_CONVERTER_3_PID 0xD38B/* Xsens USB-serial converter */ +#define XSENS_CONVERTER_4_PID 0xD38C/* Xsens Wireless Receiver */ +#define XSENS_CONVERTER_5_PID 0xD38D/* Xsens Awinda Station */ #define XSENS_CONVERTER_6_PID 0xD38E#define XSENS_CONVERTER_7_PID 0xD38F
Greg Kroah-Hartman
maintainerPATCH 13/125 USB: serial: ftdi_sio: Add support for new Xsens devices
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrick Riphagen <[email protected]>
commit 4bdcde358b4bda74e356841d351945ca3f2245dd upstream.
This adds support for new Xsens devices, using Xsens' own Vendor ID.
--- drivers/usb/serial/ftdi_sio.c | 2 ++ drivers/usb/serial/ftdi_sio_ids.h | 3 +++ 2 files changed, 5 insertions(+)
drivers/usb/serial/ftdi_sio.c +2 -0
@@ -673,6 +673,8 @@ static const struct usb_device_id id_tab { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_5_PID) }, { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_6_PID) }, { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_7_PID) }, + { USB_DEVICE(XSENS_VID, XSENS_CONVERTER_PID) }, + { USB_DEVICE(XSENS_VID, XSENS_MTW_PID) }, { USB_DEVICE(FTDI_VID, FTDI_OMNI1509) }, { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) }, { USB_DEVICE(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID) },
drivers/usb/serial/ftdi_sio_ids.h +3 -0
@@ -140,6 +140,9 @@/* * Xsens Technologies BV products (http://www.xsens.com). */ +#define XSENS_VID 0x2639 +#define XSENS_CONVERTER_PID 0xD00D/* Xsens USB-serial converter */ +#define XSENS_MTW_PID 0x0200/* Xsens MTw */ #define XSENS_CONVERTER_0_PID 0xD388/* Xsens USB converter */ #define XSENS_CONVERTER_1_PID 0xD389/* Xsens Wireless Receiver */ #define XSENS_CONVERTER_2_PID 0xD38A
Greg Kroah-Hartman
maintainerPATCH 14/125 USB: ehci-pci: USB host controller support for Intel Quark X1000
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryan O'Donoghue <[email protected]>
commit 6e693739e9b603b3ca9ce0d4f4178f0633458465 upstream.
The EHCI packet buffer in/out threshold is programmable for Intel Quark X1000 USB host controller, and the default value is 0x20 dwords. The in/out threshold can be programmed to 0x80 dwords (512 Bytes) to maximize the perfomrance, but only when isochronous/interrupt transactions are not initiated by the USB host controller. This patch is to reconfigure the packet buffer in/out threshold as maximal as possible to maximize the performance, and 0x7F dwords (508 Bytes) should be used because the USB host controller initiates isochronous/interrupt transactions.
--- drivers/usb/host/ehci-pci.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/usb/host/ehci-pci.c +25 -0
@@ -35,6 +35,21 @@ static const char hcd_name[] = "ehci-pci#define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70/*-------------------------------------------------------------------------*/ +#define PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC 0x0939 +static inline bool is_intel_quark_x1000 (struct pci_dev *pdev) +{ +return pdev->vendor ==PCI_VENDOR_ID_INTEL && + pdev->device ==PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC ; +} + +/* +* 0x84 is the offset of in/out threshold register, +* and it is the same offset as the register of 'hostpc'. +*/ +#define intel_quark_x1000_insnreg01 hostpc + +/* Maximum usable threshold value is 0x7f dwords for both IN and OUT */ +#define INTEL_QUARK_X1000_EHCI_MAX_THRESHOLD 0x007f007f/* called after powerup, by probe or system-pm "wakeup" */ static int ehci_pci_reinit (struct ehci_hcd *ehci,struct pci_dev *pdev)
@@ -50,6 +65,16 @@ static int ehci_pci_reinit(struct ehci_hif (!retval)ehci_dbg (ehci,"MWI active\n" ); +/* Reset the threshold limit */ +if (is_intel_quark_x1000 (pdev)) { +/* +* For the Intel QUARK X1000, raise the I/O threshold to the +* maximum usable value in order to improve performance. +*/ +ehci_writel (ehci,INTEL_QUARK_X1000_EHCI_MAX_THRESHOLD , + ehci->regs->intel_quark_x1000_insnreg01); + } +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 15/125 USB: Fix persist resume of some SS USB devices
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pratyush Anand <[email protected]>
commit a40178b2fa6ad87670fb1e5fa4024db00c149629 upstream.
Problem Summary: Problem has been observed generally with PM states where VBUS goes off during suspend. There are some SS USB devices which take longer time for link training compared to many others. Such devices fail to reconnect with same old address which was associated with it before suspend.
When system resumes, at some point of time (dpm_run_callback-> usb_dev_resume->usb_resume->usb_resume_both->usb_resume_device-> usb_port_resume) SW reads hub status. If device is present, then it finishes port resume and re-enumerates device with same address. If device is not present then, SW thinks that device was removed during suspend and therefore does logical disconnection and removes all the resource allocated for this device.
Now, if I put sufficient delay just before root hub status read in usb_resume_device then, SW sees always that device is present. In normal course(without any delay) SW sees that no device is present and then SW removes all resource associated with the device at this port. In the latter case, after sometime, device says that hey I am here, now host enumerates it, but with new address.
Problem had been reproduced when I connect verbatim USB3.0 hard disc with my STiH407 XHCI host running with 3.10 kernel.
I see that similar problem has been reported here.
https://bugzilla.kernel.org/show_bug.cgi?id=53211
Reading above it seems that bug was not in 3.6.6 and was present in 3.8 and again it was not present for some in 3.12.6, while it was present for few others. I tested with 3.13-FC19 running at i686 desktop, problem was still there. However, I was failed to reproduce it with 3.16-RC4 running at same i686 machine. I would say it is just a random observation. Problem for few devices is always there, as I am unable to find a proper fix for the issue.
So, now question is what should be the amount of delay so that host is always able to recognize suspended device after resume.
XHCI specs 4.19.4 says that when Link training is successful, port sets CSC bit to 1. So if SW reads port status before successful link training, then it will not find device to be present. USB Analyzer log with such buggy devices show that in some cases device switch on the RX termination after long delay of host enabling the VBUS. In few other cases it has been seen that device fails to negotiate link training in first attempt. It has been reported till now that few devices take as long as 2000 ms to train the link after host enabling its VBUS and RX termination. This patch implements a 2000 ms timeout for CSC bit to set ie for link training. If in a case link trains before timeout, loop will exit earlier.
This patch implements above delay, but only for SS device and when persist is enabled.
So, for the good device overhead is almost none. While for the bad devices penalty could be the time which it take for link training. But, If a device was connected before suspend, and was removed while system was asleep, then the penalty would be the timeout ie 2000 ms.
Results:
Verbatim USB SS hard disk connected with STiH407 USB host running 3.10 Kernel resumes in 461 msecs without this patch, but hard disk is assigned a new device address. Same system resumes in 790 msecs with this patch, but with old device address.
--- drivers/usb/core/hub.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
drivers/usb/core/hub.c +41 -0
@@ -3264,6 +3264,43 @@ static int finish_port_resume(struct usb }/* +* There are some SS USB devices which take longer time for link training. +* XHCI specs 4.19.4 says that when Link training is successful, port +* sets CSC bit to 1. So if SW reads port status before successful link +* training, then it will not find device to be present. +* USB Analyzer log with such buggy devices show that in some cases +* device switch on the RX termination after long delay of host enabling +* the VBUS. In few other cases it has been seen that device fails to +* negotiate link training in first attempt. It has been +* reported till now that few devices take as long as 2000 ms to train +* the link after host enabling its VBUS and termination. Following +* routine implements a 2000 ms timeout for link training. If in a case +* link trains before timeout, loop will exit earlier. +* +* FIXME: If a device was connected before suspend, but was removed +* while system was asleep, then the loop in the following routine will +* only exit at timeout. +* +* This routine should only be called when persist is enabled for a SS +* device. +*/ +static int wait_for_ss_port_enable (struct usb_device *udev, +struct usb_hub *hub,int *port1, +u16 *portchange,u16 *portstatus) +{ +int status =0 , delay_ms =0 ; + +while (delay_ms <2000 ) { +if (status || *portstatus &USB_PORT_STAT_CONNECTION ) +break ; +msleep (20 ); + delay_ms +=20 ; + status =hub_port_status (hub, *port1, portstatus, portchange); + } +return status; +} + +/* * usb_port_resume - re-activate a suspended usb device's upstream port * @udev: device to re-activate, not a root hub * Context: must be able to sleep; device not locked; pm locks held
@@ -3359,6 +3396,10 @@ int usb_port_resume(struct usb_device *u } } +if (udev->persist_enabled &&hub_is_superspeed (hub->hdev)) + status =wait_for_ss_port_enable (udev, hub, &port1, &portchange, + &portstatus); + status =check_port_resume_type (udev, hub, port1, status, portchange, portstatus);if (status ==0 )
Greg Kroah-Hartman
maintainerPATCH 16/125 ALSA: hda - fix an external mic jack problem on a HP machine
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Wang <[email protected]>
commit 7440850c20b69658f322119d20a94dc914127cc7 upstream.
ON the machine, two pin complex (0xb and 0xe) are both routed to the same external right-side mic jack, this makes the jack can't work.
To fix this problem, set the 0xe to "not connected".
--- sound/pci/hda/patch_sigmatel.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
sound/pci/hda/patch_sigmatel.c +12 -0
@@ -84,6 +84,7 @@ enum {STAC_DELL_EQ ,STAC_ALIENWARE_M17X ,STAC_92HD89XX_HP_FRONT_JACK , +STAC_92HD89XX_HP_Z1_G2_RIGHT_MIC_JACK , STAC_92HD73XX_MODELS };
@@ -1809,6 +1810,11 @@ static const struct hda_pintbl stac92hd8 {} }; +static const struct hda_pintbl stac92hd89xx_hp_z1_g2_right_mic_jack_pin_configs[] = { + {0x0e ,0x400000f0 }, + {} +}; +static void stac92hd73xx_fixup_ref (struct hda_codec *codec,const struct hda_fixup *fix,int action) {
@@ -1931,6 +1937,10 @@ static const struct hda_fixup stac92hd73 [STAC_92HD89XX_HP_FRONT_JACK ] = { .type =HDA_FIXUP_PINS , .v.pins = stac92hd89xx_hp_front_jack_pin_configs, + }, + [STAC_92HD89XX_HP_Z1_G2_RIGHT_MIC_JACK ] = { + .type =HDA_FIXUP_PINS , + .v.pins = stac92hd89xx_hp_z1_g2_right_mic_jack_pin_configs, } };
@@ -1991,6 +2001,8 @@ static const struct snd_pci_quirk stac92 "Alienware M17x", STAC_ALIENWARE_M17X),SND_PCI_QUIRK (PCI_VENDOR_ID_DELL ,0x0490 ,"Alienware M17x R3" ,STAC_DELL_EQ ), +SND_PCI_QUIRK (PCI_VENDOR_ID_HP ,0x1927 , +"HP Z1 G2" ,STAC_92HD89XX_HP_Z1_G2_RIGHT_MIC_JACK ),SND_PCI_QUIRK (PCI_VENDOR_ID_HP ,0x2b17 , "unknown HP", STAC_92HD89XX_HP_FRONT_JACK), {} /* terminator */
Greg Kroah-Hartman
maintainerPATCH 17/125 ALSA: usb-audio: Adjust Gamecom 780 volume level
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul S McSpadden <[email protected]>
commit 542baf94ec3c5526955b4c9fd899c7f30fae4ebe upstream.
Original patch fixed the original problem, but the sound was far too low for most users. This patch references a compare matrix to allow the volume levels to act normally. I personally tested this patch myself, and volume levels returned to normal. Please see this discussion for more details: https://bugzilla.kernel.org/show_bug.cgi?id=65251
--- sound/usb/quirks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/quirks.c +1 -1
@@ -670,7 +670,7 @@ static int snd_usb_gamecon780_boot_quirk/* set the initial volume and don't change; other values are either * too loud or silent due to firmware bug (bko#65251) */ -u8 buf[2 ] = {0x74 ,0xdc }; +u8 buf[2 ] = {0x74 ,0xe3 };return snd_usb_ctl_msg (dev,usb_sndctrlpipe (dev,0 ),UAC_SET_CUR ,USB_RECIP_INTERFACE |USB_TYPE_CLASS |USB_DIR_OUT ,UAC_FU_VOLUME <<8 ,9 <<8 , buf,2 );
Greg Kroah-Hartman
maintainerPATCH 18/125 ALSA: virtuoso: add Xonar Essence STX II support
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Clemens Ladisch <[email protected]>
commit f42bb22243d2ae264d721b055f836059fe35321f upstream.
Just add the PCI ID for the STX II. It appears to work the same as the STX, except for the addition of the not-yet-supported daughterboard.
--- Documentation/sound/alsa/ALSA-Configuration.txt | 4 ++-- sound/pci/Kconfig | 4 ++-- sound/pci/oxygen/virtuoso.c | 1 + sound/pci/oxygen/xonar_pcm179x.c | 12 ++++++++++-- 4 files changed, 15 insertions(+), 6 deletions(-)
Documentation/sound/alsa/ALSA-Configuration.txt +2 -2
@@ -2026,8 +2026,8 @@ Prior to version 0.9.0rc4 options had a ------------------- Module for sound cards based on the Asus AV66/AV100/AV200 chips, - i.e., Xonar D1, DX, D2, D2X, DS, Essence ST (Deluxe), Essence STX, - HDAV1.3 (Deluxe), and HDAV1.3 Slim. + i.e., Xonar D1, DX, D2, D2X, DS, DSX, Essence ST (Deluxe), + Essence STX (II), HDAV1.3 (Deluxe), and HDAV1.3 Slim. This module supports autoprobe and multiple cards.
sound/pci/Kconfig +2 -2
@@ -858,8 +858,8 @@ config SND_VIRTUOSO select SND_JACK if INPUT=y || INPUT=SND help Say Y here to include support for sound cards based on the - Asus AV66/AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X, DS, - Essence ST (Deluxe), and Essence STX. + Asus AV66/AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X, DS, DSX, + Essence ST (Deluxe), and Essence STX (II). Support for the HDAV1.3 (Deluxe) and HDAV1.3 Slim is experimental; for the Xense, missing.
sound/pci/oxygen/virtuoso.c +1 -0
@@ -53,6 +53,7 @@ static DEFINE_PCI_DEVICE_TABLE(xonar_ids { OXYGEN_PCI_SUBID(0x1043, 0x835e) }, { OXYGEN_PCI_SUBID(0x1043, 0x838e) }, { OXYGEN_PCI_SUBID(0x1043, 0x8522) }, + { OXYGEN_PCI_SUBID(0x1043, 0x85f4) }, { OXYGEN_PCI_SUBID_BROKEN_EEPROM }, { } };
sound/pci/oxygen/xonar_pcm179x.c +10 -2
@@ -100,8 +100,8 @@*/ /* -* Xonar Essence ST (Deluxe)/STX -* ----------------------------- +* Xonar Essence ST (Deluxe)/STX (II) +* ---------------------------------- * * CMI8788: *
@@ -1137,6 +1137,14 @@ int get_xonar_pcm179x_model(struct oxyge chip->model.init = xonar_stx_init; chip->model.resume = xonar_stx_resume; chip->model.set_dac_params = set_pcm1796_params; +break ; +case 0x85f4 : + chip->model = model_xonar_st; +/* TODO: daughterboard support */ + chip->model.shortname ="Xonar STX II" ; + chip->model.init = xonar_stx_init; + chip->model.resume = xonar_stx_resume; + chip->model.set_dac_params = set_pcm1796_params;break ;default :return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 19/125 ALSA: hda/ca0132 - Dont try loading firmware at resume when already failed
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit e24aa0a4c5ac92a171d9dd74a8d3dbf652990d36 upstream.
CA0132 driver tries to reload the firmware at resume. Usually this works since the firmware loader core caches the firmware contents by itself. However, if the driver failed to load the firmwares (e.g. missing files), reloading the firmware at resume goes through the actual file loading code path, and triggers a kernel WARNING like:
WARNING: CPU: 10 PID:11371 at drivers/base/firmware_class.c:1105 _request_firmware+0x9ab/0x9d0()
For avoiding this situation, this patch makes CA0132 skipping the f/w loading at resume when it failed at probe time.
--- sound/pci/hda/patch_ca0132.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
sound/pci/hda/patch_ca0132.c +6 -1
@@ -4376,6 +4376,9 @@ static void ca0132_download_dsp(struct hreturn ;/* NOP */ #endif +if (spec->dsp_state ==DSP_DOWNLOAD_FAILED ) +return ;/* don't retry failures */ +chipio_enable_clocks (codec); spec->dsp_state =DSP_DOWNLOADING ;if (!ca0132_download_dsp_images (codec))
@@ -4552,7 +4555,8 @@ static int ca0132_init(struct hda_codecstruct auto_pin_cfg *cfg = &spec->autocfg;int i; - spec->dsp_state =DSP_DOWNLOAD_INIT ; +if (spec->dsp_state !=DSP_DOWNLOAD_FAILED ) + spec->dsp_state =DSP_DOWNLOAD_INIT ; spec->curr_chip_addx =INVALID_CHIP_ADDRESS ;snd_hda_power_up (codec);
@@ -4663,6 +4667,7 @@ static int patch_ca0132(struct hda_codec codec->spec = spec; spec->codec = codec; + spec->dsp_state =DSP_DOWNLOAD_INIT ; spec->num_mixers =1 ; spec->mixers[0 ] = ca0132_mixer;
Greg Kroah-Hartman
maintainerPATCH 20/125 ALSA: usb-audio: fix BOSS ME-25 MIDI regression
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Clemens Ladisch <[email protected]>
commit 53da5ebfef66ea6e478ad9c6add3781472b79475 upstream.
The BOSS ME-25 turns out not to have any useful descriptors in its MIDI interface, so its needs a quirk entry after all.
--- sound/usb/quirks-table.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
sound/usb/quirks-table.h +29 -0
@@ -1581,6 +1581,35 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { +/* BOSS ME-25 */ + USB_DEVICE(0x0582, 0x0113), + .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) { + .ifnum =QUIRK_ANY_INTERFACE , + .type =QUIRK_COMPOSITE , + .data = (const struct snd_usb_audio_quirk []) { + { + .ifnum =0 , + .type =QUIRK_AUDIO_STANDARD_INTERFACE + }, + { + .ifnum =1 , + .type =QUIRK_AUDIO_STANDARD_INTERFACE + }, + { + .ifnum =2 , + .type =QUIRK_MIDI_FIXED_ENDPOINT , + .data = & (const struct snd_usb_midi_endpoint_info ) { + .out_cables =0x0001 , + .in_cables =0x0001 + } + }, + { + .ifnum =-1 + } + } + } +}, +{ /* only 44.1 kHz works at the moment */ USB_DEVICE(0x0582, 0x0120), .driver_info = (unsigned long ) & (const struct snd_usb_audio_quirk ) {
Greg Kroah-Hartman
maintainerPATCH 21/125 ALSA: hda - Add mute LED pin quirk for HP 15 touchsmart
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Henningsson <[email protected]>
commit 423044744aa4c250058e976474856a7a41972182 upstream.
This makes the mute LED work on a HP 15 touchsmart machine.
--- sound/pci/hda/patch_realtek.c | 2 ++ 1 file changed, 2 insertions(+)
sound/pci/hda/patch_realtek.c +2 -0
@@ -4782,6 +4782,8 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x1983 ,"HP Pavilion" ,ALC269_FIXUP_HP_MUTE_LED_MIC1 ),SND_PCI_QUIRK (0x103c ,0x218b ,"HP" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED ),/* ALC282 */ +SND_PCI_QUIRK (0x103c ,0x2191 ,"HP Touchsmart 14" ,ALC269_FIXUP_HP_MUTE_LED_MIC1 ), +SND_PCI_QUIRK (0x103c ,0x2192 ,"HP Touchsmart 15" ,ALC269_FIXUP_HP_MUTE_LED_MIC1 ),SND_PCI_QUIRK (0x103c ,0x220d ,"HP" ,ALC269_FIXUP_HP_MUTE_LED_MIC1 ),SND_PCI_QUIRK (0x103c ,0x220e ,"HP" ,ALC269_FIXUP_HP_MUTE_LED_MIC1 ), SND_PCI_QUIRK(0x103c, 0x220f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Greg Kroah-Hartman
maintainerPATCH 22/125 ALSA: hda - restore the gpio led after resume
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Wang <[email protected]>
commit f475371aa65de84fa483a998ab7594531026b9d9 upstream.
On some HP laptops, the mute led is controlled by codec gpio.
When some machine resume from s3/s4, the codec gpio data will be cleared to 0 by BIOS:
Before suspend:
IO[3]: enable=1, dir=1, wake=0, sticky=0, data=1, unsol=0
After resume:
IO[3]: enable=1, dir=1, wake=0, sticky=0, data=0, unsol=0
To skip the AFG node to enter D3 can't fix this problem.
A workaround is to restore the gpio data when the system resume back from s3/s4. It is safe even on the machines without this problem.
--- sound/pci/hda/patch_realtek.c | 9 +++++++++ 1 file changed, 9 insertions(+)
sound/pci/hda/patch_realtek.c +9 -0
@@ -3242,6 +3242,15 @@ static int alc269_resume(struct hda_codesnd_hda_codec_resume_cache (codec);alc_inv_dmic_sync (codec, true);hda_call_check_power_status (codec,0x01 ); + +/* on some machine, the BIOS will clear the codec gpio data when enter +* suspend, and won't restore the data after resume, so we restore it +* in the driver. +*/ +if (spec->gpio_led) +snd_hda_codec_write (codec, codec->afg,0 ,AC_VERB_SET_GPIO_DATA , + spec->gpio_led); +if (spec->has_alc5505_dsp)alc5505_dsp_resume (codec);
Greg Kroah-Hartman
maintainerPATCH 23/125 ALSA: hda/realtek - Avoid setting wrong COEF on ALC269 & co
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit f3ee07d8b6e061bf34a7167c3f564e8da4360a99 upstream.
ALC269 & co have many vendor-specific setups with COEF verbs. However, some verbs seem specific to some codec versions and they result in the codec stalling. Typically, such a case can be avoided by checking the return value from reading a COEF. If the return value is -1, it implies that the COEF is invalid, thus it shouldn't be written.
This patch adds the invalid COEF checks in appropriate places accessing ALC269 and its variants. The patch actually fixes the resume problem on Acer AO725 laptop.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=52181
--- sound/pci/hda/patch_realtek.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
sound/pci/hda/patch_realtek.c +12 -5
@@ -180,6 +180,8 @@ static void alc_fix_pll(struct hda_codec spec->pll_coef_idx); val =snd_hda_codec_read (codec, spec->pll_nid,0 ,AC_VERB_GET_PROC_COEF ,0 ); +if (val ==-1 ) +return ;snd_hda_codec_write (codec, spec->pll_nid,0 ,AC_VERB_SET_COEF_INDEX , spec->pll_coef_idx); snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
@@ -2784,6 +2786,8 @@ static int alc269_parse_auto_config(strustatic void alc269vb_toggle_power_output (struct hda_codec *codec,int power_up) {int val =alc_read_coef_idx (codec,0x04 ); +if (val ==-1 ) +return ;if (power_up) val |=1 <<11 ;else
@@ -5133,27 +5137,30 @@ static void alc269_fill_coef(struct hda_if ((alc_get_coef0 (codec) &0x00ff ) ==0x017 ) { val =alc_read_coef_idx (codec,0x04 );/* Power up output pin */ -alc_write_coef_idx (codec,0x04 , val | (1 <<11 )); +if (val !=-1 ) +alc_write_coef_idx (codec,0x04 , val | (1 <<11 )); }if ((alc_get_coef0 (codec) &0x00ff ) ==0x018 ) { val =alc_read_coef_idx (codec,0xd ); -if ((val &0x0c00 ) >>10 !=0x1 ) { +if (val !=-1 && (val &0x0c00 ) >>10 !=0x1 ) {/* Capless ramp up clock control */ alc_write_coef_idx (codec,0xd , val | (1 <<10 )); } val =alc_read_coef_idx (codec,0x17 ); -if ((val &0x01c0 ) >>6 !=0x4 ) { +if (val !=-1 && (val &0x01c0 ) >>6 !=0x4 ) {/* Class D power on reset */ alc_write_coef_idx (codec,0x17 , val | (1 <<7 )); } } val =alc_read_coef_idx (codec,0xd );/* Class D */ -alc_write_coef_idx (codec,0xd , val | (1 <<14 )); +if (val !=-1 ) +alc_write_coef_idx (codec,0xd , val | (1 <<14 )); val =alc_read_coef_idx (codec,0x4 );/* HP */ -alc_write_coef_idx (codec,0x4 , val | (1 <<11 )); +if (val !=-1 ) +alc_write_coef_idx (codec,0x4 , val | (1 <<11 )); }/*
Greg Kroah-Hartman
maintainerPATCH 24/125 mei: reset client connection state on timeout
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
commit 3e37ebb7183f0c4eb92a88c60657ac319c01b3e9 upstream.
On connection timeout we leave the connecting client in connecting state. Since a new connection is stalled till previous connection is completed in this case no new connection is possible till the user space does release the file handle. Therefore on timeout we move the client to disconnected state.
--- drivers/misc/mei/client.c | 1 + 1 file changed, 1 insertion(+)
drivers/misc/mei/client.c +1 -0
@@ -616,6 +616,7 @@ int mei_cl_connect(struct mei_cl *cl, stmutex_lock (&dev->device_lock);if (cl->state !=MEI_FILE_CONNECTED ) { + cl->state =MEI_FILE_DISCONNECTED ;/* something went really wrong */ if (!cl->status) cl->status = -EFAULT ;
Greg Kroah-Hartman
maintainerPATCH 25/125 mei: start disconnect request timer consistently
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
commit 22b987a325701223f9a37db700c6eb20b9924c6f upstream.
Link must be reset in case the fw doesn't respond to client disconnect request.
We did charge the timer only in irq path from mei_cl_irq_close and not in mei_cl_disconnect
--- drivers/misc/mei/client.c | 1 + 1 file changed, 1 insertion(+)
drivers/misc/mei/client.c +1 -0
@@ -491,6 +491,7 @@ int mei_cl_disconnect(struct mei_cl *cl)cl_err (dev, cl,"failed to disconnect.\n" ); goto free; } + cl->timer_count =MEI_CONNECT_TIMEOUT ;mdelay (10 );/* Wait for hardware disconnection ready */ list_add_tail (&cb->list, &dev->ctrl_rd_list.list); }else {
Greg Kroah-Hartman
maintainerPATCH 26/125 mei: dont schedule suspend in pm idle
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
commit d5d83f8abea13d0b50ee762276c6c900d1946264 upstream.
Calling pm_schedule_suspend from the runtime pm idle callback may reschedule existing timer, thus in case of frequent runtime rpm idle call the suspend maybe starved.
Instead we call pm_runtime_autosuspend which is checking if the timer is already charged.
An example is monitoring device pci config space. Pci config sysfs handlers calls pci_config_pm_runtime_put/get helpers which in turns calls to device idle callback
--- drivers/misc/mei/pci-me.c | 2 +- drivers/misc/mei/pci-txe.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/misc/mei/pci-me.c +1 -1
@@ -369,7 +369,7 @@ static int mei_me_pm_runtime_idle(structif (!dev)return -ENODEV ;if (mei_write_is_idle (dev)) -pm_schedule_suspend (device,MEI_ME_RPM_TIMEOUT *2 ); +pm_runtime_autosuspend (device);return -EBUSY ; }
drivers/misc/mei/pci-txe.c +1 -1
@@ -306,7 +306,7 @@ static int mei_txe_pm_runtime_idle(strucif (!dev)return -ENODEV ;if (mei_write_is_idle (dev)) -pm_schedule_suspend (device,MEI_TXI_RPM_TIMEOUT *2 ); +pm_runtime_autosuspend (device);return -EBUSY ; }
Greg Kroah-Hartman
maintainerPATCH 27/125 mei: fix return value on disconnect timeout
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
commit fe2f17eb3da38ac0d5a00c511255bf3a33d16d24 upstream.
wait_event_timeout can return 0 or the remaining jiffies so return -ETIME if disconnected state not reached.
--- drivers/misc/mei/client.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/misc/mei/client.c +5 -10
@@ -459,7 +459,7 @@ int mei_cl_disconnect(struct mei_cl *cl) {struct mei_device *dev;struct mei_cl_cb *cb; -int rets, err; +int rets;if (WARN_ON (!cl || !cl->dev))return -ENODEV ;
@@ -501,23 +501,18 @@ int mei_cl_disconnect(struct mei_cl *cl) }mutex_unlock (&dev->device_lock); - err =wait_event_timeout (dev->wait_recvd_msg, +wait_event_timeout (dev->wait_recvd_msg,MEI_FILE_DISCONNECTED == cl->state,mei_secs_to_jiffies (MEI_CL_CONNECT_TIMEOUT ));mutex_lock (&dev->device_lock); +if (MEI_FILE_DISCONNECTED == cl->state) { rets =0 ;cl_dbg (dev, cl,"successfully disconnected from FW client.\n" ); }else { - rets = -ENODEV ; -if (MEI_FILE_DISCONNECTED != cl->state) -cl_err (dev, cl,"wrong status client disconnect.\n" ); - -if (err) -cl_dbg (dev, cl,"wait failed disconnect err=%d\n" , err); - -cl_err (dev, cl,"failed to disconnect from FW client.\n" ); +cl_dbg (dev, cl,"timeout on disconnect from FW client.\n" ); + rets = -ETIME ; }mei_io_list_flush (&dev->ctrl_rd_list, cl);
Greg Kroah-Hartman
maintainerPATCH 28/125 xhci: Blacklist using streams on the Etron EJ168 controller
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 8f873c1ff4ca034626093d03b254e7cb8bb782dd upstream.
Streams on the EJ168 do not work as they should. I've spend 2 days trying to get them to work, but without success.
The first problem is that when ever you ring the stream-ring doorbell, the controller starts executing trbs at the beginning of the first ring segment, event if it ended somewhere else previously. This can be worked around by allowing enqueing only one td (not a problem with how streams are typically used) and then resetting our copies of the enqueueing en dequeueing pointers on a td completion to match what the controller seems to be doing.
This way things seem to start working with uas and instead of being able to complete only the very first scsi command, the scsi core can probe the disk.
But then things break later on when td-s get enqueued with more then one trb. The controller does seem to increase its dequeue pointer while executing a stream-ring (data transfer events I inserted for debugging do trigger). However execution seems to stop at the final normal trb of a multi trb td, even if there is a data transfer event inserted after the final trb.
The first problem alone is a serious deviation from the spec, and esp. dealing with cancellation would have been very tricky if not outright impossible, but the second problem simply is a deal breaker altogether, so this patch simply disables streams.
Note this will cause the usb-storage + uas driver pair to automatically switch to using usb-storage instead of uas on these devices, essentially reverting to the 3.14 and earlier behavior when uas was marked CONFIG_BROKEN.
https://bugzilla.redhat.com/show_bug.cgi?id=1121288
https://bugzilla.kernel.org/show_bug.cgi?id=80101
--- drivers/usb/host/xhci-pci.c | 4 +++- drivers/usb/host/xhci.c | 3 ++- drivers/usb/host/xhci.h | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-)
drivers/usb/host/xhci-pci.c +3 -1
@@ -143,6 +143,7 @@ static void xhci_pci_quirks(struct devic pdev->device == PCI_DEVICE_ID_ASROCK_P67) { xhci->quirks |=XHCI_RESET_ON_RESUME ; xhci->quirks |=XHCI_TRUST_TX_LENGTH ; + xhci->quirks |=XHCI_BROKEN_STREAMS ; }if (pdev->vendor ==PCI_VENDOR_ID_RENESAS && pdev->device ==0x0015 )
@@ -230,7 +231,8 @@ static int xhci_pci_probe(struct pci_dev goto put_usb3_hcd;/* Roothub already marked as USB 3.0 speed */ -if (HCC_MAX_PSA (xhci->hcc_params) >=4 ) +if (!(xhci->quirks &XHCI_BROKEN_STREAMS ) && +HCC_MAX_PSA (xhci->hcc_params) >=4 ) xhci->shared_hcd->can_do_streams =1 ;/* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */
drivers/usb/host/xhci.c +2 -1
@@ -3163,7 +3163,8 @@ int xhci_alloc_streams(struct usb_hcd *h num_streams);/* MaxPSASize value 0 (2 streams) means streams are not supported */ -if (HCC_MAX_PSA (xhci->hcc_params) <4 ) { +if ((xhci->quirks &XHCI_BROKEN_STREAMS ) || +HCC_MAX_PSA (xhci->hcc_params) <4 ) {xhci_dbg (xhci,"xHCI controller does not support streams.\n" );return -ENOSYS ; }
drivers/usb/host/xhci.h +2 -0
@@ -1558,6 +1558,8 @@ struct xhci_hcd {#define XHCI_PLAT (1 << 16)#define XHCI_SLOW_SUSPEND (1 << 17)#define XHCI_SPURIOUS_WAKEUP (1 << 18) +/* For controllers with a broken beyond repair streams implementation */ +#define XHCI_BROKEN_STREAMS (1 << 19)unsigned int num_active_eps;unsigned int limit_active_eps;/* There are two roothubs to keep track of bus suspend info for */
Greg Kroah-Hartman
maintainerPATCH 29/125 sched: Fix sched_setparam() policy == -1 logic
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Bristot de Oliveira <[email protected]>
commit d8d28c8f00e84a72e8bee39a85835635417bee49 upstream.
The scheduler uses policy == -1 to preserve the current policy state to implement sched_setparam(). But, as (int) -1 is equals to 0xffffffff, it's matching the if (policy & SCHED_RESET_ON_FORK) on _sched_setscheduler(). This match changes the policy value to an invalid value, breaking the sched_setparam() syscall.
This patch checks policy == -1 before check the SCHED_RESET_ON_FORK flag.
The following program shows the bug:
int main(void)
{
struct sched_param param = {
.sched_priority = 5,
};
sched_setscheduler(0, SCHED_FIFO, ¶m);
param.sched_priority = 1;
sched_setparam(0, ¶m);
param.sched_priority = 0;
sched_getparam(0, ¶m);
if (param.sched_priority != 1)
printf("failed priority setting (found %d instead of 1)\n",
param.sched_priority);
else
printf("priority setting fine\n");
}--- kernel/sched/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/sched/core.c +3 -2
@@ -3558,9 +3558,10 @@ static int _sched_setscheduler(struct ta };/* -* Fixup the legacy SCHED_RESET_ON_FORK hack +* Fixup the legacy SCHED_RESET_ON_FORK hack, except if +* the policy=-1 was passed by sched_setparam(). */ -if (policy &SCHED_RESET_ON_FORK ) { +if ((policy !=-1 ) && (policy &SCHED_RESET_ON_FORK )) { attr.sched_flags |=SCHED_FLAG_RESET_ON_FORK ; policy &= ~SCHED_RESET_ON_FORK ; attr.sched_policy = policy;
Greg Kroah-Hartman
maintainerPATCH 30/125 arm64: Fix barriers used for page table modifications
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Catalin Marinas <[email protected]>
commit 7f0b1bf04511348995d6fce38c87c98a3b5cb781 upstream.
The architecture specification states that both DSB and ISB are required between page table modifications and subsequent memory accesses using the corresponding virtual address. When TLB invalidation takes place, the tlb_flush_* functions already have the necessary barriers. However, there are other functions like create_mapping() for which this is not the case.
The patch adds the DSB+ISB instructions in the set_pte() function for valid kernel mappings. The invalid pte case is handled by tlb_flush_* and the user mappings in general have a corresponding update_mmu_cache() call containing a DSB. Even when update_mmu_cache() isn't called, the kernel can still cope with an unlikely spurious page fault by re-executing the instruction.
In addition, the set_pmd, set_pud() functions gain an ISB for architecture compliance when block mappings are created.
--- arch/arm64/include/asm/cacheflush.h | 11 +---------- arch/arm64/include/asm/pgtable.h | 13 +++++++++++++ arch/arm64/include/asm/tlbflush.h | 5 +++-- 3 files changed, 17 insertions(+), 12 deletions(-)
arch/arm64/include/asm/cacheflush.h +1 -10
@@ -138,19 +138,10 @@ static inline void __flush_icache_all(vo#define flush_icache_page (vma,page) do { } while (0)/* -* flush_cache_vmap() is used when creating mappings (eg, via vmap, -* vmalloc, ioremap etc) in kernel space for pages. On non-VIPT -* caches, since the direct-mappings of these pages may contain cached -* data, we need to do a full cache flush to ensure that writebacks -* don't corrupt data placed into these pages via the new mappings. +* Not required on AArch64 (PIPT or VIPT non-aliasing D-cache). */ static inline void flush_cache_vmap (unsigned long start,unsigned long end) { -/* -* set_pte_at() called from vmap_pte_range() does not -* have a DSB after cleaning the cache line. -*/ -dsb (ish); }static inline void flush_cache_vunmap (unsigned long start,unsigned long end)
arch/arm64/include/asm/pgtable.h +13 -0
@@ -138,6 +138,8 @@ extern struct page *empty_zero_page;#define pte_valid_user (pte) \ ((pte_val(pte) & (PTE_VALID | PTE_USER)) == (PTE_VALID | PTE_USER)) +#define pte_valid_not_user (pte) \ + ((pte_val(pte) & (PTE_VALID | PTE_USER)) == PTE_VALID)static inline pte_t pte_wrprotect (pte_t pte) {
@@ -184,6 +186,15 @@ static inline pte_t pte_mkspecial(pte_tstatic inline void set_pte (pte_t *ptep,pte_t pte) { *ptep = pte; + +/* +* Only if the new pte is valid and kernel, otherwise TLB maintenance +* or update_mmu_cache() have the necessary barriers. +*/ +if (pte_valid_not_user (pte)) { +dsb (ishst); +isb (); + } }extern void __sync_icache_dcache (pte_t pteval,unsigned long addr);
@@ -303,6 +314,7 @@ static inline void set_pmd(pmd_t *pmdp, { *pmdp = pmd;dsb (ishst); +isb (); }static inline void pmd_clear (pmd_t *pmdp)
@@ -333,6 +345,7 @@ static inline void set_pud(pud_t *pudp, { *pudp = pud;dsb (ishst); +isb (); }static inline void pud_clear (pud_t *pudp)
arch/arm64/include/asm/tlbflush.h +3 -2
@@ -122,6 +122,7 @@ static inline void flush_tlb_kernel_rangfor (addr = start; addr < end; addr +=1 << (PAGE_SHIFT -12 )) asm("tlbi vaae1is, %0" : :"r" (addr));dsb (ish); +isb (); }/*
@@ -131,8 +132,8 @@ static inline void update_mmu_cache(stru unsigned long addr, pte_t *ptep) {/* -* set_pte() does not have a DSB, so make sure that the page table -* write is visible. +* set_pte() does not have a DSB for user mappings, so make sure that +* the page table write is visible. */ dsb (ishst ); }
Greg Kroah-Hartman
maintainerPATCH 31/125 arm64: dont call break hooks for BRK exceptions from EL0
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
commit c878e0cff5c5e56b216951cbe75f7a3dd500a736 upstream.
Our break hooks are used to handle brk exceptions from kgdb (and potentially kprobes if that code ever resurfaces), so don't bother calling them if the BRK exception comes from userspace.
This prevents userspace from trapping to a kdb shell on systems where kgdb is enabled and active.
--- arch/arm64/kernel/debug-monitors.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
arch/arm64/kernel/debug-monitors.c +11 -11
@@ -315,20 +315,20 @@ static int brk_handler(unsigned long add {siginfo_t info; -if (call_break_hook (regs, esr) ==DBG_HOOK_HANDLED ) -return 0 ; +if (user_mode (regs)) { + info = (siginfo_t ) { + .si_signo =SIGTRAP , + .si_errno =0 , + .si_code =TRAP_BRKPT , + .si_addr = (void __user *)instruction_pointer (regs), + }; -if (!user_mode (regs)) +force_sig_info (SIGTRAP , &info, current); + }else if (call_break_hook (regs, esr) !=DBG_HOOK_HANDLED ) { +pr_warning ("Unexpected kernel BRK exception at EL1\n" );return -EFAULT ; + } - info = (siginfo_t ) { - .si_signo =SIGTRAP , - .si_errno =0 , - .si_code =TRAP_BRKPT , - .si_addr = (void __user *)instruction_pointer (regs), - }; - -force_sig_info (SIGTRAP , &info, current);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 32/125 efi/arm64: Store Runtime Services revision
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Semen Protsenko <[email protected]>
commit 6a7519e81321343165f89abb8b616df186d3e57a upstream.
"efi" global data structure contains "runtime_version" field which must be assigned in order to use it later in Runtime Services virtual calls (virt_efi_* functions).
Before this patch "runtime_version" was unassigned (0), so each Runtime Service virtual call that checks revision would fail.
--- arch/arm64/kernel/efi.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/kernel/efi.c +2 -0
@@ -464,6 +464,8 @@ static int __init arm64_enter_virtual_moset_bit (EFI_RUNTIME_SERVICES , &efi.flags); + efi.runtime_version = efi.systab->hdr.revision; +return 0 ; }early_initcall (arm64_enter_virtual_mode);
Greg Kroah-Hartman
maintainerPATCH 33/125 ARM: dts: AM4372: Correct mailbox node data
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suman Anna <[email protected]>
commit 44e6ab1b619853f05bf7250e55a6d82864e340d7 upstream.
The mailbox DT node for AM4372 is enabled and is corrected to remove some properties that have crept in by mistake.
--- arch/arm/boot/dts/am4372.dtsi | 3 --- 1 file changed, 3 deletions(-)
arch/arm/boot/dts/am4372.dtsi +0 -3
@@ -168,9 +168,6 @@ ti,hwmods = "mailbox"; ti,mbox-num-users = <4>; ti,mbox-num-fifos = <8>; - ti,mbox-names = "wkup_m3"; - ti,mbox-data = <0 0 0 0>; - status = "disabled"; }; timer1: timer@44e31000 {
Greg Kroah-Hartman
maintainerPATCH 34/125 ARM: 8097/1: unistd.h: relocate comments back to place
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baruch Siach <[email protected]>
commit bc994c77ce82576209dcf08f71de9ae51b0b100f upstream.
Commit cb8db5d45 (UAPI: (Scripted) Disintegrate arch/arm/include/asm) moved these syscall comments out of their context into the UAPI headers. Fix this.
--- arch/arm/include/asm/unistd.h | 10 ++++++++++ arch/arm/include/uapi/asm/unistd.h | 11 ----------- 2 files changed, 10 insertions(+), 11 deletions(-)
arch/arm/include/asm/unistd.h +10 -0
@@ -15,7 +15,17 @@#include <uapi/asm/unistd.h> +/* +* This may need to be greater than __NR_last_syscall+1 in order to +* account for the padding in the syscall table +*/ #define __NR_syscalls (384) + +/* +* *NOTE*: This is a ghost syscall private to the kernel. Only the +* __kuser_cmpxchg code in entry-armv.S should be aware of its +* existence. Don't ever use this from user code. +*/ #define __ARM_NR_cmpxchg (__ARM_NR_BASE+0x00fff0)#define __ARCH_WANT_STAT64
arch/arm/include/uapi/asm/unistd.h +0 -11
@@ -411,11 +411,6 @@#define __NR_renameat2 (__NR_SYSCALL_BASE+382)/* -* This may need to be greater than __NR_last_syscall+1 in order to -* account for the padding in the syscall table -*/ - -/* * The following SWIs are ARM private. */ #define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000)
@@ -426,12 +421,6 @@#define __ARM_NR_set_tls (__ARM_NR_BASE+5)/* -* *NOTE*: This is a ghost syscall private to the kernel. Only the -* __kuser_cmpxchg code in entry-armv.S should be aware of its -* existence. Don't ever use this from user code. -*/ - -/* * The following syscalls are obsolete and no longer available for EABI. */ #if !defined(__KERNEL__)
Greg Kroah-Hartman
maintainerPATCH 36/125 drm: omapdrm: fix compiler errors
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Russell King <[email protected]>
commit 2d31ca3ad7d5d44c8adc7f253c96ce33f3a2e931 upstream.
Regular randconfig nightly testing has detected problems with omapdrm.
omapdrm fails to build when the kernel is built to support 64-bit DMA addresses and/or 64-bit physical addresses due to an assumption about the width of these types.
Use %pad to print DMA addresses, rather than %x or %Zx (which is even more wrong than %x). Avoid passing a uint32_t pointer into a function which expects dma_addr_t pointer.
drivers/gpu/drm/omapdrm/omap_plane.c: In function 'omap_plane_pre_apply':drivers/gpu/drm/omapdrm/omap_plane.c:145:2: error: format '%x' expects argument of type 'unsigned int', but argument 5 has type 'dma_addr_t' [-Werror=format] drivers/gpu/drm/omapdrm/omap_plane.c:145:2: error: format '%x' expects argument of type 'unsigned int', but argument 6 has type 'dma_addr_t' [-Werror=format] make[5]: *** [drivers/gpu/drm/omapdrm/omap_plane.o] Error 1drivers/gpu/drm/omapdrm/omap_gem.c: In function 'omap_gem_get_paddr':drivers/gpu/drm/omapdrm/omap_gem.c:794:4: error: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'dma_addr_t' [-Werror=format] drivers/gpu/drm/omapdrm/omap_gem.c: In function 'omap_gem_describe':drivers/gpu/drm/omapdrm/omap_gem.c:991:4: error: format '%Zx' expects argument of type 'size_t', but argument 7 has type 'dma_addr_t' [-Werror=format] drivers/gpu/drm/omapdrm/omap_gem.c: In function 'omap_gem_init':drivers/gpu/drm/omapdrm/omap_gem.c:1470:4: error: format '%x' expects argument of type 'unsigned int', but argument 7 has type 'dma_addr_t' [-Werror=format] make[5]: *** [drivers/gpu/drm/omapdrm/omap_gem.o] Error 1drivers/gpu/drm/omapdrm/omap_dmm_tiler.c: In function 'dmm_txn_append':drivers/gpu/drm/omapdrm/omap_dmm_tiler.c:226:2: error: passing argument 3 of 'alloc_dma' from incompatible pointer type [-Werror] make[5]: *** [drivers/gpu/drm/omapdrm/omap_dmm_tiler.o] Error 1
make[5]: Target `__build' not remade because of errors.
make[4]: *** [drivers/gpu/drm/omapdrm] Error 2
--- drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 6 ++++-- drivers/gpu/drm/omapdrm/omap_gem.c | 10 +++++----- drivers/gpu/drm/omapdrm/omap_plane.c | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-)
drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +4 -2
@@ -199,7 +199,7 @@ static struct dmm_txn *dmm_txn_init(strustatic void dmm_txn_append (struct dmm_txn *txn,struct pat_area *area,struct page **pages,uint32_t npages,uint32_t roll) { -dma_addr_t pat_pa =0 ; +dma_addr_t pat_pa =0 , data_pa =0 ;uint32_t *data;struct pat *pat;struct refill_engine *engine = txn->engine_handle;
@@ -223,7 +223,9 @@ static void dmm_txn_append(struct dmm_tx .lut_id = engine->tcm->lut_id, }; - data =alloc_dma (txn,4 *i, &pat->data_pa); + data =alloc_dma (txn,4 *i, &data_pa); +/* FIXME: what if data_pa is more than 32-bit ? */ + pat->data_pa = data_pa;while (i--) {int n = i + roll;
drivers/gpu/drm/omapdrm/omap_gem.c +5 -5
@@ -791,7 +791,7 @@ int omap_gem_get_paddr(struct drm_gem_ob omap_obj->paddr =tiler_ssptr (block); omap_obj->block = block; -DBG ("got paddr: %08x" , omap_obj->paddr); +DBG ("got paddr: %pad" , &omap_obj->paddr); } omap_obj->paddr_cnt++;
@@ -985,9 +985,9 @@ void omap_gem_describe(struct drm_gem_ob off =drm_vma_node_start (&obj->vma_node); -seq_printf (m,"%08x: %2d (%2d) %08llx %08Zx (%2d) %p %4d" , +seq_printf (m,"%08x: %2d (%2d) %08llx %pad (%2d) %p %4d" , omap_obj->flags, obj->name, obj->refcount.refcount.counter, - off, omap_obj->paddr, omap_obj->paddr_cnt, + off, &omap_obj->paddr, omap_obj->paddr_cnt, omap_obj->vaddr, omap_obj->roll);if (omap_obj->flags &OMAP_BO_TILED ) {
@@ -1467,8 +1467,8 @@ void omap_gem_init(struct drm_device *de entry->paddr =tiler_ssptr (block); entry->block = block; -DBG ("%d:%d: %dx%d: paddr=%08x stride=%d" , i, j, w, h, - entry->paddr, +DBG ("%d:%d: %dx%d: paddr=%pad stride=%d" , i, j, w, h, + &entry->paddr, usergart[i].stride_pfn <<PAGE_SHIFT ); } }
drivers/gpu/drm/omapdrm/omap_plane.c +2 -2
@@ -142,8 +142,8 @@ static void omap_plane_pre_apply(structDBG ("%dx%d -> %dx%d (%d)" , info->width, info->height, info->out_width, info->out_height, info->screen_width); -DBG ("%d,%d %08x %08x" , info->pos_x, info->pos_y, - info->paddr, info->p_uv_addr); +DBG ("%d,%d %pad %pad" , info->pos_x, info->pos_y, + &info->paddr, &info->p_uv_addr);/* TODO: */ ilace = false;
Greg Kroah-Hartman
maintainerPATCH 37/125 mmc: mmci: Remove redundant check of status for DATA irq
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ulf Hansson <[email protected]>
commit 1cb9da502835dad73dda772b20c1e792f4e71589 upstream.
We don't need to verify the content of the status register twice, while we are about to handle a DATA irq. Instead let's leave all verification to be handled by mmci_data_irq().
--- drivers/mmc/host/mmci.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/mmc/host/mmci.c +5 -6
@@ -834,6 +834,10 @@ static void mmci_data_irq(struct mmci_host *host, struct mmc_data *data, unsigned int status) { + /* Make sure we have data to handle */ + if (!data) + return; +/* First check for errors */ if (status & (MCI_DATACRCFAIL |MCI_DATATIMEOUT |MCI_STARTBITERR |MCI_TXUNDERRUN |MCI_RXOVERRUN )) {
@@ -1133,7 +1137,6 @@ static irqreturn_t mmci_irq(int irq, voi do { struct mmc_command *cmd; - struct mmc_data *data; status = readl(host->base + MMCISTATUS);
@@ -1159,11 +1162,7 @@ static irqreturn_t mmci_irq(int irq, voi MCI_CMDSENT|MCI_CMDRESPEND) && cmd)mmci_cmd_irq (host, cmd, status); - data = host->data; -if (status & (MCI_DATACRCFAIL |MCI_DATATIMEOUT |MCI_STARTBITERR | -MCI_TXUNDERRUN |MCI_RXOVERRUN |MCI_DATAEND | -MCI_DATABLOCKEND ) && data) -mmci_data_irq (host, data, status); +mmci_data_irq (host, host->data, status);/* Don't poll for busy completion in irq context. */ if (host->busy_status)
Greg Kroah-Hartman
maintainerPATCH 38/125 mmc: mmci: Move all CMD irq handling to mmci_cmd_irq()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ulf Hansson <[email protected]>
commit ad82bfea44835da9633548e2031a1af4a9965c14 upstream.
This patch won't change the behavior of how mmci deals with CMD irqs. By moving code from mmci_irq() to mmci_cmd_irq(), we getter a better overview of what going on.
--- drivers/mmc/host/mmci.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/mmc/host/mmci.c +12 -10
@@ -906,9 +906,17 @@ mmci_cmd_irq(struct mmci_host *host, str unsigned int status) {void __iomem *base = host->base; -bool sbc = (cmd == host->mrq->sbc); -bool busy_resp = host->variant->busy_detect && - (cmd->flags &MMC_RSP_BUSY ); +bool sbc, busy_resp; + +if (!cmd) +return ; + + sbc = (cmd == host->mrq->sbc); + busy_resp = host->variant->busy_detect && (cmd->flags &MMC_RSP_BUSY ); + +if (!((status|host->busy_status) & (MCI_CMDCRCFAIL |MCI_CMDTIMEOUT | +MCI_CMDSENT |MCI_CMDRESPEND ))) +return ;/* Check if we need to wait for busy completion. */ if (host->busy_status && (status &MCI_ST_CARDBUSY ))
@@ -1136,8 +1144,6 @@ static irqreturn_t mmci_irq(int irq, voispin_lock (&host->lock); do { - struct mmc_command *cmd; - status = readl(host->base + MMCISTATUS); if (host->singleirq) {
@@ -1157,11 +1163,7 @@ static irqreturn_t mmci_irq(int irq, voidev_dbg (mmc_dev (host->mmc),"irq0 (data+cmd) %08x\n" , status); - cmd = host->cmd; -if ((status|host->busy_status) & (MCI_CMDCRCFAIL |MCI_CMDTIMEOUT | -MCI_CMDSENT |MCI_CMDRESPEND ) && cmd) -mmci_cmd_irq (host, cmd, status); - +mmci_cmd_irq (host, host->cmd, status);mmci_data_irq (host, host->data, status);/* Don't poll for busy completion in irq context. */
Greg Kroah-Hartman
maintainerPATCH 39/125 hwmon: (sis5595) Prevent overflow problem when writing large limits
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Axel Lin <[email protected]>
commit cc336546ddca8c22de83720632431c16a5f9fe9a upstream.
On platforms with sizeof(int) < sizeof(long), writing a temperature limit larger than MAXINT will result in unpredictable limit values written to the chip. Avoid auto-conversion from long to int to fix the problem.
--- drivers/hwmon/sis5595.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/sis5595.c +1 -1
@@ -159,7 +159,7 @@ static inline int TEMP_FROM_REG(s8 val) {return val *830 +52120 ; } -static inline s8 TEMP_TO_REG (int val) +static inline s8 TEMP_TO_REG (long val) {int nval =clamp_val (val,-54120 ,157530 ) ;return nval <0 ? (nval -5212 -415 ) /830 : (nval -5212 +415 ) /830 ;
Greg Kroah-Hartman
maintainerPATCH 40/125 hwmon: (amc6821) Fix possible race condition bug
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Axel Lin <[email protected]>
commit cf44819c98db11163f58f08b822d626c7a8f5188 upstream.
Ensure mutex lock protects the read-modify-write period to prevent possible race condition bug.
In additional, update data->valid should also be protected by the mutex lock.
--- drivers/hwmon/amc6821.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/hwmon/amc6821.c +11 -6
@@ -360,11 +360,13 @@ static ssize_t set_pwm1_enable(if (config)return config; +mutex_lock (&data->update_lock); config =i2c_smbus_read_byte_data (client,AMC6821_REG_CONF1 );if (config <0 ) {dev_err (&client->dev,"Error reading configuration register, aborting.\n" ); -return config; + count = config; + goto unlock; }switch (val) {
@@ -381,14 +383,15 @@ static ssize_t set_pwm1_enable( config |=AMC6821_CONF1_FDRC1 ;break ;default : -return -EINVAL ; + count = -EINVAL ; + goto unlock; } -mutex_lock (&data->update_lock);if (i2c_smbus_write_byte_data (client,AMC6821_REG_CONF1 , config)) {dev_err (&client->dev,"Configuration register write error, aborting.\n" ); count = -EIO ; } +unlock:mutex_unlock (&data->update_lock);return count; }
@@ -493,8 +496,9 @@ static ssize_t set_temp_auto_point_temp(return -EINVAL ; } - data->valid =0 ;mutex_lock (&data->update_lock); + data->valid =0 ; +switch (ix) {case 0 : ptemp[0] = clamp_val(val / 1000, 0,
@@ -658,13 +662,14 @@ static ssize_t set_fan1_div(if (config)return config; +mutex_lock (&data->update_lock); config =i2c_smbus_read_byte_data (client,AMC6821_REG_CONF4 );if (config <0 ) {dev_err (&client->dev,"Error reading configuration register, aborting.\n" ); -return config; + count = config; + goto EXIT; } -mutex_lock (&data->update_lock);switch (val) {case 2 : config &= ~AMC6821_CONF4_PSPR ;
Greg Kroah-Hartman
maintainerPATCH 41/125 hwmon: (lm78) Fix overflow problems seen when writing large temperature limits
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
commit 1074d683a51f1aded3562add9ef313e75d557327 upstream.
On platforms with sizeof(int) < sizeof(long), writing a temperature limit larger than MAXINT will result in unpredictable limit values written to the chip. Avoid auto-conversion from long to int to fix the problem.
--- drivers/hwmon/lm78.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/lm78.c +1 -1
@@ -108,7 +108,7 @@ static inline int FAN_FROM_REG(u8 val, i* TEMP: mC (-128C to +127C) * REG: 1C/bit, two's complement */ -static inline s8 TEMP_TO_REG (int val) +static inline s8 TEMP_TO_REG (long val) {int nval =clamp_val (val,-128000 ,127000 ) ;return nval <0 ? (nval -500 ) /1000 : (nval +500 ) /1000 ;
Greg Kroah-Hartman
maintainerPATCH 42/125 hwmon: (gpio-fan) Prevent overflow problem when writing large limits
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Axel Lin <[email protected]>
commit 2565fb05d1e9fc0831f7b1c083bcfcb1cba1f020 upstream.
On platforms with sizeof(int) < sizeof(unsigned long), writing a rpm value larger than MAXINT will result in unpredictable limit values written to the chip. Avoid auto-conversion from unsigned long to int to fix the problem.
--- drivers/hwmon/gpio-fan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/gpio-fan.c +1 -1
@@ -173,7 +173,7 @@ static int get_fan_speed_index(struct gpreturn -ENODEV ; } -static int rpm_to_speed_index (struct gpio_fan_data *fan_data,int rpm) +static int rpm_to_speed_index (struct gpio_fan_data *fan_data,unsigned long rpm) {struct gpio_fan_speed *speed = fan_data->speed;int i;
Greg Kroah-Hartman
maintainerPATCH 43/125 hwmon: (ads1015) Fix off-by-one for valid channel index checking
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Axel Lin <[email protected]>
commit 56de1377ad92f72ee4e5cb0faf7a9b6048fdf0bf upstream.
Current code uses channel as array index, so the valid channel value is 0 .. ADS1015_CHANNELS - 1.
--- drivers/hwmon/ads1015.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/ads1015.c +1 -1
@@ -198,7 +198,7 @@ static int ads1015_get_channels_config_o } channel =be32_to_cpup (property); -if (channel >ADS1015_CHANNELS ) { +if (channel >=ADS1015_CHANNELS ) {dev_err (&client->dev,"invalid channel index %d on %s\n" , channel, node->full_name);
Greg Kroah-Hartman
maintainerPATCH 44/125 hwmon: (lm85) Fix various errors on attribute writes
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
commit 3248c3b771ddd9d31695da17ba350eb6e1b80a53 upstream.
Temperature limit register writes did not account for negative numbers. As a result, writing -127000 resulted in -126000 written into the temperature limit register. This problem affected temp[1-3]_min, temp[1-3]_max, temp[1-3]_auto_temp_crit, and temp[1-3]_auto_temp_min.
When writing pwm[1-3]_freq, a long variable was auto-converted into an int without range check. Wiring values larger than MAXINT resulted in unexpected register values.
When writing temp[1-3]_auto_temp_max, an unsigned long variable was auto-converted into an int without range check. Writing values larger than MAXINT resulted in unexpected register values.
vrm is an u8, so the written value needs to be limited to [0, 255].
--- drivers/hwmon/lm85.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/hwmon/lm85.c +6 -3
@@ -155,7 +155,7 @@ static inline u16 FAN_TO_REG(unsigned lo/* Temperature is reported in .001 degC increments */ #define TEMP_TO_REG (val) \ - clamp_val(SCALE(val, 1000, 1), -127, 127) + DIV_ROUND_CLOSEST(clamp_val((val), -127000, 127000), 1000)#define TEMPEXT_FROM_REG (val, ext) \ SCALE(((val) << 4) + (ext), 16, 1000)#define TEMP_FROM_REG (val) ((val) * 1000)
@@ -189,7 +189,7 @@ static const int lm85_range_map[] = { 13300, 16000, 20000, 26600, 32000, 40000, 53300, 80000 }; -static int RANGE_TO_REG (int range) +static int RANGE_TO_REG (long range) {int i;
@@ -211,7 +211,7 @@ static const int adm1027_freq_map[8] = { 11, 15, 22, 29, 35, 44, 59, 88 }; -static int FREQ_TO_REG (const int *map,int freq) +static int FREQ_TO_REG (const int *map,unsigned long freq) {int i;
@@ -460,6 +460,9 @@ static ssize_t store_vrm_reg(struct deviif (err)return err; +if (val >255 ) +return -EINVAL ; + data->vrm = val;return count; }
Greg Kroah-Hartman
maintainerPATCH 45/125 hwmon: (ads1015) Fix out-of-bounds array access
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Axel Lin <[email protected]>
commit e981429557cbe10c780fab1c1a237cb832757652 upstream.
Current code uses data_rate as array index in ads1015_read_adc() and uses pga as array index in ads1015_reg_to_mv, so we must make sure both data_rate and pga settings are in valid value range.
Return -EINVAL if the setting is out-of-range.
--- drivers/hwmon/ads1015.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hwmon/ads1015.c +2 -0
@@ -212,6 +212,7 @@ static int ads1015_get_channels_config_odev_err (&client->dev,"invalid gain on %s\n" , node->full_name); +return -EINVAL ; } }
@@ -222,6 +223,7 @@ static int ads1015_get_channels_config_odev_err (&client->dev,"invalid data_rate on %s\n" , node->full_name); +return -EINVAL ; } }
Greg Kroah-Hartman
maintainerPATCH 46/125 hwmon: (dme1737) Prevent overflow problem when writing large limits
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Axel Lin <[email protected]>
commit d58e47d787c09fe5c61af3c6ce7d784762f29c3d upstream.
On platforms with sizeof(int) < sizeof(long), writing a temperature limit larger than MAXINT will result in unpredictable limit values written to the chip. Avoid auto-conversion from long to int to fix the problem.
Voltage limits, fan minimum speed, pwm frequency, pwm ramp rate, and other attributes have the same problem, fix them as well.
Zone temperature limits are signed, but were cached as u8, causing unepected values to be reported for negative temperatures. Cache as s8 to fix the problem.
vrm is an u8, so the written value needs to be limited to [0, 255].
--- drivers/hwmon/dme1737.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
drivers/hwmon/dme1737.c +18 -15
@@ -247,8 +247,8 @@ struct dme1737_data {u8 pwm_acz[3 ];u8 pwm_freq[6 ];u8 pwm_rr[2 ]; -u8 zone_low[3 ]; -u8 zone_abs[3 ]; +s8 zone_low[3 ]; +s8 zone_abs[3 ];u8 zone_hyst[2 ];u32 alarms; };
@@ -277,7 +277,7 @@ static inline int IN_FROM_REG(int reg, ireturn (reg * nominal + (3 << (res -3 ))) / (3 << (res -2 )); } -static inline int IN_TO_REG (int val,int nominal) +static inline int IN_TO_REG (long val,int nominal) {return clamp_val ((val *192 + nominal /2 ) / nominal,0 ,255 ); }
@@ -293,7 +293,7 @@ static inline int TEMP_FROM_REG(int reg,return (reg *1000 ) >> (res -8 ); } -static inline int TEMP_TO_REG (int val) +static inline int TEMP_TO_REG (long val) {return clamp_val ((val <0 ? val -500 : val +500 ) /1000 ,-128 ,127 ); }
@@ -308,7 +308,7 @@ static inline int TEMP_RANGE_FROM_REG(inreturn TEMP_RANGE [(reg >>4 ) &0x0f ]; } -static int TEMP_RANGE_TO_REG (int val,int reg) +static int TEMP_RANGE_TO_REG (long val,int reg) {int i;
@@ -331,7 +331,7 @@ static inline int TEMP_HYST_FROM_REG(intreturn (((ix ==1 ) ? reg : reg >>4 ) &0x0f ) *1000 ; } -static inline int TEMP_HYST_TO_REG (int val,int ix,int reg) +static inline int TEMP_HYST_TO_REG (long val,int ix,int reg) {int hyst =clamp_val ((val +500 ) /1000 ,0 ,15 );
@@ -347,7 +347,7 @@ static inline int FAN_FROM_REG(int reg,return (reg ==0 || reg ==0xffff ) ?0 :90000 *60 / reg; } -static inline int FAN_TO_REG (int val,int tpc) +static inline int FAN_TO_REG (long val,int tpc) {if (tpc) {return clamp_val (val / tpc,0 ,0xffff );
@@ -379,7 +379,7 @@ static inline int FAN_TYPE_FROM_REG(intreturn (edge >0 ) ?1 << (edge -1 ) :0 ; } -static inline int FAN_TYPE_TO_REG (int val,int reg) +static inline int FAN_TYPE_TO_REG (long val,int reg) {int edge = (val ==4 ) ?3 : val;
@@ -402,7 +402,7 @@ static int FAN_MAX_FROM_REG(int reg)return 1000 + i *500 ; } -static int FAN_MAX_TO_REG (int val) +static int FAN_MAX_TO_REG (long val) {int i;
@@ -460,7 +460,7 @@ static inline int PWM_ACZ_FROM_REG(int rreturn acz[(reg >>5 ) &0x07 ]; } -static inline int PWM_ACZ_TO_REG (int val,int reg) +static inline int PWM_ACZ_TO_REG (long val,int reg) {int acz = (val ==4 ) ?2 : val -1 ;
@@ -476,7 +476,7 @@ static inline int PWM_FREQ_FROM_REG(intreturn PWM_FREQ [reg &0x0f ]; } -static int PWM_FREQ_TO_REG (int val,int reg) +static int PWM_FREQ_TO_REG (long val,int reg) {int i;
@@ -510,7 +510,7 @@ static inline int PWM_RR_FROM_REG(int rereturn (rr &0x08 ) ?PWM_RR [rr &0x07 ] :0 ; } -static int PWM_RR_TO_REG (int val,int ix,int reg) +static int PWM_RR_TO_REG (long val,int ix,int reg) {int i;
@@ -528,7 +528,7 @@ static inline int PWM_RR_EN_FROM_REG(intreturn PWM_RR_FROM_REG (reg, ix) ?1 :0 ; } -static inline int PWM_RR_EN_TO_REG (int val,int ix,int reg) +static inline int PWM_RR_EN_TO_REG (long val,int ix,int reg) {int en = (ix ==1 ) ?0x80 :0x08 ;
@@ -1481,13 +1481,16 @@ static ssize_t set_vrm(struct device *de const char *buf, size_t count) {struct dme1737_data *data =dev_get_drvdata (dev); -long val; +unsigned long val;int err; - err =kstrtol (buf,10 , &val); + err =kstrtoul (buf,10 , &val);if (err)return err; +if (val >255 ) +return -EINVAL ; + data->vrm = val;return count; }
Greg Kroah-Hartman
maintainerPATCH 47/125 hwmon: (lm92) Prevent overflow problem when writing large limits
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Axel Lin <[email protected]>
commit 5b963089161b8fb244889c972edf553b9d737545 upstream.
On platforms with sizeof(int) < sizeof(long), writing a temperature limit larger than MAXINT will result in unpredictable limit values written to the chip. Avoid auto-conversion from long to int to fix the problem.
The hysteresis temperature range depends on the value of data->temp[attr->index], since val is subtracted from it. Use a wider clamp, [-120000, 220000] should do to cover the possible range. Also add missing TEMP_TO_REG() on writes into cached hysteresis value.
Also uses clamp_val to simplify the code a bit.
--- drivers/hwmon/lm92.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/hwmon/lm92.c +6 -7
@@ -74,12 +74,9 @@ static inline int TEMP_FROM_REG(s16 reg)return reg /8 *625 /10 ; } -static inline s16 TEMP_TO_REG (int val) +static inline s16 TEMP_TO_REG (long val) { -if (val <=-60000 ) -return -60000 *10 /625 *8 ; -if (val >=160000 ) -return 160000 *10 /625 *8 ; + val =clamp_val (val,-60000 ,160000 );return val *10 /625 *8 ; }
@@ -206,10 +203,12 @@ static ssize_t set_temp_hyst(struct deviif (err)return err; + val =clamp_val (val,-120000 ,220000 );mutex_lock (&data->update_lock); - data->temp[t_hyst] =TEMP_FROM_REG (data->temp[attr->index]) - val; + data->temp[t_hyst] = +TEMP_TO_REG (TEMP_FROM_REG (data->temp[attr->index]) - val);i2c_smbus_write_word_swapped (client,LM92_REG_TEMP_HYST , -TEMP_TO_REG (data->temp[t_hyst])); + data->temp[t_hyst]);mutex_unlock (&data->update_lock);return count; }
Greg Kroah-Hartman
maintainerPATCH 48/125 tpm: Add missing tpm_do_selftest to ST33 I2C driver
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
commit f07a5e9a331045e976a3d317ba43d14859d9407c upstream.
Most device drivers do call 'tpm_do_selftest' which executes a TPM_ContinueSelfTest. tpm_i2c_stm_st33 is just pointlessly different, I think it is bug.
These days we have the general assumption that the TPM is usable by the kernel immediately after the driver is finished, so we can no longer defer the mandatory self test to userspace.
--- drivers/char/tpm/tpm_i2c_stm_st33.c | 1 + 1 file changed, 1 insertion(+)
drivers/char/tpm/tpm_i2c_stm_st33.c +1 -0
@@ -714,6 +714,7 @@ tpm_st33_i2c_probe(struct i2c_client *cl }tpm_get_timeouts (chip); +tpm_do_selftest (chip);dev_info (chip->dev,"TPM I2C Initialized\n" );return 0 ;
Greg Kroah-Hartman
maintainerPATCH 49/125 drivers/i2c/busses: use correct type for dma_map/unmap
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
commit 28772ac8711e4d7268c06e765887dd8cb6924f98 upstream.
dma_{un}map_* uses 'enum dma_data_direction' not 'enum dma_transfer_direction'.
--- drivers/i2c/busses/i2c-at91.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-at91.c +2 -2
@@ -210,7 +210,7 @@ static void at91_twi_write_data_dma_callstruct at91_twi_dev *dev = (struct at91_twi_dev *)data;dma_unmap_single (dev->dev,sg_dma_address (&dev->dma.sg), - dev->buf_len,DMA_MEM_TO_DEV ); + dev->buf_len,DMA_TO_DEVICE );at91_twi_write (dev,AT91_TWI_CR ,AT91_TWI_STOP ); }
@@ -289,7 +289,7 @@ static void at91_twi_read_data_dma_callbstruct at91_twi_dev *dev = (struct at91_twi_dev *)data;dma_unmap_single (dev->dev,sg_dma_address (&dev->dma.sg), - dev->buf_len,DMA_DEV_TO_MEM ); + dev->buf_len,DMA_FROM_DEVICE );/* The last two bytes have to be read without using dma */ dev->buf += dev->buf_len -2 ;
Greg Kroah-Hartman
maintainerPATCH 50/125 i2c: rk3x: fix interrupt handling issue
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: addy ke <[email protected]>
commit 9c5f7cad3acc69ce623d04d646950183a759949e upstream.
If slave holds scl, I2C_IPD[7] will be set 1 by controller for debugging. Driver must ignore it.
[ 5.752391] rk3x-i2c ff160000.i2c: unexpected irq in WRITE: 0x80 [ 5.939027] rk3x-i2c ff160000.i2c: timeout, ipd: 0x80, state: 4
--- drivers/i2c/busses/i2c-rk3x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-rk3x.c +1 -1
@@ -399,7 +399,7 @@ static irqreturn_t rk3x_i2c_irq(int irqn }/* is there anything left to handle? */ -if (unlikely (ipd ==0 )) +if (unlikely ((ipd ®_INT_ALL ) ==0 )) goto out;switch (i2c->state) {
Greg Kroah-Hartman
maintainerPATCH 51/125 ext4: fix punch hole on files with indirect mapping
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Czerner <[email protected]>
commit 4f579ae7de560e5f449587a6c3f02594d53d4d51 upstream.
Currently punch hole code on files with direct/indirect mapping has some problems which may lead to a data loss. For example (from Jan Kara):
fallocate -n -p 10240000 4096
will punch the range 10240000 - 12632064 instead of the range 1024000 - 10244096.
Also the code is a bit weird and it's not using infrastructure provided by indirect.c, but rather creating it's own way.
This patch fixes the issues as well as making the operation to run 4 times faster from my testing (punching out 60GB file). It uses similar approach used in ext4_ind_truncate() which takes advantage of ext4_free_branches() function.
Also rename the ext4_free_hole_blocks() to something more sensible, like the equivalent we have for extent mapped files. Call it ext4_ind_remove_space().
This has been tested mostly with fsx and some xfstests which are testing punch hole but does not require unwritten extents which are not supported with direct/indirect mapping. Not problems showed up even with 1024k block size.
--- fs/ext4/ext4.h | 4 fs/ext4/indirect.c | 283 ++++++++++++++++++++++++++++++++++++++--------------- fs/ext4/inode.c | 2 3 files changed, 206 insertions(+), 83 deletions(-)
fs/ext4/ext4.h +2 -2
@@ -2144,8 +2144,8 @@ extern ssize_t ext4_ind_direct_IO(int rwextern int ext4_ind_calc_metadata_amount (struct inode *inode,sector_t lblock);extern int ext4_ind_trans_blocks (struct inode *inode,int nrblocks);extern void ext4_ind_truncate (handle_t *,struct inode *inode); -extern int ext4_free_hole_blocks (handle_t *handle,struct inode *inode, -ext4_lblk_t first,ext4_lblk_t stop); +extern int ext4_ind_remove_space (handle_t *handle,struct inode *inode, +ext4_lblk_t start,ext4_lblk_t end);/* ioctl.c */ extern long ext4_ioctl (struct file *,unsigned int ,unsigned long );
fs/ext4/indirect.c +203 -80
300 lines not on this page · raw message
fs/ext4/inode.c +1 -1
@@ -3624,7 +3624,7 @@ int ext4_punch_hole(struct inode *inode, ret =ext4_ext_remove_space (inode, first_block, stop_block -1 ); else - ret =ext4_free_hole_blocks (handle, inode, first_block, + ret =ext4_ind_remove_space (handle, inode, first_block, stop_block);up_write (&EXT4_I (inode)->i_data_sem);
Greg Kroah-Hartman
maintainerPATCH 52/125 ext4: fix ext4_discard_allocated_blocks() if we cant allocate the pa struct
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit 86f0afd463215fc3e58020493482faa4ac3a4d69 upstream.
If there is a failure while allocating the preallocation structure, a number of blocks can end up getting marked in the in-memory buddy bitmap, and then not getting released. This can result in the following corruption getting reported by the kernel:
EXT4-fs error (device sda3): ext4_mb_generate_buddy:758: group 1126, 12793 clusters in bitmap, 12729 in gd
In that case, we need to release the blocks using mb_free_blocks().
Tested: fs smoke test; also demonstrated that with injected errors,
the file system is no longer getting corrupted
Google-Bug-Id: 16657874
--- fs/ext4/mballoc.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
fs/ext4/mballoc.c +20 -1
@@ -3216,8 +3216,27 @@ static void ext4_mb_collect_stats(structstatic void ext4_discard_allocated_blocks (struct ext4_allocation_context *ac) {struct ext4_prealloc_space *pa = ac->ac_pa; +struct ext4_buddy e4b; +int err; -if (pa && pa->pa_type ==MB_INODE_PA ) +if (pa ==NULL ) { + err =ext4_mb_load_buddy (ac->ac_sb, ac->ac_f_ex.fe_group, &e4b); +if (err) { +/* +* This should never happen since we pin the +* pages in the ext4_allocation_context so +* ext4_mb_load_buddy() should never fail. +*/ +WARN (1 ,"mb_load_buddy failed (%d)" , err); +return ; + } +ext4_lock_group (ac->ac_sb, ac->ac_f_ex.fe_group); +mb_free_blocks (ac->ac_inode, &e4b, ac->ac_f_ex.fe_start, + ac->ac_f_ex.fe_len); +ext4_unlock_group (ac->ac_sb, ac->ac_f_ex.fe_group); +return ; + } +if (pa->pa_type ==MB_INODE_PA ) pa->pa_free += ac->ac_b_ex.fe_len; }
Greg Kroah-Hartman
maintainerPATCH 53/125 serial: core: Preserve termios c_cflag for console resume
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Hurley <[email protected]>
commit ae84db9661cafc63d179e1d985a2c5b841ff0ac4 upstream.
When a tty is opened for the serial console, the termios c_cflag settings are inherited from the console line settings. However, if the tty is subsequently closed, the termios settings are lost. This results in a garbled console if the console is later suspended and resumed.
Preserve the termios c_cflag for the serial console when the tty is shutdown; this reflects the most recent line settings.
--- drivers/tty/serial/serial_core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/tty/serial/serial_core.c +3 -0
@@ -243,6 +243,9 @@ static void uart_shutdown(struct tty_str/* * Turn off DTR and RTS early. */ +if (uart_console (uport) && tty) + uport->cons->cflag = tty->termios.c_cflag; +if (!tty || (tty->termios.c_cflag &HUPCL ))uart_clear_mctrl (uport,TIOCM_DTR |TIOCM_RTS );
Greg Kroah-Hartman
maintainerPATCH 54/125 crypto: ux500 - make interrupt mode plausible
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit e1f8859ee265fc89bd21b4dca79e8e983a044892 upstream.
The interrupt handler in the ux500 crypto driver has an obviously incorrect way to access the data buffer, which for a while has caused this build warning:
../ux500/cryp/cryp_core.c: In function 'cryp_interrupt_handler':../ux500/cryp/cryp_core.c:234:5: warning: passing argument 1 of '__fswab32' makes integer from pointer without a cast [enabled by default]
writel_relaxed(ctx->indata,
^
In file included from ../include/linux/swab.h:4:0,
from ../include/uapi/linux/byteorder/big_endian.h:12,
from ../include/linux/byteorder/big_endian.h:4,
from ../arch/arm/include/uapi/asm/byteorder.h:19,
from ../include/asm-generic/bitops/le.h:5,
from ../arch/arm/include/asm/bitops.h:340,
from ../include/linux/bitops.h:33,
from ../include/linux/kernel.h:10,
from ../include/linux/clk.h:16,
from ../drivers/crypto/ux500/cryp/cryp_core.c:12:../include/uapi/linux/swab.h:57:119: note: expected '__u32' but argument is of type 'const u8 *'
static inline __attribute_const__ __u32 __fswab32(__u32 val)
There are at least two, possibly three problems here:
a) when writing into the FIFO, we copy the pointer rather than the actual data we want to give to the hardware
b) the data pointer is an array of 8-bit values, while the FIFO is 32-bit wide, so both the read and write access fail to do a proper type conversion
c) This seems incorrect for big-endian kernels, on which we need to byte-swap any register access, but not normally FIFO accesses, at least the DMA case doesn't do it either.
This converts the bogus loop to use the same readsl/writesl pair that we use for the two other modes (DMA and polling). This is more efficient and consistent, and probably correct for endianess.
The bug has existed since the driver was first merged, and was probably never detected because nobody tried to use interrupt mode. It might make sense to backport this fix to stable kernels, depending on how the crypto maintainers feel about that.
--- drivers/crypto/ux500/cryp/cryp_core.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/crypto/ux500/cryp/cryp_core.c +12 -13
@@ -190,7 +190,7 @@ static void add_session_id(struct cryp_cstatic irqreturn_t cryp_interrupt_handler (int irq,void *param) {struct cryp_ctx *ctx; -int i; +int count;struct cryp_device_data *device_data;if (param ==NULL ) {
@@ -215,12 +215,11 @@ static irqreturn_t cryp_interrupt_handleif (cryp_pending_irq_src (device_data,CRYP_IRQ_SRC_OUTPUT_FIFO )) {if (ctx->outlen / ctx->blocksize >0 ) { -for (i =0 ; i < ctx->blocksize /4 ; i++) { - *(ctx->outdata) =readl_relaxed ( - &device_data->base->dout); - ctx->outdata +=4 ; - ctx->outlen -=4 ; - } + count = ctx->blocksize /4 ; + +readsl (&device_data->base->dout, ctx->outdata, count); + ctx->outdata += count; + ctx->outlen -= count;if (ctx->outlen ==0 ) { cryp_disable_irq_src(device_data,
@@ -230,12 +229,12 @@ static irqreturn_t cryp_interrupt_handle }else if (cryp_pending_irq_src (device_data,CRYP_IRQ_SRC_INPUT_FIFO )) {if (ctx->datalen / ctx->blocksize >0 ) { -for (i =0 ; i < ctx->blocksize /4 ; i++) { -writel_relaxed (ctx->indata, - &device_data->base->din); - ctx->indata +=4 ; - ctx->datalen -=4 ; - } + count = ctx->blocksize /4 ; + +writesl (&device_data->base->din, ctx->indata, count); + + ctx->indata += count; + ctx->datalen -= count;if (ctx->datalen ==0 ) cryp_disable_irq_src(device_data,
Greg Kroah-Hartman
maintainerPATCH 55/125 debugfs: Fix corrupted loop in debugfs_remove_recursive
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
commit 485d44022a152c0254dd63445fdb81c4194cbf0e upstream.
[ I'm currently running my tests on it now, and so far, after a few
hours it has yet to blow up. I'll run it for 24 hours which it never succeeded in the past. ]
The tracing code has a way to make directories within the debugfs file system as well as deleting them using mkdir/rmdir in the instance directory. This is very limited in functionality, such as there is no renames, and the parent directory "instance" can not be modified. The tracing code creates the instance directory from the debugfs code and then replaces the dentry->d_inode->i_op with its own to allow for mkdir/rmdir to work.
When these are called, the d_entry and inode locks need to be released to call the instance creation and deletion code. That code has its own accounting and locking to serialize everything to prevent multiple users from causing harm. As the parent "instance" directory can not be modified this simplifies things.
I created a stress test that creates several threads that randomly creates and deletes directories thousands of times a second. The code stood up to this test and I submitted it a while ago.
Recently I added a new test that adds readers to the mix. While the instance directories were being added and deleted, readers would read from these directories and even enable tracing within them. This test was able to trigger a bug:
general protection fault: 0000 [#1] PREEMPT SMP Modules linked in: ... CPU: 3 PID: 17789 Comm: rmdir Tainted: G W 3.15.0-rc2-test+ #41 Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./To be filled by O.E.M., BIOS SDBLI944.86P 05/08/2007 task: ffff88003786ca60 ti: ffff880077018000 task.ti: ffff880077018000 RIP: 0010:[<ffffffff811ed5eb>] [<ffffffff811ed5eb>] debugfs_remove_recursive+0x1bd/0x367 RSP: 0018:ffff880077019df8 EFLAGS: 00010246 RAX: 0000000000000002 RBX: ffff88006f0fe490 RCX: 0000000000000000 RDX: dead000000100058 RSI: 0000000000000246 RDI: ffff88003786d454 RBP: ffff88006f0fe640 R08: 0000000000000628 R09: 0000000000000000 R10: 0000000000000628 R11: ffff8800795110a0 R12: ffff88006f0fe640 R13: ffff88006f0fe640 R14: ffffffff81817d0b R15: ffffffff818188b7 FS: 00007ff13ae24700(0000) GS:ffff88007d580000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b CR2: 0000003054ec7be0 CR3: 0000000076d51000 CR4: 00000000000007e0 Stack: ffff88007a41ebe0 dead000000100058 00000000fffffffe ffff88006f0fe640 0000000000000000 ffff88006f0fe678 ffff88007a41ebe0 ffff88003793a000 00000000fffffffe ffffffff810bde82 ffff88006f0fe640 ffff88007a41eb28 Call Trace: [<ffffffff810bde82>] ? instance_rmdir+0x15b/0x1de [<ffffffff81132e2d>] ? vfs_rmdir+0x80/0xd3 [<ffffffff81132f51>] ? do_rmdir+0xd1/0x139 [<ffffffff8124ad9e>] ? trace_hardirqs_on_thunk+0x3a/0x3c [<ffffffff814fea62>] ? system_call_fastpath+0x16/0x1b Code: fe ff ff 48 8d 75 30 48 89 df e8 c9 fd ff ff 85 c0 75 13 48 c7 c6 b8 cc d2 81 48 c7 c7 b0 cc d2 81 e8 8c 7a f5 ff 48 8b 54 24 08 <48> 8b 82 a8 00 00 00 48 89 d3 48 2d a8 00 00 00 48 89 44 24 08 RIP [<ffffffff811ed5eb>] debugfs_remove_recursive+0x1bd/0x367 RSP <ffff880077019df8>
It took a while, but every time it triggered, it was always in the same place:
list_for_each_entry_safe(child, next, &parent->d_subdirs, d_u.d_child) {Where the child->d_u.d_child seemed to be corrupted. I added lots of trace_printk()s to see what was wrong, and sure enough, it was always the child's d_u.d_child field. I looked around to see what touches it and noticed that in __dentry_kill() which calls dentry_free():
static void dentry_free(struct dentry *dentry)
{
/* if dentry was never visible to RCU, immediate free is OK */
if (!(dentry->d_flags & DCACHE_RCUACCESS))
__d_free(&dentry->d_u.d_rcu);
else
call_rcu(&dentry->d_u.d_rcu, __d_free);
}I also noticed that __dentry_kill() unlinks the child->d_u.child under the parent->d_lock spin_lock.
Looking back at the loop in debugfs_remove_recursive() it never takes the parent->d_lock to do the list walk. Adding more tracing, I was able to prove this was the issue:
ftrace-t-15385 1.... 246662024us : dentry_kill <ffffffff81138b91>: free ffff88006d573600
rmdir-15409 2.... 246662024us : debugfs_remove_recursive <ffffffff811ec7e5>: child=ffff88006d573600 next=dead000000100058
The dentry_kill freed ffff88006d573600 just as the remove recursive was walking it.
In order to fix this, the list walk needs to be modified a bit to take the parent->d_lock. The safe version is no longer necessary, as every time we remove a child, the parent->d_lock must be released and the list walk must start over. Each time a child is removed, even though it may still be on the list, it should be skipped by the first check in the loop:
if (!debugfs_positive(child)) continue;
--- fs/debugfs/inode.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-)
fs/debugfs/inode.c +26 -7
@@ -534,7 +534,7 @@ EXPORT_SYMBOL_GPL(debugfs_remove);*/ void debugfs_remove_recursive (struct dentry *dentry) { -struct dentry *child, *next, *parent; +struct dentry *child, *parent;if (IS_ERR_OR_NULL (dentry))return ;
@@ -546,30 +546,49 @@ void debugfs_remove_recursive(struct den parent = dentry; down:mutex_lock (&parent->d_inode->i_mutex); -list_for_each_entry_safe (child, next, &parent->d_subdirs, d_u.d_child) { + loop: +/* +* The parent->d_subdirs is protected by the d_lock. Outside that +* lock, the child can be unlinked and set to be freed which can +* use the d_u.d_child as the rcu head and corrupt this list. +*/ +spin_lock (&parent->d_lock); +list_for_each_entry (child, &parent->d_subdirs, d_u.d_child) {if (!debugfs_positive (child))continue ;/* perhaps simple_empty(child) makes more sense */ if (!list_empty (&child->d_subdirs)) { +spin_unlock (&parent->d_lock);mutex_unlock (&parent->d_inode->i_mutex); parent = child; goto down; } - up: + +spin_unlock (&parent->d_lock); +if (!__debugfs_remove (child, parent))simple_release_fs (&debugfs_mount, &debugfs_mount_count); + +/* +* The parent->d_lock protects agaist child from unlinking +* from d_subdirs. When releasing the parent->d_lock we can +* no longer trust that the next pointer is valid. +* Restart the loop. We'll skip this one with the +* debugfs_positive() check. +*/ + goto loop; } +spin_unlock (&parent->d_lock);mutex_unlock (&parent->d_inode->i_mutex); child = parent; parent = parent->d_parent;mutex_lock (&parent->d_inode->i_mutex); -if (child != dentry) { - next =list_next_entry (child, d_u.d_child); - goto up; - } +if (child != dentry) +/* go up */ + goto loop;if (!__debugfs_remove (child, parent))simple_release_fs (&debugfs_mount, &debugfs_mount_count);
Greg Kroah-Hartman
maintainerPATCH 56/125 KVM: x86: Inter-privilege level ret emulation is not implemeneted
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nadav Amit <[email protected]>
commit 9e8919ae793f4edfaa29694a70f71a515ae9942a upstream.
Return unhandlable error on inter-privilege level ret instruction. This is since the current emulation does not check the privilege level correctly when loading the CS, and does not pop RSP/SS as needed.
--- arch/x86/kvm/emulate.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/kvm/emulate.c +4 -0
@@ -2017,6 +2017,7 @@ static int em_ret_far(struct x86_emulate {int rc;unsigned long cs; +int cpl = ctxt->ops->cpl (ctxt); rc =emulate_pop (ctxt, &ctxt->_eip, ctxt->op_bytes);if (rc !=X86EMUL_CONTINUE )
@@ -2026,6 +2027,9 @@ static int em_ret_far(struct x86_emulate rc =emulate_pop (ctxt, &cs, ctxt->op_bytes);if (rc !=X86EMUL_CONTINUE )return rc; +/* Outer-privilege level return is not implemented */ +if (ctxt->mode >=X86EMUL_MODE_PROT16 && (cs &3 ) > cpl) +return X86EMUL_UNHANDLEABLE ; rc =load_segment_descriptor (ctxt, (u16 )cs,VCPU_SREG_CS );return rc; }
Greg Kroah-Hartman
maintainerPATCH 57/125 KVM: x86: always exit on EOIs for interrupts listed in the IOAPIC redir table
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Bonzini <[email protected]>
commit 0f6c0a740b7d3e1f3697395922d674000f83d060 upstream.
Currently, the EOI exit bitmap (used for APICv) does not include interrupts that are masked. However, this can cause a bug that manifests as an interrupt storm inside the guest. Alex Williamson reported the bug and is the one who really debugged this; I only wrote the patch. :)
The scenario involves a multi-function PCI device with OHCI and EHCI USB functions and an audio function, all assigned to the guest, where both USB functions use legacy INTx interrupts.
As soon as the guest boots, interrupts for these devices turn into an interrupt storm in the guest; the host does not see the interrupt storm. Basically the EOI path does not work, and the guest continues to see the interrupt over and over, even after it attempts to mask it at the APIC. The bug is only visible with older kernels (RHEL6.5, based on 2.6.32 with not many changes in the area of APIC/IOAPIC handling).
Alex then tried forcing bit 59 (corresponding to the USB functions' IRQ) on in the eoi_exit_bitmap and TMR, and things then work. What happens is that VFIO asserts IRQ11, then KVM recomputes the EOI exit bitmap. It does not have set bit 59 because the RTE was masked, so the IOAPIC never sees the EOI and the interrupt continues to fire in the guest.
My guess was that the guest is masking the interrupt in the redirection table in the interrupt routine, i.e. while the interrupt is set in a LAPIC's ISR, The simplest fix is to ignore the masking state, we would rather have an unnecessary exit rather than a missed IRQ ACK and anyway IOAPIC interrupts are not as performance-sensitive as for example MSIs. Alex tested this patch and it fixed his bug.
[Thanks to Alex for his precise description of the problem
and initial debugging effort. A lot of the text above is based on emails exchanged with him.]
--- virt/kvm/ioapic.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
virt/kvm/ioapic.c +3 -4
@@ -254,10 +254,9 @@ void kvm_ioapic_scan_entry(struct kvm_vcspin_lock (&ioapic->lock);for (index =0 ; index <IOAPIC_NUM_PINS ; index++) { e = &ioapic->redirtbl[index]; -if (!e->fields.mask && - (e->fields.trig_mode ==IOAPIC_LEVEL_TRIG || -kvm_irq_has_notifier (ioapic->kvm,KVM_IRQCHIP_IOAPIC , - index) || index ==RTC_GSI )) { +if (e->fields.trig_mode ==IOAPIC_LEVEL_TRIG || +kvm_irq_has_notifier (ioapic->kvm,KVM_IRQCHIP_IOAPIC , index) || + index ==RTC_GSI ) {if (kvm_apic_match_dest (vcpu,NULL ,0 , e->fields.dest_id, e->fields.dest_mode)) { __set_bit(e->fields.vector,
Greg Kroah-Hartman
maintainerPATCH 58/125 KVM: s390/mm: Fix page table locking vs. split pmd lock
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Borntraeger <[email protected]>
commit 55e4283c3eb1d850893f645dd695c9c75d5fa1fc upstream.
commit ec66ad66a0de87866be347b5ecc83bd46427f53b (s390/mm: enable split page table lock for PMD level) activated the split pmd lock for s390. Turns out that we missed one place: We also have to take the pmd lock instead of the page table lock when we reallocate the page tables (==> changing entries in the PMD) during sie enablement.
--- arch/s390/mm/pgtable.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/s390/mm/pgtable.c +3 -2
@@ -1279,6 +1279,7 @@ static unsigned long page_table_realloc_ {unsigned long next, *table, *new;struct page *page; +spinlock_t *ptl;pmd_t *pmd; pmd =pmd_offset (pud, addr);
@@ -1296,7 +1297,7 @@ again:if (!new)return -ENOMEM ; -spin_lock (&mm->page_table_lock); + ptl =pmd_lock (mm, pmd);if (likely ((unsigned long *)pmd_deref (*pmd) == table)) {/* Nuke pmd entry pointing to the "short" page table */ pmdp_flush_lazy (mm, addr, pmd);
@@ -1310,7 +1311,7 @@ again:page_table_free_rcu (tlb, table); new =NULL ; } -spin_unlock (&mm->page_table_lock); +spin_unlock (ptl);if (new) {page_table_free_pgste (new); goto again;
Greg Kroah-Hartman
maintainerPATCH 59/125 KVM: PPC: Book3S: Fix LPCR one_reg interface
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Kardashevskiy <[email protected]>
commit a0840240c0c6bcbac8f0f5db11f95c19aaf9b52f upstream.
Unfortunately, the LPCR got defined as a 32-bit register in the one_reg interface. This is unfortunate because KVM allows userspace to control the DPFD (default prefetch depth) field, which is in the upper 32 bits. The result is that DPFD always get set to 0, which reduces performance in the guest.
We can't just change KVM_REG_PPC_LPCR to be a 64-bit register ID, since that would break existing userspace binaries. Instead we define a new KVM_REG_PPC_LPCR_64 id which is 64-bit. Userspace can still use the old KVM_REG_PPC_LPCR id, but it now only modifies those fields in the bottom 32 bits that userspace can modify (ILE, TC and AIL). If userspace uses the new KVM_REG_PPC_LPCR_64 id, it can modify DPFD as well.
--- Documentation/virtual/kvm/api.txt | 3 ++- arch/powerpc/include/uapi/asm/kvm.h | 1 + arch/powerpc/kvm/book3s_hv.c | 13 +++++++++++-- arch/powerpc/kvm/book3s_pr.c | 2 ++ 4 files changed, 16 insertions(+), 3 deletions(-)
Documentation/virtual/kvm/api.txt +2 -1
@@ -1869,7 +1869,8 @@ registers, find a list below: PPC | KVM_REG_PPC_PID | 64 PPC | KVM_REG_PPC_ACOP | 64 PPC | KVM_REG_PPC_VRSAVE | 32 - PPC | KVM_REG_PPC_LPCR | 64 + PPC | KVM_REG_PPC_LPCR | 32 + PPC | KVM_REG_PPC_LPCR_64 | 64 PPC | KVM_REG_PPC_PPR | 64 PPC | KVM_REG_PPC_ARCH_COMPAT 32 PPC | KVM_REG_PPC_DABRX | 32
arch/powerpc/include/uapi/asm/kvm.h +1 -0
@@ -548,6 +548,7 @@ struct kvm_get_htab_header {#define KVM_REG_PPC_VRSAVE (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb4)#define KVM_REG_PPC_LPCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb5) +#define KVM_REG_PPC_LPCR_64 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb5)#define KVM_REG_PPC_PPR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb6)/* Architecture compatibility level */
arch/powerpc/kvm/book3s_hv.c +11 -2
@@ -785,7 +785,8 @@ static int kvm_arch_vcpu_ioctl_set_sregsreturn 0 ; } -static void kvmppc_set_lpcr (struct kvm_vcpu *vcpu,u64 new_lpcr) +static void kvmppc_set_lpcr (struct kvm_vcpu *vcpu,u64 new_lpcr, +bool preserve_top32) {struct kvmppc_vcore *vc = vcpu->arch.vcore;u64 mask;
@@ -820,6 +821,10 @@ static void kvmppc_set_lpcr(struct kvm_v mask =LPCR_DPFD |LPCR_ILE |LPCR_TC ;if (cpu_has_feature (CPU_FTR_ARCH_207S )) mask |=LPCR_AIL ; + +/* Broken 32-bit version of LPCR must not clear top bits */ +if (preserve_top32) + mask &=0xFFFFFFFF ; vc->lpcr = (vc->lpcr & ~mask) | (new_lpcr & mask);spin_unlock (&vc->lock); }
@@ -939,6 +944,7 @@ static int kvmppc_get_one_reg_hv(struct *val =get_reg_val (id, vcpu->arch.vcore->tb_offset);break ;case KVM_REG_PPC_LPCR : +case KVM_REG_PPC_LPCR_64 : *val =get_reg_val (id, vcpu->arch.vcore->lpcr);break ;case KVM_REG_PPC_PPR :
@@ -1150,7 +1156,10 @@ static int kvmppc_set_one_reg_hv(structALIGN (set_reg_val (id, *val),1UL <<24 );break ;case KVM_REG_PPC_LPCR : -kvmppc_set_lpcr (vcpu,set_reg_val (id, *val)); +kvmppc_set_lpcr (vcpu,set_reg_val (id, *val), true); +break ; +case KVM_REG_PPC_LPCR_64 : +kvmppc_set_lpcr (vcpu,set_reg_val (id, *val), false);break ;case KVM_REG_PPC_PPR : vcpu->arch.ppr =set_reg_val (id, *val);
arch/powerpc/kvm/book3s_pr.c +2 -0
@@ -1233,6 +1233,7 @@ static int kvmppc_get_one_reg_pr(struct *val =get_reg_val (id,to_book3s (vcpu)->hior);break ;case KVM_REG_PPC_LPCR : +case KVM_REG_PPC_LPCR_64 :/* * We are only interested in the LPCR_ILE bit */
@@ -1268,6 +1269,7 @@ static int kvmppc_set_one_reg_pr(structto_book3s (vcpu)->hior_explicit = true;break ;case KVM_REG_PPC_LPCR : +case KVM_REG_PPC_LPCR_64 :kvmppc_set_lpcr_pr (vcpu,set_reg_val (id, *val));break ;default :
Greg Kroah-Hartman
maintainerPATCH 60/125 KVM: nVMX: fix "acknowledge interrupt on exit" when APICv is in use
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wanpeng Li <[email protected]>
commit 56cc2406d68c0f09505c389e276f27a99f495cbd upstream.
After commit 77b0f5d (KVM: nVMX: Ack and write vector info to intr_info if L1 asks us to), "Acknowledge interrupt on exit" behavior can be emulated. To do so, KVM will ask the APIC for the interrupt vector if during a nested vmexit if VM_EXIT_ACK_INTR_ON_EXIT is set. With APICv, kvm_get_apic_interrupt would return -1 and give the following WARNING:
Call Trace: [<ffffffff81493563>] dump_stack+0x49/0x5e [<ffffffff8103f0eb>] warn_slowpath_common+0x7c/0x96 [<ffffffffa059709a>] ? nested_vmx_vmexit+0xa4/0x233 [kvm_intel] [<ffffffff8103f11a>] warn_slowpath_null+0x15/0x17 [<ffffffffa059709a>] nested_vmx_vmexit+0xa4/0x233 [kvm_intel] [<ffffffffa0594295>] ? nested_vmx_exit_handled+0x6a/0x39e [kvm_intel] [<ffffffffa0537931>] ? kvm_apic_has_interrupt+0x80/0xd5 [kvm] [<ffffffffa05972ec>] vmx_check_nested_events+0xc3/0xd3 [kvm_intel] [<ffffffffa051ebe9>] inject_pending_event+0xd0/0x16e [kvm] [<ffffffffa051efa0>] vcpu_enter_guest+0x319/0x704 [kvm]
To fix this, we cannot rely on the processor's virtual interrupt delivery, because "acknowledge interrupt on exit" must only update the virtual ISR/PPR/IRR registers (and SVI, which is just a cache of the virtual ISR) but it should not deliver the interrupt through the IDT. Thus, KVM has to deliver the interrupt "by hand", similar to the treatment of EOI in commit fc57ac2c9ca8 (KVM: lapic: sync highest ISR to hardware apic on EOI, 2014-05-14).
The patch modifies kvm_cpu_get_interrupt to always acknowledge an interrupt; there are only two callers, and the other is not affected because it is never reached with kvm_apic_vid_enabled() == true. Then it modifies apic_set_isr and apic_clear_irr to update SVI and RVI in addition to the registers.
--- arch/x86/kvm/irq.c | 2 - arch/x86/kvm/lapic.c | 52 ++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 40 insertions(+), 14 deletions(-)
arch/x86/kvm/irq.c +1 -1
@@ -108,7 +108,7 @@ int kvm_cpu_get_interrupt(struct kvm_vcp vector =kvm_cpu_get_extint (v); -if (kvm_apic_vid_enabled (v->kvm) || vector !=-1 ) +if (vector !=-1 )return vector;/* PIC */ return kvm_get_apic_interrupt (v);/* APIC */
arch/x86/kvm/lapic.c +39 -13
75 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 61/125 Revert "KVM: x86: Increase the number of fixed MTRR regs to 10"
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Bonzini <[email protected]>
commit 0d234daf7e0a3290a3a20c8087eefbd6335a5bd4 upstream.
This reverts commit 682367c494869008eb89ef733f196e99415ae862, which causes 32-bit SMP Windows 7 guests to panic.
SeaBIOS has a limit on the number of MTRRs that it can handle, and this patch exceeded the limit. Better revert it. Thanks to Nadav Amit for debugging the cause.
--- arch/x86/include/asm/kvm_host.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/kvm_host.h +1 -1
@@ -95,7 +95,7 @@ static inline gfn_t gfn_to_index(gfn_t g#define KVM_REFILL_PAGES 25#define KVM_MAX_CPUID_ENTRIES 80#define KVM_NR_FIXED_MTRR_REGION 88 -#define KVM_NR_VAR_MTRR 10 +#define KVM_NR_VAR_MTRR 8#define ASYNC_PF_PER_VCPU 64
Greg Kroah-Hartman
maintainerPATCH 62/125 kvm: iommu: fix the third parameter of kvm_iommu_put_pages (CVE-2014-3601)
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Michael S. Tsirkin" <[email protected]>
commit 350b8bdd689cd2ab2c67c8a86a0be86cfa0751a7 upstream.
The third parameter of kvm_iommu_put_pages is wrong, It should be 'gfn - slot->base_gfn'.
By making gfn very large, malicious guest or userspace can cause kvm to go to this error path, and subsequently to pass a huge value as size. Alternatively if gfn is small, then pages would be pinned but never unpinned, causing host memory leak and local DOS.
Passing a reasonable but large value could be the most dangerous case, because it would unpin a page that should have stayed pinned, and thus allow the device to DMA into arbitrary memory. However, this cannot happen because of the condition that can trigger the error:
- out of memory (where you can't allocate even a single page) should not be possible for the attacker to trigger
- when exceeding the iommu's address space, guest pages after gfn will also exceed the iommu's address space, and inside kvm_iommu_put_pages() the iommu_iova_to_phys() will fail. The page thus would not be unpinned at all.
--- virt/kvm/iommu.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
virt/kvm/iommu.c +10 -9
@@ -61,6 +61,14 @@ static pfn_t kvm_pin_pages(struct kvm_mereturn pfn; } +static void kvm_unpin_pages (struct kvm *kvm,pfn_t pfn,unsigned long npages) +{ +unsigned long i; + +for (i =0 ; i < npages; ++i) +kvm_release_pfn_clean (pfn + i); +} +int kvm_iommu_map_pages (struct kvm *kvm,struct kvm_memory_slot *slot) {gfn_t gfn, end_gfn;
@@ -123,6 +131,7 @@ int kvm_iommu_map_pages(struct kvm *kvm,if (r) {printk (KERN_ERR "kvm_iommu_map_address:" "iommu failed to map pfn=%llx\n" , pfn); +kvm_unpin_pages (kvm, pfn, page_size); goto unmap_pages; }
@@ -134,7 +143,7 @@ int kvm_iommu_map_pages(struct kvm *kvm,return 0 ; unmap_pages: -kvm_iommu_put_pages (kvm, slot->base_gfn, gfn); +kvm_iommu_put_pages (kvm, slot->base_gfn, gfn - slot->base_gfn);return r; }
@@ -266,14 +275,6 @@ out_unlock:return r; } -static void kvm_unpin_pages (struct kvm *kvm,pfn_t pfn,unsigned long npages) -{ -unsigned long i; - -for (i =0 ; i < npages; ++i) -kvm_release_pfn_clean (pfn + i); -} -static void kvm_iommu_put_pages (struct kvm *kvm,gfn_t base_gfn,unsigned long npages) {
Greg Kroah-Hartman
maintainerPATCH 63/125 ext4: fix BUG_ON in mb_free_blocks()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit c99d1e6e83b06744c75d9f5e491ed495a7086b7b upstream.
If we suffer a block allocation failure (for example due to a memory allocation failure), it's possible that we will call ext4_discard_allocated_blocks() before we've actually allocated any blocks. In that case, fe_len and fe_start in ac->ac_f_ex will still be zero, and this will result in mb_free_blocks(inode, e4b, 0, 0) triggering the BUG_ON on mb_free_blocks():
BUG_ON(last >= (sb->s_blocksize << 3));
Fix this by bailing out of ext4_discard_allocated_blocks() if fs_len is zero.
Also fix a missing ext4_mb_unload_buddy() call inext4_discard_allocated_blocks().
Google-Bug-Id: 16844242
--- fs/ext4/mballoc.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/ext4/mballoc.c +5 -0
@@ -1412,6 +1412,8 @@ static void mb_free_blocks(struct inodeint last = first + count -1 ;struct super_block *sb = e4b->bd_sb; +if (WARN_ON (count ==0 )) +return ;BUG_ON (last >= (sb->s_blocksize <<3 ));assert_spin_locked (ext4_group_lock_ptr (sb, e4b->bd_group));/* Don't bother if the block group is corrupt. */
@@ -3220,6 +3222,8 @@ static void ext4_discard_allocated_blockint err;if (pa ==NULL ) { +if (ac->ac_f_ex.fe_len ==0 ) +return ; err =ext4_mb_load_buddy (ac->ac_sb, ac->ac_f_ex.fe_group, &e4b);if (err) {/*
@@ -3234,6 +3238,7 @@ static void ext4_discard_allocated_blockmb_free_blocks (ac->ac_inode, &e4b, ac->ac_f_ex.fe_start, ac->ac_f_ex.fe_len);ext4_unlock_group (ac->ac_sb, ac->ac_f_ex.fe_group); +ext4_mb_unload_buddy (&e4b);return ; }if (pa->pa_type ==MB_INODE_PA )
Greg Kroah-Hartman
maintainerPATCH 64/125 drm/radeon: add new KV pci id
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 6dc14baf4ced769017c7a7045019c7a19f373865 upstream.
bug:
https://bugs.freedesktop.org/show_bug.cgi?id=82912
--- drivers/gpu/drm/radeon/cik.c | 1 + include/drm/drm_pciids.h | 1 + 2 files changed, 2 insertions(+)
drivers/gpu/drm/radeon/cik.c +1 -0
@@ -3320,6 +3320,7 @@ static void cik_gpu_init(struct radeon_d (rdev->pdev->device ==0x130B ) || (rdev->pdev->device ==0x130E ) || (rdev->pdev->device ==0x1315 ) || + (rdev->pdev->device ==0x1318 ) || (rdev->pdev->device == 0x131B)) { rdev->config.cik.max_cu_per_sh = 4; rdev->config.cik.max_backends_per_se =1 ;
include/drm/drm_pciids.h +1 -0
@@ -17,6 +17,7 @@ {0x1002, 0x1315, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x1316, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x1317, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ + {0x1002, 0x1318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x131B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x131C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x131D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_KAVERI|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
Greg Kroah-Hartman
maintainerPATCH 65/125 drm/radeon: add new bonaire pci ids
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 5fc540edc8ea1297c76685f74bc82a2107fe6731 upstream.
--- include/drm/drm_pciids.h | 2 ++ 1 file changed, 2 insertions(+)
include/drm/drm_pciids.h +2 -0
@@ -176,6 +176,8 @@ {0x1002, 0x6631, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6640, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6641, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ + {0x1002, 0x6646, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ + {0x1002, 0x6647, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6649, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6650, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6651, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_NEW_MEMMAP}, \
Greg Kroah-Hartman
maintainerPATCH 66/125 drm/radeon: add additional SI pci ids
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 37dbeab788a8f23fd946c0be083e5484d6f929a1 upstream.
--- include/drm/drm_pciids.h | 4 ++++ 1 file changed, 4 insertions(+)
include/drm/drm_pciids.h +4 -0
@@ -165,8 +165,11 @@ {0x1002, 0x6601, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6602, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6603, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ + {0x1002, 0x6604, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ + {0x1002, 0x6605, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6606, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6607, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ + {0x1002, 0x6608, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6610, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6611, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6613, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \
@@ -300,6 +303,7 @@ {0x1002, 0x6829, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \ {0x1002, 0x682A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x682B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ + {0x1002, 0x682C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \ {0x1002, 0x682D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x682F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6830, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
Greg Kroah-Hartman
maintainerPATCH 67/125 PCI: Configure ASPM when enabling device
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vidya Sagar <[email protected]>
commit 1f6ae47ecff7f23da73417e068018b311f3b5583 upstream.
We can't do ASPM configuration at enumeration-time because enabling it makes some defective hardware unresponsive, even if ASPM is disabled later (see 41cd766b0659 ("PCI: Don't enable aspm before drivers have had a chance to veto it"). Therefore, we have to do it after a driver claims the device.
We previously configured ASPM in pci_set_power_state(), but that's not a very good place because it's not really related to setting the PCI device power state, and doing it there means:
- We incorrectly skipped ASPM config when setting a device that's already in D0 to D0.
- We unnecessarily configured ASPM when setting a device to a low-power state (the ASPM feature only applies when the device is in D0).
- We unnecessarily configured ASPM when called from a .resume() method (ASPM configuration needs to be restored during resume, but pci_restore_pcie_state() should already do this).
Move ASPM configuration from pci_set_power_state() to do_pci_enable_device() so we do it when a driver enables a device.
--- drivers/pci/pci.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/pci/pci.c +6 -6
@@ -839,12 +839,6 @@ int pci_set_power_state(struct pci_dev *if (!__pci_complete_power_transition (dev, state)) error =0 ; -/* -* When aspm_policy is "powersave" this call ensures -* that ASPM is configured. -*/ -if (!error && dev->bus->self) -pcie_aspm_powersave_config_link (dev->bus->self);return error; }
@@ -1195,12 +1189,18 @@ int __weak pcibios_enable_device(structstatic int do_pci_enable_device (struct pci_dev *dev,int bars) {int err; +struct pci_dev *bridge;u16 cmd;u8 pin; err =pci_set_power_state (dev,PCI_D0 );if (err <0 && err != -EIO )return err; + + bridge =pci_upstream_bridge (dev); +if (bridge) +pcie_aspm_powersave_config_link (bridge); + err =pcibios_enable_device (dev, bars);if (err <0 )return err;
Greg Kroah-Hartman
maintainerPATCH 68/125 PCI: Keep original resource if we fail to expand it
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guo Chao <[email protected]>
commit c33377082dd9ede1e998f7ce416077e4b1c2276c upstream.
If we have space assigned to a resource, we try to expand the resource (e.g., to accommodate SR-IOV resources), and the expansion attempt fails, we should keep the original assignment.
After bd064f0a231a ("PCI: Mark resources as IORESOURCE_UNSET if we can't assign them"), we left the resource marked IORESOURCE_UNSET when the expansion failed, even if it had originally been set. That caused errors like this:
pci 0003:00:00.0: can't enable device: BAR 15 [mem size 0x0c000000 64bit pref] not assigned pci 0003:00:00.0: Error enabling bridge (-22), continuing
Fix this by restoring the original flags when reassignment fails.
--- drivers/pci/setup-res.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/pci/setup-res.c +7 -0
@@ -320,9 +320,11 @@ int pci_reassign_resource(struct pci_dev resource_size_t min_align) {struct resource *res = dev->resource + resno; +unsigned long flags;resource_size_t new_size;int ret; + flags = res->flags; res->flags |=IORESOURCE_UNSET ;if (!res->parent) { dev_info(&dev->dev, "BAR %d: can't reassign an unassigned resource %pR\n",
@@ -339,7 +341,12 @@ int pci_reassign_resource(struct pci_devdev_info (&dev->dev,"BAR %d: reassigned %pR\n" , resno, res);if (resno <PCI_BRIDGE_RESOURCES )pci_update_resource (dev, resno); + }else { + res->flags = flags; +dev_info (&dev->dev,"BAR %d: %pR (failed to expand by %#llx)\n" , + resno, res, (unsigned long long ) addsize); } +return ret; }
Greg Kroah-Hartman
maintainerPATCH 69/125 PCI: pciehp: Clear Data Link Layer State Changed during init
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myron Stowe <[email protected]>
commit 0d25d35c987d7b0b63368d9c1ae35a917e1a7bab upstream.
During PCIe hot-plug initialization - pciehp_probe() - data structures related to slot capabilities are set up. As part of this set up, ISRs are put in place to handle slot events and all event bits are cleared out.
This patch adds the Data Link Layer State Changed (PCI_EXP_SLTSTA_DLLSC) Slot Status bit to the event bits that are cleared out during initialization.
If the BIOS doesn't clear DLLSC before handoff to the OS, pciehp notices that it's set and interprets it as a new Link Up event, which results in spurious messages:
pciehp 0000:82:04.0:pcie24: slot(4): Link Up event
pciehp 0000:82:04.0:pcie24: Device 0000:83:00.0 already exists at 0000:83:00, cannot hot-add pciehp 0000:82:04.0:pcie24: Cannot add device at 0000:83:00
Prior to e48f1b67f668 ("PCI: pciehp: Use link change notifications for hot-plug and removal"), pciehp ignored DLLSC.
Reference:
PCI-SIG. PCI Express Base Specification Revision 4.0 Version 0.3 (PCI-SIG, 2014): 7.8.11. Slot Status Register (Offset 1Ah).
--- drivers/pci/hotplug/pciehp_hpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/hotplug/pciehp_hpc.c +1 -1
@@ -794,7 +794,7 @@ struct controller *pcie_init(struct pciepcie_capability_write_word (pdev,PCI_EXP_SLTSTA ,PCI_EXP_SLTSTA_ABP |PCI_EXP_SLTSTA_PFD |PCI_EXP_SLTSTA_MRLSC |PCI_EXP_SLTSTA_PDC | -PCI_EXP_SLTSTA_CC ); +PCI_EXP_SLTSTA_CC |PCI_EXP_SLTSTA_DLLSC );/* Disable software notification */ pcie_disable_notification (ctrl);
Greg Kroah-Hartman
maintainerPATCH 70/125 ACPI / PCI: Fix sysfs acpi_index and label errors
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Simone Gotti <[email protected]>
commit dcfa9be83866e28fcb8b7e22b4eeb4ba63bd3174 upstream.
Fix errors in handling "device label" _DSM return values.
If _DSM returns a Unicode string, the ACPI type is ACPI_TYPE_BUFFER, not ACPI_TYPE_STRING. Fix dsm_label_utf16s_to_utf8s() to convert UTF-16 from acpi_object->buffer instead of acpi_object->string.
Prior to v3.14, we accepted Unicode labels (ACPI_TYPE_BUFFER return values). But after 1d0fcef73283, we accepted only ASCII (ACPI_TYPE_STRING) (and we incorrectly tried to convert those ASCII labels from UTF-16 to UTF-8).
Rejecting Unicode labels made us return -EPERM when reading sysfs "acpi_index" or "label" files, which in turn caused on-board network interfaces on a Dell PowerEdge E420 to be renamed (by udev net_id internal) from eno1/eno2 to enp2s0f0/enp2s0f1.
Fix this by accepting either ACPI_TYPE_STRING (and treating it as ASCII) or ACPI_TYPE_BUFFER (and converting from UTF-16 to UTF-8).
--- drivers/pci/pci-label.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/pci/pci-label.c +12 -6
@@ -161,8 +161,8 @@ enum acpi_attr_enum {static void dsm_label_utf16s_to_utf8s (union acpi_object *obj,char *buf) {int len; - len =utf16s_to_utf8s ((const wchar_t *)obj->string.pointer, - obj->string.length, + len =utf16s_to_utf8s ((const wchar_t *)obj->buffer.pointer, + obj->buffer.length,UTF16_LITTLE_ENDIAN , buf,PAGE_SIZE ); buf[len] ='\n' ;
@@ -187,16 +187,22 @@ static int dsm_get_label(struct device * tmp = obj->package.elements;if (obj->type ==ACPI_TYPE_PACKAGE && obj->package.count ==2 && tmp[0 ].type ==ACPI_TYPE_INTEGER && - tmp[1 ].type ==ACPI_TYPE_STRING ) { + (tmp[1 ].type ==ACPI_TYPE_STRING || + tmp[1 ].type ==ACPI_TYPE_BUFFER )) {/* * The second string element is optional even when * this _DSM is implemented; when not implemented, * this entry must return a null string. */ -if (attr ==ACPI_ATTR_INDEX_SHOW ) +if (attr ==ACPI_ATTR_INDEX_SHOW ) {scnprintf (buf,PAGE_SIZE ,"%llu\n" , tmp->integer.value); -else if (attr ==ACPI_ATTR_LABEL_SHOW ) -dsm_label_utf16s_to_utf8s (tmp +1 , buf); + }else if (attr ==ACPI_ATTR_LABEL_SHOW ) { +if (tmp[1 ].type ==ACPI_TYPE_STRING ) +scnprintf (buf,PAGE_SIZE ,"%s\n" , + tmp[1 ].string.pointer); +else if (tmp[1 ].type ==ACPI_TYPE_BUFFER ) +dsm_label_utf16s_to_utf8s (tmp +1 , buf); + } len =strlen (buf) >0 ?strlen (buf) :-1 ; }
Greg Kroah-Hartman
maintainerPATCH 71/125 x86: dont exclude low BIOS area when allocating address space for non-PCI cards
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Schulz <[email protected]>
commit cbace46a9710a480cae51e4611697df5de41713e upstream.
Commit 30919b0bf356 ("x86: avoid low BIOS area when allocating address space") moved the test for resource allocations that fall within the first 1MB of address space from the PCI-specific path to a generic path, such that all resource allocations will avoid this area. However, this breaks ISA cards which need to allocate a memory region within the first 1MB. An example is the i82365 PCMCIA controller and derivatives like the Ricoh RF5C296/396 which map part of the PCMCIA socket memory address space into the first 1MB of system memory address space. They do not work anymore as no usable memory region exists due to this change:
Intel ISA PCIC probe: Ricoh RF5C296/396 ISA-to-PCMCIA at port 0x3e0 ofs 0x00, 2 sockets
host opts [0]: none
host opts [1]: none
ISA irqs (scanned) = 3,4,5,9,10 status change on irq 10
pcmcia_socket pcmcia_socket1: pccard: PCMCIA card inserted into slot 1
pcmcia_socket pcmcia_socket0: cs: IO port probe 0xc00-0xcff: excluding 0xcf8-0xcff
pcmcia_socket pcmcia_socket0: cs: IO port probe 0xa00-0xaff: clean.
pcmcia_socket pcmcia_socket0: cs: IO port probe 0x100-0x3ff: excluding 0x170-0x177 0x1f0-0x1f7 0x2f8-0x2ff 0x370-0x37f 0x3c0-0x3e7 0x3f0-0x3ff pcmcia_socket pcmcia_socket0: cs: memory probe 0x0a0000-0x0affff: excluding 0xa0000-0xaffff
pcmcia_socket pcmcia_socket0: cs: memory probe 0x0b0000-0x0bffff: excluding 0xb0000-0xbffff
pcmcia_socket pcmcia_socket0: cs: memory probe 0x0c0000-0x0cffff: excluding 0xc0000-0xcbfff
pcmcia_socket pcmcia_socket0: cs: memory probe 0x0d0000-0x0dffff: clean.
pcmcia_socket pcmcia_socket0: cs: memory probe 0x0e0000-0x0effff: clean.
pcmcia_socket pcmcia_socket0: cs: memory probe 0x60000000-0x60ffffff: clean.
pcmcia_socket pcmcia_socket0: cs: memory probe 0xa0000000-0xa0ffffff: clean.
pcmcia_socket pcmcia_socket1: cs: IO port probe 0xc00-0xcff: excluding 0xcf8-0xcff
pcmcia_socket pcmcia_socket1: cs: IO port probe 0xa00-0xaff: clean.
pcmcia_socket pcmcia_socket1: cs: IO port probe 0x100-0x3ff: excluding 0x170-0x177 0x1f0-0x1f7 0x2f8-0x2ff 0x370-0x37f 0x3c0-0x3e7 0x3f0-0x3ff pcmcia_socket pcmcia_socket1: cs: memory probe 0x0a0000-0x0affff: excluding 0xa0000-0xaffff
pcmcia_socket pcmcia_socket1: cs: memory probe 0x0b0000-0x0bffff: excluding 0xb0000-0xbffff
pcmcia_socket pcmcia_socket1: cs: memory probe 0x0c0000-0x0cffff: excluding 0xc0000-0xcbfff
pcmcia_socket pcmcia_socket1: cs: memory probe 0x0d0000-0x0dffff: clean.
pcmcia_socket pcmcia_socket1: cs: memory probe 0x0e0000-0x0effff: clean.
pcmcia_socket pcmcia_socket1: cs: memory probe 0x60000000-0x60ffffff: clean.
pcmcia_socket pcmcia_socket1: cs: memory probe 0xa0000000-0xa0ffffff: clean.
pcmcia_socket pcmcia_socket1: cs: memory probe 0x0cc000-0x0effff: excluding 0xe0000-0xeffff
pcmcia_socket pcmcia_socket1: cs: unable to map card memory!
If filtering out the first 1MB is reverted, everything works as expected.
--- arch/x86/kernel/resource.c | 8 +++++--- arch/x86/pci/i386.c | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-)
arch/x86/kernel/resource.c +5 -3
@@ -37,10 +37,12 @@ static void remove_e820_regions(struct rvoid arch_remove_reservations (struct resource *avail) { -/* Trim out BIOS areas (low 1MB and high 2MB) and E820 regions */ +/* +* Trim out BIOS area (high 2MB) and E820 regions. We do not remove +* the low 1MB unconditionally, as this area is needed for some ISA +* cards requiring a memory range, e.g. the i82365 PCMCIA controller. +*/ if (avail->flags &IORESOURCE_MEM ) { -if (avail->start <BIOS_END ) - avail->start =BIOS_END ;resource_clip (avail,BIOS_ROM_BASE ,BIOS_ROM_END );remove_e820_regions (avail);
arch/x86/pci/i386.c +4 -0
@@ -162,6 +162,10 @@ pcibios_align_resource(void *data, constreturn start;if (start &0x300 ) start = (start +0x3ff ) & ~0x3ff ; + }else if (res->flags &IORESOURCE_MEM ) { +/* The low 1MB range is reserved for ISA cards */ +if (start <BIOS_END ) + start =BIOS_END ; }return start; }
Greg Kroah-Hartman
maintainerPATCH 72/125 powerpc/eeh: Wrong place to call pci_get_slot()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Qiu <[email protected]>
commit 9e5c6e5a3be0b2e17ff61b9b74adef4a2c9e6934 upstream.
pci_get_slot() is called with hold of PCI bus semaphore and it's not safe to be called in interrupt context. However, we possibly checks EEH error and calls the function in interrupt context. To avoid using pci_get_slot(), we turn into device tree for fetching location code. Otherwise, we might run into WARN_ON() as following messages indicate:
WARNING: at drivers/pci/search.c:223 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.16.0-rc3+ #72 task: c000000001367af0 ti: c000000001444000 task.ti: c000000001444000 NIP: c000000000497b70 LR: c000000000037530 CTR: 000000003003d114 REGS: c000000001446fa0 TRAP: 0700 Not tainted (3.16.0-rc3+) MSR: 9000000000029032 <SF,HV,EE,ME,IR,DR,RI> CR: 48002422 XER: 20000000 CFAR: c00000000003752c SOFTE: 0 : NIP [c000000000497b70] .pci_get_slot+0x40/0x110 LR [c000000000037530] .eeh_pe_loc_get+0x150/0x190 Call Trace: .of_get_property+0x30/0x60 (unreliable) .eeh_pe_loc_get+0x150/0x190 .eeh_dev_check_failure+0x1b4/0x550 .eeh_check_failure+0x90/0xf0 .lpfc_sli_check_eratt+0x504/0x7c0 [lpfc] .lpfc_poll_eratt+0x64/0x100 [lpfc] .call_timer_fn+0x64/0x190 .run_timer_softirq+0x2cc/0x3e0
--- arch/powerpc/kernel/eeh_pe.c | 46 ++++++++++++------------------------------- 1 file changed, 13 insertions(+), 33 deletions(-)
arch/powerpc/kernel/eeh_pe.c +13 -33
@@ -802,53 +802,33 @@ void eeh_pe_restore_bars(struct eeh_pe **/ const char *eeh_pe_loc_get (struct eeh_pe *pe) { -struct pci_controller *hose;struct pci_bus *bus =eeh_pe_bus_get (pe); -struct pci_dev *pdev; -struct device_node *dn; -const char *loc; +struct device_node *dn =pci_bus_to_OF_node (bus); +const char *loc =NULL ; -if (!bus) -return "N/A" ; +if (!dn) + goto out;/* PHB PE or root PE ? */ if (pci_is_root_bus (bus)) { - hose =pci_bus_to_host (bus); - loc =of_get_property (hose->dn, -"ibm,loc-code" ,NULL ); -if (loc) -return loc; - loc =of_get_property (hose->dn, -"ibm,io-base-loc-code" ,NULL ); + loc =of_get_property (dn,"ibm,loc-code" ,NULL ); +if (!loc) + loc =of_get_property (dn,"ibm,io-base-loc-code" ,NULL );if (loc) -return loc; + goto out; - pdev =pci_get_slot (bus,0x0 ); - }else { - pdev = bus->self; - } - -if (!pdev) { - loc ="N/A" ; - goto out; - } - - dn =pci_device_to_OF_node (pdev); -if (!dn) { - loc ="N/A" ; - goto out; +/* Check the root port */ + dn = dn->child; +if (!dn) + goto out; } loc =of_get_property (dn,"ibm,loc-code" ,NULL );if (!loc) loc =of_get_property (dn,"ibm,slot-location-code" ,NULL ); -if (!loc) - loc ="N/A" ; out: -if (pci_is_root_bus (bus) && pdev) -pci_dev_put (pdev); -return loc; +return loc ? loc :"N/A" ; }/**
Greg Kroah-Hartman
maintainerPATCH 73/125 powerpc/pci: Reorder pci bus/bridge unregistration during PHB removal
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tyrel Datwyler <[email protected]>
commit 7340056567e32b2c9d3554eb146e1977c93da116 upstream.
Commit bcdde7e made __sysfs_remove_dir() recursive and introduced a BUG_ON during PHB removal while attempting to delete the power managment attribute group of the bus. This is a result of tearing the bridge and bus devices down out of order in remove_phb_dynamic. Since, the the bus resides below the bridge in the sysfs device tree it should be torn down first.
This patch simply moves the device_unregister call for the PHB bridge device after the device_unregister call for the PHB bus.
--- arch/powerpc/platforms/pseries/pci_dlpar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/platforms/pseries/pci_dlpar.c +2 -2
@@ -118,10 +118,10 @@ int remove_phb_dynamic(struct pci_contro } } -/* Unregister the bridge device from sysfs and remove the PCI bus */ -device_unregister (b->bridge); +/* Remove the PCI bus and unregister the bridge device from sysfs */ phb->bus =NULL ;pci_remove_bus (b); +device_unregister (b->bridge);/* Now release the IO resource */ if (res->flags &IORESOURCE_IO )
Greg Kroah-Hartman
maintainerPATCH 74/125 powerpc/powernv: Update dev->dma_mask in pci_set_dma_mask() path
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian W Hart <[email protected]>
commit a32305bf90a2ae0e6a9a93370c7616565f75e15a upstream.
powerpc defines various machine-specific routines for handling pci_set_dma_mask(). The routines for machine "PowerNV" may neglect to set dev->dma_mask. This could confuse anyone (e.g. drivers) that consult dev->dma_mask to find the current mask. Set the dma_mask in the PowerNV leaf routine.
--- arch/powerpc/platforms/powernv/pci-ioda.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/platforms/powernv/pci-ioda.c +1 -0
@@ -491,6 +491,7 @@ static int pnv_pci_ioda_dma_set_mask(strset_dma_ops (&pdev->dev, &dma_iommu_ops);set_iommu_table_base (&pdev->dev, &pe->tce32_table); } + *pdev->dev.dma_mask = dma_mask;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 75/125 x86_64/vsyscall: Fix warn_bad_vsyscall log output
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Lutomirski <[email protected]>
commit 53b884ac3745353de220d92ef792515c3ae692f0 upstream.
This commit in Linux 3.6:
commit c767a54ba0657e52e6edaa97cbe0b0a8bf1c1655
Author: Joe Perches <[email protected]>
Date: Mon May 21 19:50:07 2012 -0700
x86/debug: Add KERN_<LEVEL> to bare printks, convert printks to pr_<level>
caused warn_bad_vsyscall to output garbage in the middle of the line. Revert the bad part of it.
The printk in question isn't actually bare; the level is "%s".
The bug this fixes is purely cosmetic; backports are optional.
--- arch/x86/kernel/vsyscall_64.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/kernel/vsyscall_64.c +4 -4
@@ -81,10 +81,10 @@ static void warn_bad_vsyscall(const charif (!show_unhandled_signals)return ; -pr_notice_ratelimited ("%s%s[%d] %s ip:%lx cs:%lx sp:%lx ax:%lx si:%lx di:%lx\n" , - level, current->comm,task_pid_nr (current), - message, regs->ip, regs->cs, - regs->sp, regs->ax, regs->si, regs->di); +printk_ratelimited ("%s%s[%d] %s ip:%lx cs:%lx sp:%lx ax:%lx si:%lx di:%lx\n" , + level, current->comm,task_pid_nr (current), + message, regs->ip, regs->cs, + regs->sp, regs->ax, regs->si, regs->di); }static int addr_to_vsyscall_nr (unsigned long addr)
Greg Kroah-Hartman
maintainerPATCH 76/125 hpsa: fix non-x86 builds
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 0b9e7b741f2bf8103b15bb14d5b4a6f5ee91c59a upstream.
commit 28e134464734 "[SCSI] hpsa: enable unit attention reporting" turns on unit attention notifications, but got the change wrong for all architectures other than x86, which now store an uninitialized value into the device register.
Gcc helpfully warns about this:
../drivers/scsi/hpsa.c: In function 'hpsa_set_driver_support_bits':../drivers/scsi/hpsa.c:6373:17: warning: 'driver_support' is used uninitialized in this function [-Wuninitialized]
driver_support |= ENABLE_UNIT_ATTN;
^This moves the #ifdef so only the prefetch-enable is conditional on x86, not also reading the initial register contents.
--- drivers/scsi/hpsa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/hpsa.c +2 -2
@@ -6365,9 +6365,9 @@ static inline void hpsa_set_driver_suppo {u32 driver_support; -#ifdef CONFIG_X86 -/* Need to enable prefetch in the SCSI core for 6400 in x86 */ driver_support =readl (&(h->cfgtable->driver_support)); +/* Need to enable prefetch in the SCSI core for 6400 in x86 */ +#ifdef CONFIG_X86 driver_support |=ENABLE_SCSI_PREFETCH ;#endif driver_support |=ENABLE_UNIT_ATTN ;
Greg Kroah-Hartman
maintainerPATCH 77/125 x86: MCE: Add raw_lock conversion again
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit ed5c41d30ef2ce578fd6b6e2f7ec23f2a58b1eba upstream.
Commit ea431643d6c3 ("x86/mce: Fix CMCI preemption bugs") breaks RT by the completely unrelated conversion of the cmci_discover_lock to a regular (non raw) spinlock. This lock was annotated in commit 59d958d2c7de ("locking, x86: mce: Annotate cmci_discover_lock as raw") with a proper explanation why.
The argument for converting the lock back to a regular spinlock was:
- it does percpu ops without disabling preemption. Preemption is not disabled due to the mistaken use of a raw spinlock.
Which is complete nonsense. The raw_spinlock is disabling preemption in the same way as a regular spinlock. In mainline spinlock maps to raw_spinlock, in RT spinlock becomes a "sleeping" lock.
raw_spinlock has on RT exactly the same semantics as in mainline. And because this lock is taken in non preemptible context it must be raw on RT.
Undo the locking brainfart.
--- arch/x86/kernel/cpu/mcheck/mce_intel.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
arch/x86/kernel/cpu/mcheck/mce_intel.c +9 -9
@@ -42,7 +42,7 @@ static DEFINE_PER_CPU(mce_banks_t, mce_b* cmci_discover_lock protects against parallel discovery attempts * which could race against each other. */ -static DEFINE_SPINLOCK (cmci_discover_lock); +static DEFINE_RAW_SPINLOCK (cmci_discover_lock);#define CMCI_THRESHOLD 1#define CMCI_POLL_INTERVAL (30 * HZ)
@@ -144,14 +144,14 @@ static void cmci_storm_disable_banks(voiint bank;u64 val; -spin_lock_irqsave (&cmci_discover_lock, flags); +raw_spin_lock_irqsave (&cmci_discover_lock, flags); owned =__get_cpu_var (mce_banks_owned);for_each_set_bit (bank, owned,MAX_NR_BANKS ) {rdmsrl (MSR_IA32_MCx_CTL2 (bank), val); val &= ~MCI_CTL2_CMCI_EN ;wrmsrl (MSR_IA32_MCx_CTL2 (bank), val); } -spin_unlock_irqrestore (&cmci_discover_lock, flags); +raw_spin_unlock_irqrestore (&cmci_discover_lock, flags); }static bool cmci_storm_detect (void )
@@ -211,7 +211,7 @@ static void cmci_discover(int banks)int i;int bios_wrong_thresh =0 ; -spin_lock_irqsave (&cmci_discover_lock, flags); +raw_spin_lock_irqsave (&cmci_discover_lock, flags);for (i =0 ; i < banks; i++) {u64 val;int bios_zero_thresh =0 ;
@@ -266,7 +266,7 @@ static void cmci_discover(int banks)WARN_ON (!test_bit (i,__get_cpu_var (mce_poll_banks))); } } -spin_unlock_irqrestore (&cmci_discover_lock, flags); +raw_spin_unlock_irqrestore (&cmci_discover_lock, flags);if (mca_cfg.bios_cmci_threshold && bios_wrong_thresh) {pr_info_once ("bios_cmci_threshold: Some banks do not have valid thresholds set\n" );
@@ -316,10 +316,10 @@ void cmci_clear(void)if (!cmci_supported (&banks))return ; -spin_lock_irqsave (&cmci_discover_lock, flags); +raw_spin_lock_irqsave (&cmci_discover_lock, flags);for (i =0 ; i < banks; i++)__cmci_disable_bank (i); -spin_unlock_irqrestore (&cmci_discover_lock, flags); +raw_spin_unlock_irqrestore (&cmci_discover_lock, flags); }static void cmci_rediscover_work_func (void *arg)
@@ -360,9 +360,9 @@ void cmci_disable_bank(int bank)if (!cmci_supported (&banks))return ; -spin_lock_irqsave (&cmci_discover_lock, flags); +raw_spin_lock_irqsave (&cmci_discover_lock, flags);__cmci_disable_bank (bank); -spin_unlock_irqrestore (&cmci_discover_lock, flags); +raw_spin_unlock_irqrestore (&cmci_discover_lock, flags); }static void intel_init_cmci (void )
Greg Kroah-Hartman
maintainerPATCH 78/125 xen/events/fifo: ensure all bitops are properly aligned even on x86
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Vrabel <[email protected]>
commit dcecb8fd93a65787130a74e61fdf29932c8d85eb upstream.
When using the FIFO-based ABI on x86_64, if the last port is at the end of an event array page then sync_test_bit() on this port's event word will read beyond the end of the page and in certain circumstances this may fault.
The fault requires the following page in the kernel's direct mapping to be not present, which would mean:
a) the array page is the last page of RAM; or
b) the following page is ballooned out /and/ it has been used for a foreign mapping by a kernel driver (such as netback or blkback) /and/ the grant has been unmapped.
Use the infrastructure added for arm64 to ensure that all bitops operating on event words are unsigned long aligned.
--- drivers/xen/events/events_fifo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/xen/events/events_fifo.c +2 -3
@@ -67,10 +67,9 @@ static event_word_t *event_array[MAX_EVEstatic unsigned event_array_pages__read_mostly ;/* -* sync_set_bit() and friends must be unsigned long aligned on non-x86 -* platforms. +* sync_set_bit() and friends must be unsigned long aligned. */ -#if !defined(CONFIG_X86 ) &&BITS_PER_LONG >32 +#if BITS_PER_LONG >32 #define BM (w) (unsigned long *)((unsigned long)w & ~0x7UL)#define EVTCHN_FIFO_BIT (b, w) \
Greg Kroah-Hartman
maintainerPATCH 80/125 x86/xen: use vmap() to map grant table pages in PVH guests
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Vrabel <[email protected]>
commit 7d951f3ccb0308c95bf76d5eef9886dea35a7013 upstream.
Commit b7dd0e350e0b (x86/xen: safely map and unmap grant frames when in atomic context) causes PVH guests to crash in arch_gnttab_map_shared() when they attempted to map the pages for the grant table.
This use of a PV-specific function during the PVH grant table setup is non-obvious and not needed. The standard vmap() function does the right thing.
--- arch/x86/xen/grant-table.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/xen/grant-table.c +5 -5
@@ -168,6 +168,7 @@ static int __init xlated_setup_gnttab_pa {struct page **pages;xen_pfn_t *pfns; +void *vaddr;int rc;unsigned int i;unsigned long nr_grant_frames =gnttab_max_grant_frames ();
@@ -193,21 +194,20 @@ static int __init xlated_setup_gnttab_pafor (i =0 ; i < nr_grant_frames; i++) pfns[i] =page_to_pfn (pages[i]); - rc =arch_gnttab_map_shared (pfns, nr_grant_frames, nr_grant_frames, - &xen_auto_xlat_grant_frames.vaddr); - -if (rc) { + vaddr =vmap (pages, nr_grant_frames,0 ,PAGE_KERNEL ); +if (!vaddr) {pr_warn ("%s Couldn't map %ld pfns rc:%d\n" , __func__, nr_grant_frames, rc);free_xenballooned_pages (nr_grant_frames, pages);kfree (pages);kfree (pfns); -return rc; +return -ENOMEM ; }kfree (pages); xen_auto_xlat_grant_frames.pfn = pfns; xen_auto_xlat_grant_frames.count = nr_grant_frames; + xen_auto_xlat_grant_frames.vaddr = vaddr;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 81/125 x86/xen: resume timer irqs early
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Vrabel <[email protected]>
commit 8d5999df35314607c38fbd6bdd709e25c3a4eeab upstream.
If the timer irqs are resumed during device resume it is possible in certain circumstances for the resume to hang early on, before device interrupts are resumed. For an Ubuntu 14.04 PVHVM guest this would occur in ~0.5% of resume attempts.
It is not entirely clear what is occuring the point of the hang but I think a task necessary for the resume calls schedule_timeout(), waiting for a timer interrupt (which never arrives). This failure may require specific tasks to be running on the other VCPUs to trigger (processes are not frozen during a suspend/resume if PREEMPT is disabled).
Add IRQF_EARLY_RESUME to the timer interrupts so they are resumed in syscore_resume().
--- arch/x86/xen/time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/xen/time.c +1 -1
@@ -444,7 +444,7 @@ void xen_setup_timer(int cpu) irq =bind_virq_to_irqhandler (VIRQ_TIMER , cpu, xen_timer_interrupt,IRQF_PERCPU |IRQF_NOBALANCING |IRQF_TIMER | -IRQF_FORCE_RESUME , +IRQF_FORCE_RESUME |IRQF_EARLY_RESUME , name,NULL ); (void )xen_set_irq_priority (irq,XEN_IRQ_PRIORITY_MAX );
Greg Kroah-Hartman
maintainerPATCH 82/125 x86,mm: fix pte_special versus pte_numa
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugh Dickins <[email protected]>
commit b38af4721f59d0b564468f623b3e52a638195015 upstream.
Sasha Levin has shown oopses on ffffea0003480048 and ffffea0003480008 at mm/memory.c:1132, running Trinity on different 3.16-rc-next kernels:
where zap_pte_range() checks page->mapping to see if PageAnon(page).
Those addresses fit struct pages for pfns d2001 and d2000, and in each dump a register or a stack slot showed d2001730 or d2000730: pte flags 0x730 are PCD ACCESSED PROTNONE SPECIAL IOMAP; and Sasha's e820 map has a hole between cfffffff and 100000000, which would need special access.
Commit c46a7c817e66 ("x86: define _PAGE_NUMA by reusing software bits on the PMD and PTE levels") has broken vm_normal_page(): a PROTNONE SPECIAL pte no longer passes the pte_special() test, so zap_pte_range() goes on to try to access a non-existent struct page.
Fix this by refining pte_special() (SPECIAL with PRESENT or PROTNONE) to complement pte_numa() (SPECIAL with neither PRESENT nor PROTNONE). A hint that this was a problem was that c46a7c817e66 added pte_numa() test to vm_normal_page(), and moved its is_zero_pfn() test from slow to fast
path: This was papering over a pte_special() snag when the zero page was encountered during zap. This patch reverts vm_normal_page() to how it was before, relying on pte_special().
It still appears that this patch may be incomplete: aren't there other places which need to be handling PROTNONE along with PRESENT? For example, pte_mknuma() clears _PAGE_PRESENT and sets _PAGE_NUMA, but on a PROT_NONE area, that would make it pte_special(). This is side-stepped by the fact that NUMA hinting faults skipped PROT_NONE VMAs and there are no grounds where a NUMA hinting fault on a PROT_NONE VMA would be interesting.
--- arch/x86/include/asm/pgtable.h | 9 +++++++-- mm/memory.c | 7 +++---- 2 files changed, 10 insertions(+), 6 deletions(-)
arch/x86/include/asm/pgtable.h +7 -2
@@ -131,8 +131,13 @@ static inline int pte_exec(pte_t pte)static inline int pte_special (pte_t pte) { -return (pte_flags (pte) & (_PAGE_PRESENT|_PAGE_SPECIAL)) == - (_PAGE_PRESENT|_PAGE_SPECIAL); +/* +* See CONFIG_NUMA_BALANCING pte_numa in include/asm-generic/pgtable.h. +* On x86 we have _PAGE_BIT_NUMA == _PAGE_BIT_GLOBAL+1 == +* __PAGE_BIT_SOFTW1 == _PAGE_BIT_SPECIAL. +*/ +return (pte_flags (pte) & _PAGE_SPECIAL) && + (pte_flags (pte) & (_PAGE_PRESENT|_PAGE_PROTNONE)); }static inline unsigned long pte_pfn (pte_t pte)
mm/memory.c +3 -4
@@ -751,7 +751,7 @@ struct page *vm_normal_page(struct vm_arunsigned long pfn =pte_pfn (pte);if (HAVE_PTE_SPECIAL ) { -if (likely (!pte_special (pte) ||pte_numa (pte))) +if (likely (!pte_special (pte))) goto check_pfn;if (vma->vm_flags & (VM_PFNMAP |VM_MIXEDMAP ))return NULL ;
@@ -777,15 +777,14 @@ struct page *vm_normal_page(struct vm_ar } } +if (is_zero_pfn (pfn)) +return NULL ; check_pfn:if (unlikely (pfn > highest_memmap_pfn)) {print_bad_pte (vma, addr, pte,NULL );return NULL ; } -if (is_zero_pfn (pfn)) -return NULL ; -/* * NOTE! We still have PageReserved() pages in the page tables. * eg. VDSO mappings can cause them to exist.
Greg Kroah-Hartman
maintainerPATCH 83/125 hpsa: fix bad -ENOMEM return value in hpsa_big_passthru_ioctl
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Stephen M. Cameron" <[email protected]>
commit 0758f4f732b08b6ef07f2e5f735655cf69fea477 upstream.
When copy_from_user fails, return -EFAULT, not -ENOMEM
Reviewed by: Mike MIller <[email protected]>
--- drivers/scsi/hpsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/hpsa.c +1 -1
@@ -5092,7 +5092,7 @@ static int hpsa_big_passthru_ioctl(struc }if (ioc->Request.Type.Direction &XFER_WRITE ) {if (copy_from_user (buff[sg_used], data_ptr, sz)) { - status = -ENOMEM ; + status = -EFAULT ; goto cleanup1; } }else
Greg Kroah-Hartman
maintainerPATCH 84/125 Btrfs: Fix memory corruption by ulist_add_merge() on 32bit arch
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 4eb1f66dce6c4dc28dd90a7ffbe6b2b1cb08aa4e upstream.
We've got bug reports that btrfs crashes when quota is enabled on 32bit kernel, typically with the Oops like below:
BUG: unable to handle kernel NULL pointer dereference at 00000004 IP: [<f9234590>] find_parent_nodes+0x360/0x1380 [btrfs] *pde = 00000000 Oops: 0000 [#1] SMP CPU: 0 PID: 151 Comm: kworker/u8:2 Tainted: G S W 3.15.2-1.gd43d97e-default #1 Workqueue: btrfs-qgroup-rescan normal_work_helper [btrfs] task: f1478130 ti: f147c000 task.ti: f147c000 EIP: 0060:[<f9234590>] EFLAGS: 00010213 CPU: 0 EIP is at find_parent_nodes+0x360/0x1380 [btrfs] EAX: f147dda8 EBX: f147ddb0 ECX: 00000011 EDX: 00000000 ESI: 00000000 EDI: f147dda4 EBP: f147ddf8 ESP: f147dd38 DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 CR0: 8005003b CR2: 00000004 CR3: 00bf3000 CR4: 00000690 Stack: 00000000 00000000 f147dda4 00000050 00000001 00000000 00000001 00000050 00000001 00000000 d3059000 00000001 00000022 000000a8 00000000 00000000 00000000 000000a1 00000000 00000000 00000001 00000000 00000000 11800000 Call Trace: [<f923564d>] __btrfs_find_all_roots+0x9d/0xf0 [btrfs] [<f9237bb1>] btrfs_qgroup_rescan_worker+0x401/0x760 [btrfs] [<f9206148>] normal_work_helper+0xc8/0x270 [btrfs] [<c025e38b>] process_one_work+0x11b/0x390 [<c025eea1>] worker_thread+0x101/0x340 [<c026432b>] kthread+0x9b/0xb0 [<c0712a71>] ret_from_kernel_thread+0x21/0x30 [<c0264290>] kthread_create_on_node+0x110/0x110
This indicates a NULL corruption in prefs_delayed list. The further investigation and bisection pointed that the call of ulist_add_merge() results in the corruption.
ulist_add_merge() takes u64 as aux and writes a 64bit value into old_aux. The callers of this function in backref.c, however, pass a pointer of a pointer to old_aux. That is, the function overwrites 64bit value on 32bit pointer. This caused a NULL in the adjacent variable, in this case, prefs_delayed.
Here is a quick attempt to band-aid over this: a new function, ulist_add_merge_ptr() is introduced to pass/store properly a pointer value instead of u64. There are still ugly void ** cast remaining in the callers because void ** cannot be taken implicitly. But, it's safer than explicit cast to u64, anyway.
Bugzilla: https://bugzilla.novell.com/show_bug.cgi?id=887046
--- fs/btrfs/backref.c | 11 +++++------ fs/btrfs/ulist.h | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-)
fs/btrfs/backref.c +5 -6
@@ -276,9 +276,8 @@ static int add_all_parents(struct btrfs_ }if (ret >0 ) goto next; - ret =ulist_add_merge (parents, eb->start, - (uintptr_t )eie, - (u64 *)&old,GFP_NOFS ); + ret =ulist_add_merge_ptr (parents, eb->start, + eie, (void **)&old,GFP_NOFS );if (ret <0 )break ;if (!ret && extent_item_pos) {
@@ -1008,9 +1007,9 @@ again: goto out; ref->inode_list = eie; } - ret =ulist_add_merge (refs, ref->parent, - (uintptr_t )ref->inode_list, - (u64 *)&eie,GFP_NOFS ); + ret =ulist_add_merge_ptr (refs, ref->parent, + ref->inode_list, + (void **)&eie,GFP_NOFS );if (ret <0 ) goto out;if (!ret && extent_item_pos) {
fs/btrfs/ulist.h +15 -0
@@ -57,6 +57,21 @@ void ulist_free(struct ulist *ulist);int ulist_add (struct ulist *ulist,u64 val,u64 aux,gfp_t gfp_mask);int ulist_add_merge (struct ulist *ulist,u64 val,u64 aux,u64 *old_aux,gfp_t gfp_mask); + +/* just like ulist_add_merge() but take a pointer for the aux data */ +static inline int ulist_add_merge_ptr (struct ulist *ulist,u64 val,void *aux, +void **old_aux,gfp_t gfp_mask) +{ +#if BITS_PER_LONG ==32 +u64 old64 = (uintptr_t )*old_aux; +int ret =ulist_add_merge (ulist, val, (uintptr_t )aux, &old64, gfp_mask); + *old_aux = (void *)((uintptr_t )old64); +return ret; +#else +return ulist_add_merge (ulist, val, (u64 )aux, (u64 *)old_aux, gfp_mask); +#endif +} +struct ulist_node *ulist_next (struct ulist *ulist,struct ulist_iterator *uiter);
Greg Kroah-Hartman
maintainerPATCH 85/125 Btrfs: fix csum tree corruption, duplicate and outdated checksums
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 27b9a8122ff71a8cadfbffb9c4f0694300464f3b upstream.
Under rare circumstances we can end up leaving 2 versions of a checksum for the same file extent range.
The reason for this is that after calling btrfs_next_leaf we process slot 0 of the leaf it returns, instead of processing the slot set in path->slots[0]. Most of the time (by far) path->slots[0] is 0, but after btrfs_next_leaf() releases the path and before it searches for the next leaf, another task might cause a split of the next leaf, which migrates some of its keys to the leaf we were processing before calling btrfs_next_leaf(). In this case btrfs_next_leaf() returns again the same leaf but with path->slots[0] having a slot number corresponding to the first new key it got, that is, a slot number that didn't exist before calling btrfs_next_leaf(), as the leaf now has more keys than it had before. So we must really process the returned leaf starting at path->slots[0] always, as it isn't always 0, and the key at slot 0 can have an offset much lower than our search offset/bytenr.
For example, consider the following scenario, where we have:
sums->bytenr: 40157184, sums->len: 16384, sums end: 40173568
four 4kb file data blocks with offsets 40157184, 40161280, 40165376, 40169472
Leaf N:
slot = 0 slot = btrfs_header_nritems() - 1
|-------------------------------------------------------------------| | [(CSUM CSUM 39239680), size 8] ... [(CSUM CSUM 40116224), size 4] | |-------------------------------------------------------------------|
Leaf N + 1:
slot = 0 slot = btrfs_header_nritems() - 1
|--------------------------------------------------------------------| | [(CSUM CSUM 40161280), size 32] ... [((CSUM CSUM 40615936), size 8 | |--------------------------------------------------------------------|
Because we are at the last slot of leaf N, we call btrfs_next_leaf() to find the next highest key, which releases the current path and then searches for that next key. However after releasing the path and before finding that next key, the item at slot 0 of leaf N + 1 gets moved to leaf N, due to a call to ctree.c:push_leaf_left() (via ctree.c:split_leaf()), and therefore btrfs_next_leaf() will returns us a path again with leaf N but with the slot pointing to its new last key (CSUM CSUM 40161280). This new version of leaf N is then:
slot = 0 slot = btrfs_header_nritems() - 2 slot = btrfs_header_nritems() - 1
|----------------------------------------------------------------------------------------------------| | [(CSUM CSUM 39239680), size 8] ... [(CSUM CSUM 40116224), size 4] [(CSUM CSUM 40161280), size 32] | |----------------------------------------------------------------------------------------------------|
And incorrecly using slot 0, makes us set next_offset to 39239680 and we jump into the "insert:" label, which will set tmp to:
tmp = min((sums->len - total_bytes) >> blocksize_bits,
(next_offset - file_key.offset) >> blocksize_bits) =
min((16384 - 0) >> 12, (39239680 - 40157184) >> 12) =
min(4, (u64)-917504 = 18446744073708634112 >> 12) = 4and
ins_size = csum_size * tmp = 4 * 4 = 16 bytes.
In other words, we insert a new csum item in the tree with key (CSUM_OBJECTID CSUM_KEY 40157184 = sums->bytenr) that contains the checksums for all the data (4 blocks of 4096 bytes each = sums->len). Which is wrong, because the item with key (CSUM CSUM 40161280) (the one that was moved from leaf N + 1 to the end of leaf N) contains the old checksums of the last 12288 bytes of our data and won't get those old checksums removed.
So this leaves us 2 different checksums for 3 4kb blocks of data in the tree, and breaks the logical rule:
Key_N+1.offset >= Key_N.offset + length_of_data_its_checksums_cover
An obvious bad effect of this is that a subsequent csum tree lookup to get the checksum of any of the blocks with logical offset of 40161280, 40165376 or 40169472 (the last 3 4kb blocks of file data), will get the old checksums.
--- fs/btrfs/file-item.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/file-item.c +1 -1
@@ -756,7 +756,7 @@ again: found_next =1 ;if (ret !=0 ) goto insert; - slot =0 ; + slot = path->slots[0 ]; }btrfs_item_key_to_cpu (path->nodes[0 ], &found_key, slot); if (found_key.objectid != BTRFS_EXTENT_CSUM_OBJECTID ||
Greg Kroah-Hartman
maintainerPATCH 86/125 Btrfs: read lock extent buffer while walking backrefs
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 6f7ff6d7832c6be13e8c95598884dbc40ad69fb7 upstream.
Before processing the extent buffer, acquire a read lock on it, so that we're safe against concurrent updates on the extent buffer.
--- fs/btrfs/backref.c | 3 +++ 1 file changed, 3 insertions(+)
fs/btrfs/backref.c +3 -0
@@ -1000,8 +1000,11 @@ again: ret = -EIO ; goto out; } +btrfs_tree_read_lock (eb); +btrfs_set_lock_blocking_rw (eb,BTRFS_READ_LOCK ); ret =find_extent_in_eb (eb, bytenr, *extent_item_pos, &eie); +btrfs_tree_read_unlock_blocking (eb);free_extent_buffer (eb);if (ret <0 ) goto out;
Greg Kroah-Hartman
maintainerPATCH 87/125 Btrfs: fix compressed write corruption on enospc
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Bo <[email protected]>
commit ce62003f690dff38d3164a632ec69efa15c32cbf upstream.
When failing to allocate space for the whole compressed extent, we'll fallback to uncompressed IO, but we've forgotten to redirty the pages which belong to this compressed extent, and these 'clean' pages will simply skip 'submit' part and go to endio directly, at last we got data corruption as we write nothing.
--- fs/btrfs/inode.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
fs/btrfs/inode.c +12 -0
@@ -709,6 +709,18 @@ retry:unlock_extent (io_tree, async_extent->start, async_extent->start + async_extent->ram_size -1 ); + +/* +* we need to redirty the pages if we decide to +* fallback to uncompressed IO, otherwise we +* will not submit these pages down to lower +* layers. +*/ +extent_range_redirty_for_io (inode, + async_extent->start, + async_extent->start + + async_extent->ram_size -1 ); + goto retry; } goto out_free;
Greg Kroah-Hartman
maintainerPATCH 88/125 btrfs: disable strict file flushes for renames and truncates
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
commit 8d875f95da43c6a8f18f77869f2ef26e9594fecc upstream.
Truncates and renames are often used to replace old versions of a file with new versions. Applications often expect this to be an atomic replacement, even if they haven't done anything to make sure the new version is fully on disk.
Btrfs has strict flushing in place to make sure that renaming over an old file with a new file will fully flush out the new file before allowing the transaction commit with the rename to complete.
This ordering means the commit code needs to be able to lock file pages, and there are a few paths in the filesystem where we will try to end a transaction with the page lock held. It's rare, but these things can deadlock.
This patch removes the ordered flushes and switches to a best effort filemap_flush like ext4 uses. It's not perfect, but it should fix the deadlocks.
--- fs/btrfs/btrfs_inode.h | 6 -- fs/btrfs/disk-io.c | 32 ------------ fs/btrfs/file.c | 26 ---------- fs/btrfs/inode.c | 47 +----------------- fs/btrfs/ordered-data.c | 123 ------------------------------------------------ fs/btrfs/ordered-data.h | 5 - fs/btrfs/transaction.c | 33 ------------ fs/btrfs/transaction.h | 1 8 files changed, 6 insertions(+), 267 deletions(-)
fs/btrfs/btrfs_inode.h +0 -6
@@ -84,12 +84,6 @@ struct btrfs_inode {*/ struct list_head delalloc_inodes; -/* -* list for tracking inodes that must be sent to disk before a -* rename or truncate commit -*/ -struct list_head ordered_operations; -/* node for the red-black tree that links inodes in subvolume root */ struct rb_node rb_node;
fs/btrfs/disk-io.c +0 -32
@@ -60,8 +60,6 @@ static void end_workqueue_fn(struct btrfstatic void free_fs_root (struct btrfs_root *root);static int btrfs_check_super_valid (struct btrfs_fs_info *fs_info,int read_only); -static void btrfs_destroy_ordered_operations (struct btrfs_transaction *t, -struct btrfs_root *root);static void btrfs_destroy_ordered_extents (struct btrfs_root *root);static int btrfs_destroy_delayed_refs (struct btrfs_transaction *trans,struct btrfs_root *root);
@@ -3829,34 +3827,6 @@ static void btrfs_error_commit_super(strbtrfs_cleanup_transaction (root); } -static void btrfs_destroy_ordered_operations (struct btrfs_transaction *t, -struct btrfs_root *root) -{ -struct btrfs_inode *btrfs_inode; -struct list_head splice; - -INIT_LIST_HEAD (&splice); - -mutex_lock (&root->fs_info->ordered_operations_mutex); -spin_lock (&root->fs_info->ordered_root_lock); - -list_splice_init (&t->ordered_operations, &splice); -while (!list_empty (&splice)) { - btrfs_inode = list_entry(splice.next, struct btrfs_inode, - ordered_operations); - -list_del_init (&btrfs_inode->ordered_operations); -spin_unlock (&root->fs_info->ordered_root_lock); - -btrfs_invalidate_inodes (btrfs_inode->root); - -spin_lock (&root->fs_info->ordered_root_lock); - } - -spin_unlock (&root->fs_info->ordered_root_lock); -mutex_unlock (&root->fs_info->ordered_operations_mutex); -} -static void btrfs_destroy_ordered_extents (struct btrfs_root *root) {struct btrfs_ordered_extent *ordered;
@@ -4093,8 +4063,6 @@ again:void btrfs_cleanup_one_transaction (struct btrfs_transaction *cur_trans,struct btrfs_root *root) { -btrfs_destroy_ordered_operations (cur_trans, root); -btrfs_destroy_delayed_refs (cur_trans, root); cur_trans->state =TRANS_STATE_COMMIT_START ;
fs/btrfs/file.c +1 -25
@@ -1838,33 +1838,9 @@ out:int btrfs_release_file (struct inode *inode,struct file *filp) { -/* -* ordered_data_close is set by settattr when we are about to truncate -* a file from a non-zero size to a zero size. This tries to -* flush down new bytes that may have been written if the -* application were using truncate to replace a file in place. -*/ -if (test_and_clear_bit (BTRFS_INODE_ORDERED_DATA_CLOSE , - &BTRFS_I (inode)->runtime_flags)) { -struct btrfs_trans_handle *trans; -struct btrfs_root *root =BTRFS_I (inode)->root; - -/* -* We need to block on a committing transaction to keep us from -* throwing a ordered operation on to the list and causing -* something like sync to deadlock trying to flush out this -* inode. -*/ - trans =btrfs_start_transaction (root,0 ); -if (IS_ERR (trans)) -return PTR_ERR (trans); -btrfs_add_ordered_operation (trans,BTRFS_I (inode)->root, inode); -btrfs_end_transaction (trans, root); -if (inode->i_size >BTRFS_ORDERED_OPERATIONS_FLUSH_LIMIT ) -filemap_flush (inode->i_mapping); - }if (filp->private_data)btrfs_ioctl_trans_end (filp); +filemap_flush (inode->i_mapping);return 0 ; }
fs/btrfs/inode.c +3 -44
78 lines not on this page · raw message
fs/btrfs/ordered-data.c +0 -123
141 lines not on this page · raw message
fs/btrfs/ordered-data.h +0 -5
@@ -190,11 +190,6 @@ int btrfs_ordered_update_i_size(struct i struct btrfs_ordered_extent *ordered);int btrfs_find_ordered_sum (struct inode *inode,u64 offset,u64 disk_bytenr,u32 *sum,int len); -int btrfs_run_ordered_operations (struct btrfs_trans_handle *trans, -struct btrfs_root *root,int wait); -void btrfs_add_ordered_operation (struct btrfs_trans_handle *trans, -struct btrfs_root *root, -struct inode *inode);int btrfs_wait_ordered_extents (struct btrfs_root *root,int nr);void btrfs_wait_ordered_roots (struct btrfs_fs_info *fs_info,int nr); void btrfs_get_logged_extents(struct inode *inode,
fs/btrfs/transaction.c +2 -31
@@ -218,7 +218,6 @@ loop:spin_lock_init (&cur_trans->delayed_refs.lock);INIT_LIST_HEAD (&cur_trans->pending_snapshots); -INIT_LIST_HEAD (&cur_trans->ordered_operations);INIT_LIST_HEAD (&cur_trans->pending_chunks);INIT_LIST_HEAD (&cur_trans->switch_commits);list_add_tail (&cur_trans->list, &fs_info->trans_list);
@@ -1612,27 +1611,6 @@ static void cleanup_transaction(struct bkmem_cache_free (btrfs_trans_handle_cachep, trans); } -static int btrfs_flush_all_pending_stuffs (struct btrfs_trans_handle *trans, -struct btrfs_root *root) -{ -int ret; - - ret =btrfs_run_delayed_items (trans, root); -if (ret) -return ret; - -/* -* rename don't use btrfs_join_transaction, so, once we -* set the transaction to blocked above, we aren't going -* to get any new ordered operations. We can safely run -* it here and no for sure that nothing new will be added -* to the list -*/ - ret =btrfs_run_ordered_operations (trans, root,1 ); - -return ret; -} -static inline int btrfs_start_delalloc_flush (struct btrfs_fs_info *fs_info) {if (btrfs_test_opt (fs_info->tree_root,FLUSHONCOMMIT ))
@@ -1653,13 +1631,6 @@ int btrfs_commit_transaction(struct btrfstruct btrfs_transaction *prev_trans =NULL ;int ret; - ret =btrfs_run_ordered_operations (trans, root,0 ); -if (ret) { -btrfs_abort_transaction (trans, root, ret); -btrfs_end_transaction (trans, root); -return ret; - } -/* Stop the commit early if ->aborted is set */ if (unlikely (ACCESS_ONCE (cur_trans->aborted))) { ret = cur_trans->aborted;
@@ -1740,7 +1711,7 @@ int btrfs_commit_transaction(struct btrfif (ret) goto cleanup_transaction; - ret =btrfs_flush_all_pending_stuffs (trans, root); + ret =btrfs_run_delayed_items (trans, root);if (ret) goto cleanup_transaction;
@@ -1748,7 +1719,7 @@ int btrfs_commit_transaction(struct btrf extwriter_counter_read(cur_trans) == 0);/* some pending stuffs might be added after the previous flush. */ - ret =btrfs_flush_all_pending_stuffs (trans, root); + ret =btrfs_run_delayed_items (trans, root);if (ret) goto cleanup_transaction;
fs/btrfs/transaction.h +0 -1
@@ -55,7 +55,6 @@ struct btrfs_transaction {wait_queue_head_t writer_wait;wait_queue_head_t commit_wait;struct list_head pending_snapshots; -struct list_head ordered_operations;struct list_head pending_chunks;struct list_head switch_commits;struct btrfs_delayed_ref_root delayed_refs;
Greg Kroah-Hartman
maintainerPATCH 89/125 Btrfs: fix crash on endio of reading corrupted block
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Bo <[email protected]>
commit 38c1c2e44bacb37efd68b90b3f70386a8ee370ee upstream.
The crash is
------------[ cut here ]------------ kernel BUG at fs/btrfs/extent_io.c:2124! [...] Workqueue: btrfs-endio normal_work_helper [btrfs] RIP: 0010:[<ffffffffa02d6055>] [<ffffffffa02d6055>] end_bio_extent_readpage+0xb45/0xcd0 [btrfs]
This is in fact a regression.
It is because we forgot to increase @offset properly in reading corrupted block, so that the @offset remains, and this leads to checksum errors while reading left blocks queued up in the same bio, and then ends up with hiting the above BUG_ON.
--- fs/btrfs/extent_io.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/extent_io.c +1 -0
@@ -2532,6 +2532,7 @@ static void end_bio_extent_readpage(strutest_bit (BIO_UPTODATE , &bio->bi_flags);if (err) uptodate =0 ; + offset += len;continue ; } }
Greg Kroah-Hartman
maintainerPATCH 90/125 Btrfs: fix filemap_flush call in btrfs_file_release
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
commit f6dc45c7a93a011dff6eb9b2ffda59c390c7705a upstream.
We should only be flushing on close if the file was flagged as needing it during truncate. I broke this with my ordered data vs transaction commit deadlock fix.
Thanks to Miao Xie for catching this.
--- fs/btrfs/file.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/btrfs/file.c +9 -1
@@ -1840,7 +1840,15 @@ int btrfs_release_file(struct inode *ino {if (filp->private_data)btrfs_ioctl_trans_end (filp); -filemap_flush (inode->i_mapping); +/* +* ordered_data_close is set by settattr when we are about to truncate +* a file from a non-zero size to a zero size. This tries to +* flush down new bytes that may have been written if the +* application were using truncate to replace a file in place. +*/ +if (test_and_clear_bit (BTRFS_INODE_ORDERED_DATA_CLOSE , + &BTRFS_I (inode)->runtime_flags)) +filemap_flush (inode->i_mapping);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 91/125 Btrfs: fix task hang under heavy compressed write
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Bo <[email protected]>
commit 9e0af23764344f7f1b68e4eefbe7dc865018b63d upstream.
This has been reported and discussed for a long time, and this hang occurs in both 3.15 and 3.16.
Btrfs now migrates to use kernel workqueue, but it introduces this hang problem.
Btrfs has a kind of work queued as an ordered way, which means that its ordered_func() must be processed in the way of FIFO, so it usually looks like --
normal_work_helper(arg)
work = container_of(arg, struct btrfs_work, normal_work);
work->func() <---- (we name it work X)
for ordered_work in wq->ordered_list
ordered_work->ordered_func()
ordered_work->ordered_free()The hang is a rare case, first when we find free space, we get an uncached block group, then we go to read its free space cache inode for free space information, so it will
file a readahead request
btrfs_readpages()
for page that is not in page cache
__do_readpage()
submit_extent_page()
btrfs_submit_bio_hook()
btrfs_bio_wq_end_io() submit_bio()
end_workqueue_bio() <--(ret by the 1st endio)
queue a work(named work Y) for the 2nd also the real endio()
So the hang occurs when work Y's work_struct and work X's work_struct happens to share the same address.
A bit more explanation,
A,B,C -- struct btrfs_work
arg -- struct work_struct
kthread:worker_thread()
pick up a work_struct from @worklist
process_one_work(arg)
worker->current_work = arg; <-- arg is A->normal_work
worker->current_func(arg)
normal_work_helper(arg)
A = container_of(arg, struct btrfs_work, normal_work);
A->func()
A->ordered_func()
A->ordered_free() <-- A gets freed
B->ordered_func()
submit_compressed_extents()
find_free_extent()
load_free_space_inode()
... <-- (the above readhead stack)
end_workqueue_bio()
btrfs_queue_work(work C)
B->ordered_free()As if work A has a high priority in wq->ordered_list and there are more ordered works queued after it, such as B->ordered_func(), its memory could have been freed before normal_work_helper() returns, which means that kernel workqueue code worker_thread() still has worker->current_work pointer to be work A->normal_work's, ie. arg's address.
Meanwhile, work C is allocated after work A is freed, work C->normal_work and work A->normal_work are likely to share the same address(I confirmed this with ftrace output, so I'm not just guessing, it's rare though).
When another kthread picks up work C->normal_work to process, and finds our kthread is processing it(see find_worker_executing_work()), it'll think work C as a collision and skip then, which ends up nobody processing work C.
So the situation is that our kthread is waiting forever on work C.
Besides, there're other cases that can lead to deadlock, but the real problem is that all btrfs workqueue shares one work->func, -- normal_work_helper, so this makes each workqueue to have its own helper function, but only a wraper pf normal_work_helper.
With this patch, I no long hit the above hang.
--- fs/btrfs/async-thread.c | 44 +++++++++++++++++++++++++++++++-------- fs/btrfs/async-thread.h | 28 +++++++++++++++++++++++- fs/btrfs/delayed-inode.c | 4 +-- fs/btrfs/disk-io.c | 53 +++++++++++++++++++++++++---------------------- fs/btrfs/extent-tree.c | 7 +++--- fs/btrfs/inode.c | 35 ++++++++++++++++++++----------- fs/btrfs/ordered-data.c | 1 fs/btrfs/qgroup.c | 1 fs/btrfs/raid56.c | 9 +++++-- fs/btrfs/reada.c | 3 +- fs/btrfs/scrub.c | 14 +++++++----- fs/btrfs/volumes.c | 3 +- 12 files changed, 141 insertions(+), 61 deletions(-)
fs/btrfs/async-thread.c +36 -8
@@ -22,7 +22,6 @@#include <linux/list.h> #include <linux/spinlock.h> #include <linux/freezer.h> -#include <linux/workqueue.h> #include "async-thread.h" #include "ctree.h"
@@ -55,8 +54,39 @@ struct btrfs_workqueue {struct __btrfs_workqueue *high; }; -static inline struct __btrfs_workqueue -*__btrfs_alloc_workqueue (const char *name,int flags,int max_active, +static void normal_work_helper (struct btrfs_work *work); + +#define BTRFS_WORK_HELPER (name) \ +void btrfs_##name(struct work_struct *arg) \ +{ \ + struct btrfs_work *work = container_of(arg, struct btrfs_work, \ + normal_work); \ + normal_work_helper(work); \ +} + +BTRFS_WORK_HELPER (worker_helper); +BTRFS_WORK_HELPER (delalloc_helper); +BTRFS_WORK_HELPER (flush_delalloc_helper); +BTRFS_WORK_HELPER (cache_helper); +BTRFS_WORK_HELPER (submit_helper); +BTRFS_WORK_HELPER (fixup_helper); +BTRFS_WORK_HELPER (endio_helper); +BTRFS_WORK_HELPER (endio_meta_helper); +BTRFS_WORK_HELPER (endio_meta_write_helper); +BTRFS_WORK_HELPER (endio_raid56_helper); +BTRFS_WORK_HELPER (rmw_helper); +BTRFS_WORK_HELPER (endio_write_helper); +BTRFS_WORK_HELPER (freespace_write_helper); +BTRFS_WORK_HELPER (delayed_meta_helper); +BTRFS_WORK_HELPER (readahead_helper); +BTRFS_WORK_HELPER (qgroup_rescan_helper); +BTRFS_WORK_HELPER (extent_refs_helper); +BTRFS_WORK_HELPER (scrub_helper); +BTRFS_WORK_HELPER (scrubwrc_helper); +BTRFS_WORK_HELPER (scrubnc_helper); + +static struct __btrfs_workqueue * +__btrfs_alloc_workqueue (const char *name,int flags,int max_active,int thresh) {struct __btrfs_workqueue *ret =kzalloc (sizeof (*ret),GFP_NOFS );
@@ -232,13 +262,11 @@ static void run_ordered_work(struct __btspin_unlock_irqrestore (lock, flags); } -static void normal_work_helper (struct work_struct *arg) +static void normal_work_helper (struct btrfs_work *work) { -struct btrfs_work *work;struct __btrfs_workqueue *wq;int need_order =0 ; - work = container_of(arg, struct btrfs_work, normal_work);/* * We should not touch things inside work in the following cases: * 1) after work->func() if it has no ordered_free
@@ -262,7 +290,7 @@ static void normal_work_helper(struct wotrace_btrfs_all_work_done (work); } -void btrfs_init_work (struct btrfs_work *work, +void btrfs_init_work (struct btrfs_work *work,btrfs_work_func_t uniq_func,btrfs_func_t func,btrfs_func_t ordered_func,btrfs_func_t ordered_free)
@@ -270,7 +298,7 @@ void btrfs_init_work(struct btrfs_work * work->func = func; work->ordered_func = ordered_func; work->ordered_free = ordered_free; -INIT_WORK (&work->normal_work, normal_work_helper); +INIT_WORK (&work->normal_work, uniq_func);INIT_LIST_HEAD (&work->ordered_list); work->flags =0 ; }
fs/btrfs/async-thread.h +27 -1
@@ -19,12 +19,14 @@ #ifndef __BTRFS_ASYNC_THREAD_ #define __BTRFS_ASYNC_THREAD_ +#include <linux/workqueue.h> struct btrfs_workqueue; /* Internal use only */ struct __btrfs_workqueue; struct btrfs_work; typedef void (*btrfs_func_t)(struct btrfs_work *arg); +typedef void (*btrfs_work_func_t)(struct work_struct *arg); struct btrfs_work { btrfs_func_t func;
@@ -38,11 +40,35 @@ struct btrfs_work {unsigned long flags; }; +#define BTRFS_WORK_HELPER_PROTO (name) \ +void btrfs_##name(struct work_struct *arg) + +BTRFS_WORK_HELPER_PROTO (worker_helper); +BTRFS_WORK_HELPER_PROTO (delalloc_helper); +BTRFS_WORK_HELPER_PROTO (flush_delalloc_helper); +BTRFS_WORK_HELPER_PROTO (cache_helper); +BTRFS_WORK_HELPER_PROTO (submit_helper); +BTRFS_WORK_HELPER_PROTO (fixup_helper); +BTRFS_WORK_HELPER_PROTO (endio_helper); +BTRFS_WORK_HELPER_PROTO (endio_meta_helper); +BTRFS_WORK_HELPER_PROTO (endio_meta_write_helper); +BTRFS_WORK_HELPER_PROTO (endio_raid56_helper); +BTRFS_WORK_HELPER_PROTO (rmw_helper); +BTRFS_WORK_HELPER_PROTO (endio_write_helper); +BTRFS_WORK_HELPER_PROTO (freespace_write_helper); +BTRFS_WORK_HELPER_PROTO (delayed_meta_helper); +BTRFS_WORK_HELPER_PROTO (readahead_helper); +BTRFS_WORK_HELPER_PROTO (qgroup_rescan_helper); +BTRFS_WORK_HELPER_PROTO (extent_refs_helper); +BTRFS_WORK_HELPER_PROTO (scrub_helper); +BTRFS_WORK_HELPER_PROTO (scrubwrc_helper); +BTRFS_WORK_HELPER_PROTO (scrubnc_helper); +struct btrfs_workqueue *btrfs_alloc_workqueue (const char *name,int flags,int max_active,int thresh); -void btrfs_init_work (struct btrfs_work *work, +void btrfs_init_work (struct btrfs_work *work,btrfs_work_func_t helper,btrfs_func_t func,btrfs_func_t ordered_func,btrfs_func_t ordered_free);
fs/btrfs/delayed-inode.c +2 -2
@@ -1395,8 +1395,8 @@ static int btrfs_wq_run_delayed_node(strreturn -ENOMEM ; async_work->delayed_root = delayed_root; -btrfs_init_work (&async_work->work, btrfs_async_run_delayed_root, -NULL ,NULL ); +btrfs_init_work (&async_work->work, btrfs_delayed_meta_helper, + btrfs_async_run_delayed_root,NULL ,NULL ); async_work->nr = nr;btrfs_queue_work (root->fs_info->delayed_workers, &async_work->work);
fs/btrfs/disk-io.c +29 -24
78 lines not on this page · raw message
fs/btrfs/extent-tree.c +4 -3
@@ -552,7 +552,8 @@ static int cache_block_group(struct btrf caching_ctl->block_group = cache; caching_ctl->progress = cache->key.objectid;atomic_set (&caching_ctl->count,1 ); -btrfs_init_work (&caching_ctl->work, caching_thread,NULL ,NULL ); +btrfs_init_work (&caching_ctl->work, btrfs_cache_helper, + caching_thread,NULL ,NULL );spin_lock (&cache->lock);/*
@@ -2749,8 +2750,8 @@ int btrfs_async_run_delayed_refs(struct async->sync =0 ;init_completion (&async->wait); -btrfs_init_work (&async->work, delayed_ref_async_start, -NULL ,NULL ); +btrfs_init_work (&async->work, btrfs_extent_refs_helper, + delayed_ref_async_start,NULL ,NULL );btrfs_queue_work (root->fs_info->extent_workers, &async->work);
fs/btrfs/inode.c +23 -12
@@ -1096,8 +1096,10 @@ static int cow_file_range_async(struct i async_cow->end = cur_end;INIT_LIST_HEAD (&async_cow->extents); -btrfs_init_work (&async_cow->work, async_cow_start, - async_cow_submit, async_cow_free); +btrfs_init_work (&async_cow->work, + btrfs_delalloc_helper, + async_cow_start, async_cow_submit, + async_cow_free); nr_pages = (cur_end - start +PAGE_CACHE_SIZE ) >>PAGE_CACHE_SHIFT ;
@@ -1881,7 +1883,8 @@ static int btrfs_writepage_start_hook(stSetPageChecked (page);page_cache_get (page); -btrfs_init_work (&fixup->work, btrfs_writepage_fixup_worker,NULL ,NULL ); +btrfs_init_work (&fixup->work, btrfs_fixup_helper, + btrfs_writepage_fixup_worker,NULL ,NULL ); fixup->page = page;btrfs_queue_work (root->fs_info->fixup_workers, &fixup->work);return -EBUSY ;
@@ -2822,7 +2825,8 @@ static int btrfs_writepage_end_io_hook(sstruct inode *inode = page->mapping->host;struct btrfs_root *root =BTRFS_I (inode)->root;struct btrfs_ordered_extent *ordered_extent =NULL ; -struct btrfs_workqueue *workers; +struct btrfs_workqueue *wq; +btrfs_work_func_t func;trace_btrfs_writepage_end_io_hook (page, start, end, uptodate);
@@ -2831,13 +2835,17 @@ static int btrfs_writepage_end_io_hook(s end - start + 1, uptodate))return 0 ; -btrfs_init_work (&ordered_extent->work, finish_ordered_fn,NULL ,NULL ); +if (btrfs_is_free_space_inode (inode)) { + wq = root->fs_info->endio_freespace_worker; + func = btrfs_freespace_write_helper; + }else { + wq = root->fs_info->endio_write_workers; + func = btrfs_endio_write_helper; + } -if (btrfs_is_free_space_inode (inode)) - workers = root->fs_info->endio_freespace_worker; -else - workers = root->fs_info->endio_write_workers; -btrfs_queue_work (workers, &ordered_extent->work); +btrfs_init_work (&ordered_extent->work, func, finish_ordered_fn,NULL , +NULL ); +btrfs_queue_work (wq, &ordered_extent->work);return 0 ; }
@@ -7158,7 +7166,8 @@ again:if (!ret) goto out_test; -btrfs_init_work (&ordered->work, finish_ordered_fn,NULL ,NULL ); +btrfs_init_work (&ordered->work, btrfs_endio_write_helper, + finish_ordered_fn,NULL ,NULL );btrfs_queue_work (root->fs_info->endio_write_workers, &ordered->work); out_test:
@@ -8485,7 +8494,9 @@ struct btrfs_delalloc_work *btrfs_alloc_ work->inode = inode; work->wait = wait; work->delay_iput = delay_iput; -btrfs_init_work (&work->work, btrfs_run_delalloc_work,NULL ,NULL ); +WARN_ON_ONCE (!inode); +btrfs_init_work (&work->work, btrfs_flush_delalloc_helper, + btrfs_run_delalloc_work,NULL ,NULL );return work; }
fs/btrfs/ordered-data.c +1 -0
@@ -615,6 +615,7 @@ int btrfs_wait_ordered_extents(struct btspin_unlock (&root->ordered_extent_lock);btrfs_init_work (&ordered->flush_work, + btrfs_flush_delalloc_helper, btrfs_run_ordered_extent_work,NULL ,NULL );list_add_tail (&ordered->work_list, &works); btrfs_queue_work(root->fs_info->flush_workers,
fs/btrfs/qgroup.c +1 -0
@@ -2551,6 +2551,7 @@ qgroup_rescan_init(struct btrfs_fs_infomemset (&fs_info->qgroup_rescan_work,0 ,sizeof (fs_info->qgroup_rescan_work));btrfs_init_work (&fs_info->qgroup_rescan_work, + btrfs_qgroup_rescan_helper, btrfs_qgroup_rescan_worker,NULL ,NULL );if (ret) {
fs/btrfs/raid56.c +6 -3
@@ -1416,7 +1416,8 @@ cleanup:static void async_rmw_stripe (struct btrfs_raid_bio *rbio) { -btrfs_init_work (&rbio->work, rmw_work,NULL ,NULL ); +btrfs_init_work (&rbio->work, btrfs_rmw_helper, + rmw_work,NULL ,NULL );btrfs_queue_work (rbio->fs_info->rmw_workers, &rbio->work);
@@ -1424,7 +1425,8 @@ static void async_rmw_stripe(struct btrfstatic void async_read_rebuild (struct btrfs_raid_bio *rbio) { -btrfs_init_work (&rbio->work, read_rebuild_work,NULL ,NULL ); +btrfs_init_work (&rbio->work, btrfs_rmw_helper, + read_rebuild_work,NULL ,NULL );btrfs_queue_work (rbio->fs_info->rmw_workers, &rbio->work);
@@ -1665,7 +1667,8 @@ static void btrfs_raid_unplug(struct blk plug = container_of(cb, struct btrfs_plug_cb, cb);if (from_schedule) { -btrfs_init_work (&plug->work, unplug_work,NULL ,NULL ); +btrfs_init_work (&plug->work, btrfs_rmw_helper, + unplug_work,NULL ,NULL );btrfs_queue_work (plug->info->rmw_workers, &plug->work);return ;
fs/btrfs/reada.c +2 -1
@@ -798,7 +798,8 @@ static void reada_start_machine(struct b/* FIXME we cannot handle this properly right now */ BUG (); } -btrfs_init_work (&rmw->work, reada_start_machine_worker,NULL ,NULL ); +btrfs_init_work (&rmw->work, btrfs_readahead_helper, + reada_start_machine_worker,NULL ,NULL ); rmw->fs_info = fs_info;btrfs_queue_work (fs_info->readahead_workers, &rmw->work);
fs/btrfs/scrub.c +8 -6
@@ -428,8 +428,8 @@ struct scrub_ctx *scrub_setup_ctx(struct sbio->index = i; sbio->sctx = sctx; sbio->page_count =0 ; -btrfs_init_work (&sbio->work, scrub_bio_end_io_worker, -NULL ,NULL ); +btrfs_init_work (&sbio->work, btrfs_scrub_helper, + scrub_bio_end_io_worker,NULL ,NULL );if (i !=SCRUB_BIOS_PER_SCTX -1 ) sctx->bios[i]->next_free = i +1 ;
@@ -999,8 +999,8 @@ nodatasum_case: fixup_nodatasum->root = fs_info->extent_root; fixup_nodatasum->mirror_num = failed_mirror_index +1 ;scrub_pending_trans_workers_inc (sctx); -btrfs_init_work (&fixup_nodatasum->work, scrub_fixup_nodatasum, -NULL ,NULL ); +btrfs_init_work (&fixup_nodatasum->work, btrfs_scrub_helper, + scrub_fixup_nodatasum,NULL ,NULL );btrfs_queue_work (fs_info->scrub_workers, &fixup_nodatasum->work); goto out;
@@ -1616,7 +1616,8 @@ static void scrub_wr_bio_end_io(struct b sbio->err = err; sbio->bio = bio; -btrfs_init_work (&sbio->work, scrub_wr_bio_end_io_worker,NULL ,NULL ); +btrfs_init_work (&sbio->work, btrfs_scrubwrc_helper, + scrub_wr_bio_end_io_worker,NULL ,NULL );btrfs_queue_work (fs_info->scrub_wr_completion_workers, &sbio->work); }
@@ -3203,7 +3204,8 @@ static int copy_nocow_pages(struct scrub nocow_ctx->len = len; nocow_ctx->mirror_num = mirror_num; nocow_ctx->physical_for_dev_replace = physical_for_dev_replace; -btrfs_init_work (&nocow_ctx->work, copy_nocow_pages_worker,NULL ,NULL ); +btrfs_init_work (&nocow_ctx->work, btrfs_scrubnc_helper, + copy_nocow_pages_worker,NULL ,NULL );INIT_LIST_HEAD (&nocow_ctx->inodes);btrfs_queue_work (fs_info->scrub_nocow_workers, &nocow_ctx->work);
fs/btrfs/volumes.c +2 -1
@@ -5800,7 +5800,8 @@ struct btrfs_device *btrfs_alloc_device(else generate_random_uuid (dev->uuid); -btrfs_init_work (&dev->work, pending_bios_fn,NULL ,NULL ); +btrfs_init_work (&dev->work, btrfs_submit_helper, + pending_bios_fn,NULL ,NULL );return dev; }
Greg Kroah-Hartman
maintainerPATCH 92/125 mei: reset client state on queued connect request
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
commit 73ab4232388b7a08f17c8d08141ff2099fa0b161 upstream.
If connect request is queued (e.g. device in pg) set client state to initializing, thus avoid preliminary exit in wait if current state is disconnected.
This is regression from:
commit e4d8270e604c3202131bac607969605ac397b893
Author: Alexander Usyskin <[email protected]>
mei: set connecting state just upon connection request is sent to the fw
--- drivers/misc/mei/client.c | 1 + 1 file changed, 1 insertion(+)
drivers/misc/mei/client.c +1 -0
@@ -601,6 +601,7 @@ int mei_cl_connect(struct mei_cl *cl, st cl->timer_count =MEI_CONNECT_TIMEOUT ;list_add_tail (&cb->list, &dev->ctrl_rd_list.list); }else { + cl->state =MEI_FILE_INITIALIZING ;list_add_tail (&cb->list, &dev->ctrl_wr_list.list); }
Greg Kroah-Hartman
maintainerPATCH 93/125 mei: nfc: fix memory leak in error path
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
commit 8e8248b1369c97c7bb6f8bcaee1f05deeabab8ef upstream.
NFC will leak buffer if send failed.
Use single exit point that does the freeing
--- drivers/misc/mei/nfc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/misc/mei/nfc.c +5 -6
@@ -342,9 +342,10 @@ static int mei_nfc_send(struct mei_cl_de ndev = (struct mei_nfc_dev *) cldev->priv_data; dev = ndev->cl->dev; + err = -ENOMEM ; mei_buf =kzalloc (length +MEI_NFC_HEADER_SIZE ,GFP_KERNEL );if (!mei_buf) -return -ENOMEM ; + goto out; hdr = (struct mei_nfc_hci_hdr *) mei_buf; hdr->cmd =MEI_NFC_CMD_HCI_SEND ;
@@ -354,12 +355,9 @@ static int mei_nfc_send(struct mei_cl_de hdr->data_size = length;memcpy (mei_buf +MEI_NFC_HEADER_SIZE , buf, length); - err =__mei_cl_send (ndev->cl, mei_buf, length +MEI_NFC_HEADER_SIZE );if (err <0 ) -return err; - -kfree (mei_buf); + goto out;if (!wait_event_interruptible_timeout (ndev->send_wq, ndev->recv_req_id == ndev->req_id,HZ )) {
@@ -368,7 +366,8 @@ static int mei_nfc_send(struct mei_cl_de }else { ndev->req_id++; } - +out: +kfree (mei_buf);return err; }
Greg Kroah-Hartman
maintainerPATCH 94/125 ext4: propagate errors up to ext4_find_entry()s callers
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit 36de928641ee48b2078d3fe9514242aaa2f92013 upstream.
If we run into some kind of error, such as ENOMEM, while calling ext4_getblk() or ext4_dx_find_entry(), we need to make sure this error gets propagated up to ext4_find_entry() and then to its callers. This way, transient errors such as ENOMEM can get propagated to the VFS. This is important so that the system calls return the appropriate error, and also so that in the case of ext4_lookup(), we return an error instead of a NULL inode, since that will result in a negative dentry cache entry that will stick around long past the OOM condition which caused a transient ENOMEM error.
Google-Bug-Id: #17142205
--- fs/ext4/ext4.h | 2 +- fs/ext4/namei.c | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-)
fs/ext4/ext4.h +1 -1
@@ -1826,7 +1826,7 @@ ext4_group_first_block_no(struct super_b/* * Special error return code only used by dx_probe() and its callers. */ -#define ERR_BAD_DX_DIR -75000 +#define ERR_BAD_DX_DIR (-(MAX_ERRNO - 1))/* * Timeout and state flag for lazy initialization inode thread.
fs/ext4/namei.c +33 -2
@@ -1227,7 +1227,7 @@ static struct buffer_head * ext4_find_enbuffer */ int num =0 ;ext4_lblk_t nblocks; -int i, err; +int i, err =0 ;int namelen; *res_dir =NULL ;
@@ -1264,7 +1264,11 @@ static struct buffer_head * ext4_find_en* return. Otherwise, fall back to doing a search the * old fashioned way. */ -if (bh || (err !=ERR_BAD_DX_DIR )) +if (err == -ENOENT ) +return NULL ; +if (err && err !=ERR_BAD_DX_DIR ) +return ERR_PTR (err); +if (bh)return bh;dxtrace (printk (KERN_DEBUG "ext4_find_entry: dx failed, " "falling back\n" ));
@@ -1295,6 +1299,11 @@ restart: } num++; bh =ext4_getblk (NULL , dir, b++,0 , &err); +if (unlikely (err)) { +if (ra_max ==0 ) +return ERR_PTR (err); +break ; + } bh_use[ra_max] = bh;if (bh) ll_rw_block(READ | REQ_META | REQ_PRIO,
@@ -1417,6 +1426,8 @@ static struct dentry *ext4_lookup(structreturn ERR_PTR (-ENAMETOOLONG ); bh =ext4_find_entry (dir, &dentry->d_name, &de,NULL ); +if (IS_ERR (bh)) +return (struct dentry *) bh; inode =NULL ;if (bh) {__u32 ino =le32_to_cpu (de->inode);
@@ -1450,6 +1461,8 @@ struct dentry *ext4_get_parent(struct destruct buffer_head *bh; bh =ext4_find_entry (child->d_inode, &dotdot, &de,NULL ); +if (IS_ERR (bh)) +return (struct dentry *) bh;if (!bh)return ERR_PTR (-ENOENT ); ino =le32_to_cpu (de->inode);
@@ -2727,6 +2740,8 @@ static int ext4_rmdir(struct inode *dir, retval = -ENOENT ; bh =ext4_find_entry (dir, &dentry->d_name, &de,NULL ); +if (IS_ERR (bh)) +return PTR_ERR (bh);if (!bh) goto end_rmdir;
@@ -2794,6 +2809,8 @@ static int ext4_unlink(struct inode *dir retval = -ENOENT ; bh =ext4_find_entry (dir, &dentry->d_name, &de,NULL ); +if (IS_ERR (bh)) +return PTR_ERR (bh);if (!bh) goto end_unlink;
@@ -3121,6 +3138,8 @@ static int ext4_find_delete_entry(handlestruct ext4_dir_entry_2 *de; bh =ext4_find_entry (dir, d_name, &de,NULL ); +if (IS_ERR (bh)) +return PTR_ERR (bh);if (bh) { retval =ext4_delete_entry (handle, dir, de, bh);brelse (bh);
@@ -3202,6 +3221,8 @@ static int ext4_rename(struct inode *olddquot_initialize (new.inode); old.bh =ext4_find_entry (old.dir, &old.dentry->d_name, &old.de,NULL ); +if (IS_ERR (old.bh)) +return PTR_ERR (old.bh);/* * Check for inode number is _not_ due to possible IO errors. * We might rmdir the source, keep it as pwd of some process
@@ -3214,6 +3235,10 @@ static int ext4_rename(struct inode *old new.bh =ext4_find_entry (new.dir, &new.dentry->d_name, &new.de, &new.inlined); +if (IS_ERR (new.bh)) { + retval =PTR_ERR (new.bh); + goto end_rename; + }if (new.bh) {if (!new.inode) {brelse (new.bh);
@@ -3330,6 +3355,8 @@ static int ext4_cross_rename(struct inod old.bh =ext4_find_entry (old.dir, &old.dentry->d_name, &old.de, &old.inlined); +if (IS_ERR (old.bh)) +return PTR_ERR (old.bh);/* * Check for inode number is _not_ due to possible IO errors. * We might rmdir the source, keep it as pwd of some process
@@ -3342,6 +3369,10 @@ static int ext4_cross_rename(struct inod new.bh =ext4_find_entry (new.dir, &new.dentry->d_name, &new.de, &new.inlined); +if (IS_ERR (new.bh)) { + retval =PTR_ERR (new.bh); + goto end_rename; + }/* RENAME_EXCHANGE case: old *and* new must both exist */ if (!new.bh ||le32_to_cpu (new.de->inode) != new.inode->i_ino)
Greg Kroah-Hartman
maintainerPATCH 95/125 ext4: move i_size,i_disksize update routines to helper function
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Monakhov <[email protected]>
commit 4631dbf677ded0419fee35ca7408285dabfaef1a upstream.
--- fs/ext4/ext4.h | 16 ++++++++++++++++ fs/ext4/extents.c | 17 ++++------------- fs/ext4/inode.c | 34 ++++++++-------------------------- 3 files changed, 28 insertions(+), 39 deletions(-)
fs/ext4/ext4.h +16 -0
@@ -2453,6 +2453,22 @@ static inline void ext4_update_i_disksizup_write (&EXT4_I (inode)->i_data_sem); } +/* Update i_size, i_disksize. Requires i_mutex to avoid races with truncate */ +static inline int ext4_update_inode_size (struct inode *inode,loff_t newsize) +{ +int changed =0 ; + +if (newsize > inode->i_size) { +i_size_write (inode, newsize); + changed =1 ; + } +if (newsize >EXT4_I (inode)->i_disksize) { +ext4_update_i_disksize (inode, newsize); + changed |=2 ; + } +return changed; +} +struct ext4_group_info {unsigned long bb_state;struct rb_root bb_free_root;
fs/ext4/extents.c +4 -13
@@ -4838,12 +4838,8 @@ static long ext4_zero_range(struct file } inode->i_mtime = inode->i_ctime =ext4_current_time (inode); -if (new_size) { -if (new_size >i_size_read (inode)) -i_size_write (inode, new_size); -if (new_size >EXT4_I (inode)->i_disksize) -ext4_update_i_disksize (inode, new_size); +ext4_update_inode_size (inode, new_size); }else {/* * Mark that we allocate beyond EOF so the subsequent truncate
@@ -4885,7 +4881,6 @@ long ext4_fallocate(struct file *file, iint ret =0 ;int flags;ext4_lblk_t lblk; -struct timespec tv;unsigned int blkbits = inode->i_blkbits;/* Return error if mode is not supported */
@@ -4944,15 +4939,11 @@ long ext4_fallocate(struct file *file, iif (IS_ERR (handle)) goto out; - tv = inode->i_ctime =ext4_current_time (inode); + inode->i_ctime =ext4_current_time (inode);if (new_size) { -if (new_size >i_size_read (inode)) { -i_size_write (inode, new_size); - inode->i_mtime = tv; - } -if (new_size >EXT4_I (inode)->i_disksize) -ext4_update_i_disksize (inode, new_size); +if (ext4_update_inode_size (inode, new_size) &0x1 ) + inode->i_mtime = inode->i_ctime; }else {/* * Mark that we allocate beyond EOF so the subsequent truncate
fs/ext4/inode.c +8 -26
@@ -1092,27 +1092,11 @@ static int ext4_write_end(struct file *f }else copied =block_write_end (file, mapping, pos, len, copied, page, fsdata); -/* -* No need to use i_size_read() here, the i_size -* cannot change under us because we hole i_mutex. -* -* But it's important to update i_size while still holding page lock: +* it's important to update i_size while still holding page lock: * page writeout could otherwise come in and zero beyond i_size. */ -if (pos + copied > inode->i_size) { -i_size_write (inode, pos + copied); - i_size_changed =1 ; - } - -if (pos + copied >EXT4_I (inode)->i_disksize) { -/* We need to mark inode dirty even if -* new_i_size is less that inode->i_size -* but greater than i_disksize. (hint delalloc) -*/ -ext4_update_i_disksize (inode, (pos + copied)); - i_size_changed =1 ; - } + i_size_changed =ext4_update_inode_size (inode, pos + copied);unlock_page (page);page_cache_release (page);
@@ -1160,7 +1144,7 @@ static int ext4_journalled_write_end(strint ret =0 , ret2;int partial =0 ;unsigned from, to; -loff_t new_i_size; +int size_changed =0 ;trace_ext4_journalled_write_end (inode, pos, len, copied); from = pos & (PAGE_CACHE_SIZE -1 );
@@ -1183,20 +1167,18 @@ static int ext4_journalled_write_end(strif (!partial)SetPageUptodate (page); } - new_i_size = pos + copied; -if (new_i_size > inode->i_size) -i_size_write (inode, pos+copied); + size_changed =ext4_update_inode_size (inode, pos + copied);ext4_set_inode_state (inode,EXT4_STATE_JDATA );EXT4_I (inode)->i_datasync_tid = handle->h_transaction->t_tid; -if (new_i_size >EXT4_I (inode)->i_disksize) { -ext4_update_i_disksize (inode, new_i_size); +unlock_page (page); +page_cache_release (page); + +if (size_changed) { ret2 =ext4_mark_inode_dirty (handle, inode);if (!ret) ret = ret2; } -unlock_page (page); -page_cache_release (page);if (pos + len > inode->i_size &&ext4_can_truncate (inode))/* if we have allocated more blocks and copied * less. We will have blocks allocated outside
Greg Kroah-Hartman
maintainerPATCH 96/125 ext4: fix incorect journal credits reservation in ext4_zero_range
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Monakhov <[email protected]>
commit 69dc9536405213c1d545fcace1fc15c481d00aae upstream.
Currently we reserve only 4 blocks but in worst case scenario ext4_zero_partial_blocks() may want to zeroout and convert two non adjacent blocks.
--- fs/ext4/extents.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/ext4/extents.c +9 -2
@@ -4730,6 +4730,7 @@ static long ext4_zero_range(struct fileloff_t new_size =0 ;int ret =0 ;int flags; +int credits;int partial;loff_t start, end;ext4_lblk_t lblk;
@@ -4829,8 +4830,14 @@ static long ext4_zero_range(struct fileif (ret) goto out_dio; } - - handle =ext4_journal_start (inode,EXT4_HT_MISC ,4 ); +/* +* In worst case we have to writeout two nonadjacent unwritten +* blocks and update the inode +*/ + credits = (2 *ext4_ext_index_trans_blocks (inode,2 )) +1 ; +if (ext4_should_journal_data (inode)) + credits +=2 ; + handle =ext4_journal_start (inode,EXT4_HT_MISC , credits);if (IS_ERR (handle)) { ret =PTR_ERR (handle);ext4_std_error (inode->i_sb, ret);
Greg Kroah-Hartman
maintainerPATCH 97/125 ext4: fix transaction issues for ext4_fallocate and ext_zero_range
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Monakhov <[email protected]>
commit c174e6d6979a04b7b77b93f244396be4b81f8bfb upstream.
After commit f282ac19d86f we use different transactions for preallocation and i_disksize update which result in complain from fsck after power-failure. spotted by generic/019. IMHO this is regression because fs becomes inconsistent, even more 'e2fsck -p' will no longer works (which drives admins go crazy) Same transaction requirement applies ctime,mtime updates
testcase: xfstest generic/019
--- fs/ext4/extents.c | 68 +++++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 33 deletions(-)
fs/ext4/extents.c +35 -33
@@ -4664,7 +4664,8 @@ retry: }static int ext4_alloc_file_blocks (struct file *file,ext4_lblk_t offset, -ext4_lblk_t len,int flags,int mode) +ext4_lblk_t len,loff_t new_size, +int flags,int mode) {struct inode *inode =file_inode (file);handle_t *handle;
@@ -4673,8 +4674,10 @@ static int ext4_alloc_file_blocks(structint retries =0 ;struct ext4_map_blocks map;unsigned int credits; +loff_t epos; map.m_lblk = offset; + map.m_len = len;/* * Don't normalize the request if it can fit in one extent so * that it doesn't get unnecessarily split into multiple
@@ -4689,9 +4692,7 @@ static int ext4_alloc_file_blocks(struct credits =ext4_chunk_trans_blocks (inode, len); retry: -while (ret >=0 && ret < len) { - map.m_lblk = map.m_lblk + ret; - map.m_len = len = len - ret; +while (ret >=0 && len) { handle =ext4_journal_start (inode,EXT4_HT_MAP_BLOCKS , credits);if (IS_ERR (handle)) {
@@ -4708,6 +4709,21 @@ retry: ret2 =ext4_journal_stop (handle);break ; } + map.m_lblk += ret; + map.m_len = len = len - ret; + epos = (loff_t )map.m_lblk << inode->i_blkbits; + inode->i_ctime =ext4_current_time (inode); +if (new_size) { +if (epos > new_size) + epos = new_size; +if (ext4_update_inode_size (inode, epos) &0x1 ) + inode->i_mtime = inode->i_ctime; + }else { +if (epos > inode->i_size) +ext4_set_inode_flag (inode, +EXT4_INODE_EOFBLOCKS ); + } +ext4_mark_inode_dirty (handle, inode); ret2 =ext4_journal_stop (handle);if (ret2)break ;
@@ -4731,7 +4747,7 @@ static long ext4_zero_range(struct fileint ret =0 ;int flags;int credits; -int partial; +int partial_begin, partial_end;loff_t start, end;ext4_lblk_t lblk;struct address_space *mapping = inode->i_mapping;
@@ -4771,7 +4787,8 @@ static long ext4_zero_range(struct fileif (start < offset || end > offset + len)return -EINVAL ; - partial = (offset + len) & ((1 << blkbits) -1 ); + partial_begin = offset & ((1 << blkbits) -1 ); + partial_end = (offset + len) & ((1 << blkbits) -1 ); lblk = start >> blkbits; max_blocks = (end >> blkbits);
@@ -4805,7 +4822,7 @@ static long ext4_zero_range(struct file* If we have a partial block after EOF we have to allocate * the entire block. */ -if (partial) +if (partial_end) max_blocks +=1 ; }
@@ -4813,6 +4830,7 @@ static long ext4_zero_range(struct file/* Now release the pages and zero block aligned part of pages*/ truncate_pagecache_range (inode, start, end -1 ); + inode->i_mtime = inode->i_ctime =ext4_current_time (inode);/* Wait all existing dio workers, newcomers will block on i_mutex */ ext4_inode_block_unlocked_dio (inode);
@@ -4825,11 +4843,14 @@ static long ext4_zero_range(struct fileif (ret) goto out_dio; - ret =ext4_alloc_file_blocks (file, lblk, max_blocks, flags, - mode); + ret =ext4_alloc_file_blocks (file, lblk, max_blocks, new_size, + flags, mode);if (ret) goto out_dio; } +if (!partial_begin && !partial_end) + goto out_dio; +/* * In worst case we have to writeout two nonadjacent unwritten * blocks and update the inode
@@ -4855,7 +4876,6 @@ static long ext4_zero_range(struct fileif ((offset + len) >i_size_read (inode))ext4_set_inode_flag (inode,EXT4_INODE_EOFBLOCKS ); } -ext4_mark_inode_dirty (handle, inode);/* Zero out partial block at the edges of the range */
@@ -4882,7 +4902,6 @@ out_mutex:long ext4_fallocate (struct file *file,int mode,loff_t offset,loff_t len) {struct inode *inode =file_inode (file); -handle_t *handle;loff_t new_size =0 ;unsigned int max_blocks;int ret =0 ;
@@ -4938,32 +4957,15 @@ long ext4_fallocate(struct file *file, i goto out; } - ret =ext4_alloc_file_blocks (file, lblk, max_blocks, flags, mode); + ret =ext4_alloc_file_blocks (file, lblk, max_blocks, new_size, + flags, mode);if (ret) goto out; - handle =ext4_journal_start (inode,EXT4_HT_INODE ,2 ); -if (IS_ERR (handle)) - goto out; - - inode->i_ctime =ext4_current_time (inode); - -if (new_size) { -if (ext4_update_inode_size (inode, new_size) &0x1 ) - inode->i_mtime = inode->i_ctime; - }else { -/* -* Mark that we allocate beyond EOF so the subsequent truncate -* can proceed even if the new size is the same as i_size. -*/ -if ((offset + len) >i_size_read (inode)) -ext4_set_inode_flag (inode,EXT4_INODE_EOFBLOCKS ); +if (file->f_flags &O_SYNC &&EXT4_SB (inode->i_sb)->s_journal) { + ret =jbd2_complete_transaction (EXT4_SB (inode->i_sb)->s_journal, +EXT4_I (inode)->i_sync_tid); } -ext4_mark_inode_dirty (handle, inode); -if (file->f_flags &O_SYNC ) -ext4_handle_sync (handle); - -ext4_journal_stop (handle); out:mutex_unlock (&inode->i_mutex);trace_ext4_fallocate_exit (inode, offset, max_blocks, ret);
Greg Kroah-Hartman
maintainerPATCH 98/125 ext4: update i_disksize coherently with block allocation on error path
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Monakhov <[email protected]>
commit 6603120e96eae9a5d6228681ae55c7fdc998d1bb upstream.
In case of delalloc block i_disksize may be less than i_size. So we have to update i_disksize each time we allocated and submitted some blocks beyond i_disksize. We weren't doing this on the error paths, so fix this.
testcase: xfstest generic/019
--- fs/ext4/inode.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/ext4/inode.c +8 -2
@@ -2194,6 +2194,7 @@ static int mpage_map_and_submit_extent(hstruct ext4_map_blocks *map = &mpd->map;int err;loff_t disksize; +int progress =0 ; mpd->io_submit.io_end->offset = ((loff_t )map->m_lblk) << inode->i_blkbits;
@@ -2210,8 +2211,11 @@ static int mpage_map_and_submit_extent(h* is non-zero, a commit should free up blocks. */ if ((err == -ENOMEM ) || - (err == -ENOSPC &&ext4_count_free_clusters (sb))) + (err == -ENOSPC &&ext4_count_free_clusters (sb))) { +if (progress) + goto update_disksize;return err; + }ext4_msg (sb,KERN_CRIT ,"Delayed block allocation failed for " "inode %lu at logical offset %llu with"
@@ -2228,15 +2232,17 @@ static int mpage_map_and_submit_extent(h *give_up_on_write = true;return err; } + progress =1 ;/* * Update buffer state, submit mapped pages, and get us new * extent to map */ err =mpage_map_and_submit_buffers (mpd);if (err <0 ) -return err; + goto update_disksize; }while (map->m_len); +update_disksize:/* * Update on-disk size after IO is submitted. Races with * truncate are avoided by checking i_size under i_data_sem.
Greg Kroah-Hartman
maintainerPATCH 99/125 ext4: fix same-dir rename when inline data directory overflows
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Darrick J. Wong" <[email protected]>
commit d80d448c6c5bdd32605b78a60fe8081d82d4da0f upstream.
When performing a same-directory rename, it's possible that adding or setting the new directory entry will cause the directory to overflow the inline data area, which causes the directory to be converted to an extent-based directory. Under this circumstance it is necessary to re-read the directory when deleting the old dirent because the "old directory" context still points to i_block in the inode table, which is now an extent tree root! The delete fails with an FS error, and the subsequent fsck complains about incorrect link counts and hardlinked directories.
Test case (originally found with flat_dir_test in the metadata_csum test program):
# mkfs.ext4 -O inline_data /dev/sda # mount /dev/sda /mnt # mkdir /mnt/x # touch /mnt/x/changelog.gz /mnt/x/copyright /mnt/x/README.Debian # sync # for i in /mnt/x/*; do mv $i $i.longer; done # ls -la /mnt/x/ total 0 -rw-r--r-- 1 root root 0 Aug 25 12:03 changelog.gz.longer -rw-r--r-- 1 root root 0 Aug 25 12:03 copyright -rw-r--r-- 1 root root 0 Aug 25 12:03 copyright.longer -rw-r--r-- 1 root root 0 Aug 25 12:03 README.Debian.longer
(Hey! Why are there four files now??)
--- fs/ext4/namei.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
fs/ext4/namei.c +18 -3
@@ -3147,7 +3147,8 @@ static int ext4_find_delete_entry(handlereturn retval; } -static void ext4_rename_delete (handle_t *handle,struct ext4_renament *ent) +static void ext4_rename_delete (handle_t *handle,struct ext4_renament *ent, +int force_reread) {int retval;/*
@@ -3159,7 +3160,8 @@ static void ext4_rename_delete(handle_tif (le32_to_cpu (ent->de->inode) != ent->inode->i_ino || ent->de->name_len != ent->dentry->d_name.len ||strncmp (ent->de->name, ent->dentry->d_name.name, - ent->de->name_len)) { + ent->de->name_len) || + force_reread) { retval =ext4_find_delete_entry (handle, ent->dir, &ent->dentry->d_name); }else {
@@ -3210,6 +3212,7 @@ static int ext4_rename(struct inode *old .dentry = new_dentry, .inode = new_dentry->d_inode, }; +int force_reread;int retval;dquot_initialize (old.dir);
@@ -3271,6 +3274,15 @@ static int ext4_rename(struct inode *oldif (retval) goto end_rename; } +/* +* If we're renaming a file within an inline_data dir and adding or +* setting the new dirent causes a conversion from inline_data to +* extents/blockmap, we need to force the dirent delete code to +* re-read the directory, or else we end up trying to delete a dirent +* from what is now the extent tree root (or a block map). +*/ + force_reread = (new.dir->i_ino == old.dir->i_ino && +ext4_test_inode_flag (new.dir,EXT4_INODE_INLINE_DATA ));if (!new.bh) { retval =ext4_add_entry (handle, new.dentry, old.inode);if (retval)
@@ -3281,6 +3293,9 @@ static int ext4_rename(struct inode *oldif (retval) goto end_rename; } +if (force_reread) + force_reread = !ext4_test_inode_flag (new.dir, +EXT4_INODE_INLINE_DATA );/* * Like most other Unix systems, set the ctime for inodes on a
@@ -3292,7 +3307,7 @@ static int ext4_rename(struct inode *old/* * ok, that's it */ -ext4_rename_delete (handle, &old); +ext4_rename_delete (handle, &old, force_reread);if (new.inode) {ext4_dec_count (handle, new.inode);
Greg Kroah-Hartman
maintainerPATCH 100/125 jbd2: fix infinite loop when recovering corrupt journal blocks
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Darrick J. Wong" <[email protected]>
commit 022eaa7517017efe4f6538750c2b59a804dc7df7 upstream.
When recovering the journal, don't fall into an infinite loop if we encounter a corrupt journal block. Instead, just skip the block and return an error, which fails the mount and thus forces the user to run a full filesystem fsck.
--- fs/jbd2/recovery.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/jbd2/recovery.c +5 -2
@@ -426,6 +426,7 @@ static int do_one_pass(journal_t *journaint tag_bytes =journal_tag_bytes (journal);__u32 crc32_sum = ~0 ;/* Transactional Checksums */ int descr_csum_size =0 ; +int block_error =0 ;/* * First thing is to establish what we expect to find in the log
@@ -598,7 +599,8 @@ static int do_one_pass(journal_t *journa"checksum recovering " "block %llu in log\n" , blocknr); -continue ; + block_error =1 ; + goto skip_write; }/* Find a buffer for the new
@@ -797,7 +799,8 @@ static int do_one_pass(journal_t *journa success = -EIO ; } } - +if (block_error && success ==0 ) + success = -EIO ;return success; failed:
Greg Kroah-Hartman
maintainerPATCH 101/125 jbd2: fix descriptor block size handling errors with journal_csum
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Darrick J. Wong" <[email protected]>
commit db9ee220361de03ee86388f9ea5e529eaad5323c upstream.
It turns out that there are some serious problems with the on-disk format of journal checksum v2. The foremost is that the function to calculate descriptor tag size returns sizes that are too big. This causes alignment issues on some architectures and is compounded by the fact that some parts of jbd2 use the structure size (incorrectly) to determine the presence of a 64bit journal instead of checking the feature flags.
Therefore, introduce journal checksum v3, which enlarges the descriptor block tag format to allow for full 32-bit checksums of journal blocks, fix the journal tag function to return the correct sizes, and fix the jbd2 recovery code to use feature flags to determine 64bitness.
Add a few function helpers so we don't have to open-code quite so many pieces.
Switching to a 16-byte block size was found to increase journal size overhead by a maximum of 0.1%, to convert a 32-bit journal with no checksumming to a 32-bit journal with checksum v3 enabled.
--- fs/ext4/super.c | 5 ++-- fs/jbd2/commit.c | 21 ++++++++++--------- fs/jbd2/journal.c | 56 +++++++++++++++++++++++++++++++++------------------ fs/jbd2/recovery.c | 26 +++++++++++++---------- fs/jbd2/revoke.c | 6 ++--- include/linux/jbd2.h | 30 ++++++++++++++++++++++----- 6 files changed, 95 insertions(+), 49 deletions(-)
fs/ext4/super.c +3 -2
@@ -3185,9 +3185,9 @@ static int set_journal_csum_feature_set(if (EXT4_HAS_RO_COMPAT_FEATURE (sb,EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) { -/* journal checksum v2 */ +/* journal checksum v3 */ compat =0 ; - incompat =JBD2_FEATURE_INCOMPAT_CSUM_V2 ; + incompat =JBD2_FEATURE_INCOMPAT_CSUM_V3 ; }else {/* journal checksum v1 */ compat =JBD2_FEATURE_COMPAT_CHECKSUM ;
@@ -3209,6 +3209,7 @@ static int set_journal_csum_feature_set(jbd2_journal_clear_features (sbi->s_journal,JBD2_FEATURE_COMPAT_CHECKSUM ,0 ,JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | +JBD2_FEATURE_INCOMPAT_CSUM_V3 |JBD2_FEATURE_INCOMPAT_CSUM_V2 ); }
fs/jbd2/commit.c +12 -9
@@ -97,7 +97,7 @@ static void jbd2_commit_block_csum_set(jstruct commit_header *h;__u32 csum; -if (!JBD2_HAS_INCOMPAT_FEATURE (j,JBD2_FEATURE_INCOMPAT_CSUM_V2 )) +if (!jbd2_journal_has_csum_v2or3 (j))return ; h = (struct commit_header *)(bh->b_data);
@@ -313,11 +313,11 @@ static __u32 jbd2_checksum_data(__u32 crreturn checksum; } -static void write_tag_block (int tag_bytes,journal_block_tag_t *tag, +static void write_tag_block (journal_t *j,journal_block_tag_t *tag,unsigned long long block) { tag->t_blocknr =cpu_to_be32 (block & (u32 )~0 ); -if (tag_bytes >JBD2_TAG_SIZE32 ) +if (JBD2_HAS_INCOMPAT_FEATURE (j,JBD2_FEATURE_INCOMPAT_64BIT )) tag->t_blocknr_high =cpu_to_be32 ((block >>31 ) >>1 ); }
@@ -327,7 +327,7 @@ static void jbd2_descr_block_csum_set(jostruct jbd2_journal_block_tail *tail;__u32 csum; -if (!JBD2_HAS_INCOMPAT_FEATURE (j,JBD2_FEATURE_INCOMPAT_CSUM_V2 )) +if (!jbd2_journal_has_csum_v2or3 (j))return ; tail = (struct jbd2_journal_block_tail *)(bh->b_data + j->j_blocksize -
@@ -340,12 +340,13 @@ static void jbd2_descr_block_csum_set(jostatic void jbd2_block_tag_csum_set (journal_t *j,journal_block_tag_t *tag,struct buffer_head *bh,__u32 sequence) { +journal_block_tag3_t *tag3 = (journal_block_tag3_t *)tag;struct page *page = bh->b_page;__u8 *addr;__u32 csum32;__be32 seq; -if (!JBD2_HAS_INCOMPAT_FEATURE (j,JBD2_FEATURE_INCOMPAT_CSUM_V2 )) +if (!jbd2_journal_has_csum_v2or3 (j))return ; seq =cpu_to_be32 (sequence);
@@ -355,8 +356,10 @@ static void jbd2_block_tag_csum_set(jour bh->b_size);kunmap_atomic (addr); -/* We only have space to store the lower 16 bits of the crc32c. */ - tag->t_checksum =cpu_to_be16 (csum32); +if (JBD2_HAS_INCOMPAT_FEATURE (j,JBD2_FEATURE_INCOMPAT_CSUM_V3 )) + tag3->t_checksum =cpu_to_be32 (csum32); +else + tag->t_checksum =cpu_to_be16 (csum32); }/* * jbd2_journal_commit_transaction
@@ -396,7 +399,7 @@ void jbd2_journal_commit_transaction(jouLIST_HEAD (io_bufs);LIST_HEAD (log_bufs); -if (JBD2_HAS_INCOMPAT_FEATURE (journal,JBD2_FEATURE_INCOMPAT_CSUM_V2 )) +if (jbd2_journal_has_csum_v2or3 (journal)) csum_size =sizeof (struct jbd2_journal_block_tail );/*
@@ -690,7 +693,7 @@ void jbd2_journal_commit_transaction(jou tag_flag |=JBD2_FLAG_SAME_UUID ; tag = (journal_block_tag_t *) tagp; -write_tag_block (tag_bytes, tag,jh2bh (jh)->b_blocknr); +write_tag_block (journal, tag,jh2bh (jh)->b_blocknr); tag->t_flags =cpu_to_be16 (tag_flag);jbd2_block_tag_csum_set (journal, tag, wbuf[bufs], commit_transaction->t_tid);
fs/jbd2/journal.c +37 -19
133 lines not on this page · raw message
fs/jbd2/recovery.c +15 -11
@@ -181,7 +181,7 @@ static int jbd2_descr_block_csum_verify(__be32 provided;__u32 calculated; -if (!JBD2_HAS_INCOMPAT_FEATURE (j,JBD2_FEATURE_INCOMPAT_CSUM_V2 )) +if (!jbd2_journal_has_csum_v2or3 (j))return 1 ; tail = (struct jbd2_journal_block_tail *)(buf + j->j_blocksize -
@@ -205,7 +205,7 @@ static int count_tags(journal_t *journalint nr =0 , size = journal->j_blocksize;int tag_bytes =journal_tag_bytes (journal); -if (JBD2_HAS_INCOMPAT_FEATURE (journal,JBD2_FEATURE_INCOMPAT_CSUM_V2 )) +if (jbd2_journal_has_csum_v2or3 (journal)) size -=sizeof (struct jbd2_journal_block_tail ); tagp = &bh->b_data[sizeof (journal_header_t)];
@@ -338,10 +338,11 @@ int jbd2_journal_skip_recovery(journal_treturn err; } -static inline unsigned long long read_tag_block (int tag_bytes,journal_block_tag_t *tag) +static inline unsigned long long read_tag_block (journal_t *journal, +journal_block_tag_t *tag) {unsigned long long block =be32_to_cpu (tag->t_blocknr); -if (tag_bytes >JBD2_TAG_SIZE32 ) +if (JBD2_HAS_INCOMPAT_FEATURE (journal,JBD2_FEATURE_INCOMPAT_64BIT )) block |= (u64 )be32_to_cpu (tag->t_blocknr_high) <<32 ;return block; }
@@ -384,7 +385,7 @@ static int jbd2_commit_block_csum_verify__be32 provided;__u32 calculated; -if (!JBD2_HAS_INCOMPAT_FEATURE (j,JBD2_FEATURE_INCOMPAT_CSUM_V2 )) +if (!jbd2_journal_has_csum_v2or3 (j))return 1 ; h = buf;
@@ -399,17 +400,21 @@ static int jbd2_commit_block_csum_verifystatic int jbd2_block_tag_csum_verify (journal_t *j,journal_block_tag_t *tag,void *buf,__u32 sequence) { +journal_block_tag3_t *tag3 = (journal_block_tag3_t *)tag;__u32 csum32;__be32 seq; -if (!JBD2_HAS_INCOMPAT_FEATURE (j,JBD2_FEATURE_INCOMPAT_CSUM_V2 )) +if (!jbd2_journal_has_csum_v2or3 (j))return 1 ; seq =cpu_to_be32 (sequence); csum32 =jbd2_chksum (j, j->j_csum_seed, (__u8 *)&seq,sizeof (seq)); csum32 =jbd2_chksum (j, csum32, buf, j->j_blocksize); -return tag->t_checksum ==cpu_to_be16 (csum32); +if (JBD2_HAS_INCOMPAT_FEATURE (j,JBD2_FEATURE_INCOMPAT_CSUM_V3 )) +return tag3->t_checksum ==cpu_to_be32 (csum32); +else +return tag->t_checksum ==cpu_to_be16 (csum32); } static int do_one_pass(journal_t *journal,
@@ -513,8 +518,7 @@ static int do_one_pass(journal_t *journaswitch (blocktype) {case JBD2_DESCRIPTOR_BLOCK :/* Verify checksum first */ -if (JBD2_HAS_INCOMPAT_FEATURE (journal, -JBD2_FEATURE_INCOMPAT_CSUM_V2 )) +if (jbd2_journal_has_csum_v2or3 (journal)) descr_csum_size =sizeof (struct jbd2_journal_block_tail ); if (descr_csum_size > 0 &&
@@ -575,7 +579,7 @@ static int do_one_pass(journal_t *journaunsigned long long blocknr;J_ASSERT (obh !=NULL ); - blocknr =read_tag_block (tag_bytes, + blocknr =read_tag_block (journal, tag);/* If the block has been
@@ -814,7 +818,7 @@ static int jbd2_revoke_block_csum_verify__be32 provided;__u32 calculated; -if (!JBD2_HAS_INCOMPAT_FEATURE (j,JBD2_FEATURE_INCOMPAT_CSUM_V2 )) +if (!jbd2_journal_has_csum_v2or3 (j))return 1 ; tail = (struct jbd2_journal_revoke_tail *)(buf + j->j_blocksize -
fs/jbd2/revoke.c +3 -3
@@ -91,8 +91,8 @@#include <linux/list.h> #include <linux/init.h> #include <linux/bio.h> -#endif #include <linux/log2.h> +#endif static struct kmem_cache *jbd2_revoke_record_cache;static struct kmem_cache *jbd2_revoke_table_cache;
@@ -597,7 +597,7 @@ static void write_one_revoke_record(jour offset = *offsetp;/* Do we need to leave space at the end for a checksum? */ -if (JBD2_HAS_INCOMPAT_FEATURE (journal,JBD2_FEATURE_INCOMPAT_CSUM_V2 )) +if (jbd2_journal_has_csum_v2or3 (journal)) csum_size =sizeof (struct jbd2_journal_revoke_tail );/* Make sure we have a descriptor with space left for the record */
@@ -644,7 +644,7 @@ static void jbd2_revoke_csum_set(journalstruct jbd2_journal_revoke_tail *tail;__u32 csum; -if (!JBD2_HAS_INCOMPAT_FEATURE (j,JBD2_FEATURE_INCOMPAT_CSUM_V2 )) +if (!jbd2_journal_has_csum_v2or3 (j))return ; tail = (struct jbd2_journal_revoke_tail *)(bh->b_data + j->j_blocksize -
include/linux/jbd2.h +25 -5
@@ -159,7 +159,11 @@ typedef struct journal_header_s* journal_block_tag (in the descriptor). The other h_chksum* fields are * not used. * -* Checksum v1 and v2 are mutually exclusive features. +* If FEATURE_INCOMPAT_CSUM_V3 is set, the descriptor block uses +* journal_block_tag3_t to store a full 32-bit checksum. Everything else +* is the same as v2. +* +* Checksum v1, v2, and v3 are mutually exclusive features. */ struct commit_header {__be32 h_magic;
@@ -179,6 +183,14 @@ struct commit_header {* raw struct shouldn't be used for pointer math or sizeof() - use * journal_tag_bytes(journal) instead to compute this. */ +typedef struct journal_block_tag3_s +{ +__be32 t_blocknr;/* The on-disk block number */ +__be32 t_flags;/* See below */ +__be32 t_blocknr_high;/* most-significant high 32bits. */ +__be32 t_checksum;/* crc32c(uuid+seq+block) */ +}journal_block_tag3_t ; + typedef struct journal_block_tag_s { __be32 t_blocknr; /* The on-disk block number */
@@ -187,9 +199,6 @@ typedef struct journal_block_tag_s__be32 t_blocknr_high;/* most-significant high 32bits. */ } journal_block_tag_t; -#define JBD2_TAG_SIZE32 (offsetof(journal_block_tag_t, t_blocknr_high)) -#define JBD2_TAG_SIZE64 (sizeof(journal_block_tag_t)) -/* Tail of descriptor block, for checksumming */ struct jbd2_journal_block_tail {__be32 t_checksum;/* crc32c(uuid+descr_block) */
@@ -284,6 +293,7 @@ typedef struct journal_superblock_s#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002#define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004#define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008 +#define JBD2_FEATURE_INCOMPAT_CSUM_V3 0x00000010/* Features known to this kernel version: */ #define JBD2_KNOWN_COMPAT_FEATURES JBD2_FEATURE_COMPAT_CHECKSUM
@@ -291,7 +301,8 @@ typedef struct journal_superblock_s#define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \ JBD2_FEATURE_INCOMPAT_64BIT | \ JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | \ - JBD2_FEATURE_INCOMPAT_CSUM_V2) + JBD2_FEATURE_INCOMPAT_CSUM_V2 | \ + JBD2_FEATURE_INCOMPAT_CSUM_V3)#ifdef __KERNEL__
@@ -1296,6 +1307,15 @@ static inline int tid_geq(tid_t x, tid_textern int jbd2_journal_blocks_per_page (struct inode *inode);extern size_t journal_tag_bytes (journal_t *journal); +static inline int jbd2_journal_has_csum_v2or3 (journal_t *journal) +{ +if (JBD2_HAS_INCOMPAT_FEATURE (journal,JBD2_FEATURE_INCOMPAT_CSUM_V2 ) || +JBD2_HAS_INCOMPAT_FEATURE (journal,JBD2_FEATURE_INCOMPAT_CSUM_V3 )) +return 1 ; + +return 0 ; +} +/* * We reserve t_outstanding_credits >> JBD2_CONTROL_BLOCKS_SHIFT for * transaction control blocks.
Greg Kroah-Hartman
maintainerPATCH 102/125 staging: lustre: Remove circular dependency on header
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pranith Kumar <[email protected]>
commit e409842a03b0c2c41c0959fef8a7563208af36c1 upstream.
The following patch fixes a build error on sparc32. I think it should go to stable 3.16.
Remove a circular dependency on atomic.h header file which leads to compilation failure on sparc32 as reported here:
http://kisskb.ellerman.id.au/kisskb/buildresult/11340509/
The specific dependency is as follows:
In file included from arch/sparc/include/asm/smp_32.h:24:0,
from arch/sparc/include/asm/smp.h:6,
from arch/sparc/include/asm/switch_to_32.h:4,
from arch/sparc/include/asm/switch_to.h:6,
from arch/sparc/include/asm/ptrace.h:84,
from arch/sparc/include/asm/processor_32.h:16,
from arch/sparc/include/asm/processor.h:6,
from arch/sparc/include/asm/barrier_32.h:4,
from arch/sparc/include/asm/barrier.h:6,
from arch/sparc/include/asm/atomic_32.h:17,
from arch/sparc/include/asm/atomic.h:6,
from drivers/staging/lustre/lustre/obdclass/class_obd.c:38--- drivers/staging/lustre/lustre/obdclass/class_obd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/obdclass/class_obd.c +1 -1
@@ -35,7 +35,7 @@*/ #define DEBUG_SUBSYSTEM S_CLASS -# include <asm/atomic.h> +# include <linux/atomic.h> #include <obd_support.h> #include <obd_class.h>
Greg Kroah-Hartman
maintainerPATCH 103/125 staging: et131x: Fix errors caused by phydev->addr accesses before initialisation
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Einon <[email protected]>
commit ec0a38bf8b28b036202070cf3ef271e343d9eafc upstream.
Fix two reported bugs, caused by et131x_adapter->phydev->addr being accessed before it is initialised, by:
- letting et131x_mii_write() take a phydev address, instead of using the one stored in adapter by default. This is so et131x_mdio_write() can use it's own addr value.
- removing implementation of et131x_mdio_reset(), as it's not needed.
- moving a call to et131x_disable_phy_coma() in et131x_pci_setup(), which uses phydev->addr, until after the mdiobus has been registered.
--- drivers/staging/et131x/et131x.c | 68 +++++++++++++++------------------------- 1 file changed, 27 insertions(+), 41 deletions(-)
drivers/staging/et131x/et131x.c +27 -41
@@ -1423,22 +1423,16 @@ static int et131x_mii_read(struct et131x* @reg: the register to read * @value: 16-bit value to write */ -static int et131x_mii_write (struct et131x_adapter *adapter,u8 reg,u16 value) +static int et131x_mii_write (struct et131x_adapter *adapter,u8 addr,u8 reg, +u16 value) {struct mac_regs __iomem *mac = &adapter->regs->mac; -struct phy_device *phydev = adapter->phydev;int status =0 ; -u8 addr;u32 delay =0 ;u32 mii_addr;u32 mii_cmd;u32 mii_indicator; -if (!phydev) -return -EIO ; - - addr = phydev->addr; -/* Save a local copy of the registers we are dealing with so we can * set them back */
@@ -1633,17 +1627,7 @@ static int et131x_mdio_write(struct mii_struct net_device *netdev = bus->priv;struct et131x_adapter *adapter =netdev_priv (netdev); -return et131x_mii_write (adapter, reg, value); -} - -static int et131x_mdio_reset (struct mii_bus *bus) -{ -struct net_device *netdev = bus->priv; -struct et131x_adapter *adapter =netdev_priv (netdev); - -et131x_mii_write (adapter,MII_BMCR ,BMCR_RESET ); - -return 0 ; +return et131x_mii_write (adapter, phy_addr, reg, value); }/* et1310_phy_power_switch - PHY power control
@@ -1658,18 +1642,20 @@ static int et131x_mdio_reset(struct mii_static void et1310_phy_power_switch (struct et131x_adapter *adapter,bool down) {u16 data; +struct phy_device *phydev = adapter->phydev;et131x_mii_read (adapter,MII_BMCR , &data); data &= ~BMCR_PDOWN ;if (down) data |=BMCR_PDOWN ; -et131x_mii_write (adapter,MII_BMCR , data); +et131x_mii_write (adapter, phydev->addr,MII_BMCR , data); }/* et131x_xcvr_init - Init the phy if we are setting it into force mode */ static void et131x_xcvr_init (struct et131x_adapter *adapter) {u16 lcr2; +struct phy_device *phydev = adapter->phydev;/* Set the LED behavior such that LED 1 indicates speed (off = * 10Mbits, blink = 100Mbits, on = 1000Mbits) and LED 2 indicates
@@ -1690,7 +1676,7 @@ static void et131x_xcvr_init(struct et13else lcr2 |= (LED_VAL_LINKON <<LED_TXRX_SHIFT ); -et131x_mii_write (adapter,PHY_LED_2 , lcr2); +et131x_mii_write (adapter, phydev->addr,PHY_LED_2 , lcr2); } }
@@ -3645,14 +3631,14 @@ static void et131x_adjust_link(struct neet131x_mii_read (adapter,PHY_MPHY_CONTROL_REG , ®ister18); -et131x_mii_write (adapter,PHY_MPHY_CONTROL_REG , - register18 |0x4 ); -et131x_mii_write (adapter,PHY_INDEX_REG , +et131x_mii_write (adapter, phydev->addr, +PHY_MPHY_CONTROL_REG , register18 |0x4 ); +et131x_mii_write (adapter, phydev->addr,PHY_INDEX_REG , register18 |0x8402 ); -et131x_mii_write (adapter,PHY_DATA_REG , +et131x_mii_write (adapter, phydev->addr,PHY_DATA_REG , register18 |511 ); -et131x_mii_write (adapter,PHY_MPHY_CONTROL_REG , - register18); +et131x_mii_write (adapter, phydev->addr, +PHY_MPHY_CONTROL_REG , register18); }et1310_config_flow_control (adapter);
@@ -3664,7 +3650,8 @@ static void et131x_adjust_link(struct neet131x_mii_read (adapter,PHY_CONFIG , ®); reg &= ~ET_PHY_CONFIG_TX_FIFO_DEPTH ; reg |=ET_PHY_CONFIG_FIFO_DEPTH_32 ; -et131x_mii_write (adapter,PHY_CONFIG , reg); +et131x_mii_write (adapter, phydev->addr,PHY_CONFIG , + reg); }et131x_set_rx_dma_timer (adapter);
@@ -3677,14 +3664,14 @@ static void et131x_adjust_link(struct neet131x_mii_read (adapter,PHY_MPHY_CONTROL_REG , ®ister18); -et131x_mii_write (adapter,PHY_MPHY_CONTROL_REG , - register18 |0x4 ); -et131x_mii_write (adapter,PHY_INDEX_REG , - register18 |0x8402 ); -et131x_mii_write (adapter,PHY_DATA_REG , - register18 |511 ); -et131x_mii_write (adapter,PHY_MPHY_CONTROL_REG , - register18); +et131x_mii_write (adapter, phydev->addr, +PHY_MPHY_CONTROL_REG , register18 |0x4 ); +et131x_mii_write (adapter, phydev->addr, +PHY_INDEX_REG , register18 |0x8402 ); +et131x_mii_write (adapter, phydev->addr, +PHY_DATA_REG , register18 |511 ); +et131x_mii_write (adapter, phydev->addr, +PHY_MPHY_CONTROL_REG , register18); }/* Free the packets being actively sent & stopped */
@@ -4646,10 +4633,6 @@ static int et131x_pci_setup(struct pci_d/* Copy address into the net_device struct */ memcpy (netdev->dev_addr, adapter->addr,ETH_ALEN ); -/* Init variable for counting how long we do not have link status */ - adapter->boot_coma =0 ; -et1310_disable_phy_coma (adapter); - rc = -ENOMEM ;/* Setup the mii_bus struct */
@@ -4665,7 +4648,6 @@ static int et131x_pci_setup(struct pci_d adapter->mii_bus->priv = netdev; adapter->mii_bus->read = et131x_mdio_read; adapter->mii_bus->write = et131x_mdio_write; - adapter->mii_bus->reset = et131x_mdio_reset; adapter->mii_bus->irq =kmalloc_array (PHY_MAX_ADDR ,sizeof (int ),GFP_KERNEL );if (!adapter->mii_bus->irq)
@@ -4689,6 +4671,10 @@ static int et131x_pci_setup(struct pci_d/* Setup et1310 as per the documentation */ et131x_adapter_setup (adapter); +/* Init variable for counting how long we do not have link status */ + adapter->boot_coma =0 ; +et1310_disable_phy_coma (adapter); +/* We can enable interrupts now * * NOTE - Because registration of interrupt handler is done in the
Greg Kroah-Hartman
maintainerPATCH 104/125 staging/rtl8188eu: add 0df6:0076 Sitecom Europe B.V.
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Holger Paradies <[email protected]>
commit 8626d524ef08f10fccc0c41e5f75aef8235edf47 upstream.
The stick is not recognized.
This dongle uses r8188eu but usb-id is missing. 3.16.0
--- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/rtl8188eu/os_dep/usb_intf.c +1 -0
@@ -57,6 +57,7 @@ static struct usb_device_id rtw_usb_id_t {USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */ {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */ {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */ + {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */ {} /* Terminating entry */ };
Greg Kroah-Hartman
maintainerPATCH 105/125 staging: r8188eu: Add new USB ID
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Larry Finger <[email protected]>
commit a2fa6721c7237b5a666f16f732628c0c09c0b954 upstream.
The Elecom WDC-150SU2M uses this chip.
--- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/rtl8188eu/os_dep/usb_intf.c +1 -0
@@ -54,6 +54,7 @@ static struct usb_device_id rtw_usb_id_t {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0179)}, /* 8188ETV *//*=== Customer ID ===*/ /****** 8188EUS ********/ + {USB_DEVICE(0x056e, 0x4008)}, /* Elecom WDC-150SU2M */ {USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */ {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */ {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */
Greg Kroah-Hartman
maintainerPATCH 106/125 xhci: Treat not finding the event_seg on COMP_STOP the same as COMP_STOP_INVAL
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 9a54886342e227433aebc9d374f8ae268a836475 upstream.
When using a Renesas uPD720231 chipset usb-3 uas to sata bridge with a 120G Crucial M500 ssd, model string: Crucial_ CT120M500SSD1, together with a the integrated Intel xhci controller on a Haswell laptop:
00:14.0 USB controller [0c03]: Intel Corporation 8 Series USB xHCI HC [8086:9c31] (rev 04)
The following error gets logged to dmesg:
xhci error: Transfer event TRB DMA ptr not part of current TD
Treating COMP_STOP the same as COMP_STOP_INVAL when no event_seg gets found fixes this.
--- drivers/usb/host/xhci-ring.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-ring.c +2 -1
@@ -2483,7 +2483,8 @@ static int handle_tx_event(struct xhci_h* last TRB of the previous TD. The command completion handle * will take care the rest. */ -if (!event_seg && trb_comp_code ==COMP_STOP_INVAL ) { +if (!event_seg && (trb_comp_code ==COMP_STOP || + trb_comp_code ==COMP_STOP_INVAL )) { ret =0 ; goto cleanup; }
Greg Kroah-Hartman
maintainerPATCH 107/125 usb: xhci: amd chipset also needs short TX quirk
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huang Rui <[email protected]>
commit 2597fe99bb0259387111d0431691f5daac84f5a5 upstream.
AMD xHC also needs short tx quirk after tested on most of chipset generations. That's because there is the same incorrect behavior like Fresco Logic host. Please see below message with on USB webcam attached on xHC host:
[ 139.262944] xhci_hcd 0000:00:10.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk? [ 139.266934] xhci_hcd 0000:00:10.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk? [ 139.270913] xhci_hcd 0000:00:10.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk? [ 139.274937] xhci_hcd 0000:00:10.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk? [ 139.278914] xhci_hcd 0000:00:10.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk? [ 139.282936] xhci_hcd 0000:00:10.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk? [ 139.286915] xhci_hcd 0000:00:10.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk? [ 139.290938] xhci_hcd 0000:00:10.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk? [ 139.294913] xhci_hcd 0000:00:10.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk? [ 139.298917] xhci_hcd 0000:00:10.0: WARN Successful completion on short TX: needs XHCI_TRUST_TX_LENGTH quirk?
--- drivers/usb/host/xhci-pci.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/host/xhci-pci.c +4 -0
@@ -101,6 +101,10 @@ static void xhci_pci_quirks(struct devic/* AMD PLL quirk */ if (pdev->vendor ==PCI_VENDOR_ID_AMD &&usb_amd_find_chipset_info ()) xhci->quirks |=XHCI_AMD_PLL_FIX ; + +if (pdev->vendor ==PCI_VENDOR_ID_AMD ) + xhci->quirks |=XHCI_TRUST_TX_LENGTH ; +if (pdev->vendor ==PCI_VENDOR_ID_INTEL ) { xhci->quirks |=XHCI_LPM_SUPPORT ; xhci->quirks |=XHCI_INTEL_HOST ;
Greg Kroah-Hartman
maintainerPATCH 108/125 xhci: rework cycle bit checking for new dequeue pointers
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit 365038d83313951d6ace15342eb24624bbef1666 upstream.
When we manually need to move the TR dequeue pointer we need to set the correct cycle bit as well. Previously we used the trb pointer from the last event received as a base, but this was changed in
commit 1f81b6d22a59 ("usb: xhci: Prefer endpoint context dequeue pointer") to use the dequeue pointer from the endpoint context instead
It turns out some Asmedia controllers advance the dequeue pointer stored in the endpoint context past the event triggering TRB, and this messed up the way the cycle bit was calculated.
Instead of adding a quirk or complicating the already hard to follow cycle bit code, the whole cycle bit calculation is now simplified and adapted to handle event and endpoint context dequeue pointer differences.
--- drivers/usb/host/xhci-ring.c | 101 ++++++++++++++++--------------------------- drivers/usb/host/xhci.c | 3 + 2 files changed, 42 insertions(+), 62 deletions(-)
drivers/usb/host/xhci-ring.c +39 -62
@@ -364,32 +364,6 @@ static void ring_doorbell_for_active_rin } } -/* -* Find the segment that trb is in. Start searching in start_seg. -* If we must move past a segment that has a link TRB with a toggle cycle state -* bit set, then we will toggle the value pointed at by cycle_state. -*/ -static struct xhci_segment *find_trb_seg ( -struct xhci_segment *start_seg, -union xhci_trb *trb,int *cycle_state) -{ -struct xhci_segment *cur_seg = start_seg; -struct xhci_generic_trb *generic_trb; - -while (cur_seg->trbs > trb || - &cur_seg->trbs[TRBS_PER_SEGMENT -1 ] < trb) { - generic_trb = &cur_seg->trbs[TRBS_PER_SEGMENT -1 ].generic; -if (generic_trb->field[3 ] &cpu_to_le32 (LINK_TOGGLE )) - *cycle_state ^=0x1 ; - cur_seg = cur_seg->next; -if (cur_seg == start_seg) -/* Looped over the entire list. Oops! */ -return NULL ; - } -return cur_seg; -} - -static struct xhci_ring *xhci_triad_to_transfer_ring (struct xhci_hcd *xhci,unsigned int slot_id,unsigned int ep_index,unsigned int stream_id)
@@ -459,9 +433,12 @@ void xhci_find_new_dequeue_state(structstruct xhci_virt_device *dev = xhci->devs[slot_id];struct xhci_virt_ep *ep = &dev->eps[ep_index];struct xhci_ring *ep_ring; -struct xhci_generic_trb *trb; +struct xhci_segment *new_seg; +union xhci_trb *new_deq;dma_addr_t addr;u64 hw_dequeue; +bool cycle_found = false; +bool td_last_trb_found = false; ep_ring =xhci_triad_to_transfer_ring (xhci, slot_id, ep_index, stream_id);
@@ -486,45 +463,45 @@ void xhci_find_new_dequeue_state(struct hw_dequeue =le64_to_cpu (ep_ctx->deq); } -/* Find virtual address and segment of hardware dequeue pointer */ - state->new_deq_seg = ep_ring->deq_seg; - state->new_deq_ptr = ep_ring->dequeue; -while (xhci_trb_virt_to_dma (state->new_deq_seg, state->new_deq_ptr) - != (dma_addr_t)(hw_dequeue & ~0xf )) { -next_trb (xhci, ep_ring, &state->new_deq_seg, - &state->new_deq_ptr); -if (state->new_deq_ptr == ep_ring->dequeue) { -WARN_ON (1 ); -return ; - } - } + new_seg = ep_ring->deq_seg; + new_deq = ep_ring->dequeue; + state->new_cycle_state = hw_dequeue &0x1 ; +/* -* Find cycle state for last_trb, starting at old cycle state of -* hw_dequeue. If there is only one segment ring, find_trb_seg() will -* return immediately and cannot toggle the cycle state if this search -* wraps around, so add one more toggle manually in that case. +* We want to find the pointer, segment and cycle state of the new trb +* (the one after current TD's last_trb). We know the cycle state at +* hw_dequeue, so walk the ring until both hw_dequeue and last_trb are +* found. */ - state->new_cycle_state = hw_dequeue &0x1 ; -if (ep_ring->first_seg == ep_ring->first_seg->next && - cur_td->last_trb < state->new_deq_ptr) - state->new_cycle_state ^=0x1 ; +do { +if (!cycle_found &&xhci_trb_virt_to_dma (new_seg, new_deq) + == (dma_addr_t)(hw_dequeue & ~0xf )) { + cycle_found = true; +if (td_last_trb_found) +break ; + } +if (new_deq == cur_td->last_trb) + td_last_trb_found = true; - state->new_deq_ptr = cur_td->last_trb; -xhci_dbg_trace (xhci, trace_xhci_dbg_cancel_urb, -"Finding segment containing last TRB in TD." ); - state->new_deq_seg =find_trb_seg (state->new_deq_seg, - state->new_deq_ptr, &state->new_cycle_state); -if (!state->new_deq_seg) { -WARN_ON (1 ); -return ; - } +if (cycle_found && +TRB_TYPE_LINK_LE32 (new_deq->generic.field[3 ]) && + new_deq->generic.field[3 ] &cpu_to_le32 (LINK_TOGGLE )) + state->new_cycle_state ^=0x1 ; + +next_trb (xhci, ep_ring, &new_seg, &new_deq); + +/* Search wrapped around, bail out */ +if (new_deq == ep->ring->dequeue) { +xhci_err (xhci,"Error: Failed finding new dequeue state\n" ); + state->new_deq_seg =NULL ; + state->new_deq_ptr =NULL ; +return ; + } + + }while (!cycle_found || !td_last_trb_found); -/* Increment to find next TRB after last_trb. Cycle if appropriate. */ - trb = &state->new_deq_ptr->generic; -if (TRB_TYPE_LINK_LE32 (trb->field[3 ]) && - (trb->field[3 ] &cpu_to_le32 (LINK_TOGGLE ))) - state->new_cycle_state ^=0x1 ; -next_trb (xhci, ep_ring, &state->new_deq_seg, &state->new_deq_ptr); + state->new_deq_seg = new_seg; + state->new_deq_ptr = new_deq;/* Don't update the ring cycle state for the producer (us). */ xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
drivers/usb/host/xhci.c +3 -0
@@ -2891,6 +2891,9 @@ void xhci_cleanup_stalled_ring(struct xh ep_index, ep->stopped_stream, ep->stopped_td, &deq_state); +if (!deq_state.new_deq_ptr || !deq_state.new_deq_seg) +return ; +/* HW with the reset endpoint quirk will use the saved dequeue state to * issue a configure endpoint command later. */
Greg Kroah-Hartman
maintainerPATCH 109/125 xhci: Disable streams on Via XHCI with device-id 0x3432
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit e21eba05afd288a227320f797864ddd859397eed upstream.
This is a bit bigger hammer then I would like to use for this, but for now it will have to make do. I'm working on getting my hands on one of these so that I can try to get streams to work (with a quirk flag if necessary) and then we can re-enable them.
For now this at least makes uas capable disk enclosures work again by forcing fallback to the usb-storage driver.
https://bugzilla.kernel.org/show_bug.cgi?id=79511
--- drivers/usb/host/xhci-pci.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/host/xhci-pci.c +5 -0
@@ -155,6 +155,11 @@ static void xhci_pci_quirks(struct devicif (pdev->vendor ==PCI_VENDOR_ID_VIA ) xhci->quirks |=XHCI_RESET_ON_RESUME ; +/* See https://bugzilla.kernel.org/show_bug.cgi?id=79511 */ +if (pdev->vendor ==PCI_VENDOR_ID_VIA && + pdev->device ==0x3432 ) + xhci->quirks |=XHCI_BROKEN_STREAMS ; +if (xhci->quirks &XHCI_RESET_ON_RESUME )xhci_dbg_trace (xhci, trace_xhci_dbg_quirks,"QUIRK: Resetting on resume" );
Greg Kroah-Hartman
maintainerPATCH 110/125 ARM: OMAP2+: hwmod: Rearm wake-up interrupts for DT when MUSB is idled
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Lindgren <[email protected]>
commit cc824534d4fef0e46e4486d5c1e10d3c6b1ebadc upstream.
Looks like MUSB cable removal can cause wake-up interrupts to stop working for device tree based booting at least for UART3 even as nothing is dynamically remuxed. This can be fixed by calling reconfigure_io_chain() for device tree based booting in hwmod code. Note that we already do that for legacy booting if the legacy mux is configured.
My guess is that this is related to UART3 and MUSB ULPI hsusb0_data0 and hsusb0_data1 support for Carkit mode that somehow affect the configured IO chain for UART3 and require rearming the wake-up interrupts.
In general, for device tree based booting, pinctrl-single calls the rearm hook that in turn calls reconfigure_io_chain so calling reconfigure_io_chain should not be needed from the hwmod code for other events.
So let's limit the hwmod rearming of iochain only to HWMOD_FORCE_MSTANDBY where MUSB is currently the only user of it. If we see other devices needing similar changes we can add more checks for it.
--- arch/arm/mach-omap2/omap_hwmod.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/mach-omap2/omap_hwmod.c +4 -0
@@ -2185,6 +2185,8 @@ static int _enable(struct omap_hwmod *oh oh->mux->pads_dynamic))) {omap_hwmod_mux (oh->mux, _HWMOD_STATE_ENABLED);_reconfigure_io_chain (); + } else if (oh->flags & HWMOD_FORCE_MSTANDBY) { +_reconfigure_io_chain (); }_add_initiator_dep (oh, mpu_oh);
@@ -2291,6 +2293,8 @@ static int _idle(struct omap_hwmod *oh)if (oh->mux && oh->mux->pads_dynamic) {omap_hwmod_mux (oh->mux, _HWMOD_STATE_IDLE);_reconfigure_io_chain (); + }else if (oh->flags &HWMOD_FORCE_MSTANDBY ) { +_reconfigure_io_chain (); } oh->_state = _HWMOD_STATE_IDLE;
Greg Kroah-Hartman
maintainerPATCH 111/125 USB: ftdi_sio: add Basic Micro ATOM Nano USB2Serial PID
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 6552cc7f09261db2aeaae389aa2c05a74b3a93b4 upstream.
Add device id for Basic Micro ATOM Nano USB2Serial adapters.
--- drivers/usb/serial/ftdi_sio.c | 1 + drivers/usb/serial/ftdi_sio_ids.h | 2 ++ 2 files changed, 3 insertions(+)
drivers/usb/serial/ftdi_sio.c +1 -0
@@ -151,6 +151,7 @@ static const struct usb_device_id id_tab { USB_DEVICE(FTDI_VID, FTDI_AMC232_PID) }, { USB_DEVICE(FTDI_VID, FTDI_CANUSB_PID) }, { USB_DEVICE(FTDI_VID, FTDI_CANDAPTER_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_BM_ATOM_NANO_PID) }, { USB_DEVICE(FTDI_VID, FTDI_NXTCAM_PID) }, { USB_DEVICE(FTDI_VID, FTDI_EV3CON_PID) }, { USB_DEVICE(FTDI_VID, FTDI_SCS_DEVICE_0_PID) },
drivers/usb/serial/ftdi_sio_ids.h +2 -0
@@ -42,6 +42,8 @@/* www.candapter.com Ewert Energy Systems CANdapter device */ #define FTDI_CANDAPTER_PID 0x9F80/* Product Id */ +#define FTDI_BM_ATOM_NANO_PID 0xa559/* Basic Micro ATOM Nano USB2Serial */ +/* * Texas Instruments XDS100v2 JTAG / BeagleBone A3 * http://processors.wiki.ti.com/index.php/XDS100
Greg Kroah-Hartman
maintainerPATCH 113/125 USB: whiteheat: Added bounds checking for bulk command response
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Forshaw <[email protected]>
commit 6817ae225cd650fb1c3295d769298c38b1eba818 upstream.
This patch fixes a potential security issue in the whiteheat USB driver which might allow a local attacker to cause kernel memory corrpution. This is due to an unchecked memcpy into a fixed size buffer (of 64 bytes). On EHCI and XHCI busses it's possible to craft responses greater than 64 bytes leading a buffer overflow.
--- drivers/usb/serial/whiteheat.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/serial/whiteheat.c +6 -1
@@ -514,6 +514,10 @@ static void command_port_read_callback(sdev_dbg (&urb->dev->dev,"%s - command_info is NULL, exiting.\n" , __func__);return ; } +if (!urb->actual_length) { +dev_dbg (&urb->dev->dev,"%s - empty response, exiting.\n" , __func__); +return ; + }if (status) {dev_dbg (&urb->dev->dev,"%s - nonzero urb status: %d\n" , __func__, status);if (status != -ENOENT )
@@ -534,7 +538,8 @@ static void command_port_read_callback(s/* These are unsolicited reports from the firmware, hence no waiting command to wakeup */ dev_dbg (&urb->dev->dev,"%s - event received\n" , __func__); - }else if (data[0 ] ==WHITEHEAT_GET_DTR_RTS ) { + }else if ((data[0 ] ==WHITEHEAT_GET_DTR_RTS ) && + (urb->actual_length -1 <=sizeof (command_info->result_buffer))) {memcpy (command_info->result_buffer, &data[1 ], urb->actual_length -1 ); command_info->command_finished =WHITEHEAT_CMD_COMPLETE ;
Greg Kroah-Hartman
maintainerPATCH 114/125 usb: ehci: using wIndex + 1 for hub port
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Chen <[email protected]>
commit 5cbcc35e5bf0eae3c7494ce3efefffc9977827ae upstream.
The roothub's index per controller is from 0, but the hub port index per hub is from 1, this patch fixes "can't find device at roohub" problem for connecting test fixture at roohub when do USB-IF Embedded Host High-Speed Electrical Test.
This patch is for v3.12+.
--- drivers/usb/host/ehci-hub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/ehci-hub.c +1 -1
@@ -1230,7 +1230,7 @@ int ehci_hub_control(if (selector ==EHSET_TEST_SINGLE_STEP_SET_FEATURE ) {spin_unlock_irqrestore (&ehci->lock, flags); retval =ehset_single_step_set_feature (hcd, - wIndex); + wIndex +1 );spin_lock_irqsave (&ehci->lock, flags);break ; }
Greg Kroah-Hartman
maintainerPATCH 115/125 usb: hub: Prevent hub autosuspend if usbcore.autosuspend is -1
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roger Quadros <[email protected]>
commit bdd405d2a5287bdb9b04670ea255e1f122138e66 upstream.
If user specifies that USB autosuspend must be disabled by module parameter "usbcore.autosuspend=-1" then we must prevent autosuspend of USB hub devices as well.
commit 596d789a211d introduced in v3.8 changed the original behaivour and stopped respecting the usbcore.autosuspend parameter for hubs.
--- drivers/usb/core/hub.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/core/hub.c +5 -1
@@ -1728,8 +1728,12 @@ static int hub_probe(struct usb_interfac* - Change autosuspend delay of hub can avoid unnecessary auto * suspend timer for hub, also may decrease power consumption * of USB bus. +* +* - If user has indicated to prevent autosuspend by passing +* usbcore.autosuspend = -1 then keep autosuspend disabled. */ -pm_runtime_set_autosuspend_delay (&hdev->dev,0 ); +if (hdev->dev.power.autosuspend_delay >=0 ) +pm_runtime_set_autosuspend_delay (&hdev->dev,0 );/* * Hubs have proper suspend/resume support, except for root hubs
Greg Kroah-Hartman
maintainerPATCH 116/125 usbcore: Fix wrong device in an error message in hub_port_connect()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit dd5f5006d1035547559c8a90781a7e249787a7a2 upstream.
The commit [5ee0f803cc3a: usbcore: don't log on consecutive debounce failures of the same port] added the check of the reliable port, but it also replaced the device argument to dev_err() wrongly, which leads to a NULL dereference.
This patch restores the right device, port_dev->dev. Also, since dev_err() itself shows the port number, reduce the port number shown in the error message, essentially reverting to the state before the commit 5ee0f803cc3a.
[The fix suggested by Hannes, and the error message cleanup suggested
by Alan Stern]
--- drivers/usb/core/hub.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/usb/core/hub.c +1 -3
@@ -4619,9 +4619,7 @@ static void hub_port_connect(struct usb_if (status != -ENODEV && port1 != unreliable_port &&printk_ratelimit ()) -dev_err (&udev->dev,"connect-debounce failed, port %d disabled\n" , - port1); - +dev_err (&port_dev->dev,"connect-debounce failed\n" ); portstatus &= ~USB_PORT_STAT_CONNECTION ; unreliable_port = port1; }else {
Greg Kroah-Hartman
maintainerPATCH 117/125 NFSD: Decrease nfsd_users in nfsd_startup_generic fail
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kinglong Mee <[email protected]>
commit d9499a95716db0d4bc9b67e88fd162133e7d6b08 upstream.
A memory allocation failure could cause nfsd_startup_generic to fail, in which case nfsd_users wouldn't be incorrectly left elevated.
After nfsd restarts nfsd_startup_generic will then succeed without doing anything--the first consequence is likely nfs4_start_net finding a bad laundry_wq and crashing.
--- fs/nfsd/nfssvc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/nfsd/nfssvc.c +4 -1
@@ -221,7 +221,8 @@ static int nfsd_startup_generic(int nrse*/ ret =nfsd_racache_init (2 *nrservs);if (ret) -return ret; + goto dec_users; + ret =nfs4_state_start ();if (ret) goto out_racache;
@@ -229,6 +230,8 @@ static int nfsd_startup_generic(int nrse out_racache:nfsd_racache_shutdown (); +dec_users: + nfsd_users--;return ret; }
Greg Kroah-Hartman
maintainerPATCH 118/125 NFS: Fix /proc/fs/nfsfs/servers and /proc/fs/nfsfs/volumes
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Eric W. Biederman" <[email protected]>
commit 65b38851a17472d31fec9019fc3a55b0802dab88 upstream.
The usage of pid_ns->child_reaper->nsproxy->net_ns in nfs_server_list_open and nfs_client_list_open is not safe.
/proc for a pid namespace can remain mounted after the all of the process in that pid namespace have exited. There are also times before the initial process in a pid namespace has started or after the initial process in a pid namespace has exited where pid_ns->child_reaper can be NULL or stale. Making the idiom pid_ns->child_reaper->nsproxy a double whammy of problems.
Luckily all that needs to happen is to move /proc/fs/nfsfs/servers and /proc/fs/nfsfs/volumes under /proc/net to /proc/net/nfsfs/servers and /proc/net/nfsfs/volumes and add a symlink from the original location, and to use seq_open_net as it has been designed.
--- fs/nfs/client.c | 95 +++++++++++++++++++++++++++++++----------------------- fs/nfs/inode.c | 3 + fs/nfs/internal.h | 9 +++++ fs/nfs/netns.h | 3 + 4 files changed, 69 insertions(+), 41 deletions(-)
fs/nfs/client.c +55 -40
@@ -1205,7 +1205,7 @@ static const struct file_operations nfs_ .open = nfs_server_list_open, .read = seq_read, .llseek = seq_lseek, - .release = seq_release, + .release = seq_release_net, .owner = THIS_MODULE, };
@@ -1226,7 +1226,7 @@ static const struct file_operations nfs_ .open = nfs_volume_list_open, .read = seq_read, .llseek = seq_lseek, - .release = seq_release, + .release = seq_release_net, .owner = THIS_MODULE, };
@@ -1236,19 +1236,8 @@ static const struct file_operations nfs_*/ static int nfs_server_list_open (struct inode *inode,struct file *file) { -struct seq_file *m; -int ret; -struct pid_namespace *pid_ns = file->f_dentry->d_sb->s_fs_info; -struct net *net = pid_ns->child_reaper->nsproxy->net_ns; - - ret =seq_open (file, &nfs_server_list_ops); -if (ret <0 ) -return ret; - - m = file->private_data; - m->private = net; - -return 0 ; +return seq_open_net (inode, file, &nfs_server_list_ops, +sizeof (struct seq_net_private )); }/*
@@ -1256,7 +1245,7 @@ static int nfs_server_list_open(struct i*/ static void *nfs_server_list_start (struct seq_file *m,loff_t *_pos) { -struct nfs_net *nn =net_generic (m->private, nfs_net_id); +struct nfs_net *nn =net_generic (seq_file_net (m), nfs_net_id);/* lock the list against modification */ spin_lock (&nn->nfs_client_lock);
@@ -1268,7 +1257,7 @@ static void *nfs_server_list_start(struc*/ static void *nfs_server_list_next (struct seq_file *p,void *v,loff_t *pos) { -struct nfs_net *nn =net_generic (p->private, nfs_net_id); +struct nfs_net *nn =net_generic (seq_file_net (p), nfs_net_id);return seq_list_next (v, &nn->nfs_client_list, pos); }
@@ -1278,7 +1267,7 @@ static void *nfs_server_list_next(struct*/ static void nfs_server_list_stop (struct seq_file *p,void *v) { -struct nfs_net *nn =net_generic (p->private, nfs_net_id); +struct nfs_net *nn =net_generic (seq_file_net (p), nfs_net_id);spin_unlock (&nn->nfs_client_lock); }
@@ -1289,7 +1278,7 @@ static void nfs_server_list_stop(structstatic int nfs_server_list_show (struct seq_file *m,void *v) {struct nfs_client *clp; -struct nfs_net *nn =net_generic (m->private, nfs_net_id); +struct nfs_net *nn =net_generic (seq_file_net (m), nfs_net_id);/* display header on line 1 */ if (v == &nn->nfs_client_list) {
@@ -1321,19 +1310,8 @@ static int nfs_server_list_show(struct s*/ static int nfs_volume_list_open (struct inode *inode,struct file *file) { -struct seq_file *m; -int ret; -struct pid_namespace *pid_ns = file->f_dentry->d_sb->s_fs_info; -struct net *net = pid_ns->child_reaper->nsproxy->net_ns; - - ret =seq_open (file, &nfs_volume_list_ops); -if (ret <0 ) -return ret; - - m = file->private_data; - m->private = net; - -return 0 ; +return seq_open_net (inode, file, &nfs_server_list_ops, +sizeof (struct seq_net_private )); }/*
@@ -1341,7 +1319,7 @@ static int nfs_volume_list_open(struct i*/ static void *nfs_volume_list_start (struct seq_file *m,loff_t *_pos) { -struct nfs_net *nn =net_generic (m->private, nfs_net_id); +struct nfs_net *nn =net_generic (seq_file_net (m), nfs_net_id);/* lock the list against modification */ spin_lock (&nn->nfs_client_lock);
@@ -1353,7 +1331,7 @@ static void *nfs_volume_list_start(struc*/ static void *nfs_volume_list_next (struct seq_file *p,void *v,loff_t *pos) { -struct nfs_net *nn =net_generic (p->private, nfs_net_id); +struct nfs_net *nn =net_generic (seq_file_net (p), nfs_net_id);return seq_list_next (v, &nn->nfs_volume_list, pos); }
@@ -1363,7 +1341,7 @@ static void *nfs_volume_list_next(struct*/ static void nfs_volume_list_stop (struct seq_file *p,void *v) { -struct nfs_net *nn =net_generic (p->private, nfs_net_id); +struct nfs_net *nn =net_generic (seq_file_net (p), nfs_net_id);spin_unlock (&nn->nfs_client_lock); }
@@ -1376,7 +1354,7 @@ static int nfs_volume_list_show(struct sstruct nfs_server *server;struct nfs_client *clp;char dev[8 ], fsid[17 ]; -struct nfs_net *nn =net_generic (m->private, nfs_net_id); +struct nfs_net *nn =net_generic (seq_file_net (m), nfs_net_id);/* display header on line 1 */ if (v == &nn->nfs_volume_list) {
@@ -1407,6 +1385,45 @@ static int nfs_volume_list_show(struct sreturn 0 ; } +int nfs_fs_proc_net_init (struct net *net) +{ +struct nfs_net *nn =net_generic (net, nfs_net_id); +struct proc_dir_entry *p; + + nn->proc_nfsfs =proc_net_mkdir (net,"nfsfs" , net->proc_net); +if (!nn->proc_nfsfs) + goto error_0; + +/* a file of servers with which we're dealing */ + p =proc_create ("servers" ,S_IFREG |S_IRUGO , + nn->proc_nfsfs, &nfs_server_list_fops); +if (!p) + goto error_1; + +/* a file of volumes that we have mounted */ + p =proc_create ("volumes" ,S_IFREG |S_IRUGO , + nn->proc_nfsfs, &nfs_volume_list_fops); +if (!p) + goto error_2; +return 0 ; + +error_2: +remove_proc_entry ("servers" , nn->proc_nfsfs); +error_1: +remove_proc_entry ("fs/nfsfs" ,NULL ); +error_0: +return -ENOMEM ; +} + +void nfs_fs_proc_net_exit (struct net *net) +{ +struct nfs_net *nn =net_generic (net, nfs_net_id); + +remove_proc_entry ("volumes" , nn->proc_nfsfs); +remove_proc_entry ("servers" , nn->proc_nfsfs); +remove_proc_entry ("fs/nfsfs" ,NULL ); +} +/* * initialise the /proc/fs/nfsfs/ directory */
@@ -1419,14 +1436,12 @@ int __init nfs_fs_proc_init(void) goto error_0;/* a file of servers with which we're dealing */ - p =proc_create ("servers" ,S_IFREG |S_IRUGO , - proc_fs_nfs, &nfs_server_list_fops); + p =proc_symlink ("servers" , proc_fs_nfs,"../../net/nfsfs/servers" );if (!p) goto error_1;/* a file of volumes that we have mounted */ - p =proc_create ("volumes" ,S_IFREG |S_IRUGO , - proc_fs_nfs, &nfs_volume_list_fops); + p =proc_symlink ("volumes" , proc_fs_nfs,"../../net/nfsfs/volumes" );if (!p) goto error_2;return 0 ;
fs/nfs/inode.c +2 -1
@@ -1840,11 +1840,12 @@ EXPORT_SYMBOL_GPL(nfs_net_id);static int nfs_net_init (struct net *net) {nfs_clients_init (net); -return 0 ; +return nfs_fs_proc_net_init (net); }static void nfs_net_exit (struct net *net) { +nfs_fs_proc_net_exit (net);nfs_cleanup_cb_ident_idr (net); }
fs/nfs/internal.h +9 -0
@@ -195,7 +195,16 @@ extern struct rpc_clnt *nfs4_find_or_cre#ifdef CONFIG_PROC_FS extern int __init nfs_fs_proc_init (void );extern void nfs_fs_proc_exit (void ); +extern int nfs_fs_proc_net_init (struct net *net); +extern void nfs_fs_proc_net_exit (struct net *net);#else +static inline int nfs_fs_proc_net_init (struct net *net) +{ +return 0 ; +} +static inline void nfs_fs_proc_net_exit (struct net *net) +{ +}static inline int nfs_fs_proc_init (void ) {return 0 ;
fs/nfs/netns.h +3 -0
@@ -29,6 +29,9 @@ struct nfs_net {#endif spinlock_t nfs_client_lock;struct timespec boot_time; +#ifdef CONFIG_PROC_FS +struct proc_dir_entry *proc_nfsfs; +#endif };extern int nfs_net_id;
Greg Kroah-Hartman
maintainerPATCH 119/125 nfs3_list_one_acl(): check get_acl() result with IS_ERR_OR_NULL
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Utkin <[email protected]>
commit 7a9e75a185e6b3a3860e6a26fb6e88691fc2c9d9 upstream.
There was a check for result being not NULL. But get_acl() may return NULL, or ERR_PTR, or actual pointer.
The purpose of the function where current change is done is to "list ACLs only when they are available", so any error condition of get_acl() mustn't be elevated, and returning 0 there is still valid.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=81111
--- fs/nfs/nfs3acl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs3acl.c +1 -1
@@ -256,7 +256,7 @@ nfs3_list_one_acl(struct inode *inode, ichar *p = data + *result; acl =get_acl (inode, type); -if (!acl) +if (IS_ERR_OR_NULL (acl))return 0 ;posix_acl_release (acl);
Greg Kroah-Hartman
maintainerPATCH 120/125 nfs: reject changes to resvport and sharecache during remount
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Scott Mayhew <[email protected]>
commit 71a6ec8ac587418ceb6b420def1ca44b334c1ff7 upstream.
Commit c8e47028 made it possible to change resvport/noresvport and sharecache/nosharecache via a remount operation, neither of which should be allowed.
--- fs/nfs/super.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/nfs/super.c +5 -4
@@ -2180,7 +2180,7 @@ out_no_address:return -EINVAL ; } -#define NFS_MOUNT_CMP_FLAGMASK ~(NFS_MOUNT_INTR \ +#define NFS_REMOUNT_CMP_FLAGMASK ~(NFS_MOUNT_INTR \ | NFS_MOUNT_SECURE \ | NFS_MOUNT_TCP \ | NFS_MOUNT_VER3 \
@@ -2188,15 +2188,16 @@ out_no_address: | NFS_MOUNT_NONLM \ | NFS_MOUNT_BROKEN_SUID \ | NFS_MOUNT_STRICTLOCK \ - | NFS_MOUNT_UNSHARED \ - | NFS_MOUNT_NORESVPORT \ | NFS_MOUNT_LEGACY_INTERFACE) +#define NFS_MOUNT_CMP_FLAGMASK (NFS_REMOUNT_CMP_FLAGMASK & \ + ~(NFS_MOUNT_UNSHARED | NFS_MOUNT_NORESVPORT)) +static int nfs_compare_remount_data (struct nfs_server *nfss,struct nfs_parsed_mount_data *data) { - if ((data->flags ^ nfss->flags) & NFS_MOUNT_CMP_FLAGMASK || + if ((data->flags ^ nfss->flags) & NFS_REMOUNT_CMP_FLAGMASK || data->rsize != nfss->rsize || data->wsize != nfss->wsize || data->version != nfss->nfs_client->rpc_ops->version ||
Greg Kroah-Hartman
maintainerPATCH 121/125 svcrdma: Select NFSv4.1 backchannel transport based on forward channel
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
commit 3c45ddf823d679a820adddd53b52c6699c9a05ac upstream.
The current code always selects XPRT_TRANSPORT_BC_TCP for the back channel, even when the forward channel was not TCP (eg, RDMA). When a 4.1 mount is attempted with RDMA, the server panics in the TCP BC code when trying to send CB_NULL.
Instead, construct the transport protocol number from the forward channel transport or'd with XPRT_TRANSPORT_BC. Transports that do not support bi-directional RPC will not have registered a "BC" transport, causing create_backchannel_client() to fail immediately.
--- fs/nfsd/nfs4callback.c | 3 ++- include/linux/sunrpc/svc_xprt.h | 1 + net/sunrpc/svcsock.c | 2 ++ net/sunrpc/xprt.c | 2 +- net/sunrpc/xprtrdma/svc_rdma_transport.c | 1 + 5 files changed, 7 insertions(+), 2 deletions(-)
fs/nfsd/nfs4callback.c +2 -1
@@ -689,7 +689,8 @@ static int setup_callback_client(struct clp->cl_cb_session = ses; args.bc_xprt = conn->cb_xprt; args.prognumber = clp->cl_cb_session->se_cb_prog; - args.protocol =XPRT_TRANSPORT_BC_TCP ; + args.protocol = conn->cb_xprt->xpt_class->xcl_ident | +XPRT_TRANSPORT_BC ; args.authflavor = ses->se_cb_sec.flavor; }/* Create RPC client */
include/linux/sunrpc/svc_xprt.h +1 -0
@@ -33,6 +33,7 @@ struct svc_xprt_class {struct svc_xprt_ops *xcl_ops;struct list_head xcl_list;u32 xcl_max_payload; +int xcl_ident; };/*
net/sunrpc/svcsock.c +2 -0
@@ -692,6 +692,7 @@ static struct svc_xprt_class svc_udp_cla .xcl_owner = THIS_MODULE, .xcl_ops = &svc_udp_ops, .xcl_max_payload = RPCSVC_MAXPAYLOAD_UDP, + .xcl_ident = XPRT_TRANSPORT_UDP, };static void svc_udp_init (struct svc_sock *svsk,struct svc_serv *serv)
@@ -1292,6 +1293,7 @@ static struct svc_xprt_class svc_tcp_cla .xcl_owner = THIS_MODULE, .xcl_ops = &svc_tcp_ops, .xcl_max_payload = RPCSVC_MAXPAYLOAD_TCP, + .xcl_ident = XPRT_TRANSPORT_TCP, };void svc_init_xprt_sock (void )
net/sunrpc/xprt.c +1 -1
@@ -1306,7 +1306,7 @@ struct rpc_xprt *xprt_create_transport(s } }spin_unlock (&xprt_list_lock); -printk (KERN_ERR "RPC: transport (%d) not supported\n" , args->ident); +dprintk ("RPC: transport (%d) not supported\n" , args->ident);return ERR_PTR (-EIO ); found:
net/sunrpc/xprtrdma/svc_rdma_transport.c +1 -0
@@ -92,6 +92,7 @@ struct svc_xprt_class svc_rdma_class = { .xcl_owner = THIS_MODULE, .xcl_ops = &svc_rdma_ops, .xcl_max_payload = RPCSVC_MAXPAYLOAD_TCP, + .xcl_ident = XPRT_TRANSPORT_RDMA, };struct svc_rdma_op_ctxt *svc_rdma_get_context (struct svcxprt_rdma *xprt)
Greg Kroah-Hartman
maintainerPATCH 122/125 NFSv3: Fix another acl regression
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit f87d928f6d98644d39809a013a22f981d39017cf upstream.
When creating a new object on the NFS server, we should not be sending posix setacl requests unless the preceding posix_acl_create returned a non-trivial acl. Doing so, causes Solaris servers in particular to return an EINVAL.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1132786
--- fs/nfs/nfs3acl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/nfs/nfs3acl.c +4 -1
@@ -129,7 +129,10 @@ static int __nfs3_proc_setacls(struct in .rpc_argp = &args, .rpc_resp = &fattr, }; -int status; +int status =0 ; + +if (acl ==NULL && (!S_ISDIR (inode->i_mode) || dfacl ==NULL )) + goto out; status = -EOPNOTSUPP ;if (!nfs_server_capable (inode,NFS_CAP_ACLS ))
Greg Kroah-Hartman
maintainerPATCH 123/125 NFSv4: Dont clear the open state when we just did an OPEN_DOWNGRADE
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit 412f6c4c26fb1eba8844290663837561ac53fa6e upstream.
If we did an OPEN_DOWNGRADE, then the right thing to do on success, is to apply the new open mode to the struct nfs4_state. Instead, we were unconditionally clearing the state, making it appear to our state machinery as if we had just performed a CLOSE.
--- fs/nfs/nfs4proc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/nfs/nfs4proc.c +5 -4
@@ -2545,6 +2545,7 @@ static void nfs4_close_done(struct rpc_tstruct nfs4_closedata *calldata = data;struct nfs4_state *state = calldata->state;struct nfs_server *server =NFS_SERVER (calldata->inode); +nfs4_stateid *res_stateid =NULL ;dprintk ("%s: begin!\n" , __func__);if (!nfs4_sequence_done (task, &calldata->res.seq_res))
@@ -2555,12 +2556,12 @@ static void nfs4_close_done(struct rpc_t*/ switch (task->tk_status) {case 0 : -if (calldata->roc) + res_stateid = &calldata->res.stateid; +if (calldata->arg.fmode ==0 && calldata->roc)pnfs_roc_set_barrier (state->inode, calldata->roc_barrier); -nfs_clear_open_stateid (state, &calldata->res.stateid,0 );renew_lease (server, calldata->timestamp); - goto out_release; +break ;case -NFS4ERR_ADMIN_REVOKED :case -NFS4ERR_STALE_STATEID :case -NFS4ERR_OLD_STATEID :
@@ -2574,7 +2575,7 @@ static void nfs4_close_done(struct rpc_t goto out_release; } } -nfs_clear_open_stateid (state,NULL , calldata->arg.fmode); +nfs_clear_open_stateid (state, res_stateid, calldata->arg.fmode); out_release:nfs_release_seqid (calldata->arg.seqid);nfs_refresh_inode (calldata->inode, calldata->res.fattr);
Greg Kroah-Hartman
maintainerPATCH 124/125 NFSv4: Fix problems with close in the presence of a delegation
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit aee7af356e151494d5014f57b33460b162f181b5 upstream.
In the presence of delegations, we can no longer assume that the state->n_rdwr, state->n_rdonly, state->n_wronly reflect the open stateid share mode, and so we need to calculate the initial value for calldata->arg.fmode using the state->flags.
--- fs/nfs/nfs4proc.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
fs/nfs/nfs4proc.c +12 -5
@@ -2587,6 +2587,7 @@ static void nfs4_close_prepare(struct rpstruct nfs4_closedata *calldata = data;struct nfs4_state *state = calldata->state;struct inode *inode = calldata->inode; +bool is_rdonly, is_wronly, is_rdwr;int call_close =0 ;dprintk ("%s: begin!\n" , __func__);
@@ -2594,18 +2595,24 @@ static void nfs4_close_prepare(struct rp goto out_wait; task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE ]; - calldata->arg.fmode =FMODE_READ |FMODE_WRITE ;spin_lock (&state->owner->so_lock); + is_rdwr =test_bit (NFS_O_RDWR_STATE , &state->flags); + is_rdonly =test_bit (NFS_O_RDONLY_STATE , &state->flags); + is_wronly =test_bit (NFS_O_WRONLY_STATE , &state->flags); +/* Calculate the current open share mode */ + calldata->arg.fmode =0 ; +if (is_rdonly || is_rdwr) + calldata->arg.fmode |=FMODE_READ ; +if (is_wronly || is_rdwr) + calldata->arg.fmode |=FMODE_WRITE ;/* Calculate the change in open mode */ if (state->n_rdwr ==0 ) {if (state->n_rdonly ==0 ) { - call_close |=test_bit (NFS_O_RDONLY_STATE , &state->flags); - call_close |=test_bit (NFS_O_RDWR_STATE , &state->flags); + call_close |= is_rdonly || is_rdwr; calldata->arg.fmode &= ~FMODE_READ ; }if (state->n_wronly ==0 ) { - call_close |=test_bit (NFS_O_WRONLY_STATE , &state->flags); - call_close |=test_bit (NFS_O_RDWR_STATE , &state->flags); + call_close |= is_wronly || is_rdwr; calldata->arg.fmode &= ~FMODE_WRITE ; } }
Greg Kroah-Hartman
maintainerPATCH 125/125 vm_is_stack: use for_each_thread() rather then buggy while_each_thread()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleg Nesterov <[email protected]>
commit 4449a51a7c281602d3a385044ab928322a122a02 upstream.
Aleksei hit the soft lockup during reading /proc/PID/smaps. David investigated the problem and suggested the right fix.
while_each_thread() is racy and should die, this patch updates vm_is_stack().
--- mm/util.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
mm/util.c +3 -6
@@ -277,17 +277,14 @@ pid_t vm_is_stack(struct task_struct *taif (in_group) {struct task_struct *t; -rcu_read_lock (); -if (!pid_alive (task)) - goto done; - t = task; - do { +rcu_read_lock (); +for_each_thread (task, t) {if (vm_is_stack_for_task (t, vma)) { ret = t->pid; goto done; } - } while_each_thread(task, t); + } done:rcu_read_unlock (); }
Greg Kroah-Hartman
maintainerQuoted 14 lines · Greg Kroah-Hartman
--------------------------
Note, there are a _lot_ of patches submitted for stable kernels that have yet to be applied, well over 200+ at the moment. Given that this series is already over 100 patches, I figured it was a good as a time as any to push this out. Don't worry, if you have emailed/marked patches to be included, and they aren't here, wait a few more releases for me to catch up, thanks.
--------------------------This is the start of the stable review cycle for the 3.16.2 release. There are 125 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.
Quoted 6 lines
Responses should be made by Fri Sep 5 22:06:09 UTC 2014. 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.16.2-rc1.gzand the diffstat can be found below.
-rc2 is out to resolve some reported issues and remove some patches that should not have been there (yet):
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.16.2-rc2.gz
Quoted 18 lines · Greg Kroah-Hartman
Quoted 17 lines · Greg Kroah-Hartman
--------------------------
Note, there are a _lot_ of patches submitted for stable kernels that have yet to be applied, well over 200+ at the moment. Given that this series is already over 100 patches, I figured it was a good as a time as any to push this out. Don't worry, if you have emailed/marked patches to be included, and they aren't here, wait a few more releases for me to catch up, thanks.
--------------------------This is the start of the stable review cycle for the 3.16.2 release. There are 125 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 Sep 5 22:06:09 UTC 2014. Anything received after that time might be too late.
Quoted 8 lines
Quoted 3 lines
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.16.2-rc1.gzand the diffstat can be found below.
-rc2 is out to resolve some reported issues and remove some patches that should not have been there (yet):
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.16.2-rc2.gz
Build results:
total: 136 pass: 136 fail: 0
Qemu tests all passed.
Detailed build and test results are available at
http://server.roeck-us.net:8010/builders.
Guenter
Quoted 17 lines · Greg Kroah-Hartman
--------------------------
Note, there are a _lot_ of patches submitted for stable kernels that have yet to be applied, well over 200+ at the moment. Given that this series is already over 100 patches, I figured it was a good as a time as any to push this out. Don't worry, if you have emailed/marked patches to be included, and they aren't here, wait a few more releases for me to catch up, thanks.
--------------------------This is the start of the stable review cycle for the 3.16.2 release. There are 125 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 Sep 5 22:06:09 UTC 2014. Anything received after that time might be too late.
Quoted 8 lines
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.16.2-rc1.gzand the diffstat can be found below.
thanks,
greg k-h
rc2 compiled and booted on my test system. No dmesg regressions.
-- Shuah
Signature · 4 lines
Shuah Khan Sr. Linux Kernel Developer Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978
Greg Kroah-Hartman
maintainerQuoted 22 lines · Shuah Khan
Quoted 21 lines · Greg Kroah-Hartman
--------------------------
Note, there are a _lot_ of patches submitted for stable kernels that have yet to be applied, well over 200+ at the moment. Given that this series is already over 100 patches, I figured it was a good as a time as any to push this out. Don't worry, if you have emailed/marked patches to be included, and they aren't here, wait a few more releases for me to catch up, thanks.
--------------------------This is the start of the stable review cycle for the 3.16.2 release. There are 125 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 Sep 5 22:06:09 UTC 2014. 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.16.2-rc1.gzand the diffstat can be found below.
Quoted 6 lines
Quoted 4 lines
thanks,
greg k-h
rc2 compiled and booted on my test system. No dmesg regressions.
Thanks for testing all of these and letting me know.
greg k-h