4.9.7-stable review
Greg Kroah-Hartman
maintainercover 4.9.7-stable review
This is the start of the stable review cycle for the 4.9.7 release. There are 66 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 Thu Feb 2 05:35:45 UTC 2017. 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/v4.x/stable-review/patch-4.9.7-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.9.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.9.7-rc1
Francisco Jerez <[email protected]>
drm/i915: Remove WaDisableLSQCROPERFforOCL KBL workaround.
Peter Zijlstra <[email protected]>
perf/core: Fix concurrent sys_perf_event_open() vs. 'move_group' race
David Rientjes <[email protected]>
mm, memcg: do not retry precharge charges
Andy Shevchenko <[email protected]>
platform/x86: intel_mid_powerbtn: Set IRQ_ONESHOT
Dan Carpenter <[email protected]>
platform/x86: mlx-platform: free first dev on error
Robin Murphy <[email protected]>
virtio_mmio: Set DMA masks appropriately
Yasuaki Ishimatsu <[email protected]>
memory_hotplug: make zone_can_shift() return a boolean value
Andy Shevchenko <[email protected]>
pinctrl: baytrail: Rectify debounce support
Masahiro Yamada <[email protected]>
pinctrl: uniphier: fix Ethernet (RMII) pin-mux setting for LD20
Mika Westerberg <[email protected]>
pinctrl: broxton: Use correct PADCFGLOCK offset
Arnd Bergmann <[email protected]>
s5k4ecgx: select CRC32 helper
Yonatan Cohen <[email protected]>
IB/rxe: Prevent from completer to operate on non valid QP
Maor Gottlieb <[email protected]>
IB/rxe: Fix rxe dev insertion to rxe_dev_list
Kenneth Lee <[email protected]>
IB/umem: Release pid in error and ODP flow
Ander Conselvan de Oliveira <[email protected]>
drm/i915: Check for NULL atomic state in intel_crtc_disable_noatomic()
Ander Conselvan de Oliveira <[email protected]>
drm/i915: Fix calculation of rotated x and y offsets for planar formats
Ander Conselvan de Oliveira <[email protected]>
drm/i915: Don't init hpd polling for vlv and chv from runtime_suspend()
Ander Conselvan de Oliveira <[email protected]>
drm/i915: Don't leak edid in intel_crt_detect_ddc()
Clint Taylor <[email protected]>
drm/i915: prevent crash with .disable_display parameter
Chris Wilson <[email protected]>
drm/i915: Clear ret before unbinding in i915_gem_evict_something()
Laurent Pinchart <[email protected]>
v4l: tvp5150: Don't override output pinmuxing at stream on/off time
Laurent Pinchart <[email protected]>
v4l: tvp5150: Fix comment regarding output pin muxing
Laurent Pinchart <[email protected]>
v4l: tvp5150: Reset device at probe time, not in get/set format handlers
Max Kellermann <[email protected]>
pctv452e: move buffer to heap, no mutex
Steve Wise <[email protected]>
iw_cxgb4: free EQ queue memory on last deref
Kinglong Mee <[email protected]>
SUNRPC: cleanup ida information when removing sunrpc module
Benjamin Coddington <[email protected]>
NFSv4.0: always send mode in SETATTR after EXCLUSIVE4
Trond Myklebust <[email protected]>
NFSv4.1: Fix a deadlock in layoutget
Chuck Lever <[email protected]>
nfs: Don't increment lock sequence ID after NFS4ERR_MOVED
Helge Deller <[email protected]>
parisc: Don't use BITS_PER_LONG in userspace-exported swab.h header
Vineet Gupta <[email protected]>
ARC: [arcompact] handle unaligned access delay slot corner case
Vineet Gupta <[email protected]>
ARC: udelay: fix inline assembler by adding LP_COUNT to clobber list
Yegor Yefremov <[email protected]>
can: ti_hecc: add missing prepare and unprepare of the clock
Einar Jón <[email protected]>
can: c_can_pci: fix null-pointer-deref in c_can_start() - set device pointer
Israel Rukshin <[email protected]>
IB/srp: fix invalid indirect_sg_entries parameter value
Israel Rukshin <[email protected]>
IB/srp: fix mr allocation when the device supports sg gaps
Max Gurtovoy <[email protected]>
IB/iser: Fix sg_tablesize calculation
Nicolas Iooss <[email protected]>
IB/cxgb3: fix misspelling in header guard
Martin Schwidefsky <[email protected]>
s390/ptrace: Preserve previous registers for short regset write
Christian Borntraeger <[email protected]>
s390/mm: Fix cmma unused transfer from pgste into pte
Jack Morgenstein <[email protected]>
RDMA/cma: Fix unknown symbol when CONFIG_IPV6 is not enabled
Omar Sandoval <[email protected]>
Btrfs: remove ->{get, set}_acl() from btrfs_dir_ro_inode_operationsOmar Sandoval <[email protected]>
Btrfs: disable xattr operations on subvolume directories
Omar Sandoval <[email protected]>
Btrfs: remove old tree_root case in btrfs_read_locked_inode()
Arnd Bergmann <[email protected]>
ISDN: eicon: silence misleading array-bounds warning
Brian Foster <[email protected]>
xfs: prevent quotacheck from overloading inode lru
Eric Dumazet <[email protected]>
sysctl: fix proc_doulongvec_ms_jiffies_minmax()
Nikolay Borisov <[email protected]>
userns: Make ucounts lock irq-safe
Will Deacon <[email protected]>
vring: Force use of DMA API for ARM-based systems with legacy devices
Vlastimil Babka <[email protected]>
mm, page_alloc: fix premature OOM when racing with cpuset mems update
Vlastimil Babka <[email protected]>
mm, page_alloc: move cpuset seqcount checking to slowpath
Vlastimil Babka <[email protected]>
mm, page_alloc: fix fast-path race with cpuset update or removal
Vlastimil Babka <[email protected]>
mm, page_alloc: fix check for NULL preferred_zone
Vlastimil Babka <[email protected]>
mm/mempolicy.c: do not put mempolicy before using its nodemask
Keno Fischer <[email protected]>
mm/huge_memory.c: respect FOLL_FORCE/FOLL_COW for thp
Lucas Stach <[email protected]>
drm/atomic: clear out fence when duplicating state
Alex Deucher <[email protected]>
Revert "drm/radeon: always apply pci shutdown callbacks"
Dan Carpenter <[email protected]>
drm/vc4: fix a bounds check
Eric Anholt <[email protected]>
drm/vc4: Return -EINVAL on the overflow checks failing.
Eric Anholt <[email protected]>
drm/vc4: Fix an integer overflow in temporary allocation layout.
Eric Anholt <[email protected]>
drm/vc4: Fix memory leak of the CRTC state.
Ville Syrjälä <[email protected]>
drm/i915: Ignore bogus plane coordinates on SKL when the plane is not visible
Takashi Iwai <[email protected]>
drm: Fix broken VT switch with video=1366x768 option
Peter Ujfalusi <[email protected]>
drm: Schedule the output_poll_work with 1s delay if we have delayed event
Dave Martin <[email protected]>
tile/ptrace: Preserve previous registers for short regset write
Kees Cook <[email protected]>
fbdev: color map copying bounds checking
-------------
Diffstat:
Makefile | 4 +- arch/arc/include/asm/delay.h | 4 +- arch/arc/kernel/unaligned.c | 3 +- arch/parisc/include/asm/bitops.h | 8 +- arch/parisc/include/uapi/asm/bitsperlong.h | 2 - arch/parisc/include/uapi/asm/swab.h | 5 +- arch/s390/kernel/ptrace.c | 8 ++ arch/s390/mm/pgtable.c | 7 +- arch/tile/kernel/ptrace.c | 2 +- arch/x86/platform/mellanox/mlx-platform.c | 2 +- drivers/base/memory.c | 4 +- drivers/gpu/drm/drm_atomic_helper.c | 2 + drivers/gpu/drm/drm_modes.c | 7 ++ drivers/gpu/drm/drm_probe_helper.c | 12 +- drivers/gpu/drm/i915/i915_drv.c | 2 +- drivers/gpu/drm/i915/i915_gem_evict.c | 1 + drivers/gpu/drm/i915/intel_crt.c | 9 +- drivers/gpu/drm/i915/intel_display.c | 14 ++- drivers/gpu/drm/i915/intel_fbdev.c | 3 + drivers/gpu/drm/i915/intel_lrc.c | 3 +- drivers/gpu/drm/i915/intel_ringbuffer.c | 8 -- drivers/gpu/drm/radeon/radeon_drv.c | 7 +- drivers/gpu/drm/vc4/vc4_crtc.c | 2 +- drivers/gpu/drm/vc4/vc4_gem.c | 4 +- drivers/gpu/drm/vc4/vc4_render_cl.c | 2 +- drivers/infiniband/core/cma.c | 3 +- drivers/infiniband/core/umem.c | 2 + drivers/infiniband/hw/cxgb4/device.c | 9 ++ drivers/infiniband/hw/cxgb4/iw_cxgb4.h | 18 +++ drivers/infiniband/hw/cxgb4/provider.c | 20 +++- drivers/infiniband/hw/cxgb4/qp.c | 35 ++++-- drivers/infiniband/sw/rxe/rxe_net.c | 2 +- drivers/infiniband/sw/rxe/rxe_qp.c | 3 +- drivers/infiniband/ulp/iser/iscsi_iser.c | 7 -- drivers/infiniband/ulp/srp/ib_srp.c | 15 ++- drivers/isdn/hardware/eicon/message.c | 3 +- drivers/media/i2c/Kconfig | 1 + drivers/media/i2c/tvp5150.c | 56 ++++++---- drivers/media/i2c/tvp5150_reg.h | 9 ++ drivers/media/usb/dvb-usb/pctv452e.c | 133 ++++++++++++----------- drivers/net/can/c_can/c_can_pci.c | 1 + drivers/net/can/ti_hecc.c | 16 ++- drivers/pinctrl/intel/pinctrl-baytrail.c | 28 +++-- drivers/pinctrl/intel/pinctrl-broxton.c | 2 +- drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c | 2 +- drivers/platform/x86/intel_mid_powerbtn.c | 2 +- drivers/video/fbdev/core/fbcmap.c | 26 +++-- drivers/virtio/virtio_mmio.c | 20 +++- drivers/virtio/virtio_ring.c | 7 ++ fs/btrfs/inode.c | 8 +- fs/nfs/nfs4proc.c | 4 +- fs/xfs/xfs_qm.c | 3 +- include/linux/memory_hotplug.h | 4 +- include/linux/mmzone.h | 6 +- include/linux/nfs4.h | 3 +- include/linux/sunrpc/clnt.h | 1 + include/uapi/rdma/cxgb3-abi.h | 2 +- kernel/events/core.c | 58 +++++++++- kernel/sysctl.c | 1 + kernel/ucount.c | 14 ++- mm/huge_memory.c | 18 ++- mm/memcontrol.c | 4 +- mm/memory_hotplug.c | 28 +++-- mm/mempolicy.c | 2 +- mm/page_alloc.c | 68 ++++++++---- net/sunrpc/clnt.c | 5 + net/sunrpc/sunrpc_syms.c | 1 + 67 files changed, 535 insertions(+), 240 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/66 fbdev: color map copying bounds checking
4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit 2dc705a9930b4806250fbf5a76e55266e59389f2 upstream.
Copying color maps to userspace doesn't check the value of to->start, which will cause kernel heap buffer OOB read due to signedness wraps.
CVE-2016-8405
--- drivers/video/fbdev/core/fbcmap.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/video/fbdev/core/fbcmap.c +14 -12
@@ -163,17 +163,18 @@ void fb_dealloc_cmap(struct fb_cmap *cmaint fb_copy_cmap (const struct fb_cmap *from,struct fb_cmap *to) { -int tooff =0 , fromoff =0 ; -int size; +unsigned int tooff =0 , fromoff =0 ; +size_t size;if (to->start > from->start) fromoff = to->start - from->start;else tooff = from->start - to->start; - size = to->len - tooff; -if (size > (int ) (from->len - fromoff)) - size = from->len - fromoff; -if (size <=0 ) +if (fromoff >= from->len || tooff >= to->len) +return -EINVAL ; + + size =min_t (size_t, to->len - tooff, from->len - fromoff); +if (size ==0 )return -EINVAL ; size *=sizeof (u16);
@@ -187,17 +188,18 @@ int fb_copy_cmap(const struct fb_cmap *fint fb_cmap_to_user (const struct fb_cmap *from,struct fb_cmap_user *to) { -int tooff =0 , fromoff =0 ; -int size; +unsigned int tooff =0 , fromoff =0 ; +size_t size;if (to->start > from->start) fromoff = to->start - from->start;else tooff = from->start - to->start; - size = to->len - tooff; -if (size > (int ) (from->len - fromoff)) - size = from->len - fromoff; -if (size <=0 ) +if (fromoff >= from->len || tooff >= to->len) +return -EINVAL ; + + size =min_t (size_t, to->len - tooff, from->len - fromoff); +if (size ==0 )return -EINVAL ; size *=sizeof (u16);
Greg Kroah-Hartman
maintainerPATCH 2/66 tile/ptrace: Preserve previous registers for short regset write
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Martin <[email protected]>
commit fd7c99142d77dc4a851879a66715abf12a3193fb upstream.
Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET to fill all the registers, the thread's old registers are preserved.
--- arch/tile/kernel/ptrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/tile/kernel/ptrace.c +1 -1
@@ -111,7 +111,7 @@ static int tile_gpr_set(struct task_stru const void *kbuf, const void __user *ubuf) { int ret; -struct pt_regs regs; +struct pt_regs regs = *task_pt_regs (target); ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, ®s,0 ,sizeof (regs));
Greg Kroah-Hartman
maintainerPATCH 3/66 drm: Schedule the output_poll_work with 1s delay if we have delayed event
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
commit 68f458eec7069d618a6c884ca007426e0cea411b upstream.
Instead of scheduling the work to handle the initial delayed event, use 1s delay.
This delay should not be needed, but Optimus/nouveau will fail in a mysterious way if the delayed event is handled as soon as possible like it is done in drm_helper_probe_single_connector_modes() in case the poll was enabled before.
Reverting 339fd36238dd would give back the 10 sec (!) delay to handle the delayed event. Adding 1sec delay to the poll_work is enough to work around the issue in Optimus setups and gives shorter response on handling the initial delayed event.
--- drivers/gpu/drm/drm_probe_helper.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_probe_helper.c +11 -1
@@ -143,8 +143,18 @@ void drm_kms_helper_poll_enable_locked(s }if (dev->mode_config.delayed_event) { +/* +* FIXME: +* +* Use short (1s) delay to handle the initial delayed event. +* This delay should not be needed, but Optimus/nouveau will +* fail in a mysterious way if the delayed event is handled as +* soon as possible like it is done in +* drm_helper_probe_single_connector_modes() in case the poll +* was enabled before. +*/ poll = true; - delay =0 ; + delay =HZ ; }if (poll)
Greg Kroah-Hartman
maintainerPATCH 6/66 drm/vc4: Fix memory leak of the CRTC state.
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Anholt <[email protected]>
commit 7622b25543665567d8830a63210385b7d705924b upstream.
The underscores variant frees the pointers inside, while the no-underscores variant calls underscores and then frees the struct.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_crtc.c +1 -1
@@ -832,7 +832,7 @@ static void vc4_crtc_destroy_state(struc } -__drm_atomic_helper_crtc_destroy_state (state); +drm_atomic_helper_crtc_destroy_state (crtc, state); }static const struct drm_crtc_funcs vc4_crtc_funcs = {
Greg Kroah-Hartman
maintainerPATCH 7/66 drm/vc4: Fix an integer overflow in temporary allocation layout.
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Anholt <[email protected]>
commit 0f2ff82e11c86c05d051cae32b58226392d33bbf upstream.
We copy the unvalidated ioctl arguments from the user into kernel temporary memory to run the validation from, to avoid a race where the user updates the unvalidate contents in between validating them and copying them into the validated BO.
However, in setting up the layout of the kernel side, we failed to check one of the additions (the roundup() for shader_rec_offset) against integer overflow, allowing a nearly MAX_UINT value of bin_cl_size to cause us to under-allocate the temporary space that we then copy_from_user into.
--- drivers/gpu/drm/vc4/vc4_gem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_gem.c +2 -1
@@ -594,7 +594,8 @@ vc4_get_bcl(struct drm_device *dev, stru args->shader_rec_count);struct vc4_bo *bo; - if (uniforms_offset < shader_rec_offset || + if (shader_rec_offset < args->bin_cl_size || + uniforms_offset < shader_rec_offset || exec_size < uniforms_offset || args->shader_rec_count >= (UINT_MAX / sizeof(struct vc4_shader_state)) ||
Greg Kroah-Hartman
maintainerPATCH 8/66 drm/vc4: Return -EINVAL on the overflow checks failing.
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Anholt <[email protected]>
commit 6b8ac63847bc2f958dd93c09edc941a0118992d9 upstream.
By failing to set the errno, we'd continue on to trying to set up the RCL, and then oops on trying to dereference the tile_bo that binning validation should have set up.
--- drivers/gpu/drm/vc4/vc4_gem.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/vc4/vc4_gem.c +1 -0
@@ -601,6 +601,7 @@ vc4_get_bcl(struct drm_device *dev, stru sizeof(struct vc4_shader_state)) || temp_size < exec_size) {DRM_ERROR ("overflow in exec arguments\n" ); + ret = -EINVAL ; goto fail; }
Greg Kroah-Hartman
maintainerPATCH 9/66 drm/vc4: fix a bounds check
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 21ccc32496b2f63228f5232b3ac0e426e8fb3c31 upstream.
We accidentally return success even if vc4_full_res_bounds_check() fails.
--- drivers/gpu/drm/vc4/vc4_render_cl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_render_cl.c +1 -1
@@ -461,7 +461,7 @@ static int vc4_rcl_surface_setup(struct } ret =vc4_full_res_bounds_check (exec, *obj, surf); -if (!ret) +if (ret)return ret;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 10/66 Revert "drm/radeon: always apply pci shutdown callbacks"
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit b9b487e494712c8e5905b724e12f5ef17e9ae6f9 upstream.
This seems to break reboot on some evergreen systems.
bugs:
https://bugs.freedesktop.org/show_bug.cgi?id=99524
https://bugzilla.kernel.org/show_bug.cgi?id=192271
This reverts commit a481daa88fd4d6b54f25348972bba10b5f6a84d0.
--- drivers/gpu/drm/radeon/radeon_drv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/radeon_drv.c +3 -4
@@ -366,11 +366,10 @@ static void radeon_pci_shutdown(struct pci_dev *pdev) {/* if we are running in a VM, make sure the device -* torn down properly on reboot/shutdown. -* unfortunately we can't detect certain -* hypervisors so just do this all the time. +* torn down properly on reboot/shutdown */ -radeon_pci_remove (pdev); +if (radeon_device_is_virtual ()) +radeon_pci_remove (pdev); }static int radeon_pmops_suspend (struct device *dev)
Greg Kroah-Hartman
maintainerPATCH 11/66 drm/atomic: clear out fence when duplicating state
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lucas Stach <[email protected]>
[Fixed differently in 4.10]
The fence needs to be cleared out, otherwise the following commit might wait on a stale fence from the previous commit. This was fixed as a side effect of 9626014258a5 (drm/fence: add in-fences support) in kernel 4.10.
As this commit introduces new functionality and as such can not be applied to stable, this patch is the minimal fix for the kernel 4.9 stable series.
--- drivers/gpu/drm/drm_atomic_helper.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +2 -0
@@ -3115,6 +3115,8 @@ void __drm_atomic_helper_plane_duplicateif (state->fb)drm_framebuffer_reference (state->fb); + + state->fence =NULL ; }EXPORT_SYMBOL (__drm_atomic_helper_plane_duplicate_state);
Greg Kroah-Hartman
maintainerPATCH 12/66 mm/huge_memory.c: respect FOLL_FORCE/FOLL_COW for thp
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keno Fischer <[email protected]>
commit 8310d48b125d19fcd9521d83b8293e63eb1646aa upstream.
In commit 19be0eaffa3a ("mm: remove gup_flags FOLL_WRITE games from __get_user_pages()"), the mm code was changed from unsetting FOLL_WRITE after a COW was resolved to setting the (newly introduced) FOLL_COW instead. Simultaneously, the check in gup.c was updated to still allow writes with FOLL_FORCE set if FOLL_COW had also been set.
However, a similar check in huge_memory.c was forgotten. As a result, remote memory writes to ro regions of memory backed by transparent huge pages cause an infinite loop in the kernel (handle_mm_fault sets FOLL_COW and returns 0 causing a retry, but follow_trans_huge_pmd bails out immidiately because (flags & FOLL_WRITE) && !pmd_write(*pmd) is true.
While in this state the process is stil SIGKILLable, but little else works (e.g. no ptrace attach, no other signals). This is easily reproduced with the following code (assuming thp are set to always):
#include <assert.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#define TEST_SIZE 5 * 1024 * 1024
int main(void) {
int status;
pid_t child;
int fd = open("/proc/self/mem", O_RDWR);
void *addr = mmap(NULL, TEST_SIZE, PROT_READ,
MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
assert(addr != MAP_FAILED);
pid_t parent_pid = getpid();
if ((child = fork()) == 0) {
void *addr2 = mmap(NULL, TEST_SIZE, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
assert(addr2 != MAP_FAILED);
memset(addr2, 'a', TEST_SIZE);
pwrite(fd, addr2, TEST_SIZE, (uintptr_t)addr);
return 0;
}
assert(child == waitpid(child, &status, 0));
assert(WIFEXITED(status) && WEXITSTATUS(status) == 0);
return 0;
}Fix this by updating follow_trans_huge_pmd in huge_memory.c analogously to the update in gup.c in the original commit. The same pattern exists in follow_devmap_pmd. However, we should not be able to reach that check with FOLL_COW set, so add WARN_ONCE to make sure we notice if we ever do.
--- mm/huge_memory.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
mm/huge_memory.c +17 -1
@@ -772,6 +772,12 @@ struct page *follow_devmap_pmd(struct vmassert_spin_locked (pmd_lockptr (mm, pmd)); +/* +* When we COW a devmap PMD entry, we split it into PTEs, so we should +* not be in this function with `flags & FOLL_COW` set. +*/ +WARN_ONCE (flags &FOLL_COW ,"mm: In follow_devmap_pmd with FOLL_COW set" ); +if (flags &FOLL_WRITE && !pmd_write (*pmd))return NULL ;
@@ -1118,6 +1124,16 @@ out_unlock:return ret; } +/* +* FOLL_FORCE can write to even unwritable pmd's, but only +* after we've gone through a COW cycle and they are dirty. +*/ +static inline bool can_follow_write_pmd (pmd_t pmd,unsigned int flags) +{ +return pmd_write (pmd) || + ((flags &FOLL_FORCE ) && (flags &FOLL_COW ) &&pmd_dirty (pmd)); +} + struct page *follow_trans_huge_pmd(struct vm_area_struct *vma, unsigned long addr, pmd_t *pmd,
@@ -1128,7 +1144,7 @@ struct page *follow_trans_huge_pmd(strucassert_spin_locked (pmd_lockptr (mm, pmd)); -if (flags &FOLL_WRITE && !pmd_write (*pmd)) +if (flags &FOLL_WRITE && !can_follow_write_pmd (*pmd, flags)) goto out;/* Avoid dumping huge zero page */
Greg Kroah-Hartman
maintainerPATCH 13/66 mm/mempolicy.c: do not put mempolicy before using its nodemask
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlastimil Babka <[email protected]>
commit d51e9894d27492783fc6d1b489070b4ba66ce969 upstream.
Since commit be97a41b291e ("mm/mempolicy.c: merge alloc_hugepage_vma to alloc_pages_vma") alloc_pages_vma() can potentially free a mempolicy by mpol_cond_put() before accessing the embedded nodemask by __alloc_pages_nodemask(). The commit log says it's so "we can use a single exit path within the function" but that's clearly wrong. We can still do that when doing mpol_cond_put() after the allocation attempt.
Make sure the mempolicy is not freed prematurely, otherwise __alloc_pages_nodemask() can end up using a bogus nodemask, which could lead e.g. to premature OOM.
--- mm/mempolicy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/mempolicy.c +1 -1
@@ -2023,8 +2023,8 @@ retry_cpuset: nmask =policy_nodemask (gfp, pol); zl =policy_zonelist (gfp, pol, node); -mpol_cond_put (pol); page =__alloc_pages_nodemask (gfp, order, zl, nmask); +mpol_cond_put (pol); out:if (unlikely (!page &&read_mems_allowed_retry (cpuset_mems_cookie))) goto retry_cpuset;
Greg Kroah-Hartman
maintainerPATCH 14/66 mm, page_alloc: fix check for NULL preferred_zone
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlastimil Babka <[email protected]>
commit ea57485af8f4221312a5a95d63c382b45e7840dc upstream.
Patch series "fix premature OOM regression in 4.7+ due to cpuset races".
This is v2 of my attempt to fix the recent report based on LTP cpuset stress test [1]. The intention is to go to stable 4.9 LTSS with this, as triggering repeated OOMs is not nice. That's why the patches try to be not too intrusive.
Unfortunately why investigating I found that modifying the testcase to use per-VMA policies instead of per-task policies will bring the OOM's back, but that seems to be much older and harder to fix problem. I have posted a RFC [2] but I believe that fixing the recent regressions has a higher priority.
Longer-term we might try to think how to fix the cpuset mess in a better and less error prone way. I was for example very surprised to learn, that cpuset updates change not only task->mems_allowed, but also nodemask of mempolicies. Until now I expected the parameter to alloc_pages_nodemask() to be stable. I wonder why do we then treat cpusets specially in get_page_from_freelist() and distinguish HARDWALL etc, when there's unconditional intersection between mempolicy and cpuset. I would expect the nodemask adjustment for saving overhead in g_p_f(), but that clearly doesn't happen in the current form. So we have both crazy complexity and overhead, AFAICS.
[1] https://lkml.kernel.org/r/CAFpQJXUq-JuEP=QPidy4p_=FN0rkH5Z-kfB4qBvsf6jMS87Edg@mail.gmail.com
[2] https://lkml.kernel.org/r/[email protected]
This patch (of 4):
Since commit c33d6c06f60f ("mm, page_alloc: avoid looking up the first zone in a zonelist twice") we have a wrong check for NULL preferred_zone, which can theoretically happen due to concurrent cpuset modification. We check the zoneref pointer which is never NULL and we should check the zone pointer. Also document this in first_zones_zonelist() comment per Michal Hocko.
--- include/linux/mmzone.h | 6 +++++- mm/page_alloc.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-)
include/linux/mmzone.h +5 -1
@@ -972,12 +972,16 @@ static __always_inline struct zoneref *n* @zonelist - The zonelist to search for a suitable zone * @highest_zoneidx - The zone index of the highest zone to return * @nodes - An optional nodemask to filter the zonelist with -* @zone - The first suitable zone found is returned via this parameter +* @return - Zoneref pointer for the first suitable zone found (see below) * * This function returns the first zone at or below a given zone index that is * within the allowed nodemask. The zoneref returned is a cursor that can be * used to iterate the zonelist with next_zones_zonelist by advancing it by * one before calling. +* +* When no eligible zone is found, zoneref->zone is NULL (zoneref itself is +* never NULL). This may happen either genuinely, or due to concurrent nodemask +* update due to cpuset modification. */ static inline struct zoneref *first_zones_zonelist(struct zonelist *zonelist, enum zone_type highest_zoneidx,
mm/page_alloc.c +1 -1
@@ -3763,7 +3763,7 @@ retry_cpuset:*/ ac.preferred_zoneref =first_zones_zonelist (ac.zonelist, ac.high_zoneidx, ac.nodemask); -if (!ac.preferred_zoneref) { +if (!ac.preferred_zoneref->zone) { page =NULL ; goto no_zone; }
Greg Kroah-Hartman
maintainerPATCH 15/66 mm, page_alloc: fix fast-path race with cpuset update or removal
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlastimil Babka <[email protected]>
commit 16096c25bf0ca5d87e4fa6ec6108ba53feead212 upstream.
Ganapatrao Kulkarni reported that the LTP test cpuset01 in stress mode triggers OOM killer in few seconds, despite lots of free memory. The test attempts to repeatedly fault in memory in one process in a cpuset, while changing allowed nodes of the cpuset between 0 and 1 in another process.
One possible cause is that in the fast path we find the preferred zoneref according to current mems_allowed, so that it points to the middle of the zonelist, skipping e.g. zones of node 1 completely. If the mems_allowed is updated to contain only node 1, we never reach it in the zonelist, and trigger OOM before checking the cpuset_mems_cookie.
This patch fixes the particular case by redoing the preferred zoneref search if we switch back to the original nodemask. The condition is also slightly changed so that when the last non-root cpuset is removed, we don't miss it.
Note that this is not a full fix, and more patches will follow.
--- mm/page_alloc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
mm/page_alloc.c +9 -1
@@ -3783,9 +3783,17 @@ retry_cpuset:/* * Restore the original nodemask if it was potentially replaced with * &cpuset_current_mems_allowed to optimize the fast-path attempt. +* Also recalculate the starting point for the zonelist iterator or +* we could end up iterating over non-eligible zones endlessly. */ -if (cpusets_enabled ()) +if (unlikely (ac.nodemask != nodemask)) { ac.nodemask = nodemask; + ac.preferred_zoneref =first_zones_zonelist (ac.zonelist, + ac.high_zoneidx, ac.nodemask); +if (!ac.preferred_zoneref->zone) + goto no_zone; + } + page =__alloc_pages_slowpath (alloc_mask, order, &ac); no_zone:
Greg Kroah-Hartman
maintainerPATCH 16/66 mm, page_alloc: move cpuset seqcount checking to slowpath
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlastimil Babka <[email protected]>
commit 5ce9bfef1d27944c119a397a9d827bef795487ce upstream.
This is a preparation for the following patch to make review simpler. While the primary motivation is a bug fix, this also simplifies the fast path, although the moved code is only enabled when cpusets are in use.
--- mm/page_alloc.c | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-)
mm/page_alloc.c +26 -21
@@ -3502,12 +3502,13 @@ __alloc_pages_slowpath(gfp_t gfp_mask, ustruct page *page =NULL ;unsigned int alloc_flags;unsigned long did_some_progress; -enum compact_priority compact_priority =DEF_COMPACT_PRIORITY ; +enum compact_priority compact_priority;enum compact_result compact_result; -int compaction_retries =0 ; -int no_progress_loops =0 ; +int compaction_retries; +int no_progress_loops;unsigned long alloc_start = jiffies;unsigned int stall_timeout =10 *HZ ; +unsigned int cpuset_mems_cookie;/* * In the slowpath, we sanity check order to avoid ever trying to
@@ -3528,6 +3529,12 @@ __alloc_pages_slowpath(gfp_t gfp_mask, u (__GFP_ATOMIC|__GFP_DIRECT_RECLAIM))) gfp_mask &= ~__GFP_ATOMIC; +retry_cpuset: + compaction_retries =0 ; + no_progress_loops =0 ; + compact_priority =DEF_COMPACT_PRIORITY ; + cpuset_mems_cookie =read_mems_allowed_begin (); +/* * The fast path uses conservative alloc_flags to succeed only until * kswapd needs to be woken up, and to avoid the cost of setting up
@@ -3699,6 +3706,15 @@ retry: } nopage: +/* +* When updating a task's mems_allowed, it is possible to race with +* parallel threads in such a way that an allocation can fail while +* the mask is being updated. If a page allocation is about to fail, +* check if the cpuset changed during allocation and if so, retry. +*/ +if (read_mems_allowed_retry (cpuset_mems_cookie)) + goto retry_cpuset; +warn_alloc (gfp_mask,"page allocation failure: order:%u" , order); got_pg:
@@ -3713,7 +3729,6 @@ __alloc_pages_nodemask(gfp_t gfp_mask, u struct zonelist *zonelist, nodemask_t *nodemask) { struct page *page; -unsigned int cpuset_mems_cookie;unsigned int alloc_flags =ALLOC_WMARK_LOW ;gfp_t alloc_mask = gfp_mask;/* The gfp_t that was actually used for allocation */ struct alloc_context ac = {
@@ -3750,9 +3765,6 @@ __alloc_pages_nodemask(gfp_t gfp_mask, uif (IS_ENABLED (CONFIG_CMA ) && ac.migratetype ==MIGRATE_MOVABLE ) alloc_flags |=ALLOC_CMA ; -retry_cpuset: - cpuset_mems_cookie =read_mems_allowed_begin (); -/* Dirty zone balancing only done in the fast path */ ac.spread_dirty_pages = (gfp_mask & __GFP_WRITE);
@@ -3765,6 +3777,11 @@ retry_cpuset: ac.high_zoneidx, ac.nodemask);if (!ac.preferred_zoneref->zone) { page =NULL ; +/* +* This might be due to race with cpuset_current_mems_allowed +* update, so make sure we retry with original nodemask in the +* slow path. +*/ goto no_zone; }
@@ -3773,6 +3790,7 @@ retry_cpuset:if (likely (page)) goto out; +no_zone:/* * Runtime PM, block IO and its error handling path can deadlock * because I/O on the device might not complete.
@@ -3790,24 +3808,11 @@ retry_cpuset: ac.nodemask = nodemask; ac.preferred_zoneref =first_zones_zonelist (ac.zonelist, ac.high_zoneidx, ac.nodemask); -if (!ac.preferred_zoneref->zone) - goto no_zone; +/* If we have NULL preferred zone, slowpath wll handle that */ } page =__alloc_pages_slowpath (alloc_mask, order, &ac); -no_zone: -/* -* When updating a task's mems_allowed, it is possible to race with -* parallel threads in such a way that an allocation can fail while -* the mask is being updated. If a page allocation is about to fail, -* check if the cpuset changed during allocation and if so, retry. -*/ -if (unlikely (!page &&read_mems_allowed_retry (cpuset_mems_cookie))) { - alloc_mask = gfp_mask; - goto retry_cpuset; - } - out:if (memcg_kmem_enabled () && (gfp_mask & __GFP_ACCOUNT) && page &&unlikely (memcg_kmem_charge (page, gfp_mask, order) !=0 )) {
Greg Kroah-Hartman
maintainerPATCH 17/66 mm, page_alloc: fix premature OOM when racing with cpuset mems update
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlastimil Babka <[email protected]>
commit e47483bca2cc59a4593b37a270b16ee42b1d9f08 upstream.
Ganapatrao Kulkarni reported that the LTP test cpuset01 in stress mode triggers OOM killer in few seconds, despite lots of free memory. The test attempts to repeatedly fault in memory in one process in a cpuset, while changing allowed nodes of the cpuset between 0 and 1 in another process.
The problem comes from insufficient protection against cpuset changes, which can cause get_page_from_freelist() to consider all zones as non-eligible due to nodemask and/or current->mems_allowed. This was masked in the past by sufficient retries, but since commit 682a3385e773 ("mm, page_alloc: inline the fast path of the zonelist iterator") we fix the preferred_zoneref once, and don't iterate over the whole zonelist in further attempts, thus the only eligible zones might be placed in the zonelist before our starting point and we always miss them.
A previous patch fixed this problem for current->mems_allowed. However, cpuset changes also update the task's mempolicy nodemask. The fix has two parts. We have to repeat the preferred_zoneref search when we detect cpuset update by way of seqcount, and we have to check the seqcount before considering OOM.
--- mm/page_alloc.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-)
mm/page_alloc.c +24 -11
@@ -3534,6 +3534,17 @@ retry_cpuset: no_progress_loops =0 ; compact_priority =DEF_COMPACT_PRIORITY ; cpuset_mems_cookie =read_mems_allowed_begin (); +/* +* We need to recalculate the starting point for the zonelist iterator +* because we might have used different nodemask in the fast path, or +* there was a cpuset modification and we are retrying - otherwise we +* could end up iterating over non-eligible zones endlessly. +*/ + ac->preferred_zoneref =first_zones_zonelist (ac->zonelist, + ac->high_zoneidx, ac->nodemask); +if (!ac->preferred_zoneref->zone) + goto nopage; +/* * The fast path uses conservative alloc_flags to succeed only until
@@ -3694,6 +3705,13 @@ retry: &compaction_retries)) goto retry; +/* +* It's possible we raced with cpuset update so the OOM would be +* premature (see below the nopage: label for full explanation). +*/ +if (read_mems_allowed_retry (cpuset_mems_cookie)) + goto retry_cpuset; +/* Reclaim has failed us, start killing things */ page =__alloc_pages_may_oom (gfp_mask, order, ac, &did_some_progress);if (page)
@@ -3707,10 +3725,11 @@ retry: nopage:/* -* When updating a task's mems_allowed, it is possible to race with -* parallel threads in such a way that an allocation can fail while -* the mask is being updated. If a page allocation is about to fail, -* check if the cpuset changed during allocation and if so, retry. +* When updating a task's mems_allowed or mempolicy nodemask, it is +* possible to race with parallel threads in such a way that our +* allocation can fail while the mask is being updated. If we are about +* to fail, check if the cpuset changed during allocation and if so, +* retry. */ if (read_mems_allowed_retry (cpuset_mems_cookie)) goto retry_cpuset;
@@ -3801,15 +3820,9 @@ no_zone:/* * Restore the original nodemask if it was potentially replaced with * &cpuset_current_mems_allowed to optimize the fast-path attempt. -* Also recalculate the starting point for the zonelist iterator or -* we could end up iterating over non-eligible zones endlessly. */ -if (unlikely (ac.nodemask != nodemask)) { +if (unlikely (ac.nodemask != nodemask)) ac.nodemask = nodemask; - ac.preferred_zoneref =first_zones_zonelist (ac.zonelist, - ac.high_zoneidx, ac.nodemask); -/* If we have NULL preferred zone, slowpath wll handle that */ - } page =__alloc_pages_slowpath (alloc_mask, order, &ac);
Greg Kroah-Hartman
maintainerPATCH 18/66 vring: Force use of DMA API for ARM-based systems with legacy devices
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
commit c7070619f3408d9a0dffbed9149e6f00479cf43b upstream.
Booting Linux on an ARM fastmodel containing an SMMU emulation results in an unexpected I/O page fault from the legacy virtio-blk PCI device:
[ 1.211721] arm-smmu-v3 2b400000.smmu: event 0x10 received: [ 1.211800] arm-smmu-v3 2b400000.smmu: 0x00000000fffff010 [ 1.211880] arm-smmu-v3 2b400000.smmu: 0x0000020800000000 [ 1.211959] arm-smmu-v3 2b400000.smmu: 0x00000008fa081002 [ 1.212075] arm-smmu-v3 2b400000.smmu: 0x0000000000000000 [ 1.212155] arm-smmu-v3 2b400000.smmu: event 0x10 received: [ 1.212234] arm-smmu-v3 2b400000.smmu: 0x00000000fffff010 [ 1.212314] arm-smmu-v3 2b400000.smmu: 0x0000020800000000 [ 1.212394] arm-smmu-v3 2b400000.smmu: 0x00000008fa081000 [ 1.212471] arm-smmu-v3 2b400000.smmu: 0x0000000000000000
<system hangs failing to read partition table>
This is because the legacy virtio-blk device is behind an SMMU, so we have consequently swizzled its DMA ops and configured the SMMU to translate accesses. This then requires the vring code to use the DMA API to establish translations, otherwise all transactions will result in fatal faults and termination.
Given that ARM-based systems only see an SMMU if one is really present (the topology is all described by firmware tables such as device-tree or IORT), then we can safely use the DMA API for all legacy virtio devices. Modern devices can advertise the prescense of an IOMMU using the VIRTIO_F_IOMMU_PLATFORM feature flag.
--- drivers/virtio/virtio_ring.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/virtio/virtio_ring.c +7 -0
@@ -159,6 +159,13 @@ static bool vring_use_dma_api(struct virif (xen_domain ())return true; +/* +* On ARM-based machines, the DMA ops will do the right thing, +* so always use them with legacy devices. +*/ +if (IS_ENABLED (CONFIG_ARM ) ||IS_ENABLED (CONFIG_ARM64 )) +return !virtio_has_feature (vdev,VIRTIO_F_VERSION_1 ); +return false; }
Greg Kroah-Hartman
maintainerPATCH 19/66 userns: Make ucounts lock irq-safe
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Borisov <[email protected]>
commit 880a38547ff08715ce4f1daf9a4bb30c87676e68 upstream.
The ucounts_lock is being used to protect various ucounts lifecycle management functionalities. However, those services can also be invoked when a pidns is being freed in an RCU callback (e.g. softirq context). This can lead to deadlocks. There were already efforts trying to prevent similar deadlocks in add7c65ca426 ("pid: fix lockdep deadlock warning due to ucount_lock"), however they just moved the context from hardirq to softrq. Fix this issue once and for all by explictly making the lock disable irqs altogether.
Dmitry Vyukov <[email protected]> reported:
Quoted 129 lines
I've got the following deadlock report while running syzkaller fuzzer on
eec0d3d065bfcdf9cd5f56dd2a36b94d12d32297of linux-next (on odroid device if it matters):=================================
[ INFO: inconsistent lock state ] 4.10.0-rc3-next-20170112-xc2-dirty #6 Not tainted
---------------------------------
inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage. swapper/2/0 [HC0[0]:SC1[1]:HE1:SE0] takes:
(ucounts_lock){+.?...}, at: [< inline >]spin_lock./include/linux/spinlock.h:302
(ucounts_lock){+.?...}, at: [<ffff2000081678c8>]put_ucounts+0x60/0x138kernel/ucount.c:162{SOFTIRQ-ON-W} state was registered at:[<ffff2000081c82d8>] mark_lock+0x220/0xb60 kernel/locking/lockdep.c:3054 [< inline >] mark_irqflags kernel/locking/lockdep.c:2941 [<ffff2000081c97a8>] __lock_acquire+0x388/0x3260 kernel/locking/lockdep.c:3295 [<ffff2000081cce24>] lock_acquire+0xa4/0x138 kernel/locking/lockdep.c:3753 [< inline >] __raw_spin_lock ./include/linux/spinlock_api_smp.h:144 [<ffff200009798128>] _raw_spin_lock+0x90/0xd0 kernel/locking/spinlock.c:151 [< inline >] spin_lock ./include/linux/spinlock.h:302 [< inline >] get_ucounts kernel/ucount.c:131 [<ffff200008167c28>] inc_ucount+0x80/0x6c8 kernel/ucount.c:189 [< inline >] inc_mnt_namespaces fs/namespace.c:2818 [<ffff200008481850>] alloc_mnt_ns+0x78/0x3a8 fs/namespace.c:2849 [<ffff200008487298>] create_mnt_ns+0x28/0x200 fs/namespace.c:2959 [< inline >] init_mount_tree fs/namespace.c:3199 [<ffff200009bd6674>] mnt_init+0x258/0x384 fs/namespace.c:3251 [<ffff200009bd60bc>] vfs_caches_init+0x6c/0x80 fs/dcache.c:3626 [<ffff200009bb1114>] start_kernel+0x414/0x460 init/main.c:648 [<ffff200009bb01e8>] __primary_switched+0x6c/0x70 arch/arm64/kernel/head.S:456 irq event stamp: 2316924 hardirqs last enabled at (2316924): [< inline >] rcu_do_batch kernel/rcu/tree.c:2911 hardirqs last enabled at (2316924): [< inline >] invoke_rcu_callbacks kernel/rcu/tree.c:3182 hardirqs last enabled at (2316924): [< inline >] __rcu_process_callbacks kernel/rcu/tree.c:3149 hardirqs last enabled at (2316924): [<ffff200008210414>] rcu_process_callbacks+0x7a4/0xc28 kernel/rcu/tree.c:3166 hardirqs last disabled at (2316923): [< inline >] rcu_do_batch kernel/rcu/tree.c:2900 hardirqs last disabled at (2316923): [< inline >] invoke_rcu_callbacks kernel/rcu/tree.c:3182 hardirqs last disabled at (2316923): [< inline >] __rcu_process_callbacks kernel/rcu/tree.c:3149 hardirqs last disabled at (2316923): [<ffff20000820fe80>] rcu_process_callbacks+0x210/0xc28 kernel/rcu/tree.c:3166 softirqs last enabled at (2316912): [<ffff20000811b4c4>] _local_bh_enable+0x4c/0x80 kernel/softirq.c:155 softirqs last disabled at (2316913): [< inline >] do_softirq_own_stack ./include/linux/interrupt.h:488 softirqs last disabled at (2316913): [< inline >] invoke_softirq kernel/softirq.c:371 softirqs last disabled at (2316913): [<ffff20000811c994>] irq_exit+0x264/0x308 kernel/softirq.c:405other info that might help us debug this:
Possible unsafe locking scenario:CPU0 ---- lock(ucounts_lock); <Interrupt> lock(ucounts_lock);*** DEADLOCK ***
1 lock held by swapper/2/0:
#0: (rcu_callback){......}, at: [< inline >]__rcu_reclaimkernel/rcu/rcu.h:108
#0: (rcu_callback){......}, at: [< inline >]rcu_do_batchkernel/rcu/tree.c:2919
#0: (rcu_callback){......}, at: [< inline >]invoke_rcu_callbacks kernel/rcu/tree.c:3182 #0: (rcu_callback){......}, at: [< inline >] __rcu_process_callbacks kernel/rcu/tree.c:3149 #0: (rcu_callback){......}, at: [<ffff200008210390>] rcu_process_callbacks+0x720/0xc28 kernel/rcu/tree.c:3166 stack backtrace: CPU: 2 PID: 0 Comm: swapper/2 Not tainted 4.10.0-rc3-next-20170112-xc2-dirty #6 Hardware name: Hardkernel ODROID-C2 (DT) Call trace: [<ffff20000808fa60>] dump_backtrace+0x0/0x440 arch/arm64/kernel/traps.c:500 [<ffff20000808fec0>] show_stack+0x20/0x30 arch/arm64/kernel/traps.c:225 [<ffff2000088a99e0>] dump_stack+0x110/0x168 [<ffff2000082fa2b4>] print_usage_bug.part.27+0x49c/0x4bc kernel/locking/lockdep.c:2387 [< inline >] print_usage_bug kernel/locking/lockdep.c:2357 [< inline >] valid_state kernel/locking/lockdep.c:2400 [< inline >] mark_lock_irq kernel/locking/lockdep.c:2617 [<ffff2000081c89ec>] mark_lock+0x934/0xb60 kernel/locking/lockdep.c:3065 [< inline >] mark_irqflags kernel/locking/lockdep.c:2923 [<ffff2000081c9a60>] __lock_acquire+0x640/0x3260 kernel/locking/lockdep.c:3295 [<ffff2000081cce24>] lock_acquire+0xa4/0x138 kernel/locking/lockdep.c:3753 [< inline >] __raw_spin_lock ./include/linux/spinlock_api_smp.h:144 [<ffff200009798128>] _raw_spin_lock+0x90/0xd0 kernel/locking/spinlock.c:151 [< inline >] spin_lock ./include/linux/spinlock.h:302 [<ffff2000081678c8>] put_ucounts+0x60/0x138 kernel/ucount.c:162 [<ffff200008168364>] dec_ucount+0xf4/0x158 kernel/ucount.c:214 [< inline >] dec_pid_namespaces kernel/pid_namespace.c:89 [<ffff200008293dc8>] delayed_free_pidns+0x40/0xe0 kernel/pid_namespace.c:156 [< inline >] __rcu_reclaim kernel/rcu/rcu.h:118 [< inline >] rcu_do_batch kernel/rcu/tree.c:2919 [< inline >] invoke_rcu_callbacks kernel/rcu/tree.c:3182 [< inline >] __rcu_process_callbacks kernel/rcu/tree.c:3149 [<ffff2000082103d8>] rcu_process_callbacks+0x768/0xc28 kernel/rcu/tree.c:3166 [<ffff2000080821dc>] __do_softirq+0x324/0x6e0 kernel/softirq.c:284 [< inline >] do_softirq_own_stack ./include/linux/interrupt.h:488 [< inline >] invoke_softirq kernel/softirq.c:371 [<ffff20000811c994>] irq_exit+0x264/0x308 kernel/softirq.c:405 [<ffff2000081ecc28>] __handle_domain_irq+0xc0/0x150 kernel/irq/irqdesc.c:636 [<ffff200008081c80>] gic_handle_irq+0x68/0xd8 Exception stack(0xffff8000648e7dd0 to 0xffff8000648e7f00)7dc0:
ffff8000648d4b3c0000000000000007
7de0: 00000000000000001ffff0000c91a9671ffff0000c91a9671ffff0000c91a9677e00:ffff20000a4b6b680000000000000001 0000000000000007 0000000000000001 7e20:1fffe4000149ae90ffff200009d350000000000000000000 0000000000000002 7e40: 0000000000000000 00000000000000000000000002624a1a0000000000000000 7e60: 0000000000000000ffff200009cbcd88000060006d2ed0000000000000000140 7e80:ffff200009cff000ffff200009cb6000ffff200009cc2020ffff200009d2159d7ea0: 0000000000000000ffff8000648d43800000000000000000ffff8000648e7f007ec0:ffff20000820a478ffff8000648e7f00ffff20000820a47c0000000010000145 7ee0: 0000000000000140dfff200000000000ffffffffffffffffffff20000820a478[<ffff2000080837f8>]el1_irq+0xb8/0x130arch/arm64/kernel/entry.S:486
[< inline >]arch_local_irq_restore./arch/arm64/include/asm/irqflags.h:81
Quoted 7 lines
[<ffff20000820a47c>] rcu_idle_exit+0x64/0xa8 kernel/rcu/tree.c:1030 [< inline >] cpuidle_idle_call kernel/sched/idle.c:200 [<ffff2000081bcbfc>] do_idle+0x1dc/0x2d0 kernel/sched/idle.c:243 [<ffff2000081bd1cc>] cpu_startup_entry+0x24/0x28 kernel/sched/idle.c:345 [<ffff200008099f8c>] secondary_start_kernel+0x2cc/0x358
arch/arm64/kernel/smp.c:276
[<000000000279f1a4>]0x279f1a4
--- kernel/ucount.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
kernel/ucount.c +8 -6
@@ -128,10 +128,10 @@ static struct ucounts *get_ucounts(strucstruct hlist_head *hashent =ucounts_hashentry (ns, uid);struct ucounts *ucounts, *new; -spin_lock (&ucounts_lock); +spin_lock_irq (&ucounts_lock); ucounts =find_ucounts (ns, uid, hashent);if (!ucounts) { -spin_unlock (&ucounts_lock); +spin_unlock_irq (&ucounts_lock); new =kzalloc (sizeof (*new),GFP_KERNEL );if (!new)
@@ -141,7 +141,7 @@ static struct ucounts *get_ucounts(struc new->uid = uid;atomic_set (&new->count,0 ); -spin_lock (&ucounts_lock); +spin_lock_irq (&ucounts_lock); ucounts =find_ucounts (ns, uid, hashent);if (ucounts) {kfree (new);
@@ -152,16 +152,18 @@ static struct ucounts *get_ucounts(struc }if (!atomic_add_unless (&ucounts->count,1 ,INT_MAX )) ucounts =NULL ; -spin_unlock (&ucounts_lock); +spin_unlock_irq (&ucounts_lock);return ucounts; }static void put_ucounts (struct ucounts *ucounts) { +unsigned long flags; +if (atomic_dec_and_test (&ucounts->count)) { -spin_lock (&ucounts_lock); +spin_lock_irqsave (&ucounts_lock, flags);hlist_del_init (&ucounts->node); -spin_unlock (&ucounts_lock); +spin_unlock_irqrestore (&ucounts_lock, flags);kfree (ucounts); }
Greg Kroah-Hartman
maintainerPATCH 20/66 sysctl: fix proc_doulongvec_ms_jiffies_minmax()
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit ff9f8a7cf935468a94d9927c68b00daae701667e upstream.
We perform the conversion between kernel jiffies and ms only when exporting kernel value to user space.
We need to do the opposite operation when value is written by user.
Only matters when HZ != 1000
--- kernel/sysctl.c | 1 + 1 file changed, 1 insertion(+)
kernel/sysctl.c +1 -0
@@ -2487,6 +2487,7 @@ static int __do_proc_doulongvec_minmax(vbreak ;if (neg)continue ; + val = convmul * val / convdiv;if ((min && val < *min) || (max && val > *max))continue ; *i = val;
Greg Kroah-Hartman
maintainerPATCH 21/66 xfs: prevent quotacheck from overloading inode lru
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Foster <[email protected]>
commit e0d76fa4475ef2cf4b52d18588b8ce95153d021b upstream.
Quotacheck runs at mount time in situations where quota accounting must be recalculated. In doing so, it uses bulkstat to visit every inode in the filesystem. Historically, every inode processed during quotacheck was released and immediately tagged for reclaim because quotacheck runs before the superblock is marked active by the VFS. In other words, the final iput() lead to an immediate ->destroy_inode() call, which allowed the XFS background reclaim worker to start reclaiming inodes.
Commit 17c12bcd3 ("xfs: when replaying bmap operations, don't let unlinked inodes get reaped") marks the XFS superblock active sooner as part of the mount process to support caching inodes processed during log recovery. This occurs before quotacheck and thus means all inodes processed by quotacheck are inserted to the LRU on release. The s_umount lock is held until the mount has completed and thus prevents the shrinkers from operating on the sb. This means that quotacheck can excessively populate the inode LRU and lead to OOM conditions on systems without sufficient RAM.
Update the quotacheck bulkstat handler to set XFS_IGET_DONTCACHE on inodes processed by quotacheck. This causes ->drop_inode() to return 1 and in turn causes iput_final() to evict the inode. This preserves the original quotacheck behavior and prevents it from overloading the LRU and running out of memory.
--- fs/xfs/xfs_qm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/xfs/xfs_qm.c +2 -1
@@ -1177,7 +1177,8 @@ xfs_qm_dqusage_adjust(* the case in all other instances. It's OK that we do this because * quotacheck is done only at mount time. */ - error =xfs_iget (mp,NULL , ino,0 ,XFS_ILOCK_EXCL , &ip); + error =xfs_iget (mp,NULL , ino,XFS_IGET_DONTCACHE ,XFS_ILOCK_EXCL , + &ip);if (error) { *res =BULKSTAT_RV_NOTHING ;return error;
Greg Kroah-Hartman
maintainerPATCH 22/66 ISDN: eicon: silence misleading array-bounds warning
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 950eabbd6ddedc1b08350b9169a6a51b130ebaaf upstream.
With some gcc versions, we get a warning about the eicon driver, and that currently shows up as the only remaining warning in one of the build bots:
In file included from ../drivers/isdn/hardware/eicon/message.c:30:0:eicon/message.c: In function 'mixer_notify_update':eicon/platform.h:333:18: warning: array subscript is above array bounds [-Warray-bounds]
The code is easily changed to open-code the unusual PUT_WORD() line causing this to avoid the warning.
--- drivers/isdn/hardware/eicon/message.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/isdn/hardware/eicon/message.c +2 -1
@@ -11297,7 +11297,8 @@ static void mixer_notify_update(PLCI *pl ((CAPI_MSG *) msg)->header.ncci =0 ; ((CAPI_MSG *) msg)->info.facility_req.Selector =SELECTOR_LINE_INTERCONNECT ; ((CAPI_MSG *) msg)->info.facility_req.structs[0 ] =3 ; -PUT_WORD (&(((CAPI_MSG *) msg)->info.facility_req.structs[1 ]),LI_REQ_SILENT_UPDATE ); + ((CAPI_MSG *) msg)->info.facility_req.structs[1 ] =LI_REQ_SILENT_UPDATE &0xff ; + ((CAPI_MSG *) msg)->info.facility_req.structs[2 ] =LI_REQ_SILENT_UPDATE >>8 ; ((CAPI_MSG *) msg)->info.facility_req.structs[3 ] =0 ; w =api_put (notify_plci->appl, (CAPI_MSG *) msg);if (w != _QUEUE_FULL)
Greg Kroah-Hartman
maintainerPATCH 23/66 Btrfs: remove old tree_root case in btrfs_read_locked_inode()
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Omar Sandoval <[email protected]>
commit 67ade058ef2c65a3e56878af9c293ec76722a2e5 upstream.
As Jeff explained in c2951f32d36c ("btrfs: remove old tree_root dirent processing in btrfs_real_readdir()"), supporting this old format is no longer necessary since the Btrfs magic number has been updated since we changed to the current format. There are other places where we still handle this old format, but since this is part of a fix that is going to stable, I'm only removing this one for now.
--- fs/btrfs/inode.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
fs/btrfs/inode.c +1 -4
@@ -3819,10 +3819,7 @@ cache_acl:break ;case S_IFDIR : inode->i_fop = &btrfs_dir_file_operations; -if (root == root->fs_info->tree_root) - inode->i_op = &btrfs_dir_ro_inode_operations; -else - inode->i_op = &btrfs_dir_inode_operations; + inode->i_op = &btrfs_dir_inode_operations;break ;case S_IFLNK : inode->i_op = &btrfs_symlink_inode_operations;
Greg Kroah-Hartman
maintainerPATCH 24/66 Btrfs: disable xattr operations on subvolume directories
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Omar Sandoval <[email protected]>
commit 1fdf41941b8010691679638f8d0c8d08cfee7726 upstream.
When you snapshot a subvolume containing a subvolume, you get a placeholder directory where the subvolume would be. These directory inodes have ->i_ops set to btrfs_dir_ro_inode_operations. Previously, these i_ops didn't include the xattr operation callbacks. The conversion to xattr_handlers missed this case, leading to bogus attempts to set xattrs on these inodes. This manifested itself as failures when running delayed inodes.
To fix this, clear IOP_XATTR in ->i_opflags on these inodes.
--- fs/btrfs/inode.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/inode.c +1 -0
@@ -5679,6 +5679,7 @@ static struct inode *new_simple_dir(stru inode->i_ino =BTRFS_EMPTY_SUBVOL_DIR_OBJECTID ; inode->i_op = &btrfs_dir_ro_inode_operations; + inode->i_opflags &= ~IOP_XATTR ; inode->i_fop = &simple_dir_operations; inode->i_mode =S_IFDIR |S_IRUGO |S_IWUSR |S_IXUGO ; inode->i_mtime =current_time (inode);
Greg Kroah-Hartman
maintainerPATCH 25/66 Btrfs: remove ->{get, set}_acl() from btrfs_dir_ro_inode_operations
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Omar Sandoval <[email protected]>
commit 57b59ed2e5b91e958843609c7884794e29e6c4cb upstream.
Subvolume directory inodes can't have ACLs.
--- fs/btrfs/inode.c | 2 -- 1 file changed, 2 deletions(-)
fs/btrfs/inode.c +0 -2
@@ -10585,8 +10585,6 @@ static const struct inode_operations btrstatic const struct inode_operations btrfs_dir_ro_inode_operations = { .lookup = btrfs_lookup, .permission = btrfs_permission, - .get_acl = btrfs_get_acl, - .set_acl = btrfs_set_acl, .update_time = btrfs_update_time, };
Greg Kroah-Hartman
maintainerPATCH 26/66 RDMA/cma: Fix unknown symbol when CONFIG_IPV6 is not enabled
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jack Morgenstein <[email protected]>
commit b4cfe3971f6eab542dd7ecc398bfa1aeec889934 upstream.
If IPV6 has not been enabled in the underlying kernel, we must avoid calling IPV6 procedures in rdma_cm.ko.
This requires using "IS_ENABLED(CONFIG_IPV6)" in "if" statements surrounding any code which calls external IPV6 procedures.
In the instance fixed here, procedure cma_bind_addr() called ipv6_addr_type() -- which resulted in calling external procedure __ipv6_addr_type().
--- drivers/infiniband/core/cma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/core/cma.c +2 -1
@@ -2768,7 +2768,8 @@ static int cma_bind_addr(struct rdma_cm_if (!src_addr || !src_addr->sa_family) { src_addr = (struct sockaddr *) &id->route.addr.src_addr; src_addr->sa_family = dst_addr->sa_family; -if (dst_addr->sa_family ==AF_INET6 ) { +if (IS_ENABLED (CONFIG_IPV6 ) && + dst_addr->sa_family ==AF_INET6 ) {struct sockaddr_in6 *src_addr6 = (struct sockaddr_in6 *) src_addr;struct sockaddr_in6 *dst_addr6 = (struct sockaddr_in6 *) dst_addr; src_addr6->sin6_scope_id = dst_addr6->sin6_scope_id;
Greg Kroah-Hartman
maintainerPATCH 27/66 s390/mm: Fix cmma unused transfer from pgste into pte
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Borntraeger <[email protected]>
commit 0d6da872d3e4a60f43c295386d7ff9a4cdcd57e9 upstream.
The last pgtable rework silently disabled the CMMA unused state by setting a local pte variable (a parameter) instead of propagating it back into the caller. Fix it.
--- arch/s390/mm/pgtable.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/s390/mm/pgtable.c +4 -3
@@ -202,7 +202,7 @@ static inline pgste_t ptep_xchg_start(streturn pgste; } -static inline void ptep_xchg_commit (struct mm_struct *mm, +static inline pte_t ptep_xchg_commit (struct mm_struct *mm,unsigned long addr,pte_t *ptep,pgste_t pgste,pte_t old,pte_t new) {
@@ -220,6 +220,7 @@ static inline void ptep_xchg_commit(stru }else { *ptep = new; } +return old; } pte_t ptep_xchg_direct(struct mm_struct *mm, unsigned long addr,
@@ -231,7 +232,7 @@ pte_t ptep_xchg_direct(struct mm_structpreempt_disable (); pgste =ptep_xchg_start (mm, addr, ptep); old =ptep_flush_direct (mm, addr, ptep); -ptep_xchg_commit (mm, addr, ptep, pgste, old, new); + old =ptep_xchg_commit (mm, addr, ptep, pgste, old, new);preempt_enable ();return old; }
@@ -246,7 +247,7 @@ pte_t ptep_xchg_lazy(struct mm_struct *mpreempt_disable (); pgste =ptep_xchg_start (mm, addr, ptep); old =ptep_flush_lazy (mm, addr, ptep); -ptep_xchg_commit (mm, addr, ptep, pgste, old, new); + old =ptep_xchg_commit (mm, addr, ptep, pgste, old, new);preempt_enable ();return old; }
Greg Kroah-Hartman
maintainerPATCH 28/66 s390/ptrace: Preserve previous registers for short regset write
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Schwidefsky <[email protected]>
commit 9dce990d2cf57b5ed4e71a9cdbd7eae4335111ff upstream.
Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET to fill all the registers, the thread's old registers are preserved.
convert_vx_to_fp() is adapted to handle only a specified number of registers rather than unconditionally handling all of them: other callers of this function are adapted appropriately.
Based on an initial patch by Dave Martin.
--- arch/s390/kernel/ptrace.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/s390/kernel/ptrace.c +8 -0
@@ -963,6 +963,11 @@ static int s390_fpregs_set(struct task_sif (target == current)save_fpu_regs (); +if (MACHINE_HAS_VX ) +convert_vx_to_fp (fprs, target->thread.fpu.vxrs); +else +memcpy (&fprs, target->thread.fpu.fprs,sizeof (fprs)); +/* If setting FPC, must validate it first. */ if (count >0 && pos < offsetof(s390_fp_regs , fprs)) {u32 ufpc[2 ] = { target->thread.fpu.fpc,0 };
@@ -1067,6 +1072,9 @@ static int s390_vxrs_low_set(struct taskif (target == current)save_fpu_regs (); +for (i =0 ; i < __NUM_VXRS_LOW; i++) + vxrs[i] = *((__u64 *)(target->thread.fpu.vxrs + i) +1 ); + rc =user_regset_copyin (&pos, &count, &kbuf, &ubuf, vxrs,0 ,-1 );if (rc ==0 )for (i =0 ; i < __NUM_VXRS_LOW; i++)
Greg Kroah-Hartman
maintainerPATCH 29/66 IB/cxgb3: fix misspelling in header guard
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Iooss <[email protected]>
commit b1a27eac7fefff33ccf6acc919fc0725bf9815fb upstream.
Use CXGB3_... instead of CXBG3_...
--- include/uapi/rdma/cxgb3-abi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/rdma/cxgb3-abi.h +1 -1
@@ -30,7 +30,7 @@* SOFTWARE. */ #ifndef CXGB3_ABI_USER_H -#define CXBG3_ABI_USER_H +#define CXGB3_ABI_USER_H #include <linux/types.h>
Greg Kroah-Hartman
maintainerPATCH 30/66 IB/iser: Fix sg_tablesize calculation
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Gurtovoy <[email protected]>
commit 1e5db6c31ade4150c2e2b1a21e39f776c38fea39 upstream.
For devices that can register page list that is bigger than USHRT_MAX, we actually take the wrong value for sg_tablesize. E.g: for CX4 max_fast_reg_page_list_len is 65536 (bigger than USHRT_MAX) so we set sg_tablesize to 0 by mistake. Therefore, each IO that is bigger than 4k splitted to "< 4k" chunks that cause performance degredation. Remove wrong sg_tablesize assignment, and use the value that was set during address resolution handler with the needed casting.
--- drivers/infiniband/ulp/iser/iscsi_iser.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/infiniband/ulp/iser/iscsi_iser.c +0 -7
@@ -651,13 +651,6 @@ iscsi_iser_session_create(struct iscsi_e SHOST_DIX_GUARD_CRC); } -/* -* Limit the sg_tablesize and max_sectors based on the device -* max fastreg page list length. -*/ - shost->sg_tablesize = min_t(unsigned short, shost->sg_tablesize, - ib_conn->device->ib_device->attrs.max_fast_reg_page_list_len); -if (iscsi_host_add (shost, ib_conn->device->ib_device->dma_device)) {mutex_unlock (&iser_conn->state_mutex);
Greg Kroah-Hartman
maintainerPATCH 31/66 IB/srp: fix mr allocation when the device supports sg gaps
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Israel Rukshin <[email protected]>
commit ad8e66b4a80182174f73487ed25fd2140cf43361 upstream.
If the device support arbitrary sg list mapping (device cap IB_DEVICE_SG_GAPS_REG set) we allocate the memory regions with IB_MR_TYPE_SG_GAPS.
--- drivers/infiniband/ulp/srp/ib_srp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +7 -2
@@ -366,6 +366,7 @@ static struct srp_fr_pool *srp_create_frstruct srp_fr_desc *d;struct ib_mr *mr;int i, ret = -EINVAL ; +enum ib_mr_type mr_type;if (pool_size <=0 ) goto err;
@@ -379,9 +380,13 @@ static struct srp_fr_pool *srp_create_frspin_lock_init (&pool->lock);INIT_LIST_HEAD (&pool->free_list); +if (device->attrs.device_cap_flags &IB_DEVICE_SG_GAPS_REG ) + mr_type =IB_MR_TYPE_SG_GAPS ; +else + mr_type =IB_MR_TYPE_MEM_REG ; +for (i =0 , d = &pool->desc[0 ]; i < pool->size; i++, d++) { - mr =ib_alloc_mr (pd,IB_MR_TYPE_MEM_REG , - max_page_list_len); + mr =ib_alloc_mr (pd, mr_type, max_page_list_len);if (IS_ERR (mr)) { ret =PTR_ERR (mr); goto destroy_pool;
Greg Kroah-Hartman
maintainerPATCH 32/66 IB/srp: fix invalid indirect_sg_entries parameter value
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Israel Rukshin <[email protected]>
commit 0a475ef4226e305bdcffe12b401ca1eab06c4913 upstream.
After setting indirect_sg_entries module_param to huge value (e.g 500,000), srp_alloc_req_data() fails to allocate indirect descriptors for the request ring (kmalloc fails). This commit enforces the maximum value of indirect_sg_entries to be SG_MAX_SEGMENTS as signified in module param description.
--- drivers/infiniband/ulp/srp/ib_srp.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/infiniband/ulp/srp/ib_srp.c +6 -0
@@ -3683,6 +3683,12 @@ static int __init srp_init_module(void) indirect_sg_entries = cmd_sg_entries; } +if (indirect_sg_entries >SG_MAX_SEGMENTS ) { +pr_warn ("Clamping indirect_sg_entries to %u\n" , +SG_MAX_SEGMENTS ); + indirect_sg_entries =SG_MAX_SEGMENTS ; + } + srp_remove_wq =create_workqueue ("srp_remove" );if (!srp_remove_wq) { ret = -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 34/66 can: ti_hecc: add missing prepare and unprepare of the clock
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yegor Yefremov <[email protected]>
commit befa60113ce7ea270cb51eada28443ca2756f480 upstream.
In order to make the driver work with the common clock framework, this patch converts the clk_enable()/clk_disable() to clk_prepare_enable()/clk_disable_unprepare().
Also add error checking for clk_prepare_enable().
--- drivers/net/can/ti_hecc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/net/can/ti_hecc.c +12 -4
@@ -948,7 +948,12 @@ static int ti_hecc_probe(struct platformnetif_napi_add (ndev, &priv->napi, ti_hecc_rx_poll,HECC_DEF_NAPI_WEIGHT ); -clk_enable (priv->clk); + err =clk_prepare_enable (priv->clk); +if (err) { +dev_err (&pdev->dev,"clk_prepare_enable() failed\n" ); + goto probe_exit_clk; + } + err =register_candev (ndev);if (err) {dev_err (&pdev->dev,"register_candev() failed\n" );
@@ -981,7 +986,7 @@ static int ti_hecc_remove(struct platforstruct ti_hecc_priv *priv =netdev_priv (ndev);unregister_candev (ndev); -clk_disable (priv->clk); +clk_disable_unprepare (priv->clk);clk_put (priv->clk); res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );iounmap (priv->base);
@@ -1006,7 +1011,7 @@ static int ti_hecc_suspend(struct platfohecc_set_bit (priv,HECC_CANMC ,HECC_CANMC_PDR ); priv->can.state =CAN_STATE_SLEEPING ; -clk_disable (priv->clk); +clk_disable_unprepare (priv->clk);return 0 ; }
@@ -1015,8 +1020,11 @@ static int ti_hecc_resume(struct platfor {struct net_device *dev =platform_get_drvdata (pdev);struct ti_hecc_priv *priv =netdev_priv (dev); +int err; -clk_enable (priv->clk); + err =clk_prepare_enable (priv->clk); +if (err) +return err;hecc_clear_bit (priv,HECC_CANMC ,HECC_CANMC_PDR ); priv->can.state =CAN_STATE_ERROR_ACTIVE ;
Greg Kroah-Hartman
maintainerPATCH 35/66 ARC: udelay: fix inline assembler by adding LP_COUNT to clobber list
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vineet Gupta <[email protected]>
commit 36425cd67052e3becf325fd4d3ba5691791ef7e4 upstream.
commit 3c7c7a2fc8811bc ("ARC: Don't use "+l" inline asm constraint") modified the inline assembly to setup LP_COUNT register manually and NOT rely on gcc to do it (with the +l inline assembler contraint hint, now being retired in the compiler)
However the fix was flawed as we didn't add LP_COUNT to asm clobber list, meaning gcc doesn't know that LP_COUNT or zero-delay-loops are in action in the inline asm.
This resulted in some fun - as nested ZOL loops were being generared
| mov lp_count,250000 ;16 # tmp235, | lp .L__GCC__LP14 # <======= OUTER LOOP (gcc generated) | .L14: | ld r2, [r5] # MEM[(volatile u32 *)prephitmp_43], w | dmb 1 | breq r2, -1, @.L21 #, w,, | bbit0 r2,1,@.L13 # w,, | ld r4,[r7] ;25 # loops_per_jiffy, loops_per_jiffy | mpymu r3,r4,r6 #, loops_per_jiffy, tmp234 | | mov lp_count, r3 # <====== INNER LOOP (from inline asm) | lp 1f | nop | 1: | nop_s | .L__GCC__LP14: ; loop end, start is @.L14 #,
This caused issues with drivers relying on sane behaviour of udelay friends.
With LP_COUNT added to clobber list, gcc doesn't generate the outer loop in say above case.
Addresses STAR 9001146134
--- arch/arc/include/asm/delay.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arc/include/asm/delay.h +3 -1
@@ -26,7 +26,9 @@ static inline void __delay(unsigned long " lp 1f \n" " nop \n" "1: \n" - : : "r"(loops)); + : + : "r"(loops) + : "lp_count"); }extern void __bad_udelay (void );
Greg Kroah-Hartman
maintainerPATCH 36/66 ARC: [arcompact] handle unaligned access delay slot corner case
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vineet Gupta <[email protected]>
commit 9aed02feae57bf7a40cb04ea0e3017cb7a998db4 upstream.
After emulating an unaligned access in delay slot of a branch, we pretend as the delay slot never happened - so return back to actual branch target (or next PC if branch was not taken).
Curently we did this by handling STATUS32.DE, we also need to clear the BTA.T bit, which is disregarded when returning from original misaligned exception, but could cause weirdness if it took the interrupt return path (in case interrupt was acive too)
One ARC700 customer ran into this when enabling unaligned access fixup for kernel mode accesses as well
--- arch/arc/kernel/unaligned.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arc/kernel/unaligned.c +2 -1
@@ -241,8 +241,9 @@ int misaligned_fixup(unsigned long addreif (state.fault) goto fault; +/* clear any remanants of delay slot */ if (delay_mode (regs)) { - regs->ret = regs->bta; + regs->ret = regs->bta ~1U; regs->status32 &= ~STATUS_DE_MASK ; }else { regs->ret += state.instr_len;
Greg Kroah-Hartman
maintainerPATCH 37/66 parisc: Dont use BITS_PER_LONG in userspace-exported swab.h header
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 2ad5d52d42810bed95100a3d912679d8864421ec upstream.
In swab.h the "#if BITS_PER_LONG > 32" breaks compiling userspace programs if BITS_PER_LONG is #defined by userspace with the sizeof() compiler builtin.
Solve this problem by using __BITS_PER_LONG instead. Since we now #include asm/bitsperlong.h avoid further potential userspace pollution by moving the #define of SHIFT_PER_LONG to bitops.h which is not exported to userspace.
This patch unbreaks compiling qemu on hppa/parisc.
--- arch/parisc/include/asm/bitops.h | 8 +++++++- arch/parisc/include/uapi/asm/bitsperlong.h | 2 -- arch/parisc/include/uapi/asm/swab.h | 5 +++-- 3 files changed, 10 insertions(+), 5 deletions(-)
arch/parisc/include/asm/bitops.h +7 -1
@@ -6,7 +6,7 @@#endif #include <linux/compiler.h> -#include <asm/types.h> /* for BITS_PER_LONG/SHIFT_PER_LONG */ +#include <asm/types.h> #include <asm/byteorder.h> #include <asm/barrier.h> #include <linux/atomic.h>
@@ -17,6 +17,12 @@* to include/asm-i386/bitops.h or kerneldoc */ +#if __BITS_PER_LONG ==64 +#define SHIFT_PER_LONG 6 +#else +#define SHIFT_PER_LONG 5 +#endif +#define CHOP_SHIFTCOUNT (x) (((unsigned long) (x)) & (BITS_PER_LONG - 1))
arch/parisc/include/uapi/asm/bitsperlong.h +0 -2
@@ -3,10 +3,8 @@#if defined(__LP64__)#define __BITS_PER_LONG 64 -#define SHIFT_PER_LONG 6#else #define __BITS_PER_LONG 32 -#define SHIFT_PER_LONG 5#endif #include <asm-generic/bitsperlong.h>
arch/parisc/include/uapi/asm/swab.h +3 -2
@@ -1,6 +1,7 @@#ifndef _PARISC_SWAB_H#define _PARISC_SWAB_H +#include <asm/bitsperlong.h> #include <linux/types.h> #include <linux/compiler.h>
@@ -38,7 +39,7 @@ static inline __attribute_const__ __u32 }#define __arch_swab32 __arch_swab32 -#if BITS_PER_LONG >32 +#if __BITS_PER_LONG >32 /* ** From "PA-RISC 2.0 Architecture", HP Professional Books. ** See Appendix I page 8 , "Endian Byte Swapping".
@@ -61,6 +62,6 @@ static inline __attribute_const__ __u64return x; }#define __arch_swab64 __arch_swab64 -#endif /* BITS_PER_LONG > 32 */ +#endif /* __BITS_PER_LONG > 32 */ #endif /* _PARISC_SWAB_H */
Greg Kroah-Hartman
maintainerPATCH 38/66 nfs: Dont increment lock sequence ID after NFS4ERR_MOVED
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
commit 059aa734824165507c65fd30a55ff000afd14983 upstream.
Xuan Qi reports that the Linux NFSv4 client failed to lock a file that was migrated. The steps he observed on the wire:
1. The client sent a LOCK request to the source server
2. The source server replied NFS4ERR_MOVED
3. The client switched to the destination server
4. The client sent the same LOCK request to the destination server with a bumped lock sequence ID
5. The destination server rejected the LOCK request with NFS4ERR_BAD_SEQID
RFC 3530 section 8.1.5 provides a list of NFS errors which do not bump a lock sequence ID.
However, RFC 3530 is now obsoleted by RFC 7530. In RFC 7530 section 9.1.7, this list has been updated by the addition of NFS4ERR_MOVED.
--- include/linux/nfs4.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/nfs4.h +2 -1
@@ -282,7 +282,7 @@ enum nfsstat4 {static inline bool seqid_mutating_err (u32 err) { -/* rfc 3530 section 8.1.5: */ +/* See RFC 7530, section 9.1.7 */ switch (err) {case NFS4ERR_STALE_CLIENTID :case NFS4ERR_STALE_STATEID :
@@ -291,6 +291,7 @@ static inline bool seqid_mutating_err(u3case NFS4ERR_BADXDR :case NFS4ERR_RESOURCE :case NFS4ERR_NOFILEHANDLE : +case NFS4ERR_MOVED :return false; };return true;
Greg Kroah-Hartman
maintainerPATCH 39/66 NFSv4.1: Fix a deadlock in layoutget
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit 8ac092519ad91931c96d306c4bfae2c6587c325f upstream.
We cannot call nfs4_handle_exception() without first ensuring that the slot has been freed. If not, we end up deadlocking with the process waiting for recovery to complete, and recovery waiting for the slot table to drain.
--- fs/nfs/nfs4proc.c | 1 + 1 file changed, 1 insertion(+)
fs/nfs/nfs4proc.c +1 -0
@@ -8371,6 +8371,7 @@ nfs4_layoutget_handle_exception(struct r goto out; } +nfs4_sequence_free_slot (&lgp->res.seq_res); err =nfs4_handle_exception (server, nfs4err, exception);if (!status) {if (exception->retry)
Greg Kroah-Hartman
maintainerPATCH 40/66 NFSv4.0: always send mode in SETATTR after EXCLUSIVE4
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Coddington <[email protected]>
commit a430607b2ef7c3be090f88c71cfcb1b3988aa7c0 upstream.
Some nfsv4.0 servers may return a mode for the verifier following an open with EXCLUSIVE4 createmode, but this does not mean the client should skip setting the mode in the following SETATTR. It should only do that for EXCLUSIVE4_1 or UNGAURDED createmode.
--- fs/nfs/nfs4proc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfs/nfs4proc.c +2 -1
@@ -2678,7 +2678,8 @@ static inline void nfs4_exclusive_attrse sattr->ia_valid |=ATTR_MTIME ;/* Except MODE, it seems harmless of setting twice. */ -if ((attrset[1 ] &FATTR4_WORD1_MODE )) +if (opendata->o_arg.createmode !=NFS4_CREATE_EXCLUSIVE && + attrset[1 ] &FATTR4_WORD1_MODE ) sattr->ia_valid &= ~ATTR_MODE ;if (attrset[2 ] &FATTR4_WORD2_SECURITY_LABEL )
Greg Kroah-Hartman
maintainerPATCH 41/66 SUNRPC: cleanup ida information when removing sunrpc module
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kinglong Mee <[email protected]>
commit c929ea0b910355e1876c64431f3d5802f95b3d75 upstream.
After removing sunrpc module, I get many kmemleak information as, unreferenced object 0xffff88003316b1e0 (size 544):
comm "gssproxy", pid 2148, jiffies 4294794465 (age 4200.081s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffffb0cfb58a>] kmemleak_alloc+0x4a/0xa0
[<ffffffffb03507fe>] kmem_cache_alloc+0x15e/0x1f0
[<ffffffffb0639baa>] ida_pre_get+0xaa/0x150
[<ffffffffb0639cfd>] ida_simple_get+0xad/0x180
[<ffffffffc06054fb>] nlmsvc_lookup_host+0x4ab/0x7f0 [lockd]
[<ffffffffc0605e1d>] lockd+0x4d/0x270 [lockd]
[<ffffffffc06061e5>] param_set_timeout+0x55/0x100 [lockd]
[<ffffffffc06cba24>] svc_defer+0x114/0x3f0 [sunrpc]
[<ffffffffc06cbbe7>] svc_defer+0x2d7/0x3f0 [sunrpc]
[<ffffffffc06c71da>] rpc_show_info+0x8a/0x110 [sunrpc]
[<ffffffffb044a33f>] proc_reg_write+0x7f/0xc0
[<ffffffffb038e41f>] __vfs_write+0xdf/0x3c0
[<ffffffffb0390f1f>] vfs_write+0xef/0x240
[<ffffffffb0392fbd>] SyS_write+0xad/0x130
[<ffffffffb0d06c37>] entry_SYSCALL_64_fastpath+0x1a/0xa9
[<ffffffffffffffff>] 0xffffffffffffffffI found, the ida information (dynamic memory) isn't cleanup.
--- include/linux/sunrpc/clnt.h | 1 + net/sunrpc/clnt.c | 5 +++++ net/sunrpc/sunrpc_syms.c | 1 + 3 files changed, 7 insertions(+)
include/linux/sunrpc/clnt.h +1 -0
@@ -216,5 +216,6 @@ void rpc_clnt_xprt_switch_put(struct rpcvoid rpc_clnt_xprt_switch_add_xprt (struct rpc_clnt *,struct rpc_xprt *);bool rpc_clnt_xprt_switch_has_addr (struct rpc_clnt *clnt,const struct sockaddr *sap); +void rpc_cleanup_clids (void );#endif /* __KERNEL__ */ #endif /* _LINUX_SUNRPC_CLNT_H */
net/sunrpc/clnt.c +5 -0
@@ -336,6 +336,11 @@ out:static DEFINE_IDA (rpc_clids); +void rpc_cleanup_clids (void ) +{ +ida_destroy (&rpc_clids); +} +static int rpc_alloc_clid (struct rpc_clnt *clnt) {int clid;
net/sunrpc/sunrpc_syms.c +1 -0
@@ -119,6 +119,7 @@ out: static void __exitcleanup_sunrpc (void ) { +rpc_cleanup_clids ();rpcauth_remove_module ();cleanup_socket_xprt ();svc_cleanup_xprt_sock ();
Greg Kroah-Hartman
maintainerPATCH 42/66 iw_cxgb4: free EQ queue memory on last deref
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve Wise <[email protected]>
commit c12a67fec8d99bb554e8d4e99120d418f1a39c87 upstream.
Commit ad61a4c7a9b7 ("iw_cxgb4: don't block in destroy_qp awaiting the last deref") introduced a bug where the RDMA QP EQ queue memory (and QIDs) are possibly freed before the underlying connection has been fully shutdown. The result being a possible DMA read issued by HW after the queue memory has been unmapped and freed. This results in possible WR corruption in the worst case, system bus errors if an IOMMU is in use, and SGE "bad WR" errors reported in the very least. The fix is to defer unmap/free of queue memory and QID resources until the QP struct has been fully dereferenced. To do this, the c4iw_ucontext must also be kept around until the last QP that references it is fully freed. In addition, since the last QP deref can happen in an IRQ disabled context, we need a new workqueue thread to do the final unmap/free of the EQ queue memory.
--- drivers/infiniband/hw/cxgb4/device.c | 9 ++++++++ drivers/infiniband/hw/cxgb4/iw_cxgb4.h | 18 ++++++++++++++++ drivers/infiniband/hw/cxgb4/provider.c | 20 +++++++++++++++--- drivers/infiniband/hw/cxgb4/qp.c | 35 ++++++++++++++++++++++++--------- 4 files changed, 69 insertions(+), 13 deletions(-)
drivers/infiniband/hw/cxgb4/device.c +9 -0
@@ -848,9 +848,17 @@ static int c4iw_rdev_open(struct c4iw_rd } } + rdev->free_workq =create_singlethread_workqueue ("iw_cxgb4_free" ); +if (!rdev->free_workq) { + err = -ENOMEM ; + goto err_free_status_page; + } + rdev->status_page->db_off =0 ;return 0 ; +err_free_status_page: +free_page ((unsigned long )rdev->status_page); destroy_ocqp_pool:c4iw_ocqp_pool_destroy (rdev); destroy_rqtpool:
@@ -864,6 +872,7 @@ destroy_resource:static void c4iw_rdev_close (struct c4iw_rdev *rdev) { +destroy_workqueue (rdev->free_workq);kfree (rdev->wr_log);free_page ((unsigned long )rdev->status_page);c4iw_pblpool_destroy (rdev);
drivers/infiniband/hw/cxgb4/iw_cxgb4.h +18 -0
@@ -45,6 +45,7 @@#include <linux/kref.h> #include <linux/timer.h> #include <linux/io.h> +#include <linux/workqueue.h> #include <asm/byteorder.h>
@@ -107,6 +108,7 @@ struct c4iw_dev_ucontext {struct list_head qpids;struct list_head cqids;struct mutex lock; +struct kref kref; };enum c4iw_rdev_flags {
@@ -183,6 +185,7 @@ struct c4iw_rdev {atomic_t wr_log_idx;struct wr_log_entry *wr_log;int wr_log_size; +struct workqueue_struct *free_workq; };static inline int c4iw_fatal_error (struct c4iw_rdev *rdev)
@@ -482,6 +485,8 @@ struct c4iw_qp {int sq_sig_all;struct completion rq_drained;struct completion sq_drained; +struct work_struct free_work; +struct c4iw_ucontext *ucontext; };static inline struct c4iw_qp *to_c4iw_qp (struct ib_qp *ibqp)
@@ -495,6 +500,7 @@ struct c4iw_ucontext {u32 key;spinlock_t mmap_lock;struct list_head mmaps; +struct kref kref; };static inline struct c4iw_ucontext *to_c4iw_ucontext (struct ib_ucontext *c)
@@ -502,6 +508,18 @@ static inline struct c4iw_ucontext *to_c return container_of(c, struct c4iw_ucontext, ibucontext); } +void _c4iw_free_ucontext (struct kref *kref); + +static inline void c4iw_put_ucontext (struct c4iw_ucontext *ucontext) +{ +kref_put (&ucontext->kref, _c4iw_free_ucontext); +} + +static inline void c4iw_get_ucontext (struct c4iw_ucontext *ucontext) +{ +kref_get (&ucontext->kref); +} +struct c4iw_mm_entry {struct list_head entry;u64 addr;
drivers/infiniband/hw/cxgb4/provider.c +16 -4
@@ -91,17 +91,28 @@ static int c4iw_process_mad(struct ib_dereturn -ENOSYS ; } -static int c4iw_dealloc_ucontext (struct ib_ucontext *context) +void _c4iw_free_ucontext (struct kref *kref) { -struct c4iw_dev *rhp =to_c4iw_dev (context->device); -struct c4iw_ucontext *ucontext =to_c4iw_ucontext (context); +struct c4iw_ucontext *ucontext; +struct c4iw_dev *rhp;struct c4iw_mm_entry *mm, *tmp; -PDBG ("%s context %p\n" , __func__, context); + ucontext = container_of(kref, struct c4iw_ucontext, kref); + rhp =to_c4iw_dev (ucontext->ibucontext.device); + +PDBG ("%s ucontext %p\n" , __func__, ucontext);list_for_each_entry_safe (mm, tmp, &ucontext->mmaps, entry)kfree (mm);c4iw_release_dev_ucontext (&rhp->rdev, &ucontext->uctx);kfree (ucontext); +} + +static int c4iw_dealloc_ucontext (struct ib_ucontext *context) +{ +struct c4iw_ucontext *ucontext =to_c4iw_ucontext (context); + +PDBG ("%s context %p\n" , __func__, context); +c4iw_put_ucontext (ucontext);return 0 ; }
@@ -125,6 +136,7 @@ static struct ib_ucontext *c4iw_alloc_ucc4iw_init_dev_ucontext (&rhp->rdev, &context->uctx);INIT_LIST_HEAD (&context->mmaps);spin_lock_init (&context->mmap_lock); +kref_init (&context->kref);if (udata->outlen <sizeof (uresp) -sizeof (uresp.reserved)) {if (!warned++)
drivers/infiniband/hw/cxgb4/qp.c +26 -9
@@ -714,13 +714,32 @@ static int build_inv_stag(union t4_wr *wreturn 0 ; } -static void _free_qp (struct kref *kref) +static void free_qp_work (struct work_struct *work) +{ +struct c4iw_ucontext *ucontext; +struct c4iw_qp *qhp; +struct c4iw_dev *rhp; + + qhp = container_of(work, struct c4iw_qp, free_work); + ucontext = qhp->ucontext; + rhp = qhp->rhp; + +PDBG ("%s qhp %p ucontext %p\n" , __func__, qhp, ucontext); +destroy_qp (&rhp->rdev, &qhp->wq, + ucontext ? &ucontext->uctx : &rhp->rdev.uctx); + +if (ucontext) +c4iw_put_ucontext (ucontext); +kfree (qhp); +} + +static void queue_qp_free (struct kref *kref) {struct c4iw_qp *qhp; qhp = container_of(kref, struct c4iw_qp, kref);PDBG ("%s qhp %p\n" , __func__, qhp); -kfree (qhp); +queue_work (qhp->rhp->rdev.free_workq, &qhp->free_work); }void c4iw_qp_add_ref (struct ib_qp *qp)
@@ -732,7 +751,7 @@ void c4iw_qp_add_ref(struct ib_qp *qp)void c4iw_qp_rem_ref (struct ib_qp *qp) {PDBG ("%s ib_qp %p\n" , __func__, qp); -kref_put (&to_c4iw_qp (qp)->kref, _free_qp); +kref_put (&to_c4iw_qp (qp)->kref, queue_qp_free); }static void add_to_fc_list (struct list_head *head,struct list_head *entry)
@@ -1642,7 +1661,6 @@ int c4iw_destroy_qp(struct ib_qp *ib_qp)struct c4iw_dev *rhp;struct c4iw_qp *qhp;struct c4iw_qp_attributes attrs; -struct c4iw_ucontext *ucontext; qhp =to_c4iw_qp (ib_qp); rhp = qhp->rhp;
@@ -1662,11 +1680,6 @@ int c4iw_destroy_qp(struct ib_qp *ib_qp)spin_unlock_irq (&rhp->lock);free_ird (rhp, qhp->attr.max_ird); - ucontext = ib_qp->uobject ? -to_c4iw_ucontext (ib_qp->uobject->context) :NULL ; -destroy_qp (&rhp->rdev, &qhp->wq, - ucontext ? &ucontext->uctx : &rhp->rdev.uctx); -c4iw_qp_rem_ref (ib_qp);PDBG ("%s ib_qp %p qpid 0x%0x\n" , __func__, ib_qp, qhp->wq.sq.qid);
@@ -1767,6 +1780,7 @@ struct ib_qp *c4iw_create_qp(struct ib_pmutex_init (&qhp->mutex);init_waitqueue_head (&qhp->wait);kref_init (&qhp->kref); +INIT_WORK (&qhp->free_work, free_qp_work); ret =insert_handle (rhp, &rhp->qpidr, qhp, qhp->wq.sq.qid);if (ret)
@@ -1853,6 +1867,9 @@ struct ib_qp *c4iw_create_qp(struct ib_p ma_sync_key_mm->len =PAGE_SIZE ;insert_mmap (ucontext, ma_sync_key_mm); } + +c4iw_get_ucontext (ucontext); + qhp->ucontext = ucontext; } qhp->ibqp.qp_num = qhp->wq.sq.qid;init_timer (&(qhp->timer));
Greg Kroah-Hartman
maintainerPATCH 43/66 pctv452e: move buffer to heap, no mutex
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Kellermann <[email protected]>
commit 48775cb73c2e26b7ca9d679875a6e570c8b8e124 upstream.
commit 73d5c5c864f4 ("[media] pctv452e: don't do DMA on stack") caused a NULL pointer dereference which occurs when dvb_usb_init() calls dvb_usb_device_power_ctrl() for the first time, before the frontend has been attached. It also caused a recursive deadlock because tt3650_ci_msg_locked() has already locked the mutex.
So, partially revert it, but move the buffer to the heap (DMA capable), not to the stack (may not be DMA capable). Instead of sharing one buffer which needs mutex protection, do a new heap allocation for each call.
--- drivers/media/usb/dvb-usb/pctv452e.c | 133 ++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 61 deletions(-)
drivers/media/usb/dvb-usb/pctv452e.c +72 -61
@@ -97,14 +97,13 @@ struct pctv452e_state {u8 c;/* transaction counter, wraps around... */ u8 initialized;/* set to 1 if 0x15 has been sent */ u16 last_rc_key; - -unsigned char data[80 ]; };static int tt3650_ci_msg (struct dvb_usb_device *d,u8 cmd,u8 *data,unsigned int write_len,unsigned int read_len) {struct pctv452e_state *state = (struct pctv452e_state *)d->priv; +u8 *buf;u8 id;unsigned int rlen;int ret;
@@ -114,36 +113,39 @@ static int tt3650_ci_msg(struct dvb_usb_return -EIO ; } -mutex_lock (&state->ca_mutex); + buf =kmalloc (64 ,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + id = state->c++; - state->data[0 ] =SYNC_BYTE_OUT ; - state->data[1 ] = id; - state->data[2 ] = cmd; - state->data[3 ] = write_len; + buf[0 ] =SYNC_BYTE_OUT ; + buf[1 ] = id; + buf[2 ] = cmd; + buf[3 ] = write_len; -memcpy (state->data +4 , data, write_len); +memcpy (buf +4 , data, write_len); rlen = (read_len >0 ) ?64 :0 ; - ret =dvb_usb_generic_rw (d, state->data,4 + write_len, - state->data, rlen,/* delay_ms */ 0 ); + ret =dvb_usb_generic_rw (d, buf,4 + write_len, + buf, rlen,/* delay_ms */ 0 );if (0 != ret) goto failed; ret = -EIO ; -if (SYNC_BYTE_IN != state->data[0 ] || id != state->data[1 ]) +if (SYNC_BYTE_IN != buf[0 ] || id != buf[1 ]) goto failed; -memcpy (data, state->data +4 , read_len); +memcpy (data, buf +4 , read_len); -mutex_unlock (&state->ca_mutex); +kfree (buf);return 0 ; failed:err ("CI error %d; %02X %02X %02X -> %*ph." , - ret,SYNC_BYTE_OUT , id, cmd,3 , state->data); + ret,SYNC_BYTE_OUT , id, cmd,3 , buf); -mutex_unlock (&state->ca_mutex); +kfree (buf);return ret; }
@@ -410,53 +412,57 @@ static int pctv452e_i2c_msg(struct dvb_u u8 *rcv_buf, u8 rcv_len) {struct pctv452e_state *state = (struct pctv452e_state *)d->priv; +u8 *buf;u8 id;int ret; -mutex_lock (&state->ca_mutex); + buf =kmalloc (64 ,GFP_KERNEL ); +if (!buf) +return -ENOMEM ; + id = state->c++; ret = -EINVAL ;if (snd_len >64 -7 || rcv_len >64 -7 ) goto failed; - state->data[0 ] =SYNC_BYTE_OUT ; - state->data[1 ] = id; - state->data[2 ] =PCTV_CMD_I2C ; - state->data[3 ] = snd_len +3 ; - state->data[4 ] = addr <<1 ; - state->data[5 ] = snd_len; - state->data[6 ] = rcv_len; + buf[0 ] =SYNC_BYTE_OUT ; + buf[1 ] = id; + buf[2 ] =PCTV_CMD_I2C ; + buf[3 ] = snd_len +3 ; + buf[4 ] = addr <<1 ; + buf[5 ] = snd_len; + buf[6 ] = rcv_len; -memcpy (state->data +7 , snd_buf, snd_len); +memcpy (buf +7 , snd_buf, snd_len); - ret =dvb_usb_generic_rw (d, state->data,7 + snd_len, - state->data,/* rcv_len */ 64 , + ret =dvb_usb_generic_rw (d, buf,7 + snd_len, + buf,/* rcv_len */ 64 ,/* delay_ms */ 0 );if (ret <0 ) goto failed;/* TT USB protocol error. */ ret = -EIO ; -if (SYNC_BYTE_IN != state->data[0 ] || id != state->data[1 ]) +if (SYNC_BYTE_IN != buf[0 ] || id != buf[1 ]) goto failed;/* I2C device didn't respond as expected. */ ret = -EREMOTEIO ; -if (state->data[5 ] < snd_len || state->data[6 ] < rcv_len) +if (buf[5 ] < snd_len || buf[6 ] < rcv_len) goto failed; -memcpy (rcv_buf, state->data +7 , rcv_len); -mutex_unlock (&state->ca_mutex); +memcpy (rcv_buf, buf +7 , rcv_len); +kfree (buf);return rcv_len; failed:err ("I2C error %d; %02X %02X %02X %02X %02X -> %*ph" , ret,SYNC_BYTE_OUT , id, addr <<1 , snd_len, rcv_len, -7 , state->data); +7 , buf); -mutex_unlock (&state->ca_mutex); +kfree (buf);return ret; }
@@ -505,7 +511,7 @@ static u32 pctv452e_i2c_func(struct i2c_static int pctv452e_power_ctrl (struct dvb_usb_device *d,int i) {struct pctv452e_state *state = (struct pctv452e_state *)d->priv; -u8 *rx; +u8 *b0, *rx;int ret;info ("%s: %d\n" , __func__, i);
@@ -516,11 +522,12 @@ static int pctv452e_power_ctrl(struct dvif (state->initialized)return 0 ; - rx =kmalloc (PCTV_ANSWER_LEN ,GFP_KERNEL ); -if (!rx) + b0 =kmalloc (5 +PCTV_ANSWER_LEN ,GFP_KERNEL ); +if (!b0)return -ENOMEM ; -mutex_lock (&state->ca_mutex); + rx = b0 +5 ; +/* hmm where shoud this should go? */ ret =usb_set_interface (d->udev,0 ,ISOC_INTERFACE_ALTERNATIVE );if (ret !=0 )
@@ -528,66 +535,70 @@ static int pctv452e_power_ctrl(struct dv __func__, ret);/* this is a one-time initialization, dont know where to put */ - state->data[0 ] =0xaa ; - state->data[1 ] = state->c++; - state->data[2 ] =PCTV_CMD_RESET ; - state->data[3 ] =1 ; - state->data[4 ] =0 ; + b0[0 ] =0xaa ; + b0[1 ] = state->c++; + b0[2 ] =PCTV_CMD_RESET ; + b0[3 ] =1 ; + b0[4 ] =0 ;/* reset board */ - ret =dvb_usb_generic_rw (d, state->data,5 , rx,PCTV_ANSWER_LEN ,0 ); + ret =dvb_usb_generic_rw (d, b0,5 , rx,PCTV_ANSWER_LEN ,0 );if (ret) goto ret; - state->data[1 ] = state->c++; - state->data[4 ] =1 ; + b0[1 ] = state->c++; + b0[4 ] =1 ;/* reset board (again?) */ - ret =dvb_usb_generic_rw (d, state->data,5 , rx,PCTV_ANSWER_LEN ,0 ); + ret =dvb_usb_generic_rw (d, b0,5 , rx,PCTV_ANSWER_LEN ,0 );if (ret) goto ret; state->initialized =1 ; ret: -mutex_unlock (&state->ca_mutex); -kfree (rx); +kfree (b0);return ret; }static int pctv452e_rc_query (struct dvb_usb_device *d) {struct pctv452e_state *state = (struct pctv452e_state *)d->priv; +u8 *b, *rx;int ret, i;u8 id; -mutex_lock (&state->ca_mutex); + b =kmalloc (CMD_BUFFER_SIZE +PCTV_ANSWER_LEN ,GFP_KERNEL ); +if (!b) +return -ENOMEM ; + + rx = b +CMD_BUFFER_SIZE ; + id = state->c++;/* prepare command header */ - state->data[0 ] =SYNC_BYTE_OUT ; - state->data[1 ] = id; - state->data[2 ] =PCTV_CMD_IR ; - state->data[3 ] =0 ; + b[0 ] =SYNC_BYTE_OUT ; + b[1 ] = id; + b[2 ] =PCTV_CMD_IR ; + b[3 ] =0 ;/* send ir request */ - ret =dvb_usb_generic_rw (d, state->data,4 , - state->data,PCTV_ANSWER_LEN ,0 ); + ret =dvb_usb_generic_rw (d, b,4 , rx,PCTV_ANSWER_LEN ,0 );if (ret !=0 ) goto ret;if (debug >3 ) { -info ("%s: read: %2d: %*ph: " , __func__, ret,3 , state->data); -for (i =0 ; (i < state->data[3 ]) && ((i +3 ) <PCTV_ANSWER_LEN ); i++) -info (" %02x" , state->data[i +3 ]); +info ("%s: read: %2d: %*ph: " , __func__, ret,3 , rx); +for (i =0 ; (i < rx[3 ]) && ((i+3 ) <PCTV_ANSWER_LEN ); i++) +info (" %02x" , rx[i+3 ]);info ("\n" ); } -if ((state->data[3 ] ==9 ) && (state->data[12 ] &0x01 )) { +if ((rx[3 ] ==9 ) && (rx[12 ] &0x01 )) {/* got a "press" event */ - state->last_rc_key =RC_SCANCODE_RC5 (state->data[7 ], state->data[6 ]); + state->last_rc_key =RC_SCANCODE_RC5 (rx[7 ], rx[6 ]);if (debug >2 )info ("%s: cmd=0x%02x sys=0x%02x\n" , - __func__, state->data[6 ], state->data[7 ]); + __func__, rx[6 ], rx[7 ]);rc_keydown (d->rc_dev,RC_TYPE_RC5 , state->last_rc_key,0 ); }else if (state->last_rc_key) {
@@ -595,7 +606,7 @@ static int pctv452e_rc_query(struct dvb_ state->last_rc_key =0 ; } ret: -mutex_unlock (&state->ca_mutex); +kfree (b);return ret; }
Greg Kroah-Hartman
maintainerPATCH 44/66 v4l: tvp5150: Reset device at probe time, not in get/set format handlers
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurent Pinchart <[email protected]>
commit aff808e813fc2d311137754165cf53d4ee6ddcc2 upstream.
The tvp5150 doesn't support format setting through the subdev pad API and thus implements the set format handler as a get format operation. The single handler, tvp5150_fill_fmt(), resets the device by calling tvp5150_reset(). This causes malfunction as the device can be reset at will, possibly from userspace when the subdev userspace API is enabled.
The reset call was added in commit ec2c4f3f93cb ("[media] media:
tvp5150: Add mbus_fmt callbacks"), probably as an attempt to set the device to a known state before detecting the current TV standard. However, the get format handler doesn't access the hardware to get the TV standard since commit 963ddc63e20d ("[media] media: tvp5150: Add cropping support"). There is thus no need to reset the device when getting the format.
However, removing the tvp5150_reset() from the get/set format handlers results in the function not being called at all if the bridge driver doesn't use the .reset() operation. The operation is nowadays abused and shouldn't be used, so shouldn't expect bridge drivers to call it. To make sure the device is properly initialize, move the reset call from the format handlers to the probe function.
--- drivers/media/i2c/tvp5150.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/media/i2c/tvp5150.c +2 -3
@@ -858,8 +858,6 @@ static int tvp5150_fill_fmt(struct v4l2_ f = &format->format; -tvp5150_reset (sd,0 ); - f->width = decoder->rect.width; f->height = decoder->rect.height /2 ;
@@ -1521,7 +1519,6 @@ static int tvp5150_probe(struct i2c_clie res = core->hdl.error; goto err; } -v4l2_ctrl_handler_setup (&core->hdl);/* Default is no cropping */ core->rect.top =0 ;
@@ -1532,6 +1529,8 @@ static int tvp5150_probe(struct i2c_clie core->rect.left =0 ; core->rect.width =TVP5150_H_MAX ; +tvp5150_reset (sd,0 );/* Calls v4l2_ctrl_handler_setup() */ + res =v4l2_async_register_subdev (sd);if (res <0 ) goto err;
Greg Kroah-Hartman
maintainerPATCH 45/66 v4l: tvp5150: Fix comment regarding output pin muxing
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurent Pinchart <[email protected]>
commit b4b2de386bbb6589d81596999d4a924928dc119b upstream.
The FID/GLCO/VLK/HVLK and INTREQ/GPCL/VBLK pins are muxed differently depending on whether the input is an S-Video or composite signal. The comment that explains the logic doesn't reflect the code. It appears that the comment is incorrect, as disabling the output data bus in composite mode makes no sense. Update the comment to match the code.
While at it define macros for the MISC_CTL register bits, the code is too confusing with numerical values.
--- drivers/media/i2c/tvp5150.c | 24 +++++++++++++++++------- drivers/media/i2c/tvp5150_reg.h | 9 +++++++++ 2 files changed, 26 insertions(+), 7 deletions(-)
drivers/media/i2c/tvp5150.c +17 -7
@@ -288,8 +288,12 @@ static inline void tvp5150_selmux(structtvp5150_write (sd,TVP5150_OP_MODE_CTL , opmode);tvp5150_write (sd,TVP5150_VD_IN_SRC_SEL_1 , input); -/* Svideo should enable YCrCb output and disable GPCL output -* For Composite and TV, it should be the reverse +/* +* Setup the FID/GLCO/VLK/HVLK and INTREQ/GPCL/VBLK output signals. For +* S-Video we output the vertical lock (VLK) signal on FID/GLCO/VLK/HVLK +* and set INTREQ/GPCL/VBLK to logic 0. For composite we output the +* field indicator (FID) signal on FID/GLCO/VLK/HVLK and set +* INTREQ/GPCL/VBLK to logic 1. */ val =tvp5150_read (sd,TVP5150_MISC_CTL );if (val <0 ) {
@@ -298,9 +302,9 @@ static inline void tvp5150_selmux(struct }if (decoder->input ==TVP5150_SVIDEO ) - val = (val & ~0x40 ) |0x10 ; + val = (val & ~TVP5150_MISC_CTL_GPCL ) |TVP5150_MISC_CTL_HVLK ;else - val = (val & ~0x10 ) |0x40 ; + val = (val & ~TVP5150_MISC_CTL_HVLK ) |TVP5150_MISC_CTL_GPCL ;tvp5150_write (sd,TVP5150_MISC_CTL , val); };
@@ -452,7 +456,12 @@ static const struct i2c_reg_value tvp515 },{ /* Automatic offset and AGC enabled */TVP5150_ANAL_CHL_CTL ,0x15 },{ /* Activate YCrCb output 0x9 or 0xd ? */ -TVP5150_MISC_CTL ,0x6f +TVP5150_MISC_CTL ,TVP5150_MISC_CTL_GPCL | +TVP5150_MISC_CTL_INTREQ_OE | +TVP5150_MISC_CTL_YCBCR_OE | +TVP5150_MISC_CTL_SYNC_OE | +TVP5150_MISC_CTL_VBLANK | +TVP5150_MISC_CTL_CLOCK_OE , },{ /* Activates video std autodetection for all standards */TVP5150_AUTOSW_MSK ,0x0 },{ /* Default format: 0x47. For 4:2:2: 0x40 */
@@ -1047,11 +1056,12 @@ static int tvp5150_s_stream(struct v4l2_ {struct tvp5150 *decoder =to_tvp5150 (sd);/* Output format: 8-bit ITU-R BT.656 with embedded syncs */ -int val =0x09 ; +int val =TVP5150_MISC_CTL_YCBCR_OE |TVP5150_MISC_CTL_CLOCK_OE ;/* Output format: 8-bit 4:2:2 YUV with discrete sync */ if (decoder->mbus_type ==V4L2_MBUS_PARALLEL ) - val =0x0d ; + val =TVP5150_MISC_CTL_YCBCR_OE |TVP5150_MISC_CTL_SYNC_OE + |TVP5150_MISC_CTL_CLOCK_OE ;/* Initializes TVP5150 to its default values */ /* # set PCLK (27MHz) */
drivers/media/i2c/tvp5150_reg.h +9 -0
@@ -9,6 +9,15 @@#define TVP5150_ANAL_CHL_CTL 0x01/* Analog channel controls */ #define TVP5150_OP_MODE_CTL 0x02/* Operation mode controls */ #define TVP5150_MISC_CTL 0x03/* Miscellaneous controls */ +#define TVP5150_MISC_CTL_VBLK_GPCL BIT(7) +#define TVP5150_MISC_CTL_GPCL BIT(6) +#define TVP5150_MISC_CTL_INTREQ_OE BIT(5) +#define TVP5150_MISC_CTL_HVLK BIT(4) +#define TVP5150_MISC_CTL_YCBCR_OE BIT(3) +#define TVP5150_MISC_CTL_SYNC_OE BIT(2) +#define TVP5150_MISC_CTL_VBLANK BIT(1) +#define TVP5150_MISC_CTL_CLOCK_OE BIT(0) +#define TVP5150_AUTOSW_MSK 0x04/* Autoswitch mask: TVP5150A / TVP5150AM */ /* Reserved 05h */
Greg Kroah-Hartman
maintainerPATCH 46/66 v4l: tvp5150: Dont override output pinmuxing at stream on/off time
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurent Pinchart <[email protected]>
commit 79d6205a3f741c9fb89cfc47dfa0eddb1526726d upstream.
The s_stream() handler incorrectly writes the whole MISC_CTL register to enable or disable the outputs, overriding the output pinmuxing configuration. Fix it to only touch the output enable bits.
The CONF_SHARED_PIN register is also written by the same function, resulting in muxing the INTREQ signal instead of the VBLK/GPCL signal on the INTREQ/GPCL/VBLK pin. As the driver doesn't support interrupts this is obviously incorrect, and breaks operation on other devices. Fix it by removing the write.
--- drivers/media/i2c/tvp5150.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-)
drivers/media/i2c/tvp5150.c +18 -13
@@ -1055,22 +1055,27 @@ static const struct media_entity_operatistatic int tvp5150_s_stream (struct v4l2_subdev *sd,int enable) {struct tvp5150 *decoder =to_tvp5150 (sd); -/* Output format: 8-bit ITU-R BT.656 with embedded syncs */ -int val =TVP5150_MISC_CTL_YCBCR_OE |TVP5150_MISC_CTL_CLOCK_OE ; +int val; -/* Output format: 8-bit 4:2:2 YUV with discrete sync */ -if (decoder->mbus_type ==V4L2_MBUS_PARALLEL ) - val =TVP5150_MISC_CTL_YCBCR_OE |TVP5150_MISC_CTL_SYNC_OE - |TVP5150_MISC_CTL_CLOCK_OE ; +/* Enable or disable the video output signals. */ + val =tvp5150_read (sd,TVP5150_MISC_CTL ); +if (val <0 ) +return val; -/* Initializes TVP5150 to its default values */ -/* # set PCLK (27MHz) */ -tvp5150_write (sd,TVP5150_CONF_SHARED_PIN ,0x00 ); + val &= ~(TVP5150_MISC_CTL_YCBCR_OE |TVP5150_MISC_CTL_SYNC_OE | +TVP5150_MISC_CTL_CLOCK_OE ); -if (enable) -tvp5150_write (sd,TVP5150_MISC_CTL , val); -else -tvp5150_write (sd,TVP5150_MISC_CTL ,0x00 ); +if (enable) { +/* +* Enable the YCbCr and clock outputs. In discrete sync mode +* (non-BT.656) additionally enable the the sync outputs. +*/ + val |=TVP5150_MISC_CTL_YCBCR_OE |TVP5150_MISC_CTL_CLOCK_OE ; +if (decoder->mbus_type ==V4L2_MBUS_PARALLEL ) + val |=TVP5150_MISC_CTL_SYNC_OE ; + } + +tvp5150_write (sd,TVP5150_MISC_CTL , val);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 47/66 drm/i915: Clear ret before unbinding in i915_gem_evict_something()
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Wilson <[email protected]>
commit e88893fea17996018b2d68a22e677ea04f3baadf upstream.
Missed when rebasing patches, I failed to set ret to zero before starting the unbind loop (which depends upon ret being zero).
--- drivers/gpu/drm/i915/i915_gem_evict.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/i915_gem_evict.c +1 -0
@@ -194,6 +194,7 @@ found: }/* Unbinding will emit any required flushes */ + ret =0 ;while (!list_empty (&eviction_list)) { vma = list_first_entry(&eviction_list, struct i915_vma,
Greg Kroah-Hartman
maintainerPATCH 48/66 drm/i915: prevent crash with .disable_display parameter
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Clint Taylor <[email protected]>
commit 27892bbdc9233f33bf0f44e08aab8f12e0dec142 upstream.
The .disable_display parameter was causing a fatal crash when fbdev was dereferenced during driver init.
V1: protection in i915_drv.c
V2: Moved protection to intel_fbdev.c
Testcase: igt/drv_module_reload/basic-no-display
--- drivers/gpu/drm/i915/intel_fbdev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/i915/intel_fbdev.c +3 -0
@@ -745,6 +745,9 @@ void intel_fbdev_initial_config_async(st {struct intel_fbdev *ifbdev =to_i915 (dev)->fbdev; +if (!ifbdev) +return ; + ifbdev->cookie =async_schedule (intel_fbdev_initial_config, ifbdev); }
Greg Kroah-Hartman
maintainerPATCH 49/66 drm/i915: Dont leak edid in intel_crt_detect_ddc()
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ander Conselvan de Oliveira <[email protected]>
commit c34f078675f505c4437919bb1897b1351f16a050 upstream.
In the path where intel_crt_detect_ddc() detects a CRT, if would return true without freeing the edid.
--- drivers/gpu/drm/i915/intel_crt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_crt.c +5 -4
@@ -499,6 +499,7 @@ static bool intel_crt_detect_ddc(structstruct drm_i915_private *dev_priv =to_i915 (crt->base.base.dev);struct edid *edid;struct i2c_adapter *i2c; +bool ret = false;BUG_ON (crt->base.type !=INTEL_OUTPUT_ANALOG );
@@ -515,17 +516,17 @@ static bool intel_crt_detect_ddc(struct*/ if (!is_digital) {DRM_DEBUG_KMS ("CRT detected via DDC:0x50 [EDID]\n" ); -return true; + ret = true; + }else { +DRM_DEBUG_KMS ("CRT not detected via DDC:0x50 [EDID reports a digital panel]\n" ); } - -DRM_DEBUG_KMS ("CRT not detected via DDC:0x50 [EDID reports a digital panel]\n" ); }else {DRM_DEBUG_KMS ("CRT not detected via DDC:0x50 [no valid EDID found]\n" ); }kfree (edid); -return false; +return ret; } static enum drm_connector_status
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Greg Kroah-Hartman
maintainerPATCH 50/66 drm/i915: Dont init hpd polling for vlv and chv from runtime_suspend()
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ander Conselvan de Oliveira <[email protected]>
commit 21d6e0bde50713922a6520ef84e5fd245b05d468 upstream.
An error in the condition for avoiding the call to intel_hpd_poll_init() for valleyview and cherryview from intel_runtime_suspend() caused it to be called unconditionally. Fix it.
--- drivers/gpu/drm/i915/i915_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.c +1 -1
@@ -2372,7 +2372,7 @@ static int intel_runtime_suspend(structassert_forcewakes_inactive (dev_priv); -if (!IS_VALLEYVIEW (dev_priv) || !IS_CHERRYVIEW (dev_priv)) +if (!IS_VALLEYVIEW (dev_priv) && !IS_CHERRYVIEW (dev_priv))intel_hpd_poll_init (dev_priv);DRM_DEBUG_KMS ("Device suspended\n" );
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Greg Kroah-Hartman
maintainerPATCH 51/66 drm/i915: Fix calculation of rotated x and y offsets for planar formats
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ander Conselvan de Oliveira <[email protected]>
commit 3781bd6e7d64d5f5bea9fdee11ab9460a700c0e4 upstream.
Parameters tile_size, tile_width and tile_height were passed in the wrong order to _intel_adjust_tile_offset() when calculating the rotated offsets.
This doesn't fix any user visible bug, since for packed formats new and old offset are the same and the rotated offsets are within a tile before they are fed to _intel_adjust_tile_offset(). In that case, the offsets are unchanged. That is not true for planar formats, but those are currently not supported.
--- drivers/gpu/drm/i915/intel_display.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -2
@@ -2587,8 +2587,9 @@ intel_fill_fb_info(struct drm_i915_priva* We only keep the x/y offsets, so push all of the * gtt offset into the x/y offsets. */ -_intel_adjust_tile_offset (&x, &y, tile_size, - tile_width, tile_height, pitch_tiles, +_intel_adjust_tile_offset (&x, &y, + tile_width, tile_height, + tile_size, pitch_tiles, gtt_offset_rotated * tile_size,0 ); gtt_offset_rotated += rot_info->plane[i].width * rot_info->plane[i].height;
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Greg Kroah-Hartman
maintainerPATCH 52/66 drm/i915: Check for NULL atomic state in intel_crtc_disable_noatomic()
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ander Conselvan de Oliveira <[email protected]>
commit 6d1d427a4e24c403b4adf928d61994bdaa0ca03a upstream.
In intel_crtc_disable_noatomic(), bail on a failure to allocate an atomic state to avoid a NULL pointer dereference.
--- drivers/gpu/drm/i915/intel_display.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_display.c +6 -0
@@ -6869,6 +6869,12 @@ static void intel_crtc_disable_noatomic( } state =drm_atomic_state_alloc (crtc->dev); +if (!state) { +DRM_DEBUG_KMS ("failed to disable [CRTC:%d:%s], out of memory" , + crtc->base.id, crtc->name); +return ; + } + state->acquire_ctx = crtc->dev->mode_config.acquire_ctx;/* Everything's already locked, -EDEADLK can't happen. */
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Greg Kroah-Hartman
maintainerPATCH 53/66 IB/umem: Release pid in error and ODP flow
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kenneth Lee <[email protected]>
commit 828f6fa65ce7e80f77f5ab12942e44eb3d9d174e upstream.
1. Release pid before enter odp flow
2. Release pid when fail to allocate memory
--- drivers/infiniband/core/umem.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/core/umem.c +2 -0
@@ -134,6 +134,7 @@ struct ib_umem *ib_umem_get(struct ib_uc IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_MW_BIND));if (access &IB_ACCESS_ON_DEMAND ) { +put_pid (umem->pid); ret =ib_umem_odp_get (context, umem);if (ret) {kfree (umem);
@@ -149,6 +150,7 @@ struct ib_umem *ib_umem_get(struct ib_uc page_list = (struct page **)__get_free_page (GFP_KERNEL );if (!page_list) { +put_pid (umem->pid);kfree (umem);return ERR_PTR (-ENOMEM ); }
Greg Kroah-Hartman
maintainerPATCH 54/66 IB/rxe: Fix rxe dev insertion to rxe_dev_list
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maor Gottlieb <[email protected]>
commit f39f775218a7520e3700de2003c84a042c3b5972 upstream.
The first argument of list_add_tail is the new item and the second is the head of the list. Fix the code to pass arguments in the right order, otherwise not all the rxe devices will be removed during teardown.
--- drivers/infiniband/sw/rxe/rxe_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_net.c +1 -1
@@ -554,7 +554,7 @@ struct rxe_dev *rxe_net_add(struct net_d }spin_lock_bh (&dev_list_lock); -list_add_tail (&rxe_dev_list, &rxe->list); +list_add_tail (&rxe->list, &rxe_dev_list);spin_unlock_bh (&dev_list_lock);return rxe; }
Greg Kroah-Hartman
maintainerPATCH 55/66 IB/rxe: Prevent from completer to operate on non valid QP
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yonatan Cohen <[email protected]>
commit 2d4b21e0a2913612274a69a3ba1bfee4cffc6e77 upstream.
On UD QP completer tasklet is scheduled for each packet sent.
If it is followed by a destroy_qp(), the kernel panic will happen as the completer tries to operate on a destroyed QP.
--- drivers/infiniband/sw/rxe/rxe_qp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/sw/rxe/rxe_qp.c +1 -2
@@ -813,8 +813,7 @@ void rxe_qp_destroy(struct rxe_qp *qp)del_timer_sync (&qp->rnr_nak_timer);rxe_cleanup_task (&qp->req.task); -if (qp_type (qp) ==IB_QPT_RC ) -rxe_cleanup_task (&qp->comp.task); +rxe_cleanup_task (&qp->comp.task);/* flush out any receive wr's or pending requests */ __rxe_do_task (&qp->req.task);
Greg Kroah-Hartman
maintainerPATCH 56/66 s5k4ecgx: select CRC32 helper
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit c739c0a7c3c2472d7562b8f802cdce44d2597c8b upstream.
A rare randconfig build failure shows up in this driver when the CRC32 helper is not there:
drivers/media/built-in.o: In function `s5k4ecgx_s_power':
s5k4ecgx.c:(.text+0x9eb4): undefined reference to `crc32_le'
This adds the 'select' that all other users of this function have.
--- drivers/media/i2c/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/Kconfig +1 -0
@@ -655,6 +655,7 @@ config VIDEO_S5K6A3 config VIDEO_S5K4ECGX tristate "Samsung S5K4ECGX sensor support" depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API + select CRC32 ---help--- This is a V4L2 sensor-level driver for Samsung S5K4ECGX 5M camera sensor with an embedded SoC image signal processor.
Greg Kroah-Hartman
maintainerPATCH 57/66 pinctrl: broxton: Use correct PADCFGLOCK offset
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mika Westerberg <[email protected]>
commit ecc8995363ee6231b32dad61c955b371b79cc4cf upstream.
PADCFGLOCK (and PADCFGLOCK_TX) offset in Broxton actually starts at 0x060 and not 0x090 as used in the driver. Fix it to use the correct offset.
--- drivers/pinctrl/intel/pinctrl-broxton.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/intel/pinctrl-broxton.c +1 -1
@@ -19,7 +19,7 @@#define BXT_PAD_OWN 0x020#define BXT_HOSTSW_OWN 0x080 -#define BXT_PADCFGLOCK 0x090 +#define BXT_PADCFGLOCK 0x060#define BXT_GPI_IE 0x110#define BXT_COMMUNITY (s, e) \
Greg Kroah-Hartman
maintainerPATCH 58/66 pinctrl: uniphier: fix Ethernet (RMII) pin-mux setting for LD20
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
commit df1539c25cce98e2ac69881958850c6535240707 upstream.
Fix the pin-mux values for the MDC, MDIO, MDIO_INTL, PHYRSTL pins.
--- drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/uniphier/pinctrl-uniphier-ld20.c +1 -1
@@ -561,7 +561,7 @@ static const int ether_rgmii_muxvals[] = 0, 0, 0, 0};static const unsigned ether_rmii_pins[] = {30 ,31 ,32 ,33 ,34 ,35 ,36 ,37 ,39 ,41 ,42 ,45 }; -static const int ether_rmii_muxvals[] = {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 }; +static const int ether_rmii_muxvals[] = {0 ,0 ,0 ,0 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 };static const unsigned i2c0_pins[] = {63 ,64 };static const int i2c0_muxvals[] = {0 ,0 };static const unsigned i2c1_pins[] = {65 ,66 };
Greg Kroah-Hartman
maintainerPATCH 59/66 pinctrl: baytrail: Rectify debounce support
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
commit 04ff5a095d662e0879f0eb04b9247e092210aeff upstream.
The commit 658b476c742f ("pinctrl: baytrail: Add debounce configuration") implements debounce for Baytrail pin control, but seems wasn't tested properly.
The register which keeps debounce value is separated from the configuration one. Writing wrong values to the latter will guarantee wrong behaviour of the driver and even might break something physically.
Besides above there is missed case how to disable it, which is actually done through the bit in configuration register.
Rectify implementation here by using proper register for debounce value.
--- drivers/pinctrl/intel/pinctrl-baytrail.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-)
drivers/pinctrl/intel/pinctrl-baytrail.c +17 -11
@@ -1092,6 +1092,7 @@ static int byt_pin_config_get(struct pinenum pin_config_param param =pinconf_to_config_param (*config);void __iomem *conf_reg =byt_gpio_reg (vg, offset,BYT_CONF0_REG );void __iomem *val_reg =byt_gpio_reg (vg, offset,BYT_VAL_REG ); +void __iomem *db_reg =byt_gpio_reg (vg, offset,BYT_DEBOUNCE_REG );unsigned long flags;u32 conf, pull, val, debounce;u16 arg =0 ;
@@ -1128,7 +1129,7 @@ static int byt_pin_config_get(struct pinreturn -EINVAL ;raw_spin_lock_irqsave (&vg->lock, flags); - debounce =readl (byt_gpio_reg (vg, offset,BYT_DEBOUNCE_REG )); + debounce =readl (db_reg);raw_spin_unlock_irqrestore (&vg->lock, flags);switch (debounce &BYT_DEBOUNCE_PULSE_MASK ) {
@@ -1176,6 +1177,7 @@ static int byt_pin_config_set(struct pinunsigned int param, arg;void __iomem *conf_reg =byt_gpio_reg (vg, offset,BYT_CONF0_REG );void __iomem *val_reg =byt_gpio_reg (vg, offset,BYT_VAL_REG ); +void __iomem *db_reg =byt_gpio_reg (vg, offset,BYT_DEBOUNCE_REG );unsigned long flags;u32 conf, val, debounce;int i, ret =0 ;
@@ -1238,36 +1240,40 @@ static int byt_pin_config_set(struct pinbreak ;case PIN_CONFIG_INPUT_DEBOUNCE : - debounce =readl (byt_gpio_reg (vg, offset, -BYT_DEBOUNCE_REG )); - conf &= ~BYT_DEBOUNCE_PULSE_MASK ; + debounce =readl (db_reg); + debounce &= ~BYT_DEBOUNCE_PULSE_MASK ;switch (arg) { +case 0 : + conf &=BYT_DEBOUNCE_EN ; +break ;case 375 : - conf |=BYT_DEBOUNCE_PULSE_375US ; + debounce |=BYT_DEBOUNCE_PULSE_375US ;break ;case 750 : - conf |=BYT_DEBOUNCE_PULSE_750US ; + debounce |=BYT_DEBOUNCE_PULSE_750US ;break ;case 1500 : - conf |=BYT_DEBOUNCE_PULSE_1500US ; + debounce |=BYT_DEBOUNCE_PULSE_1500US ;break ;case 3000 : - conf |=BYT_DEBOUNCE_PULSE_3MS ; + debounce |=BYT_DEBOUNCE_PULSE_3MS ;break ;case 6000 : - conf |=BYT_DEBOUNCE_PULSE_6MS ; + debounce |=BYT_DEBOUNCE_PULSE_6MS ;break ;case 12000 : - conf |=BYT_DEBOUNCE_PULSE_12MS ; + debounce |=BYT_DEBOUNCE_PULSE_12MS ;break ;case 24000 : - conf |=BYT_DEBOUNCE_PULSE_24MS ; + debounce |=BYT_DEBOUNCE_PULSE_24MS ;break ;default : ret = -EINVAL ; } +if (!ret) +writel (debounce, db_reg);break ;default : ret = -ENOTSUPP ;
Greg Kroah-Hartman
maintainerPATCH 60/66 memory_hotplug: make zone_can_shift() return a boolean value
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yasuaki Ishimatsu <[email protected]>
commit 8a1f780e7f28c7c1d640118242cf68d528c456cd upstream.
online_{kernel|movable} is used to change the memory zone to ZONE_{NORMAL|MOVABLE} and online the memory.
To check that memory zone can be changed, zone_can_shift() is used. Currently the function returns minus integer value, plus integer value and 0. When the function returns minus or plus integer value, it means that the memory zone can be changed to ZONE_{NORNAL|MOVABLE}.
But when the function returns 0, there are two meanings.
One of the meanings is that the memory zone does not need to be changed. For example, when memory is in ZONE_NORMAL and onlined by online_kernel the memory zone does not need to be changed.
Another meaning is that the memory zone cannot be changed. When memory is in ZONE_NORMAL and onlined by online_movable, the memory zone may not be changed to ZONE_MOVALBE due to memory online limitation(see Documentation/memory-hotplug.txt). In this case, memory must not be onlined.
The patch changes the return type of zone_can_shift() so that memory online operation fails when memory zone cannot be changed as follows:
Before applying patch:
# grep -A 35 "Node 2" /proc/zoneinfo
Node 2, zone Normal
<snip>
node_scanned 0
spanned 8388608
present 7864320
managed 7864320
# echo online_movable > memory4097/state
# grep -A 35 "Node 2" /proc/zoneinfo
Node 2, zone Normal
<snip>
node_scanned 0
spanned 8388608
present 8388608
managed 8388608 online_movable operation succeeded. But memory is onlined as ZONE_NORMAL, not ZONE_MOVABLE.
After applying patch:
# grep -A 35 "Node 2" /proc/zoneinfo
Node 2, zone Normal
<snip>
node_scanned 0
spanned 8388608
present 7864320
managed 7864320
# echo online_movable > memory4097/state
bash: echo: write error: Invalid argument
# grep -A 35 "Node 2" /proc/zoneinfo
Node 2, zone Normal
<snip>
node_scanned 0
spanned 8388608
present 7864320
managed 7864320 online_movable operation failed because of failure of changing the memory zone from ZONE_NORMAL to ZONE_MOVABLE
--- drivers/base/memory.c | 4 ++-- include/linux/memory_hotplug.h | 4 ++-- mm/memory_hotplug.c | 28 +++++++++++++++++----------- 3 files changed, 21 insertions(+), 15 deletions(-)
drivers/base/memory.c +2 -2
@@ -410,14 +410,14 @@ static ssize_t show_valid_zones(struct dsprintf (buf,"%s" , zone->name);/* MMOP_ONLINE_KERNEL */ - zone_shift =zone_can_shift (start_pfn, nr_pages,ZONE_NORMAL ); +zone_can_shift (start_pfn, nr_pages,ZONE_NORMAL , &zone_shift);if (zone_shift) {strcat (buf," " );strcat (buf, (zone + zone_shift)->name); }/* MMOP_ONLINE_MOVABLE */ - zone_shift =zone_can_shift (start_pfn, nr_pages,ZONE_MOVABLE ); +zone_can_shift (start_pfn, nr_pages,ZONE_MOVABLE , &zone_shift);if (zone_shift) {strcat (buf," " );strcat (buf, (zone + zone_shift)->name);
include/linux/memory_hotplug.h +2 -2
@@ -284,7 +284,7 @@ extern void sparse_remove_one_section(st unsigned long map_offset);extern struct page *sparse_decode_mem_map (unsigned long coded_mem_map,unsigned long pnum); -extern int zone_can_shift (unsigned long pfn,unsigned long nr_pages, -enum zone_type target); +extern bool zone_can_shift (unsigned long pfn,unsigned long nr_pages, +enum zone_type target,int *zone_shift);#endif /* __LINUX_MEMORY_HOTPLUG_H */
mm/memory_hotplug.c +17 -11
@@ -1033,36 +1033,39 @@ static void node_states_set_node(int nodnode_set_state (node,N_MEMORY ); } -int zone_can_shift (unsigned long pfn,unsigned long nr_pages, -enum zone_type target) +bool zone_can_shift (unsigned long pfn,unsigned long nr_pages, +enum zone_type target,int *zone_shift) {struct zone *zone =page_zone (pfn_to_page (pfn));enum zone_type idx =zone_idx (zone);int i; + *zone_shift =0 ; +if (idx < target) {/* pages must be at end of current zone */ if (pfn + nr_pages !=zone_end_pfn (zone)) -return 0 ; +return false;/* no zones in use between current zone and target */ for (i = idx +1 ; i < target; i++)if (zone_is_initialized (zone - idx + i)) -return 0 ; +return false; }if (target < idx) {/* pages must be at beginning of current zone */ if (pfn != zone->zone_start_pfn) -return 0 ; +return false;/* no zones in use between current zone and target */ for (i = target +1 ; i < idx; i++)if (zone_is_initialized (zone - idx + i)) -return 0 ; +return false; } -return target - idx; + *zone_shift = target - idx; +return true; }/* Must be protected by mem_hotplug_begin() */
@@ -1089,10 +1092,13 @@ int __ref online_pages(unsigned long pfn !can_online_high_movable(zone))return -EINVAL ; -if (online_type ==MMOP_ONLINE_KERNEL ) - zone_shift =zone_can_shift (pfn, nr_pages,ZONE_NORMAL ); -else if (online_type ==MMOP_ONLINE_MOVABLE ) - zone_shift =zone_can_shift (pfn, nr_pages,ZONE_MOVABLE ); +if (online_type ==MMOP_ONLINE_KERNEL ) { +if (!zone_can_shift (pfn, nr_pages,ZONE_NORMAL , &zone_shift)) +return -EINVAL ; + }else if (online_type ==MMOP_ONLINE_MOVABLE ) { +if (!zone_can_shift (pfn, nr_pages,ZONE_MOVABLE , &zone_shift)) +return -EINVAL ; + } zone =move_pfn_range (zone_shift, pfn, pfn + nr_pages);if (!zone)
Greg Kroah-Hartman
maintainerPATCH 61/66 virtio_mmio: Set DMA masks appropriately
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robin Murphy <[email protected]>
commit f7f6634d23830ff74335734fbdb28ea109c1f349 upstream.
Once DMA API usage is enabled, it becomes apparent that virtio-mmio is inadvertently relying on the default 32-bit DMA mask, which leads to problems like rapidly exhausting SWIOTLB bounce buffers.
Ensure that we set the appropriate 64-bit DMA mask whenever possible, with the coherent mask suitably limited for the legacy vring as per a0be1db4304f ("virtio_pci: Limit DMA mask to 44 bits for legacy virtio devices").
--- drivers/virtio/virtio_mmio.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/virtio/virtio_mmio.c +19 -1
@@ -59,6 +59,7 @@#define pr_fmt (fmt) "virtio-mmio: " fmt#include <linux/acpi.h> +#include <linux/dma-mapping.h> #include <linux/highmem.h> #include <linux/interrupt.h> #include <linux/io.h>
@@ -497,6 +498,7 @@ static int virtio_mmio_probe(struct platstruct virtio_mmio_device *vm_dev;struct resource *mem;unsigned long magic; +int rc; mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!mem)
@@ -545,9 +547,25 @@ static int virtio_mmio_probe(struct plat } vm_dev->vdev.id.vendor =readl (vm_dev->base +VIRTIO_MMIO_VENDOR_ID ); -if (vm_dev->version ==1 ) +if (vm_dev->version ==1 ) {writel (PAGE_SIZE , vm_dev->base +VIRTIO_MMIO_GUEST_PAGE_SIZE ); + rc =dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 )); +/* +* In the legacy case, ensure our coherently-allocated virtio +* ring will be at an address expressable as a 32-bit PFN. +*/ +if (!rc) +dma_set_coherent_mask (&pdev->dev, +DMA_BIT_MASK (32 +PAGE_SHIFT )); + }else { + rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 )); + } +if (rc) + rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 )); +if (rc) +dev_warn (&pdev->dev,"Failed to enable 64-bit or 32-bit DMA. Trying to continue, but this might not work.\n" ); +platform_set_drvdata (pdev, vm_dev);return register_virtio_device (&vm_dev->vdev);
Greg Kroah-Hartman
maintainerPATCH 62/66 platform/x86: mlx-platform: free first dev on error
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 63d762b88cb5510f2bfdb5112ced18cde867ae61 upstream.
There is an off-by-one error so we don't unregister priv->pdev_mux[0]. Also it's slightly simpler as a while loop instead of a for loop.
--- arch/x86/platform/mellanox/mlx-platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/platform/mellanox/mlx-platform.c +1 -1
@@ -233,7 +233,7 @@ static int __init mlxplat_init(void)return 0 ; fail_platform_mux_register: -for (i--; i >0 ; i--) +while (--i >=0 )platform_device_unregister (priv->pdev_mux[i]);platform_device_unregister (priv->pdev_i2c); fail_alloc:
Greg Kroah-Hartman
maintainerPATCH 63/66 platform/x86: intel_mid_powerbtn: Set IRQ_ONESHOT
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
commit 5a00b6c2438460b870a451f14593fc40d3c7edf6 upstream.
The commit 1c6c69525b40 ("genirq: Reject bogus threaded irq requests") starts refusing misconfigured interrupt handlers. This makes intel_mid_powerbtn not working anymore.
Add a mandatory flag to a threaded IRQ request in the driver.
--- drivers/platform/x86/intel_mid_powerbtn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel_mid_powerbtn.c +1 -1
@@ -77,7 +77,7 @@ static int mfld_pb_probe(struct platforminput_set_capability (input,EV_KEY ,KEY_POWER ); - error =request_threaded_irq (irq,NULL , mfld_pb_isr,0 , + error =request_threaded_irq (irq,NULL , mfld_pb_isr,IRQF_ONESHOT ,DRIVER_NAME , input);if (error) { dev_err(&pdev->dev, "Unable to request irq %d for mfld power"
Greg Kroah-Hartman
maintainerPATCH 64/66 mm, memcg: do not retry precharge charges
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Rientjes <[email protected]>
commit 3674534b775354516e5c148ea48f51d4d1909a78 upstream.
When memory.move_charge_at_immigrate is enabled and precharges are depleted during move, mem_cgroup_move_charge_pte_range() will attempt to increase the size of the precharge.
Prevent precharges from ever looping by setting __GFP_NORETRY. This was probably the intention of the GFP_KERNEL & ~__GFP_NORETRY, which is pointless as written.
--- mm/memcontrol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memcontrol.c +2 -2
@@ -4360,9 +4360,9 @@ static int mem_cgroup_do_precharge(unsigreturn ret; } -/* Try charges one by one with reclaim */ +/* Try charges one by one with reclaim, but do not retry */ while (count--) { - ret =try_charge (mc.to,GFP_KERNEL & ~__GFP_NORETRY,1 ); + ret =try_charge (mc.to,GFP_KERNEL | __GFP_NORETRY,1 );if (ret)return ret; mc.precharge++;
Greg Kroah-Hartman
maintainerPATCH 65/66 perf/core: Fix concurrent sys_perf_event_open() vs. move_group race
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit 321027c1fe77f892f4ea07846aeae08cefbbb290 upstream.
Di Shen reported a race between two concurrent sys_perf_event_open() calls where both try and move the same pre-existing software group into a hardware context.
The problem is exactly that described in commit:
f63a8daa5812 ("perf: Fix event->ctx locking")
... where, while we wait for a ctx->mutex acquisition, the event->ctx relation can have changed under us.
That very same commit failed to recognise sys_perf_event_context() as an external access vector to the events and thereby didn't apply the established locking rules correctly.
So while one sys_perf_event_open() call is stuck waiting on mutex_lock_double(), the other (which owns said locks) moves the group about. So by the time the former sys_perf_event_open() acquires the locks, the context we've acquired is stale (and possibly dead).
Apply the established locking rules as per perf_event_ctx_lock_nested() to the mutex_lock_double() for the 'move_group' case. This obviously means we need to validate state after we acquire the locks.
--- kernel/events/core.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 4 deletions(-)
kernel/events/core.c +54 -4
@@ -9503,6 +9503,37 @@ static int perf_event_set_clock(struct preturn 0 ; } +/* +* Variation on perf_event_ctx_lock_nested(), except we take two context +* mutexes. +*/ +static struct perf_event_context * +__perf_event_ctx_lock_double (struct perf_event *group_leader, +struct perf_event_context *ctx) +{ +struct perf_event_context *gctx; + +again: +rcu_read_lock (); + gctx =READ_ONCE (group_leader->ctx); +if (!atomic_inc_not_zero (&gctx->refcount)) { +rcu_read_unlock (); + goto again; + } +rcu_read_unlock (); + +mutex_lock_double (&gctx->mutex, &ctx->mutex); + +if (group_leader->ctx != gctx) { +mutex_unlock (&ctx->mutex); +mutex_unlock (&gctx->mutex); +put_ctx (gctx); + goto again; + } + +return gctx; +} +/** * sys_perf_event_open - open a performance event, associate it to a task/cpu *
@@ -9746,12 +9777,31 @@ SYSCALL_DEFINE5(perf_event_open, }if (move_group) { - gctx = group_leader->ctx; -mutex_lock_double (&gctx->mutex, &ctx->mutex); + gctx =__perf_event_ctx_lock_double (group_leader, ctx); +if (gctx->task ==TASK_TOMBSTONE ) { err = -ESRCH ; goto err_locked; } + +/* +* Check if we raced against another sys_perf_event_open() call +* moving the software group underneath us. +*/ +if (!(group_leader->group_caps &PERF_EV_CAP_SOFTWARE )) { +/* +* If someone moved the group out from under us, check +* if this new event wound up on the same ctx, if so +* its the regular !move_group case, otherwise fail. +*/ +if (gctx != ctx) { + err = -EINVAL ; + goto err_locked; + }else { +perf_event_ctx_unlock (group_leader, gctx); + move_group =0 ; + } + } }else {mutex_lock (&ctx->mutex); }
@@ -9853,7 +9903,7 @@ SYSCALL_DEFINE5(perf_event_open,perf_unpin_context (ctx);if (move_group) -mutex_unlock (&gctx->mutex); +perf_event_ctx_unlock (group_leader, gctx);mutex_unlock (&ctx->mutex);if (task) {
@@ -9879,7 +9929,7 @@ SYSCALL_DEFINE5(perf_event_open, err_locked:if (move_group) -mutex_unlock (&gctx->mutex); +perf_event_ctx_unlock (group_leader, gctx);mutex_unlock (&ctx->mutex);/* err_file: */ fput (event_file);
Greg Kroah-Hartman
maintainerPATCH 66/66 drm/i915: Remove WaDisableLSQCROPERFforOCL KBL workaround.
In reply to Greg Kroah-Hartman4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Francisco Jerez <[email protected]>
commit 4fc020d864647ea3ae8cb8f17d63e48e87ebd0bf upstream.
The WaDisableLSQCROPERFforOCL workaround has the side effect of disabling an L3SQ optimization that has huge performance implications and is unlikely to be necessary for the correct functioning of usual graphic workloads. Userspace is free to re-enable the workaround on demand, and is generally in a better position to determine whether the workaround is necessary than the DRM is (e.g. only during the execution of compute kernels that rely on both L3 fences and HDC R/W requests).
The same workaround seems to apply to BDW (at least to production stepping G1) and SKL as well (the internal workaround database claims that it does for all steppings, while the BSpec workaround table only mentions pre-production steppings), but the DRM doesn't do anything beyond whitelisting the L3SQCREG4 register so userspace can enable it when it sees fit. Do the same on KBL platforms.
Improves performance of the GFXBench4 gl_manhattan31 benchmark by 60%, and gl_4 (AKA car chase) by 14% on a KBL GT2 running Mesa master -- This is followed by a regression of 35% and 10% respectively for the same benchmarks and platform caused by my recent patch series switching userspace to use the dataport constant cache instead of the sampler to implement uniform pull constant loads, which caused us to hit more heavily the L3 cache (and on platforms other than KBL had the opposite effect of improving performance of the same two benchmarks). The overall effect on KBL of this change combined with the recent userspace change is respectively 4.6% and 2.6%. SynMark2 OglShMapPcf was affected by the constant cache changes (though it improved as it did on other platforms rather than regressing), but is not significantly affected by this patch (with statistical significance of 5% and sample size 20).
v2: Drop some more code to avoid unused variable warning.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99256
--- drivers/gpu/drm/i915/intel_lrc.c | 3 +-- drivers/gpu/drm/i915/intel_ringbuffer.c | 8 -------- 2 files changed, 1 insertion(+), 10 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +1 -2
@@ -858,8 +858,7 @@ static inline int gen8_emit_flush_cohere* this batch updates GEN8_L3SQCREG4 with default value we need to * set this bit here to retain the WA during flush. */ -if (IS_SKL_REVID (dev_priv,0 ,SKL_REVID_E0 ) || -IS_KBL_REVID (dev_priv,0 ,KBL_REVID_E0 )) +if (IS_SKL_REVID (dev_priv,0 ,SKL_REVID_E0 )) l3sqc4_flush |=GEN8_LQSC_RO_PERF_DIS ; wa_ctx_emit(batch, index, (MI_STORE_REGISTER_MEM_GEN8 |
drivers/gpu/drm/i915/intel_ringbuffer.c +0 -8
@@ -1153,14 +1153,6 @@ static int kbl_init_workarounds(struct iWA_SET_BIT_MASKED (HDC_CHICKEN0 ,HDC_FENCE_DEST_SLM_DISABLE ); -/* GEN8_L3SQCREG4 has a dependency with WA batch so any new changes -* involving this register should also be added to WA batch as required. -*/ -if (IS_KBL_REVID (dev_priv,0 ,KBL_REVID_E0 )) -/* WaDisableLSQCROPERFforOCL:kbl */ -I915_WRITE (GEN8_L3SQCREG4 ,I915_READ (GEN8_L3SQCREG4 ) | -GEN8_LQSC_RO_PERF_DIS ); -/* WaToEnableHwFixForPushConstHWBug:kbl */ if (IS_KBL_REVID (dev_priv,KBL_REVID_C0 ,REVID_FOREVER )) WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2,
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.9.7 release. There are 66 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 Thu Feb 2 05:35:45 UTC 2017. Anything received after that time might be too late.
Build results:
total: 149 pass: 149 fail: 0 Qemu test results: total: 122 pass: 122 fail: 0
Details are available at http://kerneltests.org/builders.
Guenter
Greg Kroah-Hartman
maintainerQuoted 9 lines · Guenter Roeck
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.9.7 release. There are 66 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 Thu Feb 2 05:35:45 UTC 2017. Anything received after that time might be too late.
Quoted 6 lines
Build results:
total: 149 pass: 149 fail: 0 Qemu test results: total: 122 pass: 122 fail: 0Details are available at http://kerneltests.org/builders.
Great, thanks for testing both of these and letting me know.
greg k-h
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.9.7 release. There are 66 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 Thu Feb 2 05:35:45 UTC 2017. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.7-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.9.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Greg Kroah-Hartman
maintainerQuoted 15 lines · Shuah Khan
Quoted 14 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.9.7 release. There are 66 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 Thu Feb 2 05:35:45 UTC 2017. 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/v4.x/stable-review/patch-4.9.7-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.9.y
and the diffstat can be found below.
Quoted 6 lines
Quoted 4 lines
thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
Wonderful, thanks for testing and letting me know.
greg k-h